diff options
author | rcombs <rcombs@rcombs.me> | 2023-01-28 14:15:22 -0600 |
---|---|---|
committer | rcombs <rcombs@rcombs.me> | 2023-01-29 22:14:27 -0600 |
commit | 4bcefa5be3b776c68b689b8009759390c2eb62de (patch) | |
tree | 9edd997851dee9ce3f15b58a50ec550a44d5c284 /video/out | |
parent | da81a6d5322f6fd1665d06f72dba2a809bfa240b (diff) | |
download | mpv-4bcefa5be3b776c68b689b8009759390c2eb62de.tar.bz2 mpv-4bcefa5be3b776c68b689b8009759390c2eb62de.tar.xz |
vo_lavc: set frame rate on encoder; fixes #11215
ffmpeg was internally defaulting to 24000fps, which resulted in encoders selecting inappropriate levels and making poor ratecontrol decisions.
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/vo_lavc.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/video/out/vo_lavc.c b/video/out/vo_lavc.c index 8e188b5aab..74f3c40882 100644 --- a/video/out/vo_lavc.c +++ b/video/out/vo_lavc.c @@ -134,6 +134,17 @@ static int reconfig2(struct vo *vo, struct mp_image *img) encoder->time_base = av_inv_q(tb); + // Used for rate control, level selection, etc. + // Usually it's not too catastrophic if this isn't exactly correct, + // as long as it's not off by orders of magnitude. + // If we don't set anything, encoders will use the time base, + // and 24000 is so high that the output can end up extremely screwy (see #11215), + // so we default to 240 if we don't have a real value. + if (img->nominal_fps > 0) + encoder->framerate = av_d2q(img->nominal_fps, img->nominal_fps * 1001 + 2); // Hopefully give exact results for NTSC rates + else + encoder->framerate = (AVRational){ 240, 1 }; + if (!encoder_init_codec_and_muxer(vc->enc, on_ready, vo)) goto error; |