Browse code

doc/filters: review introductory example and explanation

In particular, fix wrong vertical mirroring command, and clarify
and extend explanation.

Based on a patch by littlebat <dashing.meng@gmail.com>.

Should fix trac ticket #2413.
(cherry picked from commit 215ca864759a54f45265a51ac57dbfd75cb23da2)

Signed-off-by: Timothy Gu <timothygu99@gmail.com>

Conflicts:
doc/filters.texi

Stefano Sabatini authored on 2013/04/06 08:43:01
Showing 1 changed files
... ...
@@ -3,10 +3,10 @@
3 3
 
4 4
 Filtering in FFmpeg is enabled through the libavfilter library.
5 5
 
6
-In libavfilter, it is possible for filters to have multiple inputs and
7
-multiple outputs.
8
-To illustrate the sorts of things that are possible, we can
9
-use a complex filter graph. For example, the following one:
6
+In libavfilter, a filter can have multiple inputs and multiple
7
+outputs.
8
+To illustrate the sorts of things that are possible, we consider the
9
+following filtergraph.
10 10
 
11 11
 @example
12 12
 input --> split ---------------------> overlay --> output
... ...
@@ -15,25 +15,32 @@ input --> split ---------------------> overlay --> output
15 15
             +-----> crop --> vflip -------+
16 16
 @end example
17 17
 
18
-splits the stream in two streams, sends one stream through the crop filter
19
-and the vflip filter before merging it back with the other stream by
20
-overlaying it on top. You can use the following command to achieve this:
18
+This filtergraph splits the input stream in two streams, sends one
19
+stream through the crop filter and the vflip filter before merging it
20
+back with the other stream by overlaying it on top. You can use the
21
+following command to achieve this:
21 22
 
22 23
 @example
23
-ffmpeg -i input -vf "[in] split [T1], [T2] overlay=0:H/2 [out]; [T1] crop=iw:ih/2:0:ih/2, vflip [T2]" output
24
+ffmpeg -i INPUT -vf "split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2" OUTPUT
24 25
 @end example
25 26
 
26 27
 The result will be that in output the top half of the video is mirrored
27 28
 onto the bottom half.
28 29
 
29
-Filters are loaded using the @var{-vf} or @var{-af} option passed to
30
-@command{ffmpeg} or to @command{ffplay}. Filters in the same linear
31
-chain are separated by commas. In our example, @var{split,
32
-overlay} are in one linear chain, and @var{crop, vflip} are in
33
-another. The points where the linear chains join are labeled by names
34
-enclosed in square brackets. In our example, that is @var{[T1]} and
35
-@var{[T2]}. The special labels @var{[in]} and @var{[out]} are the points
36
-where video is input and output.
30
+Filters in the same linear chain are separated by commas, and distinct
31
+linear chains of filters are separated by semicolons. In our example,
32
+@var{crop,vflip} are in one linear chain, @var{split} and
33
+@var{overlay} are separately in another. The points where the linear
34
+chains join are labelled by names enclosed in square brackets. In the
35
+example, the split filter generates two outputs that are associated to
36
+the labels @var{[main]} and @var{[tmp]}.
37
+
38
+The stream sent to the second output of @var{split}, labelled as
39
+@var{[tmp]}, is processed through the @var{crop} filter, which crops
40
+away the lower half part of the video, and then vertically flipped. The
41
+@var{overlay} filter takes in input the first unchanged output of the
42
+split filter (which was labelled as @var{[main]}), and overlay on its
43
+lower half the output generated by the @var{crop,vflip} filterchain.
37 44
 
38 45
 Some filters take in input a list of parameters: they are specified
39 46
 after the filter name and an equal sign, and are separated from each other