]> git.sesse.net Git - ffmpeg/blob - doc/filters.texi
Merge commit '76eb0950b8d82b1e9617b9c854f091e13bb23131'
[ffmpeg] / doc / filters.texi
1 @chapter Filtering Introduction
2 @c man begin FILTERING INTRODUCTION
3
4 Filtering in FFmpeg is enabled through the libavfilter library.
5
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
11 @verbatim
12                 [main]
13 input --> split ---------------------> overlay --> output
14             |                             ^
15             |[tmp]                  [flip]|
16             +-----> crop --> vflip -------+
17 @end verbatim
18
19 This filtergraph splits the input stream in two streams, then sends one
20 stream through the crop filter and the vflip filter, before merging it
21 back with the other stream by overlaying it on top. You can use the
22 following command to achieve this:
23
24 @example
25 ffmpeg -i INPUT -vf "split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2" OUTPUT
26 @end example
27
28 The result will be that the top half of the video is mirrored
29 onto the bottom half of the output video.
30
31 Filters in the same linear chain are separated by commas, and distinct
32 linear chains of filters are separated by semicolons. In our example,
33 @var{crop,vflip} are in one linear chain, @var{split} and
34 @var{overlay} are separately in another. The points where the linear
35 chains join are labelled by names enclosed in square brackets. In the
36 example, the split filter generates two outputs that are associated to
37 the labels @var{[main]} and @var{[tmp]}.
38
39 The stream sent to the second output of @var{split}, labelled as
40 @var{[tmp]}, is processed through the @var{crop} filter, which crops
41 away the lower half part of the video, and then vertically flipped. The
42 @var{overlay} filter takes in input the first unchanged output of the
43 split filter (which was labelled as @var{[main]}), and overlay on its
44 lower half the output generated by the @var{crop,vflip} filterchain.
45
46 Some filters take in input a list of parameters: they are specified
47 after the filter name and an equal sign, and are separated from each other
48 by a colon.
49
50 There exist so-called @var{source filters} that do not have an
51 audio/video input, and @var{sink filters} that will not have audio/video
52 output.
53
54 @c man end FILTERING INTRODUCTION
55
56 @chapter graph2dot
57 @c man begin GRAPH2DOT
58
59 The @file{graph2dot} program included in the FFmpeg @file{tools}
60 directory can be used to parse a filtergraph description and issue a
61 corresponding textual representation in the dot language.
62
63 Invoke the command:
64 @example
65 graph2dot -h
66 @end example
67
68 to see how to use @file{graph2dot}.
69
70 You can then pass the dot description to the @file{dot} program (from
71 the graphviz suite of programs) and obtain a graphical representation
72 of the filtergraph.
73
74 For example the sequence of commands:
75 @example
76 echo @var{GRAPH_DESCRIPTION} | \
77 tools/graph2dot -o graph.tmp && \
78 dot -Tpng graph.tmp -o graph.png && \
79 display graph.png
80 @end example
81
82 can be used to create and display an image representing the graph
83 described by the @var{GRAPH_DESCRIPTION} string. Note that this string must be
84 a complete self-contained graph, with its inputs and outputs explicitly defined.
85 For example if your command line is of the form:
86 @example
87 ffmpeg -i infile -vf scale=640:360 outfile
88 @end example
89 your @var{GRAPH_DESCRIPTION} string will need to be of the form:
90 @example
91 nullsrc,scale=640:360,nullsink
92 @end example
93 you may also need to set the @var{nullsrc} parameters and add a @var{format}
94 filter in order to simulate a specific input file.
95
96 @c man end GRAPH2DOT
97
98 @chapter Filtergraph description
99 @c man begin FILTERGRAPH DESCRIPTION
100
101 A filtergraph is a directed graph of connected filters. It can contain
102 cycles, and there can be multiple links between a pair of
103 filters. Each link has one input pad on one side connecting it to one
104 filter from which it takes its input, and one output pad on the other
105 side connecting it to one filter accepting its output.
106
107 Each filter in a filtergraph is an instance of a filter class
108 registered in the application, which defines the features and the
109 number of input and output pads of the filter.
110
111 A filter with no input pads is called a "source", and a filter with no
112 output pads is called a "sink".
113
114 @anchor{Filtergraph syntax}
115 @section Filtergraph syntax
116
117 A filtergraph has a textual representation, which is recognized by the
118 @option{-filter}/@option{-vf}/@option{-af} and
119 @option{-filter_complex} options in @command{ffmpeg} and
120 @option{-vf}/@option{-af} in @command{ffplay}, and by the
121 @code{avfilter_graph_parse_ptr()} function defined in
122 @file{libavfilter/avfilter.h}.
123
124 A filterchain consists of a sequence of connected filters, each one
125 connected to the previous one in the sequence. A filterchain is
126 represented by a list of ","-separated filter descriptions.
127
128 A filtergraph consists of a sequence of filterchains. A sequence of
129 filterchains is represented by a list of ";"-separated filterchain
130 descriptions.
131
132 A filter is represented by a string of the form:
133 [@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
134
135 @var{filter_name} is the name of the filter class of which the
136 described filter is an instance of, and has to be the name of one of
137 the filter classes registered in the program.
138 The name of the filter class is optionally followed by a string
139 "=@var{arguments}".
140
141 @var{arguments} is a string which contains the parameters used to
142 initialize the filter instance. It may have one of two forms:
143 @itemize
144
145 @item
146 A ':'-separated list of @var{key=value} pairs.
147
148 @item
149 A ':'-separated list of @var{value}. In this case, the keys are assumed to be
150 the option names in the order they are declared. E.g. the @code{fade} filter
151 declares three options in this order -- @option{type}, @option{start_frame} and
152 @option{nb_frames}. Then the parameter list @var{in:0:30} means that the value
153 @var{in} is assigned to the option @option{type}, @var{0} to
154 @option{start_frame} and @var{30} to @option{nb_frames}.
155
156 @item
157 A ':'-separated list of mixed direct @var{value} and long @var{key=value}
158 pairs. The direct @var{value} must precede the @var{key=value} pairs, and
159 follow the same constraints order of the previous point. The following
160 @var{key=value} pairs can be set in any preferred order.
161
162 @end itemize
163
164 If the option value itself is a list of items (e.g. the @code{format} filter
165 takes a list of pixel formats), the items in the list are usually separated by
166 @samp{|}.
167
168 The list of arguments can be quoted using the character @samp{'} as initial
169 and ending mark, and the character @samp{\} for escaping the characters
170 within the quoted text; otherwise the argument string is considered
171 terminated when the next special character (belonging to the set
172 @samp{[]=;,}) is encountered.
173
174 The name and arguments of the filter are optionally preceded and
175 followed by a list of link labels.
176 A link label allows one to name a link and associate it to a filter output
177 or input pad. The preceding labels @var{in_link_1}
178 ... @var{in_link_N}, are associated to the filter input pads,
179 the following labels @var{out_link_1} ... @var{out_link_M}, are
180 associated to the output pads.
181
182 When two link labels with the same name are found in the
183 filtergraph, a link between the corresponding input and output pad is
184 created.
185
186 If an output pad is not labelled, it is linked by default to the first
187 unlabelled input pad of the next filter in the filterchain.
188 For example in the filterchain
189 @example
190 nullsrc, split[L1], [L2]overlay, nullsink
191 @end example
192 the split filter instance has two output pads, and the overlay filter
193 instance two input pads. The first output pad of split is labelled
194 "L1", the first input pad of overlay is labelled "L2", and the second
195 output pad of split is linked to the second input pad of overlay,
196 which are both unlabelled.
197
198 In a filter description, if the input label of the first filter is not
199 specified, "in" is assumed; if the output label of the last filter is not
200 specified, "out" is assumed.
201
202 In a complete filterchain all the unlabelled filter input and output
203 pads must be connected. A filtergraph is considered valid if all the
204 filter input and output pads of all the filterchains are connected.
205
206 Libavfilter will automatically insert @ref{scale} filters where format
207 conversion is required. It is possible to specify swscale flags
208 for those automatically inserted scalers by prepending
209 @code{sws_flags=@var{flags};}
210 to the filtergraph description.
211
212 Here is a BNF description of the filtergraph syntax:
213 @example
214 @var{NAME}             ::= sequence of alphanumeric characters and '_'
215 @var{LINKLABEL}        ::= "[" @var{NAME} "]"
216 @var{LINKLABELS}       ::= @var{LINKLABEL} [@var{LINKLABELS}]
217 @var{FILTER_ARGUMENTS} ::= sequence of chars (possibly quoted)
218 @var{FILTER}           ::= [@var{LINKLABELS}] @var{NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}]
219 @var{FILTERCHAIN}      ::= @var{FILTER} [,@var{FILTERCHAIN}]
220 @var{FILTERGRAPH}      ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
221 @end example
222
223 @section Notes on filtergraph escaping
224
225 Filtergraph description composition entails several levels of
226 escaping. See @ref{quoting_and_escaping,,the "Quoting and escaping"
227 section in the ffmpeg-utils(1) manual,ffmpeg-utils} for more
228 information about the employed escaping procedure.
229
230 A first level escaping affects the content of each filter option
231 value, which may contain the special character @code{:} used to
232 separate values, or one of the escaping characters @code{\'}.
233
234 A second level escaping affects the whole filter description, which
235 may contain the escaping characters @code{\'} or the special
236 characters @code{[],;} used by the filtergraph description.
237
238 Finally, when you specify a filtergraph on a shell commandline, you
239 need to perform a third level escaping for the shell special
240 characters contained within it.
241
242 For example, consider the following string to be embedded in
243 the @ref{drawtext} filter description @option{text} value:
244 @example
245 this is a 'string': may contain one, or more, special characters
246 @end example
247
248 This string contains the @code{'} special escaping character, and the
249 @code{:} special character, so it needs to be escaped in this way:
250 @example
251 text=this is a \'string\'\: may contain one, or more, special characters
252 @end example
253
254 A second level of escaping is required when embedding the filter
255 description in a filtergraph description, in order to escape all the
256 filtergraph special characters. Thus the example above becomes:
257 @example
258 drawtext=text=this is a \\\'string\\\'\\: may contain one\, or more\, special characters
259 @end example
260 (note that in addition to the @code{\'} escaping special characters,
261 also @code{,} needs to be escaped).
262
263 Finally an additional level of escaping is needed when writing the
264 filtergraph description in a shell command, which depends on the
265 escaping rules of the adopted shell. For example, assuming that
266 @code{\} is special and needs to be escaped with another @code{\}, the
267 previous string will finally result in:
268 @example
269 -vf "drawtext=text=this is a \\\\\\'string\\\\\\'\\\\: may contain one\\, or more\\, special characters"
270 @end example
271
272 @chapter Timeline editing
273
274 Some filters support a generic @option{enable} option. For the filters
275 supporting timeline editing, this option can be set to an expression which is
276 evaluated before sending a frame to the filter. If the evaluation is non-zero,
277 the filter will be enabled, otherwise the frame will be sent unchanged to the
278 next filter in the filtergraph.
279
280 The expression accepts the following values:
281 @table @samp
282 @item t
283 timestamp expressed in seconds, NAN if the input timestamp is unknown
284
285 @item n
286 sequential number of the input frame, starting from 0
287
288 @item pos
289 the position in the file of the input frame, NAN if unknown
290
291 @item w
292 @item h
293 width and height of the input frame if video
294 @end table
295
296 Additionally, these filters support an @option{enable} command that can be used
297 to re-define the expression.
298
299 Like any other filtering option, the @option{enable} option follows the same
300 rules.
301
302 For example, to enable a blur filter (@ref{smartblur}) from 10 seconds to 3
303 minutes, and a @ref{curves} filter starting at 3 seconds:
304 @example
305 smartblur = enable='between(t,10,3*60)',
306 curves    = enable='gte(t,3)' : preset=cross_process
307 @end example
308
309 @c man end FILTERGRAPH DESCRIPTION
310
311 @chapter Audio Filters
312 @c man begin AUDIO FILTERS
313
314 When you configure your FFmpeg build, you can disable any of the
315 existing filters using @code{--disable-filters}.
316 The configure output will show the audio filters included in your
317 build.
318
319 Below is a description of the currently available audio filters.
320
321 @section adelay
322
323 Delay one or more audio channels.
324
325 Samples in delayed channel are filled with silence.
326
327 The filter accepts the following option:
328
329 @table @option
330 @item delays
331 Set list of delays in milliseconds for each channel separated by '|'.
332 At least one delay greater than 0 should be provided.
333 Unused delays will be silently ignored. If number of given delays is
334 smaller than number of channels all remaining channels will not be delayed.
335 @end table
336
337 @subsection Examples
338
339 @itemize
340 @item
341 Delay first channel by 1.5 seconds, the third channel by 0.5 seconds and leave
342 the second channel (and any other channels that may be present) unchanged.
343 @example
344 adelay=1500|0|500
345 @end example
346 @end itemize
347
348 @section aecho
349
350 Apply echoing to the input audio.
351
352 Echoes are reflected sound and can occur naturally amongst mountains
353 (and sometimes large buildings) when talking or shouting; digital echo
354 effects emulate this behaviour and are often used to help fill out the
355 sound of a single instrument or vocal. The time difference between the
356 original signal and the reflection is the @code{delay}, and the
357 loudness of the reflected signal is the @code{decay}.
358 Multiple echoes can have different delays and decays.
359
360 A description of the accepted parameters follows.
361
362 @table @option
363 @item in_gain
364 Set input gain of reflected signal. Default is @code{0.6}.
365
366 @item out_gain
367 Set output gain of reflected signal. Default is @code{0.3}.
368
369 @item delays
370 Set list of time intervals in milliseconds between original signal and reflections
371 separated by '|'. Allowed range for each @code{delay} is @code{(0 - 90000.0]}.
372 Default is @code{1000}.
373
374 @item decays
375 Set list of loudnesses of reflected signals separated by '|'.
376 Allowed range for each @code{decay} is @code{(0 - 1.0]}.
377 Default is @code{0.5}.
378 @end table
379
380 @subsection Examples
381
382 @itemize
383 @item
384 Make it sound as if there are twice as many instruments as are actually playing:
385 @example
386 aecho=0.8:0.88:60:0.4
387 @end example
388
389 @item
390 If delay is very short, then it sound like a (metallic) robot playing music:
391 @example
392 aecho=0.8:0.88:6:0.4
393 @end example
394
395 @item
396 A longer delay will sound like an open air concert in the mountains:
397 @example
398 aecho=0.8:0.9:1000:0.3
399 @end example
400
401 @item
402 Same as above but with one more mountain:
403 @example
404 aecho=0.8:0.9:1000|1800:0.3|0.25
405 @end example
406 @end itemize
407
408 @section aeval
409
410 Modify an audio signal according to the specified expressions.
411
412 This filter accepts one or more expressions (one for each channel),
413 which are evaluated and used to modify a corresponding audio signal.
414
415 It accepts the following parameters:
416
417 @table @option
418 @item exprs
419 Set the '|'-separated expressions list for each separate channel. If
420 the number of input channels is greater than the number of
421 expressions, the last specified expression is used for the remaining
422 output channels.
423
424 @item channel_layout, c
425 Set output channel layout. If not specified, the channel layout is
426 specified by the number of expressions. If set to @samp{same}, it will
427 use by default the same input channel layout.
428 @end table
429
430 Each expression in @var{exprs} can contain the following constants and functions:
431
432 @table @option
433 @item ch
434 channel number of the current expression
435
436 @item n
437 number of the evaluated sample, starting from 0
438
439 @item s
440 sample rate
441
442 @item t
443 time of the evaluated sample expressed in seconds
444
445 @item nb_in_channels
446 @item nb_out_channels
447 input and output number of channels
448
449 @item val(CH)
450 the value of input channel with number @var{CH}
451 @end table
452
453 Note: this filter is slow. For faster processing you should use a
454 dedicated filter.
455
456 @subsection Examples
457
458 @itemize
459 @item
460 Half volume:
461 @example
462 aeval=val(ch)/2:c=same
463 @end example
464
465 @item
466 Invert phase of the second channel:
467 @example
468 aeval=val(0)|-val(1)
469 @end example
470 @end itemize
471
472 @section afade
473
474 Apply fade-in/out effect to input audio.
475
476 A description of the accepted parameters follows.
477
478 @table @option
479 @item type, t
480 Specify the effect type, can be either @code{in} for fade-in, or
481 @code{out} for a fade-out effect. Default is @code{in}.
482
483 @item start_sample, ss
484 Specify the number of the start sample for starting to apply the fade
485 effect. Default is 0.
486
487 @item nb_samples, ns
488 Specify the number of samples for which the fade effect has to last. At
489 the end of the fade-in effect the output audio will have the same
490 volume as the input audio, at the end of the fade-out transition
491 the output audio will be silence. Default is 44100.
492
493 @item start_time, st
494 Specify the start time of the fade effect. Default is 0.
495 The value must be specified as a time duration; see
496 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
497 for the accepted syntax.
498 If set this option is used instead of @var{start_sample}.
499
500 @item duration, d
501 Specify the duration of the fade effect. See
502 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
503 for the accepted syntax.
504 At the end of the fade-in effect the output audio will have the same
505 volume as the input audio, at the end of the fade-out transition
506 the output audio will be silence.
507 By default the duration is determined by @var{nb_samples}.
508 If set this option is used instead of @var{nb_samples}.
509
510 @item curve
511 Set curve for fade transition.
512
513 It accepts the following values:
514 @table @option
515 @item tri
516 select triangular, linear slope (default)
517 @item qsin
518 select quarter of sine wave
519 @item hsin
520 select half of sine wave
521 @item esin
522 select exponential sine wave
523 @item log
524 select logarithmic
525 @item par
526 select inverted parabola
527 @item qua
528 select quadratic
529 @item cub
530 select cubic
531 @item squ
532 select square root
533 @item cbr
534 select cubic root
535 @end table
536 @end table
537
538 @subsection Examples
539
540 @itemize
541 @item
542 Fade in first 15 seconds of audio:
543 @example
544 afade=t=in:ss=0:d=15
545 @end example
546
547 @item
548 Fade out last 25 seconds of a 900 seconds audio:
549 @example
550 afade=t=out:st=875:d=25
551 @end example
552 @end itemize
553
554 @anchor{aformat}
555 @section aformat
556
557 Set output format constraints for the input audio. The framework will
558 negotiate the most appropriate format to minimize conversions.
559
560 It accepts the following parameters:
561 @table @option
562
563 @item sample_fmts
564 A '|'-separated list of requested sample formats.
565
566 @item sample_rates
567 A '|'-separated list of requested sample rates.
568
569 @item channel_layouts
570 A '|'-separated list of requested channel layouts.
571
572 See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
573 for the required syntax.
574 @end table
575
576 If a parameter is omitted, all values are allowed.
577
578 Force the output to either unsigned 8-bit or signed 16-bit stereo
579 @example
580 aformat=sample_fmts=u8|s16:channel_layouts=stereo
581 @end example
582
583 @section allpass
584
585 Apply a two-pole all-pass filter with central frequency (in Hz)
586 @var{frequency}, and filter-width @var{width}.
587 An all-pass filter changes the audio's frequency to phase relationship
588 without changing its frequency to amplitude relationship.
589
590 The filter accepts the following options:
591
592 @table @option
593 @item frequency, f
594 Set frequency in Hz.
595
596 @item width_type
597 Set method to specify band-width of filter.
598 @table @option
599 @item h
600 Hz
601 @item q
602 Q-Factor
603 @item o
604 octave
605 @item s
606 slope
607 @end table
608
609 @item width, w
610 Specify the band-width of a filter in width_type units.
611 @end table
612
613 @section amerge
614
615 Merge two or more audio streams into a single multi-channel stream.
616
617 The filter accepts the following options:
618
619 @table @option
620
621 @item inputs
622 Set the number of inputs. Default is 2.
623
624 @end table
625
626 If the channel layouts of the inputs are disjoint, and therefore compatible,
627 the channel layout of the output will be set accordingly and the channels
628 will be reordered as necessary. If the channel layouts of the inputs are not
629 disjoint, the output will have all the channels of the first input then all
630 the channels of the second input, in that order, and the channel layout of
631 the output will be the default value corresponding to the total number of
632 channels.
633
634 For example, if the first input is in 2.1 (FL+FR+LF) and the second input
635 is FC+BL+BR, then the output will be in 5.1, with the channels in the
636 following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
637 first input, b1 is the first channel of the second input).
638
639 On the other hand, if both input are in stereo, the output channels will be
640 in the default order: a1, a2, b1, b2, and the channel layout will be
641 arbitrarily set to 4.0, which may or may not be the expected value.
642
643 All inputs must have the same sample rate, and format.
644
645 If inputs do not have the same duration, the output will stop with the
646 shortest.
647
648 @subsection Examples
649
650 @itemize
651 @item
652 Merge two mono files into a stereo stream:
653 @example
654 amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
655 @end example
656
657 @item
658 Multiple merges assuming 1 video stream and 6 audio streams in @file{input.mkv}:
659 @example
660 ffmpeg -i input.mkv -filter_complex "[0:1][0:2][0:3][0:4][0:5][0:6] amerge=inputs=6" -c:a pcm_s16le output.mkv
661 @end example
662 @end itemize
663
664 @section amix
665
666 Mixes multiple audio inputs into a single output.
667
668 Note that this filter only supports float samples (the @var{amerge}
669 and @var{pan} audio filters support many formats). If the @var{amix}
670 input has integer samples then @ref{aresample} will be automatically
671 inserted to perform the conversion to float samples.
672
673 For example
674 @example
675 ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
676 @end example
677 will mix 3 input audio streams to a single output with the same duration as the
678 first input and a dropout transition time of 3 seconds.
679
680 It accepts the following parameters:
681 @table @option
682
683 @item inputs
684 The number of inputs. If unspecified, it defaults to 2.
685
686 @item duration
687 How to determine the end-of-stream.
688 @table @option
689
690 @item longest
691 The duration of the longest input. (default)
692
693 @item shortest
694 The duration of the shortest input.
695
696 @item first
697 The duration of the first input.
698
699 @end table
700
701 @item dropout_transition
702 The transition time, in seconds, for volume renormalization when an input
703 stream ends. The default value is 2 seconds.
704
705 @end table
706
707 @section anull
708
709 Pass the audio source unchanged to the output.
710
711 @section apad
712
713 Pad the end of an audio stream with silence.
714
715 This can be used together with @command{ffmpeg} @option{-shortest} to
716 extend audio streams to the same length as the video stream.
717
718 A description of the accepted options follows.
719
720 @table @option
721 @item packet_size
722 Set silence packet size. Default value is 4096.
723
724 @item pad_len
725 Set the number of samples of silence to add to the end. After the
726 value is reached, the stream is terminated. This option is mutually
727 exclusive with @option{whole_len}.
728
729 @item whole_len
730 Set the minimum total number of samples in the output audio stream. If
731 the value is longer than the input audio length, silence is added to
732 the end, until the value is reached. This option is mutually exclusive
733 with @option{pad_len}.
734 @end table
735
736 If neither the @option{pad_len} nor the @option{whole_len} option is
737 set, the filter will add silence to the end of the input stream
738 indefinitely.
739
740 @subsection Examples
741
742 @itemize
743 @item
744 Add 1024 samples of silence to the end of the input:
745 @example
746 apad=pad_len=1024
747 @end example
748
749 @item
750 Make sure the audio output will contain at least 10000 samples, pad
751 the input with silence if required:
752 @example
753 apad=whole_len=10000
754 @end example
755
756 @item
757 Use @command{ffmpeg} to pad the audio input with silence, so that the
758 video stream will always result the shortest and will be converted
759 until the end in the output file when using the @option{shortest}
760 option:
761 @example
762 ffmpeg -i VIDEO -i AUDIO -filter_complex "[1:0]apad" -shortest OUTPUT
763 @end example
764 @end itemize
765
766 @section aphaser
767 Add a phasing effect to the input audio.
768
769 A phaser filter creates series of peaks and troughs in the frequency spectrum.
770 The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
771
772 A description of the accepted parameters follows.
773
774 @table @option
775 @item in_gain
776 Set input gain. Default is 0.4.
777
778 @item out_gain
779 Set output gain. Default is 0.74
780
781 @item delay
782 Set delay in milliseconds. Default is 3.0.
783
784 @item decay
785 Set decay. Default is 0.4.
786
787 @item speed
788 Set modulation speed in Hz. Default is 0.5.
789
790 @item type
791 Set modulation type. Default is triangular.
792
793 It accepts the following values:
794 @table @samp
795 @item triangular, t
796 @item sinusoidal, s
797 @end table
798 @end table
799
800 @anchor{aresample}
801 @section aresample
802
803 Resample the input audio to the specified parameters, using the
804 libswresample library. If none are specified then the filter will
805 automatically convert between its input and output.
806
807 This filter is also able to stretch/squeeze the audio data to make it match
808 the timestamps or to inject silence / cut out audio to make it match the
809 timestamps, do a combination of both or do neither.
810
811 The filter accepts the syntax
812 [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
813 expresses a sample rate and @var{resampler_options} is a list of
814 @var{key}=@var{value} pairs, separated by ":". See the
815 ffmpeg-resampler manual for the complete list of supported options.
816
817 @subsection Examples
818
819 @itemize
820 @item
821 Resample the input audio to 44100Hz:
822 @example
823 aresample=44100
824 @end example
825
826 @item
827 Stretch/squeeze samples to the given timestamps, with a maximum of 1000
828 samples per second compensation:
829 @example
830 aresample=async=1000
831 @end example
832 @end itemize
833
834 @section asetnsamples
835
836 Set the number of samples per each output audio frame.
837
838 The last output packet may contain a different number of samples, as
839 the filter will flush all the remaining samples when the input audio
840 signal its end.
841
842 The filter accepts the following options:
843
844 @table @option
845
846 @item nb_out_samples, n
847 Set the number of frames per each output audio frame. The number is
848 intended as the number of samples @emph{per each channel}.
849 Default value is 1024.
850
851 @item pad, p
852 If set to 1, the filter will pad the last audio frame with zeroes, so
853 that the last frame will contain the same number of samples as the
854 previous ones. Default value is 1.
855 @end table
856
857 For example, to set the number of per-frame samples to 1234 and
858 disable padding for the last frame, use:
859 @example
860 asetnsamples=n=1234:p=0
861 @end example
862
863 @section asetrate
864
865 Set the sample rate without altering the PCM data.
866 This will result in a change of speed and pitch.
867
868 The filter accepts the following options:
869
870 @table @option
871 @item sample_rate, r
872 Set the output sample rate. Default is 44100 Hz.
873 @end table
874
875 @section ashowinfo
876
877 Show a line containing various information for each input audio frame.
878 The input audio is not modified.
879
880 The shown line contains a sequence of key/value pairs of the form
881 @var{key}:@var{value}.
882
883 The following values are shown in the output:
884
885 @table @option
886 @item n
887 The (sequential) number of the input frame, starting from 0.
888
889 @item pts
890 The presentation timestamp of the input frame, in time base units; the time base
891 depends on the filter input pad, and is usually 1/@var{sample_rate}.
892
893 @item pts_time
894 The presentation timestamp of the input frame in seconds.
895
896 @item pos
897 position of the frame in the input stream, -1 if this information in
898 unavailable and/or meaningless (for example in case of synthetic audio)
899
900 @item fmt
901 The sample format.
902
903 @item chlayout
904 The channel layout.
905
906 @item rate
907 The sample rate for the audio frame.
908
909 @item nb_samples
910 The number of samples (per channel) in the frame.
911
912 @item checksum
913 The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
914 audio, the data is treated as if all the planes were concatenated.
915
916 @item plane_checksums
917 A list of Adler-32 checksums for each data plane.
918 @end table
919
920 @anchor{astats}
921 @section astats
922
923 Display time domain statistical information about the audio channels.
924 Statistics are calculated and displayed for each audio channel and,
925 where applicable, an overall figure is also given.
926
927 It accepts the following option:
928 @table @option
929 @item length
930 Short window length in seconds, used for peak and trough RMS measurement.
931 Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.1 - 10]}.
932 @end table
933
934 A description of each shown parameter follows:
935
936 @table @option
937 @item DC offset
938 Mean amplitude displacement from zero.
939
940 @item Min level
941 Minimal sample level.
942
943 @item Max level
944 Maximal sample level.
945
946 @item Peak level dB
947 @item RMS level dB
948 Standard peak and RMS level measured in dBFS.
949
950 @item RMS peak dB
951 @item RMS trough dB
952 Peak and trough values for RMS level measured over a short window.
953
954 @item Crest factor
955 Standard ratio of peak to RMS level (note: not in dB).
956
957 @item Flat factor
958 Flatness (i.e. consecutive samples with the same value) of the signal at its peak levels
959 (i.e. either @var{Min level} or @var{Max level}).
960
961 @item Peak count
962 Number of occasions (not the number of samples) that the signal attained either
963 @var{Min level} or @var{Max level}.
964 @end table
965
966 @section astreamsync
967
968 Forward two audio streams and control the order the buffers are forwarded.
969
970 The filter accepts the following options:
971
972 @table @option
973 @item expr, e
974 Set the expression deciding which stream should be
975 forwarded next: if the result is negative, the first stream is forwarded; if
976 the result is positive or zero, the second stream is forwarded. It can use
977 the following variables:
978
979 @table @var
980 @item b1 b2
981 number of buffers forwarded so far on each stream
982 @item s1 s2
983 number of samples forwarded so far on each stream
984 @item t1 t2
985 current timestamp of each stream
986 @end table
987
988 The default value is @code{t1-t2}, which means to always forward the stream
989 that has a smaller timestamp.
990 @end table
991
992 @subsection Examples
993
994 Stress-test @code{amerge} by randomly sending buffers on the wrong
995 input, while avoiding too much of a desynchronization:
996 @example
997 amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
998 [a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
999 [a2] [b2] amerge
1000 @end example
1001
1002 @section asyncts
1003
1004 Synchronize audio data with timestamps by squeezing/stretching it and/or
1005 dropping samples/adding silence when needed.
1006
1007 This filter is not built by default, please use @ref{aresample} to do squeezing/stretching.
1008
1009 It accepts the following parameters:
1010 @table @option
1011
1012 @item compensate
1013 Enable stretching/squeezing the data to make it match the timestamps. Disabled
1014 by default. When disabled, time gaps are covered with silence.
1015
1016 @item min_delta
1017 The minimum difference between timestamps and audio data (in seconds) to trigger
1018 adding/dropping samples. The default value is 0.1. If you get an imperfect
1019 sync with this filter, try setting this parameter to 0.
1020
1021 @item max_comp
1022 The maximum compensation in samples per second. Only relevant with compensate=1.
1023 The default value is 500.
1024
1025 @item first_pts
1026 Assume that the first PTS should be this value. The time base is 1 / sample
1027 rate. This allows for padding/trimming at the start of the stream. By default,
1028 no assumption is made about the first frame's expected PTS, so no padding or
1029 trimming is done. For example, this could be set to 0 to pad the beginning with
1030 silence if an audio stream starts after the video stream or to trim any samples
1031 with a negative PTS due to encoder delay.
1032
1033 @end table
1034
1035 @section atempo
1036
1037 Adjust audio tempo.
1038
1039 The filter accepts exactly one parameter, the audio tempo. If not
1040 specified then the filter will assume nominal 1.0 tempo. Tempo must
1041 be in the [0.5, 2.0] range.
1042
1043 @subsection Examples
1044
1045 @itemize
1046 @item
1047 Slow down audio to 80% tempo:
1048 @example
1049 atempo=0.8
1050 @end example
1051
1052 @item
1053 To speed up audio to 125% tempo:
1054 @example
1055 atempo=1.25
1056 @end example
1057 @end itemize
1058
1059 @section atrim
1060
1061 Trim the input so that the output contains one continuous subpart of the input.
1062
1063 It accepts the following parameters:
1064 @table @option
1065 @item start
1066 Timestamp (in seconds) of the start of the section to keep. I.e. the audio
1067 sample with the timestamp @var{start} will be the first sample in the output.
1068
1069 @item end
1070 Specify time of the first audio sample that will be dropped, i.e. the
1071 audio sample immediately preceding the one with the timestamp @var{end} will be
1072 the last sample in the output.
1073
1074 @item start_pts
1075 Same as @var{start}, except this option sets the start timestamp in samples
1076 instead of seconds.
1077
1078 @item end_pts
1079 Same as @var{end}, except this option sets the end timestamp in samples instead
1080 of seconds.
1081
1082 @item duration
1083 The maximum duration of the output in seconds.
1084
1085 @item start_sample
1086 The number of the first sample that should be output.
1087
1088 @item end_sample
1089 The number of the first sample that should be dropped.
1090 @end table
1091
1092 @option{start}, @option{end}, and @option{duration} are expressed as time
1093 duration specifications; see
1094 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
1095
1096 Note that the first two sets of the start/end options and the @option{duration}
1097 option look at the frame timestamp, while the _sample options simply count the
1098 samples that pass through the filter. So start/end_pts and start/end_sample will
1099 give different results when the timestamps are wrong, inexact or do not start at
1100 zero. Also note that this filter does not modify the timestamps. If you wish
1101 to have the output timestamps start at zero, insert the asetpts filter after the
1102 atrim filter.
1103
1104 If multiple start or end options are set, this filter tries to be greedy and
1105 keep all samples that match at least one of the specified constraints. To keep
1106 only the part that matches all the constraints at once, chain multiple atrim
1107 filters.
1108
1109 The defaults are such that all the input is kept. So it is possible to set e.g.
1110 just the end values to keep everything before the specified time.
1111
1112 Examples:
1113 @itemize
1114 @item
1115 Drop everything except the second minute of input:
1116 @example
1117 ffmpeg -i INPUT -af atrim=60:120
1118 @end example
1119
1120 @item
1121 Keep only the first 1000 samples:
1122 @example
1123 ffmpeg -i INPUT -af atrim=end_sample=1000
1124 @end example
1125
1126 @end itemize
1127
1128 @section bandpass
1129
1130 Apply a two-pole Butterworth band-pass filter with central
1131 frequency @var{frequency}, and (3dB-point) band-width width.
1132 The @var{csg} option selects a constant skirt gain (peak gain = Q)
1133 instead of the default: constant 0dB peak gain.
1134 The filter roll off at 6dB per octave (20dB per decade).
1135
1136 The filter accepts the following options:
1137
1138 @table @option
1139 @item frequency, f
1140 Set the filter's central frequency. Default is @code{3000}.
1141
1142 @item csg
1143 Constant skirt gain if set to 1. Defaults to 0.
1144
1145 @item width_type
1146 Set method to specify band-width of filter.
1147 @table @option
1148 @item h
1149 Hz
1150 @item q
1151 Q-Factor
1152 @item o
1153 octave
1154 @item s
1155 slope
1156 @end table
1157
1158 @item width, w
1159 Specify the band-width of a filter in width_type units.
1160 @end table
1161
1162 @section bandreject
1163
1164 Apply a two-pole Butterworth band-reject filter with central
1165 frequency @var{frequency}, and (3dB-point) band-width @var{width}.
1166 The filter roll off at 6dB per octave (20dB per decade).
1167
1168 The filter accepts the following options:
1169
1170 @table @option
1171 @item frequency, f
1172 Set the filter's central frequency. Default is @code{3000}.
1173
1174 @item width_type
1175 Set method to specify band-width of filter.
1176 @table @option
1177 @item h
1178 Hz
1179 @item q
1180 Q-Factor
1181 @item o
1182 octave
1183 @item s
1184 slope
1185 @end table
1186
1187 @item width, w
1188 Specify the band-width of a filter in width_type units.
1189 @end table
1190
1191 @section bass
1192
1193 Boost or cut the bass (lower) frequencies of the audio using a two-pole
1194 shelving filter with a response similar to that of a standard
1195 hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
1196
1197 The filter accepts the following options:
1198
1199 @table @option
1200 @item gain, g
1201 Give the gain at 0 Hz. Its useful range is about -20
1202 (for a large cut) to +20 (for a large boost).
1203 Beware of clipping when using a positive gain.
1204
1205 @item frequency, f
1206 Set the filter's central frequency and so can be used
1207 to extend or reduce the frequency range to be boosted or cut.
1208 The default value is @code{100} Hz.
1209
1210 @item width_type
1211 Set method to specify band-width of filter.
1212 @table @option
1213 @item h
1214 Hz
1215 @item q
1216 Q-Factor
1217 @item o
1218 octave
1219 @item s
1220 slope
1221 @end table
1222
1223 @item width, w
1224 Determine how steep is the filter's shelf transition.
1225 @end table
1226
1227 @section biquad
1228
1229 Apply a biquad IIR filter with the given coefficients.
1230 Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
1231 are the numerator and denominator coefficients respectively.
1232
1233 @section bs2b
1234 Bauer stereo to binaural transformation, which improves headphone listening of
1235 stereo audio records.
1236
1237 It accepts the following parameters:
1238 @table @option
1239
1240 @item profile
1241 Pre-defined crossfeed level.
1242 @table @option
1243
1244 @item default
1245 Default level (fcut=700, feed=50).
1246
1247 @item cmoy
1248 Chu Moy circuit (fcut=700, feed=60).
1249
1250 @item jmeier
1251 Jan Meier circuit (fcut=650, feed=95).
1252
1253 @end table
1254
1255 @item fcut
1256 Cut frequency (in Hz).
1257
1258 @item feed
1259 Feed level (in Hz).
1260
1261 @end table
1262
1263 @section channelmap
1264
1265 Remap input channels to new locations.
1266
1267 It accepts the following parameters:
1268 @table @option
1269 @item channel_layout
1270 The channel layout of the output stream.
1271
1272 @item map
1273 Map channels from input to output. The argument is a '|'-separated list of
1274 mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
1275 @var{in_channel} form. @var{in_channel} can be either the name of the input
1276 channel (e.g. FL for front left) or its index in the input channel layout.
1277 @var{out_channel} is the name of the output channel or its index in the output
1278 channel layout. If @var{out_channel} is not given then it is implicitly an
1279 index, starting with zero and increasing by one for each mapping.
1280 @end table
1281
1282 If no mapping is present, the filter will implicitly map input channels to
1283 output channels, preserving indices.
1284
1285 For example, assuming a 5.1+downmix input MOV file,
1286 @example
1287 ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
1288 @end example
1289 will create an output WAV file tagged as stereo from the downmix channels of
1290 the input.
1291
1292 To fix a 5.1 WAV improperly encoded in AAC's native channel order
1293 @example
1294 ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:channel_layout=5.1' out.wav
1295 @end example
1296
1297 @section channelsplit
1298
1299 Split each channel from an input audio stream into a separate output stream.
1300
1301 It accepts the following parameters:
1302 @table @option
1303 @item channel_layout
1304 The channel layout of the input stream. The default is "stereo".
1305 @end table
1306
1307 For example, assuming a stereo input MP3 file,
1308 @example
1309 ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
1310 @end example
1311 will create an output Matroska file with two audio streams, one containing only
1312 the left channel and the other the right channel.
1313
1314 Split a 5.1 WAV file into per-channel files:
1315 @example
1316 ffmpeg -i in.wav -filter_complex
1317 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
1318 -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
1319 front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
1320 side_right.wav
1321 @end example
1322
1323 @section chorus
1324 Add a chorus effect to the audio.
1325
1326 Can make a single vocal sound like a chorus, but can also be applied to instrumentation.
1327
1328 Chorus resembles an echo effect with a short delay, but whereas with echo the delay is
1329 constant, with chorus, it is varied using using sinusoidal or triangular modulation.
1330 The modulation depth defines the range the modulated delay is played before or after
1331 the delay. Hence the delayed sound will sound slower or faster, that is the delayed
1332 sound tuned around the original one, like in a chorus where some vocals are slightly
1333 off key.
1334
1335 It accepts the following parameters:
1336 @table @option
1337 @item in_gain
1338 Set input gain. Default is 0.4.
1339
1340 @item out_gain
1341 Set output gain. Default is 0.4.
1342
1343 @item delays
1344 Set delays. A typical delay is around 40ms to 60ms.
1345
1346 @item decays
1347 Set decays.
1348
1349 @item speeds
1350 Set speeds.
1351
1352 @item depths
1353 Set depths.
1354 @end table
1355
1356 @subsection Examples
1357
1358 @itemize
1359 @item
1360 A single delay:
1361 @example
1362 chorus=0.7:0.9:55:0.4:0.25:2
1363 @end example
1364
1365 @item
1366 Two delays:
1367 @example
1368 chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3
1369 @end example
1370
1371 @item
1372 Fuller sounding chorus with three delays:
1373 @example
1374 chorus=0.5:0.9:50|60|40:0.4|0.32|0.3:0.25|0.4|0.3:2|2.3|1.3
1375 @end example
1376 @end itemize
1377
1378 @section compand
1379 Compress or expand the audio's dynamic range.
1380
1381 It accepts the following parameters:
1382
1383 @table @option
1384
1385 @item attacks
1386 @item decays
1387 A list of times in seconds for each channel over which the instantaneous level
1388 of the input signal is averaged to determine its volume. @var{attacks} refers to
1389 increase of volume and @var{decays} refers to decrease of volume. For most
1390 situations, the attack time (response to the audio getting louder) should be
1391 shorter than the decay time, because the human ear is more sensitive to sudden
1392 loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
1393 a typical value for decay is 0.8 seconds.
1394
1395 @item points
1396 A list of points for the transfer function, specified in dB relative to the
1397 maximum possible signal amplitude. Each key points list must be defined using
1398 the following syntax: @code{x0/y0|x1/y1|x2/y2|....} or
1399 @code{x0/y0 x1/y1 x2/y2 ....}
1400
1401 The input values must be in strictly increasing order but the transfer function
1402 does not have to be monotonically rising. The point @code{0/0} is assumed but
1403 may be overridden (by @code{0/out-dBn}). Typical values for the transfer
1404 function are @code{-70/-70|-60/-20}.
1405
1406 @item soft-knee
1407 Set the curve radius in dB for all joints. It defaults to 0.01.
1408
1409 @item gain
1410 Set the additional gain in dB to be applied at all points on the transfer
1411 function. This allows for easy adjustment of the overall gain.
1412 It defaults to 0.
1413
1414 @item volume
1415 Set an initial volume, in dB, to be assumed for each channel when filtering
1416 starts. This permits the user to supply a nominal level initially, so that, for
1417 example, a very large gain is not applied to initial signal levels before the
1418 companding has begun to operate. A typical value for audio which is initially
1419 quiet is -90 dB. It defaults to 0.
1420
1421 @item delay
1422 Set a delay, in seconds. The input audio is analyzed immediately, but audio is
1423 delayed before being fed to the volume adjuster. Specifying a delay
1424 approximately equal to the attack/decay times allows the filter to effectively
1425 operate in predictive rather than reactive mode. It defaults to 0.
1426
1427 @end table
1428
1429 @subsection Examples
1430
1431 @itemize
1432 @item
1433 Make music with both quiet and loud passages suitable for listening to in a
1434 noisy environment:
1435 @example
1436 compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
1437 @end example
1438
1439 @item
1440 A noise gate for when the noise is at a lower level than the signal:
1441 @example
1442 compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
1443 @end example
1444
1445 @item
1446 Here is another noise gate, this time for when the noise is at a higher level
1447 than the signal (making it, in some ways, similar to squelch):
1448 @example
1449 compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
1450 @end example
1451 @end itemize
1452
1453 @section dcshift
1454 Apply a DC shift to the audio.
1455
1456 This can be useful to remove a DC offset (caused perhaps by a hardware problem
1457 in the recording chain) from the audio. The effect of a DC offset is reduced
1458 headroom and hence volume. The @ref{astats} filter can be used to determine if
1459 a signal has a DC offset.
1460
1461 @table @option
1462 @item shift
1463 Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift
1464 the audio.
1465
1466 @item limitergain
1467 Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
1468 used to prevent clipping.
1469 @end table
1470
1471 @section earwax
1472
1473 Make audio easier to listen to on headphones.
1474
1475 This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
1476 so that when listened to on headphones the stereo image is moved from
1477 inside your head (standard for headphones) to outside and in front of
1478 the listener (standard for speakers).
1479
1480 Ported from SoX.
1481
1482 @section equalizer
1483
1484 Apply a two-pole peaking equalisation (EQ) filter. With this
1485 filter, the signal-level at and around a selected frequency can
1486 be increased or decreased, whilst (unlike bandpass and bandreject
1487 filters) that at all other frequencies is unchanged.
1488
1489 In order to produce complex equalisation curves, this filter can
1490 be given several times, each with a different central frequency.
1491
1492 The filter accepts the following options:
1493
1494 @table @option
1495 @item frequency, f
1496 Set the filter's central frequency in Hz.
1497
1498 @item width_type
1499 Set method to specify band-width of filter.
1500 @table @option
1501 @item h
1502 Hz
1503 @item q
1504 Q-Factor
1505 @item o
1506 octave
1507 @item s
1508 slope
1509 @end table
1510
1511 @item width, w
1512 Specify the band-width of a filter in width_type units.
1513
1514 @item gain, g
1515 Set the required gain or attenuation in dB.
1516 Beware of clipping when using a positive gain.
1517 @end table
1518
1519 @subsection Examples
1520 @itemize
1521 @item
1522 Attenuate 10 dB at 1000 Hz, with a bandwidth of 200 Hz:
1523 @example
1524 equalizer=f=1000:width_type=h:width=200:g=-10
1525 @end example
1526
1527 @item
1528 Apply 2 dB gain at 1000 Hz with Q 1 and attenuate 5 dB at 100 Hz with Q 2:
1529 @example
1530 equalizer=f=1000:width_type=q:width=1:g=2,equalizer=f=100:width_type=q:width=2:g=-5
1531 @end example
1532 @end itemize
1533
1534 @section flanger
1535 Apply a flanging effect to the audio.
1536
1537 The filter accepts the following options:
1538
1539 @table @option
1540 @item delay
1541 Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
1542
1543 @item depth
1544 Set added swep delay in milliseconds. Range from 0 to 10. Default value is 2.
1545
1546 @item regen
1547 Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
1548 Default value is 0.
1549
1550 @item width
1551 Set percentage of delayed signal mixed with original. Range from 0 to 100.
1552 Default value is 71.
1553
1554 @item speed
1555 Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
1556
1557 @item shape
1558 Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
1559 Default value is @var{sinusoidal}.
1560
1561 @item phase
1562 Set swept wave percentage-shift for multi channel. Range from 0 to 100.
1563 Default value is 25.
1564
1565 @item interp
1566 Set delay-line interpolation, @var{linear} or @var{quadratic}.
1567 Default is @var{linear}.
1568 @end table
1569
1570 @section highpass
1571
1572 Apply a high-pass filter with 3dB point frequency.
1573 The filter can be either single-pole, or double-pole (the default).
1574 The filter roll off at 6dB per pole per octave (20dB per pole per decade).
1575
1576 The filter accepts the following options:
1577
1578 @table @option
1579 @item frequency, f
1580 Set frequency in Hz. Default is 3000.
1581
1582 @item poles, p
1583 Set number of poles. Default is 2.
1584
1585 @item width_type
1586 Set method to specify band-width of filter.
1587 @table @option
1588 @item h
1589 Hz
1590 @item q
1591 Q-Factor
1592 @item o
1593 octave
1594 @item s
1595 slope
1596 @end table
1597
1598 @item width, w
1599 Specify the band-width of a filter in width_type units.
1600 Applies only to double-pole filter.
1601 The default is 0.707q and gives a Butterworth response.
1602 @end table
1603
1604 @section join
1605
1606 Join multiple input streams into one multi-channel stream.
1607
1608 It accepts the following parameters:
1609 @table @option
1610
1611 @item inputs
1612 The number of input streams. It defaults to 2.
1613
1614 @item channel_layout
1615 The desired output channel layout. It defaults to stereo.
1616
1617 @item map
1618 Map channels from inputs to output. The argument is a '|'-separated list of
1619 mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
1620 form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
1621 can be either the name of the input channel (e.g. FL for front left) or its
1622 index in the specified input stream. @var{out_channel} is the name of the output
1623 channel.
1624 @end table
1625
1626 The filter will attempt to guess the mappings when they are not specified
1627 explicitly. It does so by first trying to find an unused matching input channel
1628 and if that fails it picks the first unused input channel.
1629
1630 Join 3 inputs (with properly set channel layouts):
1631 @example
1632 ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
1633 @end example
1634
1635 Build a 5.1 output from 6 single-channel streams:
1636 @example
1637 ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
1638 'join=inputs=6:channel_layout=5.1:map=0.0-FL|1.0-FR|2.0-FC|3.0-SL|4.0-SR|5.0-LFE'
1639 out
1640 @end example
1641
1642 @section ladspa
1643
1644 Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
1645
1646 To enable compilation of this filter you need to configure FFmpeg with
1647 @code{--enable-ladspa}.
1648
1649 @table @option
1650 @item file, f
1651 Specifies the name of LADSPA plugin library to load. If the environment
1652 variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
1653 each one of the directories specified by the colon separated list in
1654 @env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
1655 this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
1656 @file{/usr/lib/ladspa/}.
1657
1658 @item plugin, p
1659 Specifies the plugin within the library. Some libraries contain only
1660 one plugin, but others contain many of them. If this is not set filter
1661 will list all available plugins within the specified library.
1662
1663 @item controls, c
1664 Set the '|' separated list of controls which are zero or more floating point
1665 values that determine the behavior of the loaded plugin (for example delay,
1666 threshold or gain).
1667 Controls need to be defined using the following syntax:
1668 c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
1669 @var{valuei} is the value set on the @var{i}-th control.
1670 If @option{controls} is set to @code{help}, all available controls and
1671 their valid ranges are printed.
1672
1673 @item sample_rate, s
1674 Specify the sample rate, default to 44100. Only used if plugin have
1675 zero inputs.
1676
1677 @item nb_samples, n
1678 Set the number of samples per channel per each output frame, default
1679 is 1024. Only used if plugin have zero inputs.
1680
1681 @item duration, d
1682 Set the minimum duration of the sourced audio. See
1683 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
1684 for the accepted syntax.
1685 Note that the resulting duration may be greater than the specified duration,
1686 as the generated audio is always cut at the end of a complete frame.
1687 If not specified, or the expressed duration is negative, the audio is
1688 supposed to be generated forever.
1689 Only used if plugin have zero inputs.
1690
1691 @end table
1692
1693 @subsection Examples
1694
1695 @itemize
1696 @item
1697 List all available plugins within amp (LADSPA example plugin) library:
1698 @example
1699 ladspa=file=amp
1700 @end example
1701
1702 @item
1703 List all available controls and their valid ranges for @code{vcf_notch}
1704 plugin from @code{VCF} library:
1705 @example
1706 ladspa=f=vcf:p=vcf_notch:c=help
1707 @end example
1708
1709 @item
1710 Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
1711 plugin library:
1712 @example
1713 ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
1714 @end example
1715
1716 @item
1717 Add reverberation to the audio using TAP-plugins
1718 (Tom's Audio Processing plugins):
1719 @example
1720 ladspa=file=tap_reverb:tap_reverb
1721 @end example
1722
1723 @item
1724 Generate white noise, with 0.2 amplitude:
1725 @example
1726 ladspa=file=cmt:noise_source_white:c=c0=.2
1727 @end example
1728
1729 @item
1730 Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
1731 @code{C* Audio Plugin Suite} (CAPS) library:
1732 @example
1733 ladspa=file=caps:Click:c=c1=20'
1734 @end example
1735
1736 @item
1737 Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
1738 @example
1739 ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
1740 @end example
1741 @end itemize
1742
1743 @subsection Commands
1744
1745 This filter supports the following commands:
1746 @table @option
1747 @item cN
1748 Modify the @var{N}-th control value.
1749
1750 If the specified value is not valid, it is ignored and prior one is kept.
1751 @end table
1752
1753 @section lowpass
1754
1755 Apply a low-pass filter with 3dB point frequency.
1756 The filter can be either single-pole or double-pole (the default).
1757 The filter roll off at 6dB per pole per octave (20dB per pole per decade).
1758
1759 The filter accepts the following options:
1760
1761 @table @option
1762 @item frequency, f
1763 Set frequency in Hz. Default is 500.
1764
1765 @item poles, p
1766 Set number of poles. Default is 2.
1767
1768 @item width_type
1769 Set method to specify band-width of filter.
1770 @table @option
1771 @item h
1772 Hz
1773 @item q
1774 Q-Factor
1775 @item o
1776 octave
1777 @item s
1778 slope
1779 @end table
1780
1781 @item width, w
1782 Specify the band-width of a filter in width_type units.
1783 Applies only to double-pole filter.
1784 The default is 0.707q and gives a Butterworth response.
1785 @end table
1786
1787 @section pan
1788
1789 Mix channels with specific gain levels. The filter accepts the output
1790 channel layout followed by a set of channels definitions.
1791
1792 This filter is also designed to efficiently remap the channels of an audio
1793 stream.
1794
1795 The filter accepts parameters of the form:
1796 "@var{l}|@var{outdef}|@var{outdef}|..."
1797
1798 @table @option
1799 @item l
1800 output channel layout or number of channels
1801
1802 @item outdef
1803 output channel specification, of the form:
1804 "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
1805
1806 @item out_name
1807 output channel to define, either a channel name (FL, FR, etc.) or a channel
1808 number (c0, c1, etc.)
1809
1810 @item gain
1811 multiplicative coefficient for the channel, 1 leaving the volume unchanged
1812
1813 @item in_name
1814 input channel to use, see out_name for details; it is not possible to mix
1815 named and numbered input channels
1816 @end table
1817
1818 If the `=' in a channel specification is replaced by `<', then the gains for
1819 that specification will be renormalized so that the total is 1, thus
1820 avoiding clipping noise.
1821
1822 @subsection Mixing examples
1823
1824 For example, if you want to down-mix from stereo to mono, but with a bigger
1825 factor for the left channel:
1826 @example
1827 pan=1c|c0=0.9*c0+0.1*c1
1828 @end example
1829
1830 A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
1831 7-channels surround:
1832 @example
1833 pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
1834 @end example
1835
1836 Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
1837 that should be preferred (see "-ac" option) unless you have very specific
1838 needs.
1839
1840 @subsection Remapping examples
1841
1842 The channel remapping will be effective if, and only if:
1843
1844 @itemize
1845 @item gain coefficients are zeroes or ones,
1846 @item only one input per channel output,
1847 @end itemize
1848
1849 If all these conditions are satisfied, the filter will notify the user ("Pure
1850 channel mapping detected"), and use an optimized and lossless method to do the
1851 remapping.
1852
1853 For example, if you have a 5.1 source and want a stereo audio stream by
1854 dropping the extra channels:
1855 @example
1856 pan="stereo| c0=FL | c1=FR"
1857 @end example
1858
1859 Given the same source, you can also switch front left and front right channels
1860 and keep the input channel layout:
1861 @example
1862 pan="5.1| c0=c1 | c1=c0 | c2=c2 | c3=c3 | c4=c4 | c5=c5"
1863 @end example
1864
1865 If the input is a stereo audio stream, you can mute the front left channel (and
1866 still keep the stereo channel layout) with:
1867 @example
1868 pan="stereo|c1=c1"
1869 @end example
1870
1871 Still with a stereo audio stream input, you can copy the right channel in both
1872 front left and right:
1873 @example
1874 pan="stereo| c0=FR | c1=FR"
1875 @end example
1876
1877 @section replaygain
1878
1879 ReplayGain scanner filter. This filter takes an audio stream as an input and
1880 outputs it unchanged.
1881 At end of filtering it displays @code{track_gain} and @code{track_peak}.
1882
1883 @section resample
1884
1885 Convert the audio sample format, sample rate and channel layout. It is
1886 not meant to be used directly.
1887
1888 @section silencedetect
1889
1890 Detect silence in an audio stream.
1891
1892 This filter logs a message when it detects that the input audio volume is less
1893 or equal to a noise tolerance value for a duration greater or equal to the
1894 minimum detected noise duration.
1895
1896 The printed times and duration are expressed in seconds.
1897
1898 The filter accepts the following options:
1899
1900 @table @option
1901 @item duration, d
1902 Set silence duration until notification (default is 2 seconds).
1903
1904 @item noise, n
1905 Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
1906 specified value) or amplitude ratio. Default is -60dB, or 0.001.
1907 @end table
1908
1909 @subsection Examples
1910
1911 @itemize
1912 @item
1913 Detect 5 seconds of silence with -50dB noise tolerance:
1914 @example
1915 silencedetect=n=-50dB:d=5
1916 @end example
1917
1918 @item
1919 Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
1920 tolerance in @file{silence.mp3}:
1921 @example
1922 ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
1923 @end example
1924 @end itemize
1925
1926 @section silenceremove
1927
1928 Remove silence from the beginning, middle or end of the audio.
1929
1930 The filter accepts the following options:
1931
1932 @table @option
1933 @item start_periods
1934 This value is used to indicate if audio should be trimmed at beginning of
1935 the audio. A value of zero indicates no silence should be trimmed from the
1936 beginning. When specifying a non-zero value, it trims audio up until it
1937 finds non-silence. Normally, when trimming silence from beginning of audio
1938 the @var{start_periods} will be @code{1} but it can be increased to higher
1939 values to trim all audio up to specific count of non-silence periods.
1940 Default value is @code{0}.
1941
1942 @item start_duration
1943 Specify the amount of time that non-silence must be detected before it stops
1944 trimming audio. By increasing the duration, bursts of noises can be treated
1945 as silence and trimmed off. Default value is @code{0}.
1946
1947 @item start_threshold
1948 This indicates what sample value should be treated as silence. For digital
1949 audio, a value of @code{0} may be fine but for audio recorded from analog,
1950 you may wish to increase the value to account for background noise.
1951 Can be specified in dB (in case "dB" is appended to the specified value)
1952 or amplitude ratio. Default value is @code{0}.
1953
1954 @item stop_periods
1955 Set the count for trimming silence from the end of audio.
1956 To remove silence from the middle of a file, specify a @var{stop_periods}
1957 that is negative. This value is then treated as a positive value and is
1958 used to indicate the effect should restart processing as specified by
1959 @var{start_periods}, making it suitable for removing periods of silence
1960 in the middle of the audio.
1961 Default value is @code{0}.
1962
1963 @item stop_duration
1964 Specify a duration of silence that must exist before audio is not copied any
1965 more. By specifying a higher duration, silence that is wanted can be left in
1966 the audio.
1967 Default value is @code{0}.
1968
1969 @item stop_threshold
1970 This is the same as @option{start_threshold} but for trimming silence from
1971 the end of audio.
1972 Can be specified in dB (in case "dB" is appended to the specified value)
1973 or amplitude ratio. Default value is @code{0}.
1974
1975 @item leave_silence
1976 This indicate that @var{stop_duration} length of audio should be left intact
1977 at the beginning of each period of silence.
1978 For example, if you want to remove long pauses between words but do not want
1979 to remove the pauses completely. Default value is @code{0}.
1980
1981 @end table
1982
1983 @subsection Examples
1984
1985 @itemize
1986 @item
1987 The following example shows how this filter can be used to start a recording
1988 that does not contain the delay at the start which usually occurs between
1989 pressing the record button and the start of the performance:
1990 @example
1991 silenceremove=1:5:0.02
1992 @end example
1993 @end itemize
1994
1995 @section treble
1996
1997 Boost or cut treble (upper) frequencies of the audio using a two-pole
1998 shelving filter with a response similar to that of a standard
1999 hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
2000
2001 The filter accepts the following options:
2002
2003 @table @option
2004 @item gain, g
2005 Give the gain at whichever is the lower of ~22 kHz and the
2006 Nyquist frequency. Its useful range is about -20 (for a large cut)
2007 to +20 (for a large boost). Beware of clipping when using a positive gain.
2008
2009 @item frequency, f
2010 Set the filter's central frequency and so can be used
2011 to extend or reduce the frequency range to be boosted or cut.
2012 The default value is @code{3000} Hz.
2013
2014 @item width_type
2015 Set method to specify band-width of filter.
2016 @table @option
2017 @item h
2018 Hz
2019 @item q
2020 Q-Factor
2021 @item o
2022 octave
2023 @item s
2024 slope
2025 @end table
2026
2027 @item width, w
2028 Determine how steep is the filter's shelf transition.
2029 @end table
2030
2031 @section volume
2032
2033 Adjust the input audio volume.
2034
2035 It accepts the following parameters:
2036 @table @option
2037
2038 @item volume
2039 Set audio volume expression.
2040
2041 Output values are clipped to the maximum value.
2042
2043 The output audio volume is given by the relation:
2044 @example
2045 @var{output_volume} = @var{volume} * @var{input_volume}
2046 @end example
2047
2048 The default value for @var{volume} is "1.0".
2049
2050 @item precision
2051 This parameter represents the mathematical precision.
2052
2053 It determines which input sample formats will be allowed, which affects the
2054 precision of the volume scaling.
2055
2056 @table @option
2057 @item fixed
2058 8-bit fixed-point; this limits input sample format to U8, S16, and S32.
2059 @item float
2060 32-bit floating-point; this limits input sample format to FLT. (default)
2061 @item double
2062 64-bit floating-point; this limits input sample format to DBL.
2063 @end table
2064
2065 @item replaygain
2066 Choose the behaviour on encountering ReplayGain side data in input frames.
2067
2068 @table @option
2069 @item drop
2070 Remove ReplayGain side data, ignoring its contents (the default).
2071
2072 @item ignore
2073 Ignore ReplayGain side data, but leave it in the frame.
2074
2075 @item track
2076 Prefer the track gain, if present.
2077
2078 @item album
2079 Prefer the album gain, if present.
2080 @end table
2081
2082 @item replaygain_preamp
2083 Pre-amplification gain in dB to apply to the selected replaygain gain.
2084
2085 Default value for @var{replaygain_preamp} is 0.0.
2086
2087 @item eval
2088 Set when the volume expression is evaluated.
2089
2090 It accepts the following values:
2091 @table @samp
2092 @item once
2093 only evaluate expression once during the filter initialization, or
2094 when the @samp{volume} command is sent
2095
2096 @item frame
2097 evaluate expression for each incoming frame
2098 @end table
2099
2100 Default value is @samp{once}.
2101 @end table
2102
2103 The volume expression can contain the following parameters.
2104
2105 @table @option
2106 @item n
2107 frame number (starting at zero)
2108 @item nb_channels
2109 number of channels
2110 @item nb_consumed_samples
2111 number of samples consumed by the filter
2112 @item nb_samples
2113 number of samples in the current frame
2114 @item pos
2115 original frame position in the file
2116 @item pts
2117 frame PTS
2118 @item sample_rate
2119 sample rate
2120 @item startpts
2121 PTS at start of stream
2122 @item startt
2123 time at start of stream
2124 @item t
2125 frame time
2126 @item tb
2127 timestamp timebase
2128 @item volume
2129 last set volume value
2130 @end table
2131
2132 Note that when @option{eval} is set to @samp{once} only the
2133 @var{sample_rate} and @var{tb} variables are available, all other
2134 variables will evaluate to NAN.
2135
2136 @subsection Commands
2137
2138 This filter supports the following commands:
2139 @table @option
2140 @item volume
2141 Modify the volume expression.
2142 The command accepts the same syntax of the corresponding option.
2143
2144 If the specified expression is not valid, it is kept at its current
2145 value.
2146 @item replaygain_noclip
2147 Prevent clipping by limiting the gain applied.
2148
2149 Default value for @var{replaygain_noclip} is 1.
2150
2151 @end table
2152
2153 @subsection Examples
2154
2155 @itemize
2156 @item
2157 Halve the input audio volume:
2158 @example
2159 volume=volume=0.5
2160 volume=volume=1/2
2161 volume=volume=-6.0206dB
2162 @end example
2163
2164 In all the above example the named key for @option{volume} can be
2165 omitted, for example like in:
2166 @example
2167 volume=0.5
2168 @end example
2169
2170 @item
2171 Increase input audio power by 6 decibels using fixed-point precision:
2172 @example
2173 volume=volume=6dB:precision=fixed
2174 @end example
2175
2176 @item
2177 Fade volume after time 10 with an annihilation period of 5 seconds:
2178 @example
2179 volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
2180 @end example
2181 @end itemize
2182
2183 @section volumedetect
2184
2185 Detect the volume of the input video.
2186
2187 The filter has no parameters. The input is not modified. Statistics about
2188 the volume will be printed in the log when the input stream end is reached.
2189
2190 In particular it will show the mean volume (root mean square), maximum
2191 volume (on a per-sample basis), and the beginning of a histogram of the
2192 registered volume values (from the maximum value to a cumulated 1/1000 of
2193 the samples).
2194
2195 All volumes are in decibels relative to the maximum PCM value.
2196
2197 @subsection Examples
2198
2199 Here is an excerpt of the output:
2200 @example
2201 [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
2202 [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
2203 [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
2204 [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
2205 [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
2206 [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
2207 [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
2208 [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
2209 [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
2210 @end example
2211
2212 It means that:
2213 @itemize
2214 @item
2215 The mean square energy is approximately -27 dB, or 10^-2.7.
2216 @item
2217 The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
2218 @item
2219 There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
2220 @end itemize
2221
2222 In other words, raising the volume by +4 dB does not cause any clipping,
2223 raising it by +5 dB causes clipping for 6 samples, etc.
2224
2225 @c man end AUDIO FILTERS
2226
2227 @chapter Audio Sources
2228 @c man begin AUDIO SOURCES
2229
2230 Below is a description of the currently available audio sources.
2231
2232 @section abuffer
2233
2234 Buffer audio frames, and make them available to the filter chain.
2235
2236 This source is mainly intended for a programmatic use, in particular
2237 through the interface defined in @file{libavfilter/asrc_abuffer.h}.
2238
2239 It accepts the following parameters:
2240 @table @option
2241
2242 @item time_base
2243 The timebase which will be used for timestamps of submitted frames. It must be
2244 either a floating-point number or in @var{numerator}/@var{denominator} form.
2245
2246 @item sample_rate
2247 The sample rate of the incoming audio buffers.
2248
2249 @item sample_fmt
2250 The sample format of the incoming audio buffers.
2251 Either a sample format name or its corresponding integer representation from
2252 the enum AVSampleFormat in @file{libavutil/samplefmt.h}
2253
2254 @item channel_layout
2255 The channel layout of the incoming audio buffers.
2256 Either a channel layout name from channel_layout_map in
2257 @file{libavutil/channel_layout.c} or its corresponding integer representation
2258 from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
2259
2260 @item channels
2261 The number of channels of the incoming audio buffers.
2262 If both @var{channels} and @var{channel_layout} are specified, then they
2263 must be consistent.
2264
2265 @end table
2266
2267 @subsection Examples
2268
2269 @example
2270 abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
2271 @end example
2272
2273 will instruct the source to accept planar 16bit signed stereo at 44100Hz.
2274 Since the sample format with name "s16p" corresponds to the number
2275 6 and the "stereo" channel layout corresponds to the value 0x3, this is
2276 equivalent to:
2277 @example
2278 abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
2279 @end example
2280
2281 @section aevalsrc
2282
2283 Generate an audio signal specified by an expression.
2284
2285 This source accepts in input one or more expressions (one for each
2286 channel), which are evaluated and used to generate a corresponding
2287 audio signal.
2288
2289 This source accepts the following options:
2290
2291 @table @option
2292 @item exprs
2293 Set the '|'-separated expressions list for each separate channel. In case the
2294 @option{channel_layout} option is not specified, the selected channel layout
2295 depends on the number of provided expressions. Otherwise the last
2296 specified expression is applied to the remaining output channels.
2297
2298 @item channel_layout, c
2299 Set the channel layout. The number of channels in the specified layout
2300 must be equal to the number of specified expressions.
2301
2302 @item duration, d
2303 Set the minimum duration of the sourced audio. See
2304 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
2305 for the accepted syntax.
2306 Note that the resulting duration may be greater than the specified
2307 duration, as the generated audio is always cut at the end of a
2308 complete frame.
2309
2310 If not specified, or the expressed duration is negative, the audio is
2311 supposed to be generated forever.
2312
2313 @item nb_samples, n
2314 Set the number of samples per channel per each output frame,
2315 default to 1024.
2316
2317 @item sample_rate, s
2318 Specify the sample rate, default to 44100.
2319 @end table
2320
2321 Each expression in @var{exprs} can contain the following constants:
2322
2323 @table @option
2324 @item n
2325 number of the evaluated sample, starting from 0
2326
2327 @item t
2328 time of the evaluated sample expressed in seconds, starting from 0
2329
2330 @item s
2331 sample rate
2332
2333 @end table
2334
2335 @subsection Examples
2336
2337 @itemize
2338 @item
2339 Generate silence:
2340 @example
2341 aevalsrc=0
2342 @end example
2343
2344 @item
2345 Generate a sin signal with frequency of 440 Hz, set sample rate to
2346 8000 Hz:
2347 @example
2348 aevalsrc="sin(440*2*PI*t):s=8000"
2349 @end example
2350
2351 @item
2352 Generate a two channels signal, specify the channel layout (Front
2353 Center + Back Center) explicitly:
2354 @example
2355 aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
2356 @end example
2357
2358 @item
2359 Generate white noise:
2360 @example
2361 aevalsrc="-2+random(0)"
2362 @end example
2363
2364 @item
2365 Generate an amplitude modulated signal:
2366 @example
2367 aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
2368 @end example
2369
2370 @item
2371 Generate 2.5 Hz binaural beats on a 360 Hz carrier:
2372 @example
2373 aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
2374 @end example
2375
2376 @end itemize
2377
2378 @section anullsrc
2379
2380 The null audio source, return unprocessed audio frames. It is mainly useful
2381 as a template and to be employed in analysis / debugging tools, or as
2382 the source for filters which ignore the input data (for example the sox
2383 synth filter).
2384
2385 This source accepts the following options:
2386
2387 @table @option
2388
2389 @item channel_layout, cl
2390
2391 Specifies the channel layout, and can be either an integer or a string
2392 representing a channel layout. The default value of @var{channel_layout}
2393 is "stereo".
2394
2395 Check the channel_layout_map definition in
2396 @file{libavutil/channel_layout.c} for the mapping between strings and
2397 channel layout values.
2398
2399 @item sample_rate, r
2400 Specifies the sample rate, and defaults to 44100.
2401
2402 @item nb_samples, n
2403 Set the number of samples per requested frames.
2404
2405 @end table
2406
2407 @subsection Examples
2408
2409 @itemize
2410 @item
2411 Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
2412 @example
2413 anullsrc=r=48000:cl=4
2414 @end example
2415
2416 @item
2417 Do the same operation with a more obvious syntax:
2418 @example
2419 anullsrc=r=48000:cl=mono
2420 @end example
2421 @end itemize
2422
2423 All the parameters need to be explicitly defined.
2424
2425 @section flite
2426
2427 Synthesize a voice utterance using the libflite library.
2428
2429 To enable compilation of this filter you need to configure FFmpeg with
2430 @code{--enable-libflite}.
2431
2432 Note that the flite library is not thread-safe.
2433
2434 The filter accepts the following options:
2435
2436 @table @option
2437
2438 @item list_voices
2439 If set to 1, list the names of the available voices and exit
2440 immediately. Default value is 0.
2441
2442 @item nb_samples, n
2443 Set the maximum number of samples per frame. Default value is 512.
2444
2445 @item textfile
2446 Set the filename containing the text to speak.
2447
2448 @item text
2449 Set the text to speak.
2450
2451 @item voice, v
2452 Set the voice to use for the speech synthesis. Default value is
2453 @code{kal}. See also the @var{list_voices} option.
2454 @end table
2455
2456 @subsection Examples
2457
2458 @itemize
2459 @item
2460 Read from file @file{speech.txt}, and synthesize the text using the
2461 standard flite voice:
2462 @example
2463 flite=textfile=speech.txt
2464 @end example
2465
2466 @item
2467 Read the specified text selecting the @code{slt} voice:
2468 @example
2469 flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
2470 @end example
2471
2472 @item
2473 Input text to ffmpeg:
2474 @example
2475 ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
2476 @end example
2477
2478 @item
2479 Make @file{ffplay} speak the specified text, using @code{flite} and
2480 the @code{lavfi} device:
2481 @example
2482 ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
2483 @end example
2484 @end itemize
2485
2486 For more information about libflite, check:
2487 @url{http://www.speech.cs.cmu.edu/flite/}
2488
2489 @section sine
2490
2491 Generate an audio signal made of a sine wave with amplitude 1/8.
2492
2493 The audio signal is bit-exact.
2494
2495 The filter accepts the following options:
2496
2497 @table @option
2498
2499 @item frequency, f
2500 Set the carrier frequency. Default is 440 Hz.
2501
2502 @item beep_factor, b
2503 Enable a periodic beep every second with frequency @var{beep_factor} times
2504 the carrier frequency. Default is 0, meaning the beep is disabled.
2505
2506 @item sample_rate, r
2507 Specify the sample rate, default is 44100.
2508
2509 @item duration, d
2510 Specify the duration of the generated audio stream.
2511
2512 @item samples_per_frame
2513 Set the number of samples per output frame, default is 1024.
2514 @end table
2515
2516 @subsection Examples
2517
2518 @itemize
2519
2520 @item
2521 Generate a simple 440 Hz sine wave:
2522 @example
2523 sine
2524 @end example
2525
2526 @item
2527 Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
2528 @example
2529 sine=220:4:d=5
2530 sine=f=220:b=4:d=5
2531 sine=frequency=220:beep_factor=4:duration=5
2532 @end example
2533
2534 @end itemize
2535
2536 @c man end AUDIO SOURCES
2537
2538 @chapter Audio Sinks
2539 @c man begin AUDIO SINKS
2540
2541 Below is a description of the currently available audio sinks.
2542
2543 @section abuffersink
2544
2545 Buffer audio frames, and make them available to the end of filter chain.
2546
2547 This sink is mainly intended for programmatic use, in particular
2548 through the interface defined in @file{libavfilter/buffersink.h}
2549 or the options system.
2550
2551 It accepts a pointer to an AVABufferSinkContext structure, which
2552 defines the incoming buffers' formats, to be passed as the opaque
2553 parameter to @code{avfilter_init_filter} for initialization.
2554 @section anullsink
2555
2556 Null audio sink; do absolutely nothing with the input audio. It is
2557 mainly useful as a template and for use in analysis / debugging
2558 tools.
2559
2560 @c man end AUDIO SINKS
2561
2562 @chapter Video Filters
2563 @c man begin VIDEO FILTERS
2564
2565 When you configure your FFmpeg build, you can disable any of the
2566 existing filters using @code{--disable-filters}.
2567 The configure output will show the video filters included in your
2568 build.
2569
2570 Below is a description of the currently available video filters.
2571
2572 @section alphaextract
2573
2574 Extract the alpha component from the input as a grayscale video. This
2575 is especially useful with the @var{alphamerge} filter.
2576
2577 @section alphamerge
2578
2579 Add or replace the alpha component of the primary input with the
2580 grayscale value of a second input. This is intended for use with
2581 @var{alphaextract} to allow the transmission or storage of frame
2582 sequences that have alpha in a format that doesn't support an alpha
2583 channel.
2584
2585 For example, to reconstruct full frames from a normal YUV-encoded video
2586 and a separate video created with @var{alphaextract}, you might use:
2587 @example
2588 movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
2589 @end example
2590
2591 Since this filter is designed for reconstruction, it operates on frame
2592 sequences without considering timestamps, and terminates when either
2593 input reaches end of stream. This will cause problems if your encoding
2594 pipeline drops frames. If you're trying to apply an image as an
2595 overlay to a video stream, consider the @var{overlay} filter instead.
2596
2597 @section ass
2598
2599 Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
2600 and libavformat to work. On the other hand, it is limited to ASS (Advanced
2601 Substation Alpha) subtitles files.
2602
2603 This filter accepts the following option in addition to the common options from
2604 the @ref{subtitles} filter:
2605
2606 @table @option
2607 @item shaping
2608 Set the shaping engine
2609
2610 Available values are:
2611 @table @samp
2612 @item auto
2613 The default libass shaping engine, which is the best available.
2614 @item simple
2615 Fast, font-agnostic shaper that can do only substitutions
2616 @item complex
2617 Slower shaper using OpenType for substitutions and positioning
2618 @end table
2619
2620 The default is @code{auto}.
2621 @end table
2622
2623 @section bbox
2624
2625 Compute the bounding box for the non-black pixels in the input frame
2626 luminance plane.
2627
2628 This filter computes the bounding box containing all the pixels with a
2629 luminance value greater than the minimum allowed value.
2630 The parameters describing the bounding box are printed on the filter
2631 log.
2632
2633 The filter accepts the following option:
2634
2635 @table @option
2636 @item min_val
2637 Set the minimal luminance value. Default is @code{16}.
2638 @end table
2639
2640 @section blackdetect
2641
2642 Detect video intervals that are (almost) completely black. Can be
2643 useful to detect chapter transitions, commercials, or invalid
2644 recordings. Output lines contains the time for the start, end and
2645 duration of the detected black interval expressed in seconds.
2646
2647 In order to display the output lines, you need to set the loglevel at
2648 least to the AV_LOG_INFO value.
2649
2650 The filter accepts the following options:
2651
2652 @table @option
2653 @item black_min_duration, d
2654 Set the minimum detected black duration expressed in seconds. It must
2655 be a non-negative floating point number.
2656
2657 Default value is 2.0.
2658
2659 @item picture_black_ratio_th, pic_th
2660 Set the threshold for considering a picture "black".
2661 Express the minimum value for the ratio:
2662 @example
2663 @var{nb_black_pixels} / @var{nb_pixels}
2664 @end example
2665
2666 for which a picture is considered black.
2667 Default value is 0.98.
2668
2669 @item pixel_black_th, pix_th
2670 Set the threshold for considering a pixel "black".
2671
2672 The threshold expresses the maximum pixel luminance value for which a
2673 pixel is considered "black". The provided value is scaled according to
2674 the following equation:
2675 @example
2676 @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
2677 @end example
2678
2679 @var{luminance_range_size} and @var{luminance_minimum_value} depend on
2680 the input video format, the range is [0-255] for YUV full-range
2681 formats and [16-235] for YUV non full-range formats.
2682
2683 Default value is 0.10.
2684 @end table
2685
2686 The following example sets the maximum pixel threshold to the minimum
2687 value, and detects only black intervals of 2 or more seconds:
2688 @example
2689 blackdetect=d=2:pix_th=0.00
2690 @end example
2691
2692 @section blackframe
2693
2694 Detect frames that are (almost) completely black. Can be useful to
2695 detect chapter transitions or commercials. Output lines consist of
2696 the frame number of the detected frame, the percentage of blackness,
2697 the position in the file if known or -1 and the timestamp in seconds.
2698
2699 In order to display the output lines, you need to set the loglevel at
2700 least to the AV_LOG_INFO value.
2701
2702 It accepts the following parameters:
2703
2704 @table @option
2705
2706 @item amount
2707 The percentage of the pixels that have to be below the threshold; it defaults to
2708 @code{98}.
2709
2710 @item threshold, thresh
2711 The threshold below which a pixel value is considered black; it defaults to
2712 @code{32}.
2713
2714 @end table
2715
2716 @section blend, tblend
2717
2718 Blend two video frames into each other.
2719
2720 The @code{blend} filter takes two input streams and outputs one
2721 stream, the first input is the "top" layer and second input is
2722 "bottom" layer.  Output terminates when shortest input terminates.
2723
2724 The @code{tblend} (time blend) filter takes two consecutive frames
2725 from one single stream, and outputs the result obtained by blending
2726 the new frame on top of the old frame.
2727
2728 A description of the accepted options follows.
2729
2730 @table @option
2731 @item c0_mode
2732 @item c1_mode
2733 @item c2_mode
2734 @item c3_mode
2735 @item all_mode
2736 Set blend mode for specific pixel component or all pixel components in case
2737 of @var{all_mode}. Default value is @code{normal}.
2738
2739 Available values for component modes are:
2740 @table @samp
2741 @item addition
2742 @item and
2743 @item average
2744 @item burn
2745 @item darken
2746 @item difference
2747 @item difference128
2748 @item divide
2749 @item dodge
2750 @item exclusion
2751 @item glow
2752 @item hardlight
2753 @item hardmix
2754 @item lighten
2755 @item linearlight
2756 @item multiply
2757 @item negation
2758 @item normal
2759 @item or
2760 @item overlay
2761 @item phoenix
2762 @item pinlight
2763 @item reflect
2764 @item screen
2765 @item softlight
2766 @item subtract
2767 @item vividlight
2768 @item xor
2769 @end table
2770
2771 @item c0_opacity
2772 @item c1_opacity
2773 @item c2_opacity
2774 @item c3_opacity
2775 @item all_opacity
2776 Set blend opacity for specific pixel component or all pixel components in case
2777 of @var{all_opacity}. Only used in combination with pixel component blend modes.
2778
2779 @item c0_expr
2780 @item c1_expr
2781 @item c2_expr
2782 @item c3_expr
2783 @item all_expr
2784 Set blend expression for specific pixel component or all pixel components in case
2785 of @var{all_expr}. Note that related mode options will be ignored if those are set.
2786
2787 The expressions can use the following variables:
2788
2789 @table @option
2790 @item N
2791 The sequential number of the filtered frame, starting from @code{0}.
2792
2793 @item X
2794 @item Y
2795 the coordinates of the current sample
2796
2797 @item W
2798 @item H
2799 the width and height of currently filtered plane
2800
2801 @item SW
2802 @item SH
2803 Width and height scale depending on the currently filtered plane. It is the
2804 ratio between the corresponding luma plane number of pixels and the current
2805 plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
2806 @code{0.5,0.5} for chroma planes.
2807
2808 @item T
2809 Time of the current frame, expressed in seconds.
2810
2811 @item TOP, A
2812 Value of pixel component at current location for first video frame (top layer).
2813
2814 @item BOTTOM, B
2815 Value of pixel component at current location for second video frame (bottom layer).
2816 @end table
2817
2818 @item shortest
2819 Force termination when the shortest input terminates. Default is
2820 @code{0}. This option is only defined for the @code{blend} filter.
2821
2822 @item repeatlast
2823 Continue applying the last bottom frame after the end of the stream. A value of
2824 @code{0} disable the filter after the last frame of the bottom layer is reached.
2825 Default is @code{1}. This option is only defined for the @code{blend} filter.
2826 @end table
2827
2828 @subsection Examples
2829
2830 @itemize
2831 @item
2832 Apply transition from bottom layer to top layer in first 10 seconds:
2833 @example
2834 blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
2835 @end example
2836
2837 @item
2838 Apply 1x1 checkerboard effect:
2839 @example
2840 blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
2841 @end example
2842
2843 @item
2844 Apply uncover left effect:
2845 @example
2846 blend=all_expr='if(gte(N*SW+X,W),A,B)'
2847 @end example
2848
2849 @item
2850 Apply uncover down effect:
2851 @example
2852 blend=all_expr='if(gte(Y-N*SH,0),A,B)'
2853 @end example
2854
2855 @item
2856 Apply uncover up-left effect:
2857 @example
2858 blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
2859 @end example
2860
2861 @item
2862 Display differences between the current and the previous frame:
2863 @example
2864 tblend=all_mode=difference128
2865 @end example
2866 @end itemize
2867
2868 @section boxblur
2869
2870 Apply a boxblur algorithm to the input video.
2871
2872 It accepts the following parameters:
2873
2874 @table @option
2875
2876 @item luma_radius, lr
2877 @item luma_power, lp
2878 @item chroma_radius, cr
2879 @item chroma_power, cp
2880 @item alpha_radius, ar
2881 @item alpha_power, ap
2882
2883 @end table
2884
2885 A description of the accepted options follows.
2886
2887 @table @option
2888 @item luma_radius, lr
2889 @item chroma_radius, cr
2890 @item alpha_radius, ar
2891 Set an expression for the box radius in pixels used for blurring the
2892 corresponding input plane.
2893
2894 The radius value must be a non-negative number, and must not be
2895 greater than the value of the expression @code{min(w,h)/2} for the
2896 luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
2897 planes.
2898
2899 Default value for @option{luma_radius} is "2". If not specified,
2900 @option{chroma_radius} and @option{alpha_radius} default to the
2901 corresponding value set for @option{luma_radius}.
2902
2903 The expressions can contain the following constants:
2904 @table @option
2905 @item w
2906 @item h
2907 The input width and height in pixels.
2908
2909 @item cw
2910 @item ch
2911 The input chroma image width and height in pixels.
2912
2913 @item hsub
2914 @item vsub
2915 The horizontal and vertical chroma subsample values. For example, for the
2916 pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
2917 @end table
2918
2919 @item luma_power, lp
2920 @item chroma_power, cp
2921 @item alpha_power, ap
2922 Specify how many times the boxblur filter is applied to the
2923 corresponding plane.
2924
2925 Default value for @option{luma_power} is 2. If not specified,
2926 @option{chroma_power} and @option{alpha_power} default to the
2927 corresponding value set for @option{luma_power}.
2928
2929 A value of 0 will disable the effect.
2930 @end table
2931
2932 @subsection Examples
2933
2934 @itemize
2935 @item
2936 Apply a boxblur filter with the luma, chroma, and alpha radii
2937 set to 2:
2938 @example
2939 boxblur=luma_radius=2:luma_power=1
2940 boxblur=2:1
2941 @end example
2942
2943 @item
2944 Set the luma radius to 2, and alpha and chroma radius to 0:
2945 @example
2946 boxblur=2:1:cr=0:ar=0
2947 @end example
2948
2949 @item
2950 Set the luma and chroma radii to a fraction of the video dimension:
2951 @example
2952 boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
2953 @end example
2954 @end itemize
2955
2956 @section codecview
2957
2958 Visualize information exported by some codecs.
2959
2960 Some codecs can export information through frames using side-data or other
2961 means. For example, some MPEG based codecs export motion vectors through the
2962 @var{export_mvs} flag in the codec @option{flags2} option.
2963
2964 The filter accepts the following option:
2965
2966 @table @option
2967 @item mv
2968 Set motion vectors to visualize.
2969
2970 Available flags for @var{mv} are:
2971
2972 @table @samp
2973 @item pf
2974 forward predicted MVs of P-frames
2975 @item bf
2976 forward predicted MVs of B-frames
2977 @item bb
2978 backward predicted MVs of B-frames
2979 @end table
2980 @end table
2981
2982 @subsection Examples
2983
2984 @itemize
2985 @item
2986 Visualizes multi-directionals MVs from P and B-Frames using @command{ffplay}:
2987 @example
2988 ffplay -flags2 +export_mvs input.mpg -vf codecview=mv=pf+bf+bb
2989 @end example
2990 @end itemize
2991
2992 @section colorbalance
2993 Modify intensity of primary colors (red, green and blue) of input frames.
2994
2995 The filter allows an input frame to be adjusted in the shadows, midtones or highlights
2996 regions for the red-cyan, green-magenta or blue-yellow balance.
2997
2998 A positive adjustment value shifts the balance towards the primary color, a negative
2999 value towards the complementary color.
3000
3001 The filter accepts the following options:
3002
3003 @table @option
3004 @item rs
3005 @item gs
3006 @item bs
3007 Adjust red, green and blue shadows (darkest pixels).
3008
3009 @item rm
3010 @item gm
3011 @item bm
3012 Adjust red, green and blue midtones (medium pixels).
3013
3014 @item rh
3015 @item gh
3016 @item bh
3017 Adjust red, green and blue highlights (brightest pixels).
3018
3019 Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
3020 @end table
3021
3022 @subsection Examples
3023
3024 @itemize
3025 @item
3026 Add red color cast to shadows:
3027 @example
3028 colorbalance=rs=.3
3029 @end example
3030 @end itemize
3031
3032 @section colorlevels
3033
3034 Adjust video input frames using levels.
3035
3036 The filter accepts the following options:
3037
3038 @table @option
3039 @item rimin
3040 @item gimin
3041 @item bimin
3042 @item aimin
3043 Adjust red, green, blue and alpha input black point.
3044 Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
3045
3046 @item rimax
3047 @item gimax
3048 @item bimax
3049 @item aimax
3050 Adjust red, green, blue and alpha input white point.
3051 Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
3052
3053 Input levels are used to lighten highlights (bright tones), darken shadows
3054 (dark tones), change the balance of bright and dark tones.
3055
3056 @item romin
3057 @item gomin
3058 @item bomin
3059 @item aomin
3060 Adjust red, green, blue and alpha output black point.
3061 Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
3062
3063 @item romax
3064 @item gomax
3065 @item bomax
3066 @item aomax
3067 Adjust red, green, blue and alpha output white point.
3068 Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
3069
3070 Output levels allows manual selection of a constrained output level range.
3071 @end table
3072
3073 @subsection Examples
3074
3075 @itemize
3076 @item
3077 Make video output darker:
3078 @example
3079 colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
3080 @end example
3081
3082 @item
3083 Increase contrast:
3084 @example
3085 colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
3086 @end example
3087
3088 @item
3089 Make video output lighter:
3090 @example
3091 colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
3092 @end example
3093
3094 @item
3095 Increase brightness:
3096 @example
3097 colorlevels=romin=0.5:gomin=0.5:bomin=0.5
3098 @end example
3099 @end itemize
3100
3101 @section colorchannelmixer
3102
3103 Adjust video input frames by re-mixing color channels.
3104
3105 This filter modifies a color channel by adding the values associated to
3106 the other channels of the same pixels. For example if the value to
3107 modify is red, the output value will be:
3108 @example
3109 @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
3110 @end example
3111
3112 The filter accepts the following options:
3113
3114 @table @option
3115 @item rr
3116 @item rg
3117 @item rb
3118 @item ra
3119 Adjust contribution of input red, green, blue and alpha channels for output red channel.
3120 Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
3121
3122 @item gr
3123 @item gg
3124 @item gb
3125 @item ga
3126 Adjust contribution of input red, green, blue and alpha channels for output green channel.
3127 Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
3128
3129 @item br
3130 @item bg
3131 @item bb
3132 @item ba
3133 Adjust contribution of input red, green, blue and alpha channels for output blue channel.
3134 Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
3135
3136 @item ar
3137 @item ag
3138 @item ab
3139 @item aa
3140 Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
3141 Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
3142
3143 Allowed ranges for options are @code{[-2.0, 2.0]}.
3144 @end table
3145
3146 @subsection Examples
3147
3148 @itemize
3149 @item
3150 Convert source to grayscale:
3151 @example
3152 colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
3153 @end example
3154 @item
3155 Simulate sepia tones:
3156 @example
3157 colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
3158 @end example
3159 @end itemize
3160
3161 @section colormatrix
3162
3163 Convert color matrix.
3164
3165 The filter accepts the following options:
3166
3167 @table @option
3168 @item src
3169 @item dst
3170 Specify the source and destination color matrix. Both values must be
3171 specified.
3172
3173 The accepted values are:
3174 @table @samp
3175 @item bt709
3176 BT.709
3177
3178 @item bt601
3179 BT.601
3180
3181 @item smpte240m
3182 SMPTE-240M
3183
3184 @item fcc
3185 FCC
3186 @end table
3187 @end table
3188
3189 For example to convert from BT.601 to SMPTE-240M, use the command:
3190 @example
3191 colormatrix=bt601:smpte240m
3192 @end example
3193
3194 @section copy
3195
3196 Copy the input source unchanged to the output. This is mainly useful for
3197 testing purposes.
3198
3199 @section crop
3200
3201 Crop the input video to given dimensions.
3202
3203 It accepts the following parameters:
3204
3205 @table @option
3206 @item w, out_w
3207 The width of the output video. It defaults to @code{iw}.
3208 This expression is evaluated only once during the filter
3209 configuration.
3210
3211 @item h, out_h
3212 The height of the output video. It defaults to @code{ih}.
3213 This expression is evaluated only once during the filter
3214 configuration.
3215
3216 @item x
3217 The horizontal position, in the input video, of the left edge of the output
3218 video. It defaults to @code{(in_w-out_w)/2}.
3219 This expression is evaluated per-frame.
3220
3221 @item y
3222 The vertical position, in the input video, of the top edge of the output video.
3223 It defaults to @code{(in_h-out_h)/2}.
3224 This expression is evaluated per-frame.
3225
3226 @item keep_aspect
3227 If set to 1 will force the output display aspect ratio
3228 to be the same of the input, by changing the output sample aspect
3229 ratio. It defaults to 0.
3230 @end table
3231
3232 The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
3233 expressions containing the following constants:
3234
3235 @table @option
3236 @item x
3237 @item y
3238 The computed values for @var{x} and @var{y}. They are evaluated for
3239 each new frame.
3240
3241 @item in_w
3242 @item in_h
3243 The input width and height.
3244
3245 @item iw
3246 @item ih
3247 These are the same as @var{in_w} and @var{in_h}.
3248
3249 @item out_w
3250 @item out_h
3251 The output (cropped) width and height.
3252
3253 @item ow
3254 @item oh
3255 These are the same as @var{out_w} and @var{out_h}.
3256
3257 @item a
3258 same as @var{iw} / @var{ih}
3259
3260 @item sar
3261 input sample aspect ratio
3262
3263 @item dar
3264 input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
3265
3266 @item hsub
3267 @item vsub
3268 horizontal and vertical chroma subsample values. For example for the
3269 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
3270
3271 @item n
3272 The number of the input frame, starting from 0.
3273
3274 @item pos
3275 the position in the file of the input frame, NAN if unknown
3276
3277 @item t
3278 The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
3279
3280 @end table
3281
3282 The expression for @var{out_w} may depend on the value of @var{out_h},
3283 and the expression for @var{out_h} may depend on @var{out_w}, but they
3284 cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
3285 evaluated after @var{out_w} and @var{out_h}.
3286
3287 The @var{x} and @var{y} parameters specify the expressions for the
3288 position of the top-left corner of the output (non-cropped) area. They
3289 are evaluated for each frame. If the evaluated value is not valid, it
3290 is approximated to the nearest valid value.
3291
3292 The expression for @var{x} may depend on @var{y}, and the expression
3293 for @var{y} may depend on @var{x}.
3294
3295 @subsection Examples
3296
3297 @itemize
3298 @item
3299 Crop area with size 100x100 at position (12,34).
3300 @example
3301 crop=100:100:12:34
3302 @end example
3303
3304 Using named options, the example above becomes:
3305 @example
3306 crop=w=100:h=100:x=12:y=34
3307 @end example
3308
3309 @item
3310 Crop the central input area with size 100x100:
3311 @example
3312 crop=100:100
3313 @end example
3314
3315 @item
3316 Crop the central input area with size 2/3 of the input video:
3317 @example
3318 crop=2/3*in_w:2/3*in_h
3319 @end example
3320
3321 @item
3322 Crop the input video central square:
3323 @example
3324 crop=out_w=in_h
3325 crop=in_h
3326 @end example
3327
3328 @item
3329 Delimit the rectangle with the top-left corner placed at position
3330 100:100 and the right-bottom corner corresponding to the right-bottom
3331 corner of the input image.
3332 @example
3333 crop=in_w-100:in_h-100:100:100
3334 @end example
3335
3336 @item
3337 Crop 10 pixels from the left and right borders, and 20 pixels from
3338 the top and bottom borders
3339 @example
3340 crop=in_w-2*10:in_h-2*20
3341 @end example
3342
3343 @item
3344 Keep only the bottom right quarter of the input image:
3345 @example
3346 crop=in_w/2:in_h/2:in_w/2:in_h/2
3347 @end example
3348
3349 @item
3350 Crop height for getting Greek harmony:
3351 @example
3352 crop=in_w:1/PHI*in_w
3353 @end example
3354
3355 @item
3356 Apply trembling effect:
3357 @example
3358 crop=in_w/2:in_h/2:(in_w-out_w)/2+((in_w-out_w)/2)*sin(n/10):(in_h-out_h)/2 +((in_h-out_h)/2)*sin(n/7)
3359 @end example
3360
3361 @item
3362 Apply erratic camera effect depending on timestamp:
3363 @example
3364 crop=in_w/2:in_h/2:(in_w-out_w)/2+((in_w-out_w)/2)*sin(t*10):(in_h-out_h)/2 +((in_h-out_h)/2)*sin(t*13)"
3365 @end example
3366
3367 @item
3368 Set x depending on the value of y:
3369 @example
3370 crop=in_w/2:in_h/2:y:10+10*sin(n/10)
3371 @end example
3372 @end itemize
3373
3374 @section cropdetect
3375
3376 Auto-detect the crop size.
3377
3378 It calculates the necessary cropping parameters and prints the
3379 recommended parameters via the logging system. The detected dimensions
3380 correspond to the non-black area of the input video.
3381
3382 It accepts the following parameters:
3383
3384 @table @option
3385
3386 @item limit
3387 Set higher black value threshold, which can be optionally specified
3388 from nothing (0) to everything (255 for 8bit based formats). An intensity
3389 value greater to the set value is considered non-black. It defaults to 24.
3390 You can also specify a value between 0.0 and 1.0 which will be scaled depending
3391 on the bitdepth of the pixel format.
3392
3393 @item round
3394 The value which the width/height should be divisible by. It defaults to
3395 16. The offset is automatically adjusted to center the video. Use 2 to
3396 get only even dimensions (needed for 4:2:2 video). 16 is best when
3397 encoding to most video codecs.
3398
3399 @item reset_count, reset
3400 Set the counter that determines after how many frames cropdetect will
3401 reset the previously detected largest video area and start over to
3402 detect the current optimal crop area. Default value is 0.
3403
3404 This can be useful when channel logos distort the video area. 0
3405 indicates 'never reset', and returns the largest area encountered during
3406 playback.
3407 @end table
3408
3409 @anchor{curves}
3410 @section curves
3411
3412 Apply color adjustments using curves.
3413
3414 This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
3415 component (red, green and blue) has its values defined by @var{N} key points
3416 tied from each other using a smooth curve. The x-axis represents the pixel
3417 values from the input frame, and the y-axis the new pixel values to be set for
3418 the output frame.
3419
3420 By default, a component curve is defined by the two points @var{(0;0)} and
3421 @var{(1;1)}. This creates a straight line where each original pixel value is
3422 "adjusted" to its own value, which means no change to the image.
3423
3424 The filter allows you to redefine these two points and add some more. A new
3425 curve (using a natural cubic spline interpolation) will be define to pass
3426 smoothly through all these new coordinates. The new defined points needs to be
3427 strictly increasing over the x-axis, and their @var{x} and @var{y} values must
3428 be in the @var{[0;1]} interval.  If the computed curves happened to go outside
3429 the vector spaces, the values will be clipped accordingly.
3430
3431 If there is no key point defined in @code{x=0}, the filter will automatically
3432 insert a @var{(0;0)} point. In the same way, if there is no key point defined
3433 in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
3434
3435 The filter accepts the following options:
3436
3437 @table @option
3438 @item preset
3439 Select one of the available color presets. This option can be used in addition
3440 to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
3441 options takes priority on the preset values.
3442 Available presets are:
3443 @table @samp
3444 @item none
3445 @item color_negative
3446 @item cross_process
3447 @item darker
3448 @item increase_contrast
3449 @item lighter
3450 @item linear_contrast
3451 @item medium_contrast
3452 @item negative
3453 @item strong_contrast
3454 @item vintage
3455 @end table
3456 Default is @code{none}.
3457 @item master, m
3458 Set the master key points. These points will define a second pass mapping. It
3459 is sometimes called a "luminance" or "value" mapping. It can be used with
3460 @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
3461 post-processing LUT.
3462 @item red, r
3463 Set the key points for the red component.
3464 @item green, g
3465 Set the key points for the green component.
3466 @item blue, b
3467 Set the key points for the blue component.
3468 @item all
3469 Set the key points for all components (not including master).
3470 Can be used in addition to the other key points component
3471 options. In this case, the unset component(s) will fallback on this
3472 @option{all} setting.
3473 @item psfile
3474 Specify a Photoshop curves file (@code{.asv}) to import the settings from.
3475 @end table
3476
3477 To avoid some filtergraph syntax conflicts, each key points list need to be
3478 defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
3479
3480 @subsection Examples
3481
3482 @itemize
3483 @item
3484 Increase slightly the middle level of blue:
3485 @example
3486 curves=blue='0.5/0.58'
3487 @end example
3488
3489 @item
3490 Vintage effect:
3491 @example
3492 curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
3493 @end example
3494 Here we obtain the following coordinates for each components:
3495 @table @var
3496 @item red
3497 @code{(0;0.11) (0.42;0.51) (1;0.95)}
3498 @item green
3499 @code{(0;0) (0.50;0.48) (1;1)}
3500 @item blue
3501 @code{(0;0.22) (0.49;0.44) (1;0.80)}
3502 @end table
3503
3504 @item
3505 The previous example can also be achieved with the associated built-in preset:
3506 @example
3507 curves=preset=vintage
3508 @end example
3509
3510 @item
3511 Or simply:
3512 @example
3513 curves=vintage
3514 @end example
3515
3516 @item
3517 Use a Photoshop preset and redefine the points of the green component:
3518 @example
3519 curves=psfile='MyCurvesPresets/purple.asv':green='0.45/0.53'
3520 @end example
3521 @end itemize
3522
3523 @section dctdnoiz
3524
3525 Denoise frames using 2D DCT (frequency domain filtering).
3526
3527 This filter is not designed for real time.
3528
3529 The filter accepts the following options:
3530
3531 @table @option
3532 @item sigma, s
3533 Set the noise sigma constant.
3534
3535 This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
3536 coefficient (absolute value) below this threshold with be dropped.
3537
3538 If you need a more advanced filtering, see @option{expr}.
3539
3540 Default is @code{0}.
3541
3542 @item overlap
3543 Set number overlapping pixels for each block. Since the filter can be slow, you
3544 may want to reduce this value, at the cost of a less effective filter and the
3545 risk of various artefacts.
3546
3547 If the overlapping value doesn't permit processing the whole input width or
3548 height, a warning will be displayed and according borders won't be denoised.
3549
3550 Default value is @var{blocksize}-1, which is the best possible setting.
3551
3552 @item expr, e
3553 Set the coefficient factor expression.
3554
3555 For each coefficient of a DCT block, this expression will be evaluated as a
3556 multiplier value for the coefficient.
3557
3558 If this is option is set, the @option{sigma} option will be ignored.
3559
3560 The absolute value of the coefficient can be accessed through the @var{c}
3561 variable.
3562
3563 @item n
3564 Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
3565 @var{blocksize}, which is the width and height of the processed blocks.
3566
3567 The default value is @var{3} (8x8) and can be raised to @var{4} for a
3568 @var{blocksize} of 16x16. Note that changing this setting has huge consequences
3569 on the speed processing. Also, a larger block size does not necessarily means a
3570 better de-noising.
3571 @end table
3572
3573 @subsection Examples
3574
3575 Apply a denoise with a @option{sigma} of @code{4.5}:
3576 @example
3577 dctdnoiz=4.5
3578 @end example
3579
3580 The same operation can be achieved using the expression system:
3581 @example
3582 dctdnoiz=e='gte(c, 4.5*3)'
3583 @end example
3584
3585 Violent denoise using a block size of @code{16x16}:
3586 @example
3587 dctdnoiz=15:n=4
3588 @end example
3589
3590 @anchor{decimate}
3591 @section decimate
3592
3593 Drop duplicated frames at regular intervals.
3594
3595 The filter accepts the following options:
3596
3597 @table @option
3598 @item cycle
3599 Set the number of frames from which one will be dropped. Setting this to
3600 @var{N} means one frame in every batch of @var{N} frames will be dropped.
3601 Default is @code{5}.
3602
3603 @item dupthresh
3604 Set the threshold for duplicate detection. If the difference metric for a frame
3605 is less than or equal to this value, then it is declared as duplicate. Default
3606 is @code{1.1}
3607
3608 @item scthresh
3609 Set scene change threshold. Default is @code{15}.
3610
3611 @item blockx
3612 @item blocky
3613 Set the size of the x and y-axis blocks used during metric calculations.
3614 Larger blocks give better noise suppression, but also give worse detection of
3615 small movements. Must be a power of two. Default is @code{32}.
3616
3617 @item ppsrc
3618 Mark main input as a pre-processed input and activate clean source input
3619 stream. This allows the input to be pre-processed with various filters to help
3620 the metrics calculation while keeping the frame selection lossless. When set to
3621 @code{1}, the first stream is for the pre-processed input, and the second
3622 stream is the clean source from where the kept frames are chosen. Default is
3623 @code{0}.
3624
3625 @item chroma
3626 Set whether or not chroma is considered in the metric calculations. Default is
3627 @code{1}.
3628 @end table
3629
3630 @section dejudder
3631
3632 Remove judder produced by partially interlaced telecined content.
3633
3634 Judder can be introduced, for instance, by @ref{pullup} filter. If the original
3635 source was partially telecined content then the output of @code{pullup,dejudder}
3636 will have a variable frame rate. May change the recorded frame rate of the
3637 container. Aside from that change, this filter will not affect constant frame
3638 rate video.
3639
3640 The option available in this filter is:
3641 @table @option
3642
3643 @item cycle
3644 Specify the length of the window over which the judder repeats.
3645
3646 Accepts any integer greater than 1. Useful values are:
3647 @table @samp
3648
3649 @item 4
3650 If the original was telecined from 24 to 30 fps (Film to NTSC).
3651
3652 @item 5
3653 If the original was telecined from 25 to 30 fps (PAL to NTSC).
3654
3655 @item 20
3656 If a mixture of the two.
3657 @end table
3658
3659 The default is @samp{4}.
3660 @end table
3661
3662 @section delogo
3663
3664 Suppress a TV station logo by a simple interpolation of the surrounding
3665 pixels. Just set a rectangle covering the logo and watch it disappear
3666 (and sometimes something even uglier appear - your mileage may vary).
3667
3668 It accepts the following parameters:
3669 @table @option
3670
3671 @item x
3672 @item y
3673 Specify the top left corner coordinates of the logo. They must be
3674 specified.
3675
3676 @item w
3677 @item h
3678 Specify the width and height of the logo to clear. They must be
3679 specified.
3680
3681 @item band, t
3682 Specify the thickness of the fuzzy edge of the rectangle (added to
3683 @var{w} and @var{h}). The default value is 4.
3684
3685 @item show
3686 When set to 1, a green rectangle is drawn on the screen to simplify
3687 finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
3688 The default value is 0.
3689
3690 The rectangle is drawn on the outermost pixels which will be (partly)
3691 replaced with interpolated values. The values of the next pixels
3692 immediately outside this rectangle in each direction will be used to
3693 compute the interpolated pixel values inside the rectangle.
3694
3695 @end table
3696
3697 @subsection Examples
3698
3699 @itemize
3700 @item
3701 Set a rectangle covering the area with top left corner coordinates 0,0
3702 and size 100x77, and a band of size 10:
3703 @example
3704 delogo=x=0:y=0:w=100:h=77:band=10
3705 @end example
3706
3707 @end itemize
3708
3709 @section deshake
3710
3711 Attempt to fix small changes in horizontal and/or vertical shift. This
3712 filter helps remove camera shake from hand-holding a camera, bumping a
3713 tripod, moving on a vehicle, etc.
3714
3715 The filter accepts the following options:
3716
3717 @table @option
3718
3719 @item x
3720 @item y
3721 @item w
3722 @item h
3723 Specify a rectangular area where to limit the search for motion
3724 vectors.
3725 If desired the search for motion vectors can be limited to a
3726 rectangular area of the frame defined by its top left corner, width
3727 and height. These parameters have the same meaning as the drawbox
3728 filter which can be used to visualise the position of the bounding
3729 box.
3730
3731 This is useful when simultaneous movement of subjects within the frame
3732 might be confused for camera motion by the motion vector search.
3733
3734 If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
3735 then the full frame is used. This allows later options to be set
3736 without specifying the bounding box for the motion vector search.
3737
3738 Default - search the whole frame.
3739
3740 @item rx
3741 @item ry
3742 Specify the maximum extent of movement in x and y directions in the
3743 range 0-64 pixels. Default 16.
3744
3745 @item edge
3746 Specify how to generate pixels to fill blanks at the edge of the
3747 frame. Available values are:
3748 @table @samp
3749 @item blank, 0
3750 Fill zeroes at blank locations
3751 @item original, 1
3752 Original image at blank locations
3753 @item clamp, 2
3754 Extruded edge value at blank locations
3755 @item mirror, 3
3756 Mirrored edge at blank locations
3757 @end table
3758 Default value is @samp{mirror}.
3759
3760 @item blocksize
3761 Specify the blocksize to use for motion search. Range 4-128 pixels,
3762 default 8.
3763
3764 @item contrast
3765 Specify the contrast threshold for blocks. Only blocks with more than
3766 the specified contrast (difference between darkest and lightest
3767 pixels) will be considered. Range 1-255, default 125.
3768
3769 @item search
3770 Specify the search strategy. Available values are:
3771 @table @samp
3772 @item exhaustive, 0
3773 Set exhaustive search
3774 @item less, 1
3775 Set less exhaustive search.
3776 @end table
3777 Default value is @samp{exhaustive}.
3778
3779 @item filename
3780 If set then a detailed log of the motion search is written to the
3781 specified file.
3782
3783 @item opencl
3784 If set to 1, specify using OpenCL capabilities, only available if
3785 FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
3786
3787 @end table
3788
3789 @section detelecine
3790
3791 Apply an exact inverse of the telecine operation. It requires a predefined
3792 pattern specified using the pattern option which must be the same as that passed
3793 to the telecine filter.
3794
3795 This filter accepts the following options:
3796
3797 @table @option
3798 @item first_field
3799 @table @samp
3800 @item top, t
3801 top field first
3802 @item bottom, b
3803 bottom field first
3804 The default value is @code{top}.
3805 @end table
3806
3807 @item pattern
3808 A string of numbers representing the pulldown pattern you wish to apply.
3809 The default value is @code{23}.
3810
3811 @item start_frame
3812 A number representing position of the first frame with respect to the telecine
3813 pattern. This is to be used if the stream is cut. The default value is @code{0}.
3814 @end table
3815
3816 @section drawbox
3817
3818 Draw a colored box on the input image.
3819
3820 It accepts the following parameters:
3821
3822 @table @option
3823 @item x
3824 @item y
3825 The expressions which specify the top left corner coordinates of the box. It defaults to 0.
3826
3827 @item width, w
3828 @item height, h
3829 The expressions which specify the width and height of the box; if 0 they are interpreted as
3830 the input width and height. It defaults to 0.
3831
3832 @item color, c
3833 Specify the color of the box to write. For the general syntax of this option,
3834 check the "Color" section in the ffmpeg-utils manual. If the special
3835 value @code{invert} is used, the box edge color is the same as the
3836 video with inverted luma.
3837
3838 @item thickness, t
3839 The expression which sets the thickness of the box edge. Default value is @code{3}.
3840
3841 See below for the list of accepted constants.
3842 @end table
3843
3844 The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
3845 following constants:
3846
3847 @table @option
3848 @item dar
3849 The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
3850
3851 @item hsub
3852 @item vsub
3853 horizontal and vertical chroma subsample values. For example for the
3854 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
3855
3856 @item in_h, ih
3857 @item in_w, iw
3858 The input width and height.
3859
3860 @item sar
3861 The input sample aspect ratio.
3862
3863 @item x
3864 @item y
3865 The x and y offset coordinates where the box is drawn.
3866
3867 @item w
3868 @item h
3869 The width and height of the drawn box.
3870
3871 @item t
3872 The thickness of the drawn box.
3873
3874 These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
3875 each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
3876
3877 @end table
3878
3879 @subsection Examples
3880
3881 @itemize
3882 @item
3883 Draw a black box around the edge of the input image:
3884 @example
3885 drawbox
3886 @end example
3887
3888 @item
3889 Draw a box with color red and an opacity of 50%:
3890 @example
3891 drawbox=10:20:200:60:red@@0.5
3892 @end example
3893
3894 The previous example can be specified as:
3895 @example
3896 drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
3897 @end example
3898
3899 @item
3900 Fill the box with pink color:
3901 @example
3902 drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
3903 @end example
3904
3905 @item
3906 Draw a 2-pixel red 2.40:1 mask:
3907 @example
3908 drawbox=x=-t:y=0.5*(ih-iw/2.4)-t:w=iw+t*2:h=iw/2.4+t*2:t=2:c=red
3909 @end example
3910 @end itemize
3911
3912 @section drawgrid
3913
3914 Draw a grid on the input image.
3915
3916 It accepts the following parameters:
3917
3918 @table @option
3919 @item x
3920 @item y
3921 The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
3922
3923 @item width, w
3924 @item height, h
3925 The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
3926 input width and height, respectively, minus @code{thickness}, so image gets
3927 framed. Default to 0.
3928
3929 @item color, c
3930 Specify the color of the grid. For the general syntax of this option,
3931 check the "Color" section in the ffmpeg-utils manual. If the special
3932 value @code{invert} is used, the grid color is the same as the
3933 video with inverted luma.
3934
3935 @item thickness, t
3936 The expression which sets the thickness of the grid line. Default value is @code{1}.
3937
3938 See below for the list of accepted constants.
3939 @end table
3940
3941 The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
3942 following constants:
3943
3944 @table @option
3945 @item dar
3946 The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
3947
3948 @item hsub
3949 @item vsub
3950 horizontal and vertical chroma subsample values. For example for the
3951 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
3952
3953 @item in_h, ih
3954 @item in_w, iw
3955 The input grid cell width and height.
3956
3957 @item sar
3958 The input sample aspect ratio.
3959
3960 @item x
3961 @item y
3962 The x and y coordinates of some point of grid intersection (meant to configure offset).
3963
3964 @item w
3965 @item h
3966 The width and height of the drawn cell.
3967
3968 @item t
3969 The thickness of the drawn cell.
3970
3971 These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
3972 each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
3973
3974 @end table
3975
3976 @subsection Examples
3977
3978 @itemize
3979 @item
3980 Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
3981 @example
3982 drawgrid=width=100:height=100:thickness=2:color=red@@0.5
3983 @end example
3984
3985 @item
3986 Draw a white 3x3 grid with an opacity of 50%:
3987 @example
3988 drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
3989 @end example
3990 @end itemize
3991
3992 @anchor{drawtext}
3993 @section drawtext
3994
3995 Draw a text string or text from a specified file on top of a video, using the
3996 libfreetype library.
3997
3998 To enable compilation of this filter, you need to configure FFmpeg with
3999 @code{--enable-libfreetype}.
4000 To enable default font fallback and the @var{font} option you need to
4001 configure FFmpeg with @code{--enable-libfontconfig}.
4002 To enable the @var{text_shaping} option, you need to configure FFmpeg with
4003 @code{--enable-libfribidi}.
4004
4005 @subsection Syntax
4006
4007 It accepts the following parameters:
4008
4009 @table @option
4010
4011 @item box
4012 Used to draw a box around text using the background color.
4013 The value must be either 1 (enable) or 0 (disable).
4014 The default value of @var{box} is 0.
4015
4016 @item boxborderw
4017 Set the width of the border to be drawn around the box using @var{boxcolor}.
4018 The default value of @var{boxborderw} is 0.
4019
4020 @item boxcolor
4021 The color to be used for drawing box around text. For the syntax of this
4022 option, check the "Color" section in the ffmpeg-utils manual.
4023
4024 The default value of @var{boxcolor} is "white".
4025
4026 @item borderw
4027 Set the width of the border to be drawn around the text using @var{bordercolor}.
4028 The default value of @var{borderw} is 0.
4029
4030 @item bordercolor
4031 Set the color to be used for drawing border around text. For the syntax of this
4032 option, check the "Color" section in the ffmpeg-utils manual.
4033
4034 The default value of @var{bordercolor} is "black".
4035
4036 @item expansion
4037 Select how the @var{text} is expanded. Can be either @code{none},
4038 @code{strftime} (deprecated) or
4039 @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
4040 below for details.
4041
4042 @item fix_bounds
4043 If true, check and fix text coords to avoid clipping.
4044
4045 @item fontcolor
4046 The color to be used for drawing fonts. For the syntax of this option, check
4047 the "Color" section in the ffmpeg-utils manual.
4048
4049 The default value of @var{fontcolor} is "black".
4050
4051 @item fontcolor_expr
4052 String which is expanded the same way as @var{text} to obtain dynamic
4053 @var{fontcolor} value. By default this option has empty value and is not
4054 processed. When this option is set, it overrides @var{fontcolor} option.
4055
4056 @item font
4057 The font family to be used for drawing text. By default Sans.
4058
4059 @item fontfile
4060 The font file to be used for drawing text. The path must be included.
4061 This parameter is mandatory if the fontconfig support is disabled.
4062
4063 @item draw
4064 This option does not exist, please see the timeline system
4065
4066 @item alpha
4067 Draw the text applying alpha blending. The value can
4068 be either a number between 0.0 and 1.0
4069 The expression accepts the same variables @var{x, y} do.
4070 The default value is 1.
4071 Please see fontcolor_expr
4072
4073 @item fontsize
4074 The font size to be used for drawing text.
4075 The default value of @var{fontsize} is 16.
4076
4077 @item text_shaping
4078 If set to 1, attempt to shape the text (for example, reverse the order of
4079 right-to-left text and join Arabic characters) before drawing it.
4080 Otherwise, just draw the text exactly as given.
4081 By default 1 (if supported).
4082
4083 @item ft_load_flags
4084 The flags to be used for loading the fonts.
4085
4086 The flags map the corresponding flags supported by libfreetype, and are
4087 a combination of the following values:
4088 @table @var
4089 @item default
4090 @item no_scale
4091 @item no_hinting
4092 @item render
4093 @item no_bitmap
4094 @item vertical_layout
4095 @item force_autohint
4096 @item crop_bitmap
4097 @item pedantic
4098 @item ignore_global_advance_width
4099 @item no_recurse
4100 @item ignore_transform
4101 @item monochrome
4102 @item linear_design
4103 @item no_autohint
4104 @end table
4105
4106 Default value is "default".
4107
4108 For more information consult the documentation for the FT_LOAD_*
4109 libfreetype flags.
4110
4111 @item shadowcolor
4112 The color to be used for drawing a shadow behind the drawn text. For the
4113 syntax of this option, check the "Color" section in the ffmpeg-utils manual.
4114
4115 The default value of @var{shadowcolor} is "black".
4116
4117 @item shadowx
4118 @item shadowy
4119 The x and y offsets for the text shadow position with respect to the
4120 position of the text. They can be either positive or negative
4121 values. The default value for both is "0".
4122
4123 @item start_number
4124 The starting frame number for the n/frame_num variable. The default value
4125 is "0".
4126
4127 @item tabsize
4128 The size in number of spaces to use for rendering the tab.
4129 Default value is 4.
4130
4131 @item timecode
4132 Set the initial timecode representation in "hh:mm:ss[:;.]ff"
4133 format. It can be used with or without text parameter. @var{timecode_rate}
4134 option must be specified.
4135
4136 @item timecode_rate, rate, r
4137 Set the timecode frame rate (timecode only).
4138
4139 @item text
4140 The text string to be drawn. The text must be a sequence of UTF-8
4141 encoded characters.
4142 This parameter is mandatory if no file is specified with the parameter
4143 @var{textfile}.
4144
4145 @item textfile
4146 A text file containing text to be drawn. The text must be a sequence
4147 of UTF-8 encoded characters.
4148
4149 This parameter is mandatory if no text string is specified with the
4150 parameter @var{text}.
4151
4152 If both @var{text} and @var{textfile} are specified, an error is thrown.
4153
4154 @item reload
4155 If set to 1, the @var{textfile} will be reloaded before each frame.
4156 Be sure to update it atomically, or it may be read partially, or even fail.
4157
4158 @item x
4159 @item y
4160 The expressions which specify the offsets where text will be drawn
4161 within the video frame. They are relative to the top/left border of the
4162 output image.
4163
4164 The default value of @var{x} and @var{y} is "0".
4165
4166 See below for the list of accepted constants and functions.
4167 @end table
4168
4169 The parameters for @var{x} and @var{y} are expressions containing the
4170 following constants and functions:
4171
4172 @table @option
4173 @item dar
4174 input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
4175
4176 @item hsub
4177 @item vsub
4178 horizontal and vertical chroma subsample values. For example for the
4179 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
4180
4181 @item line_h, lh
4182 the height of each text line
4183
4184 @item main_h, h, H
4185 the input height
4186
4187 @item main_w, w, W
4188 the input width
4189
4190 @item max_glyph_a, ascent
4191 the maximum distance from the baseline to the highest/upper grid
4192 coordinate used to place a glyph outline point, for all the rendered
4193 glyphs.
4194 It is a positive value, due to the grid's orientation with the Y axis
4195 upwards.
4196
4197 @item max_glyph_d, descent
4198 the maximum distance from the baseline to the lowest grid coordinate
4199 used to place a glyph outline point, for all the rendered glyphs.
4200 This is a negative value, due to the grid's orientation, with the Y axis
4201 upwards.
4202
4203 @item max_glyph_h
4204 maximum glyph height, that is the maximum height for all the glyphs
4205 contained in the rendered text, it is equivalent to @var{ascent} -
4206 @var{descent}.
4207
4208 @item max_glyph_w
4209 maximum glyph width, that is the maximum width for all the glyphs
4210 contained in the rendered text
4211
4212 @item n
4213 the number of input frame, starting from 0
4214
4215 @item rand(min, max)
4216 return a random number included between @var{min} and @var{max}
4217
4218 @item sar
4219 The input sample aspect ratio.
4220
4221 @item t
4222 timestamp expressed in seconds, NAN if the input timestamp is unknown
4223
4224 @item text_h, th
4225 the height of the rendered text
4226
4227 @item text_w, tw
4228 the width of the rendered text
4229
4230 @item x
4231 @item y
4232 the x and y offset coordinates where the text is drawn.
4233
4234 These parameters allow the @var{x} and @var{y} expressions to refer
4235 each other, so you can for example specify @code{y=x/dar}.
4236 @end table
4237
4238 @anchor{drawtext_expansion}
4239 @subsection Text expansion
4240
4241 If @option{expansion} is set to @code{strftime},
4242 the filter recognizes strftime() sequences in the provided text and
4243 expands them accordingly. Check the documentation of strftime(). This
4244 feature is deprecated.
4245
4246 If @option{expansion} is set to @code{none}, the text is printed verbatim.
4247
4248 If @option{expansion} is set to @code{normal} (which is the default),
4249 the following expansion mechanism is used.
4250
4251 The backslash character @samp{\}, followed by any character, always expands to
4252 the second character.
4253
4254 Sequence of the form @code{%@{...@}} are expanded. The text between the
4255 braces is a function name, possibly followed by arguments separated by ':'.
4256 If the arguments contain special characters or delimiters (':' or '@}'),
4257 they should be escaped.
4258
4259 Note that they probably must also be escaped as the value for the
4260 @option{text} option in the filter argument string and as the filter
4261 argument in the filtergraph description, and possibly also for the shell,
4262 that makes up to four levels of escaping; using a text file avoids these
4263 problems.
4264
4265 The following functions are available:
4266
4267 @table @command
4268
4269 @item expr, e
4270 The expression evaluation result.
4271
4272 It must take one argument specifying the expression to be evaluated,
4273 which accepts the same constants and functions as the @var{x} and
4274 @var{y} values. Note that not all constants should be used, for
4275 example the text size is not known when evaluating the expression, so
4276 the constants @var{text_w} and @var{text_h} will have an undefined
4277 value.
4278
4279 @item expr_int_format, eif
4280 Evaluate the expression's value and output as formatted integer.
4281
4282 The first argument is the expression to be evaluated, just as for the @var{expr} function.
4283 The second argument specifies the output format. Allowed values are @samp{x},
4284 @samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
4285 @code{printf} function.
4286 The third parameter is optional and sets the number of positions taken by the output.
4287 It can be used to add padding with zeros from the left.
4288
4289 @item gmtime
4290 The time at which the filter is running, expressed in UTC.
4291 It can accept an argument: a strftime() format string.
4292
4293 @item localtime
4294 The time at which the filter is running, expressed in the local time zone.
4295 It can accept an argument: a strftime() format string.
4296
4297 @item metadata
4298 Frame metadata. It must take one argument specifying metadata key.
4299
4300 @item n, frame_num
4301 The frame number, starting from 0.
4302
4303 @item pict_type
4304 A 1 character description of the current picture type.
4305
4306 @item pts
4307 The timestamp of the current frame.
4308 It can take up to two arguments.
4309
4310 The first argument is the format of the timestamp; it defaults to @code{flt}
4311 for seconds as a decimal number with microsecond accuracy; @code{hms} stands
4312 for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
4313
4314 The second argument is an offset added to the timestamp.
4315
4316 @end table
4317
4318 @subsection Examples
4319
4320 @itemize
4321 @item
4322 Draw "Test Text" with font FreeSerif, using the default values for the
4323 optional parameters.
4324
4325 @example
4326 drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
4327 @end example
4328
4329 @item
4330 Draw 'Test Text' with font FreeSerif of size 24 at position x=100
4331 and y=50 (counting from the top-left corner of the screen), text is
4332 yellow with a red box around it. Both the text and the box have an
4333 opacity of 20%.
4334
4335 @example
4336 drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
4337           x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
4338 @end example
4339
4340 Note that the double quotes are not necessary if spaces are not used
4341 within the parameter list.
4342
4343 @item
4344 Show the text at the center of the video frame:
4345 @example
4346 drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
4347 @end example
4348
4349 @item
4350 Show a text line sliding from right to left in the last row of the video
4351 frame. The file @file{LONG_LINE} is assumed to contain a single line
4352 with no newlines.
4353 @example
4354 drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
4355 @end example
4356
4357 @item
4358 Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
4359 @example
4360 drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
4361 @end example
4362
4363 @item
4364 Draw a single green letter "g", at the center of the input video.
4365 The glyph baseline is placed at half screen height.
4366 @example
4367 drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
4368 @end example
4369
4370 @item
4371 Show text for 1 second every 3 seconds:
4372 @example
4373 drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
4374 @end example
4375
4376 @item
4377 Use fontconfig to set the font. Note that the colons need to be escaped.
4378 @example
4379 drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
4380 @end example
4381
4382 @item
4383 Print the date of a real-time encoding (see strftime(3)):
4384 @example
4385 drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
4386 @end example
4387
4388 @item
4389 Show text fading in and out (appearing/disappearing):
4390 @example
4391 #!/bin/sh
4392 DS=1.0 # display start
4393 DE=10.0 # display end
4394 FID=1.5 # fade in duration
4395 FOD=5 # fade out duration
4396 ffplay -f lavfi "color,drawtext=text=TEST:fontsize=50:fontfile=FreeSerif.ttf:fontcolor_expr=ff0000%@{eif\\\\: clip(255*(1*between(t\\, $DS + $FID\\, $DE - $FOD) + ((t - $DS)/$FID)*between(t\\, $DS\\, $DS + $FID) + (-(t - $DE)/$FOD)*between(t\\, $DE - $FOD\\, $DE) )\\, 0\\, 255) \\\\: x\\\\: 2 @}"
4397 @end example
4398
4399 @end itemize
4400
4401 For more information about libfreetype, check:
4402 @url{http://www.freetype.org/}.
4403
4404 For more information about fontconfig, check:
4405 @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
4406
4407 For more information about libfribidi, check:
4408 @url{http://fribidi.org/}.
4409
4410 @section edgedetect
4411
4412 Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
4413
4414 The filter accepts the following options:
4415
4416 @table @option
4417 @item low
4418 @item high
4419 Set low and high threshold values used by the Canny thresholding
4420 algorithm.
4421
4422 The high threshold selects the "strong" edge pixels, which are then
4423 connected through 8-connectivity with the "weak" edge pixels selected
4424 by the low threshold.
4425
4426 @var{low} and @var{high} threshold values must be chosen in the range
4427 [0,1], and @var{low} should be lesser or equal to @var{high}.
4428
4429 Default value for @var{low} is @code{20/255}, and default value for @var{high}
4430 is @code{50/255}.
4431
4432 @item mode
4433 Define the drawing mode.
4434
4435 @table @samp
4436 @item wires
4437 Draw white/gray wires on black background.
4438
4439 @item colormix
4440 Mix the colors to create a paint/cartoon effect.
4441 @end table
4442
4443 Default value is @var{wires}.
4444 @end table
4445
4446 @subsection Examples
4447
4448 @itemize
4449 @item
4450 Standard edge detection with custom values for the hysteresis thresholding:
4451 @example
4452 edgedetect=low=0.1:high=0.4
4453 @end example
4454
4455 @item
4456 Painting effect without thresholding:
4457 @example
4458 edgedetect=mode=colormix:high=0
4459 @end example
4460 @end itemize
4461
4462 @section eq
4463 Set brightness, contrast, saturation and approximate gamma adjustment.
4464
4465 The filter accepts the following options:
4466
4467 @table @option
4468 @item contrast
4469 Set the contrast expression. The value must be a float value in range
4470 @code{-2.0} to @code{2.0}. The default value is "0".
4471
4472 @item brightness
4473 Set the brightness expression. The value must be a float value in
4474 range @code{-1.0} to @code{1.0}. The default value is "0".
4475
4476 @item saturation
4477 Set the saturation expression. The value must be a float in
4478 range @code{0.0} to @code{3.0}. The default value is "1".
4479
4480 @item gamma
4481 Set the gamma expression. The value must be a float in range
4482 @code{0.1} to @code{10.0}.  The default value is "1".
4483
4484 @item gamma_r
4485 Set the gamma expression for red. The value must be a float in
4486 range @code{0.1} to @code{10.0}. The default value is "1".
4487
4488 @item gamma_g
4489 Set the gamma expression for green. The value must be a float in range
4490 @code{0.1} to @code{10.0}. The default value is "1".
4491
4492 @item gamma_b
4493 Set the gamma expression for blue. The value must be a float in range
4494 @code{0.1} to @code{10.0}. The default value is "1".
4495
4496 @item gamma_weight
4497 Set the gamma weight expression. It can be used to reduce the effect
4498 of a high gamma value on bright image areas, e.g. keep them from
4499 getting overamplified and just plain white. The value must be a float
4500 in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
4501 gamma correction all the way down while @code{1.0} leaves it at its
4502 full strength. Default is "1".
4503
4504 @item eval
4505 Set when the expressions for brightness, contrast, saturation and
4506 gamma expressions are evaluated.
4507
4508 It accepts the following values:
4509 @table @samp
4510 @item init
4511 only evaluate expressions once during the filter initialization or
4512 when a command is processed
4513
4514 @item frame
4515 evaluate expressions for each incoming frame
4516 @end table
4517
4518 Default value is @samp{init}.
4519 @end table
4520
4521 The expressions accept the following parameters:
4522 @table @option
4523 @item n
4524 frame count of the input frame starting from 0
4525
4526 @item pos
4527 byte position of the corresponding packet in the input file, NAN if
4528 unspecified
4529
4530 @item r
4531 frame rate of the input video, NAN if the input frame rate is unknown
4532
4533 @item t
4534 timestamp expressed in seconds, NAN if the input timestamp is unknown
4535 @end table
4536
4537 @subsection Commands
4538 The filter supports the following commands:
4539
4540 @table @option
4541 @item contrast
4542 Set the contrast expression.
4543
4544 @item brightness
4545 Set the brightness expression.
4546
4547 @item saturation
4548 Set the saturation expression.
4549
4550 @item gamma
4551 Set the gamma expression.
4552
4553 @item gamma_r
4554 Set the gamma_r expression.
4555
4556 @item gamma_g
4557 Set gamma_g expression.
4558
4559 @item gamma_b
4560 Set gamma_b expression.
4561
4562 @item gamma_weight
4563 Set gamma_weight expression.
4564
4565 The command accepts the same syntax of the corresponding option.
4566
4567 If the specified expression is not valid, it is kept at its current
4568 value.
4569
4570 @end table
4571
4572 @section extractplanes
4573
4574 Extract color channel components from input video stream into
4575 separate grayscale video streams.
4576
4577 The filter accepts the following option:
4578
4579 @table @option
4580 @item planes
4581 Set plane(s) to extract.
4582
4583 Available values for planes are:
4584 @table @samp
4585 @item y
4586 @item u
4587 @item v
4588 @item a
4589 @item r
4590 @item g
4591 @item b
4592 @end table
4593
4594 Choosing planes not available in the input will result in an error.
4595 That means you cannot select @code{r}, @code{g}, @code{b} planes
4596 with @code{y}, @code{u}, @code{v} planes at same time.
4597 @end table
4598
4599 @subsection Examples
4600
4601 @itemize
4602 @item
4603 Extract luma, u and v color channel component from input video frame
4604 into 3 grayscale outputs:
4605 @example
4606 ffmpeg -i video.avi -filter_complex 'extractplanes=y+u+v[y][u][v]' -map '[y]' y.avi -map '[u]' u.avi -map '[v]' v.avi
4607 @end example
4608 @end itemize
4609
4610 @section elbg
4611
4612 Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
4613
4614 For each input image, the filter will compute the optimal mapping from
4615 the input to the output given the codebook length, that is the number
4616 of distinct output colors.
4617
4618 This filter accepts the following options.
4619
4620 @table @option
4621 @item codebook_length, l
4622 Set codebook length. The value must be a positive integer, and
4623 represents the number of distinct output colors. Default value is 256.
4624
4625 @item nb_steps, n
4626 Set the maximum number of iterations to apply for computing the optimal
4627 mapping. The higher the value the better the result and the higher the
4628 computation time. Default value is 1.
4629
4630 @item seed, s
4631 Set a random seed, must be an integer included between 0 and
4632 UINT32_MAX. If not specified, or if explicitly set to -1, the filter
4633 will try to use a good random seed on a best effort basis.
4634 @end table
4635
4636 @section fade
4637
4638 Apply a fade-in/out effect to the input video.
4639
4640 It accepts the following parameters:
4641
4642 @table @option
4643 @item type, t
4644 The effect type can be either "in" for a fade-in, or "out" for a fade-out
4645 effect.
4646 Default is @code{in}.
4647
4648 @item start_frame, s
4649 Specify the number of the frame to start applying the fade
4650 effect at. Default is 0.
4651
4652 @item nb_frames, n
4653 The number of frames that the fade effect lasts. At the end of the
4654 fade-in effect, the output video will have the same intensity as the input video.
4655 At the end of the fade-out transition, the output video will be filled with the
4656 selected @option{color}.
4657 Default is 25.
4658
4659 @item alpha
4660 If set to 1, fade only alpha channel, if one exists on the input.
4661 Default value is 0.
4662
4663 @item start_time, st
4664 Specify the timestamp (in seconds) of the frame to start to apply the fade
4665 effect. If both start_frame and start_time are specified, the fade will start at
4666 whichever comes last.  Default is 0.
4667
4668 @item duration, d
4669 The number of seconds for which the fade effect has to last. At the end of the
4670 fade-in effect the output video will have the same intensity as the input video,
4671 at the end of the fade-out transition the output video will be filled with the
4672 selected @option{color}.
4673 If both duration and nb_frames are specified, duration is used. Default is 0
4674 (nb_frames is used by default).
4675
4676 @item color, c
4677 Specify the color of the fade. Default is "black".
4678 @end table
4679
4680 @subsection Examples
4681
4682 @itemize
4683 @item
4684 Fade in the first 30 frames of video:
4685 @example
4686 fade=in:0:30
4687 @end example
4688
4689 The command above is equivalent to:
4690 @example
4691 fade=t=in:s=0:n=30
4692 @end example
4693
4694 @item
4695 Fade out the last 45 frames of a 200-frame video:
4696 @example
4697 fade=out:155:45
4698 fade=type=out:start_frame=155:nb_frames=45
4699 @end example
4700
4701 @item
4702 Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
4703 @example
4704 fade=in:0:25, fade=out:975:25
4705 @end example
4706
4707 @item
4708 Make the first 5 frames yellow, then fade in from frame 5-24:
4709 @example
4710 fade=in:5:20:color=yellow
4711 @end example
4712
4713 @item
4714 Fade in alpha over first 25 frames of video:
4715 @example
4716 fade=in:0:25:alpha=1
4717 @end example
4718
4719 @item
4720 Make the first 5.5 seconds black, then fade in for 0.5 seconds:
4721 @example
4722 fade=t=in:st=5.5:d=0.5
4723 @end example
4724
4725 @end itemize
4726
4727 @section fftfilt
4728 Apply arbitrary expressions to samples in frequency domain
4729
4730 @table @option
4731 @item dc_Y
4732 Adjust the dc value (gain) of the luma plane of the image. The filter
4733 accepts an integer value in range @code{0} to @code{1000}. The default
4734 value is set to @code{0}.
4735
4736 @item dc_U
4737 Adjust the dc value (gain) of the 1st chroma plane of the image. The
4738 filter accepts an integer value in range @code{0} to @code{1000}. The
4739 default value is set to @code{0}.
4740
4741 @item dc_V
4742 Adjust the dc value (gain) of the 2nd chroma plane of the image. The
4743 filter accepts an integer value in range @code{0} to @code{1000}. The
4744 default value is set to @code{0}.
4745
4746 @item weight_Y
4747 Set the frequency domain weight expression for the luma plane.
4748
4749 @item weight_U
4750 Set the frequency domain weight expression for the 1st chroma plane.
4751
4752 @item weight_V
4753 Set the frequency domain weight expression for the 2nd chroma plane.
4754
4755 The filter accepts the following variables:
4756 @item X
4757 @item Y
4758 The coordinates of the current sample.
4759
4760 @item W
4761 @item H
4762 The width and height of the image.
4763 @end table
4764
4765 @subsection Examples
4766
4767 @itemize
4768 @item
4769 High-pass:
4770 @example
4771 fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
4772 @end example
4773
4774 @item
4775 Low-pass:
4776 @example
4777 fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
4778 @end example
4779
4780 @item
4781 Sharpen:
4782 @example
4783 fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
4784 @end example
4785
4786 @end itemize
4787
4788 @section field
4789
4790 Extract a single field from an interlaced image using stride
4791 arithmetic to avoid wasting CPU time. The output frames are marked as
4792 non-interlaced.
4793
4794 The filter accepts the following options:
4795
4796 @table @option
4797 @item type
4798 Specify whether to extract the top (if the value is @code{0} or
4799 @code{top}) or the bottom field (if the value is @code{1} or
4800 @code{bottom}).
4801 @end table
4802
4803 @section fieldmatch
4804
4805 Field matching filter for inverse telecine. It is meant to reconstruct the
4806 progressive frames from a telecined stream. The filter does not drop duplicated
4807 frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
4808 followed by a decimation filter such as @ref{decimate} in the filtergraph.
4809
4810 The separation of the field matching and the decimation is notably motivated by
4811 the possibility of inserting a de-interlacing filter fallback between the two.
4812 If the source has mixed telecined and real interlaced content,
4813 @code{fieldmatch} will not be able to match fields for the interlaced parts.
4814 But these remaining combed frames will be marked as interlaced, and thus can be
4815 de-interlaced by a later filter such as @ref{yadif} before decimation.
4816
4817 In addition to the various configuration options, @code{fieldmatch} can take an
4818 optional second stream, activated through the @option{ppsrc} option. If
4819 enabled, the frames reconstruction will be based on the fields and frames from
4820 this second stream. This allows the first input to be pre-processed in order to
4821 help the various algorithms of the filter, while keeping the output lossless
4822 (assuming the fields are matched properly). Typically, a field-aware denoiser,
4823 or brightness/contrast adjustments can help.
4824
4825 Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
4826 and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
4827 which @code{fieldmatch} is based on. While the semantic and usage are very
4828 close, some behaviour and options names can differ.
4829
4830 The @ref{decimate} filter currently only works for constant frame rate input.
4831 Do not use @code{fieldmatch} and @ref{decimate} if your input has mixed
4832 telecined and progressive content with changing framerate.
4833
4834 The filter accepts the following options:
4835
4836 @table @option
4837 @item order
4838 Specify the assumed field order of the input stream. Available values are:
4839
4840 @table @samp
4841 @item auto
4842 Auto detect parity (use FFmpeg's internal parity value).
4843 @item bff
4844 Assume bottom field first.
4845 @item tff
4846 Assume top field first.
4847 @end table
4848
4849 Note that it is sometimes recommended not to trust the parity announced by the
4850 stream.
4851
4852 Default value is @var{auto}.
4853
4854 @item mode
4855 Set the matching mode or strategy to use. @option{pc} mode is the safest in the
4856 sense that it won't risk creating jerkiness due to duplicate frames when
4857 possible, but if there are bad edits or blended fields it will end up
4858 outputting combed frames when a good match might actually exist. On the other
4859 hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
4860 but will almost always find a good frame if there is one. The other values are
4861 all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
4862 jerkiness and creating duplicate frames versus finding good matches in sections
4863 with bad edits, orphaned fields, blended fields, etc.
4864
4865 More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
4866
4867 Available values are:
4868
4869 @table @samp
4870 @item pc
4871 2-way matching (p/c)
4872 @item pc_n
4873 2-way matching, and trying 3rd match if still combed (p/c + n)
4874 @item pc_u
4875 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
4876 @item pc_n_ub
4877 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
4878 still combed (p/c + n + u/b)
4879 @item pcn
4880 3-way matching (p/c/n)
4881 @item pcn_ub
4882 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
4883 detected as combed (p/c/n + u/b)
4884 @end table
4885
4886 The parenthesis at the end indicate the matches that would be used for that
4887 mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
4888 @var{top}).
4889
4890 In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
4891 the slowest.
4892
4893 Default value is @var{pc_n}.
4894
4895 @item ppsrc
4896 Mark the main input stream as a pre-processed input, and enable the secondary
4897 input stream as the clean source to pick the fields from. See the filter
4898 introduction for more details. It is similar to the @option{clip2} feature from
4899 VFM/TFM.
4900
4901 Default value is @code{0} (disabled).
4902
4903 @item field
4904 Set the field to match from. It is recommended to set this to the same value as
4905 @option{order} unless you experience matching failures with that setting. In
4906 certain circumstances changing the field that is used to match from can have a
4907 large impact on matching performance. Available values are:
4908
4909 @table @samp
4910 @item auto
4911 Automatic (same value as @option{order}).
4912 @item bottom
4913 Match from the bottom field.
4914 @item top
4915 Match from the top field.
4916 @end table
4917
4918 Default value is @var{auto}.
4919
4920 @item mchroma
4921 Set whether or not chroma is included during the match comparisons. In most
4922 cases it is recommended to leave this enabled. You should set this to @code{0}
4923 only if your clip has bad chroma problems such as heavy rainbowing or other
4924 artifacts. Setting this to @code{0} could also be used to speed things up at
4925 the cost of some accuracy.
4926
4927 Default value is @code{1}.
4928
4929 @item y0
4930 @item y1
4931 These define an exclusion band which excludes the lines between @option{y0} and
4932 @option{y1} from being included in the field matching decision. An exclusion
4933 band can be used to ignore subtitles, a logo, or other things that may
4934 interfere with the matching. @option{y0} sets the starting scan line and
4935 @option{y1} sets the ending line; all lines in between @option{y0} and
4936 @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
4937 @option{y0} and @option{y1} to the same value will disable the feature.
4938 @option{y0} and @option{y1} defaults to @code{0}.
4939
4940 @item scthresh
4941 Set the scene change detection threshold as a percentage of maximum change on
4942 the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
4943 detection is only relevant in case @option{combmatch}=@var{sc}.  The range for
4944 @option{scthresh} is @code{[0.0, 100.0]}.
4945
4946 Default value is @code{12.0}.
4947
4948 @item combmatch
4949 When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
4950 account the combed scores of matches when deciding what match to use as the
4951 final match. Available values are:
4952
4953 @table @samp
4954 @item none
4955 No final matching based on combed scores.
4956 @item sc
4957 Combed scores are only used when a scene change is detected.
4958 @item full
4959 Use combed scores all the time.
4960 @end table
4961
4962 Default is @var{sc}.
4963
4964 @item combdbg
4965 Force @code{fieldmatch} to calculate the combed metrics for certain matches and
4966 print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
4967 Available values are:
4968
4969 @table @samp
4970 @item none
4971 No forced calculation.
4972 @item pcn
4973 Force p/c/n calculations.
4974 @item pcnub
4975 Force p/c/n/u/b calculations.
4976 @end table
4977
4978 Default value is @var{none}.
4979
4980 @item cthresh
4981 This is the area combing threshold used for combed frame detection. This
4982 essentially controls how "strong" or "visible" combing must be to be detected.
4983 Larger values mean combing must be more visible and smaller values mean combing
4984 can be less visible or strong and still be detected. Valid settings are from
4985 @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
4986 be detected as combed). This is basically a pixel difference value. A good
4987 range is @code{[8, 12]}.
4988
4989 Default value is @code{9}.
4990
4991 @item chroma
4992 Sets whether or not chroma is considered in the combed frame decision.  Only
4993 disable this if your source has chroma problems (rainbowing, etc.) that are
4994 causing problems for the combed frame detection with chroma enabled. Actually,
4995 using @option{chroma}=@var{0} is usually more reliable, except for the case
4996 where there is chroma only combing in the source.
4997
4998 Default value is @code{0}.
4999
5000 @item blockx
5001 @item blocky
5002 Respectively set the x-axis and y-axis size of the window used during combed
5003 frame detection. This has to do with the size of the area in which
5004 @option{combpel} pixels are required to be detected as combed for a frame to be
5005 declared combed. See the @option{combpel} parameter description for more info.
5006 Possible values are any number that is a power of 2 starting at 4 and going up
5007 to 512.
5008
5009 Default value is @code{16}.
5010
5011 @item combpel
5012 The number of combed pixels inside any of the @option{blocky} by
5013 @option{blockx} size blocks on the frame for the frame to be detected as
5014 combed. While @option{cthresh} controls how "visible" the combing must be, this
5015 setting controls "how much" combing there must be in any localized area (a
5016 window defined by the @option{blockx} and @option{blocky} settings) on the
5017 frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
5018 which point no frames will ever be detected as combed). This setting is known
5019 as @option{MI} in TFM/VFM vocabulary.
5020
5021 Default value is @code{80}.
5022 @end table
5023
5024 @anchor{p/c/n/u/b meaning}
5025 @subsection p/c/n/u/b meaning
5026
5027 @subsubsection p/c/n
5028
5029 We assume the following telecined stream:
5030
5031 @example
5032 Top fields:     1 2 2 3 4
5033 Bottom fields:  1 2 3 4 4
5034 @end example
5035
5036 The numbers correspond to the progressive frame the fields relate to. Here, the
5037 first two frames are progressive, the 3rd and 4th are combed, and so on.
5038
5039 When @code{fieldmatch} is configured to run a matching from bottom
5040 (@option{field}=@var{bottom}) this is how this input stream get transformed:
5041
5042 @example
5043 Input stream:
5044                 T     1 2 2 3 4
5045                 B     1 2 3 4 4   <-- matching reference
5046
5047 Matches:              c c n n c
5048
5049 Output stream:
5050                 T     1 2 3 4 4
5051                 B     1 2 3 4 4
5052 @end example
5053
5054 As a result of the field matching, we can see that some frames get duplicated.
5055 To perform a complete inverse telecine, you need to rely on a decimation filter
5056 after this operation. See for instance the @ref{decimate} filter.
5057
5058 The same operation now matching from top fields (@option{field}=@var{top})
5059 looks like this:
5060
5061 @example
5062 Input stream:
5063                 T     1 2 2 3 4   <-- matching reference
5064                 B     1 2 3 4 4
5065
5066 Matches:              c c p p c
5067
5068 Output stream:
5069                 T     1 2 2 3 4
5070                 B     1 2 2 3 4
5071 @end example
5072
5073 In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
5074 basically, they refer to the frame and field of the opposite parity:
5075
5076 @itemize
5077 @item @var{p} matches the field of the opposite parity in the previous frame
5078 @item @var{c} matches the field of the opposite parity in the current frame
5079 @item @var{n} matches the field of the opposite parity in the next frame
5080 @end itemize
5081
5082 @subsubsection u/b
5083
5084 The @var{u} and @var{b} matching are a bit special in the sense that they match
5085 from the opposite parity flag. In the following examples, we assume that we are
5086 currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
5087 'x' is placed above and below each matched fields.
5088
5089 With bottom matching (@option{field}=@var{bottom}):
5090 @example
5091 Match:           c         p           n          b          u
5092
5093                  x       x               x        x          x
5094   Top          1 2 2     1 2 2       1 2 2      1 2 2      1 2 2
5095   Bottom       1 2 3     1 2 3       1 2 3      1 2 3      1 2 3
5096                  x         x           x        x              x
5097
5098 Output frames:
5099                  2          1          2          2          2
5100                  2          2          2          1          3
5101 @end example
5102
5103 With top matching (@option{field}=@var{top}):
5104 @example
5105 Match:           c         p           n          b          u
5106
5107                  x         x           x        x              x
5108   Top          1 2 2     1 2 2       1 2 2      1 2 2      1 2 2
5109   Bottom       1 2 3     1 2 3       1 2 3      1 2 3      1 2 3
5110                  x       x               x        x          x
5111
5112 Output frames:
5113                  2          2          2          1          2
5114                  2          1          3          2          2
5115 @end example
5116
5117 @subsection Examples
5118
5119 Simple IVTC of a top field first telecined stream:
5120 @example
5121 fieldmatch=order=tff:combmatch=none, decimate
5122 @end example
5123
5124 Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
5125 @example
5126 fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
5127 @end example
5128
5129 @section fieldorder
5130
5131 Transform the field order of the input video.
5132
5133 It accepts the following parameters:
5134
5135 @table @option
5136
5137 @item order
5138 The output field order. Valid values are @var{tff} for top field first or @var{bff}
5139 for bottom field first.
5140 @end table
5141
5142 The default value is @samp{tff}.
5143
5144 The transformation is done by shifting the picture content up or down
5145 by one line, and filling the remaining line with appropriate picture content.
5146 This method is consistent with most broadcast field order converters.
5147
5148 If the input video is not flagged as being interlaced, or it is already
5149 flagged as being of the required output field order, then this filter does
5150 not alter the incoming video.
5151
5152 It is very useful when converting to or from PAL DV material,
5153 which is bottom field first.
5154
5155 For example:
5156 @example
5157 ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
5158 @end example
5159
5160 @section fifo
5161
5162 Buffer input images and send them when they are requested.
5163
5164 It is mainly useful when auto-inserted by the libavfilter
5165 framework.
5166
5167 It does not take parameters.
5168
5169 @section find_rect
5170
5171 Find a rectangular object
5172
5173 It accepts the following options:
5174
5175 @table @option
5176 @item object
5177 Filepath of the object image, needs to be in gray8.
5178
5179 @item threshold
5180 Detection threshold, default is 0.5.
5181
5182 @item mipmaps
5183 Number of mipmaps, default is 3.
5184
5185 @item xmin, ymin, xmax, ymax
5186 Specifies the rectangle in which to search.
5187 @end table
5188
5189 @subsection Examples
5190
5191 @itemize
5192 @item
5193 Generate a representative palette of a given video using @command{ffmpeg}:
5194 @example
5195 ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
5196 @end example
5197 @end itemize
5198
5199 @section cover_rect
5200
5201 Cover a rectangular object
5202
5203 It accepts the following options:
5204
5205 @table @option
5206 @item cover
5207 Filepath of the optional cover image, needs to be in yuv420.
5208
5209 @item mode
5210 Set covering mode.
5211
5212 It accepts the following values:
5213 @table @samp
5214 @item cover
5215 cover it by the supplied image
5216 @item blur
5217 cover it by interpolating the surrounding pixels
5218 @end table
5219
5220 Default value is @var{blur}.
5221 @end table
5222
5223 @subsection Examples
5224
5225 @itemize
5226 @item
5227 Generate a representative palette of a given video using @command{ffmpeg}:
5228 @example
5229 ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
5230 @end example
5231 @end itemize
5232
5233 @anchor{format}
5234 @section format
5235
5236 Convert the input video to one of the specified pixel formats.
5237 Libavfilter will try to pick one that is suitable as input to
5238 the next filter.
5239
5240 It accepts the following parameters:
5241 @table @option
5242
5243 @item pix_fmts
5244 A '|'-separated list of pixel format names, such as
5245 "pix_fmts=yuv420p|monow|rgb24".
5246
5247 @end table
5248
5249 @subsection Examples
5250
5251 @itemize
5252 @item
5253 Convert the input video to the @var{yuv420p} format
5254 @example
5255 format=pix_fmts=yuv420p
5256 @end example
5257
5258 Convert the input video to any of the formats in the list
5259 @example
5260 format=pix_fmts=yuv420p|yuv444p|yuv410p
5261 @end example
5262 @end itemize
5263
5264 @anchor{fps}
5265 @section fps
5266
5267 Convert the video to specified constant frame rate by duplicating or dropping
5268 frames as necessary.
5269
5270 It accepts the following parameters:
5271 @table @option
5272
5273 @item fps
5274 The desired output frame rate. The default is @code{25}.
5275
5276 @item round
5277 Rounding method.
5278
5279 Possible values are:
5280 @table @option
5281 @item zero
5282 zero round towards 0
5283 @item inf
5284 round away from 0
5285 @item down
5286 round towards -infinity
5287 @item up
5288 round towards +infinity
5289 @item near
5290 round to nearest
5291 @end table
5292 The default is @code{near}.
5293
5294 @item start_time
5295 Assume the first PTS should be the given value, in seconds. This allows for
5296 padding/trimming at the start of stream. By default, no assumption is made
5297 about the first frame's expected PTS, so no padding or trimming is done.
5298 For example, this could be set to 0 to pad the beginning with duplicates of
5299 the first frame if a video stream starts after the audio stream or to trim any
5300 frames with a negative PTS.
5301
5302 @end table
5303
5304 Alternatively, the options can be specified as a flat string:
5305 @var{fps}[:@var{round}].
5306
5307 See also the @ref{setpts} filter.
5308
5309 @subsection Examples
5310
5311 @itemize
5312 @item
5313 A typical usage in order to set the fps to 25:
5314 @example
5315 fps=fps=25
5316 @end example
5317
5318 @item
5319 Sets the fps to 24, using abbreviation and rounding method to round to nearest:
5320 @example
5321 fps=fps=film:round=near
5322 @end example
5323 @end itemize
5324
5325 @section framepack
5326
5327 Pack two different video streams into a stereoscopic video, setting proper
5328 metadata on supported codecs. The two views should have the same size and
5329 framerate and processing will stop when the shorter video ends. Please note
5330 that you may conveniently adjust view properties with the @ref{scale} and
5331 @ref{fps} filters.
5332
5333 It accepts the following parameters:
5334 @table @option
5335
5336 @item format
5337 The desired packing format. Supported values are:
5338
5339 @table @option
5340
5341 @item sbs
5342 The views are next to each other (default).
5343
5344 @item tab
5345 The views are on top of each other.
5346
5347 @item lines
5348 The views are packed by line.
5349
5350 @item columns
5351 The views are packed by column.
5352
5353 @item frameseq
5354 The views are temporally interleaved.
5355
5356 @end table
5357
5358 @end table
5359
5360 Some examples:
5361
5362 @example
5363 # Convert left and right views into a frame-sequential video
5364 ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
5365
5366 # Convert views into a side-by-side video with the same output resolution as the input
5367 ffmpeg -i LEFT -i RIGHT -filter_complex [0:v]scale=w=iw/2[left],[1:v]scale=w=iw/2[right],[left][right]framepack=sbs OUTPUT
5368 @end example
5369
5370 @section framestep
5371
5372 Select one frame every N-th frame.
5373
5374 This filter accepts the following option:
5375 @table @option
5376 @item step
5377 Select frame after every @code{step} frames.
5378 Allowed values are positive integers higher than 0. Default value is @code{1}.
5379 @end table
5380
5381 @anchor{frei0r}
5382 @section frei0r
5383
5384 Apply a frei0r effect to the input video.
5385
5386 To enable the compilation of this filter, you need to install the frei0r
5387 header and configure FFmpeg with @code{--enable-frei0r}.
5388
5389 It accepts the following parameters:
5390
5391 @table @option
5392
5393 @item filter_name
5394 The name of the frei0r effect to load. If the environment variable
5395 @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
5396 directories specified by the colon-separated list in @env{FREIOR_PATH}.
5397 Otherwise, the standard frei0r paths are searched, in this order:
5398 @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
5399 @file{/usr/lib/frei0r-1/}.
5400
5401 @item filter_params
5402 A '|'-separated list of parameters to pass to the frei0r effect.
5403
5404 @end table
5405
5406 A frei0r effect parameter can be a boolean (its value is either
5407 "y" or "n"), a double, a color (specified as
5408 @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
5409 numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
5410 section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
5411 @var{X} and @var{Y} are floating point numbers) and/or a string.
5412
5413 The number and types of parameters depend on the loaded effect. If an
5414 effect parameter is not specified, the default value is set.
5415
5416 @subsection Examples
5417
5418 @itemize
5419 @item
5420 Apply the distort0r effect, setting the first two double parameters:
5421 @example
5422 frei0r=filter_name=distort0r:filter_params=0.5|0.01
5423 @end example
5424
5425 @item
5426 Apply the colordistance effect, taking a color as the first parameter:
5427 @example
5428 frei0r=colordistance:0.2/0.3/0.4
5429 frei0r=colordistance:violet
5430 frei0r=colordistance:0x112233
5431 @end example
5432
5433 @item
5434 Apply the perspective effect, specifying the top left and top right image
5435 positions:
5436 @example
5437 frei0r=perspective:0.2/0.2|0.8/0.2
5438 @end example
5439 @end itemize
5440
5441 For more information, see
5442 @url{http://frei0r.dyne.org}
5443
5444 @section fspp
5445
5446 Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
5447
5448 It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
5449 processing filter, one of them is performed once per block, not per pixel.
5450 This allows for much higher speed.
5451
5452 The filter accepts the following options:
5453
5454 @table @option
5455 @item quality
5456 Set quality. This option defines the number of levels for averaging. It accepts
5457 an integer in the range 4-5. Default value is @code{4}.
5458
5459 @item qp
5460 Force a constant quantization parameter. It accepts an integer in range 0-63.
5461 If not set, the filter will use the QP from the video stream (if available).
5462
5463 @item strength
5464 Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
5465 more details but also more artifacts, while higher values make the image smoother
5466 but also blurrier. Default value is @code{0} âˆ’ PSNR optimal.
5467
5468 @item use_bframe_qp
5469 Enable the use of the QP from the B-Frames if set to @code{1}. Using this
5470 option may cause flicker since the B-Frames have often larger QP. Default is
5471 @code{0} (not enabled).
5472
5473 @end table
5474
5475 @section geq
5476
5477 The filter accepts the following options:
5478
5479 @table @option
5480 @item lum_expr, lum
5481 Set the luminance expression.
5482 @item cb_expr, cb
5483 Set the chrominance blue expression.
5484 @item cr_expr, cr
5485 Set the chrominance red expression.
5486 @item alpha_expr, a
5487 Set the alpha expression.
5488 @item red_expr, r
5489 Set the red expression.
5490 @item green_expr, g
5491 Set the green expression.
5492 @item blue_expr, b
5493 Set the blue expression.
5494 @end table
5495
5496 The colorspace is selected according to the specified options. If one
5497 of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
5498 options is specified, the filter will automatically select a YCbCr
5499 colorspace. If one of the @option{red_expr}, @option{green_expr}, or
5500 @option{blue_expr} options is specified, it will select an RGB
5501 colorspace.
5502
5503 If one of the chrominance expression is not defined, it falls back on the other
5504 one. If no alpha expression is specified it will evaluate to opaque value.
5505 If none of chrominance expressions are specified, they will evaluate
5506 to the luminance expression.
5507
5508 The expressions can use the following variables and functions:
5509
5510 @table @option
5511 @item N
5512 The sequential number of the filtered frame, starting from @code{0}.
5513
5514 @item X
5515 @item Y
5516 The coordinates of the current sample.
5517
5518 @item W
5519 @item H
5520 The width and height of the image.
5521
5522 @item SW
5523 @item SH
5524 Width and height scale depending on the currently filtered plane. It is the
5525 ratio between the corresponding luma plane number of pixels and the current
5526 plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
5527 @code{0.5,0.5} for chroma planes.
5528
5529 @item T
5530 Time of the current frame, expressed in seconds.
5531
5532 @item p(x, y)
5533 Return the value of the pixel at location (@var{x},@var{y}) of the current
5534 plane.
5535
5536 @item lum(x, y)
5537 Return the value of the pixel at location (@var{x},@var{y}) of the luminance
5538 plane.
5539
5540 @item cb(x, y)
5541 Return the value of the pixel at location (@var{x},@var{y}) of the
5542 blue-difference chroma plane. Return 0 if there is no such plane.
5543
5544 @item cr(x, y)
5545 Return the value of the pixel at location (@var{x},@var{y}) of the
5546 red-difference chroma plane. Return 0 if there is no such plane.
5547
5548 @item r(x, y)
5549 @item g(x, y)
5550 @item b(x, y)
5551 Return the value of the pixel at location (@var{x},@var{y}) of the
5552 red/green/blue component. Return 0 if there is no such component.
5553
5554 @item alpha(x, y)
5555 Return the value of the pixel at location (@var{x},@var{y}) of the alpha
5556 plane. Return 0 if there is no such plane.
5557 @end table
5558
5559 For functions, if @var{x} and @var{y} are outside the area, the value will be
5560 automatically clipped to the closer edge.
5561
5562 @subsection Examples
5563
5564 @itemize
5565 @item
5566 Flip the image horizontally:
5567 @example
5568 geq=p(W-X\,Y)
5569 @end example
5570
5571 @item
5572 Generate a bidimensional sine wave, with angle @code{PI/3} and a
5573 wavelength of 100 pixels:
5574 @example
5575 geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
5576 @end example
5577
5578 @item
5579 Generate a fancy enigmatic moving light:
5580 @example
5581 nullsrc=s=256x256,geq=random(1)/hypot(X-cos(N*0.07)*W/2-W/2\,Y-sin(N*0.09)*H/2-H/2)^2*1000000*sin(N*0.02):128:128
5582 @end example
5583
5584 @item
5585 Generate a quick emboss effect:
5586 @example
5587 format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
5588 @end example
5589
5590 @item
5591 Modify RGB components depending on pixel position:
5592 @example
5593 geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
5594 @end example
5595
5596 @item
5597 Create a radial gradient that is the same size as the input (also see
5598 the @ref{vignette} filter):
5599 @example
5600 geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
5601 @end example
5602
5603 @item
5604 Create a linear gradient to use as a mask for another filter, then
5605 compose with @ref{overlay}. In this example the video will gradually
5606 become more blurry from the top to the bottom of the y-axis as defined
5607 by the linear gradient:
5608 @example
5609 ffmpeg -i input.mp4 -filter_complex "geq=lum=255*(Y/H),format=gray[grad];[0:v]boxblur=4[blur];[blur][grad]alphamerge[alpha];[0:v][alpha]overlay" output.mp4
5610 @end example
5611 @end itemize
5612
5613 @section gradfun
5614
5615 Fix the banding artifacts that are sometimes introduced into nearly flat
5616 regions by truncation to 8bit color depth.
5617 Interpolate the gradients that should go where the bands are, and
5618 dither them.
5619
5620 It is designed for playback only.  Do not use it prior to
5621 lossy compression, because compression tends to lose the dither and
5622 bring back the bands.
5623
5624 It accepts the following parameters:
5625
5626 @table @option
5627
5628 @item strength
5629 The maximum amount by which the filter will change any one pixel. This is also
5630 the threshold for detecting nearly flat regions. Acceptable values range from
5631 .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
5632 valid range.
5633
5634 @item radius
5635 The neighborhood to fit the gradient to. A larger radius makes for smoother
5636 gradients, but also prevents the filter from modifying the pixels near detailed
5637 regions. Acceptable values are 8-32; the default value is 16. Out-of-range
5638 values will be clipped to the valid range.
5639
5640 @end table
5641
5642 Alternatively, the options can be specified as a flat string:
5643 @var{strength}[:@var{radius}]
5644
5645 @subsection Examples
5646
5647 @itemize
5648 @item
5649 Apply the filter with a @code{3.5} strength and radius of @code{8}:
5650 @example
5651 gradfun=3.5:8
5652 @end example
5653
5654 @item
5655 Specify radius, omitting the strength (which will fall-back to the default
5656 value):
5657 @example
5658 gradfun=radius=8
5659 @end example
5660
5661 @end itemize
5662
5663 @anchor{haldclut}
5664 @section haldclut
5665
5666 Apply a Hald CLUT to a video stream.
5667
5668 First input is the video stream to process, and second one is the Hald CLUT.
5669 The Hald CLUT input can be a simple picture or a complete video stream.
5670
5671 The filter accepts the following options:
5672
5673 @table @option
5674 @item shortest
5675 Force termination when the shortest input terminates. Default is @code{0}.
5676 @item repeatlast
5677 Continue applying the last CLUT after the end of the stream. A value of
5678 @code{0} disable the filter after the last frame of the CLUT is reached.
5679 Default is @code{1}.
5680 @end table
5681
5682 @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
5683 filters share the same internals).
5684
5685 More information about the Hald CLUT can be found on Eskil Steenberg's website
5686 (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
5687
5688 @subsection Workflow examples
5689
5690 @subsubsection Hald CLUT video stream
5691
5692 Generate an identity Hald CLUT stream altered with various effects:
5693 @example
5694 ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "hue=H=2*PI*t:s=sin(2*PI*t)+1, curves=cross_process" -t 10 -c:v ffv1 clut.nut
5695 @end example
5696
5697 Note: make sure you use a lossless codec.
5698
5699 Then use it with @code{haldclut} to apply it on some random stream:
5700 @example
5701 ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
5702 @end example
5703
5704 The Hald CLUT will be applied to the 10 first seconds (duration of
5705 @file{clut.nut}), then the latest picture of that CLUT stream will be applied
5706 to the remaining frames of the @code{mandelbrot} stream.
5707
5708 @subsubsection Hald CLUT with preview
5709
5710 A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
5711 @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
5712 biggest possible square starting at the top left of the picture. The remaining
5713 padding pixels (bottom or right) will be ignored. This area can be used to add
5714 a preview of the Hald CLUT.
5715
5716 Typically, the following generated Hald CLUT will be supported by the
5717 @code{haldclut} filter:
5718
5719 @example
5720 ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
5721    pad=iw+320 [padded_clut];
5722    smptebars=s=320x256, split [a][b];
5723    [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
5724    [main][b] overlay=W-320" -frames:v 1 clut.png
5725 @end example
5726
5727 It contains the original and a preview of the effect of the CLUT: SMPTE color
5728 bars are displayed on the right-top, and below the same color bars processed by
5729 the color changes.
5730
5731 Then, the effect of this Hald CLUT can be visualized with:
5732 @example
5733 ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
5734 @end example
5735
5736 @section hflip
5737
5738 Flip the input video horizontally.
5739
5740 For example, to horizontally flip the input video with @command{ffmpeg}:
5741 @example
5742 ffmpeg -i in.avi -vf "hflip" out.avi
5743 @end example
5744
5745 @section histeq
5746 This filter applies a global color histogram equalization on a
5747 per-frame basis.
5748
5749 It can be used to correct video that has a compressed range of pixel
5750 intensities.  The filter redistributes the pixel intensities to
5751 equalize their distribution across the intensity range. It may be
5752 viewed as an "automatically adjusting contrast filter". This filter is
5753 useful only for correcting degraded or poorly captured source
5754 video.
5755
5756 The filter accepts the following options:
5757
5758 @table @option
5759 @item strength
5760 Determine the amount of equalization to be applied.  As the strength
5761 is reduced, the distribution of pixel intensities more-and-more
5762 approaches that of the input frame. The value must be a float number
5763 in the range [0,1] and defaults to 0.200.
5764
5765 @item intensity
5766 Set the maximum intensity that can generated and scale the output
5767 values appropriately.  The strength should be set as desired and then
5768 the intensity can be limited if needed to avoid washing-out. The value
5769 must be a float number in the range [0,1] and defaults to 0.210.
5770
5771 @item antibanding
5772 Set the antibanding level. If enabled the filter will randomly vary
5773 the luminance of output pixels by a small amount to avoid banding of
5774 the histogram. Possible values are @code{none}, @code{weak} or
5775 @code{strong}. It defaults to @code{none}.
5776 @end table
5777
5778 @section histogram
5779
5780 Compute and draw a color distribution histogram for the input video.
5781
5782 The computed histogram is a representation of the color component
5783 distribution in an image.
5784
5785 The filter accepts the following options:
5786
5787 @table @option
5788 @item mode
5789 Set histogram mode.
5790
5791 It accepts the following values:
5792 @table @samp
5793 @item levels
5794 Standard histogram that displays the color components distribution in an
5795 image. Displays color graph for each color component. Shows distribution of
5796 the Y, U, V, A or R, G, B components, depending on input format, in the
5797 current frame. Below each graph a color component scale meter is shown.
5798
5799 @item color
5800 Displays chroma values (U/V color placement) in a two dimensional
5801 graph (which is called a vectorscope). The brighter a pixel in the
5802 vectorscope, the more pixels of the input frame correspond to that pixel
5803 (i.e., more pixels have this chroma value). The V component is displayed on
5804 the horizontal (X) axis, with the leftmost side being V = 0 and the rightmost
5805 side being V = 255. The U component is displayed on the vertical (Y) axis,
5806 with the top representing U = 0 and the bottom representing U = 255.
5807
5808 The position of a white pixel in the graph corresponds to the chroma value of
5809 a pixel of the input clip. The graph can therefore be used to read the hue
5810 (color flavor) and the saturation (the dominance of the hue in the color). As
5811 the hue of a color changes, it moves around the square. At the center of the
5812 square the saturation is zero, which means that the corresponding pixel has no
5813 color. If the amount of a specific color is increased (while leaving the other
5814 colors unchanged) the saturation increases, and the indicator moves towards
5815 the edge of the square.
5816
5817 @item color2
5818 Chroma values in vectorscope, similar as @code{color} but actual chroma values
5819 are displayed.
5820
5821 @item waveform
5822 Per row/column color component graph. In row mode, the graph on the left side
5823 represents color component value 0 and the right side represents value = 255.
5824 In column mode, the top side represents color component value = 0 and bottom
5825 side represents value = 255.
5826 @end table
5827 Default value is @code{levels}.
5828
5829 @item level_height
5830 Set height of level in @code{levels}. Default value is @code{200}.
5831 Allowed range is [50, 2048].
5832
5833 @item scale_height
5834 Set height of color scale in @code{levels}. Default value is @code{12}.
5835 Allowed range is [0, 40].
5836
5837 @item step
5838 Set step for @code{waveform} mode. Smaller values are useful to find out how
5839 many values of the same luminance are distributed across input rows/columns.
5840 Default value is @code{10}. Allowed range is [1, 255].
5841
5842 @item waveform_mode
5843 Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
5844 Default is @code{row}.
5845
5846 @item waveform_mirror
5847 Set mirroring mode for @code{waveform}. @code{0} means unmirrored, @code{1}
5848 means mirrored. In mirrored mode, higher values will be represented on the left
5849 side for @code{row} mode and at the top for @code{column} mode. Default is
5850 @code{0} (unmirrored).
5851
5852 @item display_mode
5853 Set display mode for @code{waveform} and @code{levels}.
5854 It accepts the following values:
5855 @table @samp
5856 @item parade
5857 Display separate graph for the color components side by side in
5858 @code{row} waveform mode or one below the other in @code{column} waveform mode
5859 for @code{waveform} histogram mode. For @code{levels} histogram mode,
5860 per color component graphs are placed below each other.
5861
5862 Using this display mode in @code{waveform} histogram mode makes it easy to
5863 spot color casts in the highlights and shadows of an image, by comparing the
5864 contours of the top and the bottom graphs of each waveform. Since whites,
5865 grays, and blacks are characterized by exactly equal amounts of red, green,
5866 and blue, neutral areas of the picture should display three waveforms of
5867 roughly equal width/height. If not, the correction is easy to perform by
5868 making level adjustments the three waveforms.
5869
5870 @item overlay
5871 Presents information identical to that in the @code{parade}, except
5872 that the graphs representing color components are superimposed directly
5873 over one another.
5874
5875 This display mode in @code{waveform} histogram mode makes it easier to spot
5876 relative differences or similarities in overlapping areas of the color
5877 components that are supposed to be identical, such as neutral whites, grays,
5878 or blacks.
5879 @end table
5880 Default is @code{parade}.
5881
5882 @item levels_mode
5883 Set mode for @code{levels}. Can be either @code{linear}, or @code{logarithmic}.
5884 Default is @code{linear}.
5885 @end table
5886
5887 @subsection Examples
5888
5889 @itemize
5890
5891 @item
5892 Calculate and draw histogram:
5893 @example
5894 ffplay -i input -vf histogram
5895 @end example
5896
5897 @end itemize
5898
5899 @anchor{hqdn3d}
5900 @section hqdn3d
5901
5902 This is a high precision/quality 3d denoise filter. It aims to reduce
5903 image noise, producing smooth images and making still images really
5904 still. It should enhance compressibility.
5905
5906 It accepts the following optional parameters:
5907
5908 @table @option
5909 @item luma_spatial
5910 A non-negative floating point number which specifies spatial luma strength.
5911 It defaults to 4.0.
5912
5913 @item chroma_spatial
5914 A non-negative floating point number which specifies spatial chroma strength.
5915 It defaults to 3.0*@var{luma_spatial}/4.0.
5916
5917 @item luma_tmp
5918 A floating point number which specifies luma temporal strength. It defaults to
5919 6.0*@var{luma_spatial}/4.0.
5920
5921 @item chroma_tmp
5922 A floating point number which specifies chroma temporal strength. It defaults to
5923 @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
5924 @end table
5925
5926 @section hqx
5927
5928 Apply a high-quality magnification filter designed for pixel art. This filter
5929 was originally created by Maxim Stepin.
5930
5931 It accepts the following option:
5932
5933 @table @option
5934 @item n
5935 Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
5936 @code{hq3x} and @code{4} for @code{hq4x}.
5937 Default is @code{3}.
5938 @end table
5939
5940 @section hue
5941
5942 Modify the hue and/or the saturation of the input.
5943
5944 It accepts the following parameters:
5945
5946 @table @option
5947 @item h
5948 Specify the hue angle as a number of degrees. It accepts an expression,
5949 and defaults to "0".
5950
5951 @item s
5952 Specify the saturation in the [-10,10] range. It accepts an expression and
5953 defaults to "1".
5954
5955 @item H
5956 Specify the hue angle as a number of radians. It accepts an
5957 expression, and defaults to "0".
5958
5959 @item b
5960 Specify the brightness in the [-10,10] range. It accepts an expression and
5961 defaults to "0".
5962 @end table
5963
5964 @option{h} and @option{H} are mutually exclusive, and can't be
5965 specified at the same time.
5966
5967 The @option{b}, @option{h}, @option{H} and @option{s} option values are
5968 expressions containing the following constants:
5969
5970 @table @option
5971 @item n
5972 frame count of the input frame starting from 0
5973
5974 @item pts
5975 presentation timestamp of the input frame expressed in time base units
5976
5977 @item r
5978 frame rate of the input video, NAN if the input frame rate is unknown
5979
5980 @item t
5981 timestamp expressed in seconds, NAN if the input timestamp is unknown
5982
5983 @item tb
5984 time base of the input video
5985 @end table
5986
5987 @subsection Examples
5988
5989 @itemize
5990 @item
5991 Set the hue to 90 degrees and the saturation to 1.0:
5992 @example
5993 hue=h=90:s=1
5994 @end example
5995
5996 @item
5997 Same command but expressing the hue in radians:
5998 @example
5999 hue=H=PI/2:s=1
6000 @end example
6001
6002 @item
6003 Rotate hue and make the saturation swing between 0
6004 and 2 over a period of 1 second:
6005 @example
6006 hue="H=2*PI*t: s=sin(2*PI*t)+1"
6007 @end example
6008
6009 @item
6010 Apply a 3 seconds saturation fade-in effect starting at 0:
6011 @example
6012 hue="s=min(t/3\,1)"
6013 @end example
6014
6015 The general fade-in expression can be written as:
6016 @example
6017 hue="s=min(0\, max((t-START)/DURATION\, 1))"
6018 @end example
6019
6020 @item
6021 Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
6022 @example
6023 hue="s=max(0\, min(1\, (8-t)/3))"
6024 @end example
6025
6026 The general fade-out expression can be written as:
6027 @example
6028 hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
6029 @end example
6030
6031 @end itemize
6032
6033 @subsection Commands
6034
6035 This filter supports the following commands:
6036 @table @option
6037 @item b
6038 @item s
6039 @item h
6040 @item H
6041 Modify the hue and/or the saturation and/or brightness of the input video.
6042 The command accepts the same syntax of the corresponding option.
6043
6044 If the specified expression is not valid, it is kept at its current
6045 value.
6046 @end table
6047
6048 @section idet
6049
6050 Detect video interlacing type.
6051
6052 This filter tries to detect if the input frames as interlaced, progressive,
6053 top or bottom field first. It will also try and detect fields that are
6054 repeated between adjacent frames (a sign of telecine).
6055
6056 Single frame detection considers only immediately adjacent frames when classifying each frame.
6057 Multiple frame detection incorporates the classification history of previous frames.
6058
6059 The filter will log these metadata values:
6060
6061 @table @option
6062 @item single.current_frame
6063 Detected type of current frame using single-frame detection. One of:
6064 ``tff'' (top field first), ``bff'' (bottom field first),
6065 ``progressive'', or ``undetermined''
6066
6067 @item single.tff
6068 Cumulative number of frames detected as top field first using single-frame detection.
6069
6070 @item multiple.tff
6071 Cumulative number of frames detected as top field first using multiple-frame detection.
6072
6073 @item single.bff
6074 Cumulative number of frames detected as bottom field first using single-frame detection.
6075
6076 @item multiple.current_frame
6077 Detected type of current frame using multiple-frame detection. One of:
6078 ``tff'' (top field first), ``bff'' (bottom field first),
6079 ``progressive'', or ``undetermined''
6080
6081 @item multiple.bff
6082 Cumulative number of frames detected as bottom field first using multiple-frame detection.
6083
6084 @item single.progressive
6085 Cumulative number of frames detected as progressive using single-frame detection.
6086
6087 @item multiple.progressive
6088 Cumulative number of frames detected as progressive using multiple-frame detection.
6089
6090 @item single.undetermined
6091 Cumulative number of frames that could not be classified using single-frame detection.
6092
6093 @item multiple.undetermined
6094 Cumulative number of frames that could not be classified using multiple-frame detection.
6095
6096 @item repeated.current_frame
6097 Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
6098
6099 @item repeated.neither
6100 Cumulative number of frames with no repeated field.
6101
6102 @item repeated.top
6103 Cumulative number of frames with the top field repeated from the previous frame's top field.
6104
6105 @item repeated.bottom
6106 Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
6107 @end table
6108
6109 The filter accepts the following options:
6110
6111 @table @option
6112 @item intl_thres
6113 Set interlacing threshold.
6114 @item prog_thres
6115 Set progressive threshold.
6116 @item repeat_thres
6117 Threshold for repeated field detection.
6118 @item half_life
6119 Number of frames after which a given frame's contribution to the
6120 statistics is halved (i.e., it contributes only 0.5 to it's
6121 classification). The default of 0 means that all frames seen are given
6122 full weight of 1.0 forever.
6123 @item analyze_interlaced_flag
6124 When this is not 0 then idet will use the specified number of frames to determine
6125 if the interlaced flag is accurate, it will not count undetermined frames.
6126 If the flag is found to be accurate it will be used without any further
6127 computations, if it is found to be inaccuarte it will be cleared without any
6128 further computations. This allows inserting the idet filter as a low computational
6129 method to clean up the interlaced flag
6130 @end table
6131
6132 @section il
6133
6134 Deinterleave or interleave fields.
6135
6136 This filter allows one to process interlaced images fields without
6137 deinterlacing them. Deinterleaving splits the input frame into 2
6138 fields (so called half pictures). Odd lines are moved to the top
6139 half of the output image, even lines to the bottom half.
6140 You can process (filter) them independently and then re-interleave them.
6141
6142 The filter accepts the following options:
6143
6144 @table @option
6145 @item luma_mode, l
6146 @item chroma_mode, c
6147 @item alpha_mode, a
6148 Available values for @var{luma_mode}, @var{chroma_mode} and
6149 @var{alpha_mode} are:
6150
6151 @table @samp
6152 @item none
6153 Do nothing.
6154
6155 @item deinterleave, d
6156 Deinterleave fields, placing one above the other.
6157
6158 @item interleave, i
6159 Interleave fields. Reverse the effect of deinterleaving.
6160 @end table
6161 Default value is @code{none}.
6162
6163 @item luma_swap, ls
6164 @item chroma_swap, cs
6165 @item alpha_swap, as
6166 Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
6167 @end table
6168
6169 @section interlace
6170
6171 Simple interlacing filter from progressive contents. This interleaves upper (or
6172 lower) lines from odd frames with lower (or upper) lines from even frames,
6173 halving the frame rate and preserving image height.
6174
6175 @example
6176    Original        Original             New Frame
6177    Frame 'j'      Frame 'j+1'             (tff)
6178   ==========      ===========       ==================
6179     Line 0  -------------------->    Frame 'j' Line 0
6180     Line 1          Line 1  ---->   Frame 'j+1' Line 1
6181     Line 2 --------------------->    Frame 'j' Line 2
6182     Line 3          Line 3  ---->   Frame 'j+1' Line 3
6183      ...             ...                   ...
6184 New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
6185 @end example
6186
6187 It accepts the following optional parameters:
6188
6189 @table @option
6190 @item scan
6191 This determines whether the interlaced frame is taken from the even
6192 (tff - default) or odd (bff) lines of the progressive frame.
6193
6194 @item lowpass
6195 Enable (default) or disable the vertical lowpass filter to avoid twitter
6196 interlacing and reduce moire patterns.
6197 @end table
6198
6199 @section kerndeint
6200
6201 Deinterlace input video by applying Donald Graft's adaptive kernel
6202 deinterling. Work on interlaced parts of a video to produce
6203 progressive frames.
6204
6205 The description of the accepted parameters follows.
6206
6207 @table @option
6208 @item thresh
6209 Set the threshold which affects the filter's tolerance when
6210 determining if a pixel line must be processed. It must be an integer
6211 in the range [0,255] and defaults to 10. A value of 0 will result in
6212 applying the process on every pixels.
6213
6214 @item map
6215 Paint pixels exceeding the threshold value to white if set to 1.
6216 Default is 0.
6217
6218 @item order
6219 Set the fields order. Swap fields if set to 1, leave fields alone if
6220 0. Default is 0.
6221
6222 @item sharp
6223 Enable additional sharpening if set to 1. Default is 0.
6224
6225 @item twoway
6226 Enable twoway sharpening if set to 1. Default is 0.
6227 @end table
6228
6229 @subsection Examples
6230
6231 @itemize
6232 @item
6233 Apply default values:
6234 @example
6235 kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
6236 @end example
6237
6238 @item
6239 Enable additional sharpening:
6240 @example
6241 kerndeint=sharp=1
6242 @end example
6243
6244 @item
6245 Paint processed pixels in white:
6246 @example
6247 kerndeint=map=1
6248 @end example
6249 @end itemize
6250
6251 @section lenscorrection
6252
6253 Correct radial lens distortion
6254
6255 This filter can be used to correct for radial distortion as can result from the use
6256 of wide angle lenses, and thereby re-rectify the image. To find the right parameters
6257 one can use tools available for example as part of opencv or simply trial-and-error.
6258 To use opencv use the calibration sample (under samples/cpp) from the opencv sources
6259 and extract the k1 and k2 coefficients from the resulting matrix.
6260
6261 Note that effectively the same filter is available in the open-source tools Krita and
6262 Digikam from the KDE project.
6263
6264 In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
6265 this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
6266 brightness distribution, so you may want to use both filters together in certain
6267 cases, though you will have to take care of ordering, i.e. whether vignetting should
6268 be applied before or after lens correction.
6269
6270 @subsection Options
6271
6272 The filter accepts the following options:
6273
6274 @table @option
6275 @item cx
6276 Relative x-coordinate of the focal point of the image, and thereby the center of the
6277 distortion. This value has a range [0,1] and is expressed as fractions of the image
6278 width.
6279 @item cy
6280 Relative y-coordinate of the focal point of the image, and thereby the center of the
6281 distortion. This value has a range [0,1] and is expressed as fractions of the image
6282 height.
6283 @item k1
6284 Coefficient of the quadratic correction term. 0.5 means no correction.
6285 @item k2
6286 Coefficient of the double quadratic correction term. 0.5 means no correction.
6287 @end table
6288
6289 The formula that generates the correction is:
6290
6291 @var{r_src} = @var{r_tgt} * (1 + @var{k1} * (@var{r_tgt} / @var{r_0})^2 + @var{k2} * (@var{r_tgt} / @var{r_0})^4)
6292
6293 where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
6294 distances from the focal point in the source and target images, respectively.
6295
6296 @anchor{lut3d}
6297 @section lut3d
6298
6299 Apply a 3D LUT to an input video.
6300
6301 The filter accepts the following options:
6302
6303 @table @option
6304 @item file
6305 Set the 3D LUT file name.
6306
6307 Currently supported formats:
6308 @table @samp
6309 @item 3dl
6310 AfterEffects
6311 @item cube
6312 Iridas
6313 @item dat
6314 DaVinci
6315 @item m3d
6316 Pandora
6317 @end table
6318 @item interp
6319 Select interpolation mode.
6320
6321 Available values are:
6322
6323 @table @samp
6324 @item nearest
6325 Use values from the nearest defined point.
6326 @item trilinear
6327 Interpolate values using the 8 points defining a cube.
6328 @item tetrahedral
6329 Interpolate values using a tetrahedron.
6330 @end table
6331 @end table
6332
6333 @section lut, lutrgb, lutyuv
6334
6335 Compute a look-up table for binding each pixel component input value
6336 to an output value, and apply it to the input video.
6337
6338 @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
6339 to an RGB input video.
6340
6341 These filters accept the following parameters:
6342 @table @option
6343 @item c0
6344 set first pixel component expression
6345 @item c1
6346 set second pixel component expression
6347 @item c2
6348 set third pixel component expression
6349 @item c3
6350 set fourth pixel component expression, corresponds to the alpha component
6351
6352 @item r
6353 set red component expression
6354 @item g
6355 set green component expression
6356 @item b
6357 set blue component expression
6358 @item a
6359 alpha component expression
6360
6361 @item y
6362 set Y/luminance component expression
6363 @item u
6364 set U/Cb component expression
6365 @item v
6366 set V/Cr component expression
6367 @end table
6368
6369 Each of them specifies the expression to use for computing the lookup table for
6370 the corresponding pixel component values.
6371
6372 The exact component associated to each of the @var{c*} options depends on the
6373 format in input.
6374
6375 The @var{lut} filter requires either YUV or RGB pixel formats in input,
6376 @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
6377
6378 The expressions can contain the following constants and functions:
6379
6380 @table @option
6381 @item w
6382 @item h
6383 The input width and height.
6384
6385 @item val
6386 The input value for the pixel component.
6387
6388 @item clipval
6389 The input value, clipped to the @var{minval}-@var{maxval} range.
6390
6391 @item maxval
6392 The maximum value for the pixel component.
6393
6394 @item minval
6395 The minimum value for the pixel component.
6396
6397 @item negval
6398 The negated value for the pixel component value, clipped to the
6399 @var{minval}-@var{maxval} range; it corresponds to the expression
6400 "maxval-clipval+minval".
6401
6402 @item clip(val)
6403 The computed value in @var{val}, clipped to the
6404 @var{minval}-@var{maxval} range.
6405
6406 @item gammaval(gamma)
6407 The computed gamma correction value of the pixel component value,
6408 clipped to the @var{minval}-@var{maxval} range. It corresponds to the
6409 expression
6410 "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
6411
6412 @end table
6413
6414 All expressions default to "val".
6415
6416 @subsection Examples
6417
6418 @itemize
6419 @item
6420 Negate input video:
6421 @example
6422 lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
6423 lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
6424 @end example
6425
6426 The above is the same as:
6427 @example
6428 lutrgb="r=negval:g=negval:b=negval"
6429 lutyuv="y=negval:u=negval:v=negval"
6430 @end example
6431
6432 @item
6433 Negate luminance:
6434 @example
6435 lutyuv=y=negval
6436 @end example
6437
6438 @item
6439 Remove chroma components, turning the video into a graytone image:
6440 @example
6441 lutyuv="u=128:v=128"
6442 @end example
6443
6444 @item
6445 Apply a luma burning effect:
6446 @example
6447 lutyuv="y=2*val"
6448 @end example
6449
6450 @item
6451 Remove green and blue components:
6452 @example
6453 lutrgb="g=0:b=0"
6454 @end example
6455
6456 @item
6457 Set a constant alpha channel value on input:
6458 @example
6459 format=rgba,lutrgb=a="maxval-minval/2"
6460 @end example
6461
6462 @item
6463 Correct luminance gamma by a factor of 0.5:
6464 @example
6465 lutyuv=y=gammaval(0.5)
6466 @end example
6467
6468 @item
6469 Discard least significant bits of luma:
6470 @example
6471 lutyuv=y='bitand(val, 128+64+32)'
6472 @end example
6473 @end itemize
6474
6475 @section mergeplanes
6476
6477 Merge color channel components from several video streams.
6478
6479 The filter accepts up to 4 input streams, and merge selected input
6480 planes to the output video.
6481
6482 This filter accepts the following options:
6483 @table @option
6484 @item mapping
6485 Set input to output plane mapping. Default is @code{0}.
6486
6487 The mappings is specified as a bitmap. It should be specified as a
6488 hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
6489 mapping for the first plane of the output stream. 'A' sets the number of
6490 the input stream to use (from 0 to 3), and 'a' the plane number of the
6491 corresponding input to use (from 0 to 3). The rest of the mappings is
6492 similar, 'Bb' describes the mapping for the output stream second
6493 plane, 'Cc' describes the mapping for the output stream third plane and
6494 'Dd' describes the mapping for the output stream fourth plane.
6495
6496 @item format
6497 Set output pixel format. Default is @code{yuva444p}.
6498 @end table
6499
6500 @subsection Examples
6501
6502 @itemize
6503 @item
6504 Merge three gray video streams of same width and height into single video stream:
6505 @example
6506 [a0][a1][a2]mergeplanes=0x001020:yuv444p
6507 @end example
6508
6509 @item
6510 Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
6511 @example
6512 [a0][a1]mergeplanes=0x00010210:yuva444p
6513 @end example
6514
6515 @item
6516 Swap Y and A plane in yuva444p stream:
6517 @example
6518 format=yuva444p,mergeplanes=0x03010200:yuva444p
6519 @end example
6520
6521 @item
6522 Swap U and V plane in yuv420p stream:
6523 @example
6524 format=yuv420p,mergeplanes=0x000201:yuv420p
6525 @end example
6526
6527 @item
6528 Cast a rgb24 clip to yuv444p:
6529 @example
6530 format=rgb24,mergeplanes=0x000102:yuv444p
6531 @end example
6532 @end itemize
6533
6534 @section mcdeint
6535
6536 Apply motion-compensation deinterlacing.
6537
6538 It needs one field per frame as input and must thus be used together
6539 with yadif=1/3 or equivalent.
6540
6541 This filter accepts the following options:
6542 @table @option
6543 @item mode
6544 Set the deinterlacing mode.
6545
6546 It accepts one of the following values:
6547 @table @samp
6548 @item fast
6549 @item medium
6550 @item slow
6551 use iterative motion estimation
6552 @item extra_slow
6553 like @samp{slow}, but use multiple reference frames.
6554 @end table
6555 Default value is @samp{fast}.
6556
6557 @item parity
6558 Set the picture field parity assumed for the input video. It must be
6559 one of the following values:
6560
6561 @table @samp
6562 @item 0, tff
6563 assume top field first
6564 @item 1, bff
6565 assume bottom field first
6566 @end table
6567
6568 Default value is @samp{bff}.
6569
6570 @item qp
6571 Set per-block quantization parameter (QP) used by the internal
6572 encoder.
6573
6574 Higher values should result in a smoother motion vector field but less
6575 optimal individual vectors. Default value is 1.
6576 @end table
6577
6578 @section mpdecimate
6579
6580 Drop frames that do not differ greatly from the previous frame in
6581 order to reduce frame rate.
6582
6583 The main use of this filter is for very-low-bitrate encoding
6584 (e.g. streaming over dialup modem), but it could in theory be used for
6585 fixing movies that were inverse-telecined incorrectly.
6586
6587 A description of the accepted options follows.
6588
6589 @table @option
6590 @item max
6591 Set the maximum number of consecutive frames which can be dropped (if
6592 positive), or the minimum interval between dropped frames (if
6593 negative). If the value is 0, the frame is dropped unregarding the
6594 number of previous sequentially dropped frames.
6595
6596 Default value is 0.
6597
6598 @item hi
6599 @item lo
6600 @item frac
6601 Set the dropping threshold values.
6602
6603 Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
6604 represent actual pixel value differences, so a threshold of 64
6605 corresponds to 1 unit of difference for each pixel, or the same spread
6606 out differently over the block.
6607
6608 A frame is a candidate for dropping if no 8x8 blocks differ by more
6609 than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
6610 meaning the whole image) differ by more than a threshold of @option{lo}.
6611
6612 Default value for @option{hi} is 64*12, default value for @option{lo} is
6613 64*5, and default value for @option{frac} is 0.33.
6614 @end table
6615
6616
6617 @section negate
6618
6619 Negate input video.
6620
6621 It accepts an integer in input; if non-zero it negates the
6622 alpha component (if available). The default value in input is 0.
6623
6624 @section noformat
6625
6626 Force libavfilter not to use any of the specified pixel formats for the
6627 input to the next filter.
6628
6629 It accepts the following parameters:
6630 @table @option
6631
6632 @item pix_fmts
6633 A '|'-separated list of pixel format names, such as
6634 apix_fmts=yuv420p|monow|rgb24".
6635
6636 @end table
6637
6638 @subsection Examples
6639
6640 @itemize
6641 @item
6642 Force libavfilter to use a format different from @var{yuv420p} for the
6643 input to the vflip filter:
6644 @example
6645 noformat=pix_fmts=yuv420p,vflip
6646 @end example
6647
6648 @item
6649 Convert the input video to any of the formats not contained in the list:
6650 @example
6651 noformat=yuv420p|yuv444p|yuv410p
6652 @end example
6653 @end itemize
6654
6655 @section noise
6656
6657 Add noise on video input frame.
6658
6659 The filter accepts the following options:
6660
6661 @table @option
6662 @item all_seed
6663 @item c0_seed
6664 @item c1_seed
6665 @item c2_seed
6666 @item c3_seed
6667 Set noise seed for specific pixel component or all pixel components in case
6668 of @var{all_seed}. Default value is @code{123457}.
6669
6670 @item all_strength, alls
6671 @item c0_strength, c0s
6672 @item c1_strength, c1s
6673 @item c2_strength, c2s
6674 @item c3_strength, c3s
6675 Set noise strength for specific pixel component or all pixel components in case
6676 @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
6677
6678 @item all_flags, allf
6679 @item c0_flags, c0f
6680 @item c1_flags, c1f
6681 @item c2_flags, c2f
6682 @item c3_flags, c3f
6683 Set pixel component flags or set flags for all components if @var{all_flags}.
6684 Available values for component flags are:
6685 @table @samp
6686 @item a
6687 averaged temporal noise (smoother)
6688 @item p
6689 mix random noise with a (semi)regular pattern
6690 @item t
6691 temporal noise (noise pattern changes between frames)
6692 @item u
6693 uniform noise (gaussian otherwise)
6694 @end table
6695 @end table
6696
6697 @subsection Examples
6698
6699 Add temporal and uniform noise to input video:
6700 @example
6701 noise=alls=20:allf=t+u
6702 @end example
6703
6704 @section null
6705
6706 Pass the video source unchanged to the output.
6707
6708 @section ocv
6709
6710 Apply a video transform using libopencv.
6711
6712 To enable this filter, install the libopencv library and headers and
6713 configure FFmpeg with @code{--enable-libopencv}.
6714
6715 It accepts the following parameters:
6716
6717 @table @option
6718
6719 @item filter_name
6720 The name of the libopencv filter to apply.
6721
6722 @item filter_params
6723 The parameters to pass to the libopencv filter. If not specified, the default
6724 values are assumed.
6725
6726 @end table
6727
6728 Refer to the official libopencv documentation for more precise
6729 information:
6730 @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
6731
6732 Several libopencv filters are supported; see the following subsections.
6733
6734 @anchor{dilate}
6735 @subsection dilate
6736
6737 Dilate an image by using a specific structuring element.
6738 It corresponds to the libopencv function @code{cvDilate}.
6739
6740 It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
6741
6742 @var{struct_el} represents a structuring element, and has the syntax:
6743 @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
6744
6745 @var{cols} and @var{rows} represent the number of columns and rows of
6746 the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
6747 point, and @var{shape} the shape for the structuring element. @var{shape}
6748 must be "rect", "cross", "ellipse", or "custom".
6749
6750 If the value for @var{shape} is "custom", it must be followed by a
6751 string of the form "=@var{filename}". The file with name
6752 @var{filename} is assumed to represent a binary image, with each
6753 printable character corresponding to a bright pixel. When a custom
6754 @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
6755 or columns and rows of the read file are assumed instead.
6756
6757 The default value for @var{struct_el} is "3x3+0x0/rect".
6758
6759 @var{nb_iterations} specifies the number of times the transform is
6760 applied to the image, and defaults to 1.
6761
6762 Some examples:
6763 @example
6764 # Use the default values
6765 ocv=dilate
6766
6767 # Dilate using a structuring element with a 5x5 cross, iterating two times
6768 ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
6769
6770 # Read the shape from the file diamond.shape, iterating two times.
6771 # The file diamond.shape may contain a pattern of characters like this
6772 #   *
6773 #  ***
6774 # *****
6775 #  ***
6776 #   *
6777 # The specified columns and rows are ignored
6778 # but the anchor point coordinates are not
6779 ocv=dilate:0x0+2x2/custom=diamond.shape|2
6780 @end example
6781
6782 @subsection erode
6783
6784 Erode an image by using a specific structuring element.
6785 It corresponds to the libopencv function @code{cvErode}.
6786
6787 It accepts the parameters: @var{struct_el}:@var{nb_iterations},
6788 with the same syntax and semantics as the @ref{dilate} filter.
6789
6790 @subsection smooth
6791
6792 Smooth the input video.
6793
6794 The filter takes the following parameters:
6795 @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
6796
6797 @var{type} is the type of smooth filter to apply, and must be one of
6798 the following values: "blur", "blur_no_scale", "median", "gaussian",
6799 or "bilateral". The default value is "gaussian".
6800
6801 The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
6802 depend on the smooth type. @var{param1} and
6803 @var{param2} accept integer positive values or 0. @var{param3} and
6804 @var{param4} accept floating point values.
6805
6806 The default value for @var{param1} is 3. The default value for the
6807 other parameters is 0.
6808
6809 These parameters correspond to the parameters assigned to the
6810 libopencv function @code{cvSmooth}.
6811
6812 @anchor{overlay}
6813 @section overlay
6814
6815 Overlay one video on top of another.
6816
6817 It takes two inputs and has one output. The first input is the "main"
6818 video on which the second input is overlaid.
6819
6820 It accepts the following parameters:
6821
6822 A description of the accepted options follows.
6823
6824 @table @option
6825 @item x
6826 @item y
6827 Set the expression for the x and y coordinates of the overlaid video
6828 on the main video. Default value is "0" for both expressions. In case
6829 the expression is invalid, it is set to a huge value (meaning that the
6830 overlay will not be displayed within the output visible area).
6831
6832 @item eof_action
6833 The action to take when EOF is encountered on the secondary input; it accepts
6834 one of the following values:
6835
6836 @table @option
6837 @item repeat
6838 Repeat the last frame (the default).
6839 @item endall
6840 End both streams.
6841 @item pass
6842 Pass the main input through.
6843 @end table
6844
6845 @item eval
6846 Set when the expressions for @option{x}, and @option{y} are evaluated.
6847
6848 It accepts the following values:
6849 @table @samp
6850 @item init
6851 only evaluate expressions once during the filter initialization or
6852 when a command is processed
6853
6854 @item frame
6855 evaluate expressions for each incoming frame
6856 @end table
6857
6858 Default value is @samp{frame}.
6859
6860 @item shortest
6861 If set to 1, force the output to terminate when the shortest input
6862 terminates. Default value is 0.
6863
6864 @item format
6865 Set the format for the output video.
6866
6867 It accepts the following values:
6868 @table @samp
6869 @item yuv420
6870 force YUV420 output
6871
6872 @item yuv422
6873 force YUV422 output
6874
6875 @item yuv444
6876 force YUV444 output
6877
6878 @item rgb
6879 force RGB output
6880 @end table
6881
6882 Default value is @samp{yuv420}.
6883
6884 @item rgb @emph{(deprecated)}
6885 If set to 1, force the filter to accept inputs in the RGB
6886 color space. Default value is 0. This option is deprecated, use
6887 @option{format} instead.
6888
6889 @item repeatlast
6890 If set to 1, force the filter to draw the last overlay frame over the
6891 main input until the end of the stream. A value of 0 disables this
6892 behavior. Default value is 1.
6893 @end table
6894
6895 The @option{x}, and @option{y} expressions can contain the following
6896 parameters.
6897
6898 @table @option
6899 @item main_w, W
6900 @item main_h, H
6901 The main input width and height.
6902
6903 @item overlay_w, w
6904 @item overlay_h, h
6905 The overlay input width and height.
6906
6907 @item x
6908 @item y
6909 The computed values for @var{x} and @var{y}. They are evaluated for
6910 each new frame.
6911
6912 @item hsub
6913 @item vsub
6914 horizontal and vertical chroma subsample values of the output
6915 format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
6916 @var{vsub} is 1.
6917
6918 @item n
6919 the number of input frame, starting from 0
6920
6921 @item pos
6922 the position in the file of the input frame, NAN if unknown
6923
6924 @item t
6925 The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
6926
6927 @end table
6928
6929 Note that the @var{n}, @var{pos}, @var{t} variables are available only
6930 when evaluation is done @emph{per frame}, and will evaluate to NAN
6931 when @option{eval} is set to @samp{init}.
6932
6933 Be aware that frames are taken from each input video in timestamp
6934 order, hence, if their initial timestamps differ, it is a good idea
6935 to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
6936 have them begin in the same zero timestamp, as the example for
6937 the @var{movie} filter does.
6938
6939 You can chain together more overlays but you should test the
6940 efficiency of such approach.
6941
6942 @subsection Commands
6943
6944 This filter supports the following commands:
6945 @table @option
6946 @item x
6947 @item y
6948 Modify the x and y of the overlay input.
6949 The command accepts the same syntax of the corresponding option.
6950
6951 If the specified expression is not valid, it is kept at its current
6952 value.
6953 @end table
6954
6955 @subsection Examples
6956
6957 @itemize
6958 @item
6959 Draw the overlay at 10 pixels from the bottom right corner of the main
6960 video:
6961 @example
6962 overlay=main_w-overlay_w-10:main_h-overlay_h-10
6963 @end example
6964
6965 Using named options the example above becomes:
6966 @example
6967 overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
6968 @end example
6969
6970 @item
6971 Insert a transparent PNG logo in the bottom left corner of the input,
6972 using the @command{ffmpeg} tool with the @code{-filter_complex} option:
6973 @example
6974 ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
6975 @end example
6976
6977 @item
6978 Insert 2 different transparent PNG logos (second logo on bottom
6979 right corner) using the @command{ffmpeg} tool:
6980 @example
6981 ffmpeg -i input -i logo1 -i logo2 -filter_complex 'overlay=x=10:y=H-h-10,overlay=x=W-w-10:y=H-h-10' output
6982 @end example
6983
6984 @item
6985 Add a transparent color layer on top of the main video; @code{WxH}
6986 must specify the size of the main input to the overlay filter:
6987 @example
6988 color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
6989 @end example
6990
6991 @item
6992 Play an original video and a filtered version (here with the deshake
6993 filter) side by side using the @command{ffplay} tool:
6994 @example
6995 ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
6996 @end example
6997
6998 The above command is the same as:
6999 @example
7000 ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
7001 @end example
7002
7003 @item
7004 Make a sliding overlay appearing from the left to the right top part of the
7005 screen starting since time 2:
7006 @example
7007 overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
7008 @end example
7009
7010 @item
7011 Compose output by putting two input videos side to side:
7012 @example
7013 ffmpeg -i left.avi -i right.avi -filter_complex "
7014 nullsrc=size=200x100 [background];
7015 [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
7016 [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
7017 [background][left]       overlay=shortest=1       [background+left];
7018 [background+left][right] overlay=shortest=1:x=100 [left+right]
7019 "
7020 @end example
7021
7022 @item
7023 Mask 10-20 seconds of a video by applying the delogo filter to a section
7024 @example
7025 ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
7026 -vf '[in]split[split_main][split_delogo];[split_delogo]trim=start=360:end=371,delogo=0:0:640:480[delogoed];[split_main][delogoed]overlay=eof_action=pass[out]'
7027 masked.avi
7028 @end example
7029
7030 @item
7031 Chain several overlays in cascade:
7032 @example
7033 nullsrc=s=200x200 [bg];
7034 testsrc=s=100x100, split=4 [in0][in1][in2][in3];
7035 [in0] lutrgb=r=0, [bg]   overlay=0:0     [mid0];
7036 [in1] lutrgb=g=0, [mid0] overlay=100:0   [mid1];
7037 [in2] lutrgb=b=0, [mid1] overlay=0:100   [mid2];
7038 [in3] null,       [mid2] overlay=100:100 [out0]
7039 @end example
7040
7041 @end itemize
7042
7043 @section owdenoise
7044
7045 Apply Overcomplete Wavelet denoiser.
7046
7047 The filter accepts the following options:
7048
7049 @table @option
7050 @item depth
7051 Set depth.
7052
7053 Larger depth values will denoise lower frequency components more, but
7054 slow down filtering.
7055
7056 Must be an int in the range 8-16, default is @code{8}.
7057
7058 @item luma_strength, ls
7059 Set luma strength.
7060
7061 Must be a double value in the range 0-1000, default is @code{1.0}.
7062
7063 @item chroma_strength, cs
7064 Set chroma strength.
7065
7066 Must be a double value in the range 0-1000, default is @code{1.0}.
7067 @end table
7068
7069 @section pad
7070
7071 Add paddings to the input image, and place the original input at the
7072 provided @var{x}, @var{y} coordinates.
7073
7074 It accepts the following parameters:
7075
7076 @table @option
7077 @item width, w
7078 @item height, h
7079 Specify an expression for the size of the output image with the
7080 paddings added. If the value for @var{width} or @var{height} is 0, the
7081 corresponding input size is used for the output.
7082
7083 The @var{width} expression can reference the value set by the
7084 @var{height} expression, and vice versa.
7085
7086 The default value of @var{width} and @var{height} is 0.
7087
7088 @item x
7089 @item y
7090 Specify the offsets to place the input image at within the padded area,
7091 with respect to the top/left border of the output image.
7092
7093 The @var{x} expression can reference the value set by the @var{y}
7094 expression, and vice versa.
7095
7096 The default value of @var{x} and @var{y} is 0.
7097
7098 @item color
7099 Specify the color of the padded area. For the syntax of this option,
7100 check the "Color" section in the ffmpeg-utils manual.
7101
7102 The default value of @var{color} is "black".
7103 @end table
7104
7105 The value for the @var{width}, @var{height}, @var{x}, and @var{y}
7106 options are expressions containing the following constants:
7107
7108 @table @option
7109 @item in_w
7110 @item in_h
7111 The input video width and height.
7112
7113 @item iw
7114 @item ih
7115 These are the same as @var{in_w} and @var{in_h}.
7116
7117 @item out_w
7118 @item out_h
7119 The output width and height (the size of the padded area), as
7120 specified by the @var{width} and @var{height} expressions.
7121
7122 @item ow
7123 @item oh
7124 These are the same as @var{out_w} and @var{out_h}.
7125
7126 @item x
7127 @item y
7128 The x and y offsets as specified by the @var{x} and @var{y}
7129 expressions, or NAN if not yet specified.
7130
7131 @item a
7132 same as @var{iw} / @var{ih}
7133
7134 @item sar
7135 input sample aspect ratio
7136
7137 @item dar
7138 input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
7139
7140 @item hsub
7141 @item vsub
7142 The horizontal and vertical chroma subsample values. For example for the
7143 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
7144 @end table
7145
7146 @subsection Examples
7147
7148 @itemize
7149 @item
7150 Add paddings with the color "violet" to the input video. The output video
7151 size is 640x480, and the top-left corner of the input video is placed at
7152 column 0, row 40
7153 @example
7154 pad=640:480:0:40:violet
7155 @end example
7156
7157 The example above is equivalent to the following command:
7158 @example
7159 pad=width=640:height=480:x=0:y=40:color=violet
7160 @end example
7161
7162 @item
7163 Pad the input to get an output with dimensions increased by 3/2,
7164 and put the input video at the center of the padded area:
7165 @example
7166 pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
7167 @end example
7168
7169 @item
7170 Pad the input to get a squared output with size equal to the maximum
7171 value between the input width and height, and put the input video at
7172 the center of the padded area:
7173 @example
7174 pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
7175 @end example
7176
7177 @item
7178 Pad the input to get a final w/h ratio of 16:9:
7179 @example
7180 pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
7181 @end example
7182
7183 @item
7184 In case of anamorphic video, in order to set the output display aspect
7185 correctly, it is necessary to use @var{sar} in the expression,
7186 according to the relation:
7187 @example
7188 (ih * X / ih) * sar = output_dar
7189 X = output_dar / sar
7190 @end example
7191
7192 Thus the previous example needs to be modified to:
7193 @example
7194 pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
7195 @end example
7196
7197 @item
7198 Double the output size and put the input video in the bottom-right
7199 corner of the output padded area:
7200 @example
7201 pad="2*iw:2*ih:ow-iw:oh-ih"
7202 @end example
7203 @end itemize
7204
7205 @anchor{palettegen}
7206 @section palettegen
7207
7208 Generate one palette for a whole video stream.
7209
7210 It accepts the following options:
7211
7212 @table @option
7213 @item max_colors
7214 Set the maximum number of colors to quantize in the palette.
7215 Note: the palette will still contain 256 colors; the unused palette entries
7216 will be black.
7217
7218 @item reserve_transparent
7219 Create a palette of 255 colors maximum and reserve the last one for
7220 transparency. Reserving the transparency color is useful for GIF optimization.
7221 If not set, the maximum of colors in the palette will be 256. You probably want
7222 to disable this option for a standalone image.
7223 Set by default.
7224
7225 @item stats_mode
7226 Set statistics mode.
7227
7228 It accepts the following values:
7229 @table @samp
7230 @item full
7231 Compute full frame histograms.
7232 @item diff
7233 Compute histograms only for the part that differs from previous frame. This
7234 might be relevant to give more importance to the moving part of your input if
7235 the background is static.
7236 @end table
7237
7238 Default value is @var{full}.
7239 @end table
7240
7241 The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
7242 (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
7243 color quantization of the palette. This information is also visible at
7244 @var{info} logging level.
7245
7246 @subsection Examples
7247
7248 @itemize
7249 @item
7250 Generate a representative palette of a given video using @command{ffmpeg}:
7251 @example
7252 ffmpeg -i input.mkv -vf palettegen palette.png
7253 @end example
7254 @end itemize
7255
7256 @section paletteuse
7257
7258 Use a palette to downsample an input video stream.
7259
7260 The filter takes two inputs: one video stream and a palette. The palette must
7261 be a 256 pixels image.
7262
7263 It accepts the following options:
7264
7265 @table @option
7266 @item dither
7267 Select dithering mode. Available algorithms are:
7268 @table @samp
7269 @item bayer
7270 Ordered 8x8 bayer dithering (deterministic)
7271 @item heckbert
7272 Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
7273 Note: this dithering is sometimes considered "wrong" and is included as a
7274 reference.
7275 @item floyd_steinberg
7276 Floyd and Steingberg dithering (error diffusion)
7277 @item sierra2
7278 Frankie Sierra dithering v2 (error diffusion)
7279 @item sierra2_4a
7280 Frankie Sierra dithering v2 "Lite" (error diffusion)
7281 @end table
7282
7283 Default is @var{sierra2_4a}.
7284
7285 @item bayer_scale
7286 When @var{bayer} dithering is selected, this option defines the scale of the
7287 pattern (how much the crosshatch pattern is visible). A low value means more
7288 visible pattern for less banding, and higher value means less visible pattern
7289 at the cost of more banding.
7290
7291 The option must be an integer value in the range [0,5]. Default is @var{2}.
7292
7293 @item diff_mode
7294 If set, define the zone to process
7295
7296 @table @samp
7297 @item rectangle
7298 Only the changing rectangle will be reprocessed. This is similar to GIF
7299 cropping/offsetting compression mechanism. This option can be useful for speed
7300 if only a part of the image is changing, and has use cases such as limiting the
7301 scope of the error diffusal @option{dither} to the rectangle that bounds the
7302 moving scene (it leads to more deterministic output if the scene doesn't change
7303 much, and as a result less moving noise and better GIF compression).
7304 @end table
7305
7306 Default is @var{none}.
7307 @end table
7308
7309 @subsection Examples
7310
7311 @itemize
7312 @item
7313 Use a palette (generated for example with @ref{palettegen}) to encode a GIF
7314 using @command{ffmpeg}:
7315 @example
7316 ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
7317 @end example
7318 @end itemize
7319
7320 @section perspective
7321
7322 Correct perspective of video not recorded perpendicular to the screen.
7323
7324 A description of the accepted parameters follows.
7325
7326 @table @option
7327 @item x0
7328 @item y0
7329 @item x1
7330 @item y1
7331 @item x2
7332 @item y2
7333 @item x3
7334 @item y3
7335 Set coordinates expression for top left, top right, bottom left and bottom right corners.
7336 Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
7337 If the @code{sense} option is set to @code{source}, then the specified points will be sent
7338 to the corners of the destination. If the @code{sense} option is set to @code{destination},
7339 then the corners of the source will be sent to the specified coordinates.
7340
7341 The expressions can use the following variables:
7342
7343 @table @option
7344 @item W
7345 @item H
7346 the width and height of video frame.
7347 @end table
7348
7349 @item interpolation
7350 Set interpolation for perspective correction.
7351
7352 It accepts the following values:
7353 @table @samp
7354 @item linear
7355 @item cubic
7356 @end table
7357
7358 Default value is @samp{linear}.
7359
7360 @item sense
7361 Set interpretation of coordinate options.
7362
7363 It accepts the following values:
7364 @table @samp
7365 @item 0, source
7366
7367 Send point in the source specified by the given coordinates to
7368 the corners of the destination.
7369
7370 @item 1, destination
7371
7372 Send the corners of the source to the point in the destination specified
7373 by the given coordinates.
7374
7375 Default value is @samp{source}.
7376 @end table
7377 @end table
7378
7379 @section phase
7380
7381 Delay interlaced video by one field time so that the field order changes.
7382
7383 The intended use is to fix PAL movies that have been captured with the
7384 opposite field order to the film-to-video transfer.
7385
7386 A description of the accepted parameters follows.
7387
7388 @table @option
7389 @item mode
7390 Set phase mode.
7391
7392 It accepts the following values:
7393 @table @samp
7394 @item t
7395 Capture field order top-first, transfer bottom-first.
7396 Filter will delay the bottom field.
7397
7398 @item b
7399 Capture field order bottom-first, transfer top-first.
7400 Filter will delay the top field.
7401
7402 @item p
7403 Capture and transfer with the same field order. This mode only exists
7404 for the documentation of the other options to refer to, but if you
7405 actually select it, the filter will faithfully do nothing.
7406
7407 @item a
7408 Capture field order determined automatically by field flags, transfer
7409 opposite.
7410 Filter selects among @samp{t} and @samp{b} modes on a frame by frame
7411 basis using field flags. If no field information is available,
7412 then this works just like @samp{u}.
7413
7414 @item u
7415 Capture unknown or varying, transfer opposite.
7416 Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
7417 analyzing the images and selecting the alternative that produces best
7418 match between the fields.
7419
7420 @item T
7421 Capture top-first, transfer unknown or varying.
7422 Filter selects among @samp{t} and @samp{p} using image analysis.
7423
7424 @item B
7425 Capture bottom-first, transfer unknown or varying.
7426 Filter selects among @samp{b} and @samp{p} using image analysis.
7427
7428 @item A
7429 Capture determined by field flags, transfer unknown or varying.
7430 Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
7431 image analysis. If no field information is available, then this works just
7432 like @samp{U}. This is the default mode.
7433
7434 @item U
7435 Both capture and transfer unknown or varying.
7436 Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
7437 @end table
7438 @end table
7439
7440 @section pixdesctest
7441
7442 Pixel format descriptor test filter, mainly useful for internal
7443 testing. The output video should be equal to the input video.
7444
7445 For example:
7446 @example
7447 format=monow, pixdesctest
7448 @end example
7449
7450 can be used to test the monowhite pixel format descriptor definition.
7451
7452 @section pp
7453
7454 Enable the specified chain of postprocessing subfilters using libpostproc. This
7455 library should be automatically selected with a GPL build (@code{--enable-gpl}).
7456 Subfilters must be separated by '/' and can be disabled by prepending a '-'.
7457 Each subfilter and some options have a short and a long name that can be used
7458 interchangeably, i.e. dr/dering are the same.
7459
7460 The filters accept the following options:
7461
7462 @table @option
7463 @item subfilters
7464 Set postprocessing subfilters string.
7465 @end table
7466
7467 All subfilters share common options to determine their scope:
7468
7469 @table @option
7470 @item a/autoq
7471 Honor the quality commands for this subfilter.
7472
7473 @item c/chrom
7474 Do chrominance filtering, too (default).
7475
7476 @item y/nochrom
7477 Do luminance filtering only (no chrominance).
7478
7479 @item n/noluma
7480 Do chrominance filtering only (no luminance).
7481 @end table
7482
7483 These options can be appended after the subfilter name, separated by a '|'.
7484
7485 Available subfilters are:
7486
7487 @table @option
7488 @item hb/hdeblock[|difference[|flatness]]
7489 Horizontal deblocking filter
7490 @table @option
7491 @item difference
7492 Difference factor where higher values mean more deblocking (default: @code{32}).
7493 @item flatness
7494 Flatness threshold where lower values mean more deblocking (default: @code{39}).
7495 @end table
7496
7497 @item vb/vdeblock[|difference[|flatness]]
7498 Vertical deblocking filter
7499 @table @option
7500 @item difference
7501 Difference factor where higher values mean more deblocking (default: @code{32}).
7502 @item flatness
7503 Flatness threshold where lower values mean more deblocking (default: @code{39}).
7504 @end table
7505
7506 @item ha/hadeblock[|difference[|flatness]]
7507 Accurate horizontal deblocking filter
7508 @table @option
7509 @item difference
7510 Difference factor where higher values mean more deblocking (default: @code{32}).
7511 @item flatness
7512 Flatness threshold where lower values mean more deblocking (default: @code{39}).
7513 @end table
7514
7515 @item va/vadeblock[|difference[|flatness]]
7516 Accurate vertical deblocking filter
7517 @table @option
7518 @item difference
7519 Difference factor where higher values mean more deblocking (default: @code{32}).
7520 @item flatness
7521 Flatness threshold where lower values mean more deblocking (default: @code{39}).
7522 @end table
7523 @end table
7524
7525 The horizontal and vertical deblocking filters share the difference and
7526 flatness values so you cannot set different horizontal and vertical
7527 thresholds.
7528
7529 @table @option
7530 @item h1/x1hdeblock
7531 Experimental horizontal deblocking filter
7532
7533 @item v1/x1vdeblock
7534 Experimental vertical deblocking filter
7535
7536 @item dr/dering
7537 Deringing filter
7538
7539 @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
7540 @table @option
7541 @item threshold1
7542 larger -> stronger filtering
7543 @item threshold2
7544 larger -> stronger filtering
7545 @item threshold3
7546 larger -> stronger filtering
7547 @end table
7548
7549 @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
7550 @table @option
7551 @item f/fullyrange
7552 Stretch luminance to @code{0-255}.
7553 @end table
7554
7555 @item lb/linblenddeint
7556 Linear blend deinterlacing filter that deinterlaces the given block by
7557 filtering all lines with a @code{(1 2 1)} filter.
7558
7559 @item li/linipoldeint
7560 Linear interpolating deinterlacing filter that deinterlaces the given block by
7561 linearly interpolating every second line.
7562
7563 @item ci/cubicipoldeint
7564 Cubic interpolating deinterlacing filter deinterlaces the given block by
7565 cubically interpolating every second line.
7566
7567 @item md/mediandeint
7568 Median deinterlacing filter that deinterlaces the given block by applying a
7569 median filter to every second line.
7570
7571 @item fd/ffmpegdeint
7572 FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
7573 second line with a @code{(-1 4 2 4 -1)} filter.
7574
7575 @item l5/lowpass5
7576 Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
7577 block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
7578
7579 @item fq/forceQuant[|quantizer]
7580 Overrides the quantizer table from the input with the constant quantizer you
7581 specify.
7582 @table @option
7583 @item quantizer
7584 Quantizer to use
7585 @end table
7586
7587 @item de/default
7588 Default pp filter combination (@code{hb|a,vb|a,dr|a})
7589
7590 @item fa/fast
7591 Fast pp filter combination (@code{h1|a,v1|a,dr|a})
7592
7593 @item ac
7594 High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
7595 @end table
7596
7597 @subsection Examples
7598
7599 @itemize
7600 @item
7601 Apply horizontal and vertical deblocking, deringing and automatic
7602 brightness/contrast:
7603 @example
7604 pp=hb/vb/dr/al
7605 @end example
7606
7607 @item
7608 Apply default filters without brightness/contrast correction:
7609 @example
7610 pp=de/-al
7611 @end example
7612
7613 @item
7614 Apply default filters and temporal denoiser:
7615 @example
7616 pp=default/tmpnoise|1|2|3
7617 @end example
7618
7619 @item
7620 Apply deblocking on luminance only, and switch vertical deblocking on or off
7621 automatically depending on available CPU time:
7622 @example
7623 pp=hb|y/vb|a
7624 @end example
7625 @end itemize
7626
7627 @section pp7
7628 Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
7629 similar to spp = 6 with 7 point DCT, where only the center sample is
7630 used after IDCT.
7631
7632 The filter accepts the following options:
7633
7634 @table @option
7635 @item qp
7636 Force a constant quantization parameter. It accepts an integer in range
7637 0 to 63. If not set, the filter will use the QP from the video stream
7638 (if available).
7639
7640 @item mode
7641 Set thresholding mode. Available modes are:
7642
7643 @table @samp
7644 @item hard
7645 Set hard thresholding.
7646 @item soft
7647 Set soft thresholding (better de-ringing effect, but likely blurrier).
7648 @item medium
7649 Set medium thresholding (good results, default).
7650 @end table
7651 @end table
7652
7653 @section psnr
7654
7655 Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
7656 Ratio) between two input videos.
7657
7658 This filter takes in input two input videos, the first input is
7659 considered the "main" source and is passed unchanged to the
7660 output. The second input is used as a "reference" video for computing
7661 the PSNR.
7662
7663 Both video inputs must have the same resolution and pixel format for
7664 this filter to work correctly. Also it assumes that both inputs
7665 have the same number of frames, which are compared one by one.
7666
7667 The obtained average PSNR is printed through the logging system.
7668
7669 The filter stores the accumulated MSE (mean squared error) of each
7670 frame, and at the end of the processing it is averaged across all frames
7671 equally, and the following formula is applied to obtain the PSNR:
7672
7673 @example
7674 PSNR = 10*log10(MAX^2/MSE)
7675 @end example
7676
7677 Where MAX is the average of the maximum values of each component of the
7678 image.
7679
7680 The description of the accepted parameters follows.
7681
7682 @table @option
7683 @item stats_file, f
7684 If specified the filter will use the named file to save the PSNR of
7685 each individual frame.
7686 @end table
7687
7688 The file printed if @var{stats_file} is selected, contains a sequence of
7689 key/value pairs of the form @var{key}:@var{value} for each compared
7690 couple of frames.
7691
7692 A description of each shown parameter follows:
7693
7694 @table @option
7695 @item n
7696 sequential number of the input frame, starting from 1
7697
7698 @item mse_avg
7699 Mean Square Error pixel-by-pixel average difference of the compared
7700 frames, averaged over all the image components.
7701
7702 @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
7703 Mean Square Error pixel-by-pixel average difference of the compared
7704 frames for the component specified by the suffix.
7705
7706 @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
7707 Peak Signal to Noise ratio of the compared frames for the component
7708 specified by the suffix.
7709 @end table
7710
7711 For example:
7712 @example
7713 movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
7714 [main][ref] psnr="stats_file=stats.log" [out]
7715 @end example
7716
7717 On this example the input file being processed is compared with the
7718 reference file @file{ref_movie.mpg}. The PSNR of each individual frame
7719 is stored in @file{stats.log}.
7720
7721 @anchor{pullup}
7722 @section pullup
7723
7724 Pulldown reversal (inverse telecine) filter, capable of handling mixed
7725 hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
7726 content.
7727
7728 The pullup filter is designed to take advantage of future context in making
7729 its decisions. This filter is stateless in the sense that it does not lock
7730 onto a pattern to follow, but it instead looks forward to the following
7731 fields in order to identify matches and rebuild progressive frames.
7732
7733 To produce content with an even framerate, insert the fps filter after
7734 pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
7735 @code{fps=24} for 30fps and the (rare) telecined 25fps input.
7736
7737 The filter accepts the following options:
7738
7739 @table @option
7740 @item jl
7741 @item jr
7742 @item jt
7743 @item jb
7744 These options set the amount of "junk" to ignore at the left, right, top, and
7745 bottom of the image, respectively. Left and right are in units of 8 pixels,
7746 while top and bottom are in units of 2 lines.
7747 The default is 8 pixels on each side.
7748
7749 @item sb
7750 Set the strict breaks. Setting this option to 1 will reduce the chances of
7751 filter generating an occasional mismatched frame, but it may also cause an
7752 excessive number of frames to be dropped during high motion sequences.
7753 Conversely, setting it to -1 will make filter match fields more easily.
7754 This may help processing of video where there is slight blurring between
7755 the fields, but may also cause there to be interlaced frames in the output.
7756 Default value is @code{0}.
7757
7758 @item mp
7759 Set the metric plane to use. It accepts the following values:
7760 @table @samp
7761 @item l
7762 Use luma plane.
7763
7764 @item u
7765 Use chroma blue plane.
7766
7767 @item v
7768 Use chroma red plane.
7769 @end table
7770
7771 This option may be set to use chroma plane instead of the default luma plane
7772 for doing filter's computations. This may improve accuracy on very clean
7773 source material, but more likely will decrease accuracy, especially if there
7774 is chroma noise (rainbow effect) or any grayscale video.
7775 The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
7776 load and make pullup usable in realtime on slow machines.
7777 @end table
7778
7779 For best results (without duplicated frames in the output file) it is
7780 necessary to change the output frame rate. For example, to inverse
7781 telecine NTSC input:
7782 @example
7783 ffmpeg -i input -vf pullup -r 24000/1001 ...
7784 @end example
7785
7786 @section qp
7787
7788 Change video quantization parameters (QP).
7789
7790 The filter accepts the following option:
7791
7792 @table @option
7793 @item qp
7794 Set expression for quantization parameter.
7795 @end table
7796
7797 The expression is evaluated through the eval API and can contain, among others,
7798 the following constants:
7799
7800 @table @var
7801 @item known
7802 1 if index is not 129, 0 otherwise.
7803
7804 @item qp
7805 Sequentional index starting from -129 to 128.
7806 @end table
7807
7808 @subsection Examples
7809
7810 @itemize
7811 @item
7812 Some equation like:
7813 @example
7814 qp=2+2*sin(PI*qp)
7815 @end example
7816 @end itemize
7817
7818 @section removelogo
7819
7820 Suppress a TV station logo, using an image file to determine which
7821 pixels comprise the logo. It works by filling in the pixels that
7822 comprise the logo with neighboring pixels.
7823
7824 The filter accepts the following options:
7825
7826 @table @option
7827 @item filename, f
7828 Set the filter bitmap file, which can be any image format supported by
7829 libavformat. The width and height of the image file must match those of the
7830 video stream being processed.
7831 @end table
7832
7833 Pixels in the provided bitmap image with a value of zero are not
7834 considered part of the logo, non-zero pixels are considered part of
7835 the logo. If you use white (255) for the logo and black (0) for the
7836 rest, you will be safe. For making the filter bitmap, it is
7837 recommended to take a screen capture of a black frame with the logo
7838 visible, and then using a threshold filter followed by the erode
7839 filter once or twice.
7840
7841 If needed, little splotches can be fixed manually. Remember that if
7842 logo pixels are not covered, the filter quality will be much
7843 reduced. Marking too many pixels as part of the logo does not hurt as
7844 much, but it will increase the amount of blurring needed to cover over
7845 the image and will destroy more information than necessary, and extra
7846 pixels will slow things down on a large logo.
7847
7848 @section repeatfields
7849
7850 This filter uses the repeat_field flag from the Video ES headers and hard repeats
7851 fields based on its value.
7852
7853 @section rotate
7854
7855 Rotate video by an arbitrary angle expressed in radians.
7856
7857 The filter accepts the following options:
7858
7859 A description of the optional parameters follows.
7860 @table @option
7861 @item angle, a
7862 Set an expression for the angle by which to rotate the input video
7863 clockwise, expressed as a number of radians. A negative value will
7864 result in a counter-clockwise rotation. By default it is set to "0".
7865
7866 This expression is evaluated for each frame.
7867
7868 @item out_w, ow
7869 Set the output width expression, default value is "iw".
7870 This expression is evaluated just once during configuration.
7871
7872 @item out_h, oh
7873 Set the output height expression, default value is "ih".
7874 This expression is evaluated just once during configuration.
7875
7876 @item bilinear
7877 Enable bilinear interpolation if set to 1, a value of 0 disables
7878 it. Default value is 1.
7879
7880 @item fillcolor, c
7881 Set the color used to fill the output area not covered by the rotated
7882 image. For the general syntax of this option, check the "Color" section in the
7883 ffmpeg-utils manual. If the special value "none" is selected then no
7884 background is printed (useful for example if the background is never shown).
7885
7886 Default value is "black".
7887 @end table
7888
7889 The expressions for the angle and the output size can contain the
7890 following constants and functions:
7891
7892 @table @option
7893 @item n
7894 sequential number of the input frame, starting from 0. It is always NAN
7895 before the first frame is filtered.
7896
7897 @item t
7898 time in seconds of the input frame, it is set to 0 when the filter is
7899 configured. It is always NAN before the first frame is filtered.
7900
7901 @item hsub
7902 @item vsub
7903 horizontal and vertical chroma subsample values. For example for the
7904 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
7905
7906 @item in_w, iw
7907 @item in_h, ih
7908 the input video width and height
7909
7910 @item out_w, ow
7911 @item out_h, oh
7912 the output width and height, that is the size of the padded area as
7913 specified by the @var{width} and @var{height} expressions
7914
7915 @item rotw(a)
7916 @item roth(a)
7917 the minimal width/height required for completely containing the input
7918 video rotated by @var{a} radians.
7919
7920 These are only available when computing the @option{out_w} and
7921 @option{out_h} expressions.
7922 @end table
7923
7924 @subsection Examples
7925
7926 @itemize
7927 @item
7928 Rotate the input by PI/6 radians clockwise:
7929 @example
7930 rotate=PI/6
7931 @end example
7932
7933 @item
7934 Rotate the input by PI/6 radians counter-clockwise:
7935 @example
7936 rotate=-PI/6
7937 @end example
7938
7939 @item
7940 Rotate the input by 45 degrees clockwise:
7941 @example
7942 rotate=45*PI/180
7943 @end example
7944
7945 @item
7946 Apply a constant rotation with period T, starting from an angle of PI/3:
7947 @example
7948 rotate=PI/3+2*PI*t/T
7949 @end example
7950
7951 @item
7952 Make the input video rotation oscillating with a period of T
7953 seconds and an amplitude of A radians:
7954 @example
7955 rotate=A*sin(2*PI/T*t)
7956 @end example
7957
7958 @item
7959 Rotate the video, output size is chosen so that the whole rotating
7960 input video is always completely contained in the output:
7961 @example
7962 rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
7963 @end example
7964
7965 @item
7966 Rotate the video, reduce the output size so that no background is ever
7967 shown:
7968 @example
7969 rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
7970 @end example
7971 @end itemize
7972
7973 @subsection Commands
7974
7975 The filter supports the following commands:
7976
7977 @table @option
7978 @item a, angle
7979 Set the angle expression.
7980 The command accepts the same syntax of the corresponding option.
7981
7982 If the specified expression is not valid, it is kept at its current
7983 value.
7984 @end table
7985
7986 @section sab
7987
7988 Apply Shape Adaptive Blur.
7989
7990 The filter accepts the following options:
7991
7992 @table @option
7993 @item luma_radius, lr
7994 Set luma blur filter strength, must be a value in range 0.1-4.0, default
7995 value is 1.0. A greater value will result in a more blurred image, and
7996 in slower processing.
7997
7998 @item luma_pre_filter_radius, lpfr
7999 Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
8000 value is 1.0.
8001
8002 @item luma_strength, ls
8003 Set luma maximum difference between pixels to still be considered, must
8004 be a value in the 0.1-100.0 range, default value is 1.0.
8005
8006 @item chroma_radius, cr
8007 Set chroma blur filter strength, must be a value in range 0.1-4.0. A
8008 greater value will result in a more blurred image, and in slower
8009 processing.
8010
8011 @item chroma_pre_filter_radius, cpfr
8012 Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
8013
8014 @item chroma_strength, cs
8015 Set chroma maximum difference between pixels to still be considered,
8016 must be a value in the 0.1-100.0 range.
8017 @end table
8018
8019 Each chroma option value, if not explicitly specified, is set to the
8020 corresponding luma option value.
8021
8022 @anchor{scale}
8023 @section scale
8024
8025 Scale (resize) the input video, using the libswscale library.
8026
8027 The scale filter forces the output display aspect ratio to be the same
8028 of the input, by changing the output sample aspect ratio.
8029
8030 If the input image format is different from the format requested by
8031 the next filter, the scale filter will convert the input to the
8032 requested format.
8033
8034 @subsection Options
8035 The filter accepts the following options, or any of the options
8036 supported by the libswscale scaler.
8037
8038 See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
8039 the complete list of scaler options.
8040
8041 @table @option
8042 @item width, w
8043 @item height, h
8044 Set the output video dimension expression. Default value is the input
8045 dimension.
8046
8047 If the value is 0, the input width is used for the output.
8048
8049 If one of the values is -1, the scale filter will use a value that
8050 maintains the aspect ratio of the input image, calculated from the
8051 other specified dimension. If both of them are -1, the input size is
8052 used
8053
8054 If one of the values is -n with n > 1, the scale filter will also use a value
8055 that maintains the aspect ratio of the input image, calculated from the other
8056 specified dimension. After that it will, however, make sure that the calculated
8057 dimension is divisible by n and adjust the value if necessary.
8058
8059 See below for the list of accepted constants for use in the dimension
8060 expression.
8061
8062 @item interl
8063 Set the interlacing mode. It accepts the following values:
8064
8065 @table @samp
8066 @item 1
8067 Force interlaced aware scaling.
8068
8069 @item 0
8070 Do not apply interlaced scaling.
8071
8072 @item -1
8073 Select interlaced aware scaling depending on whether the source frames
8074 are flagged as interlaced or not.
8075 @end table
8076
8077 Default value is @samp{0}.
8078
8079 @item flags
8080 Set libswscale scaling flags. See
8081 @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
8082 complete list of values. If not explicitly specified the filter applies
8083 the default flags.
8084
8085 @item size, s
8086 Set the video size. For the syntax of this option, check the
8087 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
8088
8089 @item in_color_matrix
8090 @item out_color_matrix
8091 Set in/output YCbCr color space type.
8092
8093 This allows the autodetected value to be overridden as well as allows forcing
8094 a specific value used for the output and encoder.
8095
8096 If not specified, the color space type depends on the pixel format.
8097
8098 Possible values:
8099
8100 @table @samp
8101 @item auto
8102 Choose automatically.
8103
8104 @item bt709
8105 Format conforming to International Telecommunication Union (ITU)
8106 Recommendation BT.709.
8107
8108 @item fcc
8109 Set color space conforming to the United States Federal Communications
8110 Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
8111
8112 @item bt601
8113 Set color space conforming to:
8114
8115 @itemize
8116 @item
8117 ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
8118
8119 @item
8120 ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
8121
8122 @item
8123 Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
8124
8125 @end itemize
8126
8127 @item smpte240m
8128 Set color space conforming to SMPTE ST 240:1999.
8129 @end table
8130
8131 @item in_range
8132 @item out_range
8133 Set in/output YCbCr sample range.
8134
8135 This allows the autodetected value to be overridden as well as allows forcing
8136 a specific value used for the output and encoder. If not specified, the
8137 range depends on the pixel format. Possible values:
8138
8139 @table @samp
8140 @item auto
8141 Choose automatically.
8142
8143 @item jpeg/full/pc
8144 Set full range (0-255 in case of 8-bit luma).
8145
8146 @item mpeg/tv
8147 Set "MPEG" range (16-235 in case of 8-bit luma).
8148 @end table
8149
8150 @item force_original_aspect_ratio
8151 Enable decreasing or increasing output video width or height if necessary to
8152 keep the original aspect ratio. Possible values:
8153
8154 @table @samp
8155 @item disable
8156 Scale the video as specified and disable this feature.
8157
8158 @item decrease
8159 The output video dimensions will automatically be decreased if needed.
8160
8161 @item increase
8162 The output video dimensions will automatically be increased if needed.
8163
8164 @end table
8165
8166 One useful instance of this option is that when you know a specific device's
8167 maximum allowed resolution, you can use this to limit the output video to
8168 that, while retaining the aspect ratio. For example, device A allows
8169 1280x720 playback, and your video is 1920x800. Using this option (set it to
8170 decrease) and specifying 1280x720 to the command line makes the output
8171 1280x533.
8172
8173 Please note that this is a different thing than specifying -1 for @option{w}
8174 or @option{h}, you still need to specify the output resolution for this option
8175 to work.
8176
8177 @end table
8178
8179 The values of the @option{w} and @option{h} options are expressions
8180 containing the following constants:
8181
8182 @table @var
8183 @item in_w
8184 @item in_h
8185 The input width and height
8186
8187 @item iw
8188 @item ih
8189 These are the same as @var{in_w} and @var{in_h}.
8190
8191 @item out_w
8192 @item out_h
8193 The output (scaled) width and height
8194
8195 @item ow
8196 @item oh
8197 These are the same as @var{out_w} and @var{out_h}
8198
8199 @item a
8200 The same as @var{iw} / @var{ih}
8201
8202 @item sar
8203 input sample aspect ratio
8204
8205 @item dar
8206 The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
8207
8208 @item hsub
8209 @item vsub
8210 horizontal and vertical input chroma subsample values. For example for the
8211 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
8212
8213 @item ohsub
8214 @item ovsub
8215 horizontal and vertical output chroma subsample values. For example for the
8216 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
8217 @end table
8218
8219 @subsection Examples
8220
8221 @itemize
8222 @item
8223 Scale the input video to a size of 200x100
8224 @example
8225 scale=w=200:h=100
8226 @end example
8227
8228 This is equivalent to:
8229 @example
8230 scale=200:100
8231 @end example
8232
8233 or:
8234 @example
8235 scale=200x100
8236 @end example
8237
8238 @item
8239 Specify a size abbreviation for the output size:
8240 @example
8241 scale=qcif
8242 @end example
8243
8244 which can also be written as:
8245 @example
8246 scale=size=qcif
8247 @end example
8248
8249 @item
8250 Scale the input to 2x:
8251 @example
8252 scale=w=2*iw:h=2*ih
8253 @end example
8254
8255 @item
8256 The above is the same as:
8257 @example
8258 scale=2*in_w:2*in_h
8259 @end example
8260
8261 @item
8262 Scale the input to 2x with forced interlaced scaling:
8263 @example
8264 scale=2*iw:2*ih:interl=1
8265 @end example
8266
8267 @item
8268 Scale the input to half size:
8269 @example
8270 scale=w=iw/2:h=ih/2
8271 @end example
8272
8273 @item
8274 Increase the width, and set the height to the same size:
8275 @example
8276 scale=3/2*iw:ow
8277 @end example
8278
8279 @item
8280 Seek Greek harmony:
8281 @example
8282 scale=iw:1/PHI*iw
8283 scale=ih*PHI:ih
8284 @end example
8285
8286 @item
8287 Increase the height, and set the width to 3/2 of the height:
8288 @example
8289 scale=w=3/2*oh:h=3/5*ih
8290 @end example
8291
8292 @item
8293 Increase the size, making the size a multiple of the chroma
8294 subsample values:
8295 @example
8296 scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
8297 @end example
8298
8299 @item
8300 Increase the width to a maximum of 500 pixels,
8301 keeping the same aspect ratio as the input:
8302 @example
8303 scale=w='min(500\, iw*3/2):h=-1'
8304 @end example
8305 @end itemize
8306
8307 @section separatefields
8308
8309 The @code{separatefields} takes a frame-based video input and splits
8310 each frame into its components fields, producing a new half height clip
8311 with twice the frame rate and twice the frame count.
8312
8313 This filter use field-dominance information in frame to decide which
8314 of each pair of fields to place first in the output.
8315 If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
8316
8317 @section setdar, setsar
8318
8319 The @code{setdar} filter sets the Display Aspect Ratio for the filter
8320 output video.
8321
8322 This is done by changing the specified Sample (aka Pixel) Aspect
8323 Ratio, according to the following equation:
8324 @example
8325 @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
8326 @end example
8327
8328 Keep in mind that the @code{setdar} filter does not modify the pixel
8329 dimensions of the video frame. Also, the display aspect ratio set by
8330 this filter may be changed by later filters in the filterchain,
8331 e.g. in case of scaling or if another "setdar" or a "setsar" filter is
8332 applied.
8333
8334 The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
8335 the filter output video.
8336
8337 Note that as a consequence of the application of this filter, the
8338 output display aspect ratio will change according to the equation
8339 above.
8340
8341 Keep in mind that the sample aspect ratio set by the @code{setsar}
8342 filter may be changed by later filters in the filterchain, e.g. if
8343 another "setsar" or a "setdar" filter is applied.
8344
8345 It accepts the following parameters:
8346
8347 @table @option
8348 @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
8349 Set the aspect ratio used by the filter.
8350
8351 The parameter can be a floating point number string, an expression, or
8352 a string of the form @var{num}:@var{den}, where @var{num} and
8353 @var{den} are the numerator and denominator of the aspect ratio. If
8354 the parameter is not specified, it is assumed the value "0".
8355 In case the form "@var{num}:@var{den}" is used, the @code{:} character
8356 should be escaped.
8357
8358 @item max
8359 Set the maximum integer value to use for expressing numerator and
8360 denominator when reducing the expressed aspect ratio to a rational.
8361 Default value is @code{100}.
8362
8363 @end table
8364
8365 The parameter @var{sar} is an expression containing
8366 the following constants:
8367
8368 @table @option
8369 @item E, PI, PHI
8370 These are approximated values for the mathematical constants e
8371 (Euler's number), pi (Greek pi), and phi (the golden ratio).
8372
8373 @item w, h
8374 The input width and height.
8375
8376 @item a
8377 These are the same as @var{w} / @var{h}.
8378
8379 @item sar
8380 The input sample aspect ratio.
8381
8382 @item dar
8383 The input display aspect ratio. It is the same as
8384 (@var{w} / @var{h}) * @var{sar}.
8385
8386 @item hsub, vsub
8387 Horizontal and vertical chroma subsample values. For example, for the
8388 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
8389 @end table
8390
8391 @subsection Examples
8392
8393 @itemize
8394
8395 @item
8396 To change the display aspect ratio to 16:9, specify one of the following:
8397 @example
8398 setdar=dar=1.77777
8399 setdar=dar=16/9
8400 setdar=dar=1.77777
8401 @end example
8402
8403 @item
8404 To change the sample aspect ratio to 10:11, specify:
8405 @example
8406 setsar=sar=10/11
8407 @end example
8408
8409 @item
8410 To set a display aspect ratio of 16:9, and specify a maximum integer value of
8411 1000 in the aspect ratio reduction, use the command:
8412 @example
8413 setdar=ratio=16/9:max=1000
8414 @end example
8415
8416 @end itemize
8417
8418 @anchor{setfield}
8419 @section setfield
8420
8421 Force field for the output video frame.
8422
8423 The @code{setfield} filter marks the interlace type field for the
8424 output frames. It does not change the input frame, but only sets the
8425 corresponding property, which affects how the frame is treated by
8426 following filters (e.g. @code{fieldorder} or @code{yadif}).
8427
8428 The filter accepts the following options:
8429
8430 @table @option
8431
8432 @item mode
8433 Available values are:
8434
8435 @table @samp
8436 @item auto
8437 Keep the same field property.
8438
8439 @item bff
8440 Mark the frame as bottom-field-first.
8441
8442 @item tff
8443 Mark the frame as top-field-first.
8444
8445 @item prog
8446 Mark the frame as progressive.
8447 @end table
8448 @end table
8449
8450 @section showinfo
8451
8452 Show a line containing various information for each input video frame.
8453 The input video is not modified.
8454
8455 The shown line contains a sequence of key/value pairs of the form
8456 @var{key}:@var{value}.
8457
8458 The following values are shown in the output:
8459
8460 @table @option
8461 @item n
8462 The (sequential) number of the input frame, starting from 0.
8463
8464 @item pts
8465 The Presentation TimeStamp of the input frame, expressed as a number of
8466 time base units. The time base unit depends on the filter input pad.
8467
8468 @item pts_time
8469 The Presentation TimeStamp of the input frame, expressed as a number of
8470 seconds.
8471
8472 @item pos
8473 The position of the frame in the input stream, or -1 if this information is
8474 unavailable and/or meaningless (for example in case of synthetic video).
8475
8476 @item fmt
8477 The pixel format name.
8478
8479 @item sar
8480 The sample aspect ratio of the input frame, expressed in the form
8481 @var{num}/@var{den}.
8482
8483 @item s
8484 The size of the input frame. For the syntax of this option, check the
8485 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
8486
8487 @item i
8488 The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
8489 for bottom field first).
8490
8491 @item iskey
8492 This is 1 if the frame is a key frame, 0 otherwise.
8493
8494 @item type
8495 The picture type of the input frame ("I" for an I-frame, "P" for a
8496 P-frame, "B" for a B-frame, or "?" for an unknown type).
8497 Also refer to the documentation of the @code{AVPictureType} enum and of
8498 the @code{av_get_picture_type_char} function defined in
8499 @file{libavutil/avutil.h}.
8500
8501 @item checksum
8502 The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
8503
8504 @item plane_checksum
8505 The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
8506 expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
8507 @end table
8508
8509 @section showpalette
8510
8511 Displays the 256 colors palette of each frame. This filter is only relevant for
8512 @var{pal8} pixel format frames.
8513
8514 It accepts the following option:
8515
8516 @table @option
8517 @item s
8518 Set the size of the box used to represent one palette color entry. Default is
8519 @code{30} (for a @code{30x30} pixel box).
8520 @end table
8521
8522 @section shuffleplanes
8523
8524 Reorder and/or duplicate video planes.
8525
8526 It accepts the following parameters:
8527
8528 @table @option
8529
8530 @item map0
8531 The index of the input plane to be used as the first output plane.
8532
8533 @item map1
8534 The index of the input plane to be used as the second output plane.
8535
8536 @item map2
8537 The index of the input plane to be used as the third output plane.
8538
8539 @item map3
8540 The index of the input plane to be used as the fourth output plane.
8541
8542 @end table
8543
8544 The first plane has the index 0. The default is to keep the input unchanged.
8545
8546 Swap the second and third planes of the input:
8547 @example
8548 ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
8549 @end example
8550
8551 @section signalstats
8552 Evaluate various visual metrics that assist in determining issues associated
8553 with the digitization of analog video media.
8554
8555 By default the filter will log these metadata values:
8556
8557 @table @option
8558 @item YMIN
8559 Display the minimal Y value contained within the input frame. Expressed in
8560 range of [0-255].
8561
8562 @item YLOW
8563 Display the Y value at the 10% percentile within the input frame. Expressed in
8564 range of [0-255].
8565
8566 @item YAVG
8567 Display the average Y value within the input frame. Expressed in range of
8568 [0-255].
8569
8570 @item YHIGH
8571 Display the Y value at the 90% percentile within the input frame. Expressed in
8572 range of [0-255].
8573
8574 @item YMAX
8575 Display the maximum Y value contained within the input frame. Expressed in
8576 range of [0-255].
8577
8578 @item UMIN
8579 Display the minimal U value contained within the input frame. Expressed in
8580 range of [0-255].
8581
8582 @item ULOW
8583 Display the U value at the 10% percentile within the input frame. Expressed in
8584 range of [0-255].
8585
8586 @item UAVG
8587 Display the average U value within the input frame. Expressed in range of
8588 [0-255].
8589
8590 @item UHIGH
8591 Display the U value at the 90% percentile within the input frame. Expressed in
8592 range of [0-255].
8593
8594 @item UMAX
8595 Display the maximum U value contained within the input frame. Expressed in
8596 range of [0-255].
8597
8598 @item VMIN
8599 Display the minimal V value contained within the input frame. Expressed in
8600 range of [0-255].
8601
8602 @item VLOW
8603 Display the V value at the 10% percentile within the input frame. Expressed in
8604 range of [0-255].
8605
8606 @item VAVG
8607 Display the average V value within the input frame. Expressed in range of
8608 [0-255].
8609
8610 @item VHIGH
8611 Display the V value at the 90% percentile within the input frame. Expressed in
8612 range of [0-255].
8613
8614 @item VMAX
8615 Display the maximum V value contained within the input frame. Expressed in
8616 range of [0-255].
8617
8618 @item SATMIN
8619 Display the minimal saturation value contained within the input frame.
8620 Expressed in range of [0-~181.02].
8621
8622 @item SATLOW
8623 Display the saturation value at the 10% percentile within the input frame.
8624 Expressed in range of [0-~181.02].
8625
8626 @item SATAVG
8627 Display the average saturation value within the input frame. Expressed in range
8628 of [0-~181.02].
8629
8630 @item SATHIGH
8631 Display the saturation value at the 90% percentile within the input frame.
8632 Expressed in range of [0-~181.02].
8633
8634 @item SATMAX
8635 Display the maximum saturation value contained within the input frame.
8636 Expressed in range of [0-~181.02].
8637
8638 @item HUEMED
8639 Display the median value for hue within the input frame. Expressed in range of
8640 [0-360].
8641
8642 @item HUEAVG
8643 Display the average value for hue within the input frame. Expressed in range of
8644 [0-360].
8645
8646 @item YDIF
8647 Display the average of sample value difference between all values of the Y
8648 plane in the current frame and corresponding values of the previous input frame.
8649 Expressed in range of [0-255].
8650
8651 @item UDIF
8652 Display the average of sample value difference between all values of the U
8653 plane in the current frame and corresponding values of the previous input frame.
8654 Expressed in range of [0-255].
8655
8656 @item VDIF
8657 Display the average of sample value difference between all values of the V
8658 plane in the current frame and corresponding values of the previous input frame.
8659 Expressed in range of [0-255].
8660 @end table
8661
8662 The filter accepts the following options:
8663
8664 @table @option
8665 @item stat
8666 @item out
8667
8668 @option{stat} specify an additional form of image analysis.
8669 @option{out} output video with the specified type of pixel highlighted.
8670
8671 Both options accept the following values:
8672
8673 @table @samp
8674 @item tout
8675 Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
8676 unlike the neighboring pixels of the same field. Examples of temporal outliers
8677 include the results of video dropouts, head clogs, or tape tracking issues.
8678
8679 @item vrep
8680 Identify @var{vertical line repetition}. Vertical line repetition includes
8681 similar rows of pixels within a frame. In born-digital video vertical line
8682 repetition is common, but this pattern is uncommon in video digitized from an
8683 analog source. When it occurs in video that results from the digitization of an
8684 analog source it can indicate concealment from a dropout compensator.
8685
8686 @item brng
8687 Identify pixels that fall outside of legal broadcast range.
8688 @end table
8689
8690 @item color, c
8691 Set the highlight color for the @option{out} option. The default color is
8692 yellow.
8693 @end table
8694
8695 @subsection Examples
8696
8697 @itemize
8698 @item
8699 Output data of various video metrics:
8700 @example
8701 ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
8702 @end example
8703
8704 @item
8705 Output specific data about the minimum and maximum values of the Y plane per frame:
8706 @example
8707 ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
8708 @end example
8709
8710 @item
8711 Playback video while highlighting pixels that are outside of broadcast range in red.
8712 @example
8713 ffplay example.mov -vf signalstats="out=brng:color=red"
8714 @end example
8715
8716 @item
8717 Playback video with signalstats metadata drawn over the frame.
8718 @example
8719 ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
8720 @end example
8721
8722 The contents of signalstat_drawtext.txt used in the command are:
8723 @example
8724 time %@{pts:hms@}
8725 Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
8726 U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
8727 V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
8728 saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
8729
8730 @end example
8731 @end itemize
8732
8733 @anchor{smartblur}
8734 @section smartblur
8735
8736 Blur the input video without impacting the outlines.
8737
8738 It accepts the following options:
8739
8740 @table @option
8741 @item luma_radius, lr
8742 Set the luma radius. The option value must be a float number in
8743 the range [0.1,5.0] that specifies the variance of the gaussian filter
8744 used to blur the image (slower if larger). Default value is 1.0.
8745
8746 @item luma_strength, ls
8747 Set the luma strength. The option value must be a float number
8748 in the range [-1.0,1.0] that configures the blurring. A value included
8749 in [0.0,1.0] will blur the image whereas a value included in
8750 [-1.0,0.0] will sharpen the image. Default value is 1.0.
8751
8752 @item luma_threshold, lt
8753 Set the luma threshold used as a coefficient to determine
8754 whether a pixel should be blurred or not. The option value must be an
8755 integer in the range [-30,30]. A value of 0 will filter all the image,
8756 a value included in [0,30] will filter flat areas and a value included
8757 in [-30,0] will filter edges. Default value is 0.
8758
8759 @item chroma_radius, cr
8760 Set the chroma radius. The option value must be a float number in
8761 the range [0.1,5.0] that specifies the variance of the gaussian filter
8762 used to blur the image (slower if larger). Default value is 1.0.
8763
8764 @item chroma_strength, cs
8765 Set the chroma strength. The option value must be a float number
8766 in the range [-1.0,1.0] that configures the blurring. A value included
8767 in [0.0,1.0] will blur the image whereas a value included in
8768 [-1.0,0.0] will sharpen the image. Default value is 1.0.
8769
8770 @item chroma_threshold, ct
8771 Set the chroma threshold used as a coefficient to determine
8772 whether a pixel should be blurred or not. The option value must be an
8773 integer in the range [-30,30]. A value of 0 will filter all the image,
8774 a value included in [0,30] will filter flat areas and a value included
8775 in [-30,0] will filter edges. Default value is 0.
8776 @end table
8777
8778 If a chroma option is not explicitly set, the corresponding luma value
8779 is set.
8780
8781 @section stereo3d
8782
8783 Convert between different stereoscopic image formats.
8784
8785 The filters accept the following options:
8786
8787 @table @option
8788 @item in
8789 Set stereoscopic image format of input.
8790
8791 Available values for input image formats are:
8792 @table @samp
8793 @item sbsl
8794 side by side parallel (left eye left, right eye right)
8795
8796 @item sbsr
8797 side by side crosseye (right eye left, left eye right)
8798
8799 @item sbs2l
8800 side by side parallel with half width resolution
8801 (left eye left, right eye right)
8802
8803 @item sbs2r
8804 side by side crosseye with half width resolution
8805 (right eye left, left eye right)
8806
8807 @item abl
8808 above-below (left eye above, right eye below)
8809
8810 @item abr
8811 above-below (right eye above, left eye below)
8812
8813 @item ab2l
8814 above-below with half height resolution
8815 (left eye above, right eye below)
8816
8817 @item ab2r
8818 above-below with half height resolution
8819 (right eye above, left eye below)
8820
8821 @item al
8822 alternating frames (left eye first, right eye second)
8823
8824 @item ar
8825 alternating frames (right eye first, left eye second)
8826
8827 Default value is @samp{sbsl}.
8828 @end table
8829
8830 @item out
8831 Set stereoscopic image format of output.
8832
8833 Available values for output image formats are all the input formats as well as:
8834 @table @samp
8835 @item arbg
8836 anaglyph red/blue gray
8837 (red filter on left eye, blue filter on right eye)
8838
8839 @item argg
8840 anaglyph red/green gray
8841 (red filter on left eye, green filter on right eye)
8842
8843 @item arcg
8844 anaglyph red/cyan gray
8845 (red filter on left eye, cyan filter on right eye)
8846
8847 @item arch
8848 anaglyph red/cyan half colored
8849 (red filter on left eye, cyan filter on right eye)
8850
8851 @item arcc
8852 anaglyph red/cyan color
8853 (red filter on left eye, cyan filter on right eye)
8854
8855 @item arcd
8856 anaglyph red/cyan color optimized with the least squares projection of dubois
8857 (red filter on left eye, cyan filter on right eye)
8858
8859 @item agmg
8860 anaglyph green/magenta gray
8861 (green filter on left eye, magenta filter on right eye)
8862
8863 @item agmh
8864 anaglyph green/magenta half colored
8865 (green filter on left eye, magenta filter on right eye)
8866
8867 @item agmc
8868 anaglyph green/magenta colored
8869 (green filter on left eye, magenta filter on right eye)
8870
8871 @item agmd
8872 anaglyph green/magenta color optimized with the least squares projection of dubois
8873 (green filter on left eye, magenta filter on right eye)
8874
8875 @item aybg
8876 anaglyph yellow/blue gray
8877 (yellow filter on left eye, blue filter on right eye)
8878
8879 @item aybh
8880 anaglyph yellow/blue half colored
8881 (yellow filter on left eye, blue filter on right eye)
8882
8883 @item aybc
8884 anaglyph yellow/blue colored
8885 (yellow filter on left eye, blue filter on right eye)
8886
8887 @item aybd
8888 anaglyph yellow/blue color optimized with the least squares projection of dubois
8889 (yellow filter on left eye, blue filter on right eye)
8890
8891 @item irl
8892 interleaved rows (left eye has top row, right eye starts on next row)
8893
8894 @item irr
8895 interleaved rows (right eye has top row, left eye starts on next row)
8896
8897 @item ml
8898 mono output (left eye only)
8899
8900 @item mr
8901 mono output (right eye only)
8902 @end table
8903
8904 Default value is @samp{arcd}.
8905 @end table
8906
8907 @subsection Examples
8908
8909 @itemize
8910 @item
8911 Convert input video from side by side parallel to anaglyph yellow/blue dubois:
8912 @example
8913 stereo3d=sbsl:aybd
8914 @end example
8915
8916 @item
8917 Convert input video from above bellow (left eye above, right eye below) to side by side crosseye.
8918 @example
8919 stereo3d=abl:sbsr
8920 @end example
8921 @end itemize
8922
8923 @anchor{spp}
8924 @section spp
8925
8926 Apply a simple postprocessing filter that compresses and decompresses the image
8927 at several (or - in the case of @option{quality} level @code{6} - all) shifts
8928 and average the results.
8929
8930 The filter accepts the following options:
8931
8932 @table @option
8933 @item quality
8934 Set quality. This option defines the number of levels for averaging. It accepts
8935 an integer in the range 0-6. If set to @code{0}, the filter will have no
8936 effect. A value of @code{6} means the higher quality. For each increment of
8937 that value the speed drops by a factor of approximately 2.  Default value is
8938 @code{3}.
8939
8940 @item qp
8941 Force a constant quantization parameter. If not set, the filter will use the QP
8942 from the video stream (if available).
8943
8944 @item mode
8945 Set thresholding mode. Available modes are:
8946
8947 @table @samp
8948 @item hard
8949 Set hard thresholding (default).
8950 @item soft
8951 Set soft thresholding (better de-ringing effect, but likely blurrier).
8952 @end table
8953
8954 @item use_bframe_qp
8955 Enable the use of the QP from the B-Frames if set to @code{1}. Using this
8956 option may cause flicker since the B-Frames have often larger QP. Default is
8957 @code{0} (not enabled).
8958 @end table
8959
8960 @anchor{subtitles}
8961 @section subtitles
8962
8963 Draw subtitles on top of input video using the libass library.
8964
8965 To enable compilation of this filter you need to configure FFmpeg with
8966 @code{--enable-libass}. This filter also requires a build with libavcodec and
8967 libavformat to convert the passed subtitles file to ASS (Advanced Substation
8968 Alpha) subtitles format.
8969
8970 The filter accepts the following options:
8971
8972 @table @option
8973 @item filename, f
8974 Set the filename of the subtitle file to read. It must be specified.
8975
8976 @item original_size
8977 Specify the size of the original video, the video for which the ASS file
8978 was composed. For the syntax of this option, check the
8979 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
8980 Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
8981 correctly scale the fonts if the aspect ratio has been changed.
8982
8983 @item charenc
8984 Set subtitles input character encoding. @code{subtitles} filter only. Only
8985 useful if not UTF-8.
8986
8987 @item stream_index, si
8988 Set subtitles stream index. @code{subtitles} filter only.
8989
8990 @item force_style
8991 Override default style or script info parameters of the subtitles. It accepts a
8992 string containing ASS style format @code{KEY=VALUE} couples separated by ",".
8993 @end table
8994
8995 If the first key is not specified, it is assumed that the first value
8996 specifies the @option{filename}.
8997
8998 For example, to render the file @file{sub.srt} on top of the input
8999 video, use the command:
9000 @example
9001 subtitles=sub.srt
9002 @end example
9003
9004 which is equivalent to:
9005 @example
9006 subtitles=filename=sub.srt
9007 @end example
9008
9009 To render the default subtitles stream from file @file{video.mkv}, use:
9010 @example
9011 subtitles=video.mkv
9012 @end example
9013
9014 To render the second subtitles stream from that file, use:
9015 @example
9016 subtitles=video.mkv:si=1
9017 @end example
9018
9019 To make the subtitles stream from @file{sub.srt} appear in transparent green
9020 @code{DejaVu Serif}, use:
9021 @example
9022 subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
9023 @end example
9024
9025 @section super2xsai
9026
9027 Scale the input by 2x and smooth using the Super2xSaI (Scale and
9028 Interpolate) pixel art scaling algorithm.
9029
9030 Useful for enlarging pixel art images without reducing sharpness.
9031
9032 @section swapuv
9033 Swap U & V plane.
9034
9035 @section telecine
9036
9037 Apply telecine process to the video.
9038
9039 This filter accepts the following options:
9040
9041 @table @option
9042 @item first_field
9043 @table @samp
9044 @item top, t
9045 top field first
9046 @item bottom, b
9047 bottom field first
9048 The default value is @code{top}.
9049 @end table
9050
9051 @item pattern
9052 A string of numbers representing the pulldown pattern you wish to apply.
9053 The default value is @code{23}.
9054 @end table
9055
9056 @example
9057 Some typical patterns:
9058
9059 NTSC output (30i):
9060 27.5p: 32222
9061 24p: 23 (classic)
9062 24p: 2332 (preferred)
9063 20p: 33
9064 18p: 334
9065 16p: 3444
9066
9067 PAL output (25i):
9068 27.5p: 12222
9069 24p: 222222222223 ("Euro pulldown")
9070 16.67p: 33
9071 16p: 33333334
9072 @end example
9073
9074 @section thumbnail
9075 Select the most representative frame in a given sequence of consecutive frames.
9076
9077 The filter accepts the following options:
9078
9079 @table @option
9080 @item n
9081 Set the frames batch size to analyze; in a set of @var{n} frames, the filter
9082 will pick one of them, and then handle the next batch of @var{n} frames until
9083 the end. Default is @code{100}.
9084 @end table
9085
9086 Since the filter keeps track of the whole frames sequence, a bigger @var{n}
9087 value will result in a higher memory usage, so a high value is not recommended.
9088
9089 @subsection Examples
9090
9091 @itemize
9092 @item
9093 Extract one picture each 50 frames:
9094 @example
9095 thumbnail=50
9096 @end example
9097
9098 @item
9099 Complete example of a thumbnail creation with @command{ffmpeg}:
9100 @example
9101 ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
9102 @end example
9103 @end itemize
9104
9105 @section tile
9106
9107 Tile several successive frames together.
9108
9109 The filter accepts the following options:
9110
9111 @table @option
9112
9113 @item layout
9114 Set the grid size (i.e. the number of lines and columns). For the syntax of
9115 this option, check the
9116 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
9117
9118 @item nb_frames
9119 Set the maximum number of frames to render in the given area. It must be less
9120 than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
9121 the area will be used.
9122
9123 @item margin
9124 Set the outer border margin in pixels.
9125
9126 @item padding
9127 Set the inner border thickness (i.e. the number of pixels between frames). For
9128 more advanced padding options (such as having different values for the edges),
9129 refer to the pad video filter.
9130
9131 @item color
9132 Specify the color of the unused area. For the syntax of this option, check the
9133 "Color" section in the ffmpeg-utils manual. The default value of @var{color}
9134 is "black".
9135 @end table
9136
9137 @subsection Examples
9138
9139 @itemize
9140 @item
9141 Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
9142 @example
9143 ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
9144 @end example
9145 The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
9146 duplicating each output frame to accommodate the originally detected frame
9147 rate.
9148
9149 @item
9150 Display @code{5} pictures in an area of @code{3x2} frames,
9151 with @code{7} pixels between them, and @code{2} pixels of initial margin, using
9152 mixed flat and named options:
9153 @example
9154 tile=3x2:nb_frames=5:padding=7:margin=2
9155 @end example
9156 @end itemize
9157
9158 @section tinterlace
9159
9160 Perform various types of temporal field interlacing.
9161
9162 Frames are counted starting from 1, so the first input frame is
9163 considered odd.
9164
9165 The filter accepts the following options:
9166
9167 @table @option
9168
9169 @item mode
9170 Specify the mode of the interlacing. This option can also be specified
9171 as a value alone. See below for a list of values for this option.
9172
9173 Available values are:
9174
9175 @table @samp
9176 @item merge, 0
9177 Move odd frames into the upper field, even into the lower field,
9178 generating a double height frame at half frame rate.
9179 @example
9180  ------> time
9181 Input:
9182 Frame 1         Frame 2         Frame 3         Frame 4
9183
9184 11111           22222           33333           44444
9185 11111           22222           33333           44444
9186 11111           22222           33333           44444
9187 11111           22222           33333           44444
9188
9189 Output:
9190 11111                           33333
9191 22222                           44444
9192 11111                           33333
9193 22222                           44444
9194 11111                           33333
9195 22222                           44444
9196 11111                           33333
9197 22222                           44444
9198 @end example
9199
9200 @item drop_odd, 1
9201 Only output even frames, odd frames are dropped, generating a frame with
9202 unchanged height at half frame rate.
9203
9204 @example
9205  ------> time
9206 Input:
9207 Frame 1         Frame 2         Frame 3         Frame 4
9208
9209 11111           22222           33333           44444
9210 11111           22222           33333           44444
9211 11111           22222           33333           44444
9212 11111           22222           33333           44444
9213
9214 Output:
9215                 22222                           44444
9216                 22222                           44444
9217                 22222                           44444
9218                 22222                           44444
9219 @end example
9220
9221 @item drop_even, 2
9222 Only output odd frames, even frames are dropped, generating a frame with
9223 unchanged height at half frame rate.
9224
9225 @example
9226  ------> time
9227 Input:
9228 Frame 1         Frame 2         Frame 3         Frame 4
9229
9230 11111           22222           33333           44444
9231 11111           22222           33333           44444
9232 11111           22222           33333           44444
9233 11111           22222           33333           44444
9234
9235 Output:
9236 11111                           33333
9237 11111                           33333
9238 11111                           33333
9239 11111                           33333
9240 @end example
9241
9242 @item pad, 3
9243 Expand each frame to full height, but pad alternate lines with black,
9244 generating a frame with double height at the same input frame rate.
9245
9246 @example
9247  ------> time
9248 Input:
9249 Frame 1         Frame 2         Frame 3         Frame 4
9250
9251 11111           22222           33333           44444
9252 11111           22222           33333           44444
9253 11111           22222           33333           44444
9254 11111           22222           33333           44444
9255
9256 Output:
9257 11111           .....           33333           .....
9258 .....           22222           .....           44444
9259 11111           .....           33333           .....
9260 .....           22222           .....           44444
9261 11111           .....           33333           .....
9262 .....           22222           .....           44444
9263 11111           .....           33333           .....
9264 .....           22222           .....           44444
9265 @end example
9266
9267
9268 @item interleave_top, 4
9269 Interleave the upper field from odd frames with the lower field from
9270 even frames, generating a frame with unchanged height at half frame rate.
9271
9272 @example
9273  ------> time
9274 Input:
9275 Frame 1         Frame 2         Frame 3         Frame 4
9276
9277 11111<-         22222           33333<-         44444
9278 11111           22222<-         33333           44444<-
9279 11111<-         22222           33333<-         44444
9280 11111           22222<-         33333           44444<-
9281
9282 Output:
9283 11111                           33333
9284 22222                           44444
9285 11111                           33333
9286 22222                           44444
9287 @end example
9288
9289
9290 @item interleave_bottom, 5
9291 Interleave the lower field from odd frames with the upper field from
9292 even frames, generating a frame with unchanged height at half frame rate.
9293
9294 @example
9295  ------> time
9296 Input:
9297 Frame 1         Frame 2         Frame 3         Frame 4
9298
9299 11111           22222<-         33333           44444<-
9300 11111<-         22222           33333<-         44444
9301 11111           22222<-         33333           44444<-
9302 11111<-         22222           33333<-         44444
9303
9304 Output:
9305 22222                           44444
9306 11111                           33333
9307 22222                           44444
9308 11111                           33333
9309 @end example
9310
9311
9312 @item interlacex2, 6
9313 Double frame rate with unchanged height. Frames are inserted each
9314 containing the second temporal field from the previous input frame and
9315 the first temporal field from the next input frame. This mode relies on
9316 the top_field_first flag. Useful for interlaced video displays with no
9317 field synchronisation.
9318
9319 @example
9320  ------> time
9321 Input:
9322 Frame 1         Frame 2         Frame 3         Frame 4
9323
9324 11111           22222           33333           44444
9325  11111           22222           33333           44444
9326 11111           22222           33333           44444
9327  11111           22222           33333           44444
9328
9329 Output:
9330 11111   22222   22222   33333   33333   44444   44444
9331  11111   11111   22222   22222   33333   33333   44444
9332 11111   22222   22222   33333   33333   44444   44444
9333  11111   11111   22222   22222   33333   33333   44444
9334 @end example
9335
9336
9337 @end table
9338
9339 Numeric values are deprecated but are accepted for backward
9340 compatibility reasons.
9341
9342 Default mode is @code{merge}.
9343
9344 @item flags
9345 Specify flags influencing the filter process.
9346
9347 Available value for @var{flags} is:
9348
9349 @table @option
9350 @item low_pass_filter, vlfp
9351 Enable vertical low-pass filtering in the filter.
9352 Vertical low-pass filtering is required when creating an interlaced
9353 destination from a progressive source which contains high-frequency
9354 vertical detail. Filtering will reduce interlace 'twitter' and Moire
9355 patterning.
9356
9357 Vertical low-pass filtering can only be enabled for @option{mode}
9358 @var{interleave_top} and @var{interleave_bottom}.
9359
9360 @end table
9361 @end table
9362
9363 @section transpose
9364
9365 Transpose rows with columns in the input video and optionally flip it.
9366
9367 It accepts the following parameters:
9368
9369 @table @option
9370
9371 @item dir
9372 Specify the transposition direction.
9373
9374 Can assume the following values:
9375 @table @samp
9376 @item 0, 4, cclock_flip
9377 Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
9378 @example
9379 L.R     L.l
9380 . . ->  . .
9381 l.r     R.r
9382 @end example
9383
9384 @item 1, 5, clock
9385 Rotate by 90 degrees clockwise, that is:
9386 @example
9387 L.R     l.L
9388 . . ->  . .
9389 l.r     r.R
9390 @end example
9391
9392 @item 2, 6, cclock
9393 Rotate by 90 degrees counterclockwise, that is:
9394 @example
9395 L.R     R.r
9396 . . ->  . .
9397 l.r     L.l
9398 @end example
9399
9400 @item 3, 7, clock_flip
9401 Rotate by 90 degrees clockwise and vertically flip, that is:
9402 @example
9403 L.R     r.R
9404 . . ->  . .
9405 l.r     l.L
9406 @end example
9407 @end table
9408
9409 For values between 4-7, the transposition is only done if the input
9410 video geometry is portrait and not landscape. These values are
9411 deprecated, the @code{passthrough} option should be used instead.
9412
9413 Numerical values are deprecated, and should be dropped in favor of
9414 symbolic constants.
9415
9416 @item passthrough
9417 Do not apply the transposition if the input geometry matches the one
9418 specified by the specified value. It accepts the following values:
9419 @table @samp
9420 @item none
9421 Always apply transposition.
9422 @item portrait
9423 Preserve portrait geometry (when @var{height} >= @var{width}).
9424 @item landscape
9425 Preserve landscape geometry (when @var{width} >= @var{height}).
9426 @end table
9427
9428 Default value is @code{none}.
9429 @end table
9430
9431 For example to rotate by 90 degrees clockwise and preserve portrait
9432 layout:
9433 @example
9434 transpose=dir=1:passthrough=portrait
9435 @end example
9436
9437 The command above can also be specified as:
9438 @example
9439 transpose=1:portrait
9440 @end example
9441
9442 @section trim
9443 Trim the input so that the output contains one continuous subpart of the input.
9444
9445 It accepts the following parameters:
9446 @table @option
9447 @item start
9448 Specify the time of the start of the kept section, i.e. the frame with the
9449 timestamp @var{start} will be the first frame in the output.
9450
9451 @item end
9452 Specify the time of the first frame that will be dropped, i.e. the frame
9453 immediately preceding the one with the timestamp @var{end} will be the last
9454 frame in the output.
9455
9456 @item start_pts
9457 This is the same as @var{start}, except this option sets the start timestamp
9458 in timebase units instead of seconds.
9459
9460 @item end_pts
9461 This is the same as @var{end}, except this option sets the end timestamp
9462 in timebase units instead of seconds.
9463
9464 @item duration
9465 The maximum duration of the output in seconds.
9466
9467 @item start_frame
9468 The number of the first frame that should be passed to the output.
9469
9470 @item end_frame
9471 The number of the first frame that should be dropped.
9472 @end table
9473
9474 @option{start}, @option{end}, and @option{duration} are expressed as time
9475 duration specifications; see
9476 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
9477 for the accepted syntax.
9478
9479 Note that the first two sets of the start/end options and the @option{duration}
9480 option look at the frame timestamp, while the _frame variants simply count the
9481 frames that pass through the filter. Also note that this filter does not modify
9482 the timestamps. If you wish for the output timestamps to start at zero, insert a
9483 setpts filter after the trim filter.
9484
9485 If multiple start or end options are set, this filter tries to be greedy and
9486 keep all the frames that match at least one of the specified constraints. To keep
9487 only the part that matches all the constraints at once, chain multiple trim
9488 filters.
9489
9490 The defaults are such that all the input is kept. So it is possible to set e.g.
9491 just the end values to keep everything before the specified time.
9492
9493 Examples:
9494 @itemize
9495 @item
9496 Drop everything except the second minute of input:
9497 @example
9498 ffmpeg -i INPUT -vf trim=60:120
9499 @end example
9500
9501 @item
9502 Keep only the first second:
9503 @example
9504 ffmpeg -i INPUT -vf trim=duration=1
9505 @end example
9506
9507 @end itemize
9508
9509
9510 @anchor{unsharp}
9511 @section unsharp
9512
9513 Sharpen or blur the input video.
9514
9515 It accepts the following parameters:
9516
9517 @table @option
9518 @item luma_msize_x, lx
9519 Set the luma matrix horizontal size. It must be an odd integer between
9520 3 and 63. The default value is 5.
9521
9522 @item luma_msize_y, ly
9523 Set the luma matrix vertical size. It must be an odd integer between 3
9524 and 63. The default value is 5.
9525
9526 @item luma_amount, la
9527 Set the luma effect strength. It must be a floating point number, reasonable
9528 values lay between -1.5 and 1.5.
9529
9530 Negative values will blur the input video, while positive values will
9531 sharpen it, a value of zero will disable the effect.
9532
9533 Default value is 1.0.
9534
9535 @item chroma_msize_x, cx
9536 Set the chroma matrix horizontal size. It must be an odd integer
9537 between 3 and 63. The default value is 5.
9538
9539 @item chroma_msize_y, cy
9540 Set the chroma matrix vertical size. It must be an odd integer
9541 between 3 and 63. The default value is 5.
9542
9543 @item chroma_amount, ca
9544 Set the chroma effect strength. It must be a floating point number, reasonable
9545 values lay between -1.5 and 1.5.
9546
9547 Negative values will blur the input video, while positive values will
9548 sharpen it, a value of zero will disable the effect.
9549
9550 Default value is 0.0.
9551
9552 @item opencl
9553 If set to 1, specify using OpenCL capabilities, only available if
9554 FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
9555
9556 @end table
9557
9558 All parameters are optional and default to the equivalent of the
9559 string '5:5:1.0:5:5:0.0'.
9560
9561 @subsection Examples
9562
9563 @itemize
9564 @item
9565 Apply strong luma sharpen effect:
9566 @example
9567 unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
9568 @end example
9569
9570 @item
9571 Apply a strong blur of both luma and chroma parameters:
9572 @example
9573 unsharp=7:7:-2:7:7:-2
9574 @end example
9575 @end itemize
9576
9577 @section uspp
9578
9579 Apply ultra slow/simple postprocessing filter that compresses and decompresses
9580 the image at several (or - in the case of @option{quality} level @code{8} - all)
9581 shifts and average the results.
9582
9583 The way this differs from the behavior of spp is that uspp actually encodes &
9584 decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
9585 DCT similar to MJPEG.
9586
9587 The filter accepts the following options:
9588
9589 @table @option
9590 @item quality
9591 Set quality. This option defines the number of levels for averaging. It accepts
9592 an integer in the range 0-8. If set to @code{0}, the filter will have no
9593 effect. A value of @code{8} means the higher quality. For each increment of
9594 that value the speed drops by a factor of approximately 2.  Default value is
9595 @code{3}.
9596
9597 @item qp
9598 Force a constant quantization parameter. If not set, the filter will use the QP
9599 from the video stream (if available).
9600 @end table
9601
9602 @anchor{vidstabdetect}
9603 @section vidstabdetect
9604
9605 Analyze video stabilization/deshaking. Perform pass 1 of 2, see
9606 @ref{vidstabtransform} for pass 2.
9607
9608 This filter generates a file with relative translation and rotation
9609 transform information about subsequent frames, which is then used by
9610 the @ref{vidstabtransform} filter.
9611
9612 To enable compilation of this filter you need to configure FFmpeg with
9613 @code{--enable-libvidstab}.
9614
9615 This filter accepts the following options:
9616
9617 @table @option
9618 @item result
9619 Set the path to the file used to write the transforms information.
9620 Default value is @file{transforms.trf}.
9621
9622 @item shakiness
9623 Set how shaky the video is and how quick the camera is. It accepts an
9624 integer in the range 1-10, a value of 1 means little shakiness, a
9625 value of 10 means strong shakiness. Default value is 5.
9626
9627 @item accuracy
9628 Set the accuracy of the detection process. It must be a value in the
9629 range 1-15. A value of 1 means low accuracy, a value of 15 means high
9630 accuracy. Default value is 15.
9631
9632 @item stepsize
9633 Set stepsize of the search process. The region around minimum is
9634 scanned with 1 pixel resolution. Default value is 6.
9635
9636 @item mincontrast
9637 Set minimum contrast. Below this value a local measurement field is
9638 discarded. Must be a floating point value in the range 0-1. Default
9639 value is 0.3.
9640
9641 @item tripod
9642 Set reference frame number for tripod mode.
9643
9644 If enabled, the motion of the frames is compared to a reference frame
9645 in the filtered stream, identified by the specified number. The idea
9646 is to compensate all movements in a more-or-less static scene and keep
9647 the camera view absolutely still.
9648
9649 If set to 0, it is disabled. The frames are counted starting from 1.
9650
9651 @item show
9652 Show fields and transforms in the resulting frames. It accepts an
9653 integer in the range 0-2. Default value is 0, which disables any
9654 visualization.
9655 @end table
9656
9657 @subsection Examples
9658
9659 @itemize
9660 @item
9661 Use default values:
9662 @example
9663 vidstabdetect
9664 @end example
9665
9666 @item
9667 Analyze strongly shaky movie and put the results in file
9668 @file{mytransforms.trf}:
9669 @example
9670 vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
9671 @end example
9672
9673 @item
9674 Visualize the result of internal transformations in the resulting
9675 video:
9676 @example
9677 vidstabdetect=show=1
9678 @end example
9679
9680 @item
9681 Analyze a video with medium shakiness using @command{ffmpeg}:
9682 @example
9683 ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
9684 @end example
9685 @end itemize
9686
9687 @anchor{vidstabtransform}
9688 @section vidstabtransform
9689
9690 Video stabilization/deshaking: pass 2 of 2,
9691 see @ref{vidstabdetect} for pass 1.
9692
9693 Read a file with transform information for each frame and
9694 apply/compensate them. Together with the @ref{vidstabdetect}
9695 filter this can be used to deshake videos. See also
9696 @url{http://public.hronopik.de/vid.stab}. It is important to also use
9697 the @ref{unsharp} filter, see below.
9698
9699 To enable compilation of this filter you need to configure FFmpeg with
9700 @code{--enable-libvidstab}.
9701
9702 @subsection Options
9703
9704 @table @option
9705 @item input
9706 Set path to the file used to read the transforms. Default value is
9707 @file{transforms.trf}.
9708
9709 @item smoothing
9710 Set the number of frames (value*2 + 1) used for lowpass filtering the
9711 camera movements. Default value is 10.
9712
9713 For example a number of 10 means that 21 frames are used (10 in the
9714 past and 10 in the future) to smoothen the motion in the video. A
9715 larger value leads to a smoother video, but limits the acceleration of
9716 the camera (pan/tilt movements). 0 is a special case where a static
9717 camera is simulated.
9718
9719 @item optalgo
9720 Set the camera path optimization algorithm.
9721
9722 Accepted values are:
9723 @table @samp
9724 @item gauss
9725 gaussian kernel low-pass filter on camera motion (default)
9726 @item avg
9727 averaging on transformations
9728 @end table
9729
9730 @item maxshift
9731 Set maximal number of pixels to translate frames. Default value is -1,
9732 meaning no limit.
9733
9734 @item maxangle
9735 Set maximal angle in radians (degree*PI/180) to rotate frames. Default
9736 value is -1, meaning no limit.
9737
9738 @item crop
9739 Specify how to deal with borders that may be visible due to movement
9740 compensation.
9741
9742 Available values are:
9743 @table @samp
9744 @item keep
9745 keep image information from previous frame (default)
9746 @item black
9747 fill the border black
9748 @end table
9749
9750 @item invert
9751 Invert transforms if set to 1. Default value is 0.
9752
9753 @item relative
9754 Consider transforms as relative to previous frame if set to 1,
9755 absolute if set to 0. Default value is 0.
9756
9757 @item zoom
9758 Set percentage to zoom. A positive value will result in a zoom-in
9759 effect, a negative value in a zoom-out effect. Default value is 0 (no
9760 zoom).
9761
9762 @item optzoom
9763 Set optimal zooming to avoid borders.
9764
9765 Accepted values are:
9766 @table @samp
9767 @item 0
9768 disabled
9769 @item 1
9770 optimal static zoom value is determined (only very strong movements
9771 will lead to visible borders) (default)
9772 @item 2
9773 optimal adaptive zoom value is determined (no borders will be
9774 visible), see @option{zoomspeed}
9775 @end table
9776
9777 Note that the value given at zoom is added to the one calculated here.
9778
9779 @item zoomspeed
9780 Set percent to zoom maximally each frame (enabled when
9781 @option{optzoom} is set to 2). Range is from 0 to 5, default value is
9782 0.25.
9783
9784 @item interpol
9785 Specify type of interpolation.
9786
9787 Available values are:
9788 @table @samp
9789 @item no
9790 no interpolation
9791 @item linear
9792 linear only horizontal
9793 @item bilinear
9794 linear in both directions (default)
9795 @item bicubic
9796 cubic in both directions (slow)
9797 @end table
9798
9799 @item tripod
9800 Enable virtual tripod mode if set to 1, which is equivalent to
9801 @code{relative=0:smoothing=0}. Default value is 0.
9802
9803 Use also @code{tripod} option of @ref{vidstabdetect}.
9804
9805 @item debug
9806 Increase log verbosity if set to 1. Also the detected global motions
9807 are written to the temporary file @file{global_motions.trf}. Default
9808 value is 0.
9809 @end table
9810
9811 @subsection Examples
9812
9813 @itemize
9814 @item
9815 Use @command{ffmpeg} for a typical stabilization with default values:
9816 @example
9817 ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
9818 @end example
9819
9820 Note the use of the @ref{unsharp} filter which is always recommended.
9821
9822 @item
9823 Zoom in a bit more and load transform data from a given file:
9824 @example
9825 vidstabtransform=zoom=5:input="mytransforms.trf"
9826 @end example
9827
9828 @item
9829 Smoothen the video even more:
9830 @example
9831 vidstabtransform=smoothing=30
9832 @end example
9833 @end itemize
9834
9835 @section vflip
9836
9837 Flip the input video vertically.
9838
9839 For example, to vertically flip a video with @command{ffmpeg}:
9840 @example
9841 ffmpeg -i in.avi -vf "vflip" out.avi
9842 @end example
9843
9844 @anchor{vignette}
9845 @section vignette
9846
9847 Make or reverse a natural vignetting effect.
9848
9849 The filter accepts the following options:
9850
9851 @table @option
9852 @item angle, a
9853 Set lens angle expression as a number of radians.
9854
9855 The value is clipped in the @code{[0,PI/2]} range.
9856
9857 Default value: @code{"PI/5"}
9858
9859 @item x0
9860 @item y0
9861 Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
9862 by default.
9863
9864 @item mode
9865 Set forward/backward mode.
9866
9867 Available modes are:
9868 @table @samp
9869 @item forward
9870 The larger the distance from the central point, the darker the image becomes.
9871
9872 @item backward
9873 The larger the distance from the central point, the brighter the image becomes.
9874 This can be used to reverse a vignette effect, though there is no automatic
9875 detection to extract the lens @option{angle} and other settings (yet). It can
9876 also be used to create a burning effect.
9877 @end table
9878
9879 Default value is @samp{forward}.
9880
9881 @item eval
9882 Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
9883
9884 It accepts the following values:
9885 @table @samp
9886 @item init
9887 Evaluate expressions only once during the filter initialization.
9888
9889 @item frame
9890 Evaluate expressions for each incoming frame. This is way slower than the
9891 @samp{init} mode since it requires all the scalers to be re-computed, but it
9892 allows advanced dynamic expressions.
9893 @end table
9894
9895 Default value is @samp{init}.
9896
9897 @item dither
9898 Set dithering to reduce the circular banding effects. Default is @code{1}
9899 (enabled).
9900
9901 @item aspect
9902 Set vignette aspect. This setting allows one to adjust the shape of the vignette.
9903 Setting this value to the SAR of the input will make a rectangular vignetting
9904 following the dimensions of the video.
9905
9906 Default is @code{1/1}.
9907 @end table
9908
9909 @subsection Expressions
9910
9911 The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
9912 following parameters.
9913
9914 @table @option
9915 @item w
9916 @item h
9917 input width and height
9918
9919 @item n
9920 the number of input frame, starting from 0
9921
9922 @item pts
9923 the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
9924 @var{TB} units, NAN if undefined
9925
9926 @item r
9927 frame rate of the input video, NAN if the input frame rate is unknown
9928
9929 @item t
9930 the PTS (Presentation TimeStamp) of the filtered video frame,
9931 expressed in seconds, NAN if undefined
9932
9933 @item tb
9934 time base of the input video
9935 @end table
9936
9937
9938 @subsection Examples
9939
9940 @itemize
9941 @item
9942 Apply simple strong vignetting effect:
9943 @example
9944 vignette=PI/4
9945 @end example
9946
9947 @item
9948 Make a flickering vignetting:
9949 @example
9950 vignette='PI/4+random(1)*PI/50':eval=frame
9951 @end example
9952
9953 @end itemize
9954
9955 @section w3fdif
9956
9957 Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
9958 Deinterlacing Filter").
9959
9960 Based on the process described by Martin Weston for BBC R&D, and
9961 implemented based on the de-interlace algorithm written by Jim
9962 Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
9963 uses filter coefficients calculated by BBC R&D.
9964
9965 There are two sets of filter coefficients, so called "simple":
9966 and "complex". Which set of filter coefficients is used can
9967 be set by passing an optional parameter:
9968
9969 @table @option
9970 @item filter
9971 Set the interlacing filter coefficients. Accepts one of the following values:
9972
9973 @table @samp
9974 @item simple
9975 Simple filter coefficient set.
9976 @item complex
9977 More-complex filter coefficient set.
9978 @end table
9979 Default value is @samp{complex}.
9980
9981 @item deint
9982 Specify which frames to deinterlace. Accept one of the following values:
9983
9984 @table @samp
9985 @item all
9986 Deinterlace all frames,
9987 @item interlaced
9988 Only deinterlace frames marked as interlaced.
9989 @end table
9990
9991 Default value is @samp{all}.
9992 @end table
9993
9994 @section xbr
9995 Apply the xBR high-quality magnification filter which is designed for pixel
9996 art. It follows a set of edge-detection rules, see
9997 @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
9998
9999 It accepts the following option:
10000
10001 @table @option
10002 @item n
10003 Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
10004 @code{3xBR} and @code{4} for @code{4xBR}.
10005 Default is @code{3}.
10006 @end table
10007
10008 @anchor{yadif}
10009 @section yadif
10010
10011 Deinterlace the input video ("yadif" means "yet another deinterlacing
10012 filter").
10013
10014 It accepts the following parameters:
10015
10016
10017 @table @option
10018
10019 @item mode
10020 The interlacing mode to adopt. It accepts one of the following values:
10021
10022 @table @option
10023 @item 0, send_frame
10024 Output one frame for each frame.
10025 @item 1, send_field
10026 Output one frame for each field.
10027 @item 2, send_frame_nospatial
10028 Like @code{send_frame}, but it skips the spatial interlacing check.
10029 @item 3, send_field_nospatial
10030 Like @code{send_field}, but it skips the spatial interlacing check.
10031 @end table
10032
10033 The default value is @code{send_frame}.
10034
10035 @item parity
10036 The picture field parity assumed for the input interlaced video. It accepts one
10037 of the following values:
10038
10039 @table @option
10040 @item 0, tff
10041 Assume the top field is first.
10042 @item 1, bff
10043 Assume the bottom field is first.
10044 @item -1, auto
10045 Enable automatic detection of field parity.
10046 @end table
10047
10048 The default value is @code{auto}.
10049 If the interlacing is unknown or the decoder does not export this information,
10050 top field first will be assumed.
10051
10052 @item deint
10053 Specify which frames to deinterlace. Accept one of the following
10054 values:
10055
10056 @table @option
10057 @item 0, all
10058 Deinterlace all frames.
10059 @item 1, interlaced
10060 Only deinterlace frames marked as interlaced.
10061 @end table
10062
10063 The default value is @code{all}.
10064 @end table
10065
10066 @section zoompan
10067
10068 Apply Zoom & Pan effect.
10069
10070 This filter accepts the following options:
10071
10072 @table @option
10073 @item zoom, z
10074 Set the zoom expression. Default is 1.
10075
10076 @item x
10077 @item y
10078 Set the x and y expression. Default is 0.
10079
10080 @item d
10081 Set the duration expression in number of frames.
10082 This sets for how many number of frames effect will last for
10083 single input image.
10084
10085 @item s
10086 Set the output image size, default is 'hd720'.
10087 @end table
10088
10089 Each expression can contain the following constants:
10090
10091 @table @option
10092 @item in_w, iw
10093 Input width.
10094
10095 @item in_h, ih
10096 Input height.
10097
10098 @item out_w, ow
10099 Output width.
10100
10101 @item out_h, oh
10102 Output height.
10103
10104 @item in
10105 Input frame count.
10106
10107 @item on
10108 Output frame count.
10109
10110 @item x
10111 @item y
10112 Last calculated 'x' and 'y' position from 'x' and 'y' expression
10113 for current input frame.
10114
10115 @item px
10116 @item py
10117 'x' and 'y' of last output frame of previous input frame or 0 when there was
10118 not yet such frame (first input frame).
10119
10120 @item zoom
10121 Last calculated zoom from 'z' expression for current input frame.
10122
10123 @item pzoom
10124 Last calculated zoom of last output frame of previous input frame.
10125
10126 @item duration
10127 Number of output frames for current input frame. Calculated from 'd' expression
10128 for each input frame.
10129
10130 @item pduration
10131 number of output frames created for previous input frame
10132
10133 @item a
10134 Rational number: input width / input height
10135
10136 @item sar
10137 sample aspect ratio
10138
10139 @item dar
10140 display aspect ratio
10141
10142 @end table
10143
10144 @subsection Examples
10145
10146 @itemize
10147 @item
10148 Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
10149 @example
10150 zoompan=z='min(zoom+0.0015,1.5)':d=700:x='if(gte(zoom,1.5),x,x+1/a)':y='if(gte(zoom,1.5),y,y+1)':s=640x360
10151 @end example
10152 @end itemize
10153
10154 @c man end VIDEO FILTERS
10155
10156 @chapter Video Sources
10157 @c man begin VIDEO SOURCES
10158
10159 Below is a description of the currently available video sources.
10160
10161 @section buffer
10162
10163 Buffer video frames, and make them available to the filter chain.
10164
10165 This source is mainly intended for a programmatic use, in particular
10166 through the interface defined in @file{libavfilter/vsrc_buffer.h}.
10167
10168 It accepts the following parameters:
10169
10170 @table @option
10171
10172 @item video_size
10173 Specify the size (width and height) of the buffered video frames. For the
10174 syntax of this option, check the
10175 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
10176
10177 @item width
10178 The input video width.
10179
10180 @item height
10181 The input video height.
10182
10183 @item pix_fmt
10184 A string representing the pixel format of the buffered video frames.
10185 It may be a number corresponding to a pixel format, or a pixel format
10186 name.
10187
10188 @item time_base
10189 Specify the timebase assumed by the timestamps of the buffered frames.
10190
10191 @item frame_rate
10192 Specify the frame rate expected for the video stream.
10193
10194 @item pixel_aspect, sar
10195 The sample (pixel) aspect ratio of the input video.
10196
10197 @item sws_param
10198 Specify the optional parameters to be used for the scale filter which
10199 is automatically inserted when an input change is detected in the
10200 input size or format.
10201 @end table
10202
10203 For example:
10204 @example
10205 buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
10206 @end example
10207
10208 will instruct the source to accept video frames with size 320x240 and
10209 with format "yuv410p", assuming 1/24 as the timestamps timebase and
10210 square pixels (1:1 sample aspect ratio).
10211 Since the pixel format with name "yuv410p" corresponds to the number 6
10212 (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
10213 this example corresponds to:
10214 @example
10215 buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
10216 @end example
10217
10218 Alternatively, the options can be specified as a flat string, but this
10219 syntax is deprecated:
10220
10221 @var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}[:@var{sws_param}]
10222
10223 @section cellauto
10224
10225 Create a pattern generated by an elementary cellular automaton.
10226
10227 The initial state of the cellular automaton can be defined through the
10228 @option{filename}, and @option{pattern} options. If such options are
10229 not specified an initial state is created randomly.
10230
10231 At each new frame a new row in the video is filled with the result of
10232 the cellular automaton next generation. The behavior when the whole
10233 frame is filled is defined by the @option{scroll} option.
10234
10235 This source accepts the following options:
10236
10237 @table @option
10238 @item filename, f
10239 Read the initial cellular automaton state, i.e. the starting row, from
10240 the specified file.
10241 In the file, each non-whitespace character is considered an alive
10242 cell, a newline will terminate the row, and further characters in the
10243 file will be ignored.
10244
10245 @item pattern, p
10246 Read the initial cellular automaton state, i.e. the starting row, from
10247 the specified string.
10248
10249 Each non-whitespace character in the string is considered an alive
10250 cell, a newline will terminate the row, and further characters in the
10251 string will be ignored.
10252
10253 @item rate, r
10254 Set the video rate, that is the number of frames generated per second.
10255 Default is 25.
10256
10257 @item random_fill_ratio, ratio
10258 Set the random fill ratio for the initial cellular automaton row. It
10259 is a floating point number value ranging from 0 to 1, defaults to
10260 1/PHI.
10261
10262 This option is ignored when a file or a pattern is specified.
10263
10264 @item random_seed, seed
10265 Set the seed for filling randomly the initial row, must be an integer
10266 included between 0 and UINT32_MAX. If not specified, or if explicitly
10267 set to -1, the filter will try to use a good random seed on a best
10268 effort basis.
10269
10270 @item rule
10271 Set the cellular automaton rule, it is a number ranging from 0 to 255.
10272 Default value is 110.
10273
10274 @item size, s
10275 Set the size of the output video. For the syntax of this option, check the
10276 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
10277
10278 If @option{filename} or @option{pattern} is specified, the size is set
10279 by default to the width of the specified initial state row, and the
10280 height is set to @var{width} * PHI.
10281
10282 If @option{size} is set, it must contain the width of the specified
10283 pattern string, and the specified pattern will be centered in the
10284 larger row.
10285
10286 If a filename or a pattern string is not specified, the size value
10287 defaults to "320x518" (used for a randomly generated initial state).
10288
10289 @item scroll
10290 If set to 1, scroll the output upward when all the rows in the output
10291 have been already filled. If set to 0, the new generated row will be
10292 written over the top row just after the bottom row is filled.
10293 Defaults to 1.
10294
10295 @item start_full, full
10296 If set to 1, completely fill the output with generated rows before
10297 outputting the first frame.
10298 This is the default behavior, for disabling set the value to 0.
10299
10300 @item stitch
10301 If set to 1, stitch the left and right row edges together.
10302 This is the default behavior, for disabling set the value to 0.
10303 @end table
10304
10305 @subsection Examples
10306
10307 @itemize
10308 @item
10309 Read the initial state from @file{pattern}, and specify an output of
10310 size 200x400.
10311 @example
10312 cellauto=f=pattern:s=200x400
10313 @end example
10314
10315 @item
10316 Generate a random initial row with a width of 200 cells, with a fill
10317 ratio of 2/3:
10318 @example
10319 cellauto=ratio=2/3:s=200x200
10320 @end example
10321
10322 @item
10323 Create a pattern generated by rule 18 starting by a single alive cell
10324 centered on an initial row with width 100:
10325 @example
10326 cellauto=p=@@:s=100x400:full=0:rule=18
10327 @end example
10328
10329 @item
10330 Specify a more elaborated initial pattern:
10331 @example
10332 cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
10333 @end example
10334
10335 @end itemize
10336
10337 @section mandelbrot
10338
10339 Generate a Mandelbrot set fractal, and progressively zoom towards the
10340 point specified with @var{start_x} and @var{start_y}.
10341
10342 This source accepts the following options:
10343
10344 @table @option
10345
10346 @item end_pts
10347 Set the terminal pts value. Default value is 400.
10348
10349 @item end_scale
10350 Set the terminal scale value.
10351 Must be a floating point value. Default value is 0.3.
10352
10353 @item inner
10354 Set the inner coloring mode, that is the algorithm used to draw the
10355 Mandelbrot fractal internal region.
10356
10357 It shall assume one of the following values:
10358 @table @option
10359 @item black
10360 Set black mode.
10361 @item convergence
10362 Show time until convergence.
10363 @item mincol
10364 Set color based on point closest to the origin of the iterations.
10365 @item period
10366 Set period mode.
10367 @end table
10368
10369 Default value is @var{mincol}.
10370
10371 @item bailout
10372 Set the bailout value. Default value is 10.0.
10373
10374 @item maxiter
10375 Set the maximum of iterations performed by the rendering
10376 algorithm. Default value is 7189.
10377
10378 @item outer
10379 Set outer coloring mode.
10380 It shall assume one of following values:
10381 @table @option
10382 @item iteration_count
10383 Set iteration cound mode.
10384 @item normalized_iteration_count
10385 set normalized iteration count mode.
10386 @end table
10387 Default value is @var{normalized_iteration_count}.
10388
10389 @item rate, r
10390 Set frame rate, expressed as number of frames per second. Default
10391 value is "25".
10392
10393 @item size, s
10394 Set frame size. For the syntax of this option, check the "Video
10395 size" section in the ffmpeg-utils manual. Default value is "640x480".
10396
10397 @item start_scale
10398 Set the initial scale value. Default value is 3.0.
10399
10400 @item start_x
10401 Set the initial x position. Must be a floating point value between
10402 -100 and 100. Default value is -0.743643887037158704752191506114774.
10403
10404 @item start_y
10405 Set the initial y position. Must be a floating point value between
10406 -100 and 100. Default value is -0.131825904205311970493132056385139.
10407 @end table
10408
10409 @section mptestsrc
10410
10411 Generate various test patterns, as generated by the MPlayer test filter.
10412
10413 The size of the generated video is fixed, and is 256x256.
10414 This source is useful in particular for testing encoding features.
10415
10416 This source accepts the following options:
10417
10418 @table @option
10419
10420 @item rate, r
10421 Specify the frame rate of the sourced video, as the number of frames
10422 generated per second. It has to be a string in the format
10423 @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
10424 number or a valid video frame rate abbreviation. The default value is
10425 "25".
10426
10427 @item duration, d
10428 Set the duration of the sourced video. See
10429 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
10430 for the accepted syntax.
10431
10432 If not specified, or the expressed duration is negative, the video is
10433 supposed to be generated forever.
10434
10435 @item test, t
10436
10437 Set the number or the name of the test to perform. Supported tests are:
10438 @table @option
10439 @item dc_luma
10440 @item dc_chroma
10441 @item freq_luma
10442 @item freq_chroma
10443 @item amp_luma
10444 @item amp_chroma
10445 @item cbp
10446 @item mv
10447 @item ring1
10448 @item ring2
10449 @item all
10450
10451 @end table
10452
10453 Default value is "all", which will cycle through the list of all tests.
10454 @end table
10455
10456 Some examples:
10457 @example
10458 mptestsrc=t=dc_luma
10459 @end example
10460
10461 will generate a "dc_luma" test pattern.
10462
10463 @section frei0r_src
10464
10465 Provide a frei0r source.
10466
10467 To enable compilation of this filter you need to install the frei0r
10468 header and configure FFmpeg with @code{--enable-frei0r}.
10469
10470 This source accepts the following parameters:
10471
10472 @table @option
10473
10474 @item size
10475 The size of the video to generate. For the syntax of this option, check the
10476 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
10477
10478 @item framerate
10479 The framerate of the generated video. It may be a string of the form
10480 @var{num}/@var{den} or a frame rate abbreviation.
10481
10482 @item filter_name
10483 The name to the frei0r source to load. For more information regarding frei0r and
10484 how to set the parameters, read the @ref{frei0r} section in the video filters
10485 documentation.
10486
10487 @item filter_params
10488 A '|'-separated list of parameters to pass to the frei0r source.
10489
10490 @end table
10491
10492 For example, to generate a frei0r partik0l source with size 200x200
10493 and frame rate 10 which is overlaid on the overlay filter main input:
10494 @example
10495 frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
10496 @end example
10497
10498 @section life
10499
10500 Generate a life pattern.
10501
10502 This source is based on a generalization of John Conway's life game.
10503
10504 The sourced input represents a life grid, each pixel represents a cell
10505 which can be in one of two possible states, alive or dead. Every cell
10506 interacts with its eight neighbours, which are the cells that are
10507 horizontally, vertically, or diagonally adjacent.
10508
10509 At each interaction the grid evolves according to the adopted rule,
10510 which specifies the number of neighbor alive cells which will make a
10511 cell stay alive or born. The @option{rule} option allows one to specify
10512 the rule to adopt.
10513
10514 This source accepts the following options:
10515
10516 @table @option
10517 @item filename, f
10518 Set the file from which to read the initial grid state. In the file,
10519 each non-whitespace character is considered an alive cell, and newline
10520 is used to delimit the end of each row.
10521
10522 If this option is not specified, the initial grid is generated
10523 randomly.
10524
10525 @item rate, r
10526 Set the video rate, that is the number of frames generated per second.
10527 Default is 25.
10528
10529 @item random_fill_ratio, ratio
10530 Set the random fill ratio for the initial random grid. It is a
10531 floating point number value ranging from 0 to 1, defaults to 1/PHI.
10532 It is ignored when a file is specified.
10533
10534 @item random_seed, seed
10535 Set the seed for filling the initial random grid, must be an integer
10536 included between 0 and UINT32_MAX. If not specified, or if explicitly
10537 set to -1, the filter will try to use a good random seed on a best
10538 effort basis.
10539
10540 @item rule
10541 Set the life rule.
10542
10543 A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
10544 where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
10545 @var{NS} specifies the number of alive neighbor cells which make a
10546 live cell stay alive, and @var{NB} the number of alive neighbor cells
10547 which make a dead cell to become alive (i.e. to "born").
10548 "s" and "b" can be used in place of "S" and "B", respectively.
10549
10550 Alternatively a rule can be specified by an 18-bits integer. The 9
10551 high order bits are used to encode the next cell state if it is alive
10552 for each number of neighbor alive cells, the low order bits specify
10553 the rule for "borning" new cells. Higher order bits encode for an
10554 higher number of neighbor cells.
10555 For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
10556 rule of 12 and a born rule of 9, which corresponds to "S23/B03".
10557
10558 Default value is "S23/B3", which is the original Conway's game of life
10559 rule, and will keep a cell alive if it has 2 or 3 neighbor alive
10560 cells, and will born a new cell if there are three alive cells around
10561 a dead cell.
10562
10563 @item size, s
10564 Set the size of the output video. For the syntax of this option, check the
10565 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
10566
10567 If @option{filename} is specified, the size is set by default to the
10568 same size of the input file. If @option{size} is set, it must contain
10569 the size specified in the input file, and the initial grid defined in
10570 that file is centered in the larger resulting area.
10571
10572 If a filename is not specified, the size value defaults to "320x240"
10573 (used for a randomly generated initial grid).
10574
10575 @item stitch
10576 If set to 1, stitch the left and right grid edges together, and the
10577 top and bottom edges also. Defaults to 1.
10578
10579 @item mold
10580 Set cell mold speed. If set, a dead cell will go from @option{death_color} to
10581 @option{mold_color} with a step of @option{mold}. @option{mold} can have a
10582 value from 0 to 255.
10583
10584 @item life_color
10585 Set the color of living (or new born) cells.
10586
10587 @item death_color
10588 Set the color of dead cells. If @option{mold} is set, this is the first color
10589 used to represent a dead cell.
10590
10591 @item mold_color
10592 Set mold color, for definitely dead and moldy cells.
10593
10594 For the syntax of these 3 color options, check the "Color" section in the
10595 ffmpeg-utils manual.
10596 @end table
10597
10598 @subsection Examples
10599
10600 @itemize
10601 @item
10602 Read a grid from @file{pattern}, and center it on a grid of size
10603 300x300 pixels:
10604 @example
10605 life=f=pattern:s=300x300
10606 @end example
10607
10608 @item
10609 Generate a random grid of size 200x200, with a fill ratio of 2/3:
10610 @example
10611 life=ratio=2/3:s=200x200
10612 @end example
10613
10614 @item
10615 Specify a custom rule for evolving a randomly generated grid:
10616 @example
10617 life=rule=S14/B34
10618 @end example
10619
10620 @item
10621 Full example with slow death effect (mold) using @command{ffplay}:
10622 @example
10623 ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
10624 @end example
10625 @end itemize
10626
10627 @anchor{color}
10628 @anchor{haldclutsrc}
10629 @anchor{nullsrc}
10630 @anchor{rgbtestsrc}
10631 @anchor{smptebars}
10632 @anchor{smptehdbars}
10633 @anchor{testsrc}
10634 @section color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
10635
10636 The @code{color} source provides an uniformly colored input.
10637
10638 The @code{haldclutsrc} source provides an identity Hald CLUT. See also
10639 @ref{haldclut} filter.
10640
10641 The @code{nullsrc} source returns unprocessed video frames. It is
10642 mainly useful to be employed in analysis / debugging tools, or as the
10643 source for filters which ignore the input data.
10644
10645 The @code{rgbtestsrc} source generates an RGB test pattern useful for
10646 detecting RGB vs BGR issues. You should see a red, green and blue
10647 stripe from top to bottom.
10648
10649 The @code{smptebars} source generates a color bars pattern, based on
10650 the SMPTE Engineering Guideline EG 1-1990.
10651
10652 The @code{smptehdbars} source generates a color bars pattern, based on
10653 the SMPTE RP 219-2002.
10654
10655 The @code{testsrc} source generates a test video pattern, showing a
10656 color pattern, a scrolling gradient and a timestamp. This is mainly
10657 intended for testing purposes.
10658
10659 The sources accept the following parameters:
10660
10661 @table @option
10662
10663 @item color, c
10664 Specify the color of the source, only available in the @code{color}
10665 source. For the syntax of this option, check the "Color" section in the
10666 ffmpeg-utils manual.
10667
10668 @item level
10669 Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
10670 source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
10671 pixels to be used as identity matrix for 3D lookup tables. Each component is
10672 coded on a @code{1/(N*N)} scale.
10673
10674 @item size, s
10675 Specify the size of the sourced video. For the syntax of this option, check the
10676 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
10677 The default value is @code{320x240}.
10678
10679 This option is not available with the @code{haldclutsrc} filter.
10680
10681 @item rate, r
10682 Specify the frame rate of the sourced video, as the number of frames
10683 generated per second. It has to be a string in the format
10684 @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
10685 number or a valid video frame rate abbreviation. The default value is
10686 "25".
10687
10688 @item sar
10689 Set the sample aspect ratio of the sourced video.
10690
10691 @item duration, d
10692 Set the duration of the sourced video. See
10693 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
10694 for the accepted syntax.
10695
10696 If not specified, or the expressed duration is negative, the video is
10697 supposed to be generated forever.
10698
10699 @item decimals, n
10700 Set the number of decimals to show in the timestamp, only available in the
10701 @code{testsrc} source.
10702
10703 The displayed timestamp value will correspond to the original
10704 timestamp value multiplied by the power of 10 of the specified
10705 value. Default value is 0.
10706 @end table
10707
10708 For example the following:
10709 @example
10710 testsrc=duration=5.3:size=qcif:rate=10
10711 @end example
10712
10713 will generate a video with a duration of 5.3 seconds, with size
10714 176x144 and a frame rate of 10 frames per second.
10715
10716 The following graph description will generate a red source
10717 with an opacity of 0.2, with size "qcif" and a frame rate of 10
10718 frames per second.
10719 @example
10720 color=c=red@@0.2:s=qcif:r=10
10721 @end example
10722
10723 If the input content is to be ignored, @code{nullsrc} can be used. The
10724 following command generates noise in the luminance plane by employing
10725 the @code{geq} filter:
10726 @example
10727 nullsrc=s=256x256, geq=random(1)*255:128:128
10728 @end example
10729
10730 @subsection Commands
10731
10732 The @code{color} source supports the following commands:
10733
10734 @table @option
10735 @item c, color
10736 Set the color of the created image. Accepts the same syntax of the
10737 corresponding @option{color} option.
10738 @end table
10739
10740 @c man end VIDEO SOURCES
10741
10742 @chapter Video Sinks
10743 @c man begin VIDEO SINKS
10744
10745 Below is a description of the currently available video sinks.
10746
10747 @section buffersink
10748
10749 Buffer video frames, and make them available to the end of the filter
10750 graph.
10751
10752 This sink is mainly intended for programmatic use, in particular
10753 through the interface defined in @file{libavfilter/buffersink.h}
10754 or the options system.
10755
10756 It accepts a pointer to an AVBufferSinkContext structure, which
10757 defines the incoming buffers' formats, to be passed as the opaque
10758 parameter to @code{avfilter_init_filter} for initialization.
10759
10760 @section nullsink
10761
10762 Null video sink: do absolutely nothing with the input video. It is
10763 mainly useful as a template and for use in analysis / debugging
10764 tools.
10765
10766 @c man end VIDEO SINKS
10767
10768 @chapter Multimedia Filters
10769 @c man begin MULTIMEDIA FILTERS
10770
10771 Below is a description of the currently available multimedia filters.
10772
10773 @section avectorscope
10774
10775 Convert input audio to a video output, representing the audio vector
10776 scope.
10777
10778 The filter is used to measure the difference between channels of stereo
10779 audio stream. A monoaural signal, consisting of identical left and right
10780 signal, results in straight vertical line. Any stereo separation is visible
10781 as a deviation from this line, creating a Lissajous figure.
10782 If the straight (or deviation from it) but horizontal line appears this
10783 indicates that the left and right channels are out of phase.
10784
10785 The filter accepts the following options:
10786
10787 @table @option
10788 @item mode, m
10789 Set the vectorscope mode.
10790
10791 Available values are:
10792 @table @samp
10793 @item lissajous
10794 Lissajous rotated by 45 degrees.
10795
10796 @item lissajous_xy
10797 Same as above but not rotated.
10798 @end table
10799
10800 Default value is @samp{lissajous}.
10801
10802 @item size, s
10803 Set the video size for the output. For the syntax of this option, check the
10804 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
10805 Default value is @code{400x400}.
10806
10807 @item rate, r
10808 Set the output frame rate. Default value is @code{25}.
10809
10810 @item rc
10811 @item gc
10812 @item bc
10813 Specify the red, green and blue contrast. Default values are @code{40}, @code{160} and @code{80}.
10814 Allowed range is @code{[0, 255]}.
10815
10816 @item rf
10817 @item gf
10818 @item bf
10819 Specify the red, green and blue fade. Default values are @code{15}, @code{10} and @code{5}.
10820 Allowed range is @code{[0, 255]}.
10821
10822 @item zoom
10823 Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
10824 @end table
10825
10826 @subsection Examples
10827
10828 @itemize
10829 @item
10830 Complete example using @command{ffplay}:
10831 @example
10832 ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
10833              [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
10834 @end example
10835 @end itemize
10836
10837 @section concat
10838
10839 Concatenate audio and video streams, joining them together one after the
10840 other.
10841
10842 The filter works on segments of synchronized video and audio streams. All
10843 segments must have the same number of streams of each type, and that will
10844 also be the number of streams at output.
10845
10846 The filter accepts the following options:
10847
10848 @table @option
10849
10850 @item n
10851 Set the number of segments. Default is 2.
10852
10853 @item v
10854 Set the number of output video streams, that is also the number of video
10855 streams in each segment. Default is 1.
10856
10857 @item a
10858 Set the number of output audio streams, that is also the number of audio
10859 streams in each segment. Default is 0.
10860
10861 @item unsafe
10862 Activate unsafe mode: do not fail if segments have a different format.
10863
10864 @end table
10865
10866 The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
10867 @var{a} audio outputs.
10868
10869 There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
10870 segment, in the same order as the outputs, then the inputs for the second
10871 segment, etc.
10872
10873 Related streams do not always have exactly the same duration, for various
10874 reasons including codec frame size or sloppy authoring. For that reason,
10875 related synchronized streams (e.g. a video and its audio track) should be
10876 concatenated at once. The concat filter will use the duration of the longest
10877 stream in each segment (except the last one), and if necessary pad shorter
10878 audio streams with silence.
10879
10880 For this filter to work correctly, all segments must start at timestamp 0.
10881
10882 All corresponding streams must have the same parameters in all segments; the
10883 filtering system will automatically select a common pixel format for video
10884 streams, and a common sample format, sample rate and channel layout for
10885 audio streams, but other settings, such as resolution, must be converted
10886 explicitly by the user.
10887
10888 Different frame rates are acceptable but will result in variable frame rate
10889 at output; be sure to configure the output file to handle it.
10890
10891 @subsection Examples
10892
10893 @itemize
10894 @item
10895 Concatenate an opening, an episode and an ending, all in bilingual version
10896 (video in stream 0, audio in streams 1 and 2):
10897 @example
10898 ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
10899   '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
10900    concat=n=3:v=1:a=2 [v] [a1] [a2]' \
10901   -map '[v]' -map '[a1]' -map '[a2]' output.mkv
10902 @end example
10903
10904 @item
10905 Concatenate two parts, handling audio and video separately, using the
10906 (a)movie sources, and adjusting the resolution:
10907 @example
10908 movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
10909 movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
10910 [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
10911 @end example
10912 Note that a desync will happen at the stitch if the audio and video streams
10913 do not have exactly the same duration in the first file.
10914
10915 @end itemize
10916
10917 @section ebur128
10918
10919 EBU R128 scanner filter. This filter takes an audio stream as input and outputs
10920 it unchanged. By default, it logs a message at a frequency of 10Hz with the
10921 Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
10922 Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
10923
10924 The filter also has a video output (see the @var{video} option) with a real
10925 time graph to observe the loudness evolution. The graphic contains the logged
10926 message mentioned above, so it is not printed anymore when this option is set,
10927 unless the verbose logging is set. The main graphing area contains the
10928 short-term loudness (3 seconds of analysis), and the gauge on the right is for
10929 the momentary loudness (400 milliseconds).
10930
10931 More information about the Loudness Recommendation EBU R128 on
10932 @url{http://tech.ebu.ch/loudness}.
10933
10934 The filter accepts the following options:
10935
10936 @table @option
10937
10938 @item video
10939 Activate the video output. The audio stream is passed unchanged whether this
10940 option is set or no. The video stream will be the first output stream if
10941 activated. Default is @code{0}.
10942
10943 @item size
10944 Set the video size. This option is for video only. For the syntax of this
10945 option, check the
10946 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
10947 Default and minimum resolution is @code{640x480}.
10948
10949 @item meter
10950 Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
10951 @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
10952 other integer value between this range is allowed.
10953
10954 @item metadata
10955 Set metadata injection. If set to @code{1}, the audio input will be segmented
10956 into 100ms output frames, each of them containing various loudness information
10957 in metadata.  All the metadata keys are prefixed with @code{lavfi.r128.}.
10958
10959 Default is @code{0}.
10960
10961 @item framelog
10962 Force the frame logging level.
10963
10964 Available values are:
10965 @table @samp
10966 @item info
10967 information logging level
10968 @item verbose
10969 verbose logging level
10970 @end table
10971
10972 By default, the logging level is set to @var{info}. If the @option{video} or
10973 the @option{metadata} options are set, it switches to @var{verbose}.
10974
10975 @item peak
10976 Set peak mode(s).
10977
10978 Available modes can be cumulated (the option is a @code{flag} type). Possible
10979 values are:
10980 @table @samp
10981 @item none
10982 Disable any peak mode (default).
10983 @item sample
10984 Enable sample-peak mode.
10985
10986 Simple peak mode looking for the higher sample value. It logs a message
10987 for sample-peak (identified by @code{SPK}).
10988 @item true
10989 Enable true-peak mode.
10990
10991 If enabled, the peak lookup is done on an over-sampled version of the input
10992 stream for better peak accuracy. It logs a message for true-peak.
10993 (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
10994 This mode requires a build with @code{libswresample}.
10995 @end table
10996
10997 @end table
10998
10999 @subsection Examples
11000
11001 @itemize
11002 @item
11003 Real-time graph using @command{ffplay}, with a EBU scale meter +18:
11004 @example
11005 ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
11006 @end example
11007
11008 @item
11009 Run an analysis with @command{ffmpeg}:
11010 @example
11011 ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
11012 @end example
11013 @end itemize
11014
11015 @section interleave, ainterleave
11016
11017 Temporally interleave frames from several inputs.
11018
11019 @code{interleave} works with video inputs, @code{ainterleave} with audio.
11020
11021 These filters read frames from several inputs and send the oldest
11022 queued frame to the output.
11023
11024 Input streams must have a well defined, monotonically increasing frame
11025 timestamp values.
11026
11027 In order to submit one frame to output, these filters need to enqueue
11028 at least one frame for each input, so they cannot work in case one
11029 input is not yet terminated and will not receive incoming frames.
11030
11031 For example consider the case when one input is a @code{select} filter
11032 which always drop input frames. The @code{interleave} filter will keep
11033 reading from that input, but it will never be able to send new frames
11034 to output until the input will send an end-of-stream signal.
11035
11036 Also, depending on inputs synchronization, the filters will drop
11037 frames in case one input receives more frames than the other ones, and
11038 the queue is already filled.
11039
11040 These filters accept the following options:
11041
11042 @table @option
11043 @item nb_inputs, n
11044 Set the number of different inputs, it is 2 by default.
11045 @end table
11046
11047 @subsection Examples
11048
11049 @itemize
11050 @item
11051 Interleave frames belonging to different streams using @command{ffmpeg}:
11052 @example
11053 ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
11054 @end example
11055
11056 @item
11057 Add flickering blur effect:
11058 @example
11059 select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
11060 @end example
11061 @end itemize
11062
11063 @section perms, aperms
11064
11065 Set read/write permissions for the output frames.
11066
11067 These filters are mainly aimed at developers to test direct path in the
11068 following filter in the filtergraph.
11069
11070 The filters accept the following options:
11071
11072 @table @option
11073 @item mode
11074 Select the permissions mode.
11075
11076 It accepts the following values:
11077 @table @samp
11078 @item none
11079 Do nothing. This is the default.
11080 @item ro
11081 Set all the output frames read-only.
11082 @item rw
11083 Set all the output frames directly writable.
11084 @item toggle
11085 Make the frame read-only if writable, and writable if read-only.
11086 @item random
11087 Set each output frame read-only or writable randomly.
11088 @end table
11089
11090 @item seed
11091 Set the seed for the @var{random} mode, must be an integer included between
11092 @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
11093 @code{-1}, the filter will try to use a good random seed on a best effort
11094 basis.
11095 @end table
11096
11097 Note: in case of auto-inserted filter between the permission filter and the
11098 following one, the permission might not be received as expected in that
11099 following filter. Inserting a @ref{format} or @ref{aformat} filter before the
11100 perms/aperms filter can avoid this problem.
11101
11102 @section select, aselect
11103
11104 Select frames to pass in output.
11105
11106 This filter accepts the following options:
11107
11108 @table @option
11109
11110 @item expr, e
11111 Set expression, which is evaluated for each input frame.
11112
11113 If the expression is evaluated to zero, the frame is discarded.
11114
11115 If the evaluation result is negative or NaN, the frame is sent to the
11116 first output; otherwise it is sent to the output with index
11117 @code{ceil(val)-1}, assuming that the input index starts from 0.
11118
11119 For example a value of @code{1.2} corresponds to the output with index
11120 @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
11121
11122 @item outputs, n
11123 Set the number of outputs. The output to which to send the selected
11124 frame is based on the result of the evaluation. Default value is 1.
11125 @end table
11126
11127 The expression can contain the following constants:
11128
11129 @table @option
11130 @item n
11131 The (sequential) number of the filtered frame, starting from 0.
11132
11133 @item selected_n
11134 The (sequential) number of the selected frame, starting from 0.
11135
11136 @item prev_selected_n
11137 The sequential number of the last selected frame. It's NAN if undefined.
11138
11139 @item TB
11140 The timebase of the input timestamps.
11141
11142 @item pts
11143 The PTS (Presentation TimeStamp) of the filtered video frame,
11144 expressed in @var{TB} units. It's NAN if undefined.
11145
11146 @item t
11147 The PTS of the filtered video frame,
11148 expressed in seconds. It's NAN if undefined.
11149
11150 @item prev_pts
11151 The PTS of the previously filtered video frame. It's NAN if undefined.
11152
11153 @item prev_selected_pts
11154 The PTS of the last previously filtered video frame. It's NAN if undefined.
11155
11156 @item prev_selected_t
11157 The PTS of the last previously selected video frame. It's NAN if undefined.
11158
11159 @item start_pts
11160 The PTS of the first video frame in the video. It's NAN if undefined.
11161
11162 @item start_t
11163 The time of the first video frame in the video. It's NAN if undefined.
11164
11165 @item pict_type @emph{(video only)}
11166 The type of the filtered frame. It can assume one of the following
11167 values:
11168 @table @option
11169 @item I
11170 @item P
11171 @item B
11172 @item S
11173 @item SI
11174 @item SP
11175 @item BI
11176 @end table
11177
11178 @item interlace_type @emph{(video only)}
11179 The frame interlace type. It can assume one of the following values:
11180 @table @option
11181 @item PROGRESSIVE
11182 The frame is progressive (not interlaced).
11183 @item TOPFIRST
11184 The frame is top-field-first.
11185 @item BOTTOMFIRST
11186 The frame is bottom-field-first.
11187 @end table
11188
11189 @item consumed_sample_n @emph{(audio only)}
11190 the number of selected samples before the current frame
11191
11192 @item samples_n @emph{(audio only)}
11193 the number of samples in the current frame
11194
11195 @item sample_rate @emph{(audio only)}
11196 the input sample rate
11197
11198 @item key
11199 This is 1 if the filtered frame is a key-frame, 0 otherwise.
11200
11201 @item pos
11202 the position in the file of the filtered frame, -1 if the information
11203 is not available (e.g. for synthetic video)
11204
11205 @item scene @emph{(video only)}
11206 value between 0 and 1 to indicate a new scene; a low value reflects a low
11207 probability for the current frame to introduce a new scene, while a higher
11208 value means the current frame is more likely to be one (see the example below)
11209
11210 @end table
11211
11212 The default value of the select expression is "1".
11213
11214 @subsection Examples
11215
11216 @itemize
11217 @item
11218 Select all frames in input:
11219 @example
11220 select
11221 @end example
11222
11223 The example above is the same as:
11224 @example
11225 select=1
11226 @end example
11227
11228 @item
11229 Skip all frames:
11230 @example
11231 select=0
11232 @end example
11233
11234 @item
11235 Select only I-frames:
11236 @example
11237 select='eq(pict_type\,I)'
11238 @end example
11239
11240 @item
11241 Select one frame every 100:
11242 @example
11243 select='not(mod(n\,100))'
11244 @end example
11245
11246 @item
11247 Select only frames contained in the 10-20 time interval:
11248 @example
11249 select=between(t\,10\,20)
11250 @end example
11251
11252 @item
11253 Select only I frames contained in the 10-20 time interval:
11254 @example
11255 select=between(t\,10\,20)*eq(pict_type\,I)
11256 @end example
11257
11258 @item
11259 Select frames with a minimum distance of 10 seconds:
11260 @example
11261 select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
11262 @end example
11263
11264 @item
11265 Use aselect to select only audio frames with samples number > 100:
11266 @example
11267 aselect='gt(samples_n\,100)'
11268 @end example
11269
11270 @item
11271 Create a mosaic of the first scenes:
11272 @example
11273 ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
11274 @end example
11275
11276 Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
11277 choice.
11278
11279 @item
11280 Send even and odd frames to separate outputs, and compose them:
11281 @example
11282 select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
11283 @end example
11284 @end itemize
11285
11286 @section sendcmd, asendcmd
11287
11288 Send commands to filters in the filtergraph.
11289
11290 These filters read commands to be sent to other filters in the
11291 filtergraph.
11292
11293 @code{sendcmd} must be inserted between two video filters,
11294 @code{asendcmd} must be inserted between two audio filters, but apart
11295 from that they act the same way.
11296
11297 The specification of commands can be provided in the filter arguments
11298 with the @var{commands} option, or in a file specified by the
11299 @var{filename} option.
11300
11301 These filters accept the following options:
11302 @table @option
11303 @item commands, c
11304 Set the commands to be read and sent to the other filters.
11305 @item filename, f
11306 Set the filename of the commands to be read and sent to the other
11307 filters.
11308 @end table
11309
11310 @subsection Commands syntax
11311
11312 A commands description consists of a sequence of interval
11313 specifications, comprising a list of commands to be executed when a
11314 particular event related to that interval occurs. The occurring event
11315 is typically the current frame time entering or leaving a given time
11316 interval.
11317
11318 An interval is specified by the following syntax:
11319 @example
11320 @var{START}[-@var{END}] @var{COMMANDS};
11321 @end example
11322
11323 The time interval is specified by the @var{START} and @var{END} times.
11324 @var{END} is optional and defaults to the maximum time.
11325
11326 The current frame time is considered within the specified interval if
11327 it is included in the interval [@var{START}, @var{END}), that is when
11328 the time is greater or equal to @var{START} and is lesser than
11329 @var{END}.
11330
11331 @var{COMMANDS} consists of a sequence of one or more command
11332 specifications, separated by ",", relating to that interval.  The
11333 syntax of a command specification is given by:
11334 @example
11335 [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
11336 @end example
11337
11338 @var{FLAGS} is optional and specifies the type of events relating to
11339 the time interval which enable sending the specified command, and must
11340 be a non-null sequence of identifier flags separated by "+" or "|" and
11341 enclosed between "[" and "]".
11342
11343 The following flags are recognized:
11344 @table @option
11345 @item enter
11346 The command is sent when the current frame timestamp enters the
11347 specified interval. In other words, the command is sent when the
11348 previous frame timestamp was not in the given interval, and the
11349 current is.
11350
11351 @item leave
11352 The command is sent when the current frame timestamp leaves the
11353 specified interval. In other words, the command is sent when the
11354 previous frame timestamp was in the given interval, and the
11355 current is not.
11356 @end table
11357
11358 If @var{FLAGS} is not specified, a default value of @code{[enter]} is
11359 assumed.
11360
11361 @var{TARGET} specifies the target of the command, usually the name of
11362 the filter class or a specific filter instance name.
11363
11364 @var{COMMAND} specifies the name of the command for the target filter.
11365
11366 @var{ARG} is optional and specifies the optional list of argument for
11367 the given @var{COMMAND}.
11368
11369 Between one interval specification and another, whitespaces, or
11370 sequences of characters starting with @code{#} until the end of line,
11371 are ignored and can be used to annotate comments.
11372
11373 A simplified BNF description of the commands specification syntax
11374 follows:
11375 @example
11376 @var{COMMAND_FLAG}  ::= "enter" | "leave"
11377 @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
11378 @var{COMMAND}       ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
11379 @var{COMMANDS}      ::= @var{COMMAND} [,@var{COMMANDS}]
11380 @var{INTERVAL}      ::= @var{START}[-@var{END}] @var{COMMANDS}
11381 @var{INTERVALS}     ::= @var{INTERVAL}[;@var{INTERVALS}]
11382 @end example
11383
11384 @subsection Examples
11385
11386 @itemize
11387 @item
11388 Specify audio tempo change at second 4:
11389 @example
11390 asendcmd=c='4.0 atempo tempo 1.5',atempo
11391 @end example
11392
11393 @item
11394 Specify a list of drawtext and hue commands in a file.
11395 @example
11396 # show text in the interval 5-10
11397 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
11398          [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
11399
11400 # desaturate the image in the interval 15-20
11401 15.0-20.0 [enter] hue s 0,
11402           [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
11403           [leave] hue s 1,
11404           [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
11405
11406 # apply an exponential saturation fade-out effect, starting from time 25
11407 25 [enter] hue s exp(25-t)
11408 @end example
11409
11410 A filtergraph allowing to read and process the above command list
11411 stored in a file @file{test.cmd}, can be specified with:
11412 @example
11413 sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
11414 @end example
11415 @end itemize
11416
11417 @anchor{setpts}
11418 @section setpts, asetpts
11419
11420 Change the PTS (presentation timestamp) of the input frames.
11421
11422 @code{setpts} works on video frames, @code{asetpts} on audio frames.
11423
11424 This filter accepts the following options:
11425
11426 @table @option
11427
11428 @item expr
11429 The expression which is evaluated for each frame to construct its timestamp.
11430
11431 @end table
11432
11433 The expression is evaluated through the eval API and can contain the following
11434 constants:
11435
11436 @table @option
11437 @item FRAME_RATE
11438 frame rate, only defined for constant frame-rate video
11439
11440 @item PTS
11441 The presentation timestamp in input
11442
11443 @item N
11444 The count of the input frame for video or the number of consumed samples,
11445 not including the current frame for audio, starting from 0.
11446
11447 @item NB_CONSUMED_SAMPLES
11448 The number of consumed samples, not including the current frame (only
11449 audio)
11450
11451 @item NB_SAMPLES, S
11452 The number of samples in the current frame (only audio)
11453
11454 @item SAMPLE_RATE, SR
11455 The audio sample rate.
11456
11457 @item STARTPTS
11458 The PTS of the first frame.
11459
11460 @item STARTT
11461 the time in seconds of the first frame
11462
11463 @item INTERLACED
11464 State whether the current frame is interlaced.
11465
11466 @item T
11467 the time in seconds of the current frame
11468
11469 @item POS
11470 original position in the file of the frame, or undefined if undefined
11471 for the current frame
11472
11473 @item PREV_INPTS
11474 The previous input PTS.
11475
11476 @item PREV_INT
11477 previous input time in seconds
11478
11479 @item PREV_OUTPTS
11480 The previous output PTS.
11481
11482 @item PREV_OUTT
11483 previous output time in seconds
11484
11485 @item RTCTIME
11486 The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
11487 instead.
11488
11489 @item RTCSTART
11490 The wallclock (RTC) time at the start of the movie in microseconds.
11491
11492 @item TB
11493 The timebase of the input timestamps.
11494
11495 @end table
11496
11497 @subsection Examples
11498
11499 @itemize
11500 @item
11501 Start counting PTS from zero
11502 @example
11503 setpts=PTS-STARTPTS
11504 @end example
11505
11506 @item
11507 Apply fast motion effect:
11508 @example
11509 setpts=0.5*PTS
11510 @end example
11511
11512 @item
11513 Apply slow motion effect:
11514 @example
11515 setpts=2.0*PTS
11516 @end example
11517
11518 @item
11519 Set fixed rate of 25 frames per second:
11520 @example
11521 setpts=N/(25*TB)
11522 @end example
11523
11524 @item
11525 Set fixed rate 25 fps with some jitter:
11526 @example
11527 setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
11528 @end example
11529
11530 @item
11531 Apply an offset of 10 seconds to the input PTS:
11532 @example
11533 setpts=PTS+10/TB
11534 @end example
11535
11536 @item
11537 Generate timestamps from a "live source" and rebase onto the current timebase:
11538 @example
11539 setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
11540 @end example
11541
11542 @item
11543 Generate timestamps by counting samples:
11544 @example
11545 asetpts=N/SR/TB
11546 @end example
11547
11548 @end itemize
11549
11550 @section settb, asettb
11551
11552 Set the timebase to use for the output frames timestamps.
11553 It is mainly useful for testing timebase configuration.
11554
11555 It accepts the following parameters:
11556
11557 @table @option
11558
11559 @item expr, tb
11560 The expression which is evaluated into the output timebase.
11561
11562 @end table
11563
11564 The value for @option{tb} is an arithmetic expression representing a
11565 rational. The expression can contain the constants "AVTB" (the default
11566 timebase), "intb" (the input timebase) and "sr" (the sample rate,
11567 audio only). Default value is "intb".
11568
11569 @subsection Examples
11570
11571 @itemize
11572 @item
11573 Set the timebase to 1/25:
11574 @example
11575 settb=expr=1/25
11576 @end example
11577
11578 @item
11579 Set the timebase to 1/10:
11580 @example
11581 settb=expr=0.1
11582 @end example
11583
11584 @item
11585 Set the timebase to 1001/1000:
11586 @example
11587 settb=1+0.001
11588 @end example
11589
11590 @item
11591 Set the timebase to 2*intb:
11592 @example
11593 settb=2*intb
11594 @end example
11595
11596 @item
11597 Set the default timebase value:
11598 @example
11599 settb=AVTB
11600 @end example
11601 @end itemize
11602
11603 @section showcqt
11604 Convert input audio to a video output representing
11605 frequency spectrum logarithmically (using constant Q transform with
11606 Brown-Puckette algorithm), with musical tone scale, from E0 to D#10 (10 octaves).
11607
11608 The filter accepts the following options:
11609
11610 @table @option
11611 @item volume
11612 Specify transform volume (multiplier) expression. The expression can contain
11613 variables:
11614 @table @option
11615 @item frequency, freq, f
11616 the frequency where transform is evaluated
11617 @item timeclamp, tc
11618 value of timeclamp option
11619 @end table
11620 and functions:
11621 @table @option
11622 @item a_weighting(f)
11623 A-weighting of equal loudness
11624 @item b_weighting(f)
11625 B-weighting of equal loudness
11626 @item c_weighting(f)
11627 C-weighting of equal loudness
11628 @end table
11629 Default value is @code{16}.
11630
11631 @item tlength
11632 Specify transform length expression. The expression can contain variables:
11633 @table @option
11634 @item frequency, freq, f
11635 the frequency where transform is evaluated
11636 @item timeclamp, tc
11637 value of timeclamp option
11638 @end table
11639 Default value is @code{384/f*tc/(384/f+tc)}.
11640
11641 @item timeclamp
11642 Specify the transform timeclamp. At low frequency, there is trade-off between
11643 accuracy in time domain and frequency domain. If timeclamp is lower,
11644 event in time domain is represented more accurately (such as fast bass drum),
11645 otherwise event in frequency domain is represented more accurately
11646 (such as bass guitar). Acceptable value is [0.1, 1.0]. Default value is @code{0.17}.
11647
11648 @item coeffclamp
11649 Specify the transform coeffclamp. If coeffclamp is lower, transform is
11650 more accurate, otherwise transform is faster. Acceptable value is [0.1, 10.0].
11651 Default value is @code{1.0}.
11652
11653 @item gamma
11654 Specify gamma. Lower gamma makes the spectrum more contrast, higher gamma
11655 makes the spectrum having more range. Acceptable value is [1.0, 7.0].
11656 Default value is @code{3.0}.
11657
11658 @item gamma2
11659 Specify gamma of bargraph. Acceptable value is [1.0, 7.0].
11660 Default value is @code{1.0}.
11661
11662 @item fontfile
11663 Specify font file for use with freetype. If not specified, use embedded font.
11664
11665 @item fontcolor
11666 Specify font color expression. This is arithmetic expression that should return
11667 integer value 0xRRGGBB. The expression can contain variables:
11668 @table @option
11669 @item frequency, freq, f
11670 the frequency where transform is evaluated
11671 @item timeclamp, tc
11672 value of timeclamp option
11673 @end table
11674 and functions:
11675 @table @option
11676 @item midi(f)
11677 midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
11678 @item r(x), g(x), b(x)
11679 red, green, and blue value of intensity x
11680 @end table
11681 Default value is @code{st(0, (midi(f)-59.5)/12);
11682 st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
11683 r(1-ld(1)) + b(ld(1))}
11684
11685 @item fullhd
11686 If set to 1 (the default), the video size is 1920x1080 (full HD),
11687 if set to 0, the video size is 960x540. Use this option to make CPU usage lower.
11688
11689 @item fps
11690 Specify video fps. Default value is @code{25}.
11691
11692 @item count
11693 Specify number of transform per frame, so there are fps*count transforms
11694 per second. Note that audio data rate must be divisible by fps*count.
11695 Default value is @code{6}.
11696
11697 @end table
11698
11699 @subsection Examples
11700
11701 @itemize
11702 @item
11703 Playing audio while showing the spectrum:
11704 @example
11705 ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
11706 @end example
11707
11708 @item
11709 Same as above, but with frame rate 30 fps:
11710 @example
11711 ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
11712 @end example
11713
11714 @item
11715 Playing at 960x540 and lower CPU usage:
11716 @example
11717 ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fullhd=0:count=3 [out0]'
11718 @end example
11719
11720 @item
11721 A1 and its harmonics: A1, A2, (near)E3, A3:
11722 @example
11723 ffplay -f lavfi 'aevalsrc=0.1*sin(2*PI*55*t)+0.1*sin(4*PI*55*t)+0.1*sin(6*PI*55*t)+0.1*sin(8*PI*55*t),
11724                  asplit[a][out1]; [a] showcqt [out0]'
11725 @end example
11726
11727 @item
11728 Same as above, but with more accuracy in frequency domain (and slower):
11729 @example
11730 ffplay -f lavfi 'aevalsrc=0.1*sin(2*PI*55*t)+0.1*sin(4*PI*55*t)+0.1*sin(6*PI*55*t)+0.1*sin(8*PI*55*t),
11731                  asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
11732 @end example
11733
11734 @item
11735 B-weighting of equal loudness
11736 @example
11737 volume=16*b_weighting(f)
11738 @end example
11739
11740 @item
11741 Lower Q factor
11742 @example
11743 tlength=100/f*tc/(100/f+tc)
11744 @end example
11745
11746 @item
11747 Custom fontcolor, C-note is colored green, others are colored blue
11748 @example
11749 fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))'
11750 @end example
11751
11752 @item
11753 Custom gamma, now spectrum is linear to the amplitude.
11754 @example
11755 gamma=2:gamma2=2
11756 @end example
11757
11758 @end itemize
11759
11760 @section showspectrum
11761
11762 Convert input audio to a video output, representing the audio frequency
11763 spectrum.
11764
11765 The filter accepts the following options:
11766
11767 @table @option
11768 @item size, s
11769 Specify the video size for the output. For the syntax of this option, check the
11770 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
11771 Default value is @code{640x512}.
11772
11773 @item slide
11774 Specify how the spectrum should slide along the window.
11775
11776 It accepts the following values:
11777 @table @samp
11778 @item replace
11779 the samples start again on the left when they reach the right
11780 @item scroll
11781 the samples scroll from right to left
11782 @item fullframe
11783 frames are only produced when the samples reach the right
11784 @end table
11785
11786 Default value is @code{replace}.
11787
11788 @item mode
11789 Specify display mode.
11790
11791 It accepts the following values:
11792 @table @samp
11793 @item combined
11794 all channels are displayed in the same row
11795 @item separate
11796 all channels are displayed in separate rows
11797 @end table
11798
11799 Default value is @samp{combined}.
11800
11801 @item color
11802 Specify display color mode.
11803
11804 It accepts the following values:
11805 @table @samp
11806 @item channel
11807 each channel is displayed in a separate color
11808 @item intensity
11809 each channel is is displayed using the same color scheme
11810 @end table
11811
11812 Default value is @samp{channel}.
11813
11814 @item scale
11815 Specify scale used for calculating intensity color values.
11816
11817 It accepts the following values:
11818 @table @samp
11819 @item lin
11820 linear
11821 @item sqrt
11822 square root, default
11823 @item cbrt
11824 cubic root
11825 @item log
11826 logarithmic
11827 @end table
11828
11829 Default value is @samp{sqrt}.
11830
11831 @item saturation
11832 Set saturation modifier for displayed colors. Negative values provide
11833 alternative color scheme. @code{0} is no saturation at all.
11834 Saturation must be in [-10.0, 10.0] range.
11835 Default value is @code{1}.
11836
11837 @item win_func
11838 Set window function.
11839
11840 It accepts the following values:
11841 @table @samp
11842 @item none
11843 No samples pre-processing (do not expect this to be faster)
11844 @item hann
11845 Hann window
11846 @item hamming
11847 Hamming window
11848 @item blackman
11849 Blackman window
11850 @end table
11851
11852 Default value is @code{hann}.
11853 @end table
11854
11855 The usage is very similar to the showwaves filter; see the examples in that
11856 section.
11857
11858 @subsection Examples
11859
11860 @itemize
11861 @item
11862 Large window with logarithmic color scaling:
11863 @example
11864 showspectrum=s=1280x480:scale=log
11865 @end example
11866
11867 @item
11868 Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
11869 @example
11870 ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
11871              [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
11872 @end example
11873 @end itemize
11874
11875 @section showwaves
11876
11877 Convert input audio to a video output, representing the samples waves.
11878
11879 The filter accepts the following options:
11880
11881 @table @option
11882 @item size, s
11883 Specify the video size for the output. For the syntax of this option, check the
11884 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
11885 Default value is @code{600x240}.
11886
11887 @item mode
11888 Set display mode.
11889
11890 Available values are:
11891 @table @samp
11892 @item point
11893 Draw a point for each sample.
11894
11895 @item line
11896 Draw a vertical line for each sample.
11897
11898 @item p2p
11899 Draw a point for each sample and a line between them.
11900
11901 @item cline
11902 Draw a centered vertical line for each sample.
11903 @end table
11904
11905 Default value is @code{point}.
11906
11907 @item n
11908 Set the number of samples which are printed on the same column. A
11909 larger value will decrease the frame rate. Must be a positive
11910 integer. This option can be set only if the value for @var{rate}
11911 is not explicitly specified.
11912
11913 @item rate, r
11914 Set the (approximate) output frame rate. This is done by setting the
11915 option @var{n}. Default value is "25".
11916
11917 @item split_channels
11918 Set if channels should be drawn separately or overlap. Default value is 0.
11919
11920 @end table
11921
11922 @subsection Examples
11923
11924 @itemize
11925 @item
11926 Output the input file audio and the corresponding video representation
11927 at the same time:
11928 @example
11929 amovie=a.mp3,asplit[out0],showwaves[out1]
11930 @end example
11931
11932 @item
11933 Create a synthetic signal and show it with showwaves, forcing a
11934 frame rate of 30 frames per second:
11935 @example
11936 aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
11937 @end example
11938 @end itemize
11939
11940 @section showwavespic
11941
11942 Convert input audio to a single video frame, representing the samples waves.
11943
11944 The filter accepts the following options:
11945
11946 @table @option
11947 @item size, s
11948 Specify the video size for the output. For the syntax of this option, check the
11949 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
11950 Default value is @code{600x240}.
11951
11952 @item split_channels
11953 Set if channels should be drawn separately or overlap. Default value is 0.
11954 @end table
11955
11956 @subsection Examples
11957
11958 @itemize
11959 @item
11960 Extract a channel split representation of the wave form of a whole audio track
11961 in a 1024x800 picture using @command{ffmpeg}:
11962 @example
11963 ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
11964 @end example
11965 @end itemize
11966
11967 @section split, asplit
11968
11969 Split input into several identical outputs.
11970
11971 @code{asplit} works with audio input, @code{split} with video.
11972
11973 The filter accepts a single parameter which specifies the number of outputs. If
11974 unspecified, it defaults to 2.
11975
11976 @subsection Examples
11977
11978 @itemize
11979 @item
11980 Create two separate outputs from the same input:
11981 @example
11982 [in] split [out0][out1]
11983 @end example
11984
11985 @item
11986 To create 3 or more outputs, you need to specify the number of
11987 outputs, like in:
11988 @example
11989 [in] asplit=3 [out0][out1][out2]
11990 @end example
11991
11992 @item
11993 Create two separate outputs from the same input, one cropped and
11994 one padded:
11995 @example
11996 [in] split [splitout1][splitout2];
11997 [splitout1] crop=100:100:0:0    [cropout];
11998 [splitout2] pad=200:200:100:100 [padout];
11999 @end example
12000
12001 @item
12002 Create 5 copies of the input audio with @command{ffmpeg}:
12003 @example
12004 ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
12005 @end example
12006 @end itemize
12007
12008 @section zmq, azmq
12009
12010 Receive commands sent through a libzmq client, and forward them to
12011 filters in the filtergraph.
12012
12013 @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
12014 must be inserted between two video filters, @code{azmq} between two
12015 audio filters.
12016
12017 To enable these filters you need to install the libzmq library and
12018 headers and configure FFmpeg with @code{--enable-libzmq}.
12019
12020 For more information about libzmq see:
12021 @url{http://www.zeromq.org/}
12022
12023 The @code{zmq} and @code{azmq} filters work as a libzmq server, which
12024 receives messages sent through a network interface defined by the
12025 @option{bind_address} option.
12026
12027 The received message must be in the form:
12028 @example
12029 @var{TARGET} @var{COMMAND} [@var{ARG}]
12030 @end example
12031
12032 @var{TARGET} specifies the target of the command, usually the name of
12033 the filter class or a specific filter instance name.
12034
12035 @var{COMMAND} specifies the name of the command for the target filter.
12036
12037 @var{ARG} is optional and specifies the optional argument list for the
12038 given @var{COMMAND}.
12039
12040 Upon reception, the message is processed and the corresponding command
12041 is injected into the filtergraph. Depending on the result, the filter
12042 will send a reply to the client, adopting the format:
12043 @example
12044 @var{ERROR_CODE} @var{ERROR_REASON}
12045 @var{MESSAGE}
12046 @end example
12047
12048 @var{MESSAGE} is optional.
12049
12050 @subsection Examples
12051
12052 Look at @file{tools/zmqsend} for an example of a zmq client which can
12053 be used to send commands processed by these filters.
12054
12055 Consider the following filtergraph generated by @command{ffplay}
12056 @example
12057 ffplay -dumpgraph 1 -f lavfi "
12058 color=s=100x100:c=red  [l];
12059 color=s=100x100:c=blue [r];
12060 nullsrc=s=200x100, zmq [bg];
12061 [bg][l]   overlay      [bg+l];
12062 [bg+l][r] overlay=x=100 "
12063 @end example
12064
12065 To change the color of the left side of the video, the following
12066 command can be used:
12067 @example
12068 echo Parsed_color_0 c yellow | tools/zmqsend
12069 @end example
12070
12071 To change the right side:
12072 @example
12073 echo Parsed_color_1 c pink | tools/zmqsend
12074 @end example
12075
12076 @c man end MULTIMEDIA FILTERS
12077
12078 @chapter Multimedia Sources
12079 @c man begin MULTIMEDIA SOURCES
12080
12081 Below is a description of the currently available multimedia sources.
12082
12083 @section amovie
12084
12085 This is the same as @ref{movie} source, except it selects an audio
12086 stream by default.
12087
12088 @anchor{movie}
12089 @section movie
12090
12091 Read audio and/or video stream(s) from a movie container.
12092
12093 It accepts the following parameters:
12094
12095 @table @option
12096 @item filename
12097 The name of the resource to read (not necessarily a file; it can also be a
12098 device or a stream accessed through some protocol).
12099
12100 @item format_name, f
12101 Specifies the format assumed for the movie to read, and can be either
12102 the name of a container or an input device. If not specified, the
12103 format is guessed from @var{movie_name} or by probing.
12104
12105 @item seek_point, sp
12106 Specifies the seek point in seconds. The frames will be output
12107 starting from this seek point. The parameter is evaluated with
12108 @code{av_strtod}, so the numerical value may be suffixed by an IS
12109 postfix. The default value is "0".
12110
12111 @item streams, s
12112 Specifies the streams to read. Several streams can be specified,
12113 separated by "+". The source will then have as many outputs, in the
12114 same order. The syntax is explained in the ``Stream specifiers''
12115 section in the ffmpeg manual. Two special names, "dv" and "da" specify
12116 respectively the default (best suited) video and audio stream. Default
12117 is "dv", or "da" if the filter is called as "amovie".
12118
12119 @item stream_index, si
12120 Specifies the index of the video stream to read. If the value is -1,
12121 the most suitable video stream will be automatically selected. The default
12122 value is "-1". Deprecated. If the filter is called "amovie", it will select
12123 audio instead of video.
12124
12125 @item loop
12126 Specifies how many times to read the stream in sequence.
12127 If the value is less than 1, the stream will be read again and again.
12128 Default value is "1".
12129
12130 Note that when the movie is looped the source timestamps are not
12131 changed, so it will generate non monotonically increasing timestamps.
12132 @end table
12133
12134 It allows overlaying a second video on top of the main input of
12135 a filtergraph, as shown in this graph:
12136 @example
12137 input -----------> deltapts0 --> overlay --> output
12138                                     ^
12139                                     |
12140 movie --> scale--> deltapts1 -------+
12141 @end example
12142 @subsection Examples
12143
12144 @itemize
12145 @item
12146 Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
12147 on top of the input labelled "in":
12148 @example
12149 movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
12150 [in] setpts=PTS-STARTPTS [main];
12151 [main][over] overlay=16:16 [out]
12152 @end example
12153
12154 @item
12155 Read from a video4linux2 device, and overlay it on top of the input
12156 labelled "in":
12157 @example
12158 movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
12159 [in] setpts=PTS-STARTPTS [main];
12160 [main][over] overlay=16:16 [out]
12161 @end example
12162
12163 @item
12164 Read the first video stream and the audio stream with id 0x81 from
12165 dvd.vob; the video is connected to the pad named "video" and the audio is
12166 connected to the pad named "audio":
12167 @example
12168 movie=dvd.vob:s=v:0+#0x81 [video] [audio]
12169 @end example
12170 @end itemize
12171
12172 @c man end MULTIMEDIA SOURCES