Commit be33da9a authored by Nicolas George's avatar Nicolas George

lavfi: add concat filter.

parent 1cadab60
......@@ -35,6 +35,7 @@ version next:
- Opus decoder using libopus
- caca output device using libcaca
- alphaextract and alphamerge filters
- concat filter
version 0.11:
......
......@@ -4013,6 +4013,81 @@ tools.
Below is a description of the currently available transmedia filters.
@section concat
Concatenate audio and video streams, joining them together one after the
other.
The filter works on segments of synchronized video and audio streams. All
segments must have the same number of streams of each type, and that will
also be the number of streams at output.
The filter accepts the following named parameters:
@table @option
@item n
Set the number of segments. Default is 2.
@item v
Set the number of output video streams, that is also the number of video
streams in each segment. Default is 1.
@item a
Set the number of output audio streams, that is also the number of video
streams in each segment. Default is 0.
@end table
The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
@var{a} audio outputs.
There are @var{n}×(@var{v}+@var{a}) inputs: first the inputs for the first
segment, in the same order as the outputs, then the inputs for the second
segment, etc.
Related streams do not always have exactly the same duration, for various
reasons including codec frame size or sloppy authoring. For that reason,
related synchronized streams (e.g. a video and its audio track) should be
concatenated at once. The concat filter will use the duration of the longest
stream in each segment (except the last one), and if necessary pad shorter
audio streams with silence.
For this filter to work correctly, all segments must start at timestamp 0.
All corresponding streams must have the same parameters in all segments; the
filtering system will automatically select a common pixel format for video
streams, and a common sample format, sample rate and channel layout for
audio streams, but other settings, such as resolution, must be converted
explicitly by the user.
Different frame rates are acceptable but will result in variable frame rate
at output; be sure to configure the output file to handle it.
Examples:
@itemize
@item
Concatenate an opening, an episode and an ending, all in bilingual version
(video in stream 0, audio in streams 1 and 2):
@example
ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
'[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
concat=n=3:v=1:a=2 [v] [a1] [a2]' \
-map '[v]' -map '[a1]' -map '[a2]' output.mkv
@end example
@item
Concatenate two parts, handling audio and video separately, using the
(a)movie sources, and adjusting the resolution:
@example
movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
[v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
@end example
Note that a desync will happen at the stitch if the audio and video streams
do not have exactly the same duration in the first file.
@end itemize
@section showwaves
Convert input audio to a video output, representing the samples waves.
......
......@@ -199,6 +199,7 @@ OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_yvu9.o
OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/pullup.o
# transmedia filters
OBJS-$(CONFIG_CONCAT_FILTER) += avf_concat.o
OBJS-$(CONFIG_SHOWWAVES_FILTER) += avf_showwaves.o
TOOLS = graph2dot
......
......@@ -136,6 +136,7 @@ void avfilter_register_all(void)
REGISTER_FILTER (NULLSINK, nullsink, vsink);
/* transmedia filters */
REGISTER_FILTER (CONCAT, concat, avf);
REGISTER_FILTER (SHOWWAVES, showwaves, avf);
/* those filters are part of public or internal API => registered
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment