diff options
author | Anton Khirnov <anton@khirnov.net> | 2021-12-04 15:16:54 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2021-12-07 11:23:45 +0100 |
commit | 9145c6d3b2e6e051b7450bcb96bdb3267271936c (patch) | |
tree | 84d43f8a9b56ce236c0c22dc93f4acdce5865ca7 /fftools/ffmpeg_opt.c | |
parent | 6ce954642878d792ee1f628e0f871763f07efe72 (diff) |
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.
Diffstat (limited to 'fftools/ffmpeg_opt.c')
-rw-r--r-- | fftools/ffmpeg_opt.c | 24 |
1 files changed, 24 insertions, 0 deletions
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) |