summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-12-10 09:45:50 +0100
committerAnton Khirnov <anton@khirnov.net>2022-12-10 10:20:42 +0100
commitb5626ccea72d2ef81844cd44e7320e76cbde717a (patch)
tree4751d88acdafe9a92035ff9b3e2774948315dc74
parentb00a4e3bfc1786276c956ce55fabbdc9a34732c1 (diff)
fftools/ffmpeg: always generate CFR output when -r is used
Current code may, depending on the muxer, decide to use VSYNC_VFR tagged with the specified framerate, without actually performing framerate conversion. This is clearly wrong and against the documentation, which states unambiguously that -r should produce CFR output for video encoding. FATE test changes: * nuv-rtjpeg: replace -r with '-enc_time_base -1', which keeps the original timebase. Output frames are now produced with proper durations. * filter-mpdecimate: just drop the -r option, it is unnecessary * filter-fps-r: remove, this test makes no sense and actually produces broken VFR output (with incorrect frame durations).
-rw-r--r--fftools/ffmpeg_mux_init.c16
-rw-r--r--tests/fate/filter-video.mak5
-rw-r--r--tests/fate/video.mak3
-rw-r--r--tests/ref/fate/filter-fps-r78
-rw-r--r--tests/ref/fate/nuv-rtjpeg16
5 files changed, 22 insertions, 96 deletions
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 0280759b05..9eea8639dc 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -443,10 +443,6 @@ static OutputStream *new_video_stream(Muxer *mux, const OptionsContext *o, Input
exit_program(1);
}
- if ((frame_rate || max_frame_rate) &&
- video_sync_method == VSYNC_PASSTHROUGH)
- av_log(NULL, AV_LOG_ERROR, "Using -vsync passthrough and -r/-fpsmax can produce invalid output files\n");
-
MATCH_PER_STREAM_OPT(frame_aspect_ratios, str, frame_aspect_ratio, oc, st);
if (frame_aspect_ratio) {
AVRational q;
@@ -614,8 +610,18 @@ static OutputStream *new_video_stream(Muxer *mux, const OptionsContext *o, Input
if (fps_mode)
parse_and_set_vsync(fps_mode, &ost->vsync_method, ost->file_index, ost->index, 0);
+ if ((ost->frame_rate.num || ost->max_frame_rate.num) &&
+ !(ost->vsync_method == VSYNC_AUTO ||
+ ost->vsync_method == VSYNC_CFR || ost->vsync_method == VSYNC_VSCFR)) {
+ av_log(NULL, AV_LOG_FATAL, "One of -r/-fpsmax was specified "
+ "together a non-CFR -vsync/-fps_mode. This is contradictory.\n");
+ exit_program(1);
+ }
+
if (ost->vsync_method == VSYNC_AUTO) {
- if (!strcmp(oc->oformat->name, "avi")) {
+ if (ost->frame_rate.num || ost->max_frame_rate.num) {
+ ost->vsync_method = VSYNC_CFR;
+ } else if (!strcmp(oc->oformat->name, "avi")) {
ost->vsync_method = VSYNC_VFR;
} else {
ost->vsync_method = (oc->oformat->flags & AVFMT_VARIABLE_FPS) ?
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index f3c27ed1c8..63873a7a07 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -365,7 +365,7 @@ FATE_FILTER-$(call FILTERFRAMECRC, TESTSRC2 FPS DECIMATE) += fate-filter-decimat
fate-filter-decimate: CMD = framecrc -lavfi testsrc2=r=24:d=10,fps=60,decimate=5,decimate=4,decimate=3 -pix_fmt yuv420p
FATE_FILTER-$(call FILTERFRAMECRC, TESTSRC2 FPS MPDECIMATE) += fate-filter-mpdecimate
-fate-filter-mpdecimate: CMD = framecrc -lavfi testsrc2=r=2:d=10,fps=3,mpdecimate -r 3 -pix_fmt yuv420p
+fate-filter-mpdecimate: CMD = framecrc -lavfi testsrc2=r=2:d=10,fps=3,mpdecimate -pix_fmt yuv420p
FATE_FILTER-$(call FILTERFRAMECRC, FPS TESTSRC2) += $(addprefix fate-filter-fps-, up up-round-down up-round-up down down-round-down down-round-up down-eof-pass start-drop start-fill)
fate-filter-fps-up: CMD = framecrc -lavfi testsrc2=r=3:d=2,fps=7
@@ -378,9 +378,8 @@ fate-filter-fps-down-eof-pass: CMD = framecrc -lavfi testsrc2=r=7:d=3.5,fps=3:eo
fate-filter-fps-start-drop: CMD = framecrc -lavfi testsrc2=r=7:d=3.5,fps=3:start_time=1.5
fate-filter-fps-start-fill: CMD = framecrc -lavfi testsrc2=r=7:d=1.5,setpts=PTS+14,fps=3:start_time=1.5
-FATE_FILTER_SAMPLES-$(call FILTERDEMDEC, FPS SCALE, MOV, QTRLE) += fate-filter-fps-cfr fate-filter-fps fate-filter-fps-r
+FATE_FILTER_SAMPLES-$(call FILTERDEMDEC, FPS SCALE, MOV, QTRLE) += fate-filter-fps-cfr fate-filter-fps
fate-filter-fps-cfr: CMD = framecrc -auto_conversion_filters -i $(TARGET_SAMPLES)/qtrle/apple-animation-variable-fps-bug.mov -r 30 -vsync cfr -pix_fmt yuv420p
-fate-filter-fps-r: CMD = framecrc -auto_conversion_filters -i $(TARGET_SAMPLES)/qtrle/apple-animation-variable-fps-bug.mov -r 30 -vf fps -pix_fmt yuv420p
fate-filter-fps: CMD = framecrc -auto_conversion_filters -i $(TARGET_SAMPLES)/qtrle/apple-animation-variable-fps-bug.mov -vf fps=30 -pix_fmt yuv420p
FATE_FILTER_ALPHAEXTRACT_ALPHAMERGE := $(addprefix fate-filter-alphaextract_alphamerge_, rgb yuv)
diff --git a/tests/fate/video.mak b/tests/fate/video.mak
index af7e77e814..d7639a3978 100644
--- a/tests/fate/video.mak
+++ b/tests/fate/video.mak
@@ -269,9 +269,8 @@ fate-mv-sgirle: CMD = framecrc -i $(TARGET_SAMPLES)/mv/pet-rle.movie -an
FATE_VIDEO-$(call FRAMECRC, MXG, MXPEG) += fate-mxpeg
fate-mxpeg: CMD = framecrc -idct simple -flags +bitexact -i $(TARGET_SAMPLES)/mxpeg/m1.mxg -an
-# FIXME dropped frames in this test because of coarse timebase
FATE_NUV += fate-nuv-rtjpeg
-fate-nuv-rtjpeg: CMD = framecrc -idct simple -i $(TARGET_SAMPLES)/nuv/Today.nuv -an -r 1000
+fate-nuv-rtjpeg: CMD = framecrc -idct simple -i $(TARGET_SAMPLES)/nuv/Today.nuv -an -enc_time_base -1
FATE_NUV += fate-nuv-rtjpeg-fh
fate-nuv-rtjpeg-fh: CMD = framecrc -idct simple -i $(TARGET_SAMPLES)/nuv/rtjpeg_frameheader.nuv -an
diff --git a/tests/ref/fate/filter-fps-r b/tests/ref/fate/filter-fps-r
deleted file mode 100644
index c1bc7d1547..0000000000
--- a/tests/ref/fate/filter-fps-r
+++ /dev/null
@@ -1,78 +0,0 @@
-#tb 0: 1/30
-#media_type 0: video
-#codec_id 0: rawvideo
-#dimensions 0: 112x182
-#sar 0: 0/1
-0, 0, 0, 1, 30576, 0xcdc29b3d
-0, 1, 1, 1, 30576, 0xcdc29b3d
-0, 2, 2, 1, 30576, 0xcdc29b3d
-0, 4, 4, 1, 30576, 0xcdc29b3d
-0, 5, 5, 1, 30576, 0xcdc29b3d
-0, 6, 6, 1, 30576, 0x5c83656c
-0, 7, 7, 1, 30576, 0x5c83656c
-0, 8, 8, 1, 30576, 0x5c83656c
-0, 10, 10, 1, 30576, 0x5c83656c
-0, 11, 11, 1, 30576, 0x5c83656c
-0, 12, 12, 1, 30576, 0x5c83656c
-0, 13, 13, 1, 30576, 0x26b67f83
-0, 14, 14, 1, 30576, 0x26b67f83
-0, 16, 16, 1, 30576, 0x26b67f83
-0, 17, 17, 1, 30576, 0x26b67f83
-0, 18, 18, 1, 30576, 0x26b67f83
-0, 19, 19, 1, 30576, 0x26b67f83
-0, 20, 20, 1, 30576, 0x26b67f83
-0, 22, 22, 1, 30576, 0x26b67f83
-0, 23, 23, 1, 30576, 0x26b67f83
-0, 24, 24, 1, 30576, 0x26b67f83
-0, 25, 25, 1, 30576, 0x26b67f83
-0, 26, 26, 1, 30576, 0x26b67f83
-0, 28, 28, 1, 30576, 0x26b67f83
-0, 29, 29, 1, 30576, 0x26b67f83
-0, 30, 30, 1, 30576, 0x26b67f83
-0, 31, 31, 1, 30576, 0x26b67f83
-0, 32, 32, 1, 30576, 0x26b67f83
-0, 34, 34, 1, 30576, 0x26b67f83
-0, 35, 35, 1, 30576, 0x26b67f83
-0, 36, 36, 1, 30576, 0x26b67f83
-0, 37, 37, 1, 30576, 0x26b67f83
-0, 38, 38, 1, 30576, 0x26b67f83
-0, 40, 40, 1, 30576, 0x26b67f83
-0, 41, 41, 1, 30576, 0x26b67f83
-0, 42, 42, 1, 30576, 0x26b67f83
-0, 43, 43, 1, 30576, 0x26b67f83
-0, 44, 44, 1, 30576, 0x26b67f83
-0, 46, 46, 1, 30576, 0x26b67f83
-0, 47, 47, 1, 30576, 0x26b67f83
-0, 48, 48, 1, 30576, 0x26b67f83
-0, 49, 49, 1, 30576, 0x26b67f83
-0, 50, 50, 1, 30576, 0x26b67f83
-0, 52, 52, 1, 30576, 0x26b67f83
-0, 53, 53, 1, 30576, 0x26b67f83
-0, 54, 54, 1, 30576, 0x26b67f83
-0, 55, 55, 1, 30576, 0x26b67f83
-0, 56, 56, 1, 30576, 0x26b67f83
-0, 58, 58, 1, 30576, 0x26b67f83
-0, 59, 59, 1, 30576, 0x26b67f83
-0, 60, 60, 1, 30576, 0x26b67f83
-0, 61, 61, 1, 30576, 0x26b67f83
-0, 62, 62, 1, 30576, 0x26b67f83
-0, 64, 64, 1, 30576, 0x26b67f83
-0, 65, 65, 1, 30576, 0x26b67f83
-0, 66, 66, 1, 30576, 0x26b67f83
-0, 67, 67, 1, 30576, 0x26b67f83
-0, 68, 68, 1, 30576, 0x26b67f83
-0, 70, 70, 1, 30576, 0x26b67f83
-0, 71, 71, 1, 30576, 0x26b67f83
-0, 72, 72, 1, 30576, 0x26b67f83
-0, 73, 73, 1, 30576, 0xa2fcd06f
-0, 74, 74, 1, 30576, 0xa2fcd06f
-0, 76, 76, 1, 30576, 0xa2fcd06f
-0, 77, 77, 1, 30576, 0xa2fcd06f
-0, 78, 78, 1, 30576, 0xa2fcd06f
-0, 79, 79, 1, 30576, 0xa2fcd06f
-0, 80, 80, 1, 30576, 0xa2fcd06f
-0, 82, 82, 1, 30576, 0xd4150aad
-0, 83, 83, 1, 30576, 0xd4150aad
-0, 84, 84, 1, 30576, 0xd4150aad
-0, 85, 85, 1, 30576, 0xd4150aad
-0, 86, 86, 1, 30576, 0xd4150aad
diff --git a/tests/ref/fate/nuv-rtjpeg b/tests/ref/fate/nuv-rtjpeg
index bc5af1ca22..d6093e78d8 100644
--- a/tests/ref/fate/nuv-rtjpeg
+++ b/tests/ref/fate/nuv-rtjpeg
@@ -3,11 +3,11 @@
#codec_id 0: rawvideo
#dimensions 0: 640x480
#sar 0: 1/1
-0, 118, 118, 1, 460800, 0x54aedafe
-0, 152, 152, 1, 460800, 0xb7aa8b56
-0, 177, 177, 1, 460800, 0x283ea3b5
-0, 202, 202, 1, 460800, 0x283ea3b5
-0, 235, 235, 1, 460800, 0x10e577de
-0, 269, 269, 1, 460800, 0x4e091ee2
-0, 302, 302, 1, 460800, 0x2ea88828
-0, 335, 335, 1, 460800, 0x4b7f4df0
+0, 118, 118, 33, 460800, 0x54aedafe
+0, 152, 152, 33, 460800, 0xb7aa8b56
+0, 177, 177, 33, 460800, 0x283ea3b5
+0, 202, 202, 33, 460800, 0x283ea3b5
+0, 235, 235, 33, 460800, 0x10e577de
+0, 269, 269, 33, 460800, 0x4e091ee2
+0, 302, 302, 33, 460800, 0x2ea88828
+0, 335, 335, 33, 460800, 0x4b7f4df0