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=`` 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; };