diff options
author | sfan5 <sfan5@live.de> | 2023-06-29 12:27:30 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2023-06-29 12:42:15 +0200 |
commit | 76589a5b34ba9769372cd8f233890ab892fd27ad (patch) | |
tree | 00d3df5c0307888660185306e0e1d92fdd39e44c | |
parent | eac6a82e017844718c7fe1f46e62301c24a5b0f9 (diff) | |
download | mpv-76589a5b34ba9769372cd8f233890ab892fd27ad.tar.bz2 mpv-76589a5b34ba9769372cd8f233890ab892fd27ad.tar.xz |
image_writer: respect jpeg-quality when using ffmpeg for writing
-rw-r--r-- | video/image_writer.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/video/image_writer.c b/video/image_writer.c index 11f0f6fdb5..f6636849c3 100644 --- a/video/image_writer.c +++ b/video/image_writer.c @@ -137,7 +137,11 @@ static bool write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp mp_imgfmt_to_name(image->imgfmt)); goto error_exit; } - if (codec->id == AV_CODEC_ID_PNG) { + + if (codec->id == AV_CODEC_ID_MJPEG) { + avctx->flags |= AV_CODEC_FLAG_QSCALE; + // jpeg_quality is set below + } else if (codec->id == AV_CODEC_ID_PNG) { avctx->compression_level = ctx->opts->png_compression; av_opt_set_int(avctx, "pred", ctx->opts->png_filter, AV_OPT_SEARCH_CHILDREN); @@ -173,6 +177,10 @@ static bool write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp pic->width = avctx->width; pic->height = avctx->height; pic->color_range = avctx->color_range; + if (codec->id == AV_CODEC_ID_MJPEG) { + int qscale = 1 + (100 - ctx->opts->jpeg_quality) * 30 / 100; + pic->quality = qscale * FF_QP2LAMBDA; + } if (ctx->opts->tag_csp) { avctx->color_primaries = pic->color_primaries = mp_csp_prim_to_avcol_pri(image->params.color.primaries); |