diff options
author | Calvin Walton <calvin.walton@kepstin.ca> | 2019-08-30 13:28:17 -0400 |
---|---|---|
committer | Nicolas George <george@nsup.org> | 2019-09-08 16:48:28 +0200 |
commit | 3ad5d4df9ce794d3eeb0f526c5f3e446bf97c616 (patch) | |
tree | f570c135d7223ef582f79765bca656ca09adaed7 /libavfilter/avf_concat.c | |
parent | 85386c36e331d1387a3ac0f322e3774c1b55dc26 (diff) | |
download | ffmpeg-3ad5d4df9ce794d3eeb0f526c5f3e446bf97c616.tar.gz |
lavfi/concat: allow to support inputs with different frame rates
Right now, the concat filter does not set the frame_rate value on any of
the out links. As a result, the default ffmpeg behaviour kicks in - to
copy the framerate from the first input to the outputs.
If a later input is higher framerate, this results in dropped frames; if
a later input is lower framerate it might cause judder.
This patch checks if all of the video inputs have the same framerate, and
if not it sets the out link to use '1/0' as the frame rate, the value
meaning "unknown/vfr".
A test is added to verify the VFR behaviour. The existing test for CFR
behaviour passes unchanged.
Diffstat (limited to 'libavfilter/avf_concat.c')
-rw-r--r-- | libavfilter/avf_concat.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c index 1d0c2de290..2791859d8f 100644 --- a/libavfilter/avf_concat.c +++ b/libavfilter/avf_concat.c @@ -131,8 +131,21 @@ static int config_output(AVFilterLink *outlink) outlink->h = inlink->h; outlink->sample_aspect_ratio = inlink->sample_aspect_ratio; outlink->format = inlink->format; + outlink->frame_rate = inlink->frame_rate; + + for (seg = 1; seg < cat->nb_segments; seg++) { + inlink = ctx->inputs[in_no + seg * ctx->nb_outputs]; + if (outlink->frame_rate.num != inlink->frame_rate.num || + outlink->frame_rate.den != outlink->frame_rate.den) { + av_log(ctx, AV_LOG_VERBOSE, + "Video inputs have different frame rates, output will be VFR\n"); + outlink->frame_rate = av_make_q(1, 0); + break; + } + } + for (seg = 1; seg < cat->nb_segments; seg++) { - inlink = ctx->inputs[in_no += ctx->nb_outputs]; + inlink = ctx->inputs[in_no + seg * ctx->nb_outputs]; if (!outlink->sample_aspect_ratio.num) outlink->sample_aspect_ratio = inlink->sample_aspect_ratio; /* possible enhancement: unsafe mode, do not check */ |