[FFmpeg-devel] [PATCH] ffmpeg: fix increment of sync_opts
Xiaolei Yu
dreifachstein at gmail.com
Thu Sep 8 12:51:10 EEST 2022
The encoder time base could been overridden by the command line argument
and may not always be 1/ost->frame_rate.
---
fftools/ffmpeg.c | 2 +-
tests/fate/ffmpeg.mak | 5 +++++
tests/ref/fate/enc_time_base-vfr | 25 +++++++++++++++++++++++++
3 files changed, 31 insertions(+), 1 deletion(-)
create mode 100644 tests/ref/fate/enc_time_base-vfr
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 0e1477299d..8bc48125c8 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1344,7 +1344,7 @@ static void do_video_out(OutputFile *of,
if (ret < 0 && ret != AVERROR_EOF)
exit_program(1);
- ost->sync_opts++;
+ ost->sync_opts += av_rescale_q(1, av_inv_q(ost->frame_rate), ost->enc_ctx->time_base);
ost->vsync_frame_number++;
}
diff --git a/tests/fate/ffmpeg.mak b/tests/fate/ffmpeg.mak
index 38a1ae7ed5..a3be79d65e 100644
--- a/tests/fate/ffmpeg.mak
+++ b/tests/fate/ffmpeg.mak
@@ -209,3 +209,8 @@ FATE_TIME_BASE-$(call PARSERDEMDEC, MPEGVIDEO, MPEGPS, MPEG2VIDEO, MPEGVIDEO_DEM
fate-time_base: CMD = md5 -i $(TARGET_SAMPLES)/mpeg2/dvd_single_frame.vob -an -sn -c:v copy -r 25 -time_base 1001:30000 -fflags +bitexact -f mxf
FATE_SAMPLES_FFMPEG-yes += $(FATE_TIME_BASE-yes)
+
+FATE_ENC_TIME_BASE-$(call ALLYES, LAVFI_INDEV COLOR_FILTER FRAMEMD5_MUXER) += fate-enc_time_base-vfr
+fate-enc_time_base-vfr: CMD = framemd5 -auto_conversion_filters -fflags +bitexact -flags +bitexact -f lavfi -i "color=r=30:d=1" -enc_time_base 1/600 -fps_mode vfr -r 15
+
+FATE_SAMPLES_FFMPEG-yes += $(FATE_ENC_TIME_BASE-yes)
diff --git a/tests/ref/fate/enc_time_base-vfr b/tests/ref/fate/enc_time_base-vfr
new file mode 100644
index 0000000000..cb38177d8e
--- /dev/null
+++ b/tests/ref/fate/enc_time_base-vfr
@@ -0,0 +1,25 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/600
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 320x240
+#sar 0: 1/1
+#stream#, dts, pts, duration, size, hash
+0, 0, 0, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
+0, 40, 40, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
+0, 80, 80, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
+0, 120, 120, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
+0, 160, 160, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
+0, 200, 200, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
+0, 240, 240, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
+0, 280, 280, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
+0, 320, 320, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
+0, 360, 360, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
+0, 400, 400, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
+0, 440, 440, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
+0, 480, 480, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
+0, 520, 520, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
+0, 560, 560, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
+0, 600, 600, 40, 115200, 8e4dd5c5c31a54672e30503f6ee13321
--
2.37.2
More information about the ffmpeg-devel
mailing list