From 9145c6d3b2e6e051b7450bcb96bdb3267271936c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 4 Dec 2021 15:16:54 +0100 Subject: ffmpeg: move setting video sync method to new_video_stream() do_video_out() is the wrong place for it, since the necessary information is already known when creating the stream and its value should never change. --- fftools/ffmpeg_opt.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'fftools/ffmpeg_opt.c') diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 42a65830a2..9c820ab73f 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1895,6 +1895,30 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in ost->top_field_first = -1; MATCH_PER_STREAM_OPT(top_field_first, i, ost->top_field_first, oc, st); + ost->vsync_method = video_sync_method; + if (ost->vsync_method == VSYNC_AUTO) { + if (!strcmp(oc->oformat->name, "avi")) { + ost->vsync_method = VSYNC_VFR; + } else { + ost->vsync_method = (oc->oformat->flags & AVFMT_VARIABLE_FPS) ? + ((oc->oformat->flags & AVFMT_NOTIMESTAMPS) ? + VSYNC_PASSTHROUGH : VSYNC_VFR) : + VSYNC_CFR; + } + + if (ost->source_index >= 0 && ost->vsync_method == VSYNC_CFR) { + const InputStream *ist = input_streams[ost->source_index]; + const InputFile *ifile = input_files[ist->file_index]; + + if (ifile->nb_streams == 1 && ifile->input_ts_offset == 0) + ost->vsync_method = VSYNC_VSCFR; + } + + if (ost->vsync_method == VSYNC_CFR && copy_ts) { + ost->vsync_method = VSYNC_VSCFR; + } + } + ost->is_cfr = (ost->vsync_method == VSYNC_CFR || ost->vsync_method == VSYNC_VSCFR); ost->avfilter = get_ost_filters(o, oc, ost); if (!ost->avfilter) -- cgit v1.2.3