|
|
|
@@ -3,10 +3,10 @@ |
|
|
|
|
|
|
|
Filtering in FFmpeg is enabled through the libavfilter library. |
|
|
|
|
|
|
|
In libavfilter, it is possible for filters to have multiple inputs and |
|
|
|
multiple outputs. |
|
|
|
To illustrate the sorts of things that are possible, we can |
|
|
|
use a complex filtergraph. For example, the following one: |
|
|
|
In libavfilter, a filter can have multiple inputs and multiple |
|
|
|
outputs. |
|
|
|
To illustrate the sorts of things that are possible, we consider the |
|
|
|
following filtergraph. |
|
|
|
|
|
|
|
@example |
|
|
|
input --> split ---------------------> overlay --> output |
|
|
|
@@ -15,25 +15,32 @@ input --> split ---------------------> overlay --> output |
|
|
|
+-----> crop --> vflip -------+ |
|
|
|
@end example |
|
|
|
|
|
|
|
splits the stream in two streams, sends one stream through the crop filter |
|
|
|
and the vflip filter before merging it back with the other stream by |
|
|
|
overlaying it on top. You can use the following command to achieve this: |
|
|
|
This filtergraph splits the input stream in two streams, sends one |
|
|
|
stream through the crop filter and the vflip filter before merging it |
|
|
|
back with the other stream by overlaying it on top. You can use the |
|
|
|
following command to achieve this: |
|
|
|
|
|
|
|
@example |
|
|
|
ffmpeg -i input -vf "[in] split [T1], [T2] overlay=0:H/2 [out]; [T1] crop=iw:ih/2:0:ih/2, vflip [T2]" output |
|
|
|
ffmpeg -i INPUT -vf "split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2" OUTPUT |
|
|
|
@end example |
|
|
|
|
|
|
|
The result will be that in output the top half of the video is mirrored |
|
|
|
onto the bottom half. |
|
|
|
|
|
|
|
Filters are loaded using the @var{-vf} or @var{-af} option passed to |
|
|
|
@command{ffmpeg} or to @command{ffplay}. Filters in the same linear |
|
|
|
chain are separated by commas. In our example, @var{split, |
|
|
|
overlay} are in one linear chain, and @var{crop, vflip} are in |
|
|
|
another. The points where the linear chains join are labeled by names |
|
|
|
enclosed in square brackets. In our example, that is @var{[T1]} and |
|
|
|
@var{[T2]}. The special labels @var{[in]} and @var{[out]} are the points |
|
|
|
where video is input and output. |
|
|
|
Filters in the same linear chain are separated by commas, and distinct |
|
|
|
linear chains of filters are separated by semicolons. In our example, |
|
|
|
@var{crop,vflip} are in one linear chain, @var{split} and |
|
|
|
@var{overlay} are separately in another. The points where the linear |
|
|
|
chains join are labelled by names enclosed in square brackets. In the |
|
|
|
example, the split filter generates two outputs that are associated to |
|
|
|
the labels @var{[main]} and @var{[tmp]}. |
|
|
|
|
|
|
|
The stream sent to the second output of @var{split}, labelled as |
|
|
|
@var{[tmp]}, is processed through the @var{crop} filter, which crops |
|
|
|
away the lower half part of the video, and then vertically flipped. The |
|
|
|
@var{overlay} filter takes in input the first unchanged output of the |
|
|
|
split filter (which was labelled as @var{[main]}), and overlay on its |
|
|
|
lower half the output generated by the @var{crop,vflip} filterchain. |
|
|
|
|
|
|
|
Some filters take in input a list of parameters: they are specified |
|
|
|
after the filter name and an equal sign, and are separated from each other |
|
|
|
|