]> git.sesse.net Git - ffmpeg/blob - doc/filters.texi
8bffb708d24dc88012c320650756193eb53d05e4
[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{id}=@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 optionally followed by "@@@var{id}".
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{FILTER_NAME}      ::= @var{NAME}["@@"@var{NAME}]
216 @var{LINKLABEL}        ::= "[" @var{NAME} "]"
217 @var{LINKLABELS}       ::= @var{LINKLABEL} [@var{LINKLABELS}]
218 @var{FILTER_ARGUMENTS} ::= sequence of chars (possibly quoted)
219 @var{FILTER}           ::= [@var{LINKLABELS}] @var{FILTER_NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}]
220 @var{FILTERCHAIN}      ::= @var{FILTER} [,@var{FILTERCHAIN}]
221 @var{FILTERGRAPH}      ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
222 @end example
223
224 @section Notes on filtergraph escaping
225
226 Filtergraph description composition entails several levels of
227 escaping. See @ref{quoting_and_escaping,,the "Quoting and escaping"
228 section in the ffmpeg-utils(1) manual,ffmpeg-utils} for more
229 information about the employed escaping procedure.
230
231 A first level escaping affects the content of each filter option
232 value, which may contain the special character @code{:} used to
233 separate values, or one of the escaping characters @code{\'}.
234
235 A second level escaping affects the whole filter description, which
236 may contain the escaping characters @code{\'} or the special
237 characters @code{[],;} used by the filtergraph description.
238
239 Finally, when you specify a filtergraph on a shell commandline, you
240 need to perform a third level escaping for the shell special
241 characters contained within it.
242
243 For example, consider the following string to be embedded in
244 the @ref{drawtext} filter description @option{text} value:
245 @example
246 this is a 'string': may contain one, or more, special characters
247 @end example
248
249 This string contains the @code{'} special escaping character, and the
250 @code{:} special character, so it needs to be escaped in this way:
251 @example
252 text=this is a \'string\'\: may contain one, or more, special characters
253 @end example
254
255 A second level of escaping is required when embedding the filter
256 description in a filtergraph description, in order to escape all the
257 filtergraph special characters. Thus the example above becomes:
258 @example
259 drawtext=text=this is a \\\'string\\\'\\: may contain one\, or more\, special characters
260 @end example
261 (note that in addition to the @code{\'} escaping special characters,
262 also @code{,} needs to be escaped).
263
264 Finally an additional level of escaping is needed when writing the
265 filtergraph description in a shell command, which depends on the
266 escaping rules of the adopted shell. For example, assuming that
267 @code{\} is special and needs to be escaped with another @code{\}, the
268 previous string will finally result in:
269 @example
270 -vf "drawtext=text=this is a \\\\\\'string\\\\\\'\\\\: may contain one\\, or more\\, special characters"
271 @end example
272
273 @chapter Timeline editing
274
275 Some filters support a generic @option{enable} option. For the filters
276 supporting timeline editing, this option can be set to an expression which is
277 evaluated before sending a frame to the filter. If the evaluation is non-zero,
278 the filter will be enabled, otherwise the frame will be sent unchanged to the
279 next filter in the filtergraph.
280
281 The expression accepts the following values:
282 @table @samp
283 @item t
284 timestamp expressed in seconds, NAN if the input timestamp is unknown
285
286 @item n
287 sequential number of the input frame, starting from 0
288
289 @item pos
290 the position in the file of the input frame, NAN if unknown
291
292 @item w
293 @item h
294 width and height of the input frame if video
295 @end table
296
297 Additionally, these filters support an @option{enable} command that can be used
298 to re-define the expression.
299
300 Like any other filtering option, the @option{enable} option follows the same
301 rules.
302
303 For example, to enable a blur filter (@ref{smartblur}) from 10 seconds to 3
304 minutes, and a @ref{curves} filter starting at 3 seconds:
305 @example
306 smartblur = enable='between(t,10,3*60)',
307 curves    = enable='gte(t,3)' : preset=cross_process
308 @end example
309
310 See @code{ffmpeg -filters} to view which filters have timeline support.
311
312 @c man end FILTERGRAPH DESCRIPTION
313
314 @anchor{framesync}
315 @chapter Options for filters with several inputs (framesync)
316 @c man begin OPTIONS FOR FILTERS WITH SEVERAL INPUTS
317
318 Some filters with several inputs support a common set of options.
319 These options can only be set by name, not with the short notation.
320
321 @table @option
322 @item eof_action
323 The action to take when EOF is encountered on the secondary input; it accepts
324 one of the following values:
325
326 @table @option
327 @item repeat
328 Repeat the last frame (the default).
329 @item endall
330 End both streams.
331 @item pass
332 Pass the main input through.
333 @end table
334
335 @item shortest
336 If set to 1, force the output to terminate when the shortest input
337 terminates. Default value is 0.
338
339 @item repeatlast
340 If set to 1, force the filter to extend the last frame of secondary streams
341 until the end of the primary stream. A value of 0 disables this behavior.
342 Default value is 1.
343 @end table
344
345 @c man end OPTIONS FOR FILTERS WITH SEVERAL INPUTS
346
347 @chapter Audio Filters
348 @c man begin AUDIO FILTERS
349
350 When you configure your FFmpeg build, you can disable any of the
351 existing filters using @code{--disable-filters}.
352 The configure output will show the audio filters included in your
353 build.
354
355 Below is a description of the currently available audio filters.
356
357 @section acompressor
358
359 A compressor is mainly used to reduce the dynamic range of a signal.
360 Especially modern music is mostly compressed at a high ratio to
361 improve the overall loudness. It's done to get the highest attention
362 of a listener, "fatten" the sound and bring more "power" to the track.
363 If a signal is compressed too much it may sound dull or "dead"
364 afterwards or it may start to "pump" (which could be a powerful effect
365 but can also destroy a track completely).
366 The right compression is the key to reach a professional sound and is
367 the high art of mixing and mastering. Because of its complex settings
368 it may take a long time to get the right feeling for this kind of effect.
369
370 Compression is done by detecting the volume above a chosen level
371 @code{threshold} and dividing it by the factor set with @code{ratio}.
372 So if you set the threshold to -12dB and your signal reaches -6dB a ratio
373 of 2:1 will result in a signal at -9dB. Because an exact manipulation of
374 the signal would cause distortion of the waveform the reduction can be
375 levelled over the time. This is done by setting "Attack" and "Release".
376 @code{attack} determines how long the signal has to rise above the threshold
377 before any reduction will occur and @code{release} sets the time the signal
378 has to fall below the threshold to reduce the reduction again. Shorter signals
379 than the chosen attack time will be left untouched.
380 The overall reduction of the signal can be made up afterwards with the
381 @code{makeup} setting. So compressing the peaks of a signal about 6dB and
382 raising the makeup to this level results in a signal twice as loud than the
383 source. To gain a softer entry in the compression the @code{knee} flattens the
384 hard edge at the threshold in the range of the chosen decibels.
385
386 The filter accepts the following options:
387
388 @table @option
389 @item level_in
390 Set input gain. Default is 1. Range is between 0.015625 and 64.
391
392 @item threshold
393 If a signal of stream rises above this level it will affect the gain
394 reduction.
395 By default it is 0.125. Range is between 0.00097563 and 1.
396
397 @item ratio
398 Set a ratio by which the signal is reduced. 1:2 means that if the level
399 rose 4dB above the threshold, it will be only 2dB above after the reduction.
400 Default is 2. Range is between 1 and 20.
401
402 @item attack
403 Amount of milliseconds the signal has to rise above the threshold before gain
404 reduction starts. Default is 20. Range is between 0.01 and 2000.
405
406 @item release
407 Amount of milliseconds the signal has to fall below the threshold before
408 reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
409
410 @item makeup
411 Set the amount by how much signal will be amplified after processing.
412 Default is 1. Range is from 1 to 64.
413
414 @item knee
415 Curve the sharp knee around the threshold to enter gain reduction more softly.
416 Default is 2.82843. Range is between 1 and 8.
417
418 @item link
419 Choose if the @code{average} level between all channels of input stream
420 or the louder(@code{maximum}) channel of input stream affects the
421 reduction. Default is @code{average}.
422
423 @item detection
424 Should the exact signal be taken in case of @code{peak} or an RMS one in case
425 of @code{rms}. Default is @code{rms} which is mostly smoother.
426
427 @item mix
428 How much to use compressed signal in output. Default is 1.
429 Range is between 0 and 1.
430 @end table
431
432 @section acontrast
433 Simple audio dynamic range commpression/expansion filter.
434
435 The filter accepts the following options:
436
437 @table @option
438 @item contrast
439 Set contrast. Default is 33. Allowed range is between 0 and 100.
440 @end table
441
442 @section acopy
443
444 Copy the input audio source unchanged to the output. This is mainly useful for
445 testing purposes.
446
447 @section acrossfade
448
449 Apply cross fade from one input audio stream to another input audio stream.
450 The cross fade is applied for specified duration near the end of first stream.
451
452 The filter accepts the following options:
453
454 @table @option
455 @item nb_samples, ns
456 Specify the number of samples for which the cross fade effect has to last.
457 At the end of the cross fade effect the first input audio will be completely
458 silent. Default is 44100.
459
460 @item duration, d
461 Specify the duration of the cross fade effect. See
462 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
463 for the accepted syntax.
464 By default the duration is determined by @var{nb_samples}.
465 If set this option is used instead of @var{nb_samples}.
466
467 @item overlap, o
468 Should first stream end overlap with second stream start. Default is enabled.
469
470 @item curve1
471 Set curve for cross fade transition for first stream.
472
473 @item curve2
474 Set curve for cross fade transition for second stream.
475
476 For description of available curve types see @ref{afade} filter description.
477 @end table
478
479 @subsection Examples
480
481 @itemize
482 @item
483 Cross fade from one input to another:
484 @example
485 ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:c1=exp:c2=exp output.flac
486 @end example
487
488 @item
489 Cross fade from one input to another but without overlapping:
490 @example
491 ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:o=0:c1=exp:c2=exp output.flac
492 @end example
493 @end itemize
494
495 @section acrusher
496
497 Reduce audio bit resolution.
498
499 This filter is bit crusher with enhanced functionality. A bit crusher
500 is used to audibly reduce number of bits an audio signal is sampled
501 with. This doesn't change the bit depth at all, it just produces the
502 effect. Material reduced in bit depth sounds more harsh and "digital".
503 This filter is able to even round to continuous values instead of discrete
504 bit depths.
505 Additionally it has a D/C offset which results in different crushing of
506 the lower and the upper half of the signal.
507 An Anti-Aliasing setting is able to produce "softer" crushing sounds.
508
509 Another feature of this filter is the logarithmic mode.
510 This setting switches from linear distances between bits to logarithmic ones.
511 The result is a much more "natural" sounding crusher which doesn't gate low
512 signals for example. The human ear has a logarithmic perception, too
513 so this kind of crushing is much more pleasant.
514 Logarithmic crushing is also able to get anti-aliased.
515
516 The filter accepts the following options:
517
518 @table @option
519 @item level_in
520 Set level in.
521
522 @item level_out
523 Set level out.
524
525 @item bits
526 Set bit reduction.
527
528 @item mix
529 Set mixing amount.
530
531 @item mode
532 Can be linear: @code{lin} or logarithmic: @code{log}.
533
534 @item dc
535 Set DC.
536
537 @item aa
538 Set anti-aliasing.
539
540 @item samples
541 Set sample reduction.
542
543 @item lfo
544 Enable LFO. By default disabled.
545
546 @item lforange
547 Set LFO range.
548
549 @item lforate
550 Set LFO rate.
551 @end table
552
553 @section adelay
554
555 Delay one or more audio channels.
556
557 Samples in delayed channel are filled with silence.
558
559 The filter accepts the following option:
560
561 @table @option
562 @item delays
563 Set list of delays in milliseconds for each channel separated by '|'.
564 Unused delays will be silently ignored. If number of given delays is
565 smaller than number of channels all remaining channels will not be delayed.
566 If you want to delay exact number of samples, append 'S' to number.
567 @end table
568
569 @subsection Examples
570
571 @itemize
572 @item
573 Delay first channel by 1.5 seconds, the third channel by 0.5 seconds and leave
574 the second channel (and any other channels that may be present) unchanged.
575 @example
576 adelay=1500|0|500
577 @end example
578
579 @item
580 Delay second channel by 500 samples, the third channel by 700 samples and leave
581 the first channel (and any other channels that may be present) unchanged.
582 @example
583 adelay=0|500S|700S
584 @end example
585 @end itemize
586
587 @section aecho
588
589 Apply echoing to the input audio.
590
591 Echoes are reflected sound and can occur naturally amongst mountains
592 (and sometimes large buildings) when talking or shouting; digital echo
593 effects emulate this behaviour and are often used to help fill out the
594 sound of a single instrument or vocal. The time difference between the
595 original signal and the reflection is the @code{delay}, and the
596 loudness of the reflected signal is the @code{decay}.
597 Multiple echoes can have different delays and decays.
598
599 A description of the accepted parameters follows.
600
601 @table @option
602 @item in_gain
603 Set input gain of reflected signal. Default is @code{0.6}.
604
605 @item out_gain
606 Set output gain of reflected signal. Default is @code{0.3}.
607
608 @item delays
609 Set list of time intervals in milliseconds between original signal and reflections
610 separated by '|'. Allowed range for each @code{delay} is @code{(0 - 90000.0]}.
611 Default is @code{1000}.
612
613 @item decays
614 Set list of loudness of reflected signals separated by '|'.
615 Allowed range for each @code{decay} is @code{(0 - 1.0]}.
616 Default is @code{0.5}.
617 @end table
618
619 @subsection Examples
620
621 @itemize
622 @item
623 Make it sound as if there are twice as many instruments as are actually playing:
624 @example
625 aecho=0.8:0.88:60:0.4
626 @end example
627
628 @item
629 If delay is very short, then it sound like a (metallic) robot playing music:
630 @example
631 aecho=0.8:0.88:6:0.4
632 @end example
633
634 @item
635 A longer delay will sound like an open air concert in the mountains:
636 @example
637 aecho=0.8:0.9:1000:0.3
638 @end example
639
640 @item
641 Same as above but with one more mountain:
642 @example
643 aecho=0.8:0.9:1000|1800:0.3|0.25
644 @end example
645 @end itemize
646
647 @section aemphasis
648 Audio emphasis filter creates or restores material directly taken from LPs or
649 emphased CDs with different filter curves. E.g. to store music on vinyl the
650 signal has to be altered by a filter first to even out the disadvantages of
651 this recording medium.
652 Once the material is played back the inverse filter has to be applied to
653 restore the distortion of the frequency response.
654
655 The filter accepts the following options:
656
657 @table @option
658 @item level_in
659 Set input gain.
660
661 @item level_out
662 Set output gain.
663
664 @item mode
665 Set filter mode. For restoring material use @code{reproduction} mode, otherwise
666 use @code{production} mode. Default is @code{reproduction} mode.
667
668 @item type
669 Set filter type. Selects medium. Can be one of the following:
670
671 @table @option
672 @item col
673 select Columbia.
674 @item emi
675 select EMI.
676 @item bsi
677 select BSI (78RPM).
678 @item riaa
679 select RIAA.
680 @item cd
681 select Compact Disc (CD).
682 @item 50fm
683 select 50µs (FM).
684 @item 75fm
685 select 75µs (FM).
686 @item 50kf
687 select 50µs (FM-KF).
688 @item 75kf
689 select 75µs (FM-KF).
690 @end table
691 @end table
692
693 @section aeval
694
695 Modify an audio signal according to the specified expressions.
696
697 This filter accepts one or more expressions (one for each channel),
698 which are evaluated and used to modify a corresponding audio signal.
699
700 It accepts the following parameters:
701
702 @table @option
703 @item exprs
704 Set the '|'-separated expressions list for each separate channel. If
705 the number of input channels is greater than the number of
706 expressions, the last specified expression is used for the remaining
707 output channels.
708
709 @item channel_layout, c
710 Set output channel layout. If not specified, the channel layout is
711 specified by the number of expressions. If set to @samp{same}, it will
712 use by default the same input channel layout.
713 @end table
714
715 Each expression in @var{exprs} can contain the following constants and functions:
716
717 @table @option
718 @item ch
719 channel number of the current expression
720
721 @item n
722 number of the evaluated sample, starting from 0
723
724 @item s
725 sample rate
726
727 @item t
728 time of the evaluated sample expressed in seconds
729
730 @item nb_in_channels
731 @item nb_out_channels
732 input and output number of channels
733
734 @item val(CH)
735 the value of input channel with number @var{CH}
736 @end table
737
738 Note: this filter is slow. For faster processing you should use a
739 dedicated filter.
740
741 @subsection Examples
742
743 @itemize
744 @item
745 Half volume:
746 @example
747 aeval=val(ch)/2:c=same
748 @end example
749
750 @item
751 Invert phase of the second channel:
752 @example
753 aeval=val(0)|-val(1)
754 @end example
755 @end itemize
756
757 @anchor{afade}
758 @section afade
759
760 Apply fade-in/out effect to input audio.
761
762 A description of the accepted parameters follows.
763
764 @table @option
765 @item type, t
766 Specify the effect type, can be either @code{in} for fade-in, or
767 @code{out} for a fade-out effect. Default is @code{in}.
768
769 @item start_sample, ss
770 Specify the number of the start sample for starting to apply the fade
771 effect. Default is 0.
772
773 @item nb_samples, ns
774 Specify the number of samples for which the fade effect has to last. At
775 the end of the fade-in effect the output audio will have the same
776 volume as the input audio, at the end of the fade-out transition
777 the output audio will be silence. Default is 44100.
778
779 @item start_time, st
780 Specify the start time of the fade effect. Default is 0.
781 The value must be specified as a time duration; see
782 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
783 for the accepted syntax.
784 If set this option is used instead of @var{start_sample}.
785
786 @item duration, d
787 Specify the duration of the fade effect. See
788 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
789 for the accepted syntax.
790 At the end of the fade-in effect the output audio will have the same
791 volume as the input audio, at the end of the fade-out transition
792 the output audio will be silence.
793 By default the duration is determined by @var{nb_samples}.
794 If set this option is used instead of @var{nb_samples}.
795
796 @item curve
797 Set curve for fade transition.
798
799 It accepts the following values:
800 @table @option
801 @item tri
802 select triangular, linear slope (default)
803 @item qsin
804 select quarter of sine wave
805 @item hsin
806 select half of sine wave
807 @item esin
808 select exponential sine wave
809 @item log
810 select logarithmic
811 @item ipar
812 select inverted parabola
813 @item qua
814 select quadratic
815 @item cub
816 select cubic
817 @item squ
818 select square root
819 @item cbr
820 select cubic root
821 @item par
822 select parabola
823 @item exp
824 select exponential
825 @item iqsin
826 select inverted quarter of sine wave
827 @item ihsin
828 select inverted half of sine wave
829 @item dese
830 select double-exponential seat
831 @item desi
832 select double-exponential sigmoid
833 @end table
834 @end table
835
836 @subsection Examples
837
838 @itemize
839 @item
840 Fade in first 15 seconds of audio:
841 @example
842 afade=t=in:ss=0:d=15
843 @end example
844
845 @item
846 Fade out last 25 seconds of a 900 seconds audio:
847 @example
848 afade=t=out:st=875:d=25
849 @end example
850 @end itemize
851
852 @section afftfilt
853 Apply arbitrary expressions to samples in frequency domain.
854
855 @table @option
856 @item real
857 Set frequency domain real expression for each separate channel separated
858 by '|'. Default is "1".
859 If the number of input channels is greater than the number of
860 expressions, the last specified expression is used for the remaining
861 output channels.
862
863 @item imag
864 Set frequency domain imaginary expression for each separate channel
865 separated by '|'. If not set, @var{real} option is used.
866
867 Each expression in @var{real} and @var{imag} can contain the following
868 constants:
869
870 @table @option
871 @item sr
872 sample rate
873
874 @item b
875 current frequency bin number
876
877 @item nb
878 number of available bins
879
880 @item ch
881 channel number of the current expression
882
883 @item chs
884 number of channels
885
886 @item pts
887 current frame pts
888 @end table
889
890 @item win_size
891 Set window size.
892
893 It accepts the following values:
894 @table @samp
895 @item w16
896 @item w32
897 @item w64
898 @item w128
899 @item w256
900 @item w512
901 @item w1024
902 @item w2048
903 @item w4096
904 @item w8192
905 @item w16384
906 @item w32768
907 @item w65536
908 @end table
909 Default is @code{w4096}
910
911 @item win_func
912 Set window function. Default is @code{hann}.
913
914 @item overlap
915 Set window overlap. If set to 1, the recommended overlap for selected
916 window function will be picked. Default is @code{0.75}.
917 @end table
918
919 @subsection Examples
920
921 @itemize
922 @item
923 Leave almost only low frequencies in audio:
924 @example
925 afftfilt="1-clip((b/nb)*b,0,1)"
926 @end example
927 @end itemize
928
929 @section afir
930
931 Apply an arbitrary Frequency Impulse Response filter.
932
933 This filter is designed for applying long FIR filters,
934 up to 30 seconds long.
935
936 It can be used as component for digital crossover filters,
937 room equalization, cross talk cancellation, wavefield synthesis,
938 auralization, ambiophonics and ambisonics.
939
940 This filter uses second stream as FIR coefficients.
941 If second stream holds single channel, it will be used
942 for all input channels in first stream, otherwise
943 number of channels in second stream must be same as
944 number of channels in first stream.
945
946 It accepts the following parameters:
947
948 @table @option
949 @item dry
950 Set dry gain. This sets input gain.
951
952 @item wet
953 Set wet gain. This sets final output gain.
954
955 @item length
956 Set Impulse Response filter length. Default is 1, which means whole IR is processed.
957
958 @item again
959 Enable applying gain measured from power of IR.
960 @end table
961
962 @subsection Examples
963
964 @itemize
965 @item
966 Apply reverb to stream using mono IR file as second input, complete command using ffmpeg:
967 @example
968 ffmpeg -i input.wav -i middle_tunnel_1way_mono.wav -lavfi afir output.wav
969 @end example
970 @end itemize
971
972 @anchor{aformat}
973 @section aformat
974
975 Set output format constraints for the input audio. The framework will
976 negotiate the most appropriate format to minimize conversions.
977
978 It accepts the following parameters:
979 @table @option
980
981 @item sample_fmts
982 A '|'-separated list of requested sample formats.
983
984 @item sample_rates
985 A '|'-separated list of requested sample rates.
986
987 @item channel_layouts
988 A '|'-separated list of requested channel layouts.
989
990 See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
991 for the required syntax.
992 @end table
993
994 If a parameter is omitted, all values are allowed.
995
996 Force the output to either unsigned 8-bit or signed 16-bit stereo
997 @example
998 aformat=sample_fmts=u8|s16:channel_layouts=stereo
999 @end example
1000
1001 @section agate
1002
1003 A gate is mainly used to reduce lower parts of a signal. This kind of signal
1004 processing reduces disturbing noise between useful signals.
1005
1006 Gating is done by detecting the volume below a chosen level @var{threshold}
1007 and dividing it by the factor set with @var{ratio}. The bottom of the noise
1008 floor is set via @var{range}. Because an exact manipulation of the signal
1009 would cause distortion of the waveform the reduction can be levelled over
1010 time. This is done by setting @var{attack} and @var{release}.
1011
1012 @var{attack} determines how long the signal has to fall below the threshold
1013 before any reduction will occur and @var{release} sets the time the signal
1014 has to rise above the threshold to reduce the reduction again.
1015 Shorter signals than the chosen attack time will be left untouched.
1016
1017 @table @option
1018 @item level_in
1019 Set input level before filtering.
1020 Default is 1. Allowed range is from 0.015625 to 64.
1021
1022 @item range
1023 Set the level of gain reduction when the signal is below the threshold.
1024 Default is 0.06125. Allowed range is from 0 to 1.
1025
1026 @item threshold
1027 If a signal rises above this level the gain reduction is released.
1028 Default is 0.125. Allowed range is from 0 to 1.
1029
1030 @item ratio
1031 Set a ratio by which the signal is reduced.
1032 Default is 2. Allowed range is from 1 to 9000.
1033
1034 @item attack
1035 Amount of milliseconds the signal has to rise above the threshold before gain
1036 reduction stops.
1037 Default is 20 milliseconds. Allowed range is from 0.01 to 9000.
1038
1039 @item release
1040 Amount of milliseconds the signal has to fall below the threshold before the
1041 reduction is increased again. Default is 250 milliseconds.
1042 Allowed range is from 0.01 to 9000.
1043
1044 @item makeup
1045 Set amount of amplification of signal after processing.
1046 Default is 1. Allowed range is from 1 to 64.
1047
1048 @item knee
1049 Curve the sharp knee around the threshold to enter gain reduction more softly.
1050 Default is 2.828427125. Allowed range is from 1 to 8.
1051
1052 @item detection
1053 Choose if exact signal should be taken for detection or an RMS like one.
1054 Default is @code{rms}. Can be @code{peak} or @code{rms}.
1055
1056 @item link
1057 Choose if the average level between all channels or the louder channel affects
1058 the reduction.
1059 Default is @code{average}. Can be @code{average} or @code{maximum}.
1060 @end table
1061
1062 @section alimiter
1063
1064 The limiter prevents an input signal from rising over a desired threshold.
1065 This limiter uses lookahead technology to prevent your signal from distorting.
1066 It means that there is a small delay after the signal is processed. Keep in mind
1067 that the delay it produces is the attack time you set.
1068
1069 The filter accepts the following options:
1070
1071 @table @option
1072 @item level_in
1073 Set input gain. Default is 1.
1074
1075 @item level_out
1076 Set output gain. Default is 1.
1077
1078 @item limit
1079 Don't let signals above this level pass the limiter. Default is 1.
1080
1081 @item attack
1082 The limiter will reach its attenuation level in this amount of time in
1083 milliseconds. Default is 5 milliseconds.
1084
1085 @item release
1086 Come back from limiting to attenuation 1.0 in this amount of milliseconds.
1087 Default is 50 milliseconds.
1088
1089 @item asc
1090 When gain reduction is always needed ASC takes care of releasing to an
1091 average reduction level rather than reaching a reduction of 0 in the release
1092 time.
1093
1094 @item asc_level
1095 Select how much the release time is affected by ASC, 0 means nearly no changes
1096 in release time while 1 produces higher release times.
1097
1098 @item level
1099 Auto level output signal. Default is enabled.
1100 This normalizes audio back to 0dB if enabled.
1101 @end table
1102
1103 Depending on picked setting it is recommended to upsample input 2x or 4x times
1104 with @ref{aresample} before applying this filter.
1105
1106 @section allpass
1107
1108 Apply a two-pole all-pass filter with central frequency (in Hz)
1109 @var{frequency}, and filter-width @var{width}.
1110 An all-pass filter changes the audio's frequency to phase relationship
1111 without changing its frequency to amplitude relationship.
1112
1113 The filter accepts the following options:
1114
1115 @table @option
1116 @item frequency, f
1117 Set frequency in Hz.
1118
1119 @item width_type, t
1120 Set method to specify band-width of filter.
1121 @table @option
1122 @item h
1123 Hz
1124 @item q
1125 Q-Factor
1126 @item o
1127 octave
1128 @item s
1129 slope
1130 @end table
1131
1132 @item width, w
1133 Specify the band-width of a filter in width_type units.
1134
1135 @item channels, c
1136 Specify which channels to filter, by default all available are filtered.
1137 @end table
1138
1139 @section aloop
1140
1141 Loop audio samples.
1142
1143 The filter accepts the following options:
1144
1145 @table @option
1146 @item loop
1147 Set the number of loops. Setting this value to -1 will result in infinite loops.
1148 Default is 0.
1149
1150 @item size
1151 Set maximal number of samples. Default is 0.
1152
1153 @item start
1154 Set first sample of loop. Default is 0.
1155 @end table
1156
1157 @anchor{amerge}
1158 @section amerge
1159
1160 Merge two or more audio streams into a single multi-channel stream.
1161
1162 The filter accepts the following options:
1163
1164 @table @option
1165
1166 @item inputs
1167 Set the number of inputs. Default is 2.
1168
1169 @end table
1170
1171 If the channel layouts of the inputs are disjoint, and therefore compatible,
1172 the channel layout of the output will be set accordingly and the channels
1173 will be reordered as necessary. If the channel layouts of the inputs are not
1174 disjoint, the output will have all the channels of the first input then all
1175 the channels of the second input, in that order, and the channel layout of
1176 the output will be the default value corresponding to the total number of
1177 channels.
1178
1179 For example, if the first input is in 2.1 (FL+FR+LF) and the second input
1180 is FC+BL+BR, then the output will be in 5.1, with the channels in the
1181 following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
1182 first input, b1 is the first channel of the second input).
1183
1184 On the other hand, if both input are in stereo, the output channels will be
1185 in the default order: a1, a2, b1, b2, and the channel layout will be
1186 arbitrarily set to 4.0, which may or may not be the expected value.
1187
1188 All inputs must have the same sample rate, and format.
1189
1190 If inputs do not have the same duration, the output will stop with the
1191 shortest.
1192
1193 @subsection Examples
1194
1195 @itemize
1196 @item
1197 Merge two mono files into a stereo stream:
1198 @example
1199 amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
1200 @end example
1201
1202 @item
1203 Multiple merges assuming 1 video stream and 6 audio streams in @file{input.mkv}:
1204 @example
1205 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
1206 @end example
1207 @end itemize
1208
1209 @section amix
1210
1211 Mixes multiple audio inputs into a single output.
1212
1213 Note that this filter only supports float samples (the @var{amerge}
1214 and @var{pan} audio filters support many formats). If the @var{amix}
1215 input has integer samples then @ref{aresample} will be automatically
1216 inserted to perform the conversion to float samples.
1217
1218 For example
1219 @example
1220 ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
1221 @end example
1222 will mix 3 input audio streams to a single output with the same duration as the
1223 first input and a dropout transition time of 3 seconds.
1224
1225 It accepts the following parameters:
1226 @table @option
1227
1228 @item inputs
1229 The number of inputs. If unspecified, it defaults to 2.
1230
1231 @item duration
1232 How to determine the end-of-stream.
1233 @table @option
1234
1235 @item longest
1236 The duration of the longest input. (default)
1237
1238 @item shortest
1239 The duration of the shortest input.
1240
1241 @item first
1242 The duration of the first input.
1243
1244 @end table
1245
1246 @item dropout_transition
1247 The transition time, in seconds, for volume renormalization when an input
1248 stream ends. The default value is 2 seconds.
1249
1250 @end table
1251
1252 @section anequalizer
1253
1254 High-order parametric multiband equalizer for each channel.
1255
1256 It accepts the following parameters:
1257 @table @option
1258 @item params
1259
1260 This option string is in format:
1261 "c@var{chn} f=@var{cf} w=@var{w} g=@var{g} t=@var{f} | ..."
1262 Each equalizer band is separated by '|'.
1263
1264 @table @option
1265 @item chn
1266 Set channel number to which equalization will be applied.
1267 If input doesn't have that channel the entry is ignored.
1268
1269 @item f
1270 Set central frequency for band.
1271 If input doesn't have that frequency the entry is ignored.
1272
1273 @item w
1274 Set band width in hertz.
1275
1276 @item g
1277 Set band gain in dB.
1278
1279 @item t
1280 Set filter type for band, optional, can be:
1281
1282 @table @samp
1283 @item 0
1284 Butterworth, this is default.
1285
1286 @item 1
1287 Chebyshev type 1.
1288
1289 @item 2
1290 Chebyshev type 2.
1291 @end table
1292 @end table
1293
1294 @item curves
1295 With this option activated frequency response of anequalizer is displayed
1296 in video stream.
1297
1298 @item size
1299 Set video stream size. Only useful if curves option is activated.
1300
1301 @item mgain
1302 Set max gain that will be displayed. Only useful if curves option is activated.
1303 Setting this to a reasonable value makes it possible to display gain which is derived from
1304 neighbour bands which are too close to each other and thus produce higher gain
1305 when both are activated.
1306
1307 @item fscale
1308 Set frequency scale used to draw frequency response in video output.
1309 Can be linear or logarithmic. Default is logarithmic.
1310
1311 @item colors
1312 Set color for each channel curve which is going to be displayed in video stream.
1313 This is list of color names separated by space or by '|'.
1314 Unrecognised or missing colors will be replaced by white color.
1315 @end table
1316
1317 @subsection Examples
1318
1319 @itemize
1320 @item
1321 Lower gain by 10 of central frequency 200Hz and width 100 Hz
1322 for first 2 channels using Chebyshev type 1 filter:
1323 @example
1324 anequalizer=c0 f=200 w=100 g=-10 t=1|c1 f=200 w=100 g=-10 t=1
1325 @end example
1326 @end itemize
1327
1328 @subsection Commands
1329
1330 This filter supports the following commands:
1331 @table @option
1332 @item change
1333 Alter existing filter parameters.
1334 Syntax for the commands is : "@var{fN}|f=@var{freq}|w=@var{width}|g=@var{gain}"
1335
1336 @var{fN} is existing filter number, starting from 0, if no such filter is available
1337 error is returned.
1338 @var{freq} set new frequency parameter.
1339 @var{width} set new width parameter in herz.
1340 @var{gain} set new gain parameter in dB.
1341
1342 Full filter invocation with asendcmd may look like this:
1343 asendcmd=c='4.0 anequalizer change 0|f=200|w=50|g=1',anequalizer=...
1344 @end table
1345
1346 @section anull
1347
1348 Pass the audio source unchanged to the output.
1349
1350 @section apad
1351
1352 Pad the end of an audio stream with silence.
1353
1354 This can be used together with @command{ffmpeg} @option{-shortest} to
1355 extend audio streams to the same length as the video stream.
1356
1357 A description of the accepted options follows.
1358
1359 @table @option
1360 @item packet_size
1361 Set silence packet size. Default value is 4096.
1362
1363 @item pad_len
1364 Set the number of samples of silence to add to the end. After the
1365 value is reached, the stream is terminated. This option is mutually
1366 exclusive with @option{whole_len}.
1367
1368 @item whole_len
1369 Set the minimum total number of samples in the output audio stream. If
1370 the value is longer than the input audio length, silence is added to
1371 the end, until the value is reached. This option is mutually exclusive
1372 with @option{pad_len}.
1373 @end table
1374
1375 If neither the @option{pad_len} nor the @option{whole_len} option is
1376 set, the filter will add silence to the end of the input stream
1377 indefinitely.
1378
1379 @subsection Examples
1380
1381 @itemize
1382 @item
1383 Add 1024 samples of silence to the end of the input:
1384 @example
1385 apad=pad_len=1024
1386 @end example
1387
1388 @item
1389 Make sure the audio output will contain at least 10000 samples, pad
1390 the input with silence if required:
1391 @example
1392 apad=whole_len=10000
1393 @end example
1394
1395 @item
1396 Use @command{ffmpeg} to pad the audio input with silence, so that the
1397 video stream will always result the shortest and will be converted
1398 until the end in the output file when using the @option{shortest}
1399 option:
1400 @example
1401 ffmpeg -i VIDEO -i AUDIO -filter_complex "[1:0]apad" -shortest OUTPUT
1402 @end example
1403 @end itemize
1404
1405 @section aphaser
1406 Add a phasing effect to the input audio.
1407
1408 A phaser filter creates series of peaks and troughs in the frequency spectrum.
1409 The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
1410
1411 A description of the accepted parameters follows.
1412
1413 @table @option
1414 @item in_gain
1415 Set input gain. Default is 0.4.
1416
1417 @item out_gain
1418 Set output gain. Default is 0.74
1419
1420 @item delay
1421 Set delay in milliseconds. Default is 3.0.
1422
1423 @item decay
1424 Set decay. Default is 0.4.
1425
1426 @item speed
1427 Set modulation speed in Hz. Default is 0.5.
1428
1429 @item type
1430 Set modulation type. Default is triangular.
1431
1432 It accepts the following values:
1433 @table @samp
1434 @item triangular, t
1435 @item sinusoidal, s
1436 @end table
1437 @end table
1438
1439 @section apulsator
1440
1441 Audio pulsator is something between an autopanner and a tremolo.
1442 But it can produce funny stereo effects as well. Pulsator changes the volume
1443 of the left and right channel based on a LFO (low frequency oscillator) with
1444 different waveforms and shifted phases.
1445 This filter have the ability to define an offset between left and right
1446 channel. An offset of 0 means that both LFO shapes match each other.
1447 The left and right channel are altered equally - a conventional tremolo.
1448 An offset of 50% means that the shape of the right channel is exactly shifted
1449 in phase (or moved backwards about half of the frequency) - pulsator acts as
1450 an autopanner. At 1 both curves match again. Every setting in between moves the
1451 phase shift gapless between all stages and produces some "bypassing" sounds with
1452 sine and triangle waveforms. The more you set the offset near 1 (starting from
1453 the 0.5) the faster the signal passes from the left to the right speaker.
1454
1455 The filter accepts the following options:
1456
1457 @table @option
1458 @item level_in
1459 Set input gain. By default it is 1. Range is [0.015625 - 64].
1460
1461 @item level_out
1462 Set output gain. By default it is 1. Range is [0.015625 - 64].
1463
1464 @item mode
1465 Set waveform shape the LFO will use. Can be one of: sine, triangle, square,
1466 sawup or sawdown. Default is sine.
1467
1468 @item amount
1469 Set modulation. Define how much of original signal is affected by the LFO.
1470
1471 @item offset_l
1472 Set left channel offset. Default is 0. Allowed range is [0 - 1].
1473
1474 @item offset_r
1475 Set right channel offset. Default is 0.5. Allowed range is [0 - 1].
1476
1477 @item width
1478 Set pulse width. Default is 1. Allowed range is [0 - 2].
1479
1480 @item timing
1481 Set possible timing mode. Can be one of: bpm, ms or hz. Default is hz.
1482
1483 @item bpm
1484 Set bpm. Default is 120. Allowed range is [30 - 300]. Only used if timing
1485 is set to bpm.
1486
1487 @item ms
1488 Set ms. Default is 500. Allowed range is [10 - 2000]. Only used if timing
1489 is set to ms.
1490
1491 @item hz
1492 Set frequency in Hz. Default is 2. Allowed range is [0.01 - 100]. Only used
1493 if timing is set to hz.
1494 @end table
1495
1496 @anchor{aresample}
1497 @section aresample
1498
1499 Resample the input audio to the specified parameters, using the
1500 libswresample library. If none are specified then the filter will
1501 automatically convert between its input and output.
1502
1503 This filter is also able to stretch/squeeze the audio data to make it match
1504 the timestamps or to inject silence / cut out audio to make it match the
1505 timestamps, do a combination of both or do neither.
1506
1507 The filter accepts the syntax
1508 [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
1509 expresses a sample rate and @var{resampler_options} is a list of
1510 @var{key}=@var{value} pairs, separated by ":". See the
1511 @ref{Resampler Options,,the "Resampler Options" section in the
1512 ffmpeg-resampler(1) manual,ffmpeg-resampler}
1513 for the complete list of supported options.
1514
1515 @subsection Examples
1516
1517 @itemize
1518 @item
1519 Resample the input audio to 44100Hz:
1520 @example
1521 aresample=44100
1522 @end example
1523
1524 @item
1525 Stretch/squeeze samples to the given timestamps, with a maximum of 1000
1526 samples per second compensation:
1527 @example
1528 aresample=async=1000
1529 @end example
1530 @end itemize
1531
1532 @section areverse
1533
1534 Reverse an audio clip.
1535
1536 Warning: This filter requires memory to buffer the entire clip, so trimming
1537 is suggested.
1538
1539 @subsection Examples
1540
1541 @itemize
1542 @item
1543 Take the first 5 seconds of a clip, and reverse it.
1544 @example
1545 atrim=end=5,areverse
1546 @end example
1547 @end itemize
1548
1549 @section asetnsamples
1550
1551 Set the number of samples per each output audio frame.
1552
1553 The last output packet may contain a different number of samples, as
1554 the filter will flush all the remaining samples when the input audio
1555 signals its end.
1556
1557 The filter accepts the following options:
1558
1559 @table @option
1560
1561 @item nb_out_samples, n
1562 Set the number of frames per each output audio frame. The number is
1563 intended as the number of samples @emph{per each channel}.
1564 Default value is 1024.
1565
1566 @item pad, p
1567 If set to 1, the filter will pad the last audio frame with zeroes, so
1568 that the last frame will contain the same number of samples as the
1569 previous ones. Default value is 1.
1570 @end table
1571
1572 For example, to set the number of per-frame samples to 1234 and
1573 disable padding for the last frame, use:
1574 @example
1575 asetnsamples=n=1234:p=0
1576 @end example
1577
1578 @section asetrate
1579
1580 Set the sample rate without altering the PCM data.
1581 This will result in a change of speed and pitch.
1582
1583 The filter accepts the following options:
1584
1585 @table @option
1586 @item sample_rate, r
1587 Set the output sample rate. Default is 44100 Hz.
1588 @end table
1589
1590 @section ashowinfo
1591
1592 Show a line containing various information for each input audio frame.
1593 The input audio is not modified.
1594
1595 The shown line contains a sequence of key/value pairs of the form
1596 @var{key}:@var{value}.
1597
1598 The following values are shown in the output:
1599
1600 @table @option
1601 @item n
1602 The (sequential) number of the input frame, starting from 0.
1603
1604 @item pts
1605 The presentation timestamp of the input frame, in time base units; the time base
1606 depends on the filter input pad, and is usually 1/@var{sample_rate}.
1607
1608 @item pts_time
1609 The presentation timestamp of the input frame in seconds.
1610
1611 @item pos
1612 position of the frame in the input stream, -1 if this information in
1613 unavailable and/or meaningless (for example in case of synthetic audio)
1614
1615 @item fmt
1616 The sample format.
1617
1618 @item chlayout
1619 The channel layout.
1620
1621 @item rate
1622 The sample rate for the audio frame.
1623
1624 @item nb_samples
1625 The number of samples (per channel) in the frame.
1626
1627 @item checksum
1628 The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
1629 audio, the data is treated as if all the planes were concatenated.
1630
1631 @item plane_checksums
1632 A list of Adler-32 checksums for each data plane.
1633 @end table
1634
1635 @anchor{astats}
1636 @section astats
1637
1638 Display time domain statistical information about the audio channels.
1639 Statistics are calculated and displayed for each audio channel and,
1640 where applicable, an overall figure is also given.
1641
1642 It accepts the following option:
1643 @table @option
1644 @item length
1645 Short window length in seconds, used for peak and trough RMS measurement.
1646 Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.1 - 10]}.
1647
1648 @item metadata
1649
1650 Set metadata injection. All the metadata keys are prefixed with @code{lavfi.astats.X},
1651 where @code{X} is channel number starting from 1 or string @code{Overall}. Default is
1652 disabled.
1653
1654 Available keys for each channel are:
1655 DC_offset
1656 Min_level
1657 Max_level
1658 Min_difference
1659 Max_difference
1660 Mean_difference
1661 RMS_difference
1662 Peak_level
1663 RMS_peak
1664 RMS_trough
1665 Crest_factor
1666 Flat_factor
1667 Peak_count
1668 Bit_depth
1669 Dynamic_range
1670
1671 and for Overall:
1672 DC_offset
1673 Min_level
1674 Max_level
1675 Min_difference
1676 Max_difference
1677 Mean_difference
1678 RMS_difference
1679 Peak_level
1680 RMS_level
1681 RMS_peak
1682 RMS_trough
1683 Flat_factor
1684 Peak_count
1685 Bit_depth
1686 Number_of_samples
1687
1688 For example full key look like this @code{lavfi.astats.1.DC_offset} or
1689 this @code{lavfi.astats.Overall.Peak_count}.
1690
1691 For description what each key means read below.
1692
1693 @item reset
1694 Set number of frame after which stats are going to be recalculated.
1695 Default is disabled.
1696 @end table
1697
1698 A description of each shown parameter follows:
1699
1700 @table @option
1701 @item DC offset
1702 Mean amplitude displacement from zero.
1703
1704 @item Min level
1705 Minimal sample level.
1706
1707 @item Max level
1708 Maximal sample level.
1709
1710 @item Min difference
1711 Minimal difference between two consecutive samples.
1712
1713 @item Max difference
1714 Maximal difference between two consecutive samples.
1715
1716 @item Mean difference
1717 Mean difference between two consecutive samples.
1718 The average of each difference between two consecutive samples.
1719
1720 @item RMS difference
1721 Root Mean Square difference between two consecutive samples.
1722
1723 @item Peak level dB
1724 @item RMS level dB
1725 Standard peak and RMS level measured in dBFS.
1726
1727 @item RMS peak dB
1728 @item RMS trough dB
1729 Peak and trough values for RMS level measured over a short window.
1730
1731 @item Crest factor
1732 Standard ratio of peak to RMS level (note: not in dB).
1733
1734 @item Flat factor
1735 Flatness (i.e. consecutive samples with the same value) of the signal at its peak levels
1736 (i.e. either @var{Min level} or @var{Max level}).
1737
1738 @item Peak count
1739 Number of occasions (not the number of samples) that the signal attained either
1740 @var{Min level} or @var{Max level}.
1741
1742 @item Bit depth
1743 Overall bit depth of audio. Number of bits used for each sample.
1744
1745 @item Dynamic range
1746 Measured dynamic range of audio in dB.
1747 @end table
1748
1749 @section atempo
1750
1751 Adjust audio tempo.
1752
1753 The filter accepts exactly one parameter, the audio tempo. If not
1754 specified then the filter will assume nominal 1.0 tempo. Tempo must
1755 be in the [0.5, 2.0] range.
1756
1757 @subsection Examples
1758
1759 @itemize
1760 @item
1761 Slow down audio to 80% tempo:
1762 @example
1763 atempo=0.8
1764 @end example
1765
1766 @item
1767 To speed up audio to 125% tempo:
1768 @example
1769 atempo=1.25
1770 @end example
1771 @end itemize
1772
1773 @section atrim
1774
1775 Trim the input so that the output contains one continuous subpart of the input.
1776
1777 It accepts the following parameters:
1778 @table @option
1779 @item start
1780 Timestamp (in seconds) of the start of the section to keep. I.e. the audio
1781 sample with the timestamp @var{start} will be the first sample in the output.
1782
1783 @item end
1784 Specify time of the first audio sample that will be dropped, i.e. the
1785 audio sample immediately preceding the one with the timestamp @var{end} will be
1786 the last sample in the output.
1787
1788 @item start_pts
1789 Same as @var{start}, except this option sets the start timestamp in samples
1790 instead of seconds.
1791
1792 @item end_pts
1793 Same as @var{end}, except this option sets the end timestamp in samples instead
1794 of seconds.
1795
1796 @item duration
1797 The maximum duration of the output in seconds.
1798
1799 @item start_sample
1800 The number of the first sample that should be output.
1801
1802 @item end_sample
1803 The number of the first sample that should be dropped.
1804 @end table
1805
1806 @option{start}, @option{end}, and @option{duration} are expressed as time
1807 duration specifications; see
1808 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
1809
1810 Note that the first two sets of the start/end options and the @option{duration}
1811 option look at the frame timestamp, while the _sample options simply count the
1812 samples that pass through the filter. So start/end_pts and start/end_sample will
1813 give different results when the timestamps are wrong, inexact or do not start at
1814 zero. Also note that this filter does not modify the timestamps. If you wish
1815 to have the output timestamps start at zero, insert the asetpts filter after the
1816 atrim filter.
1817
1818 If multiple start or end options are set, this filter tries to be greedy and
1819 keep all samples that match at least one of the specified constraints. To keep
1820 only the part that matches all the constraints at once, chain multiple atrim
1821 filters.
1822
1823 The defaults are such that all the input is kept. So it is possible to set e.g.
1824 just the end values to keep everything before the specified time.
1825
1826 Examples:
1827 @itemize
1828 @item
1829 Drop everything except the second minute of input:
1830 @example
1831 ffmpeg -i INPUT -af atrim=60:120
1832 @end example
1833
1834 @item
1835 Keep only the first 1000 samples:
1836 @example
1837 ffmpeg -i INPUT -af atrim=end_sample=1000
1838 @end example
1839
1840 @end itemize
1841
1842 @section bandpass
1843
1844 Apply a two-pole Butterworth band-pass filter with central
1845 frequency @var{frequency}, and (3dB-point) band-width width.
1846 The @var{csg} option selects a constant skirt gain (peak gain = Q)
1847 instead of the default: constant 0dB peak gain.
1848 The filter roll off at 6dB per octave (20dB per decade).
1849
1850 The filter accepts the following options:
1851
1852 @table @option
1853 @item frequency, f
1854 Set the filter's central frequency. Default is @code{3000}.
1855
1856 @item csg
1857 Constant skirt gain if set to 1. Defaults to 0.
1858
1859 @item width_type, t
1860 Set method to specify band-width of filter.
1861 @table @option
1862 @item h
1863 Hz
1864 @item q
1865 Q-Factor
1866 @item o
1867 octave
1868 @item s
1869 slope
1870 @end table
1871
1872 @item width, w
1873 Specify the band-width of a filter in width_type units.
1874
1875 @item channels, c
1876 Specify which channels to filter, by default all available are filtered.
1877 @end table
1878
1879 @section bandreject
1880
1881 Apply a two-pole Butterworth band-reject filter with central
1882 frequency @var{frequency}, and (3dB-point) band-width @var{width}.
1883 The filter roll off at 6dB per octave (20dB per decade).
1884
1885 The filter accepts the following options:
1886
1887 @table @option
1888 @item frequency, f
1889 Set the filter's central frequency. Default is @code{3000}.
1890
1891 @item width_type, t
1892 Set method to specify band-width of filter.
1893 @table @option
1894 @item h
1895 Hz
1896 @item q
1897 Q-Factor
1898 @item o
1899 octave
1900 @item s
1901 slope
1902 @end table
1903
1904 @item width, w
1905 Specify the band-width of a filter in width_type units.
1906
1907 @item channels, c
1908 Specify which channels to filter, by default all available are filtered.
1909 @end table
1910
1911 @section bass
1912
1913 Boost or cut the bass (lower) frequencies of the audio using a two-pole
1914 shelving filter with a response similar to that of a standard
1915 hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
1916
1917 The filter accepts the following options:
1918
1919 @table @option
1920 @item gain, g
1921 Give the gain at 0 Hz. Its useful range is about -20
1922 (for a large cut) to +20 (for a large boost).
1923 Beware of clipping when using a positive gain.
1924
1925 @item frequency, f
1926 Set the filter's central frequency and so can be used
1927 to extend or reduce the frequency range to be boosted or cut.
1928 The default value is @code{100} Hz.
1929
1930 @item width_type, t
1931 Set method to specify band-width of filter.
1932 @table @option
1933 @item h
1934 Hz
1935 @item q
1936 Q-Factor
1937 @item o
1938 octave
1939 @item s
1940 slope
1941 @end table
1942
1943 @item width, w
1944 Determine how steep is the filter's shelf transition.
1945
1946 @item channels, c
1947 Specify which channels to filter, by default all available are filtered.
1948 @end table
1949
1950 @section biquad
1951
1952 Apply a biquad IIR filter with the given coefficients.
1953 Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
1954 are the numerator and denominator coefficients respectively.
1955 and @var{channels}, @var{c} specify which channels to filter, by default all
1956 available are filtered.
1957
1958 @section bs2b
1959 Bauer stereo to binaural transformation, which improves headphone listening of
1960 stereo audio records.
1961
1962 To enable compilation of this filter you need to configure FFmpeg with
1963 @code{--enable-libbs2b}.
1964
1965 It accepts the following parameters:
1966 @table @option
1967
1968 @item profile
1969 Pre-defined crossfeed level.
1970 @table @option
1971
1972 @item default
1973 Default level (fcut=700, feed=50).
1974
1975 @item cmoy
1976 Chu Moy circuit (fcut=700, feed=60).
1977
1978 @item jmeier
1979 Jan Meier circuit (fcut=650, feed=95).
1980
1981 @end table
1982
1983 @item fcut
1984 Cut frequency (in Hz).
1985
1986 @item feed
1987 Feed level (in Hz).
1988
1989 @end table
1990
1991 @section channelmap
1992
1993 Remap input channels to new locations.
1994
1995 It accepts the following parameters:
1996 @table @option
1997 @item map
1998 Map channels from input to output. The argument is a '|'-separated list of
1999 mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
2000 @var{in_channel} form. @var{in_channel} can be either the name of the input
2001 channel (e.g. FL for front left) or its index in the input channel layout.
2002 @var{out_channel} is the name of the output channel or its index in the output
2003 channel layout. If @var{out_channel} is not given then it is implicitly an
2004 index, starting with zero and increasing by one for each mapping.
2005
2006 @item channel_layout
2007 The channel layout of the output stream.
2008 @end table
2009
2010 If no mapping is present, the filter will implicitly map input channels to
2011 output channels, preserving indices.
2012
2013 For example, assuming a 5.1+downmix input MOV file,
2014 @example
2015 ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
2016 @end example
2017 will create an output WAV file tagged as stereo from the downmix channels of
2018 the input.
2019
2020 To fix a 5.1 WAV improperly encoded in AAC's native channel order
2021 @example
2022 ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:5.1' out.wav
2023 @end example
2024
2025 @section channelsplit
2026
2027 Split each channel from an input audio stream into a separate output stream.
2028
2029 It accepts the following parameters:
2030 @table @option
2031 @item channel_layout
2032 The channel layout of the input stream. The default is "stereo".
2033 @end table
2034
2035 For example, assuming a stereo input MP3 file,
2036 @example
2037 ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
2038 @end example
2039 will create an output Matroska file with two audio streams, one containing only
2040 the left channel and the other the right channel.
2041
2042 Split a 5.1 WAV file into per-channel files:
2043 @example
2044 ffmpeg -i in.wav -filter_complex
2045 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
2046 -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
2047 front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
2048 side_right.wav
2049 @end example
2050
2051 @section chorus
2052 Add a chorus effect to the audio.
2053
2054 Can make a single vocal sound like a chorus, but can also be applied to instrumentation.
2055
2056 Chorus resembles an echo effect with a short delay, but whereas with echo the delay is
2057 constant, with chorus, it is varied using using sinusoidal or triangular modulation.
2058 The modulation depth defines the range the modulated delay is played before or after
2059 the delay. Hence the delayed sound will sound slower or faster, that is the delayed
2060 sound tuned around the original one, like in a chorus where some vocals are slightly
2061 off key.
2062
2063 It accepts the following parameters:
2064 @table @option
2065 @item in_gain
2066 Set input gain. Default is 0.4.
2067
2068 @item out_gain
2069 Set output gain. Default is 0.4.
2070
2071 @item delays
2072 Set delays. A typical delay is around 40ms to 60ms.
2073
2074 @item decays
2075 Set decays.
2076
2077 @item speeds
2078 Set speeds.
2079
2080 @item depths
2081 Set depths.
2082 @end table
2083
2084 @subsection Examples
2085
2086 @itemize
2087 @item
2088 A single delay:
2089 @example
2090 chorus=0.7:0.9:55:0.4:0.25:2
2091 @end example
2092
2093 @item
2094 Two delays:
2095 @example
2096 chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3
2097 @end example
2098
2099 @item
2100 Fuller sounding chorus with three delays:
2101 @example
2102 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
2103 @end example
2104 @end itemize
2105
2106 @section compand
2107 Compress or expand the audio's dynamic range.
2108
2109 It accepts the following parameters:
2110
2111 @table @option
2112
2113 @item attacks
2114 @item decays
2115 A list of times in seconds for each channel over which the instantaneous level
2116 of the input signal is averaged to determine its volume. @var{attacks} refers to
2117 increase of volume and @var{decays} refers to decrease of volume. For most
2118 situations, the attack time (response to the audio getting louder) should be
2119 shorter than the decay time, because the human ear is more sensitive to sudden
2120 loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
2121 a typical value for decay is 0.8 seconds.
2122 If specified number of attacks & decays is lower than number of channels, the last
2123 set attack/decay will be used for all remaining channels.
2124
2125 @item points
2126 A list of points for the transfer function, specified in dB relative to the
2127 maximum possible signal amplitude. Each key points list must be defined using
2128 the following syntax: @code{x0/y0|x1/y1|x2/y2|....} or
2129 @code{x0/y0 x1/y1 x2/y2 ....}
2130
2131 The input values must be in strictly increasing order but the transfer function
2132 does not have to be monotonically rising. The point @code{0/0} is assumed but
2133 may be overridden (by @code{0/out-dBn}). Typical values for the transfer
2134 function are @code{-70/-70|-60/-20|1/0}.
2135
2136 @item soft-knee
2137 Set the curve radius in dB for all joints. It defaults to 0.01.
2138
2139 @item gain
2140 Set the additional gain in dB to be applied at all points on the transfer
2141 function. This allows for easy adjustment of the overall gain.
2142 It defaults to 0.
2143
2144 @item volume
2145 Set an initial volume, in dB, to be assumed for each channel when filtering
2146 starts. This permits the user to supply a nominal level initially, so that, for
2147 example, a very large gain is not applied to initial signal levels before the
2148 companding has begun to operate. A typical value for audio which is initially
2149 quiet is -90 dB. It defaults to 0.
2150
2151 @item delay
2152 Set a delay, in seconds. The input audio is analyzed immediately, but audio is
2153 delayed before being fed to the volume adjuster. Specifying a delay
2154 approximately equal to the attack/decay times allows the filter to effectively
2155 operate in predictive rather than reactive mode. It defaults to 0.
2156
2157 @end table
2158
2159 @subsection Examples
2160
2161 @itemize
2162 @item
2163 Make music with both quiet and loud passages suitable for listening to in a
2164 noisy environment:
2165 @example
2166 compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
2167 @end example
2168
2169 Another example for audio with whisper and explosion parts:
2170 @example
2171 compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0
2172 @end example
2173
2174 @item
2175 A noise gate for when the noise is at a lower level than the signal:
2176 @example
2177 compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
2178 @end example
2179
2180 @item
2181 Here is another noise gate, this time for when the noise is at a higher level
2182 than the signal (making it, in some ways, similar to squelch):
2183 @example
2184 compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
2185 @end example
2186
2187 @item
2188 2:1 compression starting at -6dB:
2189 @example
2190 compand=points=-80/-80|-6/-6|0/-3.8|20/3.5
2191 @end example
2192
2193 @item
2194 2:1 compression starting at -9dB:
2195 @example
2196 compand=points=-80/-80|-9/-9|0/-5.3|20/2.9
2197 @end example
2198
2199 @item
2200 2:1 compression starting at -12dB:
2201 @example
2202 compand=points=-80/-80|-12/-12|0/-6.8|20/1.9
2203 @end example
2204
2205 @item
2206 2:1 compression starting at -18dB:
2207 @example
2208 compand=points=-80/-80|-18/-18|0/-9.8|20/0.7
2209 @end example
2210
2211 @item
2212 3:1 compression starting at -15dB:
2213 @example
2214 compand=points=-80/-80|-15/-15|0/-10.8|20/-5.2
2215 @end example
2216
2217 @item
2218 Compressor/Gate:
2219 @example
2220 compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6
2221 @end example
2222
2223 @item
2224 Expander:
2225 @example
2226 compand=attacks=0:points=-80/-169|-54/-80|-49.5/-64.6|-41.1/-41.1|-25.8/-15|-10.8/-4.5|0/0|20/8.3
2227 @end example
2228
2229 @item
2230 Hard limiter at -6dB:
2231 @example
2232 compand=attacks=0:points=-80/-80|-6/-6|20/-6
2233 @end example
2234
2235 @item
2236 Hard limiter at -12dB:
2237 @example
2238 compand=attacks=0:points=-80/-80|-12/-12|20/-12
2239 @end example
2240
2241 @item
2242 Hard noise gate at -35 dB:
2243 @example
2244 compand=attacks=0:points=-80/-115|-35.1/-80|-35/-35|20/20
2245 @end example
2246
2247 @item
2248 Soft limiter:
2249 @example
2250 compand=attacks=0:points=-80/-80|-12.4/-12.4|-6/-8|0/-6.8|20/-2.8
2251 @end example
2252 @end itemize
2253
2254 @section compensationdelay
2255
2256 Compensation Delay Line is a metric based delay to compensate differing
2257 positions of microphones or speakers.
2258
2259 For example, you have recorded guitar with two microphones placed in
2260 different location. Because the front of sound wave has fixed speed in
2261 normal conditions, the phasing of microphones can vary and depends on
2262 their location and interposition. The best sound mix can be achieved when
2263 these microphones are in phase (synchronized). Note that distance of
2264 ~30 cm between microphones makes one microphone to capture signal in
2265 antiphase to another microphone. That makes the final mix sounding moody.
2266 This filter helps to solve phasing problems by adding different delays
2267 to each microphone track and make them synchronized.
2268
2269 The best result can be reached when you take one track as base and
2270 synchronize other tracks one by one with it.
2271 Remember that synchronization/delay tolerance depends on sample rate, too.
2272 Higher sample rates will give more tolerance.
2273
2274 It accepts the following parameters:
2275
2276 @table @option
2277 @item mm
2278 Set millimeters distance. This is compensation distance for fine tuning.
2279 Default is 0.
2280
2281 @item cm
2282 Set cm distance. This is compensation distance for tightening distance setup.
2283 Default is 0.
2284
2285 @item m
2286 Set meters distance. This is compensation distance for hard distance setup.
2287 Default is 0.
2288
2289 @item dry
2290 Set dry amount. Amount of unprocessed (dry) signal.
2291 Default is 0.
2292
2293 @item wet
2294 Set wet amount. Amount of processed (wet) signal.
2295 Default is 1.
2296
2297 @item temp
2298 Set temperature degree in Celsius. This is the temperature of the environment.
2299 Default is 20.
2300 @end table
2301
2302 @section crossfeed
2303 Apply headphone crossfeed filter.
2304
2305 Crossfeed is the process of blending the left and right channels of stereo
2306 audio recording.
2307 It is mainly used to reduce extreme stereo separation of low frequencies.
2308
2309 The intent is to produce more speaker like sound to the listener.
2310
2311 The filter accepts the following options:
2312
2313 @table @option
2314 @item strength
2315 Set strength of crossfeed. Default is 0.2. Allowed range is from 0 to 1.
2316 This sets gain of low shelf filter for side part of stereo image.
2317 Default is -6dB. Max allowed is -30db when strength is set to 1.
2318
2319 @item range
2320 Set soundstage wideness. Default is 0.5. Allowed range is from 0 to 1.
2321 This sets cut off frequency of low shelf filter. Default is cut off near
2322 1550 Hz. With range set to 1 cut off frequency is set to 2100 Hz.
2323
2324 @item level_in
2325 Set input gain. Default is 0.9.
2326
2327 @item level_out
2328 Set output gain. Default is 1.
2329 @end table
2330
2331 @section crystalizer
2332 Simple algorithm to expand audio dynamic range.
2333
2334 The filter accepts the following options:
2335
2336 @table @option
2337 @item i
2338 Sets the intensity of effect (default: 2.0). Must be in range between 0.0
2339 (unchanged sound) to 10.0 (maximum effect).
2340
2341 @item c
2342 Enable clipping. By default is enabled.
2343 @end table
2344
2345 @section dcshift
2346 Apply a DC shift to the audio.
2347
2348 This can be useful to remove a DC offset (caused perhaps by a hardware problem
2349 in the recording chain) from the audio. The effect of a DC offset is reduced
2350 headroom and hence volume. The @ref{astats} filter can be used to determine if
2351 a signal has a DC offset.
2352
2353 @table @option
2354 @item shift
2355 Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift
2356 the audio.
2357
2358 @item limitergain
2359 Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
2360 used to prevent clipping.
2361 @end table
2362
2363 @section dynaudnorm
2364 Dynamic Audio Normalizer.
2365
2366 This filter applies a certain amount of gain to the input audio in order
2367 to bring its peak magnitude to a target level (e.g. 0 dBFS). However, in
2368 contrast to more "simple" normalization algorithms, the Dynamic Audio
2369 Normalizer *dynamically* re-adjusts the gain factor to the input audio.
2370 This allows for applying extra gain to the "quiet" sections of the audio
2371 while avoiding distortions or clipping the "loud" sections. In other words:
2372 The Dynamic Audio Normalizer will "even out" the volume of quiet and loud
2373 sections, in the sense that the volume of each section is brought to the
2374 same target level. Note, however, that the Dynamic Audio Normalizer achieves
2375 this goal *without* applying "dynamic range compressing". It will retain 100%
2376 of the dynamic range *within* each section of the audio file.
2377
2378 @table @option
2379 @item f
2380 Set the frame length in milliseconds. In range from 10 to 8000 milliseconds.
2381 Default is 500 milliseconds.
2382 The Dynamic Audio Normalizer processes the input audio in small chunks,
2383 referred to as frames. This is required, because a peak magnitude has no
2384 meaning for just a single sample value. Instead, we need to determine the
2385 peak magnitude for a contiguous sequence of sample values. While a "standard"
2386 normalizer would simply use the peak magnitude of the complete file, the
2387 Dynamic Audio Normalizer determines the peak magnitude individually for each
2388 frame. The length of a frame is specified in milliseconds. By default, the
2389 Dynamic Audio Normalizer uses a frame length of 500 milliseconds, which has
2390 been found to give good results with most files.
2391 Note that the exact frame length, in number of samples, will be determined
2392 automatically, based on the sampling rate of the individual input audio file.
2393
2394 @item g
2395 Set the Gaussian filter window size. In range from 3 to 301, must be odd
2396 number. Default is 31.
2397 Probably the most important parameter of the Dynamic Audio Normalizer is the
2398 @code{window size} of the Gaussian smoothing filter. The filter's window size
2399 is specified in frames, centered around the current frame. For the sake of
2400 simplicity, this must be an odd number. Consequently, the default value of 31
2401 takes into account the current frame, as well as the 15 preceding frames and
2402 the 15 subsequent frames. Using a larger window results in a stronger
2403 smoothing effect and thus in less gain variation, i.e. slower gain
2404 adaptation. Conversely, using a smaller window results in a weaker smoothing
2405 effect and thus in more gain variation, i.e. faster gain adaptation.
2406 In other words, the more you increase this value, the more the Dynamic Audio
2407 Normalizer will behave like a "traditional" normalization filter. On the
2408 contrary, the more you decrease this value, the more the Dynamic Audio
2409 Normalizer will behave like a dynamic range compressor.
2410
2411 @item p
2412 Set the target peak value. This specifies the highest permissible magnitude
2413 level for the normalized audio input. This filter will try to approach the
2414 target peak magnitude as closely as possible, but at the same time it also
2415 makes sure that the normalized signal will never exceed the peak magnitude.
2416 A frame's maximum local gain factor is imposed directly by the target peak
2417 magnitude. The default value is 0.95 and thus leaves a headroom of 5%*.
2418 It is not recommended to go above this value.
2419
2420 @item m
2421 Set the maximum gain factor. In range from 1.0 to 100.0. Default is 10.0.
2422 The Dynamic Audio Normalizer determines the maximum possible (local) gain
2423 factor for each input frame, i.e. the maximum gain factor that does not
2424 result in clipping or distortion. The maximum gain factor is determined by
2425 the frame's highest magnitude sample. However, the Dynamic Audio Normalizer
2426 additionally bounds the frame's maximum gain factor by a predetermined
2427 (global) maximum gain factor. This is done in order to avoid excessive gain
2428 factors in "silent" or almost silent frames. By default, the maximum gain
2429 factor is 10.0, For most inputs the default value should be sufficient and
2430 it usually is not recommended to increase this value. Though, for input
2431 with an extremely low overall volume level, it may be necessary to allow even
2432 higher gain factors. Note, however, that the Dynamic Audio Normalizer does
2433 not simply apply a "hard" threshold (i.e. cut off values above the threshold).
2434 Instead, a "sigmoid" threshold function will be applied. This way, the
2435 gain factors will smoothly approach the threshold value, but never exceed that
2436 value.
2437
2438 @item r
2439 Set the target RMS. In range from 0.0 to 1.0. Default is 0.0 - disabled.
2440 By default, the Dynamic Audio Normalizer performs "peak" normalization.
2441 This means that the maximum local gain factor for each frame is defined
2442 (only) by the frame's highest magnitude sample. This way, the samples can
2443 be amplified as much as possible without exceeding the maximum signal
2444 level, i.e. without clipping. Optionally, however, the Dynamic Audio
2445 Normalizer can also take into account the frame's root mean square,
2446 abbreviated RMS. In electrical engineering, the RMS is commonly used to
2447 determine the power of a time-varying signal. It is therefore considered
2448 that the RMS is a better approximation of the "perceived loudness" than
2449 just looking at the signal's peak magnitude. Consequently, by adjusting all
2450 frames to a constant RMS value, a uniform "perceived loudness" can be
2451 established. If a target RMS value has been specified, a frame's local gain
2452 factor is defined as the factor that would result in exactly that RMS value.
2453 Note, however, that the maximum local gain factor is still restricted by the
2454 frame's highest magnitude sample, in order to prevent clipping.
2455
2456 @item n
2457 Enable channels coupling. By default is enabled.
2458 By default, the Dynamic Audio Normalizer will amplify all channels by the same
2459 amount. This means the same gain factor will be applied to all channels, i.e.
2460 the maximum possible gain factor is determined by the "loudest" channel.
2461 However, in some recordings, it may happen that the volume of the different
2462 channels is uneven, e.g. one channel may be "quieter" than the other one(s).
2463 In this case, this option can be used to disable the channel coupling. This way,
2464 the gain factor will be determined independently for each channel, depending
2465 only on the individual channel's highest magnitude sample. This allows for
2466 harmonizing the volume of the different channels.
2467
2468 @item c
2469 Enable DC bias correction. By default is disabled.
2470 An audio signal (in the time domain) is a sequence of sample values.
2471 In the Dynamic Audio Normalizer these sample values are represented in the
2472 -1.0 to 1.0 range, regardless of the original input format. Normally, the
2473 audio signal, or "waveform", should be centered around the zero point.
2474 That means if we calculate the mean value of all samples in a file, or in a
2475 single frame, then the result should be 0.0 or at least very close to that
2476 value. If, however, there is a significant deviation of the mean value from
2477 0.0, in either positive or negative direction, this is referred to as a
2478 DC bias or DC offset. Since a DC bias is clearly undesirable, the Dynamic
2479 Audio Normalizer provides optional DC bias correction.
2480 With DC bias correction enabled, the Dynamic Audio Normalizer will determine
2481 the mean value, or "DC correction" offset, of each input frame and subtract
2482 that value from all of the frame's sample values which ensures those samples
2483 are centered around 0.0 again. Also, in order to avoid "gaps" at the frame
2484 boundaries, the DC correction offset values will be interpolated smoothly
2485 between neighbouring frames.
2486
2487 @item b
2488 Enable alternative boundary mode. By default is disabled.
2489 The Dynamic Audio Normalizer takes into account a certain neighbourhood
2490 around each frame. This includes the preceding frames as well as the
2491 subsequent frames. However, for the "boundary" frames, located at the very
2492 beginning and at the very end of the audio file, not all neighbouring
2493 frames are available. In particular, for the first few frames in the audio
2494 file, the preceding frames are not known. And, similarly, for the last few
2495 frames in the audio file, the subsequent frames are not known. Thus, the
2496 question arises which gain factors should be assumed for the missing frames
2497 in the "boundary" region. The Dynamic Audio Normalizer implements two modes
2498 to deal with this situation. The default boundary mode assumes a gain factor
2499 of exactly 1.0 for the missing frames, resulting in a smooth "fade in" and
2500 "fade out" at the beginning and at the end of the input, respectively.
2501
2502 @item s
2503 Set the compress factor. In range from 0.0 to 30.0. Default is 0.0.
2504 By default, the Dynamic Audio Normalizer does not apply "traditional"
2505 compression. This means that signal peaks will not be pruned and thus the
2506 full dynamic range will be retained within each local neighbourhood. However,
2507 in some cases it may be desirable to combine the Dynamic Audio Normalizer's
2508 normalization algorithm with a more "traditional" compression.
2509 For this purpose, the Dynamic Audio Normalizer provides an optional compression
2510 (thresholding) function. If (and only if) the compression feature is enabled,
2511 all input frames will be processed by a soft knee thresholding function prior
2512 to the actual normalization process. Put simply, the thresholding function is
2513 going to prune all samples whose magnitude exceeds a certain threshold value.
2514 However, the Dynamic Audio Normalizer does not simply apply a fixed threshold
2515 value. Instead, the threshold value will be adjusted for each individual
2516 frame.
2517 In general, smaller parameters result in stronger compression, and vice versa.
2518 Values below 3.0 are not recommended, because audible distortion may appear.
2519 @end table
2520
2521 @section earwax
2522
2523 Make audio easier to listen to on headphones.
2524
2525 This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
2526 so that when listened to on headphones the stereo image is moved from
2527 inside your head (standard for headphones) to outside and in front of
2528 the listener (standard for speakers).
2529
2530 Ported from SoX.
2531
2532 @section equalizer
2533
2534 Apply a two-pole peaking equalisation (EQ) filter. With this
2535 filter, the signal-level at and around a selected frequency can
2536 be increased or decreased, whilst (unlike bandpass and bandreject
2537 filters) that at all other frequencies is unchanged.
2538
2539 In order to produce complex equalisation curves, this filter can
2540 be given several times, each with a different central frequency.
2541
2542 The filter accepts the following options:
2543
2544 @table @option
2545 @item frequency, f
2546 Set the filter's central frequency in Hz.
2547
2548 @item width_type, t
2549 Set method to specify band-width of filter.
2550 @table @option
2551 @item h
2552 Hz
2553 @item q
2554 Q-Factor
2555 @item o
2556 octave
2557 @item s
2558 slope
2559 @end table
2560
2561 @item width, w
2562 Specify the band-width of a filter in width_type units.
2563
2564 @item gain, g
2565 Set the required gain or attenuation in dB.
2566 Beware of clipping when using a positive gain.
2567
2568 @item channels, c
2569 Specify which channels to filter, by default all available are filtered.
2570 @end table
2571
2572 @subsection Examples
2573 @itemize
2574 @item
2575 Attenuate 10 dB at 1000 Hz, with a bandwidth of 200 Hz:
2576 @example
2577 equalizer=f=1000:t=h:width=200:g=-10
2578 @end example
2579
2580 @item
2581 Apply 2 dB gain at 1000 Hz with Q 1 and attenuate 5 dB at 100 Hz with Q 2:
2582 @example
2583 equalizer=f=1000:t=q:w=1:g=2,equalizer=f=100:t=q:w=2:g=-5
2584 @end example
2585 @end itemize
2586
2587 @section extrastereo
2588
2589 Linearly increases the difference between left and right channels which
2590 adds some sort of "live" effect to playback.
2591
2592 The filter accepts the following options:
2593
2594 @table @option
2595 @item m
2596 Sets the difference coefficient (default: 2.5). 0.0 means mono sound
2597 (average of both channels), with 1.0 sound will be unchanged, with
2598 -1.0 left and right channels will be swapped.
2599
2600 @item c
2601 Enable clipping. By default is enabled.
2602 @end table
2603
2604 @section firequalizer
2605 Apply FIR Equalization using arbitrary frequency response.
2606
2607 The filter accepts the following option:
2608
2609 @table @option
2610 @item gain
2611 Set gain curve equation (in dB). The expression can contain variables:
2612 @table @option
2613 @item f
2614 the evaluated frequency
2615 @item sr
2616 sample rate
2617 @item ch
2618 channel number, set to 0 when multichannels evaluation is disabled
2619 @item chid
2620 channel id, see libavutil/channel_layout.h, set to the first channel id when
2621 multichannels evaluation is disabled
2622 @item chs
2623 number of channels
2624 @item chlayout
2625 channel_layout, see libavutil/channel_layout.h
2626
2627 @end table
2628 and functions:
2629 @table @option
2630 @item gain_interpolate(f)
2631 interpolate gain on frequency f based on gain_entry
2632 @item cubic_interpolate(f)
2633 same as gain_interpolate, but smoother
2634 @end table
2635 This option is also available as command. Default is @code{gain_interpolate(f)}.
2636
2637 @item gain_entry
2638 Set gain entry for gain_interpolate function. The expression can
2639 contain functions:
2640 @table @option
2641 @item entry(f, g)
2642 store gain entry at frequency f with value g
2643 @end table
2644 This option is also available as command.
2645
2646 @item delay
2647 Set filter delay in seconds. Higher value means more accurate.
2648 Default is @code{0.01}.
2649
2650 @item accuracy
2651 Set filter accuracy in Hz. Lower value means more accurate.
2652 Default is @code{5}.
2653
2654 @item wfunc
2655 Set window function. Acceptable values are:
2656 @table @option
2657 @item rectangular
2658 rectangular window, useful when gain curve is already smooth
2659 @item hann
2660 hann window (default)
2661 @item hamming
2662 hamming window
2663 @item blackman
2664 blackman window
2665 @item nuttall3
2666 3-terms continuous 1st derivative nuttall window
2667 @item mnuttall3
2668 minimum 3-terms discontinuous nuttall window
2669 @item nuttall
2670 4-terms continuous 1st derivative nuttall window
2671 @item bnuttall
2672 minimum 4-terms discontinuous nuttall (blackman-nuttall) window
2673 @item bharris
2674 blackman-harris window
2675 @item tukey
2676 tukey window
2677 @end table
2678
2679 @item fixed
2680 If enabled, use fixed number of audio samples. This improves speed when
2681 filtering with large delay. Default is disabled.
2682
2683 @item multi
2684 Enable multichannels evaluation on gain. Default is disabled.
2685
2686 @item zero_phase
2687 Enable zero phase mode by subtracting timestamp to compensate delay.
2688 Default is disabled.
2689
2690 @item scale
2691 Set scale used by gain. Acceptable values are:
2692 @table @option
2693 @item linlin
2694 linear frequency, linear gain
2695 @item linlog
2696 linear frequency, logarithmic (in dB) gain (default)
2697 @item loglin
2698 logarithmic (in octave scale where 20 Hz is 0) frequency, linear gain
2699 @item loglog
2700 logarithmic frequency, logarithmic gain
2701 @end table
2702
2703 @item dumpfile
2704 Set file for dumping, suitable for gnuplot.
2705
2706 @item dumpscale
2707 Set scale for dumpfile. Acceptable values are same with scale option.
2708 Default is linlog.
2709
2710 @item fft2
2711 Enable 2-channel convolution using complex FFT. This improves speed significantly.
2712 Default is disabled.
2713
2714 @item min_phase
2715 Enable minimum phase impulse response. Default is disabled.
2716 @end table
2717
2718 @subsection Examples
2719 @itemize
2720 @item
2721 lowpass at 1000 Hz:
2722 @example
2723 firequalizer=gain='if(lt(f,1000), 0, -INF)'
2724 @end example
2725 @item
2726 lowpass at 1000 Hz with gain_entry:
2727 @example
2728 firequalizer=gain_entry='entry(1000,0); entry(1001, -INF)'
2729 @end example
2730 @item
2731 custom equalization:
2732 @example
2733 firequalizer=gain_entry='entry(100,0); entry(400, -4); entry(1000, -6); entry(2000, 0)'
2734 @end example
2735 @item
2736 higher delay with zero phase to compensate delay:
2737 @example
2738 firequalizer=delay=0.1:fixed=on:zero_phase=on
2739 @end example
2740 @item
2741 lowpass on left channel, highpass on right channel:
2742 @example
2743 firequalizer=gain='if(eq(chid,1), gain_interpolate(f), if(eq(chid,2), gain_interpolate(1e6+f), 0))'
2744 :gain_entry='entry(1000, 0); entry(1001,-INF); entry(1e6+1000,0)':multi=on
2745 @end example
2746 @end itemize
2747
2748 @section flanger
2749 Apply a flanging effect to the audio.
2750
2751 The filter accepts the following options:
2752
2753 @table @option
2754 @item delay
2755 Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
2756
2757 @item depth
2758 Set added sweep delay in milliseconds. Range from 0 to 10. Default value is 2.
2759
2760 @item regen
2761 Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
2762 Default value is 0.
2763
2764 @item width
2765 Set percentage of delayed signal mixed with original. Range from 0 to 100.
2766 Default value is 71.
2767
2768 @item speed
2769 Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
2770
2771 @item shape
2772 Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
2773 Default value is @var{sinusoidal}.
2774
2775 @item phase
2776 Set swept wave percentage-shift for multi channel. Range from 0 to 100.
2777 Default value is 25.
2778
2779 @item interp
2780 Set delay-line interpolation, @var{linear} or @var{quadratic}.
2781 Default is @var{linear}.
2782 @end table
2783
2784 @section haas
2785 Apply Haas effect to audio.
2786
2787 Note that this makes most sense to apply on mono signals.
2788 With this filter applied to mono signals it give some directionality and
2789 stretches its stereo image.
2790
2791 The filter accepts the following options:
2792
2793 @table @option
2794 @item level_in
2795 Set input level. By default is @var{1}, or 0dB
2796
2797 @item level_out
2798 Set output level. By default is @var{1}, or 0dB.
2799
2800 @item side_gain
2801 Set gain applied to side part of signal. By default is @var{1}.
2802
2803 @item middle_source
2804 Set kind of middle source. Can be one of the following:
2805
2806 @table @samp
2807 @item left
2808 Pick left channel.
2809
2810 @item right
2811 Pick right channel.
2812
2813 @item mid
2814 Pick middle part signal of stereo image.
2815
2816 @item side
2817 Pick side part signal of stereo image.
2818 @end table
2819
2820 @item middle_phase
2821 Change middle phase. By default is disabled.
2822
2823 @item left_delay
2824 Set left channel delay. By default is @var{2.05} milliseconds.
2825
2826 @item left_balance
2827 Set left channel balance. By default is @var{-1}.
2828
2829 @item left_gain
2830 Set left channel gain. By default is @var{1}.
2831
2832 @item left_phase
2833 Change left phase. By default is disabled.
2834
2835 @item right_delay
2836 Set right channel delay. By defaults is @var{2.12} milliseconds.
2837
2838 @item right_balance
2839 Set right channel balance. By default is @var{1}.
2840
2841 @item right_gain
2842 Set right channel gain. By default is @var{1}.
2843
2844 @item right_phase
2845 Change right phase. By default is enabled.
2846 @end table
2847
2848 @section hdcd
2849
2850 Decodes High Definition Compatible Digital (HDCD) data. A 16-bit PCM stream with
2851 embedded HDCD codes is expanded into a 20-bit PCM stream.
2852
2853 The filter supports the Peak Extend and Low-level Gain Adjustment features
2854 of HDCD, and detects the Transient Filter flag.
2855
2856 @example
2857 ffmpeg -i HDCD16.flac -af hdcd OUT24.flac
2858 @end example
2859
2860 When using the filter with wav, note the default encoding for wav is 16-bit,
2861 so the resulting 20-bit stream will be truncated back to 16-bit. Use something
2862 like @command{-acodec pcm_s24le} after the filter to get 24-bit PCM output.
2863 @example
2864 ffmpeg -i HDCD16.wav -af hdcd OUT16.wav
2865 ffmpeg -i HDCD16.wav -af hdcd -c:a pcm_s24le OUT24.wav
2866 @end example
2867
2868 The filter accepts the following options:
2869
2870 @table @option
2871 @item disable_autoconvert
2872 Disable any automatic format conversion or resampling in the filter graph.
2873
2874 @item process_stereo
2875 Process the stereo channels together. If target_gain does not match between
2876 channels, consider it invalid and use the last valid target_gain.
2877
2878 @item cdt_ms
2879 Set the code detect timer period in ms.
2880
2881 @item force_pe
2882 Always extend peaks above -3dBFS even if PE isn't signaled.
2883
2884 @item analyze_mode
2885 Replace audio with a solid tone and adjust the amplitude to signal some
2886 specific aspect of the decoding process. The output file can be loaded in
2887 an audio editor alongside the original to aid analysis.
2888
2889 @code{analyze_mode=pe:force_pe=true} can be used to see all samples above the PE level.
2890
2891 Modes are:
2892 @table @samp
2893 @item 0, off
2894 Disabled
2895 @item 1, lle
2896 Gain adjustment level at each sample
2897 @item 2, pe
2898 Samples where peak extend occurs
2899 @item 3, cdt
2900 Samples where the code detect timer is active
2901 @item 4, tgm
2902 Samples where the target gain does not match between channels
2903 @end table
2904 @end table
2905
2906 @section headphone
2907
2908 Apply head-related transfer functions (HRTFs) to create virtual
2909 loudspeakers around the user for binaural listening via headphones.
2910 The HRIRs are provided via additional streams, for each channel
2911 one stereo input stream is needed.
2912
2913 The filter accepts the following options:
2914
2915 @table @option
2916 @item map
2917 Set mapping of input streams for convolution.
2918 The argument is a '|'-separated list of channel names in order as they
2919 are given as additional stream inputs for filter.
2920 This also specify number of input streams. Number of input streams
2921 must be not less than number of channels in first stream plus one.
2922
2923 @item gain
2924 Set gain applied to audio. Value is in dB. Default is 0.
2925
2926 @item type
2927 Set processing type. Can be @var{time} or @var{freq}. @var{time} is
2928 processing audio in time domain which is slow.
2929 @var{freq} is processing audio in frequency domain which is fast.
2930 Default is @var{freq}.
2931
2932 @item lfe
2933 Set custom gain for LFE channels. Value is in dB. Default is 0.
2934 @end table
2935
2936 @subsection Examples
2937
2938 @itemize
2939 @item
2940 Full example using wav files as coefficients with amovie filters for 7.1 downmix,
2941 each amovie filter use stereo file with IR coefficients as input.
2942 The files give coefficients for each position of virtual loudspeaker:
2943 @example
2944 ffmpeg -i input.wav -lavfi-complex "amovie=azi_270_ele_0_DFC.wav[sr],amovie=azi_90_ele_0_DFC.wav[sl],amovie=azi_225_ele_0_DFC.wav[br],amovie=azi_135_ele_0_DFC.wav[bl],amovie=azi_0_ele_0_DFC.wav,asplit[fc][lfe],amovie=azi_35_ele_0_DFC.wav[fl],amovie=azi_325_ele_0_DFC.wav[fr],[a:0][fl][fr][fc][lfe][bl][br][sl][sr]headphone=FL|FR|FC|LFE|BL|BR|SL|SR"
2945 output.wav
2946 @end example
2947 @end itemize
2948
2949 @section highpass
2950
2951 Apply a high-pass filter with 3dB point frequency.
2952 The filter can be either single-pole, or double-pole (the default).
2953 The filter roll off at 6dB per pole per octave (20dB per pole per decade).
2954
2955 The filter accepts the following options:
2956
2957 @table @option
2958 @item frequency, f
2959 Set frequency in Hz. Default is 3000.
2960
2961 @item poles, p
2962 Set number of poles. Default is 2.
2963
2964 @item width_type, t
2965 Set method to specify band-width of filter.
2966 @table @option
2967 @item h
2968 Hz
2969 @item q
2970 Q-Factor
2971 @item o
2972 octave
2973 @item s
2974 slope
2975 @end table
2976
2977 @item width, w
2978 Specify the band-width of a filter in width_type units.
2979 Applies only to double-pole filter.
2980 The default is 0.707q and gives a Butterworth response.
2981
2982 @item channels, c
2983 Specify which channels to filter, by default all available are filtered.
2984 @end table
2985
2986 @section join
2987
2988 Join multiple input streams into one multi-channel stream.
2989
2990 It accepts the following parameters:
2991 @table @option
2992
2993 @item inputs
2994 The number of input streams. It defaults to 2.
2995
2996 @item channel_layout
2997 The desired output channel layout. It defaults to stereo.
2998
2999 @item map
3000 Map channels from inputs to output. The argument is a '|'-separated list of
3001 mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
3002 form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
3003 can be either the name of the input channel (e.g. FL for front left) or its
3004 index in the specified input stream. @var{out_channel} is the name of the output
3005 channel.
3006 @end table
3007
3008 The filter will attempt to guess the mappings when they are not specified
3009 explicitly. It does so by first trying to find an unused matching input channel
3010 and if that fails it picks the first unused input channel.
3011
3012 Join 3 inputs (with properly set channel layouts):
3013 @example
3014 ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
3015 @end example
3016
3017 Build a 5.1 output from 6 single-channel streams:
3018 @example
3019 ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
3020 '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'
3021 out
3022 @end example
3023
3024 @section ladspa
3025
3026 Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
3027
3028 To enable compilation of this filter you need to configure FFmpeg with
3029 @code{--enable-ladspa}.
3030
3031 @table @option
3032 @item file, f
3033 Specifies the name of LADSPA plugin library to load. If the environment
3034 variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
3035 each one of the directories specified by the colon separated list in
3036 @env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
3037 this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
3038 @file{/usr/lib/ladspa/}.
3039
3040 @item plugin, p
3041 Specifies the plugin within the library. Some libraries contain only
3042 one plugin, but others contain many of them. If this is not set filter
3043 will list all available plugins within the specified library.
3044
3045 @item controls, c
3046 Set the '|' separated list of controls which are zero or more floating point
3047 values that determine the behavior of the loaded plugin (for example delay,
3048 threshold or gain).
3049 Controls need to be defined using the following syntax:
3050 c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
3051 @var{valuei} is the value set on the @var{i}-th control.
3052 Alternatively they can be also defined using the following syntax:
3053 @var{value0}|@var{value1}|@var{value2}|..., where
3054 @var{valuei} is the value set on the @var{i}-th control.
3055 If @option{controls} is set to @code{help}, all available controls and
3056 their valid ranges are printed.
3057
3058 @item sample_rate, s
3059 Specify the sample rate, default to 44100. Only used if plugin have
3060 zero inputs.
3061
3062 @item nb_samples, n
3063 Set the number of samples per channel per each output frame, default
3064 is 1024. Only used if plugin have zero inputs.
3065
3066 @item duration, d
3067 Set the minimum duration of the sourced audio. See
3068 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
3069 for the accepted syntax.
3070 Note that the resulting duration may be greater than the specified duration,
3071 as the generated audio is always cut at the end of a complete frame.
3072 If not specified, or the expressed duration is negative, the audio is
3073 supposed to be generated forever.
3074 Only used if plugin have zero inputs.
3075
3076 @end table
3077
3078 @subsection Examples
3079
3080 @itemize
3081 @item
3082 List all available plugins within amp (LADSPA example plugin) library:
3083 @example
3084 ladspa=file=amp
3085 @end example
3086
3087 @item
3088 List all available controls and their valid ranges for @code{vcf_notch}
3089 plugin from @code{VCF} library:
3090 @example
3091 ladspa=f=vcf:p=vcf_notch:c=help
3092 @end example
3093
3094 @item
3095 Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
3096 plugin library:
3097 @example
3098 ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
3099 @end example
3100
3101 @item
3102 Add reverberation to the audio using TAP-plugins
3103 (Tom's Audio Processing plugins):
3104 @example
3105 ladspa=file=tap_reverb:tap_reverb
3106 @end example
3107
3108 @item
3109 Generate white noise, with 0.2 amplitude:
3110 @example
3111 ladspa=file=cmt:noise_source_white:c=c0=.2
3112 @end example
3113
3114 @item
3115 Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
3116 @code{C* Audio Plugin Suite} (CAPS) library:
3117 @example
3118 ladspa=file=caps:Click:c=c1=20'
3119 @end example
3120
3121 @item
3122 Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
3123 @example
3124 ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
3125 @end example
3126
3127 @item
3128 Increase volume by 20dB using fast lookahead limiter from Steve Harris
3129 @code{SWH Plugins} collection:
3130 @example
3131 ladspa=fast_lookahead_limiter_1913:fastLookaheadLimiter:20|0|2
3132 @end example
3133
3134 @item
3135 Attenuate low frequencies using Multiband EQ from Steve Harris
3136 @code{SWH Plugins} collection:
3137 @example
3138 ladspa=mbeq_1197:mbeq:-24|-24|-24|0|0|0|0|0|0|0|0|0|0|0|0
3139 @end example
3140
3141 @item
3142 Reduce stereo image using @code{Narrower} from the @code{C* Audio Plugin Suite}
3143 (CAPS) library:
3144 @example
3145 ladspa=caps:Narrower
3146 @end example
3147
3148 @item
3149 Another white noise, now using @code{C* Audio Plugin Suite} (CAPS) library:
3150 @example
3151 ladspa=caps:White:.2
3152 @end example
3153
3154 @item
3155 Some fractal noise, using @code{C* Audio Plugin Suite} (CAPS) library:
3156 @example
3157 ladspa=caps:Fractal:c=c1=1
3158 @end example
3159
3160 @item
3161 Dynamic volume normalization using @code{VLevel} plugin:
3162 @example
3163 ladspa=vlevel-ladspa:vlevel_mono
3164 @end example
3165 @end itemize
3166
3167 @subsection Commands
3168
3169 This filter supports the following commands:
3170 @table @option
3171 @item cN
3172 Modify the @var{N}-th control value.
3173
3174 If the specified value is not valid, it is ignored and prior one is kept.
3175 @end table
3176
3177 @section loudnorm
3178
3179 EBU R128 loudness normalization. Includes both dynamic and linear normalization modes.
3180 Support for both single pass (livestreams, files) and double pass (files) modes.
3181 This algorithm can target IL, LRA, and maximum true peak. To accurately detect true peaks,
3182 the audio stream will be upsampled to 192 kHz unless the normalization mode is linear.
3183 Use the @code{-ar} option or @code{aresample} filter to explicitly set an output sample rate.
3184
3185 The filter accepts the following options:
3186
3187 @table @option
3188 @item I, i
3189 Set integrated loudness target.
3190 Range is -70.0 - -5.0. Default value is -24.0.
3191
3192 @item LRA, lra
3193 Set loudness range target.
3194 Range is 1.0 - 20.0. Default value is 7.0.
3195
3196 @item TP, tp
3197 Set maximum true peak.
3198 Range is -9.0 - +0.0. Default value is -2.0.
3199
3200 @item measured_I, measured_i
3201 Measured IL of input file.
3202 Range is -99.0 - +0.0.
3203
3204 @item measured_LRA, measured_lra
3205 Measured LRA of input file.
3206 Range is  0.0 - 99.0.
3207
3208 @item measured_TP, measured_tp
3209 Measured true peak of input file.
3210 Range is  -99.0 - +99.0.
3211
3212 @item measured_thresh
3213 Measured threshold of input file.
3214 Range is -99.0 - +0.0.
3215
3216 @item offset
3217 Set offset gain. Gain is applied before the true-peak limiter.
3218 Range is  -99.0 - +99.0. Default is +0.0.
3219
3220 @item linear
3221 Normalize linearly if possible.
3222 measured_I, measured_LRA, measured_TP, and measured_thresh must also
3223 to be specified in order to use this mode.
3224 Options are true or false. Default is true.
3225
3226 @item dual_mono
3227 Treat mono input files as "dual-mono". If a mono file is intended for playback
3228 on a stereo system, its EBU R128 measurement will be perceptually incorrect.
3229 If set to @code{true}, this option will compensate for this effect.
3230 Multi-channel input files are not affected by this option.
3231 Options are true or false. Default is false.
3232
3233 @item print_format
3234 Set print format for stats. Options are summary, json, or none.
3235 Default value is none.
3236 @end table
3237
3238 @section lowpass
3239
3240 Apply a low-pass filter with 3dB point frequency.
3241 The filter can be either single-pole or double-pole (the default).
3242 The filter roll off at 6dB per pole per octave (20dB per pole per decade).
3243
3244 The filter accepts the following options:
3245
3246 @table @option
3247 @item frequency, f
3248 Set frequency in Hz. Default is 500.
3249
3250 @item poles, p
3251 Set number of poles. Default is 2.
3252
3253 @item width_type, t
3254 Set method to specify band-width of filter.
3255 @table @option
3256 @item h
3257 Hz
3258 @item q
3259 Q-Factor
3260 @item o
3261 octave
3262 @item s
3263 slope
3264 @end table
3265
3266 @item width, w
3267 Specify the band-width of a filter in width_type units.
3268 Applies only to double-pole filter.
3269 The default is 0.707q and gives a Butterworth response.
3270
3271 @item channels, c
3272 Specify which channels to filter, by default all available are filtered.
3273 @end table
3274
3275 @subsection Examples
3276 @itemize
3277 @item
3278 Lowpass only LFE channel, it LFE is not present it does nothing:
3279 @example
3280 lowpass=c=LFE
3281 @end example
3282 @end itemize
3283
3284 @section lv2
3285
3286 Load a LV2 (LADSPA Version 2) plugin.
3287
3288 To enable compilation of this filter you need to configure FFmpeg with
3289 @code{--enable-lv2}.
3290
3291 @table @option
3292 @item plugin, p
3293 Specifies the plugin URI. You may need to escape ':'.
3294
3295 @item controls, c
3296 Set the '|' separated list of controls which are zero or more floating point
3297 values that determine the behavior of the loaded plugin (for example delay,
3298 threshold or gain).
3299 If @option{controls} is set to @code{help}, all available controls and
3300 their valid ranges are printed.
3301
3302 @item sample_rate, s
3303 Specify the sample rate, default to 44100. Only used if plugin have
3304 zero inputs.
3305
3306 @item nb_samples, n
3307 Set the number of samples per channel per each output frame, default
3308 is 1024. Only used if plugin have zero inputs.
3309
3310 @item duration, d
3311 Set the minimum duration of the sourced audio. See
3312 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
3313 for the accepted syntax.
3314 Note that the resulting duration may be greater than the specified duration,
3315 as the generated audio is always cut at the end of a complete frame.
3316 If not specified, or the expressed duration is negative, the audio is
3317 supposed to be generated forever.
3318 Only used if plugin have zero inputs.
3319 @end table
3320
3321 @subsection Examples
3322
3323 @itemize
3324 @item
3325 Apply bass enhancer plugin from Calf:
3326 @example
3327 lv2=p=http\\\\://calf.sourceforge.net/plugins/BassEnhancer:c=amount=2
3328 @end example
3329
3330 @item
3331 Apply bass vinyl plugin from Calf:
3332 @example
3333 lv2=p=http\\\\://calf.sourceforge.net/plugins/Vinyl:c=drone=0.2|aging=0.5
3334 @end example
3335
3336 @item
3337 Apply bit crusher plugin from ArtyFX:
3338 @example
3339 lv2=p=http\\\\://www.openavproductions.com/artyfx#bitta:c=crush=0.3
3340 @end example
3341 @end itemize
3342
3343 @section mcompand
3344 Multiband Compress or expand the audio's dynamic range.
3345
3346 The input audio is divided into bands using 4th order Linkwitz-Riley IIRs.
3347 This is akin to the crossover of a loudspeaker, and results in flat frequency
3348 response when absent compander action.
3349
3350 It accepts the following parameters:
3351
3352 @table @option
3353 @item args
3354 This option syntax is:
3355 attack,decay,[attack,decay..] soft-knee points crossover_frequency [delay [initial_volume [gain]]] | attack,decay ...
3356 For explanation of each item refer to compand filter documentation.
3357 @end table
3358
3359 @anchor{pan}
3360 @section pan
3361
3362 Mix channels with specific gain levels. The filter accepts the output
3363 channel layout followed by a set of channels definitions.
3364
3365 This filter is also designed to efficiently remap the channels of an audio
3366 stream.
3367
3368 The filter accepts parameters of the form:
3369 "@var{l}|@var{outdef}|@var{outdef}|..."
3370
3371 @table @option
3372 @item l
3373 output channel layout or number of channels
3374
3375 @item outdef
3376 output channel specification, of the form:
3377 "@var{out_name}=[@var{gain}*]@var{in_name}[(+-)[@var{gain}*]@var{in_name}...]"
3378
3379 @item out_name
3380 output channel to define, either a channel name (FL, FR, etc.) or a channel
3381 number (c0, c1, etc.)
3382
3383 @item gain
3384 multiplicative coefficient for the channel, 1 leaving the volume unchanged
3385
3386 @item in_name
3387 input channel to use, see out_name for details; it is not possible to mix
3388 named and numbered input channels
3389 @end table
3390
3391 If the `=' in a channel specification is replaced by `<', then the gains for
3392 that specification will be renormalized so that the total is 1, thus
3393 avoiding clipping noise.
3394
3395 @subsection Mixing examples
3396
3397 For example, if you want to down-mix from stereo to mono, but with a bigger
3398 factor for the left channel:
3399 @example
3400 pan=1c|c0=0.9*c0+0.1*c1
3401 @end example
3402
3403 A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
3404 7-channels surround:
3405 @example
3406 pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
3407 @end example
3408
3409 Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
3410 that should be preferred (see "-ac" option) unless you have very specific
3411 needs.
3412
3413 @subsection Remapping examples
3414
3415 The channel remapping will be effective if, and only if:
3416
3417 @itemize
3418 @item gain coefficients are zeroes or ones,
3419 @item only one input per channel output,
3420 @end itemize
3421
3422 If all these conditions are satisfied, the filter will notify the user ("Pure
3423 channel mapping detected"), and use an optimized and lossless method to do the
3424 remapping.
3425
3426 For example, if you have a 5.1 source and want a stereo audio stream by
3427 dropping the extra channels:
3428 @example
3429 pan="stereo| c0=FL | c1=FR"
3430 @end example
3431
3432 Given the same source, you can also switch front left and front right channels
3433 and keep the input channel layout:
3434 @example
3435 pan="5.1| c0=c1 | c1=c0 | c2=c2 | c3=c3 | c4=c4 | c5=c5"
3436 @end example
3437
3438 If the input is a stereo audio stream, you can mute the front left channel (and
3439 still keep the stereo channel layout) with:
3440 @example
3441 pan="stereo|c1=c1"
3442 @end example
3443
3444 Still with a stereo audio stream input, you can copy the right channel in both
3445 front left and right:
3446 @example
3447 pan="stereo| c0=FR | c1=FR"
3448 @end example
3449
3450 @section replaygain
3451
3452 ReplayGain scanner filter. This filter takes an audio stream as an input and
3453 outputs it unchanged.
3454 At end of filtering it displays @code{track_gain} and @code{track_peak}.
3455
3456 @section resample
3457
3458 Convert the audio sample format, sample rate and channel layout. It is
3459 not meant to be used directly.
3460
3461 @section rubberband
3462 Apply time-stretching and pitch-shifting with librubberband.
3463
3464 The filter accepts the following options:
3465
3466 @table @option
3467 @item tempo
3468 Set tempo scale factor.
3469
3470 @item pitch
3471 Set pitch scale factor.
3472
3473 @item transients
3474 Set transients detector.
3475 Possible values are:
3476 @table @var
3477 @item crisp
3478 @item mixed
3479 @item smooth
3480 @end table
3481
3482 @item detector
3483 Set detector.
3484 Possible values are:
3485 @table @var
3486 @item compound
3487 @item percussive
3488 @item soft
3489 @end table
3490
3491 @item phase
3492 Set phase.
3493 Possible values are:
3494 @table @var
3495 @item laminar
3496 @item independent
3497 @end table
3498
3499 @item window
3500 Set processing window size.
3501 Possible values are:
3502 @table @var
3503 @item standard
3504 @item short
3505 @item long
3506 @end table
3507
3508 @item smoothing
3509 Set smoothing.
3510 Possible values are:
3511 @table @var
3512 @item off
3513 @item on
3514 @end table
3515
3516 @item formant
3517 Enable formant preservation when shift pitching.
3518 Possible values are:
3519 @table @var
3520 @item shifted
3521 @item preserved
3522 @end table
3523
3524 @item pitchq
3525 Set pitch quality.
3526 Possible values are:
3527 @table @var
3528 @item quality
3529 @item speed
3530 @item consistency
3531 @end table
3532
3533 @item channels
3534 Set channels.
3535 Possible values are:
3536 @table @var
3537 @item apart
3538 @item together
3539 @end table
3540 @end table
3541
3542 @section sidechaincompress
3543
3544 This filter acts like normal compressor but has the ability to compress
3545 detected signal using second input signal.
3546 It needs two input streams and returns one output stream.
3547 First input stream will be processed depending on second stream signal.
3548 The filtered signal then can be filtered with other filters in later stages of
3549 processing. See @ref{pan} and @ref{amerge} filter.
3550
3551 The filter accepts the following options:
3552
3553 @table @option
3554 @item level_in
3555 Set input gain. Default is 1. Range is between 0.015625 and 64.
3556
3557 @item threshold
3558 If a signal of second stream raises above this level it will affect the gain
3559 reduction of first stream.
3560 By default is 0.125. Range is between 0.00097563 and 1.
3561
3562 @item ratio
3563 Set a ratio about which the signal is reduced. 1:2 means that if the level
3564 raised 4dB above the threshold, it will be only 2dB above after the reduction.
3565 Default is 2. Range is between 1 and 20.
3566
3567 @item attack
3568 Amount of milliseconds the signal has to rise above the threshold before gain
3569 reduction starts. Default is 20. Range is between 0.01 and 2000.
3570
3571 @item release
3572 Amount of milliseconds the signal has to fall below the threshold before
3573 reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
3574
3575 @item makeup
3576 Set the amount by how much signal will be amplified after processing.
3577 Default is 1. Range is from 1 to 64.
3578
3579 @item knee
3580 Curve the sharp knee around the threshold to enter gain reduction more softly.
3581 Default is 2.82843. Range is between 1 and 8.
3582
3583 @item link
3584 Choose if the @code{average} level between all channels of side-chain stream
3585 or the louder(@code{maximum}) channel of side-chain stream affects the
3586 reduction. Default is @code{average}.
3587
3588 @item detection
3589 Should the exact signal be taken in case of @code{peak} or an RMS one in case
3590 of @code{rms}. Default is @code{rms} which is mainly smoother.
3591
3592 @item level_sc
3593 Set sidechain gain. Default is 1. Range is between 0.015625 and 64.
3594
3595 @item mix
3596 How much to use compressed signal in output. Default is 1.
3597 Range is between 0 and 1.
3598 @end table
3599
3600 @subsection Examples
3601
3602 @itemize
3603 @item
3604 Full ffmpeg example taking 2 audio inputs, 1st input to be compressed
3605 depending on the signal of 2nd input and later compressed signal to be
3606 merged with 2nd input:
3607 @example
3608 ffmpeg -i main.flac -i sidechain.flac -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge"
3609 @end example
3610 @end itemize
3611
3612 @section sidechaingate
3613
3614 A sidechain gate acts like a normal (wideband) gate but has the ability to
3615 filter the detected signal before sending it to the gain reduction stage.
3616 Normally a gate uses the full range signal to detect a level above the
3617 threshold.
3618 For example: If you cut all lower frequencies from your sidechain signal
3619 the gate will decrease the volume of your track only if not enough highs
3620 appear. With this technique you are able to reduce the resonation of a
3621 natural drum or remove "rumbling" of muted strokes from a heavily distorted
3622 guitar.
3623 It needs two input streams and returns one output stream.
3624 First input stream will be processed depending on second stream signal.
3625
3626 The filter accepts the following options:
3627
3628 @table @option
3629 @item level_in
3630 Set input level before filtering.
3631 Default is 1. Allowed range is from 0.015625 to 64.
3632
3633 @item range
3634 Set the level of gain reduction when the signal is below the threshold.
3635 Default is 0.06125. Allowed range is from 0 to 1.
3636
3637 @item threshold
3638 If a signal rises above this level the gain reduction is released.
3639 Default is 0.125. Allowed range is from 0 to 1.
3640
3641 @item ratio
3642 Set a ratio about which the signal is reduced.
3643 Default is 2. Allowed range is from 1 to 9000.
3644
3645 @item attack
3646 Amount of milliseconds the signal has to rise above the threshold before gain
3647 reduction stops.
3648 Default is 20 milliseconds. Allowed range is from 0.01 to 9000.
3649
3650 @item release
3651 Amount of milliseconds the signal has to fall below the threshold before the
3652 reduction is increased again. Default is 250 milliseconds.
3653 Allowed range is from 0.01 to 9000.
3654
3655 @item makeup
3656 Set amount of amplification of signal after processing.
3657 Default is 1. Allowed range is from 1 to 64.
3658
3659 @item knee
3660 Curve the sharp knee around the threshold to enter gain reduction more softly.
3661 Default is 2.828427125. Allowed range is from 1 to 8.
3662
3663 @item detection
3664 Choose if exact signal should be taken for detection or an RMS like one.
3665 Default is rms. Can be peak or rms.
3666
3667 @item link
3668 Choose if the average level between all channels or the louder channel affects
3669 the reduction.
3670 Default is average. Can be average or maximum.
3671
3672 @item level_sc
3673 Set sidechain gain. Default is 1. Range is from 0.015625 to 64.
3674 @end table
3675
3676 @section silencedetect
3677
3678 Detect silence in an audio stream.
3679
3680 This filter logs a message when it detects that the input audio volume is less
3681 or equal to a noise tolerance value for a duration greater or equal to the
3682 minimum detected noise duration.
3683
3684 The printed times and duration are expressed in seconds.
3685
3686 The filter accepts the following options:
3687
3688 @table @option
3689 @item duration, d
3690 Set silence duration until notification (default is 2 seconds).
3691
3692 @item noise, n
3693 Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
3694 specified value) or amplitude ratio. Default is -60dB, or 0.001.
3695 @end table
3696
3697 @subsection Examples
3698
3699 @itemize
3700 @item
3701 Detect 5 seconds of silence with -50dB noise tolerance:
3702 @example
3703 silencedetect=n=-50dB:d=5
3704 @end example
3705
3706 @item
3707 Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
3708 tolerance in @file{silence.mp3}:
3709 @example
3710 ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
3711 @end example
3712 @end itemize
3713
3714 @section silenceremove
3715
3716 Remove silence from the beginning, middle or end of the audio.
3717
3718 The filter accepts the following options:
3719
3720 @table @option
3721 @item start_periods
3722 This value is used to indicate if audio should be trimmed at beginning of
3723 the audio. A value of zero indicates no silence should be trimmed from the
3724 beginning. When specifying a non-zero value, it trims audio up until it
3725 finds non-silence. Normally, when trimming silence from beginning of audio
3726 the @var{start_periods} will be @code{1} but it can be increased to higher
3727 values to trim all audio up to specific count of non-silence periods.
3728 Default value is @code{0}.
3729
3730 @item start_duration
3731 Specify the amount of time that non-silence must be detected before it stops
3732 trimming audio. By increasing the duration, bursts of noises can be treated
3733 as silence and trimmed off. Default value is @code{0}.
3734
3735 @item start_threshold
3736 This indicates what sample value should be treated as silence. For digital
3737 audio, a value of @code{0} may be fine but for audio recorded from analog,
3738 you may wish to increase the value to account for background noise.
3739 Can be specified in dB (in case "dB" is appended to the specified value)
3740 or amplitude ratio. Default value is @code{0}.
3741
3742 @item stop_periods
3743 Set the count for trimming silence from the end of audio.
3744 To remove silence from the middle of a file, specify a @var{stop_periods}
3745 that is negative. This value is then treated as a positive value and is
3746 used to indicate the effect should restart processing as specified by
3747 @var{start_periods}, making it suitable for removing periods of silence
3748 in the middle of the audio.
3749 Default value is @code{0}.
3750
3751 @item stop_duration
3752 Specify a duration of silence that must exist before audio is not copied any
3753 more. By specifying a higher duration, silence that is wanted can be left in
3754 the audio.
3755 Default value is @code{0}.
3756
3757 @item stop_threshold
3758 This is the same as @option{start_threshold} but for trimming silence from
3759 the end of audio.
3760 Can be specified in dB (in case "dB" is appended to the specified value)
3761 or amplitude ratio. Default value is @code{0}.
3762
3763 @item leave_silence
3764 This indicates that @var{stop_duration} length of audio should be left intact
3765 at the beginning of each period of silence.
3766 For example, if you want to remove long pauses between words but do not want
3767 to remove the pauses completely. Default value is @code{0}.
3768
3769 @item detection
3770 Set how is silence detected. Can be @code{rms} or @code{peak}. Second is faster
3771 and works better with digital silence which is exactly 0.
3772 Default value is @code{rms}.
3773
3774 @item window
3775 Set ratio used to calculate size of window for detecting silence.
3776 Default value is @code{0.02}. Allowed range is from @code{0} to @code{10}.
3777 @end table
3778
3779 @subsection Examples
3780
3781 @itemize
3782 @item
3783 The following example shows how this filter can be used to start a recording
3784 that does not contain the delay at the start which usually occurs between
3785 pressing the record button and the start of the performance:
3786 @example
3787 silenceremove=1:5:0.02
3788 @end example
3789
3790 @item
3791 Trim all silence encountered from beginning to end where there is more than 1
3792 second of silence in audio:
3793 @example
3794 silenceremove=0:0:0:-1:1:-90dB
3795 @end example
3796 @end itemize
3797
3798 @section sofalizer
3799
3800 SOFAlizer uses head-related transfer functions (HRTFs) to create virtual
3801 loudspeakers around the user for binaural listening via headphones (audio
3802 formats up to 9 channels supported).
3803 The HRTFs are stored in SOFA files (see @url{http://www.sofacoustics.org/} for a database).
3804 SOFAlizer is developed at the Acoustics Research Institute (ARI) of the
3805 Austrian Academy of Sciences.
3806
3807 To enable compilation of this filter you need to configure FFmpeg with
3808 @code{--enable-libmysofa}.
3809
3810 The filter accepts the following options:
3811
3812 @table @option
3813 @item sofa
3814 Set the SOFA file used for rendering.
3815
3816 @item gain
3817 Set gain applied to audio. Value is in dB. Default is 0.
3818
3819 @item rotation
3820 Set rotation of virtual loudspeakers in deg. Default is 0.
3821
3822 @item elevation
3823 Set elevation of virtual speakers in deg. Default is 0.
3824
3825 @item radius
3826 Set distance in meters between loudspeakers and the listener with near-field
3827 HRTFs. Default is 1.
3828
3829 @item type
3830 Set processing type. Can be @var{time} or @var{freq}. @var{time} is
3831 processing audio in time domain which is slow.
3832 @var{freq} is processing audio in frequency domain which is fast.
3833 Default is @var{freq}.
3834
3835 @item speakers
3836 Set custom positions of virtual loudspeakers. Syntax for this option is:
3837 <CH> <AZIM> <ELEV>[|<CH> <AZIM> <ELEV>|...].
3838 Each virtual loudspeaker is described with short channel name following with
3839 azimuth and elevation in degrees.
3840 Each virtual loudspeaker description is separated by '|'.
3841 For example to override front left and front right channel positions use:
3842 'speakers=FL 45 15|FR 345 15'.
3843 Descriptions with unrecognised channel names are ignored.
3844
3845 @item lfegain
3846 Set custom gain for LFE channels. Value is in dB. Default is 0.
3847 @end table
3848
3849 @subsection Examples
3850
3851 @itemize
3852 @item
3853 Using ClubFritz6 sofa file:
3854 @example
3855 sofalizer=sofa=/path/to/ClubFritz6.sofa:type=freq:radius=1
3856 @end example
3857
3858 @item
3859 Using ClubFritz12 sofa file and bigger radius with small rotation:
3860 @example
3861 sofalizer=sofa=/path/to/ClubFritz12.sofa:type=freq:radius=2:rotation=5
3862 @end example
3863
3864 @item
3865 Similar as above but with custom speaker positions for front left, front right, back left and back right
3866 and also with custom gain:
3867 @example
3868 "sofalizer=sofa=/path/to/ClubFritz6.sofa:type=freq:radius=2:speakers=FL 45|FR 315|BL 135|BR 225:gain=28"
3869 @end example
3870 @end itemize
3871
3872 @section stereotools
3873
3874 This filter has some handy utilities to manage stereo signals, for converting
3875 M/S stereo recordings to L/R signal while having control over the parameters
3876 or spreading the stereo image of master track.
3877
3878 The filter accepts the following options:
3879
3880 @table @option
3881 @item level_in
3882 Set input level before filtering for both channels. Defaults is 1.
3883 Allowed range is from 0.015625 to 64.
3884
3885 @item level_out
3886 Set output level after filtering for both channels. Defaults is 1.
3887 Allowed range is from 0.015625 to 64.
3888
3889 @item balance_in
3890 Set input balance between both channels. Default is 0.
3891 Allowed range is from -1 to 1.
3892
3893 @item balance_out
3894 Set output balance between both channels. Default is 0.
3895 Allowed range is from -1 to 1.
3896
3897 @item softclip
3898 Enable softclipping. Results in analog distortion instead of harsh digital 0dB
3899 clipping. Disabled by default.
3900
3901 @item mutel
3902 Mute the left channel. Disabled by default.
3903
3904 @item muter
3905 Mute the right channel. Disabled by default.
3906
3907 @item phasel
3908 Change the phase of the left channel. Disabled by default.
3909
3910 @item phaser
3911 Change the phase of the right channel. Disabled by default.
3912
3913 @item mode
3914 Set stereo mode. Available values are:
3915
3916 @table @samp
3917 @item lr>lr
3918 Left/Right to Left/Right, this is default.
3919
3920 @item lr>ms
3921 Left/Right to Mid/Side.
3922
3923 @item ms>lr
3924 Mid/Side to Left/Right.
3925
3926 @item lr>ll
3927 Left/Right to Left/Left.
3928
3929 @item lr>rr
3930 Left/Right to Right/Right.
3931
3932 @item lr>l+r
3933 Left/Right to Left + Right.
3934
3935 @item lr>rl
3936 Left/Right to Right/Left.
3937
3938 @item ms>ll
3939 Mid/Side to Left/Left.
3940
3941 @item ms>rr
3942 Mid/Side to Right/Right.
3943 @end table
3944
3945 @item slev
3946 Set level of side signal. Default is 1.
3947 Allowed range is from 0.015625 to 64.
3948
3949 @item sbal
3950 Set balance of side signal. Default is 0.
3951 Allowed range is from -1 to 1.
3952
3953 @item mlev
3954 Set level of the middle signal. Default is 1.
3955 Allowed range is from 0.015625 to 64.
3956
3957 @item mpan
3958 Set middle signal pan. Default is 0. Allowed range is from -1 to 1.
3959
3960 @item base
3961 Set stereo base between mono and inversed channels. Default is 0.
3962 Allowed range is from -1 to 1.
3963
3964 @item delay
3965 Set delay in milliseconds how much to delay left from right channel and
3966 vice versa. Default is 0. Allowed range is from -20 to 20.
3967
3968 @item sclevel
3969 Set S/C level. Default is 1. Allowed range is from 1 to 100.
3970
3971 @item phase
3972 Set the stereo phase in degrees. Default is 0. Allowed range is from 0 to 360.
3973
3974 @item bmode_in, bmode_out
3975 Set balance mode for balance_in/balance_out option.
3976
3977 Can be one of the following:
3978
3979 @table @samp
3980 @item balance
3981 Classic balance mode. Attenuate one channel at time.
3982 Gain is raised up to 1.
3983
3984 @item amplitude
3985 Similar as classic mode above but gain is raised up to 2.
3986
3987 @item power
3988 Equal power distribution, from -6dB to +6dB range.
3989 @end table
3990 @end table
3991
3992 @subsection Examples
3993
3994 @itemize
3995 @item
3996 Apply karaoke like effect:
3997 @example
3998 stereotools=mlev=0.015625
3999 @end example
4000
4001 @item
4002 Convert M/S signal to L/R:
4003 @example
4004 "stereotools=mode=ms>lr"
4005 @end example
4006 @end itemize
4007
4008 @section stereowiden
4009
4010 This filter enhance the stereo effect by suppressing signal common to both
4011 channels and by delaying the signal of left into right and vice versa,
4012 thereby widening the stereo effect.
4013
4014 The filter accepts the following options:
4015
4016 @table @option
4017 @item delay
4018 Time in milliseconds of the delay of left signal into right and vice versa.
4019 Default is 20 milliseconds.
4020
4021 @item feedback
4022 Amount of gain in delayed signal into right and vice versa. Gives a delay
4023 effect of left signal in right output and vice versa which gives widening
4024 effect. Default is 0.3.
4025
4026 @item crossfeed
4027 Cross feed of left into right with inverted phase. This helps in suppressing
4028 the mono. If the value is 1 it will cancel all the signal common to both
4029 channels. Default is 0.3.
4030
4031 @item drymix
4032 Set level of input signal of original channel. Default is 0.8.
4033 @end table
4034
4035 @section superequalizer
4036 Apply 18 band equalizer.
4037
4038 The filter accepts the following options:
4039 @table @option
4040 @item 1b
4041 Set 65Hz band gain.
4042 @item 2b
4043 Set 92Hz band gain.
4044 @item 3b
4045 Set 131Hz band gain.
4046 @item 4b
4047 Set 185Hz band gain.
4048 @item 5b
4049 Set 262Hz band gain.
4050 @item 6b
4051 Set 370Hz band gain.
4052 @item 7b
4053 Set 523Hz band gain.
4054 @item 8b
4055 Set 740Hz band gain.
4056 @item 9b
4057 Set 1047Hz band gain.
4058 @item 10b
4059 Set 1480Hz band gain.
4060 @item 11b
4061 Set 2093Hz band gain.
4062 @item 12b
4063 Set 2960Hz band gain.
4064 @item 13b
4065 Set 4186Hz band gain.
4066 @item 14b
4067 Set 5920Hz band gain.
4068 @item 15b
4069 Set 8372Hz band gain.
4070 @item 16b
4071 Set 11840Hz band gain.
4072 @item 17b
4073 Set 16744Hz band gain.
4074 @item 18b
4075 Set 20000Hz band gain.
4076 @end table
4077
4078 @section surround
4079 Apply audio surround upmix filter.
4080
4081 This filter allows to produce multichannel output from audio stream.
4082
4083 The filter accepts the following options:
4084
4085 @table @option
4086 @item chl_out
4087 Set output channel layout. By default, this is @var{5.1}.
4088
4089 See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
4090 for the required syntax.
4091
4092 @item chl_in
4093 Set input channel layout. By default, this is @var{stereo}.
4094
4095 See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
4096 for the required syntax.
4097
4098 @item level_in
4099 Set input volume level. By default, this is @var{1}.
4100
4101 @item level_out
4102 Set output volume level. By default, this is @var{1}.
4103
4104 @item lfe
4105 Enable LFE channel output if output channel layout has it. By default, this is enabled.
4106
4107 @item lfe_low
4108 Set LFE low cut off frequency. By default, this is @var{128} Hz.
4109
4110 @item lfe_high
4111 Set LFE high cut off frequency. By default, this is @var{256} Hz.
4112
4113 @item fc_in
4114 Set front center input volume. By default, this is @var{1}.
4115
4116 @item fc_out
4117 Set front center output volume. By default, this is @var{1}.
4118
4119 @item lfe_in
4120 Set LFE input volume. By default, this is @var{1}.
4121
4122 @item lfe_out
4123 Set LFE output volume. By default, this is @var{1}.
4124 @end table
4125
4126 @section treble
4127
4128 Boost or cut treble (upper) frequencies of the audio using a two-pole
4129 shelving filter with a response similar to that of a standard
4130 hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
4131
4132 The filter accepts the following options:
4133
4134 @table @option
4135 @item gain, g
4136 Give the gain at whichever is the lower of ~22 kHz and the
4137 Nyquist frequency. Its useful range is about -20 (for a large cut)
4138 to +20 (for a large boost). Beware of clipping when using a positive gain.
4139
4140 @item frequency, f
4141 Set the filter's central frequency and so can be used
4142 to extend or reduce the frequency range to be boosted or cut.
4143 The default value is @code{3000} Hz.
4144
4145 @item width_type, t
4146 Set method to specify band-width of filter.
4147 @table @option
4148 @item h
4149 Hz
4150 @item q
4151 Q-Factor
4152 @item o
4153 octave
4154 @item s
4155 slope
4156 @end table
4157
4158 @item width, w
4159 Determine how steep is the filter's shelf transition.
4160
4161 @item channels, c
4162 Specify which channels to filter, by default all available are filtered.
4163 @end table
4164
4165 @section tremolo
4166
4167 Sinusoidal amplitude modulation.
4168
4169 The filter accepts the following options:
4170
4171 @table @option
4172 @item f
4173 Modulation frequency in Hertz. Modulation frequencies in the subharmonic range
4174 (20 Hz or lower) will result in a tremolo effect.
4175 This filter may also be used as a ring modulator by specifying
4176 a modulation frequency higher than 20 Hz.
4177 Range is 0.1 - 20000.0. Default value is 5.0 Hz.
4178
4179 @item d
4180 Depth of modulation as a percentage. Range is 0.0 - 1.0.
4181 Default value is 0.5.
4182 @end table
4183
4184 @section vibrato
4185
4186 Sinusoidal phase modulation.
4187
4188 The filter accepts the following options:
4189
4190 @table @option
4191 @item f
4192 Modulation frequency in Hertz.
4193 Range is 0.1 - 20000.0. Default value is 5.0 Hz.
4194
4195 @item d
4196 Depth of modulation as a percentage. Range is 0.0 - 1.0.
4197 Default value is 0.5.
4198 @end table
4199
4200 @section volume
4201
4202 Adjust the input audio volume.
4203
4204 It accepts the following parameters:
4205 @table @option
4206
4207 @item volume
4208 Set audio volume expression.
4209
4210 Output values are clipped to the maximum value.
4211
4212 The output audio volume is given by the relation:
4213 @example
4214 @var{output_volume} = @var{volume} * @var{input_volume}
4215 @end example
4216
4217 The default value for @var{volume} is "1.0".
4218
4219 @item precision
4220 This parameter represents the mathematical precision.
4221
4222 It determines which input sample formats will be allowed, which affects the
4223 precision of the volume scaling.
4224
4225 @table @option
4226 @item fixed
4227 8-bit fixed-point; this limits input sample format to U8, S16, and S32.
4228 @item float
4229 32-bit floating-point; this limits input sample format to FLT. (default)
4230 @item double
4231 64-bit floating-point; this limits input sample format to DBL.
4232 @end table
4233
4234 @item replaygain
4235 Choose the behaviour on encountering ReplayGain side data in input frames.
4236
4237 @table @option
4238 @item drop
4239 Remove ReplayGain side data, ignoring its contents (the default).
4240
4241 @item ignore
4242 Ignore ReplayGain side data, but leave it in the frame.
4243
4244 @item track
4245 Prefer the track gain, if present.
4246
4247 @item album
4248 Prefer the album gain, if present.
4249 @end table
4250
4251 @item replaygain_preamp
4252 Pre-amplification gain in dB to apply to the selected replaygain gain.
4253
4254 Default value for @var{replaygain_preamp} is 0.0.
4255
4256 @item eval
4257 Set when the volume expression is evaluated.
4258
4259 It accepts the following values:
4260 @table @samp
4261 @item once
4262 only evaluate expression once during the filter initialization, or
4263 when the @samp{volume} command is sent
4264
4265 @item frame
4266 evaluate expression for each incoming frame
4267 @end table
4268
4269 Default value is @samp{once}.
4270 @end table
4271
4272 The volume expression can contain the following parameters.
4273
4274 @table @option
4275 @item n
4276 frame number (starting at zero)
4277 @item nb_channels
4278 number of channels
4279 @item nb_consumed_samples
4280 number of samples consumed by the filter
4281 @item nb_samples
4282 number of samples in the current frame
4283 @item pos
4284 original frame position in the file
4285 @item pts
4286 frame PTS
4287 @item sample_rate
4288 sample rate
4289 @item startpts
4290 PTS at start of stream
4291 @item startt
4292 time at start of stream
4293 @item t
4294 frame time
4295 @item tb
4296 timestamp timebase
4297 @item volume
4298 last set volume value
4299 @end table
4300
4301 Note that when @option{eval} is set to @samp{once} only the
4302 @var{sample_rate} and @var{tb} variables are available, all other
4303 variables will evaluate to NAN.
4304
4305 @subsection Commands
4306
4307 This filter supports the following commands:
4308 @table @option
4309 @item volume
4310 Modify the volume expression.
4311 The command accepts the same syntax of the corresponding option.
4312
4313 If the specified expression is not valid, it is kept at its current
4314 value.
4315 @item replaygain_noclip
4316 Prevent clipping by limiting the gain applied.
4317
4318 Default value for @var{replaygain_noclip} is 1.
4319
4320 @end table
4321
4322 @subsection Examples
4323
4324 @itemize
4325 @item
4326 Halve the input audio volume:
4327 @example
4328 volume=volume=0.5
4329 volume=volume=1/2
4330 volume=volume=-6.0206dB
4331 @end example
4332
4333 In all the above example the named key for @option{volume} can be
4334 omitted, for example like in:
4335 @example
4336 volume=0.5
4337 @end example
4338
4339 @item
4340 Increase input audio power by 6 decibels using fixed-point precision:
4341 @example
4342 volume=volume=6dB:precision=fixed
4343 @end example
4344
4345 @item
4346 Fade volume after time 10 with an annihilation period of 5 seconds:
4347 @example
4348 volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
4349 @end example
4350 @end itemize
4351
4352 @section volumedetect
4353
4354 Detect the volume of the input video.
4355
4356 The filter has no parameters. The input is not modified. Statistics about
4357 the volume will be printed in the log when the input stream end is reached.
4358
4359 In particular it will show the mean volume (root mean square), maximum
4360 volume (on a per-sample basis), and the beginning of a histogram of the
4361 registered volume values (from the maximum value to a cumulated 1/1000 of
4362 the samples).
4363
4364 All volumes are in decibels relative to the maximum PCM value.
4365
4366 @subsection Examples
4367
4368 Here is an excerpt of the output:
4369 @example
4370 [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
4371 [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
4372 [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
4373 [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
4374 [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
4375 [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
4376 [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
4377 [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
4378 [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
4379 @end example
4380
4381 It means that:
4382 @itemize
4383 @item
4384 The mean square energy is approximately -27 dB, or 10^-2.7.
4385 @item
4386 The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
4387 @item
4388 There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
4389 @end itemize
4390
4391 In other words, raising the volume by +4 dB does not cause any clipping,
4392 raising it by +5 dB causes clipping for 6 samples, etc.
4393
4394 @c man end AUDIO FILTERS
4395
4396 @chapter Audio Sources
4397 @c man begin AUDIO SOURCES
4398
4399 Below is a description of the currently available audio sources.
4400
4401 @section abuffer
4402
4403 Buffer audio frames, and make them available to the filter chain.
4404
4405 This source is mainly intended for a programmatic use, in particular
4406 through the interface defined in @file{libavfilter/asrc_abuffer.h}.
4407
4408 It accepts the following parameters:
4409 @table @option
4410
4411 @item time_base
4412 The timebase which will be used for timestamps of submitted frames. It must be
4413 either a floating-point number or in @var{numerator}/@var{denominator} form.
4414
4415 @item sample_rate
4416 The sample rate of the incoming audio buffers.
4417
4418 @item sample_fmt
4419 The sample format of the incoming audio buffers.
4420 Either a sample format name or its corresponding integer representation from
4421 the enum AVSampleFormat in @file{libavutil/samplefmt.h}
4422
4423 @item channel_layout
4424 The channel layout of the incoming audio buffers.
4425 Either a channel layout name from channel_layout_map in
4426 @file{libavutil/channel_layout.c} or its corresponding integer representation
4427 from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
4428
4429 @item channels
4430 The number of channels of the incoming audio buffers.
4431 If both @var{channels} and @var{channel_layout} are specified, then they
4432 must be consistent.
4433
4434 @end table
4435
4436 @subsection Examples
4437
4438 @example
4439 abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
4440 @end example
4441
4442 will instruct the source to accept planar 16bit signed stereo at 44100Hz.
4443 Since the sample format with name "s16p" corresponds to the number
4444 6 and the "stereo" channel layout corresponds to the value 0x3, this is
4445 equivalent to:
4446 @example
4447 abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
4448 @end example
4449
4450 @section aevalsrc
4451
4452 Generate an audio signal specified by an expression.
4453
4454 This source accepts in input one or more expressions (one for each
4455 channel), which are evaluated and used to generate a corresponding
4456 audio signal.
4457
4458 This source accepts the following options:
4459
4460 @table @option
4461 @item exprs
4462 Set the '|'-separated expressions list for each separate channel. In case the
4463 @option{channel_layout} option is not specified, the selected channel layout
4464 depends on the number of provided expressions. Otherwise the last
4465 specified expression is applied to the remaining output channels.
4466
4467 @item channel_layout, c
4468 Set the channel layout. The number of channels in the specified layout
4469 must be equal to the number of specified expressions.
4470
4471 @item duration, d
4472 Set the minimum duration of the sourced audio. See
4473 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
4474 for the accepted syntax.
4475 Note that the resulting duration may be greater than the specified
4476 duration, as the generated audio is always cut at the end of a
4477 complete frame.
4478
4479 If not specified, or the expressed duration is negative, the audio is
4480 supposed to be generated forever.
4481
4482 @item nb_samples, n
4483 Set the number of samples per channel per each output frame,
4484 default to 1024.
4485
4486 @item sample_rate, s
4487 Specify the sample rate, default to 44100.
4488 @end table
4489
4490 Each expression in @var{exprs} can contain the following constants:
4491
4492 @table @option
4493 @item n
4494 number of the evaluated sample, starting from 0
4495
4496 @item t
4497 time of the evaluated sample expressed in seconds, starting from 0
4498
4499 @item s
4500 sample rate
4501
4502 @end table
4503
4504 @subsection Examples
4505
4506 @itemize
4507 @item
4508 Generate silence:
4509 @example
4510 aevalsrc=0
4511 @end example
4512
4513 @item
4514 Generate a sin signal with frequency of 440 Hz, set sample rate to
4515 8000 Hz:
4516 @example
4517 aevalsrc="sin(440*2*PI*t):s=8000"
4518 @end example
4519
4520 @item
4521 Generate a two channels signal, specify the channel layout (Front
4522 Center + Back Center) explicitly:
4523 @example
4524 aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
4525 @end example
4526
4527 @item
4528 Generate white noise:
4529 @example
4530 aevalsrc="-2+random(0)"
4531 @end example
4532
4533 @item
4534 Generate an amplitude modulated signal:
4535 @example
4536 aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
4537 @end example
4538
4539 @item
4540 Generate 2.5 Hz binaural beats on a 360 Hz carrier:
4541 @example
4542 aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
4543 @end example
4544
4545 @end itemize
4546
4547 @section anullsrc
4548
4549 The null audio source, return unprocessed audio frames. It is mainly useful
4550 as a template and to be employed in analysis / debugging tools, or as
4551 the source for filters which ignore the input data (for example the sox
4552 synth filter).
4553
4554 This source accepts the following options:
4555
4556 @table @option
4557
4558 @item channel_layout, cl
4559
4560 Specifies the channel layout, and can be either an integer or a string
4561 representing a channel layout. The default value of @var{channel_layout}
4562 is "stereo".
4563
4564 Check the channel_layout_map definition in
4565 @file{libavutil/channel_layout.c} for the mapping between strings and
4566 channel layout values.
4567
4568 @item sample_rate, r
4569 Specifies the sample rate, and defaults to 44100.
4570
4571 @item nb_samples, n
4572 Set the number of samples per requested frames.
4573
4574 @end table
4575
4576 @subsection Examples
4577
4578 @itemize
4579 @item
4580 Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
4581 @example
4582 anullsrc=r=48000:cl=4
4583 @end example
4584
4585 @item
4586 Do the same operation with a more obvious syntax:
4587 @example
4588 anullsrc=r=48000:cl=mono
4589 @end example
4590 @end itemize
4591
4592 All the parameters need to be explicitly defined.
4593
4594 @section flite
4595
4596 Synthesize a voice utterance using the libflite library.
4597
4598 To enable compilation of this filter you need to configure FFmpeg with
4599 @code{--enable-libflite}.
4600
4601 Note that versions of the flite library prior to 2.0 are not thread-safe.
4602
4603 The filter accepts the following options:
4604
4605 @table @option
4606
4607 @item list_voices
4608 If set to 1, list the names of the available voices and exit
4609 immediately. Default value is 0.
4610
4611 @item nb_samples, n
4612 Set the maximum number of samples per frame. Default value is 512.
4613
4614 @item textfile
4615 Set the filename containing the text to speak.
4616
4617 @item text
4618 Set the text to speak.
4619
4620 @item voice, v
4621 Set the voice to use for the speech synthesis. Default value is
4622 @code{kal}. See also the @var{list_voices} option.
4623 @end table
4624
4625 @subsection Examples
4626
4627 @itemize
4628 @item
4629 Read from file @file{speech.txt}, and synthesize the text using the
4630 standard flite voice:
4631 @example
4632 flite=textfile=speech.txt
4633 @end example
4634
4635 @item
4636 Read the specified text selecting the @code{slt} voice:
4637 @example
4638 flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
4639 @end example
4640
4641 @item
4642 Input text to ffmpeg:
4643 @example
4644 ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
4645 @end example
4646
4647 @item
4648 Make @file{ffplay} speak the specified text, using @code{flite} and
4649 the @code{lavfi} device:
4650 @example
4651 ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
4652 @end example
4653 @end itemize
4654
4655 For more information about libflite, check:
4656 @url{http://www.festvox.org/flite/}
4657
4658 @section anoisesrc
4659
4660 Generate a noise audio signal.
4661
4662 The filter accepts the following options:
4663
4664 @table @option
4665 @item sample_rate, r
4666 Specify the sample rate. Default value is 48000 Hz.
4667
4668 @item amplitude, a
4669 Specify the amplitude (0.0 - 1.0) of the generated audio stream. Default value
4670 is 1.0.
4671
4672 @item duration, d
4673 Specify the duration of the generated audio stream. Not specifying this option
4674 results in noise with an infinite length.
4675
4676 @item color, colour, c
4677 Specify the color of noise. Available noise colors are white, pink, brown,
4678 blue and violet. Default color is white.
4679
4680 @item seed, s
4681 Specify a value used to seed the PRNG.
4682
4683 @item nb_samples, n
4684 Set the number of samples per each output frame, default is 1024.
4685 @end table
4686
4687 @subsection Examples
4688
4689 @itemize
4690
4691 @item
4692 Generate 60 seconds of pink noise, with a 44.1 kHz sampling rate and an amplitude of 0.5:
4693 @example
4694 anoisesrc=d=60:c=pink:r=44100:a=0.5
4695 @end example
4696 @end itemize
4697
4698 @section sine
4699
4700 Generate an audio signal made of a sine wave with amplitude 1/8.
4701
4702 The audio signal is bit-exact.
4703
4704 The filter accepts the following options:
4705
4706 @table @option
4707
4708 @item frequency, f
4709 Set the carrier frequency. Default is 440 Hz.
4710
4711 @item beep_factor, b
4712 Enable a periodic beep every second with frequency @var{beep_factor} times
4713 the carrier frequency. Default is 0, meaning the beep is disabled.
4714
4715 @item sample_rate, r
4716 Specify the sample rate, default is 44100.
4717
4718 @item duration, d
4719 Specify the duration of the generated audio stream.
4720
4721 @item samples_per_frame
4722 Set the number of samples per output frame.
4723
4724 The expression can contain the following constants:
4725
4726 @table @option
4727 @item n
4728 The (sequential) number of the output audio frame, starting from 0.
4729
4730 @item pts
4731 The PTS (Presentation TimeStamp) of the output audio frame,
4732 expressed in @var{TB} units.
4733
4734 @item t
4735 The PTS of the output audio frame, expressed in seconds.
4736
4737 @item TB
4738 The timebase of the output audio frames.
4739 @end table
4740
4741 Default is @code{1024}.
4742 @end table
4743
4744 @subsection Examples
4745
4746 @itemize
4747
4748 @item
4749 Generate a simple 440 Hz sine wave:
4750 @example
4751 sine
4752 @end example
4753
4754 @item
4755 Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
4756 @example
4757 sine=220:4:d=5
4758 sine=f=220:b=4:d=5
4759 sine=frequency=220:beep_factor=4:duration=5
4760 @end example
4761
4762 @item
4763 Generate a 1 kHz sine wave following @code{1602,1601,1602,1601,1602} NTSC
4764 pattern:
4765 @example
4766 sine=1000:samples_per_frame='st(0,mod(n,5)); 1602-not(not(eq(ld(0),1)+eq(ld(0),3)))'
4767 @end example
4768 @end itemize
4769
4770 @c man end AUDIO SOURCES
4771
4772 @chapter Audio Sinks
4773 @c man begin AUDIO SINKS
4774
4775 Below is a description of the currently available audio sinks.
4776
4777 @section abuffersink
4778
4779 Buffer audio frames, and make them available to the end of filter chain.
4780
4781 This sink is mainly intended for programmatic use, in particular
4782 through the interface defined in @file{libavfilter/buffersink.h}
4783 or the options system.
4784
4785 It accepts a pointer to an AVABufferSinkContext structure, which
4786 defines the incoming buffers' formats, to be passed as the opaque
4787 parameter to @code{avfilter_init_filter} for initialization.
4788 @section anullsink
4789
4790 Null audio sink; do absolutely nothing with the input audio. It is
4791 mainly useful as a template and for use in analysis / debugging
4792 tools.
4793
4794 @c man end AUDIO SINKS
4795
4796 @chapter Video Filters
4797 @c man begin VIDEO FILTERS
4798
4799 When you configure your FFmpeg build, you can disable any of the
4800 existing filters using @code{--disable-filters}.
4801 The configure output will show the video filters included in your
4802 build.
4803
4804 Below is a description of the currently available video filters.
4805
4806 @section alphaextract
4807
4808 Extract the alpha component from the input as a grayscale video. This
4809 is especially useful with the @var{alphamerge} filter.
4810
4811 @section alphamerge
4812
4813 Add or replace the alpha component of the primary input with the
4814 grayscale value of a second input. This is intended for use with
4815 @var{alphaextract} to allow the transmission or storage of frame
4816 sequences that have alpha in a format that doesn't support an alpha
4817 channel.
4818
4819 For example, to reconstruct full frames from a normal YUV-encoded video
4820 and a separate video created with @var{alphaextract}, you might use:
4821 @example
4822 movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
4823 @end example
4824
4825 Since this filter is designed for reconstruction, it operates on frame
4826 sequences without considering timestamps, and terminates when either
4827 input reaches end of stream. This will cause problems if your encoding
4828 pipeline drops frames. If you're trying to apply an image as an
4829 overlay to a video stream, consider the @var{overlay} filter instead.
4830
4831 @section ass
4832
4833 Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
4834 and libavformat to work. On the other hand, it is limited to ASS (Advanced
4835 Substation Alpha) subtitles files.
4836
4837 This filter accepts the following option in addition to the common options from
4838 the @ref{subtitles} filter:
4839
4840 @table @option
4841 @item shaping
4842 Set the shaping engine
4843
4844 Available values are:
4845 @table @samp
4846 @item auto
4847 The default libass shaping engine, which is the best available.
4848 @item simple
4849 Fast, font-agnostic shaper that can do only substitutions
4850 @item complex
4851 Slower shaper using OpenType for substitutions and positioning
4852 @end table
4853
4854 The default is @code{auto}.
4855 @end table
4856
4857 @section atadenoise
4858 Apply an Adaptive Temporal Averaging Denoiser to the video input.
4859
4860 The filter accepts the following options:
4861
4862 @table @option
4863 @item 0a
4864 Set threshold A for 1st plane. Default is 0.02.
4865 Valid range is 0 to 0.3.
4866
4867 @item 0b
4868 Set threshold B for 1st plane. Default is 0.04.
4869 Valid range is 0 to 5.
4870
4871 @item 1a
4872 Set threshold A for 2nd plane. Default is 0.02.
4873 Valid range is 0 to 0.3.
4874
4875 @item 1b
4876 Set threshold B for 2nd plane. Default is 0.04.
4877 Valid range is 0 to 5.
4878
4879 @item 2a
4880 Set threshold A for 3rd plane. Default is 0.02.
4881 Valid range is 0 to 0.3.
4882
4883 @item 2b
4884 Set threshold B for 3rd plane. Default is 0.04.
4885 Valid range is 0 to 5.
4886
4887 Threshold A is designed to react on abrupt changes in the input signal and
4888 threshold B is designed to react on continuous changes in the input signal.
4889
4890 @item s
4891 Set number of frames filter will use for averaging. Default is 33. Must be odd
4892 number in range [5, 129].
4893
4894 @item p
4895 Set what planes of frame filter will use for averaging. Default is all.
4896 @end table
4897
4898 @section avgblur
4899
4900 Apply average blur filter.
4901
4902 The filter accepts the following options:
4903
4904 @table @option
4905 @item sizeX
4906 Set horizontal kernel size.
4907
4908 @item planes
4909 Set which planes to filter. By default all planes are filtered.
4910
4911 @item sizeY
4912 Set vertical kernel size, if zero it will be same as @code{sizeX}.
4913 Default is @code{0}.
4914 @end table
4915
4916 @section bbox
4917
4918 Compute the bounding box for the non-black pixels in the input frame
4919 luminance plane.
4920
4921 This filter computes the bounding box containing all the pixels with a
4922 luminance value greater than the minimum allowed value.
4923 The parameters describing the bounding box are printed on the filter
4924 log.
4925
4926 The filter accepts the following option:
4927
4928 @table @option
4929 @item min_val
4930 Set the minimal luminance value. Default is @code{16}.
4931 @end table
4932
4933 @section bitplanenoise
4934
4935 Show and measure bit plane noise.
4936
4937 The filter accepts the following options:
4938
4939 @table @option
4940 @item bitplane
4941 Set which plane to analyze. Default is @code{1}.
4942
4943 @item filter
4944 Filter out noisy pixels from @code{bitplane} set above.
4945 Default is disabled.
4946 @end table
4947
4948 @section blackdetect
4949
4950 Detect video intervals that are (almost) completely black. Can be
4951 useful to detect chapter transitions, commercials, or invalid
4952 recordings. Output lines contains the time for the start, end and
4953 duration of the detected black interval expressed in seconds.
4954
4955 In order to display the output lines, you need to set the loglevel at
4956 least to the AV_LOG_INFO value.
4957
4958 The filter accepts the following options:
4959
4960 @table @option
4961 @item black_min_duration, d
4962 Set the minimum detected black duration expressed in seconds. It must
4963 be a non-negative floating point number.
4964
4965 Default value is 2.0.
4966
4967 @item picture_black_ratio_th, pic_th
4968 Set the threshold for considering a picture "black".
4969 Express the minimum value for the ratio:
4970 @example
4971 @var{nb_black_pixels} / @var{nb_pixels}
4972 @end example
4973
4974 for which a picture is considered black.
4975 Default value is 0.98.
4976
4977 @item pixel_black_th, pix_th
4978 Set the threshold for considering a pixel "black".
4979
4980 The threshold expresses the maximum pixel luminance value for which a
4981 pixel is considered "black". The provided value is scaled according to
4982 the following equation:
4983 @example
4984 @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
4985 @end example
4986
4987 @var{luminance_range_size} and @var{luminance_minimum_value} depend on
4988 the input video format, the range is [0-255] for YUV full-range
4989 formats and [16-235] for YUV non full-range formats.
4990
4991 Default value is 0.10.
4992 @end table
4993
4994 The following example sets the maximum pixel threshold to the minimum
4995 value, and detects only black intervals of 2 or more seconds:
4996 @example
4997 blackdetect=d=2:pix_th=0.00
4998 @end example
4999
5000 @section blackframe
5001
5002 Detect frames that are (almost) completely black. Can be useful to
5003 detect chapter transitions or commercials. Output lines consist of
5004 the frame number of the detected frame, the percentage of blackness,
5005 the position in the file if known or -1 and the timestamp in seconds.
5006
5007 In order to display the output lines, you need to set the loglevel at
5008 least to the AV_LOG_INFO value.
5009
5010 This filter exports frame metadata @code{lavfi.blackframe.pblack}.
5011 The value represents the percentage of pixels in the picture that
5012 are below the threshold value.
5013
5014 It accepts the following parameters:
5015
5016 @table @option
5017
5018 @item amount
5019 The percentage of the pixels that have to be below the threshold; it defaults to
5020 @code{98}.
5021
5022 @item threshold, thresh
5023 The threshold below which a pixel value is considered black; it defaults to
5024 @code{32}.
5025
5026 @end table
5027
5028 @section blend, tblend
5029
5030 Blend two video frames into each other.
5031
5032 The @code{blend} filter takes two input streams and outputs one
5033 stream, the first input is the "top" layer and second input is
5034 "bottom" layer.  By default, the output terminates when the longest input terminates.
5035
5036 The @code{tblend} (time blend) filter takes two consecutive frames
5037 from one single stream, and outputs the result obtained by blending
5038 the new frame on top of the old frame.
5039
5040 A description of the accepted options follows.
5041
5042 @table @option
5043 @item c0_mode
5044 @item c1_mode
5045 @item c2_mode
5046 @item c3_mode
5047 @item all_mode
5048 Set blend mode for specific pixel component or all pixel components in case
5049 of @var{all_mode}. Default value is @code{normal}.
5050
5051 Available values for component modes are:
5052 @table @samp
5053 @item addition
5054 @item grainmerge
5055 @item and
5056 @item average
5057 @item burn
5058 @item darken
5059 @item difference
5060 @item grainextract
5061 @item divide
5062 @item dodge
5063 @item freeze
5064 @item exclusion
5065 @item extremity
5066 @item glow
5067 @item hardlight
5068 @item hardmix
5069 @item heat
5070 @item lighten
5071 @item linearlight
5072 @item multiply
5073 @item multiply128
5074 @item negation
5075 @item normal
5076 @item or
5077 @item overlay
5078 @item phoenix
5079 @item pinlight
5080 @item reflect
5081 @item screen
5082 @item softlight
5083 @item subtract
5084 @item vividlight
5085 @item xor
5086 @end table
5087
5088 @item c0_opacity
5089 @item c1_opacity
5090 @item c2_opacity
5091 @item c3_opacity
5092 @item all_opacity
5093 Set blend opacity for specific pixel component or all pixel components in case
5094 of @var{all_opacity}. Only used in combination with pixel component blend modes.
5095
5096 @item c0_expr
5097 @item c1_expr
5098 @item c2_expr
5099 @item c3_expr
5100 @item all_expr
5101 Set blend expression for specific pixel component or all pixel components in case
5102 of @var{all_expr}. Note that related mode options will be ignored if those are set.
5103
5104 The expressions can use the following variables:
5105
5106 @table @option
5107 @item N
5108 The sequential number of the filtered frame, starting from @code{0}.
5109
5110 @item X
5111 @item Y
5112 the coordinates of the current sample
5113
5114 @item W
5115 @item H
5116 the width and height of currently filtered plane
5117
5118 @item SW
5119 @item SH
5120 Width and height scale depending on the currently filtered plane. It is the
5121 ratio between the corresponding luma plane number of pixels and the current
5122 plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
5123 @code{0.5,0.5} for chroma planes.
5124
5125 @item T
5126 Time of the current frame, expressed in seconds.
5127
5128 @item TOP, A
5129 Value of pixel component at current location for first video frame (top layer).
5130
5131 @item BOTTOM, B
5132 Value of pixel component at current location for second video frame (bottom layer).
5133 @end table
5134 @end table
5135
5136 The @code{blend} filter also supports the @ref{framesync} options.
5137
5138 @subsection Examples
5139
5140 @itemize
5141 @item
5142 Apply transition from bottom layer to top layer in first 10 seconds:
5143 @example
5144 blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
5145 @end example
5146
5147 @item
5148 Apply linear horizontal transition from top layer to bottom layer:
5149 @example
5150 blend=all_expr='A*(X/W)+B*(1-X/W)'
5151 @end example
5152
5153 @item
5154 Apply 1x1 checkerboard effect:
5155 @example
5156 blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
5157 @end example
5158
5159 @item
5160 Apply uncover left effect:
5161 @example
5162 blend=all_expr='if(gte(N*SW+X,W),A,B)'
5163 @end example
5164
5165 @item
5166 Apply uncover down effect:
5167 @example
5168 blend=all_expr='if(gte(Y-N*SH,0),A,B)'
5169 @end example
5170
5171 @item
5172 Apply uncover up-left effect:
5173 @example
5174 blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
5175 @end example
5176
5177 @item
5178 Split diagonally video and shows top and bottom layer on each side:
5179 @example
5180 blend=all_expr='if(gt(X,Y*(W/H)),A,B)'
5181 @end example
5182
5183 @item
5184 Display differences between the current and the previous frame:
5185 @example
5186 tblend=all_mode=grainextract
5187 @end example
5188 @end itemize
5189
5190 @section boxblur
5191
5192 Apply a boxblur algorithm to the input video.
5193
5194 It accepts the following parameters:
5195
5196 @table @option
5197
5198 @item luma_radius, lr
5199 @item luma_power, lp
5200 @item chroma_radius, cr
5201 @item chroma_power, cp
5202 @item alpha_radius, ar
5203 @item alpha_power, ap
5204
5205 @end table
5206
5207 A description of the accepted options follows.
5208
5209 @table @option
5210 @item luma_radius, lr
5211 @item chroma_radius, cr
5212 @item alpha_radius, ar
5213 Set an expression for the box radius in pixels used for blurring the
5214 corresponding input plane.
5215
5216 The radius value must be a non-negative number, and must not be
5217 greater than the value of the expression @code{min(w,h)/2} for the
5218 luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
5219 planes.
5220
5221 Default value for @option{luma_radius} is "2". If not specified,
5222 @option{chroma_radius} and @option{alpha_radius} default to the
5223 corresponding value set for @option{luma_radius}.
5224
5225 The expressions can contain the following constants:
5226 @table @option
5227 @item w
5228 @item h
5229 The input width and height in pixels.
5230
5231 @item cw
5232 @item ch
5233 The input chroma image width and height in pixels.
5234
5235 @item hsub
5236 @item vsub
5237 The horizontal and vertical chroma subsample values. For example, for the
5238 pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
5239 @end table
5240
5241 @item luma_power, lp
5242 @item chroma_power, cp
5243 @item alpha_power, ap
5244 Specify how many times the boxblur filter is applied to the
5245 corresponding plane.
5246
5247 Default value for @option{luma_power} is 2. If not specified,
5248 @option{chroma_power} and @option{alpha_power} default to the
5249 corresponding value set for @option{luma_power}.
5250
5251 A value of 0 will disable the effect.
5252 @end table
5253
5254 @subsection Examples
5255
5256 @itemize
5257 @item
5258 Apply a boxblur filter with the luma, chroma, and alpha radii
5259 set to 2:
5260 @example
5261 boxblur=luma_radius=2:luma_power=1
5262 boxblur=2:1
5263 @end example
5264
5265 @item
5266 Set the luma radius to 2, and alpha and chroma radius to 0:
5267 @example
5268 boxblur=2:1:cr=0:ar=0
5269 @end example
5270
5271 @item
5272 Set the luma and chroma radii to a fraction of the video dimension:
5273 @example
5274 boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
5275 @end example
5276 @end itemize
5277
5278 @section bwdif
5279
5280 Deinterlace the input video ("bwdif" stands for "Bob Weaver
5281 Deinterlacing Filter").
5282
5283 Motion adaptive deinterlacing based on yadif with the use of w3fdif and cubic
5284 interpolation algorithms.
5285 It accepts the following parameters:
5286
5287 @table @option
5288 @item mode
5289 The interlacing mode to adopt. It accepts one of the following values:
5290
5291 @table @option
5292 @item 0, send_frame
5293 Output one frame for each frame.
5294 @item 1, send_field
5295 Output one frame for each field.
5296 @end table
5297
5298 The default value is @code{send_field}.
5299
5300 @item parity
5301 The picture field parity assumed for the input interlaced video. It accepts one
5302 of the following values:
5303
5304 @table @option
5305 @item 0, tff
5306 Assume the top field is first.
5307 @item 1, bff
5308 Assume the bottom field is first.
5309 @item -1, auto
5310 Enable automatic detection of field parity.
5311 @end table
5312
5313 The default value is @code{auto}.
5314 If the interlacing is unknown or the decoder does not export this information,
5315 top field first will be assumed.
5316
5317 @item deint
5318 Specify which frames to deinterlace. Accept one of the following
5319 values:
5320
5321 @table @option
5322 @item 0, all
5323 Deinterlace all frames.
5324 @item 1, interlaced
5325 Only deinterlace frames marked as interlaced.
5326 @end table
5327
5328 The default value is @code{all}.
5329 @end table
5330
5331 @section chromakey
5332 YUV colorspace color/chroma keying.
5333
5334 The filter accepts the following options:
5335
5336 @table @option
5337 @item color
5338 The color which will be replaced with transparency.
5339
5340 @item similarity
5341 Similarity percentage with the key color.
5342
5343 0.01 matches only the exact key color, while 1.0 matches everything.
5344
5345 @item blend
5346 Blend percentage.
5347
5348 0.0 makes pixels either fully transparent, or not transparent at all.
5349
5350 Higher values result in semi-transparent pixels, with a higher transparency
5351 the more similar the pixels color is to the key color.
5352
5353 @item yuv
5354 Signals that the color passed is already in YUV instead of RGB.
5355
5356 Literal colors like "green" or "red" don't make sense with this enabled anymore.
5357 This can be used to pass exact YUV values as hexadecimal numbers.
5358 @end table
5359
5360 @subsection Examples
5361
5362 @itemize
5363 @item
5364 Make every green pixel in the input image transparent:
5365 @example
5366 ffmpeg -i input.png -vf chromakey=green out.png
5367 @end example
5368
5369 @item
5370 Overlay a greenscreen-video on top of a static black background.
5371 @example
5372 ffmpeg -f lavfi -i color=c=black:s=1280x720 -i video.mp4 -shortest -filter_complex "[1:v]chromakey=0x70de77:0.1:0.2[ckout];[0:v][ckout]overlay[out]" -map "[out]" output.mkv
5373 @end example
5374 @end itemize
5375
5376 @section ciescope
5377
5378 Display CIE color diagram with pixels overlaid onto it.
5379
5380 The filter accepts the following options:
5381
5382 @table @option
5383 @item system
5384 Set color system.
5385
5386 @table @samp
5387 @item ntsc, 470m
5388 @item ebu, 470bg
5389 @item smpte
5390 @item 240m
5391 @item apple
5392 @item widergb
5393 @item cie1931
5394 @item rec709, hdtv
5395 @item uhdtv, rec2020
5396 @end table
5397
5398 @item cie
5399 Set CIE system.
5400
5401 @table @samp
5402 @item xyy
5403 @item ucs
5404 @item luv
5405 @end table
5406
5407 @item gamuts
5408 Set what gamuts to draw.
5409
5410 See @code{system} option for available values.
5411
5412 @item size, s
5413 Set ciescope size, by default set to 512.
5414
5415 @item intensity, i
5416 Set intensity used to map input pixel values to CIE diagram.
5417
5418 @item contrast
5419 Set contrast used to draw tongue colors that are out of active color system gamut.
5420
5421 @item corrgamma
5422 Correct gamma displayed on scope, by default enabled.
5423
5424 @item showwhite
5425 Show white point on CIE diagram, by default disabled.
5426
5427 @item gamma
5428 Set input gamma. Used only with XYZ input color space.
5429 @end table
5430
5431 @section codecview
5432
5433 Visualize information exported by some codecs.
5434
5435 Some codecs can export information through frames using side-data or other
5436 means. For example, some MPEG based codecs export motion vectors through the
5437 @var{export_mvs} flag in the codec @option{flags2} option.
5438
5439 The filter accepts the following option:
5440
5441 @table @option
5442 @item mv
5443 Set motion vectors to visualize.
5444
5445 Available flags for @var{mv} are:
5446
5447 @table @samp
5448 @item pf
5449 forward predicted MVs of P-frames
5450 @item bf
5451 forward predicted MVs of B-frames
5452 @item bb
5453 backward predicted MVs of B-frames
5454 @end table
5455
5456 @item qp
5457 Display quantization parameters using the chroma planes.
5458
5459 @item mv_type, mvt
5460 Set motion vectors type to visualize. Includes MVs from all frames unless specified by @var{frame_type} option.
5461
5462 Available flags for @var{mv_type} are:
5463
5464 @table @samp
5465 @item fp
5466 forward predicted MVs
5467 @item bp
5468 backward predicted MVs
5469 @end table
5470
5471 @item frame_type, ft
5472 Set frame type to visualize motion vectors of.
5473
5474 Available flags for @var{frame_type} are:
5475
5476 @table @samp
5477 @item if
5478 intra-coded frames (I-frames)
5479 @item pf
5480 predicted frames (P-frames)
5481 @item bf
5482 bi-directionally predicted frames (B-frames)
5483 @end table
5484 @end table
5485
5486 @subsection Examples
5487
5488 @itemize
5489 @item
5490 Visualize forward predicted MVs of all frames using @command{ffplay}:
5491 @example
5492 ffplay -flags2 +export_mvs input.mp4 -vf codecview=mv_type=fp
5493 @end example
5494
5495 @item
5496 Visualize multi-directionals MVs of P and B-Frames using @command{ffplay}:
5497 @example
5498 ffplay -flags2 +export_mvs input.mp4 -vf codecview=mv=pf+bf+bb
5499 @end example
5500 @end itemize
5501
5502 @section colorbalance
5503 Modify intensity of primary colors (red, green and blue) of input frames.
5504
5505 The filter allows an input frame to be adjusted in the shadows, midtones or highlights
5506 regions for the red-cyan, green-magenta or blue-yellow balance.
5507
5508 A positive adjustment value shifts the balance towards the primary color, a negative
5509 value towards the complementary color.
5510
5511 The filter accepts the following options:
5512
5513 @table @option
5514 @item rs
5515 @item gs
5516 @item bs
5517 Adjust red, green and blue shadows (darkest pixels).
5518
5519 @item rm
5520 @item gm
5521 @item bm
5522 Adjust red, green and blue midtones (medium pixels).
5523
5524 @item rh
5525 @item gh
5526 @item bh
5527 Adjust red, green and blue highlights (brightest pixels).
5528
5529 Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
5530 @end table
5531
5532 @subsection Examples
5533
5534 @itemize
5535 @item
5536 Add red color cast to shadows:
5537 @example
5538 colorbalance=rs=.3
5539 @end example
5540 @end itemize
5541
5542 @section colorkey
5543 RGB colorspace color keying.
5544
5545 The filter accepts the following options:
5546
5547 @table @option
5548 @item color
5549 The color which will be replaced with transparency.
5550
5551 @item similarity
5552 Similarity percentage with the key color.
5553
5554 0.01 matches only the exact key color, while 1.0 matches everything.
5555
5556 @item blend
5557 Blend percentage.
5558
5559 0.0 makes pixels either fully transparent, or not transparent at all.
5560
5561 Higher values result in semi-transparent pixels, with a higher transparency
5562 the more similar the pixels color is to the key color.
5563 @end table
5564
5565 @subsection Examples
5566
5567 @itemize
5568 @item
5569 Make every green pixel in the input image transparent:
5570 @example
5571 ffmpeg -i input.png -vf colorkey=green out.png
5572 @end example
5573
5574 @item
5575 Overlay a greenscreen-video on top of a static background image.
5576 @example
5577 ffmpeg -i background.png -i video.mp4 -filter_complex "[1:v]colorkey=0x3BBD1E:0.3:0.2[ckout];[0:v][ckout]overlay[out]" -map "[out]" output.flv
5578 @end example
5579 @end itemize
5580
5581 @section colorlevels
5582
5583 Adjust video input frames using levels.
5584
5585 The filter accepts the following options:
5586
5587 @table @option
5588 @item rimin
5589 @item gimin
5590 @item bimin
5591 @item aimin
5592 Adjust red, green, blue and alpha input black point.
5593 Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
5594
5595 @item rimax
5596 @item gimax
5597 @item bimax
5598 @item aimax
5599 Adjust red, green, blue and alpha input white point.
5600 Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
5601
5602 Input levels are used to lighten highlights (bright tones), darken shadows
5603 (dark tones), change the balance of bright and dark tones.
5604
5605 @item romin
5606 @item gomin
5607 @item bomin
5608 @item aomin
5609 Adjust red, green, blue and alpha output black point.
5610 Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
5611
5612 @item romax
5613 @item gomax
5614 @item bomax
5615 @item aomax
5616 Adjust red, green, blue and alpha output white point.
5617 Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
5618
5619 Output levels allows manual selection of a constrained output level range.
5620 @end table
5621
5622 @subsection Examples
5623
5624 @itemize
5625 @item
5626 Make video output darker:
5627 @example
5628 colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
5629 @end example
5630
5631 @item
5632 Increase contrast:
5633 @example
5634 colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
5635 @end example
5636
5637 @item
5638 Make video output lighter:
5639 @example
5640 colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
5641 @end example
5642
5643 @item
5644 Increase brightness:
5645 @example
5646 colorlevels=romin=0.5:gomin=0.5:bomin=0.5
5647 @end example
5648 @end itemize
5649
5650 @section colorchannelmixer
5651
5652 Adjust video input frames by re-mixing color channels.
5653
5654 This filter modifies a color channel by adding the values associated to
5655 the other channels of the same pixels. For example if the value to
5656 modify is red, the output value will be:
5657 @example
5658 @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
5659 @end example
5660
5661 The filter accepts the following options:
5662
5663 @table @option
5664 @item rr
5665 @item rg
5666 @item rb
5667 @item ra
5668 Adjust contribution of input red, green, blue and alpha channels for output red channel.
5669 Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
5670
5671 @item gr
5672 @item gg
5673 @item gb
5674 @item ga
5675 Adjust contribution of input red, green, blue and alpha channels for output green channel.
5676 Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
5677
5678 @item br
5679 @item bg
5680 @item bb
5681 @item ba
5682 Adjust contribution of input red, green, blue and alpha channels for output blue channel.
5683 Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
5684
5685 @item ar
5686 @item ag
5687 @item ab
5688 @item aa
5689 Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
5690 Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
5691
5692 Allowed ranges for options are @code{[-2.0, 2.0]}.
5693 @end table
5694
5695 @subsection Examples
5696
5697 @itemize
5698 @item
5699 Convert source to grayscale:
5700 @example
5701 colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
5702 @end example
5703 @item
5704 Simulate sepia tones:
5705 @example
5706 colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
5707 @end example
5708 @end itemize
5709
5710 @section colormatrix
5711
5712 Convert color matrix.
5713
5714 The filter accepts the following options:
5715
5716 @table @option
5717 @item src
5718 @item dst
5719 Specify the source and destination color matrix. Both values must be
5720 specified.
5721
5722 The accepted values are:
5723 @table @samp
5724 @item bt709
5725 BT.709
5726
5727 @item fcc
5728 FCC
5729
5730 @item bt601
5731 BT.601
5732
5733 @item bt470
5734 BT.470
5735
5736 @item bt470bg
5737 BT.470BG
5738
5739 @item smpte170m
5740 SMPTE-170M
5741
5742 @item smpte240m
5743 SMPTE-240M
5744
5745 @item bt2020
5746 BT.2020
5747 @end table
5748 @end table
5749
5750 For example to convert from BT.601 to SMPTE-240M, use the command:
5751 @example
5752 colormatrix=bt601:smpte240m
5753 @end example
5754
5755 @section colorspace
5756
5757 Convert colorspace, transfer characteristics or color primaries.
5758 Input video needs to have an even size.
5759
5760 The filter accepts the following options:
5761
5762 @table @option
5763 @anchor{all}
5764 @item all
5765 Specify all color properties at once.
5766
5767 The accepted values are:
5768 @table @samp
5769 @item bt470m
5770 BT.470M
5771
5772 @item bt470bg
5773 BT.470BG
5774
5775 @item bt601-6-525
5776 BT.601-6 525
5777
5778 @item bt601-6-625
5779 BT.601-6 625
5780
5781 @item bt709
5782 BT.709
5783
5784 @item smpte170m
5785 SMPTE-170M
5786
5787 @item smpte240m
5788 SMPTE-240M
5789
5790 @item bt2020
5791 BT.2020
5792
5793 @end table
5794
5795 @anchor{space}
5796 @item space
5797 Specify output colorspace.
5798
5799 The accepted values are:
5800 @table @samp
5801 @item bt709
5802 BT.709
5803
5804 @item fcc
5805 FCC
5806
5807 @item bt470bg
5808 BT.470BG or BT.601-6 625
5809
5810 @item smpte170m
5811 SMPTE-170M or BT.601-6 525
5812
5813 @item smpte240m
5814 SMPTE-240M
5815
5816 @item ycgco
5817 YCgCo
5818
5819 @item bt2020ncl
5820 BT.2020 with non-constant luminance
5821
5822 @end table
5823
5824 @anchor{trc}
5825 @item trc
5826 Specify output transfer characteristics.
5827
5828 The accepted values are:
5829 @table @samp
5830 @item bt709
5831 BT.709
5832
5833 @item bt470m
5834 BT.470M
5835
5836 @item bt470bg
5837 BT.470BG
5838
5839 @item gamma22
5840 Constant gamma of 2.2
5841
5842 @item gamma28
5843 Constant gamma of 2.8
5844
5845 @item smpte170m
5846 SMPTE-170M, BT.601-6 625 or BT.601-6 525
5847
5848 @item smpte240m
5849 SMPTE-240M
5850
5851 @item srgb
5852 SRGB
5853
5854 @item iec61966-2-1
5855 iec61966-2-1
5856
5857 @item iec61966-2-4
5858 iec61966-2-4
5859
5860 @item xvycc
5861 xvycc
5862
5863 @item bt2020-10
5864 BT.2020 for 10-bits content
5865
5866 @item bt2020-12
5867 BT.2020 for 12-bits content
5868
5869 @end table
5870
5871 @anchor{primaries}
5872 @item primaries
5873 Specify output color primaries.
5874
5875 The accepted values are:
5876 @table @samp
5877 @item bt709
5878 BT.709
5879
5880 @item bt470m
5881 BT.470M
5882
5883 @item bt470bg
5884 BT.470BG or BT.601-6 625
5885
5886 @item smpte170m
5887 SMPTE-170M or BT.601-6 525
5888
5889 @item smpte240m
5890 SMPTE-240M
5891
5892 @item film
5893 film
5894
5895 @item smpte431
5896 SMPTE-431
5897
5898 @item smpte432
5899 SMPTE-432
5900
5901 @item bt2020
5902 BT.2020
5903
5904 @item jedec-p22
5905 JEDEC P22 phosphors
5906
5907 @end table
5908
5909 @anchor{range}
5910 @item range
5911 Specify output color range.
5912
5913 The accepted values are:
5914 @table @samp
5915 @item tv
5916 TV (restricted) range
5917
5918 @item mpeg
5919 MPEG (restricted) range
5920
5921 @item pc
5922 PC (full) range
5923
5924 @item jpeg
5925 JPEG (full) range
5926
5927 @end table
5928
5929 @item format
5930 Specify output color format.
5931
5932 The accepted values are:
5933 @table @samp
5934 @item yuv420p
5935 YUV 4:2:0 planar 8-bits
5936
5937 @item yuv420p10
5938 YUV 4:2:0 planar 10-bits
5939
5940 @item yuv420p12
5941 YUV 4:2:0 planar 12-bits
5942
5943 @item yuv422p
5944 YUV 4:2:2 planar 8-bits
5945
5946 @item yuv422p10
5947 YUV 4:2:2 planar 10-bits
5948
5949 @item yuv422p12
5950 YUV 4:2:2 planar 12-bits
5951
5952 @item yuv444p
5953 YUV 4:4:4 planar 8-bits
5954
5955 @item yuv444p10
5956 YUV 4:4:4 planar 10-bits
5957
5958 @item yuv444p12
5959 YUV 4:4:4 planar 12-bits
5960
5961 @end table
5962
5963 @item fast
5964 Do a fast conversion, which skips gamma/primary correction. This will take
5965 significantly less CPU, but will be mathematically incorrect. To get output
5966 compatible with that produced by the colormatrix filter, use fast=1.
5967
5968 @item dither
5969 Specify dithering mode.
5970
5971 The accepted values are:
5972 @table @samp
5973 @item none
5974 No dithering
5975
5976 @item fsb
5977 Floyd-Steinberg dithering
5978 @end table
5979
5980 @item wpadapt
5981 Whitepoint adaptation mode.
5982
5983 The accepted values are:
5984 @table @samp
5985 @item bradford
5986 Bradford whitepoint adaptation
5987
5988 @item vonkries
5989 von Kries whitepoint adaptation
5990
5991 @item identity
5992 identity whitepoint adaptation (i.e. no whitepoint adaptation)
5993 @end table
5994
5995 @item iall
5996 Override all input properties at once. Same accepted values as @ref{all}.
5997
5998 @item ispace
5999 Override input colorspace. Same accepted values as @ref{space}.
6000
6001 @item iprimaries
6002 Override input color primaries. Same accepted values as @ref{primaries}.
6003
6004 @item itrc
6005 Override input transfer characteristics. Same accepted values as @ref{trc}.
6006
6007 @item irange
6008 Override input color range. Same accepted values as @ref{range}.
6009
6010 @end table
6011
6012 The filter converts the transfer characteristics, color space and color
6013 primaries to the specified user values. The output value, if not specified,
6014 is set to a default value based on the "all" property. If that property is
6015 also not specified, the filter will log an error. The output color range and
6016 format default to the same value as the input color range and format. The
6017 input transfer characteristics, color space, color primaries and color range
6018 should be set on the input data. If any of these are missing, the filter will
6019 log an error and no conversion will take place.
6020
6021 For example to convert the input to SMPTE-240M, use the command:
6022 @example
6023 colorspace=smpte240m
6024 @end example
6025
6026 @section convolution
6027
6028 Apply convolution 3x3, 5x5 or 7x7 filter.
6029
6030 The filter accepts the following options:
6031
6032 @table @option
6033 @item 0m
6034 @item 1m
6035 @item 2m
6036 @item 3m
6037 Set matrix for each plane.
6038 Matrix is sequence of 9, 25 or 49 signed integers.
6039
6040 @item 0rdiv
6041 @item 1rdiv
6042 @item 2rdiv
6043 @item 3rdiv
6044 Set multiplier for calculated value for each plane.
6045
6046 @item 0bias
6047 @item 1bias
6048 @item 2bias
6049 @item 3bias
6050 Set bias for each plane. This value is added to the result of the multiplication.
6051 Useful for making the overall image brighter or darker. Default is 0.0.
6052 @end table
6053
6054 @subsection Examples
6055
6056 @itemize
6057 @item
6058 Apply sharpen:
6059 @example
6060 convolution="0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0"
6061 @end example
6062
6063 @item
6064 Apply blur:
6065 @example
6066 convolution="1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1/9:1/9:1/9:1/9"
6067 @end example
6068
6069 @item
6070 Apply edge enhance:
6071 @example
6072 convolution="0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:5:1:1:1:0:128:128:128"
6073 @end example
6074
6075 @item
6076 Apply edge detect:
6077 @example
6078 convolution="0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:5:5:5:1:0:128:128:128"
6079 @end example
6080
6081 @item
6082 Apply laplacian edge detector which includes diagonals:
6083 @example
6084 convolution="1 1 1 1 -8 1 1 1 1:1 1 1 1 -8 1 1 1 1:1 1 1 1 -8 1 1 1 1:1 1 1 1 -8 1 1 1 1:5:5:5:1:0:128:128:0"
6085 @end example
6086
6087 @item
6088 Apply emboss:
6089 @example
6090 convolution="-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2"
6091 @end example
6092 @end itemize
6093
6094 @section convolve
6095
6096 Apply 2D convolution of video stream in frequency domain using second stream
6097 as impulse.
6098
6099 The filter accepts the following options:
6100
6101 @table @option
6102 @item planes
6103 Set which planes to process.
6104
6105 @item impulse
6106 Set which impulse video frames will be processed, can be @var{first}
6107 or @var{all}. Default is @var{all}.
6108 @end table
6109
6110 The @code{convolve} filter also supports the @ref{framesync} options.
6111
6112 @section copy
6113
6114 Copy the input video source unchanged to the output. This is mainly useful for
6115 testing purposes.
6116
6117 @anchor{coreimage}
6118 @section coreimage
6119 Video filtering on GPU using Apple's CoreImage API on OSX.
6120
6121 Hardware acceleration is based on an OpenGL context. Usually, this means it is
6122 processed by video hardware. However, software-based OpenGL implementations
6123 exist which means there is no guarantee for hardware processing. It depends on
6124 the respective OSX.
6125
6126 There are many filters and image generators provided by Apple that come with a
6127 large variety of options. The filter has to be referenced by its name along
6128 with its options.
6129
6130 The coreimage filter accepts the following options:
6131 @table @option
6132 @item list_filters
6133 List all available filters and generators along with all their respective
6134 options as well as possible minimum and maximum values along with the default
6135 values.
6136 @example
6137 list_filters=true
6138 @end example
6139
6140 @item filter
6141 Specify all filters by their respective name and options.
6142 Use @var{list_filters} to determine all valid filter names and options.
6143 Numerical options are specified by a float value and are automatically clamped
6144 to their respective value range.  Vector and color options have to be specified
6145 by a list of space separated float values. Character escaping has to be done.
6146 A special option name @code{default} is available to use default options for a
6147 filter.
6148
6149 It is required to specify either @code{default} or at least one of the filter options.
6150 All omitted options are used with their default values.
6151 The syntax of the filter string is as follows:
6152 @example
6153 filter=<NAME>@@<OPTION>=<VALUE>[@@<OPTION>=<VALUE>][@@...][#<NAME>@@<OPTION>=<VALUE>[@@<OPTION>=<VALUE>][@@...]][#...]
6154 @end example
6155
6156 @item output_rect
6157 Specify a rectangle where the output of the filter chain is copied into the
6158 input image. It is given by a list of space separated float values:
6159 @example
6160 output_rect=x\ y\ width\ height
6161 @end example
6162 If not given, the output rectangle equals the dimensions of the input image.
6163 The output rectangle is automatically cropped at the borders of the input
6164 image. Negative values are valid for each component.
6165 @example
6166 output_rect=25\ 25\ 100\ 100
6167 @end example
6168 @end table
6169
6170 Several filters can be chained for successive processing without GPU-HOST
6171 transfers allowing for fast processing of complex filter chains.
6172 Currently, only filters with zero (generators) or exactly one (filters) input
6173 image and one output image are supported. Also, transition filters are not yet
6174 usable as intended.
6175
6176 Some filters generate output images with additional padding depending on the
6177 respective filter kernel. The padding is automatically removed to ensure the
6178 filter output has the same size as the input image.
6179
6180 For image generators, the size of the output image is determined by the
6181 previous output image of the filter chain or the input image of the whole
6182 filterchain, respectively. The generators do not use the pixel information of
6183 this image to generate their output. However, the generated output is
6184 blended onto this image, resulting in partial or complete coverage of the
6185 output image.
6186
6187 The @ref{coreimagesrc} video source can be used for generating input images
6188 which are directly fed into the filter chain. By using it, providing input
6189 images by another video source or an input video is not required.
6190
6191 @subsection Examples
6192
6193 @itemize
6194
6195 @item
6196 List all filters available:
6197 @example
6198 coreimage=list_filters=true
6199 @end example
6200
6201 @item
6202 Use the CIBoxBlur filter with default options to blur an image:
6203 @example
6204 coreimage=filter=CIBoxBlur@@default
6205 @end example
6206
6207 @item
6208 Use a filter chain with CISepiaTone at default values and CIVignetteEffect with
6209 its center at 100x100 and a radius of 50 pixels:
6210 @example
6211 coreimage=filter=CIBoxBlur@@default#CIVignetteEffect@@inputCenter=100\ 100@@inputRadius=50
6212 @end example
6213
6214 @item
6215 Use nullsrc and CIQRCodeGenerator to create a QR code for the FFmpeg homepage,
6216 given as complete and escaped command-line for Apple's standard bash shell:
6217 @example
6218 ffmpeg -f lavfi -i nullsrc=s=100x100,coreimage=filter=CIQRCodeGenerator@@inputMessage=https\\\\\://FFmpeg.org/@@inputCorrectionLevel=H -frames:v 1 QRCode.png
6219 @end example
6220 @end itemize
6221
6222 @section crop
6223
6224 Crop the input video to given dimensions.
6225
6226 It accepts the following parameters:
6227
6228 @table @option
6229 @item w, out_w
6230 The width of the output video. It defaults to @code{iw}.
6231 This expression is evaluated only once during the filter
6232 configuration, or when the @samp{w} or @samp{out_w} command is sent.
6233
6234 @item h, out_h
6235 The height of the output video. It defaults to @code{ih}.
6236 This expression is evaluated only once during the filter
6237 configuration, or when the @samp{h} or @samp{out_h} command is sent.
6238
6239 @item x
6240 The horizontal position, in the input video, of the left edge of the output
6241 video. It defaults to @code{(in_w-out_w)/2}.
6242 This expression is evaluated per-frame.
6243
6244 @item y
6245 The vertical position, in the input video, of the top edge of the output video.
6246 It defaults to @code{(in_h-out_h)/2}.
6247 This expression is evaluated per-frame.
6248
6249 @item keep_aspect
6250 If set to 1 will force the output display aspect ratio
6251 to be the same of the input, by changing the output sample aspect
6252 ratio. It defaults to 0.
6253
6254 @item exact
6255 Enable exact cropping. If enabled, subsampled videos will be cropped at exact
6256 width/height/x/y as specified and will not be rounded to nearest smaller value.
6257 It defaults to 0.
6258 @end table
6259
6260 The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
6261 expressions containing the following constants:
6262
6263 @table @option
6264 @item x
6265 @item y
6266 The computed values for @var{x} and @var{y}. They are evaluated for
6267 each new frame.
6268
6269 @item in_w
6270 @item in_h
6271 The input width and height.
6272
6273 @item iw
6274 @item ih
6275 These are the same as @var{in_w} and @var{in_h}.
6276
6277 @item out_w
6278 @item out_h
6279 The output (cropped) width and height.
6280
6281 @item ow
6282 @item oh
6283 These are the same as @var{out_w} and @var{out_h}.
6284
6285 @item a
6286 same as @var{iw} / @var{ih}
6287
6288 @item sar
6289 input sample aspect ratio
6290
6291 @item dar
6292 input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
6293
6294 @item hsub
6295 @item vsub
6296 horizontal and vertical chroma subsample values. For example for the
6297 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
6298
6299 @item n
6300 The number of the input frame, starting from 0.
6301
6302 @item pos
6303 the position in the file of the input frame, NAN if unknown
6304
6305 @item t
6306 The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
6307
6308 @end table
6309
6310 The expression for @var{out_w} may depend on the value of @var{out_h},
6311 and the expression for @var{out_h} may depend on @var{out_w}, but they
6312 cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
6313 evaluated after @var{out_w} and @var{out_h}.
6314
6315 The @var{x} and @var{y} parameters specify the expressions for the
6316 position of the top-left corner of the output (non-cropped) area. They
6317 are evaluated for each frame. If the evaluated value is not valid, it
6318 is approximated to the nearest valid value.
6319
6320 The expression for @var{x} may depend on @var{y}, and the expression
6321 for @var{y} may depend on @var{x}.
6322
6323 @subsection Examples
6324
6325 @itemize
6326 @item
6327 Crop area with size 100x100 at position (12,34).
6328 @example
6329 crop=100:100:12:34
6330 @end example
6331
6332 Using named options, the example above becomes:
6333 @example
6334 crop=w=100:h=100:x=12:y=34
6335 @end example
6336
6337 @item
6338 Crop the central input area with size 100x100:
6339 @example
6340 crop=100:100
6341 @end example
6342
6343 @item
6344 Crop the central input area with size 2/3 of the input video:
6345 @example
6346 crop=2/3*in_w:2/3*in_h
6347 @end example
6348
6349 @item
6350 Crop the input video central square:
6351 @example
6352 crop=out_w=in_h
6353 crop=in_h
6354 @end example
6355
6356 @item
6357 Delimit the rectangle with the top-left corner placed at position
6358 100:100 and the right-bottom corner corresponding to the right-bottom
6359 corner of the input image.
6360 @example
6361 crop=in_w-100:in_h-100:100:100
6362 @end example
6363
6364 @item
6365 Crop 10 pixels from the left and right borders, and 20 pixels from
6366 the top and bottom borders
6367 @example
6368 crop=in_w-2*10:in_h-2*20
6369 @end example
6370
6371 @item
6372 Keep only the bottom right quarter of the input image:
6373 @example
6374 crop=in_w/2:in_h/2:in_w/2:in_h/2
6375 @end example
6376
6377 @item
6378 Crop height for getting Greek harmony:
6379 @example
6380 crop=in_w:1/PHI*in_w
6381 @end example
6382
6383 @item
6384 Apply trembling effect:
6385 @example
6386 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)
6387 @end example
6388
6389 @item
6390 Apply erratic camera effect depending on timestamp:
6391 @example
6392 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)"
6393 @end example
6394
6395 @item
6396 Set x depending on the value of y:
6397 @example
6398 crop=in_w/2:in_h/2:y:10+10*sin(n/10)
6399 @end example
6400 @end itemize
6401
6402 @subsection Commands
6403
6404 This filter supports the following commands:
6405 @table @option
6406 @item w, out_w
6407 @item h, out_h
6408 @item x
6409 @item y
6410 Set width/height of the output video and the horizontal/vertical position
6411 in the input video.
6412 The command accepts the same syntax of the corresponding option.
6413
6414 If the specified expression is not valid, it is kept at its current
6415 value.
6416 @end table
6417
6418 @section cropdetect
6419
6420 Auto-detect the crop size.
6421
6422 It calculates the necessary cropping parameters and prints the
6423 recommended parameters via the logging system. The detected dimensions
6424 correspond to the non-black area of the input video.
6425
6426 It accepts the following parameters:
6427
6428 @table @option
6429
6430 @item limit
6431 Set higher black value threshold, which can be optionally specified
6432 from nothing (0) to everything (255 for 8-bit based formats). An intensity
6433 value greater to the set value is considered non-black. It defaults to 24.
6434 You can also specify a value between 0.0 and 1.0 which will be scaled depending
6435 on the bitdepth of the pixel format.
6436
6437 @item round
6438 The value which the width/height should be divisible by. It defaults to
6439 16. The offset is automatically adjusted to center the video. Use 2 to
6440 get only even dimensions (needed for 4:2:2 video). 16 is best when
6441 encoding to most video codecs.
6442
6443 @item reset_count, reset
6444 Set the counter that determines after how many frames cropdetect will
6445 reset the previously detected largest video area and start over to
6446 detect the current optimal crop area. Default value is 0.
6447
6448 This can be useful when channel logos distort the video area. 0
6449 indicates 'never reset', and returns the largest area encountered during
6450 playback.
6451 @end table
6452
6453 @anchor{curves}
6454 @section curves
6455
6456 Apply color adjustments using curves.
6457
6458 This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
6459 component (red, green and blue) has its values defined by @var{N} key points
6460 tied from each other using a smooth curve. The x-axis represents the pixel
6461 values from the input frame, and the y-axis the new pixel values to be set for
6462 the output frame.
6463
6464 By default, a component curve is defined by the two points @var{(0;0)} and
6465 @var{(1;1)}. This creates a straight line where each original pixel value is
6466 "adjusted" to its own value, which means no change to the image.
6467
6468 The filter allows you to redefine these two points and add some more. A new
6469 curve (using a natural cubic spline interpolation) will be define to pass
6470 smoothly through all these new coordinates. The new defined points needs to be
6471 strictly increasing over the x-axis, and their @var{x} and @var{y} values must
6472 be in the @var{[0;1]} interval.  If the computed curves happened to go outside
6473 the vector spaces, the values will be clipped accordingly.
6474
6475 The filter accepts the following options:
6476
6477 @table @option
6478 @item preset
6479 Select one of the available color presets. This option can be used in addition
6480 to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
6481 options takes priority on the preset values.
6482 Available presets are:
6483 @table @samp
6484 @item none
6485 @item color_negative
6486 @item cross_process
6487 @item darker
6488 @item increase_contrast
6489 @item lighter
6490 @item linear_contrast
6491 @item medium_contrast
6492 @item negative
6493 @item strong_contrast
6494 @item vintage
6495 @end table
6496 Default is @code{none}.
6497 @item master, m
6498 Set the master key points. These points will define a second pass mapping. It
6499 is sometimes called a "luminance" or "value" mapping. It can be used with
6500 @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
6501 post-processing LUT.
6502 @item red, r
6503 Set the key points for the red component.
6504 @item green, g
6505 Set the key points for the green component.
6506 @item blue, b
6507 Set the key points for the blue component.
6508 @item all
6509 Set the key points for all components (not including master).
6510 Can be used in addition to the other key points component
6511 options. In this case, the unset component(s) will fallback on this
6512 @option{all} setting.
6513 @item psfile
6514 Specify a Photoshop curves file (@code{.acv}) to import the settings from.
6515 @item plot
6516 Save Gnuplot script of the curves in specified file.
6517 @end table
6518
6519 To avoid some filtergraph syntax conflicts, each key points list need to be
6520 defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
6521
6522 @subsection Examples
6523
6524 @itemize
6525 @item
6526 Increase slightly the middle level of blue:
6527 @example
6528 curves=blue='0/0 0.5/0.58 1/1'
6529 @end example
6530
6531 @item
6532 Vintage effect:
6533 @example
6534 curves=r='0/0.11 .42/.51 1/0.95':g='0/0 0.50/0.48 1/1':b='0/0.22 .49/.44 1/0.8'
6535 @end example
6536 Here we obtain the following coordinates for each components:
6537 @table @var
6538 @item red
6539 @code{(0;0.11) (0.42;0.51) (1;0.95)}
6540 @item green
6541 @code{(0;0) (0.50;0.48) (1;1)}
6542 @item blue
6543 @code{(0;0.22) (0.49;0.44) (1;0.80)}
6544 @end table
6545
6546 @item
6547 The previous example can also be achieved with the associated built-in preset:
6548 @example
6549 curves=preset=vintage
6550 @end example
6551
6552 @item
6553 Or simply:
6554 @example
6555 curves=vintage
6556 @end example
6557
6558 @item
6559 Use a Photoshop preset and redefine the points of the green component:
6560 @example
6561 curves=psfile='MyCurvesPresets/purple.acv':green='0/0 0.45/0.53 1/1'
6562 @end example
6563
6564 @item
6565 Check out the curves of the @code{cross_process} profile using @command{ffmpeg}
6566 and @command{gnuplot}:
6567 @example
6568 ffmpeg -f lavfi -i color -vf curves=cross_process:plot=/tmp/curves.plt -frames:v 1 -f null -
6569 gnuplot -p /tmp/curves.plt
6570 @end example
6571 @end itemize
6572
6573 @section datascope
6574
6575 Video data analysis filter.
6576
6577 This filter shows hexadecimal pixel values of part of video.
6578
6579 The filter accepts the following options:
6580
6581 @table @option
6582 @item size, s
6583 Set output video size.
6584
6585 @item x
6586 Set x offset from where to pick pixels.
6587
6588 @item y
6589 Set y offset from where to pick pixels.
6590
6591 @item mode
6592 Set scope mode, can be one of the following:
6593 @table @samp
6594 @item mono
6595 Draw hexadecimal pixel values with white color on black background.
6596
6597 @item color
6598 Draw hexadecimal pixel values with input video pixel color on black
6599 background.
6600
6601 @item color2
6602 Draw hexadecimal pixel values on color background picked from input video,
6603 the text color is picked in such way so its always visible.
6604 @end table
6605
6606 @item axis
6607 Draw rows and columns numbers on left and top of video.
6608
6609 @item opacity
6610 Set background opacity.
6611 @end table
6612
6613 @section dctdnoiz
6614
6615 Denoise frames using 2D DCT (frequency domain filtering).
6616
6617 This filter is not designed for real time.
6618
6619 The filter accepts the following options:
6620
6621 @table @option
6622 @item sigma, s
6623 Set the noise sigma constant.
6624
6625 This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
6626 coefficient (absolute value) below this threshold with be dropped.
6627
6628 If you need a more advanced filtering, see @option{expr}.
6629
6630 Default is @code{0}.
6631
6632 @item overlap
6633 Set number overlapping pixels for each block. Since the filter can be slow, you
6634 may want to reduce this value, at the cost of a less effective filter and the
6635 risk of various artefacts.
6636
6637 If the overlapping value doesn't permit processing the whole input width or
6638 height, a warning will be displayed and according borders won't be denoised.
6639
6640 Default value is @var{blocksize}-1, which is the best possible setting.
6641
6642 @item expr, e
6643 Set the coefficient factor expression.
6644
6645 For each coefficient of a DCT block, this expression will be evaluated as a
6646 multiplier value for the coefficient.
6647
6648 If this is option is set, the @option{sigma} option will be ignored.
6649
6650 The absolute value of the coefficient can be accessed through the @var{c}
6651 variable.
6652
6653 @item n
6654 Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
6655 @var{blocksize}, which is the width and height of the processed blocks.
6656
6657 The default value is @var{3} (8x8) and can be raised to @var{4} for a
6658 @var{blocksize} of 16x16. Note that changing this setting has huge consequences
6659 on the speed processing. Also, a larger block size does not necessarily means a
6660 better de-noising.
6661 @end table
6662
6663 @subsection Examples
6664
6665 Apply a denoise with a @option{sigma} of @code{4.5}:
6666 @example
6667 dctdnoiz=4.5
6668 @end example
6669
6670 The same operation can be achieved using the expression system:
6671 @example
6672 dctdnoiz=e='gte(c, 4.5*3)'
6673 @end example
6674
6675 Violent denoise using a block size of @code{16x16}:
6676 @example
6677 dctdnoiz=15:n=4
6678 @end example
6679
6680 @section deband
6681
6682 Remove banding artifacts from input video.
6683 It works by replacing banded pixels with average value of referenced pixels.
6684
6685 The filter accepts the following options:
6686
6687 @table @option
6688 @item 1thr
6689 @item 2thr
6690 @item 3thr
6691 @item 4thr
6692 Set banding detection threshold for each plane. Default is 0.02.
6693 Valid range is 0.00003 to 0.5.
6694 If difference between current pixel and reference pixel is less than threshold,
6695 it will be considered as banded.
6696
6697 @item range, r
6698 Banding detection range in pixels. Default is 16. If positive, random number
6699 in range 0 to set value will be used. If negative, exact absolute value
6700 will be used.
6701 The range defines square of four pixels around current pixel.
6702
6703 @item direction, d
6704 Set direction in radians from which four pixel will be compared. If positive,
6705 random direction from 0 to set direction will be picked. If negative, exact of
6706 absolute value will be picked. For example direction 0, -PI or -2*PI radians
6707 will pick only pixels on same row and -PI/2 will pick only pixels on same
6708 column.
6709
6710 @item blur, b
6711 If enabled, current pixel is compared with average value of all four
6712 surrounding pixels. The default is enabled. If disabled current pixel is
6713 compared with all four surrounding pixels. The pixel is considered banded
6714 if only all four differences with surrounding pixels are less than threshold.
6715
6716 @item coupling, c
6717 If enabled, current pixel is changed if and only if all pixel components are banded,
6718 e.g. banding detection threshold is triggered for all color components.
6719 The default is disabled.
6720 @end table
6721
6722 @anchor{decimate}
6723 @section decimate
6724
6725 Drop duplicated frames at regular intervals.
6726
6727 The filter accepts the following options:
6728
6729 @table @option
6730 @item cycle
6731 Set the number of frames from which one will be dropped. Setting this to
6732 @var{N} means one frame in every batch of @var{N} frames will be dropped.
6733 Default is @code{5}.
6734
6735 @item dupthresh
6736 Set the threshold for duplicate detection. If the difference metric for a frame
6737 is less than or equal to this value, then it is declared as duplicate. Default
6738 is @code{1.1}
6739
6740 @item scthresh
6741 Set scene change threshold. Default is @code{15}.
6742
6743 @item blockx
6744 @item blocky
6745 Set the size of the x and y-axis blocks used during metric calculations.
6746 Larger blocks give better noise suppression, but also give worse detection of
6747 small movements. Must be a power of two. Default is @code{32}.
6748
6749 @item ppsrc
6750 Mark main input as a pre-processed input and activate clean source input
6751 stream. This allows the input to be pre-processed with various filters to help
6752 the metrics calculation while keeping the frame selection lossless. When set to
6753 @code{1}, the first stream is for the pre-processed input, and the second
6754 stream is the clean source from where the kept frames are chosen. Default is
6755 @code{0}.
6756
6757 @item chroma
6758 Set whether or not chroma is considered in the metric calculations. Default is
6759 @code{1}.
6760 @end table
6761
6762 @section deflate
6763
6764 Apply deflate effect to the video.
6765
6766 This filter replaces the pixel by the local(3x3) average by taking into account
6767 only values lower than the pixel.
6768
6769 It accepts the following options:
6770
6771 @table @option
6772 @item threshold0
6773 @item threshold1
6774 @item threshold2
6775 @item threshold3
6776 Limit the maximum change for each plane, default is 65535.
6777 If 0, plane will remain unchanged.
6778 @end table
6779
6780 @section deflicker
6781
6782 Remove temporal frame luminance variations.
6783
6784 It accepts the following options:
6785
6786 @table @option
6787 @item size, s
6788 Set moving-average filter size in frames. Default is 5. Allowed range is 2 - 129.
6789
6790 @item mode, m
6791 Set averaging mode to smooth temporal luminance variations.
6792
6793 Available values are:
6794 @table @samp
6795 @item am
6796 Arithmetic mean
6797
6798 @item gm
6799 Geometric mean
6800
6801 @item hm
6802 Harmonic mean
6803
6804 @item qm
6805 Quadratic mean
6806
6807 @item cm
6808 Cubic mean
6809
6810 @item pm
6811 Power mean
6812
6813 @item median
6814 Median
6815 @end table
6816
6817 @item bypass
6818 Do not actually modify frame. Useful when one only wants metadata.
6819 @end table
6820
6821 @section dejudder
6822
6823 Remove judder produced by partially interlaced telecined content.
6824
6825 Judder can be introduced, for instance, by @ref{pullup} filter. If the original
6826 source was partially telecined content then the output of @code{pullup,dejudder}
6827 will have a variable frame rate. May change the recorded frame rate of the
6828 container. Aside from that change, this filter will not affect constant frame
6829 rate video.
6830
6831 The option available in this filter is:
6832 @table @option
6833
6834 @item cycle
6835 Specify the length of the window over which the judder repeats.
6836
6837 Accepts any integer greater than 1. Useful values are:
6838 @table @samp
6839
6840 @item 4
6841 If the original was telecined from 24 to 30 fps (Film to NTSC).
6842
6843 @item 5
6844 If the original was telecined from 25 to 30 fps (PAL to NTSC).
6845
6846 @item 20
6847 If a mixture of the two.
6848 @end table
6849
6850 The default is @samp{4}.
6851 @end table
6852
6853 @section delogo
6854
6855 Suppress a TV station logo by a simple interpolation of the surrounding
6856 pixels. Just set a rectangle covering the logo and watch it disappear
6857 (and sometimes something even uglier appear - your mileage may vary).
6858
6859 It accepts the following parameters:
6860 @table @option
6861
6862 @item x
6863 @item y
6864 Specify the top left corner coordinates of the logo. They must be
6865 specified.
6866
6867 @item w
6868 @item h
6869 Specify the width and height of the logo to clear. They must be
6870 specified.
6871
6872 @item band, t
6873 Specify the thickness of the fuzzy edge of the rectangle (added to
6874 @var{w} and @var{h}). The default value is 1. This option is
6875 deprecated, setting higher values should no longer be necessary and
6876 is not recommended.
6877
6878 @item show
6879 When set to 1, a green rectangle is drawn on the screen to simplify
6880 finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
6881 The default value is 0.
6882
6883 The rectangle is drawn on the outermost pixels which will be (partly)
6884 replaced with interpolated values. The values of the next pixels
6885 immediately outside this rectangle in each direction will be used to
6886 compute the interpolated pixel values inside the rectangle.
6887
6888 @end table
6889
6890 @subsection Examples
6891
6892 @itemize
6893 @item
6894 Set a rectangle covering the area with top left corner coordinates 0,0
6895 and size 100x77, and a band of size 10:
6896 @example
6897 delogo=x=0:y=0:w=100:h=77:band=10
6898 @end example
6899
6900 @end itemize
6901
6902 @section deshake
6903
6904 Attempt to fix small changes in horizontal and/or vertical shift. This
6905 filter helps remove camera shake from hand-holding a camera, bumping a
6906 tripod, moving on a vehicle, etc.
6907
6908 The filter accepts the following options:
6909
6910 @table @option
6911
6912 @item x
6913 @item y
6914 @item w
6915 @item h
6916 Specify a rectangular area where to limit the search for motion
6917 vectors.
6918 If desired the search for motion vectors can be limited to a
6919 rectangular area of the frame defined by its top left corner, width
6920 and height. These parameters have the same meaning as the drawbox
6921 filter which can be used to visualise the position of the bounding
6922 box.
6923
6924 This is useful when simultaneous movement of subjects within the frame
6925 might be confused for camera motion by the motion vector search.
6926
6927 If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
6928 then the full frame is used. This allows later options to be set
6929 without specifying the bounding box for the motion vector search.
6930
6931 Default - search the whole frame.
6932
6933 @item rx
6934 @item ry
6935 Specify the maximum extent of movement in x and y directions in the
6936 range 0-64 pixels. Default 16.
6937
6938 @item edge
6939 Specify how to generate pixels to fill blanks at the edge of the
6940 frame. Available values are:
6941 @table @samp
6942 @item blank, 0
6943 Fill zeroes at blank locations
6944 @item original, 1
6945 Original image at blank locations
6946 @item clamp, 2
6947 Extruded edge value at blank locations
6948 @item mirror, 3
6949 Mirrored edge at blank locations
6950 @end table
6951 Default value is @samp{mirror}.
6952
6953 @item blocksize
6954 Specify the blocksize to use for motion search. Range 4-128 pixels,
6955 default 8.
6956
6957 @item contrast
6958 Specify the contrast threshold for blocks. Only blocks with more than
6959 the specified contrast (difference between darkest and lightest
6960 pixels) will be considered. Range 1-255, default 125.
6961
6962 @item search
6963 Specify the search strategy. Available values are:
6964 @table @samp
6965 @item exhaustive, 0
6966 Set exhaustive search
6967 @item less, 1
6968 Set less exhaustive search.
6969 @end table
6970 Default value is @samp{exhaustive}.
6971
6972 @item filename
6973 If set then a detailed log of the motion search is written to the
6974 specified file.
6975
6976 @end table
6977
6978 @section despill
6979
6980 Remove unwanted contamination of foreground colors, caused by reflected color of
6981 greenscreen or bluescreen.
6982
6983 This filter accepts the following options:
6984
6985 @table @option
6986 @item type
6987 Set what type of despill to use.
6988
6989 @item mix
6990 Set how spillmap will be generated.
6991
6992 @item expand
6993 Set how much to get rid of still remaining spill.
6994
6995 @item red
6996 Controls amount of red in spill area.
6997
6998 @item green
6999 Controls amount of green in spill area.
7000 Should be -1 for greenscreen.
7001
7002 @item blue
7003 Controls amount of blue in spill area.
7004 Should be -1 for bluescreen.
7005
7006 @item brightness
7007 Controls brightness of spill area, preserving colors.
7008
7009 @item alpha
7010 Modify alpha from generated spillmap.
7011 @end table
7012
7013 @section detelecine
7014
7015 Apply an exact inverse of the telecine operation. It requires a predefined
7016 pattern specified using the pattern option which must be the same as that passed
7017 to the telecine filter.
7018
7019 This filter accepts the following options:
7020
7021 @table @option
7022 @item first_field
7023 @table @samp
7024 @item top, t
7025 top field first
7026 @item bottom, b
7027 bottom field first
7028 The default value is @code{top}.
7029 @end table
7030
7031 @item pattern
7032 A string of numbers representing the pulldown pattern you wish to apply.
7033 The default value is @code{23}.
7034
7035 @item start_frame
7036 A number representing position of the first frame with respect to the telecine
7037 pattern. This is to be used if the stream is cut. The default value is @code{0}.
7038 @end table
7039
7040 @section dilation
7041
7042 Apply dilation effect to the video.
7043
7044 This filter replaces the pixel by the local(3x3) maximum.
7045
7046 It accepts the following options:
7047
7048 @table @option
7049 @item threshold0
7050 @item threshold1
7051 @item threshold2
7052 @item threshold3
7053 Limit the maximum change for each plane, default is 65535.
7054 If 0, plane will remain unchanged.
7055
7056 @item coordinates
7057 Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
7058 pixels are used.
7059
7060 Flags to local 3x3 coordinates maps like this:
7061
7062     1 2 3
7063     4   5
7064     6 7 8
7065 @end table
7066
7067 @section displace
7068
7069 Displace pixels as indicated by second and third input stream.
7070
7071 It takes three input streams and outputs one stream, the first input is the
7072 source, and second and third input are displacement maps.
7073
7074 The second input specifies how much to displace pixels along the
7075 x-axis, while the third input specifies how much to displace pixels
7076 along the y-axis.
7077 If one of displacement map streams terminates, last frame from that
7078 displacement map will be used.
7079
7080 Note that once generated, displacements maps can be reused over and over again.
7081
7082 A description of the accepted options follows.
7083
7084 @table @option
7085 @item edge
7086 Set displace behavior for pixels that are out of range.
7087
7088 Available values are:
7089 @table @samp
7090 @item blank
7091 Missing pixels are replaced by black pixels.
7092
7093 @item smear
7094 Adjacent pixels will spread out to replace missing pixels.
7095
7096 @item wrap
7097 Out of range pixels are wrapped so they point to pixels of other side.
7098
7099 @item mirror
7100 Out of range pixels will be replaced with mirrored pixels.
7101 @end table
7102 Default is @samp{smear}.
7103
7104 @end table
7105
7106 @subsection Examples
7107
7108 @itemize
7109 @item
7110 Add ripple effect to rgb input of video size hd720:
7111 @example
7112 ffmpeg -i INPUT -f lavfi -i nullsrc=s=hd720,lutrgb=128:128:128 -f lavfi -i nullsrc=s=hd720,geq='r=128+30*sin(2*PI*X/400+T):g=128+30*sin(2*PI*X/400+T):b=128+30*sin(2*PI*X/400+T)' -lavfi '[0][1][2]displace' OUTPUT
7113 @end example
7114
7115 @item
7116 Add wave effect to rgb input of video size hd720:
7117 @example
7118 ffmpeg -i INPUT -f lavfi -i nullsrc=hd720,geq='r=128+80*(sin(sqrt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2))/220*2*PI+T)):g=128+80*(sin(sqrt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2))/220*2*PI+T)):b=128+80*(sin(sqrt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2))/220*2*PI+T))' -lavfi '[1]split[x][y],[0][x][y]displace' OUTPUT
7119 @end example
7120 @end itemize
7121
7122 @section drawbox
7123
7124 Draw a colored box on the input image.
7125
7126 It accepts the following parameters:
7127
7128 @table @option
7129 @item x
7130 @item y
7131 The expressions which specify the top left corner coordinates of the box. It defaults to 0.
7132
7133 @item width, w
7134 @item height, h
7135 The expressions which specify the width and height of the box; if 0 they are interpreted as
7136 the input width and height. It defaults to 0.
7137
7138 @item color, c
7139 Specify the color of the box to write. For the general syntax of this option,
7140 check the "Color" section in the ffmpeg-utils manual. If the special
7141 value @code{invert} is used, the box edge color is the same as the
7142 video with inverted luma.
7143
7144 @item thickness, t
7145 The expression which sets the thickness of the box edge.
7146 A value of @code{fill} will create a filled box. Default value is @code{3}.
7147
7148 See below for the list of accepted constants.
7149 @end table
7150
7151 The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
7152 following constants:
7153
7154 @table @option
7155 @item dar
7156 The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
7157
7158 @item hsub
7159 @item vsub
7160 horizontal and vertical chroma subsample values. For example for the
7161 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
7162
7163 @item in_h, ih
7164 @item in_w, iw
7165 The input width and height.
7166
7167 @item sar
7168 The input sample aspect ratio.
7169
7170 @item x
7171 @item y
7172 The x and y offset coordinates where the box is drawn.
7173
7174 @item w
7175 @item h
7176 The width and height of the drawn box.
7177
7178 @item t
7179 The thickness of the drawn box.
7180
7181 These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
7182 each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
7183
7184 @end table
7185
7186 @subsection Examples
7187
7188 @itemize
7189 @item
7190 Draw a black box around the edge of the input image:
7191 @example
7192 drawbox
7193 @end example
7194
7195 @item
7196 Draw a box with color red and an opacity of 50%:
7197 @example
7198 drawbox=10:20:200:60:red@@0.5
7199 @end example
7200
7201 The previous example can be specified as:
7202 @example
7203 drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
7204 @end example
7205
7206 @item
7207 Fill the box with pink color:
7208 @example
7209 drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=fill
7210 @end example
7211
7212 @item
7213 Draw a 2-pixel red 2.40:1 mask:
7214 @example
7215 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
7216 @end example
7217 @end itemize
7218
7219 @section drawgrid
7220
7221 Draw a grid on the input image.
7222
7223 It accepts the following parameters:
7224
7225 @table @option
7226 @item x
7227 @item y
7228 The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
7229
7230 @item width, w
7231 @item height, h
7232 The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
7233 input width and height, respectively, minus @code{thickness}, so image gets
7234 framed. Default to 0.
7235
7236 @item color, c
7237 Specify the color of the grid. For the general syntax of this option,
7238 check the "Color" section in the ffmpeg-utils manual. If the special
7239 value @code{invert} is used, the grid color is the same as the
7240 video with inverted luma.
7241
7242 @item thickness, t
7243 The expression which sets the thickness of the grid line. Default value is @code{1}.
7244
7245 See below for the list of accepted constants.
7246 @end table
7247
7248 The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
7249 following constants:
7250
7251 @table @option
7252 @item dar
7253 The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
7254
7255 @item hsub
7256 @item vsub
7257 horizontal and vertical chroma subsample values. For example for the
7258 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
7259
7260 @item in_h, ih
7261 @item in_w, iw
7262 The input grid cell width and height.
7263
7264 @item sar
7265 The input sample aspect ratio.
7266
7267 @item x
7268 @item y
7269 The x and y coordinates of some point of grid intersection (meant to configure offset).
7270
7271 @item w
7272 @item h
7273 The width and height of the drawn cell.
7274
7275 @item t
7276 The thickness of the drawn cell.
7277
7278 These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
7279 each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
7280
7281 @end table
7282
7283 @subsection Examples
7284
7285 @itemize
7286 @item
7287 Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
7288 @example
7289 drawgrid=width=100:height=100:thickness=2:color=red@@0.5
7290 @end example
7291
7292 @item
7293 Draw a white 3x3 grid with an opacity of 50%:
7294 @example
7295 drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
7296 @end example
7297 @end itemize
7298
7299 @anchor{drawtext}
7300 @section drawtext
7301
7302 Draw a text string or text from a specified file on top of a video, using the
7303 libfreetype library.
7304
7305 To enable compilation of this filter, you need to configure FFmpeg with
7306 @code{--enable-libfreetype}.
7307 To enable default font fallback and the @var{font} option you need to
7308 configure FFmpeg with @code{--enable-libfontconfig}.
7309 To enable the @var{text_shaping} option, you need to configure FFmpeg with
7310 @code{--enable-libfribidi}.
7311
7312 @subsection Syntax
7313
7314 It accepts the following parameters:
7315
7316 @table @option
7317
7318 @item box
7319 Used to draw a box around text using the background color.
7320 The value must be either 1 (enable) or 0 (disable).
7321 The default value of @var{box} is 0.
7322
7323 @item boxborderw
7324 Set the width of the border to be drawn around the box using @var{boxcolor}.
7325 The default value of @var{boxborderw} is 0.
7326
7327 @item boxcolor
7328 The color to be used for drawing box around text. For the syntax of this
7329 option, check the "Color" section in the ffmpeg-utils manual.
7330
7331 The default value of @var{boxcolor} is "white".
7332
7333 @item line_spacing
7334 Set the line spacing in pixels of the border to be drawn around the box using @var{box}.
7335 The default value of @var{line_spacing} is 0.
7336
7337 @item borderw
7338 Set the width of the border to be drawn around the text using @var{bordercolor}.
7339 The default value of @var{borderw} is 0.
7340
7341 @item bordercolor
7342 Set the color to be used for drawing border around text. For the syntax of this
7343 option, check the "Color" section in the ffmpeg-utils manual.
7344
7345 The default value of @var{bordercolor} is "black".
7346
7347 @item expansion
7348 Select how the @var{text} is expanded. Can be either @code{none},
7349 @code{strftime} (deprecated) or
7350 @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
7351 below for details.
7352
7353 @item basetime
7354 Set a start time for the count. Value is in microseconds. Only applied
7355 in the deprecated strftime expansion mode. To emulate in normal expansion
7356 mode use the @code{pts} function, supplying the start time (in seconds)
7357 as the second argument.
7358
7359 @item fix_bounds
7360 If true, check and fix text coords to avoid clipping.
7361
7362 @item fontcolor
7363 The color to be used for drawing fonts. For the syntax of this option, check
7364 the "Color" section in the ffmpeg-utils manual.
7365
7366 The default value of @var{fontcolor} is "black".
7367
7368 @item fontcolor_expr
7369 String which is expanded the same way as @var{text} to obtain dynamic
7370 @var{fontcolor} value. By default this option has empty value and is not
7371 processed. When this option is set, it overrides @var{fontcolor} option.
7372
7373 @item font
7374 The font family to be used for drawing text. By default Sans.
7375
7376 @item fontfile
7377 The font file to be used for drawing text. The path must be included.
7378 This parameter is mandatory if the fontconfig support is disabled.
7379
7380 @item alpha
7381 Draw the text applying alpha blending. The value can
7382 be a number between 0.0 and 1.0.
7383 The expression accepts the same variables @var{x, y} as well.
7384 The default value is 1.
7385 Please see @var{fontcolor_expr}.
7386
7387 @item fontsize
7388 The font size to be used for drawing text.
7389 The default value of @var{fontsize} is 16.
7390
7391 @item text_shaping
7392 If set to 1, attempt to shape the text (for example, reverse the order of
7393 right-to-left text and join Arabic characters) before drawing it.
7394 Otherwise, just draw the text exactly as given.
7395 By default 1 (if supported).
7396
7397 @item ft_load_flags
7398 The flags to be used for loading the fonts.
7399
7400 The flags map the corresponding flags supported by libfreetype, and are
7401 a combination of the following values:
7402 @table @var
7403 @item default
7404 @item no_scale
7405 @item no_hinting
7406 @item render
7407 @item no_bitmap
7408 @item vertical_layout
7409 @item force_autohint
7410 @item crop_bitmap
7411 @item pedantic
7412 @item ignore_global_advance_width
7413 @item no_recurse
7414 @item ignore_transform
7415 @item monochrome
7416 @item linear_design
7417 @item no_autohint
7418 @end table
7419
7420 Default value is "default".
7421
7422 For more information consult the documentation for the FT_LOAD_*
7423 libfreetype flags.
7424
7425 @item shadowcolor
7426 The color to be used for drawing a shadow behind the drawn text. For the
7427 syntax of this option, check the "Color" section in the ffmpeg-utils manual.
7428
7429 The default value of @var{shadowcolor} is "black".
7430
7431 @item shadowx
7432 @item shadowy
7433 The x and y offsets for the text shadow position with respect to the
7434 position of the text. They can be either positive or negative
7435 values. The default value for both is "0".
7436
7437 @item start_number
7438 The starting frame number for the n/frame_num variable. The default value
7439 is "0".
7440
7441 @item tabsize
7442 The size in number of spaces to use for rendering the tab.
7443 Default value is 4.
7444
7445 @item timecode
7446 Set the initial timecode representation in "hh:mm:ss[:;.]ff"
7447 format. It can be used with or without text parameter. @var{timecode_rate}
7448 option must be specified.
7449
7450 @item timecode_rate, rate, r
7451 Set the timecode frame rate (timecode only). Value will be rounded to nearest
7452 integer. Minimum value is "1".
7453 Drop-frame timecode is supported for frame rates 30 & 60.
7454
7455 @item tc24hmax
7456 If set to 1, the output of the timecode option will wrap around at 24 hours.
7457 Default is 0 (disabled).
7458
7459 @item text
7460 The text string to be drawn. The text must be a sequence of UTF-8
7461 encoded characters.
7462 This parameter is mandatory if no file is specified with the parameter
7463 @var{textfile}.
7464
7465 @item textfile
7466 A text file containing text to be drawn. The text must be a sequence
7467 of UTF-8 encoded characters.
7468
7469 This parameter is mandatory if no text string is specified with the
7470 parameter @var{text}.
7471
7472 If both @var{text} and @var{textfile} are specified, an error is thrown.
7473
7474 @item reload
7475 If set to 1, the @var{textfile} will be reloaded before each frame.
7476 Be sure to update it atomically, or it may be read partially, or even fail.
7477
7478 @item x
7479 @item y
7480 The expressions which specify the offsets where text will be drawn
7481 within the video frame. They are relative to the top/left border of the
7482 output image.
7483
7484 The default value of @var{x} and @var{y} is "0".
7485
7486 See below for the list of accepted constants and functions.
7487 @end table
7488
7489 The parameters for @var{x} and @var{y} are expressions containing the
7490 following constants and functions:
7491
7492 @table @option
7493 @item dar
7494 input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
7495
7496 @item hsub
7497 @item vsub
7498 horizontal and vertical chroma subsample values. For example for the
7499 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
7500
7501 @item line_h, lh
7502 the height of each text line
7503
7504 @item main_h, h, H
7505 the input height
7506
7507 @item main_w, w, W
7508 the input width
7509
7510 @item max_glyph_a, ascent
7511 the maximum distance from the baseline to the highest/upper grid
7512 coordinate used to place a glyph outline point, for all the rendered
7513 glyphs.
7514 It is a positive value, due to the grid's orientation with the Y axis
7515 upwards.
7516
7517 @item max_glyph_d, descent
7518 the maximum distance from the baseline to the lowest grid coordinate
7519 used to place a glyph outline point, for all the rendered glyphs.
7520 This is a negative value, due to the grid's orientation, with the Y axis
7521 upwards.
7522
7523 @item max_glyph_h
7524 maximum glyph height, that is the maximum height for all the glyphs
7525 contained in the rendered text, it is equivalent to @var{ascent} -
7526 @var{descent}.
7527
7528 @item max_glyph_w
7529 maximum glyph width, that is the maximum width for all the glyphs
7530 contained in the rendered text
7531
7532 @item n
7533 the number of input frame, starting from 0
7534
7535 @item rand(min, max)
7536 return a random number included between @var{min} and @var{max}
7537
7538 @item sar
7539 The input sample aspect ratio.
7540
7541 @item t
7542 timestamp expressed in seconds, NAN if the input timestamp is unknown
7543
7544 @item text_h, th
7545 the height of the rendered text
7546
7547 @item text_w, tw
7548 the width of the rendered text
7549
7550 @item x
7551 @item y
7552 the x and y offset coordinates where the text is drawn.
7553
7554 These parameters allow the @var{x} and @var{y} expressions to refer
7555 each other, so you can for example specify @code{y=x/dar}.
7556 @end table
7557
7558 @anchor{drawtext_expansion}
7559 @subsection Text expansion
7560
7561 If @option{expansion} is set to @code{strftime},
7562 the filter recognizes strftime() sequences in the provided text and
7563 expands them accordingly. Check the documentation of strftime(). This
7564 feature is deprecated.
7565
7566 If @option{expansion} is set to @code{none}, the text is printed verbatim.
7567
7568 If @option{expansion} is set to @code{normal} (which is the default),
7569 the following expansion mechanism is used.
7570
7571 The backslash character @samp{\}, followed by any character, always expands to
7572 the second character.
7573
7574 Sequences of the form @code{%@{...@}} are expanded. The text between the
7575 braces is a function name, possibly followed by arguments separated by ':'.
7576 If the arguments contain special characters or delimiters (':' or '@}'),
7577 they should be escaped.
7578
7579 Note that they probably must also be escaped as the value for the
7580 @option{text} option in the filter argument string and as the filter
7581 argument in the filtergraph description, and possibly also for the shell,
7582 that makes up to four levels of escaping; using a text file avoids these
7583 problems.
7584
7585 The following functions are available:
7586
7587 @table @command
7588
7589 @item expr, e
7590 The expression evaluation result.
7591
7592 It must take one argument specifying the expression to be evaluated,
7593 which accepts the same constants and functions as the @var{x} and
7594 @var{y} values. Note that not all constants should be used, for
7595 example the text size is not known when evaluating the expression, so
7596 the constants @var{text_w} and @var{text_h} will have an undefined
7597 value.
7598
7599 @item expr_int_format, eif
7600 Evaluate the expression's value and output as formatted integer.
7601
7602 The first argument is the expression to be evaluated, just as for the @var{expr} function.
7603 The second argument specifies the output format. Allowed values are @samp{x},
7604 @samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
7605 @code{printf} function.
7606 The third parameter is optional and sets the number of positions taken by the output.
7607 It can be used to add padding with zeros from the left.
7608
7609 @item gmtime
7610 The time at which the filter is running, expressed in UTC.
7611 It can accept an argument: a strftime() format string.
7612
7613 @item localtime
7614 The time at which the filter is running, expressed in the local time zone.
7615 It can accept an argument: a strftime() format string.
7616
7617 @item metadata
7618 Frame metadata. Takes one or two arguments.
7619
7620 The first argument is mandatory and specifies the metadata key.
7621
7622 The second argument is optional and specifies a default value, used when the
7623 metadata key is not found or empty.
7624
7625 @item n, frame_num
7626 The frame number, starting from 0.
7627
7628 @item pict_type
7629 A 1 character description of the current picture type.
7630
7631 @item pts
7632 The timestamp of the current frame.
7633 It can take up to three arguments.
7634
7635 The first argument is the format of the timestamp; it defaults to @code{flt}
7636 for seconds as a decimal number with microsecond accuracy; @code{hms} stands
7637 for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
7638 @code{gmtime} stands for the timestamp of the frame formatted as UTC time;
7639 @code{localtime} stands for the timestamp of the frame formatted as
7640 local time zone time.
7641
7642 The second argument is an offset added to the timestamp.
7643
7644 If the format is set to @code{localtime} or @code{gmtime},
7645 a third argument may be supplied: a strftime() format string.
7646 By default, @var{YYYY-MM-DD HH:MM:SS} format will be used.
7647 @end table
7648
7649 @subsection Examples
7650
7651 @itemize
7652 @item
7653 Draw "Test Text" with font FreeSerif, using the default values for the
7654 optional parameters.
7655
7656 @example
7657 drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
7658 @end example
7659
7660 @item
7661 Draw 'Test Text' with font FreeSerif of size 24 at position x=100
7662 and y=50 (counting from the top-left corner of the screen), text is
7663 yellow with a red box around it. Both the text and the box have an
7664 opacity of 20%.
7665
7666 @example
7667 drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
7668           x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
7669 @end example
7670
7671 Note that the double quotes are not necessary if spaces are not used
7672 within the parameter list.
7673
7674 @item
7675 Show the text at the center of the video frame:
7676 @example
7677 drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2"
7678 @end example
7679
7680 @item
7681 Show the text at a random position, switching to a new position every 30 seconds:
7682 @example
7683 drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=if(eq(mod(t\,30)\,0)\,rand(0\,(w-text_w))\,x):y=if(eq(mod(t\,30)\,0)\,rand(0\,(h-text_h))\,y)"
7684 @end example
7685
7686 @item
7687 Show a text line sliding from right to left in the last row of the video
7688 frame. The file @file{LONG_LINE} is assumed to contain a single line
7689 with no newlines.
7690 @example
7691 drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
7692 @end example
7693
7694 @item
7695 Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
7696 @example
7697 drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
7698 @end example
7699
7700 @item
7701 Draw a single green letter "g", at the center of the input video.
7702 The glyph baseline is placed at half screen height.
7703 @example
7704 drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
7705 @end example
7706
7707 @item
7708 Show text for 1 second every 3 seconds:
7709 @example
7710 drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
7711 @end example
7712
7713 @item
7714 Use fontconfig to set the font. Note that the colons need to be escaped.
7715 @example
7716 drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
7717 @end example
7718
7719 @item
7720 Print the date of a real-time encoding (see strftime(3)):
7721 @example
7722 drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
7723 @end example
7724
7725 @item
7726 Show text fading in and out (appearing/disappearing):
7727 @example
7728 #!/bin/sh
7729 DS=1.0 # display start
7730 DE=10.0 # display end
7731 FID=1.5 # fade in duration
7732 FOD=5 # fade out duration
7733 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 @}"
7734 @end example
7735
7736 @item
7737 Horizontally align multiple separate texts. Note that @option{max_glyph_a}
7738 and the @option{fontsize} value are included in the @option{y} offset.
7739 @example
7740 drawtext=fontfile=FreeSans.ttf:text=DOG:fontsize=24:x=10:y=20+24-max_glyph_a,
7741 drawtext=fontfile=FreeSans.ttf:text=cow:fontsize=24:x=80:y=20+24-max_glyph_a
7742 @end example
7743
7744 @end itemize
7745
7746 For more information about libfreetype, check:
7747 @url{http://www.freetype.org/}.
7748
7749 For more information about fontconfig, check:
7750 @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
7751
7752 For more information about libfribidi, check:
7753 @url{http://fribidi.org/}.
7754
7755 @section edgedetect
7756
7757 Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
7758
7759 The filter accepts the following options:
7760
7761 @table @option
7762 @item low
7763 @item high
7764 Set low and high threshold values used by the Canny thresholding
7765 algorithm.
7766
7767 The high threshold selects the "strong" edge pixels, which are then
7768 connected through 8-connectivity with the "weak" edge pixels selected
7769 by the low threshold.
7770
7771 @var{low} and @var{high} threshold values must be chosen in the range
7772 [0,1], and @var{low} should be lesser or equal to @var{high}.
7773
7774 Default value for @var{low} is @code{20/255}, and default value for @var{high}
7775 is @code{50/255}.
7776
7777 @item mode
7778 Define the drawing mode.
7779
7780 @table @samp
7781 @item wires
7782 Draw white/gray wires on black background.
7783
7784 @item colormix
7785 Mix the colors to create a paint/cartoon effect.
7786 @end table
7787
7788 Default value is @var{wires}.
7789 @end table
7790
7791 @subsection Examples
7792
7793 @itemize
7794 @item
7795 Standard edge detection with custom values for the hysteresis thresholding:
7796 @example
7797 edgedetect=low=0.1:high=0.4
7798 @end example
7799
7800 @item
7801 Painting effect without thresholding:
7802 @example
7803 edgedetect=mode=colormix:high=0
7804 @end example
7805 @end itemize
7806
7807 @section eq
7808 Set brightness, contrast, saturation and approximate gamma adjustment.
7809
7810 The filter accepts the following options:
7811
7812 @table @option
7813 @item contrast
7814 Set the contrast expression. The value must be a float value in range
7815 @code{-2.0} to @code{2.0}. The default value is "1".
7816
7817 @item brightness
7818 Set the brightness expression. The value must be a float value in
7819 range @code{-1.0} to @code{1.0}. The default value is "0".
7820
7821 @item saturation
7822 Set the saturation expression. The value must be a float in
7823 range @code{0.0} to @code{3.0}. The default value is "1".
7824
7825 @item gamma
7826 Set the gamma expression. The value must be a float in range
7827 @code{0.1} to @code{10.0}.  The default value is "1".
7828
7829 @item gamma_r
7830 Set the gamma expression for red. The value must be a float in
7831 range @code{0.1} to @code{10.0}. The default value is "1".
7832
7833 @item gamma_g
7834 Set the gamma expression for green. The value must be a float in range
7835 @code{0.1} to @code{10.0}. The default value is "1".
7836
7837 @item gamma_b
7838 Set the gamma expression for blue. The value must be a float in range
7839 @code{0.1} to @code{10.0}. The default value is "1".
7840
7841 @item gamma_weight
7842 Set the gamma weight expression. It can be used to reduce the effect
7843 of a high gamma value on bright image areas, e.g. keep them from
7844 getting overamplified and just plain white. The value must be a float
7845 in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
7846 gamma correction all the way down while @code{1.0} leaves it at its
7847 full strength. Default is "1".
7848
7849 @item eval
7850 Set when the expressions for brightness, contrast, saturation and
7851 gamma expressions are evaluated.
7852
7853 It accepts the following values:
7854 @table @samp
7855 @item init
7856 only evaluate expressions once during the filter initialization or
7857 when a command is processed
7858
7859 @item frame
7860 evaluate expressions for each incoming frame
7861 @end table
7862
7863 Default value is @samp{init}.
7864 @end table
7865
7866 The expressions accept the following parameters:
7867 @table @option
7868 @item n
7869 frame count of the input frame starting from 0
7870
7871 @item pos
7872 byte position of the corresponding packet in the input file, NAN if
7873 unspecified
7874
7875 @item r
7876 frame rate of the input video, NAN if the input frame rate is unknown
7877
7878 @item t
7879 timestamp expressed in seconds, NAN if the input timestamp is unknown
7880 @end table
7881
7882 @subsection Commands
7883 The filter supports the following commands:
7884
7885 @table @option
7886 @item contrast
7887 Set the contrast expression.
7888
7889 @item brightness
7890 Set the brightness expression.
7891
7892 @item saturation
7893 Set the saturation expression.
7894
7895 @item gamma
7896 Set the gamma expression.
7897
7898 @item gamma_r
7899 Set the gamma_r expression.
7900
7901 @item gamma_g
7902 Set gamma_g expression.
7903
7904 @item gamma_b
7905 Set gamma_b expression.
7906
7907 @item gamma_weight
7908 Set gamma_weight expression.
7909
7910 The command accepts the same syntax of the corresponding option.
7911
7912 If the specified expression is not valid, it is kept at its current
7913 value.
7914
7915 @end table
7916
7917 @section erosion
7918
7919 Apply erosion effect to the video.
7920
7921 This filter replaces the pixel by the local(3x3) minimum.
7922
7923 It accepts the following options:
7924
7925 @table @option
7926 @item threshold0
7927 @item threshold1
7928 @item threshold2
7929 @item threshold3
7930 Limit the maximum change for each plane, default is 65535.
7931 If 0, plane will remain unchanged.
7932
7933 @item coordinates
7934 Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
7935 pixels are used.
7936
7937 Flags to local 3x3 coordinates maps like this:
7938
7939     1 2 3
7940     4   5
7941     6 7 8
7942 @end table
7943
7944 @section extractplanes
7945
7946 Extract color channel components from input video stream into
7947 separate grayscale video streams.
7948
7949 The filter accepts the following option:
7950
7951 @table @option
7952 @item planes
7953 Set plane(s) to extract.
7954
7955 Available values for planes are:
7956 @table @samp
7957 @item y
7958 @item u
7959 @item v
7960 @item a
7961 @item r
7962 @item g
7963 @item b
7964 @end table
7965
7966 Choosing planes not available in the input will result in an error.
7967 That means you cannot select @code{r}, @code{g}, @code{b} planes
7968 with @code{y}, @code{u}, @code{v} planes at same time.
7969 @end table
7970
7971 @subsection Examples
7972
7973 @itemize
7974 @item
7975 Extract luma, u and v color channel component from input video frame
7976 into 3 grayscale outputs:
7977 @example
7978 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
7979 @end example
7980 @end itemize
7981
7982 @section elbg
7983
7984 Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
7985
7986 For each input image, the filter will compute the optimal mapping from
7987 the input to the output given the codebook length, that is the number
7988 of distinct output colors.
7989
7990 This filter accepts the following options.
7991
7992 @table @option
7993 @item codebook_length, l
7994 Set codebook length. The value must be a positive integer, and
7995 represents the number of distinct output colors. Default value is 256.
7996
7997 @item nb_steps, n
7998 Set the maximum number of iterations to apply for computing the optimal
7999 mapping. The higher the value the better the result and the higher the
8000 computation time. Default value is 1.
8001
8002 @item seed, s
8003 Set a random seed, must be an integer included between 0 and
8004 UINT32_MAX. If not specified, or if explicitly set to -1, the filter
8005 will try to use a good random seed on a best effort basis.
8006
8007 @item pal8
8008 Set pal8 output pixel format. This option does not work with codebook
8009 length greater than 256.
8010 @end table
8011
8012 @section fade
8013
8014 Apply a fade-in/out effect to the input video.
8015
8016 It accepts the following parameters:
8017
8018 @table @option
8019 @item type, t
8020 The effect type can be either "in" for a fade-in, or "out" for a fade-out
8021 effect.
8022 Default is @code{in}.
8023
8024 @item start_frame, s
8025 Specify the number of the frame to start applying the fade
8026 effect at. Default is 0.
8027
8028 @item nb_frames, n
8029 The number of frames that the fade effect lasts. At the end of the
8030 fade-in effect, the output video will have the same intensity as the input video.
8031 At the end of the fade-out transition, the output video will be filled with the
8032 selected @option{color}.
8033 Default is 25.
8034
8035 @item alpha
8036 If set to 1, fade only alpha channel, if one exists on the input.
8037 Default value is 0.
8038
8039 @item start_time, st
8040 Specify the timestamp (in seconds) of the frame to start to apply the fade
8041 effect. If both start_frame and start_time are specified, the fade will start at
8042 whichever comes last.  Default is 0.
8043
8044 @item duration, d
8045 The number of seconds for which the fade effect has to last. At the end of the
8046 fade-in effect the output video will have the same intensity as the input video,
8047 at the end of the fade-out transition the output video will be filled with the
8048 selected @option{color}.
8049 If both duration and nb_frames are specified, duration is used. Default is 0
8050 (nb_frames is used by default).
8051
8052 @item color, c
8053 Specify the color of the fade. Default is "black".
8054 @end table
8055
8056 @subsection Examples
8057
8058 @itemize
8059 @item
8060 Fade in the first 30 frames of video:
8061 @example
8062 fade=in:0:30
8063 @end example
8064
8065 The command above is equivalent to:
8066 @example
8067 fade=t=in:s=0:n=30
8068 @end example
8069
8070 @item
8071 Fade out the last 45 frames of a 200-frame video:
8072 @example
8073 fade=out:155:45
8074 fade=type=out:start_frame=155:nb_frames=45
8075 @end example
8076
8077 @item
8078 Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
8079 @example
8080 fade=in:0:25, fade=out:975:25
8081 @end example
8082
8083 @item
8084 Make the first 5 frames yellow, then fade in from frame 5-24:
8085 @example
8086 fade=in:5:20:color=yellow
8087 @end example
8088
8089 @item
8090 Fade in alpha over first 25 frames of video:
8091 @example
8092 fade=in:0:25:alpha=1
8093 @end example
8094
8095 @item
8096 Make the first 5.5 seconds black, then fade in for 0.5 seconds:
8097 @example
8098 fade=t=in:st=5.5:d=0.5
8099 @end example
8100
8101 @end itemize
8102
8103 @section fftfilt
8104 Apply arbitrary expressions to samples in frequency domain
8105
8106 @table @option
8107 @item dc_Y
8108 Adjust the dc value (gain) of the luma plane of the image. The filter
8109 accepts an integer value in range @code{0} to @code{1000}. The default
8110 value is set to @code{0}.
8111
8112 @item dc_U
8113 Adjust the dc value (gain) of the 1st chroma plane of the image. The
8114 filter accepts an integer value in range @code{0} to @code{1000}. The
8115 default value is set to @code{0}.
8116
8117 @item dc_V
8118 Adjust the dc value (gain) of the 2nd chroma plane of the image. The
8119 filter accepts an integer value in range @code{0} to @code{1000}. The
8120 default value is set to @code{0}.
8121
8122 @item weight_Y
8123 Set the frequency domain weight expression for the luma plane.
8124
8125 @item weight_U
8126 Set the frequency domain weight expression for the 1st chroma plane.
8127
8128 @item weight_V
8129 Set the frequency domain weight expression for the 2nd chroma plane.
8130
8131 @item eval
8132 Set when the expressions are evaluated.
8133
8134 It accepts the following values:
8135 @table @samp
8136 @item init
8137 Only evaluate expressions once during the filter initialization.
8138
8139 @item frame
8140 Evaluate expressions for each incoming frame.
8141 @end table
8142
8143 Default value is @samp{init}.
8144
8145 The filter accepts the following variables:
8146 @item X
8147 @item Y
8148 The coordinates of the current sample.
8149
8150 @item W
8151 @item H
8152 The width and height of the image.
8153
8154 @item N
8155 The number of input frame, starting from 0.
8156 @end table
8157
8158 @subsection Examples
8159
8160 @itemize
8161 @item
8162 High-pass:
8163 @example
8164 fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
8165 @end example
8166
8167 @item
8168 Low-pass:
8169 @example
8170 fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
8171 @end example
8172
8173 @item
8174 Sharpen:
8175 @example
8176 fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
8177 @end example
8178
8179 @item
8180 Blur:
8181 @example
8182 fftfilt=dc_Y=0:weight_Y='exp(-4 * ((Y+X)/(W+H)))'
8183 @end example
8184
8185 @end itemize
8186
8187 @section field
8188
8189 Extract a single field from an interlaced image using stride
8190 arithmetic to avoid wasting CPU time. The output frames are marked as
8191 non-interlaced.
8192
8193 The filter accepts the following options:
8194
8195 @table @option
8196 @item type
8197 Specify whether to extract the top (if the value is @code{0} or
8198 @code{top}) or the bottom field (if the value is @code{1} or
8199 @code{bottom}).
8200 @end table
8201
8202 @section fieldhint
8203
8204 Create new frames by copying the top and bottom fields from surrounding frames
8205 supplied as numbers by the hint file.
8206
8207 @table @option
8208 @item hint
8209 Set file containing hints: absolute/relative frame numbers.
8210
8211 There must be one line for each frame in a clip. Each line must contain two
8212 numbers separated by the comma, optionally followed by @code{-} or @code{+}.
8213 Numbers supplied on each line of file can not be out of [N-1,N+1] where N
8214 is current frame number for @code{absolute} mode or out of [-1, 1] range
8215 for @code{relative} mode. First number tells from which frame to pick up top
8216 field and second number tells from which frame to pick up bottom field.
8217
8218 If optionally followed by @code{+} output frame will be marked as interlaced,
8219 else if followed by @code{-} output frame will be marked as progressive, else
8220 it will be marked same as input frame.
8221 If line starts with @code{#} or @code{;} that line is skipped.
8222
8223 @item mode
8224 Can be item @code{absolute} or @code{relative}. Default is @code{absolute}.
8225 @end table
8226
8227 Example of first several lines of @code{hint} file for @code{relative} mode:
8228 @example
8229 0,0 - # first frame
8230 1,0 - # second frame, use third's frame top field and second's frame bottom field
8231 1,0 - # third frame, use fourth's frame top field and third's frame bottom field
8232 1,0 -
8233 0,0 -
8234 0,0 -
8235 1,0 -
8236 1,0 -
8237 1,0 -
8238 0,0 -
8239 0,0 -
8240 1,0 -
8241 1,0 -
8242 1,0 -
8243 0,0 -
8244 @end example
8245
8246 @section fieldmatch
8247
8248 Field matching filter for inverse telecine. It is meant to reconstruct the
8249 progressive frames from a telecined stream. The filter does not drop duplicated
8250 frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
8251 followed by a decimation filter such as @ref{decimate} in the filtergraph.
8252
8253 The separation of the field matching and the decimation is notably motivated by
8254 the possibility of inserting a de-interlacing filter fallback between the two.
8255 If the source has mixed telecined and real interlaced content,
8256 @code{fieldmatch} will not be able to match fields for the interlaced parts.
8257 But these remaining combed frames will be marked as interlaced, and thus can be
8258 de-interlaced by a later filter such as @ref{yadif} before decimation.
8259
8260 In addition to the various configuration options, @code{fieldmatch} can take an
8261 optional second stream, activated through the @option{ppsrc} option. If
8262 enabled, the frames reconstruction will be based on the fields and frames from
8263 this second stream. This allows the first input to be pre-processed in order to
8264 help the various algorithms of the filter, while keeping the output lossless
8265 (assuming the fields are matched properly). Typically, a field-aware denoiser,
8266 or brightness/contrast adjustments can help.
8267
8268 Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
8269 and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
8270 which @code{fieldmatch} is based on. While the semantic and usage are very
8271 close, some behaviour and options names can differ.
8272
8273 The @ref{decimate} filter currently only works for constant frame rate input.
8274 If your input has mixed telecined (30fps) and progressive content with a lower
8275 framerate like 24fps use the following filterchain to produce the necessary cfr
8276 stream: @code{dejudder,fps=30000/1001,fieldmatch,decimate}.
8277
8278 The filter accepts the following options:
8279
8280 @table @option
8281 @item order
8282 Specify the assumed field order of the input stream. Available values are:
8283
8284 @table @samp
8285 @item auto
8286 Auto detect parity (use FFmpeg's internal parity value).
8287 @item bff
8288 Assume bottom field first.
8289 @item tff
8290 Assume top field first.
8291 @end table
8292
8293 Note that it is sometimes recommended not to trust the parity announced by the
8294 stream.
8295
8296 Default value is @var{auto}.
8297
8298 @item mode
8299 Set the matching mode or strategy to use. @option{pc} mode is the safest in the
8300 sense that it won't risk creating jerkiness due to duplicate frames when
8301 possible, but if there are bad edits or blended fields it will end up
8302 outputting combed frames when a good match might actually exist. On the other
8303 hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
8304 but will almost always find a good frame if there is one. The other values are
8305 all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
8306 jerkiness and creating duplicate frames versus finding good matches in sections
8307 with bad edits, orphaned fields, blended fields, etc.
8308
8309 More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
8310
8311 Available values are:
8312
8313 @table @samp
8314 @item pc
8315 2-way matching (p/c)
8316 @item pc_n
8317 2-way matching, and trying 3rd match if still combed (p/c + n)
8318 @item pc_u
8319 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
8320 @item pc_n_ub
8321 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
8322 still combed (p/c + n + u/b)
8323 @item pcn
8324 3-way matching (p/c/n)
8325 @item pcn_ub
8326 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
8327 detected as combed (p/c/n + u/b)
8328 @end table
8329
8330 The parenthesis at the end indicate the matches that would be used for that
8331 mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
8332 @var{top}).
8333
8334 In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
8335 the slowest.
8336
8337 Default value is @var{pc_n}.
8338
8339 @item ppsrc
8340 Mark the main input stream as a pre-processed input, and enable the secondary
8341 input stream as the clean source to pick the fields from. See the filter
8342 introduction for more details. It is similar to the @option{clip2} feature from
8343 VFM/TFM.
8344
8345 Default value is @code{0} (disabled).
8346
8347 @item field
8348 Set the field to match from. It is recommended to set this to the same value as
8349 @option{order} unless you experience matching failures with that setting. In
8350 certain circumstances changing the field that is used to match from can have a
8351 large impact on matching performance. Available values are:
8352
8353 @table @samp
8354 @item auto
8355 Automatic (same value as @option{order}).
8356 @item bottom
8357 Match from the bottom field.
8358 @item top
8359 Match from the top field.
8360 @end table
8361
8362 Default value is @var{auto}.
8363
8364 @item mchroma
8365 Set whether or not chroma is included during the match comparisons. In most
8366 cases it is recommended to leave this enabled. You should set this to @code{0}
8367 only if your clip has bad chroma problems such as heavy rainbowing or other
8368 artifacts. Setting this to @code{0} could also be used to speed things up at
8369 the cost of some accuracy.
8370
8371 Default value is @code{1}.
8372
8373 @item y0
8374 @item y1
8375 These define an exclusion band which excludes the lines between @option{y0} and
8376 @option{y1} from being included in the field matching decision. An exclusion
8377 band can be used to ignore subtitles, a logo, or other things that may
8378 interfere with the matching. @option{y0} sets the starting scan line and
8379 @option{y1} sets the ending line; all lines in between @option{y0} and
8380 @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
8381 @option{y0} and @option{y1} to the same value will disable the feature.
8382 @option{y0} and @option{y1} defaults to @code{0}.
8383
8384 @item scthresh
8385 Set the scene change detection threshold as a percentage of maximum change on
8386 the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
8387 detection is only relevant in case @option{combmatch}=@var{sc}.  The range for
8388 @option{scthresh} is @code{[0.0, 100.0]}.
8389
8390 Default value is @code{12.0}.
8391
8392 @item combmatch
8393 When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
8394 account the combed scores of matches when deciding what match to use as the
8395 final match. Available values are:
8396
8397 @table @samp
8398 @item none
8399 No final matching based on combed scores.
8400 @item sc
8401 Combed scores are only used when a scene change is detected.
8402 @item full
8403 Use combed scores all the time.
8404 @end table
8405
8406 Default is @var{sc}.
8407
8408 @item combdbg
8409 Force @code{fieldmatch} to calculate the combed metrics for certain matches and
8410 print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
8411 Available values are:
8412
8413 @table @samp
8414 @item none
8415 No forced calculation.
8416 @item pcn
8417 Force p/c/n calculations.
8418 @item pcnub
8419 Force p/c/n/u/b calculations.
8420 @end table
8421
8422 Default value is @var{none}.
8423
8424 @item cthresh
8425 This is the area combing threshold used for combed frame detection. This
8426 essentially controls how "strong" or "visible" combing must be to be detected.
8427 Larger values mean combing must be more visible and smaller values mean combing
8428 can be less visible or strong and still be detected. Valid settings are from
8429 @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
8430 be detected as combed). This is basically a pixel difference value. A good
8431 range is @code{[8, 12]}.
8432
8433 Default value is @code{9}.
8434
8435 @item chroma
8436 Sets whether or not chroma is considered in the combed frame decision.  Only
8437 disable this if your source has chroma problems (rainbowing, etc.) that are
8438 causing problems for the combed frame detection with chroma enabled. Actually,
8439 using @option{chroma}=@var{0} is usually more reliable, except for the case
8440 where there is chroma only combing in the source.
8441
8442 Default value is @code{0}.
8443
8444 @item blockx
8445 @item blocky
8446 Respectively set the x-axis and y-axis size of the window used during combed
8447 frame detection. This has to do with the size of the area in which
8448 @option{combpel} pixels are required to be detected as combed for a frame to be
8449 declared combed. See the @option{combpel} parameter description for more info.
8450 Possible values are any number that is a power of 2 starting at 4 and going up
8451 to 512.
8452
8453 Default value is @code{16}.
8454
8455 @item combpel
8456 The number of combed pixels inside any of the @option{blocky} by
8457 @option{blockx} size blocks on the frame for the frame to be detected as
8458 combed. While @option{cthresh} controls how "visible" the combing must be, this
8459 setting controls "how much" combing there must be in any localized area (a
8460 window defined by the @option{blockx} and @option{blocky} settings) on the
8461 frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
8462 which point no frames will ever be detected as combed). This setting is known
8463 as @option{MI} in TFM/VFM vocabulary.
8464
8465 Default value is @code{80}.
8466 @end table
8467
8468 @anchor{p/c/n/u/b meaning}
8469 @subsection p/c/n/u/b meaning
8470
8471 @subsubsection p/c/n
8472
8473 We assume the following telecined stream:
8474
8475 @example
8476 Top fields:     1 2 2 3 4
8477 Bottom fields:  1 2 3 4 4
8478 @end example
8479
8480 The numbers correspond to the progressive frame the fields relate to. Here, the
8481 first two frames are progressive, the 3rd and 4th are combed, and so on.
8482
8483 When @code{fieldmatch} is configured to run a matching from bottom
8484 (@option{field}=@var{bottom}) this is how this input stream get transformed:
8485
8486 @example
8487 Input stream:
8488                 T     1 2 2 3 4
8489                 B     1 2 3 4 4   <-- matching reference
8490
8491 Matches:              c c n n c
8492
8493 Output stream:
8494                 T     1 2 3 4 4
8495                 B     1 2 3 4 4
8496 @end example
8497
8498 As a result of the field matching, we can see that some frames get duplicated.
8499 To perform a complete inverse telecine, you need to rely on a decimation filter
8500 after this operation. See for instance the @ref{decimate} filter.
8501
8502 The same operation now matching from top fields (@option{field}=@var{top})
8503 looks like this:
8504
8505 @example
8506 Input stream:
8507                 T     1 2 2 3 4   <-- matching reference
8508                 B     1 2 3 4 4
8509
8510 Matches:              c c p p c
8511
8512 Output stream:
8513                 T     1 2 2 3 4
8514                 B     1 2 2 3 4
8515 @end example
8516
8517 In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
8518 basically, they refer to the frame and field of the opposite parity:
8519
8520 @itemize
8521 @item @var{p} matches the field of the opposite parity in the previous frame
8522 @item @var{c} matches the field of the opposite parity in the current frame
8523 @item @var{n} matches the field of the opposite parity in the next frame
8524 @end itemize
8525
8526 @subsubsection u/b
8527
8528 The @var{u} and @var{b} matching are a bit special in the sense that they match
8529 from the opposite parity flag. In the following examples, we assume that we are
8530 currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
8531 'x' is placed above and below each matched fields.
8532
8533 With bottom matching (@option{field}=@var{bottom}):
8534 @example
8535 Match:           c         p           n          b          u
8536
8537                  x       x               x        x          x
8538   Top          1 2 2     1 2 2       1 2 2      1 2 2      1 2 2
8539   Bottom       1 2 3     1 2 3       1 2 3      1 2 3      1 2 3
8540                  x         x           x        x              x
8541
8542 Output frames:
8543                  2          1          2          2          2
8544                  2          2          2          1          3
8545 @end example
8546
8547 With top matching (@option{field}=@var{top}):
8548 @example
8549 Match:           c         p           n          b          u
8550
8551                  x         x           x        x              x
8552   Top          1 2 2     1 2 2       1 2 2      1 2 2      1 2 2
8553   Bottom       1 2 3     1 2 3       1 2 3      1 2 3      1 2 3
8554                  x       x               x        x          x
8555
8556 Output frames:
8557                  2          2          2          1          2
8558                  2          1          3          2          2
8559 @end example
8560
8561 @subsection Examples
8562
8563 Simple IVTC of a top field first telecined stream:
8564 @example
8565 fieldmatch=order=tff:combmatch=none, decimate
8566 @end example
8567
8568 Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
8569 @example
8570 fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
8571 @end example
8572
8573 @section fieldorder
8574
8575 Transform the field order of the input video.
8576
8577 It accepts the following parameters:
8578
8579 @table @option
8580
8581 @item order
8582 The output field order. Valid values are @var{tff} for top field first or @var{bff}
8583 for bottom field first.
8584 @end table
8585
8586 The default value is @samp{tff}.
8587
8588 The transformation is done by shifting the picture content up or down
8589 by one line, and filling the remaining line with appropriate picture content.
8590 This method is consistent with most broadcast field order converters.
8591
8592 If the input video is not flagged as being interlaced, or it is already
8593 flagged as being of the required output field order, then this filter does
8594 not alter the incoming video.
8595
8596 It is very useful when converting to or from PAL DV material,
8597 which is bottom field first.
8598
8599 For example:
8600 @example
8601 ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
8602 @end example
8603
8604 @section fifo, afifo
8605
8606 Buffer input images and send them when they are requested.
8607
8608 It is mainly useful when auto-inserted by the libavfilter
8609 framework.
8610
8611 It does not take parameters.
8612
8613 @section fillborders
8614
8615 Fill borders of the input video, without changing video stream dimensions.
8616 Sometimes video can have garbage at the four edges and you may not want to
8617 crop video input to keep size multiple of some number.
8618
8619 This filter accepts the following options:
8620
8621 @table @option
8622 @item left
8623 Number of pixels to fill from left border.
8624
8625 @item right
8626 Number of pixels to fill from right border.
8627
8628 @item top
8629 Number of pixels to fill from top border.
8630
8631 @item bottom
8632 Number of pixels to fill from bottom border.
8633
8634 @item mode
8635 Set fill mode.
8636
8637 It accepts the following values:
8638 @table @samp
8639 @item smear
8640 fill pixels using outermost pixels
8641
8642 @item mirror
8643 fill pixels using mirroring
8644
8645 @item fixed
8646 fill pixels with constant value
8647 @end table
8648
8649 Default is @var{smear}.
8650
8651 @item color
8652 Set color for pixels in fixed mode. Default is @var{black}.
8653 @end table
8654
8655 @section find_rect
8656
8657 Find a rectangular object
8658
8659 It accepts the following options:
8660
8661 @table @option
8662 @item object
8663 Filepath of the object image, needs to be in gray8.
8664
8665 @item threshold
8666 Detection threshold, default is 0.5.
8667
8668 @item mipmaps
8669 Number of mipmaps, default is 3.
8670
8671 @item xmin, ymin, xmax, ymax
8672 Specifies the rectangle in which to search.
8673 @end table
8674
8675 @subsection Examples
8676
8677 @itemize
8678 @item
8679 Generate a representative palette of a given video using @command{ffmpeg}:
8680 @example
8681 ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
8682 @end example
8683 @end itemize
8684
8685 @section cover_rect
8686
8687 Cover a rectangular object
8688
8689 It accepts the following options:
8690
8691 @table @option
8692 @item cover
8693 Filepath of the optional cover image, needs to be in yuv420.
8694
8695 @item mode
8696 Set covering mode.
8697
8698 It accepts the following values:
8699 @table @samp
8700 @item cover
8701 cover it by the supplied image
8702 @item blur
8703 cover it by interpolating the surrounding pixels
8704 @end table
8705
8706 Default value is @var{blur}.
8707 @end table
8708
8709 @subsection Examples
8710
8711 @itemize
8712 @item
8713 Generate a representative palette of a given video using @command{ffmpeg}:
8714 @example
8715 ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
8716 @end example
8717 @end itemize
8718
8719 @section floodfill
8720
8721 Flood area with values of same pixel components with another values.
8722
8723 It accepts the following options:
8724 @table @option
8725 @item x
8726 Set pixel x coordinate.
8727
8728 @item y
8729 Set pixel y coordinate.
8730
8731 @item s0
8732 Set source #0 component value.
8733
8734 @item s1
8735 Set source #1 component value.
8736
8737 @item s2
8738 Set source #2 component value.
8739
8740 @item s3
8741 Set source #3 component value.
8742
8743 @item d0
8744 Set destination #0 component value.
8745
8746 @item d1
8747 Set destination #1 component value.
8748
8749 @item d2
8750 Set destination #2 component value.
8751
8752 @item d3
8753 Set destination #3 component value.
8754 @end table
8755
8756 @anchor{format}
8757 @section format
8758
8759 Convert the input video to one of the specified pixel formats.
8760 Libavfilter will try to pick one that is suitable as input to
8761 the next filter.
8762
8763 It accepts the following parameters:
8764 @table @option
8765
8766 @item pix_fmts
8767 A '|'-separated list of pixel format names, such as
8768 "pix_fmts=yuv420p|monow|rgb24".
8769
8770 @end table
8771
8772 @subsection Examples
8773
8774 @itemize
8775 @item
8776 Convert the input video to the @var{yuv420p} format
8777 @example
8778 format=pix_fmts=yuv420p
8779 @end example
8780
8781 Convert the input video to any of the formats in the list
8782 @example
8783 format=pix_fmts=yuv420p|yuv444p|yuv410p
8784 @end example
8785 @end itemize
8786
8787 @anchor{fps}
8788 @section fps
8789
8790 Convert the video to specified constant frame rate by duplicating or dropping
8791 frames as necessary.
8792
8793 It accepts the following parameters:
8794 @table @option
8795
8796 @item fps
8797 The desired output frame rate. The default is @code{25}.
8798
8799 @item start_time
8800 Assume the first PTS should be the given value, in seconds. This allows for
8801 padding/trimming at the start of stream. By default, no assumption is made
8802 about the first frame's expected PTS, so no padding or trimming is done.
8803 For example, this could be set to 0 to pad the beginning with duplicates of
8804 the first frame if a video stream starts after the audio stream or to trim any
8805 frames with a negative PTS.
8806
8807 @item round
8808 Timestamp (PTS) rounding method.
8809
8810 Possible values are:
8811 @table @option
8812 @item zero
8813 round towards 0
8814 @item inf
8815 round away from 0
8816 @item down
8817 round towards -infinity
8818 @item up
8819 round towards +infinity
8820 @item near
8821 round to nearest
8822 @end table
8823 The default is @code{near}.
8824
8825 @item eof_action
8826 Action performed when reading the last frame.
8827
8828 Possible values are:
8829 @table @option
8830 @item round
8831 Use same timestamp rounding method as used for other frames.
8832 @item pass
8833 Pass through last frame if input duration has not been reached yet.
8834 @end table
8835 The default is @code{round}.
8836
8837 @end table
8838
8839 Alternatively, the options can be specified as a flat string:
8840 @var{fps}[:@var{start_time}[:@var{round}]].
8841
8842 See also the @ref{setpts} filter.
8843
8844 @subsection Examples
8845
8846 @itemize
8847 @item
8848 A typical usage in order to set the fps to 25:
8849 @example
8850 fps=fps=25
8851 @end example
8852
8853 @item
8854 Sets the fps to 24, using abbreviation and rounding method to round to nearest:
8855 @example
8856 fps=fps=film:round=near
8857 @end example
8858 @end itemize
8859
8860 @section framepack
8861
8862 Pack two different video streams into a stereoscopic video, setting proper
8863 metadata on supported codecs. The two views should have the same size and
8864 framerate and processing will stop when the shorter video ends. Please note
8865 that you may conveniently adjust view properties with the @ref{scale} and
8866 @ref{fps} filters.
8867
8868 It accepts the following parameters:
8869 @table @option
8870
8871 @item format
8872 The desired packing format. Supported values are:
8873
8874 @table @option
8875
8876 @item sbs
8877 The views are next to each other (default).
8878
8879 @item tab
8880 The views are on top of each other.
8881
8882 @item lines
8883 The views are packed by line.
8884
8885 @item columns
8886 The views are packed by column.
8887
8888 @item frameseq
8889 The views are temporally interleaved.
8890
8891 @end table
8892
8893 @end table
8894
8895 Some examples:
8896
8897 @example
8898 # Convert left and right views into a frame-sequential video
8899 ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
8900
8901 # Convert views into a side-by-side video with the same output resolution as the input
8902 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
8903 @end example
8904
8905 @section framerate
8906
8907 Change the frame rate by interpolating new video output frames from the source
8908 frames.
8909
8910 This filter is not designed to function correctly with interlaced media. If
8911 you wish to change the frame rate of interlaced media then you are required
8912 to deinterlace before this filter and re-interlace after this filter.
8913
8914 A description of the accepted options follows.
8915
8916 @table @option
8917 @item fps
8918 Specify the output frames per second. This option can also be specified
8919 as a value alone. The default is @code{50}.
8920
8921 @item interp_start
8922 Specify the start of a range where the output frame will be created as a
8923 linear interpolation of two frames. The range is [@code{0}-@code{255}],
8924 the default is @code{15}.
8925
8926 @item interp_end
8927 Specify the end of a range where the output frame will be created as a
8928 linear interpolation of two frames. The range is [@code{0}-@code{255}],
8929 the default is @code{240}.
8930
8931 @item scene
8932 Specify the level at which a scene change is detected as a value between
8933 0 and 100 to indicate a new scene; a low value reflects a low
8934 probability for the current frame to introduce a new scene, while a higher
8935 value means the current frame is more likely to be one.
8936 The default is @code{7}.
8937
8938 @item flags
8939 Specify flags influencing the filter process.
8940
8941 Available value for @var{flags} is:
8942
8943 @table @option
8944 @item scene_change_detect, scd
8945 Enable scene change detection using the value of the option @var{scene}.
8946 This flag is enabled by default.
8947 @end table
8948 @end table
8949
8950 @section framestep
8951
8952 Select one frame every N-th frame.
8953
8954 This filter accepts the following option:
8955 @table @option
8956 @item step
8957 Select frame after every @code{step} frames.
8958 Allowed values are positive integers higher than 0. Default value is @code{1}.
8959 @end table
8960
8961 @anchor{frei0r}
8962 @section frei0r
8963
8964 Apply a frei0r effect to the input video.
8965
8966 To enable the compilation of this filter, you need to install the frei0r
8967 header and configure FFmpeg with @code{--enable-frei0r}.
8968
8969 It accepts the following parameters:
8970
8971 @table @option
8972
8973 @item filter_name
8974 The name of the frei0r effect to load. If the environment variable
8975 @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
8976 directories specified by the colon-separated list in @env{FREI0R_PATH}.
8977 Otherwise, the standard frei0r paths are searched, in this order:
8978 @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
8979 @file{/usr/lib/frei0r-1/}.
8980
8981 @item filter_params
8982 A '|'-separated list of parameters to pass to the frei0r effect.
8983
8984 @end table
8985
8986 A frei0r effect parameter can be a boolean (its value is either
8987 "y" or "n"), a double, a color (specified as
8988 @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
8989 numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
8990 section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
8991 @var{X} and @var{Y} are floating point numbers) and/or a string.
8992
8993 The number and types of parameters depend on the loaded effect. If an
8994 effect parameter is not specified, the default value is set.
8995
8996 @subsection Examples
8997
8998 @itemize
8999 @item
9000 Apply the distort0r effect, setting the first two double parameters:
9001 @example
9002 frei0r=filter_name=distort0r:filter_params=0.5|0.01
9003 @end example
9004
9005 @item
9006 Apply the colordistance effect, taking a color as the first parameter:
9007 @example
9008 frei0r=colordistance:0.2/0.3/0.4
9009 frei0r=colordistance:violet
9010 frei0r=colordistance:0x112233
9011 @end example
9012
9013 @item
9014 Apply the perspective effect, specifying the top left and top right image
9015 positions:
9016 @example
9017 frei0r=perspective:0.2/0.2|0.8/0.2
9018 @end example
9019 @end itemize
9020
9021 For more information, see
9022 @url{http://frei0r.dyne.org}
9023
9024 @section fspp
9025
9026 Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
9027
9028 It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
9029 processing filter, one of them is performed once per block, not per pixel.
9030 This allows for much higher speed.
9031
9032 The filter accepts the following options:
9033
9034 @table @option
9035 @item quality
9036 Set quality. This option defines the number of levels for averaging. It accepts
9037 an integer in the range 4-5. Default value is @code{4}.
9038
9039 @item qp
9040 Force a constant quantization parameter. It accepts an integer in range 0-63.
9041 If not set, the filter will use the QP from the video stream (if available).
9042
9043 @item strength
9044 Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
9045 more details but also more artifacts, while higher values make the image smoother
9046 but also blurrier. Default value is @code{0} âˆ’ PSNR optimal.
9047
9048 @item use_bframe_qp
9049 Enable the use of the QP from the B-Frames if set to @code{1}. Using this
9050 option may cause flicker since the B-Frames have often larger QP. Default is
9051 @code{0} (not enabled).
9052
9053 @end table
9054
9055 @section gblur
9056
9057 Apply Gaussian blur filter.
9058
9059 The filter accepts the following options:
9060
9061 @table @option
9062 @item sigma
9063 Set horizontal sigma, standard deviation of Gaussian blur. Default is @code{0.5}.
9064
9065 @item steps
9066 Set number of steps for Gaussian approximation. Defauls is @code{1}.
9067
9068 @item planes
9069 Set which planes to filter. By default all planes are filtered.
9070
9071 @item sigmaV
9072 Set vertical sigma, if negative it will be same as @code{sigma}.
9073 Default is @code{-1}.
9074 @end table
9075
9076 @section geq
9077
9078 The filter accepts the following options:
9079
9080 @table @option
9081 @item lum_expr, lum
9082 Set the luminance expression.
9083 @item cb_expr, cb
9084 Set the chrominance blue expression.
9085 @item cr_expr, cr
9086 Set the chrominance red expression.
9087 @item alpha_expr, a
9088 Set the alpha expression.
9089 @item red_expr, r
9090 Set the red expression.
9091 @item green_expr, g
9092 Set the green expression.
9093 @item blue_expr, b
9094 Set the blue expression.
9095 @end table
9096
9097 The colorspace is selected according to the specified options. If one
9098 of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
9099 options is specified, the filter will automatically select a YCbCr
9100 colorspace. If one of the @option{red_expr}, @option{green_expr}, or
9101 @option{blue_expr} options is specified, it will select an RGB
9102 colorspace.
9103
9104 If one of the chrominance expression is not defined, it falls back on the other
9105 one. If no alpha expression is specified it will evaluate to opaque value.
9106 If none of chrominance expressions are specified, they will evaluate
9107 to the luminance expression.
9108
9109 The expressions can use the following variables and functions:
9110
9111 @table @option
9112 @item N
9113 The sequential number of the filtered frame, starting from @code{0}.
9114
9115 @item X
9116 @item Y
9117 The coordinates of the current sample.
9118
9119 @item W
9120 @item H
9121 The width and height of the image.
9122
9123 @item SW
9124 @item SH
9125 Width and height scale depending on the currently filtered plane. It is the
9126 ratio between the corresponding luma plane number of pixels and the current
9127 plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
9128 @code{0.5,0.5} for chroma planes.
9129
9130 @item T
9131 Time of the current frame, expressed in seconds.
9132
9133 @item p(x, y)
9134 Return the value of the pixel at location (@var{x},@var{y}) of the current
9135 plane.
9136
9137 @item lum(x, y)
9138 Return the value of the pixel at location (@var{x},@var{y}) of the luminance
9139 plane.
9140
9141 @item cb(x, y)
9142 Return the value of the pixel at location (@var{x},@var{y}) of the
9143 blue-difference chroma plane. Return 0 if there is no such plane.
9144
9145 @item cr(x, y)
9146 Return the value of the pixel at location (@var{x},@var{y}) of the
9147 red-difference chroma plane. Return 0 if there is no such plane.
9148
9149 @item r(x, y)
9150 @item g(x, y)
9151 @item b(x, y)
9152 Return the value of the pixel at location (@var{x},@var{y}) of the
9153 red/green/blue component. Return 0 if there is no such component.
9154
9155 @item alpha(x, y)
9156 Return the value of the pixel at location (@var{x},@var{y}) of the alpha
9157 plane. Return 0 if there is no such plane.
9158 @end table
9159
9160 For functions, if @var{x} and @var{y} are outside the area, the value will be
9161 automatically clipped to the closer edge.
9162
9163 @subsection Examples
9164
9165 @itemize
9166 @item
9167 Flip the image horizontally:
9168 @example
9169 geq=p(W-X\,Y)
9170 @end example
9171
9172 @item
9173 Generate a bidimensional sine wave, with angle @code{PI/3} and a
9174 wavelength of 100 pixels:
9175 @example
9176 geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
9177 @end example
9178
9179 @item
9180 Generate a fancy enigmatic moving light:
9181 @example
9182 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
9183 @end example
9184
9185 @item
9186 Generate a quick emboss effect:
9187 @example
9188 format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
9189 @end example
9190
9191 @item
9192 Modify RGB components depending on pixel position:
9193 @example
9194 geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
9195 @end example
9196
9197 @item
9198 Create a radial gradient that is the same size as the input (also see
9199 the @ref{vignette} filter):
9200 @example
9201 geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
9202 @end example
9203 @end itemize
9204
9205 @section gradfun
9206
9207 Fix the banding artifacts that are sometimes introduced into nearly flat
9208 regions by truncation to 8-bit color depth.
9209 Interpolate the gradients that should go where the bands are, and
9210 dither them.
9211
9212 It is designed for playback only.  Do not use it prior to
9213 lossy compression, because compression tends to lose the dither and
9214 bring back the bands.
9215
9216 It accepts the following parameters:
9217
9218 @table @option
9219
9220 @item strength
9221 The maximum amount by which the filter will change any one pixel. This is also
9222 the threshold for detecting nearly flat regions. Acceptable values range from
9223 .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
9224 valid range.
9225
9226 @item radius
9227 The neighborhood to fit the gradient to. A larger radius makes for smoother
9228 gradients, but also prevents the filter from modifying the pixels near detailed
9229 regions. Acceptable values are 8-32; the default value is 16. Out-of-range
9230 values will be clipped to the valid range.
9231
9232 @end table
9233
9234 Alternatively, the options can be specified as a flat string:
9235 @var{strength}[:@var{radius}]
9236
9237 @subsection Examples
9238
9239 @itemize
9240 @item
9241 Apply the filter with a @code{3.5} strength and radius of @code{8}:
9242 @example
9243 gradfun=3.5:8
9244 @end example
9245
9246 @item
9247 Specify radius, omitting the strength (which will fall-back to the default
9248 value):
9249 @example
9250 gradfun=radius=8
9251 @end example
9252
9253 @end itemize
9254
9255 @anchor{haldclut}
9256 @section haldclut
9257
9258 Apply a Hald CLUT to a video stream.
9259
9260 First input is the video stream to process, and second one is the Hald CLUT.
9261 The Hald CLUT input can be a simple picture or a complete video stream.
9262
9263 The filter accepts the following options:
9264
9265 @table @option
9266 @item shortest
9267 Force termination when the shortest input terminates. Default is @code{0}.
9268 @item repeatlast
9269 Continue applying the last CLUT after the end of the stream. A value of
9270 @code{0} disable the filter after the last frame of the CLUT is reached.
9271 Default is @code{1}.
9272 @end table
9273
9274 @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
9275 filters share the same internals).
9276
9277 More information about the Hald CLUT can be found on Eskil Steenberg's website
9278 (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
9279
9280 @subsection Workflow examples
9281
9282 @subsubsection Hald CLUT video stream
9283
9284 Generate an identity Hald CLUT stream altered with various effects:
9285 @example
9286 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
9287 @end example
9288
9289 Note: make sure you use a lossless codec.
9290
9291 Then use it with @code{haldclut} to apply it on some random stream:
9292 @example
9293 ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
9294 @end example
9295
9296 The Hald CLUT will be applied to the 10 first seconds (duration of
9297 @file{clut.nut}), then the latest picture of that CLUT stream will be applied
9298 to the remaining frames of the @code{mandelbrot} stream.
9299
9300 @subsubsection Hald CLUT with preview
9301
9302 A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
9303 @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
9304 biggest possible square starting at the top left of the picture. The remaining
9305 padding pixels (bottom or right) will be ignored. This area can be used to add
9306 a preview of the Hald CLUT.
9307
9308 Typically, the following generated Hald CLUT will be supported by the
9309 @code{haldclut} filter:
9310
9311 @example
9312 ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
9313    pad=iw+320 [padded_clut];
9314    smptebars=s=320x256, split [a][b];
9315    [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
9316    [main][b] overlay=W-320" -frames:v 1 clut.png
9317 @end example
9318
9319 It contains the original and a preview of the effect of the CLUT: SMPTE color
9320 bars are displayed on the right-top, and below the same color bars processed by
9321 the color changes.
9322
9323 Then, the effect of this Hald CLUT can be visualized with:
9324 @example
9325 ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
9326 @end example
9327
9328 @section hflip
9329
9330 Flip the input video horizontally.
9331
9332 For example, to horizontally flip the input video with @command{ffmpeg}:
9333 @example
9334 ffmpeg -i in.avi -vf "hflip" out.avi
9335 @end example
9336
9337 @section histeq
9338 This filter applies a global color histogram equalization on a
9339 per-frame basis.
9340
9341 It can be used to correct video that has a compressed range of pixel
9342 intensities.  The filter redistributes the pixel intensities to
9343 equalize their distribution across the intensity range. It may be
9344 viewed as an "automatically adjusting contrast filter". This filter is
9345 useful only for correcting degraded or poorly captured source
9346 video.
9347
9348 The filter accepts the following options:
9349
9350 @table @option
9351 @item strength
9352 Determine the amount of equalization to be applied.  As the strength
9353 is reduced, the distribution of pixel intensities more-and-more
9354 approaches that of the input frame. The value must be a float number
9355 in the range [0,1] and defaults to 0.200.
9356
9357 @item intensity
9358 Set the maximum intensity that can generated and scale the output
9359 values appropriately.  The strength should be set as desired and then
9360 the intensity can be limited if needed to avoid washing-out. The value
9361 must be a float number in the range [0,1] and defaults to 0.210.
9362
9363 @item antibanding
9364 Set the antibanding level. If enabled the filter will randomly vary
9365 the luminance of output pixels by a small amount to avoid banding of
9366 the histogram. Possible values are @code{none}, @code{weak} or
9367 @code{strong}. It defaults to @code{none}.
9368 @end table
9369
9370 @section histogram
9371
9372 Compute and draw a color distribution histogram for the input video.
9373
9374 The computed histogram is a representation of the color component
9375 distribution in an image.
9376
9377 Standard histogram displays the color components distribution in an image.
9378 Displays color graph for each color component. Shows distribution of
9379 the Y, U, V, A or R, G, B components, depending on input format, in the
9380 current frame. Below each graph a color component scale meter is shown.
9381
9382 The filter accepts the following options:
9383
9384 @table @option
9385 @item level_height
9386 Set height of level. Default value is @code{200}.
9387 Allowed range is [50, 2048].
9388
9389 @item scale_height
9390 Set height of color scale. Default value is @code{12}.
9391 Allowed range is [0, 40].
9392
9393 @item display_mode
9394 Set display mode.
9395 It accepts the following values:
9396 @table @samp
9397 @item stack
9398 Per color component graphs are placed below each other.
9399
9400 @item parade
9401 Per color component graphs are placed side by side.
9402
9403 @item overlay
9404 Presents information identical to that in the @code{parade}, except
9405 that the graphs representing color components are superimposed directly
9406 over one another.
9407 @end table
9408 Default is @code{stack}.
9409
9410 @item levels_mode
9411 Set mode. Can be either @code{linear}, or @code{logarithmic}.
9412 Default is @code{linear}.
9413
9414 @item components
9415 Set what color components to display.
9416 Default is @code{7}.
9417
9418 @item fgopacity
9419 Set foreground opacity. Default is @code{0.7}.
9420
9421 @item bgopacity
9422 Set background opacity. Default is @code{0.5}.
9423 @end table
9424
9425 @subsection Examples
9426
9427 @itemize
9428
9429 @item
9430 Calculate and draw histogram:
9431 @example
9432 ffplay -i input -vf histogram
9433 @end example
9434
9435 @end itemize
9436
9437 @anchor{hqdn3d}
9438 @section hqdn3d
9439
9440 This is a high precision/quality 3d denoise filter. It aims to reduce
9441 image noise, producing smooth images and making still images really
9442 still. It should enhance compressibility.
9443
9444 It accepts the following optional parameters:
9445
9446 @table @option
9447 @item luma_spatial
9448 A non-negative floating point number which specifies spatial luma strength.
9449 It defaults to 4.0.
9450
9451 @item chroma_spatial
9452 A non-negative floating point number which specifies spatial chroma strength.
9453 It defaults to 3.0*@var{luma_spatial}/4.0.
9454
9455 @item luma_tmp
9456 A floating point number which specifies luma temporal strength. It defaults to
9457 6.0*@var{luma_spatial}/4.0.
9458
9459 @item chroma_tmp
9460 A floating point number which specifies chroma temporal strength. It defaults to
9461 @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
9462 @end table
9463
9464 @section hwdownload
9465
9466 Download hardware frames to system memory.
9467
9468 The input must be in hardware frames, and the output a non-hardware format.
9469 Not all formats will be supported on the output - it may be necessary to insert
9470 an additional @option{format} filter immediately following in the graph to get
9471 the output in a supported format.
9472
9473 @section hwmap
9474
9475 Map hardware frames to system memory or to another device.
9476
9477 This filter has several different modes of operation; which one is used depends
9478 on the input and output formats:
9479 @itemize
9480 @item
9481 Hardware frame input, normal frame output
9482
9483 Map the input frames to system memory and pass them to the output.  If the
9484 original hardware frame is later required (for example, after overlaying
9485 something else on part of it), the @option{hwmap} filter can be used again
9486 in the next mode to retrieve it.
9487 @item
9488 Normal frame input, hardware frame output
9489
9490 If the input is actually a software-mapped hardware frame, then unmap it -
9491 that is, return the original hardware frame.
9492
9493 Otherwise, a device must be provided.  Create new hardware surfaces on that
9494 device for the output, then map them back to the software format at the input
9495 and give those frames to the preceding filter.  This will then act like the
9496 @option{hwupload} filter, but may be able to avoid an additional copy when
9497 the input is already in a compatible format.
9498 @item
9499 Hardware frame input and output
9500
9501 A device must be supplied for the output, either directly or with the
9502 @option{derive_device} option.  The input and output devices must be of
9503 different types and compatible - the exact meaning of this is
9504 system-dependent, but typically it means that they must refer to the same
9505 underlying hardware context (for example, refer to the same graphics card).
9506
9507 If the input frames were originally created on the output device, then unmap
9508 to retrieve the original frames.
9509
9510 Otherwise, map the frames to the output device - create new hardware frames
9511 on the output corresponding to the frames on the input.
9512 @end itemize
9513
9514 The following additional parameters are accepted:
9515
9516 @table @option
9517 @item mode
9518 Set the frame mapping mode.  Some combination of:
9519 @table @var
9520 @item read
9521 The mapped frame should be readable.
9522 @item write
9523 The mapped frame should be writeable.
9524 @item overwrite
9525 The mapping will always overwrite the entire frame.
9526
9527 This may improve performance in some cases, as the original contents of the
9528 frame need not be loaded.
9529 @item direct
9530 The mapping must not involve any copying.
9531
9532 Indirect mappings to copies of frames are created in some cases where either
9533 direct mapping is not possible or it would have unexpected properties.
9534 Setting this flag ensures that the mapping is direct and will fail if that is
9535 not possible.
9536 @end table
9537 Defaults to @var{read+write} if not specified.
9538
9539 @item derive_device @var{type}
9540 Rather than using the device supplied at initialisation, instead derive a new
9541 device of type @var{type} from the device the input frames exist on.
9542
9543 @item reverse
9544 In a hardware to hardware mapping, map in reverse - create frames in the sink
9545 and map them back to the source.  This may be necessary in some cases where
9546 a mapping in one direction is required but only the opposite direction is
9547 supported by the devices being used.
9548
9549 This option is dangerous - it may break the preceding filter in undefined
9550 ways if there are any additional constraints on that filter's output.
9551 Do not use it without fully understanding the implications of its use.
9552 @end table
9553
9554 @section hwupload
9555
9556 Upload system memory frames to hardware surfaces.
9557
9558 The device to upload to must be supplied when the filter is initialised.  If
9559 using ffmpeg, select the appropriate device with the @option{-filter_hw_device}
9560 option.
9561
9562 @anchor{hwupload_cuda}
9563 @section hwupload_cuda
9564
9565 Upload system memory frames to a CUDA device.
9566
9567 It accepts the following optional parameters:
9568
9569 @table @option
9570 @item device
9571 The number of the CUDA device to use
9572 @end table
9573
9574 @section hqx
9575
9576 Apply a high-quality magnification filter designed for pixel art. This filter
9577 was originally created by Maxim Stepin.
9578
9579 It accepts the following option:
9580
9581 @table @option
9582 @item n
9583 Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
9584 @code{hq3x} and @code{4} for @code{hq4x}.
9585 Default is @code{3}.
9586 @end table
9587
9588 @section hstack
9589 Stack input videos horizontally.
9590
9591 All streams must be of same pixel format and of same height.
9592
9593 Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
9594 to create same output.
9595
9596 The filter accept the following option:
9597
9598 @table @option
9599 @item inputs
9600 Set number of input streams. Default is 2.
9601
9602 @item shortest
9603 If set to 1, force the output to terminate when the shortest input
9604 terminates. Default value is 0.
9605 @end table
9606
9607 @section hue
9608
9609 Modify the hue and/or the saturation of the input.
9610
9611 It accepts the following parameters:
9612
9613 @table @option
9614 @item h
9615 Specify the hue angle as a number of degrees. It accepts an expression,
9616 and defaults to "0".
9617
9618 @item s
9619 Specify the saturation in the [-10,10] range. It accepts an expression and
9620 defaults to "1".
9621
9622 @item H
9623 Specify the hue angle as a number of radians. It accepts an
9624 expression, and defaults to "0".
9625
9626 @item b
9627 Specify the brightness in the [-10,10] range. It accepts an expression and
9628 defaults to "0".
9629 @end table
9630
9631 @option{h} and @option{H} are mutually exclusive, and can't be
9632 specified at the same time.
9633
9634 The @option{b}, @option{h}, @option{H} and @option{s} option values are
9635 expressions containing the following constants:
9636
9637 @table @option
9638 @item n
9639 frame count of the input frame starting from 0
9640
9641 @item pts
9642 presentation timestamp of the input frame expressed in time base units
9643
9644 @item r
9645 frame rate of the input video, NAN if the input frame rate is unknown
9646
9647 @item t
9648 timestamp expressed in seconds, NAN if the input timestamp is unknown
9649
9650 @item tb
9651 time base of the input video
9652 @end table
9653
9654 @subsection Examples
9655
9656 @itemize
9657 @item
9658 Set the hue to 90 degrees and the saturation to 1.0:
9659 @example
9660 hue=h=90:s=1
9661 @end example
9662
9663 @item
9664 Same command but expressing the hue in radians:
9665 @example
9666 hue=H=PI/2:s=1
9667 @end example
9668
9669 @item
9670 Rotate hue and make the saturation swing between 0
9671 and 2 over a period of 1 second:
9672 @example
9673 hue="H=2*PI*t: s=sin(2*PI*t)+1"
9674 @end example
9675
9676 @item
9677 Apply a 3 seconds saturation fade-in effect starting at 0:
9678 @example
9679 hue="s=min(t/3\,1)"
9680 @end example
9681
9682 The general fade-in expression can be written as:
9683 @example
9684 hue="s=min(0\, max((t-START)/DURATION\, 1))"
9685 @end example
9686
9687 @item
9688 Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
9689 @example
9690 hue="s=max(0\, min(1\, (8-t)/3))"
9691 @end example
9692
9693 The general fade-out expression can be written as:
9694 @example
9695 hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
9696 @end example
9697
9698 @end itemize
9699
9700 @subsection Commands
9701
9702 This filter supports the following commands:
9703 @table @option
9704 @item b
9705 @item s
9706 @item h
9707 @item H
9708 Modify the hue and/or the saturation and/or brightness of the input video.
9709 The command accepts the same syntax of the corresponding option.
9710
9711 If the specified expression is not valid, it is kept at its current
9712 value.
9713 @end table
9714
9715 @section hysteresis
9716
9717 Grow first stream into second stream by connecting components.
9718 This makes it possible to build more robust edge masks.
9719
9720 This filter accepts the following options:
9721
9722 @table @option
9723 @item planes
9724 Set which planes will be processed as bitmap, unprocessed planes will be
9725 copied from first stream.
9726 By default value 0xf, all planes will be processed.
9727
9728 @item threshold
9729 Set threshold which is used in filtering. If pixel component value is higher than
9730 this value filter algorithm for connecting components is activated.
9731 By default value is 0.
9732 @end table
9733
9734 @section idet
9735
9736 Detect video interlacing type.
9737
9738 This filter tries to detect if the input frames are interlaced, progressive,
9739 top or bottom field first. It will also try to detect fields that are
9740 repeated between adjacent frames (a sign of telecine).
9741
9742 Single frame detection considers only immediately adjacent frames when classifying each frame.
9743 Multiple frame detection incorporates the classification history of previous frames.
9744
9745 The filter will log these metadata values:
9746
9747 @table @option
9748 @item single.current_frame
9749 Detected type of current frame using single-frame detection. One of:
9750 ``tff'' (top field first), ``bff'' (bottom field first),
9751 ``progressive'', or ``undetermined''
9752
9753 @item single.tff
9754 Cumulative number of frames detected as top field first using single-frame detection.
9755
9756 @item multiple.tff
9757 Cumulative number of frames detected as top field first using multiple-frame detection.
9758
9759 @item single.bff
9760 Cumulative number of frames detected as bottom field first using single-frame detection.
9761
9762 @item multiple.current_frame
9763 Detected type of current frame using multiple-frame detection. One of:
9764 ``tff'' (top field first), ``bff'' (bottom field first),
9765 ``progressive'', or ``undetermined''
9766
9767 @item multiple.bff
9768 Cumulative number of frames detected as bottom field first using multiple-frame detection.
9769
9770 @item single.progressive
9771 Cumulative number of frames detected as progressive using single-frame detection.
9772
9773 @item multiple.progressive
9774 Cumulative number of frames detected as progressive using multiple-frame detection.
9775
9776 @item single.undetermined
9777 Cumulative number of frames that could not be classified using single-frame detection.
9778
9779 @item multiple.undetermined
9780 Cumulative number of frames that could not be classified using multiple-frame detection.
9781
9782 @item repeated.current_frame
9783 Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
9784
9785 @item repeated.neither
9786 Cumulative number of frames with no repeated field.
9787
9788 @item repeated.top
9789 Cumulative number of frames with the top field repeated from the previous frame's top field.
9790
9791 @item repeated.bottom
9792 Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
9793 @end table
9794
9795 The filter accepts the following options:
9796
9797 @table @option
9798 @item intl_thres
9799 Set interlacing threshold.
9800 @item prog_thres
9801 Set progressive threshold.
9802 @item rep_thres
9803 Threshold for repeated field detection.
9804 @item half_life
9805 Number of frames after which a given frame's contribution to the
9806 statistics is halved (i.e., it contributes only 0.5 to its
9807 classification). The default of 0 means that all frames seen are given
9808 full weight of 1.0 forever.
9809 @item analyze_interlaced_flag
9810 When this is not 0 then idet will use the specified number of frames to determine
9811 if the interlaced flag is accurate, it will not count undetermined frames.
9812 If the flag is found to be accurate it will be used without any further
9813 computations, if it is found to be inaccurate it will be cleared without any
9814 further computations. This allows inserting the idet filter as a low computational
9815 method to clean up the interlaced flag
9816 @end table
9817
9818 @section il
9819
9820 Deinterleave or interleave fields.
9821
9822 This filter allows one to process interlaced images fields without
9823 deinterlacing them. Deinterleaving splits the input frame into 2
9824 fields (so called half pictures). Odd lines are moved to the top
9825 half of the output image, even lines to the bottom half.
9826 You can process (filter) them independently and then re-interleave them.
9827
9828 The filter accepts the following options:
9829
9830 @table @option
9831 @item luma_mode, l
9832 @item chroma_mode, c
9833 @item alpha_mode, a
9834 Available values for @var{luma_mode}, @var{chroma_mode} and
9835 @var{alpha_mode} are:
9836
9837 @table @samp
9838 @item none
9839 Do nothing.
9840
9841 @item deinterleave, d
9842 Deinterleave fields, placing one above the other.
9843
9844 @item interleave, i
9845 Interleave fields. Reverse the effect of deinterleaving.
9846 @end table
9847 Default value is @code{none}.
9848
9849 @item luma_swap, ls
9850 @item chroma_swap, cs
9851 @item alpha_swap, as
9852 Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
9853 @end table
9854
9855 @section inflate
9856
9857 Apply inflate effect to the video.
9858
9859 This filter replaces the pixel by the local(3x3) average by taking into account
9860 only values higher than the pixel.
9861
9862 It accepts the following options:
9863
9864 @table @option
9865 @item threshold0
9866 @item threshold1
9867 @item threshold2
9868 @item threshold3
9869 Limit the maximum change for each plane, default is 65535.
9870 If 0, plane will remain unchanged.
9871 @end table
9872
9873 @section interlace
9874
9875 Simple interlacing filter from progressive contents. This interleaves upper (or
9876 lower) lines from odd frames with lower (or upper) lines from even frames,
9877 halving the frame rate and preserving image height.
9878
9879 @example
9880    Original        Original             New Frame
9881    Frame 'j'      Frame 'j+1'             (tff)
9882   ==========      ===========       ==================
9883     Line 0  -------------------->    Frame 'j' Line 0
9884     Line 1          Line 1  ---->   Frame 'j+1' Line 1
9885     Line 2 --------------------->    Frame 'j' Line 2
9886     Line 3          Line 3  ---->   Frame 'j+1' Line 3
9887      ...             ...                   ...
9888 New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
9889 @end example
9890
9891 It accepts the following optional parameters:
9892
9893 @table @option
9894 @item scan
9895 This determines whether the interlaced frame is taken from the even
9896 (tff - default) or odd (bff) lines of the progressive frame.
9897
9898 @item lowpass
9899 Vertical lowpass filter to avoid twitter interlacing and
9900 reduce moire patterns.
9901
9902 @table @samp
9903 @item 0, off
9904 Disable vertical lowpass filter
9905
9906 @item 1, linear
9907 Enable linear filter (default)
9908
9909 @item 2, complex
9910 Enable complex filter. This will slightly less reduce twitter and moire
9911 but better retain detail and subjective sharpness impression.
9912
9913 @end table
9914 @end table
9915
9916 @section kerndeint
9917
9918 Deinterlace input video by applying Donald Graft's adaptive kernel
9919 deinterling. Work on interlaced parts of a video to produce
9920 progressive frames.
9921
9922 The description of the accepted parameters follows.
9923
9924 @table @option
9925 @item thresh
9926 Set the threshold which affects the filter's tolerance when
9927 determining if a pixel line must be processed. It must be an integer
9928 in the range [0,255] and defaults to 10. A value of 0 will result in
9929 applying the process on every pixels.
9930
9931 @item map
9932 Paint pixels exceeding the threshold value to white if set to 1.
9933 Default is 0.
9934
9935 @item order
9936 Set the fields order. Swap fields if set to 1, leave fields alone if
9937 0. Default is 0.
9938
9939 @item sharp
9940 Enable additional sharpening if set to 1. Default is 0.
9941
9942 @item twoway
9943 Enable twoway sharpening if set to 1. Default is 0.
9944 @end table
9945
9946 @subsection Examples
9947
9948 @itemize
9949 @item
9950 Apply default values:
9951 @example
9952 kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
9953 @end example
9954
9955 @item
9956 Enable additional sharpening:
9957 @example
9958 kerndeint=sharp=1
9959 @end example
9960
9961 @item
9962 Paint processed pixels in white:
9963 @example
9964 kerndeint=map=1
9965 @end example
9966 @end itemize
9967
9968 @section lenscorrection
9969
9970 Correct radial lens distortion
9971
9972 This filter can be used to correct for radial distortion as can result from the use
9973 of wide angle lenses, and thereby re-rectify the image. To find the right parameters
9974 one can use tools available for example as part of opencv or simply trial-and-error.
9975 To use opencv use the calibration sample (under samples/cpp) from the opencv sources
9976 and extract the k1 and k2 coefficients from the resulting matrix.
9977
9978 Note that effectively the same filter is available in the open-source tools Krita and
9979 Digikam from the KDE project.
9980
9981 In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
9982 this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
9983 brightness distribution, so you may want to use both filters together in certain
9984 cases, though you will have to take care of ordering, i.e. whether vignetting should
9985 be applied before or after lens correction.
9986
9987 @subsection Options
9988
9989 The filter accepts the following options:
9990
9991 @table @option
9992 @item cx
9993 Relative x-coordinate of the focal point of the image, and thereby the center of the
9994 distortion. This value has a range [0,1] and is expressed as fractions of the image
9995 width.
9996 @item cy
9997 Relative y-coordinate of the focal point of the image, and thereby the center of the
9998 distortion. This value has a range [0,1] and is expressed as fractions of the image
9999 height.
10000 @item k1
10001 Coefficient of the quadratic correction term. 0.5 means no correction.
10002 @item k2
10003 Coefficient of the double quadratic correction term. 0.5 means no correction.
10004 @end table
10005
10006 The formula that generates the correction is:
10007
10008 @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)
10009
10010 where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
10011 distances from the focal point in the source and target images, respectively.
10012
10013 @section libvmaf
10014
10015 Obtain the VMAF (Video Multi-Method Assessment Fusion)
10016 score between two input videos.
10017
10018 The obtained VMAF score is printed through the logging system.
10019
10020 It requires Netflix's vmaf library (libvmaf) as a pre-requisite.
10021 After installing the library it can be enabled using:
10022 @code{./configure --enable-libvmaf}.
10023 If no model path is specified it uses the default model: @code{vmaf_v0.6.1.pkl}.
10024
10025 The filter has following options:
10026
10027 @table @option
10028 @item model_path
10029 Set the model path which is to be used for SVM.
10030 Default value: @code{"vmaf_v0.6.1.pkl"}
10031
10032 @item log_path
10033 Set the file path to be used to store logs.
10034
10035 @item log_fmt
10036 Set the format of the log file (xml or json).
10037
10038 @item enable_transform
10039 Enables transform for computing vmaf.
10040
10041 @item phone_model
10042 Invokes the phone model which will generate VMAF scores higher than in the
10043 regular model, which is more suitable for laptop, TV, etc. viewing conditions.
10044
10045 @item psnr
10046 Enables computing psnr along with vmaf.
10047
10048 @item ssim
10049 Enables computing ssim along with vmaf.
10050
10051 @item ms_ssim
10052 Enables computing ms_ssim along with vmaf.
10053
10054 @item pool
10055 Set the pool method (mean, min or harmonic mean) to be used for computing vmaf.
10056 @end table
10057
10058 This filter also supports the @ref{framesync} options.
10059
10060 On the below examples the input file @file{main.mpg} being processed is
10061 compared with the reference file @file{ref.mpg}.
10062
10063 @example
10064 ffmpeg -i main.mpg -i ref.mpg -lavfi libvmaf -f null -
10065 @end example
10066
10067 Example with options:
10068 @example
10069 ffmpeg -i main.mpg -i ref.mpg -lavfi libvmaf="psnr=1:enable-transform=1" -f null -
10070 @end example
10071
10072 @section limiter
10073
10074 Limits the pixel components values to the specified range [min, max].
10075
10076 The filter accepts the following options:
10077
10078 @table @option
10079 @item min
10080 Lower bound. Defaults to the lowest allowed value for the input.
10081
10082 @item max
10083 Upper bound. Defaults to the highest allowed value for the input.
10084
10085 @item planes
10086 Specify which planes will be processed. Defaults to all available.
10087 @end table
10088
10089 @section loop
10090
10091 Loop video frames.
10092
10093 The filter accepts the following options:
10094
10095 @table @option
10096 @item loop
10097 Set the number of loops. Setting this value to -1 will result in infinite loops.
10098 Default is 0.
10099
10100 @item size
10101 Set maximal size in number of frames. Default is 0.
10102
10103 @item start
10104 Set first frame of loop. Default is 0.
10105 @end table
10106
10107 @anchor{lut3d}
10108 @section lut3d
10109
10110 Apply a 3D LUT to an input video.
10111
10112 The filter accepts the following options:
10113
10114 @table @option
10115 @item file
10116 Set the 3D LUT file name.
10117
10118 Currently supported formats:
10119 @table @samp
10120 @item 3dl
10121 AfterEffects
10122 @item cube
10123 Iridas
10124 @item dat
10125 DaVinci
10126 @item m3d
10127 Pandora
10128 @end table
10129 @item interp
10130 Select interpolation mode.
10131
10132 Available values are:
10133
10134 @table @samp
10135 @item nearest
10136 Use values from the nearest defined point.
10137 @item trilinear
10138 Interpolate values using the 8 points defining a cube.
10139 @item tetrahedral
10140 Interpolate values using a tetrahedron.
10141 @end table
10142 @end table
10143
10144 This filter also supports the @ref{framesync} options.
10145
10146 @section lumakey
10147
10148 Turn certain luma values into transparency.
10149
10150 The filter accepts the following options:
10151
10152 @table @option
10153 @item threshold
10154 Set the luma which will be used as base for transparency.
10155 Default value is @code{0}.
10156
10157 @item tolerance
10158 Set the range of luma values to be keyed out.
10159 Default value is @code{0}.
10160
10161 @item softness
10162 Set the range of softness. Default value is @code{0}.
10163 Use this to control gradual transition from zero to full transparency.
10164 @end table
10165
10166 @section lut, lutrgb, lutyuv
10167
10168 Compute a look-up table for binding each pixel component input value
10169 to an output value, and apply it to the input video.
10170
10171 @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
10172 to an RGB input video.
10173
10174 These filters accept the following parameters:
10175 @table @option
10176 @item c0
10177 set first pixel component expression
10178 @item c1
10179 set second pixel component expression
10180 @item c2
10181 set third pixel component expression
10182 @item c3
10183 set fourth pixel component expression, corresponds to the alpha component
10184
10185 @item r
10186 set red component expression
10187 @item g
10188 set green component expression
10189 @item b
10190 set blue component expression
10191 @item a
10192 alpha component expression
10193
10194 @item y
10195 set Y/luminance component expression
10196 @item u
10197 set U/Cb component expression
10198 @item v
10199 set V/Cr component expression
10200 @end table
10201
10202 Each of them specifies the expression to use for computing the lookup table for
10203 the corresponding pixel component values.
10204
10205 The exact component associated to each of the @var{c*} options depends on the
10206 format in input.
10207
10208 The @var{lut} filter requires either YUV or RGB pixel formats in input,
10209 @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
10210
10211 The expressions can contain the following constants and functions:
10212
10213 @table @option
10214 @item w
10215 @item h
10216 The input width and height.
10217
10218 @item val
10219 The input value for the pixel component.
10220
10221 @item clipval
10222 The input value, clipped to the @var{minval}-@var{maxval} range.
10223
10224 @item maxval
10225 The maximum value for the pixel component.
10226
10227 @item minval
10228 The minimum value for the pixel component.
10229
10230 @item negval
10231 The negated value for the pixel component value, clipped to the
10232 @var{minval}-@var{maxval} range; it corresponds to the expression
10233 "maxval-clipval+minval".
10234
10235 @item clip(val)
10236 The computed value in @var{val}, clipped to the
10237 @var{minval}-@var{maxval} range.
10238
10239 @item gammaval(gamma)
10240 The computed gamma correction value of the pixel component value,
10241 clipped to the @var{minval}-@var{maxval} range. It corresponds to the
10242 expression
10243 "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
10244
10245 @end table
10246
10247 All expressions default to "val".
10248
10249 @subsection Examples
10250
10251 @itemize
10252 @item
10253 Negate input video:
10254 @example
10255 lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
10256 lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
10257 @end example
10258
10259 The above is the same as:
10260 @example
10261 lutrgb="r=negval:g=negval:b=negval"
10262 lutyuv="y=negval:u=negval:v=negval"
10263 @end example
10264
10265 @item
10266 Negate luminance:
10267 @example
10268 lutyuv=y=negval
10269 @end example
10270
10271 @item
10272 Remove chroma components, turning the video into a graytone image:
10273 @example
10274 lutyuv="u=128:v=128"
10275 @end example
10276
10277 @item
10278 Apply a luma burning effect:
10279 @example
10280 lutyuv="y=2*val"
10281 @end example
10282
10283 @item
10284 Remove green and blue components:
10285 @example
10286 lutrgb="g=0:b=0"
10287 @end example
10288
10289 @item
10290 Set a constant alpha channel value on input:
10291 @example
10292 format=rgba,lutrgb=a="maxval-minval/2"
10293 @end example
10294
10295 @item
10296 Correct luminance gamma by a factor of 0.5:
10297 @example
10298 lutyuv=y=gammaval(0.5)
10299 @end example
10300
10301 @item
10302 Discard least significant bits of luma:
10303 @example
10304 lutyuv=y='bitand(val, 128+64+32)'
10305 @end example
10306
10307 @item
10308 Technicolor like effect:
10309 @example
10310 lutyuv=u='(val-maxval/2)*2+maxval/2':v='(val-maxval/2)*2+maxval/2'
10311 @end example
10312 @end itemize
10313
10314 @section lut2, tlut2
10315
10316 The @code{lut2} filter takes two input streams and outputs one
10317 stream.
10318
10319 The @code{tlut2} (time lut2) filter takes two consecutive frames
10320 from one single stream.
10321
10322 This filter accepts the following parameters:
10323 @table @option
10324 @item c0
10325 set first pixel component expression
10326 @item c1
10327 set second pixel component expression
10328 @item c2
10329 set third pixel component expression
10330 @item c3
10331 set fourth pixel component expression, corresponds to the alpha component
10332 @end table
10333
10334 Each of them specifies the expression to use for computing the lookup table for
10335 the corresponding pixel component values.
10336
10337 The exact component associated to each of the @var{c*} options depends on the
10338 format in inputs.
10339
10340 The expressions can contain the following constants:
10341
10342 @table @option
10343 @item w
10344 @item h
10345 The input width and height.
10346
10347 @item x
10348 The first input value for the pixel component.
10349
10350 @item y
10351 The second input value for the pixel component.
10352
10353 @item bdx
10354 The first input video bit depth.
10355
10356 @item bdy
10357 The second input video bit depth.
10358 @end table
10359
10360 All expressions default to "x".
10361
10362 @subsection Examples
10363
10364 @itemize
10365 @item
10366 Highlight differences between two RGB video streams:
10367 @example
10368 lut2='ifnot(x-y,0,pow(2,bdx)-1):ifnot(x-y,0,pow(2,bdx)-1):ifnot(x-y,0,pow(2,bdx)-1)'
10369 @end example
10370
10371 @item
10372 Highlight differences between two YUV video streams:
10373 @example
10374 lut2='ifnot(x-y,0,pow(2,bdx)-1):ifnot(x-y,pow(2,bdx-1),pow(2,bdx)-1):ifnot(x-y,pow(2,bdx-1),pow(2,bdx)-1)'
10375 @end example
10376
10377 @item
10378 Show max difference between two video streams:
10379 @example
10380 lut2='if(lt(x,y),0,if(gt(x,y),pow(2,bdx)-1,pow(2,bdx-1))):if(lt(x,y),0,if(gt(x,y),pow(2,bdx)-1,pow(2,bdx-1))):if(lt(x,y),0,if(gt(x,y),pow(2,bdx)-1,pow(2,bdx-1)))'
10381 @end example
10382 @end itemize
10383
10384 @section maskedclamp
10385
10386 Clamp the first input stream with the second input and third input stream.
10387
10388 Returns the value of first stream to be between second input
10389 stream - @code{undershoot} and third input stream + @code{overshoot}.
10390
10391 This filter accepts the following options:
10392 @table @option
10393 @item undershoot
10394 Default value is @code{0}.
10395
10396 @item overshoot
10397 Default value is @code{0}.
10398
10399 @item planes
10400 Set which planes will be processed as bitmap, unprocessed planes will be
10401 copied from first stream.
10402 By default value 0xf, all planes will be processed.
10403 @end table
10404
10405 @section maskedmerge
10406
10407 Merge the first input stream with the second input stream using per pixel
10408 weights in the third input stream.
10409
10410 A value of 0 in the third stream pixel component means that pixel component
10411 from first stream is returned unchanged, while maximum value (eg. 255 for
10412 8-bit videos) means that pixel component from second stream is returned
10413 unchanged. Intermediate values define the amount of merging between both
10414 input stream's pixel components.
10415
10416 This filter accepts the following options:
10417 @table @option
10418 @item planes
10419 Set which planes will be processed as bitmap, unprocessed planes will be
10420 copied from first stream.
10421 By default value 0xf, all planes will be processed.
10422 @end table
10423
10424 @section mcdeint
10425
10426 Apply motion-compensation deinterlacing.
10427
10428 It needs one field per frame as input and must thus be used together
10429 with yadif=1/3 or equivalent.
10430
10431 This filter accepts the following options:
10432 @table @option
10433 @item mode
10434 Set the deinterlacing mode.
10435
10436 It accepts one of the following values:
10437 @table @samp
10438 @item fast
10439 @item medium
10440 @item slow
10441 use iterative motion estimation
10442 @item extra_slow
10443 like @samp{slow}, but use multiple reference frames.
10444 @end table
10445 Default value is @samp{fast}.
10446
10447 @item parity
10448 Set the picture field parity assumed for the input video. It must be
10449 one of the following values:
10450
10451 @table @samp
10452 @item 0, tff
10453 assume top field first
10454 @item 1, bff
10455 assume bottom field first
10456 @end table
10457
10458 Default value is @samp{bff}.
10459
10460 @item qp
10461 Set per-block quantization parameter (QP) used by the internal
10462 encoder.
10463
10464 Higher values should result in a smoother motion vector field but less
10465 optimal individual vectors. Default value is 1.
10466 @end table
10467
10468 @section mergeplanes
10469
10470 Merge color channel components from several video streams.
10471
10472 The filter accepts up to 4 input streams, and merge selected input
10473 planes to the output video.
10474
10475 This filter accepts the following options:
10476 @table @option
10477 @item mapping
10478 Set input to output plane mapping. Default is @code{0}.
10479
10480 The mappings is specified as a bitmap. It should be specified as a
10481 hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
10482 mapping for the first plane of the output stream. 'A' sets the number of
10483 the input stream to use (from 0 to 3), and 'a' the plane number of the
10484 corresponding input to use (from 0 to 3). The rest of the mappings is
10485 similar, 'Bb' describes the mapping for the output stream second
10486 plane, 'Cc' describes the mapping for the output stream third plane and
10487 'Dd' describes the mapping for the output stream fourth plane.
10488
10489 @item format
10490 Set output pixel format. Default is @code{yuva444p}.
10491 @end table
10492
10493 @subsection Examples
10494
10495 @itemize
10496 @item
10497 Merge three gray video streams of same width and height into single video stream:
10498 @example
10499 [a0][a1][a2]mergeplanes=0x001020:yuv444p
10500 @end example
10501
10502 @item
10503 Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
10504 @example
10505 [a0][a1]mergeplanes=0x00010210:yuva444p
10506 @end example
10507
10508 @item
10509 Swap Y and A plane in yuva444p stream:
10510 @example
10511 format=yuva444p,mergeplanes=0x03010200:yuva444p
10512 @end example
10513
10514 @item
10515 Swap U and V plane in yuv420p stream:
10516 @example
10517 format=yuv420p,mergeplanes=0x000201:yuv420p
10518 @end example
10519
10520 @item
10521 Cast a rgb24 clip to yuv444p:
10522 @example
10523 format=rgb24,mergeplanes=0x000102:yuv444p
10524 @end example
10525 @end itemize
10526
10527 @section mestimate
10528
10529 Estimate and export motion vectors using block matching algorithms.
10530 Motion vectors are stored in frame side data to be used by other filters.
10531
10532 This filter accepts the following options:
10533 @table @option
10534 @item method
10535 Specify the motion estimation method. Accepts one of the following values:
10536
10537 @table @samp
10538 @item esa
10539 Exhaustive search algorithm.
10540 @item tss
10541 Three step search algorithm.
10542 @item tdls
10543 Two dimensional logarithmic search algorithm.
10544 @item ntss
10545 New three step search algorithm.
10546 @item fss
10547 Four step search algorithm.
10548 @item ds
10549 Diamond search algorithm.
10550 @item hexbs
10551 Hexagon-based search algorithm.
10552 @item epzs
10553 Enhanced predictive zonal search algorithm.
10554 @item umh
10555 Uneven multi-hexagon search algorithm.
10556 @end table
10557 Default value is @samp{esa}.
10558
10559 @item mb_size
10560 Macroblock size. Default @code{16}.
10561
10562 @item search_param
10563 Search parameter. Default @code{7}.
10564 @end table
10565
10566 @section midequalizer
10567
10568 Apply Midway Image Equalization effect using two video streams.
10569
10570 Midway Image Equalization adjusts a pair of images to have the same
10571 histogram, while maintaining their dynamics as much as possible. It's
10572 useful for e.g. matching exposures from a pair of stereo cameras.
10573
10574 This filter has two inputs and one output, which must be of same pixel format, but
10575 may be of different sizes. The output of filter is first input adjusted with
10576 midway histogram of both inputs.
10577
10578 This filter accepts the following option:
10579
10580 @table @option
10581 @item planes
10582 Set which planes to process. Default is @code{15}, which is all available planes.
10583 @end table
10584
10585 @section minterpolate
10586
10587 Convert the video to specified frame rate using motion interpolation.
10588
10589 This filter accepts the following options:
10590 @table @option
10591 @item fps
10592 Specify the output frame rate. This can be rational e.g. @code{60000/1001}. Frames are dropped if @var{fps} is lower than source fps. Default @code{60}.
10593
10594 @item mi_mode
10595 Motion interpolation mode. Following values are accepted:
10596 @table @samp
10597 @item dup
10598 Duplicate previous or next frame for interpolating new ones.
10599 @item blend
10600 Blend source frames. Interpolated frame is mean of previous and next frames.
10601 @item mci
10602 Motion compensated interpolation. Following options are effective when this mode is selected:
10603
10604 @table @samp
10605 @item mc_mode
10606 Motion compensation mode. Following values are accepted:
10607 @table @samp
10608 @item obmc
10609 Overlapped block motion compensation.
10610 @item aobmc
10611 Adaptive overlapped block motion compensation. Window weighting coefficients are controlled adaptively according to the reliabilities of the neighboring motion vectors to reduce oversmoothing.
10612 @end table
10613 Default mode is @samp{obmc}.
10614
10615 @item me_mode
10616 Motion estimation mode. Following values are accepted:
10617 @table @samp
10618 @item bidir
10619 Bidirectional motion estimation. Motion vectors are estimated for each source frame in both forward and backward directions.
10620 @item bilat
10621 Bilateral motion estimation. Motion vectors are estimated directly for interpolated frame.
10622 @end table
10623 Default mode is @samp{bilat}.
10624
10625 @item me
10626 The algorithm to be used for motion estimation. Following values are accepted:
10627 @table @samp
10628 @item esa
10629 Exhaustive search algorithm.
10630 @item tss
10631 Three step search algorithm.
10632 @item tdls
10633 Two dimensional logarithmic search algorithm.
10634 @item ntss
10635 New three step search algorithm.
10636 @item fss
10637 Four step search algorithm.
10638 @item ds
10639 Diamond search algorithm.
10640 @item hexbs
10641 Hexagon-based search algorithm.
10642 @item epzs
10643 Enhanced predictive zonal search algorithm.
10644 @item umh
10645 Uneven multi-hexagon search algorithm.
10646 @end table
10647 Default algorithm is @samp{epzs}.
10648
10649 @item mb_size
10650 Macroblock size. Default @code{16}.
10651
10652 @item search_param
10653 Motion estimation search parameter. Default @code{32}.
10654
10655 @item vsbmc
10656 Enable variable-size block motion compensation. Motion estimation is applied with smaller block sizes at object boundaries in order to make the them less blur. Default is @code{0} (disabled).
10657 @end table
10658 @end table
10659
10660 @item scd
10661 Scene change detection method. Scene change leads motion vectors to be in random direction. Scene change detection replace interpolated frames by duplicate ones. May not be needed for other modes. Following values are accepted:
10662 @table @samp
10663 @item none
10664 Disable scene change detection.
10665 @item fdiff
10666 Frame difference. Corresponding pixel values are compared and if it satisfies @var{scd_threshold} scene change is detected.
10667 @end table
10668 Default method is @samp{fdiff}.
10669
10670 @item scd_threshold
10671 Scene change detection threshold. Default is @code{5.0}.
10672 @end table
10673
10674 @section mix
10675
10676 Mix several video input streams into one video stream.
10677
10678 A description of the accepted options follows.
10679
10680 @table @option
10681 @item nb_inputs
10682 The number of inputs. If unspecified, it defaults to 2.
10683
10684 @item weights
10685 Specify weight of each input video stream as sequence.
10686 Each weight is separated by space.
10687
10688 @item duration
10689 Specify how end of stream is determined.
10690 @table @samp
10691 @item longest
10692 The duration of the longest input. (default)
10693
10694 @item shortest
10695 The duration of the shortest input.
10696
10697 @item first
10698 The duration of the first input.
10699 @end table
10700 @end table
10701
10702 @section mpdecimate
10703
10704 Drop frames that do not differ greatly from the previous frame in
10705 order to reduce frame rate.
10706
10707 The main use of this filter is for very-low-bitrate encoding
10708 (e.g. streaming over dialup modem), but it could in theory be used for
10709 fixing movies that were inverse-telecined incorrectly.
10710
10711 A description of the accepted options follows.
10712
10713 @table @option
10714 @item max
10715 Set the maximum number of consecutive frames which can be dropped (if
10716 positive), or the minimum interval between dropped frames (if
10717 negative). If the value is 0, the frame is dropped disregarding the
10718 number of previous sequentially dropped frames.
10719
10720 Default value is 0.
10721
10722 @item hi
10723 @item lo
10724 @item frac
10725 Set the dropping threshold values.
10726
10727 Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
10728 represent actual pixel value differences, so a threshold of 64
10729 corresponds to 1 unit of difference for each pixel, or the same spread
10730 out differently over the block.
10731
10732 A frame is a candidate for dropping if no 8x8 blocks differ by more
10733 than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
10734 meaning the whole image) differ by more than a threshold of @option{lo}.
10735
10736 Default value for @option{hi} is 64*12, default value for @option{lo} is
10737 64*5, and default value for @option{frac} is 0.33.
10738 @end table
10739
10740
10741 @section negate
10742
10743 Negate input video.
10744
10745 It accepts an integer in input; if non-zero it negates the
10746 alpha component (if available). The default value in input is 0.
10747
10748 @section nlmeans
10749
10750 Denoise frames using Non-Local Means algorithm.
10751
10752 Each pixel is adjusted by looking for other pixels with similar contexts. This
10753 context similarity is defined by comparing their surrounding patches of size
10754 @option{p}x@option{p}. Patches are searched in an area of @option{r}x@option{r}
10755 around the pixel.
10756
10757 Note that the research area defines centers for patches, which means some
10758 patches will be made of pixels outside that research area.
10759
10760 The filter accepts the following options.
10761
10762 @table @option
10763 @item s
10764 Set denoising strength.
10765
10766 @item p
10767 Set patch size.
10768
10769 @item pc
10770 Same as @option{p} but for chroma planes.
10771
10772 The default value is @var{0} and means automatic.
10773
10774 @item r
10775 Set research size.
10776
10777 @item rc
10778 Same as @option{r} but for chroma planes.
10779
10780 The default value is @var{0} and means automatic.
10781 @end table
10782
10783 @section nnedi
10784
10785 Deinterlace video using neural network edge directed interpolation.
10786
10787 This filter accepts the following options:
10788
10789 @table @option
10790 @item weights
10791 Mandatory option, without binary file filter can not work.
10792 Currently file can be found here:
10793 https://github.com/dubhater/vapoursynth-nnedi3/blob/master/src/nnedi3_weights.bin
10794
10795 @item deint
10796 Set which frames to deinterlace, by default it is @code{all}.
10797 Can be @code{all} or @code{interlaced}.
10798
10799 @item field
10800 Set mode of operation.
10801
10802 Can be one of the following:
10803
10804 @table @samp
10805 @item af
10806 Use frame flags, both fields.
10807 @item a
10808 Use frame flags, single field.
10809 @item t
10810 Use top field only.
10811 @item b
10812 Use bottom field only.
10813 @item tf
10814 Use both fields, top first.
10815 @item bf
10816 Use both fields, bottom first.
10817 @end table
10818
10819 @item planes
10820 Set which planes to process, by default filter process all frames.
10821
10822 @item nsize
10823 Set size of local neighborhood around each pixel, used by the predictor neural
10824 network.
10825
10826 Can be one of the following:
10827
10828 @table @samp
10829 @item s8x6
10830 @item s16x6
10831 @item s32x6
10832 @item s48x6
10833 @item s8x4
10834 @item s16x4
10835 @item s32x4
10836 @end table
10837
10838 @item nns
10839 Set the number of neurons in predictor neural network.
10840 Can be one of the following:
10841
10842 @table @samp
10843 @item n16
10844 @item n32
10845 @item n64
10846 @item n128
10847 @item n256
10848 @end table
10849
10850 @item qual
10851 Controls the number of different neural network predictions that are blended
10852 together to compute the final output value. Can be @code{fast}, default or
10853 @code{slow}.
10854
10855 @item etype
10856 Set which set of weights to use in the predictor.
10857 Can be one of the following:
10858
10859 @table @samp
10860 @item a
10861 weights trained to minimize absolute error
10862 @item s
10863 weights trained to minimize squared error
10864 @end table
10865
10866 @item pscrn
10867 Controls whether or not the prescreener neural network is used to decide
10868 which pixels should be processed by the predictor neural network and which
10869 can be handled by simple cubic interpolation.
10870 The prescreener is trained to know whether cubic interpolation will be
10871 sufficient for a pixel or whether it should be predicted by the predictor nn.
10872 The computational complexity of the prescreener nn is much less than that of
10873 the predictor nn. Since most pixels can be handled by cubic interpolation,
10874 using the prescreener generally results in much faster processing.
10875 The prescreener is pretty accurate, so the difference between using it and not
10876 using it is almost always unnoticeable.
10877
10878 Can be one of the following:
10879
10880 @table @samp
10881 @item none
10882 @item original
10883 @item new
10884 @end table
10885
10886 Default is @code{new}.
10887
10888 @item fapprox
10889 Set various debugging flags.
10890 @end table
10891
10892 @section noformat
10893
10894 Force libavfilter not to use any of the specified pixel formats for the
10895 input to the next filter.
10896
10897 It accepts the following parameters:
10898 @table @option
10899
10900 @item pix_fmts
10901 A '|'-separated list of pixel format names, such as
10902 pix_fmts=yuv420p|monow|rgb24".
10903
10904 @end table
10905
10906 @subsection Examples
10907
10908 @itemize
10909 @item
10910 Force libavfilter to use a format different from @var{yuv420p} for the
10911 input to the vflip filter:
10912 @example
10913 noformat=pix_fmts=yuv420p,vflip
10914 @end example
10915
10916 @item
10917 Convert the input video to any of the formats not contained in the list:
10918 @example
10919 noformat=yuv420p|yuv444p|yuv410p
10920 @end example
10921 @end itemize
10922
10923 @section noise
10924
10925 Add noise on video input frame.
10926
10927 The filter accepts the following options:
10928
10929 @table @option
10930 @item all_seed
10931 @item c0_seed
10932 @item c1_seed
10933 @item c2_seed
10934 @item c3_seed
10935 Set noise seed for specific pixel component or all pixel components in case
10936 of @var{all_seed}. Default value is @code{123457}.
10937
10938 @item all_strength, alls
10939 @item c0_strength, c0s
10940 @item c1_strength, c1s
10941 @item c2_strength, c2s
10942 @item c3_strength, c3s
10943 Set noise strength for specific pixel component or all pixel components in case
10944 @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
10945
10946 @item all_flags, allf
10947 @item c0_flags, c0f
10948 @item c1_flags, c1f
10949 @item c2_flags, c2f
10950 @item c3_flags, c3f
10951 Set pixel component flags or set flags for all components if @var{all_flags}.
10952 Available values for component flags are:
10953 @table @samp
10954 @item a
10955 averaged temporal noise (smoother)
10956 @item p
10957 mix random noise with a (semi)regular pattern
10958 @item t
10959 temporal noise (noise pattern changes between frames)
10960 @item u
10961 uniform noise (gaussian otherwise)
10962 @end table
10963 @end table
10964
10965 @subsection Examples
10966
10967 Add temporal and uniform noise to input video:
10968 @example
10969 noise=alls=20:allf=t+u
10970 @end example
10971
10972 @section normalize
10973
10974 Normalize RGB video (aka histogram stretching, contrast stretching).
10975 See: https://en.wikipedia.org/wiki/Normalization_(image_processing)
10976
10977 For each channel of each frame, the filter computes the input range and maps
10978 it linearly to the user-specified output range. The output range defaults
10979 to the full dynamic range from pure black to pure white.
10980
10981 Temporal smoothing can be used on the input range to reduce flickering (rapid
10982 changes in brightness) caused when small dark or bright objects enter or leave
10983 the scene. This is similar to the auto-exposure (automatic gain control) on a
10984 video camera, and, like a video camera, it may cause a period of over- or
10985 under-exposure of the video.
10986
10987 The R,G,B channels can be normalized independently, which may cause some
10988 color shifting, or linked together as a single channel, which prevents
10989 color shifting. Linked normalization preserves hue. Independent normalization
10990 does not, so it can be used to remove some color casts. Independent and linked
10991 normalization can be combined in any ratio.
10992
10993 The normalize filter accepts the following options:
10994
10995 @table @option
10996 @item blackpt
10997 @item whitept
10998 Colors which define the output range. The minimum input value is mapped to
10999 the @var{blackpt}. The maximum input value is mapped to the @var{whitept}.
11000 The defaults are black and white respectively. Specifying white for
11001 @var{blackpt} and black for @var{whitept} will give color-inverted,
11002 normalized video. Shades of grey can be used to reduce the dynamic range
11003 (contrast). Specifying saturated colors here can create some interesting
11004 effects.
11005
11006 @item smoothing
11007 The number of previous frames to use for temporal smoothing. The input range
11008 of each channel is smoothed using a rolling average over the current frame
11009 and the @var{smoothing} previous frames. The default is 0 (no temporal
11010 smoothing).
11011
11012 @item independence
11013 Controls the ratio of independent (color shifting) channel normalization to
11014 linked (color preserving) normalization. 0.0 is fully linked, 1.0 is fully
11015 independent. Defaults to 1.0 (fully independent).
11016
11017 @item strength
11018 Overall strength of the filter. 1.0 is full strength. 0.0 is a rather
11019 expensive no-op. Defaults to 1.0 (full strength).
11020
11021 @end table
11022
11023 @subsection Examples
11024
11025 Stretch video contrast to use the full dynamic range, with no temporal
11026 smoothing; may flicker depending on the source content:
11027 @example
11028 normalize=blackpt=black:whitept=white:smoothing=0
11029 @end example
11030
11031 As above, but with 50 frames of temporal smoothing; flicker should be
11032 reduced, depending on the source content:
11033 @example
11034 normalize=blackpt=black:whitept=white:smoothing=50
11035 @end example
11036
11037 As above, but with hue-preserving linked channel normalization:
11038 @example
11039 normalize=blackpt=black:whitept=white:smoothing=50:independence=0
11040 @end example
11041
11042 As above, but with half strength:
11043 @example
11044 normalize=blackpt=black:whitept=white:smoothing=50:independence=0:strength=0.5
11045 @end example
11046
11047 Map the darkest input color to red, the brightest input color to cyan:
11048 @example
11049 normalize=blackpt=red:whitept=cyan
11050 @end example
11051
11052 @section null
11053
11054 Pass the video source unchanged to the output.
11055
11056 @section ocr
11057 Optical Character Recognition
11058
11059 This filter uses Tesseract for optical character recognition.
11060
11061 It accepts the following options:
11062
11063 @table @option
11064 @item datapath
11065 Set datapath to tesseract data. Default is to use whatever was
11066 set at installation.
11067
11068 @item language
11069 Set language, default is "eng".
11070
11071 @item whitelist
11072 Set character whitelist.
11073
11074 @item blacklist
11075 Set character blacklist.
11076 @end table
11077
11078 The filter exports recognized text as the frame metadata @code{lavfi.ocr.text}.
11079
11080 @section ocv
11081
11082 Apply a video transform using libopencv.
11083
11084 To enable this filter, install the libopencv library and headers and
11085 configure FFmpeg with @code{--enable-libopencv}.
11086
11087 It accepts the following parameters:
11088
11089 @table @option
11090
11091 @item filter_name
11092 The name of the libopencv filter to apply.
11093
11094 @item filter_params
11095 The parameters to pass to the libopencv filter. If not specified, the default
11096 values are assumed.
11097
11098 @end table
11099
11100 Refer to the official libopencv documentation for more precise
11101 information:
11102 @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
11103
11104 Several libopencv filters are supported; see the following subsections.
11105
11106 @anchor{dilate}
11107 @subsection dilate
11108
11109 Dilate an image by using a specific structuring element.
11110 It corresponds to the libopencv function @code{cvDilate}.
11111
11112 It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
11113
11114 @var{struct_el} represents a structuring element, and has the syntax:
11115 @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
11116
11117 @var{cols} and @var{rows} represent the number of columns and rows of
11118 the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
11119 point, and @var{shape} the shape for the structuring element. @var{shape}
11120 must be "rect", "cross", "ellipse", or "custom".
11121
11122 If the value for @var{shape} is "custom", it must be followed by a
11123 string of the form "=@var{filename}". The file with name
11124 @var{filename} is assumed to represent a binary image, with each
11125 printable character corresponding to a bright pixel. When a custom
11126 @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
11127 or columns and rows of the read file are assumed instead.
11128
11129 The default value for @var{struct_el} is "3x3+0x0/rect".
11130
11131 @var{nb_iterations} specifies the number of times the transform is
11132 applied to the image, and defaults to 1.
11133
11134 Some examples:
11135 @example
11136 # Use the default values
11137 ocv=dilate
11138
11139 # Dilate using a structuring element with a 5x5 cross, iterating two times
11140 ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
11141
11142 # Read the shape from the file diamond.shape, iterating two times.
11143 # The file diamond.shape may contain a pattern of characters like this
11144 #   *
11145 #  ***
11146 # *****
11147 #  ***
11148 #   *
11149 # The specified columns and rows are ignored
11150 # but the anchor point coordinates are not
11151 ocv=dilate:0x0+2x2/custom=diamond.shape|2
11152 @end example
11153
11154 @subsection erode
11155
11156 Erode an image by using a specific structuring element.
11157 It corresponds to the libopencv function @code{cvErode}.
11158
11159 It accepts the parameters: @var{struct_el}:@var{nb_iterations},
11160 with the same syntax and semantics as the @ref{dilate} filter.
11161
11162 @subsection smooth
11163
11164 Smooth the input video.
11165
11166 The filter takes the following parameters:
11167 @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
11168
11169 @var{type} is the type of smooth filter to apply, and must be one of
11170 the following values: "blur", "blur_no_scale", "median", "gaussian",
11171 or "bilateral". The default value is "gaussian".
11172
11173 The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
11174 depend on the smooth type. @var{param1} and
11175 @var{param2} accept integer positive values or 0. @var{param3} and
11176 @var{param4} accept floating point values.
11177
11178 The default value for @var{param1} is 3. The default value for the
11179 other parameters is 0.
11180
11181 These parameters correspond to the parameters assigned to the
11182 libopencv function @code{cvSmooth}.
11183
11184 @section oscilloscope
11185
11186 2D Video Oscilloscope.
11187
11188 Useful to measure spatial impulse, step responses, chroma delays, etc.
11189
11190 It accepts the following parameters:
11191
11192 @table @option
11193 @item x
11194 Set scope center x position.
11195
11196 @item y
11197 Set scope center y position.
11198
11199 @item s
11200 Set scope size, relative to frame diagonal.
11201
11202 @item t
11203 Set scope tilt/rotation.
11204
11205 @item o
11206 Set trace opacity.
11207
11208 @item tx
11209 Set trace center x position.
11210
11211 @item ty
11212 Set trace center y position.
11213
11214 @item tw
11215 Set trace width, relative to width of frame.
11216
11217 @item th
11218 Set trace height, relative to height of frame.
11219
11220 @item c
11221 Set which components to trace. By default it traces first three components.
11222
11223 @item g
11224 Draw trace grid. By default is enabled.
11225
11226 @item st
11227 Draw some statistics. By default is enabled.
11228
11229 @item sc
11230 Draw scope. By default is enabled.
11231 @end table
11232
11233 @subsection Examples
11234
11235 @itemize
11236 @item
11237 Inspect full first row of video frame.
11238 @example
11239 oscilloscope=x=0.5:y=0:s=1
11240 @end example
11241
11242 @item
11243 Inspect full last row of video frame.
11244 @example
11245 oscilloscope=x=0.5:y=1:s=1
11246 @end example
11247
11248 @item
11249 Inspect full 5th line of video frame of height 1080.
11250 @example
11251 oscilloscope=x=0.5:y=5/1080:s=1
11252 @end example
11253
11254 @item
11255 Inspect full last column of video frame.
11256 @example
11257 oscilloscope=x=1:y=0.5:s=1:t=1
11258 @end example
11259
11260 @end itemize
11261
11262 @anchor{overlay}
11263 @section overlay
11264
11265 Overlay one video on top of another.
11266
11267 It takes two inputs and has one output. The first input is the "main"
11268 video on which the second input is overlaid.
11269
11270 It accepts the following parameters:
11271
11272 A description of the accepted options follows.
11273
11274 @table @option
11275 @item x
11276 @item y
11277 Set the expression for the x and y coordinates of the overlaid video
11278 on the main video. Default value is "0" for both expressions. In case
11279 the expression is invalid, it is set to a huge value (meaning that the
11280 overlay will not be displayed within the output visible area).
11281
11282 @item eof_action
11283 See @ref{framesync}.
11284
11285 @item eval
11286 Set when the expressions for @option{x}, and @option{y} are evaluated.
11287
11288 It accepts the following values:
11289 @table @samp
11290 @item init
11291 only evaluate expressions once during the filter initialization or
11292 when a command is processed
11293
11294 @item frame
11295 evaluate expressions for each incoming frame
11296 @end table
11297
11298 Default value is @samp{frame}.
11299
11300 @item shortest
11301 See @ref{framesync}.
11302
11303 @item format
11304 Set the format for the output video.
11305
11306 It accepts the following values:
11307 @table @samp
11308 @item yuv420
11309 force YUV420 output
11310
11311 @item yuv422
11312 force YUV422 output
11313
11314 @item yuv444
11315 force YUV444 output
11316
11317 @item rgb
11318 force packed RGB output
11319
11320 @item gbrp
11321 force planar RGB output
11322
11323 @item auto
11324 automatically pick format
11325 @end table
11326
11327 Default value is @samp{yuv420}.
11328
11329 @item repeatlast
11330 See @ref{framesync}.
11331 @end table
11332
11333 The @option{x}, and @option{y} expressions can contain the following
11334 parameters.
11335
11336 @table @option
11337 @item main_w, W
11338 @item main_h, H
11339 The main input width and height.
11340
11341 @item overlay_w, w
11342 @item overlay_h, h
11343 The overlay input width and height.
11344
11345 @item x
11346 @item y
11347 The computed values for @var{x} and @var{y}. They are evaluated for
11348 each new frame.
11349
11350 @item hsub
11351 @item vsub
11352 horizontal and vertical chroma subsample values of the output
11353 format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
11354 @var{vsub} is 1.
11355
11356 @item n
11357 the number of input frame, starting from 0
11358
11359 @item pos
11360 the position in the file of the input frame, NAN if unknown
11361
11362 @item t
11363 The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
11364
11365 @end table
11366
11367 This filter also supports the @ref{framesync} options.
11368
11369 Note that the @var{n}, @var{pos}, @var{t} variables are available only
11370 when evaluation is done @emph{per frame}, and will evaluate to NAN
11371 when @option{eval} is set to @samp{init}.
11372
11373 Be aware that frames are taken from each input video in timestamp
11374 order, hence, if their initial timestamps differ, it is a good idea
11375 to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
11376 have them begin in the same zero timestamp, as the example for
11377 the @var{movie} filter does.
11378
11379 You can chain together more overlays but you should test the
11380 efficiency of such approach.
11381
11382 @subsection Commands
11383
11384 This filter supports the following commands:
11385 @table @option
11386 @item x
11387 @item y
11388 Modify the x and y of the overlay input.
11389 The command accepts the same syntax of the corresponding option.
11390
11391 If the specified expression is not valid, it is kept at its current
11392 value.
11393 @end table
11394
11395 @subsection Examples
11396
11397 @itemize
11398 @item
11399 Draw the overlay at 10 pixels from the bottom right corner of the main
11400 video:
11401 @example
11402 overlay=main_w-overlay_w-10:main_h-overlay_h-10
11403 @end example
11404
11405 Using named options the example above becomes:
11406 @example
11407 overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
11408 @end example
11409
11410 @item
11411 Insert a transparent PNG logo in the bottom left corner of the input,
11412 using the @command{ffmpeg} tool with the @code{-filter_complex} option:
11413 @example
11414 ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
11415 @end example
11416
11417 @item
11418 Insert 2 different transparent PNG logos (second logo on bottom
11419 right corner) using the @command{ffmpeg} tool:
11420 @example
11421 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
11422 @end example
11423
11424 @item
11425 Add a transparent color layer on top of the main video; @code{WxH}
11426 must specify the size of the main input to the overlay filter:
11427 @example
11428 color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
11429 @end example
11430
11431 @item
11432 Play an original video and a filtered version (here with the deshake
11433 filter) side by side using the @command{ffplay} tool:
11434 @example
11435 ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
11436 @end example
11437
11438 The above command is the same as:
11439 @example
11440 ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
11441 @end example
11442
11443 @item
11444 Make a sliding overlay appearing from the left to the right top part of the
11445 screen starting since time 2:
11446 @example
11447 overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
11448 @end example
11449
11450 @item
11451 Compose output by putting two input videos side to side:
11452 @example
11453 ffmpeg -i left.avi -i right.avi -filter_complex "
11454 nullsrc=size=200x100 [background];
11455 [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
11456 [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
11457 [background][left]       overlay=shortest=1       [background+left];
11458 [background+left][right] overlay=shortest=1:x=100 [left+right]
11459 "
11460 @end example
11461
11462 @item
11463 Mask 10-20 seconds of a video by applying the delogo filter to a section
11464 @example
11465 ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
11466 -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]'
11467 masked.avi
11468 @end example
11469
11470 @item
11471 Chain several overlays in cascade:
11472 @example
11473 nullsrc=s=200x200 [bg];
11474 testsrc=s=100x100, split=4 [in0][in1][in2][in3];
11475 [in0] lutrgb=r=0, [bg]   overlay=0:0     [mid0];
11476 [in1] lutrgb=g=0, [mid0] overlay=100:0   [mid1];
11477 [in2] lutrgb=b=0, [mid1] overlay=0:100   [mid2];
11478 [in3] null,       [mid2] overlay=100:100 [out0]
11479 @end example
11480
11481 @end itemize
11482
11483 @section owdenoise
11484
11485 Apply Overcomplete Wavelet denoiser.
11486
11487 The filter accepts the following options:
11488
11489 @table @option
11490 @item depth
11491 Set depth.
11492
11493 Larger depth values will denoise lower frequency components more, but
11494 slow down filtering.
11495
11496 Must be an int in the range 8-16, default is @code{8}.
11497
11498 @item luma_strength, ls
11499 Set luma strength.
11500
11501 Must be a double value in the range 0-1000, default is @code{1.0}.
11502
11503 @item chroma_strength, cs
11504 Set chroma strength.
11505
11506 Must be a double value in the range 0-1000, default is @code{1.0}.
11507 @end table
11508
11509 @anchor{pad}
11510 @section pad
11511
11512 Add paddings to the input image, and place the original input at the
11513 provided @var{x}, @var{y} coordinates.
11514
11515 It accepts the following parameters:
11516
11517 @table @option
11518 @item width, w
11519 @item height, h
11520 Specify an expression for the size of the output image with the
11521 paddings added. If the value for @var{width} or @var{height} is 0, the
11522 corresponding input size is used for the output.
11523
11524 The @var{width} expression can reference the value set by the
11525 @var{height} expression, and vice versa.
11526
11527 The default value of @var{width} and @var{height} is 0.
11528
11529 @item x
11530 @item y
11531 Specify the offsets to place the input image at within the padded area,
11532 with respect to the top/left border of the output image.
11533
11534 The @var{x} expression can reference the value set by the @var{y}
11535 expression, and vice versa.
11536
11537 The default value of @var{x} and @var{y} is 0.
11538
11539 If @var{x} or @var{y} evaluate to a negative number, they'll be changed
11540 so the input image is centered on the padded area.
11541
11542 @item color
11543 Specify the color of the padded area. For the syntax of this option,
11544 check the "Color" section in the ffmpeg-utils manual.
11545
11546 The default value of @var{color} is "black".
11547
11548 @item eval
11549 Specify when to evaluate  @var{width}, @var{height}, @var{x} and @var{y} expression.
11550
11551 It accepts the following values:
11552
11553 @table @samp
11554 @item init
11555 Only evaluate expressions once during the filter initialization or when
11556 a command is processed.
11557
11558 @item frame
11559 Evaluate expressions for each incoming frame.
11560
11561 @end table
11562
11563 Default value is @samp{init}.
11564
11565 @item aspect
11566 Pad to aspect instead to a resolution.
11567
11568 @end table
11569
11570 The value for the @var{width}, @var{height}, @var{x}, and @var{y}
11571 options are expressions containing the following constants:
11572
11573 @table @option
11574 @item in_w
11575 @item in_h
11576 The input video width and height.
11577
11578 @item iw
11579 @item ih
11580 These are the same as @var{in_w} and @var{in_h}.
11581
11582 @item out_w
11583 @item out_h
11584 The output width and height (the size of the padded area), as
11585 specified by the @var{width} and @var{height} expressions.
11586
11587 @item ow
11588 @item oh
11589 These are the same as @var{out_w} and @var{out_h}.
11590
11591 @item x
11592 @item y
11593 The x and y offsets as specified by the @var{x} and @var{y}
11594 expressions, or NAN if not yet specified.
11595
11596 @item a
11597 same as @var{iw} / @var{ih}
11598
11599 @item sar
11600 input sample aspect ratio
11601
11602 @item dar
11603 input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
11604
11605 @item hsub
11606 @item vsub
11607 The horizontal and vertical chroma subsample values. For example for the
11608 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
11609 @end table
11610
11611 @subsection Examples
11612
11613 @itemize
11614 @item
11615 Add paddings with the color "violet" to the input video. The output video
11616 size is 640x480, and the top-left corner of the input video is placed at
11617 column 0, row 40
11618 @example
11619 pad=640:480:0:40:violet
11620 @end example
11621
11622 The example above is equivalent to the following command:
11623 @example
11624 pad=width=640:height=480:x=0:y=40:color=violet
11625 @end example
11626
11627 @item
11628 Pad the input to get an output with dimensions increased by 3/2,
11629 and put the input video at the center of the padded area:
11630 @example
11631 pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
11632 @end example
11633
11634 @item
11635 Pad the input to get a squared output with size equal to the maximum
11636 value between the input width and height, and put the input video at
11637 the center of the padded area:
11638 @example
11639 pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
11640 @end example
11641
11642 @item
11643 Pad the input to get a final w/h ratio of 16:9:
11644 @example
11645 pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
11646 @end example
11647
11648 @item
11649 In case of anamorphic video, in order to set the output display aspect
11650 correctly, it is necessary to use @var{sar} in the expression,
11651 according to the relation:
11652 @example
11653 (ih * X / ih) * sar = output_dar
11654 X = output_dar / sar
11655 @end example
11656
11657 Thus the previous example needs to be modified to:
11658 @example
11659 pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
11660 @end example
11661
11662 @item
11663 Double the output size and put the input video in the bottom-right
11664 corner of the output padded area:
11665 @example
11666 pad="2*iw:2*ih:ow-iw:oh-ih"
11667 @end example
11668 @end itemize
11669
11670 @anchor{palettegen}
11671 @section palettegen
11672
11673 Generate one palette for a whole video stream.
11674
11675 It accepts the following options:
11676
11677 @table @option
11678 @item max_colors
11679 Set the maximum number of colors to quantize in the palette.
11680 Note: the palette will still contain 256 colors; the unused palette entries
11681 will be black.
11682
11683 @item reserve_transparent
11684 Create a palette of 255 colors maximum and reserve the last one for
11685 transparency. Reserving the transparency color is useful for GIF optimization.
11686 If not set, the maximum of colors in the palette will be 256. You probably want
11687 to disable this option for a standalone image.
11688 Set by default.
11689
11690 @item transparency_color
11691 Set the color that will be used as background for transparency.
11692
11693 @item stats_mode
11694 Set statistics mode.
11695
11696 It accepts the following values:
11697 @table @samp
11698 @item full
11699 Compute full frame histograms.
11700 @item diff
11701 Compute histograms only for the part that differs from previous frame. This
11702 might be relevant to give more importance to the moving part of your input if
11703 the background is static.
11704 @item single
11705 Compute new histogram for each frame.
11706 @end table
11707
11708 Default value is @var{full}.
11709 @end table
11710
11711 The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
11712 (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
11713 color quantization of the palette. This information is also visible at
11714 @var{info} logging level.
11715
11716 @subsection Examples
11717
11718 @itemize
11719 @item
11720 Generate a representative palette of a given video using @command{ffmpeg}:
11721 @example
11722 ffmpeg -i input.mkv -vf palettegen palette.png
11723 @end example
11724 @end itemize
11725
11726 @section paletteuse
11727
11728 Use a palette to downsample an input video stream.
11729
11730 The filter takes two inputs: one video stream and a palette. The palette must
11731 be a 256 pixels image.
11732
11733 It accepts the following options:
11734
11735 @table @option
11736 @item dither
11737 Select dithering mode. Available algorithms are:
11738 @table @samp
11739 @item bayer
11740 Ordered 8x8 bayer dithering (deterministic)
11741 @item heckbert
11742 Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
11743 Note: this dithering is sometimes considered "wrong" and is included as a
11744 reference.
11745 @item floyd_steinberg
11746 Floyd and Steingberg dithering (error diffusion)
11747 @item sierra2
11748 Frankie Sierra dithering v2 (error diffusion)
11749 @item sierra2_4a
11750 Frankie Sierra dithering v2 "Lite" (error diffusion)
11751 @end table
11752
11753 Default is @var{sierra2_4a}.
11754
11755 @item bayer_scale
11756 When @var{bayer} dithering is selected, this option defines the scale of the
11757 pattern (how much the crosshatch pattern is visible). A low value means more
11758 visible pattern for less banding, and higher value means less visible pattern
11759 at the cost of more banding.
11760
11761 The option must be an integer value in the range [0,5]. Default is @var{2}.
11762
11763 @item diff_mode
11764 If set, define the zone to process
11765
11766 @table @samp
11767 @item rectangle
11768 Only the changing rectangle will be reprocessed. This is similar to GIF
11769 cropping/offsetting compression mechanism. This option can be useful for speed
11770 if only a part of the image is changing, and has use cases such as limiting the
11771 scope of the error diffusal @option{dither} to the rectangle that bounds the
11772 moving scene (it leads to more deterministic output if the scene doesn't change
11773 much, and as a result less moving noise and better GIF compression).
11774 @end table
11775
11776 Default is @var{none}.
11777
11778 @item new
11779 Take new palette for each output frame.
11780
11781 @item alpha_threshold
11782 Sets the alpha threshold for transparency. Alpha values above this threshold
11783 will be treated as completely opaque, and values below this threshold will be
11784 treated as completely transparent.
11785
11786 The option must be an integer value in the range [0,255]. Default is @var{128}.
11787 @end table
11788
11789 @subsection Examples
11790
11791 @itemize
11792 @item
11793 Use a palette (generated for example with @ref{palettegen}) to encode a GIF
11794 using @command{ffmpeg}:
11795 @example
11796 ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
11797 @end example
11798 @end itemize
11799
11800 @section perspective
11801
11802 Correct perspective of video not recorded perpendicular to the screen.
11803
11804 A description of the accepted parameters follows.
11805
11806 @table @option
11807 @item x0
11808 @item y0
11809 @item x1
11810 @item y1
11811 @item x2
11812 @item y2
11813 @item x3
11814 @item y3
11815 Set coordinates expression for top left, top right, bottom left and bottom right corners.
11816 Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
11817 If the @code{sense} option is set to @code{source}, then the specified points will be sent
11818 to the corners of the destination. If the @code{sense} option is set to @code{destination},
11819 then the corners of the source will be sent to the specified coordinates.
11820
11821 The expressions can use the following variables:
11822
11823 @table @option
11824 @item W
11825 @item H
11826 the width and height of video frame.
11827 @item in
11828 Input frame count.
11829 @item on
11830 Output frame count.
11831 @end table
11832
11833 @item interpolation
11834 Set interpolation for perspective correction.
11835
11836 It accepts the following values:
11837 @table @samp
11838 @item linear
11839 @item cubic
11840 @end table
11841
11842 Default value is @samp{linear}.
11843
11844 @item sense
11845 Set interpretation of coordinate options.
11846
11847 It accepts the following values:
11848 @table @samp
11849 @item 0, source
11850
11851 Send point in the source specified by the given coordinates to
11852 the corners of the destination.
11853
11854 @item 1, destination
11855
11856 Send the corners of the source to the point in the destination specified
11857 by the given coordinates.
11858
11859 Default value is @samp{source}.
11860 @end table
11861
11862 @item eval
11863 Set when the expressions for coordinates @option{x0,y0,...x3,y3} are evaluated.
11864
11865 It accepts the following values:
11866 @table @samp
11867 @item init
11868 only evaluate expressions once during the filter initialization or
11869 when a command is processed
11870
11871 @item frame
11872 evaluate expressions for each incoming frame
11873 @end table
11874
11875 Default value is @samp{init}.
11876 @end table
11877
11878 @section phase
11879
11880 Delay interlaced video by one field time so that the field order changes.
11881
11882 The intended use is to fix PAL movies that have been captured with the
11883 opposite field order to the film-to-video transfer.
11884
11885 A description of the accepted parameters follows.
11886
11887 @table @option
11888 @item mode
11889 Set phase mode.
11890
11891 It accepts the following values:
11892 @table @samp
11893 @item t
11894 Capture field order top-first, transfer bottom-first.
11895 Filter will delay the bottom field.
11896
11897 @item b
11898 Capture field order bottom-first, transfer top-first.
11899 Filter will delay the top field.
11900
11901 @item p
11902 Capture and transfer with the same field order. This mode only exists
11903 for the documentation of the other options to refer to, but if you
11904 actually select it, the filter will faithfully do nothing.
11905
11906 @item a
11907 Capture field order determined automatically by field flags, transfer
11908 opposite.
11909 Filter selects among @samp{t} and @samp{b} modes on a frame by frame
11910 basis using field flags. If no field information is available,
11911 then this works just like @samp{u}.
11912
11913 @item u
11914 Capture unknown or varying, transfer opposite.
11915 Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
11916 analyzing the images and selecting the alternative that produces best
11917 match between the fields.
11918
11919 @item T
11920 Capture top-first, transfer unknown or varying.
11921 Filter selects among @samp{t} and @samp{p} using image analysis.
11922
11923 @item B
11924 Capture bottom-first, transfer unknown or varying.
11925 Filter selects among @samp{b} and @samp{p} using image analysis.
11926
11927 @item A
11928 Capture determined by field flags, transfer unknown or varying.
11929 Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
11930 image analysis. If no field information is available, then this works just
11931 like @samp{U}. This is the default mode.
11932
11933 @item U
11934 Both capture and transfer unknown or varying.
11935 Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
11936 @end table
11937 @end table
11938
11939 @section pixdesctest
11940
11941 Pixel format descriptor test filter, mainly useful for internal
11942 testing. The output video should be equal to the input video.
11943
11944 For example:
11945 @example
11946 format=monow, pixdesctest
11947 @end example
11948
11949 can be used to test the monowhite pixel format descriptor definition.
11950
11951 @section pixscope
11952
11953 Display sample values of color channels. Mainly useful for checking color
11954 and levels. Minimum supported resolution is 640x480.
11955
11956 The filters accept the following options:
11957
11958 @table @option
11959 @item x
11960 Set scope X position, relative offset on X axis.
11961
11962 @item y
11963 Set scope Y position, relative offset on Y axis.
11964
11965 @item w
11966 Set scope width.
11967
11968 @item h
11969 Set scope height.
11970
11971 @item o
11972 Set window opacity. This window also holds statistics about pixel area.
11973
11974 @item wx
11975 Set window X position, relative offset on X axis.
11976
11977 @item wy
11978 Set window Y position, relative offset on Y axis.
11979 @end table
11980
11981 @section pp
11982
11983 Enable the specified chain of postprocessing subfilters using libpostproc. This
11984 library should be automatically selected with a GPL build (@code{--enable-gpl}).
11985 Subfilters must be separated by '/' and can be disabled by prepending a '-'.
11986 Each subfilter and some options have a short and a long name that can be used
11987 interchangeably, i.e. dr/dering are the same.
11988
11989 The filters accept the following options:
11990
11991 @table @option
11992 @item subfilters
11993 Set postprocessing subfilters string.
11994 @end table
11995
11996 All subfilters share common options to determine their scope:
11997
11998 @table @option
11999 @item a/autoq
12000 Honor the quality commands for this subfilter.
12001
12002 @item c/chrom
12003 Do chrominance filtering, too (default).
12004
12005 @item y/nochrom
12006 Do luminance filtering only (no chrominance).
12007
12008 @item n/noluma
12009 Do chrominance filtering only (no luminance).
12010 @end table
12011
12012 These options can be appended after the subfilter name, separated by a '|'.
12013
12014 Available subfilters are:
12015
12016 @table @option
12017 @item hb/hdeblock[|difference[|flatness]]
12018 Horizontal deblocking filter
12019 @table @option
12020 @item difference
12021 Difference factor where higher values mean more deblocking (default: @code{32}).
12022 @item flatness
12023 Flatness threshold where lower values mean more deblocking (default: @code{39}).
12024 @end table
12025
12026 @item vb/vdeblock[|difference[|flatness]]
12027 Vertical deblocking filter
12028 @table @option
12029 @item difference
12030 Difference factor where higher values mean more deblocking (default: @code{32}).
12031 @item flatness
12032 Flatness threshold where lower values mean more deblocking (default: @code{39}).
12033 @end table
12034
12035 @item ha/hadeblock[|difference[|flatness]]
12036 Accurate horizontal deblocking filter
12037 @table @option
12038 @item difference
12039 Difference factor where higher values mean more deblocking (default: @code{32}).
12040 @item flatness
12041 Flatness threshold where lower values mean more deblocking (default: @code{39}).
12042 @end table
12043
12044 @item va/vadeblock[|difference[|flatness]]
12045 Accurate vertical deblocking filter
12046 @table @option
12047 @item difference
12048 Difference factor where higher values mean more deblocking (default: @code{32}).
12049 @item flatness
12050 Flatness threshold where lower values mean more deblocking (default: @code{39}).
12051 @end table
12052 @end table
12053
12054 The horizontal and vertical deblocking filters share the difference and
12055 flatness values so you cannot set different horizontal and vertical
12056 thresholds.
12057
12058 @table @option
12059 @item h1/x1hdeblock
12060 Experimental horizontal deblocking filter
12061
12062 @item v1/x1vdeblock
12063 Experimental vertical deblocking filter
12064
12065 @item dr/dering
12066 Deringing filter
12067
12068 @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
12069 @table @option
12070 @item threshold1
12071 larger -> stronger filtering
12072 @item threshold2
12073 larger -> stronger filtering
12074 @item threshold3
12075 larger -> stronger filtering
12076 @end table
12077
12078 @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
12079 @table @option
12080 @item f/fullyrange
12081 Stretch luminance to @code{0-255}.
12082 @end table
12083
12084 @item lb/linblenddeint
12085 Linear blend deinterlacing filter that deinterlaces the given block by
12086 filtering all lines with a @code{(1 2 1)} filter.
12087
12088 @item li/linipoldeint
12089 Linear interpolating deinterlacing filter that deinterlaces the given block by
12090 linearly interpolating every second line.
12091
12092 @item ci/cubicipoldeint
12093 Cubic interpolating deinterlacing filter deinterlaces the given block by
12094 cubically interpolating every second line.
12095
12096 @item md/mediandeint
12097 Median deinterlacing filter that deinterlaces the given block by applying a
12098 median filter to every second line.
12099
12100 @item fd/ffmpegdeint
12101 FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
12102 second line with a @code{(-1 4 2 4 -1)} filter.
12103
12104 @item l5/lowpass5
12105 Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
12106 block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
12107
12108 @item fq/forceQuant[|quantizer]
12109 Overrides the quantizer table from the input with the constant quantizer you
12110 specify.
12111 @table @option
12112 @item quantizer
12113 Quantizer to use
12114 @end table
12115
12116 @item de/default
12117 Default pp filter combination (@code{hb|a,vb|a,dr|a})
12118
12119 @item fa/fast
12120 Fast pp filter combination (@code{h1|a,v1|a,dr|a})
12121
12122 @item ac
12123 High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
12124 @end table
12125
12126 @subsection Examples
12127
12128 @itemize
12129 @item
12130 Apply horizontal and vertical deblocking, deringing and automatic
12131 brightness/contrast:
12132 @example
12133 pp=hb/vb/dr/al
12134 @end example
12135
12136 @item
12137 Apply default filters without brightness/contrast correction:
12138 @example
12139 pp=de/-al
12140 @end example
12141
12142 @item
12143 Apply default filters and temporal denoiser:
12144 @example
12145 pp=default/tmpnoise|1|2|3
12146 @end example
12147
12148 @item
12149 Apply deblocking on luminance only, and switch vertical deblocking on or off
12150 automatically depending on available CPU time:
12151 @example
12152 pp=hb|y/vb|a
12153 @end example
12154 @end itemize
12155
12156 @section pp7
12157 Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
12158 similar to spp = 6 with 7 point DCT, where only the center sample is
12159 used after IDCT.
12160
12161 The filter accepts the following options:
12162
12163 @table @option
12164 @item qp
12165 Force a constant quantization parameter. It accepts an integer in range
12166 0 to 63. If not set, the filter will use the QP from the video stream
12167 (if available).
12168
12169 @item mode
12170 Set thresholding mode. Available modes are:
12171
12172 @table @samp
12173 @item hard
12174 Set hard thresholding.
12175 @item soft
12176 Set soft thresholding (better de-ringing effect, but likely blurrier).
12177 @item medium
12178 Set medium thresholding (good results, default).
12179 @end table
12180 @end table
12181
12182 @section premultiply
12183 Apply alpha premultiply effect to input video stream using first plane
12184 of second stream as alpha.
12185
12186 Both streams must have same dimensions and same pixel format.
12187
12188 The filter accepts the following option:
12189
12190 @table @option
12191 @item planes
12192 Set which planes will be processed, unprocessed planes will be copied.
12193 By default value 0xf, all planes will be processed.
12194
12195 @item inplace
12196 Do not require 2nd input for processing, instead use alpha plane from input stream.
12197 @end table
12198
12199 @section prewitt
12200 Apply prewitt operator to input video stream.
12201
12202 The filter accepts the following option:
12203
12204 @table @option
12205 @item planes
12206 Set which planes will be processed, unprocessed planes will be copied.
12207 By default value 0xf, all planes will be processed.
12208
12209 @item scale
12210 Set value which will be multiplied with filtered result.
12211
12212 @item delta
12213 Set value which will be added to filtered result.
12214 @end table
12215
12216 @section pseudocolor
12217
12218 Alter frame colors in video with pseudocolors.
12219
12220 This filter accept the following options:
12221
12222 @table @option
12223 @item c0
12224 set pixel first component expression
12225
12226 @item c1
12227 set pixel second component expression
12228
12229 @item c2
12230 set pixel third component expression
12231
12232 @item c3
12233 set pixel fourth component expression, corresponds to the alpha component
12234
12235 @item i
12236 set component to use as base for altering colors
12237 @end table
12238
12239 Each of them specifies the expression to use for computing the lookup table for
12240 the corresponding pixel component values.
12241
12242 The expressions can contain the following constants and functions:
12243
12244 @table @option
12245 @item w
12246 @item h
12247 The input width and height.
12248
12249 @item val
12250 The input value for the pixel component.
12251
12252 @item ymin, umin, vmin, amin
12253 The minimum allowed component value.
12254
12255 @item ymax, umax, vmax, amax
12256 The maximum allowed component value.
12257 @end table
12258
12259 All expressions default to "val".
12260
12261 @subsection Examples
12262
12263 @itemize
12264 @item
12265 Change too high luma values to gradient:
12266 @example
12267 pseudocolor="'if(between(val,ymax,amax),lerp(ymin,ymax,(val-ymax)/(amax-ymax)),-1):if(between(val,ymax,amax),lerp(umax,umin,(val-ymax)/(amax-ymax)),-1):if(between(val,ymax,amax),lerp(vmin,vmax,(val-ymax)/(amax-ymax)),-1):-1'"
12268 @end example
12269 @end itemize
12270
12271 @section psnr
12272
12273 Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
12274 Ratio) between two input videos.
12275
12276 This filter takes in input two input videos, the first input is
12277 considered the "main" source and is passed unchanged to the
12278 output. The second input is used as a "reference" video for computing
12279 the PSNR.
12280
12281 Both video inputs must have the same resolution and pixel format for
12282 this filter to work correctly. Also it assumes that both inputs
12283 have the same number of frames, which are compared one by one.
12284
12285 The obtained average PSNR is printed through the logging system.
12286
12287 The filter stores the accumulated MSE (mean squared error) of each
12288 frame, and at the end of the processing it is averaged across all frames
12289 equally, and the following formula is applied to obtain the PSNR:
12290
12291 @example
12292 PSNR = 10*log10(MAX^2/MSE)
12293 @end example
12294
12295 Where MAX is the average of the maximum values of each component of the
12296 image.
12297
12298 The description of the accepted parameters follows.
12299
12300 @table @option
12301 @item stats_file, f
12302 If specified the filter will use the named file to save the PSNR of
12303 each individual frame. When filename equals "-" the data is sent to
12304 standard output.
12305
12306 @item stats_version
12307 Specifies which version of the stats file format to use. Details of
12308 each format are written below.
12309 Default value is 1.
12310
12311 @item stats_add_max
12312 Determines whether the max value is output to the stats log.
12313 Default value is 0.
12314 Requires stats_version >= 2. If this is set and stats_version < 2,
12315 the filter will return an error.
12316 @end table
12317
12318 This filter also supports the @ref{framesync} options.
12319
12320 The file printed if @var{stats_file} is selected, contains a sequence of
12321 key/value pairs of the form @var{key}:@var{value} for each compared
12322 couple of frames.
12323
12324 If a @var{stats_version} greater than 1 is specified, a header line precedes
12325 the list of per-frame-pair stats, with key value pairs following the frame
12326 format with the following parameters:
12327
12328 @table @option
12329 @item psnr_log_version
12330 The version of the log file format. Will match @var{stats_version}.
12331
12332 @item fields
12333 A comma separated list of the per-frame-pair parameters included in
12334 the log.
12335 @end table
12336
12337 A description of each shown per-frame-pair parameter follows:
12338
12339 @table @option
12340 @item n
12341 sequential number of the input frame, starting from 1
12342
12343 @item mse_avg
12344 Mean Square Error pixel-by-pixel average difference of the compared
12345 frames, averaged over all the image components.
12346
12347 @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
12348 Mean Square Error pixel-by-pixel average difference of the compared
12349 frames for the component specified by the suffix.
12350
12351 @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
12352 Peak Signal to Noise ratio of the compared frames for the component
12353 specified by the suffix.
12354
12355 @item max_avg, max_y, max_u, max_v
12356 Maximum allowed value for each channel, and average over all
12357 channels.
12358 @end table
12359
12360 For example:
12361 @example
12362 movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
12363 [main][ref] psnr="stats_file=stats.log" [out]
12364 @end example
12365
12366 On this example the input file being processed is compared with the
12367 reference file @file{ref_movie.mpg}. The PSNR of each individual frame
12368 is stored in @file{stats.log}.
12369
12370 @anchor{pullup}
12371 @section pullup
12372
12373 Pulldown reversal (inverse telecine) filter, capable of handling mixed
12374 hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
12375 content.
12376
12377 The pullup filter is designed to take advantage of future context in making
12378 its decisions. This filter is stateless in the sense that it does not lock
12379 onto a pattern to follow, but it instead looks forward to the following
12380 fields in order to identify matches and rebuild progressive frames.
12381
12382 To produce content with an even framerate, insert the fps filter after
12383 pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
12384 @code{fps=24} for 30fps and the (rare) telecined 25fps input.
12385
12386 The filter accepts the following options:
12387
12388 @table @option
12389 @item jl
12390 @item jr
12391 @item jt
12392 @item jb
12393 These options set the amount of "junk" to ignore at the left, right, top, and
12394 bottom of the image, respectively. Left and right are in units of 8 pixels,
12395 while top and bottom are in units of 2 lines.
12396 The default is 8 pixels on each side.
12397
12398 @item sb
12399 Set the strict breaks. Setting this option to 1 will reduce the chances of
12400 filter generating an occasional mismatched frame, but it may also cause an
12401 excessive number of frames to be dropped during high motion sequences.
12402 Conversely, setting it to -1 will make filter match fields more easily.
12403 This may help processing of video where there is slight blurring between
12404 the fields, but may also cause there to be interlaced frames in the output.
12405 Default value is @code{0}.
12406
12407 @item mp
12408 Set the metric plane to use. It accepts the following values:
12409 @table @samp
12410 @item l
12411 Use luma plane.
12412
12413 @item u
12414 Use chroma blue plane.
12415
12416 @item v
12417 Use chroma red plane.
12418 @end table
12419
12420 This option may be set to use chroma plane instead of the default luma plane
12421 for doing filter's computations. This may improve accuracy on very clean
12422 source material, but more likely will decrease accuracy, especially if there
12423 is chroma noise (rainbow effect) or any grayscale video.
12424 The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
12425 load and make pullup usable in realtime on slow machines.
12426 @end table
12427
12428 For best results (without duplicated frames in the output file) it is
12429 necessary to change the output frame rate. For example, to inverse
12430 telecine NTSC input:
12431 @example
12432 ffmpeg -i input -vf pullup -r 24000/1001 ...
12433 @end example
12434
12435 @section qp
12436
12437 Change video quantization parameters (QP).
12438
12439 The filter accepts the following option:
12440
12441 @table @option
12442 @item qp
12443 Set expression for quantization parameter.
12444 @end table
12445
12446 The expression is evaluated through the eval API and can contain, among others,
12447 the following constants:
12448
12449 @table @var
12450 @item known
12451 1 if index is not 129, 0 otherwise.
12452
12453 @item qp
12454 Sequential index starting from -129 to 128.
12455 @end table
12456
12457 @subsection Examples
12458
12459 @itemize
12460 @item
12461 Some equation like:
12462 @example
12463 qp=2+2*sin(PI*qp)
12464 @end example
12465 @end itemize
12466
12467 @section random
12468
12469 Flush video frames from internal cache of frames into a random order.
12470 No frame is discarded.
12471 Inspired by @ref{frei0r} nervous filter.
12472
12473 @table @option
12474 @item frames
12475 Set size in number of frames of internal cache, in range from @code{2} to
12476 @code{512}. Default is @code{30}.
12477
12478 @item seed
12479 Set seed for random number generator, must be an integer included between
12480 @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
12481 less than @code{0}, the filter will try to use a good random seed on a
12482 best effort basis.
12483 @end table
12484
12485 @section readeia608
12486
12487 Read closed captioning (EIA-608) information from the top lines of a video frame.
12488
12489 This filter adds frame metadata for @code{lavfi.readeia608.X.cc} and
12490 @code{lavfi.readeia608.X.line}, where @code{X} is the number of the identified line
12491 with EIA-608 data (starting from 0). A description of each metadata value follows:
12492
12493 @table @option
12494 @item lavfi.readeia608.X.cc
12495 The two bytes stored as EIA-608 data (printed in hexadecimal).
12496
12497 @item lavfi.readeia608.X.line
12498 The number of the line on which the EIA-608 data was identified and read.
12499 @end table
12500
12501 This filter accepts the following options:
12502
12503 @table @option
12504 @item scan_min
12505 Set the line to start scanning for EIA-608 data. Default is @code{0}.
12506
12507 @item scan_max
12508 Set the line to end scanning for EIA-608 data. Default is @code{29}.
12509
12510 @item mac
12511 Set minimal acceptable amplitude change for sync codes detection.
12512 Default is @code{0.2}. Allowed range is @code{[0.001 - 1]}.
12513
12514 @item spw
12515 Set the ratio of width reserved for sync code detection.
12516 Default is @code{0.27}. Allowed range is @code{[0.01 - 0.7]}.
12517
12518 @item mhd
12519 Set the max peaks height difference for sync code detection.
12520 Default is @code{0.1}. Allowed range is @code{[0.0 - 0.5]}.
12521
12522 @item mpd
12523 Set max peaks period difference for sync code detection.
12524 Default is @code{0.1}. Allowed range is @code{[0.0 - 0.5]}.
12525
12526 @item msd
12527 Set the first two max start code bits differences.
12528 Default is @code{0.02}. Allowed range is @code{[0.0 - 0.5]}.
12529
12530 @item bhd
12531 Set the minimum ratio of bits height compared to 3rd start code bit.
12532 Default is @code{0.75}. Allowed range is @code{[0.01 - 1]}.
12533
12534 @item th_w
12535 Set the white color threshold. Default is @code{0.35}. Allowed range is @code{[0.1 - 1]}.
12536
12537 @item th_b
12538 Set the black color threshold. Default is @code{0.15}. Allowed range is @code{[0.0 - 0.5]}.
12539
12540 @item chp
12541 Enable checking the parity bit. In the event of a parity error, the filter will output
12542 @code{0x00} for that character. Default is false.
12543 @end table
12544
12545 @subsection Examples
12546
12547 @itemize
12548 @item
12549 Output a csv with presentation time and the first two lines of identified EIA-608 captioning data.
12550 @example
12551 ffprobe -f lavfi -i movie=captioned_video.mov,readeia608 -show_entries frame=pkt_pts_time:frame_tags=lavfi.readeia608.0.cc,lavfi.readeia608.1.cc -of csv
12552 @end example
12553 @end itemize
12554
12555 @section readvitc
12556
12557 Read vertical interval timecode (VITC) information from the top lines of a
12558 video frame.
12559
12560 The filter adds frame metadata key @code{lavfi.readvitc.tc_str} with the
12561 timecode value, if a valid timecode has been detected. Further metadata key
12562 @code{lavfi.readvitc.found} is set to 0/1 depending on whether
12563 timecode data has been found or not.
12564
12565 This filter accepts the following options:
12566
12567 @table @option
12568 @item scan_max
12569 Set the maximum number of lines to scan for VITC data. If the value is set to
12570 @code{-1} the full video frame is scanned. Default is @code{45}.
12571
12572 @item thr_b
12573 Set the luma threshold for black. Accepts float numbers in the range [0.0,1.0],
12574 default value is @code{0.2}. The value must be equal or less than @code{thr_w}.
12575
12576 @item thr_w
12577 Set the luma threshold for white. Accepts float numbers in the range [0.0,1.0],
12578 default value is @code{0.6}. The value must be equal or greater than @code{thr_b}.
12579 @end table
12580
12581 @subsection Examples
12582
12583 @itemize
12584 @item
12585 Detect and draw VITC data onto the video frame; if no valid VITC is detected,
12586 draw @code{--:--:--:--} as a placeholder:
12587 @example
12588 ffmpeg -i input.avi -filter:v 'readvitc,drawtext=fontfile=FreeMono.ttf:text=%@{metadata\\:lavfi.readvitc.tc_str\\:--\\\\\\:--\\\\\\:--\\\\\\:--@}:x=(w-tw)/2:y=400-ascent'
12589 @end example
12590 @end itemize
12591
12592 @section remap
12593
12594 Remap pixels using 2nd: Xmap and 3rd: Ymap input video stream.
12595
12596 Destination pixel at position (X, Y) will be picked from source (x, y) position
12597 where x = Xmap(X, Y) and y = Ymap(X, Y). If mapping values are out of range, zero
12598 value for pixel will be used for destination pixel.
12599
12600 Xmap and Ymap input video streams must be of same dimensions. Output video stream
12601 will have Xmap/Ymap video stream dimensions.
12602 Xmap and Ymap input video streams are 16bit depth, single channel.
12603
12604 @section removegrain
12605
12606 The removegrain filter is a spatial denoiser for progressive video.
12607
12608 @table @option
12609 @item m0
12610 Set mode for the first plane.
12611
12612 @item m1
12613 Set mode for the second plane.
12614
12615 @item m2
12616 Set mode for the third plane.
12617
12618 @item m3
12619 Set mode for the fourth plane.
12620 @end table
12621
12622 Range of mode is from 0 to 24. Description of each mode follows:
12623
12624 @table @var
12625 @item 0
12626 Leave input plane unchanged. Default.
12627
12628 @item 1
12629 Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
12630
12631 @item 2
12632 Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
12633
12634 @item 3
12635 Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
12636
12637 @item 4
12638 Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
12639 This is equivalent to a median filter.
12640
12641 @item 5
12642 Line-sensitive clipping giving the minimal change.
12643
12644 @item 6
12645 Line-sensitive clipping, intermediate.
12646
12647 @item 7
12648 Line-sensitive clipping, intermediate.
12649
12650 @item 8
12651 Line-sensitive clipping, intermediate.
12652
12653 @item 9
12654 Line-sensitive clipping on a line where the neighbours pixels are the closest.
12655
12656 @item 10
12657 Replaces the target pixel with the closest neighbour.
12658
12659 @item 11
12660 [1 2 1] horizontal and vertical kernel blur.
12661
12662 @item 12
12663 Same as mode 11.
12664
12665 @item 13
12666 Bob mode, interpolates top field from the line where the neighbours
12667 pixels are the closest.
12668
12669 @item 14
12670 Bob mode, interpolates bottom field from the line where the neighbours
12671 pixels are the closest.
12672
12673 @item 15
12674 Bob mode, interpolates top field. Same as 13 but with a more complicated
12675 interpolation formula.
12676
12677 @item 16
12678 Bob mode, interpolates bottom field. Same as 14 but with a more complicated
12679 interpolation formula.
12680
12681 @item 17
12682 Clips the pixel with the minimum and maximum of respectively the maximum and
12683 minimum of each pair of opposite neighbour pixels.
12684
12685 @item 18
12686 Line-sensitive clipping using opposite neighbours whose greatest distance from
12687 the current pixel is minimal.
12688
12689 @item 19
12690 Replaces the pixel with the average of its 8 neighbours.
12691
12692 @item 20
12693 Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
12694
12695 @item 21
12696 Clips pixels using the averages of opposite neighbour.
12697
12698 @item 22
12699 Same as mode 21 but simpler and faster.
12700
12701 @item 23
12702 Small edge and halo removal, but reputed useless.
12703
12704 @item 24
12705 Similar as 23.
12706 @end table
12707
12708 @section removelogo
12709
12710 Suppress a TV station logo, using an image file to determine which
12711 pixels comprise the logo. It works by filling in the pixels that
12712 comprise the logo with neighboring pixels.
12713
12714 The filter accepts the following options:
12715
12716 @table @option
12717 @item filename, f
12718 Set the filter bitmap file, which can be any image format supported by
12719 libavformat. The width and height of the image file must match those of the
12720 video stream being processed.
12721 @end table
12722
12723 Pixels in the provided bitmap image with a value of zero are not
12724 considered part of the logo, non-zero pixels are considered part of
12725 the logo. If you use white (255) for the logo and black (0) for the
12726 rest, you will be safe. For making the filter bitmap, it is
12727 recommended to take a screen capture of a black frame with the logo
12728 visible, and then using a threshold filter followed by the erode
12729 filter once or twice.
12730
12731 If needed, little splotches can be fixed manually. Remember that if
12732 logo pixels are not covered, the filter quality will be much
12733 reduced. Marking too many pixels as part of the logo does not hurt as
12734 much, but it will increase the amount of blurring needed to cover over
12735 the image and will destroy more information than necessary, and extra
12736 pixels will slow things down on a large logo.
12737
12738 @section repeatfields
12739
12740 This filter uses the repeat_field flag from the Video ES headers and hard repeats
12741 fields based on its value.
12742
12743 @section reverse
12744
12745 Reverse a video clip.
12746
12747 Warning: This filter requires memory to buffer the entire clip, so trimming
12748 is suggested.
12749
12750 @subsection Examples
12751
12752 @itemize
12753 @item
12754 Take the first 5 seconds of a clip, and reverse it.
12755 @example
12756 trim=end=5,reverse
12757 @end example
12758 @end itemize
12759
12760 @section roberts
12761 Apply roberts cross operator to input video stream.
12762
12763 The filter accepts the following option:
12764
12765 @table @option
12766 @item planes
12767 Set which planes will be processed, unprocessed planes will be copied.
12768 By default value 0xf, all planes will be processed.
12769
12770 @item scale
12771 Set value which will be multiplied with filtered result.
12772
12773 @item delta
12774 Set value which will be added to filtered result.
12775 @end table
12776
12777 @section rotate
12778
12779 Rotate video by an arbitrary angle expressed in radians.
12780
12781 The filter accepts the following options:
12782
12783 A description of the optional parameters follows.
12784 @table @option
12785 @item angle, a
12786 Set an expression for the angle by which to rotate the input video
12787 clockwise, expressed as a number of radians. A negative value will
12788 result in a counter-clockwise rotation. By default it is set to "0".
12789
12790 This expression is evaluated for each frame.
12791
12792 @item out_w, ow
12793 Set the output width expression, default value is "iw".
12794 This expression is evaluated just once during configuration.
12795
12796 @item out_h, oh
12797 Set the output height expression, default value is "ih".
12798 This expression is evaluated just once during configuration.
12799
12800 @item bilinear
12801 Enable bilinear interpolation if set to 1, a value of 0 disables
12802 it. Default value is 1.
12803
12804 @item fillcolor, c
12805 Set the color used to fill the output area not covered by the rotated
12806 image. For the general syntax of this option, check the "Color" section in the
12807 ffmpeg-utils manual. If the special value "none" is selected then no
12808 background is printed (useful for example if the background is never shown).
12809
12810 Default value is "black".
12811 @end table
12812
12813 The expressions for the angle and the output size can contain the
12814 following constants and functions:
12815
12816 @table @option
12817 @item n
12818 sequential number of the input frame, starting from 0. It is always NAN
12819 before the first frame is filtered.
12820
12821 @item t
12822 time in seconds of the input frame, it is set to 0 when the filter is
12823 configured. It is always NAN before the first frame is filtered.
12824
12825 @item hsub
12826 @item vsub
12827 horizontal and vertical chroma subsample values. For example for the
12828 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
12829
12830 @item in_w, iw
12831 @item in_h, ih
12832 the input video width and height
12833
12834 @item out_w, ow
12835 @item out_h, oh
12836 the output width and height, that is the size of the padded area as
12837 specified by the @var{width} and @var{height} expressions
12838
12839 @item rotw(a)
12840 @item roth(a)
12841 the minimal width/height required for completely containing the input
12842 video rotated by @var{a} radians.
12843
12844 These are only available when computing the @option{out_w} and
12845 @option{out_h} expressions.
12846 @end table
12847
12848 @subsection Examples
12849
12850 @itemize
12851 @item
12852 Rotate the input by PI/6 radians clockwise:
12853 @example
12854 rotate=PI/6
12855 @end example
12856
12857 @item
12858 Rotate the input by PI/6 radians counter-clockwise:
12859 @example
12860 rotate=-PI/6
12861 @end example
12862
12863 @item
12864 Rotate the input by 45 degrees clockwise:
12865 @example
12866 rotate=45*PI/180
12867 @end example
12868
12869 @item
12870 Apply a constant rotation with period T, starting from an angle of PI/3:
12871 @example
12872 rotate=PI/3+2*PI*t/T
12873 @end example
12874
12875 @item
12876 Make the input video rotation oscillating with a period of T
12877 seconds and an amplitude of A radians:
12878 @example
12879 rotate=A*sin(2*PI/T*t)
12880 @end example
12881
12882 @item
12883 Rotate the video, output size is chosen so that the whole rotating
12884 input video is always completely contained in the output:
12885 @example
12886 rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
12887 @end example
12888
12889 @item
12890 Rotate the video, reduce the output size so that no background is ever
12891 shown:
12892 @example
12893 rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
12894 @end example
12895 @end itemize
12896
12897 @subsection Commands
12898
12899 The filter supports the following commands:
12900
12901 @table @option
12902 @item a, angle
12903 Set the angle expression.
12904 The command accepts the same syntax of the corresponding option.
12905
12906 If the specified expression is not valid, it is kept at its current
12907 value.
12908 @end table
12909
12910 @section sab
12911
12912 Apply Shape Adaptive Blur.
12913
12914 The filter accepts the following options:
12915
12916 @table @option
12917 @item luma_radius, lr
12918 Set luma blur filter strength, must be a value in range 0.1-4.0, default
12919 value is 1.0. A greater value will result in a more blurred image, and
12920 in slower processing.
12921
12922 @item luma_pre_filter_radius, lpfr
12923 Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
12924 value is 1.0.
12925
12926 @item luma_strength, ls
12927 Set luma maximum difference between pixels to still be considered, must
12928 be a value in the 0.1-100.0 range, default value is 1.0.
12929
12930 @item chroma_radius, cr
12931 Set chroma blur filter strength, must be a value in range -0.9-4.0. A
12932 greater value will result in a more blurred image, and in slower
12933 processing.
12934
12935 @item chroma_pre_filter_radius, cpfr
12936 Set chroma pre-filter radius, must be a value in the -0.9-2.0 range.
12937
12938 @item chroma_strength, cs
12939 Set chroma maximum difference between pixels to still be considered,
12940 must be a value in the -0.9-100.0 range.
12941 @end table
12942
12943 Each chroma option value, if not explicitly specified, is set to the
12944 corresponding luma option value.
12945
12946 @anchor{scale}
12947 @section scale
12948
12949 Scale (resize) the input video, using the libswscale library.
12950
12951 The scale filter forces the output display aspect ratio to be the same
12952 of the input, by changing the output sample aspect ratio.
12953
12954 If the input image format is different from the format requested by
12955 the next filter, the scale filter will convert the input to the
12956 requested format.
12957
12958 @subsection Options
12959 The filter accepts the following options, or any of the options
12960 supported by the libswscale scaler.
12961
12962 See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
12963 the complete list of scaler options.
12964
12965 @table @option
12966 @item width, w
12967 @item height, h
12968 Set the output video dimension expression. Default value is the input
12969 dimension.
12970
12971 If the @var{width} or @var{w} value is 0, the input width is used for
12972 the output. If the @var{height} or @var{h} value is 0, the input height
12973 is used for the output.
12974
12975 If one and only one of the values is -n with n >= 1, the scale filter
12976 will use a value that maintains the aspect ratio of the input image,
12977 calculated from the other specified dimension. After that it will,
12978 however, make sure that the calculated dimension is divisible by n and
12979 adjust the value if necessary.
12980
12981 If both values are -n with n >= 1, the behavior will be identical to
12982 both values being set to 0 as previously detailed.
12983
12984 See below for the list of accepted constants for use in the dimension
12985 expression.
12986
12987 @item eval
12988 Specify when to evaluate @var{width} and @var{height} expression. It accepts the following values:
12989
12990 @table @samp
12991 @item init
12992 Only evaluate expressions once during the filter initialization or when a command is processed.
12993
12994 @item frame
12995 Evaluate expressions for each incoming frame.
12996
12997 @end table
12998
12999 Default value is @samp{init}.
13000
13001
13002 @item interl
13003 Set the interlacing mode. It accepts the following values:
13004
13005 @table @samp
13006 @item 1
13007 Force interlaced aware scaling.
13008
13009 @item 0
13010 Do not apply interlaced scaling.
13011
13012 @item -1
13013 Select interlaced aware scaling depending on whether the source frames
13014 are flagged as interlaced or not.
13015 @end table
13016
13017 Default value is @samp{0}.
13018
13019 @item flags
13020 Set libswscale scaling flags. See
13021 @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
13022 complete list of values. If not explicitly specified the filter applies
13023 the default flags.
13024
13025
13026 @item param0, param1
13027 Set libswscale input parameters for scaling algorithms that need them. See
13028 @ref{sws_params,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
13029 complete documentation. If not explicitly specified the filter applies
13030 empty parameters.
13031
13032
13033
13034 @item size, s
13035 Set the video size. For the syntax of this option, check the
13036 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
13037
13038 @item in_color_matrix
13039 @item out_color_matrix
13040 Set in/output YCbCr color space type.
13041
13042 This allows the autodetected value to be overridden as well as allows forcing
13043 a specific value used for the output and encoder.
13044
13045 If not specified, the color space type depends on the pixel format.
13046
13047 Possible values:
13048
13049 @table @samp
13050 @item auto
13051 Choose automatically.
13052
13053 @item bt709
13054 Format conforming to International Telecommunication Union (ITU)
13055 Recommendation BT.709.
13056
13057 @item fcc
13058 Set color space conforming to the United States Federal Communications
13059 Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
13060
13061 @item bt601
13062 Set color space conforming to:
13063
13064 @itemize
13065 @item
13066 ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
13067
13068 @item
13069 ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
13070
13071 @item
13072 Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
13073
13074 @end itemize
13075
13076 @item smpte240m
13077 Set color space conforming to SMPTE ST 240:1999.
13078 @end table
13079
13080 @item in_range
13081 @item out_range
13082 Set in/output YCbCr sample range.
13083
13084 This allows the autodetected value to be overridden as well as allows forcing
13085 a specific value used for the output and encoder. If not specified, the
13086 range depends on the pixel format. Possible values:
13087
13088 @table @samp
13089 @item auto
13090 Choose automatically.
13091
13092 @item jpeg/full/pc
13093 Set full range (0-255 in case of 8-bit luma).
13094
13095 @item mpeg/tv
13096 Set "MPEG" range (16-235 in case of 8-bit luma).
13097 @end table
13098
13099 @item force_original_aspect_ratio
13100 Enable decreasing or increasing output video width or height if necessary to
13101 keep the original aspect ratio. Possible values:
13102
13103 @table @samp
13104 @item disable
13105 Scale the video as specified and disable this feature.
13106
13107 @item decrease
13108 The output video dimensions will automatically be decreased if needed.
13109
13110 @item increase
13111 The output video dimensions will automatically be increased if needed.
13112
13113 @end table
13114
13115 One useful instance of this option is that when you know a specific device's
13116 maximum allowed resolution, you can use this to limit the output video to
13117 that, while retaining the aspect ratio. For example, device A allows
13118 1280x720 playback, and your video is 1920x800. Using this option (set it to
13119 decrease) and specifying 1280x720 to the command line makes the output
13120 1280x533.
13121
13122 Please note that this is a different thing than specifying -1 for @option{w}
13123 or @option{h}, you still need to specify the output resolution for this option
13124 to work.
13125
13126 @end table
13127
13128 The values of the @option{w} and @option{h} options are expressions
13129 containing the following constants:
13130
13131 @table @var
13132 @item in_w
13133 @item in_h
13134 The input width and height
13135
13136 @item iw
13137 @item ih
13138 These are the same as @var{in_w} and @var{in_h}.
13139
13140 @item out_w
13141 @item out_h
13142 The output (scaled) width and height
13143
13144 @item ow
13145 @item oh
13146 These are the same as @var{out_w} and @var{out_h}
13147
13148 @item a
13149 The same as @var{iw} / @var{ih}
13150
13151 @item sar
13152 input sample aspect ratio
13153
13154 @item dar
13155 The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
13156
13157 @item hsub
13158 @item vsub
13159 horizontal and vertical input chroma subsample values. For example for the
13160 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
13161
13162 @item ohsub
13163 @item ovsub
13164 horizontal and vertical output chroma subsample values. For example for the
13165 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
13166 @end table
13167
13168 @subsection Examples
13169
13170 @itemize
13171 @item
13172 Scale the input video to a size of 200x100
13173 @example
13174 scale=w=200:h=100
13175 @end example
13176
13177 This is equivalent to:
13178 @example
13179 scale=200:100
13180 @end example
13181
13182 or:
13183 @example
13184 scale=200x100
13185 @end example
13186
13187 @item
13188 Specify a size abbreviation for the output size:
13189 @example
13190 scale=qcif
13191 @end example
13192
13193 which can also be written as:
13194 @example
13195 scale=size=qcif
13196 @end example
13197
13198 @item
13199 Scale the input to 2x:
13200 @example
13201 scale=w=2*iw:h=2*ih
13202 @end example
13203
13204 @item
13205 The above is the same as:
13206 @example
13207 scale=2*in_w:2*in_h
13208 @end example
13209
13210 @item
13211 Scale the input to 2x with forced interlaced scaling:
13212 @example
13213 scale=2*iw:2*ih:interl=1
13214 @end example
13215
13216 @item
13217 Scale the input to half size:
13218 @example
13219 scale=w=iw/2:h=ih/2
13220 @end example
13221
13222 @item
13223 Increase the width, and set the height to the same size:
13224 @example
13225 scale=3/2*iw:ow
13226 @end example
13227
13228 @item
13229 Seek Greek harmony:
13230 @example
13231 scale=iw:1/PHI*iw
13232 scale=ih*PHI:ih
13233 @end example
13234
13235 @item
13236 Increase the height, and set the width to 3/2 of the height:
13237 @example
13238 scale=w=3/2*oh:h=3/5*ih
13239 @end example
13240
13241 @item
13242 Increase the size, making the size a multiple of the chroma
13243 subsample values:
13244 @example
13245 scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
13246 @end example
13247
13248 @item
13249 Increase the width to a maximum of 500 pixels,
13250 keeping the same aspect ratio as the input:
13251 @example
13252 scale=w='min(500\, iw*3/2):h=-1'
13253 @end example
13254 @end itemize
13255
13256 @subsection Commands
13257
13258 This filter supports the following commands:
13259 @table @option
13260 @item width, w
13261 @item height, h
13262 Set the output video dimension expression.
13263 The command accepts the same syntax of the corresponding option.
13264
13265 If the specified expression is not valid, it is kept at its current
13266 value.
13267 @end table
13268
13269 @section scale_npp
13270
13271 Use the NVIDIA Performance Primitives (libnpp) to perform scaling and/or pixel
13272 format conversion on CUDA video frames. Setting the output width and height
13273 works in the same way as for the @var{scale} filter.
13274
13275 The following additional options are accepted:
13276 @table @option
13277 @item format
13278 The pixel format of the output CUDA frames. If set to the string "same" (the
13279 default), the input format will be kept. Note that automatic format negotiation
13280 and conversion is not yet supported for hardware frames
13281
13282 @item interp_algo
13283 The interpolation algorithm used for resizing. One of the following:
13284 @table @option
13285 @item nn
13286 Nearest neighbour.
13287
13288 @item linear
13289 @item cubic
13290 @item cubic2p_bspline
13291 2-parameter cubic (B=1, C=0)
13292
13293 @item cubic2p_catmullrom
13294 2-parameter cubic (B=0, C=1/2)
13295
13296 @item cubic2p_b05c03
13297 2-parameter cubic (B=1/2, C=3/10)
13298
13299 @item super
13300 Supersampling
13301
13302 @item lanczos
13303 @end table
13304
13305 @end table
13306
13307 @section scale2ref
13308
13309 Scale (resize) the input video, based on a reference video.
13310
13311 See the scale filter for available options, scale2ref supports the same but
13312 uses the reference video instead of the main input as basis. scale2ref also
13313 supports the following additional constants for the @option{w} and
13314 @option{h} options:
13315
13316 @table @var
13317 @item main_w
13318 @item main_h
13319 The main input video's width and height
13320
13321 @item main_a
13322 The same as @var{main_w} / @var{main_h}
13323
13324 @item main_sar
13325 The main input video's sample aspect ratio
13326
13327 @item main_dar, mdar
13328 The main input video's display aspect ratio. Calculated from
13329 @code{(main_w / main_h) * main_sar}.
13330
13331 @item main_hsub
13332 @item main_vsub
13333 The main input video's horizontal and vertical chroma subsample values.
13334 For example for the pixel format "yuv422p" @var{hsub} is 2 and @var{vsub}
13335 is 1.
13336 @end table
13337
13338 @subsection Examples
13339
13340 @itemize
13341 @item
13342 Scale a subtitle stream (b) to match the main video (a) in size before overlaying
13343 @example
13344 'scale2ref[b][a];[a][b]overlay'
13345 @end example
13346 @end itemize
13347
13348 @anchor{selectivecolor}
13349 @section selectivecolor
13350
13351 Adjust cyan, magenta, yellow and black (CMYK) to certain ranges of colors (such
13352 as "reds", "yellows", "greens", "cyans", ...). The adjustment range is defined
13353 by the "purity" of the color (that is, how saturated it already is).
13354
13355 This filter is similar to the Adobe Photoshop Selective Color tool.
13356
13357 The filter accepts the following options:
13358
13359 @table @option
13360 @item correction_method
13361 Select color correction method.
13362
13363 Available values are:
13364 @table @samp
13365 @item absolute
13366 Specified adjustments are applied "as-is" (added/subtracted to original pixel
13367 component value).
13368 @item relative
13369 Specified adjustments are relative to the original component value.
13370 @end table
13371 Default is @code{absolute}.
13372 @item reds
13373 Adjustments for red pixels (pixels where the red component is the maximum)
13374 @item yellows
13375 Adjustments for yellow pixels (pixels where the blue component is the minimum)
13376 @item greens
13377 Adjustments for green pixels (pixels where the green component is the maximum)
13378 @item cyans
13379 Adjustments for cyan pixels (pixels where the red component is the minimum)
13380 @item blues
13381 Adjustments for blue pixels (pixels where the blue component is the maximum)
13382 @item magentas
13383 Adjustments for magenta pixels (pixels where the green component is the minimum)
13384 @item whites
13385 Adjustments for white pixels (pixels where all components are greater than 128)
13386 @item neutrals
13387 Adjustments for all pixels except pure black and pure white
13388 @item blacks
13389 Adjustments for black pixels (pixels where all components are lesser than 128)
13390 @item psfile
13391 Specify a Photoshop selective color file (@code{.asv}) to import the settings from.
13392 @end table
13393
13394 All the adjustment settings (@option{reds}, @option{yellows}, ...) accept up to
13395 4 space separated floating point adjustment values in the [-1,1] range,
13396 respectively to adjust the amount of cyan, magenta, yellow and black for the
13397 pixels of its range.
13398
13399 @subsection Examples
13400
13401 @itemize
13402 @item
13403 Increase cyan by 50% and reduce yellow by 33% in every green areas, and
13404 increase magenta by 27% in blue areas:
13405 @example
13406 selectivecolor=greens=.5 0 -.33 0:blues=0 .27
13407 @end example
13408
13409 @item
13410 Use a Photoshop selective color preset:
13411 @example
13412 selectivecolor=psfile=MySelectiveColorPresets/Misty.asv
13413 @end example
13414 @end itemize
13415
13416 @anchor{separatefields}
13417 @section separatefields
13418
13419 The @code{separatefields} takes a frame-based video input and splits
13420 each frame into its components fields, producing a new half height clip
13421 with twice the frame rate and twice the frame count.
13422
13423 This filter use field-dominance information in frame to decide which
13424 of each pair of fields to place first in the output.
13425 If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
13426
13427 @section setdar, setsar
13428
13429 The @code{setdar} filter sets the Display Aspect Ratio for the filter
13430 output video.
13431
13432 This is done by changing the specified Sample (aka Pixel) Aspect
13433 Ratio, according to the following equation:
13434 @example
13435 @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
13436 @end example
13437
13438 Keep in mind that the @code{setdar} filter does not modify the pixel
13439 dimensions of the video frame. Also, the display aspect ratio set by
13440 this filter may be changed by later filters in the filterchain,
13441 e.g. in case of scaling or if another "setdar" or a "setsar" filter is
13442 applied.
13443
13444 The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
13445 the filter output video.
13446
13447 Note that as a consequence of the application of this filter, the
13448 output display aspect ratio will change according to the equation
13449 above.
13450
13451 Keep in mind that the sample aspect ratio set by the @code{setsar}
13452 filter may be changed by later filters in the filterchain, e.g. if
13453 another "setsar" or a "setdar" filter is applied.
13454
13455 It accepts the following parameters:
13456
13457 @table @option
13458 @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
13459 Set the aspect ratio used by the filter.
13460
13461 The parameter can be a floating point number string, an expression, or
13462 a string of the form @var{num}:@var{den}, where @var{num} and
13463 @var{den} are the numerator and denominator of the aspect ratio. If
13464 the parameter is not specified, it is assumed the value "0".
13465 In case the form "@var{num}:@var{den}" is used, the @code{:} character
13466 should be escaped.
13467
13468 @item max
13469 Set the maximum integer value to use for expressing numerator and
13470 denominator when reducing the expressed aspect ratio to a rational.
13471 Default value is @code{100}.
13472
13473 @end table
13474
13475 The parameter @var{sar} is an expression containing
13476 the following constants:
13477
13478 @table @option
13479 @item E, PI, PHI
13480 These are approximated values for the mathematical constants e
13481 (Euler's number), pi (Greek pi), and phi (the golden ratio).
13482
13483 @item w, h
13484 The input width and height.
13485
13486 @item a
13487 These are the same as @var{w} / @var{h}.
13488
13489 @item sar
13490 The input sample aspect ratio.
13491
13492 @item dar
13493 The input display aspect ratio. It is the same as
13494 (@var{w} / @var{h}) * @var{sar}.
13495
13496 @item hsub, vsub
13497 Horizontal and vertical chroma subsample values. For example, for the
13498 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
13499 @end table
13500
13501 @subsection Examples
13502
13503 @itemize
13504
13505 @item
13506 To change the display aspect ratio to 16:9, specify one of the following:
13507 @example
13508 setdar=dar=1.77777
13509 setdar=dar=16/9
13510 @end example
13511
13512 @item
13513 To change the sample aspect ratio to 10:11, specify:
13514 @example
13515 setsar=sar=10/11
13516 @end example
13517
13518 @item
13519 To set a display aspect ratio of 16:9, and specify a maximum integer value of
13520 1000 in the aspect ratio reduction, use the command:
13521 @example
13522 setdar=ratio=16/9:max=1000
13523 @end example
13524
13525 @end itemize
13526
13527 @anchor{setfield}
13528 @section setfield
13529
13530 Force field for the output video frame.
13531
13532 The @code{setfield} filter marks the interlace type field for the
13533 output frames. It does not change the input frame, but only sets the
13534 corresponding property, which affects how the frame is treated by
13535 following filters (e.g. @code{fieldorder} or @code{yadif}).
13536
13537 The filter accepts the following options:
13538
13539 @table @option
13540
13541 @item mode
13542 Available values are:
13543
13544 @table @samp
13545 @item auto
13546 Keep the same field property.
13547
13548 @item bff
13549 Mark the frame as bottom-field-first.
13550
13551 @item tff
13552 Mark the frame as top-field-first.
13553
13554 @item prog
13555 Mark the frame as progressive.
13556 @end table
13557 @end table
13558
13559 @section showinfo
13560
13561 Show a line containing various information for each input video frame.
13562 The input video is not modified.
13563
13564 The shown line contains a sequence of key/value pairs of the form
13565 @var{key}:@var{value}.
13566
13567 The following values are shown in the output:
13568
13569 @table @option
13570 @item n
13571 The (sequential) number of the input frame, starting from 0.
13572
13573 @item pts
13574 The Presentation TimeStamp of the input frame, expressed as a number of
13575 time base units. The time base unit depends on the filter input pad.
13576
13577 @item pts_time
13578 The Presentation TimeStamp of the input frame, expressed as a number of
13579 seconds.
13580
13581 @item pos
13582 The position of the frame in the input stream, or -1 if this information is
13583 unavailable and/or meaningless (for example in case of synthetic video).
13584
13585 @item fmt
13586 The pixel format name.
13587
13588 @item sar
13589 The sample aspect ratio of the input frame, expressed in the form
13590 @var{num}/@var{den}.
13591
13592 @item s
13593 The size of the input frame. For the syntax of this option, check the
13594 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
13595
13596 @item i
13597 The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
13598 for bottom field first).
13599
13600 @item iskey
13601 This is 1 if the frame is a key frame, 0 otherwise.
13602
13603 @item type
13604 The picture type of the input frame ("I" for an I-frame, "P" for a
13605 P-frame, "B" for a B-frame, or "?" for an unknown type).
13606 Also refer to the documentation of the @code{AVPictureType} enum and of
13607 the @code{av_get_picture_type_char} function defined in
13608 @file{libavutil/avutil.h}.
13609
13610 @item checksum
13611 The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
13612
13613 @item plane_checksum
13614 The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
13615 expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
13616 @end table
13617
13618 @section showpalette
13619
13620 Displays the 256 colors palette of each frame. This filter is only relevant for
13621 @var{pal8} pixel format frames.
13622
13623 It accepts the following option:
13624
13625 @table @option
13626 @item s
13627 Set the size of the box used to represent one palette color entry. Default is
13628 @code{30} (for a @code{30x30} pixel box).
13629 @end table
13630
13631 @section shuffleframes
13632
13633 Reorder and/or duplicate and/or drop video frames.
13634
13635 It accepts the following parameters:
13636
13637 @table @option
13638 @item mapping
13639 Set the destination indexes of input frames.
13640 This is space or '|' separated list of indexes that maps input frames to output
13641 frames. Number of indexes also sets maximal value that each index may have.
13642 '-1' index have special meaning and that is to drop frame.
13643 @end table
13644
13645 The first frame has the index 0. The default is to keep the input unchanged.
13646
13647 @subsection Examples
13648
13649 @itemize
13650 @item
13651 Swap second and third frame of every three frames of the input:
13652 @example
13653 ffmpeg -i INPUT -vf "shuffleframes=0 2 1" OUTPUT
13654 @end example
13655
13656 @item
13657 Swap 10th and 1st frame of every ten frames of the input:
13658 @example
13659 ffmpeg -i INPUT -vf "shuffleframes=9 1 2 3 4 5 6 7 8 0" OUTPUT
13660 @end example
13661 @end itemize
13662
13663 @section shuffleplanes
13664
13665 Reorder and/or duplicate video planes.
13666
13667 It accepts the following parameters:
13668
13669 @table @option
13670
13671 @item map0
13672 The index of the input plane to be used as the first output plane.
13673
13674 @item map1
13675 The index of the input plane to be used as the second output plane.
13676
13677 @item map2
13678 The index of the input plane to be used as the third output plane.
13679
13680 @item map3
13681 The index of the input plane to be used as the fourth output plane.
13682
13683 @end table
13684
13685 The first plane has the index 0. The default is to keep the input unchanged.
13686
13687 @subsection Examples
13688
13689 @itemize
13690 @item
13691 Swap the second and third planes of the input:
13692 @example
13693 ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
13694 @end example
13695 @end itemize
13696
13697 @anchor{signalstats}
13698 @section signalstats
13699 Evaluate various visual metrics that assist in determining issues associated
13700 with the digitization of analog video media.
13701
13702 By default the filter will log these metadata values:
13703
13704 @table @option
13705 @item YMIN
13706 Display the minimal Y value contained within the input frame. Expressed in
13707 range of [0-255].
13708
13709 @item YLOW
13710 Display the Y value at the 10% percentile within the input frame. Expressed in
13711 range of [0-255].
13712
13713 @item YAVG
13714 Display the average Y value within the input frame. Expressed in range of
13715 [0-255].
13716
13717 @item YHIGH
13718 Display the Y value at the 90% percentile within the input frame. Expressed in
13719 range of [0-255].
13720
13721 @item YMAX
13722 Display the maximum Y value contained within the input frame. Expressed in
13723 range of [0-255].
13724
13725 @item UMIN
13726 Display the minimal U value contained within the input frame. Expressed in
13727 range of [0-255].
13728
13729 @item ULOW
13730 Display the U value at the 10% percentile within the input frame. Expressed in
13731 range of [0-255].
13732
13733 @item UAVG
13734 Display the average U value within the input frame. Expressed in range of
13735 [0-255].
13736
13737 @item UHIGH
13738 Display the U value at the 90% percentile within the input frame. Expressed in
13739 range of [0-255].
13740
13741 @item UMAX
13742 Display the maximum U value contained within the input frame. Expressed in
13743 range of [0-255].
13744
13745 @item VMIN
13746 Display the minimal V value contained within the input frame. Expressed in
13747 range of [0-255].
13748
13749 @item VLOW
13750 Display the V value at the 10% percentile within the input frame. Expressed in
13751 range of [0-255].
13752
13753 @item VAVG
13754 Display the average V value within the input frame. Expressed in range of
13755 [0-255].
13756
13757 @item VHIGH
13758 Display the V value at the 90% percentile within the input frame. Expressed in
13759 range of [0-255].
13760
13761 @item VMAX
13762 Display the maximum V value contained within the input frame. Expressed in
13763 range of [0-255].
13764
13765 @item SATMIN
13766 Display the minimal saturation value contained within the input frame.
13767 Expressed in range of [0-~181.02].
13768
13769 @item SATLOW
13770 Display the saturation value at the 10% percentile within the input frame.
13771 Expressed in range of [0-~181.02].
13772
13773 @item SATAVG
13774 Display the average saturation value within the input frame. Expressed in range
13775 of [0-~181.02].
13776
13777 @item SATHIGH
13778 Display the saturation value at the 90% percentile within the input frame.
13779 Expressed in range of [0-~181.02].
13780
13781 @item SATMAX
13782 Display the maximum saturation value contained within the input frame.
13783 Expressed in range of [0-~181.02].
13784
13785 @item HUEMED
13786 Display the median value for hue within the input frame. Expressed in range of
13787 [0-360].
13788
13789 @item HUEAVG
13790 Display the average value for hue within the input frame. Expressed in range of
13791 [0-360].
13792
13793 @item YDIF
13794 Display the average of sample value difference between all values of the Y
13795 plane in the current frame and corresponding values of the previous input frame.
13796 Expressed in range of [0-255].
13797
13798 @item UDIF
13799 Display the average of sample value difference between all values of the U
13800 plane in the current frame and corresponding values of the previous input frame.
13801 Expressed in range of [0-255].
13802
13803 @item VDIF
13804 Display the average of sample value difference between all values of the V
13805 plane in the current frame and corresponding values of the previous input frame.
13806 Expressed in range of [0-255].
13807
13808 @item YBITDEPTH
13809 Display bit depth of Y plane in current frame.
13810 Expressed in range of [0-16].
13811
13812 @item UBITDEPTH
13813 Display bit depth of U plane in current frame.
13814 Expressed in range of [0-16].
13815
13816 @item VBITDEPTH
13817 Display bit depth of V plane in current frame.
13818 Expressed in range of [0-16].
13819 @end table
13820
13821 The filter accepts the following options:
13822
13823 @table @option
13824 @item stat
13825 @item out
13826
13827 @option{stat} specify an additional form of image analysis.
13828 @option{out} output video with the specified type of pixel highlighted.
13829
13830 Both options accept the following values:
13831
13832 @table @samp
13833 @item tout
13834 Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
13835 unlike the neighboring pixels of the same field. Examples of temporal outliers
13836 include the results of video dropouts, head clogs, or tape tracking issues.
13837
13838 @item vrep
13839 Identify @var{vertical line repetition}. Vertical line repetition includes
13840 similar rows of pixels within a frame. In born-digital video vertical line
13841 repetition is common, but this pattern is uncommon in video digitized from an
13842 analog source. When it occurs in video that results from the digitization of an
13843 analog source it can indicate concealment from a dropout compensator.
13844
13845 @item brng
13846 Identify pixels that fall outside of legal broadcast range.
13847 @end table
13848
13849 @item color, c
13850 Set the highlight color for the @option{out} option. The default color is
13851 yellow.
13852 @end table
13853
13854 @subsection Examples
13855
13856 @itemize
13857 @item
13858 Output data of various video metrics:
13859 @example
13860 ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
13861 @end example
13862
13863 @item
13864 Output specific data about the minimum and maximum values of the Y plane per frame:
13865 @example
13866 ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
13867 @end example
13868
13869 @item
13870 Playback video while highlighting pixels that are outside of broadcast range in red.
13871 @example
13872 ffplay example.mov -vf signalstats="out=brng:color=red"
13873 @end example
13874
13875 @item
13876 Playback video with signalstats metadata drawn over the frame.
13877 @example
13878 ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
13879 @end example
13880
13881 The contents of signalstat_drawtext.txt used in the command are:
13882 @example
13883 time %@{pts:hms@}
13884 Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
13885 U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
13886 V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
13887 saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
13888
13889 @end example
13890 @end itemize
13891
13892 @anchor{signature}
13893 @section signature
13894
13895 Calculates the MPEG-7 Video Signature. The filter can handle more than one
13896 input. In this case the matching between the inputs can be calculated additionally.
13897 The filter always passes through the first input. The signature of each stream can
13898 be written into a file.
13899
13900 It accepts the following options:
13901
13902 @table @option
13903 @item detectmode
13904 Enable or disable the matching process.
13905
13906 Available values are:
13907
13908 @table @samp
13909 @item off
13910 Disable the calculation of a matching (default).
13911 @item full
13912 Calculate the matching for the whole video and output whether the whole video
13913 matches or only parts.
13914 @item fast
13915 Calculate only until a matching is found or the video ends. Should be faster in
13916 some cases.
13917 @end table
13918
13919 @item nb_inputs
13920 Set the number of inputs. The option value must be a non negative integer.
13921 Default value is 1.
13922
13923 @item filename
13924 Set the path to which the output is written. If there is more than one input,
13925 the path must be a prototype, i.e. must contain %d or %0nd (where n is a positive
13926 integer), that will be replaced with the input number. If no filename is
13927 specified, no output will be written. This is the default.
13928
13929 @item format
13930 Choose the output format.
13931
13932 Available values are:
13933
13934 @table @samp
13935 @item binary
13936 Use the specified binary representation (default).
13937 @item xml
13938 Use the specified xml representation.
13939 @end table
13940
13941 @item th_d
13942 Set threshold to detect one word as similar. The option value must be an integer
13943 greater than zero. The default value is 9000.
13944
13945 @item th_dc
13946 Set threshold to detect all words as similar. The option value must be an integer
13947 greater than zero. The default value is 60000.
13948
13949 @item th_xh
13950 Set threshold to detect frames as similar. The option value must be an integer
13951 greater than zero. The default value is 116.
13952
13953 @item th_di
13954 Set the minimum length of a sequence in frames to recognize it as matching
13955 sequence. The option value must be a non negative integer value.
13956 The default value is 0.
13957
13958 @item th_it
13959 Set the minimum relation, that matching frames to all frames must have.
13960 The option value must be a double value between 0 and 1. The default value is 0.5.
13961 @end table
13962
13963 @subsection Examples
13964
13965 @itemize
13966 @item
13967 To calculate the signature of an input video and store it in signature.bin:
13968 @example
13969 ffmpeg -i input.mkv -vf signature=filename=signature.bin -map 0:v -f null -
13970 @end example
13971
13972 @item
13973 To detect whether two videos match and store the signatures in XML format in
13974 signature0.xml and signature1.xml:
13975 @example
13976 ffmpeg -i input1.mkv -i input2.mkv -filter_complex "[0:v][1:v] signature=nb_inputs=2:detectmode=full:format=xml:filename=signature%d.xml" -map :v -f null -
13977 @end example
13978
13979 @end itemize
13980
13981 @anchor{smartblur}
13982 @section smartblur
13983
13984 Blur the input video without impacting the outlines.
13985
13986 It accepts the following options:
13987
13988 @table @option
13989 @item luma_radius, lr
13990 Set the luma radius. The option value must be a float number in
13991 the range [0.1,5.0] that specifies the variance of the gaussian filter
13992 used to blur the image (slower if larger). Default value is 1.0.
13993
13994 @item luma_strength, ls
13995 Set the luma strength. The option value must be a float number
13996 in the range [-1.0,1.0] that configures the blurring. A value included
13997 in [0.0,1.0] will blur the image whereas a value included in
13998 [-1.0,0.0] will sharpen the image. Default value is 1.0.
13999
14000 @item luma_threshold, lt
14001 Set the luma threshold used as a coefficient to determine
14002 whether a pixel should be blurred or not. The option value must be an
14003 integer in the range [-30,30]. A value of 0 will filter all the image,
14004 a value included in [0,30] will filter flat areas and a value included
14005 in [-30,0] will filter edges. Default value is 0.
14006
14007 @item chroma_radius, cr
14008 Set the chroma radius. The option value must be a float number in
14009 the range [0.1,5.0] that specifies the variance of the gaussian filter
14010 used to blur the image (slower if larger). Default value is @option{luma_radius}.
14011
14012 @item chroma_strength, cs
14013 Set the chroma strength. The option value must be a float number
14014 in the range [-1.0,1.0] that configures the blurring. A value included
14015 in [0.0,1.0] will blur the image whereas a value included in
14016 [-1.0,0.0] will sharpen the image. Default value is @option{luma_strength}.
14017
14018 @item chroma_threshold, ct
14019 Set the chroma threshold used as a coefficient to determine
14020 whether a pixel should be blurred or not. The option value must be an
14021 integer in the range [-30,30]. A value of 0 will filter all the image,
14022 a value included in [0,30] will filter flat areas and a value included
14023 in [-30,0] will filter edges. Default value is @option{luma_threshold}.
14024 @end table
14025
14026 If a chroma option is not explicitly set, the corresponding luma value
14027 is set.
14028
14029 @section ssim
14030
14031 Obtain the SSIM (Structural SImilarity Metric) between two input videos.
14032
14033 This filter takes in input two input videos, the first input is
14034 considered the "main" source and is passed unchanged to the
14035 output. The second input is used as a "reference" video for computing
14036 the SSIM.
14037
14038 Both video inputs must have the same resolution and pixel format for
14039 this filter to work correctly. Also it assumes that both inputs
14040 have the same number of frames, which are compared one by one.
14041
14042 The filter stores the calculated SSIM of each frame.
14043
14044 The description of the accepted parameters follows.
14045
14046 @table @option
14047 @item stats_file, f
14048 If specified the filter will use the named file to save the SSIM of
14049 each individual frame. When filename equals "-" the data is sent to
14050 standard output.
14051 @end table
14052
14053 The file printed if @var{stats_file} is selected, contains a sequence of
14054 key/value pairs of the form @var{key}:@var{value} for each compared
14055 couple of frames.
14056
14057 A description of each shown parameter follows:
14058
14059 @table @option
14060 @item n
14061 sequential number of the input frame, starting from 1
14062
14063 @item Y, U, V, R, G, B
14064 SSIM of the compared frames for the component specified by the suffix.
14065
14066 @item All
14067 SSIM of the compared frames for the whole frame.
14068
14069 @item dB
14070 Same as above but in dB representation.
14071 @end table
14072
14073 This filter also supports the @ref{framesync} options.
14074
14075 For example:
14076 @example
14077 movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
14078 [main][ref] ssim="stats_file=stats.log" [out]
14079 @end example
14080
14081 On this example the input file being processed is compared with the
14082 reference file @file{ref_movie.mpg}. The SSIM of each individual frame
14083 is stored in @file{stats.log}.
14084
14085 Another example with both psnr and ssim at same time:
14086 @example
14087 ffmpeg -i main.mpg -i ref.mpg -lavfi  "ssim;[0:v][1:v]psnr" -f null -
14088 @end example
14089
14090 @section stereo3d
14091
14092 Convert between different stereoscopic image formats.
14093
14094 The filters accept the following options:
14095
14096 @table @option
14097 @item in
14098 Set stereoscopic image format of input.
14099
14100 Available values for input image formats are:
14101 @table @samp
14102 @item sbsl
14103 side by side parallel (left eye left, right eye right)
14104
14105 @item sbsr
14106 side by side crosseye (right eye left, left eye right)
14107
14108 @item sbs2l
14109 side by side parallel with half width resolution
14110 (left eye left, right eye right)
14111
14112 @item sbs2r
14113 side by side crosseye with half width resolution
14114 (right eye left, left eye right)
14115
14116 @item abl
14117 above-below (left eye above, right eye below)
14118
14119 @item abr
14120 above-below (right eye above, left eye below)
14121
14122 @item ab2l
14123 above-below with half height resolution
14124 (left eye above, right eye below)
14125
14126 @item ab2r
14127 above-below with half height resolution
14128 (right eye above, left eye below)
14129
14130 @item al
14131 alternating frames (left eye first, right eye second)
14132
14133 @item ar
14134 alternating frames (right eye first, left eye second)
14135
14136 @item irl
14137 interleaved rows (left eye has top row, right eye starts on next row)
14138
14139 @item irr
14140 interleaved rows (right eye has top row, left eye starts on next row)
14141
14142 @item icl
14143 interleaved columns, left eye first
14144
14145 @item icr
14146 interleaved columns, right eye first
14147
14148 Default value is @samp{sbsl}.
14149 @end table
14150
14151 @item out
14152 Set stereoscopic image format of output.
14153
14154 @table @samp
14155 @item sbsl
14156 side by side parallel (left eye left, right eye right)
14157
14158 @item sbsr
14159 side by side crosseye (right eye left, left eye right)
14160
14161 @item sbs2l
14162 side by side parallel with half width resolution
14163 (left eye left, right eye right)
14164
14165 @item sbs2r
14166 side by side crosseye with half width resolution
14167 (right eye left, left eye right)
14168
14169 @item abl
14170 above-below (left eye above, right eye below)
14171
14172 @item abr
14173 above-below (right eye above, left eye below)
14174
14175 @item ab2l
14176 above-below with half height resolution
14177 (left eye above, right eye below)
14178
14179 @item ab2r
14180 above-below with half height resolution
14181 (right eye above, left eye below)
14182
14183 @item al
14184 alternating frames (left eye first, right eye second)
14185
14186 @item ar
14187 alternating frames (right eye first, left eye second)
14188
14189 @item irl
14190 interleaved rows (left eye has top row, right eye starts on next row)
14191
14192 @item irr
14193 interleaved rows (right eye has top row, left eye starts on next row)
14194
14195 @item arbg
14196 anaglyph red/blue gray
14197 (red filter on left eye, blue filter on right eye)
14198
14199 @item argg
14200 anaglyph red/green gray
14201 (red filter on left eye, green filter on right eye)
14202
14203 @item arcg
14204 anaglyph red/cyan gray
14205 (red filter on left eye, cyan filter on right eye)
14206
14207 @item arch
14208 anaglyph red/cyan half colored
14209 (red filter on left eye, cyan filter on right eye)
14210
14211 @item arcc
14212 anaglyph red/cyan color
14213 (red filter on left eye, cyan filter on right eye)
14214
14215 @item arcd
14216 anaglyph red/cyan color optimized with the least squares projection of dubois
14217 (red filter on left eye, cyan filter on right eye)
14218
14219 @item agmg
14220 anaglyph green/magenta gray
14221 (green filter on left eye, magenta filter on right eye)
14222
14223 @item agmh
14224 anaglyph green/magenta half colored
14225 (green filter on left eye, magenta filter on right eye)
14226
14227 @item agmc
14228 anaglyph green/magenta colored
14229 (green filter on left eye, magenta filter on right eye)
14230
14231 @item agmd
14232 anaglyph green/magenta color optimized with the least squares projection of dubois
14233 (green filter on left eye, magenta filter on right eye)
14234
14235 @item aybg
14236 anaglyph yellow/blue gray
14237 (yellow filter on left eye, blue filter on right eye)
14238
14239 @item aybh
14240 anaglyph yellow/blue half colored
14241 (yellow filter on left eye, blue filter on right eye)
14242
14243 @item aybc
14244 anaglyph yellow/blue colored
14245 (yellow filter on left eye, blue filter on right eye)
14246
14247 @item aybd
14248 anaglyph yellow/blue color optimized with the least squares projection of dubois
14249 (yellow filter on left eye, blue filter on right eye)
14250
14251 @item ml
14252 mono output (left eye only)
14253
14254 @item mr
14255 mono output (right eye only)
14256
14257 @item chl
14258 checkerboard, left eye first
14259
14260 @item chr
14261 checkerboard, right eye first
14262
14263 @item icl
14264 interleaved columns, left eye first
14265
14266 @item icr
14267 interleaved columns, right eye first
14268
14269 @item hdmi
14270 HDMI frame pack
14271 @end table
14272
14273 Default value is @samp{arcd}.
14274 @end table
14275
14276 @subsection Examples
14277
14278 @itemize
14279 @item
14280 Convert input video from side by side parallel to anaglyph yellow/blue dubois:
14281 @example
14282 stereo3d=sbsl:aybd
14283 @end example
14284
14285 @item
14286 Convert input video from above below (left eye above, right eye below) to side by side crosseye.
14287 @example
14288 stereo3d=abl:sbsr
14289 @end example
14290 @end itemize
14291
14292 @section streamselect, astreamselect
14293 Select video or audio streams.
14294
14295 The filter accepts the following options:
14296
14297 @table @option
14298 @item inputs
14299 Set number of inputs. Default is 2.
14300
14301 @item map
14302 Set input indexes to remap to outputs.
14303 @end table
14304
14305 @subsection Commands
14306
14307 The @code{streamselect} and @code{astreamselect} filter supports the following
14308 commands:
14309
14310 @table @option
14311 @item map
14312 Set input indexes to remap to outputs.
14313 @end table
14314
14315 @subsection Examples
14316
14317 @itemize
14318 @item
14319 Select first 5 seconds 1st stream and rest of time 2nd stream:
14320 @example
14321 sendcmd='5.0 streamselect map 1',streamselect=inputs=2:map=0
14322 @end example
14323
14324 @item
14325 Same as above, but for audio:
14326 @example
14327 asendcmd='5.0 astreamselect map 1',astreamselect=inputs=2:map=0
14328 @end example
14329 @end itemize
14330
14331 @section sobel
14332 Apply sobel operator to input video stream.
14333
14334 The filter accepts the following option:
14335
14336 @table @option
14337 @item planes
14338 Set which planes will be processed, unprocessed planes will be copied.
14339 By default value 0xf, all planes will be processed.
14340
14341 @item scale
14342 Set value which will be multiplied with filtered result.
14343
14344 @item delta
14345 Set value which will be added to filtered result.
14346 @end table
14347
14348 @anchor{spp}
14349 @section spp
14350
14351 Apply a simple postprocessing filter that compresses and decompresses the image
14352 at several (or - in the case of @option{quality} level @code{6} - all) shifts
14353 and average the results.
14354
14355 The filter accepts the following options:
14356
14357 @table @option
14358 @item quality
14359 Set quality. This option defines the number of levels for averaging. It accepts
14360 an integer in the range 0-6. If set to @code{0}, the filter will have no
14361 effect. A value of @code{6} means the higher quality. For each increment of
14362 that value the speed drops by a factor of approximately 2.  Default value is
14363 @code{3}.
14364
14365 @item qp
14366 Force a constant quantization parameter. If not set, the filter will use the QP
14367 from the video stream (if available).
14368
14369 @item mode
14370 Set thresholding mode. Available modes are:
14371
14372 @table @samp
14373 @item hard
14374 Set hard thresholding (default).
14375 @item soft
14376 Set soft thresholding (better de-ringing effect, but likely blurrier).
14377 @end table
14378
14379 @item use_bframe_qp
14380 Enable the use of the QP from the B-Frames if set to @code{1}. Using this
14381 option may cause flicker since the B-Frames have often larger QP. Default is
14382 @code{0} (not enabled).
14383 @end table
14384
14385 @anchor{subtitles}
14386 @section subtitles
14387
14388 Draw subtitles on top of input video using the libass library.
14389
14390 To enable compilation of this filter you need to configure FFmpeg with
14391 @code{--enable-libass}. This filter also requires a build with libavcodec and
14392 libavformat to convert the passed subtitles file to ASS (Advanced Substation
14393 Alpha) subtitles format.
14394
14395 The filter accepts the following options:
14396
14397 @table @option
14398 @item filename, f
14399 Set the filename of the subtitle file to read. It must be specified.
14400
14401 @item original_size
14402 Specify the size of the original video, the video for which the ASS file
14403 was composed. For the syntax of this option, check the
14404 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
14405 Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
14406 correctly scale the fonts if the aspect ratio has been changed.
14407
14408 @item fontsdir
14409 Set a directory path containing fonts that can be used by the filter.
14410 These fonts will be used in addition to whatever the font provider uses.
14411
14412 @item alpha
14413 Process alpha channel, by default alpha channel is untouched.
14414
14415 @item charenc
14416 Set subtitles input character encoding. @code{subtitles} filter only. Only
14417 useful if not UTF-8.
14418
14419 @item stream_index, si
14420 Set subtitles stream index. @code{subtitles} filter only.
14421
14422 @item force_style
14423 Override default style or script info parameters of the subtitles. It accepts a
14424 string containing ASS style format @code{KEY=VALUE} couples separated by ",".
14425 @end table
14426
14427 If the first key is not specified, it is assumed that the first value
14428 specifies the @option{filename}.
14429
14430 For example, to render the file @file{sub.srt} on top of the input
14431 video, use the command:
14432 @example
14433 subtitles=sub.srt
14434 @end example
14435
14436 which is equivalent to:
14437 @example
14438 subtitles=filename=sub.srt
14439 @end example
14440
14441 To render the default subtitles stream from file @file{video.mkv}, use:
14442 @example
14443 subtitles=video.mkv
14444 @end example
14445
14446 To render the second subtitles stream from that file, use:
14447 @example
14448 subtitles=video.mkv:si=1
14449 @end example
14450
14451 To make the subtitles stream from @file{sub.srt} appear in transparent green
14452 @code{DejaVu Serif}, use:
14453 @example
14454 subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
14455 @end example
14456
14457 @section super2xsai
14458
14459 Scale the input by 2x and smooth using the Super2xSaI (Scale and
14460 Interpolate) pixel art scaling algorithm.
14461
14462 Useful for enlarging pixel art images without reducing sharpness.
14463
14464 @section swaprect
14465
14466 Swap two rectangular objects in video.
14467
14468 This filter accepts the following options:
14469
14470 @table @option
14471 @item w
14472 Set object width.
14473
14474 @item h
14475 Set object height.
14476
14477 @item x1
14478 Set 1st rect x coordinate.
14479
14480 @item y1
14481 Set 1st rect y coordinate.
14482
14483 @item x2
14484 Set 2nd rect x coordinate.
14485
14486 @item y2
14487 Set 2nd rect y coordinate.
14488
14489 All expressions are evaluated once for each frame.
14490 @end table
14491
14492 The all options are expressions containing the following constants:
14493
14494 @table @option
14495 @item w
14496 @item h
14497 The input width and height.
14498
14499 @item a
14500 same as @var{w} / @var{h}
14501
14502 @item sar
14503 input sample aspect ratio
14504
14505 @item dar
14506 input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
14507
14508 @item n
14509 The number of the input frame, starting from 0.
14510
14511 @item t
14512 The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
14513
14514 @item pos
14515 the position in the file of the input frame, NAN if unknown
14516 @end table
14517
14518 @section swapuv
14519 Swap U & V plane.
14520
14521 @section telecine
14522
14523 Apply telecine process to the video.
14524
14525 This filter accepts the following options:
14526
14527 @table @option
14528 @item first_field
14529 @table @samp
14530 @item top, t
14531 top field first
14532 @item bottom, b
14533 bottom field first
14534 The default value is @code{top}.
14535 @end table
14536
14537 @item pattern
14538 A string of numbers representing the pulldown pattern you wish to apply.
14539 The default value is @code{23}.
14540 @end table
14541
14542 @example
14543 Some typical patterns:
14544
14545 NTSC output (30i):
14546 27.5p: 32222
14547 24p: 23 (classic)
14548 24p: 2332 (preferred)
14549 20p: 33
14550 18p: 334
14551 16p: 3444
14552
14553 PAL output (25i):
14554 27.5p: 12222
14555 24p: 222222222223 ("Euro pulldown")
14556 16.67p: 33
14557 16p: 33333334
14558 @end example
14559
14560 @section threshold
14561
14562 Apply threshold effect to video stream.
14563
14564 This filter needs four video streams to perform thresholding.
14565 First stream is stream we are filtering.
14566 Second stream is holding threshold values, third stream is holding min values,
14567 and last, fourth stream is holding max values.
14568
14569 The filter accepts the following option:
14570
14571 @table @option
14572 @item planes
14573 Set which planes will be processed, unprocessed planes will be copied.
14574 By default value 0xf, all planes will be processed.
14575 @end table
14576
14577 For example if first stream pixel's component value is less then threshold value
14578 of pixel component from 2nd threshold stream, third stream value will picked,
14579 otherwise fourth stream pixel component value will be picked.
14580
14581 Using color source filter one can perform various types of thresholding:
14582
14583 @subsection Examples
14584
14585 @itemize
14586 @item
14587 Binary threshold, using gray color as threshold:
14588 @example
14589 ffmpeg -i 320x240.avi -f lavfi -i color=gray -f lavfi -i color=black -f lavfi -i color=white -lavfi threshold output.avi
14590 @end example
14591
14592 @item
14593 Inverted binary threshold, using gray color as threshold:
14594 @example
14595 ffmpeg -i 320x240.avi -f lavfi -i color=gray -f lavfi -i color=white -f lavfi -i color=black -lavfi threshold output.avi
14596 @end example
14597
14598 @item
14599 Truncate binary threshold, using gray color as threshold:
14600 @example
14601 ffmpeg -i 320x240.avi -f lavfi -i color=gray -i 320x240.avi -f lavfi -i color=gray -lavfi threshold output.avi
14602 @end example
14603
14604 @item
14605 Threshold to zero, using gray color as threshold:
14606 @example
14607 ffmpeg -i 320x240.avi -f lavfi -i color=gray -f lavfi -i color=white -i 320x240.avi -lavfi threshold output.avi
14608 @end example
14609
14610 @item
14611 Inverted threshold to zero, using gray color as threshold:
14612 @example
14613 ffmpeg -i 320x240.avi -f lavfi -i color=gray -i 320x240.avi -f lavfi -i color=white -lavfi threshold output.avi
14614 @end example
14615 @end itemize
14616
14617 @section thumbnail
14618 Select the most representative frame in a given sequence of consecutive frames.
14619
14620 The filter accepts the following options:
14621
14622 @table @option
14623 @item n
14624 Set the frames batch size to analyze; in a set of @var{n} frames, the filter
14625 will pick one of them, and then handle the next batch of @var{n} frames until
14626 the end. Default is @code{100}.
14627 @end table
14628
14629 Since the filter keeps track of the whole frames sequence, a bigger @var{n}
14630 value will result in a higher memory usage, so a high value is not recommended.
14631
14632 @subsection Examples
14633
14634 @itemize
14635 @item
14636 Extract one picture each 50 frames:
14637 @example
14638 thumbnail=50
14639 @end example
14640
14641 @item
14642 Complete example of a thumbnail creation with @command{ffmpeg}:
14643 @example
14644 ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
14645 @end example
14646 @end itemize
14647
14648 @section tile
14649
14650 Tile several successive frames together.
14651
14652 The filter accepts the following options:
14653
14654 @table @option
14655
14656 @item layout
14657 Set the grid size (i.e. the number of lines and columns). For the syntax of
14658 this option, check the
14659 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
14660
14661 @item nb_frames
14662 Set the maximum number of frames to render in the given area. It must be less
14663 than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
14664 the area will be used.
14665
14666 @item margin
14667 Set the outer border margin in pixels.
14668
14669 @item padding
14670 Set the inner border thickness (i.e. the number of pixels between frames). For
14671 more advanced padding options (such as having different values for the edges),
14672 refer to the pad video filter.
14673
14674 @item color
14675 Specify the color of the unused area. For the syntax of this option, check the
14676 "Color" section in the ffmpeg-utils manual. The default value of @var{color}
14677 is "black".
14678
14679 @item overlap
14680 Set the number of frames to overlap when tiling several successive frames together.
14681 The value must be between @code{0} and @var{nb_frames - 1}.
14682
14683 @item init_padding
14684 Set the number of frames to initially be empty before displaying first output frame.
14685 This controls how soon will one get first output frame.
14686 The value must be between @code{0} and @var{nb_frames - 1}.
14687 @end table
14688
14689 @subsection Examples
14690
14691 @itemize
14692 @item
14693 Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
14694 @example
14695 ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
14696 @end example
14697 The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
14698 duplicating each output frame to accommodate the originally detected frame
14699 rate.
14700
14701 @item
14702 Display @code{5} pictures in an area of @code{3x2} frames,
14703 with @code{7} pixels between them, and @code{2} pixels of initial margin, using
14704 mixed flat and named options:
14705 @example
14706 tile=3x2:nb_frames=5:padding=7:margin=2
14707 @end example
14708 @end itemize
14709
14710 @section tinterlace
14711
14712 Perform various types of temporal field interlacing.
14713
14714 Frames are counted starting from 1, so the first input frame is
14715 considered odd.
14716
14717 The filter accepts the following options:
14718
14719 @table @option
14720
14721 @item mode
14722 Specify the mode of the interlacing. This option can also be specified
14723 as a value alone. See below for a list of values for this option.
14724
14725 Available values are:
14726
14727 @table @samp
14728 @item merge, 0
14729 Move odd frames into the upper field, even into the lower field,
14730 generating a double height frame at half frame rate.
14731 @example
14732  ------> time
14733 Input:
14734 Frame 1         Frame 2         Frame 3         Frame 4
14735
14736 11111           22222           33333           44444
14737 11111           22222           33333           44444
14738 11111           22222           33333           44444
14739 11111           22222           33333           44444
14740
14741 Output:
14742 11111                           33333
14743 22222                           44444
14744 11111                           33333
14745 22222                           44444
14746 11111                           33333
14747 22222                           44444
14748 11111                           33333
14749 22222                           44444
14750 @end example
14751
14752 @item drop_even, 1
14753 Only output odd frames, even frames are dropped, generating a frame with
14754 unchanged height at half frame rate.
14755
14756 @example
14757  ------> time
14758 Input:
14759 Frame 1         Frame 2         Frame 3         Frame 4
14760
14761 11111           22222           33333           44444
14762 11111           22222           33333           44444
14763 11111           22222           33333           44444
14764 11111           22222           33333           44444
14765
14766 Output:
14767 11111                           33333
14768 11111                           33333
14769 11111                           33333
14770 11111                           33333
14771 @end example
14772
14773 @item drop_odd, 2
14774 Only output even frames, odd frames are dropped, generating a frame with
14775 unchanged height at half frame rate.
14776
14777 @example
14778  ------> time
14779 Input:
14780 Frame 1         Frame 2         Frame 3         Frame 4
14781
14782 11111           22222           33333           44444
14783 11111           22222           33333           44444
14784 11111           22222           33333           44444
14785 11111           22222           33333           44444
14786
14787 Output:
14788                 22222                           44444
14789                 22222                           44444
14790                 22222                           44444
14791                 22222                           44444
14792 @end example
14793
14794 @item pad, 3
14795 Expand each frame to full height, but pad alternate lines with black,
14796 generating a frame with double height at the same input frame rate.
14797
14798 @example
14799  ------> time
14800 Input:
14801 Frame 1         Frame 2         Frame 3         Frame 4
14802
14803 11111           22222           33333           44444
14804 11111           22222           33333           44444
14805 11111           22222           33333           44444
14806 11111           22222           33333           44444
14807
14808 Output:
14809 11111           .....           33333           .....
14810 .....           22222           .....           44444
14811 11111           .....           33333           .....
14812 .....           22222           .....           44444
14813 11111           .....           33333           .....
14814 .....           22222           .....           44444
14815 11111           .....           33333           .....
14816 .....           22222           .....           44444
14817 @end example
14818
14819
14820 @item interleave_top, 4
14821 Interleave the upper field from odd frames with the lower field from
14822 even frames, generating a frame with unchanged height at half frame rate.
14823
14824 @example
14825  ------> time
14826 Input:
14827 Frame 1         Frame 2         Frame 3         Frame 4
14828
14829 11111<-         22222           33333<-         44444
14830 11111           22222<-         33333           44444<-
14831 11111<-         22222           33333<-         44444
14832 11111           22222<-         33333           44444<-
14833
14834 Output:
14835 11111                           33333
14836 22222                           44444
14837 11111                           33333
14838 22222                           44444
14839 @end example
14840
14841
14842 @item interleave_bottom, 5
14843 Interleave the lower field from odd frames with the upper field from
14844 even frames, generating a frame with unchanged height at half frame rate.
14845
14846 @example
14847  ------> time
14848 Input:
14849 Frame 1         Frame 2         Frame 3         Frame 4
14850
14851 11111           22222<-         33333           44444<-
14852 11111<-         22222           33333<-         44444
14853 11111           22222<-         33333           44444<-
14854 11111<-         22222           33333<-         44444
14855
14856 Output:
14857 22222                           44444
14858 11111                           33333
14859 22222                           44444
14860 11111                           33333
14861 @end example
14862
14863
14864 @item interlacex2, 6
14865 Double frame rate with unchanged height. Frames are inserted each
14866 containing the second temporal field from the previous input frame and
14867 the first temporal field from the next input frame. This mode relies on
14868 the top_field_first flag. Useful for interlaced video displays with no
14869 field synchronisation.
14870
14871 @example
14872  ------> time
14873 Input:
14874 Frame 1         Frame 2         Frame 3         Frame 4
14875
14876 11111           22222           33333           44444
14877  11111           22222           33333           44444
14878 11111           22222           33333           44444
14879  11111           22222           33333           44444
14880
14881 Output:
14882 11111   22222   22222   33333   33333   44444   44444
14883  11111   11111   22222   22222   33333   33333   44444
14884 11111   22222   22222   33333   33333   44444   44444
14885  11111   11111   22222   22222   33333   33333   44444
14886 @end example
14887
14888
14889 @item mergex2, 7
14890 Move odd frames into the upper field, even into the lower field,
14891 generating a double height frame at same frame rate.
14892
14893 @example
14894  ------> time
14895 Input:
14896 Frame 1         Frame 2         Frame 3         Frame 4
14897
14898 11111           22222           33333           44444
14899 11111           22222           33333           44444
14900 11111           22222           33333           44444
14901 11111           22222           33333           44444
14902
14903 Output:
14904 11111           33333           33333           55555
14905 22222           22222           44444           44444
14906 11111           33333           33333           55555
14907 22222           22222           44444           44444
14908 11111           33333           33333           55555
14909 22222           22222           44444           44444
14910 11111           33333           33333           55555
14911 22222           22222           44444           44444
14912 @end example
14913
14914 @end table
14915
14916 Numeric values are deprecated but are accepted for backward
14917 compatibility reasons.
14918
14919 Default mode is @code{merge}.
14920
14921 @item flags
14922 Specify flags influencing the filter process.
14923
14924 Available value for @var{flags} is:
14925
14926 @table @option
14927 @item low_pass_filter, vlfp
14928 Enable linear vertical low-pass filtering in the filter.
14929 Vertical low-pass filtering is required when creating an interlaced
14930 destination from a progressive source which contains high-frequency
14931 vertical detail. Filtering will reduce interlace 'twitter' and Moire
14932 patterning.
14933
14934 @item complex_filter, cvlfp
14935 Enable complex vertical low-pass filtering.
14936 This will slightly less reduce interlace 'twitter' and Moire
14937 patterning but better retain detail and subjective sharpness impression.
14938
14939 @end table
14940
14941 Vertical low-pass filtering can only be enabled for @option{mode}
14942 @var{interleave_top} and @var{interleave_bottom}.
14943
14944 @end table
14945
14946 @section tonemap
14947 Tone map colors from different dynamic ranges.
14948
14949 This filter expects data in single precision floating point, as it needs to
14950 operate on (and can output) out-of-range values. Another filter, such as
14951 @ref{zscale}, is needed to convert the resulting frame to a usable format.
14952
14953 The tonemapping algorithms implemented only work on linear light, so input
14954 data should be linearized beforehand (and possibly correctly tagged).
14955
14956 @example
14957 ffmpeg -i INPUT -vf zscale=transfer=linear,tonemap=clip,zscale=transfer=bt709,format=yuv420p OUTPUT
14958 @end example
14959
14960 @subsection Options
14961 The filter accepts the following options.
14962
14963 @table @option
14964 @item tonemap
14965 Set the tone map algorithm to use.
14966
14967 Possible values are:
14968 @table @var
14969 @item none
14970 Do not apply any tone map, only desaturate overbright pixels.
14971
14972 @item clip
14973 Hard-clip any out-of-range values. Use it for perfect color accuracy for
14974 in-range values, while distorting out-of-range values.
14975
14976 @item linear
14977 Stretch the entire reference gamut to a linear multiple of the display.
14978
14979 @item gamma
14980 Fit a logarithmic transfer between the tone curves.
14981
14982 @item reinhard
14983 Preserve overall image brightness with a simple curve, using nonlinear
14984 contrast, which results in flattening details and degrading color accuracy.
14985
14986 @item hable
14987 Preserve both dark and bright details better than @var{reinhard}, at the cost
14988 of slightly darkening everything. Use it when detail preservation is more
14989 important than color and brightness accuracy.
14990
14991 @item mobius
14992 Smoothly map out-of-range values, while retaining contrast and colors for
14993 in-range material as much as possible. Use it when color accuracy is more
14994 important than detail preservation.
14995 @end table
14996
14997 Default is none.
14998
14999 @item param
15000 Tune the tone mapping algorithm.
15001
15002 This affects the following algorithms:
15003 @table @var
15004 @item none
15005 Ignored.
15006
15007 @item linear
15008 Specifies the scale factor to use while stretching.
15009 Default to 1.0.
15010
15011 @item gamma
15012 Specifies the exponent of the function.
15013 Default to 1.8.
15014
15015 @item clip
15016 Specify an extra linear coefficient to multiply into the signal before clipping.
15017 Default to 1.0.
15018
15019 @item reinhard
15020 Specify the local contrast coefficient at the display peak.
15021 Default to 0.5, which means that in-gamut values will be about half as bright
15022 as when clipping.
15023
15024 @item hable
15025 Ignored.
15026
15027 @item mobius
15028 Specify the transition point from linear to mobius transform. Every value
15029 below this point is guaranteed to be mapped 1:1. The higher the value, the
15030 more accurate the result will be, at the cost of losing bright details.
15031 Default to 0.3, which due to the steep initial slope still preserves in-range
15032 colors fairly accurately.
15033 @end table
15034
15035 @item desat
15036 Apply desaturation for highlights that exceed this level of brightness. The
15037 higher the parameter, the more color information will be preserved. This
15038 setting helps prevent unnaturally blown-out colors for super-highlights, by
15039 (smoothly) turning into white instead. This makes images feel more natural,
15040 at the cost of reducing information about out-of-range colors.
15041
15042 The default of 2.0 is somewhat conservative and will mostly just apply to
15043 skies or directly sunlit surfaces. A setting of 0.0 disables this option.
15044
15045 This option works only if the input frame has a supported color tag.
15046
15047 @item peak
15048 Override signal/nominal/reference peak with this value. Useful when the
15049 embedded peak information in display metadata is not reliable or when tone
15050 mapping from a lower range to a higher range.
15051 @end table
15052
15053 @section transpose
15054
15055 Transpose rows with columns in the input video and optionally flip it.
15056
15057 It accepts the following parameters:
15058
15059 @table @option
15060
15061 @item dir
15062 Specify the transposition direction.
15063
15064 Can assume the following values:
15065 @table @samp
15066 @item 0, 4, cclock_flip
15067 Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
15068 @example
15069 L.R     L.l
15070 . . ->  . .
15071 l.r     R.r
15072 @end example
15073
15074 @item 1, 5, clock
15075 Rotate by 90 degrees clockwise, that is:
15076 @example
15077 L.R     l.L
15078 . . ->  . .
15079 l.r     r.R
15080 @end example
15081
15082 @item 2, 6, cclock
15083 Rotate by 90 degrees counterclockwise, that is:
15084 @example
15085 L.R     R.r
15086 . . ->  . .
15087 l.r     L.l
15088 @end example
15089
15090 @item 3, 7, clock_flip
15091 Rotate by 90 degrees clockwise and vertically flip, that is:
15092 @example
15093 L.R     r.R
15094 . . ->  . .
15095 l.r     l.L
15096 @end example
15097 @end table
15098
15099 For values between 4-7, the transposition is only done if the input
15100 video geometry is portrait and not landscape. These values are
15101 deprecated, the @code{passthrough} option should be used instead.
15102
15103 Numerical values are deprecated, and should be dropped in favor of
15104 symbolic constants.
15105
15106 @item passthrough
15107 Do not apply the transposition if the input geometry matches the one
15108 specified by the specified value. It accepts the following values:
15109 @table @samp
15110 @item none
15111 Always apply transposition.
15112 @item portrait
15113 Preserve portrait geometry (when @var{height} >= @var{width}).
15114 @item landscape
15115 Preserve landscape geometry (when @var{width} >= @var{height}).
15116 @end table
15117
15118 Default value is @code{none}.
15119 @end table
15120
15121 For example to rotate by 90 degrees clockwise and preserve portrait
15122 layout:
15123 @example
15124 transpose=dir=1:passthrough=portrait
15125 @end example
15126
15127 The command above can also be specified as:
15128 @example
15129 transpose=1:portrait
15130 @end example
15131
15132 @section trim
15133 Trim the input so that the output contains one continuous subpart of the input.
15134
15135 It accepts the following parameters:
15136 @table @option
15137 @item start
15138 Specify the time of the start of the kept section, i.e. the frame with the
15139 timestamp @var{start} will be the first frame in the output.
15140
15141 @item end
15142 Specify the time of the first frame that will be dropped, i.e. the frame
15143 immediately preceding the one with the timestamp @var{end} will be the last
15144 frame in the output.
15145
15146 @item start_pts
15147 This is the same as @var{start}, except this option sets the start timestamp
15148 in timebase units instead of seconds.
15149
15150 @item end_pts
15151 This is the same as @var{end}, except this option sets the end timestamp
15152 in timebase units instead of seconds.
15153
15154 @item duration
15155 The maximum duration of the output in seconds.
15156
15157 @item start_frame
15158 The number of the first frame that should be passed to the output.
15159
15160 @item end_frame
15161 The number of the first frame that should be dropped.
15162 @end table
15163
15164 @option{start}, @option{end}, and @option{duration} are expressed as time
15165 duration specifications; see
15166 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
15167 for the accepted syntax.
15168
15169 Note that the first two sets of the start/end options and the @option{duration}
15170 option look at the frame timestamp, while the _frame variants simply count the
15171 frames that pass through the filter. Also note that this filter does not modify
15172 the timestamps. If you wish for the output timestamps to start at zero, insert a
15173 setpts filter after the trim filter.
15174
15175 If multiple start or end options are set, this filter tries to be greedy and
15176 keep all the frames that match at least one of the specified constraints. To keep
15177 only the part that matches all the constraints at once, chain multiple trim
15178 filters.
15179
15180 The defaults are such that all the input is kept. So it is possible to set e.g.
15181 just the end values to keep everything before the specified time.
15182
15183 Examples:
15184 @itemize
15185 @item
15186 Drop everything except the second minute of input:
15187 @example
15188 ffmpeg -i INPUT -vf trim=60:120
15189 @end example
15190
15191 @item
15192 Keep only the first second:
15193 @example
15194 ffmpeg -i INPUT -vf trim=duration=1
15195 @end example
15196
15197 @end itemize
15198
15199 @section unpremultiply
15200 Apply alpha unpremultiply effect to input video stream using first plane
15201 of second stream as alpha.
15202
15203 Both streams must have same dimensions and same pixel format.
15204
15205 The filter accepts the following option:
15206
15207 @table @option
15208 @item planes
15209 Set which planes will be processed, unprocessed planes will be copied.
15210 By default value 0xf, all planes will be processed.
15211
15212 If the format has 1 or 2 components, then luma is bit 0.
15213 If the format has 3 or 4 components:
15214 for RGB formats bit 0 is green, bit 1 is blue and bit 2 is red;
15215 for YUV formats bit 0 is luma, bit 1 is chroma-U and bit 2 is chroma-V.
15216 If present, the alpha channel is always the last bit.
15217
15218 @item inplace
15219 Do not require 2nd input for processing, instead use alpha plane from input stream.
15220 @end table
15221
15222 @anchor{unsharp}
15223 @section unsharp
15224
15225 Sharpen or blur the input video.
15226
15227 It accepts the following parameters:
15228
15229 @table @option
15230 @item luma_msize_x, lx
15231 Set the luma matrix horizontal size. It must be an odd integer between
15232 3 and 23. The default value is 5.
15233
15234 @item luma_msize_y, ly
15235 Set the luma matrix vertical size. It must be an odd integer between 3
15236 and 23. The default value is 5.
15237
15238 @item luma_amount, la
15239 Set the luma effect strength. It must be a floating point number, reasonable
15240 values lay between -1.5 and 1.5.
15241
15242 Negative values will blur the input video, while positive values will
15243 sharpen it, a value of zero will disable the effect.
15244
15245 Default value is 1.0.
15246
15247 @item chroma_msize_x, cx
15248 Set the chroma matrix horizontal size. It must be an odd integer
15249 between 3 and 23. The default value is 5.
15250
15251 @item chroma_msize_y, cy
15252 Set the chroma matrix vertical size. It must be an odd integer
15253 between 3 and 23. The default value is 5.
15254
15255 @item chroma_amount, ca
15256 Set the chroma effect strength. It must be a floating point number, reasonable
15257 values lay between -1.5 and 1.5.
15258
15259 Negative values will blur the input video, while positive values will
15260 sharpen it, a value of zero will disable the effect.
15261
15262 Default value is 0.0.
15263
15264 @end table
15265
15266 All parameters are optional and default to the equivalent of the
15267 string '5:5:1.0:5:5:0.0'.
15268
15269 @subsection Examples
15270
15271 @itemize
15272 @item
15273 Apply strong luma sharpen effect:
15274 @example
15275 unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
15276 @end example
15277
15278 @item
15279 Apply a strong blur of both luma and chroma parameters:
15280 @example
15281 unsharp=7:7:-2:7:7:-2
15282 @end example
15283 @end itemize
15284
15285 @section uspp
15286
15287 Apply ultra slow/simple postprocessing filter that compresses and decompresses
15288 the image at several (or - in the case of @option{quality} level @code{8} - all)
15289 shifts and average the results.
15290
15291 The way this differs from the behavior of spp is that uspp actually encodes &
15292 decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
15293 DCT similar to MJPEG.
15294
15295 The filter accepts the following options:
15296
15297 @table @option
15298 @item quality
15299 Set quality. This option defines the number of levels for averaging. It accepts
15300 an integer in the range 0-8. If set to @code{0}, the filter will have no
15301 effect. A value of @code{8} means the higher quality. For each increment of
15302 that value the speed drops by a factor of approximately 2.  Default value is
15303 @code{3}.
15304
15305 @item qp
15306 Force a constant quantization parameter. If not set, the filter will use the QP
15307 from the video stream (if available).
15308 @end table
15309
15310 @section vaguedenoiser
15311
15312 Apply a wavelet based denoiser.
15313
15314 It transforms each frame from the video input into the wavelet domain,
15315 using Cohen-Daubechies-Feauveau 9/7. Then it applies some filtering to
15316 the obtained coefficients. It does an inverse wavelet transform after.
15317 Due to wavelet properties, it should give a nice smoothed result, and
15318 reduced noise, without blurring picture features.
15319
15320 This filter accepts the following options:
15321
15322 @table @option
15323 @item threshold
15324 The filtering strength. The higher, the more filtered the video will be.
15325 Hard thresholding can use a higher threshold than soft thresholding
15326 before the video looks overfiltered. Default value is 2.
15327
15328 @item method
15329 The filtering method the filter will use.
15330
15331 It accepts the following values:
15332 @table @samp
15333 @item hard
15334 All values under the threshold will be zeroed.
15335
15336 @item soft
15337 All values under the threshold will be zeroed. All values above will be
15338 reduced by the threshold.
15339
15340 @item garrote
15341 Scales or nullifies coefficients - intermediary between (more) soft and
15342 (less) hard thresholding.
15343 @end table
15344
15345 Default is garrote.
15346
15347 @item nsteps
15348 Number of times, the wavelet will decompose the picture. Picture can't
15349 be decomposed beyond a particular point (typically, 8 for a 640x480
15350 frame - as 2^9 = 512 > 480). Valid values are integers between 1 and 32. Default value is 6.
15351
15352 @item percent
15353 Partial of full denoising (limited coefficients shrinking), from 0 to 100. Default value is 85.
15354
15355 @item planes
15356 A list of the planes to process. By default all planes are processed.
15357 @end table
15358
15359 @section vectorscope
15360
15361 Display 2 color component values in the two dimensional graph (which is called
15362 a vectorscope).
15363
15364 This filter accepts the following options:
15365
15366 @table @option
15367 @item mode, m
15368 Set vectorscope mode.
15369
15370 It accepts the following values:
15371 @table @samp
15372 @item gray
15373 Gray values are displayed on graph, higher brightness means more pixels have
15374 same component color value on location in graph. This is the default mode.
15375
15376 @item color
15377 Gray values are displayed on graph. Surrounding pixels values which are not
15378 present in video frame are drawn in gradient of 2 color components which are
15379 set by option @code{x} and @code{y}. The 3rd color component is static.
15380
15381 @item color2
15382 Actual color components values present in video frame are displayed on graph.
15383
15384 @item color3
15385 Similar as color2 but higher frequency of same values @code{x} and @code{y}
15386 on graph increases value of another color component, which is luminance by
15387 default values of @code{x} and @code{y}.
15388
15389 @item color4
15390 Actual colors present in video frame are displayed on graph. If two different
15391 colors map to same position on graph then color with higher value of component
15392 not present in graph is picked.
15393
15394 @item color5
15395 Gray values are displayed on graph. Similar to @code{color} but with 3rd color
15396 component picked from radial gradient.
15397 @end table
15398
15399 @item x
15400 Set which color component will be represented on X-axis. Default is @code{1}.
15401
15402 @item y
15403 Set which color component will be represented on Y-axis. Default is @code{2}.
15404
15405 @item intensity, i
15406 Set intensity, used by modes: gray, color, color3 and color5 for increasing brightness
15407 of color component which represents frequency of (X, Y) location in graph.
15408
15409 @item envelope, e
15410 @table @samp
15411 @item none
15412 No envelope, this is default.
15413
15414 @item instant
15415 Instant envelope, even darkest single pixel will be clearly highlighted.
15416
15417 @item peak
15418 Hold maximum and minimum values presented in graph over time. This way you
15419 can still spot out of range values without constantly looking at vectorscope.
15420
15421 @item peak+instant
15422 Peak and instant envelope combined together.
15423 @end table
15424
15425 @item graticule, g
15426 Set what kind of graticule to draw.
15427 @table @samp
15428 @item none
15429 @item green
15430 @item color
15431 @end table
15432
15433 @item opacity, o
15434 Set graticule opacity.
15435
15436 @item flags, f
15437 Set graticule flags.
15438
15439 @table @samp
15440 @item white
15441 Draw graticule for white point.
15442
15443 @item black
15444 Draw graticule for black point.
15445
15446 @item name
15447 Draw color points short names.
15448 @end table
15449
15450 @item bgopacity, b
15451 Set background opacity.
15452
15453 @item lthreshold, l
15454 Set low threshold for color component not represented on X or Y axis.
15455 Values lower than this value will be ignored. Default is 0.
15456 Note this value is multiplied with actual max possible value one pixel component
15457 can have. So for 8-bit input and low threshold value of 0.1 actual threshold
15458 is 0.1 * 255 = 25.
15459
15460 @item hthreshold, h
15461 Set high threshold for color component not represented on X or Y axis.
15462 Values higher than this value will be ignored. Default is 1.
15463 Note this value is multiplied with actual max possible value one pixel component
15464 can have. So for 8-bit input and high threshold value of 0.9 actual threshold
15465 is 0.9 * 255 = 230.
15466
15467 @item colorspace, c
15468 Set what kind of colorspace to use when drawing graticule.
15469 @table @samp
15470 @item auto
15471 @item 601
15472 @item 709
15473 @end table
15474 Default is auto.
15475 @end table
15476
15477 @anchor{vidstabdetect}
15478 @section vidstabdetect
15479
15480 Analyze video stabilization/deshaking. Perform pass 1 of 2, see
15481 @ref{vidstabtransform} for pass 2.
15482
15483 This filter generates a file with relative translation and rotation
15484 transform information about subsequent frames, which is then used by
15485 the @ref{vidstabtransform} filter.
15486
15487 To enable compilation of this filter you need to configure FFmpeg with
15488 @code{--enable-libvidstab}.
15489
15490 This filter accepts the following options:
15491
15492 @table @option
15493 @item result
15494 Set the path to the file used to write the transforms information.
15495 Default value is @file{transforms.trf}.
15496
15497 @item shakiness
15498 Set how shaky the video is and how quick the camera is. It accepts an
15499 integer in the range 1-10, a value of 1 means little shakiness, a
15500 value of 10 means strong shakiness. Default value is 5.
15501
15502 @item accuracy
15503 Set the accuracy of the detection process. It must be a value in the
15504 range 1-15. A value of 1 means low accuracy, a value of 15 means high
15505 accuracy. Default value is 15.
15506
15507 @item stepsize
15508 Set stepsize of the search process. The region around minimum is
15509 scanned with 1 pixel resolution. Default value is 6.
15510
15511 @item mincontrast
15512 Set minimum contrast. Below this value a local measurement field is
15513 discarded. Must be a floating point value in the range 0-1. Default
15514 value is 0.3.
15515
15516 @item tripod
15517 Set reference frame number for tripod mode.
15518
15519 If enabled, the motion of the frames is compared to a reference frame
15520 in the filtered stream, identified by the specified number. The idea
15521 is to compensate all movements in a more-or-less static scene and keep
15522 the camera view absolutely still.
15523
15524 If set to 0, it is disabled. The frames are counted starting from 1.
15525
15526 @item show
15527 Show fields and transforms in the resulting frames. It accepts an
15528 integer in the range 0-2. Default value is 0, which disables any
15529 visualization.
15530 @end table
15531
15532 @subsection Examples
15533
15534 @itemize
15535 @item
15536 Use default values:
15537 @example
15538 vidstabdetect
15539 @end example
15540
15541 @item
15542 Analyze strongly shaky movie and put the results in file
15543 @file{mytransforms.trf}:
15544 @example
15545 vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
15546 @end example
15547
15548 @item
15549 Visualize the result of internal transformations in the resulting
15550 video:
15551 @example
15552 vidstabdetect=show=1
15553 @end example
15554
15555 @item
15556 Analyze a video with medium shakiness using @command{ffmpeg}:
15557 @example
15558 ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
15559 @end example
15560 @end itemize
15561
15562 @anchor{vidstabtransform}
15563 @section vidstabtransform
15564
15565 Video stabilization/deshaking: pass 2 of 2,
15566 see @ref{vidstabdetect} for pass 1.
15567
15568 Read a file with transform information for each frame and
15569 apply/compensate them. Together with the @ref{vidstabdetect}
15570 filter this can be used to deshake videos. See also
15571 @url{http://public.hronopik.de/vid.stab}. It is important to also use
15572 the @ref{unsharp} filter, see below.
15573
15574 To enable compilation of this filter you need to configure FFmpeg with
15575 @code{--enable-libvidstab}.
15576
15577 @subsection Options
15578
15579 @table @option
15580 @item input
15581 Set path to the file used to read the transforms. Default value is
15582 @file{transforms.trf}.
15583
15584 @item smoothing
15585 Set the number of frames (value*2 + 1) used for lowpass filtering the
15586 camera movements. Default value is 10.
15587
15588 For example a number of 10 means that 21 frames are used (10 in the
15589 past and 10 in the future) to smoothen the motion in the video. A
15590 larger value leads to a smoother video, but limits the acceleration of
15591 the camera (pan/tilt movements). 0 is a special case where a static
15592 camera is simulated.
15593
15594 @item optalgo
15595 Set the camera path optimization algorithm.
15596
15597 Accepted values are:
15598 @table @samp
15599 @item gauss
15600 gaussian kernel low-pass filter on camera motion (default)
15601 @item avg
15602 averaging on transformations
15603 @end table
15604
15605 @item maxshift
15606 Set maximal number of pixels to translate frames. Default value is -1,
15607 meaning no limit.
15608
15609 @item maxangle
15610 Set maximal angle in radians (degree*PI/180) to rotate frames. Default
15611 value is -1, meaning no limit.
15612
15613 @item crop
15614 Specify how to deal with borders that may be visible due to movement
15615 compensation.
15616
15617 Available values are:
15618 @table @samp
15619 @item keep
15620 keep image information from previous frame (default)
15621 @item black
15622 fill the border black
15623 @end table
15624
15625 @item invert
15626 Invert transforms if set to 1. Default value is 0.
15627
15628 @item relative
15629 Consider transforms as relative to previous frame if set to 1,
15630 absolute if set to 0. Default value is 0.
15631
15632 @item zoom
15633 Set percentage to zoom. A positive value will result in a zoom-in
15634 effect, a negative value in a zoom-out effect. Default value is 0 (no
15635 zoom).
15636
15637 @item optzoom
15638 Set optimal zooming to avoid borders.
15639
15640 Accepted values are:
15641 @table @samp
15642 @item 0
15643 disabled
15644 @item 1
15645 optimal static zoom value is determined (only very strong movements
15646 will lead to visible borders) (default)
15647 @item 2
15648 optimal adaptive zoom value is determined (no borders will be
15649 visible), see @option{zoomspeed}
15650 @end table
15651
15652 Note that the value given at zoom is added to the one calculated here.
15653
15654 @item zoomspeed
15655 Set percent to zoom maximally each frame (enabled when
15656 @option{optzoom} is set to 2). Range is from 0 to 5, default value is
15657 0.25.
15658
15659 @item interpol
15660 Specify type of interpolation.
15661
15662 Available values are:
15663 @table @samp
15664 @item no
15665 no interpolation
15666 @item linear
15667 linear only horizontal
15668 @item bilinear
15669 linear in both directions (default)
15670 @item bicubic
15671 cubic in both directions (slow)
15672 @end table
15673
15674 @item tripod
15675 Enable virtual tripod mode if set to 1, which is equivalent to
15676 @code{relative=0:smoothing=0}. Default value is 0.
15677
15678 Use also @code{tripod} option of @ref{vidstabdetect}.
15679
15680 @item debug
15681 Increase log verbosity if set to 1. Also the detected global motions
15682 are written to the temporary file @file{global_motions.trf}. Default
15683 value is 0.
15684 @end table
15685
15686 @subsection Examples
15687
15688 @itemize
15689 @item
15690 Use @command{ffmpeg} for a typical stabilization with default values:
15691 @example
15692 ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
15693 @end example
15694
15695 Note the use of the @ref{unsharp} filter which is always recommended.
15696
15697 @item
15698 Zoom in a bit more and load transform data from a given file:
15699 @example
15700 vidstabtransform=zoom=5:input="mytransforms.trf"
15701 @end example
15702
15703 @item
15704 Smoothen the video even more:
15705 @example
15706 vidstabtransform=smoothing=30
15707 @end example
15708 @end itemize
15709
15710 @section vflip
15711
15712 Flip the input video vertically.
15713
15714 For example, to vertically flip a video with @command{ffmpeg}:
15715 @example
15716 ffmpeg -i in.avi -vf "vflip" out.avi
15717 @end example
15718
15719 @anchor{vignette}
15720 @section vignette
15721
15722 Make or reverse a natural vignetting effect.
15723
15724 The filter accepts the following options:
15725
15726 @table @option
15727 @item angle, a
15728 Set lens angle expression as a number of radians.
15729
15730 The value is clipped in the @code{[0,PI/2]} range.
15731
15732 Default value: @code{"PI/5"}
15733
15734 @item x0
15735 @item y0
15736 Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
15737 by default.
15738
15739 @item mode
15740 Set forward/backward mode.
15741
15742 Available modes are:
15743 @table @samp
15744 @item forward
15745 The larger the distance from the central point, the darker the image becomes.
15746
15747 @item backward
15748 The larger the distance from the central point, the brighter the image becomes.
15749 This can be used to reverse a vignette effect, though there is no automatic
15750 detection to extract the lens @option{angle} and other settings (yet). It can
15751 also be used to create a burning effect.
15752 @end table
15753
15754 Default value is @samp{forward}.
15755
15756 @item eval
15757 Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
15758
15759 It accepts the following values:
15760 @table @samp
15761 @item init
15762 Evaluate expressions only once during the filter initialization.
15763
15764 @item frame
15765 Evaluate expressions for each incoming frame. This is way slower than the
15766 @samp{init} mode since it requires all the scalers to be re-computed, but it
15767 allows advanced dynamic expressions.
15768 @end table
15769
15770 Default value is @samp{init}.
15771
15772 @item dither
15773 Set dithering to reduce the circular banding effects. Default is @code{1}
15774 (enabled).
15775
15776 @item aspect
15777 Set vignette aspect. This setting allows one to adjust the shape of the vignette.
15778 Setting this value to the SAR of the input will make a rectangular vignetting
15779 following the dimensions of the video.
15780
15781 Default is @code{1/1}.
15782 @end table
15783
15784 @subsection Expressions
15785
15786 The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
15787 following parameters.
15788
15789 @table @option
15790 @item w
15791 @item h
15792 input width and height
15793
15794 @item n
15795 the number of input frame, starting from 0
15796
15797 @item pts
15798 the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
15799 @var{TB} units, NAN if undefined
15800
15801 @item r
15802 frame rate of the input video, NAN if the input frame rate is unknown
15803
15804 @item t
15805 the PTS (Presentation TimeStamp) of the filtered video frame,
15806 expressed in seconds, NAN if undefined
15807
15808 @item tb
15809 time base of the input video
15810 @end table
15811
15812
15813 @subsection Examples
15814
15815 @itemize
15816 @item
15817 Apply simple strong vignetting effect:
15818 @example
15819 vignette=PI/4
15820 @end example
15821
15822 @item
15823 Make a flickering vignetting:
15824 @example
15825 vignette='PI/4+random(1)*PI/50':eval=frame
15826 @end example
15827
15828 @end itemize
15829
15830 @section vmafmotion
15831
15832 Obtain the average vmaf motion score of a video.
15833 It is one of the component filters of VMAF.
15834
15835 The obtained average motion score is printed through the logging system.
15836
15837 In the below example the input file @file{ref.mpg} is being processed and score
15838 is computed.
15839
15840 @example
15841 ffmpeg -i ref.mpg -lavfi vmafmotion -f null -
15842 @end example
15843
15844 @section vstack
15845 Stack input videos vertically.
15846
15847 All streams must be of same pixel format and of same width.
15848
15849 Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
15850 to create same output.
15851
15852 The filter accept the following option:
15853
15854 @table @option
15855 @item inputs
15856 Set number of input streams. Default is 2.
15857
15858 @item shortest
15859 If set to 1, force the output to terminate when the shortest input
15860 terminates. Default value is 0.
15861 @end table
15862
15863 @section w3fdif
15864
15865 Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
15866 Deinterlacing Filter").
15867
15868 Based on the process described by Martin Weston for BBC R&D, and
15869 implemented based on the de-interlace algorithm written by Jim
15870 Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
15871 uses filter coefficients calculated by BBC R&D.
15872
15873 There are two sets of filter coefficients, so called "simple":
15874 and "complex". Which set of filter coefficients is used can
15875 be set by passing an optional parameter:
15876
15877 @table @option
15878 @item filter
15879 Set the interlacing filter coefficients. Accepts one of the following values:
15880
15881 @table @samp
15882 @item simple
15883 Simple filter coefficient set.
15884 @item complex
15885 More-complex filter coefficient set.
15886 @end table
15887 Default value is @samp{complex}.
15888
15889 @item deint
15890 Specify which frames to deinterlace. Accept one of the following values:
15891
15892 @table @samp
15893 @item all
15894 Deinterlace all frames,
15895 @item interlaced
15896 Only deinterlace frames marked as interlaced.
15897 @end table
15898
15899 Default value is @samp{all}.
15900 @end table
15901
15902 @section waveform
15903 Video waveform monitor.
15904
15905 The waveform monitor plots color component intensity. By default luminance
15906 only. Each column of the waveform corresponds to a column of pixels in the
15907 source video.
15908
15909 It accepts the following options:
15910
15911 @table @option
15912 @item mode, m
15913 Can be either @code{row}, or @code{column}. Default is @code{column}.
15914 In row mode, the graph on the left side represents color component value 0 and
15915 the right side represents value = 255. In column mode, the top side represents
15916 color component value = 0 and bottom side represents value = 255.
15917
15918 @item intensity, i
15919 Set intensity. Smaller values are useful to find out how many values of the same
15920 luminance are distributed across input rows/columns.
15921 Default value is @code{0.04}. Allowed range is [0, 1].
15922
15923 @item mirror, r
15924 Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored.
15925 In mirrored mode, higher values will be represented on the left
15926 side for @code{row} mode and at the top for @code{column} mode. Default is
15927 @code{1} (mirrored).
15928
15929 @item display, d
15930 Set display mode.
15931 It accepts the following values:
15932 @table @samp
15933 @item overlay
15934 Presents information identical to that in the @code{parade}, except
15935 that the graphs representing color components are superimposed directly
15936 over one another.
15937
15938 This display mode makes it easier to spot relative differences or similarities
15939 in overlapping areas of the color components that are supposed to be identical,
15940 such as neutral whites, grays, or blacks.
15941
15942 @item stack
15943 Display separate graph for the color components side by side in
15944 @code{row} mode or one below the other in @code{column} mode.
15945
15946 @item parade
15947 Display separate graph for the color components side by side in
15948 @code{column} mode or one below the other in @code{row} mode.
15949
15950 Using this display mode makes it easy to spot color casts in the highlights
15951 and shadows of an image, by comparing the contours of the top and the bottom
15952 graphs of each waveform. Since whites, grays, and blacks are characterized
15953 by exactly equal amounts of red, green, and blue, neutral areas of the picture
15954 should display three waveforms of roughly equal width/height. If not, the
15955 correction is easy to perform by making level adjustments the three waveforms.
15956 @end table
15957 Default is @code{stack}.
15958
15959 @item components, c
15960 Set which color components to display. Default is 1, which means only luminance
15961 or red color component if input is in RGB colorspace. If is set for example to
15962 7 it will display all 3 (if) available color components.
15963
15964 @item envelope, e
15965 @table @samp
15966 @item none
15967 No envelope, this is default.
15968
15969 @item instant
15970 Instant envelope, minimum and maximum values presented in graph will be easily
15971 visible even with small @code{step} value.
15972
15973 @item peak
15974 Hold minimum and maximum values presented in graph across time. This way you
15975 can still spot out of range values without constantly looking at waveforms.
15976
15977 @item peak+instant
15978 Peak and instant envelope combined together.
15979 @end table
15980
15981 @item filter, f
15982 @table @samp
15983 @item lowpass
15984 No filtering, this is default.
15985
15986 @item flat
15987 Luma and chroma combined together.
15988
15989 @item aflat
15990 Similar as above, but shows difference between blue and red chroma.
15991
15992 @item chroma
15993 Displays only chroma.
15994
15995 @item color
15996 Displays actual color value on waveform.
15997
15998 @item acolor
15999 Similar as above, but with luma showing frequency of chroma values.
16000 @end table
16001
16002 @item graticule, g
16003 Set which graticule to display.
16004
16005 @table @samp
16006 @item none
16007 Do not display graticule.
16008
16009 @item green
16010 Display green graticule showing legal broadcast ranges.
16011 @end table
16012
16013 @item opacity, o
16014 Set graticule opacity.
16015
16016 @item flags, fl
16017 Set graticule flags.
16018
16019 @table @samp
16020 @item numbers
16021 Draw numbers above lines. By default enabled.
16022
16023 @item dots
16024 Draw dots instead of lines.
16025 @end table
16026
16027 @item scale, s
16028 Set scale used for displaying graticule.
16029
16030 @table @samp
16031 @item digital
16032 @item millivolts
16033 @item ire
16034 @end table
16035 Default is digital.
16036
16037 @item bgopacity, b
16038 Set background opacity.
16039 @end table
16040
16041 @section weave, doubleweave
16042
16043 The @code{weave} takes a field-based video input and join
16044 each two sequential fields into single frame, producing a new double
16045 height clip with half the frame rate and half the frame count.
16046
16047 The @code{doubleweave} works same as @code{weave} but without
16048 halving frame rate and frame count.
16049
16050 It accepts the following option:
16051
16052 @table @option
16053 @item first_field
16054 Set first field. Available values are:
16055
16056 @table @samp
16057 @item top, t
16058 Set the frame as top-field-first.
16059
16060 @item bottom, b
16061 Set the frame as bottom-field-first.
16062 @end table
16063 @end table
16064
16065 @subsection Examples
16066
16067 @itemize
16068 @item
16069 Interlace video using @ref{select} and @ref{separatefields} filter:
16070 @example
16071 separatefields,select=eq(mod(n,4),0)+eq(mod(n,4),3),weave
16072 @end example
16073 @end itemize
16074
16075 @section xbr
16076 Apply the xBR high-quality magnification filter which is designed for pixel
16077 art. It follows a set of edge-detection rules, see
16078 @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
16079
16080 It accepts the following option:
16081
16082 @table @option
16083 @item n
16084 Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
16085 @code{3xBR} and @code{4} for @code{4xBR}.
16086 Default is @code{3}.
16087 @end table
16088
16089 @anchor{yadif}
16090 @section yadif
16091
16092 Deinterlace the input video ("yadif" means "yet another deinterlacing
16093 filter").
16094
16095 It accepts the following parameters:
16096
16097
16098 @table @option
16099
16100 @item mode
16101 The interlacing mode to adopt. It accepts one of the following values:
16102
16103 @table @option
16104 @item 0, send_frame
16105 Output one frame for each frame.
16106 @item 1, send_field
16107 Output one frame for each field.
16108 @item 2, send_frame_nospatial
16109 Like @code{send_frame}, but it skips the spatial interlacing check.
16110 @item 3, send_field_nospatial
16111 Like @code{send_field}, but it skips the spatial interlacing check.
16112 @end table
16113
16114 The default value is @code{send_frame}.
16115
16116 @item parity
16117 The picture field parity assumed for the input interlaced video. It accepts one
16118 of the following values:
16119
16120 @table @option
16121 @item 0, tff
16122 Assume the top field is first.
16123 @item 1, bff
16124 Assume the bottom field is first.
16125 @item -1, auto
16126 Enable automatic detection of field parity.
16127 @end table
16128
16129 The default value is @code{auto}.
16130 If the interlacing is unknown or the decoder does not export this information,
16131 top field first will be assumed.
16132
16133 @item deint
16134 Specify which frames to deinterlace. Accept one of the following
16135 values:
16136
16137 @table @option
16138 @item 0, all
16139 Deinterlace all frames.
16140 @item 1, interlaced
16141 Only deinterlace frames marked as interlaced.
16142 @end table
16143
16144 The default value is @code{all}.
16145 @end table
16146
16147 @section zoompan
16148
16149 Apply Zoom & Pan effect.
16150
16151 This filter accepts the following options:
16152
16153 @table @option
16154 @item zoom, z
16155 Set the zoom expression. Default is 1.
16156
16157 @item x
16158 @item y
16159 Set the x and y expression. Default is 0.
16160
16161 @item d
16162 Set the duration expression in number of frames.
16163 This sets for how many number of frames effect will last for
16164 single input image.
16165
16166 @item s
16167 Set the output image size, default is 'hd720'.
16168
16169 @item fps
16170 Set the output frame rate, default is '25'.
16171 @end table
16172
16173 Each expression can contain the following constants:
16174
16175 @table @option
16176 @item in_w, iw
16177 Input width.
16178
16179 @item in_h, ih
16180 Input height.
16181
16182 @item out_w, ow
16183 Output width.
16184
16185 @item out_h, oh
16186 Output height.
16187
16188 @item in
16189 Input frame count.
16190
16191 @item on
16192 Output frame count.
16193
16194 @item x
16195 @item y
16196 Last calculated 'x' and 'y' position from 'x' and 'y' expression
16197 for current input frame.
16198
16199 @item px
16200 @item py
16201 'x' and 'y' of last output frame of previous input frame or 0 when there was
16202 not yet such frame (first input frame).
16203
16204 @item zoom
16205 Last calculated zoom from 'z' expression for current input frame.
16206
16207 @item pzoom
16208 Last calculated zoom of last output frame of previous input frame.
16209
16210 @item duration
16211 Number of output frames for current input frame. Calculated from 'd' expression
16212 for each input frame.
16213
16214 @item pduration
16215 number of output frames created for previous input frame
16216
16217 @item a
16218 Rational number: input width / input height
16219
16220 @item sar
16221 sample aspect ratio
16222
16223 @item dar
16224 display aspect ratio
16225
16226 @end table
16227
16228 @subsection Examples
16229
16230 @itemize
16231 @item
16232 Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
16233 @example
16234 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
16235 @end example
16236
16237 @item
16238 Zoom-in up to 1.5 and pan always at center of picture:
16239 @example
16240 zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
16241 @end example
16242
16243 @item
16244 Same as above but without pausing:
16245 @example
16246 zoompan=z='min(max(zoom,pzoom)+0.0015,1.5)':d=1:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
16247 @end example
16248 @end itemize
16249
16250 @anchor{zscale}
16251 @section zscale
16252 Scale (resize) the input video, using the z.lib library:
16253 https://github.com/sekrit-twc/zimg.
16254
16255 The zscale filter forces the output display aspect ratio to be the same
16256 as the input, by changing the output sample aspect ratio.
16257
16258 If the input image format is different from the format requested by
16259 the next filter, the zscale filter will convert the input to the
16260 requested format.
16261
16262 @subsection Options
16263 The filter accepts the following options.
16264
16265 @table @option
16266 @item width, w
16267 @item height, h
16268 Set the output video dimension expression. Default value is the input
16269 dimension.
16270
16271 If the @var{width} or @var{w} value is 0, the input width is used for
16272 the output. If the @var{height} or @var{h} value is 0, the input height
16273 is used for the output.
16274
16275 If one and only one of the values is -n with n >= 1, the zscale filter
16276 will use a value that maintains the aspect ratio of the input image,
16277 calculated from the other specified dimension. After that it will,
16278 however, make sure that the calculated dimension is divisible by n and
16279 adjust the value if necessary.
16280
16281 If both values are -n with n >= 1, the behavior will be identical to
16282 both values being set to 0 as previously detailed.
16283
16284 See below for the list of accepted constants for use in the dimension
16285 expression.
16286
16287 @item size, s
16288 Set the video size. For the syntax of this option, check the
16289 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
16290
16291 @item dither, d
16292 Set the dither type.
16293
16294 Possible values are:
16295 @table @var
16296 @item none
16297 @item ordered
16298 @item random
16299 @item error_diffusion
16300 @end table
16301
16302 Default is none.
16303
16304 @item filter, f
16305 Set the resize filter type.
16306
16307 Possible values are:
16308 @table @var
16309 @item point
16310 @item bilinear
16311 @item bicubic
16312 @item spline16
16313 @item spline36
16314 @item lanczos
16315 @end table
16316
16317 Default is bilinear.
16318
16319 @item range, r
16320 Set the color range.
16321
16322 Possible values are:
16323 @table @var
16324 @item input
16325 @item limited
16326 @item full
16327 @end table
16328
16329 Default is same as input.
16330
16331 @item primaries, p
16332 Set the color primaries.
16333
16334 Possible values are:
16335 @table @var
16336 @item input
16337 @item 709
16338 @item unspecified
16339 @item 170m
16340 @item 240m
16341 @item 2020
16342 @end table
16343
16344 Default is same as input.
16345
16346 @item transfer, t
16347 Set the transfer characteristics.
16348
16349 Possible values are:
16350 @table @var
16351 @item input
16352 @item 709
16353 @item unspecified
16354 @item 601
16355 @item linear
16356 @item 2020_10
16357 @item 2020_12
16358 @item smpte2084
16359 @item iec61966-2-1
16360 @item arib-std-b67
16361 @end table
16362
16363 Default is same as input.
16364
16365 @item matrix, m
16366 Set the colorspace matrix.
16367
16368 Possible value are:
16369 @table @var
16370 @item input
16371 @item 709
16372 @item unspecified
16373 @item 470bg
16374 @item 170m
16375 @item 2020_ncl
16376 @item 2020_cl
16377 @end table
16378
16379 Default is same as input.
16380
16381 @item rangein, rin
16382 Set the input color range.
16383
16384 Possible values are:
16385 @table @var
16386 @item input
16387 @item limited
16388 @item full
16389 @end table
16390
16391 Default is same as input.
16392
16393 @item primariesin, pin
16394 Set the input color primaries.
16395
16396 Possible values are:
16397 @table @var
16398 @item input
16399 @item 709
16400 @item unspecified
16401 @item 170m
16402 @item 240m
16403 @item 2020
16404 @end table
16405
16406 Default is same as input.
16407
16408 @item transferin, tin
16409 Set the input transfer characteristics.
16410
16411 Possible values are:
16412 @table @var
16413 @item input
16414 @item 709
16415 @item unspecified
16416 @item 601
16417 @item linear
16418 @item 2020_10
16419 @item 2020_12
16420 @end table
16421
16422 Default is same as input.
16423
16424 @item matrixin, min
16425 Set the input colorspace matrix.
16426
16427 Possible value are:
16428 @table @var
16429 @item input
16430 @item 709
16431 @item unspecified
16432 @item 470bg
16433 @item 170m
16434 @item 2020_ncl
16435 @item 2020_cl
16436 @end table
16437
16438 @item chromal, c
16439 Set the output chroma location.
16440
16441 Possible values are:
16442 @table @var
16443 @item input
16444 @item left
16445 @item center
16446 @item topleft
16447 @item top
16448 @item bottomleft
16449 @item bottom
16450 @end table
16451
16452 @item chromalin, cin
16453 Set the input chroma location.
16454
16455 Possible values are:
16456 @table @var
16457 @item input
16458 @item left
16459 @item center
16460 @item topleft
16461 @item top
16462 @item bottomleft
16463 @item bottom
16464 @end table
16465
16466 @item npl
16467 Set the nominal peak luminance.
16468 @end table
16469
16470 The values of the @option{w} and @option{h} options are expressions
16471 containing the following constants:
16472
16473 @table @var
16474 @item in_w
16475 @item in_h
16476 The input width and height
16477
16478 @item iw
16479 @item ih
16480 These are the same as @var{in_w} and @var{in_h}.
16481
16482 @item out_w
16483 @item out_h
16484 The output (scaled) width and height
16485
16486 @item ow
16487 @item oh
16488 These are the same as @var{out_w} and @var{out_h}
16489
16490 @item a
16491 The same as @var{iw} / @var{ih}
16492
16493 @item sar
16494 input sample aspect ratio
16495
16496 @item dar
16497 The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
16498
16499 @item hsub
16500 @item vsub
16501 horizontal and vertical input chroma subsample values. For example for the
16502 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
16503
16504 @item ohsub
16505 @item ovsub
16506 horizontal and vertical output chroma subsample values. For example for the
16507 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
16508 @end table
16509
16510 @table @option
16511 @end table
16512
16513 @c man end VIDEO FILTERS
16514
16515 @chapter Video Sources
16516 @c man begin VIDEO SOURCES
16517
16518 Below is a description of the currently available video sources.
16519
16520 @section buffer
16521
16522 Buffer video frames, and make them available to the filter chain.
16523
16524 This source is mainly intended for a programmatic use, in particular
16525 through the interface defined in @file{libavfilter/vsrc_buffer.h}.
16526
16527 It accepts the following parameters:
16528
16529 @table @option
16530
16531 @item video_size
16532 Specify the size (width and height) of the buffered video frames. For the
16533 syntax of this option, check the
16534 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
16535
16536 @item width
16537 The input video width.
16538
16539 @item height
16540 The input video height.
16541
16542 @item pix_fmt
16543 A string representing the pixel format of the buffered video frames.
16544 It may be a number corresponding to a pixel format, or a pixel format
16545 name.
16546
16547 @item time_base
16548 Specify the timebase assumed by the timestamps of the buffered frames.
16549
16550 @item frame_rate
16551 Specify the frame rate expected for the video stream.
16552
16553 @item pixel_aspect, sar
16554 The sample (pixel) aspect ratio of the input video.
16555
16556 @item sws_param
16557 Specify the optional parameters to be used for the scale filter which
16558 is automatically inserted when an input change is detected in the
16559 input size or format.
16560
16561 @item hw_frames_ctx
16562 When using a hardware pixel format, this should be a reference to an
16563 AVHWFramesContext describing input frames.
16564 @end table
16565
16566 For example:
16567 @example
16568 buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
16569 @end example
16570
16571 will instruct the source to accept video frames with size 320x240 and
16572 with format "yuv410p", assuming 1/24 as the timestamps timebase and
16573 square pixels (1:1 sample aspect ratio).
16574 Since the pixel format with name "yuv410p" corresponds to the number 6
16575 (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
16576 this example corresponds to:
16577 @example
16578 buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
16579 @end example
16580
16581 Alternatively, the options can be specified as a flat string, but this
16582 syntax is deprecated:
16583
16584 @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}]
16585
16586 @section cellauto
16587
16588 Create a pattern generated by an elementary cellular automaton.
16589
16590 The initial state of the cellular automaton can be defined through the
16591 @option{filename} and @option{pattern} options. If such options are
16592 not specified an initial state is created randomly.
16593
16594 At each new frame a new row in the video is filled with the result of
16595 the cellular automaton next generation. The behavior when the whole
16596 frame is filled is defined by the @option{scroll} option.
16597
16598 This source accepts the following options:
16599
16600 @table @option
16601 @item filename, f
16602 Read the initial cellular automaton state, i.e. the starting row, from
16603 the specified file.
16604 In the file, each non-whitespace character is considered an alive
16605 cell, a newline will terminate the row, and further characters in the
16606 file will be ignored.
16607
16608 @item pattern, p
16609 Read the initial cellular automaton state, i.e. the starting row, from
16610 the specified string.
16611
16612 Each non-whitespace character in the string is considered an alive
16613 cell, a newline will terminate the row, and further characters in the
16614 string will be ignored.
16615
16616 @item rate, r
16617 Set the video rate, that is the number of frames generated per second.
16618 Default is 25.
16619
16620 @item random_fill_ratio, ratio
16621 Set the random fill ratio for the initial cellular automaton row. It
16622 is a floating point number value ranging from 0 to 1, defaults to
16623 1/PHI.
16624
16625 This option is ignored when a file or a pattern is specified.
16626
16627 @item random_seed, seed
16628 Set the seed for filling randomly the initial row, must be an integer
16629 included between 0 and UINT32_MAX. If not specified, or if explicitly
16630 set to -1, the filter will try to use a good random seed on a best
16631 effort basis.
16632
16633 @item rule
16634 Set the cellular automaton rule, it is a number ranging from 0 to 255.
16635 Default value is 110.
16636
16637 @item size, s
16638 Set the size of the output video. For the syntax of this option, check the
16639 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
16640
16641 If @option{filename} or @option{pattern} is specified, the size is set
16642 by default to the width of the specified initial state row, and the
16643 height is set to @var{width} * PHI.
16644
16645 If @option{size} is set, it must contain the width of the specified
16646 pattern string, and the specified pattern will be centered in the
16647 larger row.
16648
16649 If a filename or a pattern string is not specified, the size value
16650 defaults to "320x518" (used for a randomly generated initial state).
16651
16652 @item scroll
16653 If set to 1, scroll the output upward when all the rows in the output
16654 have been already filled. If set to 0, the new generated row will be
16655 written over the top row just after the bottom row is filled.
16656 Defaults to 1.
16657
16658 @item start_full, full
16659 If set to 1, completely fill the output with generated rows before
16660 outputting the first frame.
16661 This is the default behavior, for disabling set the value to 0.
16662
16663 @item stitch
16664 If set to 1, stitch the left and right row edges together.
16665 This is the default behavior, for disabling set the value to 0.
16666 @end table
16667
16668 @subsection Examples
16669
16670 @itemize
16671 @item
16672 Read the initial state from @file{pattern}, and specify an output of
16673 size 200x400.
16674 @example
16675 cellauto=f=pattern:s=200x400
16676 @end example
16677
16678 @item
16679 Generate a random initial row with a width of 200 cells, with a fill
16680 ratio of 2/3:
16681 @example
16682 cellauto=ratio=2/3:s=200x200
16683 @end example
16684
16685 @item
16686 Create a pattern generated by rule 18 starting by a single alive cell
16687 centered on an initial row with width 100:
16688 @example
16689 cellauto=p=@@:s=100x400:full=0:rule=18
16690 @end example
16691
16692 @item
16693 Specify a more elaborated initial pattern:
16694 @example
16695 cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
16696 @end example
16697
16698 @end itemize
16699
16700 @anchor{coreimagesrc}
16701 @section coreimagesrc
16702 Video source generated on GPU using Apple's CoreImage API on OSX.
16703
16704 This video source is a specialized version of the @ref{coreimage} video filter.
16705 Use a core image generator at the beginning of the applied filterchain to
16706 generate the content.
16707
16708 The coreimagesrc video source accepts the following options:
16709 @table @option
16710 @item list_generators
16711 List all available generators along with all their respective options as well as
16712 possible minimum and maximum values along with the default values.
16713 @example
16714 list_generators=true
16715 @end example
16716
16717 @item size, s
16718 Specify the size of the sourced video. For the syntax of this option, check the
16719 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
16720 The default value is @code{320x240}.
16721
16722 @item rate, r
16723 Specify the frame rate of the sourced video, as the number of frames
16724 generated per second. It has to be a string in the format
16725 @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
16726 number or a valid video frame rate abbreviation. The default value is
16727 "25".
16728
16729 @item sar
16730 Set the sample aspect ratio of the sourced video.
16731
16732 @item duration, d
16733 Set the duration of the sourced video. See
16734 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
16735 for the accepted syntax.
16736
16737 If not specified, or the expressed duration is negative, the video is
16738 supposed to be generated forever.
16739 @end table
16740
16741 Additionally, all options of the @ref{coreimage} video filter are accepted.
16742 A complete filterchain can be used for further processing of the
16743 generated input without CPU-HOST transfer. See @ref{coreimage} documentation
16744 and examples for details.
16745
16746 @subsection Examples
16747
16748 @itemize
16749
16750 @item
16751 Use CIQRCodeGenerator to create a QR code for the FFmpeg homepage,
16752 given as complete and escaped command-line for Apple's standard bash shell:
16753 @example
16754 ffmpeg -f lavfi -i coreimagesrc=s=100x100:filter=CIQRCodeGenerator@@inputMessage=https\\\\\://FFmpeg.org/@@inputCorrectionLevel=H -frames:v 1 QRCode.png
16755 @end example
16756 This example is equivalent to the QRCode example of @ref{coreimage} without the
16757 need for a nullsrc video source.
16758 @end itemize
16759
16760
16761 @section mandelbrot
16762
16763 Generate a Mandelbrot set fractal, and progressively zoom towards the
16764 point specified with @var{start_x} and @var{start_y}.
16765
16766 This source accepts the following options:
16767
16768 @table @option
16769
16770 @item end_pts
16771 Set the terminal pts value. Default value is 400.
16772
16773 @item end_scale
16774 Set the terminal scale value.
16775 Must be a floating point value. Default value is 0.3.
16776
16777 @item inner
16778 Set the inner coloring mode, that is the algorithm used to draw the
16779 Mandelbrot fractal internal region.
16780
16781 It shall assume one of the following values:
16782 @table @option
16783 @item black
16784 Set black mode.
16785 @item convergence
16786 Show time until convergence.
16787 @item mincol
16788 Set color based on point closest to the origin of the iterations.
16789 @item period
16790 Set period mode.
16791 @end table
16792
16793 Default value is @var{mincol}.
16794
16795 @item bailout
16796 Set the bailout value. Default value is 10.0.
16797
16798 @item maxiter
16799 Set the maximum of iterations performed by the rendering
16800 algorithm. Default value is 7189.
16801
16802 @item outer
16803 Set outer coloring mode.
16804 It shall assume one of following values:
16805 @table @option
16806 @item iteration_count
16807 Set iteration cound mode.
16808 @item normalized_iteration_count
16809 set normalized iteration count mode.
16810 @end table
16811 Default value is @var{normalized_iteration_count}.
16812
16813 @item rate, r
16814 Set frame rate, expressed as number of frames per second. Default
16815 value is "25".
16816
16817 @item size, s
16818 Set frame size. For the syntax of this option, check the "Video
16819 size" section in the ffmpeg-utils manual. Default value is "640x480".
16820
16821 @item start_scale
16822 Set the initial scale value. Default value is 3.0.
16823
16824 @item start_x
16825 Set the initial x position. Must be a floating point value between
16826 -100 and 100. Default value is -0.743643887037158704752191506114774.
16827
16828 @item start_y
16829 Set the initial y position. Must be a floating point value between
16830 -100 and 100. Default value is -0.131825904205311970493132056385139.
16831 @end table
16832
16833 @section mptestsrc
16834
16835 Generate various test patterns, as generated by the MPlayer test filter.
16836
16837 The size of the generated video is fixed, and is 256x256.
16838 This source is useful in particular for testing encoding features.
16839
16840 This source accepts the following options:
16841
16842 @table @option
16843
16844 @item rate, r
16845 Specify the frame rate of the sourced video, as the number of frames
16846 generated per second. It has to be a string in the format
16847 @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
16848 number or a valid video frame rate abbreviation. The default value is
16849 "25".
16850
16851 @item duration, d
16852 Set the duration of the sourced video. See
16853 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
16854 for the accepted syntax.
16855
16856 If not specified, or the expressed duration is negative, the video is
16857 supposed to be generated forever.
16858
16859 @item test, t
16860
16861 Set the number or the name of the test to perform. Supported tests are:
16862 @table @option
16863 @item dc_luma
16864 @item dc_chroma
16865 @item freq_luma
16866 @item freq_chroma
16867 @item amp_luma
16868 @item amp_chroma
16869 @item cbp
16870 @item mv
16871 @item ring1
16872 @item ring2
16873 @item all
16874
16875 @end table
16876
16877 Default value is "all", which will cycle through the list of all tests.
16878 @end table
16879
16880 Some examples:
16881 @example
16882 mptestsrc=t=dc_luma
16883 @end example
16884
16885 will generate a "dc_luma" test pattern.
16886
16887 @section frei0r_src
16888
16889 Provide a frei0r source.
16890
16891 To enable compilation of this filter you need to install the frei0r
16892 header and configure FFmpeg with @code{--enable-frei0r}.
16893
16894 This source accepts the following parameters:
16895
16896 @table @option
16897
16898 @item size
16899 The size of the video to generate. For the syntax of this option, check the
16900 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
16901
16902 @item framerate
16903 The framerate of the generated video. It may be a string of the form
16904 @var{num}/@var{den} or a frame rate abbreviation.
16905
16906 @item filter_name
16907 The name to the frei0r source to load. For more information regarding frei0r and
16908 how to set the parameters, read the @ref{frei0r} section in the video filters
16909 documentation.
16910
16911 @item filter_params
16912 A '|'-separated list of parameters to pass to the frei0r source.
16913
16914 @end table
16915
16916 For example, to generate a frei0r partik0l source with size 200x200
16917 and frame rate 10 which is overlaid on the overlay filter main input:
16918 @example
16919 frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
16920 @end example
16921
16922 @section life
16923
16924 Generate a life pattern.
16925
16926 This source is based on a generalization of John Conway's life game.
16927
16928 The sourced input represents a life grid, each pixel represents a cell
16929 which can be in one of two possible states, alive or dead. Every cell
16930 interacts with its eight neighbours, which are the cells that are
16931 horizontally, vertically, or diagonally adjacent.
16932
16933 At each interaction the grid evolves according to the adopted rule,
16934 which specifies the number of neighbor alive cells which will make a
16935 cell stay alive or born. The @option{rule} option allows one to specify
16936 the rule to adopt.
16937
16938 This source accepts the following options:
16939
16940 @table @option
16941 @item filename, f
16942 Set the file from which to read the initial grid state. In the file,
16943 each non-whitespace character is considered an alive cell, and newline
16944 is used to delimit the end of each row.
16945
16946 If this option is not specified, the initial grid is generated
16947 randomly.
16948
16949 @item rate, r
16950 Set the video rate, that is the number of frames generated per second.
16951 Default is 25.
16952
16953 @item random_fill_ratio, ratio
16954 Set the random fill ratio for the initial random grid. It is a
16955 floating point number value ranging from 0 to 1, defaults to 1/PHI.
16956 It is ignored when a file is specified.
16957
16958 @item random_seed, seed
16959 Set the seed for filling the initial random grid, must be an integer
16960 included between 0 and UINT32_MAX. If not specified, or if explicitly
16961 set to -1, the filter will try to use a good random seed on a best
16962 effort basis.
16963
16964 @item rule
16965 Set the life rule.
16966
16967 A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
16968 where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
16969 @var{NS} specifies the number of alive neighbor cells which make a
16970 live cell stay alive, and @var{NB} the number of alive neighbor cells
16971 which make a dead cell to become alive (i.e. to "born").
16972 "s" and "b" can be used in place of "S" and "B", respectively.
16973
16974 Alternatively a rule can be specified by an 18-bits integer. The 9
16975 high order bits are used to encode the next cell state if it is alive
16976 for each number of neighbor alive cells, the low order bits specify
16977 the rule for "borning" new cells. Higher order bits encode for an
16978 higher number of neighbor cells.
16979 For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
16980 rule of 12 and a born rule of 9, which corresponds to "S23/B03".
16981
16982 Default value is "S23/B3", which is the original Conway's game of life
16983 rule, and will keep a cell alive if it has 2 or 3 neighbor alive
16984 cells, and will born a new cell if there are three alive cells around
16985 a dead cell.
16986
16987 @item size, s
16988 Set the size of the output video. For the syntax of this option, check the
16989 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
16990
16991 If @option{filename} is specified, the size is set by default to the
16992 same size of the input file. If @option{size} is set, it must contain
16993 the size specified in the input file, and the initial grid defined in
16994 that file is centered in the larger resulting area.
16995
16996 If a filename is not specified, the size value defaults to "320x240"
16997 (used for a randomly generated initial grid).
16998
16999 @item stitch
17000 If set to 1, stitch the left and right grid edges together, and the
17001 top and bottom edges also. Defaults to 1.
17002
17003 @item mold
17004 Set cell mold speed. If set, a dead cell will go from @option{death_color} to
17005 @option{mold_color} with a step of @option{mold}. @option{mold} can have a
17006 value from 0 to 255.
17007
17008 @item life_color
17009 Set the color of living (or new born) cells.
17010
17011 @item death_color
17012 Set the color of dead cells. If @option{mold} is set, this is the first color
17013 used to represent a dead cell.
17014
17015 @item mold_color
17016 Set mold color, for definitely dead and moldy cells.
17017
17018 For the syntax of these 3 color options, check the "Color" section in the
17019 ffmpeg-utils manual.
17020 @end table
17021
17022 @subsection Examples
17023
17024 @itemize
17025 @item
17026 Read a grid from @file{pattern}, and center it on a grid of size
17027 300x300 pixels:
17028 @example
17029 life=f=pattern:s=300x300
17030 @end example
17031
17032 @item
17033 Generate a random grid of size 200x200, with a fill ratio of 2/3:
17034 @example
17035 life=ratio=2/3:s=200x200
17036 @end example
17037
17038 @item
17039 Specify a custom rule for evolving a randomly generated grid:
17040 @example
17041 life=rule=S14/B34
17042 @end example
17043
17044 @item
17045 Full example with slow death effect (mold) using @command{ffplay}:
17046 @example
17047 ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
17048 @end example
17049 @end itemize
17050
17051 @anchor{allrgb}
17052 @anchor{allyuv}
17053 @anchor{color}
17054 @anchor{haldclutsrc}
17055 @anchor{nullsrc}
17056 @anchor{rgbtestsrc}
17057 @anchor{smptebars}
17058 @anchor{smptehdbars}
17059 @anchor{testsrc}
17060 @anchor{testsrc2}
17061 @anchor{yuvtestsrc}
17062 @section allrgb, allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc, testsrc2, yuvtestsrc
17063
17064 The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
17065
17066 The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
17067
17068 The @code{color} source provides an uniformly colored input.
17069
17070 The @code{haldclutsrc} source provides an identity Hald CLUT. See also
17071 @ref{haldclut} filter.
17072
17073 The @code{nullsrc} source returns unprocessed video frames. It is
17074 mainly useful to be employed in analysis / debugging tools, or as the
17075 source for filters which ignore the input data.
17076
17077 The @code{rgbtestsrc} source generates an RGB test pattern useful for
17078 detecting RGB vs BGR issues. You should see a red, green and blue
17079 stripe from top to bottom.
17080
17081 The @code{smptebars} source generates a color bars pattern, based on
17082 the SMPTE Engineering Guideline EG 1-1990.
17083
17084 The @code{smptehdbars} source generates a color bars pattern, based on
17085 the SMPTE RP 219-2002.
17086
17087 The @code{testsrc} source generates a test video pattern, showing a
17088 color pattern, a scrolling gradient and a timestamp. This is mainly
17089 intended for testing purposes.
17090
17091 The @code{testsrc2} source is similar to testsrc, but supports more
17092 pixel formats instead of just @code{rgb24}. This allows using it as an
17093 input for other tests without requiring a format conversion.
17094
17095 The @code{yuvtestsrc} source generates an YUV test pattern. You should
17096 see a y, cb and cr stripe from top to bottom.
17097
17098 The sources accept the following parameters:
17099
17100 @table @option
17101
17102 @item alpha
17103 Specify the alpha (opacity) of the background, only available in the
17104 @code{testsrc2} source. The value must be between 0 (fully transparent) and
17105 255 (fully opaque, the default).
17106
17107 @item color, c
17108 Specify the color of the source, only available in the @code{color}
17109 source. For the syntax of this option, check the "Color" section in the
17110 ffmpeg-utils manual.
17111
17112 @item level
17113 Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
17114 source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
17115 pixels to be used as identity matrix for 3D lookup tables. Each component is
17116 coded on a @code{1/(N*N)} scale.
17117
17118 @item size, s
17119 Specify the size of the sourced video. For the syntax of this option, check the
17120 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
17121 The default value is @code{320x240}.
17122
17123 This option is not available with the @code{haldclutsrc} filter.
17124
17125 @item rate, r
17126 Specify the frame rate of the sourced video, as the number of frames
17127 generated per second. It has to be a string in the format
17128 @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
17129 number or a valid video frame rate abbreviation. The default value is
17130 "25".
17131
17132 @item sar
17133 Set the sample aspect ratio of the sourced video.
17134
17135 @item duration, d
17136 Set the duration of the sourced video. See
17137 @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
17138 for the accepted syntax.
17139
17140 If not specified, or the expressed duration is negative, the video is
17141 supposed to be generated forever.
17142
17143 @item decimals, n
17144 Set the number of decimals to show in the timestamp, only available in the
17145 @code{testsrc} source.
17146
17147 The displayed timestamp value will correspond to the original
17148 timestamp value multiplied by the power of 10 of the specified
17149 value. Default value is 0.
17150 @end table
17151
17152 For example the following:
17153 @example
17154 testsrc=duration=5.3:size=qcif:rate=10
17155 @end example
17156
17157 will generate a video with a duration of 5.3 seconds, with size
17158 176x144 and a frame rate of 10 frames per second.
17159
17160 The following graph description will generate a red source
17161 with an opacity of 0.2, with size "qcif" and a frame rate of 10
17162 frames per second.
17163 @example
17164 color=c=red@@0.2:s=qcif:r=10
17165 @end example
17166
17167 If the input content is to be ignored, @code{nullsrc} can be used. The
17168 following command generates noise in the luminance plane by employing
17169 the @code{geq} filter:
17170 @example
17171 nullsrc=s=256x256, geq=random(1)*255:128:128
17172 @end example
17173
17174 @subsection Commands
17175
17176 The @code{color} source supports the following commands:
17177
17178 @table @option
17179 @item c, color
17180 Set the color of the created image. Accepts the same syntax of the
17181 corresponding @option{color} option.
17182 @end table
17183
17184 @c man end VIDEO SOURCES
17185
17186 @chapter Video Sinks
17187 @c man begin VIDEO SINKS
17188
17189 Below is a description of the currently available video sinks.
17190
17191 @section buffersink
17192
17193 Buffer video frames, and make them available to the end of the filter
17194 graph.
17195
17196 This sink is mainly intended for programmatic use, in particular
17197 through the interface defined in @file{libavfilter/buffersink.h}
17198 or the options system.
17199
17200 It accepts a pointer to an AVBufferSinkContext structure, which
17201 defines the incoming buffers' formats, to be passed as the opaque
17202 parameter to @code{avfilter_init_filter} for initialization.
17203
17204 @section nullsink
17205
17206 Null video sink: do absolutely nothing with the input video. It is
17207 mainly useful as a template and for use in analysis / debugging
17208 tools.
17209
17210 @c man end VIDEO SINKS
17211
17212 @chapter Multimedia Filters
17213 @c man begin MULTIMEDIA FILTERS
17214
17215 Below is a description of the currently available multimedia filters.
17216
17217 @section abitscope
17218
17219 Convert input audio to a video output, displaying the audio bit scope.
17220
17221 The filter accepts the following options:
17222
17223 @table @option
17224 @item rate, r
17225 Set frame rate, expressed as number of frames per second. Default
17226 value is "25".
17227
17228 @item size, s
17229 Specify the video size for the output. For the syntax of this option, check the
17230 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
17231 Default value is @code{1024x256}.
17232
17233 @item colors
17234 Specify list of colors separated by space or by '|' which will be used to
17235 draw channels. Unrecognized or missing colors will be replaced
17236 by white color.
17237 @end table
17238
17239 @section ahistogram
17240
17241 Convert input audio to a video output, displaying the volume histogram.
17242
17243 The filter accepts the following options:
17244
17245 @table @option
17246 @item dmode
17247 Specify how histogram is calculated.
17248
17249 It accepts the following values:
17250 @table @samp
17251 @item single
17252 Use single histogram for all channels.
17253 @item separate
17254 Use separate histogram for each channel.
17255 @end table
17256 Default is @code{single}.
17257
17258 @item rate, r
17259 Set frame rate, expressed as number of frames per second. Default
17260 value is "25".
17261
17262 @item size, s
17263 Specify the video size for the output. For the syntax of this option, check the
17264 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
17265 Default value is @code{hd720}.
17266
17267 @item scale
17268 Set display scale.
17269
17270 It accepts the following values:
17271 @table @samp
17272 @item log
17273 logarithmic
17274 @item sqrt
17275 square root
17276 @item cbrt
17277 cubic root
17278 @item lin
17279 linear
17280 @item rlog
17281 reverse logarithmic
17282 @end table
17283 Default is @code{log}.
17284
17285 @item ascale
17286 Set amplitude scale.
17287
17288 It accepts the following values:
17289 @table @samp
17290 @item log
17291 logarithmic
17292 @item lin
17293 linear
17294 @end table
17295 Default is @code{log}.
17296
17297 @item acount
17298 Set how much frames to accumulate in histogram.
17299 Defauls is 1. Setting this to -1 accumulates all frames.
17300
17301 @item rheight
17302 Set histogram ratio of window height.
17303
17304 @item slide
17305 Set sonogram sliding.
17306
17307 It accepts the following values:
17308 @table @samp
17309 @item replace
17310 replace old rows with new ones.
17311 @item scroll
17312 scroll from top to bottom.
17313 @end table
17314 Default is @code{replace}.
17315 @end table
17316
17317 @section aphasemeter
17318
17319 Convert input audio to a video output, displaying the audio phase.
17320
17321 The filter accepts the following options:
17322
17323 @table @option
17324 @item rate, r
17325 Set the output frame rate. Default value is @code{25}.
17326
17327 @item size, s
17328 Set the video size for the output. For the syntax of this option, check the
17329 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
17330 Default value is @code{800x400}.
17331
17332 @item rc
17333 @item gc
17334 @item bc
17335 Specify the red, green, blue contrast. Default values are @code{2},
17336 @code{7} and @code{1}.
17337 Allowed range is @code{[0, 255]}.
17338
17339 @item mpc
17340 Set color which will be used for drawing median phase. If color is
17341 @code{none} which is default, no median phase value will be drawn.
17342
17343 @item video
17344 Enable video output. Default is enabled.
17345 @end table
17346
17347 The filter also exports the frame metadata @code{lavfi.aphasemeter.phase} which
17348 represents mean phase of current audio frame. Value is in range @code{[-1, 1]}.
17349 The @code{-1} means left and right channels are completely out of phase and
17350 @code{1} means channels are in phase.
17351
17352 @section avectorscope
17353
17354 Convert input audio to a video output, representing the audio vector
17355 scope.
17356
17357 The filter is used to measure the difference between channels of stereo
17358 audio stream. A monoaural signal, consisting of identical left and right
17359 signal, results in straight vertical line. Any stereo separation is visible
17360 as a deviation from this line, creating a Lissajous figure.
17361 If the straight (or deviation from it) but horizontal line appears this
17362 indicates that the left and right channels are out of phase.
17363
17364 The filter accepts the following options:
17365
17366 @table @option
17367 @item mode, m
17368 Set the vectorscope mode.
17369
17370 Available values are:
17371 @table @samp
17372 @item lissajous
17373 Lissajous rotated by 45 degrees.
17374
17375 @item lissajous_xy
17376 Same as above but not rotated.
17377
17378 @item polar
17379 Shape resembling half of circle.
17380 @end table
17381
17382 Default value is @samp{lissajous}.
17383
17384 @item size, s
17385 Set the video size for the output. For the syntax of this option, check the
17386 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
17387 Default value is @code{400x400}.
17388
17389 @item rate, r
17390 Set the output frame rate. Default value is @code{25}.
17391
17392 @item rc
17393 @item gc
17394 @item bc
17395 @item ac
17396 Specify the red, green, blue and alpha contrast. Default values are @code{40},
17397 @code{160}, @code{80} and @code{255}.
17398 Allowed range is @code{[0, 255]}.
17399
17400 @item rf
17401 @item gf
17402 @item bf
17403 @item af
17404 Specify the red, green, blue and alpha fade. Default values are @code{15},
17405 @code{10}, @code{5} and @code{5}.
17406 Allowed range is @code{[0, 255]}.
17407
17408 @item zoom
17409 Set the zoom factor. Default value is @code{1}. Allowed range is @code{[0, 10]}.
17410 Values lower than @var{1} will auto adjust zoom factor to maximal possible value.
17411
17412 @item draw
17413 Set the vectorscope drawing mode.
17414
17415 Available values are:
17416 @table @samp
17417 @item dot
17418 Draw dot for each sample.
17419
17420 @item line
17421 Draw line between previous and current sample.
17422 @end table
17423
17424 Default value is @samp{dot}.
17425
17426 @item scale
17427 Specify amplitude scale of audio samples.
17428
17429 Available values are:
17430 @table @samp
17431 @item lin
17432 Linear.
17433
17434 @item sqrt
17435 Square root.
17436
17437 @item cbrt
17438 Cubic root.
17439
17440 @item log
17441 Logarithmic.
17442 @end table
17443
17444 @item swap
17445 Swap left channel axis with right channel axis.
17446
17447 @item mirror
17448 Mirror axis.
17449
17450 @table @samp
17451 @item none
17452 No mirror.
17453
17454 @item x
17455 Mirror only x axis.
17456
17457 @item y
17458 Mirror only y axis.
17459
17460 @item xy
17461 Mirror both axis.
17462 @end table
17463
17464 @end table
17465
17466 @subsection Examples
17467
17468 @itemize
17469 @item
17470 Complete example using @command{ffplay}:
17471 @example
17472 ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
17473              [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
17474 @end example
17475 @end itemize
17476
17477 @section bench, abench
17478
17479 Benchmark part of a filtergraph.
17480
17481 The filter accepts the following options:
17482
17483 @table @option
17484 @item action
17485 Start or stop a timer.
17486
17487 Available values are:
17488 @table @samp
17489 @item start
17490 Get the current time, set it as frame metadata (using the key
17491 @code{lavfi.bench.start_time}), and forward the frame to the next filter.
17492
17493 @item stop
17494 Get the current time and fetch the @code{lavfi.bench.start_time} metadata from
17495 the input frame metadata to get the time difference. Time difference, average,
17496 maximum and minimum time (respectively @code{t}, @code{avg}, @code{max} and
17497 @code{min}) are then printed. The timestamps are expressed in seconds.
17498 @end table
17499 @end table
17500
17501 @subsection Examples
17502
17503 @itemize
17504 @item
17505 Benchmark @ref{selectivecolor} filter:
17506 @example
17507 bench=start,selectivecolor=reds=-.2 .12 -.49,bench=stop
17508 @end example
17509 @end itemize
17510
17511 @section concat
17512
17513 Concatenate audio and video streams, joining them together one after the
17514 other.
17515
17516 The filter works on segments of synchronized video and audio streams. All
17517 segments must have the same number of streams of each type, and that will
17518 also be the number of streams at output.
17519
17520 The filter accepts the following options:
17521
17522 @table @option
17523
17524 @item n
17525 Set the number of segments. Default is 2.
17526
17527 @item v
17528 Set the number of output video streams, that is also the number of video
17529 streams in each segment. Default is 1.
17530
17531 @item a
17532 Set the number of output audio streams, that is also the number of audio
17533 streams in each segment. Default is 0.
17534
17535 @item unsafe
17536 Activate unsafe mode: do not fail if segments have a different format.
17537
17538 @end table
17539
17540 The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
17541 @var{a} audio outputs.
17542
17543 There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
17544 segment, in the same order as the outputs, then the inputs for the second
17545 segment, etc.
17546
17547 Related streams do not always have exactly the same duration, for various
17548 reasons including codec frame size or sloppy authoring. For that reason,
17549 related synchronized streams (e.g. a video and its audio track) should be
17550 concatenated at once. The concat filter will use the duration of the longest
17551 stream in each segment (except the last one), and if necessary pad shorter
17552 audio streams with silence.
17553
17554 For this filter to work correctly, all segments must start at timestamp 0.
17555
17556 All corresponding streams must have the same parameters in all segments; the
17557 filtering system will automatically select a common pixel format for video
17558 streams, and a common sample format, sample rate and channel layout for
17559 audio streams, but other settings, such as resolution, must be converted
17560 explicitly by the user.
17561
17562 Different frame rates are acceptable but will result in variable frame rate
17563 at output; be sure to configure the output file to handle it.
17564
17565 @subsection Examples
17566
17567 @itemize
17568 @item
17569 Concatenate an opening, an episode and an ending, all in bilingual version
17570 (video in stream 0, audio in streams 1 and 2):
17571 @example
17572 ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
17573   '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
17574    concat=n=3:v=1:a=2 [v] [a1] [a2]' \
17575   -map '[v]' -map '[a1]' -map '[a2]' output.mkv
17576 @end example
17577
17578 @item
17579 Concatenate two parts, handling audio and video separately, using the
17580 (a)movie sources, and adjusting the resolution:
17581 @example
17582 movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
17583 movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
17584 [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
17585 @end example
17586 Note that a desync will happen at the stitch if the audio and video streams
17587 do not have exactly the same duration in the first file.
17588
17589 @end itemize
17590
17591 @section drawgraph, adrawgraph
17592
17593 Draw a graph using input video or audio metadata.
17594
17595 It accepts the following parameters:
17596
17597 @table @option
17598 @item m1
17599 Set 1st frame metadata key from which metadata values will be used to draw a graph.
17600
17601 @item fg1
17602 Set 1st foreground color expression.
17603
17604 @item m2
17605 Set 2nd frame metadata key from which metadata values will be used to draw a graph.
17606
17607 @item fg2
17608 Set 2nd foreground color expression.
17609
17610 @item m3
17611 Set 3rd frame metadata key from which metadata values will be used to draw a graph.
17612
17613 @item fg3
17614 Set 3rd foreground color expression.
17615
17616 @item m4
17617 Set 4th frame metadata key from which metadata values will be used to draw a graph.
17618
17619 @item fg4
17620 Set 4th foreground color expression.
17621
17622 @item min
17623 Set minimal value of metadata value.
17624
17625 @item max
17626 Set maximal value of metadata value.
17627
17628 @item bg
17629 Set graph background color. Default is white.
17630
17631 @item mode
17632 Set graph mode.
17633
17634 Available values for mode is:
17635 @table @samp
17636 @item bar
17637 @item dot
17638 @item line
17639 @end table
17640
17641 Default is @code{line}.
17642
17643 @item slide
17644 Set slide mode.
17645
17646 Available values for slide is:
17647 @table @samp
17648 @item frame
17649 Draw new frame when right border is reached.
17650
17651 @item replace
17652 Replace old columns with new ones.
17653
17654 @item scroll
17655 Scroll from right to left.
17656
17657 @item rscroll
17658 Scroll from left to right.
17659
17660 @item picture
17661 Draw single picture.
17662 @end table
17663
17664 Default is @code{frame}.
17665
17666 @item size
17667 Set size of graph video. For the syntax of this option, check the
17668 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
17669 The default value is @code{900x256}.
17670
17671 The foreground color expressions can use the following variables:
17672 @table @option
17673 @item MIN
17674 Minimal value of metadata value.
17675
17676 @item MAX
17677 Maximal value of metadata value.
17678
17679 @item VAL
17680 Current metadata key value.
17681 @end table
17682
17683 The color is defined as 0xAABBGGRR.
17684 @end table
17685
17686 Example using metadata from @ref{signalstats} filter:
17687 @example
17688 signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255
17689 @end example
17690
17691 Example using metadata from @ref{ebur128} filter:
17692 @example
17693 ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5
17694 @end example
17695
17696 @anchor{ebur128}
17697 @section ebur128
17698
17699 EBU R128 scanner filter. This filter takes an audio stream as input and outputs
17700 it unchanged. By default, it logs a message at a frequency of 10Hz with the
17701 Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
17702 Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
17703
17704 The filter also has a video output (see the @var{video} option) with a real
17705 time graph to observe the loudness evolution. The graphic contains the logged
17706 message mentioned above, so it is not printed anymore when this option is set,
17707 unless the verbose logging is set. The main graphing area contains the
17708 short-term loudness (3 seconds of analysis), and the gauge on the right is for
17709 the momentary loudness (400 milliseconds).
17710
17711 More information about the Loudness Recommendation EBU R128 on
17712 @url{http://tech.ebu.ch/loudness}.
17713
17714 The filter accepts the following options:
17715
17716 @table @option
17717
17718 @item video
17719 Activate the video output. The audio stream is passed unchanged whether this
17720 option is set or no. The video stream will be the first output stream if
17721 activated. Default is @code{0}.
17722
17723 @item size
17724 Set the video size. This option is for video only. For the syntax of this
17725 option, check the
17726 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
17727 Default and minimum resolution is @code{640x480}.
17728
17729 @item meter
17730 Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
17731 @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
17732 other integer value between this range is allowed.
17733
17734 @item metadata
17735 Set metadata injection. If set to @code{1}, the audio input will be segmented
17736 into 100ms output frames, each of them containing various loudness information
17737 in metadata.  All the metadata keys are prefixed with @code{lavfi.r128.}.
17738
17739 Default is @code{0}.
17740
17741 @item framelog
17742 Force the frame logging level.
17743
17744 Available values are:
17745 @table @samp
17746 @item info
17747 information logging level
17748 @item verbose
17749 verbose logging level
17750 @end table
17751
17752 By default, the logging level is set to @var{info}. If the @option{video} or
17753 the @option{metadata} options are set, it switches to @var{verbose}.
17754
17755 @item peak
17756 Set peak mode(s).
17757
17758 Available modes can be cumulated (the option is a @code{flag} type). Possible
17759 values are:
17760 @table @samp
17761 @item none
17762 Disable any peak mode (default).
17763 @item sample
17764 Enable sample-peak mode.
17765
17766 Simple peak mode looking for the higher sample value. It logs a message
17767 for sample-peak (identified by @code{SPK}).
17768 @item true
17769 Enable true-peak mode.
17770
17771 If enabled, the peak lookup is done on an over-sampled version of the input
17772 stream for better peak accuracy. It logs a message for true-peak.
17773 (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
17774 This mode requires a build with @code{libswresample}.
17775 @end table
17776
17777 @item dualmono
17778 Treat mono input files as "dual mono". If a mono file is intended for playback
17779 on a stereo system, its EBU R128 measurement will be perceptually incorrect.
17780 If set to @code{true}, this option will compensate for this effect.
17781 Multi-channel input files are not affected by this option.
17782
17783 @item panlaw
17784 Set a specific pan law to be used for the measurement of dual mono files.
17785 This parameter is optional, and has a default value of -3.01dB.
17786 @end table
17787
17788 @subsection Examples
17789
17790 @itemize
17791 @item
17792 Real-time graph using @command{ffplay}, with a EBU scale meter +18:
17793 @example
17794 ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
17795 @end example
17796
17797 @item
17798 Run an analysis with @command{ffmpeg}:
17799 @example
17800 ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
17801 @end example
17802 @end itemize
17803
17804 @section interleave, ainterleave
17805
17806 Temporally interleave frames from several inputs.
17807
17808 @code{interleave} works with video inputs, @code{ainterleave} with audio.
17809
17810 These filters read frames from several inputs and send the oldest
17811 queued frame to the output.
17812
17813 Input streams must have well defined, monotonically increasing frame
17814 timestamp values.
17815
17816 In order to submit one frame to output, these filters need to enqueue
17817 at least one frame for each input, so they cannot work in case one
17818 input is not yet terminated and will not receive incoming frames.
17819
17820 For example consider the case when one input is a @code{select} filter
17821 which always drops input frames. The @code{interleave} filter will keep
17822 reading from that input, but it will never be able to send new frames
17823 to output until the input sends an end-of-stream signal.
17824
17825 Also, depending on inputs synchronization, the filters will drop
17826 frames in case one input receives more frames than the other ones, and
17827 the queue is already filled.
17828
17829 These filters accept the following options:
17830
17831 @table @option
17832 @item nb_inputs, n
17833 Set the number of different inputs, it is 2 by default.
17834 @end table
17835
17836 @subsection Examples
17837
17838 @itemize
17839 @item
17840 Interleave frames belonging to different streams using @command{ffmpeg}:
17841 @example
17842 ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
17843 @end example
17844
17845 @item
17846 Add flickering blur effect:
17847 @example
17848 select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
17849 @end example
17850 @end itemize
17851
17852 @section metadata, ametadata
17853
17854 Manipulate frame metadata.
17855
17856 This filter accepts the following options:
17857
17858 @table @option
17859 @item mode
17860 Set mode of operation of the filter.
17861
17862 Can be one of the following:
17863
17864 @table @samp
17865 @item select
17866 If both @code{value} and @code{key} is set, select frames
17867 which have such metadata. If only @code{key} is set, select
17868 every frame that has such key in metadata.
17869
17870 @item add
17871 Add new metadata @code{key} and @code{value}. If key is already available
17872 do nothing.
17873
17874 @item modify
17875 Modify value of already present key.
17876
17877 @item delete
17878 If @code{value} is set, delete only keys that have such value.
17879 Otherwise, delete key. If @code{key} is not set, delete all metadata values in
17880 the frame.
17881
17882 @item print
17883 Print key and its value if metadata was found. If @code{key} is not set print all
17884 metadata values available in frame.
17885 @end table
17886
17887 @item key
17888 Set key used with all modes. Must be set for all modes except @code{print} and @code{delete}.
17889
17890 @item value
17891 Set metadata value which will be used. This option is mandatory for
17892 @code{modify} and @code{add} mode.
17893
17894 @item function
17895 Which function to use when comparing metadata value and @code{value}.
17896
17897 Can be one of following:
17898
17899 @table @samp
17900 @item same_str
17901 Values are interpreted as strings, returns true if metadata value is same as @code{value}.
17902
17903 @item starts_with
17904 Values are interpreted as strings, returns true if metadata value starts with
17905 the @code{value} option string.
17906
17907 @item less
17908 Values are interpreted as floats, returns true if metadata value is less than @code{value}.
17909
17910 @item equal
17911 Values are interpreted as floats, returns true if @code{value} is equal with metadata value.
17912
17913 @item greater
17914 Values are interpreted as floats, returns true if metadata value is greater than @code{value}.
17915
17916 @item expr
17917 Values are interpreted as floats, returns true if expression from option @code{expr}
17918 evaluates to true.
17919 @end table
17920
17921 @item expr
17922 Set expression which is used when @code{function} is set to @code{expr}.
17923 The expression is evaluated through the eval API and can contain the following
17924 constants:
17925
17926 @table @option
17927 @item VALUE1
17928 Float representation of @code{value} from metadata key.
17929
17930 @item VALUE2
17931 Float representation of @code{value} as supplied by user in @code{value} option.
17932 @end table
17933
17934 @item file
17935 If specified in @code{print} mode, output is written to the named file. Instead of
17936 plain filename any writable url can be specified. Filename ``-'' is a shorthand
17937 for standard output. If @code{file} option is not set, output is written to the log
17938 with AV_LOG_INFO loglevel.
17939
17940 @end table
17941
17942 @subsection Examples
17943
17944 @itemize
17945 @item
17946 Print all metadata values for frames with key @code{lavfi.signalstats.YDIF} with values
17947 between 0 and 1.
17948 @example
17949 signalstats,metadata=print:key=lavfi.signalstats.YDIF:value=0:function=expr:expr='between(VALUE1,0,1)'
17950 @end example
17951 @item
17952 Print silencedetect output to file @file{metadata.txt}.
17953 @example
17954 silencedetect,ametadata=mode=print:file=metadata.txt
17955 @end example
17956 @item
17957 Direct all metadata to a pipe with file descriptor 4.
17958 @example
17959 metadata=mode=print:file='pipe\:4'
17960 @end example
17961 @end itemize
17962
17963 @section perms, aperms
17964
17965 Set read/write permissions for the output frames.
17966
17967 These filters are mainly aimed at developers to test direct path in the
17968 following filter in the filtergraph.
17969
17970 The filters accept the following options:
17971
17972 @table @option
17973 @item mode
17974 Select the permissions mode.
17975
17976 It accepts the following values:
17977 @table @samp
17978 @item none
17979 Do nothing. This is the default.
17980 @item ro
17981 Set all the output frames read-only.
17982 @item rw
17983 Set all the output frames directly writable.
17984 @item toggle
17985 Make the frame read-only if writable, and writable if read-only.
17986 @item random
17987 Set each output frame read-only or writable randomly.
17988 @end table
17989
17990 @item seed
17991 Set the seed for the @var{random} mode, must be an integer included between
17992 @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
17993 @code{-1}, the filter will try to use a good random seed on a best effort
17994 basis.
17995 @end table
17996
17997 Note: in case of auto-inserted filter between the permission filter and the
17998 following one, the permission might not be received as expected in that
17999 following filter. Inserting a @ref{format} or @ref{aformat} filter before the
18000 perms/aperms filter can avoid this problem.
18001
18002 @section realtime, arealtime
18003
18004 Slow down filtering to match real time approximately.
18005
18006 These filters will pause the filtering for a variable amount of time to
18007 match the output rate with the input timestamps.
18008 They are similar to the @option{re} option to @code{ffmpeg}.
18009
18010 They accept the following options:
18011
18012 @table @option
18013 @item limit
18014 Time limit for the pauses. Any pause longer than that will be considered
18015 a timestamp discontinuity and reset the timer. Default is 2 seconds.
18016 @end table
18017
18018 @anchor{select}
18019 @section select, aselect
18020
18021 Select frames to pass in output.
18022
18023 This filter accepts the following options:
18024
18025 @table @option
18026
18027 @item expr, e
18028 Set expression, which is evaluated for each input frame.
18029
18030 If the expression is evaluated to zero, the frame is discarded.
18031
18032 If the evaluation result is negative or NaN, the frame is sent to the
18033 first output; otherwise it is sent to the output with index
18034 @code{ceil(val)-1}, assuming that the input index starts from 0.
18035
18036 For example a value of @code{1.2} corresponds to the output with index
18037 @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
18038
18039 @item outputs, n
18040 Set the number of outputs. The output to which to send the selected
18041 frame is based on the result of the evaluation. Default value is 1.
18042 @end table
18043
18044 The expression can contain the following constants:
18045
18046 @table @option
18047 @item n
18048 The (sequential) number of the filtered frame, starting from 0.
18049
18050 @item selected_n
18051 The (sequential) number of the selected frame, starting from 0.
18052
18053 @item prev_selected_n
18054 The sequential number of the last selected frame. It's NAN if undefined.
18055
18056 @item TB
18057 The timebase of the input timestamps.
18058
18059 @item pts
18060 The PTS (Presentation TimeStamp) of the filtered video frame,
18061 expressed in @var{TB} units. It's NAN if undefined.
18062
18063 @item t
18064 The PTS of the filtered video frame,
18065 expressed in seconds. It's NAN if undefined.
18066
18067 @item prev_pts
18068 The PTS of the previously filtered video frame. It's NAN if undefined.
18069
18070 @item prev_selected_pts
18071 The PTS of the last previously filtered video frame. It's NAN if undefined.
18072
18073 @item prev_selected_t
18074 The PTS of the last previously selected video frame, expressed in seconds. It's NAN if undefined.
18075
18076 @item start_pts
18077 The PTS of the first video frame in the video. It's NAN if undefined.
18078
18079 @item start_t
18080 The time of the first video frame in the video. It's NAN if undefined.
18081
18082 @item pict_type @emph{(video only)}
18083 The type of the filtered frame. It can assume one of the following
18084 values:
18085 @table @option
18086 @item I
18087 @item P
18088 @item B
18089 @item S
18090 @item SI
18091 @item SP
18092 @item BI
18093 @end table
18094
18095 @item interlace_type @emph{(video only)}
18096 The frame interlace type. It can assume one of the following values:
18097 @table @option
18098 @item PROGRESSIVE
18099 The frame is progressive (not interlaced).
18100 @item TOPFIRST
18101 The frame is top-field-first.
18102 @item BOTTOMFIRST
18103 The frame is bottom-field-first.
18104 @end table
18105
18106 @item consumed_sample_n @emph{(audio only)}
18107 the number of selected samples before the current frame
18108
18109 @item samples_n @emph{(audio only)}
18110 the number of samples in the current frame
18111
18112 @item sample_rate @emph{(audio only)}
18113 the input sample rate
18114
18115 @item key
18116 This is 1 if the filtered frame is a key-frame, 0 otherwise.
18117
18118 @item pos
18119 the position in the file of the filtered frame, -1 if the information
18120 is not available (e.g. for synthetic video)
18121
18122 @item scene @emph{(video only)}
18123 value between 0 and 1 to indicate a new scene; a low value reflects a low
18124 probability for the current frame to introduce a new scene, while a higher
18125 value means the current frame is more likely to be one (see the example below)
18126
18127 @item concatdec_select
18128 The concat demuxer can select only part of a concat input file by setting an
18129 inpoint and an outpoint, but the output packets may not be entirely contained
18130 in the selected interval. By using this variable, it is possible to skip frames
18131 generated by the concat demuxer which are not exactly contained in the selected
18132 interval.
18133
18134 This works by comparing the frame pts against the @var{lavf.concat.start_time}
18135 and the @var{lavf.concat.duration} packet metadata values which are also
18136 present in the decoded frames.
18137
18138 The @var{concatdec_select} variable is -1 if the frame pts is at least
18139 start_time and either the duration metadata is missing or the frame pts is less
18140 than start_time + duration, 0 otherwise, and NaN if the start_time metadata is
18141 missing.
18142
18143 That basically means that an input frame is selected if its pts is within the
18144 interval set by the concat demuxer.
18145
18146 @end table
18147
18148 The default value of the select expression is "1".
18149
18150 @subsection Examples
18151
18152 @itemize
18153 @item
18154 Select all frames in input:
18155 @example
18156 select
18157 @end example
18158
18159 The example above is the same as:
18160 @example
18161 select=1
18162 @end example
18163
18164 @item
18165 Skip all frames:
18166 @example
18167 select=0
18168 @end example
18169
18170 @item
18171 Select only I-frames:
18172 @example
18173 select='eq(pict_type\,I)'
18174 @end example
18175
18176 @item
18177 Select one frame every 100:
18178 @example
18179 select='not(mod(n\,100))'
18180 @end example
18181
18182 @item
18183 Select only frames contained in the 10-20 time interval:
18184 @example
18185 select=between(t\,10\,20)
18186 @end example
18187
18188 @item
18189 Select only I-frames contained in the 10-20 time interval:
18190 @example
18191 select=between(t\,10\,20)*eq(pict_type\,I)
18192 @end example
18193
18194 @item
18195 Select frames with a minimum distance of 10 seconds:
18196 @example
18197 select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
18198 @end example
18199
18200 @item
18201 Use aselect to select only audio frames with samples number > 100:
18202 @example
18203 aselect='gt(samples_n\,100)'
18204 @end example
18205
18206 @item
18207 Create a mosaic of the first scenes:
18208 @example
18209 ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
18210 @end example
18211
18212 Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
18213 choice.
18214
18215 @item
18216 Send even and odd frames to separate outputs, and compose them:
18217 @example
18218 select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
18219 @end example
18220
18221 @item
18222 Select useful frames from an ffconcat file which is using inpoints and
18223 outpoints but where the source files are not intra frame only.
18224 @example
18225 ffmpeg -copyts -vsync 0 -segment_time_metadata 1 -i input.ffconcat -vf select=concatdec_select -af aselect=concatdec_select output.avi
18226 @end example
18227 @end itemize
18228
18229 @section sendcmd, asendcmd
18230
18231 Send commands to filters in the filtergraph.
18232
18233 These filters read commands to be sent to other filters in the
18234 filtergraph.
18235
18236 @code{sendcmd} must be inserted between two video filters,
18237 @code{asendcmd} must be inserted between two audio filters, but apart
18238 from that they act the same way.
18239
18240 The specification of commands can be provided in the filter arguments
18241 with the @var{commands} option, or in a file specified by the
18242 @var{filename} option.
18243
18244 These filters accept the following options:
18245 @table @option
18246 @item commands, c
18247 Set the commands to be read and sent to the other filters.
18248 @item filename, f
18249 Set the filename of the commands to be read and sent to the other
18250 filters.
18251 @end table
18252
18253 @subsection Commands syntax
18254
18255 A commands description consists of a sequence of interval
18256 specifications, comprising a list of commands to be executed when a
18257 particular event related to that interval occurs. The occurring event
18258 is typically the current frame time entering or leaving a given time
18259 interval.
18260
18261 An interval is specified by the following syntax:
18262 @example
18263 @var{START}[-@var{END}] @var{COMMANDS};
18264 @end example
18265
18266 The time interval is specified by the @var{START} and @var{END} times.
18267 @var{END} is optional and defaults to the maximum time.
18268
18269 The current frame time is considered within the specified interval if
18270 it is included in the interval [@var{START}, @var{END}), that is when
18271 the time is greater or equal to @var{START} and is lesser than
18272 @var{END}.
18273
18274 @var{COMMANDS} consists of a sequence of one or more command
18275 specifications, separated by ",", relating to that interval.  The
18276 syntax of a command specification is given by:
18277 @example
18278 [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
18279 @end example
18280
18281 @var{FLAGS} is optional and specifies the type of events relating to
18282 the time interval which enable sending the specified command, and must
18283 be a non-null sequence of identifier flags separated by "+" or "|" and
18284 enclosed between "[" and "]".
18285
18286 The following flags are recognized:
18287 @table @option
18288 @item enter
18289 The command is sent when the current frame timestamp enters the
18290 specified interval. In other words, the command is sent when the
18291 previous frame timestamp was not in the given interval, and the
18292 current is.
18293
18294 @item leave
18295 The command is sent when the current frame timestamp leaves the
18296 specified interval. In other words, the command is sent when the
18297 previous frame timestamp was in the given interval, and the
18298 current is not.
18299 @end table
18300
18301 If @var{FLAGS} is not specified, a default value of @code{[enter]} is
18302 assumed.
18303
18304 @var{TARGET} specifies the target of the command, usually the name of
18305 the filter class or a specific filter instance name.
18306
18307 @var{COMMAND} specifies the name of the command for the target filter.
18308
18309 @var{ARG} is optional and specifies the optional list of argument for
18310 the given @var{COMMAND}.
18311
18312 Between one interval specification and another, whitespaces, or
18313 sequences of characters starting with @code{#} until the end of line,
18314 are ignored and can be used to annotate comments.
18315
18316 A simplified BNF description of the commands specification syntax
18317 follows:
18318 @example
18319 @var{COMMAND_FLAG}  ::= "enter" | "leave"
18320 @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
18321 @var{COMMAND}       ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
18322 @var{COMMANDS}      ::= @var{COMMAND} [,@var{COMMANDS}]
18323 @var{INTERVAL}      ::= @var{START}[-@var{END}] @var{COMMANDS}
18324 @var{INTERVALS}     ::= @var{INTERVAL}[;@var{INTERVALS}]
18325 @end example
18326
18327 @subsection Examples
18328
18329 @itemize
18330 @item
18331 Specify audio tempo change at second 4:
18332 @example
18333 asendcmd=c='4.0 atempo tempo 1.5',atempo
18334 @end example
18335
18336 @item
18337 Target a specific filter instance:
18338 @example
18339 asendcmd=c='4.0 atempo@@my tempo 1.5',atempo@@my
18340 @end example
18341
18342 @item
18343 Specify a list of drawtext and hue commands in a file.
18344 @example
18345 # show text in the interval 5-10
18346 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
18347          [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
18348
18349 # desaturate the image in the interval 15-20
18350 15.0-20.0 [enter] hue s 0,
18351           [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
18352           [leave] hue s 1,
18353           [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
18354
18355 # apply an exponential saturation fade-out effect, starting from time 25
18356 25 [enter] hue s exp(25-t)
18357 @end example
18358
18359 A filtergraph allowing to read and process the above command list
18360 stored in a file @file{test.cmd}, can be specified with:
18361 @example
18362 sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
18363 @end example
18364 @end itemize
18365
18366 @anchor{setpts}
18367 @section setpts, asetpts
18368
18369 Change the PTS (presentation timestamp) of the input frames.
18370
18371 @code{setpts} works on video frames, @code{asetpts} on audio frames.
18372
18373 This filter accepts the following options:
18374
18375 @table @option
18376
18377 @item expr
18378 The expression which is evaluated for each frame to construct its timestamp.
18379
18380 @end table
18381
18382 The expression is evaluated through the eval API and can contain the following
18383 constants:
18384
18385 @table @option
18386 @item FRAME_RATE
18387 frame rate, only defined for constant frame-rate video
18388
18389 @item PTS
18390 The presentation timestamp in input
18391
18392 @item N
18393 The count of the input frame for video or the number of consumed samples,
18394 not including the current frame for audio, starting from 0.
18395
18396 @item NB_CONSUMED_SAMPLES
18397 The number of consumed samples, not including the current frame (only
18398 audio)
18399
18400 @item NB_SAMPLES, S
18401 The number of samples in the current frame (only audio)
18402
18403 @item SAMPLE_RATE, SR
18404 The audio sample rate.
18405
18406 @item STARTPTS
18407 The PTS of the first frame.
18408
18409 @item STARTT
18410 the time in seconds of the first frame
18411
18412 @item INTERLACED
18413 State whether the current frame is interlaced.
18414
18415 @item T
18416 the time in seconds of the current frame
18417
18418 @item POS
18419 original position in the file of the frame, or undefined if undefined
18420 for the current frame
18421
18422 @item PREV_INPTS
18423 The previous input PTS.
18424
18425 @item PREV_INT
18426 previous input time in seconds
18427
18428 @item PREV_OUTPTS
18429 The previous output PTS.
18430
18431 @item PREV_OUTT
18432 previous output time in seconds
18433
18434 @item RTCTIME
18435 The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
18436 instead.
18437
18438 @item RTCSTART
18439 The wallclock (RTC) time at the start of the movie in microseconds.
18440
18441 @item TB
18442 The timebase of the input timestamps.
18443
18444 @end table
18445
18446 @subsection Examples
18447
18448 @itemize
18449 @item
18450 Start counting PTS from zero
18451 @example
18452 setpts=PTS-STARTPTS
18453 @end example
18454
18455 @item
18456 Apply fast motion effect:
18457 @example
18458 setpts=0.5*PTS
18459 @end example
18460
18461 @item
18462 Apply slow motion effect:
18463 @example
18464 setpts=2.0*PTS
18465 @end example
18466
18467 @item
18468 Set fixed rate of 25 frames per second:
18469 @example
18470 setpts=N/(25*TB)
18471 @end example
18472
18473 @item
18474 Set fixed rate 25 fps with some jitter:
18475 @example
18476 setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
18477 @end example
18478
18479 @item
18480 Apply an offset of 10 seconds to the input PTS:
18481 @example
18482 setpts=PTS+10/TB
18483 @end example
18484
18485 @item
18486 Generate timestamps from a "live source" and rebase onto the current timebase:
18487 @example
18488 setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
18489 @end example
18490
18491 @item
18492 Generate timestamps by counting samples:
18493 @example
18494 asetpts=N/SR/TB
18495 @end example
18496
18497 @end itemize
18498
18499 @section settb, asettb
18500
18501 Set the timebase to use for the output frames timestamps.
18502 It is mainly useful for testing timebase configuration.
18503
18504 It accepts the following parameters:
18505
18506 @table @option
18507
18508 @item expr, tb
18509 The expression which is evaluated into the output timebase.
18510
18511 @end table
18512
18513 The value for @option{tb} is an arithmetic expression representing a
18514 rational. The expression can contain the constants "AVTB" (the default
18515 timebase), "intb" (the input timebase) and "sr" (the sample rate,
18516 audio only). Default value is "intb".
18517
18518 @subsection Examples
18519
18520 @itemize
18521 @item
18522 Set the timebase to 1/25:
18523 @example
18524 settb=expr=1/25
18525 @end example
18526
18527 @item
18528 Set the timebase to 1/10:
18529 @example
18530 settb=expr=0.1
18531 @end example
18532
18533 @item
18534 Set the timebase to 1001/1000:
18535 @example
18536 settb=1+0.001
18537 @end example
18538
18539 @item
18540 Set the timebase to 2*intb:
18541 @example
18542 settb=2*intb
18543 @end example
18544
18545 @item
18546 Set the default timebase value:
18547 @example
18548 settb=AVTB
18549 @end example
18550 @end itemize
18551
18552 @section showcqt
18553 Convert input audio to a video output representing frequency spectrum
18554 logarithmically using Brown-Puckette constant Q transform algorithm with
18555 direct frequency domain coefficient calculation (but the transform itself
18556 is not really constant Q, instead the Q factor is actually variable/clamped),
18557 with musical tone scale, from E0 to D#10.
18558
18559 The filter accepts the following options:
18560
18561 @table @option
18562 @item size, s
18563 Specify the video size for the output. It must be even. For the syntax of this option,
18564 check the @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
18565 Default value is @code{1920x1080}.
18566
18567 @item fps, rate, r
18568 Set the output frame rate. Default value is @code{25}.
18569
18570 @item bar_h
18571 Set the bargraph height. It must be even. Default value is @code{-1} which
18572 computes the bargraph height automatically.
18573
18574 @item axis_h
18575 Set the axis height. It must be even. Default value is @code{-1} which computes
18576 the axis height automatically.
18577
18578 @item sono_h
18579 Set the sonogram height. It must be even. Default value is @code{-1} which
18580 computes the sonogram height automatically.
18581
18582 @item fullhd
18583 Set the fullhd resolution. This option is deprecated, use @var{size}, @var{s}
18584 instead. Default value is @code{1}.
18585
18586 @item sono_v, volume
18587 Specify the sonogram volume expression. It can contain variables:
18588 @table @option
18589 @item bar_v
18590 the @var{bar_v} evaluated expression
18591 @item frequency, freq, f
18592 the frequency where it is evaluated
18593 @item timeclamp, tc
18594 the value of @var{timeclamp} option
18595 @end table
18596 and functions:
18597 @table @option
18598 @item a_weighting(f)
18599 A-weighting of equal loudness
18600 @item b_weighting(f)
18601 B-weighting of equal loudness
18602 @item c_weighting(f)
18603 C-weighting of equal loudness.
18604 @end table
18605 Default value is @code{16}.
18606
18607 @item bar_v, volume2
18608 Specify the bargraph volume expression. It can contain variables:
18609 @table @option
18610 @item sono_v
18611 the @var{sono_v} evaluated expression
18612 @item frequency, freq, f
18613 the frequency where it is evaluated
18614 @item timeclamp, tc
18615 the value of @var{timeclamp} option
18616 @end table
18617 and functions:
18618 @table @option
18619 @item a_weighting(f)
18620 A-weighting of equal loudness
18621 @item b_weighting(f)
18622 B-weighting of equal loudness
18623 @item c_weighting(f)
18624 C-weighting of equal loudness.
18625 @end table
18626 Default value is @code{sono_v}.
18627
18628 @item sono_g, gamma
18629 Specify the sonogram gamma. Lower gamma makes the spectrum more contrast,
18630 higher gamma makes the spectrum having more range. Default value is @code{3}.
18631 Acceptable range is @code{[1, 7]}.
18632
18633 @item bar_g, gamma2
18634 Specify the bargraph gamma. Default value is @code{1}. Acceptable range is
18635 @code{[1, 7]}.
18636
18637 @item bar_t
18638 Specify the bargraph transparency level. Lower value makes the bargraph sharper.
18639 Default value is @code{1}. Acceptable range is @code{[0, 1]}.
18640
18641 @item timeclamp, tc
18642 Specify the transform timeclamp. At low frequency, there is trade-off between
18643 accuracy in time domain and frequency domain. If timeclamp is lower,
18644 event in time domain is represented more accurately (such as fast bass drum),
18645 otherwise event in frequency domain is represented more accurately
18646 (such as bass guitar). Acceptable range is @code{[0.002, 1]}. Default value is @code{0.17}.
18647
18648 @item attack
18649 Set attack time in seconds. The default is @code{0} (disabled). Otherwise, it
18650 limits future samples by applying asymmetric windowing in time domain, useful
18651 when low latency is required. Accepted range is @code{[0, 1]}.
18652
18653 @item basefreq
18654 Specify the transform base frequency. Default value is @code{20.01523126408007475},
18655 which is frequency 50 cents below E0. Acceptable range is @code{[10, 100000]}.
18656
18657 @item endfreq
18658 Specify the transform end frequency. Default value is @code{20495.59681441799654},
18659 which is frequency 50 cents above D#10. Acceptable range is @code{[10, 100000]}.
18660
18661 @item coeffclamp
18662 This option is deprecated and ignored.
18663
18664 @item tlength
18665 Specify the transform length in time domain. Use this option to control accuracy
18666 trade-off between time domain and frequency domain at every frequency sample.
18667 It can contain variables:
18668 @table @option
18669 @item frequency, freq, f
18670 the frequency where it is evaluated
18671 @item timeclamp, tc
18672 the value of @var{timeclamp} option.
18673 @end table
18674 Default value is @code{384*tc/(384+tc*f)}.
18675
18676 @item count
18677 Specify the transform count for every video frame. Default value is @code{6}.
18678 Acceptable range is @code{[1, 30]}.
18679
18680 @item fcount
18681 Specify the transform count for every single pixel. Default value is @code{0},
18682 which makes it computed automatically. Acceptable range is @code{[0, 10]}.
18683
18684 @item fontfile
18685 Specify font file for use with freetype to draw the axis. If not specified,
18686 use embedded font. Note that drawing with font file or embedded font is not
18687 implemented with custom @var{basefreq} and @var{endfreq}, use @var{axisfile}
18688 option instead.
18689
18690 @item font
18691 Specify fontconfig pattern. This has lower priority than @var{fontfile}.
18692 The : in the pattern may be replaced by | to avoid unnecessary escaping.
18693
18694 @item fontcolor
18695 Specify font color expression. This is arithmetic expression that should return
18696 integer value 0xRRGGBB. It can contain variables:
18697 @table @option
18698 @item frequency, freq, f
18699 the frequency where it is evaluated
18700 @item timeclamp, tc
18701 the value of @var{timeclamp} option
18702 @end table
18703 and functions:
18704 @table @option
18705 @item midi(f)
18706 midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
18707 @item r(x), g(x), b(x)
18708 red, green, and blue value of intensity x.
18709 @end table
18710 Default value is @code{st(0, (midi(f)-59.5)/12);
18711 st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
18712 r(1-ld(1)) + b(ld(1))}.
18713
18714 @item axisfile
18715 Specify image file to draw the axis. This option override @var{fontfile} and
18716 @var{fontcolor} option.
18717
18718 @item axis, text
18719 Enable/disable drawing text to the axis. If it is set to @code{0}, drawing to
18720 the axis is disabled, ignoring @var{fontfile} and @var{axisfile} option.
18721 Default value is @code{1}.
18722
18723 @item csp
18724 Set colorspace. The accepted values are:
18725 @table @samp
18726 @item unspecified
18727 Unspecified (default)
18728
18729 @item bt709
18730 BT.709
18731
18732 @item fcc
18733 FCC
18734
18735 @item bt470bg
18736 BT.470BG or BT.601-6 625
18737
18738 @item smpte170m
18739 SMPTE-170M or BT.601-6 525
18740
18741 @item smpte240m
18742 SMPTE-240M
18743
18744 @item bt2020ncl
18745 BT.2020 with non-constant luminance
18746
18747 @end table
18748
18749 @item cscheme
18750 Set spectrogram color scheme. This is list of floating point values with format
18751 @code{left_r|left_g|left_b|right_r|right_g|right_b}.
18752 The default is @code{1|0.5|0|0|0.5|1}.
18753
18754 @end table
18755
18756 @subsection Examples
18757
18758 @itemize
18759 @item
18760 Playing audio while showing the spectrum:
18761 @example
18762 ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
18763 @end example
18764
18765 @item
18766 Same as above, but with frame rate 30 fps:
18767 @example
18768 ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
18769 @end example
18770
18771 @item
18772 Playing at 1280x720:
18773 @example
18774 ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=s=1280x720:count=4 [out0]'
18775 @end example
18776
18777 @item
18778 Disable sonogram display:
18779 @example
18780 sono_h=0
18781 @end example
18782
18783 @item
18784 A1 and its harmonics: A1, A2, (near)E3, A3:
18785 @example
18786 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),
18787                  asplit[a][out1]; [a] showcqt [out0]'
18788 @end example
18789
18790 @item
18791 Same as above, but with more accuracy in frequency domain:
18792 @example
18793 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),
18794                  asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
18795 @end example
18796
18797 @item
18798 Custom volume:
18799 @example
18800 bar_v=10:sono_v=bar_v*a_weighting(f)
18801 @end example
18802
18803 @item
18804 Custom gamma, now spectrum is linear to the amplitude.
18805 @example
18806 bar_g=2:sono_g=2
18807 @end example
18808
18809 @item
18810 Custom tlength equation:
18811 @example
18812 tc=0.33:tlength='st(0,0.17); 384*tc / (384 / ld(0) + tc*f /(1-ld(0))) + 384*tc / (tc*f / ld(0) + 384 /(1-ld(0)))'
18813 @end example
18814
18815 @item
18816 Custom fontcolor and fontfile, C-note is colored green, others are colored blue:
18817 @example
18818 fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))':fontfile=myfont.ttf
18819 @end example
18820
18821 @item
18822 Custom font using fontconfig:
18823 @example
18824 font='Courier New,Monospace,mono|bold'
18825 @end example
18826
18827 @item
18828 Custom frequency range with custom axis using image file:
18829 @example
18830 axisfile=myaxis.png:basefreq=40:endfreq=10000
18831 @end example
18832 @end itemize
18833
18834 @section showfreqs
18835
18836 Convert input audio to video output representing the audio power spectrum.
18837 Audio amplitude is on Y-axis while frequency is on X-axis.
18838
18839 The filter accepts the following options:
18840
18841 @table @option
18842 @item size, s
18843 Specify size of video. For the syntax of this option, check the
18844 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
18845 Default is @code{1024x512}.
18846
18847 @item mode
18848 Set display mode.
18849 This set how each frequency bin will be represented.
18850
18851 It accepts the following values:
18852 @table @samp
18853 @item line
18854 @item bar
18855 @item dot
18856 @end table
18857 Default is @code{bar}.
18858
18859 @item ascale
18860 Set amplitude scale.
18861
18862 It accepts the following values:
18863 @table @samp
18864 @item lin
18865 Linear scale.
18866
18867 @item sqrt
18868 Square root scale.
18869
18870 @item cbrt
18871 Cubic root scale.
18872
18873 @item log
18874 Logarithmic scale.
18875 @end table
18876 Default is @code{log}.
18877
18878 @item fscale
18879 Set frequency scale.
18880
18881 It accepts the following values:
18882 @table @samp
18883 @item lin
18884 Linear scale.
18885
18886 @item log
18887 Logarithmic scale.
18888
18889 @item rlog
18890 Reverse logarithmic scale.
18891 @end table
18892 Default is @code{lin}.
18893
18894 @item win_size
18895 Set window size.
18896
18897 It accepts the following values:
18898 @table @samp
18899 @item w16
18900 @item w32
18901 @item w64
18902 @item w128
18903 @item w256
18904 @item w512
18905 @item w1024
18906 @item w2048
18907 @item w4096
18908 @item w8192
18909 @item w16384
18910 @item w32768
18911 @item w65536
18912 @end table
18913 Default is @code{w2048}
18914
18915 @item win_func
18916 Set windowing function.
18917
18918 It accepts the following values:
18919 @table @samp
18920 @item rect
18921 @item bartlett
18922 @item hanning
18923 @item hamming
18924 @item blackman
18925 @item welch
18926 @item flattop
18927 @item bharris
18928 @item bnuttall
18929 @item bhann
18930 @item sine
18931 @item nuttall
18932 @item lanczos
18933 @item gauss
18934 @item tukey
18935 @item dolph
18936 @item cauchy
18937 @item parzen
18938 @item poisson
18939 @end table
18940 Default is @code{hanning}.
18941
18942 @item overlap
18943 Set window overlap. In range @code{[0, 1]}. Default is @code{1},
18944 which means optimal overlap for selected window function will be picked.
18945
18946 @item averaging
18947 Set time averaging. Setting this to 0 will display current maximal peaks.
18948 Default is @code{1}, which means time averaging is disabled.
18949
18950 @item colors
18951 Specify list of colors separated by space or by '|' which will be used to
18952 draw channel frequencies. Unrecognized or missing colors will be replaced
18953 by white color.
18954
18955 @item cmode
18956 Set channel display mode.
18957
18958 It accepts the following values:
18959 @table @samp
18960 @item combined
18961 @item separate
18962 @end table
18963 Default is @code{combined}.
18964
18965 @item minamp
18966 Set minimum amplitude used in @code{log} amplitude scaler.
18967
18968 @end table
18969
18970 @anchor{showspectrum}
18971 @section showspectrum
18972
18973 Convert input audio to a video output, representing the audio frequency
18974 spectrum.
18975
18976 The filter accepts the following options:
18977
18978 @table @option
18979 @item size, s
18980 Specify the video size for the output. For the syntax of this option, check the
18981 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
18982 Default value is @code{640x512}.
18983
18984 @item slide
18985 Specify how the spectrum should slide along the window.
18986
18987 It accepts the following values:
18988 @table @samp
18989 @item replace
18990 the samples start again on the left when they reach the right
18991 @item scroll
18992 the samples scroll from right to left
18993 @item fullframe
18994 frames are only produced when the samples reach the right
18995 @item rscroll
18996 the samples scroll from left to right
18997 @end table
18998
18999 Default value is @code{replace}.
19000
19001 @item mode
19002 Specify display mode.
19003
19004 It accepts the following values:
19005 @table @samp
19006 @item combined
19007 all channels are displayed in the same row
19008 @item separate
19009 all channels are displayed in separate rows
19010 @end table
19011
19012 Default value is @samp{combined}.
19013
19014 @item color
19015 Specify display color mode.
19016
19017 It accepts the following values:
19018 @table @samp
19019 @item channel
19020 each channel is displayed in a separate color
19021 @item intensity
19022 each channel is displayed using the same color scheme
19023 @item rainbow
19024 each channel is displayed using the rainbow color scheme
19025 @item moreland
19026 each channel is displayed using the moreland color scheme
19027 @item nebulae
19028 each channel is displayed using the nebulae color scheme
19029 @item fire
19030 each channel is displayed using the fire color scheme
19031 @item fiery
19032 each channel is displayed using the fiery color scheme
19033 @item fruit
19034 each channel is displayed using the fruit color scheme
19035 @item cool
19036 each channel is displayed using the cool color scheme
19037 @end table
19038
19039 Default value is @samp{channel}.
19040
19041 @item scale
19042 Specify scale used for calculating intensity color values.
19043
19044 It accepts the following values:
19045 @table @samp
19046 @item lin
19047 linear
19048 @item sqrt
19049 square root, default
19050 @item cbrt
19051 cubic root
19052 @item log
19053 logarithmic
19054 @item 4thrt
19055 4th root
19056 @item 5thrt
19057 5th root
19058 @end table
19059
19060 Default value is @samp{sqrt}.
19061
19062 @item saturation
19063 Set saturation modifier for displayed colors. Negative values provide
19064 alternative color scheme. @code{0} is no saturation at all.
19065 Saturation must be in [-10.0, 10.0] range.
19066 Default value is @code{1}.
19067
19068 @item win_func
19069 Set window function.
19070
19071 It accepts the following values:
19072 @table @samp
19073 @item rect
19074 @item bartlett
19075 @item hann
19076 @item hanning
19077 @item hamming
19078 @item blackman
19079 @item welch
19080 @item flattop
19081 @item bharris
19082 @item bnuttall
19083 @item bhann
19084 @item sine
19085 @item nuttall
19086 @item lanczos
19087 @item gauss
19088 @item tukey
19089 @item dolph
19090 @item cauchy
19091 @item parzen
19092 @item poisson
19093 @end table
19094
19095 Default value is @code{hann}.
19096
19097 @item orientation
19098 Set orientation of time vs frequency axis. Can be @code{vertical} or
19099 @code{horizontal}. Default is @code{vertical}.
19100
19101 @item overlap
19102 Set ratio of overlap window. Default value is @code{0}.
19103 When value is @code{1} overlap is set to recommended size for specific
19104 window function currently used.
19105
19106 @item gain
19107 Set scale gain for calculating intensity color values.
19108 Default value is @code{1}.
19109
19110 @item data
19111 Set which data to display. Can be @code{magnitude}, default or @code{phase}.
19112
19113 @item rotation
19114 Set color rotation, must be in [-1.0, 1.0] range.
19115 Default value is @code{0}.
19116 @end table
19117
19118 The usage is very similar to the showwaves filter; see the examples in that
19119 section.
19120
19121 @subsection Examples
19122
19123 @itemize
19124 @item
19125 Large window with logarithmic color scaling:
19126 @example
19127 showspectrum=s=1280x480:scale=log
19128 @end example
19129
19130 @item
19131 Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
19132 @example
19133 ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
19134              [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
19135 @end example
19136 @end itemize
19137
19138 @section showspectrumpic
19139
19140 Convert input audio to a single video frame, representing the audio frequency
19141 spectrum.
19142
19143 The filter accepts the following options:
19144
19145 @table @option
19146 @item size, s
19147 Specify the video size for the output. For the syntax of this option, check the
19148 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
19149 Default value is @code{4096x2048}.
19150
19151 @item mode
19152 Specify display mode.
19153
19154 It accepts the following values:
19155 @table @samp
19156 @item combined
19157 all channels are displayed in the same row
19158 @item separate
19159 all channels are displayed in separate rows
19160 @end table
19161 Default value is @samp{combined}.
19162
19163 @item color
19164 Specify display color mode.
19165
19166 It accepts the following values:
19167 @table @samp
19168 @item channel
19169 each channel is displayed in a separate color
19170 @item intensity
19171 each channel is displayed using the same color scheme
19172 @item rainbow
19173 each channel is displayed using the rainbow color scheme
19174 @item moreland
19175 each channel is displayed using the moreland color scheme
19176 @item nebulae
19177 each channel is displayed using the nebulae color scheme
19178 @item fire
19179 each channel is displayed using the fire color scheme
19180 @item fiery
19181 each channel is displayed using the fiery color scheme
19182 @item fruit
19183 each channel is displayed using the fruit color scheme
19184 @item cool
19185 each channel is displayed using the cool color scheme
19186 @end table
19187 Default value is @samp{intensity}.
19188
19189 @item scale
19190 Specify scale used for calculating intensity color values.
19191
19192 It accepts the following values:
19193 @table @samp
19194 @item lin
19195 linear
19196 @item sqrt
19197 square root, default
19198 @item cbrt
19199 cubic root
19200 @item log
19201 logarithmic
19202 @item 4thrt
19203 4th root
19204 @item 5thrt
19205 5th root
19206 @end table
19207 Default value is @samp{log}.
19208
19209 @item saturation
19210 Set saturation modifier for displayed colors. Negative values provide
19211 alternative color scheme. @code{0} is no saturation at all.
19212 Saturation must be in [-10.0, 10.0] range.
19213 Default value is @code{1}.
19214
19215 @item win_func
19216 Set window function.
19217
19218 It accepts the following values:
19219 @table @samp
19220 @item rect
19221 @item bartlett
19222 @item hann
19223 @item hanning
19224 @item hamming
19225 @item blackman
19226 @item welch
19227 @item flattop
19228 @item bharris
19229 @item bnuttall
19230 @item bhann
19231 @item sine
19232 @item nuttall
19233 @item lanczos
19234 @item gauss
19235 @item tukey
19236 @item dolph
19237 @item cauchy
19238 @item parzen
19239 @item poisson
19240 @end table
19241 Default value is @code{hann}.
19242
19243 @item orientation
19244 Set orientation of time vs frequency axis. Can be @code{vertical} or
19245 @code{horizontal}. Default is @code{vertical}.
19246
19247 @item gain
19248 Set scale gain for calculating intensity color values.
19249 Default value is @code{1}.
19250
19251 @item legend
19252 Draw time and frequency axes and legends. Default is enabled.
19253
19254 @item rotation
19255 Set color rotation, must be in [-1.0, 1.0] range.
19256 Default value is @code{0}.
19257 @end table
19258
19259 @subsection Examples
19260
19261 @itemize
19262 @item
19263 Extract an audio spectrogram of a whole audio track
19264 in a 1024x1024 picture using @command{ffmpeg}:
19265 @example
19266 ffmpeg -i audio.flac -lavfi showspectrumpic=s=1024x1024 spectrogram.png
19267 @end example
19268 @end itemize
19269
19270 @section showvolume
19271
19272 Convert input audio volume to a video output.
19273
19274 The filter accepts the following options:
19275
19276 @table @option
19277 @item rate, r
19278 Set video rate.
19279
19280 @item b
19281 Set border width, allowed range is [0, 5]. Default is 1.
19282
19283 @item w
19284 Set channel width, allowed range is [80, 8192]. Default is 400.
19285
19286 @item h
19287 Set channel height, allowed range is [1, 900]. Default is 20.
19288
19289 @item f
19290 Set fade, allowed range is [0.001, 1]. Default is 0.95.
19291
19292 @item c
19293 Set volume color expression.
19294
19295 The expression can use the following variables:
19296
19297 @table @option
19298 @item VOLUME
19299 Current max volume of channel in dB.
19300
19301 @item PEAK
19302 Current peak.
19303
19304 @item CHANNEL
19305 Current channel number, starting from 0.
19306 @end table
19307
19308 @item t
19309 If set, displays channel names. Default is enabled.
19310
19311 @item v
19312 If set, displays volume values. Default is enabled.
19313
19314 @item o
19315 Set orientation, can be @code{horizontal} or @code{vertical},
19316 default is @code{horizontal}.
19317
19318 @item s
19319 Set step size, allowed range s [0, 5]. Default is 0, which means
19320 step is disabled.
19321 @end table
19322
19323 @section showwaves
19324
19325 Convert input audio to a video output, representing the samples waves.
19326
19327 The filter accepts the following options:
19328
19329 @table @option
19330 @item size, s
19331 Specify the video size for the output. For the syntax of this option, check the
19332 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
19333 Default value is @code{600x240}.
19334
19335 @item mode
19336 Set display mode.
19337
19338 Available values are:
19339 @table @samp
19340 @item point
19341 Draw a point for each sample.
19342
19343 @item line
19344 Draw a vertical line for each sample.
19345
19346 @item p2p
19347 Draw a point for each sample and a line between them.
19348
19349 @item cline
19350 Draw a centered vertical line for each sample.
19351 @end table
19352
19353 Default value is @code{point}.
19354
19355 @item n
19356 Set the number of samples which are printed on the same column. A
19357 larger value will decrease the frame rate. Must be a positive
19358 integer. This option can be set only if the value for @var{rate}
19359 is not explicitly specified.
19360
19361 @item rate, r
19362 Set the (approximate) output frame rate. This is done by setting the
19363 option @var{n}. Default value is "25".
19364
19365 @item split_channels
19366 Set if channels should be drawn separately or overlap. Default value is 0.
19367
19368 @item colors
19369 Set colors separated by '|' which are going to be used for drawing of each channel.
19370
19371 @item scale
19372 Set amplitude scale.
19373
19374 Available values are:
19375 @table @samp
19376 @item lin
19377 Linear.
19378
19379 @item log
19380 Logarithmic.
19381
19382 @item sqrt
19383 Square root.
19384
19385 @item cbrt
19386 Cubic root.
19387 @end table
19388
19389 Default is linear.
19390 @end table
19391
19392 @subsection Examples
19393
19394 @itemize
19395 @item
19396 Output the input file audio and the corresponding video representation
19397 at the same time:
19398 @example
19399 amovie=a.mp3,asplit[out0],showwaves[out1]
19400 @end example
19401
19402 @item
19403 Create a synthetic signal and show it with showwaves, forcing a
19404 frame rate of 30 frames per second:
19405 @example
19406 aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
19407 @end example
19408 @end itemize
19409
19410 @section showwavespic
19411
19412 Convert input audio to a single video frame, representing the samples waves.
19413
19414 The filter accepts the following options:
19415
19416 @table @option
19417 @item size, s
19418 Specify the video size for the output. For the syntax of this option, check the
19419 @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
19420 Default value is @code{600x240}.
19421
19422 @item split_channels
19423 Set if channels should be drawn separately or overlap. Default value is 0.
19424
19425 @item colors
19426 Set colors separated by '|' which are going to be used for drawing of each channel.
19427
19428 @item scale
19429 Set amplitude scale.
19430
19431 Available values are:
19432 @table @samp
19433 @item lin
19434 Linear.
19435
19436 @item log
19437 Logarithmic.
19438
19439 @item sqrt
19440 Square root.
19441
19442 @item cbrt
19443 Cubic root.
19444 @end table
19445
19446 Default is linear.
19447 @end table
19448
19449 @subsection Examples
19450
19451 @itemize
19452 @item
19453 Extract a channel split representation of the wave form of a whole audio track
19454 in a 1024x800 picture using @command{ffmpeg}:
19455 @example
19456 ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
19457 @end example
19458 @end itemize
19459
19460 @section sidedata, asidedata
19461
19462 Delete frame side data, or select frames based on it.
19463
19464 This filter accepts the following options:
19465
19466 @table @option
19467 @item mode
19468 Set mode of operation of the filter.
19469
19470 Can be one of the following:
19471
19472 @table @samp
19473 @item select
19474 Select every frame with side data of @code{type}.
19475
19476 @item delete
19477 Delete side data of @code{type}. If @code{type} is not set, delete all side
19478 data in the frame.
19479
19480 @end table
19481
19482 @item type
19483 Set side data type used with all modes. Must be set for @code{select} mode. For
19484 the list of frame side data types, refer to the @code{AVFrameSideDataType} enum
19485 in @file{libavutil/frame.h}. For example, to choose
19486 @code{AV_FRAME_DATA_PANSCAN} side data, you must specify @code{PANSCAN}.
19487
19488 @end table
19489
19490 @section spectrumsynth
19491
19492 Sythesize audio from 2 input video spectrums, first input stream represents
19493 magnitude across time and second represents phase across time.
19494 The filter will transform from frequency domain as displayed in videos back
19495 to time domain as presented in audio output.
19496
19497 This filter is primarily created for reversing processed @ref{showspectrum}
19498 filter outputs, but can synthesize sound from other spectrograms too.
19499 But in such case results are going to be poor if the phase data is not
19500 available, because in such cases phase data need to be recreated, usually
19501 its just recreated from random noise.
19502 For best results use gray only output (@code{channel} color mode in
19503 @ref{showspectrum} filter) and @code{log} scale for magnitude video and
19504 @code{lin} scale for phase video. To produce phase, for 2nd video, use
19505 @code{data} option. Inputs videos should generally use @code{fullframe}
19506 slide mode as that saves resources needed for decoding video.
19507
19508 The filter accepts the following options:
19509
19510 @table @option
19511 @item sample_rate
19512 Specify sample rate of output audio, the sample rate of audio from which
19513 spectrum was generated may differ.
19514
19515 @item channels
19516 Set number of channels represented in input video spectrums.
19517
19518 @item scale
19519 Set scale which was used when generating magnitude input spectrum.
19520 Can be @code{lin} or @code{log}. Default is @code{log}.
19521
19522 @item slide
19523 Set slide which was used when generating inputs spectrums.
19524 Can be @code{replace}, @code{scroll}, @code{fullframe} or @code{rscroll}.
19525 Default is @code{fullframe}.
19526
19527 @item win_func
19528 Set window function used for resynthesis.
19529
19530 @item overlap
19531 Set window overlap. In range @code{[0, 1]}. Default is @code{1},
19532 which means optimal overlap for selected window function will be picked.
19533
19534 @item orientation
19535 Set orientation of input videos. Can be @code{vertical} or @code{horizontal}.
19536 Default is @code{vertical}.
19537 @end table
19538
19539 @subsection Examples
19540
19541 @itemize
19542 @item
19543 First create magnitude and phase videos from audio, assuming audio is stereo with 44100 sample rate,
19544 then resynthesize videos back to audio with spectrumsynth:
19545 @example
19546 ffmpeg -i input.flac -lavfi showspectrum=mode=separate:scale=log:overlap=0.875:color=channel:slide=fullframe:data=magnitude -an -c:v rawvideo magnitude.nut
19547 ffmpeg -i input.flac -lavfi showspectrum=mode=separate:scale=lin:overlap=0.875:color=channel:slide=fullframe:data=phase -an -c:v rawvideo phase.nut
19548 ffmpeg -i magnitude.nut -i phase.nut -lavfi spectrumsynth=channels=2:sample_rate=44100:win_func=hann:overlap=0.875:slide=fullframe output.flac
19549 @end example
19550 @end itemize
19551
19552 @section split, asplit
19553
19554 Split input into several identical outputs.
19555
19556 @code{asplit} works with audio input, @code{split} with video.
19557
19558 The filter accepts a single parameter which specifies the number of outputs. If
19559 unspecified, it defaults to 2.
19560
19561 @subsection Examples
19562
19563 @itemize
19564 @item
19565 Create two separate outputs from the same input:
19566 @example
19567 [in] split [out0][out1]
19568 @end example
19569
19570 @item
19571 To create 3 or more outputs, you need to specify the number of
19572 outputs, like in:
19573 @example
19574 [in] asplit=3 [out0][out1][out2]
19575 @end example
19576
19577 @item
19578 Create two separate outputs from the same input, one cropped and
19579 one padded:
19580 @example
19581 [in] split [splitout1][splitout2];
19582 [splitout1] crop=100:100:0:0    [cropout];
19583 [splitout2] pad=200:200:100:100 [padout];
19584 @end example
19585
19586 @item
19587 Create 5 copies of the input audio with @command{ffmpeg}:
19588 @example
19589 ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
19590 @end example
19591 @end itemize
19592
19593 @section zmq, azmq
19594
19595 Receive commands sent through a libzmq client, and forward them to
19596 filters in the filtergraph.
19597
19598 @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
19599 must be inserted between two video filters, @code{azmq} between two
19600 audio filters.
19601
19602 To enable these filters you need to install the libzmq library and
19603 headers and configure FFmpeg with @code{--enable-libzmq}.
19604
19605 For more information about libzmq see:
19606 @url{http://www.zeromq.org/}
19607
19608 The @code{zmq} and @code{azmq} filters work as a libzmq server, which
19609 receives messages sent through a network interface defined by the
19610 @option{bind_address} option.
19611
19612 The received message must be in the form:
19613 @example
19614 @var{TARGET} @var{COMMAND} [@var{ARG}]
19615 @end example
19616
19617 @var{TARGET} specifies the target of the command, usually the name of
19618 the filter class or a specific filter instance name.
19619
19620 @var{COMMAND} specifies the name of the command for the target filter.
19621
19622 @var{ARG} is optional and specifies the optional argument list for the
19623 given @var{COMMAND}.
19624
19625 Upon reception, the message is processed and the corresponding command
19626 is injected into the filtergraph. Depending on the result, the filter
19627 will send a reply to the client, adopting the format:
19628 @example
19629 @var{ERROR_CODE} @var{ERROR_REASON}
19630 @var{MESSAGE}
19631 @end example
19632
19633 @var{MESSAGE} is optional.
19634
19635 @subsection Examples
19636
19637 Look at @file{tools/zmqsend} for an example of a zmq client which can
19638 be used to send commands processed by these filters.
19639
19640 Consider the following filtergraph generated by @command{ffplay}
19641 @example
19642 ffplay -dumpgraph 1 -f lavfi "
19643 color=s=100x100:c=red  [l];
19644 color=s=100x100:c=blue [r];
19645 nullsrc=s=200x100, zmq [bg];
19646 [bg][l]   overlay      [bg+l];
19647 [bg+l][r] overlay=x=100 "
19648 @end example
19649
19650 To change the color of the left side of the video, the following
19651 command can be used:
19652 @example
19653 echo Parsed_color_0 c yellow | tools/zmqsend
19654 @end example
19655
19656 To change the right side:
19657 @example
19658 echo Parsed_color_1 c pink | tools/zmqsend
19659 @end example
19660
19661 @c man end MULTIMEDIA FILTERS
19662
19663 @chapter Multimedia Sources
19664 @c man begin MULTIMEDIA SOURCES
19665
19666 Below is a description of the currently available multimedia sources.
19667
19668 @section amovie
19669
19670 This is the same as @ref{movie} source, except it selects an audio
19671 stream by default.
19672
19673 @anchor{movie}
19674 @section movie
19675
19676 Read audio and/or video stream(s) from a movie container.
19677
19678 It accepts the following parameters:
19679
19680 @table @option
19681 @item filename
19682 The name of the resource to read (not necessarily a file; it can also be a
19683 device or a stream accessed through some protocol).
19684
19685 @item format_name, f
19686 Specifies the format assumed for the movie to read, and can be either
19687 the name of a container or an input device. If not specified, the
19688 format is guessed from @var{movie_name} or by probing.
19689
19690 @item seek_point, sp
19691 Specifies the seek point in seconds. The frames will be output
19692 starting from this seek point. The parameter is evaluated with
19693 @code{av_strtod}, so the numerical value may be suffixed by an IS
19694 postfix. The default value is "0".
19695
19696 @item streams, s
19697 Specifies the streams to read. Several streams can be specified,
19698 separated by "+". The source will then have as many outputs, in the
19699 same order. The syntax is explained in the ``Stream specifiers''
19700 section in the ffmpeg manual. Two special names, "dv" and "da" specify
19701 respectively the default (best suited) video and audio stream. Default
19702 is "dv", or "da" if the filter is called as "amovie".
19703
19704 @item stream_index, si
19705 Specifies the index of the video stream to read. If the value is -1,
19706 the most suitable video stream will be automatically selected. The default
19707 value is "-1". Deprecated. If the filter is called "amovie", it will select
19708 audio instead of video.
19709
19710 @item loop
19711 Specifies how many times to read the stream in sequence.
19712 If the value is 0, the stream will be looped infinitely.
19713 Default value is "1".
19714
19715 Note that when the movie is looped the source timestamps are not
19716 changed, so it will generate non monotonically increasing timestamps.
19717
19718 @item discontinuity
19719 Specifies the time difference between frames above which the point is
19720 considered a timestamp discontinuity which is removed by adjusting the later
19721 timestamps.
19722 @end table
19723
19724 It allows overlaying a second video on top of the main input of
19725 a filtergraph, as shown in this graph:
19726 @example
19727 input -----------> deltapts0 --> overlay --> output
19728                                     ^
19729                                     |
19730 movie --> scale--> deltapts1 -------+
19731 @end example
19732 @subsection Examples
19733
19734 @itemize
19735 @item
19736 Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
19737 on top of the input labelled "in":
19738 @example
19739 movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
19740 [in] setpts=PTS-STARTPTS [main];
19741 [main][over] overlay=16:16 [out]
19742 @end example
19743
19744 @item
19745 Read from a video4linux2 device, and overlay it on top of the input
19746 labelled "in":
19747 @example
19748 movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
19749 [in] setpts=PTS-STARTPTS [main];
19750 [main][over] overlay=16:16 [out]
19751 @end example
19752
19753 @item
19754 Read the first video stream and the audio stream with id 0x81 from
19755 dvd.vob; the video is connected to the pad named "video" and the audio is
19756 connected to the pad named "audio":
19757 @example
19758 movie=dvd.vob:s=v:0+#0x81 [video] [audio]
19759 @end example
19760 @end itemize
19761
19762 @subsection Commands
19763
19764 Both movie and amovie support the following commands:
19765 @table @option
19766 @item seek
19767 Perform seek using "av_seek_frame".
19768 The syntax is: seek @var{stream_index}|@var{timestamp}|@var{flags}
19769 @itemize
19770 @item
19771 @var{stream_index}: If stream_index is -1, a default
19772 stream is selected, and @var{timestamp} is automatically converted
19773 from AV_TIME_BASE units to the stream specific time_base.
19774 @item
19775 @var{timestamp}: Timestamp in AVStream.time_base units
19776 or, if no stream is specified, in AV_TIME_BASE units.
19777 @item
19778 @var{flags}: Flags which select direction and seeking mode.
19779 @end itemize
19780
19781 @item get_duration
19782 Get movie duration in AV_TIME_BASE units.
19783
19784 @end table
19785
19786 @c man end MULTIMEDIA SOURCES