summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2019-08-02 16:04:54 +0200
committersfan5 <sfan5@live.de>2019-09-14 23:02:39 +0200
commitee0f4444f9b7e22e6b2b3895bf340f585b0cce70 (patch)
tree2e5a4d7dc9fca5cdf0f9fecde40d7ccd095cd659
parent0f79444c6dfe48a4d3a6b5075e504decca8c967a (diff)
downloadmpv-ee0f4444f9b7e22e6b2b3895bf340f585b0cce70.tar.bz2
mpv-ee0f4444f9b7e22e6b2b3895bf340f585b0cce70.tar.xz
image_writer: add webp-compression option
-rw-r--r--DOCS/man/options.rst4
-rw-r--r--DOCS/man/vo.rst2
-rw-r--r--video/image_writer.c3
-rw-r--r--video/image_writer.h1
4 files changed, 10 insertions, 0 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 15b960f4c2..80a02c9d03 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -3460,6 +3460,10 @@ Screenshot
``--screenshot-webp-quality=<0-100>``
Set the WebP quality level. Higher means better quality. The default is 75.
+``--screenshot-webp-compression=<0-6>``
+ Set the WebP compression level. Higher means better compression, but takes
+ more CPU time. Note that this also affects the screenshot quality when used
+ with lossy WebP files. The default is 4.
Software Scaler
---------------
diff --git a/DOCS/man/vo.rst b/DOCS/man/vo.rst
index 7ffcf47443..ecdea1b94f 100644
--- a/DOCS/man/vo.rst
+++ b/DOCS/man/vo.rst
@@ -431,6 +431,8 @@ Available video output drivers are:
Enable writing lossless WebP files (default: no)
``--vo-image-webp-quality=<0-100>``
WebP quality (default: 75)
+ ``--vo-image-webp-compression=<0-6>``
+ WebP compression factor (default: 4)
``--vo-image-outdir=<dirname>``
Specify the directory to save the image files to (default: ``./``).
diff --git a/video/image_writer.c b/video/image_writer.c
index 29cdac10c1..e66543a772 100644
--- a/video/image_writer.c
+++ b/video/image_writer.c
@@ -50,6 +50,7 @@ const struct image_writer_opts image_writer_opts_defaults = {
.jpeg_source_chroma = 1,
.webp_lossless = 0,
.webp_quality = 75,
+ .webp_compression = 4,
.tag_csp = 0,
};
@@ -71,6 +72,7 @@ const struct m_option image_writer_opts[] = {
OPT_INTRANGE("png-filter", png_filter, 0, 0, 5),
OPT_FLAG("webp-lossless", webp_lossless, 0),
OPT_INTRANGE("webp-quality", webp_quality, 0, 0, 100),
+ OPT_INTRANGE("webp-compression", webp_compression, 0, 0, 6),
OPT_FLAG("high-bit-depth", high_bit_depth, 0),
OPT_FLAG("tag-colorspace", tag_csp, 0),
{0},
@@ -135,6 +137,7 @@ static bool write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp
av_opt_set_int(avctx, "pred", ctx->opts->png_filter,
AV_OPT_SEARCH_CHILDREN);
} else if (codec->id == AV_CODEC_ID_WEBP) {
+ avctx->compression_level = ctx->opts->webp_compression;
av_opt_set_int(avctx, "lossless", ctx->opts->webp_lossless,
AV_OPT_SEARCH_CHILDREN);
av_opt_set_int(avctx, "quality", ctx->opts->webp_quality,
diff --git a/video/image_writer.h b/video/image_writer.h
index e9564e06de..d178d7398b 100644
--- a/video/image_writer.h
+++ b/video/image_writer.h
@@ -34,6 +34,7 @@ struct image_writer_opts {
int jpeg_source_chroma;
int webp_lossless;
int webp_quality;
+ int webp_compression;
int tag_csp;
};