summaryrefslogtreecommitdiff
path: root/fftools/ffmpeg_mux_init.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-12-10 09:45:50 +0100
committerAnton Khirnov <anton@khirnov.net>2023-01-10 11:49:28 +0100
commit260f3918937463f1b90e1b77cba80b917f3cb8c1 (patch)
tree27667ff7aa2c447d4dd5e3609196b50f4abe2e5d /fftools/ffmpeg_mux_init.c
parente884360e913a08c085ae29ffc1461a2bb205d550 (diff)
downloadffmpeg-260f3918937463f1b90e1b77cba80b917f3cb8c1.tar.gz
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).
Diffstat (limited to 'fftools/ffmpeg_mux_init.c')
-rw-r--r--fftools/ffmpeg_mux_init.c16
1 files changed, 11 insertions, 5 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) ?