diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index dd85fbfd63..bd873638ca 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -2654,6 +2654,10 @@ Screenshot ``--screenshot-jpeg-quality=<0-100>`` Set the JPEG quality level. Higher means better quality. The default is 90. +``--screenshot-jpeg-source-chroma=`` + Write JPEG files with the same chroma subsampling as the video + (default: yes). If disabled, the libjpeg default is used. + ``--screenshot-png-compression=<0-9>`` Set the PNG compression level. Higher means better compression. This will affect the file size of the written screenshot file and the time it takes diff --git a/video/image_writer.c b/video/image_writer.c index bcb71f4863..935d4bd962 100644 --- a/video/image_writer.c +++ b/video/image_writer.c @@ -48,6 +48,7 @@ const struct image_writer_opts image_writer_opts_defaults = { .jpeg_optimize = 100, .jpeg_smooth = 0, .jpeg_baseline = 1, + .jpeg_source_chroma = 1, .tag_csp = 1, }; @@ -59,6 +60,7 @@ const struct m_sub_options image_writer_conf = { OPT_INTRANGE("jpeg-optimize", jpeg_optimize, 0, 0, 100), OPT_INTRANGE("jpeg-smooth", jpeg_smooth, 0, 0, 100), OPT_FLAG("jpeg-baseline", jpeg_baseline, 0), + OPT_FLAG("jpeg-source-chroma", jpeg_source_chroma, 0), OPT_INTRANGE("png-compression", png_compression, 0, 0, 9), OPT_INTRANGE("png-filter", png_filter, 0, 0, 5), OPT_STRING("format", format, 0), @@ -193,8 +195,10 @@ static bool write_jpeg(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp cinfo.optimize_coding = ctx->opts->jpeg_optimize; cinfo.smoothing_factor = ctx->opts->jpeg_smooth; - cinfo.comp_info[0].h_samp_factor = 1 << ctx->original_format.chroma_xs; - cinfo.comp_info[0].v_samp_factor = 1 << ctx->original_format.chroma_ys; + if (ctx->opts->jpeg_source_chroma) { + cinfo.comp_info[0].h_samp_factor = 1 << ctx->original_format.chroma_xs; + cinfo.comp_info[0].v_samp_factor = 1 << ctx->original_format.chroma_ys; + } jpeg_start_compress(&cinfo, TRUE); diff --git a/video/image_writer.h b/video/image_writer.h index b27db3981a..5e41d79abb 100644 --- a/video/image_writer.h +++ b/video/image_writer.h @@ -28,6 +28,7 @@ struct image_writer_opts { int jpeg_dpi; int jpeg_progressive; int jpeg_baseline; + int jpeg_source_chroma; int tag_csp; };