• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1@chapter Filtering Introduction
2@c man begin FILTERING INTRODUCTION
3
4Filtering in FFmpeg is enabled through the libavfilter library.
5
6In libavfilter, a filter can have multiple inputs and multiple
7outputs.
8To illustrate the sorts of things that are possible, we consider the
9following filtergraph.
10
11@verbatim
12                [main]
13input --> split ---------------------> overlay --> output
14            |                             ^
15            |[tmp]                  [flip]|
16            +-----> crop --> vflip -------+
17@end verbatim
18
19This filtergraph splits the input stream in two streams, then sends one
20stream through the crop filter and the vflip filter, before merging it
21back with the other stream by overlaying it on top. You can use the
22following command to achieve this:
23
24@example
25ffmpeg -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
28The result will be that the top half of the video is mirrored
29onto the bottom half of the output video.
30
31Filters in the same linear chain are separated by commas, and distinct
32linear 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
35chains join are labelled by names enclosed in square brackets. In the
36example, the split filter generates two outputs that are associated to
37the labels @var{[main]} and @var{[tmp]}.
38
39The stream sent to the second output of @var{split}, labelled as
40@var{[tmp]}, is processed through the @var{crop} filter, which crops
41away 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
43split filter (which was labelled as @var{[main]}), and overlay on its
44lower half the output generated by the @var{crop,vflip} filterchain.
45
46Some filters take in input a list of parameters: they are specified
47after the filter name and an equal sign, and are separated from each other
48by a colon.
49
50There exist so-called @var{source filters} that do not have an
51audio/video input, and @var{sink filters} that will not have audio/video
52output.
53
54@c man end FILTERING INTRODUCTION
55
56@chapter graph2dot
57@c man begin GRAPH2DOT
58
59The @file{graph2dot} program included in the FFmpeg @file{tools}
60directory can be used to parse a filtergraph description and issue a
61corresponding textual representation in the dot language.
62
63Invoke the command:
64@example
65graph2dot -h
66@end example
67
68to see how to use @file{graph2dot}.
69
70You can then pass the dot description to the @file{dot} program (from
71the graphviz suite of programs) and obtain a graphical representation
72of the filtergraph.
73
74For example the sequence of commands:
75@example
76echo @var{GRAPH_DESCRIPTION} | \
77tools/graph2dot -o graph.tmp && \
78dot -Tpng graph.tmp -o graph.png && \
79display graph.png
80@end example
81
82can be used to create and display an image representing the graph
83described by the @var{GRAPH_DESCRIPTION} string. Note that this string must be
84a complete self-contained graph, with its inputs and outputs explicitly defined.
85For example if your command line is of the form:
86@example
87ffmpeg -i infile -vf scale=640:360 outfile
88@end example
89your @var{GRAPH_DESCRIPTION} string will need to be of the form:
90@example
91nullsrc,scale=640:360,nullsink
92@end example
93you may also need to set the @var{nullsrc} parameters and add a @var{format}
94filter 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
101A filtergraph is a directed graph of connected filters. It can contain
102cycles, and there can be multiple links between a pair of
103filters. Each link has one input pad on one side connecting it to one
104filter from which it takes its input, and one output pad on the other
105side connecting it to one filter accepting its output.
106
107Each filter in a filtergraph is an instance of a filter class
108registered in the application, which defines the features and the
109number of input and output pads of the filter.
110
111A filter with no input pads is called a "source", and a filter with no
112output pads is called a "sink".
113
114@anchor{Filtergraph syntax}
115@section Filtergraph syntax
116
117A 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
124A filterchain consists of a sequence of connected filters, each one
125connected to the previous one in the sequence. A filterchain is
126represented by a list of ","-separated filter descriptions.
127
128A filtergraph consists of a sequence of filterchains. A sequence of
129filterchains is represented by a list of ";"-separated filterchain
130descriptions.
131
132A 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
136described filter is an instance of, and has to be the name of one of
137the filter classes registered in the program optionally followed by "@@@var{id}".
138The 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
142initialize the filter instance. It may have one of two forms:
143@itemize
144
145@item
146A ':'-separated list of @var{key=value} pairs.
147
148@item
149A ':'-separated list of @var{value}. In this case, the keys are assumed to be
150the option names in the order they are declared. E.g. the @code{fade} filter
151declares 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
157A ':'-separated list of mixed direct @var{value} and long @var{key=value}
158pairs. The direct @var{value} must precede the @var{key=value} pairs, and
159follow 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
164If the option value itself is a list of items (e.g. the @code{format} filter
165takes a list of pixel formats), the items in the list are usually separated by
166@samp{|}.
167
168The list of arguments can be quoted using the character @samp{'} as initial
169and ending mark, and the character @samp{\} for escaping the characters
170within the quoted text; otherwise the argument string is considered
171terminated when the next special character (belonging to the set
172@samp{[]=;,}) is encountered.
173
174The name and arguments of the filter are optionally preceded and
175followed by a list of link labels.
176A link label allows one to name a link and associate it to a filter output
177or input pad. The preceding labels @var{in_link_1}
178... @var{in_link_N}, are associated to the filter input pads,
179the following labels @var{out_link_1} ... @var{out_link_M}, are
180associated to the output pads.
181
182When two link labels with the same name are found in the
183filtergraph, a link between the corresponding input and output pad is
184created.
185
186If an output pad is not labelled, it is linked by default to the first
187unlabelled input pad of the next filter in the filterchain.
188For example in the filterchain
189@example
190nullsrc, split[L1], [L2]overlay, nullsink
191@end example
192the split filter instance has two output pads, and the overlay filter
193instance 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
195output pad of split is linked to the second input pad of overlay,
196which are both unlabelled.
197
198In a filter description, if the input label of the first filter is not
199specified, "in" is assumed; if the output label of the last filter is not
200specified, "out" is assumed.
201
202In a complete filterchain all the unlabelled filter input and output
203pads must be connected. A filtergraph is considered valid if all the
204filter input and output pads of all the filterchains are connected.
205
206Libavfilter will automatically insert @ref{scale} filters where format
207conversion is required. It is possible to specify swscale flags
208for those automatically inserted scalers by prepending
209@code{sws_flags=@var{flags};}
210to the filtergraph description.
211
212Here 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@anchor{filtergraph escaping}
225@section Notes on filtergraph escaping
226
227Filtergraph description composition entails several levels of
228escaping. See @ref{quoting_and_escaping,,the "Quoting and escaping"
229section in the ffmpeg-utils(1) manual,ffmpeg-utils} for more
230information about the employed escaping procedure.
231
232A first level escaping affects the content of each filter option
233value, which may contain the special character @code{:} used to
234separate values, or one of the escaping characters @code{\'}.
235
236A second level escaping affects the whole filter description, which
237may contain the escaping characters @code{\'} or the special
238characters @code{[],;} used by the filtergraph description.
239
240Finally, when you specify a filtergraph on a shell commandline, you
241need to perform a third level escaping for the shell special
242characters contained within it.
243
244For example, consider the following string to be embedded in
245the @ref{drawtext} filter description @option{text} value:
246@example
247this is a 'string': may contain one, or more, special characters
248@end example
249
250This string contains the @code{'} special escaping character, and the
251@code{:} special character, so it needs to be escaped in this way:
252@example
253text=this is a \'string\'\: may contain one, or more, special characters
254@end example
255
256A second level of escaping is required when embedding the filter
257description in a filtergraph description, in order to escape all the
258filtergraph special characters. Thus the example above becomes:
259@example
260drawtext=text=this is a \\\'string\\\'\\: may contain one\, or more\, special characters
261@end example
262(note that in addition to the @code{\'} escaping special characters,
263also @code{,} needs to be escaped).
264
265Finally an additional level of escaping is needed when writing the
266filtergraph description in a shell command, which depends on the
267escaping rules of the adopted shell. For example, assuming that
268@code{\} is special and needs to be escaped with another @code{\}, the
269previous string will finally result in:
270@example
271-vf "drawtext=text=this is a \\\\\\'string\\\\\\'\\\\: may contain one\\, or more\\, special characters"
272@end example
273
274@chapter Timeline editing
275
276Some filters support a generic @option{enable} option. For the filters
277supporting timeline editing, this option can be set to an expression which is
278evaluated before sending a frame to the filter. If the evaluation is non-zero,
279the filter will be enabled, otherwise the frame will be sent unchanged to the
280next filter in the filtergraph.
281
282The expression accepts the following values:
283@table @samp
284@item t
285timestamp expressed in seconds, NAN if the input timestamp is unknown
286
287@item n
288sequential number of the input frame, starting from 0
289
290@item pos
291the position in the file of the input frame, NAN if unknown
292
293@item w
294@item h
295width and height of the input frame if video
296@end table
297
298Additionally, these filters support an @option{enable} command that can be used
299to re-define the expression.
300
301Like any other filtering option, the @option{enable} option follows the same
302rules.
303
304For example, to enable a blur filter (@ref{smartblur}) from 10 seconds to 3
305minutes, and a @ref{curves} filter starting at 3 seconds:
306@example
307smartblur = enable='between(t,10,3*60)',
308curves    = enable='gte(t,3)' : preset=cross_process
309@end example
310
311See @code{ffmpeg -filters} to view which filters have timeline support.
312
313@c man end FILTERGRAPH DESCRIPTION
314
315@anchor{commands}
316@chapter Changing options at runtime with a command
317
318Some options can be changed during the operation of the filter using
319a command. These options are marked 'T' on the output of
320@command{ffmpeg} @option{-h filter=<name of filter>}.
321The name of the command is the name of the option and the argument is
322the new value.
323
324@anchor{framesync}
325@chapter Options for filters with several inputs (framesync)
326@c man begin OPTIONS FOR FILTERS WITH SEVERAL INPUTS
327
328Some filters with several inputs support a common set of options.
329These options can only be set by name, not with the short notation.
330
331@table @option
332@item eof_action
333The action to take when EOF is encountered on the secondary input; it accepts
334one of the following values:
335
336@table @option
337@item repeat
338Repeat the last frame (the default).
339@item endall
340End both streams.
341@item pass
342Pass the main input through.
343@end table
344
345@item shortest
346If set to 1, force the output to terminate when the shortest input
347terminates. Default value is 0.
348
349@item repeatlast
350If set to 1, force the filter to extend the last frame of secondary streams
351until the end of the primary stream. A value of 0 disables this behavior.
352Default value is 1.
353@end table
354
355@c man end OPTIONS FOR FILTERS WITH SEVERAL INPUTS
356
357@chapter Audio Filters
358@c man begin AUDIO FILTERS
359
360When you configure your FFmpeg build, you can disable any of the
361existing filters using @code{--disable-filters}.
362The configure output will show the audio filters included in your
363build.
364
365Below is a description of the currently available audio filters.
366
367@section acompressor
368
369A compressor is mainly used to reduce the dynamic range of a signal.
370Especially modern music is mostly compressed at a high ratio to
371improve the overall loudness. It's done to get the highest attention
372of a listener, "fatten" the sound and bring more "power" to the track.
373If a signal is compressed too much it may sound dull or "dead"
374afterwards or it may start to "pump" (which could be a powerful effect
375but can also destroy a track completely).
376The right compression is the key to reach a professional sound and is
377the high art of mixing and mastering. Because of its complex settings
378it may take a long time to get the right feeling for this kind of effect.
379
380Compression is done by detecting the volume above a chosen level
381@code{threshold} and dividing it by the factor set with @code{ratio}.
382So if you set the threshold to -12dB and your signal reaches -6dB a ratio
383of 2:1 will result in a signal at -9dB. Because an exact manipulation of
384the signal would cause distortion of the waveform the reduction can be
385levelled over the time. This is done by setting "Attack" and "Release".
386@code{attack} determines how long the signal has to rise above the threshold
387before any reduction will occur and @code{release} sets the time the signal
388has to fall below the threshold to reduce the reduction again. Shorter signals
389than the chosen attack time will be left untouched.
390The overall reduction of the signal can be made up afterwards with the
391@code{makeup} setting. So compressing the peaks of a signal about 6dB and
392raising the makeup to this level results in a signal twice as loud than the
393source. To gain a softer entry in the compression the @code{knee} flattens the
394hard edge at the threshold in the range of the chosen decibels.
395
396The filter accepts the following options:
397
398@table @option
399@item level_in
400Set input gain. Default is 1. Range is between 0.015625 and 64.
401
402@item mode
403Set mode of compressor operation. Can be @code{upward} or @code{downward}.
404Default is @code{downward}.
405
406@item threshold
407If a signal of stream rises above this level it will affect the gain
408reduction.
409By default it is 0.125. Range is between 0.00097563 and 1.
410
411@item ratio
412Set a ratio by which the signal is reduced. 1:2 means that if the level
413rose 4dB above the threshold, it will be only 2dB above after the reduction.
414Default is 2. Range is between 1 and 20.
415
416@item attack
417Amount of milliseconds the signal has to rise above the threshold before gain
418reduction starts. Default is 20. Range is between 0.01 and 2000.
419
420@item release
421Amount of milliseconds the signal has to fall below the threshold before
422reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
423
424@item makeup
425Set the amount by how much signal will be amplified after processing.
426Default is 1. Range is from 1 to 64.
427
428@item knee
429Curve the sharp knee around the threshold to enter gain reduction more softly.
430Default is 2.82843. Range is between 1 and 8.
431
432@item link
433Choose if the @code{average} level between all channels of input stream
434or the louder(@code{maximum}) channel of input stream affects the
435reduction. Default is @code{average}.
436
437@item detection
438Should the exact signal be taken in case of @code{peak} or an RMS one in case
439of @code{rms}. Default is @code{rms} which is mostly smoother.
440
441@item mix
442How much to use compressed signal in output. Default is 1.
443Range is between 0 and 1.
444@end table
445
446@subsection Commands
447
448This filter supports the all above options as @ref{commands}.
449
450@section acontrast
451Simple audio dynamic range compression/expansion filter.
452
453The filter accepts the following options:
454
455@table @option
456@item contrast
457Set contrast. Default is 33. Allowed range is between 0 and 100.
458@end table
459
460@section acopy
461
462Copy the input audio source unchanged to the output. This is mainly useful for
463testing purposes.
464
465@section acrossfade
466
467Apply cross fade from one input audio stream to another input audio stream.
468The cross fade is applied for specified duration near the end of first stream.
469
470The filter accepts the following options:
471
472@table @option
473@item nb_samples, ns
474Specify the number of samples for which the cross fade effect has to last.
475At the end of the cross fade effect the first input audio will be completely
476silent. Default is 44100.
477
478@item duration, d
479Specify the duration of the cross fade effect. See
480@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
481for the accepted syntax.
482By default the duration is determined by @var{nb_samples}.
483If set this option is used instead of @var{nb_samples}.
484
485@item overlap, o
486Should first stream end overlap with second stream start. Default is enabled.
487
488@item curve1
489Set curve for cross fade transition for first stream.
490
491@item curve2
492Set curve for cross fade transition for second stream.
493
494For description of available curve types see @ref{afade} filter description.
495@end table
496
497@subsection Examples
498
499@itemize
500@item
501Cross fade from one input to another:
502@example
503ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:c1=exp:c2=exp output.flac
504@end example
505
506@item
507Cross fade from one input to another but without overlapping:
508@example
509ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:o=0:c1=exp:c2=exp output.flac
510@end example
511@end itemize
512
513@section acrossover
514Split audio stream into several bands.
515
516This filter splits audio stream into two or more frequency ranges.
517Summing all streams back will give flat output.
518
519The filter accepts the following options:
520
521@table @option
522@item split
523Set split frequencies. Those must be positive and increasing.
524
525@item order
526Set filter order, can be @var{2nd}, @var{4th} or @var{8th}.
527Default is @var{4th}.
528@end table
529
530@section acrusher
531
532Reduce audio bit resolution.
533
534This filter is bit crusher with enhanced functionality. A bit crusher
535is used to audibly reduce number of bits an audio signal is sampled
536with. This doesn't change the bit depth at all, it just produces the
537effect. Material reduced in bit depth sounds more harsh and "digital".
538This filter is able to even round to continuous values instead of discrete
539bit depths.
540Additionally it has a D/C offset which results in different crushing of
541the lower and the upper half of the signal.
542An Anti-Aliasing setting is able to produce "softer" crushing sounds.
543
544Another feature of this filter is the logarithmic mode.
545This setting switches from linear distances between bits to logarithmic ones.
546The result is a much more "natural" sounding crusher which doesn't gate low
547signals for example. The human ear has a logarithmic perception,
548so this kind of crushing is much more pleasant.
549Logarithmic crushing is also able to get anti-aliased.
550
551The filter accepts the following options:
552
553@table @option
554@item level_in
555Set level in.
556
557@item level_out
558Set level out.
559
560@item bits
561Set bit reduction.
562
563@item mix
564Set mixing amount.
565
566@item mode
567Can be linear: @code{lin} or logarithmic: @code{log}.
568
569@item dc
570Set DC.
571
572@item aa
573Set anti-aliasing.
574
575@item samples
576Set sample reduction.
577
578@item lfo
579Enable LFO. By default disabled.
580
581@item lforange
582Set LFO range.
583
584@item lforate
585Set LFO rate.
586@end table
587
588@section acue
589
590Delay audio filtering until a given wallclock timestamp. See the @ref{cue}
591filter.
592
593@section adeclick
594Remove impulsive noise from input audio.
595
596Samples detected as impulsive noise are replaced by interpolated samples using
597autoregressive modelling.
598
599@table @option
600@item w
601Set window size, in milliseconds. Allowed range is from @code{10} to
602@code{100}. Default value is @code{55} milliseconds.
603This sets size of window which will be processed at once.
604
605@item o
606Set window overlap, in percentage of window size. Allowed range is from
607@code{50} to @code{95}. Default value is @code{75} percent.
608Setting this to a very high value increases impulsive noise removal but makes
609whole process much slower.
610
611@item a
612Set autoregression order, in percentage of window size. Allowed range is from
613@code{0} to @code{25}. Default value is @code{2} percent. This option also
614controls quality of interpolated samples using neighbour good samples.
615
616@item t
617Set threshold value. Allowed range is from @code{1} to @code{100}.
618Default value is @code{2}.
619This controls the strength of impulsive noise which is going to be removed.
620The lower value, the more samples will be detected as impulsive noise.
621
622@item b
623Set burst fusion, in percentage of window size. Allowed range is @code{0} to
624@code{10}. Default value is @code{2}.
625If any two samples detected as noise are spaced less than this value then any
626sample between those two samples will be also detected as noise.
627
628@item m
629Set overlap method.
630
631It accepts the following values:
632@table @option
633@item a
634Select overlap-add method. Even not interpolated samples are slightly
635changed with this method.
636
637@item s
638Select overlap-save method. Not interpolated samples remain unchanged.
639@end table
640
641Default value is @code{a}.
642@end table
643
644@section adeclip
645Remove clipped samples from input audio.
646
647Samples detected as clipped are replaced by interpolated samples using
648autoregressive modelling.
649
650@table @option
651@item w
652Set window size, in milliseconds. Allowed range is from @code{10} to @code{100}.
653Default value is @code{55} milliseconds.
654This sets size of window which will be processed at once.
655
656@item o
657Set window overlap, in percentage of window size. Allowed range is from @code{50}
658to @code{95}. Default value is @code{75} percent.
659
660@item a
661Set autoregression order, in percentage of window size. Allowed range is from
662@code{0} to @code{25}. Default value is @code{8} percent. This option also controls
663quality of interpolated samples using neighbour good samples.
664
665@item t
666Set threshold value. Allowed range is from @code{1} to @code{100}.
667Default value is @code{10}. Higher values make clip detection less aggressive.
668
669@item n
670Set size of histogram used to detect clips. Allowed range is from @code{100} to @code{9999}.
671Default value is @code{1000}. Higher values make clip detection less aggressive.
672
673@item m
674Set overlap method.
675
676It accepts the following values:
677@table @option
678@item a
679Select overlap-add method. Even not interpolated samples are slightly changed
680with this method.
681
682@item s
683Select overlap-save method. Not interpolated samples remain unchanged.
684@end table
685
686Default value is @code{a}.
687@end table
688
689@section adelay
690
691Delay one or more audio channels.
692
693Samples in delayed channel are filled with silence.
694
695The filter accepts the following option:
696
697@table @option
698@item delays
699Set list of delays in milliseconds for each channel separated by '|'.
700Unused delays will be silently ignored. If number of given delays is
701smaller than number of channels all remaining channels will not be delayed.
702If you want to delay exact number of samples, append 'S' to number.
703If you want instead to delay in seconds, append 's' to number.
704
705@item all
706Use last set delay for all remaining channels. By default is disabled.
707This option if enabled changes how option @code{delays} is interpreted.
708@end table
709
710@subsection Examples
711
712@itemize
713@item
714Delay first channel by 1.5 seconds, the third channel by 0.5 seconds and leave
715the second channel (and any other channels that may be present) unchanged.
716@example
717adelay=1500|0|500
718@end example
719
720@item
721Delay second channel by 500 samples, the third channel by 700 samples and leave
722the first channel (and any other channels that may be present) unchanged.
723@example
724adelay=0|500S|700S
725@end example
726
727@item
728Delay all channels by same number of samples:
729@example
730adelay=delays=64S:all=1
731@end example
732@end itemize
733
734@section aderivative, aintegral
735
736Compute derivative/integral of audio stream.
737
738Applying both filters one after another produces original audio.
739
740@section aecho
741
742Apply echoing to the input audio.
743
744Echoes are reflected sound and can occur naturally amongst mountains
745(and sometimes large buildings) when talking or shouting; digital echo
746effects emulate this behaviour and are often used to help fill out the
747sound of a single instrument or vocal. The time difference between the
748original signal and the reflection is the @code{delay}, and the
749loudness of the reflected signal is the @code{decay}.
750Multiple echoes can have different delays and decays.
751
752A description of the accepted parameters follows.
753
754@table @option
755@item in_gain
756Set input gain of reflected signal. Default is @code{0.6}.
757
758@item out_gain
759Set output gain of reflected signal. Default is @code{0.3}.
760
761@item delays
762Set list of time intervals in milliseconds between original signal and reflections
763separated by '|'. Allowed range for each @code{delay} is @code{(0 - 90000.0]}.
764Default is @code{1000}.
765
766@item decays
767Set list of loudness of reflected signals separated by '|'.
768Allowed range for each @code{decay} is @code{(0 - 1.0]}.
769Default is @code{0.5}.
770@end table
771
772@subsection Examples
773
774@itemize
775@item
776Make it sound as if there are twice as many instruments as are actually playing:
777@example
778aecho=0.8:0.88:60:0.4
779@end example
780
781@item
782If delay is very short, then it sounds like a (metallic) robot playing music:
783@example
784aecho=0.8:0.88:6:0.4
785@end example
786
787@item
788A longer delay will sound like an open air concert in the mountains:
789@example
790aecho=0.8:0.9:1000:0.3
791@end example
792
793@item
794Same as above but with one more mountain:
795@example
796aecho=0.8:0.9:1000|1800:0.3|0.25
797@end example
798@end itemize
799
800@section aemphasis
801Audio emphasis filter creates or restores material directly taken from LPs or
802emphased CDs with different filter curves. E.g. to store music on vinyl the
803signal has to be altered by a filter first to even out the disadvantages of
804this recording medium.
805Once the material is played back the inverse filter has to be applied to
806restore the distortion of the frequency response.
807
808The filter accepts the following options:
809
810@table @option
811@item level_in
812Set input gain.
813
814@item level_out
815Set output gain.
816
817@item mode
818Set filter mode. For restoring material use @code{reproduction} mode, otherwise
819use @code{production} mode. Default is @code{reproduction} mode.
820
821@item type
822Set filter type. Selects medium. Can be one of the following:
823
824@table @option
825@item col
826select Columbia.
827@item emi
828select EMI.
829@item bsi
830select BSI (78RPM).
831@item riaa
832select RIAA.
833@item cd
834select Compact Disc (CD).
835@item 50fm
836select 50µs (FM).
837@item 75fm
838select 75µs (FM).
839@item 50kf
840select 50µs (FM-KF).
841@item 75kf
842select 75µs (FM-KF).
843@end table
844@end table
845
846@section aeval
847
848Modify an audio signal according to the specified expressions.
849
850This filter accepts one or more expressions (one for each channel),
851which are evaluated and used to modify a corresponding audio signal.
852
853It accepts the following parameters:
854
855@table @option
856@item exprs
857Set the '|'-separated expressions list for each separate channel. If
858the number of input channels is greater than the number of
859expressions, the last specified expression is used for the remaining
860output channels.
861
862@item channel_layout, c
863Set output channel layout. If not specified, the channel layout is
864specified by the number of expressions. If set to @samp{same}, it will
865use by default the same input channel layout.
866@end table
867
868Each expression in @var{exprs} can contain the following constants and functions:
869
870@table @option
871@item ch
872channel number of the current expression
873
874@item n
875number of the evaluated sample, starting from 0
876
877@item s
878sample rate
879
880@item t
881time of the evaluated sample expressed in seconds
882
883@item nb_in_channels
884@item nb_out_channels
885input and output number of channels
886
887@item val(CH)
888the value of input channel with number @var{CH}
889@end table
890
891Note: this filter is slow. For faster processing you should use a
892dedicated filter.
893
894@subsection Examples
895
896@itemize
897@item
898Half volume:
899@example
900aeval=val(ch)/2:c=same
901@end example
902
903@item
904Invert phase of the second channel:
905@example
906aeval=val(0)|-val(1)
907@end example
908@end itemize
909
910@anchor{afade}
911@section afade
912
913Apply fade-in/out effect to input audio.
914
915A description of the accepted parameters follows.
916
917@table @option
918@item type, t
919Specify the effect type, can be either @code{in} for fade-in, or
920@code{out} for a fade-out effect. Default is @code{in}.
921
922@item start_sample, ss
923Specify the number of the start sample for starting to apply the fade
924effect. Default is 0.
925
926@item nb_samples, ns
927Specify the number of samples for which the fade effect has to last. At
928the end of the fade-in effect the output audio will have the same
929volume as the input audio, at the end of the fade-out transition
930the output audio will be silence. Default is 44100.
931
932@item start_time, st
933Specify the start time of the fade effect. Default is 0.
934The value must be specified as a time duration; see
935@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
936for the accepted syntax.
937If set this option is used instead of @var{start_sample}.
938
939@item duration, d
940Specify the duration of the fade effect. See
941@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
942for the accepted syntax.
943At the end of the fade-in effect the output audio will have the same
944volume as the input audio, at the end of the fade-out transition
945the output audio will be silence.
946By default the duration is determined by @var{nb_samples}.
947If set this option is used instead of @var{nb_samples}.
948
949@item curve
950Set curve for fade transition.
951
952It accepts the following values:
953@table @option
954@item tri
955select triangular, linear slope (default)
956@item qsin
957select quarter of sine wave
958@item hsin
959select half of sine wave
960@item esin
961select exponential sine wave
962@item log
963select logarithmic
964@item ipar
965select inverted parabola
966@item qua
967select quadratic
968@item cub
969select cubic
970@item squ
971select square root
972@item cbr
973select cubic root
974@item par
975select parabola
976@item exp
977select exponential
978@item iqsin
979select inverted quarter of sine wave
980@item ihsin
981select inverted half of sine wave
982@item dese
983select double-exponential seat
984@item desi
985select double-exponential sigmoid
986@item losi
987select logistic sigmoid
988@item nofade
989no fade applied
990@end table
991@end table
992
993@subsection Examples
994
995@itemize
996@item
997Fade in first 15 seconds of audio:
998@example
999afade=t=in:ss=0:d=15
1000@end example
1001
1002@item
1003Fade out last 25 seconds of a 900 seconds audio:
1004@example
1005afade=t=out:st=875:d=25
1006@end example
1007@end itemize
1008
1009@section afftdn
1010Denoise audio samples with FFT.
1011
1012A description of the accepted parameters follows.
1013
1014@table @option
1015@item nr
1016Set the noise reduction in dB, allowed range is 0.01 to 97.
1017Default value is 12 dB.
1018
1019@item nf
1020Set the noise floor in dB, allowed range is -80 to -20.
1021Default value is -50 dB.
1022
1023@item nt
1024Set the noise type.
1025
1026It accepts the following values:
1027@table @option
1028@item w
1029Select white noise.
1030
1031@item v
1032Select vinyl noise.
1033
1034@item s
1035Select shellac noise.
1036
1037@item c
1038Select custom noise, defined in @code{bn} option.
1039
1040Default value is white noise.
1041@end table
1042
1043@item bn
1044Set custom band noise for every one of 15 bands.
1045Bands are separated by ' ' or '|'.
1046
1047@item rf
1048Set the residual floor in dB, allowed range is -80 to -20.
1049Default value is -38 dB.
1050
1051@item tn
1052Enable noise tracking. By default is disabled.
1053With this enabled, noise floor is automatically adjusted.
1054
1055@item tr
1056Enable residual tracking. By default is disabled.
1057
1058@item om
1059Set the output mode.
1060
1061It accepts the following values:
1062@table @option
1063@item i
1064Pass input unchanged.
1065
1066@item o
1067Pass noise filtered out.
1068
1069@item n
1070Pass only noise.
1071
1072Default value is @var{o}.
1073@end table
1074@end table
1075
1076@subsection Commands
1077
1078This filter supports the following commands:
1079@table @option
1080@item sample_noise, sn
1081Start or stop measuring noise profile.
1082Syntax for the command is : "start" or "stop" string.
1083After measuring noise profile is stopped it will be
1084automatically applied in filtering.
1085
1086@item noise_reduction, nr
1087Change noise reduction. Argument is single float number.
1088Syntax for the command is : "@var{noise_reduction}"
1089
1090@item noise_floor, nf
1091Change noise floor. Argument is single float number.
1092Syntax for the command is : "@var{noise_floor}"
1093
1094@item output_mode, om
1095Change output mode operation.
1096Syntax for the command is : "i", "o" or "n" string.
1097@end table
1098
1099@section afftfilt
1100Apply arbitrary expressions to samples in frequency domain.
1101
1102@table @option
1103@item real
1104Set frequency domain real expression for each separate channel separated
1105by '|'. Default is "re".
1106If the number of input channels is greater than the number of
1107expressions, the last specified expression is used for the remaining
1108output channels.
1109
1110@item imag
1111Set frequency domain imaginary expression for each separate channel
1112separated by '|'. Default is "im".
1113
1114Each expression in @var{real} and @var{imag} can contain the following
1115constants and functions:
1116
1117@table @option
1118@item sr
1119sample rate
1120
1121@item b
1122current frequency bin number
1123
1124@item nb
1125number of available bins
1126
1127@item ch
1128channel number of the current expression
1129
1130@item chs
1131number of channels
1132
1133@item pts
1134current frame pts
1135
1136@item re
1137current real part of frequency bin of current channel
1138
1139@item im
1140current imaginary part of frequency bin of current channel
1141
1142@item real(b, ch)
1143Return the value of real part of frequency bin at location (@var{bin},@var{channel})
1144
1145@item imag(b, ch)
1146Return the value of imaginary part of frequency bin at location (@var{bin},@var{channel})
1147@end table
1148
1149@item win_size
1150Set window size. Allowed range is from 16 to 131072.
1151Default is @code{4096}
1152
1153@item win_func
1154Set window function. Default is @code{hann}.
1155
1156@item overlap
1157Set window overlap. If set to 1, the recommended overlap for selected
1158window function will be picked. Default is @code{0.75}.
1159@end table
1160
1161@subsection Examples
1162
1163@itemize
1164@item
1165Leave almost only low frequencies in audio:
1166@example
1167afftfilt="'real=re * (1-clip((b/nb)*b,0,1))':imag='im * (1-clip((b/nb)*b,0,1))'"
1168@end example
1169
1170@item
1171Apply robotize effect:
1172@example
1173afftfilt="real='hypot(re,im)*sin(0)':imag='hypot(re,im)*cos(0)':win_size=512:overlap=0.75"
1174@end example
1175
1176@item
1177Apply whisper effect:
1178@example
1179afftfilt="real='hypot(re,im)*cos((random(0)*2-1)*2*3.14)':imag='hypot(re,im)*sin((random(1)*2-1)*2*3.14)':win_size=128:overlap=0.8"
1180@end example
1181@end itemize
1182
1183@anchor{afir}
1184@section afir
1185
1186Apply an arbitrary Finite Impulse Response filter.
1187
1188This filter is designed for applying long FIR filters,
1189up to 60 seconds long.
1190
1191It can be used as component for digital crossover filters,
1192room equalization, cross talk cancellation, wavefield synthesis,
1193auralization, ambiophonics, ambisonics and spatialization.
1194
1195This filter uses the streams higher than first one as FIR coefficients.
1196If the non-first stream holds a single channel, it will be used
1197for all input channels in the first stream, otherwise
1198the number of channels in the non-first stream must be same as
1199the number of channels in the first stream.
1200
1201It accepts the following parameters:
1202
1203@table @option
1204@item dry
1205Set dry gain. This sets input gain.
1206
1207@item wet
1208Set wet gain. This sets final output gain.
1209
1210@item length
1211Set Impulse Response filter length. Default is 1, which means whole IR is processed.
1212
1213@item gtype
1214Enable applying gain measured from power of IR.
1215
1216Set which approach to use for auto gain measurement.
1217
1218@table @option
1219@item none
1220Do not apply any gain.
1221
1222@item peak
1223select peak gain, very conservative approach. This is default value.
1224
1225@item dc
1226select DC gain, limited application.
1227
1228@item gn
1229select gain to noise approach, this is most popular one.
1230@end table
1231
1232@item irgain
1233Set gain to be applied to IR coefficients before filtering.
1234Allowed range is 0 to 1. This gain is applied after any gain applied with @var{gtype} option.
1235
1236@item irfmt
1237Set format of IR stream. Can be @code{mono} or @code{input}.
1238Default is @code{input}.
1239
1240@item maxir
1241Set max allowed Impulse Response filter duration in seconds. Default is 30 seconds.
1242Allowed range is 0.1 to 60 seconds.
1243
1244@item response
1245Show IR frequency response, magnitude(magenta), phase(green) and group delay(yellow) in additional video stream.
1246By default it is disabled.
1247
1248@item channel
1249Set for which IR channel to display frequency response. By default is first channel
1250displayed. This option is used only when @var{response} is enabled.
1251
1252@item size
1253Set video stream size. This option is used only when @var{response} is enabled.
1254
1255@item rate
1256Set video stream frame rate. This option is used only when @var{response} is enabled.
1257
1258@item minp
1259Set minimal partition size used for convolution. Default is @var{8192}.
1260Allowed range is from @var{1} to @var{32768}.
1261Lower values decreases latency at cost of higher CPU usage.
1262
1263@item maxp
1264Set maximal partition size used for convolution. Default is @var{8192}.
1265Allowed range is from @var{8} to @var{32768}.
1266Lower values may increase CPU usage.
1267
1268@item nbirs
1269Set number of input impulse responses streams which will be switchable at runtime.
1270Allowed range is from @var{1} to @var{32}. Default is @var{1}.
1271
1272@item ir
1273Set IR stream which will be used for convolution, starting from @var{0}, should always be
1274lower than supplied value by @code{nbirs} option. Default is @var{0}.
1275This option can be changed at runtime via @ref{commands}.
1276@end table
1277
1278@subsection Examples
1279
1280@itemize
1281@item
1282Apply reverb to stream using mono IR file as second input, complete command using ffmpeg:
1283@example
1284ffmpeg -i input.wav -i middle_tunnel_1way_mono.wav -lavfi afir output.wav
1285@end example
1286@end itemize
1287
1288@anchor{aformat}
1289@section aformat
1290
1291Set output format constraints for the input audio. The framework will
1292negotiate the most appropriate format to minimize conversions.
1293
1294It accepts the following parameters:
1295@table @option
1296
1297@item sample_fmts, f
1298A '|'-separated list of requested sample formats.
1299
1300@item sample_rates, r
1301A '|'-separated list of requested sample rates.
1302
1303@item channel_layouts, cl
1304A '|'-separated list of requested channel layouts.
1305
1306See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
1307for the required syntax.
1308@end table
1309
1310If a parameter is omitted, all values are allowed.
1311
1312Force the output to either unsigned 8-bit or signed 16-bit stereo
1313@example
1314aformat=sample_fmts=u8|s16:channel_layouts=stereo
1315@end example
1316
1317@section agate
1318
1319A gate is mainly used to reduce lower parts of a signal. This kind of signal
1320processing reduces disturbing noise between useful signals.
1321
1322Gating is done by detecting the volume below a chosen level @var{threshold}
1323and dividing it by the factor set with @var{ratio}. The bottom of the noise
1324floor is set via @var{range}. Because an exact manipulation of the signal
1325would cause distortion of the waveform the reduction can be levelled over
1326time. This is done by setting @var{attack} and @var{release}.
1327
1328@var{attack} determines how long the signal has to fall below the threshold
1329before any reduction will occur and @var{release} sets the time the signal
1330has to rise above the threshold to reduce the reduction again.
1331Shorter signals than the chosen attack time will be left untouched.
1332
1333@table @option
1334@item level_in
1335Set input level before filtering.
1336Default is 1. Allowed range is from 0.015625 to 64.
1337
1338@item mode
1339Set the mode of operation. Can be @code{upward} or @code{downward}.
1340Default is @code{downward}. If set to @code{upward} mode, higher parts of signal
1341will be amplified, expanding dynamic range in upward direction.
1342Otherwise, in case of @code{downward} lower parts of signal will be reduced.
1343
1344@item range
1345Set the level of gain reduction when the signal is below the threshold.
1346Default is 0.06125. Allowed range is from 0 to 1.
1347Setting this to 0 disables reduction and then filter behaves like expander.
1348
1349@item threshold
1350If a signal rises above this level the gain reduction is released.
1351Default is 0.125. Allowed range is from 0 to 1.
1352
1353@item ratio
1354Set a ratio by which the signal is reduced.
1355Default is 2. Allowed range is from 1 to 9000.
1356
1357@item attack
1358Amount of milliseconds the signal has to rise above the threshold before gain
1359reduction stops.
1360Default is 20 milliseconds. Allowed range is from 0.01 to 9000.
1361
1362@item release
1363Amount of milliseconds the signal has to fall below the threshold before the
1364reduction is increased again. Default is 250 milliseconds.
1365Allowed range is from 0.01 to 9000.
1366
1367@item makeup
1368Set amount of amplification of signal after processing.
1369Default is 1. Allowed range is from 1 to 64.
1370
1371@item knee
1372Curve the sharp knee around the threshold to enter gain reduction more softly.
1373Default is 2.828427125. Allowed range is from 1 to 8.
1374
1375@item detection
1376Choose if exact signal should be taken for detection or an RMS like one.
1377Default is @code{rms}. Can be @code{peak} or @code{rms}.
1378
1379@item link
1380Choose if the average level between all channels or the louder channel affects
1381the reduction.
1382Default is @code{average}. Can be @code{average} or @code{maximum}.
1383@end table
1384
1385@section aiir
1386
1387Apply an arbitrary Infinite Impulse Response filter.
1388
1389It accepts the following parameters:
1390
1391@table @option
1392@item zeros, z
1393Set numerator/zeros coefficients.
1394
1395@item poles, p
1396Set denominator/poles coefficients.
1397
1398@item gains, k
1399Set channels gains.
1400
1401@item dry_gain
1402Set input gain.
1403
1404@item wet_gain
1405Set output gain.
1406
1407@item format, f
1408Set coefficients format.
1409
1410@table @samp
1411@item tf
1412digital transfer function
1413@item zp
1414Z-plane zeros/poles, cartesian (default)
1415@item pr
1416Z-plane zeros/poles, polar radians
1417@item pd
1418Z-plane zeros/poles, polar degrees
1419@item sp
1420S-plane zeros/poles
1421@end table
1422
1423@item process, r
1424Set kind of processing.
1425Can be @code{d} - direct or @code{s} - serial cascading. Default is @code{s}.
1426
1427@item precision, e
1428Set filtering precision.
1429
1430@table @samp
1431@item dbl
1432double-precision floating-point (default)
1433@item flt
1434single-precision floating-point
1435@item i32
143632-bit integers
1437@item i16
143816-bit integers
1439@end table
1440
1441@item normalize, n
1442Normalize filter coefficients, by default is enabled.
1443Enabling it will normalize magnitude response at DC to 0dB.
1444
1445@item mix
1446How much to use filtered signal in output. Default is 1.
1447Range is between 0 and 1.
1448
1449@item response
1450Show IR frequency response, magnitude(magenta), phase(green) and group delay(yellow) in additional video stream.
1451By default it is disabled.
1452
1453@item channel
1454Set for which IR channel to display frequency response. By default is first channel
1455displayed. This option is used only when @var{response} is enabled.
1456
1457@item size
1458Set video stream size. This option is used only when @var{response} is enabled.
1459@end table
1460
1461Coefficients in @code{tf} format are separated by spaces and are in ascending
1462order.
1463
1464Coefficients in @code{zp} format are separated by spaces and order of coefficients
1465doesn't matter. Coefficients in @code{zp} format are complex numbers with @var{i}
1466imaginary unit.
1467
1468Different coefficients and gains can be provided for every channel, in such case
1469use '|' to separate coefficients or gains. Last provided coefficients will be
1470used for all remaining channels.
1471
1472@subsection Examples
1473
1474@itemize
1475@item
1476Apply 2 pole elliptic notch at around 5000Hz for 48000 Hz sample rate:
1477@example
1478aiir=k=1:z=7.957584807809675810E-1 -2.575128568908332300 3.674839853930788710 -2.57512875289799137 7.957586296317130880E-1:p=1 -2.86950072432325953 3.63022088054647218 -2.28075678147272232 6.361362326477423500E-1:f=tf:r=d
1479@end example
1480
1481@item
1482Same as above but in @code{zp} format:
1483@example
1484aiir=k=0.79575848078096756:z=0.80918701+0.58773007i 0.80918701-0.58773007i 0.80884700+0.58784055i 0.80884700-0.58784055i:p=0.63892345+0.59951235i 0.63892345-0.59951235i 0.79582691+0.44198673i 0.79582691-0.44198673i:f=zp:r=s
1485@end example
1486@end itemize
1487
1488@section alimiter
1489
1490The limiter prevents an input signal from rising over a desired threshold.
1491This limiter uses lookahead technology to prevent your signal from distorting.
1492It means that there is a small delay after the signal is processed. Keep in mind
1493that the delay it produces is the attack time you set.
1494
1495The filter accepts the following options:
1496
1497@table @option
1498@item level_in
1499Set input gain. Default is 1.
1500
1501@item level_out
1502Set output gain. Default is 1.
1503
1504@item limit
1505Don't let signals above this level pass the limiter. Default is 1.
1506
1507@item attack
1508The limiter will reach its attenuation level in this amount of time in
1509milliseconds. Default is 5 milliseconds.
1510
1511@item release
1512Come back from limiting to attenuation 1.0 in this amount of milliseconds.
1513Default is 50 milliseconds.
1514
1515@item asc
1516When gain reduction is always needed ASC takes care of releasing to an
1517average reduction level rather than reaching a reduction of 0 in the release
1518time.
1519
1520@item asc_level
1521Select how much the release time is affected by ASC, 0 means nearly no changes
1522in release time while 1 produces higher release times.
1523
1524@item level
1525Auto level output signal. Default is enabled.
1526This normalizes audio back to 0dB if enabled.
1527@end table
1528
1529Depending on picked setting it is recommended to upsample input 2x or 4x times
1530with @ref{aresample} before applying this filter.
1531
1532@section allpass
1533
1534Apply a two-pole all-pass filter with central frequency (in Hz)
1535@var{frequency}, and filter-width @var{width}.
1536An all-pass filter changes the audio's frequency to phase relationship
1537without changing its frequency to amplitude relationship.
1538
1539The filter accepts the following options:
1540
1541@table @option
1542@item frequency, f
1543Set frequency in Hz.
1544
1545@item width_type, t
1546Set method to specify band-width of filter.
1547@table @option
1548@item h
1549Hz
1550@item q
1551Q-Factor
1552@item o
1553octave
1554@item s
1555slope
1556@item k
1557kHz
1558@end table
1559
1560@item width, w
1561Specify the band-width of a filter in width_type units.
1562
1563@item mix, m
1564How much to use filtered signal in output. Default is 1.
1565Range is between 0 and 1.
1566
1567@item channels, c
1568Specify which channels to filter, by default all available are filtered.
1569
1570@item normalize, n
1571Normalize biquad coefficients, by default is disabled.
1572Enabling it will normalize magnitude response at DC to 0dB.
1573
1574@item order, o
1575Set the filter order, can be 1 or 2. Default is 2.
1576@end table
1577
1578@subsection Commands
1579
1580This filter supports the following commands:
1581@table @option
1582@item frequency, f
1583Change allpass frequency.
1584Syntax for the command is : "@var{frequency}"
1585
1586@item width_type, t
1587Change allpass width_type.
1588Syntax for the command is : "@var{width_type}"
1589
1590@item width, w
1591Change allpass width.
1592Syntax for the command is : "@var{width}"
1593
1594@item mix, m
1595Change allpass mix.
1596Syntax for the command is : "@var{mix}"
1597@end table
1598
1599@section aloop
1600
1601Loop audio samples.
1602
1603The filter accepts the following options:
1604
1605@table @option
1606@item loop
1607Set the number of loops. Setting this value to -1 will result in infinite loops.
1608Default is 0.
1609
1610@item size
1611Set maximal number of samples. Default is 0.
1612
1613@item start
1614Set first sample of loop. Default is 0.
1615@end table
1616
1617@anchor{amerge}
1618@section amerge
1619
1620Merge two or more audio streams into a single multi-channel stream.
1621
1622The filter accepts the following options:
1623
1624@table @option
1625
1626@item inputs
1627Set the number of inputs. Default is 2.
1628
1629@end table
1630
1631If the channel layouts of the inputs are disjoint, and therefore compatible,
1632the channel layout of the output will be set accordingly and the channels
1633will be reordered as necessary. If the channel layouts of the inputs are not
1634disjoint, the output will have all the channels of the first input then all
1635the channels of the second input, in that order, and the channel layout of
1636the output will be the default value corresponding to the total number of
1637channels.
1638
1639For example, if the first input is in 2.1 (FL+FR+LF) and the second input
1640is FC+BL+BR, then the output will be in 5.1, with the channels in the
1641following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
1642first input, b1 is the first channel of the second input).
1643
1644On the other hand, if both input are in stereo, the output channels will be
1645in the default order: a1, a2, b1, b2, and the channel layout will be
1646arbitrarily set to 4.0, which may or may not be the expected value.
1647
1648All inputs must have the same sample rate, and format.
1649
1650If inputs do not have the same duration, the output will stop with the
1651shortest.
1652
1653@subsection Examples
1654
1655@itemize
1656@item
1657Merge two mono files into a stereo stream:
1658@example
1659amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
1660@end example
1661
1662@item
1663Multiple merges assuming 1 video stream and 6 audio streams in @file{input.mkv}:
1664@example
1665ffmpeg -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
1666@end example
1667@end itemize
1668
1669@section amix
1670
1671Mixes multiple audio inputs into a single output.
1672
1673Note that this filter only supports float samples (the @var{amerge}
1674and @var{pan} audio filters support many formats). If the @var{amix}
1675input has integer samples then @ref{aresample} will be automatically
1676inserted to perform the conversion to float samples.
1677
1678For example
1679@example
1680ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
1681@end example
1682will mix 3 input audio streams to a single output with the same duration as the
1683first input and a dropout transition time of 3 seconds.
1684
1685It accepts the following parameters:
1686@table @option
1687
1688@item inputs
1689The number of inputs. If unspecified, it defaults to 2.
1690
1691@item duration
1692How to determine the end-of-stream.
1693@table @option
1694
1695@item longest
1696The duration of the longest input. (default)
1697
1698@item shortest
1699The duration of the shortest input.
1700
1701@item first
1702The duration of the first input.
1703
1704@end table
1705
1706@item dropout_transition
1707The transition time, in seconds, for volume renormalization when an input
1708stream ends. The default value is 2 seconds.
1709
1710@item weights
1711Specify weight of each input audio stream as sequence.
1712Each weight is separated by space. By default all inputs have same weight.
1713@end table
1714
1715@subsection Commands
1716
1717This filter supports the following commands:
1718@table @option
1719@item weights
1720Syntax is same as option with same name.
1721@end table
1722
1723@section amultiply
1724
1725Multiply first audio stream with second audio stream and store result
1726in output audio stream. Multiplication is done by multiplying each
1727sample from first stream with sample at same position from second stream.
1728
1729With this element-wise multiplication one can create amplitude fades and
1730amplitude modulations.
1731
1732@section anequalizer
1733
1734High-order parametric multiband equalizer for each channel.
1735
1736It accepts the following parameters:
1737@table @option
1738@item params
1739
1740This option string is in format:
1741"c@var{chn} f=@var{cf} w=@var{w} g=@var{g} t=@var{f} | ..."
1742Each equalizer band is separated by '|'.
1743
1744@table @option
1745@item chn
1746Set channel number to which equalization will be applied.
1747If input doesn't have that channel the entry is ignored.
1748
1749@item f
1750Set central frequency for band.
1751If input doesn't have that frequency the entry is ignored.
1752
1753@item w
1754Set band width in hertz.
1755
1756@item g
1757Set band gain in dB.
1758
1759@item t
1760Set filter type for band, optional, can be:
1761
1762@table @samp
1763@item 0
1764Butterworth, this is default.
1765
1766@item 1
1767Chebyshev type 1.
1768
1769@item 2
1770Chebyshev type 2.
1771@end table
1772@end table
1773
1774@item curves
1775With this option activated frequency response of anequalizer is displayed
1776in video stream.
1777
1778@item size
1779Set video stream size. Only useful if curves option is activated.
1780
1781@item mgain
1782Set max gain that will be displayed. Only useful if curves option is activated.
1783Setting this to a reasonable value makes it possible to display gain which is derived from
1784neighbour bands which are too close to each other and thus produce higher gain
1785when both are activated.
1786
1787@item fscale
1788Set frequency scale used to draw frequency response in video output.
1789Can be linear or logarithmic. Default is logarithmic.
1790
1791@item colors
1792Set color for each channel curve which is going to be displayed in video stream.
1793This is list of color names separated by space or by '|'.
1794Unrecognised or missing colors will be replaced by white color.
1795@end table
1796
1797@subsection Examples
1798
1799@itemize
1800@item
1801Lower gain by 10 of central frequency 200Hz and width 100 Hz
1802for first 2 channels using Chebyshev type 1 filter:
1803@example
1804anequalizer=c0 f=200 w=100 g=-10 t=1|c1 f=200 w=100 g=-10 t=1
1805@end example
1806@end itemize
1807
1808@subsection Commands
1809
1810This filter supports the following commands:
1811@table @option
1812@item change
1813Alter existing filter parameters.
1814Syntax for the commands is : "@var{fN}|f=@var{freq}|w=@var{width}|g=@var{gain}"
1815
1816@var{fN} is existing filter number, starting from 0, if no such filter is available
1817error is returned.
1818@var{freq} set new frequency parameter.
1819@var{width} set new width parameter in herz.
1820@var{gain} set new gain parameter in dB.
1821
1822Full filter invocation with asendcmd may look like this:
1823asendcmd=c='4.0 anequalizer change 0|f=200|w=50|g=1',anequalizer=...
1824@end table
1825
1826@section anlmdn
1827
1828Reduce broadband noise in audio samples using Non-Local Means algorithm.
1829
1830Each sample is adjusted by looking for other samples with similar contexts. This
1831context similarity is defined by comparing their surrounding patches of size
1832@option{p}. Patches are searched in an area of @option{r} around the sample.
1833
1834The filter accepts the following options:
1835
1836@table @option
1837@item s
1838Set denoising strength. Allowed range is from 0.00001 to 10. Default value is 0.00001.
1839
1840@item p
1841Set patch radius duration. Allowed range is from 1 to 100 milliseconds.
1842Default value is 2 milliseconds.
1843
1844@item r
1845Set research radius duration. Allowed range is from 2 to 300 milliseconds.
1846Default value is 6 milliseconds.
1847
1848@item o
1849Set the output mode.
1850
1851It accepts the following values:
1852@table @option
1853@item i
1854Pass input unchanged.
1855
1856@item o
1857Pass noise filtered out.
1858
1859@item n
1860Pass only noise.
1861
1862Default value is @var{o}.
1863@end table
1864
1865@item m
1866Set smooth factor. Default value is @var{11}. Allowed range is from @var{1} to @var{15}.
1867@end table
1868
1869@subsection Commands
1870
1871This filter supports the following commands:
1872@table @option
1873@item s
1874Change denoise strength. Argument is single float number.
1875Syntax for the command is : "@var{s}"
1876
1877@item o
1878Change output mode.
1879Syntax for the command is : "i", "o" or "n" string.
1880@end table
1881
1882@section anlms
1883Apply Normalized Least-Mean-Squares algorithm to the first audio stream using the second audio stream.
1884
1885This adaptive filter is used to mimic a desired filter by finding the filter coefficients that
1886relate to producing the least mean square of the error signal (difference between the desired,
18872nd input audio stream and the actual signal, the 1st input audio stream).
1888
1889A description of the accepted options follows.
1890
1891@table @option
1892@item order
1893Set filter order.
1894
1895@item mu
1896Set filter mu.
1897
1898@item eps
1899Set the filter eps.
1900
1901@item leakage
1902Set the filter leakage.
1903
1904@item out_mode
1905It accepts the following values:
1906@table @option
1907@item i
1908Pass the 1st input.
1909
1910@item d
1911Pass the 2nd input.
1912
1913@item o
1914Pass filtered samples.
1915
1916@item n
1917Pass difference between desired and filtered samples.
1918
1919Default value is @var{o}.
1920@end table
1921@end table
1922
1923@subsection Examples
1924
1925@itemize
1926@item
1927One of many usages of this filter is noise reduction, input audio is filtered
1928with same samples that are delayed by fixed amount, one such example for stereo audio is:
1929@example
1930asplit[a][b],[a]adelay=32S|32S[a],[b][a]anlms=order=128:leakage=0.0005:mu=.5:out_mode=o
1931@end example
1932@end itemize
1933
1934@subsection Commands
1935
1936This filter supports the same commands as options, excluding option @code{order}.
1937
1938@section anull
1939
1940Pass the audio source unchanged to the output.
1941
1942@section apad
1943
1944Pad the end of an audio stream with silence.
1945
1946This can be used together with @command{ffmpeg} @option{-shortest} to
1947extend audio streams to the same length as the video stream.
1948
1949A description of the accepted options follows.
1950
1951@table @option
1952@item packet_size
1953Set silence packet size. Default value is 4096.
1954
1955@item pad_len
1956Set the number of samples of silence to add to the end. After the
1957value is reached, the stream is terminated. This option is mutually
1958exclusive with @option{whole_len}.
1959
1960@item whole_len
1961Set the minimum total number of samples in the output audio stream. If
1962the value is longer than the input audio length, silence is added to
1963the end, until the value is reached. This option is mutually exclusive
1964with @option{pad_len}.
1965
1966@item pad_dur
1967Specify the duration of samples of silence to add. See
1968@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
1969for the accepted syntax. Used only if set to non-zero value.
1970
1971@item whole_dur
1972Specify the minimum total duration in the output audio stream. See
1973@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
1974for the accepted syntax. Used only if set to non-zero value. If the value is longer than
1975the input audio length, silence is added to the end, until the value is reached.
1976This option is mutually exclusive with @option{pad_dur}
1977@end table
1978
1979If neither the @option{pad_len} nor the @option{whole_len} nor @option{pad_dur}
1980nor @option{whole_dur} option is set, the filter will add silence to the end of
1981the input stream indefinitely.
1982
1983@subsection Examples
1984
1985@itemize
1986@item
1987Add 1024 samples of silence to the end of the input:
1988@example
1989apad=pad_len=1024
1990@end example
1991
1992@item
1993Make sure the audio output will contain at least 10000 samples, pad
1994the input with silence if required:
1995@example
1996apad=whole_len=10000
1997@end example
1998
1999@item
2000Use @command{ffmpeg} to pad the audio input with silence, so that the
2001video stream will always result the shortest and will be converted
2002until the end in the output file when using the @option{shortest}
2003option:
2004@example
2005ffmpeg -i VIDEO -i AUDIO -filter_complex "[1:0]apad" -shortest OUTPUT
2006@end example
2007@end itemize
2008
2009@section aphaser
2010Add a phasing effect to the input audio.
2011
2012A phaser filter creates series of peaks and troughs in the frequency spectrum.
2013The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
2014
2015A description of the accepted parameters follows.
2016
2017@table @option
2018@item in_gain
2019Set input gain. Default is 0.4.
2020
2021@item out_gain
2022Set output gain. Default is 0.74
2023
2024@item delay
2025Set delay in milliseconds. Default is 3.0.
2026
2027@item decay
2028Set decay. Default is 0.4.
2029
2030@item speed
2031Set modulation speed in Hz. Default is 0.5.
2032
2033@item type
2034Set modulation type. Default is triangular.
2035
2036It accepts the following values:
2037@table @samp
2038@item triangular, t
2039@item sinusoidal, s
2040@end table
2041@end table
2042
2043@section apulsator
2044
2045Audio pulsator is something between an autopanner and a tremolo.
2046But it can produce funny stereo effects as well. Pulsator changes the volume
2047of the left and right channel based on a LFO (low frequency oscillator) with
2048different waveforms and shifted phases.
2049This filter have the ability to define an offset between left and right
2050channel. An offset of 0 means that both LFO shapes match each other.
2051The left and right channel are altered equally - a conventional tremolo.
2052An offset of 50% means that the shape of the right channel is exactly shifted
2053in phase (or moved backwards about half of the frequency) - pulsator acts as
2054an autopanner. At 1 both curves match again. Every setting in between moves the
2055phase shift gapless between all stages and produces some "bypassing" sounds with
2056sine and triangle waveforms. The more you set the offset near 1 (starting from
2057the 0.5) the faster the signal passes from the left to the right speaker.
2058
2059The filter accepts the following options:
2060
2061@table @option
2062@item level_in
2063Set input gain. By default it is 1. Range is [0.015625 - 64].
2064
2065@item level_out
2066Set output gain. By default it is 1. Range is [0.015625 - 64].
2067
2068@item mode
2069Set waveform shape the LFO will use. Can be one of: sine, triangle, square,
2070sawup or sawdown. Default is sine.
2071
2072@item amount
2073Set modulation. Define how much of original signal is affected by the LFO.
2074
2075@item offset_l
2076Set left channel offset. Default is 0. Allowed range is [0 - 1].
2077
2078@item offset_r
2079Set right channel offset. Default is 0.5. Allowed range is [0 - 1].
2080
2081@item width
2082Set pulse width. Default is 1. Allowed range is [0 - 2].
2083
2084@item timing
2085Set possible timing mode. Can be one of: bpm, ms or hz. Default is hz.
2086
2087@item bpm
2088Set bpm. Default is 120. Allowed range is [30 - 300]. Only used if timing
2089is set to bpm.
2090
2091@item ms
2092Set ms. Default is 500. Allowed range is [10 - 2000]. Only used if timing
2093is set to ms.
2094
2095@item hz
2096Set frequency in Hz. Default is 2. Allowed range is [0.01 - 100]. Only used
2097if timing is set to hz.
2098@end table
2099
2100@anchor{aresample}
2101@section aresample
2102
2103Resample the input audio to the specified parameters, using the
2104libswresample library. If none are specified then the filter will
2105automatically convert between its input and output.
2106
2107This filter is also able to stretch/squeeze the audio data to make it match
2108the timestamps or to inject silence / cut out audio to make it match the
2109timestamps, do a combination of both or do neither.
2110
2111The filter accepts the syntax
2112[@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
2113expresses a sample rate and @var{resampler_options} is a list of
2114@var{key}=@var{value} pairs, separated by ":". See the
2115@ref{Resampler Options,,"Resampler Options" section in the
2116ffmpeg-resampler(1) manual,ffmpeg-resampler}
2117for the complete list of supported options.
2118
2119@subsection Examples
2120
2121@itemize
2122@item
2123Resample the input audio to 44100Hz:
2124@example
2125aresample=44100
2126@end example
2127
2128@item
2129Stretch/squeeze samples to the given timestamps, with a maximum of 1000
2130samples per second compensation:
2131@example
2132aresample=async=1000
2133@end example
2134@end itemize
2135
2136@section areverse
2137
2138Reverse an audio clip.
2139
2140Warning: This filter requires memory to buffer the entire clip, so trimming
2141is suggested.
2142
2143@subsection Examples
2144
2145@itemize
2146@item
2147Take the first 5 seconds of a clip, and reverse it.
2148@example
2149atrim=end=5,areverse
2150@end example
2151@end itemize
2152
2153@section arnndn
2154
2155Reduce noise from speech using Recurrent Neural Networks.
2156
2157This filter accepts the following options:
2158
2159@table @option
2160@item model, m
2161Set train model file to load. This option is always required.
2162@end table
2163
2164@section asetnsamples
2165
2166Set the number of samples per each output audio frame.
2167
2168The last output packet may contain a different number of samples, as
2169the filter will flush all the remaining samples when the input audio
2170signals its end.
2171
2172The filter accepts the following options:
2173
2174@table @option
2175
2176@item nb_out_samples, n
2177Set the number of frames per each output audio frame. The number is
2178intended as the number of samples @emph{per each channel}.
2179Default value is 1024.
2180
2181@item pad, p
2182If set to 1, the filter will pad the last audio frame with zeroes, so
2183that the last frame will contain the same number of samples as the
2184previous ones. Default value is 1.
2185@end table
2186
2187For example, to set the number of per-frame samples to 1234 and
2188disable padding for the last frame, use:
2189@example
2190asetnsamples=n=1234:p=0
2191@end example
2192
2193@section asetrate
2194
2195Set the sample rate without altering the PCM data.
2196This will result in a change of speed and pitch.
2197
2198The filter accepts the following options:
2199
2200@table @option
2201@item sample_rate, r
2202Set the output sample rate. Default is 44100 Hz.
2203@end table
2204
2205@section ashowinfo
2206
2207Show a line containing various information for each input audio frame.
2208The input audio is not modified.
2209
2210The shown line contains a sequence of key/value pairs of the form
2211@var{key}:@var{value}.
2212
2213The following values are shown in the output:
2214
2215@table @option
2216@item n
2217The (sequential) number of the input frame, starting from 0.
2218
2219@item pts
2220The presentation timestamp of the input frame, in time base units; the time base
2221depends on the filter input pad, and is usually 1/@var{sample_rate}.
2222
2223@item pts_time
2224The presentation timestamp of the input frame in seconds.
2225
2226@item pos
2227position of the frame in the input stream, -1 if this information in
2228unavailable and/or meaningless (for example in case of synthetic audio)
2229
2230@item fmt
2231The sample format.
2232
2233@item chlayout
2234The channel layout.
2235
2236@item rate
2237The sample rate for the audio frame.
2238
2239@item nb_samples
2240The number of samples (per channel) in the frame.
2241
2242@item checksum
2243The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
2244audio, the data is treated as if all the planes were concatenated.
2245
2246@item plane_checksums
2247A list of Adler-32 checksums for each data plane.
2248@end table
2249
2250@section asoftclip
2251Apply audio soft clipping.
2252
2253Soft clipping is a type of distortion effect where the amplitude of a signal is saturated
2254along a smooth curve, rather than the abrupt shape of hard-clipping.
2255
2256This filter accepts the following options:
2257
2258@table @option
2259@item type
2260Set type of soft-clipping.
2261
2262It accepts the following values:
2263@table @option
2264@item tanh
2265@item atan
2266@item cubic
2267@item exp
2268@item alg
2269@item quintic
2270@item sin
2271@end table
2272
2273@item param
2274Set additional parameter which controls sigmoid function.
2275@end table
2276
2277@subsection Commands
2278
2279This filter supports the all above options as @ref{commands}.
2280
2281@section asr
2282Automatic Speech Recognition
2283
2284This filter uses PocketSphinx for speech recognition. To enable
2285compilation of this filter, you need to configure FFmpeg with
2286@code{--enable-pocketsphinx}.
2287
2288It accepts the following options:
2289
2290@table @option
2291@item rate
2292Set sampling rate of input audio. Defaults is @code{16000}.
2293This need to match speech models, otherwise one will get poor results.
2294
2295@item hmm
2296Set dictionary containing acoustic model files.
2297
2298@item dict
2299Set pronunciation dictionary.
2300
2301@item lm
2302Set language model file.
2303
2304@item lmctl
2305Set language model set.
2306
2307@item lmname
2308Set which language model to use.
2309
2310@item logfn
2311Set output for log messages.
2312@end table
2313
2314The filter exports recognized speech as the frame metadata @code{lavfi.asr.text}.
2315
2316@anchor{astats}
2317@section astats
2318
2319Display time domain statistical information about the audio channels.
2320Statistics are calculated and displayed for each audio channel and,
2321where applicable, an overall figure is also given.
2322
2323It accepts the following option:
2324@table @option
2325@item length
2326Short window length in seconds, used for peak and trough RMS measurement.
2327Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.01 - 10]}.
2328
2329@item metadata
2330
2331Set metadata injection. All the metadata keys are prefixed with @code{lavfi.astats.X},
2332where @code{X} is channel number starting from 1 or string @code{Overall}. Default is
2333disabled.
2334
2335Available keys for each channel are:
2336DC_offset
2337Min_level
2338Max_level
2339Min_difference
2340Max_difference
2341Mean_difference
2342RMS_difference
2343Peak_level
2344RMS_peak
2345RMS_trough
2346Crest_factor
2347Flat_factor
2348Peak_count
2349Noise_floor
2350Noise_floor_count
2351Bit_depth
2352Dynamic_range
2353Zero_crossings
2354Zero_crossings_rate
2355Number_of_NaNs
2356Number_of_Infs
2357Number_of_denormals
2358
2359and for Overall:
2360DC_offset
2361Min_level
2362Max_level
2363Min_difference
2364Max_difference
2365Mean_difference
2366RMS_difference
2367Peak_level
2368RMS_level
2369RMS_peak
2370RMS_trough
2371Flat_factor
2372Peak_count
2373Noise_floor
2374Noise_floor_count
2375Bit_depth
2376Number_of_samples
2377Number_of_NaNs
2378Number_of_Infs
2379Number_of_denormals
2380
2381For example full key look like this @code{lavfi.astats.1.DC_offset} or
2382this @code{lavfi.astats.Overall.Peak_count}.
2383
2384For description what each key means read below.
2385
2386@item reset
2387Set number of frame after which stats are going to be recalculated.
2388Default is disabled.
2389
2390@item measure_perchannel
2391Select the entries which need to be measured per channel. The metadata keys can
2392be used as flags, default is @option{all} which measures everything.
2393@option{none} disables all per channel measurement.
2394
2395@item measure_overall
2396Select the entries which need to be measured overall. The metadata keys can
2397be used as flags, default is @option{all} which measures everything.
2398@option{none} disables all overall measurement.
2399
2400@end table
2401
2402A description of each shown parameter follows:
2403
2404@table @option
2405@item DC offset
2406Mean amplitude displacement from zero.
2407
2408@item Min level
2409Minimal sample level.
2410
2411@item Max level
2412Maximal sample level.
2413
2414@item Min difference
2415Minimal difference between two consecutive samples.
2416
2417@item Max difference
2418Maximal difference between two consecutive samples.
2419
2420@item Mean difference
2421Mean difference between two consecutive samples.
2422The average of each difference between two consecutive samples.
2423
2424@item RMS difference
2425Root Mean Square difference between two consecutive samples.
2426
2427@item Peak level dB
2428@item RMS level dB
2429Standard peak and RMS level measured in dBFS.
2430
2431@item RMS peak dB
2432@item RMS trough dB
2433Peak and trough values for RMS level measured over a short window.
2434
2435@item Crest factor
2436Standard ratio of peak to RMS level (note: not in dB).
2437
2438@item Flat factor
2439Flatness (i.e. consecutive samples with the same value) of the signal at its peak levels
2440(i.e. either @var{Min level} or @var{Max level}).
2441
2442@item Peak count
2443Number of occasions (not the number of samples) that the signal attained either
2444@var{Min level} or @var{Max level}.
2445
2446@item Noise floor dB
2447Minimum local peak measured in dBFS over a short window.
2448
2449@item Noise floor count
2450Number of occasions (not the number of samples) that the signal attained
2451@var{Noise floor}.
2452
2453@item Bit depth
2454Overall bit depth of audio. Number of bits used for each sample.
2455
2456@item Dynamic range
2457Measured dynamic range of audio in dB.
2458
2459@item Zero crossings
2460Number of points where the waveform crosses the zero level axis.
2461
2462@item Zero crossings rate
2463Rate of Zero crossings and number of audio samples.
2464@end table
2465
2466@section asubboost
2467Boost subwoofer frequencies.
2468
2469The filter accepts the following options:
2470
2471@table @option
2472@item dry
2473Set dry gain, how much of original signal is kept. Allowed range is from 0 to 1.
2474Default value is 0.5.
2475
2476@item wet
2477Set wet gain, how much of filtered signal is kept. Allowed range is from 0 to 1.
2478Default value is 0.8.
2479
2480@item decay
2481Set delay line decay gain value. Allowed range is from 0 to 1.
2482Default value is 0.7.
2483
2484@item feedback
2485Set delay line feedback gain value. Allowed range is from 0 to 1.
2486Default value is 0.5.
2487
2488@item cutoff
2489Set cutoff frequency in herz. Allowed range is 50 to 900.
2490Default value is 100.
2491
2492@item slope
2493Set slope amount for cutoff frequency. Allowed range is 0.0001 to 1.
2494Default value is 0.5.
2495
2496@item delay
2497Set delay. Allowed range is from 1 to 100.
2498Default value is 20.
2499@end table
2500
2501@subsection Commands
2502
2503This filter supports the all above options as @ref{commands}.
2504
2505@section atempo
2506
2507Adjust audio tempo.
2508
2509The filter accepts exactly one parameter, the audio tempo. If not
2510specified then the filter will assume nominal 1.0 tempo. Tempo must
2511be in the [0.5, 100.0] range.
2512
2513Note that tempo greater than 2 will skip some samples rather than
2514blend them in.  If for any reason this is a concern it is always
2515possible to daisy-chain several instances of atempo to achieve the
2516desired product tempo.
2517
2518@subsection Examples
2519
2520@itemize
2521@item
2522Slow down audio to 80% tempo:
2523@example
2524atempo=0.8
2525@end example
2526
2527@item
2528To speed up audio to 300% tempo:
2529@example
2530atempo=3
2531@end example
2532
2533@item
2534To speed up audio to 300% tempo by daisy-chaining two atempo instances:
2535@example
2536atempo=sqrt(3),atempo=sqrt(3)
2537@end example
2538@end itemize
2539
2540@subsection Commands
2541
2542This filter supports the following commands:
2543@table @option
2544@item tempo
2545Change filter tempo scale factor.
2546Syntax for the command is : "@var{tempo}"
2547@end table
2548
2549@section atrim
2550
2551Trim the input so that the output contains one continuous subpart of the input.
2552
2553It accepts the following parameters:
2554@table @option
2555@item start
2556Timestamp (in seconds) of the start of the section to keep. I.e. the audio
2557sample with the timestamp @var{start} will be the first sample in the output.
2558
2559@item end
2560Specify time of the first audio sample that will be dropped, i.e. the
2561audio sample immediately preceding the one with the timestamp @var{end} will be
2562the last sample in the output.
2563
2564@item start_pts
2565Same as @var{start}, except this option sets the start timestamp in samples
2566instead of seconds.
2567
2568@item end_pts
2569Same as @var{end}, except this option sets the end timestamp in samples instead
2570of seconds.
2571
2572@item duration
2573The maximum duration of the output in seconds.
2574
2575@item start_sample
2576The number of the first sample that should be output.
2577
2578@item end_sample
2579The number of the first sample that should be dropped.
2580@end table
2581
2582@option{start}, @option{end}, and @option{duration} are expressed as time
2583duration specifications; see
2584@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
2585
2586Note that the first two sets of the start/end options and the @option{duration}
2587option look at the frame timestamp, while the _sample options simply count the
2588samples that pass through the filter. So start/end_pts and start/end_sample will
2589give different results when the timestamps are wrong, inexact or do not start at
2590zero. Also note that this filter does not modify the timestamps. If you wish
2591to have the output timestamps start at zero, insert the asetpts filter after the
2592atrim filter.
2593
2594If multiple start or end options are set, this filter tries to be greedy and
2595keep all samples that match at least one of the specified constraints. To keep
2596only the part that matches all the constraints at once, chain multiple atrim
2597filters.
2598
2599The defaults are such that all the input is kept. So it is possible to set e.g.
2600just the end values to keep everything before the specified time.
2601
2602Examples:
2603@itemize
2604@item
2605Drop everything except the second minute of input:
2606@example
2607ffmpeg -i INPUT -af atrim=60:120
2608@end example
2609
2610@item
2611Keep only the first 1000 samples:
2612@example
2613ffmpeg -i INPUT -af atrim=end_sample=1000
2614@end example
2615
2616@end itemize
2617
2618@section axcorrelate
2619Calculate normalized cross-correlation between two input audio streams.
2620
2621Resulted samples are always between -1 and 1 inclusive.
2622If result is 1 it means two input samples are highly correlated in that selected segment.
2623Result 0 means they are not correlated at all.
2624If result is -1 it means two input samples are out of phase, which means they cancel each
2625other.
2626
2627The filter accepts the following options:
2628
2629@table @option
2630@item size
2631Set size of segment over which cross-correlation is calculated.
2632Default is 256. Allowed range is from 2 to 131072.
2633
2634@item algo
2635Set algorithm for cross-correlation. Can be @code{slow} or @code{fast}.
2636Default is @code{slow}. Fast algorithm assumes mean values over any given segment
2637are always zero and thus need much less calculations to make.
2638This is generally not true, but is valid for typical audio streams.
2639@end table
2640
2641@subsection Examples
2642
2643@itemize
2644@item
2645Calculate correlation between channels in stereo audio stream:
2646@example
2647ffmpeg -i stereo.wav -af channelsplit,axcorrelate=size=1024:algo=fast correlation.wav
2648@end example
2649@end itemize
2650
2651@section bandpass
2652
2653Apply a two-pole Butterworth band-pass filter with central
2654frequency @var{frequency}, and (3dB-point) band-width width.
2655The @var{csg} option selects a constant skirt gain (peak gain = Q)
2656instead of the default: constant 0dB peak gain.
2657The filter roll off at 6dB per octave (20dB per decade).
2658
2659The filter accepts the following options:
2660
2661@table @option
2662@item frequency, f
2663Set the filter's central frequency. Default is @code{3000}.
2664
2665@item csg
2666Constant skirt gain if set to 1. Defaults to 0.
2667
2668@item width_type, t
2669Set method to specify band-width of filter.
2670@table @option
2671@item h
2672Hz
2673@item q
2674Q-Factor
2675@item o
2676octave
2677@item s
2678slope
2679@item k
2680kHz
2681@end table
2682
2683@item width, w
2684Specify the band-width of a filter in width_type units.
2685
2686@item mix, m
2687How much to use filtered signal in output. Default is 1.
2688Range is between 0 and 1.
2689
2690@item channels, c
2691Specify which channels to filter, by default all available are filtered.
2692
2693@item normalize, n
2694Normalize biquad coefficients, by default is disabled.
2695Enabling it will normalize magnitude response at DC to 0dB.
2696@end table
2697
2698@subsection Commands
2699
2700This filter supports the following commands:
2701@table @option
2702@item frequency, f
2703Change bandpass frequency.
2704Syntax for the command is : "@var{frequency}"
2705
2706@item width_type, t
2707Change bandpass width_type.
2708Syntax for the command is : "@var{width_type}"
2709
2710@item width, w
2711Change bandpass width.
2712Syntax for the command is : "@var{width}"
2713
2714@item mix, m
2715Change bandpass mix.
2716Syntax for the command is : "@var{mix}"
2717@end table
2718
2719@section bandreject
2720
2721Apply a two-pole Butterworth band-reject filter with central
2722frequency @var{frequency}, and (3dB-point) band-width @var{width}.
2723The filter roll off at 6dB per octave (20dB per decade).
2724
2725The filter accepts the following options:
2726
2727@table @option
2728@item frequency, f
2729Set the filter's central frequency. Default is @code{3000}.
2730
2731@item width_type, t
2732Set method to specify band-width of filter.
2733@table @option
2734@item h
2735Hz
2736@item q
2737Q-Factor
2738@item o
2739octave
2740@item s
2741slope
2742@item k
2743kHz
2744@end table
2745
2746@item width, w
2747Specify the band-width of a filter in width_type units.
2748
2749@item mix, m
2750How much to use filtered signal in output. Default is 1.
2751Range is between 0 and 1.
2752
2753@item channels, c
2754Specify which channels to filter, by default all available are filtered.
2755
2756@item normalize, n
2757Normalize biquad coefficients, by default is disabled.
2758Enabling it will normalize magnitude response at DC to 0dB.
2759@end table
2760
2761@subsection Commands
2762
2763This filter supports the following commands:
2764@table @option
2765@item frequency, f
2766Change bandreject frequency.
2767Syntax for the command is : "@var{frequency}"
2768
2769@item width_type, t
2770Change bandreject width_type.
2771Syntax for the command is : "@var{width_type}"
2772
2773@item width, w
2774Change bandreject width.
2775Syntax for the command is : "@var{width}"
2776
2777@item mix, m
2778Change bandreject mix.
2779Syntax for the command is : "@var{mix}"
2780@end table
2781
2782@section bass, lowshelf
2783
2784Boost or cut the bass (lower) frequencies of the audio using a two-pole
2785shelving filter with a response similar to that of a standard
2786hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
2787
2788The filter accepts the following options:
2789
2790@table @option
2791@item gain, g
2792Give the gain at 0 Hz. Its useful range is about -20
2793(for a large cut) to +20 (for a large boost).
2794Beware of clipping when using a positive gain.
2795
2796@item frequency, f
2797Set the filter's central frequency and so can be used
2798to extend or reduce the frequency range to be boosted or cut.
2799The default value is @code{100} Hz.
2800
2801@item width_type, t
2802Set method to specify band-width of filter.
2803@table @option
2804@item h
2805Hz
2806@item q
2807Q-Factor
2808@item o
2809octave
2810@item s
2811slope
2812@item k
2813kHz
2814@end table
2815
2816@item width, w
2817Determine how steep is the filter's shelf transition.
2818
2819@item mix, m
2820How much to use filtered signal in output. Default is 1.
2821Range is between 0 and 1.
2822
2823@item channels, c
2824Specify which channels to filter, by default all available are filtered.
2825
2826@item normalize, n
2827Normalize biquad coefficients, by default is disabled.
2828Enabling it will normalize magnitude response at DC to 0dB.
2829@end table
2830
2831@subsection Commands
2832
2833This filter supports the following commands:
2834@table @option
2835@item frequency, f
2836Change bass frequency.
2837Syntax for the command is : "@var{frequency}"
2838
2839@item width_type, t
2840Change bass width_type.
2841Syntax for the command is : "@var{width_type}"
2842
2843@item width, w
2844Change bass width.
2845Syntax for the command is : "@var{width}"
2846
2847@item gain, g
2848Change bass gain.
2849Syntax for the command is : "@var{gain}"
2850
2851@item mix, m
2852Change bass mix.
2853Syntax for the command is : "@var{mix}"
2854@end table
2855
2856@section biquad
2857
2858Apply a biquad IIR filter with the given coefficients.
2859Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
2860are the numerator and denominator coefficients respectively.
2861and @var{channels}, @var{c} specify which channels to filter, by default all
2862available are filtered.
2863
2864@subsection Commands
2865
2866This filter supports the following commands:
2867@table @option
2868@item a0
2869@item a1
2870@item a2
2871@item b0
2872@item b1
2873@item b2
2874Change biquad parameter.
2875Syntax for the command is : "@var{value}"
2876
2877@item mix, m
2878How much to use filtered signal in output. Default is 1.
2879Range is between 0 and 1.
2880
2881@item channels, c
2882Specify which channels to filter, by default all available are filtered.
2883
2884@item normalize, n
2885Normalize biquad coefficients, by default is disabled.
2886Enabling it will normalize magnitude response at DC to 0dB.
2887@end table
2888
2889@section bs2b
2890Bauer stereo to binaural transformation, which improves headphone listening of
2891stereo audio records.
2892
2893To enable compilation of this filter you need to configure FFmpeg with
2894@code{--enable-libbs2b}.
2895
2896It accepts the following parameters:
2897@table @option
2898
2899@item profile
2900Pre-defined crossfeed level.
2901@table @option
2902
2903@item default
2904Default level (fcut=700, feed=50).
2905
2906@item cmoy
2907Chu Moy circuit (fcut=700, feed=60).
2908
2909@item jmeier
2910Jan Meier circuit (fcut=650, feed=95).
2911
2912@end table
2913
2914@item fcut
2915Cut frequency (in Hz).
2916
2917@item feed
2918Feed level (in Hz).
2919
2920@end table
2921
2922@section channelmap
2923
2924Remap input channels to new locations.
2925
2926It accepts the following parameters:
2927@table @option
2928@item map
2929Map channels from input to output. The argument is a '|'-separated list of
2930mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
2931@var{in_channel} form. @var{in_channel} can be either the name of the input
2932channel (e.g. FL for front left) or its index in the input channel layout.
2933@var{out_channel} is the name of the output channel or its index in the output
2934channel layout. If @var{out_channel} is not given then it is implicitly an
2935index, starting with zero and increasing by one for each mapping.
2936
2937@item channel_layout
2938The channel layout of the output stream.
2939@end table
2940
2941If no mapping is present, the filter will implicitly map input channels to
2942output channels, preserving indices.
2943
2944@subsection Examples
2945
2946@itemize
2947@item
2948For example, assuming a 5.1+downmix input MOV file,
2949@example
2950ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
2951@end example
2952will create an output WAV file tagged as stereo from the downmix channels of
2953the input.
2954
2955@item
2956To fix a 5.1 WAV improperly encoded in AAC's native channel order
2957@example
2958ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:5.1' out.wav
2959@end example
2960@end itemize
2961
2962@section channelsplit
2963
2964Split each channel from an input audio stream into a separate output stream.
2965
2966It accepts the following parameters:
2967@table @option
2968@item channel_layout
2969The channel layout of the input stream. The default is "stereo".
2970@item channels
2971A channel layout describing the channels to be extracted as separate output streams
2972or "all" to extract each input channel as a separate stream. The default is "all".
2973
2974Choosing channels not present in channel layout in the input will result in an error.
2975@end table
2976
2977@subsection Examples
2978
2979@itemize
2980@item
2981For example, assuming a stereo input MP3 file,
2982@example
2983ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
2984@end example
2985will create an output Matroska file with two audio streams, one containing only
2986the left channel and the other the right channel.
2987
2988@item
2989Split a 5.1 WAV file into per-channel files:
2990@example
2991ffmpeg -i in.wav -filter_complex
2992'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
2993-map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
2994front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
2995side_right.wav
2996@end example
2997
2998@item
2999Extract only LFE from a 5.1 WAV file:
3000@example
3001ffmpeg -i in.wav -filter_complex 'channelsplit=channel_layout=5.1:channels=LFE[LFE]'
3002-map '[LFE]' lfe.wav
3003@end example
3004@end itemize
3005
3006@section chorus
3007Add a chorus effect to the audio.
3008
3009Can make a single vocal sound like a chorus, but can also be applied to instrumentation.
3010
3011Chorus resembles an echo effect with a short delay, but whereas with echo the delay is
3012constant, with chorus, it is varied using using sinusoidal or triangular modulation.
3013The modulation depth defines the range the modulated delay is played before or after
3014the delay. Hence the delayed sound will sound slower or faster, that is the delayed
3015sound tuned around the original one, like in a chorus where some vocals are slightly
3016off key.
3017
3018It accepts the following parameters:
3019@table @option
3020@item in_gain
3021Set input gain. Default is 0.4.
3022
3023@item out_gain
3024Set output gain. Default is 0.4.
3025
3026@item delays
3027Set delays. A typical delay is around 40ms to 60ms.
3028
3029@item decays
3030Set decays.
3031
3032@item speeds
3033Set speeds.
3034
3035@item depths
3036Set depths.
3037@end table
3038
3039@subsection Examples
3040
3041@itemize
3042@item
3043A single delay:
3044@example
3045chorus=0.7:0.9:55:0.4:0.25:2
3046@end example
3047
3048@item
3049Two delays:
3050@example
3051chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3
3052@end example
3053
3054@item
3055Fuller sounding chorus with three delays:
3056@example
3057chorus=0.5:0.9:50|60|40:0.4|0.32|0.3:0.25|0.4|0.3:2|2.3|1.3
3058@end example
3059@end itemize
3060
3061@section compand
3062Compress or expand the audio's dynamic range.
3063
3064It accepts the following parameters:
3065
3066@table @option
3067
3068@item attacks
3069@item decays
3070A list of times in seconds for each channel over which the instantaneous level
3071of the input signal is averaged to determine its volume. @var{attacks} refers to
3072increase of volume and @var{decays} refers to decrease of volume. For most
3073situations, the attack time (response to the audio getting louder) should be
3074shorter than the decay time, because the human ear is more sensitive to sudden
3075loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
3076a typical value for decay is 0.8 seconds.
3077If specified number of attacks & decays is lower than number of channels, the last
3078set attack/decay will be used for all remaining channels.
3079
3080@item points
3081A list of points for the transfer function, specified in dB relative to the
3082maximum possible signal amplitude. Each key points list must be defined using
3083the following syntax: @code{x0/y0|x1/y1|x2/y2|....} or
3084@code{x0/y0 x1/y1 x2/y2 ....}
3085
3086The input values must be in strictly increasing order but the transfer function
3087does not have to be monotonically rising. The point @code{0/0} is assumed but
3088may be overridden (by @code{0/out-dBn}). Typical values for the transfer
3089function are @code{-70/-70|-60/-20|1/0}.
3090
3091@item soft-knee
3092Set the curve radius in dB for all joints. It defaults to 0.01.
3093
3094@item gain
3095Set the additional gain in dB to be applied at all points on the transfer
3096function. This allows for easy adjustment of the overall gain.
3097It defaults to 0.
3098
3099@item volume
3100Set an initial volume, in dB, to be assumed for each channel when filtering
3101starts. This permits the user to supply a nominal level initially, so that, for
3102example, a very large gain is not applied to initial signal levels before the
3103companding has begun to operate. A typical value for audio which is initially
3104quiet is -90 dB. It defaults to 0.
3105
3106@item delay
3107Set a delay, in seconds. The input audio is analyzed immediately, but audio is
3108delayed before being fed to the volume adjuster. Specifying a delay
3109approximately equal to the attack/decay times allows the filter to effectively
3110operate in predictive rather than reactive mode. It defaults to 0.
3111
3112@end table
3113
3114@subsection Examples
3115
3116@itemize
3117@item
3118Make music with both quiet and loud passages suitable for listening to in a
3119noisy environment:
3120@example
3121compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
3122@end example
3123
3124Another example for audio with whisper and explosion parts:
3125@example
3126compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0
3127@end example
3128
3129@item
3130A noise gate for when the noise is at a lower level than the signal:
3131@example
3132compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
3133@end example
3134
3135@item
3136Here is another noise gate, this time for when the noise is at a higher level
3137than the signal (making it, in some ways, similar to squelch):
3138@example
3139compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
3140@end example
3141
3142@item
31432:1 compression starting at -6dB:
3144@example
3145compand=points=-80/-80|-6/-6|0/-3.8|20/3.5
3146@end example
3147
3148@item
31492:1 compression starting at -9dB:
3150@example
3151compand=points=-80/-80|-9/-9|0/-5.3|20/2.9
3152@end example
3153
3154@item
31552:1 compression starting at -12dB:
3156@example
3157compand=points=-80/-80|-12/-12|0/-6.8|20/1.9
3158@end example
3159
3160@item
31612:1 compression starting at -18dB:
3162@example
3163compand=points=-80/-80|-18/-18|0/-9.8|20/0.7
3164@end example
3165
3166@item
31673:1 compression starting at -15dB:
3168@example
3169compand=points=-80/-80|-15/-15|0/-10.8|20/-5.2
3170@end example
3171
3172@item
3173Compressor/Gate:
3174@example
3175compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6
3176@end example
3177
3178@item
3179Expander:
3180@example
3181compand=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
3182@end example
3183
3184@item
3185Hard limiter at -6dB:
3186@example
3187compand=attacks=0:points=-80/-80|-6/-6|20/-6
3188@end example
3189
3190@item
3191Hard limiter at -12dB:
3192@example
3193compand=attacks=0:points=-80/-80|-12/-12|20/-12
3194@end example
3195
3196@item
3197Hard noise gate at -35 dB:
3198@example
3199compand=attacks=0:points=-80/-115|-35.1/-80|-35/-35|20/20
3200@end example
3201
3202@item
3203Soft limiter:
3204@example
3205compand=attacks=0:points=-80/-80|-12.4/-12.4|-6/-8|0/-6.8|20/-2.8
3206@end example
3207@end itemize
3208
3209@section compensationdelay
3210
3211Compensation Delay Line is a metric based delay to compensate differing
3212positions of microphones or speakers.
3213
3214For example, you have recorded guitar with two microphones placed in
3215different locations. Because the front of sound wave has fixed speed in
3216normal conditions, the phasing of microphones can vary and depends on
3217their location and interposition. The best sound mix can be achieved when
3218these microphones are in phase (synchronized). Note that a distance of
3219~30 cm between microphones makes one microphone capture the signal in
3220antiphase to the other microphone. That makes the final mix sound moody.
3221This filter helps to solve phasing problems by adding different delays
3222to each microphone track and make them synchronized.
3223
3224The best result can be reached when you take one track as base and
3225synchronize other tracks one by one with it.
3226Remember that synchronization/delay tolerance depends on sample rate, too.
3227Higher sample rates will give more tolerance.
3228
3229The filter accepts the following parameters:
3230
3231@table @option
3232@item mm
3233Set millimeters distance. This is compensation distance for fine tuning.
3234Default is 0.
3235
3236@item cm
3237Set cm distance. This is compensation distance for tightening distance setup.
3238Default is 0.
3239
3240@item m
3241Set meters distance. This is compensation distance for hard distance setup.
3242Default is 0.
3243
3244@item dry
3245Set dry amount. Amount of unprocessed (dry) signal.
3246Default is 0.
3247
3248@item wet
3249Set wet amount. Amount of processed (wet) signal.
3250Default is 1.
3251
3252@item temp
3253Set temperature in degrees Celsius. This is the temperature of the environment.
3254Default is 20.
3255@end table
3256
3257@section crossfeed
3258Apply headphone crossfeed filter.
3259
3260Crossfeed is the process of blending the left and right channels of stereo
3261audio recording.
3262It is mainly used to reduce extreme stereo separation of low frequencies.
3263
3264The intent is to produce more speaker like sound to the listener.
3265
3266The filter accepts the following options:
3267
3268@table @option
3269@item strength
3270Set strength of crossfeed. Default is 0.2. Allowed range is from 0 to 1.
3271This sets gain of low shelf filter for side part of stereo image.
3272Default is -6dB. Max allowed is -30db when strength is set to 1.
3273
3274@item range
3275Set soundstage wideness. Default is 0.5. Allowed range is from 0 to 1.
3276This sets cut off frequency of low shelf filter. Default is cut off near
32771550 Hz. With range set to 1 cut off frequency is set to 2100 Hz.
3278
3279@item slope
3280Set curve slope of low shelf filter. Default is 0.5.
3281Allowed range is from 0.01 to 1.
3282
3283@item level_in
3284Set input gain. Default is 0.9.
3285
3286@item level_out
3287Set output gain. Default is 1.
3288@end table
3289
3290@subsection Commands
3291
3292This filter supports the all above options as @ref{commands}.
3293
3294@section crystalizer
3295Simple algorithm to expand audio dynamic range.
3296
3297The filter accepts the following options:
3298
3299@table @option
3300@item i
3301Sets the intensity of effect (default: 2.0). Must be in range between 0.0
3302(unchanged sound) to 10.0 (maximum effect).
3303
3304@item c
3305Enable clipping. By default is enabled.
3306@end table
3307
3308@subsection Commands
3309
3310This filter supports the all above options as @ref{commands}.
3311
3312@section dcshift
3313Apply a DC shift to the audio.
3314
3315This can be useful to remove a DC offset (caused perhaps by a hardware problem
3316in the recording chain) from the audio. The effect of a DC offset is reduced
3317headroom and hence volume. The @ref{astats} filter can be used to determine if
3318a signal has a DC offset.
3319
3320@table @option
3321@item shift
3322Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift
3323the audio.
3324
3325@item limitergain
3326Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
3327used to prevent clipping.
3328@end table
3329
3330@section deesser
3331
3332Apply de-essing to the audio samples.
3333
3334@table @option
3335@item i
3336Set intensity for triggering de-essing. Allowed range is from 0 to 1.
3337Default is 0.
3338
3339@item m
3340Set amount of ducking on treble part of sound. Allowed range is from 0 to 1.
3341Default is 0.5.
3342
3343@item f
3344How much of original frequency content to keep when de-essing. Allowed range is from 0 to 1.
3345Default is 0.5.
3346
3347@item s
3348Set the output mode.
3349
3350It accepts the following values:
3351@table @option
3352@item i
3353Pass input unchanged.
3354
3355@item o
3356Pass ess filtered out.
3357
3358@item e
3359Pass only ess.
3360
3361Default value is @var{o}.
3362@end table
3363
3364@end table
3365
3366@section drmeter
3367Measure audio dynamic range.
3368
3369DR values of 14 and higher is found in very dynamic material. DR of 8 to 13
3370is found in transition material. And anything less that 8 have very poor dynamics
3371and is very compressed.
3372
3373The filter accepts the following options:
3374
3375@table @option
3376@item length
3377Set window length in seconds used to split audio into segments of equal length.
3378Default is 3 seconds.
3379@end table
3380
3381@section dynaudnorm
3382Dynamic Audio Normalizer.
3383
3384This filter applies a certain amount of gain to the input audio in order
3385to bring its peak magnitude to a target level (e.g. 0 dBFS). However, in
3386contrast to more "simple" normalization algorithms, the Dynamic Audio
3387Normalizer *dynamically* re-adjusts the gain factor to the input audio.
3388This allows for applying extra gain to the "quiet" sections of the audio
3389while avoiding distortions or clipping the "loud" sections. In other words:
3390The Dynamic Audio Normalizer will "even out" the volume of quiet and loud
3391sections, in the sense that the volume of each section is brought to the
3392same target level. Note, however, that the Dynamic Audio Normalizer achieves
3393this goal *without* applying "dynamic range compressing". It will retain 100%
3394of the dynamic range *within* each section of the audio file.
3395
3396@table @option
3397@item framelen, f
3398Set the frame length in milliseconds. In range from 10 to 8000 milliseconds.
3399Default is 500 milliseconds.
3400The Dynamic Audio Normalizer processes the input audio in small chunks,
3401referred to as frames. This is required, because a peak magnitude has no
3402meaning for just a single sample value. Instead, we need to determine the
3403peak magnitude for a contiguous sequence of sample values. While a "standard"
3404normalizer would simply use the peak magnitude of the complete file, the
3405Dynamic Audio Normalizer determines the peak magnitude individually for each
3406frame. The length of a frame is specified in milliseconds. By default, the
3407Dynamic Audio Normalizer uses a frame length of 500 milliseconds, which has
3408been found to give good results with most files.
3409Note that the exact frame length, in number of samples, will be determined
3410automatically, based on the sampling rate of the individual input audio file.
3411
3412@item gausssize, g
3413Set the Gaussian filter window size. In range from 3 to 301, must be odd
3414number. Default is 31.
3415Probably the most important parameter of the Dynamic Audio Normalizer is the
3416@code{window size} of the Gaussian smoothing filter. The filter's window size
3417is specified in frames, centered around the current frame. For the sake of
3418simplicity, this must be an odd number. Consequently, the default value of 31
3419takes into account the current frame, as well as the 15 preceding frames and
3420the 15 subsequent frames. Using a larger window results in a stronger
3421smoothing effect and thus in less gain variation, i.e. slower gain
3422adaptation. Conversely, using a smaller window results in a weaker smoothing
3423effect and thus in more gain variation, i.e. faster gain adaptation.
3424In other words, the more you increase this value, the more the Dynamic Audio
3425Normalizer will behave like a "traditional" normalization filter. On the
3426contrary, the more you decrease this value, the more the Dynamic Audio
3427Normalizer will behave like a dynamic range compressor.
3428
3429@item peak, p
3430Set the target peak value. This specifies the highest permissible magnitude
3431level for the normalized audio input. This filter will try to approach the
3432target peak magnitude as closely as possible, but at the same time it also
3433makes sure that the normalized signal will never exceed the peak magnitude.
3434A frame's maximum local gain factor is imposed directly by the target peak
3435magnitude. The default value is 0.95 and thus leaves a headroom of 5%*.
3436It is not recommended to go above this value.
3437
3438@item maxgain, m
3439Set the maximum gain factor. In range from 1.0 to 100.0. Default is 10.0.
3440The Dynamic Audio Normalizer determines the maximum possible (local) gain
3441factor for each input frame, i.e. the maximum gain factor that does not
3442result in clipping or distortion. The maximum gain factor is determined by
3443the frame's highest magnitude sample. However, the Dynamic Audio Normalizer
3444additionally bounds the frame's maximum gain factor by a predetermined
3445(global) maximum gain factor. This is done in order to avoid excessive gain
3446factors in "silent" or almost silent frames. By default, the maximum gain
3447factor is 10.0, For most inputs the default value should be sufficient and
3448it usually is not recommended to increase this value. Though, for input
3449with an extremely low overall volume level, it may be necessary to allow even
3450higher gain factors. Note, however, that the Dynamic Audio Normalizer does
3451not simply apply a "hard" threshold (i.e. cut off values above the threshold).
3452Instead, a "sigmoid" threshold function will be applied. This way, the
3453gain factors will smoothly approach the threshold value, but never exceed that
3454value.
3455
3456@item targetrms, r
3457Set the target RMS. In range from 0.0 to 1.0. Default is 0.0 - disabled.
3458By default, the Dynamic Audio Normalizer performs "peak" normalization.
3459This means that the maximum local gain factor for each frame is defined
3460(only) by the frame's highest magnitude sample. This way, the samples can
3461be amplified as much as possible without exceeding the maximum signal
3462level, i.e. without clipping. Optionally, however, the Dynamic Audio
3463Normalizer can also take into account the frame's root mean square,
3464abbreviated RMS. In electrical engineering, the RMS is commonly used to
3465determine the power of a time-varying signal. It is therefore considered
3466that the RMS is a better approximation of the "perceived loudness" than
3467just looking at the signal's peak magnitude. Consequently, by adjusting all
3468frames to a constant RMS value, a uniform "perceived loudness" can be
3469established. If a target RMS value has been specified, a frame's local gain
3470factor is defined as the factor that would result in exactly that RMS value.
3471Note, however, that the maximum local gain factor is still restricted by the
3472frame's highest magnitude sample, in order to prevent clipping.
3473
3474@item coupling, n
3475Enable channels coupling. By default is enabled.
3476By default, the Dynamic Audio Normalizer will amplify all channels by the same
3477amount. This means the same gain factor will be applied to all channels, i.e.
3478the maximum possible gain factor is determined by the "loudest" channel.
3479However, in some recordings, it may happen that the volume of the different
3480channels is uneven, e.g. one channel may be "quieter" than the other one(s).
3481In this case, this option can be used to disable the channel coupling. This way,
3482the gain factor will be determined independently for each channel, depending
3483only on the individual channel's highest magnitude sample. This allows for
3484harmonizing the volume of the different channels.
3485
3486@item correctdc, c
3487Enable DC bias correction. By default is disabled.
3488An audio signal (in the time domain) is a sequence of sample values.
3489In the Dynamic Audio Normalizer these sample values are represented in the
3490-1.0 to 1.0 range, regardless of the original input format. Normally, the
3491audio signal, or "waveform", should be centered around the zero point.
3492That means if we calculate the mean value of all samples in a file, or in a
3493single frame, then the result should be 0.0 or at least very close to that
3494value. If, however, there is a significant deviation of the mean value from
34950.0, in either positive or negative direction, this is referred to as a
3496DC bias or DC offset. Since a DC bias is clearly undesirable, the Dynamic
3497Audio Normalizer provides optional DC bias correction.
3498With DC bias correction enabled, the Dynamic Audio Normalizer will determine
3499the mean value, or "DC correction" offset, of each input frame and subtract
3500that value from all of the frame's sample values which ensures those samples
3501are centered around 0.0 again. Also, in order to avoid "gaps" at the frame
3502boundaries, the DC correction offset values will be interpolated smoothly
3503between neighbouring frames.
3504
3505@item altboundary, b
3506Enable alternative boundary mode. By default is disabled.
3507The Dynamic Audio Normalizer takes into account a certain neighbourhood
3508around each frame. This includes the preceding frames as well as the
3509subsequent frames. However, for the "boundary" frames, located at the very
3510beginning and at the very end of the audio file, not all neighbouring
3511frames are available. In particular, for the first few frames in the audio
3512file, the preceding frames are not known. And, similarly, for the last few
3513frames in the audio file, the subsequent frames are not known. Thus, the
3514question arises which gain factors should be assumed for the missing frames
3515in the "boundary" region. The Dynamic Audio Normalizer implements two modes
3516to deal with this situation. The default boundary mode assumes a gain factor
3517of exactly 1.0 for the missing frames, resulting in a smooth "fade in" and
3518"fade out" at the beginning and at the end of the input, respectively.
3519
3520@item compress, s
3521Set the compress factor. In range from 0.0 to 30.0. Default is 0.0.
3522By default, the Dynamic Audio Normalizer does not apply "traditional"
3523compression. This means that signal peaks will not be pruned and thus the
3524full dynamic range will be retained within each local neighbourhood. However,
3525in some cases it may be desirable to combine the Dynamic Audio Normalizer's
3526normalization algorithm with a more "traditional" compression.
3527For this purpose, the Dynamic Audio Normalizer provides an optional compression
3528(thresholding) function. If (and only if) the compression feature is enabled,
3529all input frames will be processed by a soft knee thresholding function prior
3530to the actual normalization process. Put simply, the thresholding function is
3531going to prune all samples whose magnitude exceeds a certain threshold value.
3532However, the Dynamic Audio Normalizer does not simply apply a fixed threshold
3533value. Instead, the threshold value will be adjusted for each individual
3534frame.
3535In general, smaller parameters result in stronger compression, and vice versa.
3536Values below 3.0 are not recommended, because audible distortion may appear.
3537
3538@item threshold, t
3539Set the target threshold value. This specifies the lowest permissible
3540magnitude level for the audio input which will be normalized.
3541If input frame volume is above this value frame will be normalized.
3542Otherwise frame may not be normalized at all. The default value is set
3543to 0, which means all input frames will be normalized.
3544This option is mostly useful if digital noise is not wanted to be amplified.
3545@end table
3546
3547@subsection Commands
3548
3549This filter supports the all above options as @ref{commands}.
3550
3551@section earwax
3552
3553Make audio easier to listen to on headphones.
3554
3555This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
3556so that when listened to on headphones the stereo image is moved from
3557inside your head (standard for headphones) to outside and in front of
3558the listener (standard for speakers).
3559
3560Ported from SoX.
3561
3562@section equalizer
3563
3564Apply a two-pole peaking equalisation (EQ) filter. With this
3565filter, the signal-level at and around a selected frequency can
3566be increased or decreased, whilst (unlike bandpass and bandreject
3567filters) that at all other frequencies is unchanged.
3568
3569In order to produce complex equalisation curves, this filter can
3570be given several times, each with a different central frequency.
3571
3572The filter accepts the following options:
3573
3574@table @option
3575@item frequency, f
3576Set the filter's central frequency in Hz.
3577
3578@item width_type, t
3579Set method to specify band-width of filter.
3580@table @option
3581@item h
3582Hz
3583@item q
3584Q-Factor
3585@item o
3586octave
3587@item s
3588slope
3589@item k
3590kHz
3591@end table
3592
3593@item width, w
3594Specify the band-width of a filter in width_type units.
3595
3596@item gain, g
3597Set the required gain or attenuation in dB.
3598Beware of clipping when using a positive gain.
3599
3600@item mix, m
3601How much to use filtered signal in output. Default is 1.
3602Range is between 0 and 1.
3603
3604@item channels, c
3605Specify which channels to filter, by default all available are filtered.
3606
3607@item normalize, n
3608Normalize biquad coefficients, by default is disabled.
3609Enabling it will normalize magnitude response at DC to 0dB.
3610@end table
3611
3612@subsection Examples
3613@itemize
3614@item
3615Attenuate 10 dB at 1000 Hz, with a bandwidth of 200 Hz:
3616@example
3617equalizer=f=1000:t=h:width=200:g=-10
3618@end example
3619
3620@item
3621Apply 2 dB gain at 1000 Hz with Q 1 and attenuate 5 dB at 100 Hz with Q 2:
3622@example
3623equalizer=f=1000:t=q:w=1:g=2,equalizer=f=100:t=q:w=2:g=-5
3624@end example
3625@end itemize
3626
3627@subsection Commands
3628
3629This filter supports the following commands:
3630@table @option
3631@item frequency, f
3632Change equalizer frequency.
3633Syntax for the command is : "@var{frequency}"
3634
3635@item width_type, t
3636Change equalizer width_type.
3637Syntax for the command is : "@var{width_type}"
3638
3639@item width, w
3640Change equalizer width.
3641Syntax for the command is : "@var{width}"
3642
3643@item gain, g
3644Change equalizer gain.
3645Syntax for the command is : "@var{gain}"
3646
3647@item mix, m
3648Change equalizer mix.
3649Syntax for the command is : "@var{mix}"
3650@end table
3651
3652@section extrastereo
3653
3654Linearly increases the difference between left and right channels which
3655adds some sort of "live" effect to playback.
3656
3657The filter accepts the following options:
3658
3659@table @option
3660@item m
3661Sets the difference coefficient (default: 2.5). 0.0 means mono sound
3662(average of both channels), with 1.0 sound will be unchanged, with
3663-1.0 left and right channels will be swapped.
3664
3665@item c
3666Enable clipping. By default is enabled.
3667@end table
3668
3669@subsection Commands
3670
3671This filter supports the all above options as @ref{commands}.
3672
3673@section firequalizer
3674Apply FIR Equalization using arbitrary frequency response.
3675
3676The filter accepts the following option:
3677
3678@table @option
3679@item gain
3680Set gain curve equation (in dB). The expression can contain variables:
3681@table @option
3682@item f
3683the evaluated frequency
3684@item sr
3685sample rate
3686@item ch
3687channel number, set to 0 when multichannels evaluation is disabled
3688@item chid
3689channel id, see libavutil/channel_layout.h, set to the first channel id when
3690multichannels evaluation is disabled
3691@item chs
3692number of channels
3693@item chlayout
3694channel_layout, see libavutil/channel_layout.h
3695
3696@end table
3697and functions:
3698@table @option
3699@item gain_interpolate(f)
3700interpolate gain on frequency f based on gain_entry
3701@item cubic_interpolate(f)
3702same as gain_interpolate, but smoother
3703@end table
3704This option is also available as command. Default is @code{gain_interpolate(f)}.
3705
3706@item gain_entry
3707Set gain entry for gain_interpolate function. The expression can
3708contain functions:
3709@table @option
3710@item entry(f, g)
3711store gain entry at frequency f with value g
3712@end table
3713This option is also available as command.
3714
3715@item delay
3716Set filter delay in seconds. Higher value means more accurate.
3717Default is @code{0.01}.
3718
3719@item accuracy
3720Set filter accuracy in Hz. Lower value means more accurate.
3721Default is @code{5}.
3722
3723@item wfunc
3724Set window function. Acceptable values are:
3725@table @option
3726@item rectangular
3727rectangular window, useful when gain curve is already smooth
3728@item hann
3729hann window (default)
3730@item hamming
3731hamming window
3732@item blackman
3733blackman window
3734@item nuttall3
37353-terms continuous 1st derivative nuttall window
3736@item mnuttall3
3737minimum 3-terms discontinuous nuttall window
3738@item nuttall
37394-terms continuous 1st derivative nuttall window
3740@item bnuttall
3741minimum 4-terms discontinuous nuttall (blackman-nuttall) window
3742@item bharris
3743blackman-harris window
3744@item tukey
3745tukey window
3746@end table
3747
3748@item fixed
3749If enabled, use fixed number of audio samples. This improves speed when
3750filtering with large delay. Default is disabled.
3751
3752@item multi
3753Enable multichannels evaluation on gain. Default is disabled.
3754
3755@item zero_phase
3756Enable zero phase mode by subtracting timestamp to compensate delay.
3757Default is disabled.
3758
3759@item scale
3760Set scale used by gain. Acceptable values are:
3761@table @option
3762@item linlin
3763linear frequency, linear gain
3764@item linlog
3765linear frequency, logarithmic (in dB) gain (default)
3766@item loglin
3767logarithmic (in octave scale where 20 Hz is 0) frequency, linear gain
3768@item loglog
3769logarithmic frequency, logarithmic gain
3770@end table
3771
3772@item dumpfile
3773Set file for dumping, suitable for gnuplot.
3774
3775@item dumpscale
3776Set scale for dumpfile. Acceptable values are same with scale option.
3777Default is linlog.
3778
3779@item fft2
3780Enable 2-channel convolution using complex FFT. This improves speed significantly.
3781Default is disabled.
3782
3783@item min_phase
3784Enable minimum phase impulse response. Default is disabled.
3785@end table
3786
3787@subsection Examples
3788@itemize
3789@item
3790lowpass at 1000 Hz:
3791@example
3792firequalizer=gain='if(lt(f,1000), 0, -INF)'
3793@end example
3794@item
3795lowpass at 1000 Hz with gain_entry:
3796@example
3797firequalizer=gain_entry='entry(1000,0); entry(1001, -INF)'
3798@end example
3799@item
3800custom equalization:
3801@example
3802firequalizer=gain_entry='entry(100,0); entry(400, -4); entry(1000, -6); entry(2000, 0)'
3803@end example
3804@item
3805higher delay with zero phase to compensate delay:
3806@example
3807firequalizer=delay=0.1:fixed=on:zero_phase=on
3808@end example
3809@item
3810lowpass on left channel, highpass on right channel:
3811@example
3812firequalizer=gain='if(eq(chid,1), gain_interpolate(f), if(eq(chid,2), gain_interpolate(1e6+f), 0))'
3813:gain_entry='entry(1000, 0); entry(1001,-INF); entry(1e6+1000,0)':multi=on
3814@end example
3815@end itemize
3816
3817@section flanger
3818Apply a flanging effect to the audio.
3819
3820The filter accepts the following options:
3821
3822@table @option
3823@item delay
3824Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
3825
3826@item depth
3827Set added sweep delay in milliseconds. Range from 0 to 10. Default value is 2.
3828
3829@item regen
3830Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
3831Default value is 0.
3832
3833@item width
3834Set percentage of delayed signal mixed with original. Range from 0 to 100.
3835Default value is 71.
3836
3837@item speed
3838Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
3839
3840@item shape
3841Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
3842Default value is @var{sinusoidal}.
3843
3844@item phase
3845Set swept wave percentage-shift for multi channel. Range from 0 to 100.
3846Default value is 25.
3847
3848@item interp
3849Set delay-line interpolation, @var{linear} or @var{quadratic}.
3850Default is @var{linear}.
3851@end table
3852
3853@section haas
3854Apply Haas effect to audio.
3855
3856Note that this makes most sense to apply on mono signals.
3857With this filter applied to mono signals it give some directionality and
3858stretches its stereo image.
3859
3860The filter accepts the following options:
3861
3862@table @option
3863@item level_in
3864Set input level. By default is @var{1}, or 0dB
3865
3866@item level_out
3867Set output level. By default is @var{1}, or 0dB.
3868
3869@item side_gain
3870Set gain applied to side part of signal. By default is @var{1}.
3871
3872@item middle_source
3873Set kind of middle source. Can be one of the following:
3874
3875@table @samp
3876@item left
3877Pick left channel.
3878
3879@item right
3880Pick right channel.
3881
3882@item mid
3883Pick middle part signal of stereo image.
3884
3885@item side
3886Pick side part signal of stereo image.
3887@end table
3888
3889@item middle_phase
3890Change middle phase. By default is disabled.
3891
3892@item left_delay
3893Set left channel delay. By default is @var{2.05} milliseconds.
3894
3895@item left_balance
3896Set left channel balance. By default is @var{-1}.
3897
3898@item left_gain
3899Set left channel gain. By default is @var{1}.
3900
3901@item left_phase
3902Change left phase. By default is disabled.
3903
3904@item right_delay
3905Set right channel delay. By defaults is @var{2.12} milliseconds.
3906
3907@item right_balance
3908Set right channel balance. By default is @var{1}.
3909
3910@item right_gain
3911Set right channel gain. By default is @var{1}.
3912
3913@item right_phase
3914Change right phase. By default is enabled.
3915@end table
3916
3917@section hdcd
3918
3919Decodes High Definition Compatible Digital (HDCD) data. A 16-bit PCM stream with
3920embedded HDCD codes is expanded into a 20-bit PCM stream.
3921
3922The filter supports the Peak Extend and Low-level Gain Adjustment features
3923of HDCD, and detects the Transient Filter flag.
3924
3925@example
3926ffmpeg -i HDCD16.flac -af hdcd OUT24.flac
3927@end example
3928
3929When using the filter with wav, note the default encoding for wav is 16-bit,
3930so the resulting 20-bit stream will be truncated back to 16-bit. Use something
3931like @command{-acodec pcm_s24le} after the filter to get 24-bit PCM output.
3932@example
3933ffmpeg -i HDCD16.wav -af hdcd OUT16.wav
3934ffmpeg -i HDCD16.wav -af hdcd -c:a pcm_s24le OUT24.wav
3935@end example
3936
3937The filter accepts the following options:
3938
3939@table @option
3940@item disable_autoconvert
3941Disable any automatic format conversion or resampling in the filter graph.
3942
3943@item process_stereo
3944Process the stereo channels together. If target_gain does not match between
3945channels, consider it invalid and use the last valid target_gain.
3946
3947@item cdt_ms
3948Set the code detect timer period in ms.
3949
3950@item force_pe
3951Always extend peaks above -3dBFS even if PE isn't signaled.
3952
3953@item analyze_mode
3954Replace audio with a solid tone and adjust the amplitude to signal some
3955specific aspect of the decoding process. The output file can be loaded in
3956an audio editor alongside the original to aid analysis.
3957
3958@code{analyze_mode=pe:force_pe=true} can be used to see all samples above the PE level.
3959
3960Modes are:
3961@table @samp
3962@item 0, off
3963Disabled
3964@item 1, lle
3965Gain adjustment level at each sample
3966@item 2, pe
3967Samples where peak extend occurs
3968@item 3, cdt
3969Samples where the code detect timer is active
3970@item 4, tgm
3971Samples where the target gain does not match between channels
3972@end table
3973@end table
3974
3975@section headphone
3976
3977Apply head-related transfer functions (HRTFs) to create virtual
3978loudspeakers around the user for binaural listening via headphones.
3979The HRIRs are provided via additional streams, for each channel
3980one stereo input stream is needed.
3981
3982The filter accepts the following options:
3983
3984@table @option
3985@item map
3986Set mapping of input streams for convolution.
3987The argument is a '|'-separated list of channel names in order as they
3988are given as additional stream inputs for filter.
3989This also specify number of input streams. Number of input streams
3990must be not less than number of channels in first stream plus one.
3991
3992@item gain
3993Set gain applied to audio. Value is in dB. Default is 0.
3994
3995@item type
3996Set processing type. Can be @var{time} or @var{freq}. @var{time} is
3997processing audio in time domain which is slow.
3998@var{freq} is processing audio in frequency domain which is fast.
3999Default is @var{freq}.
4000
4001@item lfe
4002Set custom gain for LFE channels. Value is in dB. Default is 0.
4003
4004@item size
4005Set size of frame in number of samples which will be processed at once.
4006Default value is @var{1024}. Allowed range is from 1024 to 96000.
4007
4008@item hrir
4009Set format of hrir stream.
4010Default value is @var{stereo}. Alternative value is @var{multich}.
4011If value is set to @var{stereo}, number of additional streams should
4012be greater or equal to number of input channels in first input stream.
4013Also each additional stream should have stereo number of channels.
4014If value is set to @var{multich}, number of additional streams should
4015be exactly one. Also number of input channels of additional stream
4016should be equal or greater than twice number of channels of first input
4017stream.
4018@end table
4019
4020@subsection Examples
4021
4022@itemize
4023@item
4024Full example using wav files as coefficients with amovie filters for 7.1 downmix,
4025each amovie filter use stereo file with IR coefficients as input.
4026The files give coefficients for each position of virtual loudspeaker:
4027@example
4028ffmpeg -i input.wav
4029-filter_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];[0:a][fl][fr][fc][lfe][bl][br][sl][sr]headphone=FL|FR|FC|LFE|BL|BR|SL|SR"
4030output.wav
4031@end example
4032
4033@item
4034Full example using wav files as coefficients with amovie filters for 7.1 downmix,
4035but now in @var{multich} @var{hrir} format.
4036@example
4037ffmpeg -i input.wav -filter_complex "amovie=minp.wav[hrirs];[0:a][hrirs]headphone=map=FL|FR|FC|LFE|BL|BR|SL|SR:hrir=multich"
4038output.wav
4039@end example
4040@end itemize
4041
4042@section highpass
4043
4044Apply a high-pass filter with 3dB point frequency.
4045The filter can be either single-pole, or double-pole (the default).
4046The filter roll off at 6dB per pole per octave (20dB per pole per decade).
4047
4048The filter accepts the following options:
4049
4050@table @option
4051@item frequency, f
4052Set frequency in Hz. Default is 3000.
4053
4054@item poles, p
4055Set number of poles. Default is 2.
4056
4057@item width_type, t
4058Set method to specify band-width of filter.
4059@table @option
4060@item h
4061Hz
4062@item q
4063Q-Factor
4064@item o
4065octave
4066@item s
4067slope
4068@item k
4069kHz
4070@end table
4071
4072@item width, w
4073Specify the band-width of a filter in width_type units.
4074Applies only to double-pole filter.
4075The default is 0.707q and gives a Butterworth response.
4076
4077@item mix, m
4078How much to use filtered signal in output. Default is 1.
4079Range is between 0 and 1.
4080
4081@item channels, c
4082Specify which channels to filter, by default all available are filtered.
4083
4084@item normalize, n
4085Normalize biquad coefficients, by default is disabled.
4086Enabling it will normalize magnitude response at DC to 0dB.
4087@end table
4088
4089@subsection Commands
4090
4091This filter supports the following commands:
4092@table @option
4093@item frequency, f
4094Change highpass frequency.
4095Syntax for the command is : "@var{frequency}"
4096
4097@item width_type, t
4098Change highpass width_type.
4099Syntax for the command is : "@var{width_type}"
4100
4101@item width, w
4102Change highpass width.
4103Syntax for the command is : "@var{width}"
4104
4105@item mix, m
4106Change highpass mix.
4107Syntax for the command is : "@var{mix}"
4108@end table
4109
4110@section join
4111
4112Join multiple input streams into one multi-channel stream.
4113
4114It accepts the following parameters:
4115@table @option
4116
4117@item inputs
4118The number of input streams. It defaults to 2.
4119
4120@item channel_layout
4121The desired output channel layout. It defaults to stereo.
4122
4123@item map
4124Map channels from inputs to output. The argument is a '|'-separated list of
4125mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
4126form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
4127can be either the name of the input channel (e.g. FL for front left) or its
4128index in the specified input stream. @var{out_channel} is the name of the output
4129channel.
4130@end table
4131
4132The filter will attempt to guess the mappings when they are not specified
4133explicitly. It does so by first trying to find an unused matching input channel
4134and if that fails it picks the first unused input channel.
4135
4136Join 3 inputs (with properly set channel layouts):
4137@example
4138ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
4139@end example
4140
4141Build a 5.1 output from 6 single-channel streams:
4142@example
4143ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
4144'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'
4145out
4146@end example
4147
4148@section ladspa
4149
4150Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
4151
4152To enable compilation of this filter you need to configure FFmpeg with
4153@code{--enable-ladspa}.
4154
4155@table @option
4156@item file, f
4157Specifies the name of LADSPA plugin library to load. If the environment
4158variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
4159each one of the directories specified by the colon separated list in
4160@env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
4161this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
4162@file{/usr/lib/ladspa/}.
4163
4164@item plugin, p
4165Specifies the plugin within the library. Some libraries contain only
4166one plugin, but others contain many of them. If this is not set filter
4167will list all available plugins within the specified library.
4168
4169@item controls, c
4170Set the '|' separated list of controls which are zero or more floating point
4171values that determine the behavior of the loaded plugin (for example delay,
4172threshold or gain).
4173Controls need to be defined using the following syntax:
4174c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
4175@var{valuei} is the value set on the @var{i}-th control.
4176Alternatively they can be also defined using the following syntax:
4177@var{value0}|@var{value1}|@var{value2}|..., where
4178@var{valuei} is the value set on the @var{i}-th control.
4179If @option{controls} is set to @code{help}, all available controls and
4180their valid ranges are printed.
4181
4182@item sample_rate, s
4183Specify the sample rate, default to 44100. Only used if plugin have
4184zero inputs.
4185
4186@item nb_samples, n
4187Set the number of samples per channel per each output frame, default
4188is 1024. Only used if plugin have zero inputs.
4189
4190@item duration, d
4191Set the minimum duration of the sourced audio. See
4192@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
4193for the accepted syntax.
4194Note that the resulting duration may be greater than the specified duration,
4195as the generated audio is always cut at the end of a complete frame.
4196If not specified, or the expressed duration is negative, the audio is
4197supposed to be generated forever.
4198Only used if plugin have zero inputs.
4199
4200@end table
4201
4202@subsection Examples
4203
4204@itemize
4205@item
4206List all available plugins within amp (LADSPA example plugin) library:
4207@example
4208ladspa=file=amp
4209@end example
4210
4211@item
4212List all available controls and their valid ranges for @code{vcf_notch}
4213plugin from @code{VCF} library:
4214@example
4215ladspa=f=vcf:p=vcf_notch:c=help
4216@end example
4217
4218@item
4219Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
4220plugin library:
4221@example
4222ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
4223@end example
4224
4225@item
4226Add reverberation to the audio using TAP-plugins
4227(Tom's Audio Processing plugins):
4228@example
4229ladspa=file=tap_reverb:tap_reverb
4230@end example
4231
4232@item
4233Generate white noise, with 0.2 amplitude:
4234@example
4235ladspa=file=cmt:noise_source_white:c=c0=.2
4236@end example
4237
4238@item
4239Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
4240@code{C* Audio Plugin Suite} (CAPS) library:
4241@example
4242ladspa=file=caps:Click:c=c1=20'
4243@end example
4244
4245@item
4246Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
4247@example
4248ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
4249@end example
4250
4251@item
4252Increase volume by 20dB using fast lookahead limiter from Steve Harris
4253@code{SWH Plugins} collection:
4254@example
4255ladspa=fast_lookahead_limiter_1913:fastLookaheadLimiter:20|0|2
4256@end example
4257
4258@item
4259Attenuate low frequencies using Multiband EQ from Steve Harris
4260@code{SWH Plugins} collection:
4261@example
4262ladspa=mbeq_1197:mbeq:-24|-24|-24|0|0|0|0|0|0|0|0|0|0|0|0
4263@end example
4264
4265@item
4266Reduce stereo image using @code{Narrower} from the @code{C* Audio Plugin Suite}
4267(CAPS) library:
4268@example
4269ladspa=caps:Narrower
4270@end example
4271
4272@item
4273Another white noise, now using @code{C* Audio Plugin Suite} (CAPS) library:
4274@example
4275ladspa=caps:White:.2
4276@end example
4277
4278@item
4279Some fractal noise, using @code{C* Audio Plugin Suite} (CAPS) library:
4280@example
4281ladspa=caps:Fractal:c=c1=1
4282@end example
4283
4284@item
4285Dynamic volume normalization using @code{VLevel} plugin:
4286@example
4287ladspa=vlevel-ladspa:vlevel_mono
4288@end example
4289@end itemize
4290
4291@subsection Commands
4292
4293This filter supports the following commands:
4294@table @option
4295@item cN
4296Modify the @var{N}-th control value.
4297
4298If the specified value is not valid, it is ignored and prior one is kept.
4299@end table
4300
4301@section loudnorm
4302
4303EBU R128 loudness normalization. Includes both dynamic and linear normalization modes.
4304Support for both single pass (livestreams, files) and double pass (files) modes.
4305This algorithm can target IL, LRA, and maximum true peak. In dynamic mode, to accurately
4306detect true peaks, the audio stream will be upsampled to 192 kHz.
4307Use the @code{-ar} option or @code{aresample} filter to explicitly set an output sample rate.
4308
4309The filter accepts the following options:
4310
4311@table @option
4312@item I, i
4313Set integrated loudness target.
4314Range is -70.0 - -5.0. Default value is -24.0.
4315
4316@item LRA, lra
4317Set loudness range target.
4318Range is 1.0 - 20.0. Default value is 7.0.
4319
4320@item TP, tp
4321Set maximum true peak.
4322Range is -9.0 - +0.0. Default value is -2.0.
4323
4324@item measured_I, measured_i
4325Measured IL of input file.
4326Range is -99.0 - +0.0.
4327
4328@item measured_LRA, measured_lra
4329Measured LRA of input file.
4330Range is  0.0 - 99.0.
4331
4332@item measured_TP, measured_tp
4333Measured true peak of input file.
4334Range is  -99.0 - +99.0.
4335
4336@item measured_thresh
4337Measured threshold of input file.
4338Range is -99.0 - +0.0.
4339
4340@item offset
4341Set offset gain. Gain is applied before the true-peak limiter.
4342Range is  -99.0 - +99.0. Default is +0.0.
4343
4344@item linear
4345Normalize by linearly scaling the source audio.
4346@code{measured_I}, @code{measured_LRA}, @code{measured_TP},
4347and @code{measured_thresh} must all be specified. Target LRA shouldn't
4348be lower than source LRA and the change in integrated loudness shouldn't
4349result in a true peak which exceeds the target TP. If any of these
4350conditions aren't met, normalization mode will revert to @var{dynamic}.
4351Options are @code{true} or @code{false}. Default is @code{true}.
4352
4353@item dual_mono
4354Treat mono input files as "dual-mono". If a mono file is intended for playback
4355on a stereo system, its EBU R128 measurement will be perceptually incorrect.
4356If set to @code{true}, this option will compensate for this effect.
4357Multi-channel input files are not affected by this option.
4358Options are true or false. Default is false.
4359
4360@item print_format
4361Set print format for stats. Options are summary, json, or none.
4362Default value is none.
4363@end table
4364
4365@section lowpass
4366
4367Apply a low-pass filter with 3dB point frequency.
4368The filter can be either single-pole or double-pole (the default).
4369The filter roll off at 6dB per pole per octave (20dB per pole per decade).
4370
4371The filter accepts the following options:
4372
4373@table @option
4374@item frequency, f
4375Set frequency in Hz. Default is 500.
4376
4377@item poles, p
4378Set number of poles. Default is 2.
4379
4380@item width_type, t
4381Set method to specify band-width of filter.
4382@table @option
4383@item h
4384Hz
4385@item q
4386Q-Factor
4387@item o
4388octave
4389@item s
4390slope
4391@item k
4392kHz
4393@end table
4394
4395@item width, w
4396Specify the band-width of a filter in width_type units.
4397Applies only to double-pole filter.
4398The default is 0.707q and gives a Butterworth response.
4399
4400@item mix, m
4401How much to use filtered signal in output. Default is 1.
4402Range is between 0 and 1.
4403
4404@item channels, c
4405Specify which channels to filter, by default all available are filtered.
4406
4407@item normalize, n
4408Normalize biquad coefficients, by default is disabled.
4409Enabling it will normalize magnitude response at DC to 0dB.
4410@end table
4411
4412@subsection Examples
4413@itemize
4414@item
4415Lowpass only LFE channel, it LFE is not present it does nothing:
4416@example
4417lowpass=c=LFE
4418@end example
4419@end itemize
4420
4421@subsection Commands
4422
4423This filter supports the following commands:
4424@table @option
4425@item frequency, f
4426Change lowpass frequency.
4427Syntax for the command is : "@var{frequency}"
4428
4429@item width_type, t
4430Change lowpass width_type.
4431Syntax for the command is : "@var{width_type}"
4432
4433@item width, w
4434Change lowpass width.
4435Syntax for the command is : "@var{width}"
4436
4437@item mix, m
4438Change lowpass mix.
4439Syntax for the command is : "@var{mix}"
4440@end table
4441
4442@section lv2
4443
4444Load a LV2 (LADSPA Version 2) plugin.
4445
4446To enable compilation of this filter you need to configure FFmpeg with
4447@code{--enable-lv2}.
4448
4449@table @option
4450@item plugin, p
4451Specifies the plugin URI. You may need to escape ':'.
4452
4453@item controls, c
4454Set the '|' separated list of controls which are zero or more floating point
4455values that determine the behavior of the loaded plugin (for example delay,
4456threshold or gain).
4457If @option{controls} is set to @code{help}, all available controls and
4458their valid ranges are printed.
4459
4460@item sample_rate, s
4461Specify the sample rate, default to 44100. Only used if plugin have
4462zero inputs.
4463
4464@item nb_samples, n
4465Set the number of samples per channel per each output frame, default
4466is 1024. Only used if plugin have zero inputs.
4467
4468@item duration, d
4469Set the minimum duration of the sourced audio. See
4470@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
4471for the accepted syntax.
4472Note that the resulting duration may be greater than the specified duration,
4473as the generated audio is always cut at the end of a complete frame.
4474If not specified, or the expressed duration is negative, the audio is
4475supposed to be generated forever.
4476Only used if plugin have zero inputs.
4477@end table
4478
4479@subsection Examples
4480
4481@itemize
4482@item
4483Apply bass enhancer plugin from Calf:
4484@example
4485lv2=p=http\\\\://calf.sourceforge.net/plugins/BassEnhancer:c=amount=2
4486@end example
4487
4488@item
4489Apply vinyl plugin from Calf:
4490@example
4491lv2=p=http\\\\://calf.sourceforge.net/plugins/Vinyl:c=drone=0.2|aging=0.5
4492@end example
4493
4494@item
4495Apply bit crusher plugin from ArtyFX:
4496@example
4497lv2=p=http\\\\://www.openavproductions.com/artyfx#bitta:c=crush=0.3
4498@end example
4499@end itemize
4500
4501@section mcompand
4502Multiband Compress or expand the audio's dynamic range.
4503
4504The input audio is divided into bands using 4th order Linkwitz-Riley IIRs.
4505This is akin to the crossover of a loudspeaker, and results in flat frequency
4506response when absent compander action.
4507
4508It accepts the following parameters:
4509
4510@table @option
4511@item args
4512This option syntax is:
4513attack,decay,[attack,decay..] soft-knee points crossover_frequency [delay [initial_volume [gain]]] | attack,decay ...
4514For explanation of each item refer to compand filter documentation.
4515@end table
4516
4517@anchor{pan}
4518@section pan
4519
4520Mix channels with specific gain levels. The filter accepts the output
4521channel layout followed by a set of channels definitions.
4522
4523This filter is also designed to efficiently remap the channels of an audio
4524stream.
4525
4526The filter accepts parameters of the form:
4527"@var{l}|@var{outdef}|@var{outdef}|..."
4528
4529@table @option
4530@item l
4531output channel layout or number of channels
4532
4533@item outdef
4534output channel specification, of the form:
4535"@var{out_name}=[@var{gain}*]@var{in_name}[(+-)[@var{gain}*]@var{in_name}...]"
4536
4537@item out_name
4538output channel to define, either a channel name (FL, FR, etc.) or a channel
4539number (c0, c1, etc.)
4540
4541@item gain
4542multiplicative coefficient for the channel, 1 leaving the volume unchanged
4543
4544@item in_name
4545input channel to use, see out_name for details; it is not possible to mix
4546named and numbered input channels
4547@end table
4548
4549If the `=' in a channel specification is replaced by `<', then the gains for
4550that specification will be renormalized so that the total is 1, thus
4551avoiding clipping noise.
4552
4553@subsection Mixing examples
4554
4555For example, if you want to down-mix from stereo to mono, but with a bigger
4556factor for the left channel:
4557@example
4558pan=1c|c0=0.9*c0+0.1*c1
4559@end example
4560
4561A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
45627-channels surround:
4563@example
4564pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
4565@end example
4566
4567Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
4568that should be preferred (see "-ac" option) unless you have very specific
4569needs.
4570
4571@subsection Remapping examples
4572
4573The channel remapping will be effective if, and only if:
4574
4575@itemize
4576@item gain coefficients are zeroes or ones,
4577@item only one input per channel output,
4578@end itemize
4579
4580If all these conditions are satisfied, the filter will notify the user ("Pure
4581channel mapping detected"), and use an optimized and lossless method to do the
4582remapping.
4583
4584For example, if you have a 5.1 source and want a stereo audio stream by
4585dropping the extra channels:
4586@example
4587pan="stereo| c0=FL | c1=FR"
4588@end example
4589
4590Given the same source, you can also switch front left and front right channels
4591and keep the input channel layout:
4592@example
4593pan="5.1| c0=c1 | c1=c0 | c2=c2 | c3=c3 | c4=c4 | c5=c5"
4594@end example
4595
4596If the input is a stereo audio stream, you can mute the front left channel (and
4597still keep the stereo channel layout) with:
4598@example
4599pan="stereo|c1=c1"
4600@end example
4601
4602Still with a stereo audio stream input, you can copy the right channel in both
4603front left and right:
4604@example
4605pan="stereo| c0=FR | c1=FR"
4606@end example
4607
4608@section replaygain
4609
4610ReplayGain scanner filter. This filter takes an audio stream as an input and
4611outputs it unchanged.
4612At end of filtering it displays @code{track_gain} and @code{track_peak}.
4613
4614@section resample
4615
4616Convert the audio sample format, sample rate and channel layout. It is
4617not meant to be used directly.
4618
4619@section rubberband
4620Apply time-stretching and pitch-shifting with librubberband.
4621
4622To enable compilation of this filter, you need to configure FFmpeg with
4623@code{--enable-librubberband}.
4624
4625The filter accepts the following options:
4626
4627@table @option
4628@item tempo
4629Set tempo scale factor.
4630
4631@item pitch
4632Set pitch scale factor.
4633
4634@item transients
4635Set transients detector.
4636Possible values are:
4637@table @var
4638@item crisp
4639@item mixed
4640@item smooth
4641@end table
4642
4643@item detector
4644Set detector.
4645Possible values are:
4646@table @var
4647@item compound
4648@item percussive
4649@item soft
4650@end table
4651
4652@item phase
4653Set phase.
4654Possible values are:
4655@table @var
4656@item laminar
4657@item independent
4658@end table
4659
4660@item window
4661Set processing window size.
4662Possible values are:
4663@table @var
4664@item standard
4665@item short
4666@item long
4667@end table
4668
4669@item smoothing
4670Set smoothing.
4671Possible values are:
4672@table @var
4673@item off
4674@item on
4675@end table
4676
4677@item formant
4678Enable formant preservation when shift pitching.
4679Possible values are:
4680@table @var
4681@item shifted
4682@item preserved
4683@end table
4684
4685@item pitchq
4686Set pitch quality.
4687Possible values are:
4688@table @var
4689@item quality
4690@item speed
4691@item consistency
4692@end table
4693
4694@item channels
4695Set channels.
4696Possible values are:
4697@table @var
4698@item apart
4699@item together
4700@end table
4701@end table
4702
4703@subsection Commands
4704
4705This filter supports the following commands:
4706@table @option
4707@item tempo
4708Change filter tempo scale factor.
4709Syntax for the command is : "@var{tempo}"
4710
4711@item pitch
4712Change filter pitch scale factor.
4713Syntax for the command is : "@var{pitch}"
4714@end table
4715
4716@section sidechaincompress
4717
4718This filter acts like normal compressor but has the ability to compress
4719detected signal using second input signal.
4720It needs two input streams and returns one output stream.
4721First input stream will be processed depending on second stream signal.
4722The filtered signal then can be filtered with other filters in later stages of
4723processing. See @ref{pan} and @ref{amerge} filter.
4724
4725The filter accepts the following options:
4726
4727@table @option
4728@item level_in
4729Set input gain. Default is 1. Range is between 0.015625 and 64.
4730
4731@item mode
4732Set mode of compressor operation. Can be @code{upward} or @code{downward}.
4733Default is @code{downward}.
4734
4735@item threshold
4736If a signal of second stream raises above this level it will affect the gain
4737reduction of first stream.
4738By default is 0.125. Range is between 0.00097563 and 1.
4739
4740@item ratio
4741Set a ratio about which the signal is reduced. 1:2 means that if the level
4742raised 4dB above the threshold, it will be only 2dB above after the reduction.
4743Default is 2. Range is between 1 and 20.
4744
4745@item attack
4746Amount of milliseconds the signal has to rise above the threshold before gain
4747reduction starts. Default is 20. Range is between 0.01 and 2000.
4748
4749@item release
4750Amount of milliseconds the signal has to fall below the threshold before
4751reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
4752
4753@item makeup
4754Set the amount by how much signal will be amplified after processing.
4755Default is 1. Range is from 1 to 64.
4756
4757@item knee
4758Curve the sharp knee around the threshold to enter gain reduction more softly.
4759Default is 2.82843. Range is between 1 and 8.
4760
4761@item link
4762Choose if the @code{average} level between all channels of side-chain stream
4763or the louder(@code{maximum}) channel of side-chain stream affects the
4764reduction. Default is @code{average}.
4765
4766@item detection
4767Should the exact signal be taken in case of @code{peak} or an RMS one in case
4768of @code{rms}. Default is @code{rms} which is mainly smoother.
4769
4770@item level_sc
4771Set sidechain gain. Default is 1. Range is between 0.015625 and 64.
4772
4773@item mix
4774How much to use compressed signal in output. Default is 1.
4775Range is between 0 and 1.
4776@end table
4777
4778@subsection Commands
4779
4780This filter supports the all above options as @ref{commands}.
4781
4782@subsection Examples
4783
4784@itemize
4785@item
4786Full ffmpeg example taking 2 audio inputs, 1st input to be compressed
4787depending on the signal of 2nd input and later compressed signal to be
4788merged with 2nd input:
4789@example
4790ffmpeg -i main.flac -i sidechain.flac -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge"
4791@end example
4792@end itemize
4793
4794@section sidechaingate
4795
4796A sidechain gate acts like a normal (wideband) gate but has the ability to
4797filter the detected signal before sending it to the gain reduction stage.
4798Normally a gate uses the full range signal to detect a level above the
4799threshold.
4800For example: If you cut all lower frequencies from your sidechain signal
4801the gate will decrease the volume of your track only if not enough highs
4802appear. With this technique you are able to reduce the resonation of a
4803natural drum or remove "rumbling" of muted strokes from a heavily distorted
4804guitar.
4805It needs two input streams and returns one output stream.
4806First input stream will be processed depending on second stream signal.
4807
4808The filter accepts the following options:
4809
4810@table @option
4811@item level_in
4812Set input level before filtering.
4813Default is 1. Allowed range is from 0.015625 to 64.
4814
4815@item mode
4816Set the mode of operation. Can be @code{upward} or @code{downward}.
4817Default is @code{downward}. If set to @code{upward} mode, higher parts of signal
4818will be amplified, expanding dynamic range in upward direction.
4819Otherwise, in case of @code{downward} lower parts of signal will be reduced.
4820
4821@item range
4822Set the level of gain reduction when the signal is below the threshold.
4823Default is 0.06125. Allowed range is from 0 to 1.
4824Setting this to 0 disables reduction and then filter behaves like expander.
4825
4826@item threshold
4827If a signal rises above this level the gain reduction is released.
4828Default is 0.125. Allowed range is from 0 to 1.
4829
4830@item ratio
4831Set a ratio about which the signal is reduced.
4832Default is 2. Allowed range is from 1 to 9000.
4833
4834@item attack
4835Amount of milliseconds the signal has to rise above the threshold before gain
4836reduction stops.
4837Default is 20 milliseconds. Allowed range is from 0.01 to 9000.
4838
4839@item release
4840Amount of milliseconds the signal has to fall below the threshold before the
4841reduction is increased again. Default is 250 milliseconds.
4842Allowed range is from 0.01 to 9000.
4843
4844@item makeup
4845Set amount of amplification of signal after processing.
4846Default is 1. Allowed range is from 1 to 64.
4847
4848@item knee
4849Curve the sharp knee around the threshold to enter gain reduction more softly.
4850Default is 2.828427125. Allowed range is from 1 to 8.
4851
4852@item detection
4853Choose if exact signal should be taken for detection or an RMS like one.
4854Default is rms. Can be peak or rms.
4855
4856@item link
4857Choose if the average level between all channels or the louder channel affects
4858the reduction.
4859Default is average. Can be average or maximum.
4860
4861@item level_sc
4862Set sidechain gain. Default is 1. Range is from 0.015625 to 64.
4863@end table
4864
4865@section silencedetect
4866
4867Detect silence in an audio stream.
4868
4869This filter logs a message when it detects that the input audio volume is less
4870or equal to a noise tolerance value for a duration greater or equal to the
4871minimum detected noise duration.
4872
4873The printed times and duration are expressed in seconds. The
4874@code{lavfi.silence_start} or @code{lavfi.silence_start.X} metadata key
4875is set on the first frame whose timestamp equals or exceeds the detection
4876duration and it contains the timestamp of the first frame of the silence.
4877
4878The @code{lavfi.silence_duration} or @code{lavfi.silence_duration.X}
4879and @code{lavfi.silence_end} or @code{lavfi.silence_end.X} metadata
4880keys are set on the first frame after the silence. If @option{mono} is
4881enabled, and each channel is evaluated separately, the @code{.X}
4882suffixed keys are used, and @code{X} corresponds to the channel number.
4883
4884The filter accepts the following options:
4885
4886@table @option
4887@item noise, n
4888Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
4889specified value) or amplitude ratio. Default is -60dB, or 0.001.
4890
4891@item duration, d
4892Set silence duration until notification (default is 2 seconds). See
4893@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
4894for the accepted syntax.
4895
4896@item mono, m
4897Process each channel separately, instead of combined. By default is disabled.
4898@end table
4899
4900@subsection Examples
4901
4902@itemize
4903@item
4904Detect 5 seconds of silence with -50dB noise tolerance:
4905@example
4906silencedetect=n=-50dB:d=5
4907@end example
4908
4909@item
4910Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
4911tolerance in @file{silence.mp3}:
4912@example
4913ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
4914@end example
4915@end itemize
4916
4917@section silenceremove
4918
4919Remove silence from the beginning, middle or end of the audio.
4920
4921The filter accepts the following options:
4922
4923@table @option
4924@item start_periods
4925This value is used to indicate if audio should be trimmed at beginning of
4926the audio. A value of zero indicates no silence should be trimmed from the
4927beginning. When specifying a non-zero value, it trims audio up until it
4928finds non-silence. Normally, when trimming silence from beginning of audio
4929the @var{start_periods} will be @code{1} but it can be increased to higher
4930values to trim all audio up to specific count of non-silence periods.
4931Default value is @code{0}.
4932
4933@item start_duration
4934Specify the amount of time that non-silence must be detected before it stops
4935trimming audio. By increasing the duration, bursts of noises can be treated
4936as silence and trimmed off. Default value is @code{0}.
4937
4938@item start_threshold
4939This indicates what sample value should be treated as silence. For digital
4940audio, a value of @code{0} may be fine but for audio recorded from analog,
4941you may wish to increase the value to account for background noise.
4942Can be specified in dB (in case "dB" is appended to the specified value)
4943or amplitude ratio. Default value is @code{0}.
4944
4945@item start_silence
4946Specify max duration of silence at beginning that will be kept after
4947trimming. Default is 0, which is equal to trimming all samples detected
4948as silence.
4949
4950@item start_mode
4951Specify mode of detection of silence end in start of multi-channel audio.
4952Can be @var{any} or @var{all}. Default is @var{any}.
4953With @var{any}, any sample that is detected as non-silence will cause
4954stopped trimming of silence.
4955With @var{all}, only if all channels are detected as non-silence will cause
4956stopped trimming of silence.
4957
4958@item stop_periods
4959Set the count for trimming silence from the end of audio.
4960To remove silence from the middle of a file, specify a @var{stop_periods}
4961that is negative. This value is then treated as a positive value and is
4962used to indicate the effect should restart processing as specified by
4963@var{start_periods}, making it suitable for removing periods of silence
4964in the middle of the audio.
4965Default value is @code{0}.
4966
4967@item stop_duration
4968Specify a duration of silence that must exist before audio is not copied any
4969more. By specifying a higher duration, silence that is wanted can be left in
4970the audio.
4971Default value is @code{0}.
4972
4973@item stop_threshold
4974This is the same as @option{start_threshold} but for trimming silence from
4975the end of audio.
4976Can be specified in dB (in case "dB" is appended to the specified value)
4977or amplitude ratio. Default value is @code{0}.
4978
4979@item stop_silence
4980Specify max duration of silence at end that will be kept after
4981trimming. Default is 0, which is equal to trimming all samples detected
4982as silence.
4983
4984@item stop_mode
4985Specify mode of detection of silence start in end of multi-channel audio.
4986Can be @var{any} or @var{all}. Default is @var{any}.
4987With @var{any}, any sample that is detected as non-silence will cause
4988stopped trimming of silence.
4989With @var{all}, only if all channels are detected as non-silence will cause
4990stopped trimming of silence.
4991
4992@item detection
4993Set how is silence detected. Can be @code{rms} or @code{peak}. Second is faster
4994and works better with digital silence which is exactly 0.
4995Default value is @code{rms}.
4996
4997@item window
4998Set duration in number of seconds used to calculate size of window in number
4999of samples for detecting silence.
5000Default value is @code{0.02}. Allowed range is from @code{0} to @code{10}.
5001@end table
5002
5003@subsection Examples
5004
5005@itemize
5006@item
5007The following example shows how this filter can be used to start a recording
5008that does not contain the delay at the start which usually occurs between
5009pressing the record button and the start of the performance:
5010@example
5011silenceremove=start_periods=1:start_duration=5:start_threshold=0.02
5012@end example
5013
5014@item
5015Trim all silence encountered from beginning to end where there is more than 1
5016second of silence in audio:
5017@example
5018silenceremove=stop_periods=-1:stop_duration=1:stop_threshold=-90dB
5019@end example
5020
5021@item
5022Trim all digital silence samples, using peak detection, from beginning to end
5023where there is more than 0 samples of digital silence in audio and digital
5024silence is detected in all channels at same positions in stream:
5025@example
5026silenceremove=window=0:detection=peak:stop_mode=all:start_mode=all:stop_periods=-1:stop_threshold=0
5027@end example
5028@end itemize
5029
5030@section sofalizer
5031
5032SOFAlizer uses head-related transfer functions (HRTFs) to create virtual
5033loudspeakers around the user for binaural listening via headphones (audio
5034formats up to 9 channels supported).
5035The HRTFs are stored in SOFA files (see @url{http://www.sofacoustics.org/} for a database).
5036SOFAlizer is developed at the Acoustics Research Institute (ARI) of the
5037Austrian Academy of Sciences.
5038
5039To enable compilation of this filter you need to configure FFmpeg with
5040@code{--enable-libmysofa}.
5041
5042The filter accepts the following options:
5043
5044@table @option
5045@item sofa
5046Set the SOFA file used for rendering.
5047
5048@item gain
5049Set gain applied to audio. Value is in dB. Default is 0.
5050
5051@item rotation
5052Set rotation of virtual loudspeakers in deg. Default is 0.
5053
5054@item elevation
5055Set elevation of virtual speakers in deg. Default is 0.
5056
5057@item radius
5058Set distance in meters between loudspeakers and the listener with near-field
5059HRTFs. Default is 1.
5060
5061@item type
5062Set processing type. Can be @var{time} or @var{freq}. @var{time} is
5063processing audio in time domain which is slow.
5064@var{freq} is processing audio in frequency domain which is fast.
5065Default is @var{freq}.
5066
5067@item speakers
5068Set custom positions of virtual loudspeakers. Syntax for this option is:
5069<CH> <AZIM> <ELEV>[|<CH> <AZIM> <ELEV>|...].
5070Each virtual loudspeaker is described with short channel name following with
5071azimuth and elevation in degrees.
5072Each virtual loudspeaker description is separated by '|'.
5073For example to override front left and front right channel positions use:
5074'speakers=FL 45 15|FR 345 15'.
5075Descriptions with unrecognised channel names are ignored.
5076
5077@item lfegain
5078Set custom gain for LFE channels. Value is in dB. Default is 0.
5079
5080@item framesize
5081Set custom frame size in number of samples. Default is 1024.
5082Allowed range is from 1024 to 96000. Only used if option @samp{type}
5083is set to @var{freq}.
5084
5085@item normalize
5086Should all IRs be normalized upon importing SOFA file.
5087By default is enabled.
5088
5089@item interpolate
5090Should nearest IRs be interpolated with neighbor IRs if exact position
5091does not match. By default is disabled.
5092
5093@item minphase
5094Minphase all IRs upon loading of SOFA file. By default is disabled.
5095
5096@item anglestep
5097Set neighbor search angle step. Only used if option @var{interpolate} is enabled.
5098
5099@item radstep
5100Set neighbor search radius step. Only used if option @var{interpolate} is enabled.
5101@end table
5102
5103@subsection Examples
5104
5105@itemize
5106@item
5107Using ClubFritz6 sofa file:
5108@example
5109sofalizer=sofa=/path/to/ClubFritz6.sofa:type=freq:radius=1
5110@end example
5111
5112@item
5113Using ClubFritz12 sofa file and bigger radius with small rotation:
5114@example
5115sofalizer=sofa=/path/to/ClubFritz12.sofa:type=freq:radius=2:rotation=5
5116@end example
5117
5118@item
5119Similar as above but with custom speaker positions for front left, front right, back left and back right
5120and also with custom gain:
5121@example
5122"sofalizer=sofa=/path/to/ClubFritz6.sofa:type=freq:radius=2:speakers=FL 45|FR 315|BL 135|BR 225:gain=28"
5123@end example
5124@end itemize
5125
5126@section stereotools
5127
5128This filter has some handy utilities to manage stereo signals, for converting
5129M/S stereo recordings to L/R signal while having control over the parameters
5130or spreading the stereo image of master track.
5131
5132The filter accepts the following options:
5133
5134@table @option
5135@item level_in
5136Set input level before filtering for both channels. Defaults is 1.
5137Allowed range is from 0.015625 to 64.
5138
5139@item level_out
5140Set output level after filtering for both channels. Defaults is 1.
5141Allowed range is from 0.015625 to 64.
5142
5143@item balance_in
5144Set input balance between both channels. Default is 0.
5145Allowed range is from -1 to 1.
5146
5147@item balance_out
5148Set output balance between both channels. Default is 0.
5149Allowed range is from -1 to 1.
5150
5151@item softclip
5152Enable softclipping. Results in analog distortion instead of harsh digital 0dB
5153clipping. Disabled by default.
5154
5155@item mutel
5156Mute the left channel. Disabled by default.
5157
5158@item muter
5159Mute the right channel. Disabled by default.
5160
5161@item phasel
5162Change the phase of the left channel. Disabled by default.
5163
5164@item phaser
5165Change the phase of the right channel. Disabled by default.
5166
5167@item mode
5168Set stereo mode. Available values are:
5169
5170@table @samp
5171@item lr>lr
5172Left/Right to Left/Right, this is default.
5173
5174@item lr>ms
5175Left/Right to Mid/Side.
5176
5177@item ms>lr
5178Mid/Side to Left/Right.
5179
5180@item lr>ll
5181Left/Right to Left/Left.
5182
5183@item lr>rr
5184Left/Right to Right/Right.
5185
5186@item lr>l+r
5187Left/Right to Left + Right.
5188
5189@item lr>rl
5190Left/Right to Right/Left.
5191
5192@item ms>ll
5193Mid/Side to Left/Left.
5194
5195@item ms>rr
5196Mid/Side to Right/Right.
5197@end table
5198
5199@item slev
5200Set level of side signal. Default is 1.
5201Allowed range is from 0.015625 to 64.
5202
5203@item sbal
5204Set balance of side signal. Default is 0.
5205Allowed range is from -1 to 1.
5206
5207@item mlev
5208Set level of the middle signal. Default is 1.
5209Allowed range is from 0.015625 to 64.
5210
5211@item mpan
5212Set middle signal pan. Default is 0. Allowed range is from -1 to 1.
5213
5214@item base
5215Set stereo base between mono and inversed channels. Default is 0.
5216Allowed range is from -1 to 1.
5217
5218@item delay
5219Set delay in milliseconds how much to delay left from right channel and
5220vice versa. Default is 0. Allowed range is from -20 to 20.
5221
5222@item sclevel
5223Set S/C level. Default is 1. Allowed range is from 1 to 100.
5224
5225@item phase
5226Set the stereo phase in degrees. Default is 0. Allowed range is from 0 to 360.
5227
5228@item bmode_in, bmode_out
5229Set balance mode for balance_in/balance_out option.
5230
5231Can be one of the following:
5232
5233@table @samp
5234@item balance
5235Classic balance mode. Attenuate one channel at time.
5236Gain is raised up to 1.
5237
5238@item amplitude
5239Similar as classic mode above but gain is raised up to 2.
5240
5241@item power
5242Equal power distribution, from -6dB to +6dB range.
5243@end table
5244@end table
5245
5246@subsection Examples
5247
5248@itemize
5249@item
5250Apply karaoke like effect:
5251@example
5252stereotools=mlev=0.015625
5253@end example
5254
5255@item
5256Convert M/S signal to L/R:
5257@example
5258"stereotools=mode=ms>lr"
5259@end example
5260@end itemize
5261
5262@section stereowiden
5263
5264This filter enhance the stereo effect by suppressing signal common to both
5265channels and by delaying the signal of left into right and vice versa,
5266thereby widening the stereo effect.
5267
5268The filter accepts the following options:
5269
5270@table @option
5271@item delay
5272Time in milliseconds of the delay of left signal into right and vice versa.
5273Default is 20 milliseconds.
5274
5275@item feedback
5276Amount of gain in delayed signal into right and vice versa. Gives a delay
5277effect of left signal in right output and vice versa which gives widening
5278effect. Default is 0.3.
5279
5280@item crossfeed
5281Cross feed of left into right with inverted phase. This helps in suppressing
5282the mono. If the value is 1 it will cancel all the signal common to both
5283channels. Default is 0.3.
5284
5285@item drymix
5286Set level of input signal of original channel. Default is 0.8.
5287@end table
5288
5289@subsection Commands
5290
5291This filter supports the all above options except @code{delay} as @ref{commands}.
5292
5293@section superequalizer
5294Apply 18 band equalizer.
5295
5296The filter accepts the following options:
5297@table @option
5298@item 1b
5299Set 65Hz band gain.
5300@item 2b
5301Set 92Hz band gain.
5302@item 3b
5303Set 131Hz band gain.
5304@item 4b
5305Set 185Hz band gain.
5306@item 5b
5307Set 262Hz band gain.
5308@item 6b
5309Set 370Hz band gain.
5310@item 7b
5311Set 523Hz band gain.
5312@item 8b
5313Set 740Hz band gain.
5314@item 9b
5315Set 1047Hz band gain.
5316@item 10b
5317Set 1480Hz band gain.
5318@item 11b
5319Set 2093Hz band gain.
5320@item 12b
5321Set 2960Hz band gain.
5322@item 13b
5323Set 4186Hz band gain.
5324@item 14b
5325Set 5920Hz band gain.
5326@item 15b
5327Set 8372Hz band gain.
5328@item 16b
5329Set 11840Hz band gain.
5330@item 17b
5331Set 16744Hz band gain.
5332@item 18b
5333Set 20000Hz band gain.
5334@end table
5335
5336@section surround
5337Apply audio surround upmix filter.
5338
5339This filter allows to produce multichannel output from audio stream.
5340
5341The filter accepts the following options:
5342
5343@table @option
5344@item chl_out
5345Set output channel layout. By default, this is @var{5.1}.
5346
5347See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
5348for the required syntax.
5349
5350@item chl_in
5351Set input channel layout. By default, this is @var{stereo}.
5352
5353See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
5354for the required syntax.
5355
5356@item level_in
5357Set input volume level. By default, this is @var{1}.
5358
5359@item level_out
5360Set output volume level. By default, this is @var{1}.
5361
5362@item lfe
5363Enable LFE channel output if output channel layout has it. By default, this is enabled.
5364
5365@item lfe_low
5366Set LFE low cut off frequency. By default, this is @var{128} Hz.
5367
5368@item lfe_high
5369Set LFE high cut off frequency. By default, this is @var{256} Hz.
5370
5371@item lfe_mode
5372Set LFE mode, can be @var{add} or @var{sub}. Default is @var{add}.
5373In @var{add} mode, LFE channel is created from input audio and added to output.
5374In @var{sub} mode, LFE channel is created from input audio and added to output but
5375also all non-LFE output channels are subtracted with output LFE channel.
5376
5377@item angle
5378Set angle of stereo surround transform, Allowed range is from @var{0} to @var{360}.
5379Default is @var{90}.
5380
5381@item fc_in
5382Set front center input volume. By default, this is @var{1}.
5383
5384@item fc_out
5385Set front center output volume. By default, this is @var{1}.
5386
5387@item fl_in
5388Set front left input volume. By default, this is @var{1}.
5389
5390@item fl_out
5391Set front left output volume. By default, this is @var{1}.
5392
5393@item fr_in
5394Set front right input volume. By default, this is @var{1}.
5395
5396@item fr_out
5397Set front right output volume. By default, this is @var{1}.
5398
5399@item sl_in
5400Set side left input volume. By default, this is @var{1}.
5401
5402@item sl_out
5403Set side left output volume. By default, this is @var{1}.
5404
5405@item sr_in
5406Set side right input volume. By default, this is @var{1}.
5407
5408@item sr_out
5409Set side right output volume. By default, this is @var{1}.
5410
5411@item bl_in
5412Set back left input volume. By default, this is @var{1}.
5413
5414@item bl_out
5415Set back left output volume. By default, this is @var{1}.
5416
5417@item br_in
5418Set back right input volume. By default, this is @var{1}.
5419
5420@item br_out
5421Set back right output volume. By default, this is @var{1}.
5422
5423@item bc_in
5424Set back center input volume. By default, this is @var{1}.
5425
5426@item bc_out
5427Set back center output volume. By default, this is @var{1}.
5428
5429@item lfe_in
5430Set LFE input volume. By default, this is @var{1}.
5431
5432@item lfe_out
5433Set LFE output volume. By default, this is @var{1}.
5434
5435@item allx
5436Set spread usage of stereo image across X axis for all channels.
5437
5438@item ally
5439Set spread usage of stereo image across Y axis for all channels.
5440
5441@item fcx, flx, frx, blx, brx, slx, srx, bcx
5442Set spread usage of stereo image across X axis for each channel.
5443
5444@item fcy, fly, fry, bly, bry, sly, sry, bcy
5445Set spread usage of stereo image across Y axis for each channel.
5446
5447@item win_size
5448Set window size. Allowed range is from @var{1024} to @var{65536}. Default size is @var{4096}.
5449
5450@item win_func
5451Set window function.
5452
5453It accepts the following values:
5454@table @samp
5455@item rect
5456@item bartlett
5457@item hann, hanning
5458@item hamming
5459@item blackman
5460@item welch
5461@item flattop
5462@item bharris
5463@item bnuttall
5464@item bhann
5465@item sine
5466@item nuttall
5467@item lanczos
5468@item gauss
5469@item tukey
5470@item dolph
5471@item cauchy
5472@item parzen
5473@item poisson
5474@item bohman
5475@end table
5476Default is @code{hann}.
5477
5478@item overlap
5479Set window overlap. If set to 1, the recommended overlap for selected
5480window function will be picked. Default is @code{0.5}.
5481@end table
5482
5483@section treble, highshelf
5484
5485Boost or cut treble (upper) frequencies of the audio using a two-pole
5486shelving filter with a response similar to that of a standard
5487hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
5488
5489The filter accepts the following options:
5490
5491@table @option
5492@item gain, g
5493Give the gain at whichever is the lower of ~22 kHz and the
5494Nyquist frequency. Its useful range is about -20 (for a large cut)
5495to +20 (for a large boost). Beware of clipping when using a positive gain.
5496
5497@item frequency, f
5498Set the filter's central frequency and so can be used
5499to extend or reduce the frequency range to be boosted or cut.
5500The default value is @code{3000} Hz.
5501
5502@item width_type, t
5503Set method to specify band-width of filter.
5504@table @option
5505@item h
5506Hz
5507@item q
5508Q-Factor
5509@item o
5510octave
5511@item s
5512slope
5513@item k
5514kHz
5515@end table
5516
5517@item width, w
5518Determine how steep is the filter's shelf transition.
5519
5520@item mix, m
5521How much to use filtered signal in output. Default is 1.
5522Range is between 0 and 1.
5523
5524@item channels, c
5525Specify which channels to filter, by default all available are filtered.
5526
5527@item normalize, n
5528Normalize biquad coefficients, by default is disabled.
5529Enabling it will normalize magnitude response at DC to 0dB.
5530@end table
5531
5532@subsection Commands
5533
5534This filter supports the following commands:
5535@table @option
5536@item frequency, f
5537Change treble frequency.
5538Syntax for the command is : "@var{frequency}"
5539
5540@item width_type, t
5541Change treble width_type.
5542Syntax for the command is : "@var{width_type}"
5543
5544@item width, w
5545Change treble width.
5546Syntax for the command is : "@var{width}"
5547
5548@item gain, g
5549Change treble gain.
5550Syntax for the command is : "@var{gain}"
5551
5552@item mix, m
5553Change treble mix.
5554Syntax for the command is : "@var{mix}"
5555@end table
5556
5557@section tremolo
5558
5559Sinusoidal amplitude modulation.
5560
5561The filter accepts the following options:
5562
5563@table @option
5564@item f
5565Modulation frequency in Hertz. Modulation frequencies in the subharmonic range
5566(20 Hz or lower) will result in a tremolo effect.
5567This filter may also be used as a ring modulator by specifying
5568a modulation frequency higher than 20 Hz.
5569Range is 0.1 - 20000.0. Default value is 5.0 Hz.
5570
5571@item d
5572Depth of modulation as a percentage. Range is 0.0 - 1.0.
5573Default value is 0.5.
5574@end table
5575
5576@section vibrato
5577
5578Sinusoidal phase modulation.
5579
5580The filter accepts the following options:
5581
5582@table @option
5583@item f
5584Modulation frequency in Hertz.
5585Range is 0.1 - 20000.0. Default value is 5.0 Hz.
5586
5587@item d
5588Depth of modulation as a percentage. Range is 0.0 - 1.0.
5589Default value is 0.5.
5590@end table
5591
5592@section volume
5593
5594Adjust the input audio volume.
5595
5596It accepts the following parameters:
5597@table @option
5598
5599@item volume
5600Set audio volume expression.
5601
5602Output values are clipped to the maximum value.
5603
5604The output audio volume is given by the relation:
5605@example
5606@var{output_volume} = @var{volume} * @var{input_volume}
5607@end example
5608
5609The default value for @var{volume} is "1.0".
5610
5611@item precision
5612This parameter represents the mathematical precision.
5613
5614It determines which input sample formats will be allowed, which affects the
5615precision of the volume scaling.
5616
5617@table @option
5618@item fixed
56198-bit fixed-point; this limits input sample format to U8, S16, and S32.
5620@item float
562132-bit floating-point; this limits input sample format to FLT. (default)
5622@item double
562364-bit floating-point; this limits input sample format to DBL.
5624@end table
5625
5626@item replaygain
5627Choose the behaviour on encountering ReplayGain side data in input frames.
5628
5629@table @option
5630@item drop
5631Remove ReplayGain side data, ignoring its contents (the default).
5632
5633@item ignore
5634Ignore ReplayGain side data, but leave it in the frame.
5635
5636@item track
5637Prefer the track gain, if present.
5638
5639@item album
5640Prefer the album gain, if present.
5641@end table
5642
5643@item replaygain_preamp
5644Pre-amplification gain in dB to apply to the selected replaygain gain.
5645
5646Default value for @var{replaygain_preamp} is 0.0.
5647
5648@item replaygain_noclip
5649Prevent clipping by limiting the gain applied.
5650
5651Default value for @var{replaygain_noclip} is 1.
5652
5653@item eval
5654Set when the volume expression is evaluated.
5655
5656It accepts the following values:
5657@table @samp
5658@item once
5659only evaluate expression once during the filter initialization, or
5660when the @samp{volume} command is sent
5661
5662@item frame
5663evaluate expression for each incoming frame
5664@end table
5665
5666Default value is @samp{once}.
5667@end table
5668
5669The volume expression can contain the following parameters.
5670
5671@table @option
5672@item n
5673frame number (starting at zero)
5674@item nb_channels
5675number of channels
5676@item nb_consumed_samples
5677number of samples consumed by the filter
5678@item nb_samples
5679number of samples in the current frame
5680@item pos
5681original frame position in the file
5682@item pts
5683frame PTS
5684@item sample_rate
5685sample rate
5686@item startpts
5687PTS at start of stream
5688@item startt
5689time at start of stream
5690@item t
5691frame time
5692@item tb
5693timestamp timebase
5694@item volume
5695last set volume value
5696@end table
5697
5698Note that when @option{eval} is set to @samp{once} only the
5699@var{sample_rate} and @var{tb} variables are available, all other
5700variables will evaluate to NAN.
5701
5702@subsection Commands
5703
5704This filter supports the following commands:
5705@table @option
5706@item volume
5707Modify the volume expression.
5708The command accepts the same syntax of the corresponding option.
5709
5710If the specified expression is not valid, it is kept at its current
5711value.
5712@end table
5713
5714@subsection Examples
5715
5716@itemize
5717@item
5718Halve the input audio volume:
5719@example
5720volume=volume=0.5
5721volume=volume=1/2
5722volume=volume=-6.0206dB
5723@end example
5724
5725In all the above example the named key for @option{volume} can be
5726omitted, for example like in:
5727@example
5728volume=0.5
5729@end example
5730
5731@item
5732Increase input audio power by 6 decibels using fixed-point precision:
5733@example
5734volume=volume=6dB:precision=fixed
5735@end example
5736
5737@item
5738Fade volume after time 10 with an annihilation period of 5 seconds:
5739@example
5740volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
5741@end example
5742@end itemize
5743
5744@section volumedetect
5745
5746Detect the volume of the input video.
5747
5748The filter has no parameters. The input is not modified. Statistics about
5749the volume will be printed in the log when the input stream end is reached.
5750
5751In particular it will show the mean volume (root mean square), maximum
5752volume (on a per-sample basis), and the beginning of a histogram of the
5753registered volume values (from the maximum value to a cumulated 1/1000 of
5754the samples).
5755
5756All volumes are in decibels relative to the maximum PCM value.
5757
5758@subsection Examples
5759
5760Here is an excerpt of the output:
5761@example
5762[Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
5763[Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
5764[Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
5765[Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
5766[Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
5767[Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
5768[Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
5769[Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
5770[Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
5771@end example
5772
5773It means that:
5774@itemize
5775@item
5776The mean square energy is approximately -27 dB, or 10^-2.7.
5777@item
5778The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
5779@item
5780There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
5781@end itemize
5782
5783In other words, raising the volume by +4 dB does not cause any clipping,
5784raising it by +5 dB causes clipping for 6 samples, etc.
5785
5786@c man end AUDIO FILTERS
5787
5788@chapter Audio Sources
5789@c man begin AUDIO SOURCES
5790
5791Below is a description of the currently available audio sources.
5792
5793@section abuffer
5794
5795Buffer audio frames, and make them available to the filter chain.
5796
5797This source is mainly intended for a programmatic use, in particular
5798through the interface defined in @file{libavfilter/asrc_abuffer.h}.
5799
5800It accepts the following parameters:
5801@table @option
5802
5803@item time_base
5804The timebase which will be used for timestamps of submitted frames. It must be
5805either a floating-point number or in @var{numerator}/@var{denominator} form.
5806
5807@item sample_rate
5808The sample rate of the incoming audio buffers.
5809
5810@item sample_fmt
5811The sample format of the incoming audio buffers.
5812Either a sample format name or its corresponding integer representation from
5813the enum AVSampleFormat in @file{libavutil/samplefmt.h}
5814
5815@item channel_layout
5816The channel layout of the incoming audio buffers.
5817Either a channel layout name from channel_layout_map in
5818@file{libavutil/channel_layout.c} or its corresponding integer representation
5819from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
5820
5821@item channels
5822The number of channels of the incoming audio buffers.
5823If both @var{channels} and @var{channel_layout} are specified, then they
5824must be consistent.
5825
5826@end table
5827
5828@subsection Examples
5829
5830@example
5831abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
5832@end example
5833
5834will instruct the source to accept planar 16bit signed stereo at 44100Hz.
5835Since the sample format with name "s16p" corresponds to the number
58366 and the "stereo" channel layout corresponds to the value 0x3, this is
5837equivalent to:
5838@example
5839abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
5840@end example
5841
5842@section aevalsrc
5843
5844Generate an audio signal specified by an expression.
5845
5846This source accepts in input one or more expressions (one for each
5847channel), which are evaluated and used to generate a corresponding
5848audio signal.
5849
5850This source accepts the following options:
5851
5852@table @option
5853@item exprs
5854Set the '|'-separated expressions list for each separate channel. In case the
5855@option{channel_layout} option is not specified, the selected channel layout
5856depends on the number of provided expressions. Otherwise the last
5857specified expression is applied to the remaining output channels.
5858
5859@item channel_layout, c
5860Set the channel layout. The number of channels in the specified layout
5861must be equal to the number of specified expressions.
5862
5863@item duration, d
5864Set the minimum duration of the sourced audio. See
5865@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
5866for the accepted syntax.
5867Note that the resulting duration may be greater than the specified
5868duration, as the generated audio is always cut at the end of a
5869complete frame.
5870
5871If not specified, or the expressed duration is negative, the audio is
5872supposed to be generated forever.
5873
5874@item nb_samples, n
5875Set the number of samples per channel per each output frame,
5876default to 1024.
5877
5878@item sample_rate, s
5879Specify the sample rate, default to 44100.
5880@end table
5881
5882Each expression in @var{exprs} can contain the following constants:
5883
5884@table @option
5885@item n
5886number of the evaluated sample, starting from 0
5887
5888@item t
5889time of the evaluated sample expressed in seconds, starting from 0
5890
5891@item s
5892sample rate
5893
5894@end table
5895
5896@subsection Examples
5897
5898@itemize
5899@item
5900Generate silence:
5901@example
5902aevalsrc=0
5903@end example
5904
5905@item
5906Generate a sin signal with frequency of 440 Hz, set sample rate to
59078000 Hz:
5908@example
5909aevalsrc="sin(440*2*PI*t):s=8000"
5910@end example
5911
5912@item
5913Generate a two channels signal, specify the channel layout (Front
5914Center + Back Center) explicitly:
5915@example
5916aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
5917@end example
5918
5919@item
5920Generate white noise:
5921@example
5922aevalsrc="-2+random(0)"
5923@end example
5924
5925@item
5926Generate an amplitude modulated signal:
5927@example
5928aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
5929@end example
5930
5931@item
5932Generate 2.5 Hz binaural beats on a 360 Hz carrier:
5933@example
5934aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
5935@end example
5936
5937@end itemize
5938
5939@section afirsrc
5940
5941Generate a FIR coefficients using frequency sampling method.
5942
5943The resulting stream can be used with @ref{afir} filter for filtering the audio signal.
5944
5945The filter accepts the following options:
5946
5947@table @option
5948@item taps, t
5949Set number of filter coefficents in output audio stream.
5950Default value is 1025.
5951
5952@item frequency, f
5953Set frequency points from where magnitude and phase are set.
5954This must be in non decreasing order, and first element must be 0, while last element
5955must be 1. Elements are separated by white spaces.
5956
5957@item magnitude, m
5958Set magnitude value for every frequency point set by @option{frequency}.
5959Number of values must be same as number of frequency points.
5960Values are separated by white spaces.
5961
5962@item phase, p
5963Set phase value for every frequency point set by @option{frequency}.
5964Number of values must be same as number of frequency points.
5965Values are separated by white spaces.
5966
5967@item sample_rate, r
5968Set sample rate, default is 44100.
5969
5970@item nb_samples, n
5971Set number of samples per each frame. Default is 1024.
5972
5973@item win_func, w
5974Set window function. Default is blackman.
5975@end table
5976
5977@section anullsrc
5978
5979The null audio source, return unprocessed audio frames. It is mainly useful
5980as a template and to be employed in analysis / debugging tools, or as
5981the source for filters which ignore the input data (for example the sox
5982synth filter).
5983
5984This source accepts the following options:
5985
5986@table @option
5987
5988@item channel_layout, cl
5989
5990Specifies the channel layout, and can be either an integer or a string
5991representing a channel layout. The default value of @var{channel_layout}
5992is "stereo".
5993
5994Check the channel_layout_map definition in
5995@file{libavutil/channel_layout.c} for the mapping between strings and
5996channel layout values.
5997
5998@item sample_rate, r
5999Specifies the sample rate, and defaults to 44100.
6000
6001@item nb_samples, n
6002Set the number of samples per requested frames.
6003
6004@end table
6005
6006@subsection Examples
6007
6008@itemize
6009@item
6010Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
6011@example
6012anullsrc=r=48000:cl=4
6013@end example
6014
6015@item
6016Do the same operation with a more obvious syntax:
6017@example
6018anullsrc=r=48000:cl=mono
6019@end example
6020@end itemize
6021
6022All the parameters need to be explicitly defined.
6023
6024@section flite
6025
6026Synthesize a voice utterance using the libflite library.
6027
6028To enable compilation of this filter you need to configure FFmpeg with
6029@code{--enable-libflite}.
6030
6031Note that versions of the flite library prior to 2.0 are not thread-safe.
6032
6033The filter accepts the following options:
6034
6035@table @option
6036
6037@item list_voices
6038If set to 1, list the names of the available voices and exit
6039immediately. Default value is 0.
6040
6041@item nb_samples, n
6042Set the maximum number of samples per frame. Default value is 512.
6043
6044@item textfile
6045Set the filename containing the text to speak.
6046
6047@item text
6048Set the text to speak.
6049
6050@item voice, v
6051Set the voice to use for the speech synthesis. Default value is
6052@code{kal}. See also the @var{list_voices} option.
6053@end table
6054
6055@subsection Examples
6056
6057@itemize
6058@item
6059Read from file @file{speech.txt}, and synthesize the text using the
6060standard flite voice:
6061@example
6062flite=textfile=speech.txt
6063@end example
6064
6065@item
6066Read the specified text selecting the @code{slt} voice:
6067@example
6068flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
6069@end example
6070
6071@item
6072Input text to ffmpeg:
6073@example
6074ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
6075@end example
6076
6077@item
6078Make @file{ffplay} speak the specified text, using @code{flite} and
6079the @code{lavfi} device:
6080@example
6081ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
6082@end example
6083@end itemize
6084
6085For more information about libflite, check:
6086@url{http://www.festvox.org/flite/}
6087
6088@section anoisesrc
6089
6090Generate a noise audio signal.
6091
6092The filter accepts the following options:
6093
6094@table @option
6095@item sample_rate, r
6096Specify the sample rate. Default value is 48000 Hz.
6097
6098@item amplitude, a
6099Specify the amplitude (0.0 - 1.0) of the generated audio stream. Default value
6100is 1.0.
6101
6102@item duration, d
6103Specify the duration of the generated audio stream. Not specifying this option
6104results in noise with an infinite length.
6105
6106@item color, colour, c
6107Specify the color of noise. Available noise colors are white, pink, brown,
6108blue, violet and velvet. Default color is white.
6109
6110@item seed, s
6111Specify a value used to seed the PRNG.
6112
6113@item nb_samples, n
6114Set the number of samples per each output frame, default is 1024.
6115@end table
6116
6117@subsection Examples
6118
6119@itemize
6120
6121@item
6122Generate 60 seconds of pink noise, with a 44.1 kHz sampling rate and an amplitude of 0.5:
6123@example
6124anoisesrc=d=60:c=pink:r=44100:a=0.5
6125@end example
6126@end itemize
6127
6128@section hilbert
6129
6130Generate odd-tap Hilbert transform FIR coefficients.
6131
6132The resulting stream can be used with @ref{afir} filter for phase-shifting
6133the signal by 90 degrees.
6134
6135This is used in many matrix coding schemes and for analytic signal generation.
6136The process is often written as a multiplication by i (or j), the imaginary unit.
6137
6138The filter accepts the following options:
6139
6140@table @option
6141
6142@item sample_rate, s
6143Set sample rate, default is 44100.
6144
6145@item taps, t
6146Set length of FIR filter, default is 22051.
6147
6148@item nb_samples, n
6149Set number of samples per each frame.
6150
6151@item win_func, w
6152Set window function to be used when generating FIR coefficients.
6153@end table
6154
6155@section sinc
6156
6157Generate a sinc kaiser-windowed low-pass, high-pass, band-pass, or band-reject FIR coefficients.
6158
6159The resulting stream can be used with @ref{afir} filter for filtering the audio signal.
6160
6161The filter accepts the following options:
6162
6163@table @option
6164@item sample_rate, r
6165Set sample rate, default is 44100.
6166
6167@item nb_samples, n
6168Set number of samples per each frame. Default is 1024.
6169
6170@item hp
6171Set high-pass frequency. Default is 0.
6172
6173@item lp
6174Set low-pass frequency. Default is 0.
6175If high-pass frequency is lower than low-pass frequency and low-pass frequency
6176is higher than 0 then filter will create band-pass filter coefficients,
6177otherwise band-reject filter coefficients.
6178
6179@item phase
6180Set filter phase response. Default is 50. Allowed range is from 0 to 100.
6181
6182@item beta
6183Set Kaiser window beta.
6184
6185@item att
6186Set stop-band attenuation. Default is 120dB, allowed range is from 40 to 180 dB.
6187
6188@item round
6189Enable rounding, by default is disabled.
6190
6191@item hptaps
6192Set number of taps for high-pass filter.
6193
6194@item lptaps
6195Set number of taps for low-pass filter.
6196@end table
6197
6198@section sine
6199
6200Generate an audio signal made of a sine wave with amplitude 1/8.
6201
6202The audio signal is bit-exact.
6203
6204The filter accepts the following options:
6205
6206@table @option
6207
6208@item frequency, f
6209Set the carrier frequency. Default is 440 Hz.
6210
6211@item beep_factor, b
6212Enable a periodic beep every second with frequency @var{beep_factor} times
6213the carrier frequency. Default is 0, meaning the beep is disabled.
6214
6215@item sample_rate, r
6216Specify the sample rate, default is 44100.
6217
6218@item duration, d
6219Specify the duration of the generated audio stream.
6220
6221@item samples_per_frame
6222Set the number of samples per output frame.
6223
6224The expression can contain the following constants:
6225
6226@table @option
6227@item n
6228The (sequential) number of the output audio frame, starting from 0.
6229
6230@item pts
6231The PTS (Presentation TimeStamp) of the output audio frame,
6232expressed in @var{TB} units.
6233
6234@item t
6235The PTS of the output audio frame, expressed in seconds.
6236
6237@item TB
6238The timebase of the output audio frames.
6239@end table
6240
6241Default is @code{1024}.
6242@end table
6243
6244@subsection Examples
6245
6246@itemize
6247
6248@item
6249Generate a simple 440 Hz sine wave:
6250@example
6251sine
6252@end example
6253
6254@item
6255Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
6256@example
6257sine=220:4:d=5
6258sine=f=220:b=4:d=5
6259sine=frequency=220:beep_factor=4:duration=5
6260@end example
6261
6262@item
6263Generate a 1 kHz sine wave following @code{1602,1601,1602,1601,1602} NTSC
6264pattern:
6265@example
6266sine=1000:samples_per_frame='st(0,mod(n,5)); 1602-not(not(eq(ld(0),1)+eq(ld(0),3)))'
6267@end example
6268@end itemize
6269
6270@c man end AUDIO SOURCES
6271
6272@chapter Audio Sinks
6273@c man begin AUDIO SINKS
6274
6275Below is a description of the currently available audio sinks.
6276
6277@section abuffersink
6278
6279Buffer audio frames, and make them available to the end of filter chain.
6280
6281This sink is mainly intended for programmatic use, in particular
6282through the interface defined in @file{libavfilter/buffersink.h}
6283or the options system.
6284
6285It accepts a pointer to an AVABufferSinkContext structure, which
6286defines the incoming buffers' formats, to be passed as the opaque
6287parameter to @code{avfilter_init_filter} for initialization.
6288@section anullsink
6289
6290Null audio sink; do absolutely nothing with the input audio. It is
6291mainly useful as a template and for use in analysis / debugging
6292tools.
6293
6294@c man end AUDIO SINKS
6295
6296@chapter Video Filters
6297@c man begin VIDEO FILTERS
6298
6299When you configure your FFmpeg build, you can disable any of the
6300existing filters using @code{--disable-filters}.
6301The configure output will show the video filters included in your
6302build.
6303
6304Below is a description of the currently available video filters.
6305
6306@section addroi
6307
6308Mark a region of interest in a video frame.
6309
6310The frame data is passed through unchanged, but metadata is attached
6311to the frame indicating regions of interest which can affect the
6312behaviour of later encoding.  Multiple regions can be marked by
6313applying the filter multiple times.
6314
6315@table @option
6316@item x
6317Region distance in pixels from the left edge of the frame.
6318@item y
6319Region distance in pixels from the top edge of the frame.
6320@item w
6321Region width in pixels.
6322@item h
6323Region height in pixels.
6324
6325The parameters @var{x}, @var{y}, @var{w} and @var{h} are expressions,
6326and may contain the following variables:
6327@table @option
6328@item iw
6329Width of the input frame.
6330@item ih
6331Height of the input frame.
6332@end table
6333
6334@item qoffset
6335Quantisation offset to apply within the region.
6336
6337This must be a real value in the range -1 to +1.  A value of zero
6338indicates no quality change.  A negative value asks for better quality
6339(less quantisation), while a positive value asks for worse quality
6340(greater quantisation).
6341
6342The range is calibrated so that the extreme values indicate the
6343largest possible offset - if the rest of the frame is encoded with the
6344worst possible quality, an offset of -1 indicates that this region
6345should be encoded with the best possible quality anyway.  Intermediate
6346values are then interpolated in some codec-dependent way.
6347
6348For example, in 10-bit H.264 the quantisation parameter varies between
6349-12 and 51.  A typical qoffset value of -1/10 therefore indicates that
6350this region should be encoded with a QP around one-tenth of the full
6351range better than the rest of the frame.  So, if most of the frame
6352were to be encoded with a QP of around 30, this region would get a QP
6353of around 24 (an offset of approximately -1/10 * (51 - -12) = -6.3).
6354An extreme value of -1 would indicate that this region should be
6355encoded with the best possible quality regardless of the treatment of
6356the rest of the frame - that is, should be encoded at a QP of -12.
6357@item clear
6358If set to true, remove any existing regions of interest marked on the
6359frame before adding the new one.
6360@end table
6361
6362@subsection Examples
6363
6364@itemize
6365@item
6366Mark the centre quarter of the frame as interesting.
6367@example
6368addroi=iw/4:ih/4:iw/2:ih/2:-1/10
6369@end example
6370@item
6371Mark the 100-pixel-wide region on the left edge of the frame as very
6372uninteresting (to be encoded at much lower quality than the rest of
6373the frame).
6374@example
6375addroi=0:0:100:ih:+1/5
6376@end example
6377@end itemize
6378
6379@section alphaextract
6380
6381Extract the alpha component from the input as a grayscale video. This
6382is especially useful with the @var{alphamerge} filter.
6383
6384@section alphamerge
6385
6386Add or replace the alpha component of the primary input with the
6387grayscale value of a second input. This is intended for use with
6388@var{alphaextract} to allow the transmission or storage of frame
6389sequences that have alpha in a format that doesn't support an alpha
6390channel.
6391
6392For example, to reconstruct full frames from a normal YUV-encoded video
6393and a separate video created with @var{alphaextract}, you might use:
6394@example
6395movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
6396@end example
6397
6398Since this filter is designed for reconstruction, it operates on frame
6399sequences without considering timestamps, and terminates when either
6400input reaches end of stream. This will cause problems if your encoding
6401pipeline drops frames. If you're trying to apply an image as an
6402overlay to a video stream, consider the @var{overlay} filter instead.
6403
6404@section amplify
6405
6406Amplify differences between current pixel and pixels of adjacent frames in
6407same pixel location.
6408
6409This filter accepts the following options:
6410
6411@table @option
6412@item radius
6413Set frame radius. Default is 2. Allowed range is from 1 to 63.
6414For example radius of 3 will instruct filter to calculate average of 7 frames.
6415
6416@item factor
6417Set factor to amplify difference. Default is 2. Allowed range is from 0 to 65535.
6418
6419@item threshold
6420Set threshold for difference amplification. Any difference greater or equal to
6421this value will not alter source pixel. Default is 10.
6422Allowed range is from 0 to 65535.
6423
6424@item tolerance
6425Set tolerance for difference amplification. Any difference lower to
6426this value will not alter source pixel. Default is 0.
6427Allowed range is from 0 to 65535.
6428
6429@item low
6430Set lower limit for changing source pixel. Default is 65535. Allowed range is from 0 to 65535.
6431This option controls maximum possible value that will decrease source pixel value.
6432
6433@item high
6434Set high limit for changing source pixel. Default is 65535. Allowed range is from 0 to 65535.
6435This option controls maximum possible value that will increase source pixel value.
6436
6437@item planes
6438Set which planes to filter. Default is all. Allowed range is from 0 to 15.
6439@end table
6440
6441@subsection Commands
6442
6443This filter supports the following @ref{commands} that corresponds to option of same name:
6444@table @option
6445@item factor
6446@item threshold
6447@item tolerance
6448@item low
6449@item high
6450@item planes
6451@end table
6452
6453@section ass
6454
6455Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
6456and libavformat to work. On the other hand, it is limited to ASS (Advanced
6457Substation Alpha) subtitles files.
6458
6459This filter accepts the following option in addition to the common options from
6460the @ref{subtitles} filter:
6461
6462@table @option
6463@item shaping
6464Set the shaping engine
6465
6466Available values are:
6467@table @samp
6468@item auto
6469The default libass shaping engine, which is the best available.
6470@item simple
6471Fast, font-agnostic shaper that can do only substitutions
6472@item complex
6473Slower shaper using OpenType for substitutions and positioning
6474@end table
6475
6476The default is @code{auto}.
6477@end table
6478
6479@section atadenoise
6480Apply an Adaptive Temporal Averaging Denoiser to the video input.
6481
6482The filter accepts the following options:
6483
6484@table @option
6485@item 0a
6486Set threshold A for 1st plane. Default is 0.02.
6487Valid range is 0 to 0.3.
6488
6489@item 0b
6490Set threshold B for 1st plane. Default is 0.04.
6491Valid range is 0 to 5.
6492
6493@item 1a
6494Set threshold A for 2nd plane. Default is 0.02.
6495Valid range is 0 to 0.3.
6496
6497@item 1b
6498Set threshold B for 2nd plane. Default is 0.04.
6499Valid range is 0 to 5.
6500
6501@item 2a
6502Set threshold A for 3rd plane. Default is 0.02.
6503Valid range is 0 to 0.3.
6504
6505@item 2b
6506Set threshold B for 3rd plane. Default is 0.04.
6507Valid range is 0 to 5.
6508
6509Threshold A is designed to react on abrupt changes in the input signal and
6510threshold B is designed to react on continuous changes in the input signal.
6511
6512@item s
6513Set number of frames filter will use for averaging. Default is 9. Must be odd
6514number in range [5, 129].
6515
6516@item p
6517Set what planes of frame filter will use for averaging. Default is all.
6518
6519@item a
6520Set what variant of algorithm filter will use for averaging. Default is @code{p} parallel.
6521Alternatively can be set to @code{s} serial.
6522
6523Parallel can be faster then serial, while other way around is never true.
6524Parallel will abort early on first change being greater then thresholds, while serial
6525will continue processing other side of frames if they are equal or bellow thresholds.
6526@end table
6527
6528@subsection Commands
6529This filter supports same @ref{commands} as options except option @code{s}.
6530The command accepts the same syntax of the corresponding option.
6531
6532@section avgblur
6533
6534Apply average blur filter.
6535
6536The filter accepts the following options:
6537
6538@table @option
6539@item sizeX
6540Set horizontal radius size.
6541
6542@item planes
6543Set which planes to filter. By default all planes are filtered.
6544
6545@item sizeY
6546Set vertical radius size, if zero it will be same as @code{sizeX}.
6547Default is @code{0}.
6548@end table
6549
6550@subsection Commands
6551This filter supports same commands as options.
6552The command accepts the same syntax of the corresponding option.
6553
6554If the specified expression is not valid, it is kept at its current
6555value.
6556
6557@section bbox
6558
6559Compute the bounding box for the non-black pixels in the input frame
6560luminance plane.
6561
6562This filter computes the bounding box containing all the pixels with a
6563luminance value greater than the minimum allowed value.
6564The parameters describing the bounding box are printed on the filter
6565log.
6566
6567The filter accepts the following option:
6568
6569@table @option
6570@item min_val
6571Set the minimal luminance value. Default is @code{16}.
6572@end table
6573
6574@section bilateral
6575Apply bilateral filter, spatial smoothing while preserving edges.
6576
6577The filter accepts the following options:
6578@table @option
6579@item sigmaS
6580Set sigma of gaussian function to calculate spatial weight.
6581Allowed range is 0 to 10. Default is 0.1.
6582
6583@item sigmaR
6584Set sigma of gaussian function to calculate range weight.
6585Allowed range is 0 to 1. Default is 0.1.
6586
6587@item planes
6588Set planes to filter. Default is first only.
6589@end table
6590
6591@section bitplanenoise
6592
6593Show and measure bit plane noise.
6594
6595The filter accepts the following options:
6596
6597@table @option
6598@item bitplane
6599Set which plane to analyze. Default is @code{1}.
6600
6601@item filter
6602Filter out noisy pixels from @code{bitplane} set above.
6603Default is disabled.
6604@end table
6605
6606@section blackdetect
6607
6608Detect video intervals that are (almost) completely black. Can be
6609useful to detect chapter transitions, commercials, or invalid
6610recordings.
6611
6612The filter outputs its detection analysis to both the log as well as
6613frame metadata. If a black segment of at least the specified minimum
6614duration is found, a line with the start and end timestamps as well
6615as duration is printed to the log with level @code{info}. In addition,
6616a log line with level @code{debug} is printed per frame showing the
6617black amount detected for that frame.
6618
6619The filter also attaches metadata to the first frame of a black
6620segment with key @code{lavfi.black_start} and to the first frame
6621after the black segment ends with key @code{lavfi.black_end}. The
6622value is the frame's timestamp. This metadata is added regardless
6623of the minimum duration specified.
6624
6625The filter accepts the following options:
6626
6627@table @option
6628@item black_min_duration, d
6629Set the minimum detected black duration expressed in seconds. It must
6630be a non-negative floating point number.
6631
6632Default value is 2.0.
6633
6634@item picture_black_ratio_th, pic_th
6635Set the threshold for considering a picture "black".
6636Express the minimum value for the ratio:
6637@example
6638@var{nb_black_pixels} / @var{nb_pixels}
6639@end example
6640
6641for which a picture is considered black.
6642Default value is 0.98.
6643
6644@item pixel_black_th, pix_th
6645Set the threshold for considering a pixel "black".
6646
6647The threshold expresses the maximum pixel luminance value for which a
6648pixel is considered "black". The provided value is scaled according to
6649the following equation:
6650@example
6651@var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
6652@end example
6653
6654@var{luminance_range_size} and @var{luminance_minimum_value} depend on
6655the input video format, the range is [0-255] for YUV full-range
6656formats and [16-235] for YUV non full-range formats.
6657
6658Default value is 0.10.
6659@end table
6660
6661The following example sets the maximum pixel threshold to the minimum
6662value, and detects only black intervals of 2 or more seconds:
6663@example
6664blackdetect=d=2:pix_th=0.00
6665@end example
6666
6667@section blackframe
6668
6669Detect frames that are (almost) completely black. Can be useful to
6670detect chapter transitions or commercials. Output lines consist of
6671the frame number of the detected frame, the percentage of blackness,
6672the position in the file if known or -1 and the timestamp in seconds.
6673
6674In order to display the output lines, you need to set the loglevel at
6675least to the AV_LOG_INFO value.
6676
6677This filter exports frame metadata @code{lavfi.blackframe.pblack}.
6678The value represents the percentage of pixels in the picture that
6679are below the threshold value.
6680
6681It accepts the following parameters:
6682
6683@table @option
6684
6685@item amount
6686The percentage of the pixels that have to be below the threshold; it defaults to
6687@code{98}.
6688
6689@item threshold, thresh
6690The threshold below which a pixel value is considered black; it defaults to
6691@code{32}.
6692
6693@end table
6694
6695@anchor{blend}
6696@section blend
6697
6698Blend two video frames into each other.
6699
6700The @code{blend} filter takes two input streams and outputs one
6701stream, the first input is the "top" layer and second input is
6702"bottom" layer.  By default, the output terminates when the longest input terminates.
6703
6704The @code{tblend} (time blend) filter takes two consecutive frames
6705from one single stream, and outputs the result obtained by blending
6706the new frame on top of the old frame.
6707
6708A description of the accepted options follows.
6709
6710@table @option
6711@item c0_mode
6712@item c1_mode
6713@item c2_mode
6714@item c3_mode
6715@item all_mode
6716Set blend mode for specific pixel component or all pixel components in case
6717of @var{all_mode}. Default value is @code{normal}.
6718
6719Available values for component modes are:
6720@table @samp
6721@item addition
6722@item grainmerge
6723@item and
6724@item average
6725@item burn
6726@item darken
6727@item difference
6728@item grainextract
6729@item divide
6730@item dodge
6731@item freeze
6732@item exclusion
6733@item extremity
6734@item glow
6735@item hardlight
6736@item hardmix
6737@item heat
6738@item lighten
6739@item linearlight
6740@item multiply
6741@item multiply128
6742@item negation
6743@item normal
6744@item or
6745@item overlay
6746@item phoenix
6747@item pinlight
6748@item reflect
6749@item screen
6750@item softlight
6751@item subtract
6752@item vividlight
6753@item xor
6754@end table
6755
6756@item c0_opacity
6757@item c1_opacity
6758@item c2_opacity
6759@item c3_opacity
6760@item all_opacity
6761Set blend opacity for specific pixel component or all pixel components in case
6762of @var{all_opacity}. Only used in combination with pixel component blend modes.
6763
6764@item c0_expr
6765@item c1_expr
6766@item c2_expr
6767@item c3_expr
6768@item all_expr
6769Set blend expression for specific pixel component or all pixel components in case
6770of @var{all_expr}. Note that related mode options will be ignored if those are set.
6771
6772The expressions can use the following variables:
6773
6774@table @option
6775@item N
6776The sequential number of the filtered frame, starting from @code{0}.
6777
6778@item X
6779@item Y
6780the coordinates of the current sample
6781
6782@item W
6783@item H
6784the width and height of currently filtered plane
6785
6786@item SW
6787@item SH
6788Width and height scale for the plane being filtered. It is the
6789ratio between the dimensions of the current plane to the luma plane,
6790e.g. for a @code{yuv420p} frame, the values are @code{1,1} for
6791the luma plane and @code{0.5,0.5} for the chroma planes.
6792
6793@item T
6794Time of the current frame, expressed in seconds.
6795
6796@item TOP, A
6797Value of pixel component at current location for first video frame (top layer).
6798
6799@item BOTTOM, B
6800Value of pixel component at current location for second video frame (bottom layer).
6801@end table
6802@end table
6803
6804The @code{blend} filter also supports the @ref{framesync} options.
6805
6806@subsection Examples
6807
6808@itemize
6809@item
6810Apply transition from bottom layer to top layer in first 10 seconds:
6811@example
6812blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
6813@end example
6814
6815@item
6816Apply linear horizontal transition from top layer to bottom layer:
6817@example
6818blend=all_expr='A*(X/W)+B*(1-X/W)'
6819@end example
6820
6821@item
6822Apply 1x1 checkerboard effect:
6823@example
6824blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
6825@end example
6826
6827@item
6828Apply uncover left effect:
6829@example
6830blend=all_expr='if(gte(N*SW+X,W),A,B)'
6831@end example
6832
6833@item
6834Apply uncover down effect:
6835@example
6836blend=all_expr='if(gte(Y-N*SH,0),A,B)'
6837@end example
6838
6839@item
6840Apply uncover up-left effect:
6841@example
6842blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
6843@end example
6844
6845@item
6846Split diagonally video and shows top and bottom layer on each side:
6847@example
6848blend=all_expr='if(gt(X,Y*(W/H)),A,B)'
6849@end example
6850
6851@item
6852Display differences between the current and the previous frame:
6853@example
6854tblend=all_mode=grainextract
6855@end example
6856@end itemize
6857
6858@section bm3d
6859
6860Denoise frames using Block-Matching 3D algorithm.
6861
6862The filter accepts the following options.
6863
6864@table @option
6865@item sigma
6866Set denoising strength. Default value is 1.
6867Allowed range is from 0 to 999.9.
6868The denoising algorithm is very sensitive to sigma, so adjust it
6869according to the source.
6870
6871@item block
6872Set local patch size. This sets dimensions in 2D.
6873
6874@item bstep
6875Set sliding step for processing blocks. Default value is 4.
6876Allowed range is from 1 to 64.
6877Smaller values allows processing more reference blocks and is slower.
6878
6879@item group
6880Set maximal number of similar blocks for 3rd dimension. Default value is 1.
6881When set to 1, no block matching is done. Larger values allows more blocks
6882in single group.
6883Allowed range is from 1 to 256.
6884
6885@item range
6886Set radius for search block matching. Default is 9.
6887Allowed range is from 1 to INT32_MAX.
6888
6889@item mstep
6890Set step between two search locations for block matching. Default is 1.
6891Allowed range is from 1 to 64. Smaller is slower.
6892
6893@item thmse
6894Set threshold of mean square error for block matching. Valid range is 0 to
6895INT32_MAX.
6896
6897@item hdthr
6898Set thresholding parameter for hard thresholding in 3D transformed domain.
6899Larger values results in stronger hard-thresholding filtering in frequency
6900domain.
6901
6902@item estim
6903Set filtering estimation mode. Can be @code{basic} or @code{final}.
6904Default is @code{basic}.
6905
6906@item ref
6907If enabled, filter will use 2nd stream for block matching.
6908Default is disabled for @code{basic} value of @var{estim} option,
6909and always enabled if value of @var{estim} is @code{final}.
6910
6911@item planes
6912Set planes to filter. Default is all available except alpha.
6913@end table
6914
6915@subsection Examples
6916
6917@itemize
6918@item
6919Basic filtering with bm3d:
6920@example
6921bm3d=sigma=3:block=4:bstep=2:group=1:estim=basic
6922@end example
6923
6924@item
6925Same as above, but filtering only luma:
6926@example
6927bm3d=sigma=3:block=4:bstep=2:group=1:estim=basic:planes=1
6928@end example
6929
6930@item
6931Same as above, but with both estimation modes:
6932@example
6933split[a][b],[a]bm3d=sigma=3:block=4:bstep=2:group=1:estim=basic[a],[b][a]bm3d=sigma=3:block=4:bstep=2:group=16:estim=final:ref=1
6934@end example
6935
6936@item
6937Same as above, but prefilter with @ref{nlmeans} filter instead:
6938@example
6939split[a][b],[a]nlmeans=s=3:r=7:p=3[a],[b][a]bm3d=sigma=3:block=4:bstep=2:group=16:estim=final:ref=1
6940@end example
6941@end itemize
6942
6943@section boxblur
6944
6945Apply a boxblur algorithm to the input video.
6946
6947It accepts the following parameters:
6948
6949@table @option
6950
6951@item luma_radius, lr
6952@item luma_power, lp
6953@item chroma_radius, cr
6954@item chroma_power, cp
6955@item alpha_radius, ar
6956@item alpha_power, ap
6957
6958@end table
6959
6960A description of the accepted options follows.
6961
6962@table @option
6963@item luma_radius, lr
6964@item chroma_radius, cr
6965@item alpha_radius, ar
6966Set an expression for the box radius in pixels used for blurring the
6967corresponding input plane.
6968
6969The radius value must be a non-negative number, and must not be
6970greater than the value of the expression @code{min(w,h)/2} for the
6971luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
6972planes.
6973
6974Default value for @option{luma_radius} is "2". If not specified,
6975@option{chroma_radius} and @option{alpha_radius} default to the
6976corresponding value set for @option{luma_radius}.
6977
6978The expressions can contain the following constants:
6979@table @option
6980@item w
6981@item h
6982The input width and height in pixels.
6983
6984@item cw
6985@item ch
6986The input chroma image width and height in pixels.
6987
6988@item hsub
6989@item vsub
6990The horizontal and vertical chroma subsample values. For example, for the
6991pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
6992@end table
6993
6994@item luma_power, lp
6995@item chroma_power, cp
6996@item alpha_power, ap
6997Specify how many times the boxblur filter is applied to the
6998corresponding plane.
6999
7000Default value for @option{luma_power} is 2. If not specified,
7001@option{chroma_power} and @option{alpha_power} default to the
7002corresponding value set for @option{luma_power}.
7003
7004A value of 0 will disable the effect.
7005@end table
7006
7007@subsection Examples
7008
7009@itemize
7010@item
7011Apply a boxblur filter with the luma, chroma, and alpha radii
7012set to 2:
7013@example
7014boxblur=luma_radius=2:luma_power=1
7015boxblur=2:1
7016@end example
7017
7018@item
7019Set the luma radius to 2, and alpha and chroma radius to 0:
7020@example
7021boxblur=2:1:cr=0:ar=0
7022@end example
7023
7024@item
7025Set the luma and chroma radii to a fraction of the video dimension:
7026@example
7027boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
7028@end example
7029@end itemize
7030
7031@section bwdif
7032
7033Deinterlace the input video ("bwdif" stands for "Bob Weaver
7034Deinterlacing Filter").
7035
7036Motion adaptive deinterlacing based on yadif with the use of w3fdif and cubic
7037interpolation algorithms.
7038It accepts the following parameters:
7039
7040@table @option
7041@item mode
7042The interlacing mode to adopt. It accepts one of the following values:
7043
7044@table @option
7045@item 0, send_frame
7046Output one frame for each frame.
7047@item 1, send_field
7048Output one frame for each field.
7049@end table
7050
7051The default value is @code{send_field}.
7052
7053@item parity
7054The picture field parity assumed for the input interlaced video. It accepts one
7055of the following values:
7056
7057@table @option
7058@item 0, tff
7059Assume the top field is first.
7060@item 1, bff
7061Assume the bottom field is first.
7062@item -1, auto
7063Enable automatic detection of field parity.
7064@end table
7065
7066The default value is @code{auto}.
7067If the interlacing is unknown or the decoder does not export this information,
7068top field first will be assumed.
7069
7070@item deint
7071Specify which frames to deinterlace. Accepts one of the following
7072values:
7073
7074@table @option
7075@item 0, all
7076Deinterlace all frames.
7077@item 1, interlaced
7078Only deinterlace frames marked as interlaced.
7079@end table
7080
7081The default value is @code{all}.
7082@end table
7083
7084@section cas
7085
7086Apply Contrast Adaptive Sharpen filter to video stream.
7087
7088The filter accepts the following options:
7089
7090@table @option
7091@item strength
7092Set the sharpening strength. Default value is 0.
7093
7094@item planes
7095Set planes to filter. Default value is to filter all
7096planes except alpha plane.
7097@end table
7098
7099@section chromahold
7100Remove all color information for all colors except for certain one.
7101
7102The filter accepts the following options:
7103
7104@table @option
7105@item color
7106The color which will not be replaced with neutral chroma.
7107
7108@item similarity
7109Similarity percentage with the above color.
71100.01 matches only the exact key color, while 1.0 matches everything.
7111
7112@item blend
7113Blend percentage.
71140.0 makes pixels either fully gray, or not gray at all.
7115Higher values result in more preserved color.
7116
7117@item yuv
7118Signals that the color passed is already in YUV instead of RGB.
7119
7120Literal colors like "green" or "red" don't make sense with this enabled anymore.
7121This can be used to pass exact YUV values as hexadecimal numbers.
7122@end table
7123
7124@subsection Commands
7125This filter supports same @ref{commands} as options.
7126The command accepts the same syntax of the corresponding option.
7127
7128If the specified expression is not valid, it is kept at its current
7129value.
7130
7131@section chromakey
7132YUV colorspace color/chroma keying.
7133
7134The filter accepts the following options:
7135
7136@table @option
7137@item color
7138The color which will be replaced with transparency.
7139
7140@item similarity
7141Similarity percentage with the key color.
7142
71430.01 matches only the exact key color, while 1.0 matches everything.
7144
7145@item blend
7146Blend percentage.
7147
71480.0 makes pixels either fully transparent, or not transparent at all.
7149
7150Higher values result in semi-transparent pixels, with a higher transparency
7151the more similar the pixels color is to the key color.
7152
7153@item yuv
7154Signals that the color passed is already in YUV instead of RGB.
7155
7156Literal colors like "green" or "red" don't make sense with this enabled anymore.
7157This can be used to pass exact YUV values as hexadecimal numbers.
7158@end table
7159
7160@subsection Commands
7161This filter supports same @ref{commands} as options.
7162The command accepts the same syntax of the corresponding option.
7163
7164If the specified expression is not valid, it is kept at its current
7165value.
7166
7167@subsection Examples
7168
7169@itemize
7170@item
7171Make every green pixel in the input image transparent:
7172@example
7173ffmpeg -i input.png -vf chromakey=green out.png
7174@end example
7175
7176@item
7177Overlay a greenscreen-video on top of a static black background.
7178@example
7179ffmpeg -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
7180@end example
7181@end itemize
7182
7183@section chromashift
7184Shift chroma pixels horizontally and/or vertically.
7185
7186The filter accepts the following options:
7187@table @option
7188@item cbh
7189Set amount to shift chroma-blue horizontally.
7190@item cbv
7191Set amount to shift chroma-blue vertically.
7192@item crh
7193Set amount to shift chroma-red horizontally.
7194@item crv
7195Set amount to shift chroma-red vertically.
7196@item edge
7197Set edge mode, can be @var{smear}, default, or @var{warp}.
7198@end table
7199
7200@subsection Commands
7201
7202This filter supports the all above options as @ref{commands}.
7203
7204@section ciescope
7205
7206Display CIE color diagram with pixels overlaid onto it.
7207
7208The filter accepts the following options:
7209
7210@table @option
7211@item system
7212Set color system.
7213
7214@table @samp
7215@item ntsc, 470m
7216@item ebu, 470bg
7217@item smpte
7218@item 240m
7219@item apple
7220@item widergb
7221@item cie1931
7222@item rec709, hdtv
7223@item uhdtv, rec2020
7224@item dcip3
7225@end table
7226
7227@item cie
7228Set CIE system.
7229
7230@table @samp
7231@item xyy
7232@item ucs
7233@item luv
7234@end table
7235
7236@item gamuts
7237Set what gamuts to draw.
7238
7239See @code{system} option for available values.
7240
7241@item size, s
7242Set ciescope size, by default set to 512.
7243
7244@item intensity, i
7245Set intensity used to map input pixel values to CIE diagram.
7246
7247@item contrast
7248Set contrast used to draw tongue colors that are out of active color system gamut.
7249
7250@item corrgamma
7251Correct gamma displayed on scope, by default enabled.
7252
7253@item showwhite
7254Show white point on CIE diagram, by default disabled.
7255
7256@item gamma
7257Set input gamma. Used only with XYZ input color space.
7258@end table
7259
7260@section codecview
7261
7262Visualize information exported by some codecs.
7263
7264Some codecs can export information through frames using side-data or other
7265means. For example, some MPEG based codecs export motion vectors through the
7266@var{export_mvs} flag in the codec @option{flags2} option.
7267
7268The filter accepts the following option:
7269
7270@table @option
7271@item mv
7272Set motion vectors to visualize.
7273
7274Available flags for @var{mv} are:
7275
7276@table @samp
7277@item pf
7278forward predicted MVs of P-frames
7279@item bf
7280forward predicted MVs of B-frames
7281@item bb
7282backward predicted MVs of B-frames
7283@end table
7284
7285@item qp
7286Display quantization parameters using the chroma planes.
7287
7288@item mv_type, mvt
7289Set motion vectors type to visualize. Includes MVs from all frames unless specified by @var{frame_type} option.
7290
7291Available flags for @var{mv_type} are:
7292
7293@table @samp
7294@item fp
7295forward predicted MVs
7296@item bp
7297backward predicted MVs
7298@end table
7299
7300@item frame_type, ft
7301Set frame type to visualize motion vectors of.
7302
7303Available flags for @var{frame_type} are:
7304
7305@table @samp
7306@item if
7307intra-coded frames (I-frames)
7308@item pf
7309predicted frames (P-frames)
7310@item bf
7311bi-directionally predicted frames (B-frames)
7312@end table
7313@end table
7314
7315@subsection Examples
7316
7317@itemize
7318@item
7319Visualize forward predicted MVs of all frames using @command{ffplay}:
7320@example
7321ffplay -flags2 +export_mvs input.mp4 -vf codecview=mv_type=fp
7322@end example
7323
7324@item
7325Visualize multi-directionals MVs of P and B-Frames using @command{ffplay}:
7326@example
7327ffplay -flags2 +export_mvs input.mp4 -vf codecview=mv=pf+bf+bb
7328@end example
7329@end itemize
7330
7331@section colorbalance
7332Modify intensity of primary colors (red, green and blue) of input frames.
7333
7334The filter allows an input frame to be adjusted in the shadows, midtones or highlights
7335regions for the red-cyan, green-magenta or blue-yellow balance.
7336
7337A positive adjustment value shifts the balance towards the primary color, a negative
7338value towards the complementary color.
7339
7340The filter accepts the following options:
7341
7342@table @option
7343@item rs
7344@item gs
7345@item bs
7346Adjust red, green and blue shadows (darkest pixels).
7347
7348@item rm
7349@item gm
7350@item bm
7351Adjust red, green and blue midtones (medium pixels).
7352
7353@item rh
7354@item gh
7355@item bh
7356Adjust red, green and blue highlights (brightest pixels).
7357
7358Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
7359
7360@item pl
7361Preserve lightness when changing color balance. Default is disabled.
7362@end table
7363
7364@subsection Examples
7365
7366@itemize
7367@item
7368Add red color cast to shadows:
7369@example
7370colorbalance=rs=.3
7371@end example
7372@end itemize
7373
7374@subsection Commands
7375
7376This filter supports the all above options as @ref{commands}.
7377
7378@section colorchannelmixer
7379
7380Adjust video input frames by re-mixing color channels.
7381
7382This filter modifies a color channel by adding the values associated to
7383the other channels of the same pixels. For example if the value to
7384modify is red, the output value will be:
7385@example
7386@var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
7387@end example
7388
7389The filter accepts the following options:
7390
7391@table @option
7392@item rr
7393@item rg
7394@item rb
7395@item ra
7396Adjust contribution of input red, green, blue and alpha channels for output red channel.
7397Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
7398
7399@item gr
7400@item gg
7401@item gb
7402@item ga
7403Adjust contribution of input red, green, blue and alpha channels for output green channel.
7404Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
7405
7406@item br
7407@item bg
7408@item bb
7409@item ba
7410Adjust contribution of input red, green, blue and alpha channels for output blue channel.
7411Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
7412
7413@item ar
7414@item ag
7415@item ab
7416@item aa
7417Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
7418Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
7419
7420Allowed ranges for options are @code{[-2.0, 2.0]}.
7421@end table
7422
7423@subsection Examples
7424
7425@itemize
7426@item
7427Convert source to grayscale:
7428@example
7429colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
7430@end example
7431@item
7432Simulate sepia tones:
7433@example
7434colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
7435@end example
7436@end itemize
7437
7438@subsection Commands
7439
7440This filter supports the all above options as @ref{commands}.
7441
7442@section colorkey
7443RGB colorspace color keying.
7444
7445The filter accepts the following options:
7446
7447@table @option
7448@item color
7449The color which will be replaced with transparency.
7450
7451@item similarity
7452Similarity percentage with the key color.
7453
74540.01 matches only the exact key color, while 1.0 matches everything.
7455
7456@item blend
7457Blend percentage.
7458
74590.0 makes pixels either fully transparent, or not transparent at all.
7460
7461Higher values result in semi-transparent pixels, with a higher transparency
7462the more similar the pixels color is to the key color.
7463@end table
7464
7465@subsection Examples
7466
7467@itemize
7468@item
7469Make every green pixel in the input image transparent:
7470@example
7471ffmpeg -i input.png -vf colorkey=green out.png
7472@end example
7473
7474@item
7475Overlay a greenscreen-video on top of a static background image.
7476@example
7477ffmpeg -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
7478@end example
7479@end itemize
7480
7481@subsection Commands
7482This filter supports same @ref{commands} as options.
7483The command accepts the same syntax of the corresponding option.
7484
7485If the specified expression is not valid, it is kept at its current
7486value.
7487
7488@section colorhold
7489Remove all color information for all RGB colors except for certain one.
7490
7491The filter accepts the following options:
7492
7493@table @option
7494@item color
7495The color which will not be replaced with neutral gray.
7496
7497@item similarity
7498Similarity percentage with the above color.
74990.01 matches only the exact key color, while 1.0 matches everything.
7500
7501@item blend
7502Blend percentage. 0.0 makes pixels fully gray.
7503Higher values result in more preserved color.
7504@end table
7505
7506@subsection Commands
7507This filter supports same @ref{commands} as options.
7508The command accepts the same syntax of the corresponding option.
7509
7510If the specified expression is not valid, it is kept at its current
7511value.
7512
7513@section colorlevels
7514
7515Adjust video input frames using levels.
7516
7517The filter accepts the following options:
7518
7519@table @option
7520@item rimin
7521@item gimin
7522@item bimin
7523@item aimin
7524Adjust red, green, blue and alpha input black point.
7525Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
7526
7527@item rimax
7528@item gimax
7529@item bimax
7530@item aimax
7531Adjust red, green, blue and alpha input white point.
7532Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
7533
7534Input levels are used to lighten highlights (bright tones), darken shadows
7535(dark tones), change the balance of bright and dark tones.
7536
7537@item romin
7538@item gomin
7539@item bomin
7540@item aomin
7541Adjust red, green, blue and alpha output black point.
7542Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
7543
7544@item romax
7545@item gomax
7546@item bomax
7547@item aomax
7548Adjust red, green, blue and alpha output white point.
7549Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
7550
7551Output levels allows manual selection of a constrained output level range.
7552@end table
7553
7554@subsection Examples
7555
7556@itemize
7557@item
7558Make video output darker:
7559@example
7560colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
7561@end example
7562
7563@item
7564Increase contrast:
7565@example
7566colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
7567@end example
7568
7569@item
7570Make video output lighter:
7571@example
7572colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
7573@end example
7574
7575@item
7576Increase brightness:
7577@example
7578colorlevels=romin=0.5:gomin=0.5:bomin=0.5
7579@end example
7580@end itemize
7581
7582@subsection Commands
7583
7584This filter supports the all above options as @ref{commands}.
7585
7586@section colormatrix
7587
7588Convert color matrix.
7589
7590The filter accepts the following options:
7591
7592@table @option
7593@item src
7594@item dst
7595Specify the source and destination color matrix. Both values must be
7596specified.
7597
7598The accepted values are:
7599@table @samp
7600@item bt709
7601BT.709
7602
7603@item fcc
7604FCC
7605
7606@item bt601
7607BT.601
7608
7609@item bt470
7610BT.470
7611
7612@item bt470bg
7613BT.470BG
7614
7615@item smpte170m
7616SMPTE-170M
7617
7618@item smpte240m
7619SMPTE-240M
7620
7621@item bt2020
7622BT.2020
7623@end table
7624@end table
7625
7626For example to convert from BT.601 to SMPTE-240M, use the command:
7627@example
7628colormatrix=bt601:smpte240m
7629@end example
7630
7631@section colorspace
7632
7633Convert colorspace, transfer characteristics or color primaries.
7634Input video needs to have an even size.
7635
7636The filter accepts the following options:
7637
7638@table @option
7639@anchor{all}
7640@item all
7641Specify all color properties at once.
7642
7643The accepted values are:
7644@table @samp
7645@item bt470m
7646BT.470M
7647
7648@item bt470bg
7649BT.470BG
7650
7651@item bt601-6-525
7652BT.601-6 525
7653
7654@item bt601-6-625
7655BT.601-6 625
7656
7657@item bt709
7658BT.709
7659
7660@item smpte170m
7661SMPTE-170M
7662
7663@item smpte240m
7664SMPTE-240M
7665
7666@item bt2020
7667BT.2020
7668
7669@end table
7670
7671@anchor{space}
7672@item space
7673Specify output colorspace.
7674
7675The accepted values are:
7676@table @samp
7677@item bt709
7678BT.709
7679
7680@item fcc
7681FCC
7682
7683@item bt470bg
7684BT.470BG or BT.601-6 625
7685
7686@item smpte170m
7687SMPTE-170M or BT.601-6 525
7688
7689@item smpte240m
7690SMPTE-240M
7691
7692@item ycgco
7693YCgCo
7694
7695@item bt2020ncl
7696BT.2020 with non-constant luminance
7697
7698@end table
7699
7700@anchor{trc}
7701@item trc
7702Specify output transfer characteristics.
7703
7704The accepted values are:
7705@table @samp
7706@item bt709
7707BT.709
7708
7709@item bt470m
7710BT.470M
7711
7712@item bt470bg
7713BT.470BG
7714
7715@item gamma22
7716Constant gamma of 2.2
7717
7718@item gamma28
7719Constant gamma of 2.8
7720
7721@item smpte170m
7722SMPTE-170M, BT.601-6 625 or BT.601-6 525
7723
7724@item smpte240m
7725SMPTE-240M
7726
7727@item srgb
7728SRGB
7729
7730@item iec61966-2-1
7731iec61966-2-1
7732
7733@item iec61966-2-4
7734iec61966-2-4
7735
7736@item xvycc
7737xvycc
7738
7739@item bt2020-10
7740BT.2020 for 10-bits content
7741
7742@item bt2020-12
7743BT.2020 for 12-bits content
7744
7745@end table
7746
7747@anchor{primaries}
7748@item primaries
7749Specify output color primaries.
7750
7751The accepted values are:
7752@table @samp
7753@item bt709
7754BT.709
7755
7756@item bt470m
7757BT.470M
7758
7759@item bt470bg
7760BT.470BG or BT.601-6 625
7761
7762@item smpte170m
7763SMPTE-170M or BT.601-6 525
7764
7765@item smpte240m
7766SMPTE-240M
7767
7768@item film
7769film
7770
7771@item smpte431
7772SMPTE-431
7773
7774@item smpte432
7775SMPTE-432
7776
7777@item bt2020
7778BT.2020
7779
7780@item jedec-p22
7781JEDEC P22 phosphors
7782
7783@end table
7784
7785@anchor{range}
7786@item range
7787Specify output color range.
7788
7789The accepted values are:
7790@table @samp
7791@item tv
7792TV (restricted) range
7793
7794@item mpeg
7795MPEG (restricted) range
7796
7797@item pc
7798PC (full) range
7799
7800@item jpeg
7801JPEG (full) range
7802
7803@end table
7804
7805@item format
7806Specify output color format.
7807
7808The accepted values are:
7809@table @samp
7810@item yuv420p
7811YUV 4:2:0 planar 8-bits
7812
7813@item yuv420p10
7814YUV 4:2:0 planar 10-bits
7815
7816@item yuv420p12
7817YUV 4:2:0 planar 12-bits
7818
7819@item yuv422p
7820YUV 4:2:2 planar 8-bits
7821
7822@item yuv422p10
7823YUV 4:2:2 planar 10-bits
7824
7825@item yuv422p12
7826YUV 4:2:2 planar 12-bits
7827
7828@item yuv444p
7829YUV 4:4:4 planar 8-bits
7830
7831@item yuv444p10
7832YUV 4:4:4 planar 10-bits
7833
7834@item yuv444p12
7835YUV 4:4:4 planar 12-bits
7836
7837@end table
7838
7839@item fast
7840Do a fast conversion, which skips gamma/primary correction. This will take
7841significantly less CPU, but will be mathematically incorrect. To get output
7842compatible with that produced by the colormatrix filter, use fast=1.
7843
7844@item dither
7845Specify dithering mode.
7846
7847The accepted values are:
7848@table @samp
7849@item none
7850No dithering
7851
7852@item fsb
7853Floyd-Steinberg dithering
7854@end table
7855
7856@item wpadapt
7857Whitepoint adaptation mode.
7858
7859The accepted values are:
7860@table @samp
7861@item bradford
7862Bradford whitepoint adaptation
7863
7864@item vonkries
7865von Kries whitepoint adaptation
7866
7867@item identity
7868identity whitepoint adaptation (i.e. no whitepoint adaptation)
7869@end table
7870
7871@item iall
7872Override all input properties at once. Same accepted values as @ref{all}.
7873
7874@item ispace
7875Override input colorspace. Same accepted values as @ref{space}.
7876
7877@item iprimaries
7878Override input color primaries. Same accepted values as @ref{primaries}.
7879
7880@item itrc
7881Override input transfer characteristics. Same accepted values as @ref{trc}.
7882
7883@item irange
7884Override input color range. Same accepted values as @ref{range}.
7885
7886@end table
7887
7888The filter converts the transfer characteristics, color space and color
7889primaries to the specified user values. The output value, if not specified,
7890is set to a default value based on the "all" property. If that property is
7891also not specified, the filter will log an error. The output color range and
7892format default to the same value as the input color range and format. The
7893input transfer characteristics, color space, color primaries and color range
7894should be set on the input data. If any of these are missing, the filter will
7895log an error and no conversion will take place.
7896
7897For example to convert the input to SMPTE-240M, use the command:
7898@example
7899colorspace=smpte240m
7900@end example
7901
7902@section convolution
7903
7904Apply convolution of 3x3, 5x5, 7x7 or horizontal/vertical up to 49 elements.
7905
7906The filter accepts the following options:
7907
7908@table @option
7909@item 0m
7910@item 1m
7911@item 2m
7912@item 3m
7913Set matrix for each plane.
7914Matrix is sequence of 9, 25 or 49 signed integers in @var{square} mode,
7915and from 1 to 49 odd number of signed integers in @var{row} mode.
7916
7917@item 0rdiv
7918@item 1rdiv
7919@item 2rdiv
7920@item 3rdiv
7921Set multiplier for calculated value for each plane.
7922If unset or 0, it will be sum of all matrix elements.
7923
7924@item 0bias
7925@item 1bias
7926@item 2bias
7927@item 3bias
7928Set bias for each plane. This value is added to the result of the multiplication.
7929Useful for making the overall image brighter or darker. Default is 0.0.
7930
7931@item 0mode
7932@item 1mode
7933@item 2mode
7934@item 3mode
7935Set matrix mode for each plane. Can be @var{square}, @var{row} or @var{column}.
7936Default is @var{square}.
7937@end table
7938
7939@subsection Examples
7940
7941@itemize
7942@item
7943Apply sharpen:
7944@example
7945convolution="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"
7946@end example
7947
7948@item
7949Apply blur:
7950@example
7951convolution="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"
7952@end example
7953
7954@item
7955Apply edge enhance:
7956@example
7957convolution="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"
7958@end example
7959
7960@item
7961Apply edge detect:
7962@example
7963convolution="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"
7964@end example
7965
7966@item
7967Apply laplacian edge detector which includes diagonals:
7968@example
7969convolution="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"
7970@end example
7971
7972@item
7973Apply emboss:
7974@example
7975convolution="-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"
7976@end example
7977@end itemize
7978
7979@section convolve
7980
7981Apply 2D convolution of video stream in frequency domain using second stream
7982as impulse.
7983
7984The filter accepts the following options:
7985
7986@table @option
7987@item planes
7988Set which planes to process.
7989
7990@item impulse
7991Set which impulse video frames will be processed, can be @var{first}
7992or @var{all}. Default is @var{all}.
7993@end table
7994
7995The @code{convolve} filter also supports the @ref{framesync} options.
7996
7997@section copy
7998
7999Copy the input video source unchanged to the output. This is mainly useful for
8000testing purposes.
8001
8002@anchor{coreimage}
8003@section coreimage
8004Video filtering on GPU using Apple's CoreImage API on OSX.
8005
8006Hardware acceleration is based on an OpenGL context. Usually, this means it is
8007processed by video hardware. However, software-based OpenGL implementations
8008exist which means there is no guarantee for hardware processing. It depends on
8009the respective OSX.
8010
8011There are many filters and image generators provided by Apple that come with a
8012large variety of options. The filter has to be referenced by its name along
8013with its options.
8014
8015The coreimage filter accepts the following options:
8016@table @option
8017@item list_filters
8018List all available filters and generators along with all their respective
8019options as well as possible minimum and maximum values along with the default
8020values.
8021@example
8022list_filters=true
8023@end example
8024
8025@item filter
8026Specify all filters by their respective name and options.
8027Use @var{list_filters} to determine all valid filter names and options.
8028Numerical options are specified by a float value and are automatically clamped
8029to their respective value range.  Vector and color options have to be specified
8030by a list of space separated float values. Character escaping has to be done.
8031A special option name @code{default} is available to use default options for a
8032filter.
8033
8034It is required to specify either @code{default} or at least one of the filter options.
8035All omitted options are used with their default values.
8036The syntax of the filter string is as follows:
8037@example
8038filter=<NAME>@@<OPTION>=<VALUE>[@@<OPTION>=<VALUE>][@@...][#<NAME>@@<OPTION>=<VALUE>[@@<OPTION>=<VALUE>][@@...]][#...]
8039@end example
8040
8041@item output_rect
8042Specify a rectangle where the output of the filter chain is copied into the
8043input image. It is given by a list of space separated float values:
8044@example
8045output_rect=x\ y\ width\ height
8046@end example
8047If not given, the output rectangle equals the dimensions of the input image.
8048The output rectangle is automatically cropped at the borders of the input
8049image. Negative values are valid for each component.
8050@example
8051output_rect=25\ 25\ 100\ 100
8052@end example
8053@end table
8054
8055Several filters can be chained for successive processing without GPU-HOST
8056transfers allowing for fast processing of complex filter chains.
8057Currently, only filters with zero (generators) or exactly one (filters) input
8058image and one output image are supported. Also, transition filters are not yet
8059usable as intended.
8060
8061Some filters generate output images with additional padding depending on the
8062respective filter kernel. The padding is automatically removed to ensure the
8063filter output has the same size as the input image.
8064
8065For image generators, the size of the output image is determined by the
8066previous output image of the filter chain or the input image of the whole
8067filterchain, respectively. The generators do not use the pixel information of
8068this image to generate their output. However, the generated output is
8069blended onto this image, resulting in partial or complete coverage of the
8070output image.
8071
8072The @ref{coreimagesrc} video source can be used for generating input images
8073which are directly fed into the filter chain. By using it, providing input
8074images by another video source or an input video is not required.
8075
8076@subsection Examples
8077
8078@itemize
8079
8080@item
8081List all filters available:
8082@example
8083coreimage=list_filters=true
8084@end example
8085
8086@item
8087Use the CIBoxBlur filter with default options to blur an image:
8088@example
8089coreimage=filter=CIBoxBlur@@default
8090@end example
8091
8092@item
8093Use a filter chain with CISepiaTone at default values and CIVignetteEffect with
8094its center at 100x100 and a radius of 50 pixels:
8095@example
8096coreimage=filter=CIBoxBlur@@default#CIVignetteEffect@@inputCenter=100\ 100@@inputRadius=50
8097@end example
8098
8099@item
8100Use nullsrc and CIQRCodeGenerator to create a QR code for the FFmpeg homepage,
8101given as complete and escaped command-line for Apple's standard bash shell:
8102@example
8103ffmpeg -f lavfi -i nullsrc=s=100x100,coreimage=filter=CIQRCodeGenerator@@inputMessage=https\\\\\://FFmpeg.org/@@inputCorrectionLevel=H -frames:v 1 QRCode.png
8104@end example
8105@end itemize
8106
8107@section cover_rect
8108
8109Cover a rectangular object
8110
8111It accepts the following options:
8112
8113@table @option
8114@item cover
8115Filepath of the optional cover image, needs to be in yuv420.
8116
8117@item mode
8118Set covering mode.
8119
8120It accepts the following values:
8121@table @samp
8122@item cover
8123cover it by the supplied image
8124@item blur
8125cover it by interpolating the surrounding pixels
8126@end table
8127
8128Default value is @var{blur}.
8129@end table
8130
8131@subsection Examples
8132
8133@itemize
8134@item
8135Cover a rectangular object by the supplied image of a given video using @command{ffmpeg}:
8136@example
8137ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
8138@end example
8139@end itemize
8140
8141@section crop
8142
8143Crop the input video to given dimensions.
8144
8145It accepts the following parameters:
8146
8147@table @option
8148@item w, out_w
8149The width of the output video. It defaults to @code{iw}.
8150This expression is evaluated only once during the filter
8151configuration, or when the @samp{w} or @samp{out_w} command is sent.
8152
8153@item h, out_h
8154The height of the output video. It defaults to @code{ih}.
8155This expression is evaluated only once during the filter
8156configuration, or when the @samp{h} or @samp{out_h} command is sent.
8157
8158@item x
8159The horizontal position, in the input video, of the left edge of the output
8160video. It defaults to @code{(in_w-out_w)/2}.
8161This expression is evaluated per-frame.
8162
8163@item y
8164The vertical position, in the input video, of the top edge of the output video.
8165It defaults to @code{(in_h-out_h)/2}.
8166This expression is evaluated per-frame.
8167
8168@item keep_aspect
8169If set to 1 will force the output display aspect ratio
8170to be the same of the input, by changing the output sample aspect
8171ratio. It defaults to 0.
8172
8173@item exact
8174Enable exact cropping. If enabled, subsampled videos will be cropped at exact
8175width/height/x/y as specified and will not be rounded to nearest smaller value.
8176It defaults to 0.
8177@end table
8178
8179The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
8180expressions containing the following constants:
8181
8182@table @option
8183@item x
8184@item y
8185The computed values for @var{x} and @var{y}. They are evaluated for
8186each new frame.
8187
8188@item in_w
8189@item in_h
8190The input width and height.
8191
8192@item iw
8193@item ih
8194These are the same as @var{in_w} and @var{in_h}.
8195
8196@item out_w
8197@item out_h
8198The output (cropped) width and height.
8199
8200@item ow
8201@item oh
8202These are the same as @var{out_w} and @var{out_h}.
8203
8204@item a
8205same as @var{iw} / @var{ih}
8206
8207@item sar
8208input sample aspect ratio
8209
8210@item dar
8211input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
8212
8213@item hsub
8214@item vsub
8215horizontal and vertical chroma subsample values. For example for the
8216pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
8217
8218@item n
8219The number of the input frame, starting from 0.
8220
8221@item pos
8222the position in the file of the input frame, NAN if unknown
8223
8224@item t
8225The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
8226
8227@end table
8228
8229The expression for @var{out_w} may depend on the value of @var{out_h},
8230and the expression for @var{out_h} may depend on @var{out_w}, but they
8231cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
8232evaluated after @var{out_w} and @var{out_h}.
8233
8234The @var{x} and @var{y} parameters specify the expressions for the
8235position of the top-left corner of the output (non-cropped) area. They
8236are evaluated for each frame. If the evaluated value is not valid, it
8237is approximated to the nearest valid value.
8238
8239The expression for @var{x} may depend on @var{y}, and the expression
8240for @var{y} may depend on @var{x}.
8241
8242@subsection Examples
8243
8244@itemize
8245@item
8246Crop area with size 100x100 at position (12,34).
8247@example
8248crop=100:100:12:34
8249@end example
8250
8251Using named options, the example above becomes:
8252@example
8253crop=w=100:h=100:x=12:y=34
8254@end example
8255
8256@item
8257Crop the central input area with size 100x100:
8258@example
8259crop=100:100
8260@end example
8261
8262@item
8263Crop the central input area with size 2/3 of the input video:
8264@example
8265crop=2/3*in_w:2/3*in_h
8266@end example
8267
8268@item
8269Crop the input video central square:
8270@example
8271crop=out_w=in_h
8272crop=in_h
8273@end example
8274
8275@item
8276Delimit the rectangle with the top-left corner placed at position
8277100:100 and the right-bottom corner corresponding to the right-bottom
8278corner of the input image.
8279@example
8280crop=in_w-100:in_h-100:100:100
8281@end example
8282
8283@item
8284Crop 10 pixels from the left and right borders, and 20 pixels from
8285the top and bottom borders
8286@example
8287crop=in_w-2*10:in_h-2*20
8288@end example
8289
8290@item
8291Keep only the bottom right quarter of the input image:
8292@example
8293crop=in_w/2:in_h/2:in_w/2:in_h/2
8294@end example
8295
8296@item
8297Crop height for getting Greek harmony:
8298@example
8299crop=in_w:1/PHI*in_w
8300@end example
8301
8302@item
8303Apply trembling effect:
8304@example
8305crop=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)
8306@end example
8307
8308@item
8309Apply erratic camera effect depending on timestamp:
8310@example
8311crop=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)"
8312@end example
8313
8314@item
8315Set x depending on the value of y:
8316@example
8317crop=in_w/2:in_h/2:y:10+10*sin(n/10)
8318@end example
8319@end itemize
8320
8321@subsection Commands
8322
8323This filter supports the following commands:
8324@table @option
8325@item w, out_w
8326@item h, out_h
8327@item x
8328@item y
8329Set width/height of the output video and the horizontal/vertical position
8330in the input video.
8331The command accepts the same syntax of the corresponding option.
8332
8333If the specified expression is not valid, it is kept at its current
8334value.
8335@end table
8336
8337@section cropdetect
8338
8339Auto-detect the crop size.
8340
8341It calculates the necessary cropping parameters and prints the
8342recommended parameters via the logging system. The detected dimensions
8343correspond to the non-black area of the input video.
8344
8345It accepts the following parameters:
8346
8347@table @option
8348
8349@item limit
8350Set higher black value threshold, which can be optionally specified
8351from nothing (0) to everything (255 for 8-bit based formats). An intensity
8352value greater to the set value is considered non-black. It defaults to 24.
8353You can also specify a value between 0.0 and 1.0 which will be scaled depending
8354on the bitdepth of the pixel format.
8355
8356@item round
8357The value which the width/height should be divisible by. It defaults to
835816. The offset is automatically adjusted to center the video. Use 2 to
8359get only even dimensions (needed for 4:2:2 video). 16 is best when
8360encoding to most video codecs.
8361
8362@item reset_count, reset
8363Set the counter that determines after how many frames cropdetect will
8364reset the previously detected largest video area and start over to
8365detect the current optimal crop area. Default value is 0.
8366
8367This can be useful when channel logos distort the video area. 0
8368indicates 'never reset', and returns the largest area encountered during
8369playback.
8370@end table
8371
8372@anchor{cue}
8373@section cue
8374
8375Delay video filtering until a given wallclock timestamp. The filter first
8376passes on @option{preroll} amount of frames, then it buffers at most
8377@option{buffer} amount of frames and waits for the cue. After reaching the cue
8378it forwards the buffered frames and also any subsequent frames coming in its
8379input.
8380
8381The filter can be used synchronize the output of multiple ffmpeg processes for
8382realtime output devices like decklink. By putting the delay in the filtering
8383chain and pre-buffering frames the process can pass on data to output almost
8384immediately after the target wallclock timestamp is reached.
8385
8386Perfect frame accuracy cannot be guaranteed, but the result is good enough for
8387some use cases.
8388
8389@table @option
8390
8391@item cue
8392The cue timestamp expressed in a UNIX timestamp in microseconds. Default is 0.
8393
8394@item preroll
8395The duration of content to pass on as preroll expressed in seconds. Default is 0.
8396
8397@item buffer
8398The maximum duration of content to buffer before waiting for the cue expressed
8399in seconds. Default is 0.
8400
8401@end table
8402
8403@anchor{curves}
8404@section curves
8405
8406Apply color adjustments using curves.
8407
8408This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
8409component (red, green and blue) has its values defined by @var{N} key points
8410tied from each other using a smooth curve. The x-axis represents the pixel
8411values from the input frame, and the y-axis the new pixel values to be set for
8412the output frame.
8413
8414By default, a component curve is defined by the two points @var{(0;0)} and
8415@var{(1;1)}. This creates a straight line where each original pixel value is
8416"adjusted" to its own value, which means no change to the image.
8417
8418The filter allows you to redefine these two points and add some more. A new
8419curve (using a natural cubic spline interpolation) will be define to pass
8420smoothly through all these new coordinates. The new defined points needs to be
8421strictly increasing over the x-axis, and their @var{x} and @var{y} values must
8422be in the @var{[0;1]} interval.  If the computed curves happened to go outside
8423the vector spaces, the values will be clipped accordingly.
8424
8425The filter accepts the following options:
8426
8427@table @option
8428@item preset
8429Select one of the available color presets. This option can be used in addition
8430to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
8431options takes priority on the preset values.
8432Available presets are:
8433@table @samp
8434@item none
8435@item color_negative
8436@item cross_process
8437@item darker
8438@item increase_contrast
8439@item lighter
8440@item linear_contrast
8441@item medium_contrast
8442@item negative
8443@item strong_contrast
8444@item vintage
8445@end table
8446Default is @code{none}.
8447@item master, m
8448Set the master key points. These points will define a second pass mapping. It
8449is sometimes called a "luminance" or "value" mapping. It can be used with
8450@option{r}, @option{g}, @option{b} or @option{all} since it acts like a
8451post-processing LUT.
8452@item red, r
8453Set the key points for the red component.
8454@item green, g
8455Set the key points for the green component.
8456@item blue, b
8457Set the key points for the blue component.
8458@item all
8459Set the key points for all components (not including master).
8460Can be used in addition to the other key points component
8461options. In this case, the unset component(s) will fallback on this
8462@option{all} setting.
8463@item psfile
8464Specify a Photoshop curves file (@code{.acv}) to import the settings from.
8465@item plot
8466Save Gnuplot script of the curves in specified file.
8467@end table
8468
8469To avoid some filtergraph syntax conflicts, each key points list need to be
8470defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
8471
8472@subsection Examples
8473
8474@itemize
8475@item
8476Increase slightly the middle level of blue:
8477@example
8478curves=blue='0/0 0.5/0.58 1/1'
8479@end example
8480
8481@item
8482Vintage effect:
8483@example
8484curves=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'
8485@end example
8486Here we obtain the following coordinates for each components:
8487@table @var
8488@item red
8489@code{(0;0.11) (0.42;0.51) (1;0.95)}
8490@item green
8491@code{(0;0) (0.50;0.48) (1;1)}
8492@item blue
8493@code{(0;0.22) (0.49;0.44) (1;0.80)}
8494@end table
8495
8496@item
8497The previous example can also be achieved with the associated built-in preset:
8498@example
8499curves=preset=vintage
8500@end example
8501
8502@item
8503Or simply:
8504@example
8505curves=vintage
8506@end example
8507
8508@item
8509Use a Photoshop preset and redefine the points of the green component:
8510@example
8511curves=psfile='MyCurvesPresets/purple.acv':green='0/0 0.45/0.53 1/1'
8512@end example
8513
8514@item
8515Check out the curves of the @code{cross_process} profile using @command{ffmpeg}
8516and @command{gnuplot}:
8517@example
8518ffmpeg -f lavfi -i color -vf curves=cross_process:plot=/tmp/curves.plt -frames:v 1 -f null -
8519gnuplot -p /tmp/curves.plt
8520@end example
8521@end itemize
8522
8523@section datascope
8524
8525Video data analysis filter.
8526
8527This filter shows hexadecimal pixel values of part of video.
8528
8529The filter accepts the following options:
8530
8531@table @option
8532@item size, s
8533Set output video size.
8534
8535@item x
8536Set x offset from where to pick pixels.
8537
8538@item y
8539Set y offset from where to pick pixels.
8540
8541@item mode
8542Set scope mode, can be one of the following:
8543@table @samp
8544@item mono
8545Draw hexadecimal pixel values with white color on black background.
8546
8547@item color
8548Draw hexadecimal pixel values with input video pixel color on black
8549background.
8550
8551@item color2
8552Draw hexadecimal pixel values on color background picked from input video,
8553the text color is picked in such way so its always visible.
8554@end table
8555
8556@item axis
8557Draw rows and columns numbers on left and top of video.
8558
8559@item opacity
8560Set background opacity.
8561
8562@item format
8563Set display number format. Can be @code{hex}, or @code{dec}. Default is @code{hex}.
8564@end table
8565
8566@section dblur
8567Apply Directional blur filter.
8568
8569The filter accepts the following options:
8570
8571@table @option
8572@item angle
8573Set angle of directional blur. Default is @code{45}.
8574
8575@item radius
8576Set radius of directional blur. Default is @code{5}.
8577
8578@item planes
8579Set which planes to filter. By default all planes are filtered.
8580@end table
8581
8582@subsection Commands
8583This filter supports same @ref{commands} as options.
8584The command accepts the same syntax of the corresponding option.
8585
8586If the specified expression is not valid, it is kept at its current
8587value.
8588
8589@section dctdnoiz
8590
8591Denoise frames using 2D DCT (frequency domain filtering).
8592
8593This filter is not designed for real time.
8594
8595The filter accepts the following options:
8596
8597@table @option
8598@item sigma, s
8599Set the noise sigma constant.
8600
8601This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
8602coefficient (absolute value) below this threshold with be dropped.
8603
8604If you need a more advanced filtering, see @option{expr}.
8605
8606Default is @code{0}.
8607
8608@item overlap
8609Set number overlapping pixels for each block. Since the filter can be slow, you
8610may want to reduce this value, at the cost of a less effective filter and the
8611risk of various artefacts.
8612
8613If the overlapping value doesn't permit processing the whole input width or
8614height, a warning will be displayed and according borders won't be denoised.
8615
8616Default value is @var{blocksize}-1, which is the best possible setting.
8617
8618@item expr, e
8619Set the coefficient factor expression.
8620
8621For each coefficient of a DCT block, this expression will be evaluated as a
8622multiplier value for the coefficient.
8623
8624If this is option is set, the @option{sigma} option will be ignored.
8625
8626The absolute value of the coefficient can be accessed through the @var{c}
8627variable.
8628
8629@item n
8630Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
8631@var{blocksize}, which is the width and height of the processed blocks.
8632
8633The default value is @var{3} (8x8) and can be raised to @var{4} for a
8634@var{blocksize} of 16x16. Note that changing this setting has huge consequences
8635on the speed processing. Also, a larger block size does not necessarily means a
8636better de-noising.
8637@end table
8638
8639@subsection Examples
8640
8641Apply a denoise with a @option{sigma} of @code{4.5}:
8642@example
8643dctdnoiz=4.5
8644@end example
8645
8646The same operation can be achieved using the expression system:
8647@example
8648dctdnoiz=e='gte(c, 4.5*3)'
8649@end example
8650
8651Violent denoise using a block size of @code{16x16}:
8652@example
8653dctdnoiz=15:n=4
8654@end example
8655
8656@section deband
8657
8658Remove banding artifacts from input video.
8659It works by replacing banded pixels with average value of referenced pixels.
8660
8661The filter accepts the following options:
8662
8663@table @option
8664@item 1thr
8665@item 2thr
8666@item 3thr
8667@item 4thr
8668Set banding detection threshold for each plane. Default is 0.02.
8669Valid range is 0.00003 to 0.5.
8670If difference between current pixel and reference pixel is less than threshold,
8671it will be considered as banded.
8672
8673@item range, r
8674Banding detection range in pixels. Default is 16. If positive, random number
8675in range 0 to set value will be used. If negative, exact absolute value
8676will be used.
8677The range defines square of four pixels around current pixel.
8678
8679@item direction, d
8680Set direction in radians from which four pixel will be compared. If positive,
8681random direction from 0 to set direction will be picked. If negative, exact of
8682absolute value will be picked. For example direction 0, -PI or -2*PI radians
8683will pick only pixels on same row and -PI/2 will pick only pixels on same
8684column.
8685
8686@item blur, b
8687If enabled, current pixel is compared with average value of all four
8688surrounding pixels. The default is enabled. If disabled current pixel is
8689compared with all four surrounding pixels. The pixel is considered banded
8690if only all four differences with surrounding pixels are less than threshold.
8691
8692@item coupling, c
8693If enabled, current pixel is changed if and only if all pixel components are banded,
8694e.g. banding detection threshold is triggered for all color components.
8695The default is disabled.
8696@end table
8697
8698@section deblock
8699
8700Remove blocking artifacts from input video.
8701
8702The filter accepts the following options:
8703
8704@table @option
8705@item filter
8706Set filter type, can be @var{weak} or @var{strong}. Default is @var{strong}.
8707This controls what kind of deblocking is applied.
8708
8709@item block
8710Set size of block, allowed range is from 4 to 512. Default is @var{8}.
8711
8712@item alpha
8713@item beta
8714@item gamma
8715@item delta
8716Set blocking detection thresholds. Allowed range is 0 to 1.
8717Defaults are: @var{0.098} for @var{alpha} and @var{0.05} for the rest.
8718Using higher threshold gives more deblocking strength.
8719Setting @var{alpha} controls threshold detection at exact edge of block.
8720Remaining options controls threshold detection near the edge. Each one for
8721below/above or left/right. Setting any of those to @var{0} disables
8722deblocking.
8723
8724@item planes
8725Set planes to filter. Default is to filter all available planes.
8726@end table
8727
8728@subsection Examples
8729
8730@itemize
8731@item
8732Deblock using weak filter and block size of 4 pixels.
8733@example
8734deblock=filter=weak:block=4
8735@end example
8736
8737@item
8738Deblock using strong filter, block size of 4 pixels and custom thresholds for
8739deblocking more edges.
8740@example
8741deblock=filter=strong:block=4:alpha=0.12:beta=0.07:gamma=0.06:delta=0.05
8742@end example
8743
8744@item
8745Similar as above, but filter only first plane.
8746@example
8747deblock=filter=strong:block=4:alpha=0.12:beta=0.07:gamma=0.06:delta=0.05:planes=1
8748@end example
8749
8750@item
8751Similar as above, but filter only second and third plane.
8752@example
8753deblock=filter=strong:block=4:alpha=0.12:beta=0.07:gamma=0.06:delta=0.05:planes=6
8754@end example
8755@end itemize
8756
8757@anchor{decimate}
8758@section decimate
8759
8760Drop duplicated frames at regular intervals.
8761
8762The filter accepts the following options:
8763
8764@table @option
8765@item cycle
8766Set the number of frames from which one will be dropped. Setting this to
8767@var{N} means one frame in every batch of @var{N} frames will be dropped.
8768Default is @code{5}.
8769
8770@item dupthresh
8771Set the threshold for duplicate detection. If the difference metric for a frame
8772is less than or equal to this value, then it is declared as duplicate. Default
8773is @code{1.1}
8774
8775@item scthresh
8776Set scene change threshold. Default is @code{15}.
8777
8778@item blockx
8779@item blocky
8780Set the size of the x and y-axis blocks used during metric calculations.
8781Larger blocks give better noise suppression, but also give worse detection of
8782small movements. Must be a power of two. Default is @code{32}.
8783
8784@item ppsrc
8785Mark main input as a pre-processed input and activate clean source input
8786stream. This allows the input to be pre-processed with various filters to help
8787the metrics calculation while keeping the frame selection lossless. When set to
8788@code{1}, the first stream is for the pre-processed input, and the second
8789stream is the clean source from where the kept frames are chosen. Default is
8790@code{0}.
8791
8792@item chroma
8793Set whether or not chroma is considered in the metric calculations. Default is
8794@code{1}.
8795@end table
8796
8797@section deconvolve
8798
8799Apply 2D deconvolution of video stream in frequency domain using second stream
8800as impulse.
8801
8802The filter accepts the following options:
8803
8804@table @option
8805@item planes
8806Set which planes to process.
8807
8808@item impulse
8809Set which impulse video frames will be processed, can be @var{first}
8810or @var{all}. Default is @var{all}.
8811
8812@item noise
8813Set noise when doing divisions. Default is @var{0.0000001}. Useful when width
8814and height are not same and not power of 2 or if stream prior to convolving
8815had noise.
8816@end table
8817
8818The @code{deconvolve} filter also supports the @ref{framesync} options.
8819
8820@section dedot
8821
8822Reduce cross-luminance (dot-crawl) and cross-color (rainbows) from video.
8823
8824It accepts the following options:
8825
8826@table @option
8827@item m
8828Set mode of operation. Can be combination of @var{dotcrawl} for cross-luminance reduction and/or
8829@var{rainbows} for cross-color reduction.
8830
8831@item lt
8832Set spatial luma threshold. Lower values increases reduction of cross-luminance.
8833
8834@item tl
8835Set tolerance for temporal luma. Higher values increases reduction of cross-luminance.
8836
8837@item tc
8838Set tolerance for chroma temporal variation. Higher values increases reduction of cross-color.
8839
8840@item ct
8841Set temporal chroma threshold. Lower values increases reduction of cross-color.
8842@end table
8843
8844@section deflate
8845
8846Apply deflate effect to the video.
8847
8848This filter replaces the pixel by the local(3x3) average by taking into account
8849only values lower than the pixel.
8850
8851It accepts the following options:
8852
8853@table @option
8854@item threshold0
8855@item threshold1
8856@item threshold2
8857@item threshold3
8858Limit the maximum change for each plane, default is 65535.
8859If 0, plane will remain unchanged.
8860@end table
8861
8862@subsection Commands
8863
8864This filter supports the all above options as @ref{commands}.
8865
8866@section deflicker
8867
8868Remove temporal frame luminance variations.
8869
8870It accepts the following options:
8871
8872@table @option
8873@item size, s
8874Set moving-average filter size in frames. Default is 5. Allowed range is 2 - 129.
8875
8876@item mode, m
8877Set averaging mode to smooth temporal luminance variations.
8878
8879Available values are:
8880@table @samp
8881@item am
8882Arithmetic mean
8883
8884@item gm
8885Geometric mean
8886
8887@item hm
8888Harmonic mean
8889
8890@item qm
8891Quadratic mean
8892
8893@item cm
8894Cubic mean
8895
8896@item pm
8897Power mean
8898
8899@item median
8900Median
8901@end table
8902
8903@item bypass
8904Do not actually modify frame. Useful when one only wants metadata.
8905@end table
8906
8907@section dejudder
8908
8909Remove judder produced by partially interlaced telecined content.
8910
8911Judder can be introduced, for instance, by @ref{pullup} filter. If the original
8912source was partially telecined content then the output of @code{pullup,dejudder}
8913will have a variable frame rate. May change the recorded frame rate of the
8914container. Aside from that change, this filter will not affect constant frame
8915rate video.
8916
8917The option available in this filter is:
8918@table @option
8919
8920@item cycle
8921Specify the length of the window over which the judder repeats.
8922
8923Accepts any integer greater than 1. Useful values are:
8924@table @samp
8925
8926@item 4
8927If the original was telecined from 24 to 30 fps (Film to NTSC).
8928
8929@item 5
8930If the original was telecined from 25 to 30 fps (PAL to NTSC).
8931
8932@item 20
8933If a mixture of the two.
8934@end table
8935
8936The default is @samp{4}.
8937@end table
8938
8939@section delogo
8940
8941Suppress a TV station logo by a simple interpolation of the surrounding
8942pixels. Just set a rectangle covering the logo and watch it disappear
8943(and sometimes something even uglier appear - your mileage may vary).
8944
8945It accepts the following parameters:
8946@table @option
8947
8948@item x
8949@item y
8950Specify the top left corner coordinates of the logo. They must be
8951specified.
8952
8953@item w
8954@item h
8955Specify the width and height of the logo to clear. They must be
8956specified.
8957
8958@item band, t
8959Specify the thickness of the fuzzy edge of the rectangle (added to
8960@var{w} and @var{h}). The default value is 1. This option is
8961deprecated, setting higher values should no longer be necessary and
8962is not recommended.
8963
8964@item show
8965When set to 1, a green rectangle is drawn on the screen to simplify
8966finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
8967The default value is 0.
8968
8969The rectangle is drawn on the outermost pixels which will be (partly)
8970replaced with interpolated values. The values of the next pixels
8971immediately outside this rectangle in each direction will be used to
8972compute the interpolated pixel values inside the rectangle.
8973
8974@end table
8975
8976@subsection Examples
8977
8978@itemize
8979@item
8980Set a rectangle covering the area with top left corner coordinates 0,0
8981and size 100x77, and a band of size 10:
8982@example
8983delogo=x=0:y=0:w=100:h=77:band=10
8984@end example
8985
8986@end itemize
8987
8988@anchor{derain}
8989@section derain
8990
8991Remove the rain in the input image/video by applying the derain methods based on
8992convolutional neural networks. Supported models:
8993
8994@itemize
8995@item
8996Recurrent Squeeze-and-Excitation Context Aggregation Net (RESCAN).
8997See @url{http://openaccess.thecvf.com/content_ECCV_2018/papers/Xia_Li_Recurrent_Squeeze-and-Excitation_Context_ECCV_2018_paper.pdf}.
8998@end itemize
8999
9000Training as well as model generation scripts are provided in
9001the repository at @url{https://github.com/XueweiMeng/derain_filter.git}.
9002
9003Native model files (.model) can be generated from TensorFlow model
9004files (.pb) by using tools/python/convert.py
9005
9006The filter accepts the following options:
9007
9008@table @option
9009@item filter_type
9010Specify which filter to use. This option accepts the following values:
9011
9012@table @samp
9013@item derain
9014Derain filter. To conduct derain filter, you need to use a derain model.
9015
9016@item dehaze
9017Dehaze filter. To conduct dehaze filter, you need to use a dehaze model.
9018@end table
9019Default value is @samp{derain}.
9020
9021@item dnn_backend
9022Specify which DNN backend to use for model loading and execution. This option accepts
9023the following values:
9024
9025@table @samp
9026@item native
9027Native implementation of DNN loading and execution.
9028
9029@item tensorflow
9030TensorFlow backend. To enable this backend you
9031need to install the TensorFlow for C library (see
9032@url{https://www.tensorflow.org/install/install_c}) and configure FFmpeg with
9033@code{--enable-libtensorflow}
9034@end table
9035Default value is @samp{native}.
9036
9037@item model
9038Set path to model file specifying network architecture and its parameters.
9039Note that different backends use different file formats. TensorFlow and native
9040backend can load files for only its format.
9041@end table
9042
9043It can also be finished with @ref{dnn_processing} filter.
9044
9045@section deshake
9046
9047Attempt to fix small changes in horizontal and/or vertical shift. This
9048filter helps remove camera shake from hand-holding a camera, bumping a
9049tripod, moving on a vehicle, etc.
9050
9051The filter accepts the following options:
9052
9053@table @option
9054
9055@item x
9056@item y
9057@item w
9058@item h
9059Specify a rectangular area where to limit the search for motion
9060vectors.
9061If desired the search for motion vectors can be limited to a
9062rectangular area of the frame defined by its top left corner, width
9063and height. These parameters have the same meaning as the drawbox
9064filter which can be used to visualise the position of the bounding
9065box.
9066
9067This is useful when simultaneous movement of subjects within the frame
9068might be confused for camera motion by the motion vector search.
9069
9070If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
9071then the full frame is used. This allows later options to be set
9072without specifying the bounding box for the motion vector search.
9073
9074Default - search the whole frame.
9075
9076@item rx
9077@item ry
9078Specify the maximum extent of movement in x and y directions in the
9079range 0-64 pixels. Default 16.
9080
9081@item edge
9082Specify how to generate pixels to fill blanks at the edge of the
9083frame. Available values are:
9084@table @samp
9085@item blank, 0
9086Fill zeroes at blank locations
9087@item original, 1
9088Original image at blank locations
9089@item clamp, 2
9090Extruded edge value at blank locations
9091@item mirror, 3
9092Mirrored edge at blank locations
9093@end table
9094Default value is @samp{mirror}.
9095
9096@item blocksize
9097Specify the blocksize to use for motion search. Range 4-128 pixels,
9098default 8.
9099
9100@item contrast
9101Specify the contrast threshold for blocks. Only blocks with more than
9102the specified contrast (difference between darkest and lightest
9103pixels) will be considered. Range 1-255, default 125.
9104
9105@item search
9106Specify the search strategy. Available values are:
9107@table @samp
9108@item exhaustive, 0
9109Set exhaustive search
9110@item less, 1
9111Set less exhaustive search.
9112@end table
9113Default value is @samp{exhaustive}.
9114
9115@item filename
9116If set then a detailed log of the motion search is written to the
9117specified file.
9118
9119@end table
9120
9121@section despill
9122
9123Remove unwanted contamination of foreground colors, caused by reflected color of
9124greenscreen or bluescreen.
9125
9126This filter accepts the following options:
9127
9128@table @option
9129@item type
9130Set what type of despill to use.
9131
9132@item mix
9133Set how spillmap will be generated.
9134
9135@item expand
9136Set how much to get rid of still remaining spill.
9137
9138@item red
9139Controls amount of red in spill area.
9140
9141@item green
9142Controls amount of green in spill area.
9143Should be -1 for greenscreen.
9144
9145@item blue
9146Controls amount of blue in spill area.
9147Should be -1 for bluescreen.
9148
9149@item brightness
9150Controls brightness of spill area, preserving colors.
9151
9152@item alpha
9153Modify alpha from generated spillmap.
9154@end table
9155
9156@section detelecine
9157
9158Apply an exact inverse of the telecine operation. It requires a predefined
9159pattern specified using the pattern option which must be the same as that passed
9160to the telecine filter.
9161
9162This filter accepts the following options:
9163
9164@table @option
9165@item first_field
9166@table @samp
9167@item top, t
9168top field first
9169@item bottom, b
9170bottom field first
9171The default value is @code{top}.
9172@end table
9173
9174@item pattern
9175A string of numbers representing the pulldown pattern you wish to apply.
9176The default value is @code{23}.
9177
9178@item start_frame
9179A number representing position of the first frame with respect to the telecine
9180pattern. This is to be used if the stream is cut. The default value is @code{0}.
9181@end table
9182
9183@section dilation
9184
9185Apply dilation effect to the video.
9186
9187This filter replaces the pixel by the local(3x3) maximum.
9188
9189It accepts the following options:
9190
9191@table @option
9192@item threshold0
9193@item threshold1
9194@item threshold2
9195@item threshold3
9196Limit the maximum change for each plane, default is 65535.
9197If 0, plane will remain unchanged.
9198
9199@item coordinates
9200Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
9201pixels are used.
9202
9203Flags to local 3x3 coordinates maps like this:
9204
9205    1 2 3
9206    4   5
9207    6 7 8
9208@end table
9209
9210@subsection Commands
9211
9212This filter supports the all above options as @ref{commands}.
9213
9214@section displace
9215
9216Displace pixels as indicated by second and third input stream.
9217
9218It takes three input streams and outputs one stream, the first input is the
9219source, and second and third input are displacement maps.
9220
9221The second input specifies how much to displace pixels along the
9222x-axis, while the third input specifies how much to displace pixels
9223along the y-axis.
9224If one of displacement map streams terminates, last frame from that
9225displacement map will be used.
9226
9227Note that once generated, displacements maps can be reused over and over again.
9228
9229A description of the accepted options follows.
9230
9231@table @option
9232@item edge
9233Set displace behavior for pixels that are out of range.
9234
9235Available values are:
9236@table @samp
9237@item blank
9238Missing pixels are replaced by black pixels.
9239
9240@item smear
9241Adjacent pixels will spread out to replace missing pixels.
9242
9243@item wrap
9244Out of range pixels are wrapped so they point to pixels of other side.
9245
9246@item mirror
9247Out of range pixels will be replaced with mirrored pixels.
9248@end table
9249Default is @samp{smear}.
9250
9251@end table
9252
9253@subsection Examples
9254
9255@itemize
9256@item
9257Add ripple effect to rgb input of video size hd720:
9258@example
9259ffmpeg -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
9260@end example
9261
9262@item
9263Add wave effect to rgb input of video size hd720:
9264@example
9265ffmpeg -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
9266@end example
9267@end itemize
9268
9269@anchor{dnn_processing}
9270@section dnn_processing
9271
9272Do image processing with deep neural networks. It works together with another filter
9273which converts the pixel format of the Frame to what the dnn network requires.
9274
9275The filter accepts the following options:
9276
9277@table @option
9278@item dnn_backend
9279Specify which DNN backend to use for model loading and execution. This option accepts
9280the following values:
9281
9282@table @samp
9283@item native
9284Native implementation of DNN loading and execution.
9285
9286@item tensorflow
9287TensorFlow backend. To enable this backend you
9288need to install the TensorFlow for C library (see
9289@url{https://www.tensorflow.org/install/install_c}) and configure FFmpeg with
9290@code{--enable-libtensorflow}
9291@end table
9292
9293Default value is @samp{native}.
9294
9295@item model
9296Set path to model file specifying network architecture and its parameters.
9297Note that different backends use different file formats. TensorFlow and native
9298backend can load files for only its format.
9299
9300Native model file (.model) can be generated from TensorFlow model file (.pb) by using tools/python/convert.py
9301
9302@item input
9303Set the input name of the dnn network.
9304
9305@item output
9306Set the output name of the dnn network.
9307
9308@end table
9309
9310@subsection Examples
9311
9312@itemize
9313@item
9314Remove rain in rgb24 frame with can.pb (see @ref{derain} filter):
9315@example
9316./ffmpeg -i rain.jpg -vf format=rgb24,dnn_processing=dnn_backend=tensorflow:model=can.pb:input=x:output=y derain.jpg
9317@end example
9318
9319@item
9320Halve the pixel value of the frame with format gray32f:
9321@example
9322ffmpeg -i input.jpg -vf format=grayf32,dnn_processing=model=halve_gray_float.model:input=dnn_in:output=dnn_out:dnn_backend=native -y out.native.png
9323@end example
9324
9325@item
9326Handle the Y channel with srcnn.pb (see @ref{sr} filter) for frame with yuv420p (planar YUV formats supported):
9327@example
9328./ffmpeg -i 480p.jpg -vf format=yuv420p,scale=w=iw*2:h=ih*2,dnn_processing=dnn_backend=tensorflow:model=srcnn.pb:input=x:output=y -y srcnn.jpg
9329@end example
9330
9331@item
9332Handle the Y channel with espcn.pb (see @ref{sr} filter), which changes frame size, for format yuv420p (planar YUV formats supported):
9333@example
9334./ffmpeg -i 480p.jpg -vf format=yuv420p,dnn_processing=dnn_backend=tensorflow:model=espcn.pb:input=x:output=y -y tmp.espcn.jpg
9335@end example
9336
9337@end itemize
9338
9339@section drawbox
9340
9341Draw a colored box on the input image.
9342
9343It accepts the following parameters:
9344
9345@table @option
9346@item x
9347@item y
9348The expressions which specify the top left corner coordinates of the box. It defaults to 0.
9349
9350@item width, w
9351@item height, h
9352The expressions which specify the width and height of the box; if 0 they are interpreted as
9353the input width and height. It defaults to 0.
9354
9355@item color, c
9356Specify the color of the box to write. For the general syntax of this option,
9357check the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}. If the special
9358value @code{invert} is used, the box edge color is the same as the
9359video with inverted luma.
9360
9361@item thickness, t
9362The expression which sets the thickness of the box edge.
9363A value of @code{fill} will create a filled box. Default value is @code{3}.
9364
9365See below for the list of accepted constants.
9366
9367@item replace
9368Applicable if the input has alpha. With value @code{1}, the pixels of the painted box
9369will overwrite the video's color and alpha pixels.
9370Default is @code{0}, which composites the box onto the input, leaving the video's alpha intact.
9371@end table
9372
9373The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
9374following constants:
9375
9376@table @option
9377@item dar
9378The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
9379
9380@item hsub
9381@item vsub
9382horizontal and vertical chroma subsample values. For example for the
9383pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
9384
9385@item in_h, ih
9386@item in_w, iw
9387The input width and height.
9388
9389@item sar
9390The input sample aspect ratio.
9391
9392@item x
9393@item y
9394The x and y offset coordinates where the box is drawn.
9395
9396@item w
9397@item h
9398The width and height of the drawn box.
9399
9400@item t
9401The thickness of the drawn box.
9402
9403These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
9404each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
9405
9406@end table
9407
9408@subsection Examples
9409
9410@itemize
9411@item
9412Draw a black box around the edge of the input image:
9413@example
9414drawbox
9415@end example
9416
9417@item
9418Draw a box with color red and an opacity of 50%:
9419@example
9420drawbox=10:20:200:60:red@@0.5
9421@end example
9422
9423The previous example can be specified as:
9424@example
9425drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
9426@end example
9427
9428@item
9429Fill the box with pink color:
9430@example
9431drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=fill
9432@end example
9433
9434@item
9435Draw a 2-pixel red 2.40:1 mask:
9436@example
9437drawbox=x=-t:y=0.5*(ih-iw/2.4)-t:w=iw+t*2:h=iw/2.4+t*2:t=2:c=red
9438@end example
9439@end itemize
9440
9441@subsection Commands
9442This filter supports same commands as options.
9443The command accepts the same syntax of the corresponding option.
9444
9445If the specified expression is not valid, it is kept at its current
9446value.
9447
9448@anchor{drawgraph}
9449@section drawgraph
9450Draw a graph using input video metadata.
9451
9452It accepts the following parameters:
9453
9454@table @option
9455@item m1
9456Set 1st frame metadata key from which metadata values will be used to draw a graph.
9457
9458@item fg1
9459Set 1st foreground color expression.
9460
9461@item m2
9462Set 2nd frame metadata key from which metadata values will be used to draw a graph.
9463
9464@item fg2
9465Set 2nd foreground color expression.
9466
9467@item m3
9468Set 3rd frame metadata key from which metadata values will be used to draw a graph.
9469
9470@item fg3
9471Set 3rd foreground color expression.
9472
9473@item m4
9474Set 4th frame metadata key from which metadata values will be used to draw a graph.
9475
9476@item fg4
9477Set 4th foreground color expression.
9478
9479@item min
9480Set minimal value of metadata value.
9481
9482@item max
9483Set maximal value of metadata value.
9484
9485@item bg
9486Set graph background color. Default is white.
9487
9488@item mode
9489Set graph mode.
9490
9491Available values for mode is:
9492@table @samp
9493@item bar
9494@item dot
9495@item line
9496@end table
9497
9498Default is @code{line}.
9499
9500@item slide
9501Set slide mode.
9502
9503Available values for slide is:
9504@table @samp
9505@item frame
9506Draw new frame when right border is reached.
9507
9508@item replace
9509Replace old columns with new ones.
9510
9511@item scroll
9512Scroll from right to left.
9513
9514@item rscroll
9515Scroll from left to right.
9516
9517@item picture
9518Draw single picture.
9519@end table
9520
9521Default is @code{frame}.
9522
9523@item size
9524Set size of graph video. For the syntax of this option, check the
9525@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
9526The default value is @code{900x256}.
9527
9528@item rate, r
9529Set the output frame rate. Default value is @code{25}.
9530
9531The foreground color expressions can use the following variables:
9532@table @option
9533@item MIN
9534Minimal value of metadata value.
9535
9536@item MAX
9537Maximal value of metadata value.
9538
9539@item VAL
9540Current metadata key value.
9541@end table
9542
9543The color is defined as 0xAABBGGRR.
9544@end table
9545
9546Example using metadata from @ref{signalstats} filter:
9547@example
9548signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255
9549@end example
9550
9551Example using metadata from @ref{ebur128} filter:
9552@example
9553ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5
9554@end example
9555
9556@section drawgrid
9557
9558Draw a grid on the input image.
9559
9560It accepts the following parameters:
9561
9562@table @option
9563@item x
9564@item y
9565The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
9566
9567@item width, w
9568@item height, h
9569The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
9570input width and height, respectively, minus @code{thickness}, so image gets
9571framed. Default to 0.
9572
9573@item color, c
9574Specify the color of the grid. For the general syntax of this option,
9575check the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}. If the special
9576value @code{invert} is used, the grid color is the same as the
9577video with inverted luma.
9578
9579@item thickness, t
9580The expression which sets the thickness of the grid line. Default value is @code{1}.
9581
9582See below for the list of accepted constants.
9583
9584@item replace
9585Applicable if the input has alpha. With @code{1} the pixels of the painted grid
9586will overwrite the video's color and alpha pixels.
9587Default is @code{0}, which composites the grid onto the input, leaving the video's alpha intact.
9588@end table
9589
9590The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
9591following constants:
9592
9593@table @option
9594@item dar
9595The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
9596
9597@item hsub
9598@item vsub
9599horizontal and vertical chroma subsample values. For example for the
9600pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
9601
9602@item in_h, ih
9603@item in_w, iw
9604The input grid cell width and height.
9605
9606@item sar
9607The input sample aspect ratio.
9608
9609@item x
9610@item y
9611The x and y coordinates of some point of grid intersection (meant to configure offset).
9612
9613@item w
9614@item h
9615The width and height of the drawn cell.
9616
9617@item t
9618The thickness of the drawn cell.
9619
9620These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
9621each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
9622
9623@end table
9624
9625@subsection Examples
9626
9627@itemize
9628@item
9629Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
9630@example
9631drawgrid=width=100:height=100:thickness=2:color=red@@0.5
9632@end example
9633
9634@item
9635Draw a white 3x3 grid with an opacity of 50%:
9636@example
9637drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
9638@end example
9639@end itemize
9640
9641@subsection Commands
9642This filter supports same commands as options.
9643The command accepts the same syntax of the corresponding option.
9644
9645If the specified expression is not valid, it is kept at its current
9646value.
9647
9648@anchor{drawtext}
9649@section drawtext
9650
9651Draw a text string or text from a specified file on top of a video, using the
9652libfreetype library.
9653
9654To enable compilation of this filter, you need to configure FFmpeg with
9655@code{--enable-libfreetype}.
9656To enable default font fallback and the @var{font} option you need to
9657configure FFmpeg with @code{--enable-libfontconfig}.
9658To enable the @var{text_shaping} option, you need to configure FFmpeg with
9659@code{--enable-libfribidi}.
9660
9661@subsection Syntax
9662
9663It accepts the following parameters:
9664
9665@table @option
9666
9667@item box
9668Used to draw a box around text using the background color.
9669The value must be either 1 (enable) or 0 (disable).
9670The default value of @var{box} is 0.
9671
9672@item boxborderw
9673Set the width of the border to be drawn around the box using @var{boxcolor}.
9674The default value of @var{boxborderw} is 0.
9675
9676@item boxcolor
9677The color to be used for drawing box around text. For the syntax of this
9678option, check the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.
9679
9680The default value of @var{boxcolor} is "white".
9681
9682@item line_spacing
9683Set the line spacing in pixels of the border to be drawn around the box using @var{box}.
9684The default value of @var{line_spacing} is 0.
9685
9686@item borderw
9687Set the width of the border to be drawn around the text using @var{bordercolor}.
9688The default value of @var{borderw} is 0.
9689
9690@item bordercolor
9691Set the color to be used for drawing border around text. For the syntax of this
9692option, check the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.
9693
9694The default value of @var{bordercolor} is "black".
9695
9696@item expansion
9697Select how the @var{text} is expanded. Can be either @code{none},
9698@code{strftime} (deprecated) or
9699@code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
9700below for details.
9701
9702@item basetime
9703Set a start time for the count. Value is in microseconds. Only applied
9704in the deprecated strftime expansion mode. To emulate in normal expansion
9705mode use the @code{pts} function, supplying the start time (in seconds)
9706as the second argument.
9707
9708@item fix_bounds
9709If true, check and fix text coords to avoid clipping.
9710
9711@item fontcolor
9712The color to be used for drawing fonts. For the syntax of this option, check
9713the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.
9714
9715The default value of @var{fontcolor} is "black".
9716
9717@item fontcolor_expr
9718String which is expanded the same way as @var{text} to obtain dynamic
9719@var{fontcolor} value. By default this option has empty value and is not
9720processed. When this option is set, it overrides @var{fontcolor} option.
9721
9722@item font
9723The font family to be used for drawing text. By default Sans.
9724
9725@item fontfile
9726The font file to be used for drawing text. The path must be included.
9727This parameter is mandatory if the fontconfig support is disabled.
9728
9729@item alpha
9730Draw the text applying alpha blending. The value can
9731be a number between 0.0 and 1.0.
9732The expression accepts the same variables @var{x, y} as well.
9733The default value is 1.
9734Please see @var{fontcolor_expr}.
9735
9736@item fontsize
9737The font size to be used for drawing text.
9738The default value of @var{fontsize} is 16.
9739
9740@item text_shaping
9741If set to 1, attempt to shape the text (for example, reverse the order of
9742right-to-left text and join Arabic characters) before drawing it.
9743Otherwise, just draw the text exactly as given.
9744By default 1 (if supported).
9745
9746@item ft_load_flags
9747The flags to be used for loading the fonts.
9748
9749The flags map the corresponding flags supported by libfreetype, and are
9750a combination of the following values:
9751@table @var
9752@item default
9753@item no_scale
9754@item no_hinting
9755@item render
9756@item no_bitmap
9757@item vertical_layout
9758@item force_autohint
9759@item crop_bitmap
9760@item pedantic
9761@item ignore_global_advance_width
9762@item no_recurse
9763@item ignore_transform
9764@item monochrome
9765@item linear_design
9766@item no_autohint
9767@end table
9768
9769Default value is "default".
9770
9771For more information consult the documentation for the FT_LOAD_*
9772libfreetype flags.
9773
9774@item shadowcolor
9775The color to be used for drawing a shadow behind the drawn text. For the
9776syntax of this option, check the @ref{color syntax,,"Color" section in the
9777ffmpeg-utils manual,ffmpeg-utils}.
9778
9779The default value of @var{shadowcolor} is "black".
9780
9781@item shadowx
9782@item shadowy
9783The x and y offsets for the text shadow position with respect to the
9784position of the text. They can be either positive or negative
9785values. The default value for both is "0".
9786
9787@item start_number
9788The starting frame number for the n/frame_num variable. The default value
9789is "0".
9790
9791@item tabsize
9792The size in number of spaces to use for rendering the tab.
9793Default value is 4.
9794
9795@item timecode
9796Set the initial timecode representation in "hh:mm:ss[:;.]ff"
9797format. It can be used with or without text parameter. @var{timecode_rate}
9798option must be specified.
9799
9800@item timecode_rate, rate, r
9801Set the timecode frame rate (timecode only). Value will be rounded to nearest
9802integer. Minimum value is "1".
9803Drop-frame timecode is supported for frame rates 30 & 60.
9804
9805@item tc24hmax
9806If set to 1, the output of the timecode option will wrap around at 24 hours.
9807Default is 0 (disabled).
9808
9809@item text
9810The text string to be drawn. The text must be a sequence of UTF-8
9811encoded characters.
9812This parameter is mandatory if no file is specified with the parameter
9813@var{textfile}.
9814
9815@item textfile
9816A text file containing text to be drawn. The text must be a sequence
9817of UTF-8 encoded characters.
9818
9819This parameter is mandatory if no text string is specified with the
9820parameter @var{text}.
9821
9822If both @var{text} and @var{textfile} are specified, an error is thrown.
9823
9824@item reload
9825If set to 1, the @var{textfile} will be reloaded before each frame.
9826Be sure to update it atomically, or it may be read partially, or even fail.
9827
9828@item x
9829@item y
9830The expressions which specify the offsets where text will be drawn
9831within the video frame. They are relative to the top/left border of the
9832output image.
9833
9834The default value of @var{x} and @var{y} is "0".
9835
9836See below for the list of accepted constants and functions.
9837@end table
9838
9839The parameters for @var{x} and @var{y} are expressions containing the
9840following constants and functions:
9841
9842@table @option
9843@item dar
9844input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
9845
9846@item hsub
9847@item vsub
9848horizontal and vertical chroma subsample values. For example for the
9849pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
9850
9851@item line_h, lh
9852the height of each text line
9853
9854@item main_h, h, H
9855the input height
9856
9857@item main_w, w, W
9858the input width
9859
9860@item max_glyph_a, ascent
9861the maximum distance from the baseline to the highest/upper grid
9862coordinate used to place a glyph outline point, for all the rendered
9863glyphs.
9864It is a positive value, due to the grid's orientation with the Y axis
9865upwards.
9866
9867@item max_glyph_d, descent
9868the maximum distance from the baseline to the lowest grid coordinate
9869used to place a glyph outline point, for all the rendered glyphs.
9870This is a negative value, due to the grid's orientation, with the Y axis
9871upwards.
9872
9873@item max_glyph_h
9874maximum glyph height, that is the maximum height for all the glyphs
9875contained in the rendered text, it is equivalent to @var{ascent} -
9876@var{descent}.
9877
9878@item max_glyph_w
9879maximum glyph width, that is the maximum width for all the glyphs
9880contained in the rendered text
9881
9882@item n
9883the number of input frame, starting from 0
9884
9885@item rand(min, max)
9886return a random number included between @var{min} and @var{max}
9887
9888@item sar
9889The input sample aspect ratio.
9890
9891@item t
9892timestamp expressed in seconds, NAN if the input timestamp is unknown
9893
9894@item text_h, th
9895the height of the rendered text
9896
9897@item text_w, tw
9898the width of the rendered text
9899
9900@item x
9901@item y
9902the x and y offset coordinates where the text is drawn.
9903
9904These parameters allow the @var{x} and @var{y} expressions to refer
9905to each other, so you can for example specify @code{y=x/dar}.
9906
9907@item pict_type
9908A one character description of the current frame's picture type.
9909
9910@item pkt_pos
9911The current packet's position in the input file or stream
9912(in bytes, from the start of the input). A value of -1 indicates
9913this info is not available.
9914
9915@item pkt_duration
9916The current packet's duration, in seconds.
9917
9918@item pkt_size
9919The current packet's size (in bytes).
9920@end table
9921
9922@anchor{drawtext_expansion}
9923@subsection Text expansion
9924
9925If @option{expansion} is set to @code{strftime},
9926the filter recognizes strftime() sequences in the provided text and
9927expands them accordingly. Check the documentation of strftime(). This
9928feature is deprecated.
9929
9930If @option{expansion} is set to @code{none}, the text is printed verbatim.
9931
9932If @option{expansion} is set to @code{normal} (which is the default),
9933the following expansion mechanism is used.
9934
9935The backslash character @samp{\}, followed by any character, always expands to
9936the second character.
9937
9938Sequences of the form @code{%@{...@}} are expanded. The text between the
9939braces is a function name, possibly followed by arguments separated by ':'.
9940If the arguments contain special characters or delimiters (':' or '@}'),
9941they should be escaped.
9942
9943Note that they probably must also be escaped as the value for the
9944@option{text} option in the filter argument string and as the filter
9945argument in the filtergraph description, and possibly also for the shell,
9946that makes up to four levels of escaping; using a text file avoids these
9947problems.
9948
9949The following functions are available:
9950
9951@table @command
9952
9953@item expr, e
9954The expression evaluation result.
9955
9956It must take one argument specifying the expression to be evaluated,
9957which accepts the same constants and functions as the @var{x} and
9958@var{y} values. Note that not all constants should be used, for
9959example the text size is not known when evaluating the expression, so
9960the constants @var{text_w} and @var{text_h} will have an undefined
9961value.
9962
9963@item expr_int_format, eif
9964Evaluate the expression's value and output as formatted integer.
9965
9966The first argument is the expression to be evaluated, just as for the @var{expr} function.
9967The second argument specifies the output format. Allowed values are @samp{x},
9968@samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
9969@code{printf} function.
9970The third parameter is optional and sets the number of positions taken by the output.
9971It can be used to add padding with zeros from the left.
9972
9973@item gmtime
9974The time at which the filter is running, expressed in UTC.
9975It can accept an argument: a strftime() format string.
9976
9977@item localtime
9978The time at which the filter is running, expressed in the local time zone.
9979It can accept an argument: a strftime() format string.
9980
9981@item metadata
9982Frame metadata. Takes one or two arguments.
9983
9984The first argument is mandatory and specifies the metadata key.
9985
9986The second argument is optional and specifies a default value, used when the
9987metadata key is not found or empty.
9988
9989Available metadata can be identified by inspecting entries
9990starting with TAG included within each frame section
9991printed by running @code{ffprobe -show_frames}.
9992
9993String metadata generated in filters leading to
9994the drawtext filter are also available.
9995
9996@item n, frame_num
9997The frame number, starting from 0.
9998
9999@item pict_type
10000A one character description of the current picture type.
10001
10002@item pts
10003The timestamp of the current frame.
10004It can take up to three arguments.
10005
10006The first argument is the format of the timestamp; it defaults to @code{flt}
10007for seconds as a decimal number with microsecond accuracy; @code{hms} stands
10008for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
10009@code{gmtime} stands for the timestamp of the frame formatted as UTC time;
10010@code{localtime} stands for the timestamp of the frame formatted as
10011local time zone time.
10012
10013The second argument is an offset added to the timestamp.
10014
10015If the format is set to @code{hms}, a third argument @code{24HH} may be
10016supplied to present the hour part of the formatted timestamp in 24h format
10017(00-23).
10018
10019If the format is set to @code{localtime} or @code{gmtime},
10020a third argument may be supplied: a strftime() format string.
10021By default, @var{YYYY-MM-DD HH:MM:SS} format will be used.
10022@end table
10023
10024@subsection Commands
10025
10026This filter supports altering parameters via commands:
10027@table @option
10028@item reinit
10029Alter existing filter parameters.
10030
10031Syntax for the argument is the same as for filter invocation, e.g.
10032
10033@example
10034fontsize=56:fontcolor=green:text='Hello World'
10035@end example
10036
10037Full filter invocation with sendcmd would look like this:
10038
10039@example
10040sendcmd=c='56.0 drawtext reinit fontsize=56\:fontcolor=green\:text=Hello\\ World'
10041@end example
10042@end table
10043
10044If the entire argument can't be parsed or applied as valid values then the filter will
10045continue with its existing parameters.
10046
10047@subsection Examples
10048
10049@itemize
10050@item
10051Draw "Test Text" with font FreeSerif, using the default values for the
10052optional parameters.
10053
10054@example
10055drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
10056@end example
10057
10058@item
10059Draw 'Test Text' with font FreeSerif of size 24 at position x=100
10060and y=50 (counting from the top-left corner of the screen), text is
10061yellow with a red box around it. Both the text and the box have an
10062opacity of 20%.
10063
10064@example
10065drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
10066          x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
10067@end example
10068
10069Note that the double quotes are not necessary if spaces are not used
10070within the parameter list.
10071
10072@item
10073Show the text at the center of the video frame:
10074@example
10075drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2"
10076@end example
10077
10078@item
10079Show the text at a random position, switching to a new position every 30 seconds:
10080@example
10081drawtext="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)"
10082@end example
10083
10084@item
10085Show a text line sliding from right to left in the last row of the video
10086frame. The file @file{LONG_LINE} is assumed to contain a single line
10087with no newlines.
10088@example
10089drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
10090@end example
10091
10092@item
10093Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
10094@example
10095drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
10096@end example
10097
10098@item
10099Draw a single green letter "g", at the center of the input video.
10100The glyph baseline is placed at half screen height.
10101@example
10102drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
10103@end example
10104
10105@item
10106Show text for 1 second every 3 seconds:
10107@example
10108drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
10109@end example
10110
10111@item
10112Use fontconfig to set the font. Note that the colons need to be escaped.
10113@example
10114drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
10115@end example
10116
10117@item
10118Print the date of a real-time encoding (see strftime(3)):
10119@example
10120drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
10121@end example
10122
10123@item
10124Show text fading in and out (appearing/disappearing):
10125@example
10126#!/bin/sh
10127DS=1.0 # display start
10128DE=10.0 # display end
10129FID=1.5 # fade in duration
10130FOD=5 # fade out duration
10131ffplay -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 @}"
10132@end example
10133
10134@item
10135Horizontally align multiple separate texts. Note that @option{max_glyph_a}
10136and the @option{fontsize} value are included in the @option{y} offset.
10137@example
10138drawtext=fontfile=FreeSans.ttf:text=DOG:fontsize=24:x=10:y=20+24-max_glyph_a,
10139drawtext=fontfile=FreeSans.ttf:text=cow:fontsize=24:x=80:y=20+24-max_glyph_a
10140@end example
10141
10142@item
10143Plot special @var{lavf.image2dec.source_basename} metadata onto each frame if
10144such metadata exists. Otherwise, plot the string "NA". Note that image2 demuxer
10145must have option @option{-export_path_metadata 1} for the special metadata fields
10146to be available for filters.
10147@example
10148drawtext="fontsize=20:fontcolor=white:fontfile=FreeSans.ttf:text='%@{metadata\:lavf.image2dec.source_basename\:NA@}':x=10:y=10"
10149@end example
10150
10151@end itemize
10152
10153For more information about libfreetype, check:
10154@url{http://www.freetype.org/}.
10155
10156For more information about fontconfig, check:
10157@url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
10158
10159For more information about libfribidi, check:
10160@url{http://fribidi.org/}.
10161
10162@section edgedetect
10163
10164Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
10165
10166The filter accepts the following options:
10167
10168@table @option
10169@item low
10170@item high
10171Set low and high threshold values used by the Canny thresholding
10172algorithm.
10173
10174The high threshold selects the "strong" edge pixels, which are then
10175connected through 8-connectivity with the "weak" edge pixels selected
10176by the low threshold.
10177
10178@var{low} and @var{high} threshold values must be chosen in the range
10179[0,1], and @var{low} should be lesser or equal to @var{high}.
10180
10181Default value for @var{low} is @code{20/255}, and default value for @var{high}
10182is @code{50/255}.
10183
10184@item mode
10185Define the drawing mode.
10186
10187@table @samp
10188@item wires
10189Draw white/gray wires on black background.
10190
10191@item colormix
10192Mix the colors to create a paint/cartoon effect.
10193
10194@item canny
10195Apply Canny edge detector on all selected planes.
10196@end table
10197Default value is @var{wires}.
10198
10199@item planes
10200Select planes for filtering. By default all available planes are filtered.
10201@end table
10202
10203@subsection Examples
10204
10205@itemize
10206@item
10207Standard edge detection with custom values for the hysteresis thresholding:
10208@example
10209edgedetect=low=0.1:high=0.4
10210@end example
10211
10212@item
10213Painting effect without thresholding:
10214@example
10215edgedetect=mode=colormix:high=0
10216@end example
10217@end itemize
10218
10219@section elbg
10220
10221Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
10222
10223For each input image, the filter will compute the optimal mapping from
10224the input to the output given the codebook length, that is the number
10225of distinct output colors.
10226
10227This filter accepts the following options.
10228
10229@table @option
10230@item codebook_length, l
10231Set codebook length. The value must be a positive integer, and
10232represents the number of distinct output colors. Default value is 256.
10233
10234@item nb_steps, n
10235Set the maximum number of iterations to apply for computing the optimal
10236mapping. The higher the value the better the result and the higher the
10237computation time. Default value is 1.
10238
10239@item seed, s
10240Set a random seed, must be an integer included between 0 and
10241UINT32_MAX. If not specified, or if explicitly set to -1, the filter
10242will try to use a good random seed on a best effort basis.
10243
10244@item pal8
10245Set pal8 output pixel format. This option does not work with codebook
10246length greater than 256.
10247@end table
10248
10249@section entropy
10250
10251Measure graylevel entropy in histogram of color channels of video frames.
10252
10253It accepts the following parameters:
10254
10255@table @option
10256@item mode
10257Can be either @var{normal} or @var{diff}. Default is @var{normal}.
10258
10259@var{diff} mode measures entropy of histogram delta values, absolute differences
10260between neighbour histogram values.
10261@end table
10262
10263@section eq
10264Set brightness, contrast, saturation and approximate gamma adjustment.
10265
10266The filter accepts the following options:
10267
10268@table @option
10269@item contrast
10270Set the contrast expression. The value must be a float value in range
10271@code{-1000.0} to @code{1000.0}. The default value is "1".
10272
10273@item brightness
10274Set the brightness expression. The value must be a float value in
10275range @code{-1.0} to @code{1.0}. The default value is "0".
10276
10277@item saturation
10278Set the saturation expression. The value must be a float in
10279range @code{0.0} to @code{3.0}. The default value is "1".
10280
10281@item gamma
10282Set the gamma expression. The value must be a float in range
10283@code{0.1} to @code{10.0}.  The default value is "1".
10284
10285@item gamma_r
10286Set the gamma expression for red. The value must be a float in
10287range @code{0.1} to @code{10.0}. The default value is "1".
10288
10289@item gamma_g
10290Set the gamma expression for green. The value must be a float in range
10291@code{0.1} to @code{10.0}. The default value is "1".
10292
10293@item gamma_b
10294Set the gamma expression for blue. The value must be a float in range
10295@code{0.1} to @code{10.0}. The default value is "1".
10296
10297@item gamma_weight
10298Set the gamma weight expression. It can be used to reduce the effect
10299of a high gamma value on bright image areas, e.g. keep them from
10300getting overamplified and just plain white. The value must be a float
10301in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
10302gamma correction all the way down while @code{1.0} leaves it at its
10303full strength. Default is "1".
10304
10305@item eval
10306Set when the expressions for brightness, contrast, saturation and
10307gamma expressions are evaluated.
10308
10309It accepts the following values:
10310@table @samp
10311@item init
10312only evaluate expressions once during the filter initialization or
10313when a command is processed
10314
10315@item frame
10316evaluate expressions for each incoming frame
10317@end table
10318
10319Default value is @samp{init}.
10320@end table
10321
10322The expressions accept the following parameters:
10323@table @option
10324@item n
10325frame count of the input frame starting from 0
10326
10327@item pos
10328byte position of the corresponding packet in the input file, NAN if
10329unspecified
10330
10331@item r
10332frame rate of the input video, NAN if the input frame rate is unknown
10333
10334@item t
10335timestamp expressed in seconds, NAN if the input timestamp is unknown
10336@end table
10337
10338@subsection Commands
10339The filter supports the following commands:
10340
10341@table @option
10342@item contrast
10343Set the contrast expression.
10344
10345@item brightness
10346Set the brightness expression.
10347
10348@item saturation
10349Set the saturation expression.
10350
10351@item gamma
10352Set the gamma expression.
10353
10354@item gamma_r
10355Set the gamma_r expression.
10356
10357@item gamma_g
10358Set gamma_g expression.
10359
10360@item gamma_b
10361Set gamma_b expression.
10362
10363@item gamma_weight
10364Set gamma_weight expression.
10365
10366The command accepts the same syntax of the corresponding option.
10367
10368If the specified expression is not valid, it is kept at its current
10369value.
10370
10371@end table
10372
10373@section erosion
10374
10375Apply erosion effect to the video.
10376
10377This filter replaces the pixel by the local(3x3) minimum.
10378
10379It accepts the following options:
10380
10381@table @option
10382@item threshold0
10383@item threshold1
10384@item threshold2
10385@item threshold3
10386Limit the maximum change for each plane, default is 65535.
10387If 0, plane will remain unchanged.
10388
10389@item coordinates
10390Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
10391pixels are used.
10392
10393Flags to local 3x3 coordinates maps like this:
10394
10395    1 2 3
10396    4   5
10397    6 7 8
10398@end table
10399
10400@subsection Commands
10401
10402This filter supports the all above options as @ref{commands}.
10403
10404@section extractplanes
10405
10406Extract color channel components from input video stream into
10407separate grayscale video streams.
10408
10409The filter accepts the following option:
10410
10411@table @option
10412@item planes
10413Set plane(s) to extract.
10414
10415Available values for planes are:
10416@table @samp
10417@item y
10418@item u
10419@item v
10420@item a
10421@item r
10422@item g
10423@item b
10424@end table
10425
10426Choosing planes not available in the input will result in an error.
10427That means you cannot select @code{r}, @code{g}, @code{b} planes
10428with @code{y}, @code{u}, @code{v} planes at same time.
10429@end table
10430
10431@subsection Examples
10432
10433@itemize
10434@item
10435Extract luma, u and v color channel component from input video frame
10436into 3 grayscale outputs:
10437@example
10438ffmpeg -i video.avi -filter_complex 'extractplanes=y+u+v[y][u][v]' -map '[y]' y.avi -map '[u]' u.avi -map '[v]' v.avi
10439@end example
10440@end itemize
10441
10442@section fade
10443
10444Apply a fade-in/out effect to the input video.
10445
10446It accepts the following parameters:
10447
10448@table @option
10449@item type, t
10450The effect type can be either "in" for a fade-in, or "out" for a fade-out
10451effect.
10452Default is @code{in}.
10453
10454@item start_frame, s
10455Specify the number of the frame to start applying the fade
10456effect at. Default is 0.
10457
10458@item nb_frames, n
10459The number of frames that the fade effect lasts. At the end of the
10460fade-in effect, the output video will have the same intensity as the input video.
10461At the end of the fade-out transition, the output video will be filled with the
10462selected @option{color}.
10463Default is 25.
10464
10465@item alpha
10466If set to 1, fade only alpha channel, if one exists on the input.
10467Default value is 0.
10468
10469@item start_time, st
10470Specify the timestamp (in seconds) of the frame to start to apply the fade
10471effect. If both start_frame and start_time are specified, the fade will start at
10472whichever comes last.  Default is 0.
10473
10474@item duration, d
10475The number of seconds for which the fade effect has to last. At the end of the
10476fade-in effect the output video will have the same intensity as the input video,
10477at the end of the fade-out transition the output video will be filled with the
10478selected @option{color}.
10479If both duration and nb_frames are specified, duration is used. Default is 0
10480(nb_frames is used by default).
10481
10482@item color, c
10483Specify the color of the fade. Default is "black".
10484@end table
10485
10486@subsection Examples
10487
10488@itemize
10489@item
10490Fade in the first 30 frames of video:
10491@example
10492fade=in:0:30
10493@end example
10494
10495The command above is equivalent to:
10496@example
10497fade=t=in:s=0:n=30
10498@end example
10499
10500@item
10501Fade out the last 45 frames of a 200-frame video:
10502@example
10503fade=out:155:45
10504fade=type=out:start_frame=155:nb_frames=45
10505@end example
10506
10507@item
10508Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
10509@example
10510fade=in:0:25, fade=out:975:25
10511@end example
10512
10513@item
10514Make the first 5 frames yellow, then fade in from frame 5-24:
10515@example
10516fade=in:5:20:color=yellow
10517@end example
10518
10519@item
10520Fade in alpha over first 25 frames of video:
10521@example
10522fade=in:0:25:alpha=1
10523@end example
10524
10525@item
10526Make the first 5.5 seconds black, then fade in for 0.5 seconds:
10527@example
10528fade=t=in:st=5.5:d=0.5
10529@end example
10530
10531@end itemize
10532
10533@section fftdnoiz
10534Denoise frames using 3D FFT (frequency domain filtering).
10535
10536The filter accepts the following options:
10537
10538@table @option
10539@item sigma
10540Set the noise sigma constant. This sets denoising strength.
10541Default value is 1. Allowed range is from 0 to 30.
10542Using very high sigma with low overlap may give blocking artifacts.
10543
10544@item amount
10545Set amount of denoising. By default all detected noise is reduced.
10546Default value is 1. Allowed range is from 0 to 1.
10547
10548@item block
10549Set size of block, Default is 4, can be 3, 4, 5 or 6.
10550Actual size of block in pixels is 2 to power of @var{block}, so by default
10551block size in pixels is 2^4 which is 16.
10552
10553@item overlap
10554Set block overlap. Default is 0.5. Allowed range is from 0.2 to 0.8.
10555
10556@item prev
10557Set number of previous frames to use for denoising. By default is set to 0.
10558
10559@item next
10560Set number of next frames to to use for denoising. By default is set to 0.
10561
10562@item planes
10563Set planes which will be filtered, by default are all available filtered
10564except alpha.
10565@end table
10566
10567@section fftfilt
10568Apply arbitrary expressions to samples in frequency domain
10569
10570@table @option
10571@item dc_Y
10572Adjust the dc value (gain) of the luma plane of the image. The filter
10573accepts an integer value in range @code{0} to @code{1000}. The default
10574value is set to @code{0}.
10575
10576@item dc_U
10577Adjust the dc value (gain) of the 1st chroma plane of the image. The
10578filter accepts an integer value in range @code{0} to @code{1000}. The
10579default value is set to @code{0}.
10580
10581@item dc_V
10582Adjust the dc value (gain) of the 2nd chroma plane of the image. The
10583filter accepts an integer value in range @code{0} to @code{1000}. The
10584default value is set to @code{0}.
10585
10586@item weight_Y
10587Set the frequency domain weight expression for the luma plane.
10588
10589@item weight_U
10590Set the frequency domain weight expression for the 1st chroma plane.
10591
10592@item weight_V
10593Set the frequency domain weight expression for the 2nd chroma plane.
10594
10595@item eval
10596Set when the expressions are evaluated.
10597
10598It accepts the following values:
10599@table @samp
10600@item init
10601Only evaluate expressions once during the filter initialization.
10602
10603@item frame
10604Evaluate expressions for each incoming frame.
10605@end table
10606
10607Default value is @samp{init}.
10608
10609The filter accepts the following variables:
10610@item X
10611@item Y
10612The coordinates of the current sample.
10613
10614@item W
10615@item H
10616The width and height of the image.
10617
10618@item N
10619The number of input frame, starting from 0.
10620@end table
10621
10622@subsection Examples
10623
10624@itemize
10625@item
10626High-pass:
10627@example
10628fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
10629@end example
10630
10631@item
10632Low-pass:
10633@example
10634fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
10635@end example
10636
10637@item
10638Sharpen:
10639@example
10640fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
10641@end example
10642
10643@item
10644Blur:
10645@example
10646fftfilt=dc_Y=0:weight_Y='exp(-4 * ((Y+X)/(W+H)))'
10647@end example
10648
10649@end itemize
10650
10651@section field
10652
10653Extract a single field from an interlaced image using stride
10654arithmetic to avoid wasting CPU time. The output frames are marked as
10655non-interlaced.
10656
10657The filter accepts the following options:
10658
10659@table @option
10660@item type
10661Specify whether to extract the top (if the value is @code{0} or
10662@code{top}) or the bottom field (if the value is @code{1} or
10663@code{bottom}).
10664@end table
10665
10666@section fieldhint
10667
10668Create new frames by copying the top and bottom fields from surrounding frames
10669supplied as numbers by the hint file.
10670
10671@table @option
10672@item hint
10673Set file containing hints: absolute/relative frame numbers.
10674
10675There must be one line for each frame in a clip. Each line must contain two
10676numbers separated by the comma, optionally followed by @code{-} or @code{+}.
10677Numbers supplied on each line of file can not be out of [N-1,N+1] where N
10678is current frame number for @code{absolute} mode or out of [-1, 1] range
10679for @code{relative} mode. First number tells from which frame to pick up top
10680field and second number tells from which frame to pick up bottom field.
10681
10682If optionally followed by @code{+} output frame will be marked as interlaced,
10683else if followed by @code{-} output frame will be marked as progressive, else
10684it will be marked same as input frame.
10685If optionally followed by @code{t} output frame will use only top field, or in
10686case of @code{b} it will use only bottom field.
10687If line starts with @code{#} or @code{;} that line is skipped.
10688
10689@item mode
10690Can be item @code{absolute} or @code{relative}. Default is @code{absolute}.
10691@end table
10692
10693Example of first several lines of @code{hint} file for @code{relative} mode:
10694@example
106950,0 - # first frame
106961,0 - # second frame, use third's frame top field and second's frame bottom field
106971,0 - # third frame, use fourth's frame top field and third's frame bottom field
106981,0 -
106990,0 -
107000,0 -
107011,0 -
107021,0 -
107031,0 -
107040,0 -
107050,0 -
107061,0 -
107071,0 -
107081,0 -
107090,0 -
10710@end example
10711
10712@section fieldmatch
10713
10714Field matching filter for inverse telecine. It is meant to reconstruct the
10715progressive frames from a telecined stream. The filter does not drop duplicated
10716frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
10717followed by a decimation filter such as @ref{decimate} in the filtergraph.
10718
10719The separation of the field matching and the decimation is notably motivated by
10720the possibility of inserting a de-interlacing filter fallback between the two.
10721If the source has mixed telecined and real interlaced content,
10722@code{fieldmatch} will not be able to match fields for the interlaced parts.
10723But these remaining combed frames will be marked as interlaced, and thus can be
10724de-interlaced by a later filter such as @ref{yadif} before decimation.
10725
10726In addition to the various configuration options, @code{fieldmatch} can take an
10727optional second stream, activated through the @option{ppsrc} option. If
10728enabled, the frames reconstruction will be based on the fields and frames from
10729this second stream. This allows the first input to be pre-processed in order to
10730help the various algorithms of the filter, while keeping the output lossless
10731(assuming the fields are matched properly). Typically, a field-aware denoiser,
10732or brightness/contrast adjustments can help.
10733
10734Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
10735and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
10736which @code{fieldmatch} is based on. While the semantic and usage are very
10737close, some behaviour and options names can differ.
10738
10739The @ref{decimate} filter currently only works for constant frame rate input.
10740If your input has mixed telecined (30fps) and progressive content with a lower
10741framerate like 24fps use the following filterchain to produce the necessary cfr
10742stream: @code{dejudder,fps=30000/1001,fieldmatch,decimate}.
10743
10744The filter accepts the following options:
10745
10746@table @option
10747@item order
10748Specify the assumed field order of the input stream. Available values are:
10749
10750@table @samp
10751@item auto
10752Auto detect parity (use FFmpeg's internal parity value).
10753@item bff
10754Assume bottom field first.
10755@item tff
10756Assume top field first.
10757@end table
10758
10759Note that it is sometimes recommended not to trust the parity announced by the
10760stream.
10761
10762Default value is @var{auto}.
10763
10764@item mode
10765Set the matching mode or strategy to use. @option{pc} mode is the safest in the
10766sense that it won't risk creating jerkiness due to duplicate frames when
10767possible, but if there are bad edits or blended fields it will end up
10768outputting combed frames when a good match might actually exist. On the other
10769hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
10770but will almost always find a good frame if there is one. The other values are
10771all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
10772jerkiness and creating duplicate frames versus finding good matches in sections
10773with bad edits, orphaned fields, blended fields, etc.
10774
10775More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
10776
10777Available values are:
10778
10779@table @samp
10780@item pc
107812-way matching (p/c)
10782@item pc_n
107832-way matching, and trying 3rd match if still combed (p/c + n)
10784@item pc_u
107852-way matching, and trying 3rd match (same order) if still combed (p/c + u)
10786@item pc_n_ub
107872-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
10788still combed (p/c + n + u/b)
10789@item pcn
107903-way matching (p/c/n)
10791@item pcn_ub
107923-way matching, and trying 4th/5th matches if all 3 of the original matches are
10793detected as combed (p/c/n + u/b)
10794@end table
10795
10796The parenthesis at the end indicate the matches that would be used for that
10797mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
10798@var{top}).
10799
10800In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
10801the slowest.
10802
10803Default value is @var{pc_n}.
10804
10805@item ppsrc
10806Mark the main input stream as a pre-processed input, and enable the secondary
10807input stream as the clean source to pick the fields from. See the filter
10808introduction for more details. It is similar to the @option{clip2} feature from
10809VFM/TFM.
10810
10811Default value is @code{0} (disabled).
10812
10813@item field
10814Set the field to match from. It is recommended to set this to the same value as
10815@option{order} unless you experience matching failures with that setting. In
10816certain circumstances changing the field that is used to match from can have a
10817large impact on matching performance. Available values are:
10818
10819@table @samp
10820@item auto
10821Automatic (same value as @option{order}).
10822@item bottom
10823Match from the bottom field.
10824@item top
10825Match from the top field.
10826@end table
10827
10828Default value is @var{auto}.
10829
10830@item mchroma
10831Set whether or not chroma is included during the match comparisons. In most
10832cases it is recommended to leave this enabled. You should set this to @code{0}
10833only if your clip has bad chroma problems such as heavy rainbowing or other
10834artifacts. Setting this to @code{0} could also be used to speed things up at
10835the cost of some accuracy.
10836
10837Default value is @code{1}.
10838
10839@item y0
10840@item y1
10841These define an exclusion band which excludes the lines between @option{y0} and
10842@option{y1} from being included in the field matching decision. An exclusion
10843band can be used to ignore subtitles, a logo, or other things that may
10844interfere with the matching. @option{y0} sets the starting scan line and
10845@option{y1} sets the ending line; all lines in between @option{y0} and
10846@option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
10847@option{y0} and @option{y1} to the same value will disable the feature.
10848@option{y0} and @option{y1} defaults to @code{0}.
10849
10850@item scthresh
10851Set the scene change detection threshold as a percentage of maximum change on
10852the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
10853detection is only relevant in case @option{combmatch}=@var{sc}.  The range for
10854@option{scthresh} is @code{[0.0, 100.0]}.
10855
10856Default value is @code{12.0}.
10857
10858@item combmatch
10859When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
10860account the combed scores of matches when deciding what match to use as the
10861final match. Available values are:
10862
10863@table @samp
10864@item none
10865No final matching based on combed scores.
10866@item sc
10867Combed scores are only used when a scene change is detected.
10868@item full
10869Use combed scores all the time.
10870@end table
10871
10872Default is @var{sc}.
10873
10874@item combdbg
10875Force @code{fieldmatch} to calculate the combed metrics for certain matches and
10876print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
10877Available values are:
10878
10879@table @samp
10880@item none
10881No forced calculation.
10882@item pcn
10883Force p/c/n calculations.
10884@item pcnub
10885Force p/c/n/u/b calculations.
10886@end table
10887
10888Default value is @var{none}.
10889
10890@item cthresh
10891This is the area combing threshold used for combed frame detection. This
10892essentially controls how "strong" or "visible" combing must be to be detected.
10893Larger values mean combing must be more visible and smaller values mean combing
10894can be less visible or strong and still be detected. Valid settings are from
10895@code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
10896be detected as combed). This is basically a pixel difference value. A good
10897range is @code{[8, 12]}.
10898
10899Default value is @code{9}.
10900
10901@item chroma
10902Sets whether or not chroma is considered in the combed frame decision.  Only
10903disable this if your source has chroma problems (rainbowing, etc.) that are
10904causing problems for the combed frame detection with chroma enabled. Actually,
10905using @option{chroma}=@var{0} is usually more reliable, except for the case
10906where there is chroma only combing in the source.
10907
10908Default value is @code{0}.
10909
10910@item blockx
10911@item blocky
10912Respectively set the x-axis and y-axis size of the window used during combed
10913frame detection. This has to do with the size of the area in which
10914@option{combpel} pixels are required to be detected as combed for a frame to be
10915declared combed. See the @option{combpel} parameter description for more info.
10916Possible values are any number that is a power of 2 starting at 4 and going up
10917to 512.
10918
10919Default value is @code{16}.
10920
10921@item combpel
10922The number of combed pixels inside any of the @option{blocky} by
10923@option{blockx} size blocks on the frame for the frame to be detected as
10924combed. While @option{cthresh} controls how "visible" the combing must be, this
10925setting controls "how much" combing there must be in any localized area (a
10926window defined by the @option{blockx} and @option{blocky} settings) on the
10927frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
10928which point no frames will ever be detected as combed). This setting is known
10929as @option{MI} in TFM/VFM vocabulary.
10930
10931Default value is @code{80}.
10932@end table
10933
10934@anchor{p/c/n/u/b meaning}
10935@subsection p/c/n/u/b meaning
10936
10937@subsubsection p/c/n
10938
10939We assume the following telecined stream:
10940
10941@example
10942Top fields:     1 2 2 3 4
10943Bottom fields:  1 2 3 4 4
10944@end example
10945
10946The numbers correspond to the progressive frame the fields relate to. Here, the
10947first two frames are progressive, the 3rd and 4th are combed, and so on.
10948
10949When @code{fieldmatch} is configured to run a matching from bottom
10950(@option{field}=@var{bottom}) this is how this input stream get transformed:
10951
10952@example
10953Input stream:
10954                T     1 2 2 3 4
10955                B     1 2 3 4 4   <-- matching reference
10956
10957Matches:              c c n n c
10958
10959Output stream:
10960                T     1 2 3 4 4
10961                B     1 2 3 4 4
10962@end example
10963
10964As a result of the field matching, we can see that some frames get duplicated.
10965To perform a complete inverse telecine, you need to rely on a decimation filter
10966after this operation. See for instance the @ref{decimate} filter.
10967
10968The same operation now matching from top fields (@option{field}=@var{top})
10969looks like this:
10970
10971@example
10972Input stream:
10973                T     1 2 2 3 4   <-- matching reference
10974                B     1 2 3 4 4
10975
10976Matches:              c c p p c
10977
10978Output stream:
10979                T     1 2 2 3 4
10980                B     1 2 2 3 4
10981@end example
10982
10983In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
10984basically, they refer to the frame and field of the opposite parity:
10985
10986@itemize
10987@item @var{p} matches the field of the opposite parity in the previous frame
10988@item @var{c} matches the field of the opposite parity in the current frame
10989@item @var{n} matches the field of the opposite parity in the next frame
10990@end itemize
10991
10992@subsubsection u/b
10993
10994The @var{u} and @var{b} matching are a bit special in the sense that they match
10995from the opposite parity flag. In the following examples, we assume that we are
10996currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
10997'x' is placed above and below each matched fields.
10998
10999With bottom matching (@option{field}=@var{bottom}):
11000@example
11001Match:           c         p           n          b          u
11002
11003                 x       x               x        x          x
11004  Top          1 2 2     1 2 2       1 2 2      1 2 2      1 2 2
11005  Bottom       1 2 3     1 2 3       1 2 3      1 2 3      1 2 3
11006                 x         x           x        x              x
11007
11008Output frames:
11009                 2          1          2          2          2
11010                 2          2          2          1          3
11011@end example
11012
11013With top matching (@option{field}=@var{top}):
11014@example
11015Match:           c         p           n          b          u
11016
11017                 x         x           x        x              x
11018  Top          1 2 2     1 2 2       1 2 2      1 2 2      1 2 2
11019  Bottom       1 2 3     1 2 3       1 2 3      1 2 3      1 2 3
11020                 x       x               x        x          x
11021
11022Output frames:
11023                 2          2          2          1          2
11024                 2          1          3          2          2
11025@end example
11026
11027@subsection Examples
11028
11029Simple IVTC of a top field first telecined stream:
11030@example
11031fieldmatch=order=tff:combmatch=none, decimate
11032@end example
11033
11034Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
11035@example
11036fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
11037@end example
11038
11039@section fieldorder
11040
11041Transform the field order of the input video.
11042
11043It accepts the following parameters:
11044
11045@table @option
11046
11047@item order
11048The output field order. Valid values are @var{tff} for top field first or @var{bff}
11049for bottom field first.
11050@end table
11051
11052The default value is @samp{tff}.
11053
11054The transformation is done by shifting the picture content up or down
11055by one line, and filling the remaining line with appropriate picture content.
11056This method is consistent with most broadcast field order converters.
11057
11058If the input video is not flagged as being interlaced, or it is already
11059flagged as being of the required output field order, then this filter does
11060not alter the incoming video.
11061
11062It is very useful when converting to or from PAL DV material,
11063which is bottom field first.
11064
11065For example:
11066@example
11067ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
11068@end example
11069
11070@section fifo, afifo
11071
11072Buffer input images and send them when they are requested.
11073
11074It is mainly useful when auto-inserted by the libavfilter
11075framework.
11076
11077It does not take parameters.
11078
11079@section fillborders
11080
11081Fill borders of the input video, without changing video stream dimensions.
11082Sometimes video can have garbage at the four edges and you may not want to
11083crop video input to keep size multiple of some number.
11084
11085This filter accepts the following options:
11086
11087@table @option
11088@item left
11089Number of pixels to fill from left border.
11090
11091@item right
11092Number of pixels to fill from right border.
11093
11094@item top
11095Number of pixels to fill from top border.
11096
11097@item bottom
11098Number of pixels to fill from bottom border.
11099
11100@item mode
11101Set fill mode.
11102
11103It accepts the following values:
11104@table @samp
11105@item smear
11106fill pixels using outermost pixels
11107
11108@item mirror
11109fill pixels using mirroring
11110
11111@item fixed
11112fill pixels with constant value
11113@end table
11114
11115Default is @var{smear}.
11116
11117@item color
11118Set color for pixels in fixed mode. Default is @var{black}.
11119@end table
11120
11121@subsection Commands
11122This filter supports same @ref{commands} as options.
11123The command accepts the same syntax of the corresponding option.
11124
11125If the specified expression is not valid, it is kept at its current
11126value.
11127
11128@section find_rect
11129
11130Find a rectangular object
11131
11132It accepts the following options:
11133
11134@table @option
11135@item object
11136Filepath of the object image, needs to be in gray8.
11137
11138@item threshold
11139Detection threshold, default is 0.5.
11140
11141@item mipmaps
11142Number of mipmaps, default is 3.
11143
11144@item xmin, ymin, xmax, ymax
11145Specifies the rectangle in which to search.
11146@end table
11147
11148@subsection Examples
11149
11150@itemize
11151@item
11152Cover a rectangular object by the supplied image of a given video using @command{ffmpeg}:
11153@example
11154ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
11155@end example
11156@end itemize
11157
11158@section floodfill
11159
11160Flood area with values of same pixel components with another values.
11161
11162It accepts the following options:
11163@table @option
11164@item x
11165Set pixel x coordinate.
11166
11167@item y
11168Set pixel y coordinate.
11169
11170@item s0
11171Set source #0 component value.
11172
11173@item s1
11174Set source #1 component value.
11175
11176@item s2
11177Set source #2 component value.
11178
11179@item s3
11180Set source #3 component value.
11181
11182@item d0
11183Set destination #0 component value.
11184
11185@item d1
11186Set destination #1 component value.
11187
11188@item d2
11189Set destination #2 component value.
11190
11191@item d3
11192Set destination #3 component value.
11193@end table
11194
11195@anchor{format}
11196@section format
11197
11198Convert the input video to one of the specified pixel formats.
11199Libavfilter will try to pick one that is suitable as input to
11200the next filter.
11201
11202It accepts the following parameters:
11203@table @option
11204
11205@item pix_fmts
11206A '|'-separated list of pixel format names, such as
11207"pix_fmts=yuv420p|monow|rgb24".
11208
11209@end table
11210
11211@subsection Examples
11212
11213@itemize
11214@item
11215Convert the input video to the @var{yuv420p} format
11216@example
11217format=pix_fmts=yuv420p
11218@end example
11219
11220Convert the input video to any of the formats in the list
11221@example
11222format=pix_fmts=yuv420p|yuv444p|yuv410p
11223@end example
11224@end itemize
11225
11226@anchor{fps}
11227@section fps
11228
11229Convert the video to specified constant frame rate by duplicating or dropping
11230frames as necessary.
11231
11232It accepts the following parameters:
11233@table @option
11234
11235@item fps
11236The desired output frame rate. The default is @code{25}.
11237
11238@item start_time
11239Assume the first PTS should be the given value, in seconds. This allows for
11240padding/trimming at the start of stream. By default, no assumption is made
11241about the first frame's expected PTS, so no padding or trimming is done.
11242For example, this could be set to 0 to pad the beginning with duplicates of
11243the first frame if a video stream starts after the audio stream or to trim any
11244frames with a negative PTS.
11245
11246@item round
11247Timestamp (PTS) rounding method.
11248
11249Possible values are:
11250@table @option
11251@item zero
11252round towards 0
11253@item inf
11254round away from 0
11255@item down
11256round towards -infinity
11257@item up
11258round towards +infinity
11259@item near
11260round to nearest
11261@end table
11262The default is @code{near}.
11263
11264@item eof_action
11265Action performed when reading the last frame.
11266
11267Possible values are:
11268@table @option
11269@item round
11270Use same timestamp rounding method as used for other frames.
11271@item pass
11272Pass through last frame if input duration has not been reached yet.
11273@end table
11274The default is @code{round}.
11275
11276@end table
11277
11278Alternatively, the options can be specified as a flat string:
11279@var{fps}[:@var{start_time}[:@var{round}]].
11280
11281See also the @ref{setpts} filter.
11282
11283@subsection Examples
11284
11285@itemize
11286@item
11287A typical usage in order to set the fps to 25:
11288@example
11289fps=fps=25
11290@end example
11291
11292@item
11293Sets the fps to 24, using abbreviation and rounding method to round to nearest:
11294@example
11295fps=fps=film:round=near
11296@end example
11297@end itemize
11298
11299@section framepack
11300
11301Pack two different video streams into a stereoscopic video, setting proper
11302metadata on supported codecs. The two views should have the same size and
11303framerate and processing will stop when the shorter video ends. Please note
11304that you may conveniently adjust view properties with the @ref{scale} and
11305@ref{fps} filters.
11306
11307It accepts the following parameters:
11308@table @option
11309
11310@item format
11311The desired packing format. Supported values are:
11312
11313@table @option
11314
11315@item sbs
11316The views are next to each other (default).
11317
11318@item tab
11319The views are on top of each other.
11320
11321@item lines
11322The views are packed by line.
11323
11324@item columns
11325The views are packed by column.
11326
11327@item frameseq
11328The views are temporally interleaved.
11329
11330@end table
11331
11332@end table
11333
11334Some examples:
11335
11336@example
11337# Convert left and right views into a frame-sequential video
11338ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
11339
11340# Convert views into a side-by-side video with the same output resolution as the input
11341ffmpeg -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
11342@end example
11343
11344@section framerate
11345
11346Change the frame rate by interpolating new video output frames from the source
11347frames.
11348
11349This filter is not designed to function correctly with interlaced media. If
11350you wish to change the frame rate of interlaced media then you are required
11351to deinterlace before this filter and re-interlace after this filter.
11352
11353A description of the accepted options follows.
11354
11355@table @option
11356@item fps
11357Specify the output frames per second. This option can also be specified
11358as a value alone. The default is @code{50}.
11359
11360@item interp_start
11361Specify the start of a range where the output frame will be created as a
11362linear interpolation of two frames. The range is [@code{0}-@code{255}],
11363the default is @code{15}.
11364
11365@item interp_end
11366Specify the end of a range where the output frame will be created as a
11367linear interpolation of two frames. The range is [@code{0}-@code{255}],
11368the default is @code{240}.
11369
11370@item scene
11371Specify the level at which a scene change is detected as a value between
113720 and 100 to indicate a new scene; a low value reflects a low
11373probability for the current frame to introduce a new scene, while a higher
11374value means the current frame is more likely to be one.
11375The default is @code{8.2}.
11376
11377@item flags
11378Specify flags influencing the filter process.
11379
11380Available value for @var{flags} is:
11381
11382@table @option
11383@item scene_change_detect, scd
11384Enable scene change detection using the value of the option @var{scene}.
11385This flag is enabled by default.
11386@end table
11387@end table
11388
11389@section framestep
11390
11391Select one frame every N-th frame.
11392
11393This filter accepts the following option:
11394@table @option
11395@item step
11396Select frame after every @code{step} frames.
11397Allowed values are positive integers higher than 0. Default value is @code{1}.
11398@end table
11399
11400@section freezedetect
11401
11402Detect frozen video.
11403
11404This filter logs a message and sets frame metadata when it detects that the
11405input video has no significant change in content during a specified duration.
11406Video freeze detection calculates the mean average absolute difference of all
11407the components of video frames and compares it to a noise floor.
11408
11409The printed times and duration are expressed in seconds. The
11410@code{lavfi.freezedetect.freeze_start} metadata key is set on the first frame
11411whose timestamp equals or exceeds the detection duration and it contains the
11412timestamp of the first frame of the freeze. The
11413@code{lavfi.freezedetect.freeze_duration} and
11414@code{lavfi.freezedetect.freeze_end} metadata keys are set on the first frame
11415after the freeze.
11416
11417The filter accepts the following options:
11418
11419@table @option
11420@item noise, n
11421Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
11422specified value) or as a difference ratio between 0 and 1. Default is -60dB, or
114230.001.
11424
11425@item duration, d
11426Set freeze duration until notification (default is 2 seconds).
11427@end table
11428
11429@section freezeframes
11430
11431Freeze video frames.
11432
11433This filter freezes video frames using frame from 2nd input.
11434
11435The filter accepts the following options:
11436
11437@table @option
11438@item first
11439Set number of first frame from which to start freeze.
11440
11441@item last
11442Set number of last frame from which to end freeze.
11443
11444@item replace
11445Set number of frame from 2nd input which will be used instead of replaced frames.
11446@end table
11447
11448@anchor{frei0r}
11449@section frei0r
11450
11451Apply a frei0r effect to the input video.
11452
11453To enable the compilation of this filter, you need to install the frei0r
11454header and configure FFmpeg with @code{--enable-frei0r}.
11455
11456It accepts the following parameters:
11457
11458@table @option
11459
11460@item filter_name
11461The name of the frei0r effect to load. If the environment variable
11462@env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
11463directories specified by the colon-separated list in @env{FREI0R_PATH}.
11464Otherwise, the standard frei0r paths are searched, in this order:
11465@file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
11466@file{/usr/lib/frei0r-1/}.
11467
11468@item filter_params
11469A '|'-separated list of parameters to pass to the frei0r effect.
11470
11471@end table
11472
11473A frei0r effect parameter can be a boolean (its value is either
11474"y" or "n"), a double, a color (specified as
11475@var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
11476numbers between 0.0 and 1.0, inclusive) or a color description as specified in the
11477@ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils},
11478a position (specified as @var{X}/@var{Y}, where
11479@var{X} and @var{Y} are floating point numbers) and/or a string.
11480
11481The number and types of parameters depend on the loaded effect. If an
11482effect parameter is not specified, the default value is set.
11483
11484@subsection Examples
11485
11486@itemize
11487@item
11488Apply the distort0r effect, setting the first two double parameters:
11489@example
11490frei0r=filter_name=distort0r:filter_params=0.5|0.01
11491@end example
11492
11493@item
11494Apply the colordistance effect, taking a color as the first parameter:
11495@example
11496frei0r=colordistance:0.2/0.3/0.4
11497frei0r=colordistance:violet
11498frei0r=colordistance:0x112233
11499@end example
11500
11501@item
11502Apply the perspective effect, specifying the top left and top right image
11503positions:
11504@example
11505frei0r=perspective:0.2/0.2|0.8/0.2
11506@end example
11507@end itemize
11508
11509For more information, see
11510@url{http://frei0r.dyne.org}
11511
11512@section fspp
11513
11514Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
11515
11516It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
11517processing filter, one of them is performed once per block, not per pixel.
11518This allows for much higher speed.
11519
11520The filter accepts the following options:
11521
11522@table @option
11523@item quality
11524Set quality. This option defines the number of levels for averaging. It accepts
11525an integer in the range 4-5. Default value is @code{4}.
11526
11527@item qp
11528Force a constant quantization parameter. It accepts an integer in range 0-63.
11529If not set, the filter will use the QP from the video stream (if available).
11530
11531@item strength
11532Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
11533more details but also more artifacts, while higher values make the image smoother
11534but also blurrier. Default value is @code{0} − PSNR optimal.
11535
11536@item use_bframe_qp
11537Enable the use of the QP from the B-Frames if set to @code{1}. Using this
11538option may cause flicker since the B-Frames have often larger QP. Default is
11539@code{0} (not enabled).
11540
11541@end table
11542
11543@section gblur
11544
11545Apply Gaussian blur filter.
11546
11547The filter accepts the following options:
11548
11549@table @option
11550@item sigma
11551Set horizontal sigma, standard deviation of Gaussian blur. Default is @code{0.5}.
11552
11553@item steps
11554Set number of steps for Gaussian approximation. Default is @code{1}.
11555
11556@item planes
11557Set which planes to filter. By default all planes are filtered.
11558
11559@item sigmaV
11560Set vertical sigma, if negative it will be same as @code{sigma}.
11561Default is @code{-1}.
11562@end table
11563
11564@subsection Commands
11565This filter supports same commands as options.
11566The command accepts the same syntax of the corresponding option.
11567
11568If the specified expression is not valid, it is kept at its current
11569value.
11570
11571@section geq
11572
11573Apply generic equation to each pixel.
11574
11575The filter accepts the following options:
11576
11577@table @option
11578@item lum_expr, lum
11579Set the luminance expression.
11580@item cb_expr, cb
11581Set the chrominance blue expression.
11582@item cr_expr, cr
11583Set the chrominance red expression.
11584@item alpha_expr, a
11585Set the alpha expression.
11586@item red_expr, r
11587Set the red expression.
11588@item green_expr, g
11589Set the green expression.
11590@item blue_expr, b
11591Set the blue expression.
11592@end table
11593
11594The colorspace is selected according to the specified options. If one
11595of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
11596options is specified, the filter will automatically select a YCbCr
11597colorspace. If one of the @option{red_expr}, @option{green_expr}, or
11598@option{blue_expr} options is specified, it will select an RGB
11599colorspace.
11600
11601If one of the chrominance expression is not defined, it falls back on the other
11602one. If no alpha expression is specified it will evaluate to opaque value.
11603If none of chrominance expressions are specified, they will evaluate
11604to the luminance expression.
11605
11606The expressions can use the following variables and functions:
11607
11608@table @option
11609@item N
11610The sequential number of the filtered frame, starting from @code{0}.
11611
11612@item X
11613@item Y
11614The coordinates of the current sample.
11615
11616@item W
11617@item H
11618The width and height of the image.
11619
11620@item SW
11621@item SH
11622Width and height scale depending on the currently filtered plane. It is the
11623ratio between the corresponding luma plane number of pixels and the current
11624plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
11625@code{0.5,0.5} for chroma planes.
11626
11627@item T
11628Time of the current frame, expressed in seconds.
11629
11630@item p(x, y)
11631Return the value of the pixel at location (@var{x},@var{y}) of the current
11632plane.
11633
11634@item lum(x, y)
11635Return the value of the pixel at location (@var{x},@var{y}) of the luminance
11636plane.
11637
11638@item cb(x, y)
11639Return the value of the pixel at location (@var{x},@var{y}) of the
11640blue-difference chroma plane. Return 0 if there is no such plane.
11641
11642@item cr(x, y)
11643Return the value of the pixel at location (@var{x},@var{y}) of the
11644red-difference chroma plane. Return 0 if there is no such plane.
11645
11646@item r(x, y)
11647@item g(x, y)
11648@item b(x, y)
11649Return the value of the pixel at location (@var{x},@var{y}) of the
11650red/green/blue component. Return 0 if there is no such component.
11651
11652@item alpha(x, y)
11653Return the value of the pixel at location (@var{x},@var{y}) of the alpha
11654plane. Return 0 if there is no such plane.
11655
11656@item psum(x,y), lumsum(x, y), cbsum(x,y), crsum(x,y), rsum(x,y), gsum(x,y), bsum(x,y), alphasum(x,y)
11657Sum of sample values in the rectangle from (0,0) to (x,y), this allows obtaining
11658sums of samples within a rectangle. See the functions without the sum postfix.
11659
11660@item interpolation
11661Set one of interpolation methods:
11662@table @option
11663@item nearest, n
11664@item bilinear, b
11665@end table
11666Default is bilinear.
11667@end table
11668
11669For functions, if @var{x} and @var{y} are outside the area, the value will be
11670automatically clipped to the closer edge.
11671
11672Please note that this filter can use multiple threads in which case each slice
11673will have its own expression state. If you want to use only a single expression
11674state because your expressions depend on previous state then you should limit
11675the number of filter threads to 1.
11676
11677@subsection Examples
11678
11679@itemize
11680@item
11681Flip the image horizontally:
11682@example
11683geq=p(W-X\,Y)
11684@end example
11685
11686@item
11687Generate a bidimensional sine wave, with angle @code{PI/3} and a
11688wavelength of 100 pixels:
11689@example
11690geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
11691@end example
11692
11693@item
11694Generate a fancy enigmatic moving light:
11695@example
11696nullsrc=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
11697@end example
11698
11699@item
11700Generate a quick emboss effect:
11701@example
11702format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
11703@end example
11704
11705@item
11706Modify RGB components depending on pixel position:
11707@example
11708geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
11709@end example
11710
11711@item
11712Create a radial gradient that is the same size as the input (also see
11713the @ref{vignette} filter):
11714@example
11715geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
11716@end example
11717@end itemize
11718
11719@section gradfun
11720
11721Fix the banding artifacts that are sometimes introduced into nearly flat
11722regions by truncation to 8-bit color depth.
11723Interpolate the gradients that should go where the bands are, and
11724dither them.
11725
11726It is designed for playback only.  Do not use it prior to
11727lossy compression, because compression tends to lose the dither and
11728bring back the bands.
11729
11730It accepts the following parameters:
11731
11732@table @option
11733
11734@item strength
11735The maximum amount by which the filter will change any one pixel. This is also
11736the threshold for detecting nearly flat regions. Acceptable values range from
11737.51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
11738valid range.
11739
11740@item radius
11741The neighborhood to fit the gradient to. A larger radius makes for smoother
11742gradients, but also prevents the filter from modifying the pixels near detailed
11743regions. Acceptable values are 8-32; the default value is 16. Out-of-range
11744values will be clipped to the valid range.
11745
11746@end table
11747
11748Alternatively, the options can be specified as a flat string:
11749@var{strength}[:@var{radius}]
11750
11751@subsection Examples
11752
11753@itemize
11754@item
11755Apply the filter with a @code{3.5} strength and radius of @code{8}:
11756@example
11757gradfun=3.5:8
11758@end example
11759
11760@item
11761Specify radius, omitting the strength (which will fall-back to the default
11762value):
11763@example
11764gradfun=radius=8
11765@end example
11766
11767@end itemize
11768
11769@anchor{graphmonitor}
11770@section graphmonitor
11771Show various filtergraph stats.
11772
11773With this filter one can debug complete filtergraph.
11774Especially issues with links filling with queued frames.
11775
11776The filter accepts the following options:
11777
11778@table @option
11779@item size, s
11780Set video output size. Default is @var{hd720}.
11781
11782@item opacity, o
11783Set video opacity. Default is @var{0.9}. Allowed range is from @var{0} to @var{1}.
11784
11785@item mode, m
11786Set output mode, can be @var{fulll} or @var{compact}.
11787In @var{compact} mode only filters with some queued frames have displayed stats.
11788
11789@item flags, f
11790Set flags which enable which stats are shown in video.
11791
11792Available values for flags are:
11793@table @samp
11794@item queue
11795Display number of queued frames in each link.
11796
11797@item frame_count_in
11798Display number of frames taken from filter.
11799
11800@item frame_count_out
11801Display number of frames given out from filter.
11802
11803@item pts
11804Display current filtered frame pts.
11805
11806@item time
11807Display current filtered frame time.
11808
11809@item timebase
11810Display time base for filter link.
11811
11812@item format
11813Display used format for filter link.
11814
11815@item size
11816Display video size or number of audio channels in case of audio used by filter link.
11817
11818@item rate
11819Display video frame rate or sample rate in case of audio used by filter link.
11820@end table
11821
11822@item rate, r
11823Set upper limit for video rate of output stream, Default value is @var{25}.
11824This guarantee that output video frame rate will not be higher than this value.
11825@end table
11826
11827@section greyedge
11828A color constancy variation filter which estimates scene illumination via grey edge algorithm
11829and corrects the scene colors accordingly.
11830
11831See: @url{https://staff.science.uva.nl/th.gevers/pub/GeversTIP07.pdf}
11832
11833The filter accepts the following options:
11834
11835@table @option
11836@item difford
11837The order of differentiation to be applied on the scene. Must be chosen in the range
11838[0,2] and default value is 1.
11839
11840@item minknorm
11841The Minkowski parameter to be used for calculating the Minkowski distance. Must
11842be chosen in the range [0,20] and default value is 1. Set to 0 for getting
11843max value instead of calculating Minkowski distance.
11844
11845@item sigma
11846The standard deviation of Gaussian blur to be applied on the scene. Must be
11847chosen in the range [0,1024.0] and default value = 1. floor( @var{sigma} * break_off_sigma(3) )
11848can't be equal to 0 if @var{difford} is greater than 0.
11849@end table
11850
11851@subsection Examples
11852@itemize
11853
11854@item
11855Grey Edge:
11856@example
11857greyedge=difford=1:minknorm=5:sigma=2
11858@end example
11859
11860@item
11861Max Edge:
11862@example
11863greyedge=difford=1:minknorm=0:sigma=2
11864@end example
11865
11866@end itemize
11867
11868@anchor{haldclut}
11869@section haldclut
11870
11871Apply a Hald CLUT to a video stream.
11872
11873First input is the video stream to process, and second one is the Hald CLUT.
11874The Hald CLUT input can be a simple picture or a complete video stream.
11875
11876The filter accepts the following options:
11877
11878@table @option
11879@item shortest
11880Force termination when the shortest input terminates. Default is @code{0}.
11881@item repeatlast
11882Continue applying the last CLUT after the end of the stream. A value of
11883@code{0} disable the filter after the last frame of the CLUT is reached.
11884Default is @code{1}.
11885@end table
11886
11887@code{haldclut} also has the same interpolation options as @ref{lut3d} (both
11888filters share the same internals).
11889
11890This filter also supports the @ref{framesync} options.
11891
11892More information about the Hald CLUT can be found on Eskil Steenberg's website
11893(Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
11894
11895@subsection Workflow examples
11896
11897@subsubsection Hald CLUT video stream
11898
11899Generate an identity Hald CLUT stream altered with various effects:
11900@example
11901ffmpeg -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
11902@end example
11903
11904Note: make sure you use a lossless codec.
11905
11906Then use it with @code{haldclut} to apply it on some random stream:
11907@example
11908ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
11909@end example
11910
11911The Hald CLUT will be applied to the 10 first seconds (duration of
11912@file{clut.nut}), then the latest picture of that CLUT stream will be applied
11913to the remaining frames of the @code{mandelbrot} stream.
11914
11915@subsubsection Hald CLUT with preview
11916
11917A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
11918@code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
11919biggest possible square starting at the top left of the picture. The remaining
11920padding pixels (bottom or right) will be ignored. This area can be used to add
11921a preview of the Hald CLUT.
11922
11923Typically, the following generated Hald CLUT will be supported by the
11924@code{haldclut} filter:
11925
11926@example
11927ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
11928   pad=iw+320 [padded_clut];
11929   smptebars=s=320x256, split [a][b];
11930   [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
11931   [main][b] overlay=W-320" -frames:v 1 clut.png
11932@end example
11933
11934It contains the original and a preview of the effect of the CLUT: SMPTE color
11935bars are displayed on the right-top, and below the same color bars processed by
11936the color changes.
11937
11938Then, the effect of this Hald CLUT can be visualized with:
11939@example
11940ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
11941@end example
11942
11943@section hflip
11944
11945Flip the input video horizontally.
11946
11947For example, to horizontally flip the input video with @command{ffmpeg}:
11948@example
11949ffmpeg -i in.avi -vf "hflip" out.avi
11950@end example
11951
11952@section histeq
11953This filter applies a global color histogram equalization on a
11954per-frame basis.
11955
11956It can be used to correct video that has a compressed range of pixel
11957intensities.  The filter redistributes the pixel intensities to
11958equalize their distribution across the intensity range. It may be
11959viewed as an "automatically adjusting contrast filter". This filter is
11960useful only for correcting degraded or poorly captured source
11961video.
11962
11963The filter accepts the following options:
11964
11965@table @option
11966@item strength
11967Determine the amount of equalization to be applied.  As the strength
11968is reduced, the distribution of pixel intensities more-and-more
11969approaches that of the input frame. The value must be a float number
11970in the range [0,1] and defaults to 0.200.
11971
11972@item intensity
11973Set the maximum intensity that can generated and scale the output
11974values appropriately.  The strength should be set as desired and then
11975the intensity can be limited if needed to avoid washing-out. The value
11976must be a float number in the range [0,1] and defaults to 0.210.
11977
11978@item antibanding
11979Set the antibanding level. If enabled the filter will randomly vary
11980the luminance of output pixels by a small amount to avoid banding of
11981the histogram. Possible values are @code{none}, @code{weak} or
11982@code{strong}. It defaults to @code{none}.
11983@end table
11984
11985@anchor{histogram}
11986@section histogram
11987
11988Compute and draw a color distribution histogram for the input video.
11989
11990The computed histogram is a representation of the color component
11991distribution in an image.
11992
11993Standard histogram displays the color components distribution in an image.
11994Displays color graph for each color component. Shows distribution of
11995the Y, U, V, A or R, G, B components, depending on input format, in the
11996current frame. Below each graph a color component scale meter is shown.
11997
11998The filter accepts the following options:
11999
12000@table @option
12001@item level_height
12002Set height of level. Default value is @code{200}.
12003Allowed range is [50, 2048].
12004
12005@item scale_height
12006Set height of color scale. Default value is @code{12}.
12007Allowed range is [0, 40].
12008
12009@item display_mode
12010Set display mode.
12011It accepts the following values:
12012@table @samp
12013@item stack
12014Per color component graphs are placed below each other.
12015
12016@item parade
12017Per color component graphs are placed side by side.
12018
12019@item overlay
12020Presents information identical to that in the @code{parade}, except
12021that the graphs representing color components are superimposed directly
12022over one another.
12023@end table
12024Default is @code{stack}.
12025
12026@item levels_mode
12027Set mode. Can be either @code{linear}, or @code{logarithmic}.
12028Default is @code{linear}.
12029
12030@item components
12031Set what color components to display.
12032Default is @code{7}.
12033
12034@item fgopacity
12035Set foreground opacity. Default is @code{0.7}.
12036
12037@item bgopacity
12038Set background opacity. Default is @code{0.5}.
12039@end table
12040
12041@subsection Examples
12042
12043@itemize
12044
12045@item
12046Calculate and draw histogram:
12047@example
12048ffplay -i input -vf histogram
12049@end example
12050
12051@end itemize
12052
12053@anchor{hqdn3d}
12054@section hqdn3d
12055
12056This is a high precision/quality 3d denoise filter. It aims to reduce
12057image noise, producing smooth images and making still images really
12058still. It should enhance compressibility.
12059
12060It accepts the following optional parameters:
12061
12062@table @option
12063@item luma_spatial
12064A non-negative floating point number which specifies spatial luma strength.
12065It defaults to 4.0.
12066
12067@item chroma_spatial
12068A non-negative floating point number which specifies spatial chroma strength.
12069It defaults to 3.0*@var{luma_spatial}/4.0.
12070
12071@item luma_tmp
12072A floating point number which specifies luma temporal strength. It defaults to
120736.0*@var{luma_spatial}/4.0.
12074
12075@item chroma_tmp
12076A floating point number which specifies chroma temporal strength. It defaults to
12077@var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
12078@end table
12079
12080@subsection Commands
12081This filter supports same @ref{commands} as options.
12082The command accepts the same syntax of the corresponding option.
12083
12084If the specified expression is not valid, it is kept at its current
12085value.
12086
12087@anchor{hwdownload}
12088@section hwdownload
12089
12090Download hardware frames to system memory.
12091
12092The input must be in hardware frames, and the output a non-hardware format.
12093Not all formats will be supported on the output - it may be necessary to insert
12094an additional @option{format} filter immediately following in the graph to get
12095the output in a supported format.
12096
12097@section hwmap
12098
12099Map hardware frames to system memory or to another device.
12100
12101This filter has several different modes of operation; which one is used depends
12102on the input and output formats:
12103@itemize
12104@item
12105Hardware frame input, normal frame output
12106
12107Map the input frames to system memory and pass them to the output.  If the
12108original hardware frame is later required (for example, after overlaying
12109something else on part of it), the @option{hwmap} filter can be used again
12110in the next mode to retrieve it.
12111@item
12112Normal frame input, hardware frame output
12113
12114If the input is actually a software-mapped hardware frame, then unmap it -
12115that is, return the original hardware frame.
12116
12117Otherwise, a device must be provided.  Create new hardware surfaces on that
12118device for the output, then map them back to the software format at the input
12119and give those frames to the preceding filter.  This will then act like the
12120@option{hwupload} filter, but may be able to avoid an additional copy when
12121the input is already in a compatible format.
12122@item
12123Hardware frame input and output
12124
12125A device must be supplied for the output, either directly or with the
12126@option{derive_device} option.  The input and output devices must be of
12127different types and compatible - the exact meaning of this is
12128system-dependent, but typically it means that they must refer to the same
12129underlying hardware context (for example, refer to the same graphics card).
12130
12131If the input frames were originally created on the output device, then unmap
12132to retrieve the original frames.
12133
12134Otherwise, map the frames to the output device - create new hardware frames
12135on the output corresponding to the frames on the input.
12136@end itemize
12137
12138The following additional parameters are accepted:
12139
12140@table @option
12141@item mode
12142Set the frame mapping mode.  Some combination of:
12143@table @var
12144@item read
12145The mapped frame should be readable.
12146@item write
12147The mapped frame should be writeable.
12148@item overwrite
12149The mapping will always overwrite the entire frame.
12150
12151This may improve performance in some cases, as the original contents of the
12152frame need not be loaded.
12153@item direct
12154The mapping must not involve any copying.
12155
12156Indirect mappings to copies of frames are created in some cases where either
12157direct mapping is not possible or it would have unexpected properties.
12158Setting this flag ensures that the mapping is direct and will fail if that is
12159not possible.
12160@end table
12161Defaults to @var{read+write} if not specified.
12162
12163@item derive_device @var{type}
12164Rather than using the device supplied at initialisation, instead derive a new
12165device of type @var{type} from the device the input frames exist on.
12166
12167@item reverse
12168In a hardware to hardware mapping, map in reverse - create frames in the sink
12169and map them back to the source.  This may be necessary in some cases where
12170a mapping in one direction is required but only the opposite direction is
12171supported by the devices being used.
12172
12173This option is dangerous - it may break the preceding filter in undefined
12174ways if there are any additional constraints on that filter's output.
12175Do not use it without fully understanding the implications of its use.
12176@end table
12177
12178@anchor{hwupload}
12179@section hwupload
12180
12181Upload system memory frames to hardware surfaces.
12182
12183The device to upload to must be supplied when the filter is initialised.  If
12184using ffmpeg, select the appropriate device with the @option{-filter_hw_device}
12185option or with the @option{derive_device} option.  The input and output devices
12186must be of different types and compatible - the exact meaning of this is
12187system-dependent, but typically it means that they must refer to the same
12188underlying hardware context (for example, refer to the same graphics card).
12189
12190The following additional parameters are accepted:
12191
12192@table @option
12193@item derive_device @var{type}
12194Rather than using the device supplied at initialisation, instead derive a new
12195device of type @var{type} from the device the input frames exist on.
12196@end table
12197
12198@anchor{hwupload_cuda}
12199@section hwupload_cuda
12200
12201Upload system memory frames to a CUDA device.
12202
12203It accepts the following optional parameters:
12204
12205@table @option
12206@item device
12207The number of the CUDA device to use
12208@end table
12209
12210@section hqx
12211
12212Apply a high-quality magnification filter designed for pixel art. This filter
12213was originally created by Maxim Stepin.
12214
12215It accepts the following option:
12216
12217@table @option
12218@item n
12219Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
12220@code{hq3x} and @code{4} for @code{hq4x}.
12221Default is @code{3}.
12222@end table
12223
12224@section hstack
12225Stack input videos horizontally.
12226
12227All streams must be of same pixel format and of same height.
12228
12229Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
12230to create same output.
12231
12232The filter accepts the following option:
12233
12234@table @option
12235@item inputs
12236Set number of input streams. Default is 2.
12237
12238@item shortest
12239If set to 1, force the output to terminate when the shortest input
12240terminates. Default value is 0.
12241@end table
12242
12243@section hue
12244
12245Modify the hue and/or the saturation of the input.
12246
12247It accepts the following parameters:
12248
12249@table @option
12250@item h
12251Specify the hue angle as a number of degrees. It accepts an expression,
12252and defaults to "0".
12253
12254@item s
12255Specify the saturation in the [-10,10] range. It accepts an expression and
12256defaults to "1".
12257
12258@item H
12259Specify the hue angle as a number of radians. It accepts an
12260expression, and defaults to "0".
12261
12262@item b
12263Specify the brightness in the [-10,10] range. It accepts an expression and
12264defaults to "0".
12265@end table
12266
12267@option{h} and @option{H} are mutually exclusive, and can't be
12268specified at the same time.
12269
12270The @option{b}, @option{h}, @option{H} and @option{s} option values are
12271expressions containing the following constants:
12272
12273@table @option
12274@item n
12275frame count of the input frame starting from 0
12276
12277@item pts
12278presentation timestamp of the input frame expressed in time base units
12279
12280@item r
12281frame rate of the input video, NAN if the input frame rate is unknown
12282
12283@item t
12284timestamp expressed in seconds, NAN if the input timestamp is unknown
12285
12286@item tb
12287time base of the input video
12288@end table
12289
12290@subsection Examples
12291
12292@itemize
12293@item
12294Set the hue to 90 degrees and the saturation to 1.0:
12295@example
12296hue=h=90:s=1
12297@end example
12298
12299@item
12300Same command but expressing the hue in radians:
12301@example
12302hue=H=PI/2:s=1
12303@end example
12304
12305@item
12306Rotate hue and make the saturation swing between 0
12307and 2 over a period of 1 second:
12308@example
12309hue="H=2*PI*t: s=sin(2*PI*t)+1"
12310@end example
12311
12312@item
12313Apply a 3 seconds saturation fade-in effect starting at 0:
12314@example
12315hue="s=min(t/3\,1)"
12316@end example
12317
12318The general fade-in expression can be written as:
12319@example
12320hue="s=min(0\, max((t-START)/DURATION\, 1))"
12321@end example
12322
12323@item
12324Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
12325@example
12326hue="s=max(0\, min(1\, (8-t)/3))"
12327@end example
12328
12329The general fade-out expression can be written as:
12330@example
12331hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
12332@end example
12333
12334@end itemize
12335
12336@subsection Commands
12337
12338This filter supports the following commands:
12339@table @option
12340@item b
12341@item s
12342@item h
12343@item H
12344Modify the hue and/or the saturation and/or brightness of the input video.
12345The command accepts the same syntax of the corresponding option.
12346
12347If the specified expression is not valid, it is kept at its current
12348value.
12349@end table
12350
12351@section hysteresis
12352
12353Grow first stream into second stream by connecting components.
12354This makes it possible to build more robust edge masks.
12355
12356This filter accepts the following options:
12357
12358@table @option
12359@item planes
12360Set which planes will be processed as bitmap, unprocessed planes will be
12361copied from first stream.
12362By default value 0xf, all planes will be processed.
12363
12364@item threshold
12365Set threshold which is used in filtering. If pixel component value is higher than
12366this value filter algorithm for connecting components is activated.
12367By default value is 0.
12368@end table
12369
12370The @code{hysteresis} filter also supports the @ref{framesync} options.
12371
12372@section idet
12373
12374Detect video interlacing type.
12375
12376This filter tries to detect if the input frames are interlaced, progressive,
12377top or bottom field first. It will also try to detect fields that are
12378repeated between adjacent frames (a sign of telecine).
12379
12380Single frame detection considers only immediately adjacent frames when classifying each frame.
12381Multiple frame detection incorporates the classification history of previous frames.
12382
12383The filter will log these metadata values:
12384
12385@table @option
12386@item single.current_frame
12387Detected type of current frame using single-frame detection. One of:
12388``tff'' (top field first), ``bff'' (bottom field first),
12389``progressive'', or ``undetermined''
12390
12391@item single.tff
12392Cumulative number of frames detected as top field first using single-frame detection.
12393
12394@item multiple.tff
12395Cumulative number of frames detected as top field first using multiple-frame detection.
12396
12397@item single.bff
12398Cumulative number of frames detected as bottom field first using single-frame detection.
12399
12400@item multiple.current_frame
12401Detected type of current frame using multiple-frame detection. One of:
12402``tff'' (top field first), ``bff'' (bottom field first),
12403``progressive'', or ``undetermined''
12404
12405@item multiple.bff
12406Cumulative number of frames detected as bottom field first using multiple-frame detection.
12407
12408@item single.progressive
12409Cumulative number of frames detected as progressive using single-frame detection.
12410
12411@item multiple.progressive
12412Cumulative number of frames detected as progressive using multiple-frame detection.
12413
12414@item single.undetermined
12415Cumulative number of frames that could not be classified using single-frame detection.
12416
12417@item multiple.undetermined
12418Cumulative number of frames that could not be classified using multiple-frame detection.
12419
12420@item repeated.current_frame
12421Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
12422
12423@item repeated.neither
12424Cumulative number of frames with no repeated field.
12425
12426@item repeated.top
12427Cumulative number of frames with the top field repeated from the previous frame's top field.
12428
12429@item repeated.bottom
12430Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
12431@end table
12432
12433The filter accepts the following options:
12434
12435@table @option
12436@item intl_thres
12437Set interlacing threshold.
12438@item prog_thres
12439Set progressive threshold.
12440@item rep_thres
12441Threshold for repeated field detection.
12442@item half_life
12443Number of frames after which a given frame's contribution to the
12444statistics is halved (i.e., it contributes only 0.5 to its
12445classification). The default of 0 means that all frames seen are given
12446full weight of 1.0 forever.
12447@item analyze_interlaced_flag
12448When this is not 0 then idet will use the specified number of frames to determine
12449if the interlaced flag is accurate, it will not count undetermined frames.
12450If the flag is found to be accurate it will be used without any further
12451computations, if it is found to be inaccurate it will be cleared without any
12452further computations. This allows inserting the idet filter as a low computational
12453method to clean up the interlaced flag
12454@end table
12455
12456@section il
12457
12458Deinterleave or interleave fields.
12459
12460This filter allows one to process interlaced images fields without
12461deinterlacing them. Deinterleaving splits the input frame into 2
12462fields (so called half pictures). Odd lines are moved to the top
12463half of the output image, even lines to the bottom half.
12464You can process (filter) them independently and then re-interleave them.
12465
12466The filter accepts the following options:
12467
12468@table @option
12469@item luma_mode, l
12470@item chroma_mode, c
12471@item alpha_mode, a
12472Available values for @var{luma_mode}, @var{chroma_mode} and
12473@var{alpha_mode} are:
12474
12475@table @samp
12476@item none
12477Do nothing.
12478
12479@item deinterleave, d
12480Deinterleave fields, placing one above the other.
12481
12482@item interleave, i
12483Interleave fields. Reverse the effect of deinterleaving.
12484@end table
12485Default value is @code{none}.
12486
12487@item luma_swap, ls
12488@item chroma_swap, cs
12489@item alpha_swap, as
12490Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
12491@end table
12492
12493@subsection Commands
12494
12495This filter supports the all above options as @ref{commands}.
12496
12497@section inflate
12498
12499Apply inflate effect to the video.
12500
12501This filter replaces the pixel by the local(3x3) average by taking into account
12502only values higher than the pixel.
12503
12504It accepts the following options:
12505
12506@table @option
12507@item threshold0
12508@item threshold1
12509@item threshold2
12510@item threshold3
12511Limit the maximum change for each plane, default is 65535.
12512If 0, plane will remain unchanged.
12513@end table
12514
12515@subsection Commands
12516
12517This filter supports the all above options as @ref{commands}.
12518
12519@section interlace
12520
12521Simple interlacing filter from progressive contents. This interleaves upper (or
12522lower) lines from odd frames with lower (or upper) lines from even frames,
12523halving the frame rate and preserving image height.
12524
12525@example
12526   Original        Original             New Frame
12527   Frame 'j'      Frame 'j+1'             (tff)
12528  ==========      ===========       ==================
12529    Line 0  -------------------->    Frame 'j' Line 0
12530    Line 1          Line 1  ---->   Frame 'j+1' Line 1
12531    Line 2 --------------------->    Frame 'j' Line 2
12532    Line 3          Line 3  ---->   Frame 'j+1' Line 3
12533     ...             ...                   ...
12534New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
12535@end example
12536
12537It accepts the following optional parameters:
12538
12539@table @option
12540@item scan
12541This determines whether the interlaced frame is taken from the even
12542(tff - default) or odd (bff) lines of the progressive frame.
12543
12544@item lowpass
12545Vertical lowpass filter to avoid twitter interlacing and
12546reduce moire patterns.
12547
12548@table @samp
12549@item 0, off
12550Disable vertical lowpass filter
12551
12552@item 1, linear
12553Enable linear filter (default)
12554
12555@item 2, complex
12556Enable complex filter. This will slightly less reduce twitter and moire
12557but better retain detail and subjective sharpness impression.
12558
12559@end table
12560@end table
12561
12562@section kerndeint
12563
12564Deinterlace input video by applying Donald Graft's adaptive kernel
12565deinterling. Work on interlaced parts of a video to produce
12566progressive frames.
12567
12568The description of the accepted parameters follows.
12569
12570@table @option
12571@item thresh
12572Set the threshold which affects the filter's tolerance when
12573determining if a pixel line must be processed. It must be an integer
12574in the range [0,255] and defaults to 10. A value of 0 will result in
12575applying the process on every pixels.
12576
12577@item map
12578Paint pixels exceeding the threshold value to white if set to 1.
12579Default is 0.
12580
12581@item order
12582Set the fields order. Swap fields if set to 1, leave fields alone if
125830. Default is 0.
12584
12585@item sharp
12586Enable additional sharpening if set to 1. Default is 0.
12587
12588@item twoway
12589Enable twoway sharpening if set to 1. Default is 0.
12590@end table
12591
12592@subsection Examples
12593
12594@itemize
12595@item
12596Apply default values:
12597@example
12598kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
12599@end example
12600
12601@item
12602Enable additional sharpening:
12603@example
12604kerndeint=sharp=1
12605@end example
12606
12607@item
12608Paint processed pixels in white:
12609@example
12610kerndeint=map=1
12611@end example
12612@end itemize
12613
12614@section lagfun
12615
12616Slowly update darker pixels.
12617
12618This filter makes short flashes of light appear longer.
12619This filter accepts the following options:
12620
12621@table @option
12622@item decay
12623Set factor for decaying. Default is .95. Allowed range is from 0 to 1.
12624
12625@item planes
12626Set which planes to filter. Default is all. Allowed range is from 0 to 15.
12627@end table
12628
12629@section lenscorrection
12630
12631Correct radial lens distortion
12632
12633This filter can be used to correct for radial distortion as can result from the use
12634of wide angle lenses, and thereby re-rectify the image. To find the right parameters
12635one can use tools available for example as part of opencv or simply trial-and-error.
12636To use opencv use the calibration sample (under samples/cpp) from the opencv sources
12637and extract the k1 and k2 coefficients from the resulting matrix.
12638
12639Note that effectively the same filter is available in the open-source tools Krita and
12640Digikam from the KDE project.
12641
12642In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
12643this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
12644brightness distribution, so you may want to use both filters together in certain
12645cases, though you will have to take care of ordering, i.e. whether vignetting should
12646be applied before or after lens correction.
12647
12648@subsection Options
12649
12650The filter accepts the following options:
12651
12652@table @option
12653@item cx
12654Relative x-coordinate of the focal point of the image, and thereby the center of the
12655distortion. This value has a range [0,1] and is expressed as fractions of the image
12656width. Default is 0.5.
12657@item cy
12658Relative y-coordinate of the focal point of the image, and thereby the center of the
12659distortion. This value has a range [0,1] and is expressed as fractions of the image
12660height. Default is 0.5.
12661@item k1
12662Coefficient of the quadratic correction term. This value has a range [-1,1]. 0 means
12663no correction. Default is 0.
12664@item k2
12665Coefficient of the double quadratic correction term. This value has a range [-1,1].
126660 means no correction. Default is 0.
12667@end table
12668
12669The formula that generates the correction is:
12670
12671@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)
12672
12673where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
12674distances from the focal point in the source and target images, respectively.
12675
12676@section lensfun
12677
12678Apply lens correction via the lensfun library (@url{http://lensfun.sourceforge.net/}).
12679
12680The @code{lensfun} filter requires the camera make, camera model, and lens model
12681to apply the lens correction. The filter will load the lensfun database and
12682query it to find the corresponding camera and lens entries in the database. As
12683long as these entries can be found with the given options, the filter can
12684perform corrections on frames. Note that incomplete strings will result in the
12685filter choosing the best match with the given options, and the filter will
12686output the chosen camera and lens models (logged with level "info"). You must
12687provide the make, camera model, and lens model as they are required.
12688
12689The filter accepts the following options:
12690
12691@table @option
12692@item make
12693The make of the camera (for example, "Canon"). This option is required.
12694
12695@item model
12696The model of the camera (for example, "Canon EOS 100D"). This option is
12697required.
12698
12699@item lens_model
12700The model of the lens (for example, "Canon EF-S 18-55mm f/3.5-5.6 IS STM"). This
12701option is required.
12702
12703@item mode
12704The type of correction to apply. The following values are valid options:
12705
12706@table @samp
12707@item vignetting
12708Enables fixing lens vignetting.
12709
12710@item geometry
12711Enables fixing lens geometry. This is the default.
12712
12713@item subpixel
12714Enables fixing chromatic aberrations.
12715
12716@item vig_geo
12717Enables fixing lens vignetting and lens geometry.
12718
12719@item vig_subpixel
12720Enables fixing lens vignetting and chromatic aberrations.
12721
12722@item distortion
12723Enables fixing both lens geometry and chromatic aberrations.
12724
12725@item all
12726Enables all possible corrections.
12727
12728@end table
12729@item focal_length
12730The focal length of the image/video (zoom; expected constant for video). For
12731example, a 18--55mm lens has focal length range of [18--55], so a value in that
12732range should be chosen when using that lens. Default 18.
12733
12734@item aperture
12735The aperture of the image/video (expected constant for video). Note that
12736aperture is only used for vignetting correction. Default 3.5.
12737
12738@item focus_distance
12739The focus distance of the image/video (expected constant for video). Note that
12740focus distance is only used for vignetting and only slightly affects the
12741vignetting correction process. If unknown, leave it at the default value (which
12742is 1000).
12743
12744@item scale
12745The scale factor which is applied after transformation. After correction the
12746video is no longer necessarily rectangular. This parameter controls how much of
12747the resulting image is visible. The value 0 means that a value will be chosen
12748automatically such that there is little or no unmapped area in the output
12749image. 1.0 means that no additional scaling is done. Lower values may result
12750in more of the corrected image being visible, while higher values may avoid
12751unmapped areas in the output.
12752
12753@item target_geometry
12754The target geometry of the output image/video. The following values are valid
12755options:
12756
12757@table @samp
12758@item rectilinear (default)
12759@item fisheye
12760@item panoramic
12761@item equirectangular
12762@item fisheye_orthographic
12763@item fisheye_stereographic
12764@item fisheye_equisolid
12765@item fisheye_thoby
12766@end table
12767@item reverse
12768Apply the reverse of image correction (instead of correcting distortion, apply
12769it).
12770
12771@item interpolation
12772The type of interpolation used when correcting distortion. The following values
12773are valid options:
12774
12775@table @samp
12776@item nearest
12777@item linear (default)
12778@item lanczos
12779@end table
12780@end table
12781
12782@subsection Examples
12783
12784@itemize
12785@item
12786Apply lens correction with make "Canon", camera model "Canon EOS 100D", and lens
12787model "Canon EF-S 18-55mm f/3.5-5.6 IS STM" with focal length of "18" and
12788aperture of "8.0".
12789
12790@example
12791ffmpeg -i input.mov -vf lensfun=make=Canon:model="Canon EOS 100D":lens_model="Canon EF-S 18-55mm f/3.5-5.6 IS STM":focal_length=18:aperture=8 -c:v h264 -b:v 8000k output.mov
12792@end example
12793
12794@item
12795Apply the same as before, but only for the first 5 seconds of video.
12796
12797@example
12798ffmpeg -i input.mov -vf lensfun=make=Canon:model="Canon EOS 100D":lens_model="Canon EF-S 18-55mm f/3.5-5.6 IS STM":focal_length=18:aperture=8:enable='lte(t\,5)' -c:v h264 -b:v 8000k output.mov
12799@end example
12800
12801@end itemize
12802
12803@section libvmaf
12804
12805Obtain the VMAF (Video Multi-Method Assessment Fusion)
12806score between two input videos.
12807
12808The obtained VMAF score is printed through the logging system.
12809
12810It requires Netflix's vmaf library (libvmaf) as a pre-requisite.
12811After installing the library it can be enabled using:
12812@code{./configure --enable-libvmaf --enable-version3}.
12813If no model path is specified it uses the default model: @code{vmaf_v0.6.1.pkl}.
12814
12815The filter has following options:
12816
12817@table @option
12818@item model_path
12819Set the model path which is to be used for SVM.
12820Default value: @code{"/usr/local/share/model/vmaf_v0.6.1.pkl"}
12821
12822@item log_path
12823Set the file path to be used to store logs.
12824
12825@item log_fmt
12826Set the format of the log file (xml or json).
12827
12828@item enable_transform
12829This option can enable/disable the @code{score_transform} applied to the final predicted VMAF score,
12830if you have specified score_transform option in the input parameter file passed to @code{run_vmaf_training.py}
12831Default value: @code{false}
12832
12833@item phone_model
12834Invokes the phone model which will generate VMAF scores higher than in the
12835regular model, which is more suitable for laptop, TV, etc. viewing conditions.
12836Default value: @code{false}
12837
12838@item psnr
12839Enables computing psnr along with vmaf.
12840Default value: @code{false}
12841
12842@item ssim
12843Enables computing ssim along with vmaf.
12844Default value: @code{false}
12845
12846@item ms_ssim
12847Enables computing ms_ssim along with vmaf.
12848Default value: @code{false}
12849
12850@item pool
12851Set the pool method to be used for computing vmaf.
12852Options are @code{min}, @code{harmonic_mean} or @code{mean} (default).
12853
12854@item n_threads
12855Set number of threads to be used when computing vmaf.
12856Default value: @code{0}, which makes use of all available logical processors.
12857
12858@item n_subsample
12859Set interval for frame subsampling used when computing vmaf.
12860Default value: @code{1}
12861
12862@item enable_conf_interval
12863Enables confidence interval.
12864Default value: @code{false}
12865@end table
12866
12867This filter also supports the @ref{framesync} options.
12868
12869@subsection Examples
12870@itemize
12871@item
12872On the below examples the input file @file{main.mpg} being processed is
12873compared with the reference file @file{ref.mpg}.
12874
12875@example
12876ffmpeg -i main.mpg -i ref.mpg -lavfi libvmaf -f null -
12877@end example
12878
12879@item
12880Example with options:
12881@example
12882ffmpeg -i main.mpg -i ref.mpg -lavfi libvmaf="psnr=1:log_fmt=json" -f null -
12883@end example
12884
12885@item
12886Example with options and different containers:
12887@example
12888ffmpeg -i main.mpg -i ref.mkv -lavfi "[0:v]settb=AVTB,setpts=PTS-STARTPTS[main];[1:v]settb=AVTB,setpts=PTS-STARTPTS[ref];[main][ref]libvmaf=psnr=1:log_fmt=json" -f null -
12889@end example
12890@end itemize
12891
12892@section limiter
12893
12894Limits the pixel components values to the specified range [min, max].
12895
12896The filter accepts the following options:
12897
12898@table @option
12899@item min
12900Lower bound. Defaults to the lowest allowed value for the input.
12901
12902@item max
12903Upper bound. Defaults to the highest allowed value for the input.
12904
12905@item planes
12906Specify which planes will be processed. Defaults to all available.
12907@end table
12908
12909@section loop
12910
12911Loop video frames.
12912
12913The filter accepts the following options:
12914
12915@table @option
12916@item loop
12917Set the number of loops. Setting this value to -1 will result in infinite loops.
12918Default is 0.
12919
12920@item size
12921Set maximal size in number of frames. Default is 0.
12922
12923@item start
12924Set first frame of loop. Default is 0.
12925@end table
12926
12927@subsection Examples
12928
12929@itemize
12930@item
12931Loop single first frame infinitely:
12932@example
12933loop=loop=-1:size=1:start=0
12934@end example
12935
12936@item
12937Loop single first frame 10 times:
12938@example
12939loop=loop=10:size=1:start=0
12940@end example
12941
12942@item
12943Loop 10 first frames 5 times:
12944@example
12945loop=loop=5:size=10:start=0
12946@end example
12947@end itemize
12948
12949@section lut1d
12950
12951Apply a 1D LUT to an input video.
12952
12953The filter accepts the following options:
12954
12955@table @option
12956@item file
12957Set the 1D LUT file name.
12958
12959Currently supported formats:
12960@table @samp
12961@item cube
12962Iridas
12963@item csp
12964cineSpace
12965@end table
12966
12967@item interp
12968Select interpolation mode.
12969
12970Available values are:
12971
12972@table @samp
12973@item nearest
12974Use values from the nearest defined point.
12975@item linear
12976Interpolate values using the linear interpolation.
12977@item cosine
12978Interpolate values using the cosine interpolation.
12979@item cubic
12980Interpolate values using the cubic interpolation.
12981@item spline
12982Interpolate values using the spline interpolation.
12983@end table
12984@end table
12985
12986@anchor{lut3d}
12987@section lut3d
12988
12989Apply a 3D LUT to an input video.
12990
12991The filter accepts the following options:
12992
12993@table @option
12994@item file
12995Set the 3D LUT file name.
12996
12997Currently supported formats:
12998@table @samp
12999@item 3dl
13000AfterEffects
13001@item cube
13002Iridas
13003@item dat
13004DaVinci
13005@item m3d
13006Pandora
13007@item csp
13008cineSpace
13009@end table
13010@item interp
13011Select interpolation mode.
13012
13013Available values are:
13014
13015@table @samp
13016@item nearest
13017Use values from the nearest defined point.
13018@item trilinear
13019Interpolate values using the 8 points defining a cube.
13020@item tetrahedral
13021Interpolate values using a tetrahedron.
13022@end table
13023@end table
13024
13025@section lumakey
13026
13027Turn certain luma values into transparency.
13028
13029The filter accepts the following options:
13030
13031@table @option
13032@item threshold
13033Set the luma which will be used as base for transparency.
13034Default value is @code{0}.
13035
13036@item tolerance
13037Set the range of luma values to be keyed out.
13038Default value is @code{0.01}.
13039
13040@item softness
13041Set the range of softness. Default value is @code{0}.
13042Use this to control gradual transition from zero to full transparency.
13043@end table
13044
13045@subsection Commands
13046This filter supports same @ref{commands} as options.
13047The command accepts the same syntax of the corresponding option.
13048
13049If the specified expression is not valid, it is kept at its current
13050value.
13051
13052@section lut, lutrgb, lutyuv
13053
13054Compute a look-up table for binding each pixel component input value
13055to an output value, and apply it to the input video.
13056
13057@var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
13058to an RGB input video.
13059
13060These filters accept the following parameters:
13061@table @option
13062@item c0
13063set first pixel component expression
13064@item c1
13065set second pixel component expression
13066@item c2
13067set third pixel component expression
13068@item c3
13069set fourth pixel component expression, corresponds to the alpha component
13070
13071@item r
13072set red component expression
13073@item g
13074set green component expression
13075@item b
13076set blue component expression
13077@item a
13078alpha component expression
13079
13080@item y
13081set Y/luminance component expression
13082@item u
13083set U/Cb component expression
13084@item v
13085set V/Cr component expression
13086@end table
13087
13088Each of them specifies the expression to use for computing the lookup table for
13089the corresponding pixel component values.
13090
13091The exact component associated to each of the @var{c*} options depends on the
13092format in input.
13093
13094The @var{lut} filter requires either YUV or RGB pixel formats in input,
13095@var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
13096
13097The expressions can contain the following constants and functions:
13098
13099@table @option
13100@item w
13101@item h
13102The input width and height.
13103
13104@item val
13105The input value for the pixel component.
13106
13107@item clipval
13108The input value, clipped to the @var{minval}-@var{maxval} range.
13109
13110@item maxval
13111The maximum value for the pixel component.
13112
13113@item minval
13114The minimum value for the pixel component.
13115
13116@item negval
13117The negated value for the pixel component value, clipped to the
13118@var{minval}-@var{maxval} range; it corresponds to the expression
13119"maxval-clipval+minval".
13120
13121@item clip(val)
13122The computed value in @var{val}, clipped to the
13123@var{minval}-@var{maxval} range.
13124
13125@item gammaval(gamma)
13126The computed gamma correction value of the pixel component value,
13127clipped to the @var{minval}-@var{maxval} range. It corresponds to the
13128expression
13129"pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
13130
13131@end table
13132
13133All expressions default to "val".
13134
13135@subsection Examples
13136
13137@itemize
13138@item
13139Negate input video:
13140@example
13141lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
13142lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
13143@end example
13144
13145The above is the same as:
13146@example
13147lutrgb="r=negval:g=negval:b=negval"
13148lutyuv="y=negval:u=negval:v=negval"
13149@end example
13150
13151@item
13152Negate luminance:
13153@example
13154lutyuv=y=negval
13155@end example
13156
13157@item
13158Remove chroma components, turning the video into a graytone image:
13159@example
13160lutyuv="u=128:v=128"
13161@end example
13162
13163@item
13164Apply a luma burning effect:
13165@example
13166lutyuv="y=2*val"
13167@end example
13168
13169@item
13170Remove green and blue components:
13171@example
13172lutrgb="g=0:b=0"
13173@end example
13174
13175@item
13176Set a constant alpha channel value on input:
13177@example
13178format=rgba,lutrgb=a="maxval-minval/2"
13179@end example
13180
13181@item
13182Correct luminance gamma by a factor of 0.5:
13183@example
13184lutyuv=y=gammaval(0.5)
13185@end example
13186
13187@item
13188Discard least significant bits of luma:
13189@example
13190lutyuv=y='bitand(val, 128+64+32)'
13191@end example
13192
13193@item
13194Technicolor like effect:
13195@example
13196lutyuv=u='(val-maxval/2)*2+maxval/2':v='(val-maxval/2)*2+maxval/2'
13197@end example
13198@end itemize
13199
13200@section lut2, tlut2
13201
13202The @code{lut2} filter takes two input streams and outputs one
13203stream.
13204
13205The @code{tlut2} (time lut2) filter takes two consecutive frames
13206from one single stream.
13207
13208This filter accepts the following parameters:
13209@table @option
13210@item c0
13211set first pixel component expression
13212@item c1
13213set second pixel component expression
13214@item c2
13215set third pixel component expression
13216@item c3
13217set fourth pixel component expression, corresponds to the alpha component
13218
13219@item d
13220set output bit depth, only available for @code{lut2} filter. By default is 0,
13221which means bit depth is automatically picked from first input format.
13222@end table
13223
13224The @code{lut2} filter also supports the @ref{framesync} options.
13225
13226Each of them specifies the expression to use for computing the lookup table for
13227the corresponding pixel component values.
13228
13229The exact component associated to each of the @var{c*} options depends on the
13230format in inputs.
13231
13232The expressions can contain the following constants:
13233
13234@table @option
13235@item w
13236@item h
13237The input width and height.
13238
13239@item x
13240The first input value for the pixel component.
13241
13242@item y
13243The second input value for the pixel component.
13244
13245@item bdx
13246The first input video bit depth.
13247
13248@item bdy
13249The second input video bit depth.
13250@end table
13251
13252All expressions default to "x".
13253
13254@subsection Examples
13255
13256@itemize
13257@item
13258Highlight differences between two RGB video streams:
13259@example
13260lut2='ifnot(x-y,0,pow(2,bdx)-1):ifnot(x-y,0,pow(2,bdx)-1):ifnot(x-y,0,pow(2,bdx)-1)'
13261@end example
13262
13263@item
13264Highlight differences between two YUV video streams:
13265@example
13266lut2='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)'
13267@end example
13268
13269@item
13270Show max difference between two video streams:
13271@example
13272lut2='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)))'
13273@end example
13274@end itemize
13275
13276@section maskedclamp
13277
13278Clamp the first input stream with the second input and third input stream.
13279
13280Returns the value of first stream to be between second input
13281stream - @code{undershoot} and third input stream + @code{overshoot}.
13282
13283This filter accepts the following options:
13284@table @option
13285@item undershoot
13286Default value is @code{0}.
13287
13288@item overshoot
13289Default value is @code{0}.
13290
13291@item planes
13292Set which planes will be processed as bitmap, unprocessed planes will be
13293copied from first stream.
13294By default value 0xf, all planes will be processed.
13295@end table
13296
13297@section maskedmax
13298
13299Merge the second and third input stream into output stream using absolute differences
13300between second input stream and first input stream and absolute difference between
13301third input stream and first input stream. The picked value will be from second input
13302stream if second absolute difference is greater than first one or from third input stream
13303otherwise.
13304
13305This filter accepts the following options:
13306@table @option
13307@item planes
13308Set which planes will be processed as bitmap, unprocessed planes will be
13309copied from first stream.
13310By default value 0xf, all planes will be processed.
13311@end table
13312
13313@section maskedmerge
13314
13315Merge the first input stream with the second input stream using per pixel
13316weights in the third input stream.
13317
13318A value of 0 in the third stream pixel component means that pixel component
13319from first stream is returned unchanged, while maximum value (eg. 255 for
133208-bit videos) means that pixel component from second stream is returned
13321unchanged. Intermediate values define the amount of merging between both
13322input stream's pixel components.
13323
13324This filter accepts the following options:
13325@table @option
13326@item planes
13327Set which planes will be processed as bitmap, unprocessed planes will be
13328copied from first stream.
13329By default value 0xf, all planes will be processed.
13330@end table
13331
13332@section maskedmin
13333
13334Merge the second and third input stream into output stream using absolute differences
13335between second input stream and first input stream and absolute difference between
13336third input stream and first input stream. The picked value will be from second input
13337stream if second absolute difference is less than first one or from third input stream
13338otherwise.
13339
13340This filter accepts the following options:
13341@table @option
13342@item planes
13343Set which planes will be processed as bitmap, unprocessed planes will be
13344copied from first stream.
13345By default value 0xf, all planes will be processed.
13346@end table
13347
13348@section maskedthreshold
13349Pick pixels comparing absolute difference of two video streams with fixed
13350threshold.
13351
13352If absolute difference between pixel component of first and second video
13353stream is equal or lower than user supplied threshold than pixel component
13354from first video stream is picked, otherwise pixel component from second
13355video stream is picked.
13356
13357This filter accepts the following options:
13358@table @option
13359@item threshold
13360Set threshold used when picking pixels from absolute difference from two input
13361video streams.
13362
13363@item planes
13364Set which planes will be processed as bitmap, unprocessed planes will be
13365copied from second stream.
13366By default value 0xf, all planes will be processed.
13367@end table
13368
13369@section maskfun
13370Create mask from input video.
13371
13372For example it is useful to create motion masks after @code{tblend} filter.
13373
13374This filter accepts the following options:
13375
13376@table @option
13377@item low
13378Set low threshold. Any pixel component lower or exact than this value will be set to 0.
13379
13380@item high
13381Set high threshold. Any pixel component higher than this value will be set to max value
13382allowed for current pixel format.
13383
13384@item planes
13385Set planes to filter, by default all available planes are filtered.
13386
13387@item fill
13388Fill all frame pixels with this value.
13389
13390@item sum
13391Set max average pixel value for frame. If sum of all pixel components is higher that this
13392average, output frame will be completely filled with value set by @var{fill} option.
13393Typically useful for scene changes when used in combination with @code{tblend} filter.
13394@end table
13395
13396@section mcdeint
13397
13398Apply motion-compensation deinterlacing.
13399
13400It needs one field per frame as input and must thus be used together
13401with yadif=1/3 or equivalent.
13402
13403This filter accepts the following options:
13404@table @option
13405@item mode
13406Set the deinterlacing mode.
13407
13408It accepts one of the following values:
13409@table @samp
13410@item fast
13411@item medium
13412@item slow
13413use iterative motion estimation
13414@item extra_slow
13415like @samp{slow}, but use multiple reference frames.
13416@end table
13417Default value is @samp{fast}.
13418
13419@item parity
13420Set the picture field parity assumed for the input video. It must be
13421one of the following values:
13422
13423@table @samp
13424@item 0, tff
13425assume top field first
13426@item 1, bff
13427assume bottom field first
13428@end table
13429
13430Default value is @samp{bff}.
13431
13432@item qp
13433Set per-block quantization parameter (QP) used by the internal
13434encoder.
13435
13436Higher values should result in a smoother motion vector field but less
13437optimal individual vectors. Default value is 1.
13438@end table
13439
13440@section median
13441
13442Pick median pixel from certain rectangle defined by radius.
13443
13444This filter accepts the following options:
13445
13446@table @option
13447@item radius
13448Set horizontal radius size. Default value is @code{1}.
13449Allowed range is integer from 1 to 127.
13450
13451@item planes
13452Set which planes to process. Default is @code{15}, which is all available planes.
13453
13454@item radiusV
13455Set vertical radius size. Default value is @code{0}.
13456Allowed range is integer from 0 to 127.
13457If it is 0, value will be picked from horizontal @code{radius} option.
13458
13459@item percentile
13460Set median percentile. Default value is @code{0.5}.
13461Default value of @code{0.5} will pick always median values, while @code{0} will pick
13462minimum values, and @code{1} maximum values.
13463@end table
13464
13465@subsection Commands
13466This filter supports same @ref{commands} as options.
13467The command accepts the same syntax of the corresponding option.
13468
13469If the specified expression is not valid, it is kept at its current
13470value.
13471
13472@section mergeplanes
13473
13474Merge color channel components from several video streams.
13475
13476The filter accepts up to 4 input streams, and merge selected input
13477planes to the output video.
13478
13479This filter accepts the following options:
13480@table @option
13481@item mapping
13482Set input to output plane mapping. Default is @code{0}.
13483
13484The mappings is specified as a bitmap. It should be specified as a
13485hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
13486mapping for the first plane of the output stream. 'A' sets the number of
13487the input stream to use (from 0 to 3), and 'a' the plane number of the
13488corresponding input to use (from 0 to 3). The rest of the mappings is
13489similar, 'Bb' describes the mapping for the output stream second
13490plane, 'Cc' describes the mapping for the output stream third plane and
13491'Dd' describes the mapping for the output stream fourth plane.
13492
13493@item format
13494Set output pixel format. Default is @code{yuva444p}.
13495@end table
13496
13497@subsection Examples
13498
13499@itemize
13500@item
13501Merge three gray video streams of same width and height into single video stream:
13502@example
13503[a0][a1][a2]mergeplanes=0x001020:yuv444p
13504@end example
13505
13506@item
13507Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
13508@example
13509[a0][a1]mergeplanes=0x00010210:yuva444p
13510@end example
13511
13512@item
13513Swap Y and A plane in yuva444p stream:
13514@example
13515format=yuva444p,mergeplanes=0x03010200:yuva444p
13516@end example
13517
13518@item
13519Swap U and V plane in yuv420p stream:
13520@example
13521format=yuv420p,mergeplanes=0x000201:yuv420p
13522@end example
13523
13524@item
13525Cast a rgb24 clip to yuv444p:
13526@example
13527format=rgb24,mergeplanes=0x000102:yuv444p
13528@end example
13529@end itemize
13530
13531@section mestimate
13532
13533Estimate and export motion vectors using block matching algorithms.
13534Motion vectors are stored in frame side data to be used by other filters.
13535
13536This filter accepts the following options:
13537@table @option
13538@item method
13539Specify the motion estimation method. Accepts one of the following values:
13540
13541@table @samp
13542@item esa
13543Exhaustive search algorithm.
13544@item tss
13545Three step search algorithm.
13546@item tdls
13547Two dimensional logarithmic search algorithm.
13548@item ntss
13549New three step search algorithm.
13550@item fss
13551Four step search algorithm.
13552@item ds
13553Diamond search algorithm.
13554@item hexbs
13555Hexagon-based search algorithm.
13556@item epzs
13557Enhanced predictive zonal search algorithm.
13558@item umh
13559Uneven multi-hexagon search algorithm.
13560@end table
13561Default value is @samp{esa}.
13562
13563@item mb_size
13564Macroblock size. Default @code{16}.
13565
13566@item search_param
13567Search parameter. Default @code{7}.
13568@end table
13569
13570@section midequalizer
13571
13572Apply Midway Image Equalization effect using two video streams.
13573
13574Midway Image Equalization adjusts a pair of images to have the same
13575histogram, while maintaining their dynamics as much as possible. It's
13576useful for e.g. matching exposures from a pair of stereo cameras.
13577
13578This filter has two inputs and one output, which must be of same pixel format, but
13579may be of different sizes. The output of filter is first input adjusted with
13580midway histogram of both inputs.
13581
13582This filter accepts the following option:
13583
13584@table @option
13585@item planes
13586Set which planes to process. Default is @code{15}, which is all available planes.
13587@end table
13588
13589@section minterpolate
13590
13591Convert the video to specified frame rate using motion interpolation.
13592
13593This filter accepts the following options:
13594@table @option
13595@item fps
13596Specify 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}.
13597
13598@item mi_mode
13599Motion interpolation mode. Following values are accepted:
13600@table @samp
13601@item dup
13602Duplicate previous or next frame for interpolating new ones.
13603@item blend
13604Blend source frames. Interpolated frame is mean of previous and next frames.
13605@item mci
13606Motion compensated interpolation. Following options are effective when this mode is selected:
13607
13608@table @samp
13609@item mc_mode
13610Motion compensation mode. Following values are accepted:
13611@table @samp
13612@item obmc
13613Overlapped block motion compensation.
13614@item aobmc
13615Adaptive overlapped block motion compensation. Window weighting coefficients are controlled adaptively according to the reliabilities of the neighboring motion vectors to reduce oversmoothing.
13616@end table
13617Default mode is @samp{obmc}.
13618
13619@item me_mode
13620Motion estimation mode. Following values are accepted:
13621@table @samp
13622@item bidir
13623Bidirectional motion estimation. Motion vectors are estimated for each source frame in both forward and backward directions.
13624@item bilat
13625Bilateral motion estimation. Motion vectors are estimated directly for interpolated frame.
13626@end table
13627Default mode is @samp{bilat}.
13628
13629@item me
13630The algorithm to be used for motion estimation. Following values are accepted:
13631@table @samp
13632@item esa
13633Exhaustive search algorithm.
13634@item tss
13635Three step search algorithm.
13636@item tdls
13637Two dimensional logarithmic search algorithm.
13638@item ntss
13639New three step search algorithm.
13640@item fss
13641Four step search algorithm.
13642@item ds
13643Diamond search algorithm.
13644@item hexbs
13645Hexagon-based search algorithm.
13646@item epzs
13647Enhanced predictive zonal search algorithm.
13648@item umh
13649Uneven multi-hexagon search algorithm.
13650@end table
13651Default algorithm is @samp{epzs}.
13652
13653@item mb_size
13654Macroblock size. Default @code{16}.
13655
13656@item search_param
13657Motion estimation search parameter. Default @code{32}.
13658
13659@item vsbmc
13660Enable 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).
13661@end table
13662@end table
13663
13664@item scd
13665Scene 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:
13666@table @samp
13667@item none
13668Disable scene change detection.
13669@item fdiff
13670Frame difference. Corresponding pixel values are compared and if it satisfies @var{scd_threshold} scene change is detected.
13671@end table
13672Default method is @samp{fdiff}.
13673
13674@item scd_threshold
13675Scene change detection threshold. Default is @code{10.}.
13676@end table
13677
13678@section mix
13679
13680Mix several video input streams into one video stream.
13681
13682A description of the accepted options follows.
13683
13684@table @option
13685@item nb_inputs
13686The number of inputs. If unspecified, it defaults to 2.
13687
13688@item weights
13689Specify weight of each input video stream as sequence.
13690Each weight is separated by space. If number of weights
13691is smaller than number of @var{frames} last specified
13692weight will be used for all remaining unset weights.
13693
13694@item scale
13695Specify scale, if it is set it will be multiplied with sum
13696of each weight multiplied with pixel values to give final destination
13697pixel value. By default @var{scale} is auto scaled to sum of weights.
13698
13699@item duration
13700Specify how end of stream is determined.
13701@table @samp
13702@item longest
13703The duration of the longest input. (default)
13704
13705@item shortest
13706The duration of the shortest input.
13707
13708@item first
13709The duration of the first input.
13710@end table
13711@end table
13712
13713@section mpdecimate
13714
13715Drop frames that do not differ greatly from the previous frame in
13716order to reduce frame rate.
13717
13718The main use of this filter is for very-low-bitrate encoding
13719(e.g. streaming over dialup modem), but it could in theory be used for
13720fixing movies that were inverse-telecined incorrectly.
13721
13722A description of the accepted options follows.
13723
13724@table @option
13725@item max
13726Set the maximum number of consecutive frames which can be dropped (if
13727positive), or the minimum interval between dropped frames (if
13728negative). If the value is 0, the frame is dropped disregarding the
13729number of previous sequentially dropped frames.
13730
13731Default value is 0.
13732
13733@item hi
13734@item lo
13735@item frac
13736Set the dropping threshold values.
13737
13738Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
13739represent actual pixel value differences, so a threshold of 64
13740corresponds to 1 unit of difference for each pixel, or the same spread
13741out differently over the block.
13742
13743A frame is a candidate for dropping if no 8x8 blocks differ by more
13744than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
13745meaning the whole image) differ by more than a threshold of @option{lo}.
13746
13747Default value for @option{hi} is 64*12, default value for @option{lo} is
1374864*5, and default value for @option{frac} is 0.33.
13749@end table
13750
13751
13752@section negate
13753
13754Negate (invert) the input video.
13755
13756It accepts the following option:
13757
13758@table @option
13759
13760@item negate_alpha
13761With value 1, it negates the alpha component, if present. Default value is 0.
13762@end table
13763
13764@anchor{nlmeans}
13765@section nlmeans
13766
13767Denoise frames using Non-Local Means algorithm.
13768
13769Each pixel is adjusted by looking for other pixels with similar contexts. This
13770context similarity is defined by comparing their surrounding patches of size
13771@option{p}x@option{p}. Patches are searched in an area of @option{r}x@option{r}
13772around the pixel.
13773
13774Note that the research area defines centers for patches, which means some
13775patches will be made of pixels outside that research area.
13776
13777The filter accepts the following options.
13778
13779@table @option
13780@item s
13781Set denoising strength. Default is 1.0. Must be in range [1.0, 30.0].
13782
13783@item p
13784Set patch size. Default is 7. Must be odd number in range [0, 99].
13785
13786@item pc
13787Same as @option{p} but for chroma planes.
13788
13789The default value is @var{0} and means automatic.
13790
13791@item r
13792Set research size. Default is 15. Must be odd number in range [0, 99].
13793
13794@item rc
13795Same as @option{r} but for chroma planes.
13796
13797The default value is @var{0} and means automatic.
13798@end table
13799
13800@section nnedi
13801
13802Deinterlace video using neural network edge directed interpolation.
13803
13804This filter accepts the following options:
13805
13806@table @option
13807@item weights
13808Mandatory option, without binary file filter can not work.
13809Currently file can be found here:
13810https://github.com/dubhater/vapoursynth-nnedi3/blob/master/src/nnedi3_weights.bin
13811
13812@item deint
13813Set which frames to deinterlace, by default it is @code{all}.
13814Can be @code{all} or @code{interlaced}.
13815
13816@item field
13817Set mode of operation.
13818
13819Can be one of the following:
13820
13821@table @samp
13822@item af
13823Use frame flags, both fields.
13824@item a
13825Use frame flags, single field.
13826@item t
13827Use top field only.
13828@item b
13829Use bottom field only.
13830@item tf
13831Use both fields, top first.
13832@item bf
13833Use both fields, bottom first.
13834@end table
13835
13836@item planes
13837Set which planes to process, by default filter process all frames.
13838
13839@item nsize
13840Set size of local neighborhood around each pixel, used by the predictor neural
13841network.
13842
13843Can be one of the following:
13844
13845@table @samp
13846@item s8x6
13847@item s16x6
13848@item s32x6
13849@item s48x6
13850@item s8x4
13851@item s16x4
13852@item s32x4
13853@end table
13854
13855@item nns
13856Set the number of neurons in predictor neural network.
13857Can be one of the following:
13858
13859@table @samp
13860@item n16
13861@item n32
13862@item n64
13863@item n128
13864@item n256
13865@end table
13866
13867@item qual
13868Controls the number of different neural network predictions that are blended
13869together to compute the final output value. Can be @code{fast}, default or
13870@code{slow}.
13871
13872@item etype
13873Set which set of weights to use in the predictor.
13874Can be one of the following:
13875
13876@table @samp
13877@item a
13878weights trained to minimize absolute error
13879@item s
13880weights trained to minimize squared error
13881@end table
13882
13883@item pscrn
13884Controls whether or not the prescreener neural network is used to decide
13885which pixels should be processed by the predictor neural network and which
13886can be handled by simple cubic interpolation.
13887The prescreener is trained to know whether cubic interpolation will be
13888sufficient for a pixel or whether it should be predicted by the predictor nn.
13889The computational complexity of the prescreener nn is much less than that of
13890the predictor nn. Since most pixels can be handled by cubic interpolation,
13891using the prescreener generally results in much faster processing.
13892The prescreener is pretty accurate, so the difference between using it and not
13893using it is almost always unnoticeable.
13894
13895Can be one of the following:
13896
13897@table @samp
13898@item none
13899@item original
13900@item new
13901@end table
13902
13903Default is @code{new}.
13904
13905@item fapprox
13906Set various debugging flags.
13907@end table
13908
13909@section noformat
13910
13911Force libavfilter not to use any of the specified pixel formats for the
13912input to the next filter.
13913
13914It accepts the following parameters:
13915@table @option
13916
13917@item pix_fmts
13918A '|'-separated list of pixel format names, such as
13919pix_fmts=yuv420p|monow|rgb24".
13920
13921@end table
13922
13923@subsection Examples
13924
13925@itemize
13926@item
13927Force libavfilter to use a format different from @var{yuv420p} for the
13928input to the vflip filter:
13929@example
13930noformat=pix_fmts=yuv420p,vflip
13931@end example
13932
13933@item
13934Convert the input video to any of the formats not contained in the list:
13935@example
13936noformat=yuv420p|yuv444p|yuv410p
13937@end example
13938@end itemize
13939
13940@section noise
13941
13942Add noise on video input frame.
13943
13944The filter accepts the following options:
13945
13946@table @option
13947@item all_seed
13948@item c0_seed
13949@item c1_seed
13950@item c2_seed
13951@item c3_seed
13952Set noise seed for specific pixel component or all pixel components in case
13953of @var{all_seed}. Default value is @code{123457}.
13954
13955@item all_strength, alls
13956@item c0_strength, c0s
13957@item c1_strength, c1s
13958@item c2_strength, c2s
13959@item c3_strength, c3s
13960Set noise strength for specific pixel component or all pixel components in case
13961@var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
13962
13963@item all_flags, allf
13964@item c0_flags, c0f
13965@item c1_flags, c1f
13966@item c2_flags, c2f
13967@item c3_flags, c3f
13968Set pixel component flags or set flags for all components if @var{all_flags}.
13969Available values for component flags are:
13970@table @samp
13971@item a
13972averaged temporal noise (smoother)
13973@item p
13974mix random noise with a (semi)regular pattern
13975@item t
13976temporal noise (noise pattern changes between frames)
13977@item u
13978uniform noise (gaussian otherwise)
13979@end table
13980@end table
13981
13982@subsection Examples
13983
13984Add temporal and uniform noise to input video:
13985@example
13986noise=alls=20:allf=t+u
13987@end example
13988
13989@section normalize
13990
13991Normalize RGB video (aka histogram stretching, contrast stretching).
13992See: https://en.wikipedia.org/wiki/Normalization_(image_processing)
13993
13994For each channel of each frame, the filter computes the input range and maps
13995it linearly to the user-specified output range. The output range defaults
13996to the full dynamic range from pure black to pure white.
13997
13998Temporal smoothing can be used on the input range to reduce flickering (rapid
13999changes in brightness) caused when small dark or bright objects enter or leave
14000the scene. This is similar to the auto-exposure (automatic gain control) on a
14001video camera, and, like a video camera, it may cause a period of over- or
14002under-exposure of the video.
14003
14004The R,G,B channels can be normalized independently, which may cause some
14005color shifting, or linked together as a single channel, which prevents
14006color shifting. Linked normalization preserves hue. Independent normalization
14007does not, so it can be used to remove some color casts. Independent and linked
14008normalization can be combined in any ratio.
14009
14010The normalize filter accepts the following options:
14011
14012@table @option
14013@item blackpt
14014@item whitept
14015Colors which define the output range. The minimum input value is mapped to
14016the @var{blackpt}. The maximum input value is mapped to the @var{whitept}.
14017The defaults are black and white respectively. Specifying white for
14018@var{blackpt} and black for @var{whitept} will give color-inverted,
14019normalized video. Shades of grey can be used to reduce the dynamic range
14020(contrast). Specifying saturated colors here can create some interesting
14021effects.
14022
14023@item smoothing
14024The number of previous frames to use for temporal smoothing. The input range
14025of each channel is smoothed using a rolling average over the current frame
14026and the @var{smoothing} previous frames. The default is 0 (no temporal
14027smoothing).
14028
14029@item independence
14030Controls the ratio of independent (color shifting) channel normalization to
14031linked (color preserving) normalization. 0.0 is fully linked, 1.0 is fully
14032independent. Defaults to 1.0 (fully independent).
14033
14034@item strength
14035Overall strength of the filter. 1.0 is full strength. 0.0 is a rather
14036expensive no-op. Defaults to 1.0 (full strength).
14037
14038@end table
14039
14040@subsection Commands
14041This filter supports same @ref{commands} as options, excluding @var{smoothing} option.
14042The command accepts the same syntax of the corresponding option.
14043
14044If the specified expression is not valid, it is kept at its current
14045value.
14046
14047@subsection Examples
14048
14049Stretch video contrast to use the full dynamic range, with no temporal
14050smoothing; may flicker depending on the source content:
14051@example
14052normalize=blackpt=black:whitept=white:smoothing=0
14053@end example
14054
14055As above, but with 50 frames of temporal smoothing; flicker should be
14056reduced, depending on the source content:
14057@example
14058normalize=blackpt=black:whitept=white:smoothing=50
14059@end example
14060
14061As above, but with hue-preserving linked channel normalization:
14062@example
14063normalize=blackpt=black:whitept=white:smoothing=50:independence=0
14064@end example
14065
14066As above, but with half strength:
14067@example
14068normalize=blackpt=black:whitept=white:smoothing=50:independence=0:strength=0.5
14069@end example
14070
14071Map the darkest input color to red, the brightest input color to cyan:
14072@example
14073normalize=blackpt=red:whitept=cyan
14074@end example
14075
14076@section null
14077
14078Pass the video source unchanged to the output.
14079
14080@section ocr
14081Optical Character Recognition
14082
14083This filter uses Tesseract for optical character recognition. To enable
14084compilation of this filter, you need to configure FFmpeg with
14085@code{--enable-libtesseract}.
14086
14087It accepts the following options:
14088
14089@table @option
14090@item datapath
14091Set datapath to tesseract data. Default is to use whatever was
14092set at installation.
14093
14094@item language
14095Set language, default is "eng".
14096
14097@item whitelist
14098Set character whitelist.
14099
14100@item blacklist
14101Set character blacklist.
14102@end table
14103
14104The filter exports recognized text as the frame metadata @code{lavfi.ocr.text}.
14105The filter exports confidence of recognized words as the frame metadata @code{lavfi.ocr.confidence}.
14106
14107@section ocv
14108
14109Apply a video transform using libopencv.
14110
14111To enable this filter, install the libopencv library and headers and
14112configure FFmpeg with @code{--enable-libopencv}.
14113
14114It accepts the following parameters:
14115
14116@table @option
14117
14118@item filter_name
14119The name of the libopencv filter to apply.
14120
14121@item filter_params
14122The parameters to pass to the libopencv filter. If not specified, the default
14123values are assumed.
14124
14125@end table
14126
14127Refer to the official libopencv documentation for more precise
14128information:
14129@url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
14130
14131Several libopencv filters are supported; see the following subsections.
14132
14133@anchor{dilate}
14134@subsection dilate
14135
14136Dilate an image by using a specific structuring element.
14137It corresponds to the libopencv function @code{cvDilate}.
14138
14139It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
14140
14141@var{struct_el} represents a structuring element, and has the syntax:
14142@var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
14143
14144@var{cols} and @var{rows} represent the number of columns and rows of
14145the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
14146point, and @var{shape} the shape for the structuring element. @var{shape}
14147must be "rect", "cross", "ellipse", or "custom".
14148
14149If the value for @var{shape} is "custom", it must be followed by a
14150string of the form "=@var{filename}". The file with name
14151@var{filename} is assumed to represent a binary image, with each
14152printable character corresponding to a bright pixel. When a custom
14153@var{shape} is used, @var{cols} and @var{rows} are ignored, the number
14154or columns and rows of the read file are assumed instead.
14155
14156The default value for @var{struct_el} is "3x3+0x0/rect".
14157
14158@var{nb_iterations} specifies the number of times the transform is
14159applied to the image, and defaults to 1.
14160
14161Some examples:
14162@example
14163# Use the default values
14164ocv=dilate
14165
14166# Dilate using a structuring element with a 5x5 cross, iterating two times
14167ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
14168
14169# Read the shape from the file diamond.shape, iterating two times.
14170# The file diamond.shape may contain a pattern of characters like this
14171#   *
14172#  ***
14173# *****
14174#  ***
14175#   *
14176# The specified columns and rows are ignored
14177# but the anchor point coordinates are not
14178ocv=dilate:0x0+2x2/custom=diamond.shape|2
14179@end example
14180
14181@subsection erode
14182
14183Erode an image by using a specific structuring element.
14184It corresponds to the libopencv function @code{cvErode}.
14185
14186It accepts the parameters: @var{struct_el}:@var{nb_iterations},
14187with the same syntax and semantics as the @ref{dilate} filter.
14188
14189@subsection smooth
14190
14191Smooth the input video.
14192
14193The filter takes the following parameters:
14194@var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
14195
14196@var{type} is the type of smooth filter to apply, and must be one of
14197the following values: "blur", "blur_no_scale", "median", "gaussian",
14198or "bilateral". The default value is "gaussian".
14199
14200The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
14201depends on the smooth type. @var{param1} and
14202@var{param2} accept integer positive values or 0. @var{param3} and
14203@var{param4} accept floating point values.
14204
14205The default value for @var{param1} is 3. The default value for the
14206other parameters is 0.
14207
14208These parameters correspond to the parameters assigned to the
14209libopencv function @code{cvSmooth}.
14210
14211@section oscilloscope
14212
142132D Video Oscilloscope.
14214
14215Useful to measure spatial impulse, step responses, chroma delays, etc.
14216
14217It accepts the following parameters:
14218
14219@table @option
14220@item x
14221Set scope center x position.
14222
14223@item y
14224Set scope center y position.
14225
14226@item s
14227Set scope size, relative to frame diagonal.
14228
14229@item t
14230Set scope tilt/rotation.
14231
14232@item o
14233Set trace opacity.
14234
14235@item tx
14236Set trace center x position.
14237
14238@item ty
14239Set trace center y position.
14240
14241@item tw
14242Set trace width, relative to width of frame.
14243
14244@item th
14245Set trace height, relative to height of frame.
14246
14247@item c
14248Set which components to trace. By default it traces first three components.
14249
14250@item g
14251Draw trace grid. By default is enabled.
14252
14253@item st
14254Draw some statistics. By default is enabled.
14255
14256@item sc
14257Draw scope. By default is enabled.
14258@end table
14259
14260@subsection Commands
14261This filter supports same @ref{commands} as options.
14262The command accepts the same syntax of the corresponding option.
14263
14264If the specified expression is not valid, it is kept at its current
14265value.
14266
14267@subsection Examples
14268
14269@itemize
14270@item
14271Inspect full first row of video frame.
14272@example
14273oscilloscope=x=0.5:y=0:s=1
14274@end example
14275
14276@item
14277Inspect full last row of video frame.
14278@example
14279oscilloscope=x=0.5:y=1:s=1
14280@end example
14281
14282@item
14283Inspect full 5th line of video frame of height 1080.
14284@example
14285oscilloscope=x=0.5:y=5/1080:s=1
14286@end example
14287
14288@item
14289Inspect full last column of video frame.
14290@example
14291oscilloscope=x=1:y=0.5:s=1:t=1
14292@end example
14293
14294@end itemize
14295
14296@anchor{overlay}
14297@section overlay
14298
14299Overlay one video on top of another.
14300
14301It takes two inputs and has one output. The first input is the "main"
14302video on which the second input is overlaid.
14303
14304It accepts the following parameters:
14305
14306A description of the accepted options follows.
14307
14308@table @option
14309@item x
14310@item y
14311Set the expression for the x and y coordinates of the overlaid video
14312on the main video. Default value is "0" for both expressions. In case
14313the expression is invalid, it is set to a huge value (meaning that the
14314overlay will not be displayed within the output visible area).
14315
14316@item eof_action
14317See @ref{framesync}.
14318
14319@item eval
14320Set when the expressions for @option{x}, and @option{y} are evaluated.
14321
14322It accepts the following values:
14323@table @samp
14324@item init
14325only evaluate expressions once during the filter initialization or
14326when a command is processed
14327
14328@item frame
14329evaluate expressions for each incoming frame
14330@end table
14331
14332Default value is @samp{frame}.
14333
14334@item shortest
14335See @ref{framesync}.
14336
14337@item format
14338Set the format for the output video.
14339
14340It accepts the following values:
14341@table @samp
14342@item yuv420
14343force YUV420 output
14344
14345@item yuv422
14346force YUV422 output
14347
14348@item yuv444
14349force YUV444 output
14350
14351@item rgb
14352force packed RGB output
14353
14354@item gbrp
14355force planar RGB output
14356
14357@item auto
14358automatically pick format
14359@end table
14360
14361Default value is @samp{yuv420}.
14362
14363@item repeatlast
14364See @ref{framesync}.
14365
14366@item alpha
14367Set format of alpha of the overlaid video, it can be @var{straight} or
14368@var{premultiplied}. Default is @var{straight}.
14369@end table
14370
14371The @option{x}, and @option{y} expressions can contain the following
14372parameters.
14373
14374@table @option
14375@item main_w, W
14376@item main_h, H
14377The main input width and height.
14378
14379@item overlay_w, w
14380@item overlay_h, h
14381The overlay input width and height.
14382
14383@item x
14384@item y
14385The computed values for @var{x} and @var{y}. They are evaluated for
14386each new frame.
14387
14388@item hsub
14389@item vsub
14390horizontal and vertical chroma subsample values of the output
14391format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
14392@var{vsub} is 1.
14393
14394@item n
14395the number of input frame, starting from 0
14396
14397@item pos
14398the position in the file of the input frame, NAN if unknown
14399
14400@item t
14401The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
14402
14403@end table
14404
14405This filter also supports the @ref{framesync} options.
14406
14407Note that the @var{n}, @var{pos}, @var{t} variables are available only
14408when evaluation is done @emph{per frame}, and will evaluate to NAN
14409when @option{eval} is set to @samp{init}.
14410
14411Be aware that frames are taken from each input video in timestamp
14412order, hence, if their initial timestamps differ, it is a good idea
14413to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
14414have them begin in the same zero timestamp, as the example for
14415the @var{movie} filter does.
14416
14417You can chain together more overlays but you should test the
14418efficiency of such approach.
14419
14420@subsection Commands
14421
14422This filter supports the following commands:
14423@table @option
14424@item x
14425@item y
14426Modify the x and y of the overlay input.
14427The command accepts the same syntax of the corresponding option.
14428
14429If the specified expression is not valid, it is kept at its current
14430value.
14431@end table
14432
14433@subsection Examples
14434
14435@itemize
14436@item
14437Draw the overlay at 10 pixels from the bottom right corner of the main
14438video:
14439@example
14440overlay=main_w-overlay_w-10:main_h-overlay_h-10
14441@end example
14442
14443Using named options the example above becomes:
14444@example
14445overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
14446@end example
14447
14448@item
14449Insert a transparent PNG logo in the bottom left corner of the input,
14450using the @command{ffmpeg} tool with the @code{-filter_complex} option:
14451@example
14452ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
14453@end example
14454
14455@item
14456Insert 2 different transparent PNG logos (second logo on bottom
14457right corner) using the @command{ffmpeg} tool:
14458@example
14459ffmpeg -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
14460@end example
14461
14462@item
14463Add a transparent color layer on top of the main video; @code{WxH}
14464must specify the size of the main input to the overlay filter:
14465@example
14466color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
14467@end example
14468
14469@item
14470Play an original video and a filtered version (here with the deshake
14471filter) side by side using the @command{ffplay} tool:
14472@example
14473ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
14474@end example
14475
14476The above command is the same as:
14477@example
14478ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
14479@end example
14480
14481@item
14482Make a sliding overlay appearing from the left to the right top part of the
14483screen starting since time 2:
14484@example
14485overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
14486@end example
14487
14488@item
14489Compose output by putting two input videos side to side:
14490@example
14491ffmpeg -i left.avi -i right.avi -filter_complex "
14492nullsrc=size=200x100 [background];
14493[0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
14494[1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
14495[background][left]       overlay=shortest=1       [background+left];
14496[background+left][right] overlay=shortest=1:x=100 [left+right]
14497"
14498@end example
14499
14500@item
14501Mask 10-20 seconds of a video by applying the delogo filter to a section
14502@example
14503ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
14504-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]'
14505masked.avi
14506@end example
14507
14508@item
14509Chain several overlays in cascade:
14510@example
14511nullsrc=s=200x200 [bg];
14512testsrc=s=100x100, split=4 [in0][in1][in2][in3];
14513[in0] lutrgb=r=0, [bg]   overlay=0:0     [mid0];
14514[in1] lutrgb=g=0, [mid0] overlay=100:0   [mid1];
14515[in2] lutrgb=b=0, [mid1] overlay=0:100   [mid2];
14516[in3] null,       [mid2] overlay=100:100 [out0]
14517@end example
14518
14519@end itemize
14520
14521@anchor{overlay_cuda}
14522@section overlay_cuda
14523
14524Overlay one video on top of another.
14525
14526This is the CUDA cariant of the @ref{overlay} filter.
14527It only accepts CUDA frames. The underlying input pixel formats have to match.
14528
14529It takes two inputs and has one output. The first input is the "main"
14530video on which the second input is overlaid.
14531
14532It accepts the following parameters:
14533
14534@table @option
14535@item x
14536@item y
14537Set the x and y coordinates of the overlaid video on the main video.
14538Default value is "0" for both expressions.
14539
14540@item eof_action
14541See @ref{framesync}.
14542
14543@item shortest
14544See @ref{framesync}.
14545
14546@item repeatlast
14547See @ref{framesync}.
14548
14549@end table
14550
14551This filter also supports the @ref{framesync} options.
14552
14553@section owdenoise
14554
14555Apply Overcomplete Wavelet denoiser.
14556
14557The filter accepts the following options:
14558
14559@table @option
14560@item depth
14561Set depth.
14562
14563Larger depth values will denoise lower frequency components more, but
14564slow down filtering.
14565
14566Must be an int in the range 8-16, default is @code{8}.
14567
14568@item luma_strength, ls
14569Set luma strength.
14570
14571Must be a double value in the range 0-1000, default is @code{1.0}.
14572
14573@item chroma_strength, cs
14574Set chroma strength.
14575
14576Must be a double value in the range 0-1000, default is @code{1.0}.
14577@end table
14578
14579@anchor{pad}
14580@section pad
14581
14582Add paddings to the input image, and place the original input at the
14583provided @var{x}, @var{y} coordinates.
14584
14585It accepts the following parameters:
14586
14587@table @option
14588@item width, w
14589@item height, h
14590Specify an expression for the size of the output image with the
14591paddings added. If the value for @var{width} or @var{height} is 0, the
14592corresponding input size is used for the output.
14593
14594The @var{width} expression can reference the value set by the
14595@var{height} expression, and vice versa.
14596
14597The default value of @var{width} and @var{height} is 0.
14598
14599@item x
14600@item y
14601Specify the offsets to place the input image at within the padded area,
14602with respect to the top/left border of the output image.
14603
14604The @var{x} expression can reference the value set by the @var{y}
14605expression, and vice versa.
14606
14607The default value of @var{x} and @var{y} is 0.
14608
14609If @var{x} or @var{y} evaluate to a negative number, they'll be changed
14610so the input image is centered on the padded area.
14611
14612@item color
14613Specify the color of the padded area. For the syntax of this option,
14614check the @ref{color syntax,,"Color" section in the ffmpeg-utils
14615manual,ffmpeg-utils}.
14616
14617The default value of @var{color} is "black".
14618
14619@item eval
14620Specify when to evaluate  @var{width}, @var{height}, @var{x} and @var{y} expression.
14621
14622It accepts the following values:
14623
14624@table @samp
14625@item init
14626Only evaluate expressions once during the filter initialization or when
14627a command is processed.
14628
14629@item frame
14630Evaluate expressions for each incoming frame.
14631
14632@end table
14633
14634Default value is @samp{init}.
14635
14636@item aspect
14637Pad to aspect instead to a resolution.
14638
14639@end table
14640
14641The value for the @var{width}, @var{height}, @var{x}, and @var{y}
14642options are expressions containing the following constants:
14643
14644@table @option
14645@item in_w
14646@item in_h
14647The input video width and height.
14648
14649@item iw
14650@item ih
14651These are the same as @var{in_w} and @var{in_h}.
14652
14653@item out_w
14654@item out_h
14655The output width and height (the size of the padded area), as
14656specified by the @var{width} and @var{height} expressions.
14657
14658@item ow
14659@item oh
14660These are the same as @var{out_w} and @var{out_h}.
14661
14662@item x
14663@item y
14664The x and y offsets as specified by the @var{x} and @var{y}
14665expressions, or NAN if not yet specified.
14666
14667@item a
14668same as @var{iw} / @var{ih}
14669
14670@item sar
14671input sample aspect ratio
14672
14673@item dar
14674input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
14675
14676@item hsub
14677@item vsub
14678The horizontal and vertical chroma subsample values. For example for the
14679pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
14680@end table
14681
14682@subsection Examples
14683
14684@itemize
14685@item
14686Add paddings with the color "violet" to the input video. The output video
14687size is 640x480, and the top-left corner of the input video is placed at
14688column 0, row 40
14689@example
14690pad=640:480:0:40:violet
14691@end example
14692
14693The example above is equivalent to the following command:
14694@example
14695pad=width=640:height=480:x=0:y=40:color=violet
14696@end example
14697
14698@item
14699Pad the input to get an output with dimensions increased by 3/2,
14700and put the input video at the center of the padded area:
14701@example
14702pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
14703@end example
14704
14705@item
14706Pad the input to get a squared output with size equal to the maximum
14707value between the input width and height, and put the input video at
14708the center of the padded area:
14709@example
14710pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
14711@end example
14712
14713@item
14714Pad the input to get a final w/h ratio of 16:9:
14715@example
14716pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
14717@end example
14718
14719@item
14720In case of anamorphic video, in order to set the output display aspect
14721correctly, it is necessary to use @var{sar} in the expression,
14722according to the relation:
14723@example
14724(ih * X / ih) * sar = output_dar
14725X = output_dar / sar
14726@end example
14727
14728Thus the previous example needs to be modified to:
14729@example
14730pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
14731@end example
14732
14733@item
14734Double the output size and put the input video in the bottom-right
14735corner of the output padded area:
14736@example
14737pad="2*iw:2*ih:ow-iw:oh-ih"
14738@end example
14739@end itemize
14740
14741@anchor{palettegen}
14742@section palettegen
14743
14744Generate one palette for a whole video stream.
14745
14746It accepts the following options:
14747
14748@table @option
14749@item max_colors
14750Set the maximum number of colors to quantize in the palette.
14751Note: the palette will still contain 256 colors; the unused palette entries
14752will be black.
14753
14754@item reserve_transparent
14755Create a palette of 255 colors maximum and reserve the last one for
14756transparency. Reserving the transparency color is useful for GIF optimization.
14757If not set, the maximum of colors in the palette will be 256. You probably want
14758to disable this option for a standalone image.
14759Set by default.
14760
14761@item transparency_color
14762Set the color that will be used as background for transparency.
14763
14764@item stats_mode
14765Set statistics mode.
14766
14767It accepts the following values:
14768@table @samp
14769@item full
14770Compute full frame histograms.
14771@item diff
14772Compute histograms only for the part that differs from previous frame. This
14773might be relevant to give more importance to the moving part of your input if
14774the background is static.
14775@item single
14776Compute new histogram for each frame.
14777@end table
14778
14779Default value is @var{full}.
14780@end table
14781
14782The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
14783(@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
14784color quantization of the palette. This information is also visible at
14785@var{info} logging level.
14786
14787@subsection Examples
14788
14789@itemize
14790@item
14791Generate a representative palette of a given video using @command{ffmpeg}:
14792@example
14793ffmpeg -i input.mkv -vf palettegen palette.png
14794@end example
14795@end itemize
14796
14797@section paletteuse
14798
14799Use a palette to downsample an input video stream.
14800
14801The filter takes two inputs: one video stream and a palette. The palette must
14802be a 256 pixels image.
14803
14804It accepts the following options:
14805
14806@table @option
14807@item dither
14808Select dithering mode. Available algorithms are:
14809@table @samp
14810@item bayer
14811Ordered 8x8 bayer dithering (deterministic)
14812@item heckbert
14813Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
14814Note: this dithering is sometimes considered "wrong" and is included as a
14815reference.
14816@item floyd_steinberg
14817Floyd and Steingberg dithering (error diffusion)
14818@item sierra2
14819Frankie Sierra dithering v2 (error diffusion)
14820@item sierra2_4a
14821Frankie Sierra dithering v2 "Lite" (error diffusion)
14822@end table
14823
14824Default is @var{sierra2_4a}.
14825
14826@item bayer_scale
14827When @var{bayer} dithering is selected, this option defines the scale of the
14828pattern (how much the crosshatch pattern is visible). A low value means more
14829visible pattern for less banding, and higher value means less visible pattern
14830at the cost of more banding.
14831
14832The option must be an integer value in the range [0,5]. Default is @var{2}.
14833
14834@item diff_mode
14835If set, define the zone to process
14836
14837@table @samp
14838@item rectangle
14839Only the changing rectangle will be reprocessed. This is similar to GIF
14840cropping/offsetting compression mechanism. This option can be useful for speed
14841if only a part of the image is changing, and has use cases such as limiting the
14842scope of the error diffusal @option{dither} to the rectangle that bounds the
14843moving scene (it leads to more deterministic output if the scene doesn't change
14844much, and as a result less moving noise and better GIF compression).
14845@end table
14846
14847Default is @var{none}.
14848
14849@item new
14850Take new palette for each output frame.
14851
14852@item alpha_threshold
14853Sets the alpha threshold for transparency. Alpha values above this threshold
14854will be treated as completely opaque, and values below this threshold will be
14855treated as completely transparent.
14856
14857The option must be an integer value in the range [0,255]. Default is @var{128}.
14858@end table
14859
14860@subsection Examples
14861
14862@itemize
14863@item
14864Use a palette (generated for example with @ref{palettegen}) to encode a GIF
14865using @command{ffmpeg}:
14866@example
14867ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
14868@end example
14869@end itemize
14870
14871@section perspective
14872
14873Correct perspective of video not recorded perpendicular to the screen.
14874
14875A description of the accepted parameters follows.
14876
14877@table @option
14878@item x0
14879@item y0
14880@item x1
14881@item y1
14882@item x2
14883@item y2
14884@item x3
14885@item y3
14886Set coordinates expression for top left, top right, bottom left and bottom right corners.
14887Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
14888If the @code{sense} option is set to @code{source}, then the specified points will be sent
14889to the corners of the destination. If the @code{sense} option is set to @code{destination},
14890then the corners of the source will be sent to the specified coordinates.
14891
14892The expressions can use the following variables:
14893
14894@table @option
14895@item W
14896@item H
14897the width and height of video frame.
14898@item in
14899Input frame count.
14900@item on
14901Output frame count.
14902@end table
14903
14904@item interpolation
14905Set interpolation for perspective correction.
14906
14907It accepts the following values:
14908@table @samp
14909@item linear
14910@item cubic
14911@end table
14912
14913Default value is @samp{linear}.
14914
14915@item sense
14916Set interpretation of coordinate options.
14917
14918It accepts the following values:
14919@table @samp
14920@item 0, source
14921
14922Send point in the source specified by the given coordinates to
14923the corners of the destination.
14924
14925@item 1, destination
14926
14927Send the corners of the source to the point in the destination specified
14928by the given coordinates.
14929
14930Default value is @samp{source}.
14931@end table
14932
14933@item eval
14934Set when the expressions for coordinates @option{x0,y0,...x3,y3} are evaluated.
14935
14936It accepts the following values:
14937@table @samp
14938@item init
14939only evaluate expressions once during the filter initialization or
14940when a command is processed
14941
14942@item frame
14943evaluate expressions for each incoming frame
14944@end table
14945
14946Default value is @samp{init}.
14947@end table
14948
14949@section phase
14950
14951Delay interlaced video by one field time so that the field order changes.
14952
14953The intended use is to fix PAL movies that have been captured with the
14954opposite field order to the film-to-video transfer.
14955
14956A description of the accepted parameters follows.
14957
14958@table @option
14959@item mode
14960Set phase mode.
14961
14962It accepts the following values:
14963@table @samp
14964@item t
14965Capture field order top-first, transfer bottom-first.
14966Filter will delay the bottom field.
14967
14968@item b
14969Capture field order bottom-first, transfer top-first.
14970Filter will delay the top field.
14971
14972@item p
14973Capture and transfer with the same field order. This mode only exists
14974for the documentation of the other options to refer to, but if you
14975actually select it, the filter will faithfully do nothing.
14976
14977@item a
14978Capture field order determined automatically by field flags, transfer
14979opposite.
14980Filter selects among @samp{t} and @samp{b} modes on a frame by frame
14981basis using field flags. If no field information is available,
14982then this works just like @samp{u}.
14983
14984@item u
14985Capture unknown or varying, transfer opposite.
14986Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
14987analyzing the images and selecting the alternative that produces best
14988match between the fields.
14989
14990@item T
14991Capture top-first, transfer unknown or varying.
14992Filter selects among @samp{t} and @samp{p} using image analysis.
14993
14994@item B
14995Capture bottom-first, transfer unknown or varying.
14996Filter selects among @samp{b} and @samp{p} using image analysis.
14997
14998@item A
14999Capture determined by field flags, transfer unknown or varying.
15000Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
15001image analysis. If no field information is available, then this works just
15002like @samp{U}. This is the default mode.
15003
15004@item U
15005Both capture and transfer unknown or varying.
15006Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
15007@end table
15008@end table
15009
15010@section photosensitivity
15011Reduce various flashes in video, so to help users with epilepsy.
15012
15013It accepts the following options:
15014@table @option
15015@item frames, f
15016Set how many frames to use when filtering. Default is 30.
15017
15018@item threshold, t
15019Set detection threshold factor. Default is 1.
15020Lower is stricter.
15021
15022@item skip
15023Set how many pixels to skip when sampling frames. Default is 1.
15024Allowed range is from 1 to 1024.
15025
15026@item bypass
15027Leave frames unchanged. Default is disabled.
15028@end table
15029
15030@section pixdesctest
15031
15032Pixel format descriptor test filter, mainly useful for internal
15033testing. The output video should be equal to the input video.
15034
15035For example:
15036@example
15037format=monow, pixdesctest
15038@end example
15039
15040can be used to test the monowhite pixel format descriptor definition.
15041
15042@section pixscope
15043
15044Display sample values of color channels. Mainly useful for checking color
15045and levels. Minimum supported resolution is 640x480.
15046
15047The filters accept the following options:
15048
15049@table @option
15050@item x
15051Set scope X position, relative offset on X axis.
15052
15053@item y
15054Set scope Y position, relative offset on Y axis.
15055
15056@item w
15057Set scope width.
15058
15059@item h
15060Set scope height.
15061
15062@item o
15063Set window opacity. This window also holds statistics about pixel area.
15064
15065@item wx
15066Set window X position, relative offset on X axis.
15067
15068@item wy
15069Set window Y position, relative offset on Y axis.
15070@end table
15071
15072@section pp
15073
15074Enable the specified chain of postprocessing subfilters using libpostproc. This
15075library should be automatically selected with a GPL build (@code{--enable-gpl}).
15076Subfilters must be separated by '/' and can be disabled by prepending a '-'.
15077Each subfilter and some options have a short and a long name that can be used
15078interchangeably, i.e. dr/dering are the same.
15079
15080The filters accept the following options:
15081
15082@table @option
15083@item subfilters
15084Set postprocessing subfilters string.
15085@end table
15086
15087All subfilters share common options to determine their scope:
15088
15089@table @option
15090@item a/autoq
15091Honor the quality commands for this subfilter.
15092
15093@item c/chrom
15094Do chrominance filtering, too (default).
15095
15096@item y/nochrom
15097Do luminance filtering only (no chrominance).
15098
15099@item n/noluma
15100Do chrominance filtering only (no luminance).
15101@end table
15102
15103These options can be appended after the subfilter name, separated by a '|'.
15104
15105Available subfilters are:
15106
15107@table @option
15108@item hb/hdeblock[|difference[|flatness]]
15109Horizontal deblocking filter
15110@table @option
15111@item difference
15112Difference factor where higher values mean more deblocking (default: @code{32}).
15113@item flatness
15114Flatness threshold where lower values mean more deblocking (default: @code{39}).
15115@end table
15116
15117@item vb/vdeblock[|difference[|flatness]]
15118Vertical deblocking filter
15119@table @option
15120@item difference
15121Difference factor where higher values mean more deblocking (default: @code{32}).
15122@item flatness
15123Flatness threshold where lower values mean more deblocking (default: @code{39}).
15124@end table
15125
15126@item ha/hadeblock[|difference[|flatness]]
15127Accurate horizontal deblocking filter
15128@table @option
15129@item difference
15130Difference factor where higher values mean more deblocking (default: @code{32}).
15131@item flatness
15132Flatness threshold where lower values mean more deblocking (default: @code{39}).
15133@end table
15134
15135@item va/vadeblock[|difference[|flatness]]
15136Accurate vertical deblocking filter
15137@table @option
15138@item difference
15139Difference factor where higher values mean more deblocking (default: @code{32}).
15140@item flatness
15141Flatness threshold where lower values mean more deblocking (default: @code{39}).
15142@end table
15143@end table
15144
15145The horizontal and vertical deblocking filters share the difference and
15146flatness values so you cannot set different horizontal and vertical
15147thresholds.
15148
15149@table @option
15150@item h1/x1hdeblock
15151Experimental horizontal deblocking filter
15152
15153@item v1/x1vdeblock
15154Experimental vertical deblocking filter
15155
15156@item dr/dering
15157Deringing filter
15158
15159@item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
15160@table @option
15161@item threshold1
15162larger -> stronger filtering
15163@item threshold2
15164larger -> stronger filtering
15165@item threshold3
15166larger -> stronger filtering
15167@end table
15168
15169@item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
15170@table @option
15171@item f/fullyrange
15172Stretch luminance to @code{0-255}.
15173@end table
15174
15175@item lb/linblenddeint
15176Linear blend deinterlacing filter that deinterlaces the given block by
15177filtering all lines with a @code{(1 2 1)} filter.
15178
15179@item li/linipoldeint
15180Linear interpolating deinterlacing filter that deinterlaces the given block by
15181linearly interpolating every second line.
15182
15183@item ci/cubicipoldeint
15184Cubic interpolating deinterlacing filter deinterlaces the given block by
15185cubically interpolating every second line.
15186
15187@item md/mediandeint
15188Median deinterlacing filter that deinterlaces the given block by applying a
15189median filter to every second line.
15190
15191@item fd/ffmpegdeint
15192FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
15193second line with a @code{(-1 4 2 4 -1)} filter.
15194
15195@item l5/lowpass5
15196Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
15197block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
15198
15199@item fq/forceQuant[|quantizer]
15200Overrides the quantizer table from the input with the constant quantizer you
15201specify.
15202@table @option
15203@item quantizer
15204Quantizer to use
15205@end table
15206
15207@item de/default
15208Default pp filter combination (@code{hb|a,vb|a,dr|a})
15209
15210@item fa/fast
15211Fast pp filter combination (@code{h1|a,v1|a,dr|a})
15212
15213@item ac
15214High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
15215@end table
15216
15217@subsection Examples
15218
15219@itemize
15220@item
15221Apply horizontal and vertical deblocking, deringing and automatic
15222brightness/contrast:
15223@example
15224pp=hb/vb/dr/al
15225@end example
15226
15227@item
15228Apply default filters without brightness/contrast correction:
15229@example
15230pp=de/-al
15231@end example
15232
15233@item
15234Apply default filters and temporal denoiser:
15235@example
15236pp=default/tmpnoise|1|2|3
15237@end example
15238
15239@item
15240Apply deblocking on luminance only, and switch vertical deblocking on or off
15241automatically depending on available CPU time:
15242@example
15243pp=hb|y/vb|a
15244@end example
15245@end itemize
15246
15247@section pp7
15248Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
15249similar to spp = 6 with 7 point DCT, where only the center sample is
15250used after IDCT.
15251
15252The filter accepts the following options:
15253
15254@table @option
15255@item qp
15256Force a constant quantization parameter. It accepts an integer in range
152570 to 63. If not set, the filter will use the QP from the video stream
15258(if available).
15259
15260@item mode
15261Set thresholding mode. Available modes are:
15262
15263@table @samp
15264@item hard
15265Set hard thresholding.
15266@item soft
15267Set soft thresholding (better de-ringing effect, but likely blurrier).
15268@item medium
15269Set medium thresholding (good results, default).
15270@end table
15271@end table
15272
15273@section premultiply
15274Apply alpha premultiply effect to input video stream using first plane
15275of second stream as alpha.
15276
15277Both streams must have same dimensions and same pixel format.
15278
15279The filter accepts the following option:
15280
15281@table @option
15282@item planes
15283Set which planes will be processed, unprocessed planes will be copied.
15284By default value 0xf, all planes will be processed.
15285
15286@item inplace
15287Do not require 2nd input for processing, instead use alpha plane from input stream.
15288@end table
15289
15290@section prewitt
15291Apply prewitt operator to input video stream.
15292
15293The filter accepts the following option:
15294
15295@table @option
15296@item planes
15297Set which planes will be processed, unprocessed planes will be copied.
15298By default value 0xf, all planes will be processed.
15299
15300@item scale
15301Set value which will be multiplied with filtered result.
15302
15303@item delta
15304Set value which will be added to filtered result.
15305@end table
15306
15307@section pseudocolor
15308
15309Alter frame colors in video with pseudocolors.
15310
15311This filter accepts the following options:
15312
15313@table @option
15314@item c0
15315set pixel first component expression
15316
15317@item c1
15318set pixel second component expression
15319
15320@item c2
15321set pixel third component expression
15322
15323@item c3
15324set pixel fourth component expression, corresponds to the alpha component
15325
15326@item i
15327set component to use as base for altering colors
15328@end table
15329
15330Each of them specifies the expression to use for computing the lookup table for
15331the corresponding pixel component values.
15332
15333The expressions can contain the following constants and functions:
15334
15335@table @option
15336@item w
15337@item h
15338The input width and height.
15339
15340@item val
15341The input value for the pixel component.
15342
15343@item ymin, umin, vmin, amin
15344The minimum allowed component value.
15345
15346@item ymax, umax, vmax, amax
15347The maximum allowed component value.
15348@end table
15349
15350All expressions default to "val".
15351
15352@subsection Examples
15353
15354@itemize
15355@item
15356Change too high luma values to gradient:
15357@example
15358pseudocolor="'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'"
15359@end example
15360@end itemize
15361
15362@section psnr
15363
15364Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
15365Ratio) between two input videos.
15366
15367This filter takes in input two input videos, the first input is
15368considered the "main" source and is passed unchanged to the
15369output. The second input is used as a "reference" video for computing
15370the PSNR.
15371
15372Both video inputs must have the same resolution and pixel format for
15373this filter to work correctly. Also it assumes that both inputs
15374have the same number of frames, which are compared one by one.
15375
15376The obtained average PSNR is printed through the logging system.
15377
15378The filter stores the accumulated MSE (mean squared error) of each
15379frame, and at the end of the processing it is averaged across all frames
15380equally, and the following formula is applied to obtain the PSNR:
15381
15382@example
15383PSNR = 10*log10(MAX^2/MSE)
15384@end example
15385
15386Where MAX is the average of the maximum values of each component of the
15387image.
15388
15389The description of the accepted parameters follows.
15390
15391@table @option
15392@item stats_file, f
15393If specified the filter will use the named file to save the PSNR of
15394each individual frame. When filename equals "-" the data is sent to
15395standard output.
15396
15397@item stats_version
15398Specifies which version of the stats file format to use. Details of
15399each format are written below.
15400Default value is 1.
15401
15402@item stats_add_max
15403Determines whether the max value is output to the stats log.
15404Default value is 0.
15405Requires stats_version >= 2. If this is set and stats_version < 2,
15406the filter will return an error.
15407@end table
15408
15409This filter also supports the @ref{framesync} options.
15410
15411The file printed if @var{stats_file} is selected, contains a sequence of
15412key/value pairs of the form @var{key}:@var{value} for each compared
15413couple of frames.
15414
15415If a @var{stats_version} greater than 1 is specified, a header line precedes
15416the list of per-frame-pair stats, with key value pairs following the frame
15417format with the following parameters:
15418
15419@table @option
15420@item psnr_log_version
15421The version of the log file format. Will match @var{stats_version}.
15422
15423@item fields
15424A comma separated list of the per-frame-pair parameters included in
15425the log.
15426@end table
15427
15428A description of each shown per-frame-pair parameter follows:
15429
15430@table @option
15431@item n
15432sequential number of the input frame, starting from 1
15433
15434@item mse_avg
15435Mean Square Error pixel-by-pixel average difference of the compared
15436frames, averaged over all the image components.
15437
15438@item mse_y, mse_u, mse_v, mse_r, mse_g, mse_b, mse_a
15439Mean Square Error pixel-by-pixel average difference of the compared
15440frames for the component specified by the suffix.
15441
15442@item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
15443Peak Signal to Noise ratio of the compared frames for the component
15444specified by the suffix.
15445
15446@item max_avg, max_y, max_u, max_v
15447Maximum allowed value for each channel, and average over all
15448channels.
15449@end table
15450
15451@subsection Examples
15452@itemize
15453@item
15454For example:
15455@example
15456movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
15457[main][ref] psnr="stats_file=stats.log" [out]
15458@end example
15459
15460On this example the input file being processed is compared with the
15461reference file @file{ref_movie.mpg}. The PSNR of each individual frame
15462is stored in @file{stats.log}.
15463
15464@item
15465Another example with different containers:
15466@example
15467ffmpeg -i main.mpg -i ref.mkv -lavfi  "[0:v]settb=AVTB,setpts=PTS-STARTPTS[main];[1:v]settb=AVTB,setpts=PTS-STARTPTS[ref];[main][ref]psnr" -f null -
15468@end example
15469@end itemize
15470
15471@anchor{pullup}
15472@section pullup
15473
15474Pulldown reversal (inverse telecine) filter, capable of handling mixed
15475hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
15476content.
15477
15478The pullup filter is designed to take advantage of future context in making
15479its decisions. This filter is stateless in the sense that it does not lock
15480onto a pattern to follow, but it instead looks forward to the following
15481fields in order to identify matches and rebuild progressive frames.
15482
15483To produce content with an even framerate, insert the fps filter after
15484pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
15485@code{fps=24} for 30fps and the (rare) telecined 25fps input.
15486
15487The filter accepts the following options:
15488
15489@table @option
15490@item jl
15491@item jr
15492@item jt
15493@item jb
15494These options set the amount of "junk" to ignore at the left, right, top, and
15495bottom of the image, respectively. Left and right are in units of 8 pixels,
15496while top and bottom are in units of 2 lines.
15497The default is 8 pixels on each side.
15498
15499@item sb
15500Set the strict breaks. Setting this option to 1 will reduce the chances of
15501filter generating an occasional mismatched frame, but it may also cause an
15502excessive number of frames to be dropped during high motion sequences.
15503Conversely, setting it to -1 will make filter match fields more easily.
15504This may help processing of video where there is slight blurring between
15505the fields, but may also cause there to be interlaced frames in the output.
15506Default value is @code{0}.
15507
15508@item mp
15509Set the metric plane to use. It accepts the following values:
15510@table @samp
15511@item l
15512Use luma plane.
15513
15514@item u
15515Use chroma blue plane.
15516
15517@item v
15518Use chroma red plane.
15519@end table
15520
15521This option may be set to use chroma plane instead of the default luma plane
15522for doing filter's computations. This may improve accuracy on very clean
15523source material, but more likely will decrease accuracy, especially if there
15524is chroma noise (rainbow effect) or any grayscale video.
15525The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
15526load and make pullup usable in realtime on slow machines.
15527@end table
15528
15529For best results (without duplicated frames in the output file) it is
15530necessary to change the output frame rate. For example, to inverse
15531telecine NTSC input:
15532@example
15533ffmpeg -i input -vf pullup -r 24000/1001 ...
15534@end example
15535
15536@section qp
15537
15538Change video quantization parameters (QP).
15539
15540The filter accepts the following option:
15541
15542@table @option
15543@item qp
15544Set expression for quantization parameter.
15545@end table
15546
15547The expression is evaluated through the eval API and can contain, among others,
15548the following constants:
15549
15550@table @var
15551@item known
155521 if index is not 129, 0 otherwise.
15553
15554@item qp
15555Sequential index starting from -129 to 128.
15556@end table
15557
15558@subsection Examples
15559
15560@itemize
15561@item
15562Some equation like:
15563@example
15564qp=2+2*sin(PI*qp)
15565@end example
15566@end itemize
15567
15568@section random
15569
15570Flush video frames from internal cache of frames into a random order.
15571No frame is discarded.
15572Inspired by @ref{frei0r} nervous filter.
15573
15574@table @option
15575@item frames
15576Set size in number of frames of internal cache, in range from @code{2} to
15577@code{512}. Default is @code{30}.
15578
15579@item seed
15580Set seed for random number generator, must be an integer included between
15581@code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
15582less than @code{0}, the filter will try to use a good random seed on a
15583best effort basis.
15584@end table
15585
15586@section readeia608
15587
15588Read closed captioning (EIA-608) information from the top lines of a video frame.
15589
15590This filter adds frame metadata for @code{lavfi.readeia608.X.cc} and
15591@code{lavfi.readeia608.X.line}, where @code{X} is the number of the identified line
15592with EIA-608 data (starting from 0). A description of each metadata value follows:
15593
15594@table @option
15595@item lavfi.readeia608.X.cc
15596The two bytes stored as EIA-608 data (printed in hexadecimal).
15597
15598@item lavfi.readeia608.X.line
15599The number of the line on which the EIA-608 data was identified and read.
15600@end table
15601
15602This filter accepts the following options:
15603
15604@table @option
15605@item scan_min
15606Set the line to start scanning for EIA-608 data. Default is @code{0}.
15607
15608@item scan_max
15609Set the line to end scanning for EIA-608 data. Default is @code{29}.
15610
15611@item spw
15612Set the ratio of width reserved for sync code detection.
15613Default is @code{0.27}. Allowed range is @code{[0.1 - 0.7]}.
15614
15615@item chp
15616Enable checking the parity bit. In the event of a parity error, the filter will output
15617@code{0x00} for that character. Default is false.
15618
15619@item lp
15620Lowpass lines prior to further processing. Default is enabled.
15621@end table
15622
15623@subsection Examples
15624
15625@itemize
15626@item
15627Output a csv with presentation time and the first two lines of identified EIA-608 captioning data.
15628@example
15629ffprobe -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
15630@end example
15631@end itemize
15632
15633@section readvitc
15634
15635Read vertical interval timecode (VITC) information from the top lines of a
15636video frame.
15637
15638The filter adds frame metadata key @code{lavfi.readvitc.tc_str} with the
15639timecode value, if a valid timecode has been detected. Further metadata key
15640@code{lavfi.readvitc.found} is set to 0/1 depending on whether
15641timecode data has been found or not.
15642
15643This filter accepts the following options:
15644
15645@table @option
15646@item scan_max
15647Set the maximum number of lines to scan for VITC data. If the value is set to
15648@code{-1} the full video frame is scanned. Default is @code{45}.
15649
15650@item thr_b
15651Set the luma threshold for black. Accepts float numbers in the range [0.0,1.0],
15652default value is @code{0.2}. The value must be equal or less than @code{thr_w}.
15653
15654@item thr_w
15655Set the luma threshold for white. Accepts float numbers in the range [0.0,1.0],
15656default value is @code{0.6}. The value must be equal or greater than @code{thr_b}.
15657@end table
15658
15659@subsection Examples
15660
15661@itemize
15662@item
15663Detect and draw VITC data onto the video frame; if no valid VITC is detected,
15664draw @code{--:--:--:--} as a placeholder:
15665@example
15666ffmpeg -i input.avi -filter:v 'readvitc,drawtext=fontfile=FreeMono.ttf:text=%@{metadata\\:lavfi.readvitc.tc_str\\:--\\\\\\:--\\\\\\:--\\\\\\:--@}:x=(w-tw)/2:y=400-ascent'
15667@end example
15668@end itemize
15669
15670@section remap
15671
15672Remap pixels using 2nd: Xmap and 3rd: Ymap input video stream.
15673
15674Destination pixel at position (X, Y) will be picked from source (x, y) position
15675where x = Xmap(X, Y) and y = Ymap(X, Y). If mapping values are out of range, zero
15676value for pixel will be used for destination pixel.
15677
15678Xmap and Ymap input video streams must be of same dimensions. Output video stream
15679will have Xmap/Ymap video stream dimensions.
15680Xmap and Ymap input video streams are 16bit depth, single channel.
15681
15682@table @option
15683@item format
15684Specify pixel format of output from this filter. Can be @code{color} or @code{gray}.
15685Default is @code{color}.
15686
15687@item fill
15688Specify the color of the unmapped pixels. For the syntax of this option,
15689check the @ref{color syntax,,"Color" section in the ffmpeg-utils
15690manual,ffmpeg-utils}. Default color is @code{black}.
15691@end table
15692
15693@section removegrain
15694
15695The removegrain filter is a spatial denoiser for progressive video.
15696
15697@table @option
15698@item m0
15699Set mode for the first plane.
15700
15701@item m1
15702Set mode for the second plane.
15703
15704@item m2
15705Set mode for the third plane.
15706
15707@item m3
15708Set mode for the fourth plane.
15709@end table
15710
15711Range of mode is from 0 to 24. Description of each mode follows:
15712
15713@table @var
15714@item 0
15715Leave input plane unchanged. Default.
15716
15717@item 1
15718Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
15719
15720@item 2
15721Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
15722
15723@item 3
15724Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
15725
15726@item 4
15727Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
15728This is equivalent to a median filter.
15729
15730@item 5
15731Line-sensitive clipping giving the minimal change.
15732
15733@item 6
15734Line-sensitive clipping, intermediate.
15735
15736@item 7
15737Line-sensitive clipping, intermediate.
15738
15739@item 8
15740Line-sensitive clipping, intermediate.
15741
15742@item 9
15743Line-sensitive clipping on a line where the neighbours pixels are the closest.
15744
15745@item 10
15746Replaces the target pixel with the closest neighbour.
15747
15748@item 11
15749[1 2 1] horizontal and vertical kernel blur.
15750
15751@item 12
15752Same as mode 11.
15753
15754@item 13
15755Bob mode, interpolates top field from the line where the neighbours
15756pixels are the closest.
15757
15758@item 14
15759Bob mode, interpolates bottom field from the line where the neighbours
15760pixels are the closest.
15761
15762@item 15
15763Bob mode, interpolates top field. Same as 13 but with a more complicated
15764interpolation formula.
15765
15766@item 16
15767Bob mode, interpolates bottom field. Same as 14 but with a more complicated
15768interpolation formula.
15769
15770@item 17
15771Clips the pixel with the minimum and maximum of respectively the maximum and
15772minimum of each pair of opposite neighbour pixels.
15773
15774@item 18
15775Line-sensitive clipping using opposite neighbours whose greatest distance from
15776the current pixel is minimal.
15777
15778@item 19
15779Replaces the pixel with the average of its 8 neighbours.
15780
15781@item 20
15782Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
15783
15784@item 21
15785Clips pixels using the averages of opposite neighbour.
15786
15787@item 22
15788Same as mode 21 but simpler and faster.
15789
15790@item 23
15791Small edge and halo removal, but reputed useless.
15792
15793@item 24
15794Similar as 23.
15795@end table
15796
15797@section removelogo
15798
15799Suppress a TV station logo, using an image file to determine which
15800pixels comprise the logo. It works by filling in the pixels that
15801comprise the logo with neighboring pixels.
15802
15803The filter accepts the following options:
15804
15805@table @option
15806@item filename, f
15807Set the filter bitmap file, which can be any image format supported by
15808libavformat. The width and height of the image file must match those of the
15809video stream being processed.
15810@end table
15811
15812Pixels in the provided bitmap image with a value of zero are not
15813considered part of the logo, non-zero pixels are considered part of
15814the logo. If you use white (255) for the logo and black (0) for the
15815rest, you will be safe. For making the filter bitmap, it is
15816recommended to take a screen capture of a black frame with the logo
15817visible, and then using a threshold filter followed by the erode
15818filter once or twice.
15819
15820If needed, little splotches can be fixed manually. Remember that if
15821logo pixels are not covered, the filter quality will be much
15822reduced. Marking too many pixels as part of the logo does not hurt as
15823much, but it will increase the amount of blurring needed to cover over
15824the image and will destroy more information than necessary, and extra
15825pixels will slow things down on a large logo.
15826
15827@section repeatfields
15828
15829This filter uses the repeat_field flag from the Video ES headers and hard repeats
15830fields based on its value.
15831
15832@section reverse
15833
15834Reverse a video clip.
15835
15836Warning: This filter requires memory to buffer the entire clip, so trimming
15837is suggested.
15838
15839@subsection Examples
15840
15841@itemize
15842@item
15843Take the first 5 seconds of a clip, and reverse it.
15844@example
15845trim=end=5,reverse
15846@end example
15847@end itemize
15848
15849@section rgbashift
15850Shift R/G/B/A pixels horizontally and/or vertically.
15851
15852The filter accepts the following options:
15853@table @option
15854@item rh
15855Set amount to shift red horizontally.
15856@item rv
15857Set amount to shift red vertically.
15858@item gh
15859Set amount to shift green horizontally.
15860@item gv
15861Set amount to shift green vertically.
15862@item bh
15863Set amount to shift blue horizontally.
15864@item bv
15865Set amount to shift blue vertically.
15866@item ah
15867Set amount to shift alpha horizontally.
15868@item av
15869Set amount to shift alpha vertically.
15870@item edge
15871Set edge mode, can be @var{smear}, default, or @var{warp}.
15872@end table
15873
15874@subsection Commands
15875
15876This filter supports the all above options as @ref{commands}.
15877
15878@section roberts
15879Apply roberts cross operator to input video stream.
15880
15881The filter accepts the following option:
15882
15883@table @option
15884@item planes
15885Set which planes will be processed, unprocessed planes will be copied.
15886By default value 0xf, all planes will be processed.
15887
15888@item scale
15889Set value which will be multiplied with filtered result.
15890
15891@item delta
15892Set value which will be added to filtered result.
15893@end table
15894
15895@section rotate
15896
15897Rotate video by an arbitrary angle expressed in radians.
15898
15899The filter accepts the following options:
15900
15901A description of the optional parameters follows.
15902@table @option
15903@item angle, a
15904Set an expression for the angle by which to rotate the input video
15905clockwise, expressed as a number of radians. A negative value will
15906result in a counter-clockwise rotation. By default it is set to "0".
15907
15908This expression is evaluated for each frame.
15909
15910@item out_w, ow
15911Set the output width expression, default value is "iw".
15912This expression is evaluated just once during configuration.
15913
15914@item out_h, oh
15915Set the output height expression, default value is "ih".
15916This expression is evaluated just once during configuration.
15917
15918@item bilinear
15919Enable bilinear interpolation if set to 1, a value of 0 disables
15920it. Default value is 1.
15921
15922@item fillcolor, c
15923Set the color used to fill the output area not covered by the rotated
15924image. For the general syntax of this option, check the
15925@ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.
15926If the special value "none" is selected then no
15927background is printed (useful for example if the background is never shown).
15928
15929Default value is "black".
15930@end table
15931
15932The expressions for the angle and the output size can contain the
15933following constants and functions:
15934
15935@table @option
15936@item n
15937sequential number of the input frame, starting from 0. It is always NAN
15938before the first frame is filtered.
15939
15940@item t
15941time in seconds of the input frame, it is set to 0 when the filter is
15942configured. It is always NAN before the first frame is filtered.
15943
15944@item hsub
15945@item vsub
15946horizontal and vertical chroma subsample values. For example for the
15947pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
15948
15949@item in_w, iw
15950@item in_h, ih
15951the input video width and height
15952
15953@item out_w, ow
15954@item out_h, oh
15955the output width and height, that is the size of the padded area as
15956specified by the @var{width} and @var{height} expressions
15957
15958@item rotw(a)
15959@item roth(a)
15960the minimal width/height required for completely containing the input
15961video rotated by @var{a} radians.
15962
15963These are only available when computing the @option{out_w} and
15964@option{out_h} expressions.
15965@end table
15966
15967@subsection Examples
15968
15969@itemize
15970@item
15971Rotate the input by PI/6 radians clockwise:
15972@example
15973rotate=PI/6
15974@end example
15975
15976@item
15977Rotate the input by PI/6 radians counter-clockwise:
15978@example
15979rotate=-PI/6
15980@end example
15981
15982@item
15983Rotate the input by 45 degrees clockwise:
15984@example
15985rotate=45*PI/180
15986@end example
15987
15988@item
15989Apply a constant rotation with period T, starting from an angle of PI/3:
15990@example
15991rotate=PI/3+2*PI*t/T
15992@end example
15993
15994@item
15995Make the input video rotation oscillating with a period of T
15996seconds and an amplitude of A radians:
15997@example
15998rotate=A*sin(2*PI/T*t)
15999@end example
16000
16001@item
16002Rotate the video, output size is chosen so that the whole rotating
16003input video is always completely contained in the output:
16004@example
16005rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
16006@end example
16007
16008@item
16009Rotate the video, reduce the output size so that no background is ever
16010shown:
16011@example
16012rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
16013@end example
16014@end itemize
16015
16016@subsection Commands
16017
16018The filter supports the following commands:
16019
16020@table @option
16021@item a, angle
16022Set the angle expression.
16023The command accepts the same syntax of the corresponding option.
16024
16025If the specified expression is not valid, it is kept at its current
16026value.
16027@end table
16028
16029@section sab
16030
16031Apply Shape Adaptive Blur.
16032
16033The filter accepts the following options:
16034
16035@table @option
16036@item luma_radius, lr
16037Set luma blur filter strength, must be a value in range 0.1-4.0, default
16038value is 1.0. A greater value will result in a more blurred image, and
16039in slower processing.
16040
16041@item luma_pre_filter_radius, lpfr
16042Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
16043value is 1.0.
16044
16045@item luma_strength, ls
16046Set luma maximum difference between pixels to still be considered, must
16047be a value in the 0.1-100.0 range, default value is 1.0.
16048
16049@item chroma_radius, cr
16050Set chroma blur filter strength, must be a value in range -0.9-4.0. A
16051greater value will result in a more blurred image, and in slower
16052processing.
16053
16054@item chroma_pre_filter_radius, cpfr
16055Set chroma pre-filter radius, must be a value in the -0.9-2.0 range.
16056
16057@item chroma_strength, cs
16058Set chroma maximum difference between pixels to still be considered,
16059must be a value in the -0.9-100.0 range.
16060@end table
16061
16062Each chroma option value, if not explicitly specified, is set to the
16063corresponding luma option value.
16064
16065@anchor{scale}
16066@section scale
16067
16068Scale (resize) the input video, using the libswscale library.
16069
16070The scale filter forces the output display aspect ratio to be the same
16071of the input, by changing the output sample aspect ratio.
16072
16073If the input image format is different from the format requested by
16074the next filter, the scale filter will convert the input to the
16075requested format.
16076
16077@subsection Options
16078The filter accepts the following options, or any of the options
16079supported by the libswscale scaler.
16080
16081See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
16082the complete list of scaler options.
16083
16084@table @option
16085@item width, w
16086@item height, h
16087Set the output video dimension expression. Default value is the input
16088dimension.
16089
16090If the @var{width} or @var{w} value is 0, the input width is used for
16091the output. If the @var{height} or @var{h} value is 0, the input height
16092is used for the output.
16093
16094If one and only one of the values is -n with n >= 1, the scale filter
16095will use a value that maintains the aspect ratio of the input image,
16096calculated from the other specified dimension. After that it will,
16097however, make sure that the calculated dimension is divisible by n and
16098adjust the value if necessary.
16099
16100If both values are -n with n >= 1, the behavior will be identical to
16101both values being set to 0 as previously detailed.
16102
16103See below for the list of accepted constants for use in the dimension
16104expression.
16105
16106@item eval
16107Specify when to evaluate @var{width} and @var{height} expression. It accepts the following values:
16108
16109@table @samp
16110@item init
16111Only evaluate expressions once during the filter initialization or when a command is processed.
16112
16113@item frame
16114Evaluate expressions for each incoming frame.
16115
16116@end table
16117
16118Default value is @samp{init}.
16119
16120
16121@item interl
16122Set the interlacing mode. It accepts the following values:
16123
16124@table @samp
16125@item 1
16126Force interlaced aware scaling.
16127
16128@item 0
16129Do not apply interlaced scaling.
16130
16131@item -1
16132Select interlaced aware scaling depending on whether the source frames
16133are flagged as interlaced or not.
16134@end table
16135
16136Default value is @samp{0}.
16137
16138@item flags
16139Set libswscale scaling flags. See
16140@ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
16141complete list of values. If not explicitly specified the filter applies
16142the default flags.
16143
16144
16145@item param0, param1
16146Set libswscale input parameters for scaling algorithms that need them. See
16147@ref{sws_params,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
16148complete documentation. If not explicitly specified the filter applies
16149empty parameters.
16150
16151
16152
16153@item size, s
16154Set the video size. For the syntax of this option, check the
16155@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
16156
16157@item in_color_matrix
16158@item out_color_matrix
16159Set in/output YCbCr color space type.
16160
16161This allows the autodetected value to be overridden as well as allows forcing
16162a specific value used for the output and encoder.
16163
16164If not specified, the color space type depends on the pixel format.
16165
16166Possible values:
16167
16168@table @samp
16169@item auto
16170Choose automatically.
16171
16172@item bt709
16173Format conforming to International Telecommunication Union (ITU)
16174Recommendation BT.709.
16175
16176@item fcc
16177Set color space conforming to the United States Federal Communications
16178Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
16179
16180@item bt601
16181@item bt470
16182@item smpte170m
16183Set color space conforming to:
16184
16185@itemize
16186@item
16187ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
16188
16189@item
16190ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
16191
16192@item
16193Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
16194
16195@end itemize
16196
16197@item smpte240m
16198Set color space conforming to SMPTE ST 240:1999.
16199
16200@item bt2020
16201Set color space conforming to ITU-R BT.2020 non-constant luminance system.
16202@end table
16203
16204@item in_range
16205@item out_range
16206Set in/output YCbCr sample range.
16207
16208This allows the autodetected value to be overridden as well as allows forcing
16209a specific value used for the output and encoder. If not specified, the
16210range depends on the pixel format. Possible values:
16211
16212@table @samp
16213@item auto/unknown
16214Choose automatically.
16215
16216@item jpeg/full/pc
16217Set full range (0-255 in case of 8-bit luma).
16218
16219@item mpeg/limited/tv
16220Set "MPEG" range (16-235 in case of 8-bit luma).
16221@end table
16222
16223@item force_original_aspect_ratio
16224Enable decreasing or increasing output video width or height if necessary to
16225keep the original aspect ratio. Possible values:
16226
16227@table @samp
16228@item disable
16229Scale the video as specified and disable this feature.
16230
16231@item decrease
16232The output video dimensions will automatically be decreased if needed.
16233
16234@item increase
16235The output video dimensions will automatically be increased if needed.
16236
16237@end table
16238
16239One useful instance of this option is that when you know a specific device's
16240maximum allowed resolution, you can use this to limit the output video to
16241that, while retaining the aspect ratio. For example, device A allows
162421280x720 playback, and your video is 1920x800. Using this option (set it to
16243decrease) and specifying 1280x720 to the command line makes the output
162441280x533.
16245
16246Please note that this is a different thing than specifying -1 for @option{w}
16247or @option{h}, you still need to specify the output resolution for this option
16248to work.
16249
16250@item force_divisible_by
16251Ensures that both the output dimensions, width and height, are divisible by the
16252given integer when used together with @option{force_original_aspect_ratio}. This
16253works similar to using @code{-n} in the @option{w} and @option{h} options.
16254
16255This option respects the value set for @option{force_original_aspect_ratio},
16256increasing or decreasing the resolution accordingly. The video's aspect ratio
16257may be slightly modified.
16258
16259This option can be handy if you need to have a video fit within or exceed
16260a defined resolution using @option{force_original_aspect_ratio} but also have
16261encoder restrictions on width or height divisibility.
16262
16263@end table
16264
16265The values of the @option{w} and @option{h} options are expressions
16266containing the following constants:
16267
16268@table @var
16269@item in_w
16270@item in_h
16271The input width and height
16272
16273@item iw
16274@item ih
16275These are the same as @var{in_w} and @var{in_h}.
16276
16277@item out_w
16278@item out_h
16279The output (scaled) width and height
16280
16281@item ow
16282@item oh
16283These are the same as @var{out_w} and @var{out_h}
16284
16285@item a
16286The same as @var{iw} / @var{ih}
16287
16288@item sar
16289input sample aspect ratio
16290
16291@item dar
16292The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
16293
16294@item hsub
16295@item vsub
16296horizontal and vertical input chroma subsample values. For example for the
16297pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
16298
16299@item ohsub
16300@item ovsub
16301horizontal and vertical output chroma subsample values. For example for the
16302pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
16303
16304@item n
16305The (sequential) number of the input frame, starting from 0.
16306Only available with @code{eval=frame}.
16307
16308@item t
16309The presentation timestamp of the input frame, expressed as a number of
16310seconds. Only available with @code{eval=frame}.
16311
16312@item pos
16313The position (byte offset) of the frame in the input stream, or NaN if
16314this information is unavailable and/or meaningless (for example in case of synthetic video).
16315Only available with @code{eval=frame}.
16316@end table
16317
16318@subsection Examples
16319
16320@itemize
16321@item
16322Scale the input video to a size of 200x100
16323@example
16324scale=w=200:h=100
16325@end example
16326
16327This is equivalent to:
16328@example
16329scale=200:100
16330@end example
16331
16332or:
16333@example
16334scale=200x100
16335@end example
16336
16337@item
16338Specify a size abbreviation for the output size:
16339@example
16340scale=qcif
16341@end example
16342
16343which can also be written as:
16344@example
16345scale=size=qcif
16346@end example
16347
16348@item
16349Scale the input to 2x:
16350@example
16351scale=w=2*iw:h=2*ih
16352@end example
16353
16354@item
16355The above is the same as:
16356@example
16357scale=2*in_w:2*in_h
16358@end example
16359
16360@item
16361Scale the input to 2x with forced interlaced scaling:
16362@example
16363scale=2*iw:2*ih:interl=1
16364@end example
16365
16366@item
16367Scale the input to half size:
16368@example
16369scale=w=iw/2:h=ih/2
16370@end example
16371
16372@item
16373Increase the width, and set the height to the same size:
16374@example
16375scale=3/2*iw:ow
16376@end example
16377
16378@item
16379Seek Greek harmony:
16380@example
16381scale=iw:1/PHI*iw
16382scale=ih*PHI:ih
16383@end example
16384
16385@item
16386Increase the height, and set the width to 3/2 of the height:
16387@example
16388scale=w=3/2*oh:h=3/5*ih
16389@end example
16390
16391@item
16392Increase the size, making the size a multiple of the chroma
16393subsample values:
16394@example
16395scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
16396@end example
16397
16398@item
16399Increase the width to a maximum of 500 pixels,
16400keeping the same aspect ratio as the input:
16401@example
16402scale=w='min(500\, iw*3/2):h=-1'
16403@end example
16404
16405@item
16406Make pixels square by combining scale and setsar:
16407@example
16408scale='trunc(ih*dar):ih',setsar=1/1
16409@end example
16410
16411@item
16412Make pixels square by combining scale and setsar,
16413making sure the resulting resolution is even (required by some codecs):
16414@example
16415scale='trunc(ih*dar/2)*2:trunc(ih/2)*2',setsar=1/1
16416@end example
16417@end itemize
16418
16419@subsection Commands
16420
16421This filter supports the following commands:
16422@table @option
16423@item width, w
16424@item height, h
16425Set the output video dimension expression.
16426The command accepts the same syntax of the corresponding option.
16427
16428If the specified expression is not valid, it is kept at its current
16429value.
16430@end table
16431
16432@section scale_npp
16433
16434Use the NVIDIA Performance Primitives (libnpp) to perform scaling and/or pixel
16435format conversion on CUDA video frames. Setting the output width and height
16436works in the same way as for the @var{scale} filter.
16437
16438The following additional options are accepted:
16439@table @option
16440@item format
16441The pixel format of the output CUDA frames. If set to the string "same" (the
16442default), the input format will be kept. Note that automatic format negotiation
16443and conversion is not yet supported for hardware frames
16444
16445@item interp_algo
16446The interpolation algorithm used for resizing. One of the following:
16447@table @option
16448@item nn
16449Nearest neighbour.
16450
16451@item linear
16452@item cubic
16453@item cubic2p_bspline
164542-parameter cubic (B=1, C=0)
16455
16456@item cubic2p_catmullrom
164572-parameter cubic (B=0, C=1/2)
16458
16459@item cubic2p_b05c03
164602-parameter cubic (B=1/2, C=3/10)
16461
16462@item super
16463Supersampling
16464
16465@item lanczos
16466@end table
16467
16468@item force_original_aspect_ratio
16469Enable decreasing or increasing output video width or height if necessary to
16470keep the original aspect ratio. Possible values:
16471
16472@table @samp
16473@item disable
16474Scale the video as specified and disable this feature.
16475
16476@item decrease
16477The output video dimensions will automatically be decreased if needed.
16478
16479@item increase
16480The output video dimensions will automatically be increased if needed.
16481
16482@end table
16483
16484One useful instance of this option is that when you know a specific device's
16485maximum allowed resolution, you can use this to limit the output video to
16486that, while retaining the aspect ratio. For example, device A allows
164871280x720 playback, and your video is 1920x800. Using this option (set it to
16488decrease) and specifying 1280x720 to the command line makes the output
164891280x533.
16490
16491Please note that this is a different thing than specifying -1 for @option{w}
16492or @option{h}, you still need to specify the output resolution for this option
16493to work.
16494
16495@item force_divisible_by
16496Ensures that both the output dimensions, width and height, are divisible by the
16497given integer when used together with @option{force_original_aspect_ratio}. This
16498works similar to using @code{-n} in the @option{w} and @option{h} options.
16499
16500This option respects the value set for @option{force_original_aspect_ratio},
16501increasing or decreasing the resolution accordingly. The video's aspect ratio
16502may be slightly modified.
16503
16504This option can be handy if you need to have a video fit within or exceed
16505a defined resolution using @option{force_original_aspect_ratio} but also have
16506encoder restrictions on width or height divisibility.
16507
16508@end table
16509
16510@section scale2ref
16511
16512Scale (resize) the input video, based on a reference video.
16513
16514See the scale filter for available options, scale2ref supports the same but
16515uses the reference video instead of the main input as basis. scale2ref also
16516supports the following additional constants for the @option{w} and
16517@option{h} options:
16518
16519@table @var
16520@item main_w
16521@item main_h
16522The main input video's width and height
16523
16524@item main_a
16525The same as @var{main_w} / @var{main_h}
16526
16527@item main_sar
16528The main input video's sample aspect ratio
16529
16530@item main_dar, mdar
16531The main input video's display aspect ratio. Calculated from
16532@code{(main_w / main_h) * main_sar}.
16533
16534@item main_hsub
16535@item main_vsub
16536The main input video's horizontal and vertical chroma subsample values.
16537For example for the pixel format "yuv422p" @var{hsub} is 2 and @var{vsub}
16538is 1.
16539
16540@item main_n
16541The (sequential) number of the main input frame, starting from 0.
16542Only available with @code{eval=frame}.
16543
16544@item main_t
16545The presentation timestamp of the main input frame, expressed as a number of
16546seconds. Only available with @code{eval=frame}.
16547
16548@item main_pos
16549The position (byte offset) of the frame in the main input stream, or NaN if
16550this information is unavailable and/or meaningless (for example in case of synthetic video).
16551Only available with @code{eval=frame}.
16552@end table
16553
16554@subsection Examples
16555
16556@itemize
16557@item
16558Scale a subtitle stream (b) to match the main video (a) in size before overlaying
16559@example
16560'scale2ref[b][a];[a][b]overlay'
16561@end example
16562
16563@item
16564Scale a logo to 1/10th the height of a video, while preserving its display aspect ratio.
16565@example
16566[logo-in][video-in]scale2ref=w=oh*mdar:h=ih/10[logo-out][video-out]
16567@end example
16568@end itemize
16569
16570@subsection Commands
16571
16572This filter supports the following commands:
16573@table @option
16574@item width, w
16575@item height, h
16576Set the output video dimension expression.
16577The command accepts the same syntax of the corresponding option.
16578
16579If the specified expression is not valid, it is kept at its current
16580value.
16581@end table
16582
16583@section scroll
16584Scroll input video horizontally and/or vertically by constant speed.
16585
16586The filter accepts the following options:
16587@table @option
16588@item horizontal, h
16589Set the horizontal scrolling speed. Default is 0. Allowed range is from -1 to 1.
16590Negative values changes scrolling direction.
16591
16592@item vertical, v
16593Set the vertical scrolling speed. Default is 0. Allowed range is from -1 to 1.
16594Negative values changes scrolling direction.
16595
16596@item hpos
16597Set the initial horizontal scrolling position. Default is 0. Allowed range is from 0 to 1.
16598
16599@item vpos
16600Set the initial vertical scrolling position. Default is 0. Allowed range is from 0 to 1.
16601@end table
16602
16603@subsection Commands
16604
16605This filter supports the following @ref{commands}:
16606@table @option
16607@item horizontal, h
16608Set the horizontal scrolling speed.
16609@item vertical, v
16610Set the vertical scrolling speed.
16611@end table
16612
16613@anchor{scdet}
16614@section scdet
16615
16616Detect video scene change.
16617
16618This filter sets frame metadata with mafd between frame, the scene score, and
16619forward the frame to the next filter, so they can use these metadata to detect
16620scene change or others.
16621
16622In addition, this filter logs a message and sets frame metadata when it detects
16623a scene change by @option{threshold}.
16624
16625@code{lavfi.scd.mafd} metadata keys are set with mafd for every frame.
16626
16627@code{lavfi.scd.score} metadata keys are set with scene change score for every frame
16628to detect scene change.
16629
16630@code{lavfi.scd.time} metadata keys are set with current filtered frame time which
16631detect scene change with @option{threshold}.
16632
16633The filter accepts the following options:
16634
16635@table @option
16636@item threshold, t
16637Set the scene change detection threshold as a percentage of maximum change. Good
16638values are in the @code{[8.0, 14.0]} range. The range for @option{threshold} is
16639@code{[0., 100.]}.
16640
16641Default value is @code{10.}.
16642
16643@item sc_pass, s
16644Set the flag to pass scene change frames to the next filter. Default value is @code{0}
16645You can enable it if you want to get snapshot of scene change frames only.
16646@end table
16647
16648@anchor{selectivecolor}
16649@section selectivecolor
16650
16651Adjust cyan, magenta, yellow and black (CMYK) to certain ranges of colors (such
16652as "reds", "yellows", "greens", "cyans", ...). The adjustment range is defined
16653by the "purity" of the color (that is, how saturated it already is).
16654
16655This filter is similar to the Adobe Photoshop Selective Color tool.
16656
16657The filter accepts the following options:
16658
16659@table @option
16660@item correction_method
16661Select color correction method.
16662
16663Available values are:
16664@table @samp
16665@item absolute
16666Specified adjustments are applied "as-is" (added/subtracted to original pixel
16667component value).
16668@item relative
16669Specified adjustments are relative to the original component value.
16670@end table
16671Default is @code{absolute}.
16672@item reds
16673Adjustments for red pixels (pixels where the red component is the maximum)
16674@item yellows
16675Adjustments for yellow pixels (pixels where the blue component is the minimum)
16676@item greens
16677Adjustments for green pixels (pixels where the green component is the maximum)
16678@item cyans
16679Adjustments for cyan pixels (pixels where the red component is the minimum)
16680@item blues
16681Adjustments for blue pixels (pixels where the blue component is the maximum)
16682@item magentas
16683Adjustments for magenta pixels (pixels where the green component is the minimum)
16684@item whites
16685Adjustments for white pixels (pixels where all components are greater than 128)
16686@item neutrals
16687Adjustments for all pixels except pure black and pure white
16688@item blacks
16689Adjustments for black pixels (pixels where all components are lesser than 128)
16690@item psfile
16691Specify a Photoshop selective color file (@code{.asv}) to import the settings from.
16692@end table
16693
16694All the adjustment settings (@option{reds}, @option{yellows}, ...) accept up to
166954 space separated floating point adjustment values in the [-1,1] range,
16696respectively to adjust the amount of cyan, magenta, yellow and black for the
16697pixels of its range.
16698
16699@subsection Examples
16700
16701@itemize
16702@item
16703Increase cyan by 50% and reduce yellow by 33% in every green areas, and
16704increase magenta by 27% in blue areas:
16705@example
16706selectivecolor=greens=.5 0 -.33 0:blues=0 .27
16707@end example
16708
16709@item
16710Use a Photoshop selective color preset:
16711@example
16712selectivecolor=psfile=MySelectiveColorPresets/Misty.asv
16713@end example
16714@end itemize
16715
16716@anchor{separatefields}
16717@section separatefields
16718
16719The @code{separatefields} takes a frame-based video input and splits
16720each frame into its components fields, producing a new half height clip
16721with twice the frame rate and twice the frame count.
16722
16723This filter use field-dominance information in frame to decide which
16724of each pair of fields to place first in the output.
16725If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
16726
16727@section setdar, setsar
16728
16729The @code{setdar} filter sets the Display Aspect Ratio for the filter
16730output video.
16731
16732This is done by changing the specified Sample (aka Pixel) Aspect
16733Ratio, according to the following equation:
16734@example
16735@var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
16736@end example
16737
16738Keep in mind that the @code{setdar} filter does not modify the pixel
16739dimensions of the video frame. Also, the display aspect ratio set by
16740this filter may be changed by later filters in the filterchain,
16741e.g. in case of scaling or if another "setdar" or a "setsar" filter is
16742applied.
16743
16744The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
16745the filter output video.
16746
16747Note that as a consequence of the application of this filter, the
16748output display aspect ratio will change according to the equation
16749above.
16750
16751Keep in mind that the sample aspect ratio set by the @code{setsar}
16752filter may be changed by later filters in the filterchain, e.g. if
16753another "setsar" or a "setdar" filter is applied.
16754
16755It accepts the following parameters:
16756
16757@table @option
16758@item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
16759Set the aspect ratio used by the filter.
16760
16761The parameter can be a floating point number string, an expression, or
16762a string of the form @var{num}:@var{den}, where @var{num} and
16763@var{den} are the numerator and denominator of the aspect ratio. If
16764the parameter is not specified, it is assumed the value "0".
16765In case the form "@var{num}:@var{den}" is used, the @code{:} character
16766should be escaped.
16767
16768@item max
16769Set the maximum integer value to use for expressing numerator and
16770denominator when reducing the expressed aspect ratio to a rational.
16771Default value is @code{100}.
16772
16773@end table
16774
16775The parameter @var{sar} is an expression containing
16776the following constants:
16777
16778@table @option
16779@item E, PI, PHI
16780These are approximated values for the mathematical constants e
16781(Euler's number), pi (Greek pi), and phi (the golden ratio).
16782
16783@item w, h
16784The input width and height.
16785
16786@item a
16787These are the same as @var{w} / @var{h}.
16788
16789@item sar
16790The input sample aspect ratio.
16791
16792@item dar
16793The input display aspect ratio. It is the same as
16794(@var{w} / @var{h}) * @var{sar}.
16795
16796@item hsub, vsub
16797Horizontal and vertical chroma subsample values. For example, for the
16798pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
16799@end table
16800
16801@subsection Examples
16802
16803@itemize
16804
16805@item
16806To change the display aspect ratio to 16:9, specify one of the following:
16807@example
16808setdar=dar=1.77777
16809setdar=dar=16/9
16810@end example
16811
16812@item
16813To change the sample aspect ratio to 10:11, specify:
16814@example
16815setsar=sar=10/11
16816@end example
16817
16818@item
16819To set a display aspect ratio of 16:9, and specify a maximum integer value of
168201000 in the aspect ratio reduction, use the command:
16821@example
16822setdar=ratio=16/9:max=1000
16823@end example
16824
16825@end itemize
16826
16827@anchor{setfield}
16828@section setfield
16829
16830Force field for the output video frame.
16831
16832The @code{setfield} filter marks the interlace type field for the
16833output frames. It does not change the input frame, but only sets the
16834corresponding property, which affects how the frame is treated by
16835following filters (e.g. @code{fieldorder} or @code{yadif}).
16836
16837The filter accepts the following options:
16838
16839@table @option
16840
16841@item mode
16842Available values are:
16843
16844@table @samp
16845@item auto
16846Keep the same field property.
16847
16848@item bff
16849Mark the frame as bottom-field-first.
16850
16851@item tff
16852Mark the frame as top-field-first.
16853
16854@item prog
16855Mark the frame as progressive.
16856@end table
16857@end table
16858
16859@anchor{setparams}
16860@section setparams
16861
16862Force frame parameter for the output video frame.
16863
16864The @code{setparams} filter marks interlace and color range for the
16865output frames. It does not change the input frame, but only sets the
16866corresponding property, which affects how the frame is treated by
16867filters/encoders.
16868
16869@table @option
16870@item field_mode
16871Available values are:
16872
16873@table @samp
16874@item auto
16875Keep the same field property (default).
16876
16877@item bff
16878Mark the frame as bottom-field-first.
16879
16880@item tff
16881Mark the frame as top-field-first.
16882
16883@item prog
16884Mark the frame as progressive.
16885@end table
16886
16887@item range
16888Available values are:
16889
16890@table @samp
16891@item auto
16892Keep the same color range property (default).
16893
16894@item unspecified, unknown
16895Mark the frame as unspecified color range.
16896
16897@item limited, tv, mpeg
16898Mark the frame as limited range.
16899
16900@item full, pc, jpeg
16901Mark the frame as full range.
16902@end table
16903
16904@item color_primaries
16905Set the color primaries.
16906Available values are:
16907
16908@table @samp
16909@item auto
16910Keep the same color primaries property (default).
16911
16912@item bt709
16913@item unknown
16914@item bt470m
16915@item bt470bg
16916@item smpte170m
16917@item smpte240m
16918@item film
16919@item bt2020
16920@item smpte428
16921@item smpte431
16922@item smpte432
16923@item jedec-p22
16924@end table
16925
16926@item color_trc
16927Set the color transfer.
16928Available values are:
16929
16930@table @samp
16931@item auto
16932Keep the same color trc property (default).
16933
16934@item bt709
16935@item unknown
16936@item bt470m
16937@item bt470bg
16938@item smpte170m
16939@item smpte240m
16940@item linear
16941@item log100
16942@item log316
16943@item iec61966-2-4
16944@item bt1361e
16945@item iec61966-2-1
16946@item bt2020-10
16947@item bt2020-12
16948@item smpte2084
16949@item smpte428
16950@item arib-std-b67
16951@end table
16952
16953@item colorspace
16954Set the colorspace.
16955Available values are:
16956
16957@table @samp
16958@item auto
16959Keep the same colorspace property (default).
16960
16961@item gbr
16962@item bt709
16963@item unknown
16964@item fcc
16965@item bt470bg
16966@item smpte170m
16967@item smpte240m
16968@item ycgco
16969@item bt2020nc
16970@item bt2020c
16971@item smpte2085
16972@item chroma-derived-nc
16973@item chroma-derived-c
16974@item ictcp
16975@end table
16976@end table
16977
16978@section showinfo
16979
16980Show a line containing various information for each input video frame.
16981The input video is not modified.
16982
16983This filter supports the following options:
16984
16985@table @option
16986@item checksum
16987Calculate checksums of each plane. By default enabled.
16988@end table
16989
16990The shown line contains a sequence of key/value pairs of the form
16991@var{key}:@var{value}.
16992
16993The following values are shown in the output:
16994
16995@table @option
16996@item n
16997The (sequential) number of the input frame, starting from 0.
16998
16999@item pts
17000The Presentation TimeStamp of the input frame, expressed as a number of
17001time base units. The time base unit depends on the filter input pad.
17002
17003@item pts_time
17004The Presentation TimeStamp of the input frame, expressed as a number of
17005seconds.
17006
17007@item pos
17008The position of the frame in the input stream, or -1 if this information is
17009unavailable and/or meaningless (for example in case of synthetic video).
17010
17011@item fmt
17012The pixel format name.
17013
17014@item sar
17015The sample aspect ratio of the input frame, expressed in the form
17016@var{num}/@var{den}.
17017
17018@item s
17019The size of the input frame. For the syntax of this option, check the
17020@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
17021
17022@item i
17023The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
17024for bottom field first).
17025
17026@item iskey
17027This is 1 if the frame is a key frame, 0 otherwise.
17028
17029@item type
17030The picture type of the input frame ("I" for an I-frame, "P" for a
17031P-frame, "B" for a B-frame, or "?" for an unknown type).
17032Also refer to the documentation of the @code{AVPictureType} enum and of
17033the @code{av_get_picture_type_char} function defined in
17034@file{libavutil/avutil.h}.
17035
17036@item checksum
17037The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
17038
17039@item plane_checksum
17040The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
17041expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
17042
17043@item mean
17044The mean value of pixels in each plane of the input frame, expressed in the form
17045"[@var{mean0} @var{mean1} @var{mean2} @var{mean3}]".
17046
17047@item stdev
17048The standard deviation of pixel values in each plane of the input frame, expressed
17049in the form "[@var{stdev0} @var{stdev1} @var{stdev2} @var{stdev3}]".
17050
17051@end table
17052
17053@section showpalette
17054
17055Displays the 256 colors palette of each frame. This filter is only relevant for
17056@var{pal8} pixel format frames.
17057
17058It accepts the following option:
17059
17060@table @option
17061@item s
17062Set the size of the box used to represent one palette color entry. Default is
17063@code{30} (for a @code{30x30} pixel box).
17064@end table
17065
17066@section shuffleframes
17067
17068Reorder and/or duplicate and/or drop video frames.
17069
17070It accepts the following parameters:
17071
17072@table @option
17073@item mapping
17074Set the destination indexes of input frames.
17075This is space or '|' separated list of indexes that maps input frames to output
17076frames. Number of indexes also sets maximal value that each index may have.
17077'-1' index have special meaning and that is to drop frame.
17078@end table
17079
17080The first frame has the index 0. The default is to keep the input unchanged.
17081
17082@subsection Examples
17083
17084@itemize
17085@item
17086Swap second and third frame of every three frames of the input:
17087@example
17088ffmpeg -i INPUT -vf "shuffleframes=0 2 1" OUTPUT
17089@end example
17090
17091@item
17092Swap 10th and 1st frame of every ten frames of the input:
17093@example
17094ffmpeg -i INPUT -vf "shuffleframes=9 1 2 3 4 5 6 7 8 0" OUTPUT
17095@end example
17096@end itemize
17097
17098@section shuffleplanes
17099
17100Reorder and/or duplicate video planes.
17101
17102It accepts the following parameters:
17103
17104@table @option
17105
17106@item map0
17107The index of the input plane to be used as the first output plane.
17108
17109@item map1
17110The index of the input plane to be used as the second output plane.
17111
17112@item map2
17113The index of the input plane to be used as the third output plane.
17114
17115@item map3
17116The index of the input plane to be used as the fourth output plane.
17117
17118@end table
17119
17120The first plane has the index 0. The default is to keep the input unchanged.
17121
17122@subsection Examples
17123
17124@itemize
17125@item
17126Swap the second and third planes of the input:
17127@example
17128ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
17129@end example
17130@end itemize
17131
17132@anchor{signalstats}
17133@section signalstats
17134Evaluate various visual metrics that assist in determining issues associated
17135with the digitization of analog video media.
17136
17137By default the filter will log these metadata values:
17138
17139@table @option
17140@item YMIN
17141Display the minimal Y value contained within the input frame. Expressed in
17142range of [0-255].
17143
17144@item YLOW
17145Display the Y value at the 10% percentile within the input frame. Expressed in
17146range of [0-255].
17147
17148@item YAVG
17149Display the average Y value within the input frame. Expressed in range of
17150[0-255].
17151
17152@item YHIGH
17153Display the Y value at the 90% percentile within the input frame. Expressed in
17154range of [0-255].
17155
17156@item YMAX
17157Display the maximum Y value contained within the input frame. Expressed in
17158range of [0-255].
17159
17160@item UMIN
17161Display the minimal U value contained within the input frame. Expressed in
17162range of [0-255].
17163
17164@item ULOW
17165Display the U value at the 10% percentile within the input frame. Expressed in
17166range of [0-255].
17167
17168@item UAVG
17169Display the average U value within the input frame. Expressed in range of
17170[0-255].
17171
17172@item UHIGH
17173Display the U value at the 90% percentile within the input frame. Expressed in
17174range of [0-255].
17175
17176@item UMAX
17177Display the maximum U value contained within the input frame. Expressed in
17178range of [0-255].
17179
17180@item VMIN
17181Display the minimal V value contained within the input frame. Expressed in
17182range of [0-255].
17183
17184@item VLOW
17185Display the V value at the 10% percentile within the input frame. Expressed in
17186range of [0-255].
17187
17188@item VAVG
17189Display the average V value within the input frame. Expressed in range of
17190[0-255].
17191
17192@item VHIGH
17193Display the V value at the 90% percentile within the input frame. Expressed in
17194range of [0-255].
17195
17196@item VMAX
17197Display the maximum V value contained within the input frame. Expressed in
17198range of [0-255].
17199
17200@item SATMIN
17201Display the minimal saturation value contained within the input frame.
17202Expressed in range of [0-~181.02].
17203
17204@item SATLOW
17205Display the saturation value at the 10% percentile within the input frame.
17206Expressed in range of [0-~181.02].
17207
17208@item SATAVG
17209Display the average saturation value within the input frame. Expressed in range
17210of [0-~181.02].
17211
17212@item SATHIGH
17213Display the saturation value at the 90% percentile within the input frame.
17214Expressed in range of [0-~181.02].
17215
17216@item SATMAX
17217Display the maximum saturation value contained within the input frame.
17218Expressed in range of [0-~181.02].
17219
17220@item HUEMED
17221Display the median value for hue within the input frame. Expressed in range of
17222[0-360].
17223
17224@item HUEAVG
17225Display the average value for hue within the input frame. Expressed in range of
17226[0-360].
17227
17228@item YDIF
17229Display the average of sample value difference between all values of the Y
17230plane in the current frame and corresponding values of the previous input frame.
17231Expressed in range of [0-255].
17232
17233@item UDIF
17234Display the average of sample value difference between all values of the U
17235plane in the current frame and corresponding values of the previous input frame.
17236Expressed in range of [0-255].
17237
17238@item VDIF
17239Display the average of sample value difference between all values of the V
17240plane in the current frame and corresponding values of the previous input frame.
17241Expressed in range of [0-255].
17242
17243@item YBITDEPTH
17244Display bit depth of Y plane in current frame.
17245Expressed in range of [0-16].
17246
17247@item UBITDEPTH
17248Display bit depth of U plane in current frame.
17249Expressed in range of [0-16].
17250
17251@item VBITDEPTH
17252Display bit depth of V plane in current frame.
17253Expressed in range of [0-16].
17254@end table
17255
17256The filter accepts the following options:
17257
17258@table @option
17259@item stat
17260@item out
17261
17262@option{stat} specify an additional form of image analysis.
17263@option{out} output video with the specified type of pixel highlighted.
17264
17265Both options accept the following values:
17266
17267@table @samp
17268@item tout
17269Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
17270unlike the neighboring pixels of the same field. Examples of temporal outliers
17271include the results of video dropouts, head clogs, or tape tracking issues.
17272
17273@item vrep
17274Identify @var{vertical line repetition}. Vertical line repetition includes
17275similar rows of pixels within a frame. In born-digital video vertical line
17276repetition is common, but this pattern is uncommon in video digitized from an
17277analog source. When it occurs in video that results from the digitization of an
17278analog source it can indicate concealment from a dropout compensator.
17279
17280@item brng
17281Identify pixels that fall outside of legal broadcast range.
17282@end table
17283
17284@item color, c
17285Set the highlight color for the @option{out} option. The default color is
17286yellow.
17287@end table
17288
17289@subsection Examples
17290
17291@itemize
17292@item
17293Output data of various video metrics:
17294@example
17295ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
17296@end example
17297
17298@item
17299Output specific data about the minimum and maximum values of the Y plane per frame:
17300@example
17301ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
17302@end example
17303
17304@item
17305Playback video while highlighting pixels that are outside of broadcast range in red.
17306@example
17307ffplay example.mov -vf signalstats="out=brng:color=red"
17308@end example
17309
17310@item
17311Playback video with signalstats metadata drawn over the frame.
17312@example
17313ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
17314@end example
17315
17316The contents of signalstat_drawtext.txt used in the command are:
17317@example
17318time %@{pts:hms@}
17319Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
17320U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
17321V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
17322saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
17323
17324@end example
17325@end itemize
17326
17327@anchor{signature}
17328@section signature
17329
17330Calculates the MPEG-7 Video Signature. The filter can handle more than one
17331input. In this case the matching between the inputs can be calculated additionally.
17332The filter always passes through the first input. The signature of each stream can
17333be written into a file.
17334
17335It accepts the following options:
17336
17337@table @option
17338@item detectmode
17339Enable or disable the matching process.
17340
17341Available values are:
17342
17343@table @samp
17344@item off
17345Disable the calculation of a matching (default).
17346@item full
17347Calculate the matching for the whole video and output whether the whole video
17348matches or only parts.
17349@item fast
17350Calculate only until a matching is found or the video ends. Should be faster in
17351some cases.
17352@end table
17353
17354@item nb_inputs
17355Set the number of inputs. The option value must be a non negative integer.
17356Default value is 1.
17357
17358@item filename
17359Set the path to which the output is written. If there is more than one input,
17360the path must be a prototype, i.e. must contain %d or %0nd (where n is a positive
17361integer), that will be replaced with the input number. If no filename is
17362specified, no output will be written. This is the default.
17363
17364@item format
17365Choose the output format.
17366
17367Available values are:
17368
17369@table @samp
17370@item binary
17371Use the specified binary representation (default).
17372@item xml
17373Use the specified xml representation.
17374@end table
17375
17376@item th_d
17377Set threshold to detect one word as similar. The option value must be an integer
17378greater than zero. The default value is 9000.
17379
17380@item th_dc
17381Set threshold to detect all words as similar. The option value must be an integer
17382greater than zero. The default value is 60000.
17383
17384@item th_xh
17385Set threshold to detect frames as similar. The option value must be an integer
17386greater than zero. The default value is 116.
17387
17388@item th_di
17389Set the minimum length of a sequence in frames to recognize it as matching
17390sequence. The option value must be a non negative integer value.
17391The default value is 0.
17392
17393@item th_it
17394Set the minimum relation, that matching frames to all frames must have.
17395The option value must be a double value between 0 and 1. The default value is 0.5.
17396@end table
17397
17398@subsection Examples
17399
17400@itemize
17401@item
17402To calculate the signature of an input video and store it in signature.bin:
17403@example
17404ffmpeg -i input.mkv -vf signature=filename=signature.bin -map 0:v -f null -
17405@end example
17406
17407@item
17408To detect whether two videos match and store the signatures in XML format in
17409signature0.xml and signature1.xml:
17410@example
17411ffmpeg -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 -
17412@end example
17413
17414@end itemize
17415
17416@anchor{smartblur}
17417@section smartblur
17418
17419Blur the input video without impacting the outlines.
17420
17421It accepts the following options:
17422
17423@table @option
17424@item luma_radius, lr
17425Set the luma radius. The option value must be a float number in
17426the range [0.1,5.0] that specifies the variance of the gaussian filter
17427used to blur the image (slower if larger). Default value is 1.0.
17428
17429@item luma_strength, ls
17430Set the luma strength. The option value must be a float number
17431in the range [-1.0,1.0] that configures the blurring. A value included
17432in [0.0,1.0] will blur the image whereas a value included in
17433[-1.0,0.0] will sharpen the image. Default value is 1.0.
17434
17435@item luma_threshold, lt
17436Set the luma threshold used as a coefficient to determine
17437whether a pixel should be blurred or not. The option value must be an
17438integer in the range [-30,30]. A value of 0 will filter all the image,
17439a value included in [0,30] will filter flat areas and a value included
17440in [-30,0] will filter edges. Default value is 0.
17441
17442@item chroma_radius, cr
17443Set the chroma radius. The option value must be a float number in
17444the range [0.1,5.0] that specifies the variance of the gaussian filter
17445used to blur the image (slower if larger). Default value is @option{luma_radius}.
17446
17447@item chroma_strength, cs
17448Set the chroma strength. The option value must be a float number
17449in the range [-1.0,1.0] that configures the blurring. A value included
17450in [0.0,1.0] will blur the image whereas a value included in
17451[-1.0,0.0] will sharpen the image. Default value is @option{luma_strength}.
17452
17453@item chroma_threshold, ct
17454Set the chroma threshold used as a coefficient to determine
17455whether a pixel should be blurred or not. The option value must be an
17456integer in the range [-30,30]. A value of 0 will filter all the image,
17457a value included in [0,30] will filter flat areas and a value included
17458in [-30,0] will filter edges. Default value is @option{luma_threshold}.
17459@end table
17460
17461If a chroma option is not explicitly set, the corresponding luma value
17462is set.
17463
17464@section sobel
17465Apply sobel operator to input video stream.
17466
17467The filter accepts the following option:
17468
17469@table @option
17470@item planes
17471Set which planes will be processed, unprocessed planes will be copied.
17472By default value 0xf, all planes will be processed.
17473
17474@item scale
17475Set value which will be multiplied with filtered result.
17476
17477@item delta
17478Set value which will be added to filtered result.
17479@end table
17480
17481@anchor{spp}
17482@section spp
17483
17484Apply a simple postprocessing filter that compresses and decompresses the image
17485at several (or - in the case of @option{quality} level @code{6} - all) shifts
17486and average the results.
17487
17488The filter accepts the following options:
17489
17490@table @option
17491@item quality
17492Set quality. This option defines the number of levels for averaging. It accepts
17493an integer in the range 0-6. If set to @code{0}, the filter will have no
17494effect. A value of @code{6} means the higher quality. For each increment of
17495that value the speed drops by a factor of approximately 2.  Default value is
17496@code{3}.
17497
17498@item qp
17499Force a constant quantization parameter. If not set, the filter will use the QP
17500from the video stream (if available).
17501
17502@item mode
17503Set thresholding mode. Available modes are:
17504
17505@table @samp
17506@item hard
17507Set hard thresholding (default).
17508@item soft
17509Set soft thresholding (better de-ringing effect, but likely blurrier).
17510@end table
17511
17512@item use_bframe_qp
17513Enable the use of the QP from the B-Frames if set to @code{1}. Using this
17514option may cause flicker since the B-Frames have often larger QP. Default is
17515@code{0} (not enabled).
17516@end table
17517
17518@subsection Commands
17519
17520This filter supports the following commands:
17521@table @option
17522@item quality, level
17523Set quality level. The value @code{max} can be used to set the maximum level,
17524currently @code{6}.
17525@end table
17526
17527@anchor{sr}
17528@section sr
17529
17530Scale the input by applying one of the super-resolution methods based on
17531convolutional neural networks. Supported models:
17532
17533@itemize
17534@item
17535Super-Resolution Convolutional Neural Network model (SRCNN).
17536See @url{https://arxiv.org/abs/1501.00092}.
17537
17538@item
17539Efficient Sub-Pixel Convolutional Neural Network model (ESPCN).
17540See @url{https://arxiv.org/abs/1609.05158}.
17541@end itemize
17542
17543Training scripts as well as scripts for model file (.pb) saving can be found at
17544@url{https://github.com/XueweiMeng/sr/tree/sr_dnn_native}. Original repository
17545is at @url{https://github.com/HighVoltageRocknRoll/sr.git}.
17546
17547Native model files (.model) can be generated from TensorFlow model
17548files (.pb) by using tools/python/convert.py
17549
17550The filter accepts the following options:
17551
17552@table @option
17553@item dnn_backend
17554Specify which DNN backend to use for model loading and execution. This option accepts
17555the following values:
17556
17557@table @samp
17558@item native
17559Native implementation of DNN loading and execution.
17560
17561@item tensorflow
17562TensorFlow backend. To enable this backend you
17563need to install the TensorFlow for C library (see
17564@url{https://www.tensorflow.org/install/install_c}) and configure FFmpeg with
17565@code{--enable-libtensorflow}
17566@end table
17567
17568Default value is @samp{native}.
17569
17570@item model
17571Set path to model file specifying network architecture and its parameters.
17572Note that different backends use different file formats. TensorFlow backend
17573can load files for both formats, while native backend can load files for only
17574its format.
17575
17576@item scale_factor
17577Set scale factor for SRCNN model. Allowed values are @code{2}, @code{3} and @code{4}.
17578Default value is @code{2}. Scale factor is necessary for SRCNN model, because it accepts
17579input upscaled using bicubic upscaling with proper scale factor.
17580@end table
17581
17582This feature can also be finished with @ref{dnn_processing} filter.
17583
17584@section ssim
17585
17586Obtain the SSIM (Structural SImilarity Metric) between two input videos.
17587
17588This filter takes in input two input videos, the first input is
17589considered the "main" source and is passed unchanged to the
17590output. The second input is used as a "reference" video for computing
17591the SSIM.
17592
17593Both video inputs must have the same resolution and pixel format for
17594this filter to work correctly. Also it assumes that both inputs
17595have the same number of frames, which are compared one by one.
17596
17597The filter stores the calculated SSIM of each frame.
17598
17599The description of the accepted parameters follows.
17600
17601@table @option
17602@item stats_file, f
17603If specified the filter will use the named file to save the SSIM of
17604each individual frame. When filename equals "-" the data is sent to
17605standard output.
17606@end table
17607
17608The file printed if @var{stats_file} is selected, contains a sequence of
17609key/value pairs of the form @var{key}:@var{value} for each compared
17610couple of frames.
17611
17612A description of each shown parameter follows:
17613
17614@table @option
17615@item n
17616sequential number of the input frame, starting from 1
17617
17618@item Y, U, V, R, G, B
17619SSIM of the compared frames for the component specified by the suffix.
17620
17621@item All
17622SSIM of the compared frames for the whole frame.
17623
17624@item dB
17625Same as above but in dB representation.
17626@end table
17627
17628This filter also supports the @ref{framesync} options.
17629
17630@subsection Examples
17631@itemize
17632@item
17633For example:
17634@example
17635movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
17636[main][ref] ssim="stats_file=stats.log" [out]
17637@end example
17638
17639On this example the input file being processed is compared with the
17640reference file @file{ref_movie.mpg}. The SSIM of each individual frame
17641is stored in @file{stats.log}.
17642
17643@item
17644Another example with both psnr and ssim at same time:
17645@example
17646ffmpeg -i main.mpg -i ref.mpg -lavfi  "ssim;[0:v][1:v]psnr" -f null -
17647@end example
17648
17649@item
17650Another example with different containers:
17651@example
17652ffmpeg -i main.mpg -i ref.mkv -lavfi  "[0:v]settb=AVTB,setpts=PTS-STARTPTS[main];[1:v]settb=AVTB,setpts=PTS-STARTPTS[ref];[main][ref]ssim" -f null -
17653@end example
17654@end itemize
17655
17656@section stereo3d
17657
17658Convert between different stereoscopic image formats.
17659
17660The filters accept the following options:
17661
17662@table @option
17663@item in
17664Set stereoscopic image format of input.
17665
17666Available values for input image formats are:
17667@table @samp
17668@item sbsl
17669side by side parallel (left eye left, right eye right)
17670
17671@item sbsr
17672side by side crosseye (right eye left, left eye right)
17673
17674@item sbs2l
17675side by side parallel with half width resolution
17676(left eye left, right eye right)
17677
17678@item sbs2r
17679side by side crosseye with half width resolution
17680(right eye left, left eye right)
17681
17682@item abl
17683@item tbl
17684above-below (left eye above, right eye below)
17685
17686@item abr
17687@item tbr
17688above-below (right eye above, left eye below)
17689
17690@item ab2l
17691@item tb2l
17692above-below with half height resolution
17693(left eye above, right eye below)
17694
17695@item ab2r
17696@item tb2r
17697above-below with half height resolution
17698(right eye above, left eye below)
17699
17700@item al
17701alternating frames (left eye first, right eye second)
17702
17703@item ar
17704alternating frames (right eye first, left eye second)
17705
17706@item irl
17707interleaved rows (left eye has top row, right eye starts on next row)
17708
17709@item irr
17710interleaved rows (right eye has top row, left eye starts on next row)
17711
17712@item icl
17713interleaved columns, left eye first
17714
17715@item icr
17716interleaved columns, right eye first
17717
17718Default value is @samp{sbsl}.
17719@end table
17720
17721@item out
17722Set stereoscopic image format of output.
17723
17724@table @samp
17725@item sbsl
17726side by side parallel (left eye left, right eye right)
17727
17728@item sbsr
17729side by side crosseye (right eye left, left eye right)
17730
17731@item sbs2l
17732side by side parallel with half width resolution
17733(left eye left, right eye right)
17734
17735@item sbs2r
17736side by side crosseye with half width resolution
17737(right eye left, left eye right)
17738
17739@item abl
17740@item tbl
17741above-below (left eye above, right eye below)
17742
17743@item abr
17744@item tbr
17745above-below (right eye above, left eye below)
17746
17747@item ab2l
17748@item tb2l
17749above-below with half height resolution
17750(left eye above, right eye below)
17751
17752@item ab2r
17753@item tb2r
17754above-below with half height resolution
17755(right eye above, left eye below)
17756
17757@item al
17758alternating frames (left eye first, right eye second)
17759
17760@item ar
17761alternating frames (right eye first, left eye second)
17762
17763@item irl
17764interleaved rows (left eye has top row, right eye starts on next row)
17765
17766@item irr
17767interleaved rows (right eye has top row, left eye starts on next row)
17768
17769@item arbg
17770anaglyph red/blue gray
17771(red filter on left eye, blue filter on right eye)
17772
17773@item argg
17774anaglyph red/green gray
17775(red filter on left eye, green filter on right eye)
17776
17777@item arcg
17778anaglyph red/cyan gray
17779(red filter on left eye, cyan filter on right eye)
17780
17781@item arch
17782anaglyph red/cyan half colored
17783(red filter on left eye, cyan filter on right eye)
17784
17785@item arcc
17786anaglyph red/cyan color
17787(red filter on left eye, cyan filter on right eye)
17788
17789@item arcd
17790anaglyph red/cyan color optimized with the least squares projection of dubois
17791(red filter on left eye, cyan filter on right eye)
17792
17793@item agmg
17794anaglyph green/magenta gray
17795(green filter on left eye, magenta filter on right eye)
17796
17797@item agmh
17798anaglyph green/magenta half colored
17799(green filter on left eye, magenta filter on right eye)
17800
17801@item agmc
17802anaglyph green/magenta colored
17803(green filter on left eye, magenta filter on right eye)
17804
17805@item agmd
17806anaglyph green/magenta color optimized with the least squares projection of dubois
17807(green filter on left eye, magenta filter on right eye)
17808
17809@item aybg
17810anaglyph yellow/blue gray
17811(yellow filter on left eye, blue filter on right eye)
17812
17813@item aybh
17814anaglyph yellow/blue half colored
17815(yellow filter on left eye, blue filter on right eye)
17816
17817@item aybc
17818anaglyph yellow/blue colored
17819(yellow filter on left eye, blue filter on right eye)
17820
17821@item aybd
17822anaglyph yellow/blue color optimized with the least squares projection of dubois
17823(yellow filter on left eye, blue filter on right eye)
17824
17825@item ml
17826mono output (left eye only)
17827
17828@item mr
17829mono output (right eye only)
17830
17831@item chl
17832checkerboard, left eye first
17833
17834@item chr
17835checkerboard, right eye first
17836
17837@item icl
17838interleaved columns, left eye first
17839
17840@item icr
17841interleaved columns, right eye first
17842
17843@item hdmi
17844HDMI frame pack
17845@end table
17846
17847Default value is @samp{arcd}.
17848@end table
17849
17850@subsection Examples
17851
17852@itemize
17853@item
17854Convert input video from side by side parallel to anaglyph yellow/blue dubois:
17855@example
17856stereo3d=sbsl:aybd
17857@end example
17858
17859@item
17860Convert input video from above below (left eye above, right eye below) to side by side crosseye.
17861@example
17862stereo3d=abl:sbsr
17863@end example
17864@end itemize
17865
17866@section streamselect, astreamselect
17867Select video or audio streams.
17868
17869The filter accepts the following options:
17870
17871@table @option
17872@item inputs
17873Set number of inputs. Default is 2.
17874
17875@item map
17876Set input indexes to remap to outputs.
17877@end table
17878
17879@subsection Commands
17880
17881The @code{streamselect} and @code{astreamselect} filter supports the following
17882commands:
17883
17884@table @option
17885@item map
17886Set input indexes to remap to outputs.
17887@end table
17888
17889@subsection Examples
17890
17891@itemize
17892@item
17893Select first 5 seconds 1st stream and rest of time 2nd stream:
17894@example
17895sendcmd='5.0 streamselect map 1',streamselect=inputs=2:map=0
17896@end example
17897
17898@item
17899Same as above, but for audio:
17900@example
17901asendcmd='5.0 astreamselect map 1',astreamselect=inputs=2:map=0
17902@end example
17903@end itemize
17904
17905@anchor{subtitles}
17906@section subtitles
17907
17908Draw subtitles on top of input video using the libass library.
17909
17910To enable compilation of this filter you need to configure FFmpeg with
17911@code{--enable-libass}. This filter also requires a build with libavcodec and
17912libavformat to convert the passed subtitles file to ASS (Advanced Substation
17913Alpha) subtitles format.
17914
17915The filter accepts the following options:
17916
17917@table @option
17918@item filename, f
17919Set the filename of the subtitle file to read. It must be specified.
17920
17921@item original_size
17922Specify the size of the original video, the video for which the ASS file
17923was composed. For the syntax of this option, check the
17924@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
17925Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
17926correctly scale the fonts if the aspect ratio has been changed.
17927
17928@item fontsdir
17929Set a directory path containing fonts that can be used by the filter.
17930These fonts will be used in addition to whatever the font provider uses.
17931
17932@item alpha
17933Process alpha channel, by default alpha channel is untouched.
17934
17935@item charenc
17936Set subtitles input character encoding. @code{subtitles} filter only. Only
17937useful if not UTF-8.
17938
17939@item stream_index, si
17940Set subtitles stream index. @code{subtitles} filter only.
17941
17942@item force_style
17943Override default style or script info parameters of the subtitles. It accepts a
17944string containing ASS style format @code{KEY=VALUE} couples separated by ",".
17945@end table
17946
17947If the first key is not specified, it is assumed that the first value
17948specifies the @option{filename}.
17949
17950For example, to render the file @file{sub.srt} on top of the input
17951video, use the command:
17952@example
17953subtitles=sub.srt
17954@end example
17955
17956which is equivalent to:
17957@example
17958subtitles=filename=sub.srt
17959@end example
17960
17961To render the default subtitles stream from file @file{video.mkv}, use:
17962@example
17963subtitles=video.mkv
17964@end example
17965
17966To render the second subtitles stream from that file, use:
17967@example
17968subtitles=video.mkv:si=1
17969@end example
17970
17971To make the subtitles stream from @file{sub.srt} appear in 80% transparent blue
17972@code{DejaVu Serif}, use:
17973@example
17974subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HCCFF0000'
17975@end example
17976
17977@section super2xsai
17978
17979Scale the input by 2x and smooth using the Super2xSaI (Scale and
17980Interpolate) pixel art scaling algorithm.
17981
17982Useful for enlarging pixel art images without reducing sharpness.
17983
17984@section swaprect
17985
17986Swap two rectangular objects in video.
17987
17988This filter accepts the following options:
17989
17990@table @option
17991@item w
17992Set object width.
17993
17994@item h
17995Set object height.
17996
17997@item x1
17998Set 1st rect x coordinate.
17999
18000@item y1
18001Set 1st rect y coordinate.
18002
18003@item x2
18004Set 2nd rect x coordinate.
18005
18006@item y2
18007Set 2nd rect y coordinate.
18008
18009All expressions are evaluated once for each frame.
18010@end table
18011
18012The all options are expressions containing the following constants:
18013
18014@table @option
18015@item w
18016@item h
18017The input width and height.
18018
18019@item a
18020same as @var{w} / @var{h}
18021
18022@item sar
18023input sample aspect ratio
18024
18025@item dar
18026input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
18027
18028@item n
18029The number of the input frame, starting from 0.
18030
18031@item t
18032The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
18033
18034@item pos
18035the position in the file of the input frame, NAN if unknown
18036@end table
18037
18038@section swapuv
18039Swap U & V plane.
18040
18041@section tblend
18042Blend successive video frames.
18043
18044See @ref{blend}
18045
18046@section telecine
18047
18048Apply telecine process to the video.
18049
18050This filter accepts the following options:
18051
18052@table @option
18053@item first_field
18054@table @samp
18055@item top, t
18056top field first
18057@item bottom, b
18058bottom field first
18059The default value is @code{top}.
18060@end table
18061
18062@item pattern
18063A string of numbers representing the pulldown pattern you wish to apply.
18064The default value is @code{23}.
18065@end table
18066
18067@example
18068Some typical patterns:
18069
18070NTSC output (30i):
1807127.5p: 32222
1807224p: 23 (classic)
1807324p: 2332 (preferred)
1807420p: 33
1807518p: 334
1807616p: 3444
18077
18078PAL output (25i):
1807927.5p: 12222
1808024p: 222222222223 ("Euro pulldown")
1808116.67p: 33
1808216p: 33333334
18083@end example
18084
18085@section thistogram
18086
18087Compute and draw a color distribution histogram for the input video across time.
18088
18089Unlike @ref{histogram} video filter which only shows histogram of single input frame
18090at certain time, this filter shows also past histograms of number of frames defined
18091by @code{width} option.
18092
18093The computed histogram is a representation of the color component
18094distribution in an image.
18095
18096The filter accepts the following options:
18097
18098@table @option
18099@item width, w
18100Set width of single color component output. Default value is @code{0}.
18101Value of @code{0} means width will be picked from input video.
18102This also set number of passed histograms to keep.
18103Allowed range is [0, 8192].
18104
18105@item display_mode, d
18106Set display mode.
18107It accepts the following values:
18108@table @samp
18109@item stack
18110Per color component graphs are placed below each other.
18111
18112@item parade
18113Per color component graphs are placed side by side.
18114
18115@item overlay
18116Presents information identical to that in the @code{parade}, except
18117that the graphs representing color components are superimposed directly
18118over one another.
18119@end table
18120Default is @code{stack}.
18121
18122@item levels_mode, m
18123Set mode. Can be either @code{linear}, or @code{logarithmic}.
18124Default is @code{linear}.
18125
18126@item components, c
18127Set what color components to display.
18128Default is @code{7}.
18129
18130@item bgopacity, b
18131Set background opacity. Default is @code{0.9}.
18132
18133@item envelope, e
18134Show envelope. Default is disabled.
18135
18136@item ecolor, ec
18137Set envelope color. Default is @code{gold}.
18138@end table
18139
18140@section threshold
18141
18142Apply threshold effect to video stream.
18143
18144This filter needs four video streams to perform thresholding.
18145First stream is stream we are filtering.
18146Second stream is holding threshold values, third stream is holding min values,
18147and last, fourth stream is holding max values.
18148
18149The filter accepts the following option:
18150
18151@table @option
18152@item planes
18153Set which planes will be processed, unprocessed planes will be copied.
18154By default value 0xf, all planes will be processed.
18155@end table
18156
18157For example if first stream pixel's component value is less then threshold value
18158of pixel component from 2nd threshold stream, third stream value will picked,
18159otherwise fourth stream pixel component value will be picked.
18160
18161Using color source filter one can perform various types of thresholding:
18162
18163@subsection Examples
18164
18165@itemize
18166@item
18167Binary threshold, using gray color as threshold:
18168@example
18169ffmpeg -i 320x240.avi -f lavfi -i color=gray -f lavfi -i color=black -f lavfi -i color=white -lavfi threshold output.avi
18170@end example
18171
18172@item
18173Inverted binary threshold, using gray color as threshold:
18174@example
18175ffmpeg -i 320x240.avi -f lavfi -i color=gray -f lavfi -i color=white -f lavfi -i color=black -lavfi threshold output.avi
18176@end example
18177
18178@item
18179Truncate binary threshold, using gray color as threshold:
18180@example
18181ffmpeg -i 320x240.avi -f lavfi -i color=gray -i 320x240.avi -f lavfi -i color=gray -lavfi threshold output.avi
18182@end example
18183
18184@item
18185Threshold to zero, using gray color as threshold:
18186@example
18187ffmpeg -i 320x240.avi -f lavfi -i color=gray -f lavfi -i color=white -i 320x240.avi -lavfi threshold output.avi
18188@end example
18189
18190@item
18191Inverted threshold to zero, using gray color as threshold:
18192@example
18193ffmpeg -i 320x240.avi -f lavfi -i color=gray -i 320x240.avi -f lavfi -i color=white -lavfi threshold output.avi
18194@end example
18195@end itemize
18196
18197@section thumbnail
18198Select the most representative frame in a given sequence of consecutive frames.
18199
18200The filter accepts the following options:
18201
18202@table @option
18203@item n
18204Set the frames batch size to analyze; in a set of @var{n} frames, the filter
18205will pick one of them, and then handle the next batch of @var{n} frames until
18206the end. Default is @code{100}.
18207@end table
18208
18209Since the filter keeps track of the whole frames sequence, a bigger @var{n}
18210value will result in a higher memory usage, so a high value is not recommended.
18211
18212@subsection Examples
18213
18214@itemize
18215@item
18216Extract one picture each 50 frames:
18217@example
18218thumbnail=50
18219@end example
18220
18221@item
18222Complete example of a thumbnail creation with @command{ffmpeg}:
18223@example
18224ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
18225@end example
18226@end itemize
18227
18228@anchor{tile}
18229@section tile
18230
18231Tile several successive frames together.
18232
18233The @ref{untile} filter can do the reverse.
18234
18235The filter accepts the following options:
18236
18237@table @option
18238
18239@item layout
18240Set the grid size (i.e. the number of lines and columns). For the syntax of
18241this option, check the
18242@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
18243
18244@item nb_frames
18245Set the maximum number of frames to render in the given area. It must be less
18246than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
18247the area will be used.
18248
18249@item margin
18250Set the outer border margin in pixels.
18251
18252@item padding
18253Set the inner border thickness (i.e. the number of pixels between frames). For
18254more advanced padding options (such as having different values for the edges),
18255refer to the pad video filter.
18256
18257@item color
18258Specify the color of the unused area. For the syntax of this option, check the
18259@ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.
18260The default value of @var{color} is "black".
18261
18262@item overlap
18263Set the number of frames to overlap when tiling several successive frames together.
18264The value must be between @code{0} and @var{nb_frames - 1}.
18265
18266@item init_padding
18267Set the number of frames to initially be empty before displaying first output frame.
18268This controls how soon will one get first output frame.
18269The value must be between @code{0} and @var{nb_frames - 1}.
18270@end table
18271
18272@subsection Examples
18273
18274@itemize
18275@item
18276Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
18277@example
18278ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
18279@end example
18280The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
18281duplicating each output frame to accommodate the originally detected frame
18282rate.
18283
18284@item
18285Display @code{5} pictures in an area of @code{3x2} frames,
18286with @code{7} pixels between them, and @code{2} pixels of initial margin, using
18287mixed flat and named options:
18288@example
18289tile=3x2:nb_frames=5:padding=7:margin=2
18290@end example
18291@end itemize
18292
18293@section tinterlace
18294
18295Perform various types of temporal field interlacing.
18296
18297Frames are counted starting from 1, so the first input frame is
18298considered odd.
18299
18300The filter accepts the following options:
18301
18302@table @option
18303
18304@item mode
18305Specify the mode of the interlacing. This option can also be specified
18306as a value alone. See below for a list of values for this option.
18307
18308Available values are:
18309
18310@table @samp
18311@item merge, 0
18312Move odd frames into the upper field, even into the lower field,
18313generating a double height frame at half frame rate.
18314@example
18315 ------> time
18316Input:
18317Frame 1         Frame 2         Frame 3         Frame 4
18318
1831911111           22222           33333           44444
1832011111           22222           33333           44444
1832111111           22222           33333           44444
1832211111           22222           33333           44444
18323
18324Output:
1832511111                           33333
1832622222                           44444
1832711111                           33333
1832822222                           44444
1832911111                           33333
1833022222                           44444
1833111111                           33333
1833222222                           44444
18333@end example
18334
18335@item drop_even, 1
18336Only output odd frames, even frames are dropped, generating a frame with
18337unchanged height at half frame rate.
18338
18339@example
18340 ------> time
18341Input:
18342Frame 1         Frame 2         Frame 3         Frame 4
18343
1834411111           22222           33333           44444
1834511111           22222           33333           44444
1834611111           22222           33333           44444
1834711111           22222           33333           44444
18348
18349Output:
1835011111                           33333
1835111111                           33333
1835211111                           33333
1835311111                           33333
18354@end example
18355
18356@item drop_odd, 2
18357Only output even frames, odd frames are dropped, generating a frame with
18358unchanged height at half frame rate.
18359
18360@example
18361 ------> time
18362Input:
18363Frame 1         Frame 2         Frame 3         Frame 4
18364
1836511111           22222           33333           44444
1836611111           22222           33333           44444
1836711111           22222           33333           44444
1836811111           22222           33333           44444
18369
18370Output:
18371                22222                           44444
18372                22222                           44444
18373                22222                           44444
18374                22222                           44444
18375@end example
18376
18377@item pad, 3
18378Expand each frame to full height, but pad alternate lines with black,
18379generating a frame with double height at the same input frame rate.
18380
18381@example
18382 ------> time
18383Input:
18384Frame 1         Frame 2         Frame 3         Frame 4
18385
1838611111           22222           33333           44444
1838711111           22222           33333           44444
1838811111           22222           33333           44444
1838911111           22222           33333           44444
18390
18391Output:
1839211111           .....           33333           .....
18393.....           22222           .....           44444
1839411111           .....           33333           .....
18395.....           22222           .....           44444
1839611111           .....           33333           .....
18397.....           22222           .....           44444
1839811111           .....           33333           .....
18399.....           22222           .....           44444
18400@end example
18401
18402
18403@item interleave_top, 4
18404Interleave the upper field from odd frames with the lower field from
18405even frames, generating a frame with unchanged height at half frame rate.
18406
18407@example
18408 ------> time
18409Input:
18410Frame 1         Frame 2         Frame 3         Frame 4
18411
1841211111<-         22222           33333<-         44444
1841311111           22222<-         33333           44444<-
1841411111<-         22222           33333<-         44444
1841511111           22222<-         33333           44444<-
18416
18417Output:
1841811111                           33333
1841922222                           44444
1842011111                           33333
1842122222                           44444
18422@end example
18423
18424
18425@item interleave_bottom, 5
18426Interleave the lower field from odd frames with the upper field from
18427even frames, generating a frame with unchanged height at half frame rate.
18428
18429@example
18430 ------> time
18431Input:
18432Frame 1         Frame 2         Frame 3         Frame 4
18433
1843411111           22222<-         33333           44444<-
1843511111<-         22222           33333<-         44444
1843611111           22222<-         33333           44444<-
1843711111<-         22222           33333<-         44444
18438
18439Output:
1844022222                           44444
1844111111                           33333
1844222222                           44444
1844311111                           33333
18444@end example
18445
18446
18447@item interlacex2, 6
18448Double frame rate with unchanged height. Frames are inserted each
18449containing the second temporal field from the previous input frame and
18450the first temporal field from the next input frame. This mode relies on
18451the top_field_first flag. Useful for interlaced video displays with no
18452field synchronisation.
18453
18454@example
18455 ------> time
18456Input:
18457Frame 1         Frame 2         Frame 3         Frame 4
18458
1845911111           22222           33333           44444
18460 11111           22222           33333           44444
1846111111           22222           33333           44444
18462 11111           22222           33333           44444
18463
18464Output:
1846511111   22222   22222   33333   33333   44444   44444
18466 11111   11111   22222   22222   33333   33333   44444
1846711111   22222   22222   33333   33333   44444   44444
18468 11111   11111   22222   22222   33333   33333   44444
18469@end example
18470
18471
18472@item mergex2, 7
18473Move odd frames into the upper field, even into the lower field,
18474generating a double height frame at same frame rate.
18475
18476@example
18477 ------> time
18478Input:
18479Frame 1         Frame 2         Frame 3         Frame 4
18480
1848111111           22222           33333           44444
1848211111           22222           33333           44444
1848311111           22222           33333           44444
1848411111           22222           33333           44444
18485
18486Output:
1848711111           33333           33333           55555
1848822222           22222           44444           44444
1848911111           33333           33333           55555
1849022222           22222           44444           44444
1849111111           33333           33333           55555
1849222222           22222           44444           44444
1849311111           33333           33333           55555
1849422222           22222           44444           44444
18495@end example
18496
18497@end table
18498
18499Numeric values are deprecated but are accepted for backward
18500compatibility reasons.
18501
18502Default mode is @code{merge}.
18503
18504@item flags
18505Specify flags influencing the filter process.
18506
18507Available value for @var{flags} is:
18508
18509@table @option
18510@item low_pass_filter, vlpf
18511Enable linear vertical low-pass filtering in the filter.
18512Vertical low-pass filtering is required when creating an interlaced
18513destination from a progressive source which contains high-frequency
18514vertical detail. Filtering will reduce interlace 'twitter' and Moire
18515patterning.
18516
18517@item complex_filter, cvlpf
18518Enable complex vertical low-pass filtering.
18519This will slightly less reduce interlace 'twitter' and Moire
18520patterning but better retain detail and subjective sharpness impression.
18521
18522@item bypass_il
18523Bypass already interlaced frames, only adjust the frame rate.
18524@end table
18525
18526Vertical low-pass filtering and bypassing already interlaced frames can only be
18527enabled for @option{mode} @var{interleave_top} and @var{interleave_bottom}.
18528
18529@end table
18530
18531@section tmedian
18532Pick median pixels from several successive input video frames.
18533
18534The filter accepts the following options:
18535
18536@table @option
18537@item radius
18538Set radius of median filter.
18539Default is 1. Allowed range is from 1 to 127.
18540
18541@item planes
18542Set which planes to filter. Default value is @code{15}, by which all planes are processed.
18543
18544@item percentile
18545Set median percentile. Default value is @code{0.5}.
18546Default value of @code{0.5} will pick always median values, while @code{0} will pick
18547minimum values, and @code{1} maximum values.
18548@end table
18549
18550@section tmix
18551
18552Mix successive video frames.
18553
18554A description of the accepted options follows.
18555
18556@table @option
18557@item frames
18558The number of successive frames to mix. If unspecified, it defaults to 3.
18559
18560@item weights
18561Specify weight of each input video frame.
18562Each weight is separated by space. If number of weights is smaller than
18563number of @var{frames} last specified weight will be used for all remaining
18564unset weights.
18565
18566@item scale
18567Specify scale, if it is set it will be multiplied with sum
18568of each weight multiplied with pixel values to give final destination
18569pixel value. By default @var{scale} is auto scaled to sum of weights.
18570@end table
18571
18572@subsection Examples
18573
18574@itemize
18575@item
18576Average 7 successive frames:
18577@example
18578tmix=frames=7:weights="1 1 1 1 1 1 1"
18579@end example
18580
18581@item
18582Apply simple temporal convolution:
18583@example
18584tmix=frames=3:weights="-1 3 -1"
18585@end example
18586
18587@item
18588Similar as above but only showing temporal differences:
18589@example
18590tmix=frames=3:weights="-1 2 -1":scale=1
18591@end example
18592@end itemize
18593
18594@anchor{tonemap}
18595@section tonemap
18596Tone map colors from different dynamic ranges.
18597
18598This filter expects data in single precision floating point, as it needs to
18599operate on (and can output) out-of-range values. Another filter, such as
18600@ref{zscale}, is needed to convert the resulting frame to a usable format.
18601
18602The tonemapping algorithms implemented only work on linear light, so input
18603data should be linearized beforehand (and possibly correctly tagged).
18604
18605@example
18606ffmpeg -i INPUT -vf zscale=transfer=linear,tonemap=clip,zscale=transfer=bt709,format=yuv420p OUTPUT
18607@end example
18608
18609@subsection Options
18610The filter accepts the following options.
18611
18612@table @option
18613@item tonemap
18614Set the tone map algorithm to use.
18615
18616Possible values are:
18617@table @var
18618@item none
18619Do not apply any tone map, only desaturate overbright pixels.
18620
18621@item clip
18622Hard-clip any out-of-range values. Use it for perfect color accuracy for
18623in-range values, while distorting out-of-range values.
18624
18625@item linear
18626Stretch the entire reference gamut to a linear multiple of the display.
18627
18628@item gamma
18629Fit a logarithmic transfer between the tone curves.
18630
18631@item reinhard
18632Preserve overall image brightness with a simple curve, using nonlinear
18633contrast, which results in flattening details and degrading color accuracy.
18634
18635@item hable
18636Preserve both dark and bright details better than @var{reinhard}, at the cost
18637of slightly darkening everything. Use it when detail preservation is more
18638important than color and brightness accuracy.
18639
18640@item mobius
18641Smoothly map out-of-range values, while retaining contrast and colors for
18642in-range material as much as possible. Use it when color accuracy is more
18643important than detail preservation.
18644@end table
18645
18646Default is none.
18647
18648@item param
18649Tune the tone mapping algorithm.
18650
18651This affects the following algorithms:
18652@table @var
18653@item none
18654Ignored.
18655
18656@item linear
18657Specifies the scale factor to use while stretching.
18658Default to 1.0.
18659
18660@item gamma
18661Specifies the exponent of the function.
18662Default to 1.8.
18663
18664@item clip
18665Specify an extra linear coefficient to multiply into the signal before clipping.
18666Default to 1.0.
18667
18668@item reinhard
18669Specify the local contrast coefficient at the display peak.
18670Default to 0.5, which means that in-gamut values will be about half as bright
18671as when clipping.
18672
18673@item hable
18674Ignored.
18675
18676@item mobius
18677Specify the transition point from linear to mobius transform. Every value
18678below this point is guaranteed to be mapped 1:1. The higher the value, the
18679more accurate the result will be, at the cost of losing bright details.
18680Default to 0.3, which due to the steep initial slope still preserves in-range
18681colors fairly accurately.
18682@end table
18683
18684@item desat
18685Apply desaturation for highlights that exceed this level of brightness. The
18686higher the parameter, the more color information will be preserved. This
18687setting helps prevent unnaturally blown-out colors for super-highlights, by
18688(smoothly) turning into white instead. This makes images feel more natural,
18689at the cost of reducing information about out-of-range colors.
18690
18691The default of 2.0 is somewhat conservative and will mostly just apply to
18692skies or directly sunlit surfaces. A setting of 0.0 disables this option.
18693
18694This option works only if the input frame has a supported color tag.
18695
18696@item peak
18697Override signal/nominal/reference peak with this value. Useful when the
18698embedded peak information in display metadata is not reliable or when tone
18699mapping from a lower range to a higher range.
18700@end table
18701
18702@section tpad
18703
18704Temporarily pad video frames.
18705
18706The filter accepts the following options:
18707
18708@table @option
18709@item start
18710Specify number of delay frames before input video stream. Default is 0.
18711
18712@item stop
18713Specify number of padding frames after input video stream.
18714Set to -1 to pad indefinitely. Default is 0.
18715
18716@item start_mode
18717Set kind of frames added to beginning of stream.
18718Can be either @var{add} or @var{clone}.
18719With @var{add} frames of solid-color are added.
18720With @var{clone} frames are clones of first frame.
18721Default is @var{add}.
18722
18723@item stop_mode
18724Set kind of frames added to end of stream.
18725Can be either @var{add} or @var{clone}.
18726With @var{add} frames of solid-color are added.
18727With @var{clone} frames are clones of last frame.
18728Default is @var{add}.
18729
18730@item start_duration, stop_duration
18731Specify the duration of the start/stop delay. See
18732@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
18733for the accepted syntax.
18734These options override @var{start} and @var{stop}. Default is 0.
18735
18736@item color
18737Specify the color of the padded area. For the syntax of this option,
18738check the @ref{color syntax,,"Color" section in the ffmpeg-utils
18739manual,ffmpeg-utils}.
18740
18741The default value of @var{color} is "black".
18742@end table
18743
18744@anchor{transpose}
18745@section transpose
18746
18747Transpose rows with columns in the input video and optionally flip it.
18748
18749It accepts the following parameters:
18750
18751@table @option
18752
18753@item dir
18754Specify the transposition direction.
18755
18756Can assume the following values:
18757@table @samp
18758@item 0, 4, cclock_flip
18759Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
18760@example
18761L.R     L.l
18762. . ->  . .
18763l.r     R.r
18764@end example
18765
18766@item 1, 5, clock
18767Rotate by 90 degrees clockwise, that is:
18768@example
18769L.R     l.L
18770. . ->  . .
18771l.r     r.R
18772@end example
18773
18774@item 2, 6, cclock
18775Rotate by 90 degrees counterclockwise, that is:
18776@example
18777L.R     R.r
18778. . ->  . .
18779l.r     L.l
18780@end example
18781
18782@item 3, 7, clock_flip
18783Rotate by 90 degrees clockwise and vertically flip, that is:
18784@example
18785L.R     r.R
18786. . ->  . .
18787l.r     l.L
18788@end example
18789@end table
18790
18791For values between 4-7, the transposition is only done if the input
18792video geometry is portrait and not landscape. These values are
18793deprecated, the @code{passthrough} option should be used instead.
18794
18795Numerical values are deprecated, and should be dropped in favor of
18796symbolic constants.
18797
18798@item passthrough
18799Do not apply the transposition if the input geometry matches the one
18800specified by the specified value. It accepts the following values:
18801@table @samp
18802@item none
18803Always apply transposition.
18804@item portrait
18805Preserve portrait geometry (when @var{height} >= @var{width}).
18806@item landscape
18807Preserve landscape geometry (when @var{width} >= @var{height}).
18808@end table
18809
18810Default value is @code{none}.
18811@end table
18812
18813For example to rotate by 90 degrees clockwise and preserve portrait
18814layout:
18815@example
18816transpose=dir=1:passthrough=portrait
18817@end example
18818
18819The command above can also be specified as:
18820@example
18821transpose=1:portrait
18822@end example
18823
18824@section transpose_npp
18825
18826Transpose rows with columns in the input video and optionally flip it.
18827For more in depth examples see the @ref{transpose} video filter, which shares mostly the same options.
18828
18829It accepts the following parameters:
18830
18831@table @option
18832
18833@item dir
18834Specify the transposition direction.
18835
18836Can assume the following values:
18837@table @samp
18838@item cclock_flip
18839Rotate by 90 degrees counterclockwise and vertically flip. (default)
18840
18841@item clock
18842Rotate by 90 degrees clockwise.
18843
18844@item cclock
18845Rotate by 90 degrees counterclockwise.
18846
18847@item clock_flip
18848Rotate by 90 degrees clockwise and vertically flip.
18849@end table
18850
18851@item passthrough
18852Do not apply the transposition if the input geometry matches the one
18853specified by the specified value. It accepts the following values:
18854@table @samp
18855@item none
18856Always apply transposition. (default)
18857@item portrait
18858Preserve portrait geometry (when @var{height} >= @var{width}).
18859@item landscape
18860Preserve landscape geometry (when @var{width} >= @var{height}).
18861@end table
18862
18863@end table
18864
18865@section trim
18866Trim the input so that the output contains one continuous subpart of the input.
18867
18868It accepts the following parameters:
18869@table @option
18870@item start
18871Specify the time of the start of the kept section, i.e. the frame with the
18872timestamp @var{start} will be the first frame in the output.
18873
18874@item end
18875Specify the time of the first frame that will be dropped, i.e. the frame
18876immediately preceding the one with the timestamp @var{end} will be the last
18877frame in the output.
18878
18879@item start_pts
18880This is the same as @var{start}, except this option sets the start timestamp
18881in timebase units instead of seconds.
18882
18883@item end_pts
18884This is the same as @var{end}, except this option sets the end timestamp
18885in timebase units instead of seconds.
18886
18887@item duration
18888The maximum duration of the output in seconds.
18889
18890@item start_frame
18891The number of the first frame that should be passed to the output.
18892
18893@item end_frame
18894The number of the first frame that should be dropped.
18895@end table
18896
18897@option{start}, @option{end}, and @option{duration} are expressed as time
18898duration specifications; see
18899@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
18900for the accepted syntax.
18901
18902Note that the first two sets of the start/end options and the @option{duration}
18903option look at the frame timestamp, while the _frame variants simply count the
18904frames that pass through the filter. Also note that this filter does not modify
18905the timestamps. If you wish for the output timestamps to start at zero, insert a
18906setpts filter after the trim filter.
18907
18908If multiple start or end options are set, this filter tries to be greedy and
18909keep all the frames that match at least one of the specified constraints. To keep
18910only the part that matches all the constraints at once, chain multiple trim
18911filters.
18912
18913The defaults are such that all the input is kept. So it is possible to set e.g.
18914just the end values to keep everything before the specified time.
18915
18916Examples:
18917@itemize
18918@item
18919Drop everything except the second minute of input:
18920@example
18921ffmpeg -i INPUT -vf trim=60:120
18922@end example
18923
18924@item
18925Keep only the first second:
18926@example
18927ffmpeg -i INPUT -vf trim=duration=1
18928@end example
18929
18930@end itemize
18931
18932@section unpremultiply
18933Apply alpha unpremultiply effect to input video stream using first plane
18934of second stream as alpha.
18935
18936Both streams must have same dimensions and same pixel format.
18937
18938The filter accepts the following option:
18939
18940@table @option
18941@item planes
18942Set which planes will be processed, unprocessed planes will be copied.
18943By default value 0xf, all planes will be processed.
18944
18945If the format has 1 or 2 components, then luma is bit 0.
18946If the format has 3 or 4 components:
18947for RGB formats bit 0 is green, bit 1 is blue and bit 2 is red;
18948for YUV formats bit 0 is luma, bit 1 is chroma-U and bit 2 is chroma-V.
18949If present, the alpha channel is always the last bit.
18950
18951@item inplace
18952Do not require 2nd input for processing, instead use alpha plane from input stream.
18953@end table
18954
18955@anchor{unsharp}
18956@section unsharp
18957
18958Sharpen or blur the input video.
18959
18960It accepts the following parameters:
18961
18962@table @option
18963@item luma_msize_x, lx
18964Set the luma matrix horizontal size. It must be an odd integer between
189653 and 23. The default value is 5.
18966
18967@item luma_msize_y, ly
18968Set the luma matrix vertical size. It must be an odd integer between 3
18969and 23. The default value is 5.
18970
18971@item luma_amount, la
18972Set the luma effect strength. It must be a floating point number, reasonable
18973values lay between -1.5 and 1.5.
18974
18975Negative values will blur the input video, while positive values will
18976sharpen it, a value of zero will disable the effect.
18977
18978Default value is 1.0.
18979
18980@item chroma_msize_x, cx
18981Set the chroma matrix horizontal size. It must be an odd integer
18982between 3 and 23. The default value is 5.
18983
18984@item chroma_msize_y, cy
18985Set the chroma matrix vertical size. It must be an odd integer
18986between 3 and 23. The default value is 5.
18987
18988@item chroma_amount, ca
18989Set the chroma effect strength. It must be a floating point number, reasonable
18990values lay between -1.5 and 1.5.
18991
18992Negative values will blur the input video, while positive values will
18993sharpen it, a value of zero will disable the effect.
18994
18995Default value is 0.0.
18996
18997@end table
18998
18999All parameters are optional and default to the equivalent of the
19000string '5:5:1.0:5:5:0.0'.
19001
19002@subsection Examples
19003
19004@itemize
19005@item
19006Apply strong luma sharpen effect:
19007@example
19008unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
19009@end example
19010
19011@item
19012Apply a strong blur of both luma and chroma parameters:
19013@example
19014unsharp=7:7:-2:7:7:-2
19015@end example
19016@end itemize
19017
19018@anchor{untile}
19019@section untile
19020
19021Decompose a video made of tiled images into the individual images.
19022
19023The frame rate of the output video is the frame rate of the input video
19024multiplied by the number of tiles.
19025
19026This filter does the reverse of @ref{tile}.
19027
19028The filter accepts the following options:
19029
19030@table @option
19031
19032@item layout
19033Set the grid size (i.e. the number of lines and columns). For the syntax of
19034this option, check the
19035@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
19036@end table
19037
19038@subsection Examples
19039
19040@itemize
19041@item
19042Produce a 1-second video from a still image file made of 25 frames stacked
19043vertically, like an analogic film reel:
19044@example
19045ffmpeg -r 1 -i image.jpg -vf untile=1x25 movie.mkv
19046@end example
19047@end itemize
19048
19049@section uspp
19050
19051Apply ultra slow/simple postprocessing filter that compresses and decompresses
19052the image at several (or - in the case of @option{quality} level @code{8} - all)
19053shifts and average the results.
19054
19055The way this differs from the behavior of spp is that uspp actually encodes &
19056decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
19057DCT similar to MJPEG.
19058
19059The filter accepts the following options:
19060
19061@table @option
19062@item quality
19063Set quality. This option defines the number of levels for averaging. It accepts
19064an integer in the range 0-8. If set to @code{0}, the filter will have no
19065effect. A value of @code{8} means the higher quality. For each increment of
19066that value the speed drops by a factor of approximately 2.  Default value is
19067@code{3}.
19068
19069@item qp
19070Force a constant quantization parameter. If not set, the filter will use the QP
19071from the video stream (if available).
19072@end table
19073
19074@section v360
19075
19076Convert 360 videos between various formats.
19077
19078The filter accepts the following options:
19079
19080@table @option
19081
19082@item input
19083@item output
19084Set format of the input/output video.
19085
19086Available formats:
19087
19088@table @samp
19089
19090@item e
19091@item equirect
19092Equirectangular projection.
19093
19094@item c3x2
19095@item c6x1
19096@item c1x6
19097Cubemap with 3x2/6x1/1x6 layout.
19098
19099Format specific options:
19100
19101@table @option
19102@item in_pad
19103@item out_pad
19104Set padding proportion for the input/output cubemap. Values in decimals.
19105
19106Example values:
19107@table @samp
19108@item 0
19109No padding.
19110@item 0.01
191111% of face is padding. For example, with 1920x1280 resolution face size would be 640x640 and padding would be 3 pixels from each side. (640 * 0.01 = 6 pixels)
19112@end table
19113
19114Default value is @b{@samp{0}}.
19115Maximum value is @b{@samp{0.1}}.
19116
19117@item fin_pad
19118@item fout_pad
19119Set fixed padding for the input/output cubemap. Values in pixels.
19120
19121Default value is @b{@samp{0}}. If greater than zero it overrides other padding options.
19122
19123@item in_forder
19124@item out_forder
19125Set order of faces for the input/output cubemap. Choose one direction for each position.
19126
19127Designation of directions:
19128@table @samp
19129@item r
19130right
19131@item l
19132left
19133@item u
19134up
19135@item d
19136down
19137@item f
19138forward
19139@item b
19140back
19141@end table
19142
19143Default value is @b{@samp{rludfb}}.
19144
19145@item in_frot
19146@item out_frot
19147Set rotation of faces for the input/output cubemap. Choose one angle for each position.
19148
19149Designation of angles:
19150@table @samp
19151@item 0
191520 degrees clockwise
19153@item 1
1915490 degrees clockwise
19155@item 2
19156180 degrees clockwise
19157@item 3
19158270 degrees clockwise
19159@end table
19160
19161Default value is @b{@samp{000000}}.
19162@end table
19163
19164@item eac
19165Equi-Angular Cubemap.
19166
19167@item flat
19168@item gnomonic
19169@item rectilinear
19170Regular video.
19171
19172Format specific options:
19173@table @option
19174@item h_fov
19175@item v_fov
19176@item d_fov
19177Set output horizontal/vertical/diagonal field of view. Values in degrees.
19178
19179If diagonal field of view is set it overrides horizontal and vertical field of view.
19180
19181@item ih_fov
19182@item iv_fov
19183@item id_fov
19184Set input horizontal/vertical/diagonal field of view. Values in degrees.
19185
19186If diagonal field of view is set it overrides horizontal and vertical field of view.
19187@end table
19188
19189@item dfisheye
19190Dual fisheye.
19191
19192Format specific options:
19193@table @option
19194@item h_fov
19195@item v_fov
19196@item d_fov
19197Set output horizontal/vertical/diagonal field of view. Values in degrees.
19198
19199If diagonal field of view is set it overrides horizontal and vertical field of view.
19200
19201@item ih_fov
19202@item iv_fov
19203@item id_fov
19204Set input horizontal/vertical/diagonal field of view. Values in degrees.
19205
19206If diagonal field of view is set it overrides horizontal and vertical field of view.
19207@end table
19208
19209@item barrel
19210@item fb
19211@item barrelsplit
19212Facebook's 360 formats.
19213
19214@item sg
19215Stereographic format.
19216
19217Format specific options:
19218@table @option
19219@item h_fov
19220@item v_fov
19221@item d_fov
19222Set output horizontal/vertical/diagonal field of view. Values in degrees.
19223
19224If diagonal field of view is set it overrides horizontal and vertical field of view.
19225
19226@item ih_fov
19227@item iv_fov
19228@item id_fov
19229Set input horizontal/vertical/diagonal field of view. Values in degrees.
19230
19231If diagonal field of view is set it overrides horizontal and vertical field of view.
19232@end table
19233
19234@item mercator
19235Mercator format.
19236
19237@item ball
19238Ball format, gives significant distortion toward the back.
19239
19240@item hammer
19241Hammer-Aitoff map projection format.
19242
19243@item sinusoidal
19244Sinusoidal map projection format.
19245
19246@item fisheye
19247Fisheye projection.
19248
19249Format specific options:
19250@table @option
19251@item h_fov
19252@item v_fov
19253@item d_fov
19254Set output horizontal/vertical/diagonal field of view. Values in degrees.
19255
19256If diagonal field of view is set it overrides horizontal and vertical field of view.
19257
19258@item ih_fov
19259@item iv_fov
19260@item id_fov
19261Set input horizontal/vertical/diagonal field of view. Values in degrees.
19262
19263If diagonal field of view is set it overrides horizontal and vertical field of view.
19264@end table
19265
19266@item pannini
19267Pannini projection.
19268
19269Format specific options:
19270@table @option
19271@item h_fov
19272Set output pannini parameter.
19273
19274@item ih_fov
19275Set input pannini parameter.
19276@end table
19277
19278@item cylindrical
19279Cylindrical projection.
19280
19281Format specific options:
19282@table @option
19283@item h_fov
19284@item v_fov
19285@item d_fov
19286Set output horizontal/vertical/diagonal field of view. Values in degrees.
19287
19288If diagonal field of view is set it overrides horizontal and vertical field of view.
19289
19290@item ih_fov
19291@item iv_fov
19292@item id_fov
19293Set input horizontal/vertical/diagonal field of view. Values in degrees.
19294
19295If diagonal field of view is set it overrides horizontal and vertical field of view.
19296@end table
19297
19298@item perspective
19299Perspective projection. @i{(output only)}
19300
19301Format specific options:
19302@table @option
19303@item v_fov
19304Set perspective parameter.
19305@end table
19306
19307@item tetrahedron
19308Tetrahedron projection.
19309
19310@item tsp
19311Truncated square pyramid projection.
19312
19313@item he
19314@item hequirect
19315Half equirectangular projection.
19316@end table
19317
19318@item interp
19319Set interpolation method.@*
19320@i{Note: more complex interpolation methods require much more memory to run.}
19321
19322Available methods:
19323
19324@table @samp
19325@item near
19326@item nearest
19327Nearest neighbour.
19328@item line
19329@item linear
19330Bilinear interpolation.
19331@item lagrange9
19332Lagrange9 interpolation.
19333@item cube
19334@item cubic
19335Bicubic interpolation.
19336@item lanc
19337@item lanczos
19338Lanczos interpolation.
19339@item sp16
19340@item spline16
19341Spline16 interpolation.
19342@item gauss
19343@item gaussian
19344Gaussian interpolation.
19345@end table
19346
19347Default value is @b{@samp{line}}.
19348
19349@item w
19350@item h
19351Set the output video resolution.
19352
19353Default resolution depends on formats.
19354
19355@item in_stereo
19356@item out_stereo
19357Set the input/output stereo format.
19358
19359@table @samp
19360@item 2d
193612D mono
19362@item sbs
19363Side by side
19364@item tb
19365Top bottom
19366@end table
19367
19368Default value is @b{@samp{2d}} for input and output format.
19369
19370@item yaw
19371@item pitch
19372@item roll
19373Set rotation for the output video. Values in degrees.
19374
19375@item rorder
19376Set rotation order for the output video. Choose one item for each position.
19377
19378@table @samp
19379@item y, Y
19380yaw
19381@item p, P
19382pitch
19383@item r, R
19384roll
19385@end table
19386
19387Default value is @b{@samp{ypr}}.
19388
19389@item h_flip
19390@item v_flip
19391@item d_flip
19392Flip the output video horizontally(swaps left-right)/vertically(swaps up-down)/in-depth(swaps back-forward). Boolean values.
19393
19394@item ih_flip
19395@item iv_flip
19396Set if input video is flipped horizontally/vertically. Boolean values.
19397
19398@item in_trans
19399Set if input video is transposed. Boolean value, by default disabled.
19400
19401@item out_trans
19402Set if output video needs to be transposed. Boolean value, by default disabled.
19403
19404@item alpha_mask
19405Build mask in alpha plane for all unmapped pixels by marking them fully transparent. Boolean value, by default disabled.
19406@end table
19407
19408@subsection Examples
19409
19410@itemize
19411@item
19412Convert equirectangular video to cubemap with 3x2 layout and 1% padding using bicubic interpolation:
19413@example
19414ffmpeg -i input.mkv -vf v360=e:c3x2:cubic:out_pad=0.01 output.mkv
19415@end example
19416@item
19417Extract back view of Equi-Angular Cubemap:
19418@example
19419ffmpeg -i input.mkv -vf v360=eac:flat:yaw=180 output.mkv
19420@end example
19421@item
19422Convert transposed and horizontally flipped Equi-Angular Cubemap in side-by-side stereo format to equirectangular top-bottom stereo format:
19423@example
19424v360=eac:equirect:in_stereo=sbs:in_trans=1:ih_flip=1:out_stereo=tb
19425@end example
19426@end itemize
19427
19428@subsection Commands
19429
19430This filter supports subset of above options as @ref{commands}.
19431
19432@section vaguedenoiser
19433
19434Apply a wavelet based denoiser.
19435
19436It transforms each frame from the video input into the wavelet domain,
19437using Cohen-Daubechies-Feauveau 9/7. Then it applies some filtering to
19438the obtained coefficients. It does an inverse wavelet transform after.
19439Due to wavelet properties, it should give a nice smoothed result, and
19440reduced noise, without blurring picture features.
19441
19442This filter accepts the following options:
19443
19444@table @option
19445@item threshold
19446The filtering strength. The higher, the more filtered the video will be.
19447Hard thresholding can use a higher threshold than soft thresholding
19448before the video looks overfiltered. Default value is 2.
19449
19450@item method
19451The filtering method the filter will use.
19452
19453It accepts the following values:
19454@table @samp
19455@item hard
19456All values under the threshold will be zeroed.
19457
19458@item soft
19459All values under the threshold will be zeroed. All values above will be
19460reduced by the threshold.
19461
19462@item garrote
19463Scales or nullifies coefficients - intermediary between (more) soft and
19464(less) hard thresholding.
19465@end table
19466
19467Default is garrote.
19468
19469@item nsteps
19470Number of times, the wavelet will decompose the picture. Picture can't
19471be decomposed beyond a particular point (typically, 8 for a 640x480
19472frame - as 2^9 = 512 > 480). Valid values are integers between 1 and 32. Default value is 6.
19473
19474@item percent
19475Partial of full denoising (limited coefficients shrinking), from 0 to 100. Default value is 85.
19476
19477@item planes
19478A list of the planes to process. By default all planes are processed.
19479
19480@item type
19481The threshold type the filter will use.
19482
19483It accepts the following values:
19484@table @samp
19485@item universal
19486Threshold used is same for all decompositions.
19487
19488@item bayes
19489Threshold used depends also on each decomposition coefficients.
19490@end table
19491
19492Default is universal.
19493@end table
19494
19495@section vectorscope
19496
19497Display 2 color component values in the two dimensional graph (which is called
19498a vectorscope).
19499
19500This filter accepts the following options:
19501
19502@table @option
19503@item mode, m
19504Set vectorscope mode.
19505
19506It accepts the following values:
19507@table @samp
19508@item gray
19509@item tint
19510Gray values are displayed on graph, higher brightness means more pixels have
19511same component color value on location in graph. This is the default mode.
19512
19513@item color
19514Gray values are displayed on graph. Surrounding pixels values which are not
19515present in video frame are drawn in gradient of 2 color components which are
19516set by option @code{x} and @code{y}. The 3rd color component is static.
19517
19518@item color2
19519Actual color components values present in video frame are displayed on graph.
19520
19521@item color3
19522Similar as color2 but higher frequency of same values @code{x} and @code{y}
19523on graph increases value of another color component, which is luminance by
19524default values of @code{x} and @code{y}.
19525
19526@item color4
19527Actual colors present in video frame are displayed on graph. If two different
19528colors map to same position on graph then color with higher value of component
19529not present in graph is picked.
19530
19531@item color5
19532Gray values are displayed on graph. Similar to @code{color} but with 3rd color
19533component picked from radial gradient.
19534@end table
19535
19536@item x
19537Set which color component will be represented on X-axis. Default is @code{1}.
19538
19539@item y
19540Set which color component will be represented on Y-axis. Default is @code{2}.
19541
19542@item intensity, i
19543Set intensity, used by modes: gray, color, color3 and color5 for increasing brightness
19544of color component which represents frequency of (X, Y) location in graph.
19545
19546@item envelope, e
19547@table @samp
19548@item none
19549No envelope, this is default.
19550
19551@item instant
19552Instant envelope, even darkest single pixel will be clearly highlighted.
19553
19554@item peak
19555Hold maximum and minimum values presented in graph over time. This way you
19556can still spot out of range values without constantly looking at vectorscope.
19557
19558@item peak+instant
19559Peak and instant envelope combined together.
19560@end table
19561
19562@item graticule, g
19563Set what kind of graticule to draw.
19564@table @samp
19565@item none
19566@item green
19567@item color
19568@item invert
19569@end table
19570
19571@item opacity, o
19572Set graticule opacity.
19573
19574@item flags, f
19575Set graticule flags.
19576
19577@table @samp
19578@item white
19579Draw graticule for white point.
19580
19581@item black
19582Draw graticule for black point.
19583
19584@item name
19585Draw color points short names.
19586@end table
19587
19588@item bgopacity, b
19589Set background opacity.
19590
19591@item lthreshold, l
19592Set low threshold for color component not represented on X or Y axis.
19593Values lower than this value will be ignored. Default is 0.
19594Note this value is multiplied with actual max possible value one pixel component
19595can have. So for 8-bit input and low threshold value of 0.1 actual threshold
19596is 0.1 * 255 = 25.
19597
19598@item hthreshold, h
19599Set high threshold for color component not represented on X or Y axis.
19600Values higher than this value will be ignored. Default is 1.
19601Note this value is multiplied with actual max possible value one pixel component
19602can have. So for 8-bit input and high threshold value of 0.9 actual threshold
19603is 0.9 * 255 = 230.
19604
19605@item colorspace, c
19606Set what kind of colorspace to use when drawing graticule.
19607@table @samp
19608@item auto
19609@item 601
19610@item 709
19611@end table
19612Default is auto.
19613
19614@item tint0, t0
19615@item tint1, t1
19616Set color tint for gray/tint vectorscope mode. By default both options are zero.
19617This means no tint, and output will remain gray.
19618@end table
19619
19620@anchor{vidstabdetect}
19621@section vidstabdetect
19622
19623Analyze video stabilization/deshaking. Perform pass 1 of 2, see
19624@ref{vidstabtransform} for pass 2.
19625
19626This filter generates a file with relative translation and rotation
19627transform information about subsequent frames, which is then used by
19628the @ref{vidstabtransform} filter.
19629
19630To enable compilation of this filter you need to configure FFmpeg with
19631@code{--enable-libvidstab}.
19632
19633This filter accepts the following options:
19634
19635@table @option
19636@item result
19637Set the path to the file used to write the transforms information.
19638Default value is @file{transforms.trf}.
19639
19640@item shakiness
19641Set how shaky the video is and how quick the camera is. It accepts an
19642integer in the range 1-10, a value of 1 means little shakiness, a
19643value of 10 means strong shakiness. Default value is 5.
19644
19645@item accuracy
19646Set the accuracy of the detection process. It must be a value in the
19647range 1-15. A value of 1 means low accuracy, a value of 15 means high
19648accuracy. Default value is 15.
19649
19650@item stepsize
19651Set stepsize of the search process. The region around minimum is
19652scanned with 1 pixel resolution. Default value is 6.
19653
19654@item mincontrast
19655Set minimum contrast. Below this value a local measurement field is
19656discarded. Must be a floating point value in the range 0-1. Default
19657value is 0.3.
19658
19659@item tripod
19660Set reference frame number for tripod mode.
19661
19662If enabled, the motion of the frames is compared to a reference frame
19663in the filtered stream, identified by the specified number. The idea
19664is to compensate all movements in a more-or-less static scene and keep
19665the camera view absolutely still.
19666
19667If set to 0, it is disabled. The frames are counted starting from 1.
19668
19669@item show
19670Show fields and transforms in the resulting frames. It accepts an
19671integer in the range 0-2. Default value is 0, which disables any
19672visualization.
19673@end table
19674
19675@subsection Examples
19676
19677@itemize
19678@item
19679Use default values:
19680@example
19681vidstabdetect
19682@end example
19683
19684@item
19685Analyze strongly shaky movie and put the results in file
19686@file{mytransforms.trf}:
19687@example
19688vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
19689@end example
19690
19691@item
19692Visualize the result of internal transformations in the resulting
19693video:
19694@example
19695vidstabdetect=show=1
19696@end example
19697
19698@item
19699Analyze a video with medium shakiness using @command{ffmpeg}:
19700@example
19701ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
19702@end example
19703@end itemize
19704
19705@anchor{vidstabtransform}
19706@section vidstabtransform
19707
19708Video stabilization/deshaking: pass 2 of 2,
19709see @ref{vidstabdetect} for pass 1.
19710
19711Read a file with transform information for each frame and
19712apply/compensate them. Together with the @ref{vidstabdetect}
19713filter this can be used to deshake videos. See also
19714@url{http://public.hronopik.de/vid.stab}. It is important to also use
19715the @ref{unsharp} filter, see below.
19716
19717To enable compilation of this filter you need to configure FFmpeg with
19718@code{--enable-libvidstab}.
19719
19720@subsection Options
19721
19722@table @option
19723@item input
19724Set path to the file used to read the transforms. Default value is
19725@file{transforms.trf}.
19726
19727@item smoothing
19728Set the number of frames (value*2 + 1) used for lowpass filtering the
19729camera movements. Default value is 10.
19730
19731For example a number of 10 means that 21 frames are used (10 in the
19732past and 10 in the future) to smoothen the motion in the video. A
19733larger value leads to a smoother video, but limits the acceleration of
19734the camera (pan/tilt movements). 0 is a special case where a static
19735camera is simulated.
19736
19737@item optalgo
19738Set the camera path optimization algorithm.
19739
19740Accepted values are:
19741@table @samp
19742@item gauss
19743gaussian kernel low-pass filter on camera motion (default)
19744@item avg
19745averaging on transformations
19746@end table
19747
19748@item maxshift
19749Set maximal number of pixels to translate frames. Default value is -1,
19750meaning no limit.
19751
19752@item maxangle
19753Set maximal angle in radians (degree*PI/180) to rotate frames. Default
19754value is -1, meaning no limit.
19755
19756@item crop
19757Specify how to deal with borders that may be visible due to movement
19758compensation.
19759
19760Available values are:
19761@table @samp
19762@item keep
19763keep image information from previous frame (default)
19764@item black
19765fill the border black
19766@end table
19767
19768@item invert
19769Invert transforms if set to 1. Default value is 0.
19770
19771@item relative
19772Consider transforms as relative to previous frame if set to 1,
19773absolute if set to 0. Default value is 0.
19774
19775@item zoom
19776Set percentage to zoom. A positive value will result in a zoom-in
19777effect, a negative value in a zoom-out effect. Default value is 0 (no
19778zoom).
19779
19780@item optzoom
19781Set optimal zooming to avoid borders.
19782
19783Accepted values are:
19784@table @samp
19785@item 0
19786disabled
19787@item 1
19788optimal static zoom value is determined (only very strong movements
19789will lead to visible borders) (default)
19790@item 2
19791optimal adaptive zoom value is determined (no borders will be
19792visible), see @option{zoomspeed}
19793@end table
19794
19795Note that the value given at zoom is added to the one calculated here.
19796
19797@item zoomspeed
19798Set percent to zoom maximally each frame (enabled when
19799@option{optzoom} is set to 2). Range is from 0 to 5, default value is
198000.25.
19801
19802@item interpol
19803Specify type of interpolation.
19804
19805Available values are:
19806@table @samp
19807@item no
19808no interpolation
19809@item linear
19810linear only horizontal
19811@item bilinear
19812linear in both directions (default)
19813@item bicubic
19814cubic in both directions (slow)
19815@end table
19816
19817@item tripod
19818Enable virtual tripod mode if set to 1, which is equivalent to
19819@code{relative=0:smoothing=0}. Default value is 0.
19820
19821Use also @code{tripod} option of @ref{vidstabdetect}.
19822
19823@item debug
19824Increase log verbosity if set to 1. Also the detected global motions
19825are written to the temporary file @file{global_motions.trf}. Default
19826value is 0.
19827@end table
19828
19829@subsection Examples
19830
19831@itemize
19832@item
19833Use @command{ffmpeg} for a typical stabilization with default values:
19834@example
19835ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
19836@end example
19837
19838Note the use of the @ref{unsharp} filter which is always recommended.
19839
19840@item
19841Zoom in a bit more and load transform data from a given file:
19842@example
19843vidstabtransform=zoom=5:input="mytransforms.trf"
19844@end example
19845
19846@item
19847Smoothen the video even more:
19848@example
19849vidstabtransform=smoothing=30
19850@end example
19851@end itemize
19852
19853@section vflip
19854
19855Flip the input video vertically.
19856
19857For example, to vertically flip a video with @command{ffmpeg}:
19858@example
19859ffmpeg -i in.avi -vf "vflip" out.avi
19860@end example
19861
19862@section vfrdet
19863
19864Detect variable frame rate video.
19865
19866This filter tries to detect if the input is variable or constant frame rate.
19867
19868At end it will output number of frames detected as having variable delta pts,
19869and ones with constant delta pts.
19870If there was frames with variable delta, than it will also show min, max and
19871average delta encountered.
19872
19873@section vibrance
19874
19875Boost or alter saturation.
19876
19877The filter accepts the following options:
19878@table @option
19879@item intensity
19880Set strength of boost if positive value or strength of alter if negative value.
19881Default is 0. Allowed range is from -2 to 2.
19882
19883@item rbal
19884Set the red balance. Default is 1. Allowed range is from -10 to 10.
19885
19886@item gbal
19887Set the green balance. Default is 1. Allowed range is from -10 to 10.
19888
19889@item bbal
19890Set the blue balance. Default is 1. Allowed range is from -10 to 10.
19891
19892@item rlum
19893Set the red luma coefficient.
19894
19895@item glum
19896Set the green luma coefficient.
19897
19898@item blum
19899Set the blue luma coefficient.
19900
19901@item alternate
19902If @code{intensity} is negative and this is set to 1, colors will change,
19903otherwise colors will be less saturated, more towards gray.
19904@end table
19905
19906@subsection Commands
19907
19908This filter supports the all above options as @ref{commands}.
19909
19910@anchor{vignette}
19911@section vignette
19912
19913Make or reverse a natural vignetting effect.
19914
19915The filter accepts the following options:
19916
19917@table @option
19918@item angle, a
19919Set lens angle expression as a number of radians.
19920
19921The value is clipped in the @code{[0,PI/2]} range.
19922
19923Default value: @code{"PI/5"}
19924
19925@item x0
19926@item y0
19927Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
19928by default.
19929
19930@item mode
19931Set forward/backward mode.
19932
19933Available modes are:
19934@table @samp
19935@item forward
19936The larger the distance from the central point, the darker the image becomes.
19937
19938@item backward
19939The larger the distance from the central point, the brighter the image becomes.
19940This can be used to reverse a vignette effect, though there is no automatic
19941detection to extract the lens @option{angle} and other settings (yet). It can
19942also be used to create a burning effect.
19943@end table
19944
19945Default value is @samp{forward}.
19946
19947@item eval
19948Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
19949
19950It accepts the following values:
19951@table @samp
19952@item init
19953Evaluate expressions only once during the filter initialization.
19954
19955@item frame
19956Evaluate expressions for each incoming frame. This is way slower than the
19957@samp{init} mode since it requires all the scalers to be re-computed, but it
19958allows advanced dynamic expressions.
19959@end table
19960
19961Default value is @samp{init}.
19962
19963@item dither
19964Set dithering to reduce the circular banding effects. Default is @code{1}
19965(enabled).
19966
19967@item aspect
19968Set vignette aspect. This setting allows one to adjust the shape of the vignette.
19969Setting this value to the SAR of the input will make a rectangular vignetting
19970following the dimensions of the video.
19971
19972Default is @code{1/1}.
19973@end table
19974
19975@subsection Expressions
19976
19977The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
19978following parameters.
19979
19980@table @option
19981@item w
19982@item h
19983input width and height
19984
19985@item n
19986the number of input frame, starting from 0
19987
19988@item pts
19989the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
19990@var{TB} units, NAN if undefined
19991
19992@item r
19993frame rate of the input video, NAN if the input frame rate is unknown
19994
19995@item t
19996the PTS (Presentation TimeStamp) of the filtered video frame,
19997expressed in seconds, NAN if undefined
19998
19999@item tb
20000time base of the input video
20001@end table
20002
20003
20004@subsection Examples
20005
20006@itemize
20007@item
20008Apply simple strong vignetting effect:
20009@example
20010vignette=PI/4
20011@end example
20012
20013@item
20014Make a flickering vignetting:
20015@example
20016vignette='PI/4+random(1)*PI/50':eval=frame
20017@end example
20018
20019@end itemize
20020
20021@section vmafmotion
20022
20023Obtain the average VMAF motion score of a video.
20024It is one of the component metrics of VMAF.
20025
20026The obtained average motion score is printed through the logging system.
20027
20028The filter accepts the following options:
20029
20030@table @option
20031@item stats_file
20032If specified, the filter will use the named file to save the motion score of
20033each frame with respect to the previous frame.
20034When filename equals "-" the data is sent to standard output.
20035@end table
20036
20037Example:
20038@example
20039ffmpeg -i ref.mpg -vf vmafmotion -f null -
20040@end example
20041
20042@section vstack
20043Stack input videos vertically.
20044
20045All streams must be of same pixel format and of same width.
20046
20047Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
20048to create same output.
20049
20050The filter accepts the following options:
20051
20052@table @option
20053@item inputs
20054Set number of input streams. Default is 2.
20055
20056@item shortest
20057If set to 1, force the output to terminate when the shortest input
20058terminates. Default value is 0.
20059@end table
20060
20061@section w3fdif
20062
20063Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
20064Deinterlacing Filter").
20065
20066Based on the process described by Martin Weston for BBC R&D, and
20067implemented based on the de-interlace algorithm written by Jim
20068Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
20069uses filter coefficients calculated by BBC R&D.
20070
20071This filter uses field-dominance information in frame to decide which
20072of each pair of fields to place first in the output.
20073If it gets it wrong use @ref{setfield} filter before @code{w3fdif} filter.
20074
20075There are two sets of filter coefficients, so called "simple"
20076and "complex". Which set of filter coefficients is used can
20077be set by passing an optional parameter:
20078
20079@table @option
20080@item filter
20081Set the interlacing filter coefficients. Accepts one of the following values:
20082
20083@table @samp
20084@item simple
20085Simple filter coefficient set.
20086@item complex
20087More-complex filter coefficient set.
20088@end table
20089Default value is @samp{complex}.
20090
20091@item deint
20092Specify which frames to deinterlace. Accepts one of the following values:
20093
20094@table @samp
20095@item all
20096Deinterlace all frames,
20097@item interlaced
20098Only deinterlace frames marked as interlaced.
20099@end table
20100
20101Default value is @samp{all}.
20102@end table
20103
20104@section waveform
20105Video waveform monitor.
20106
20107The waveform monitor plots color component intensity. By default luminance
20108only. Each column of the waveform corresponds to a column of pixels in the
20109source video.
20110
20111It accepts the following options:
20112
20113@table @option
20114@item mode, m
20115Can be either @code{row}, or @code{column}. Default is @code{column}.
20116In row mode, the graph on the left side represents color component value 0 and
20117the right side represents value = 255. In column mode, the top side represents
20118color component value = 0 and bottom side represents value = 255.
20119
20120@item intensity, i
20121Set intensity. Smaller values are useful to find out how many values of the same
20122luminance are distributed across input rows/columns.
20123Default value is @code{0.04}. Allowed range is [0, 1].
20124
20125@item mirror, r
20126Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored.
20127In mirrored mode, higher values will be represented on the left
20128side for @code{row} mode and at the top for @code{column} mode. Default is
20129@code{1} (mirrored).
20130
20131@item display, d
20132Set display mode.
20133It accepts the following values:
20134@table @samp
20135@item overlay
20136Presents information identical to that in the @code{parade}, except
20137that the graphs representing color components are superimposed directly
20138over one another.
20139
20140This display mode makes it easier to spot relative differences or similarities
20141in overlapping areas of the color components that are supposed to be identical,
20142such as neutral whites, grays, or blacks.
20143
20144@item stack
20145Display separate graph for the color components side by side in
20146@code{row} mode or one below the other in @code{column} mode.
20147
20148@item parade
20149Display separate graph for the color components side by side in
20150@code{column} mode or one below the other in @code{row} mode.
20151
20152Using this display mode makes it easy to spot color casts in the highlights
20153and shadows of an image, by comparing the contours of the top and the bottom
20154graphs of each waveform. Since whites, grays, and blacks are characterized
20155by exactly equal amounts of red, green, and blue, neutral areas of the picture
20156should display three waveforms of roughly equal width/height. If not, the
20157correction is easy to perform by making level adjustments the three waveforms.
20158@end table
20159Default is @code{stack}.
20160
20161@item components, c
20162Set which color components to display. Default is 1, which means only luminance
20163or red color component if input is in RGB colorspace. If is set for example to
201647 it will display all 3 (if) available color components.
20165
20166@item envelope, e
20167@table @samp
20168@item none
20169No envelope, this is default.
20170
20171@item instant
20172Instant envelope, minimum and maximum values presented in graph will be easily
20173visible even with small @code{step} value.
20174
20175@item peak
20176Hold minimum and maximum values presented in graph across time. This way you
20177can still spot out of range values without constantly looking at waveforms.
20178
20179@item peak+instant
20180Peak and instant envelope combined together.
20181@end table
20182
20183@item filter, f
20184@table @samp
20185@item lowpass
20186No filtering, this is default.
20187
20188@item flat
20189Luma and chroma combined together.
20190
20191@item aflat
20192Similar as above, but shows difference between blue and red chroma.
20193
20194@item xflat
20195Similar as above, but use different colors.
20196
20197@item yflat
20198Similar as above, but again with different colors.
20199
20200@item chroma
20201Displays only chroma.
20202
20203@item color
20204Displays actual color value on waveform.
20205
20206@item acolor
20207Similar as above, but with luma showing frequency of chroma values.
20208@end table
20209
20210@item graticule, g
20211Set which graticule to display.
20212
20213@table @samp
20214@item none
20215Do not display graticule.
20216
20217@item green
20218Display green graticule showing legal broadcast ranges.
20219
20220@item orange
20221Display orange graticule showing legal broadcast ranges.
20222
20223@item invert
20224Display invert graticule showing legal broadcast ranges.
20225@end table
20226
20227@item opacity, o
20228Set graticule opacity.
20229
20230@item flags, fl
20231Set graticule flags.
20232
20233@table @samp
20234@item numbers
20235Draw numbers above lines. By default enabled.
20236
20237@item dots
20238Draw dots instead of lines.
20239@end table
20240
20241@item scale, s
20242Set scale used for displaying graticule.
20243
20244@table @samp
20245@item digital
20246@item millivolts
20247@item ire
20248@end table
20249Default is digital.
20250
20251@item bgopacity, b
20252Set background opacity.
20253
20254@item tint0, t0
20255@item tint1, t1
20256Set tint for output.
20257Only used with lowpass filter and when display is not overlay and input
20258pixel formats are not RGB.
20259@end table
20260
20261@section weave, doubleweave
20262
20263The @code{weave} takes a field-based video input and join
20264each two sequential fields into single frame, producing a new double
20265height clip with half the frame rate and half the frame count.
20266
20267The @code{doubleweave} works same as @code{weave} but without
20268halving frame rate and frame count.
20269
20270It accepts the following option:
20271
20272@table @option
20273@item first_field
20274Set first field. Available values are:
20275
20276@table @samp
20277@item top, t
20278Set the frame as top-field-first.
20279
20280@item bottom, b
20281Set the frame as bottom-field-first.
20282@end table
20283@end table
20284
20285@subsection Examples
20286
20287@itemize
20288@item
20289Interlace video using @ref{select} and @ref{separatefields} filter:
20290@example
20291separatefields,select=eq(mod(n,4),0)+eq(mod(n,4),3),weave
20292@end example
20293@end itemize
20294
20295@section xbr
20296Apply the xBR high-quality magnification filter which is designed for pixel
20297art. It follows a set of edge-detection rules, see
20298@url{https://forums.libretro.com/t/xbr-algorithm-tutorial/123}.
20299
20300It accepts the following option:
20301
20302@table @option
20303@item n
20304Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
20305@code{3xBR} and @code{4} for @code{4xBR}.
20306Default is @code{3}.
20307@end table
20308
20309@section xfade
20310
20311Apply cross fade from one input video stream to another input video stream.
20312The cross fade is applied for specified duration.
20313
20314The filter accepts the following options:
20315
20316@table @option
20317@item transition
20318Set one of available transition effects:
20319
20320@table @samp
20321@item custom
20322@item fade
20323@item wipeleft
20324@item wiperight
20325@item wipeup
20326@item wipedown
20327@item slideleft
20328@item slideright
20329@item slideup
20330@item slidedown
20331@item circlecrop
20332@item rectcrop
20333@item distance
20334@item fadeblack
20335@item fadewhite
20336@item radial
20337@item smoothleft
20338@item smoothright
20339@item smoothup
20340@item smoothdown
20341@item circleopen
20342@item circleclose
20343@item vertopen
20344@item vertclose
20345@item horzopen
20346@item horzclose
20347@item dissolve
20348@item pixelize
20349@item diagtl
20350@item diagtr
20351@item diagbl
20352@item diagbr
20353@item hlslice
20354@item hrslice
20355@item vuslice
20356@item vdslice
20357@end table
20358Default transition effect is fade.
20359
20360@item duration
20361Set cross fade duration in seconds.
20362Default duration is 1 second.
20363
20364@item offset
20365Set cross fade start relative to first input stream in seconds.
20366Default offset is 0.
20367
20368@item expr
20369Set expression for custom transition effect.
20370
20371The expressions can use the following variables and functions:
20372
20373@table @option
20374@item X
20375@item Y
20376The coordinates of the current sample.
20377
20378@item W
20379@item H
20380The width and height of the image.
20381
20382@item P
20383Progress of transition effect.
20384
20385@item PLANE
20386Currently processed plane.
20387
20388@item A
20389Return value of first input at current location and plane.
20390
20391@item B
20392Return value of second input at current location and plane.
20393
20394@item a0(x, y)
20395@item a1(x, y)
20396@item a2(x, y)
20397@item a3(x, y)
20398Return the value of the pixel at location (@var{x},@var{y}) of the
20399first/second/third/fourth component of first input.
20400
20401@item b0(x, y)
20402@item b1(x, y)
20403@item b2(x, y)
20404@item b3(x, y)
20405Return the value of the pixel at location (@var{x},@var{y}) of the
20406first/second/third/fourth component of second input.
20407@end table
20408@end table
20409
20410@subsection Examples
20411
20412@itemize
20413@item
20414Cross fade from one input video to another input video, with fade transition and duration of transition
20415of 2 seconds starting at offset of 5 seconds:
20416@example
20417ffmpeg -i first.mp4 -i second.mp4 -filter_complex xfade=transition=fade:duration=2:offset=5 output.mp4
20418@end example
20419@end itemize
20420
20421@section xmedian
20422Pick median pixels from several input videos.
20423
20424The filter accepts the following options:
20425
20426@table @option
20427@item inputs
20428Set number of inputs.
20429Default is 3. Allowed range is from 3 to 255.
20430If number of inputs is even number, than result will be mean value between two median values.
20431
20432@item planes
20433Set which planes to filter. Default value is @code{15}, by which all planes are processed.
20434
20435@item percentile
20436Set median percentile. Default value is @code{0.5}.
20437Default value of @code{0.5} will pick always median values, while @code{0} will pick
20438minimum values, and @code{1} maximum values.
20439@end table
20440
20441@section xstack
20442Stack video inputs into custom layout.
20443
20444All streams must be of same pixel format.
20445
20446The filter accepts the following options:
20447
20448@table @option
20449@item inputs
20450Set number of input streams. Default is 2.
20451
20452@item layout
20453Specify layout of inputs.
20454This option requires the desired layout configuration to be explicitly set by the user.
20455This sets position of each video input in output. Each input
20456is separated by '|'.
20457The first number represents the column, and the second number represents the row.
20458Numbers start at 0 and are separated by '_'. Optionally one can use wX and hX,
20459where X is video input from which to take width or height.
20460Multiple values can be used when separated by '+'. In such
20461case values are summed together.
20462
20463Note that if inputs are of different sizes gaps may appear, as not all of
20464the output video frame will be filled. Similarly, videos can overlap each
20465other if their position doesn't leave enough space for the full frame of
20466adjoining videos.
20467
20468For 2 inputs, a default layout of @code{0_0|w0_0} is set. In all other cases,
20469a layout must be set by the user.
20470
20471@item shortest
20472If set to 1, force the output to terminate when the shortest input
20473terminates. Default value is 0.
20474
20475@item fill
20476If set to valid color, all unused pixels will be filled with that color.
20477By default fill is set to none, so it is disabled.
20478@end table
20479
20480@subsection Examples
20481
20482@itemize
20483@item
20484Display 4 inputs into 2x2 grid.
20485
20486Layout:
20487@example
20488input1(0, 0)  | input3(w0, 0)
20489input2(0, h0) | input4(w0, h0)
20490@end example
20491
20492@example
20493xstack=inputs=4:layout=0_0|0_h0|w0_0|w0_h0
20494@end example
20495
20496Note that if inputs are of different sizes, gaps or overlaps may occur.
20497
20498@item
20499Display 4 inputs into 1x4 grid.
20500
20501Layout:
20502@example
20503input1(0, 0)
20504input2(0, h0)
20505input3(0, h0+h1)
20506input4(0, h0+h1+h2)
20507@end example
20508
20509@example
20510xstack=inputs=4:layout=0_0|0_h0|0_h0+h1|0_h0+h1+h2
20511@end example
20512
20513Note that if inputs are of different widths, unused space will appear.
20514
20515@item
20516Display 9 inputs into 3x3 grid.
20517
20518Layout:
20519@example
20520input1(0, 0)       | input4(w0, 0)      | input7(w0+w3, 0)
20521input2(0, h0)      | input5(w0, h0)     | input8(w0+w3, h0)
20522input3(0, h0+h1)   | input6(w0, h0+h1)  | input9(w0+w3, h0+h1)
20523@end example
20524
20525@example
20526xstack=inputs=9:layout=0_0|0_h0|0_h0+h1|w0_0|w0_h0|w0_h0+h1|w0+w3_0|w0+w3_h0|w0+w3_h0+h1
20527@end example
20528
20529Note that if inputs are of different sizes, gaps or overlaps may occur.
20530
20531@item
20532Display 16 inputs into 4x4 grid.
20533
20534Layout:
20535@example
20536input1(0, 0)       | input5(w0, 0)       | input9 (w0+w4, 0)       | input13(w0+w4+w8, 0)
20537input2(0, h0)      | input6(w0, h0)      | input10(w0+w4, h0)      | input14(w0+w4+w8, h0)
20538input3(0, h0+h1)   | input7(w0, h0+h1)   | input11(w0+w4, h0+h1)   | input15(w0+w4+w8, h0+h1)
20539input4(0, h0+h1+h2)| input8(w0, h0+h1+h2)| input12(w0+w4, h0+h1+h2)| input16(w0+w4+w8, h0+h1+h2)
20540@end example
20541
20542@example
20543xstack=inputs=16:layout=0_0|0_h0|0_h0+h1|0_h0+h1+h2|w0_0|w0_h0|w0_h0+h1|w0_h0+h1+h2|w0+w4_0|
20544w0+w4_h0|w0+w4_h0+h1|w0+w4_h0+h1+h2|w0+w4+w8_0|w0+w4+w8_h0|w0+w4+w8_h0+h1|w0+w4+w8_h0+h1+h2
20545@end example
20546
20547Note that if inputs are of different sizes, gaps or overlaps may occur.
20548
20549@end itemize
20550
20551@anchor{yadif}
20552@section yadif
20553
20554Deinterlace the input video ("yadif" means "yet another deinterlacing
20555filter").
20556
20557It accepts the following parameters:
20558
20559
20560@table @option
20561
20562@item mode
20563The interlacing mode to adopt. It accepts one of the following values:
20564
20565@table @option
20566@item 0, send_frame
20567Output one frame for each frame.
20568@item 1, send_field
20569Output one frame for each field.
20570@item 2, send_frame_nospatial
20571Like @code{send_frame}, but it skips the spatial interlacing check.
20572@item 3, send_field_nospatial
20573Like @code{send_field}, but it skips the spatial interlacing check.
20574@end table
20575
20576The default value is @code{send_frame}.
20577
20578@item parity
20579The picture field parity assumed for the input interlaced video. It accepts one
20580of the following values:
20581
20582@table @option
20583@item 0, tff
20584Assume the top field is first.
20585@item 1, bff
20586Assume the bottom field is first.
20587@item -1, auto
20588Enable automatic detection of field parity.
20589@end table
20590
20591The default value is @code{auto}.
20592If the interlacing is unknown or the decoder does not export this information,
20593top field first will be assumed.
20594
20595@item deint
20596Specify which frames to deinterlace. Accepts one of the following
20597values:
20598
20599@table @option
20600@item 0, all
20601Deinterlace all frames.
20602@item 1, interlaced
20603Only deinterlace frames marked as interlaced.
20604@end table
20605
20606The default value is @code{all}.
20607@end table
20608
20609@section yadif_cuda
20610
20611Deinterlace the input video using the @ref{yadif} algorithm, but implemented
20612in CUDA so that it can work as part of a GPU accelerated pipeline with nvdec
20613and/or nvenc.
20614
20615It accepts the following parameters:
20616
20617
20618@table @option
20619
20620@item mode
20621The interlacing mode to adopt. It accepts one of the following values:
20622
20623@table @option
20624@item 0, send_frame
20625Output one frame for each frame.
20626@item 1, send_field
20627Output one frame for each field.
20628@item 2, send_frame_nospatial
20629Like @code{send_frame}, but it skips the spatial interlacing check.
20630@item 3, send_field_nospatial
20631Like @code{send_field}, but it skips the spatial interlacing check.
20632@end table
20633
20634The default value is @code{send_frame}.
20635
20636@item parity
20637The picture field parity assumed for the input interlaced video. It accepts one
20638of the following values:
20639
20640@table @option
20641@item 0, tff
20642Assume the top field is first.
20643@item 1, bff
20644Assume the bottom field is first.
20645@item -1, auto
20646Enable automatic detection of field parity.
20647@end table
20648
20649The default value is @code{auto}.
20650If the interlacing is unknown or the decoder does not export this information,
20651top field first will be assumed.
20652
20653@item deint
20654Specify which frames to deinterlace. Accepts one of the following
20655values:
20656
20657@table @option
20658@item 0, all
20659Deinterlace all frames.
20660@item 1, interlaced
20661Only deinterlace frames marked as interlaced.
20662@end table
20663
20664The default value is @code{all}.
20665@end table
20666
20667@section yaepblur
20668
20669Apply blur filter while preserving edges ("yaepblur" means "yet another edge preserving blur filter").
20670The algorithm is described in
20671"J. S. Lee, Digital image enhancement and noise filtering by use of local statistics, IEEE Trans. Pattern Anal. Mach. Intell. PAMI-2, 1980."
20672
20673It accepts the following parameters:
20674
20675@table @option
20676@item radius, r
20677Set the window radius. Default value is 3.
20678
20679@item planes, p
20680Set which planes to filter. Default is only the first plane.
20681
20682@item sigma, s
20683Set blur strength. Default value is 128.
20684@end table
20685
20686@subsection Commands
20687This filter supports same @ref{commands} as options.
20688
20689@section zoompan
20690
20691Apply Zoom & Pan effect.
20692
20693This filter accepts the following options:
20694
20695@table @option
20696@item zoom, z
20697Set the zoom expression. Range is 1-10. Default is 1.
20698
20699@item x
20700@item y
20701Set the x and y expression. Default is 0.
20702
20703@item d
20704Set the duration expression in number of frames.
20705This sets for how many number of frames effect will last for
20706single input image.
20707
20708@item s
20709Set the output image size, default is 'hd720'.
20710
20711@item fps
20712Set the output frame rate, default is '25'.
20713@end table
20714
20715Each expression can contain the following constants:
20716
20717@table @option
20718@item in_w, iw
20719Input width.
20720
20721@item in_h, ih
20722Input height.
20723
20724@item out_w, ow
20725Output width.
20726
20727@item out_h, oh
20728Output height.
20729
20730@item in
20731Input frame count.
20732
20733@item on
20734Output frame count.
20735
20736@item x
20737@item y
20738Last calculated 'x' and 'y' position from 'x' and 'y' expression
20739for current input frame.
20740
20741@item px
20742@item py
20743'x' and 'y' of last output frame of previous input frame or 0 when there was
20744not yet such frame (first input frame).
20745
20746@item zoom
20747Last calculated zoom from 'z' expression for current input frame.
20748
20749@item pzoom
20750Last calculated zoom of last output frame of previous input frame.
20751
20752@item duration
20753Number of output frames for current input frame. Calculated from 'd' expression
20754for each input frame.
20755
20756@item pduration
20757number of output frames created for previous input frame
20758
20759@item a
20760Rational number: input width / input height
20761
20762@item sar
20763sample aspect ratio
20764
20765@item dar
20766display aspect ratio
20767
20768@end table
20769
20770@subsection Examples
20771
20772@itemize
20773@item
20774Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
20775@example
20776zoompan=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
20777@end example
20778
20779@item
20780Zoom-in up to 1.5 and pan always at center of picture:
20781@example
20782zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
20783@end example
20784
20785@item
20786Same as above but without pausing:
20787@example
20788zoompan=z='min(max(zoom,pzoom)+0.0015,1.5)':d=1:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
20789@end example
20790@end itemize
20791
20792@anchor{zscale}
20793@section zscale
20794Scale (resize) the input video, using the z.lib library:
20795@url{https://github.com/sekrit-twc/zimg}. To enable compilation of this
20796filter, you need to configure FFmpeg with @code{--enable-libzimg}.
20797
20798The zscale filter forces the output display aspect ratio to be the same
20799as the input, by changing the output sample aspect ratio.
20800
20801If the input image format is different from the format requested by
20802the next filter, the zscale filter will convert the input to the
20803requested format.
20804
20805@subsection Options
20806The filter accepts the following options.
20807
20808@table @option
20809@item width, w
20810@item height, h
20811Set the output video dimension expression. Default value is the input
20812dimension.
20813
20814If the @var{width} or @var{w} value is 0, the input width is used for
20815the output. If the @var{height} or @var{h} value is 0, the input height
20816is used for the output.
20817
20818If one and only one of the values is -n with n >= 1, the zscale filter
20819will use a value that maintains the aspect ratio of the input image,
20820calculated from the other specified dimension. After that it will,
20821however, make sure that the calculated dimension is divisible by n and
20822adjust the value if necessary.
20823
20824If both values are -n with n >= 1, the behavior will be identical to
20825both values being set to 0 as previously detailed.
20826
20827See below for the list of accepted constants for use in the dimension
20828expression.
20829
20830@item size, s
20831Set the video size. For the syntax of this option, check the
20832@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
20833
20834@item dither, d
20835Set the dither type.
20836
20837Possible values are:
20838@table @var
20839@item none
20840@item ordered
20841@item random
20842@item error_diffusion
20843@end table
20844
20845Default is none.
20846
20847@item filter, f
20848Set the resize filter type.
20849
20850Possible values are:
20851@table @var
20852@item point
20853@item bilinear
20854@item bicubic
20855@item spline16
20856@item spline36
20857@item lanczos
20858@end table
20859
20860Default is bilinear.
20861
20862@item range, r
20863Set the color range.
20864
20865Possible values are:
20866@table @var
20867@item input
20868@item limited
20869@item full
20870@end table
20871
20872Default is same as input.
20873
20874@item primaries, p
20875Set the color primaries.
20876
20877Possible values are:
20878@table @var
20879@item input
20880@item 709
20881@item unspecified
20882@item 170m
20883@item 240m
20884@item 2020
20885@end table
20886
20887Default is same as input.
20888
20889@item transfer, t
20890Set the transfer characteristics.
20891
20892Possible values are:
20893@table @var
20894@item input
20895@item 709
20896@item unspecified
20897@item 601
20898@item linear
20899@item 2020_10
20900@item 2020_12
20901@item smpte2084
20902@item iec61966-2-1
20903@item arib-std-b67
20904@end table
20905
20906Default is same as input.
20907
20908@item matrix, m
20909Set the colorspace matrix.
20910
20911Possible value are:
20912@table @var
20913@item input
20914@item 709
20915@item unspecified
20916@item 470bg
20917@item 170m
20918@item 2020_ncl
20919@item 2020_cl
20920@end table
20921
20922Default is same as input.
20923
20924@item rangein, rin
20925Set the input color range.
20926
20927Possible values are:
20928@table @var
20929@item input
20930@item limited
20931@item full
20932@end table
20933
20934Default is same as input.
20935
20936@item primariesin, pin
20937Set the input color primaries.
20938
20939Possible values are:
20940@table @var
20941@item input
20942@item 709
20943@item unspecified
20944@item 170m
20945@item 240m
20946@item 2020
20947@end table
20948
20949Default is same as input.
20950
20951@item transferin, tin
20952Set the input transfer characteristics.
20953
20954Possible values are:
20955@table @var
20956@item input
20957@item 709
20958@item unspecified
20959@item 601
20960@item linear
20961@item 2020_10
20962@item 2020_12
20963@end table
20964
20965Default is same as input.
20966
20967@item matrixin, min
20968Set the input colorspace matrix.
20969
20970Possible value are:
20971@table @var
20972@item input
20973@item 709
20974@item unspecified
20975@item 470bg
20976@item 170m
20977@item 2020_ncl
20978@item 2020_cl
20979@end table
20980
20981@item chromal, c
20982Set the output chroma location.
20983
20984Possible values are:
20985@table @var
20986@item input
20987@item left
20988@item center
20989@item topleft
20990@item top
20991@item bottomleft
20992@item bottom
20993@end table
20994
20995@item chromalin, cin
20996Set the input chroma location.
20997
20998Possible values are:
20999@table @var
21000@item input
21001@item left
21002@item center
21003@item topleft
21004@item top
21005@item bottomleft
21006@item bottom
21007@end table
21008
21009@item npl
21010Set the nominal peak luminance.
21011@end table
21012
21013The values of the @option{w} and @option{h} options are expressions
21014containing the following constants:
21015
21016@table @var
21017@item in_w
21018@item in_h
21019The input width and height
21020
21021@item iw
21022@item ih
21023These are the same as @var{in_w} and @var{in_h}.
21024
21025@item out_w
21026@item out_h
21027The output (scaled) width and height
21028
21029@item ow
21030@item oh
21031These are the same as @var{out_w} and @var{out_h}
21032
21033@item a
21034The same as @var{iw} / @var{ih}
21035
21036@item sar
21037input sample aspect ratio
21038
21039@item dar
21040The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
21041
21042@item hsub
21043@item vsub
21044horizontal and vertical input chroma subsample values. For example for the
21045pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
21046
21047@item ohsub
21048@item ovsub
21049horizontal and vertical output chroma subsample values. For example for the
21050pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
21051@end table
21052
21053@subsection Commands
21054
21055This filter supports the following commands:
21056@table @option
21057@item width, w
21058@item height, h
21059Set the output video dimension expression.
21060The command accepts the same syntax of the corresponding option.
21061
21062If the specified expression is not valid, it is kept at its current
21063value.
21064@end table
21065
21066@c man end VIDEO FILTERS
21067
21068@chapter OpenCL Video Filters
21069@c man begin OPENCL VIDEO FILTERS
21070
21071Below is a description of the currently available OpenCL video filters.
21072
21073To enable compilation of these filters you need to configure FFmpeg with
21074@code{--enable-opencl}.
21075
21076Running OpenCL filters requires you to initialize a hardware device and to pass that device to all filters in any filter graph.
21077@table @option
21078
21079@item -init_hw_device opencl[=@var{name}][:@var{device}[,@var{key=value}...]]
21080Initialise a new hardware device of type @var{opencl} called @var{name}, using the
21081given device parameters.
21082
21083@item -filter_hw_device @var{name}
21084Pass the hardware device called @var{name} to all filters in any filter graph.
21085
21086@end table
21087
21088For more detailed information see @url{https://www.ffmpeg.org/ffmpeg.html#Advanced-Video-options}
21089
21090@itemize
21091@item
21092Example of choosing the first device on the second platform and running avgblur_opencl filter with default parameters on it.
21093@example
21094-init_hw_device opencl=gpu:1.0 -filter_hw_device gpu -i INPUT -vf "hwupload, avgblur_opencl, hwdownload" OUTPUT
21095@end example
21096@end itemize
21097
21098Since OpenCL filters are not able to access frame data in normal memory, all frame data needs to be uploaded(@ref{hwupload}) to hardware surfaces connected to the appropriate device before being used and then downloaded(@ref{hwdownload}) back to normal memory. Note that @ref{hwupload} will upload to a surface with the same layout as the software frame, so it may be necessary to add a @ref{format} filter immediately before to get the input into the right format and @ref{hwdownload} does not support all formats on the output - it may be necessary to insert an additional @ref{format} filter immediately following in the graph to get the output in a supported format.
21099
21100@section avgblur_opencl
21101
21102Apply average blur filter.
21103
21104The filter accepts the following options:
21105
21106@table @option
21107@item sizeX
21108Set horizontal radius size.
21109Range is @code{[1, 1024]} and default value is @code{1}.
21110
21111@item planes
21112Set which planes to filter. Default value is @code{0xf}, by which all planes are processed.
21113
21114@item sizeY
21115Set vertical radius size. Range is @code{[1, 1024]} and default value is @code{0}. If zero, @code{sizeX} value will be used.
21116@end table
21117
21118@subsection Example
21119
21120@itemize
21121@item
21122Apply average blur filter with horizontal and vertical size of 3, setting each pixel of the output to the average value of the 7x7 region centered on it in the input. For pixels on the edges of the image, the region does not extend beyond the image boundaries, and so out-of-range coordinates are not used in the calculations.
21123@example
21124-i INPUT -vf "hwupload, avgblur_opencl=3, hwdownload" OUTPUT
21125@end example
21126@end itemize
21127
21128@section boxblur_opencl
21129
21130Apply a boxblur algorithm to the input video.
21131
21132It accepts the following parameters:
21133
21134@table @option
21135
21136@item luma_radius, lr
21137@item luma_power, lp
21138@item chroma_radius, cr
21139@item chroma_power, cp
21140@item alpha_radius, ar
21141@item alpha_power, ap
21142
21143@end table
21144
21145A description of the accepted options follows.
21146
21147@table @option
21148@item luma_radius, lr
21149@item chroma_radius, cr
21150@item alpha_radius, ar
21151Set an expression for the box radius in pixels used for blurring the
21152corresponding input plane.
21153
21154The radius value must be a non-negative number, and must not be
21155greater than the value of the expression @code{min(w,h)/2} for the
21156luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
21157planes.
21158
21159Default value for @option{luma_radius} is "2". If not specified,
21160@option{chroma_radius} and @option{alpha_radius} default to the
21161corresponding value set for @option{luma_radius}.
21162
21163The expressions can contain the following constants:
21164@table @option
21165@item w
21166@item h
21167The input width and height in pixels.
21168
21169@item cw
21170@item ch
21171The input chroma image width and height in pixels.
21172
21173@item hsub
21174@item vsub
21175The horizontal and vertical chroma subsample values. For example, for the
21176pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
21177@end table
21178
21179@item luma_power, lp
21180@item chroma_power, cp
21181@item alpha_power, ap
21182Specify how many times the boxblur filter is applied to the
21183corresponding plane.
21184
21185Default value for @option{luma_power} is 2. If not specified,
21186@option{chroma_power} and @option{alpha_power} default to the
21187corresponding value set for @option{luma_power}.
21188
21189A value of 0 will disable the effect.
21190@end table
21191
21192@subsection Examples
21193
21194Apply boxblur filter, setting each pixel of the output to the average value of box-radiuses @var{luma_radius}, @var{chroma_radius}, @var{alpha_radius} for each plane respectively. The filter will apply @var{luma_power}, @var{chroma_power}, @var{alpha_power} times onto the corresponding plane. For pixels on the edges of the image, the radius does not extend beyond the image boundaries, and so out-of-range coordinates are not used in the calculations.
21195
21196@itemize
21197@item
21198Apply a boxblur filter with the luma, chroma, and alpha radius
21199set to 2 and luma, chroma, and alpha power set to 3. The filter will run 3 times with box-radius set to 2 for every plane of the image.
21200@example
21201-i INPUT -vf "hwupload, boxblur_opencl=luma_radius=2:luma_power=3, hwdownload" OUTPUT
21202-i INPUT -vf "hwupload, boxblur_opencl=2:3, hwdownload" OUTPUT
21203@end example
21204
21205@item
21206Apply a boxblur filter with luma radius set to 2, luma_power to 1, chroma_radius to 4, chroma_power to 5, alpha_radius to 3 and alpha_power to 7.
21207
21208For the luma plane, a 2x2 box radius will be run once.
21209
21210For the chroma plane, a 4x4 box radius will be run 5 times.
21211
21212For the alpha plane, a 3x3 box radius will be run 7 times.
21213@example
21214-i INPUT -vf "hwupload, boxblur_opencl=2:1:4:5:3:7, hwdownload" OUTPUT
21215@end example
21216@end itemize
21217
21218@section colorkey_opencl
21219RGB colorspace color keying.
21220
21221The filter accepts the following options:
21222
21223@table @option
21224@item color
21225The color which will be replaced with transparency.
21226
21227@item similarity
21228Similarity percentage with the key color.
21229
212300.01 matches only the exact key color, while 1.0 matches everything.
21231
21232@item blend
21233Blend percentage.
21234
212350.0 makes pixels either fully transparent, or not transparent at all.
21236
21237Higher values result in semi-transparent pixels, with a higher transparency
21238the more similar the pixels color is to the key color.
21239@end table
21240
21241@subsection Examples
21242
21243@itemize
21244@item
21245Make every semi-green pixel in the input transparent with some slight blending:
21246@example
21247-i INPUT -vf "hwupload, colorkey_opencl=green:0.3:0.1, hwdownload" OUTPUT
21248@end example
21249@end itemize
21250
21251@section convolution_opencl
21252
21253Apply convolution of 3x3, 5x5, 7x7 matrix.
21254
21255The filter accepts the following options:
21256
21257@table @option
21258@item 0m
21259@item 1m
21260@item 2m
21261@item 3m
21262Set matrix for each plane.
21263Matrix is sequence of 9, 25 or 49 signed numbers.
21264Default value for each plane is @code{0 0 0 0 1 0 0 0 0}.
21265
21266@item 0rdiv
21267@item 1rdiv
21268@item 2rdiv
21269@item 3rdiv
21270Set multiplier for calculated value for each plane.
21271If unset or 0, it will be sum of all matrix elements.
21272The option value must be a float number greater or equal to @code{0.0}. Default value is @code{1.0}.
21273
21274@item 0bias
21275@item 1bias
21276@item 2bias
21277@item 3bias
21278Set bias for each plane. This value is added to the result of the multiplication.
21279Useful for making the overall image brighter or darker.
21280The option value must be a float number greater or equal to @code{0.0}. Default value is @code{0.0}.
21281
21282@end table
21283
21284@subsection Examples
21285
21286@itemize
21287@item
21288Apply sharpen:
21289@example
21290-i INPUT -vf "hwupload, convolution_opencl=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, hwdownload" OUTPUT
21291@end example
21292
21293@item
21294Apply blur:
21295@example
21296-i INPUT -vf "hwupload, convolution_opencl=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, hwdownload" OUTPUT
21297@end example
21298
21299@item
21300Apply edge enhance:
21301@example
21302-i INPUT -vf "hwupload, convolution_opencl=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, hwdownload" OUTPUT
21303@end example
21304
21305@item
21306Apply edge detect:
21307@example
21308-i INPUT -vf "hwupload, convolution_opencl=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, hwdownload" OUTPUT
21309@end example
21310
21311@item
21312Apply laplacian edge detector which includes diagonals:
21313@example
21314-i INPUT -vf "hwupload, convolution_opencl=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, hwdownload" OUTPUT
21315@end example
21316
21317@item
21318Apply emboss:
21319@example
21320-i INPUT -vf "hwupload, convolution_opencl=-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, hwdownload" OUTPUT
21321@end example
21322@end itemize
21323
21324@section erosion_opencl
21325
21326Apply erosion effect to the video.
21327
21328This filter replaces the pixel by the local(3x3) minimum.
21329
21330It accepts the following options:
21331
21332@table @option
21333@item threshold0
21334@item threshold1
21335@item threshold2
21336@item threshold3
21337Limit the maximum change for each plane. Range is @code{[0, 65535]} and default value is @code{65535}.
21338If @code{0}, plane will remain unchanged.
21339
21340@item coordinates
21341Flag which specifies the pixel to refer to.
21342Range is @code{[0, 255]} and default value is @code{255}, i.e. all eight pixels are used.
21343
21344Flags to local 3x3 coordinates region centered on @code{x}:
21345
21346    1 2 3
21347
21348    4 x 5
21349
21350    6 7 8
21351@end table
21352
21353@subsection Example
21354
21355@itemize
21356@item
21357Apply erosion filter with threshold0 set to 30, threshold1 set 40, threshold2 set to 50 and coordinates set to 231, setting each pixel of the output to the local minimum between pixels: 1, 2, 3, 6, 7, 8 of the 3x3 region centered on it in the input. If the difference between input pixel and local minimum is more then threshold of the corresponding plane, output pixel will be set to input pixel - threshold of corresponding plane.
21358@example
21359-i INPUT -vf "hwupload, erosion_opencl=30:40:50:coordinates=231, hwdownload" OUTPUT
21360@end example
21361@end itemize
21362
21363@section deshake_opencl
21364Feature-point based video stabilization filter.
21365
21366The filter accepts the following options:
21367
21368@table @option
21369@item tripod
21370Simulates a tripod by preventing any camera movement whatsoever from the original frame. Defaults to @code{0}.
21371
21372@item debug
21373Whether or not additional debug info should be displayed, both in the processed output and in the console.
21374
21375Note that in order to see console debug output you will also need to pass @code{-v verbose} to ffmpeg.
21376
21377Viewing point matches in the output video is only supported for RGB input.
21378
21379Defaults to @code{0}.
21380
21381@item adaptive_crop
21382Whether or not to do a tiny bit of cropping at the borders to cut down on the amount of mirrored pixels.
21383
21384Defaults to @code{1}.
21385
21386@item refine_features
21387Whether or not feature points should be refined at a sub-pixel level.
21388
21389This can be turned off for a slight performance gain at the cost of precision.
21390
21391Defaults to @code{1}.
21392
21393@item smooth_strength
21394The strength of the smoothing applied to the camera path from @code{0.0} to @code{1.0}.
21395
21396@code{1.0} is the maximum smoothing strength while values less than that result in less smoothing.
21397
21398@code{0.0} causes the filter to adaptively choose a smoothing strength on a per-frame basis.
21399
21400Defaults to @code{0.0}.
21401
21402@item smooth_window_multiplier
21403Controls the size of the smoothing window (the number of frames buffered to determine motion information from).
21404
21405The size of the smoothing window is determined by multiplying the framerate of the video by this number.
21406
21407Acceptable values range from @code{0.1} to @code{10.0}.
21408
21409Larger values increase the amount of motion data available for determining how to smooth the camera path,
21410potentially improving smoothness, but also increase latency and memory usage.
21411
21412Defaults to @code{2.0}.
21413
21414@end table
21415
21416@subsection Examples
21417
21418@itemize
21419@item
21420Stabilize a video with a fixed, medium smoothing strength:
21421@example
21422-i INPUT -vf "hwupload, deshake_opencl=smooth_strength=0.5, hwdownload" OUTPUT
21423@end example
21424
21425@item
21426Stabilize a video with debugging (both in console and in rendered video):
21427@example
21428-i INPUT -filter_complex "[0:v]format=rgba, hwupload, deshake_opencl=debug=1, hwdownload, format=rgba, format=yuv420p" -v verbose OUTPUT
21429@end example
21430@end itemize
21431
21432@section dilation_opencl
21433
21434Apply dilation effect to the video.
21435
21436This filter replaces the pixel by the local(3x3) maximum.
21437
21438It accepts the following options:
21439
21440@table @option
21441@item threshold0
21442@item threshold1
21443@item threshold2
21444@item threshold3
21445Limit the maximum change for each plane. Range is @code{[0, 65535]} and default value is @code{65535}.
21446If @code{0}, plane will remain unchanged.
21447
21448@item coordinates
21449Flag which specifies the pixel to refer to.
21450Range is @code{[0, 255]} and default value is @code{255}, i.e. all eight pixels are used.
21451
21452Flags to local 3x3 coordinates region centered on @code{x}:
21453
21454    1 2 3
21455
21456    4 x 5
21457
21458    6 7 8
21459@end table
21460
21461@subsection Example
21462
21463@itemize
21464@item
21465Apply dilation filter with threshold0 set to 30, threshold1 set 40, threshold2 set to 50 and coordinates set to 231, setting each pixel of the output to the local maximum between pixels: 1, 2, 3, 6, 7, 8 of the 3x3 region centered on it in the input. If the difference between input pixel and local maximum is more then threshold of the corresponding plane, output pixel will be set to input pixel + threshold of corresponding plane.
21466@example
21467-i INPUT -vf "hwupload, dilation_opencl=30:40:50:coordinates=231, hwdownload" OUTPUT
21468@end example
21469@end itemize
21470
21471@section nlmeans_opencl
21472
21473Non-local Means denoise filter through OpenCL, this filter accepts same options as @ref{nlmeans}.
21474
21475@section overlay_opencl
21476
21477Overlay one video on top of another.
21478
21479It takes two inputs and has one output. The first input is the "main" video on which the second input is overlaid.
21480This filter requires same memory layout for all the inputs. So, format conversion may be needed.
21481
21482The filter accepts the following options:
21483
21484@table @option
21485
21486@item x
21487Set the x coordinate of the overlaid video on the main video.
21488Default value is @code{0}.
21489
21490@item y
21491Set the y coordinate of the overlaid video on the main video.
21492Default value is @code{0}.
21493
21494@end table
21495
21496@subsection Examples
21497
21498@itemize
21499@item
21500Overlay an image LOGO at the top-left corner of the INPUT video. Both inputs are yuv420p format.
21501@example
21502-i INPUT -i LOGO -filter_complex "[0:v]hwupload[a], [1:v]format=yuv420p, hwupload[b], [a][b]overlay_opencl, hwdownload" OUTPUT
21503@end example
21504@item
21505The inputs have same memory layout for color channels , the overlay has additional alpha plane, like INPUT is yuv420p, and the LOGO is yuva420p.
21506@example
21507-i INPUT -i LOGO -filter_complex "[0:v]hwupload[a], [1:v]format=yuva420p, hwupload[b], [a][b]overlay_opencl, hwdownload" OUTPUT
21508@end example
21509
21510@end itemize
21511
21512@section pad_opencl
21513
21514Add paddings to the input image, and place the original input at the
21515provided @var{x}, @var{y} coordinates.
21516
21517It accepts the following options:
21518
21519@table @option
21520@item width, w
21521@item height, h
21522Specify an expression for the size of the output image with the
21523paddings added. If the value for @var{width} or @var{height} is 0, the
21524corresponding input size is used for the output.
21525
21526The @var{width} expression can reference the value set by the
21527@var{height} expression, and vice versa.
21528
21529The default value of @var{width} and @var{height} is 0.
21530
21531@item x
21532@item y
21533Specify the offsets to place the input image at within the padded area,
21534with respect to the top/left border of the output image.
21535
21536The @var{x} expression can reference the value set by the @var{y}
21537expression, and vice versa.
21538
21539The default value of @var{x} and @var{y} is 0.
21540
21541If @var{x} or @var{y} evaluate to a negative number, they'll be changed
21542so the input image is centered on the padded area.
21543
21544@item color
21545Specify the color of the padded area. For the syntax of this option,
21546check the @ref{color syntax,,"Color" section in the ffmpeg-utils
21547manual,ffmpeg-utils}.
21548
21549@item aspect
21550Pad to an aspect instead to a resolution.
21551@end table
21552
21553The value for the @var{width}, @var{height}, @var{x}, and @var{y}
21554options are expressions containing the following constants:
21555
21556@table @option
21557@item in_w
21558@item in_h
21559The input video width and height.
21560
21561@item iw
21562@item ih
21563These are the same as @var{in_w} and @var{in_h}.
21564
21565@item out_w
21566@item out_h
21567The output width and height (the size of the padded area), as
21568specified by the @var{width} and @var{height} expressions.
21569
21570@item ow
21571@item oh
21572These are the same as @var{out_w} and @var{out_h}.
21573
21574@item x
21575@item y
21576The x and y offsets as specified by the @var{x} and @var{y}
21577expressions, or NAN if not yet specified.
21578
21579@item a
21580same as @var{iw} / @var{ih}
21581
21582@item sar
21583input sample aspect ratio
21584
21585@item dar
21586input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
21587@end table
21588
21589@section prewitt_opencl
21590
21591Apply the Prewitt operator (@url{https://en.wikipedia.org/wiki/Prewitt_operator}) to input video stream.
21592
21593The filter accepts the following option:
21594
21595@table @option
21596@item planes
21597Set which planes to filter. Default value is @code{0xf}, by which all planes are processed.
21598
21599@item scale
21600Set value which will be multiplied with filtered result.
21601Range is @code{[0.0, 65535]} and default value is @code{1.0}.
21602
21603@item delta
21604Set value which will be added to filtered result.
21605Range is @code{[-65535, 65535]} and default value is @code{0.0}.
21606@end table
21607
21608@subsection Example
21609
21610@itemize
21611@item
21612Apply the Prewitt operator with scale set to 2 and delta set to 10.
21613@example
21614-i INPUT -vf "hwupload, prewitt_opencl=scale=2:delta=10, hwdownload" OUTPUT
21615@end example
21616@end itemize
21617
21618@anchor{program_opencl}
21619@section program_opencl
21620
21621Filter video using an OpenCL program.
21622
21623@table @option
21624
21625@item source
21626OpenCL program source file.
21627
21628@item kernel
21629Kernel name in program.
21630
21631@item inputs
21632Number of inputs to the filter.  Defaults to 1.
21633
21634@item size, s
21635Size of output frames.  Defaults to the same as the first input.
21636
21637@end table
21638
21639The @code{program_opencl} filter also supports the @ref{framesync} options.
21640
21641The program source file must contain a kernel function with the given name,
21642which will be run once for each plane of the output.  Each run on a plane
21643gets enqueued as a separate 2D global NDRange with one work-item for each
21644pixel to be generated.  The global ID offset for each work-item is therefore
21645the coordinates of a pixel in the destination image.
21646
21647The kernel function needs to take the following arguments:
21648@itemize
21649@item
21650Destination image, @var{__write_only image2d_t}.
21651
21652This image will become the output; the kernel should write all of it.
21653@item
21654Frame index, @var{unsigned int}.
21655
21656This is a counter starting from zero and increasing by one for each frame.
21657@item
21658Source images, @var{__read_only image2d_t}.
21659
21660These are the most recent images on each input.  The kernel may read from
21661them to generate the output, but they can't be written to.
21662@end itemize
21663
21664Example programs:
21665
21666@itemize
21667@item
21668Copy the input to the output (output must be the same size as the input).
21669@verbatim
21670__kernel void copy(__write_only image2d_t destination,
21671                   unsigned int index,
21672                   __read_only  image2d_t source)
21673{
21674    const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE;
21675
21676    int2 location = (int2)(get_global_id(0), get_global_id(1));
21677
21678    float4 value = read_imagef(source, sampler, location);
21679
21680    write_imagef(destination, location, value);
21681}
21682@end verbatim
21683
21684@item
21685Apply a simple transformation, rotating the input by an amount increasing
21686with the index counter.  Pixel values are linearly interpolated by the
21687sampler, and the output need not have the same dimensions as the input.
21688@verbatim
21689__kernel void rotate_image(__write_only image2d_t dst,
21690                           unsigned int index,
21691                           __read_only  image2d_t src)
21692{
21693    const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
21694                               CLK_FILTER_LINEAR);
21695
21696    float angle = (float)index / 100.0f;
21697
21698    float2 dst_dim = convert_float2(get_image_dim(dst));
21699    float2 src_dim = convert_float2(get_image_dim(src));
21700
21701    float2 dst_cen = dst_dim / 2.0f;
21702    float2 src_cen = src_dim / 2.0f;
21703
21704    int2   dst_loc = (int2)(get_global_id(0), get_global_id(1));
21705
21706    float2 dst_pos = convert_float2(dst_loc) - dst_cen;
21707    float2 src_pos = {
21708        cos(angle) * dst_pos.x - sin(angle) * dst_pos.y,
21709        sin(angle) * dst_pos.x + cos(angle) * dst_pos.y
21710    };
21711    src_pos = src_pos * src_dim / dst_dim;
21712
21713    float2 src_loc = src_pos + src_cen;
21714
21715    if (src_loc.x < 0.0f      || src_loc.y < 0.0f ||
21716        src_loc.x > src_dim.x || src_loc.y > src_dim.y)
21717        write_imagef(dst, dst_loc, 0.5f);
21718    else
21719        write_imagef(dst, dst_loc, read_imagef(src, sampler, src_loc));
21720}
21721@end verbatim
21722
21723@item
21724Blend two inputs together, with the amount of each input used varying
21725with the index counter.
21726@verbatim
21727__kernel void blend_images(__write_only image2d_t dst,
21728                           unsigned int index,
21729                           __read_only  image2d_t src1,
21730                           __read_only  image2d_t src2)
21731{
21732    const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
21733                               CLK_FILTER_LINEAR);
21734
21735    float blend = (cos((float)index / 50.0f) + 1.0f) / 2.0f;
21736
21737    int2  dst_loc = (int2)(get_global_id(0), get_global_id(1));
21738    int2 src1_loc = dst_loc * get_image_dim(src1) / get_image_dim(dst);
21739    int2 src2_loc = dst_loc * get_image_dim(src2) / get_image_dim(dst);
21740
21741    float4 val1 = read_imagef(src1, sampler, src1_loc);
21742    float4 val2 = read_imagef(src2, sampler, src2_loc);
21743
21744    write_imagef(dst, dst_loc, val1 * blend + val2 * (1.0f - blend));
21745}
21746@end verbatim
21747
21748@end itemize
21749
21750@section roberts_opencl
21751Apply the Roberts cross operator (@url{https://en.wikipedia.org/wiki/Roberts_cross}) to input video stream.
21752
21753The filter accepts the following option:
21754
21755@table @option
21756@item planes
21757Set which planes to filter. Default value is @code{0xf}, by which all planes are processed.
21758
21759@item scale
21760Set value which will be multiplied with filtered result.
21761Range is @code{[0.0, 65535]} and default value is @code{1.0}.
21762
21763@item delta
21764Set value which will be added to filtered result.
21765Range is @code{[-65535, 65535]} and default value is @code{0.0}.
21766@end table
21767
21768@subsection Example
21769
21770@itemize
21771@item
21772Apply the Roberts cross operator with scale set to 2 and delta set to 10
21773@example
21774-i INPUT -vf "hwupload, roberts_opencl=scale=2:delta=10, hwdownload" OUTPUT
21775@end example
21776@end itemize
21777
21778@section sobel_opencl
21779
21780Apply the Sobel operator (@url{https://en.wikipedia.org/wiki/Sobel_operator}) to input video stream.
21781
21782The filter accepts the following option:
21783
21784@table @option
21785@item planes
21786Set which planes to filter. Default value is @code{0xf}, by which all planes are processed.
21787
21788@item scale
21789Set value which will be multiplied with filtered result.
21790Range is @code{[0.0, 65535]} and default value is @code{1.0}.
21791
21792@item delta
21793Set value which will be added to filtered result.
21794Range is @code{[-65535, 65535]} and default value is @code{0.0}.
21795@end table
21796
21797@subsection Example
21798
21799@itemize
21800@item
21801Apply sobel operator with scale set to 2 and delta set to 10
21802@example
21803-i INPUT -vf "hwupload, sobel_opencl=scale=2:delta=10, hwdownload" OUTPUT
21804@end example
21805@end itemize
21806
21807@section tonemap_opencl
21808
21809Perform HDR(PQ/HLG) to SDR conversion with tone-mapping.
21810
21811It accepts the following parameters:
21812
21813@table @option
21814@item tonemap
21815Specify the tone-mapping operator to be used. Same as tonemap option in @ref{tonemap}.
21816
21817@item param
21818Tune the tone mapping algorithm. same as param option in @ref{tonemap}.
21819
21820@item desat
21821Apply desaturation for highlights that exceed this level of brightness. The
21822higher the parameter, the more color information will be preserved. This
21823setting helps prevent unnaturally blown-out colors for super-highlights, by
21824(smoothly) turning into white instead. This makes images feel more natural,
21825at the cost of reducing information about out-of-range colors.
21826
21827The default value is 0.5, and the algorithm here is a little different from
21828the cpu version tonemap currently. A setting of 0.0 disables this option.
21829
21830@item threshold
21831The tonemapping algorithm parameters is fine-tuned per each scene. And a threshold
21832is used to detect whether the scene has changed or not. If the distance between
21833the current frame average brightness and the current running average exceeds
21834a threshold value, we would re-calculate scene average and peak brightness.
21835The default value is 0.2.
21836
21837@item format
21838Specify the output pixel format.
21839
21840Currently supported formats are:
21841@table @var
21842@item p010
21843@item nv12
21844@end table
21845
21846@item range, r
21847Set the output color range.
21848
21849Possible values are:
21850@table @var
21851@item tv/mpeg
21852@item pc/jpeg
21853@end table
21854
21855Default is same as input.
21856
21857@item primaries, p
21858Set the output color primaries.
21859
21860Possible values are:
21861@table @var
21862@item bt709
21863@item bt2020
21864@end table
21865
21866Default is same as input.
21867
21868@item transfer, t
21869Set the output transfer characteristics.
21870
21871Possible values are:
21872@table @var
21873@item bt709
21874@item bt2020
21875@end table
21876
21877Default is bt709.
21878
21879@item matrix, m
21880Set the output colorspace matrix.
21881
21882Possible value are:
21883@table @var
21884@item bt709
21885@item bt2020
21886@end table
21887
21888Default is same as input.
21889
21890@end table
21891
21892@subsection Example
21893
21894@itemize
21895@item
21896Convert HDR(PQ/HLG) video to bt2020-transfer-characteristic p010 format using linear operator.
21897@example
21898-i INPUT -vf "format=p010,hwupload,tonemap_opencl=t=bt2020:tonemap=linear:format=p010,hwdownload,format=p010" OUTPUT
21899@end example
21900@end itemize
21901
21902@section unsharp_opencl
21903
21904Sharpen or blur the input video.
21905
21906It accepts the following parameters:
21907
21908@table @option
21909@item luma_msize_x, lx
21910Set the luma matrix horizontal size.
21911Range is @code{[1, 23]} and default value is @code{5}.
21912
21913@item luma_msize_y, ly
21914Set the luma matrix vertical size.
21915Range is @code{[1, 23]} and default value is @code{5}.
21916
21917@item luma_amount, la
21918Set the luma effect strength.
21919Range is @code{[-10, 10]} and default value is @code{1.0}.
21920
21921Negative values will blur the input video, while positive values will
21922sharpen it, a value of zero will disable the effect.
21923
21924@item chroma_msize_x, cx
21925Set the chroma matrix horizontal size.
21926Range is @code{[1, 23]} and default value is @code{5}.
21927
21928@item chroma_msize_y, cy
21929Set the chroma matrix vertical size.
21930Range is @code{[1, 23]} and default value is @code{5}.
21931
21932@item chroma_amount, ca
21933Set the chroma effect strength.
21934Range is @code{[-10, 10]} and default value is @code{0.0}.
21935
21936Negative values will blur the input video, while positive values will
21937sharpen it, a value of zero will disable the effect.
21938
21939@end table
21940
21941All parameters are optional and default to the equivalent of the
21942string '5:5:1.0:5:5:0.0'.
21943
21944@subsection Examples
21945
21946@itemize
21947@item
21948Apply strong luma sharpen effect:
21949@example
21950-i INPUT -vf "hwupload, unsharp_opencl=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5, hwdownload" OUTPUT
21951@end example
21952
21953@item
21954Apply a strong blur of both luma and chroma parameters:
21955@example
21956-i INPUT -vf "hwupload, unsharp_opencl=7:7:-2:7:7:-2, hwdownload" OUTPUT
21957@end example
21958@end itemize
21959
21960@section xfade_opencl
21961
21962Cross fade two videos with custom transition effect by using OpenCL.
21963
21964It accepts the following options:
21965
21966@table @option
21967@item transition
21968Set one of possible transition effects.
21969
21970@table @option
21971@item custom
21972Select custom transition effect, the actual transition description
21973will be picked from source and kernel options.
21974
21975@item fade
21976@item wipeleft
21977@item wiperight
21978@item wipeup
21979@item wipedown
21980@item slideleft
21981@item slideright
21982@item slideup
21983@item slidedown
21984
21985Default transition is fade.
21986@end table
21987
21988@item source
21989OpenCL program source file for custom transition.
21990
21991@item kernel
21992Set name of kernel to use for custom transition from program source file.
21993
21994@item duration
21995Set duration of video transition.
21996
21997@item offset
21998Set time of start of transition relative to first video.
21999@end table
22000
22001The program source file must contain a kernel function with the given name,
22002which will be run once for each plane of the output.  Each run on a plane
22003gets enqueued as a separate 2D global NDRange with one work-item for each
22004pixel to be generated.  The global ID offset for each work-item is therefore
22005the coordinates of a pixel in the destination image.
22006
22007The kernel function needs to take the following arguments:
22008@itemize
22009@item
22010Destination image, @var{__write_only image2d_t}.
22011
22012This image will become the output; the kernel should write all of it.
22013
22014@item
22015First Source image, @var{__read_only image2d_t}.
22016Second Source image, @var{__read_only image2d_t}.
22017
22018These are the most recent images on each input.  The kernel may read from
22019them to generate the output, but they can't be written to.
22020
22021@item
22022Transition progress, @var{float}. This value is always between 0 and 1 inclusive.
22023@end itemize
22024
22025Example programs:
22026
22027@itemize
22028@item
22029Apply dots curtain transition effect:
22030@verbatim
22031__kernel void blend_images(__write_only image2d_t dst,
22032                           __read_only  image2d_t src1,
22033                           __read_only  image2d_t src2,
22034                           float progress)
22035{
22036    const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
22037                               CLK_FILTER_LINEAR);
22038    int2  p = (int2)(get_global_id(0), get_global_id(1));
22039    float2 rp = (float2)(get_global_id(0), get_global_id(1));
22040    float2 dim = (float2)(get_image_dim(src1).x, get_image_dim(src1).y);
22041    rp = rp / dim;
22042
22043    float2 dots = (float2)(20.0, 20.0);
22044    float2 center = (float2)(0,0);
22045    float2 unused;
22046
22047    float4 val1 = read_imagef(src1, sampler, p);
22048    float4 val2 = read_imagef(src2, sampler, p);
22049    bool next = distance(fract(rp * dots, &unused), (float2)(0.5, 0.5)) < (progress / distance(rp, center));
22050
22051    write_imagef(dst, p, next ? val1 : val2);
22052}
22053@end verbatim
22054
22055@end itemize
22056
22057@c man end OPENCL VIDEO FILTERS
22058
22059@chapter VAAPI Video Filters
22060@c man begin VAAPI VIDEO FILTERS
22061
22062VAAPI Video filters are usually used with VAAPI decoder and VAAPI encoder. Below is a description of VAAPI video filters.
22063
22064To enable compilation of these filters you need to configure FFmpeg with
22065@code{--enable-vaapi}.
22066
22067To use vaapi filters, you need to setup the vaapi device correctly. For more information, please read @url{https://trac.ffmpeg.org/wiki/Hardware/VAAPI}
22068
22069@section tonemap_vaapi
22070
22071Perform HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion with tone-mapping.
22072It maps the dynamic range of HDR10 content to the SDR content.
22073It currently only accepts HDR10 as input.
22074
22075It accepts the following parameters:
22076
22077@table @option
22078@item format
22079Specify the output pixel format.
22080
22081Currently supported formats are:
22082@table @var
22083@item p010
22084@item nv12
22085@end table
22086
22087Default is nv12.
22088
22089@item primaries, p
22090Set the output color primaries.
22091
22092Default is same as input.
22093
22094@item transfer, t
22095Set the output transfer characteristics.
22096
22097Default is bt709.
22098
22099@item matrix, m
22100Set the output colorspace matrix.
22101
22102Default is same as input.
22103
22104@end table
22105
22106@subsection Example
22107
22108@itemize
22109@item
22110Convert HDR(HDR10) video to bt2020-transfer-characteristic p010 format
22111@example
22112tonemap_vaapi=format=p010:t=bt2020-10
22113@end example
22114@end itemize
22115
22116@c man end VAAPI VIDEO FILTERS
22117
22118@chapter Video Sources
22119@c man begin VIDEO SOURCES
22120
22121Below is a description of the currently available video sources.
22122
22123@section buffer
22124
22125Buffer video frames, and make them available to the filter chain.
22126
22127This source is mainly intended for a programmatic use, in particular
22128through the interface defined in @file{libavfilter/vsrc_buffer.h}.
22129
22130It accepts the following parameters:
22131
22132@table @option
22133
22134@item video_size
22135Specify the size (width and height) of the buffered video frames. For the
22136syntax of this option, check the
22137@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
22138
22139@item width
22140The input video width.
22141
22142@item height
22143The input video height.
22144
22145@item pix_fmt
22146A string representing the pixel format of the buffered video frames.
22147It may be a number corresponding to a pixel format, or a pixel format
22148name.
22149
22150@item time_base
22151Specify the timebase assumed by the timestamps of the buffered frames.
22152
22153@item frame_rate
22154Specify the frame rate expected for the video stream.
22155
22156@item pixel_aspect, sar
22157The sample (pixel) aspect ratio of the input video.
22158
22159@item sws_param
22160This option is deprecated and ignored. Prepend @code{sws_flags=@var{flags};}
22161to the filtergraph description to specify swscale flags for automatically
22162inserted scalers. See @ref{Filtergraph syntax}.
22163
22164@item hw_frames_ctx
22165When using a hardware pixel format, this should be a reference to an
22166AVHWFramesContext describing input frames.
22167@end table
22168
22169For example:
22170@example
22171buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
22172@end example
22173
22174will instruct the source to accept video frames with size 320x240 and
22175with format "yuv410p", assuming 1/24 as the timestamps timebase and
22176square pixels (1:1 sample aspect ratio).
22177Since the pixel format with name "yuv410p" corresponds to the number 6
22178(check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
22179this example corresponds to:
22180@example
22181buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
22182@end example
22183
22184Alternatively, the options can be specified as a flat string, but this
22185syntax is deprecated:
22186
22187@var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}
22188
22189@section cellauto
22190
22191Create a pattern generated by an elementary cellular automaton.
22192
22193The initial state of the cellular automaton can be defined through the
22194@option{filename} and @option{pattern} options. If such options are
22195not specified an initial state is created randomly.
22196
22197At each new frame a new row in the video is filled with the result of
22198the cellular automaton next generation. The behavior when the whole
22199frame is filled is defined by the @option{scroll} option.
22200
22201This source accepts the following options:
22202
22203@table @option
22204@item filename, f
22205Read the initial cellular automaton state, i.e. the starting row, from
22206the specified file.
22207In the file, each non-whitespace character is considered an alive
22208cell, a newline will terminate the row, and further characters in the
22209file will be ignored.
22210
22211@item pattern, p
22212Read the initial cellular automaton state, i.e. the starting row, from
22213the specified string.
22214
22215Each non-whitespace character in the string is considered an alive
22216cell, a newline will terminate the row, and further characters in the
22217string will be ignored.
22218
22219@item rate, r
22220Set the video rate, that is the number of frames generated per second.
22221Default is 25.
22222
22223@item random_fill_ratio, ratio
22224Set the random fill ratio for the initial cellular automaton row. It
22225is a floating point number value ranging from 0 to 1, defaults to
222261/PHI.
22227
22228This option is ignored when a file or a pattern is specified.
22229
22230@item random_seed, seed
22231Set the seed for filling randomly the initial row, must be an integer
22232included between 0 and UINT32_MAX. If not specified, or if explicitly
22233set to -1, the filter will try to use a good random seed on a best
22234effort basis.
22235
22236@item rule
22237Set the cellular automaton rule, it is a number ranging from 0 to 255.
22238Default value is 110.
22239
22240@item size, s
22241Set the size of the output video. For the syntax of this option, check the
22242@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
22243
22244If @option{filename} or @option{pattern} is specified, the size is set
22245by default to the width of the specified initial state row, and the
22246height is set to @var{width} * PHI.
22247
22248If @option{size} is set, it must contain the width of the specified
22249pattern string, and the specified pattern will be centered in the
22250larger row.
22251
22252If a filename or a pattern string is not specified, the size value
22253defaults to "320x518" (used for a randomly generated initial state).
22254
22255@item scroll
22256If set to 1, scroll the output upward when all the rows in the output
22257have been already filled. If set to 0, the new generated row will be
22258written over the top row just after the bottom row is filled.
22259Defaults to 1.
22260
22261@item start_full, full
22262If set to 1, completely fill the output with generated rows before
22263outputting the first frame.
22264This is the default behavior, for disabling set the value to 0.
22265
22266@item stitch
22267If set to 1, stitch the left and right row edges together.
22268This is the default behavior, for disabling set the value to 0.
22269@end table
22270
22271@subsection Examples
22272
22273@itemize
22274@item
22275Read the initial state from @file{pattern}, and specify an output of
22276size 200x400.
22277@example
22278cellauto=f=pattern:s=200x400
22279@end example
22280
22281@item
22282Generate a random initial row with a width of 200 cells, with a fill
22283ratio of 2/3:
22284@example
22285cellauto=ratio=2/3:s=200x200
22286@end example
22287
22288@item
22289Create a pattern generated by rule 18 starting by a single alive cell
22290centered on an initial row with width 100:
22291@example
22292cellauto=p=@@:s=100x400:full=0:rule=18
22293@end example
22294
22295@item
22296Specify a more elaborated initial pattern:
22297@example
22298cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
22299@end example
22300
22301@end itemize
22302
22303@anchor{coreimagesrc}
22304@section coreimagesrc
22305Video source generated on GPU using Apple's CoreImage API on OSX.
22306
22307This video source is a specialized version of the @ref{coreimage} video filter.
22308Use a core image generator at the beginning of the applied filterchain to
22309generate the content.
22310
22311The coreimagesrc video source accepts the following options:
22312@table @option
22313@item list_generators
22314List all available generators along with all their respective options as well as
22315possible minimum and maximum values along with the default values.
22316@example
22317list_generators=true
22318@end example
22319
22320@item size, s
22321Specify the size of the sourced video. For the syntax of this option, check the
22322@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
22323The default value is @code{320x240}.
22324
22325@item rate, r
22326Specify the frame rate of the sourced video, as the number of frames
22327generated per second. It has to be a string in the format
22328@var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
22329number or a valid video frame rate abbreviation. The default value is
22330"25".
22331
22332@item sar
22333Set the sample aspect ratio of the sourced video.
22334
22335@item duration, d
22336Set the duration of the sourced video. See
22337@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
22338for the accepted syntax.
22339
22340If not specified, or the expressed duration is negative, the video is
22341supposed to be generated forever.
22342@end table
22343
22344Additionally, all options of the @ref{coreimage} video filter are accepted.
22345A complete filterchain can be used for further processing of the
22346generated input without CPU-HOST transfer. See @ref{coreimage} documentation
22347and examples for details.
22348
22349@subsection Examples
22350
22351@itemize
22352
22353@item
22354Use CIQRCodeGenerator to create a QR code for the FFmpeg homepage,
22355given as complete and escaped command-line for Apple's standard bash shell:
22356@example
22357ffmpeg -f lavfi -i coreimagesrc=s=100x100:filter=CIQRCodeGenerator@@inputMessage=https\\\\\://FFmpeg.org/@@inputCorrectionLevel=H -frames:v 1 QRCode.png
22358@end example
22359This example is equivalent to the QRCode example of @ref{coreimage} without the
22360need for a nullsrc video source.
22361@end itemize
22362
22363
22364@section gradients
22365Generate several gradients.
22366
22367@table @option
22368@item size, s
22369Set frame size. For the syntax of this option, check the @ref{video size syntax,,"Video
22370size" section in the ffmpeg-utils manual,ffmpeg-utils}. Default value is "640x480".
22371
22372@item rate, r
22373Set frame rate, expressed as number of frames per second. Default
22374value is "25".
22375
22376@item c0, c1, c2, c3, c4, c5, c6, c7
22377Set 8 colors. Default values for colors is to pick random one.
22378
22379@item x0, y0, y0, y1
22380Set gradient line source and destination points. If negative or out of range, random ones
22381are picked.
22382
22383@item nb_colors, n
22384Set number of colors to use at once. Allowed range is from 2 to 8. Default value is 2.
22385
22386@item seed
22387Set seed for picking gradient line points.
22388@end table
22389
22390
22391@section mandelbrot
22392
22393Generate a Mandelbrot set fractal, and progressively zoom towards the
22394point specified with @var{start_x} and @var{start_y}.
22395
22396This source accepts the following options:
22397
22398@table @option
22399
22400@item end_pts
22401Set the terminal pts value. Default value is 400.
22402
22403@item end_scale
22404Set the terminal scale value.
22405Must be a floating point value. Default value is 0.3.
22406
22407@item inner
22408Set the inner coloring mode, that is the algorithm used to draw the
22409Mandelbrot fractal internal region.
22410
22411It shall assume one of the following values:
22412@table @option
22413@item black
22414Set black mode.
22415@item convergence
22416Show time until convergence.
22417@item mincol
22418Set color based on point closest to the origin of the iterations.
22419@item period
22420Set period mode.
22421@end table
22422
22423Default value is @var{mincol}.
22424
22425@item bailout
22426Set the bailout value. Default value is 10.0.
22427
22428@item maxiter
22429Set the maximum of iterations performed by the rendering
22430algorithm. Default value is 7189.
22431
22432@item outer
22433Set outer coloring mode.
22434It shall assume one of following values:
22435@table @option
22436@item iteration_count
22437Set iteration count mode.
22438@item normalized_iteration_count
22439set normalized iteration count mode.
22440@end table
22441Default value is @var{normalized_iteration_count}.
22442
22443@item rate, r
22444Set frame rate, expressed as number of frames per second. Default
22445value is "25".
22446
22447@item size, s
22448Set frame size. For the syntax of this option, check the @ref{video size syntax,,"Video
22449size" section in the ffmpeg-utils manual,ffmpeg-utils}. Default value is "640x480".
22450
22451@item start_scale
22452Set the initial scale value. Default value is 3.0.
22453
22454@item start_x
22455Set the initial x position. Must be a floating point value between
22456-100 and 100. Default value is -0.743643887037158704752191506114774.
22457
22458@item start_y
22459Set the initial y position. Must be a floating point value between
22460-100 and 100. Default value is -0.131825904205311970493132056385139.
22461@end table
22462
22463@section mptestsrc
22464
22465Generate various test patterns, as generated by the MPlayer test filter.
22466
22467The size of the generated video is fixed, and is 256x256.
22468This source is useful in particular for testing encoding features.
22469
22470This source accepts the following options:
22471
22472@table @option
22473
22474@item rate, r
22475Specify the frame rate of the sourced video, as the number of frames
22476generated per second. It has to be a string in the format
22477@var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
22478number or a valid video frame rate abbreviation. The default value is
22479"25".
22480
22481@item duration, d
22482Set the duration of the sourced video. See
22483@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
22484for the accepted syntax.
22485
22486If not specified, or the expressed duration is negative, the video is
22487supposed to be generated forever.
22488
22489@item test, t
22490
22491Set the number or the name of the test to perform. Supported tests are:
22492@table @option
22493@item dc_luma
22494@item dc_chroma
22495@item freq_luma
22496@item freq_chroma
22497@item amp_luma
22498@item amp_chroma
22499@item cbp
22500@item mv
22501@item ring1
22502@item ring2
22503@item all
22504
22505@item max_frames, m
22506Set the maximum number of frames generated for each test, default value is 30.
22507
22508@end table
22509
22510Default value is "all", which will cycle through the list of all tests.
22511@end table
22512
22513Some examples:
22514@example
22515mptestsrc=t=dc_luma
22516@end example
22517
22518will generate a "dc_luma" test pattern.
22519
22520@section frei0r_src
22521
22522Provide a frei0r source.
22523
22524To enable compilation of this filter you need to install the frei0r
22525header and configure FFmpeg with @code{--enable-frei0r}.
22526
22527This source accepts the following parameters:
22528
22529@table @option
22530
22531@item size
22532The size of the video to generate. For the syntax of this option, check the
22533@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
22534
22535@item framerate
22536The framerate of the generated video. It may be a string of the form
22537@var{num}/@var{den} or a frame rate abbreviation.
22538
22539@item filter_name
22540The name to the frei0r source to load. For more information regarding frei0r and
22541how to set the parameters, read the @ref{frei0r} section in the video filters
22542documentation.
22543
22544@item filter_params
22545A '|'-separated list of parameters to pass to the frei0r source.
22546
22547@end table
22548
22549For example, to generate a frei0r partik0l source with size 200x200
22550and frame rate 10 which is overlaid on the overlay filter main input:
22551@example
22552frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
22553@end example
22554
22555@section life
22556
22557Generate a life pattern.
22558
22559This source is based on a generalization of John Conway's life game.
22560
22561The sourced input represents a life grid, each pixel represents a cell
22562which can be in one of two possible states, alive or dead. Every cell
22563interacts with its eight neighbours, which are the cells that are
22564horizontally, vertically, or diagonally adjacent.
22565
22566At each interaction the grid evolves according to the adopted rule,
22567which specifies the number of neighbor alive cells which will make a
22568cell stay alive or born. The @option{rule} option allows one to specify
22569the rule to adopt.
22570
22571This source accepts the following options:
22572
22573@table @option
22574@item filename, f
22575Set the file from which to read the initial grid state. In the file,
22576each non-whitespace character is considered an alive cell, and newline
22577is used to delimit the end of each row.
22578
22579If this option is not specified, the initial grid is generated
22580randomly.
22581
22582@item rate, r
22583Set the video rate, that is the number of frames generated per second.
22584Default is 25.
22585
22586@item random_fill_ratio, ratio
22587Set the random fill ratio for the initial random grid. It is a
22588floating point number value ranging from 0 to 1, defaults to 1/PHI.
22589It is ignored when a file is specified.
22590
22591@item random_seed, seed
22592Set the seed for filling the initial random grid, must be an integer
22593included between 0 and UINT32_MAX. If not specified, or if explicitly
22594set to -1, the filter will try to use a good random seed on a best
22595effort basis.
22596
22597@item rule
22598Set the life rule.
22599
22600A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
22601where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
22602@var{NS} specifies the number of alive neighbor cells which make a
22603live cell stay alive, and @var{NB} the number of alive neighbor cells
22604which make a dead cell to become alive (i.e. to "born").
22605"s" and "b" can be used in place of "S" and "B", respectively.
22606
22607Alternatively a rule can be specified by an 18-bits integer. The 9
22608high order bits are used to encode the next cell state if it is alive
22609for each number of neighbor alive cells, the low order bits specify
22610the rule for "borning" new cells. Higher order bits encode for an
22611higher number of neighbor cells.
22612For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
22613rule of 12 and a born rule of 9, which corresponds to "S23/B03".
22614
22615Default value is "S23/B3", which is the original Conway's game of life
22616rule, and will keep a cell alive if it has 2 or 3 neighbor alive
22617cells, and will born a new cell if there are three alive cells around
22618a dead cell.
22619
22620@item size, s
22621Set the size of the output video. For the syntax of this option, check the
22622@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
22623
22624If @option{filename} is specified, the size is set by default to the
22625same size of the input file. If @option{size} is set, it must contain
22626the size specified in the input file, and the initial grid defined in
22627that file is centered in the larger resulting area.
22628
22629If a filename is not specified, the size value defaults to "320x240"
22630(used for a randomly generated initial grid).
22631
22632@item stitch
22633If set to 1, stitch the left and right grid edges together, and the
22634top and bottom edges also. Defaults to 1.
22635
22636@item mold
22637Set cell mold speed. If set, a dead cell will go from @option{death_color} to
22638@option{mold_color} with a step of @option{mold}. @option{mold} can have a
22639value from 0 to 255.
22640
22641@item life_color
22642Set the color of living (or new born) cells.
22643
22644@item death_color
22645Set the color of dead cells. If @option{mold} is set, this is the first color
22646used to represent a dead cell.
22647
22648@item mold_color
22649Set mold color, for definitely dead and moldy cells.
22650
22651For the syntax of these 3 color options, check the @ref{color syntax,,"Color" section in the
22652ffmpeg-utils manual,ffmpeg-utils}.
22653@end table
22654
22655@subsection Examples
22656
22657@itemize
22658@item
22659Read a grid from @file{pattern}, and center it on a grid of size
22660300x300 pixels:
22661@example
22662life=f=pattern:s=300x300
22663@end example
22664
22665@item
22666Generate a random grid of size 200x200, with a fill ratio of 2/3:
22667@example
22668life=ratio=2/3:s=200x200
22669@end example
22670
22671@item
22672Specify a custom rule for evolving a randomly generated grid:
22673@example
22674life=rule=S14/B34
22675@end example
22676
22677@item
22678Full example with slow death effect (mold) using @command{ffplay}:
22679@example
22680ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
22681@end example
22682@end itemize
22683
22684@anchor{allrgb}
22685@anchor{allyuv}
22686@anchor{color}
22687@anchor{haldclutsrc}
22688@anchor{nullsrc}
22689@anchor{pal75bars}
22690@anchor{pal100bars}
22691@anchor{rgbtestsrc}
22692@anchor{smptebars}
22693@anchor{smptehdbars}
22694@anchor{testsrc}
22695@anchor{testsrc2}
22696@anchor{yuvtestsrc}
22697@section allrgb, allyuv, color, haldclutsrc, nullsrc, pal75bars, pal100bars, rgbtestsrc, smptebars, smptehdbars, testsrc, testsrc2, yuvtestsrc
22698
22699The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
22700
22701The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
22702
22703The @code{color} source provides an uniformly colored input.
22704
22705The @code{haldclutsrc} source provides an identity Hald CLUT. See also
22706@ref{haldclut} filter.
22707
22708The @code{nullsrc} source returns unprocessed video frames. It is
22709mainly useful to be employed in analysis / debugging tools, or as the
22710source for filters which ignore the input data.
22711
22712The @code{pal75bars} source generates a color bars pattern, based on
22713EBU PAL recommendations with 75% color levels.
22714
22715The @code{pal100bars} source generates a color bars pattern, based on
22716EBU PAL recommendations with 100% color levels.
22717
22718The @code{rgbtestsrc} source generates an RGB test pattern useful for
22719detecting RGB vs BGR issues. You should see a red, green and blue
22720stripe from top to bottom.
22721
22722The @code{smptebars} source generates a color bars pattern, based on
22723the SMPTE Engineering Guideline EG 1-1990.
22724
22725The @code{smptehdbars} source generates a color bars pattern, based on
22726the SMPTE RP 219-2002.
22727
22728The @code{testsrc} source generates a test video pattern, showing a
22729color pattern, a scrolling gradient and a timestamp. This is mainly
22730intended for testing purposes.
22731
22732The @code{testsrc2} source is similar to testsrc, but supports more
22733pixel formats instead of just @code{rgb24}. This allows using it as an
22734input for other tests without requiring a format conversion.
22735
22736The @code{yuvtestsrc} source generates an YUV test pattern. You should
22737see a y, cb and cr stripe from top to bottom.
22738
22739The sources accept the following parameters:
22740
22741@table @option
22742
22743@item level
22744Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
22745source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
22746pixels to be used as identity matrix for 3D lookup tables. Each component is
22747coded on a @code{1/(N*N)} scale.
22748
22749@item color, c
22750Specify the color of the source, only available in the @code{color}
22751source. For the syntax of this option, check the
22752@ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.
22753
22754@item size, s
22755Specify the size of the sourced video. For the syntax of this option, check the
22756@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
22757The default value is @code{320x240}.
22758
22759This option is not available with the @code{allrgb}, @code{allyuv}, and
22760@code{haldclutsrc} filters.
22761
22762@item rate, r
22763Specify the frame rate of the sourced video, as the number of frames
22764generated per second. It has to be a string in the format
22765@var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
22766number or a valid video frame rate abbreviation. The default value is
22767"25".
22768
22769@item duration, d
22770Set the duration of the sourced video. See
22771@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
22772for the accepted syntax.
22773
22774If not specified, or the expressed duration is negative, the video is
22775supposed to be generated forever.
22776
22777@item sar
22778Set the sample aspect ratio of the sourced video.
22779
22780@item alpha
22781Specify the alpha (opacity) of the background, only available in the
22782@code{testsrc2} source. The value must be between 0 (fully transparent) and
22783255 (fully opaque, the default).
22784
22785@item decimals, n
22786Set the number of decimals to show in the timestamp, only available in the
22787@code{testsrc} source.
22788
22789The displayed timestamp value will correspond to the original
22790timestamp value multiplied by the power of 10 of the specified
22791value. Default value is 0.
22792@end table
22793
22794@subsection Examples
22795
22796@itemize
22797@item
22798Generate a video with a duration of 5.3 seconds, with size
22799176x144 and a frame rate of 10 frames per second:
22800@example
22801testsrc=duration=5.3:size=qcif:rate=10
22802@end example
22803
22804@item
22805The following graph description will generate a red source
22806with an opacity of 0.2, with size "qcif" and a frame rate of 10
22807frames per second:
22808@example
22809color=c=red@@0.2:s=qcif:r=10
22810@end example
22811
22812@item
22813If the input content is to be ignored, @code{nullsrc} can be used. The
22814following command generates noise in the luminance plane by employing
22815the @code{geq} filter:
22816@example
22817nullsrc=s=256x256, geq=random(1)*255:128:128
22818@end example
22819@end itemize
22820
22821@subsection Commands
22822
22823The @code{color} source supports the following commands:
22824
22825@table @option
22826@item c, color
22827Set the color of the created image. Accepts the same syntax of the
22828corresponding @option{color} option.
22829@end table
22830
22831@section openclsrc
22832
22833Generate video using an OpenCL program.
22834
22835@table @option
22836
22837@item source
22838OpenCL program source file.
22839
22840@item kernel
22841Kernel name in program.
22842
22843@item size, s
22844Size of frames to generate.  This must be set.
22845
22846@item format
22847Pixel format to use for the generated frames.  This must be set.
22848
22849@item rate, r
22850Number of frames generated every second.  Default value is '25'.
22851
22852@end table
22853
22854For details of how the program loading works, see the @ref{program_opencl}
22855filter.
22856
22857Example programs:
22858
22859@itemize
22860@item
22861Generate a colour ramp by setting pixel values from the position of the pixel
22862in the output image.  (Note that this will work with all pixel formats, but
22863the generated output will not be the same.)
22864@verbatim
22865__kernel void ramp(__write_only image2d_t dst,
22866                   unsigned int index)
22867{
22868    int2 loc = (int2)(get_global_id(0), get_global_id(1));
22869
22870    float4 val;
22871    val.xy = val.zw = convert_float2(loc) / convert_float2(get_image_dim(dst));
22872
22873    write_imagef(dst, loc, val);
22874}
22875@end verbatim
22876
22877@item
22878Generate a Sierpinski carpet pattern, panning by a single pixel each frame.
22879@verbatim
22880__kernel void sierpinski_carpet(__write_only image2d_t dst,
22881                                unsigned int index)
22882{
22883    int2 loc = (int2)(get_global_id(0), get_global_id(1));
22884
22885    float4 value = 0.0f;
22886    int x = loc.x + index;
22887    int y = loc.y + index;
22888    while (x > 0 || y > 0) {
22889        if (x % 3 == 1 && y % 3 == 1) {
22890            value = 1.0f;
22891            break;
22892        }
22893        x /= 3;
22894        y /= 3;
22895    }
22896
22897    write_imagef(dst, loc, value);
22898}
22899@end verbatim
22900
22901@end itemize
22902
22903@section sierpinski
22904
22905Generate a Sierpinski carpet/triangle fractal, and randomly pan around.
22906
22907This source accepts the following options:
22908
22909@table @option
22910@item size, s
22911Set frame size. For the syntax of this option, check the @ref{video size syntax,,"Video
22912size" section in the ffmpeg-utils manual,ffmpeg-utils}. Default value is "640x480".
22913
22914@item rate, r
22915Set frame rate, expressed as number of frames per second. Default
22916value is "25".
22917
22918@item seed
22919Set seed which is used for random panning.
22920
22921@item jump
22922Set max jump for single pan destination. Allowed range is from 1 to 10000.
22923
22924@item type
22925Set fractal type, can be default @code{carpet} or @code{triangle}.
22926@end table
22927
22928@c man end VIDEO SOURCES
22929
22930@chapter Video Sinks
22931@c man begin VIDEO SINKS
22932
22933Below is a description of the currently available video sinks.
22934
22935@section buffersink
22936
22937Buffer video frames, and make them available to the end of the filter
22938graph.
22939
22940This sink is mainly intended for programmatic use, in particular
22941through the interface defined in @file{libavfilter/buffersink.h}
22942or the options system.
22943
22944It accepts a pointer to an AVBufferSinkContext structure, which
22945defines the incoming buffers' formats, to be passed as the opaque
22946parameter to @code{avfilter_init_filter} for initialization.
22947
22948@section nullsink
22949
22950Null video sink: do absolutely nothing with the input video. It is
22951mainly useful as a template and for use in analysis / debugging
22952tools.
22953
22954@c man end VIDEO SINKS
22955
22956@chapter Multimedia Filters
22957@c man begin MULTIMEDIA FILTERS
22958
22959Below is a description of the currently available multimedia filters.
22960
22961@section abitscope
22962
22963Convert input audio to a video output, displaying the audio bit scope.
22964
22965The filter accepts the following options:
22966
22967@table @option
22968@item rate, r
22969Set frame rate, expressed as number of frames per second. Default
22970value is "25".
22971
22972@item size, s
22973Specify the video size for the output. For the syntax of this option, check the
22974@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
22975Default value is @code{1024x256}.
22976
22977@item colors
22978Specify list of colors separated by space or by '|' which will be used to
22979draw channels. Unrecognized or missing colors will be replaced
22980by white color.
22981@end table
22982
22983@section adrawgraph
22984Draw a graph using input audio metadata.
22985
22986See @ref{drawgraph}
22987
22988@section agraphmonitor
22989
22990See @ref{graphmonitor}.
22991
22992@section ahistogram
22993
22994Convert input audio to a video output, displaying the volume histogram.
22995
22996The filter accepts the following options:
22997
22998@table @option
22999@item dmode
23000Specify how histogram is calculated.
23001
23002It accepts the following values:
23003@table @samp
23004@item single
23005Use single histogram for all channels.
23006@item separate
23007Use separate histogram for each channel.
23008@end table
23009Default is @code{single}.
23010
23011@item rate, r
23012Set frame rate, expressed as number of frames per second. Default
23013value is "25".
23014
23015@item size, s
23016Specify the video size for the output. For the syntax of this option, check the
23017@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
23018Default value is @code{hd720}.
23019
23020@item scale
23021Set display scale.
23022
23023It accepts the following values:
23024@table @samp
23025@item log
23026logarithmic
23027@item sqrt
23028square root
23029@item cbrt
23030cubic root
23031@item lin
23032linear
23033@item rlog
23034reverse logarithmic
23035@end table
23036Default is @code{log}.
23037
23038@item ascale
23039Set amplitude scale.
23040
23041It accepts the following values:
23042@table @samp
23043@item log
23044logarithmic
23045@item lin
23046linear
23047@end table
23048Default is @code{log}.
23049
23050@item acount
23051Set how much frames to accumulate in histogram.
23052Default is 1. Setting this to -1 accumulates all frames.
23053
23054@item rheight
23055Set histogram ratio of window height.
23056
23057@item slide
23058Set sonogram sliding.
23059
23060It accepts the following values:
23061@table @samp
23062@item replace
23063replace old rows with new ones.
23064@item scroll
23065scroll from top to bottom.
23066@end table
23067Default is @code{replace}.
23068@end table
23069
23070@section aphasemeter
23071
23072Measures phase of input audio, which is exported as metadata @code{lavfi.aphasemeter.phase},
23073representing mean phase of current audio frame. A video output can also be produced and is
23074enabled by default. The audio is passed through as first output.
23075
23076Audio will be rematrixed to stereo if it has a different channel layout. Phase value is in
23077range @code{[-1, 1]} where @code{-1} means left and right channels are completely out of phase
23078and @code{1} means channels are in phase.
23079
23080The filter accepts the following options, all related to its video output:
23081
23082@table @option
23083@item rate, r
23084Set the output frame rate. Default value is @code{25}.
23085
23086@item size, s
23087Set the video size for the output. For the syntax of this option, check the
23088@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
23089Default value is @code{800x400}.
23090
23091@item rc
23092@item gc
23093@item bc
23094Specify the red, green, blue contrast. Default values are @code{2},
23095@code{7} and @code{1}.
23096Allowed range is @code{[0, 255]}.
23097
23098@item mpc
23099Set color which will be used for drawing median phase. If color is
23100@code{none} which is default, no median phase value will be drawn.
23101
23102@item video
23103Enable video output. Default is enabled.
23104@end table
23105
23106@section avectorscope
23107
23108Convert input audio to a video output, representing the audio vector
23109scope.
23110
23111The filter is used to measure the difference between channels of stereo
23112audio stream. A monaural signal, consisting of identical left and right
23113signal, results in straight vertical line. Any stereo separation is visible
23114as a deviation from this line, creating a Lissajous figure.
23115If the straight (or deviation from it) but horizontal line appears this
23116indicates that the left and right channels are out of phase.
23117
23118The filter accepts the following options:
23119
23120@table @option
23121@item mode, m
23122Set the vectorscope mode.
23123
23124Available values are:
23125@table @samp
23126@item lissajous
23127Lissajous rotated by 45 degrees.
23128
23129@item lissajous_xy
23130Same as above but not rotated.
23131
23132@item polar
23133Shape resembling half of circle.
23134@end table
23135
23136Default value is @samp{lissajous}.
23137
23138@item size, s
23139Set the video size for the output. For the syntax of this option, check the
23140@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
23141Default value is @code{400x400}.
23142
23143@item rate, r
23144Set the output frame rate. Default value is @code{25}.
23145
23146@item rc
23147@item gc
23148@item bc
23149@item ac
23150Specify the red, green, blue and alpha contrast. Default values are @code{40},
23151@code{160}, @code{80} and @code{255}.
23152Allowed range is @code{[0, 255]}.
23153
23154@item rf
23155@item gf
23156@item bf
23157@item af
23158Specify the red, green, blue and alpha fade. Default values are @code{15},
23159@code{10}, @code{5} and @code{5}.
23160Allowed range is @code{[0, 255]}.
23161
23162@item zoom
23163Set the zoom factor. Default value is @code{1}. Allowed range is @code{[0, 10]}.
23164Values lower than @var{1} will auto adjust zoom factor to maximal possible value.
23165
23166@item draw
23167Set the vectorscope drawing mode.
23168
23169Available values are:
23170@table @samp
23171@item dot
23172Draw dot for each sample.
23173
23174@item line
23175Draw line between previous and current sample.
23176@end table
23177
23178Default value is @samp{dot}.
23179
23180@item scale
23181Specify amplitude scale of audio samples.
23182
23183Available values are:
23184@table @samp
23185@item lin
23186Linear.
23187
23188@item sqrt
23189Square root.
23190
23191@item cbrt
23192Cubic root.
23193
23194@item log
23195Logarithmic.
23196@end table
23197
23198@item swap
23199Swap left channel axis with right channel axis.
23200
23201@item mirror
23202Mirror axis.
23203
23204@table @samp
23205@item none
23206No mirror.
23207
23208@item x
23209Mirror only x axis.
23210
23211@item y
23212Mirror only y axis.
23213
23214@item xy
23215Mirror both axis.
23216@end table
23217
23218@end table
23219
23220@subsection Examples
23221
23222@itemize
23223@item
23224Complete example using @command{ffplay}:
23225@example
23226ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
23227             [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
23228@end example
23229@end itemize
23230
23231@section bench, abench
23232
23233Benchmark part of a filtergraph.
23234
23235The filter accepts the following options:
23236
23237@table @option
23238@item action
23239Start or stop a timer.
23240
23241Available values are:
23242@table @samp
23243@item start
23244Get the current time, set it as frame metadata (using the key
23245@code{lavfi.bench.start_time}), and forward the frame to the next filter.
23246
23247@item stop
23248Get the current time and fetch the @code{lavfi.bench.start_time} metadata from
23249the input frame metadata to get the time difference. Time difference, average,
23250maximum and minimum time (respectively @code{t}, @code{avg}, @code{max} and
23251@code{min}) are then printed. The timestamps are expressed in seconds.
23252@end table
23253@end table
23254
23255@subsection Examples
23256
23257@itemize
23258@item
23259Benchmark @ref{selectivecolor} filter:
23260@example
23261bench=start,selectivecolor=reds=-.2 .12 -.49,bench=stop
23262@end example
23263@end itemize
23264
23265@section concat
23266
23267Concatenate audio and video streams, joining them together one after the
23268other.
23269
23270The filter works on segments of synchronized video and audio streams. All
23271segments must have the same number of streams of each type, and that will
23272also be the number of streams at output.
23273
23274The filter accepts the following options:
23275
23276@table @option
23277
23278@item n
23279Set the number of segments. Default is 2.
23280
23281@item v
23282Set the number of output video streams, that is also the number of video
23283streams in each segment. Default is 1.
23284
23285@item a
23286Set the number of output audio streams, that is also the number of audio
23287streams in each segment. Default is 0.
23288
23289@item unsafe
23290Activate unsafe mode: do not fail if segments have a different format.
23291
23292@end table
23293
23294The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
23295@var{a} audio outputs.
23296
23297There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
23298segment, in the same order as the outputs, then the inputs for the second
23299segment, etc.
23300
23301Related streams do not always have exactly the same duration, for various
23302reasons including codec frame size or sloppy authoring. For that reason,
23303related synchronized streams (e.g. a video and its audio track) should be
23304concatenated at once. The concat filter will use the duration of the longest
23305stream in each segment (except the last one), and if necessary pad shorter
23306audio streams with silence.
23307
23308For this filter to work correctly, all segments must start at timestamp 0.
23309
23310All corresponding streams must have the same parameters in all segments; the
23311filtering system will automatically select a common pixel format for video
23312streams, and a common sample format, sample rate and channel layout for
23313audio streams, but other settings, such as resolution, must be converted
23314explicitly by the user.
23315
23316Different frame rates are acceptable but will result in variable frame rate
23317at output; be sure to configure the output file to handle it.
23318
23319@subsection Examples
23320
23321@itemize
23322@item
23323Concatenate an opening, an episode and an ending, all in bilingual version
23324(video in stream 0, audio in streams 1 and 2):
23325@example
23326ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
23327  '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
23328   concat=n=3:v=1:a=2 [v] [a1] [a2]' \
23329  -map '[v]' -map '[a1]' -map '[a2]' output.mkv
23330@end example
23331
23332@item
23333Concatenate two parts, handling audio and video separately, using the
23334(a)movie sources, and adjusting the resolution:
23335@example
23336movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
23337movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
23338[v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
23339@end example
23340Note that a desync will happen at the stitch if the audio and video streams
23341do not have exactly the same duration in the first file.
23342
23343@end itemize
23344
23345@subsection Commands
23346
23347This filter supports the following commands:
23348@table @option
23349@item next
23350Close the current segment and step to the next one
23351@end table
23352
23353@anchor{ebur128}
23354@section ebur128
23355
23356EBU R128 scanner filter. This filter takes an audio stream and analyzes its loudness
23357level. By default, it logs a message at a frequency of 10Hz with the
23358Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
23359Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
23360
23361The filter can only analyze streams which have a sampling rate of 48000 Hz and whose
23362sample format is double-precision floating point. The input stream will be converted to
23363this specification, if needed. Users may need to insert aformat and/or aresample filters
23364after this filter to obtain the original parameters.
23365
23366The filter also has a video output (see the @var{video} option) with a real
23367time graph to observe the loudness evolution. The graphic contains the logged
23368message mentioned above, so it is not printed anymore when this option is set,
23369unless the verbose logging is set. The main graphing area contains the
23370short-term loudness (3 seconds of analysis), and the gauge on the right is for
23371the momentary loudness (400 milliseconds), but can optionally be configured
23372to instead display short-term loudness (see @var{gauge}).
23373
23374The green area marks a  +/- 1LU target range around the target loudness
23375(-23LUFS by default, unless modified through @var{target}).
23376
23377More information about the Loudness Recommendation EBU R128 on
23378@url{http://tech.ebu.ch/loudness}.
23379
23380The filter accepts the following options:
23381
23382@table @option
23383
23384@item video
23385Activate the video output. The audio stream is passed unchanged whether this
23386option is set or no. The video stream will be the first output stream if
23387activated. Default is @code{0}.
23388
23389@item size
23390Set the video size. This option is for video only. For the syntax of this
23391option, check the
23392@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
23393Default and minimum resolution is @code{640x480}.
23394
23395@item meter
23396Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
23397@code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
23398other integer value between this range is allowed.
23399
23400@item metadata
23401Set metadata injection. If set to @code{1}, the audio input will be segmented
23402into 100ms output frames, each of them containing various loudness information
23403in metadata.  All the metadata keys are prefixed with @code{lavfi.r128.}.
23404
23405Default is @code{0}.
23406
23407@item framelog
23408Force the frame logging level.
23409
23410Available values are:
23411@table @samp
23412@item info
23413information logging level
23414@item verbose
23415verbose logging level
23416@end table
23417
23418By default, the logging level is set to @var{info}. If the @option{video} or
23419the @option{metadata} options are set, it switches to @var{verbose}.
23420
23421@item peak
23422Set peak mode(s).
23423
23424Available modes can be cumulated (the option is a @code{flag} type). Possible
23425values are:
23426@table @samp
23427@item none
23428Disable any peak mode (default).
23429@item sample
23430Enable sample-peak mode.
23431
23432Simple peak mode looking for the higher sample value. It logs a message
23433for sample-peak (identified by @code{SPK}).
23434@item true
23435Enable true-peak mode.
23436
23437If enabled, the peak lookup is done on an over-sampled version of the input
23438stream for better peak accuracy. It logs a message for true-peak.
23439(identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
23440This mode requires a build with @code{libswresample}.
23441@end table
23442
23443@item dualmono
23444Treat mono input files as "dual mono". If a mono file is intended for playback
23445on a stereo system, its EBU R128 measurement will be perceptually incorrect.
23446If set to @code{true}, this option will compensate for this effect.
23447Multi-channel input files are not affected by this option.
23448
23449@item panlaw
23450Set a specific pan law to be used for the measurement of dual mono files.
23451This parameter is optional, and has a default value of -3.01dB.
23452
23453@item target
23454Set a specific target level (in LUFS) used as relative zero in the visualization.
23455This parameter is optional and has a default value of -23LUFS as specified
23456by EBU R128. However, material published online may prefer a level of -16LUFS
23457(e.g. for use with podcasts or video platforms).
23458
23459@item gauge
23460Set the value displayed by the gauge. Valid values are @code{momentary} and s
23461@code{shortterm}. By default the momentary value will be used, but in certain
23462scenarios it may be more useful to observe the short term value instead (e.g.
23463live mixing).
23464
23465@item scale
23466Sets the display scale for the loudness. Valid parameters are @code{absolute}
23467(in LUFS) or @code{relative} (LU) relative to the target. This only affects the
23468video output, not the summary or continuous log output.
23469@end table
23470
23471@subsection Examples
23472
23473@itemize
23474@item
23475Real-time graph using @command{ffplay}, with a EBU scale meter +18:
23476@example
23477ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
23478@end example
23479
23480@item
23481Run an analysis with @command{ffmpeg}:
23482@example
23483ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
23484@end example
23485@end itemize
23486
23487@section interleave, ainterleave
23488
23489Temporally interleave frames from several inputs.
23490
23491@code{interleave} works with video inputs, @code{ainterleave} with audio.
23492
23493These filters read frames from several inputs and send the oldest
23494queued frame to the output.
23495
23496Input streams must have well defined, monotonically increasing frame
23497timestamp values.
23498
23499In order to submit one frame to output, these filters need to enqueue
23500at least one frame for each input, so they cannot work in case one
23501input is not yet terminated and will not receive incoming frames.
23502
23503For example consider the case when one input is a @code{select} filter
23504which always drops input frames. The @code{interleave} filter will keep
23505reading from that input, but it will never be able to send new frames
23506to output until the input sends an end-of-stream signal.
23507
23508Also, depending on inputs synchronization, the filters will drop
23509frames in case one input receives more frames than the other ones, and
23510the queue is already filled.
23511
23512These filters accept the following options:
23513
23514@table @option
23515@item nb_inputs, n
23516Set the number of different inputs, it is 2 by default.
23517
23518@item duration
23519How to determine the end-of-stream.
23520
23521@table @option
23522@item longest
23523The duration of the longest input. (default)
23524
23525@item shortest
23526The duration of the shortest input.
23527
23528@item first
23529The duration of the first input.
23530@end table
23531
23532@end table
23533
23534@subsection Examples
23535
23536@itemize
23537@item
23538Interleave frames belonging to different streams using @command{ffmpeg}:
23539@example
23540ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
23541@end example
23542
23543@item
23544Add flickering blur effect:
23545@example
23546select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
23547@end example
23548@end itemize
23549
23550@section metadata, ametadata
23551
23552Manipulate frame metadata.
23553
23554This filter accepts the following options:
23555
23556@table @option
23557@item mode
23558Set mode of operation of the filter.
23559
23560Can be one of the following:
23561
23562@table @samp
23563@item select
23564If both @code{value} and @code{key} is set, select frames
23565which have such metadata. If only @code{key} is set, select
23566every frame that has such key in metadata.
23567
23568@item add
23569Add new metadata @code{key} and @code{value}. If key is already available
23570do nothing.
23571
23572@item modify
23573Modify value of already present key.
23574
23575@item delete
23576If @code{value} is set, delete only keys that have such value.
23577Otherwise, delete key. If @code{key} is not set, delete all metadata values in
23578the frame.
23579
23580@item print
23581Print key and its value if metadata was found. If @code{key} is not set print all
23582metadata values available in frame.
23583@end table
23584
23585@item key
23586Set key used with all modes. Must be set for all modes except @code{print} and @code{delete}.
23587
23588@item value
23589Set metadata value which will be used. This option is mandatory for
23590@code{modify} and @code{add} mode.
23591
23592@item function
23593Which function to use when comparing metadata value and @code{value}.
23594
23595Can be one of following:
23596
23597@table @samp
23598@item same_str
23599Values are interpreted as strings, returns true if metadata value is same as @code{value}.
23600
23601@item starts_with
23602Values are interpreted as strings, returns true if metadata value starts with
23603the @code{value} option string.
23604
23605@item less
23606Values are interpreted as floats, returns true if metadata value is less than @code{value}.
23607
23608@item equal
23609Values are interpreted as floats, returns true if @code{value} is equal with metadata value.
23610
23611@item greater
23612Values are interpreted as floats, returns true if metadata value is greater than @code{value}.
23613
23614@item expr
23615Values are interpreted as floats, returns true if expression from option @code{expr}
23616evaluates to true.
23617
23618@item ends_with
23619Values are interpreted as strings, returns true if metadata value ends with
23620the @code{value} option string.
23621@end table
23622
23623@item expr
23624Set expression which is used when @code{function} is set to @code{expr}.
23625The expression is evaluated through the eval API and can contain the following
23626constants:
23627
23628@table @option
23629@item VALUE1
23630Float representation of @code{value} from metadata key.
23631
23632@item VALUE2
23633Float representation of @code{value} as supplied by user in @code{value} option.
23634@end table
23635
23636@item file
23637If specified in @code{print} mode, output is written to the named file. Instead of
23638plain filename any writable url can be specified. Filename ``-'' is a shorthand
23639for standard output. If @code{file} option is not set, output is written to the log
23640with AV_LOG_INFO loglevel.
23641
23642@item direct
23643Reduces buffering in print mode when output is written to a URL set using @var{file}.
23644
23645@end table
23646
23647@subsection Examples
23648
23649@itemize
23650@item
23651Print all metadata values for frames with key @code{lavfi.signalstats.YDIF} with values
23652between 0 and 1.
23653@example
23654signalstats,metadata=print:key=lavfi.signalstats.YDIF:value=0:function=expr:expr='between(VALUE1,0,1)'
23655@end example
23656@item
23657Print silencedetect output to file @file{metadata.txt}.
23658@example
23659silencedetect,ametadata=mode=print:file=metadata.txt
23660@end example
23661@item
23662Direct all metadata to a pipe with file descriptor 4.
23663@example
23664metadata=mode=print:file='pipe\:4'
23665@end example
23666@end itemize
23667
23668@section perms, aperms
23669
23670Set read/write permissions for the output frames.
23671
23672These filters are mainly aimed at developers to test direct path in the
23673following filter in the filtergraph.
23674
23675The filters accept the following options:
23676
23677@table @option
23678@item mode
23679Select the permissions mode.
23680
23681It accepts the following values:
23682@table @samp
23683@item none
23684Do nothing. This is the default.
23685@item ro
23686Set all the output frames read-only.
23687@item rw
23688Set all the output frames directly writable.
23689@item toggle
23690Make the frame read-only if writable, and writable if read-only.
23691@item random
23692Set each output frame read-only or writable randomly.
23693@end table
23694
23695@item seed
23696Set the seed for the @var{random} mode, must be an integer included between
23697@code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
23698@code{-1}, the filter will try to use a good random seed on a best effort
23699basis.
23700@end table
23701
23702Note: in case of auto-inserted filter between the permission filter and the
23703following one, the permission might not be received as expected in that
23704following filter. Inserting a @ref{format} or @ref{aformat} filter before the
23705perms/aperms filter can avoid this problem.
23706
23707@section realtime, arealtime
23708
23709Slow down filtering to match real time approximately.
23710
23711These filters will pause the filtering for a variable amount of time to
23712match the output rate with the input timestamps.
23713They are similar to the @option{re} option to @code{ffmpeg}.
23714
23715They accept the following options:
23716
23717@table @option
23718@item limit
23719Time limit for the pauses. Any pause longer than that will be considered
23720a timestamp discontinuity and reset the timer. Default is 2 seconds.
23721@item speed
23722Speed factor for processing. The value must be a float larger than zero.
23723Values larger than 1.0 will result in faster than realtime processing,
23724smaller will slow processing down. The @var{limit} is automatically adapted
23725accordingly. Default is 1.0.
23726
23727A processing speed faster than what is possible without these filters cannot
23728be achieved.
23729@end table
23730
23731@anchor{select}
23732@section select, aselect
23733
23734Select frames to pass in output.
23735
23736This filter accepts the following options:
23737
23738@table @option
23739
23740@item expr, e
23741Set expression, which is evaluated for each input frame.
23742
23743If the expression is evaluated to zero, the frame is discarded.
23744
23745If the evaluation result is negative or NaN, the frame is sent to the
23746first output; otherwise it is sent to the output with index
23747@code{ceil(val)-1}, assuming that the input index starts from 0.
23748
23749For example a value of @code{1.2} corresponds to the output with index
23750@code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
23751
23752@item outputs, n
23753Set the number of outputs. The output to which to send the selected
23754frame is based on the result of the evaluation. Default value is 1.
23755@end table
23756
23757The expression can contain the following constants:
23758
23759@table @option
23760@item n
23761The (sequential) number of the filtered frame, starting from 0.
23762
23763@item selected_n
23764The (sequential) number of the selected frame, starting from 0.
23765
23766@item prev_selected_n
23767The sequential number of the last selected frame. It's NAN if undefined.
23768
23769@item TB
23770The timebase of the input timestamps.
23771
23772@item pts
23773The PTS (Presentation TimeStamp) of the filtered video frame,
23774expressed in @var{TB} units. It's NAN if undefined.
23775
23776@item t
23777The PTS of the filtered video frame,
23778expressed in seconds. It's NAN if undefined.
23779
23780@item prev_pts
23781The PTS of the previously filtered video frame. It's NAN if undefined.
23782
23783@item prev_selected_pts
23784The PTS of the last previously filtered video frame. It's NAN if undefined.
23785
23786@item prev_selected_t
23787The PTS of the last previously selected video frame, expressed in seconds. It's NAN if undefined.
23788
23789@item start_pts
23790The PTS of the first video frame in the video. It's NAN if undefined.
23791
23792@item start_t
23793The time of the first video frame in the video. It's NAN if undefined.
23794
23795@item pict_type @emph{(video only)}
23796The type of the filtered frame. It can assume one of the following
23797values:
23798@table @option
23799@item I
23800@item P
23801@item B
23802@item S
23803@item SI
23804@item SP
23805@item BI
23806@end table
23807
23808@item interlace_type @emph{(video only)}
23809The frame interlace type. It can assume one of the following values:
23810@table @option
23811@item PROGRESSIVE
23812The frame is progressive (not interlaced).
23813@item TOPFIRST
23814The frame is top-field-first.
23815@item BOTTOMFIRST
23816The frame is bottom-field-first.
23817@end table
23818
23819@item consumed_sample_n @emph{(audio only)}
23820the number of selected samples before the current frame
23821
23822@item samples_n @emph{(audio only)}
23823the number of samples in the current frame
23824
23825@item sample_rate @emph{(audio only)}
23826the input sample rate
23827
23828@item key
23829This is 1 if the filtered frame is a key-frame, 0 otherwise.
23830
23831@item pos
23832the position in the file of the filtered frame, -1 if the information
23833is not available (e.g. for synthetic video)
23834
23835@item scene @emph{(video only)}
23836value between 0 and 1 to indicate a new scene; a low value reflects a low
23837probability for the current frame to introduce a new scene, while a higher
23838value means the current frame is more likely to be one (see the example below)
23839
23840@item concatdec_select
23841The concat demuxer can select only part of a concat input file by setting an
23842inpoint and an outpoint, but the output packets may not be entirely contained
23843in the selected interval. By using this variable, it is possible to skip frames
23844generated by the concat demuxer which are not exactly contained in the selected
23845interval.
23846
23847This works by comparing the frame pts against the @var{lavf.concat.start_time}
23848and the @var{lavf.concat.duration} packet metadata values which are also
23849present in the decoded frames.
23850
23851The @var{concatdec_select} variable is -1 if the frame pts is at least
23852start_time and either the duration metadata is missing or the frame pts is less
23853than start_time + duration, 0 otherwise, and NaN if the start_time metadata is
23854missing.
23855
23856That basically means that an input frame is selected if its pts is within the
23857interval set by the concat demuxer.
23858
23859@end table
23860
23861The default value of the select expression is "1".
23862
23863@subsection Examples
23864
23865@itemize
23866@item
23867Select all frames in input:
23868@example
23869select
23870@end example
23871
23872The example above is the same as:
23873@example
23874select=1
23875@end example
23876
23877@item
23878Skip all frames:
23879@example
23880select=0
23881@end example
23882
23883@item
23884Select only I-frames:
23885@example
23886select='eq(pict_type\,I)'
23887@end example
23888
23889@item
23890Select one frame every 100:
23891@example
23892select='not(mod(n\,100))'
23893@end example
23894
23895@item
23896Select only frames contained in the 10-20 time interval:
23897@example
23898select=between(t\,10\,20)
23899@end example
23900
23901@item
23902Select only I-frames contained in the 10-20 time interval:
23903@example
23904select=between(t\,10\,20)*eq(pict_type\,I)
23905@end example
23906
23907@item
23908Select frames with a minimum distance of 10 seconds:
23909@example
23910select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
23911@end example
23912
23913@item
23914Use aselect to select only audio frames with samples number > 100:
23915@example
23916aselect='gt(samples_n\,100)'
23917@end example
23918
23919@item
23920Create a mosaic of the first scenes:
23921@example
23922ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
23923@end example
23924
23925Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
23926choice.
23927
23928@item
23929Send even and odd frames to separate outputs, and compose them:
23930@example
23931select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
23932@end example
23933
23934@item
23935Select useful frames from an ffconcat file which is using inpoints and
23936outpoints but where the source files are not intra frame only.
23937@example
23938ffmpeg -copyts -vsync 0 -segment_time_metadata 1 -i input.ffconcat -vf select=concatdec_select -af aselect=concatdec_select output.avi
23939@end example
23940@end itemize
23941
23942@section sendcmd, asendcmd
23943
23944Send commands to filters in the filtergraph.
23945
23946These filters read commands to be sent to other filters in the
23947filtergraph.
23948
23949@code{sendcmd} must be inserted between two video filters,
23950@code{asendcmd} must be inserted between two audio filters, but apart
23951from that they act the same way.
23952
23953The specification of commands can be provided in the filter arguments
23954with the @var{commands} option, or in a file specified by the
23955@var{filename} option.
23956
23957These filters accept the following options:
23958@table @option
23959@item commands, c
23960Set the commands to be read and sent to the other filters.
23961@item filename, f
23962Set the filename of the commands to be read and sent to the other
23963filters.
23964@end table
23965
23966@subsection Commands syntax
23967
23968A commands description consists of a sequence of interval
23969specifications, comprising a list of commands to be executed when a
23970particular event related to that interval occurs. The occurring event
23971is typically the current frame time entering or leaving a given time
23972interval.
23973
23974An interval is specified by the following syntax:
23975@example
23976@var{START}[-@var{END}] @var{COMMANDS};
23977@end example
23978
23979The time interval is specified by the @var{START} and @var{END} times.
23980@var{END} is optional and defaults to the maximum time.
23981
23982The current frame time is considered within the specified interval if
23983it is included in the interval [@var{START}, @var{END}), that is when
23984the time is greater or equal to @var{START} and is lesser than
23985@var{END}.
23986
23987@var{COMMANDS} consists of a sequence of one or more command
23988specifications, separated by ",", relating to that interval.  The
23989syntax of a command specification is given by:
23990@example
23991[@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
23992@end example
23993
23994@var{FLAGS} is optional and specifies the type of events relating to
23995the time interval which enable sending the specified command, and must
23996be a non-null sequence of identifier flags separated by "+" or "|" and
23997enclosed between "[" and "]".
23998
23999The following flags are recognized:
24000@table @option
24001@item enter
24002The command is sent when the current frame timestamp enters the
24003specified interval. In other words, the command is sent when the
24004previous frame timestamp was not in the given interval, and the
24005current is.
24006
24007@item leave
24008The command is sent when the current frame timestamp leaves the
24009specified interval. In other words, the command is sent when the
24010previous frame timestamp was in the given interval, and the
24011current is not.
24012
24013@item expr
24014The command @var{ARG} is interpreted as expression and result of
24015expression is passed as @var{ARG}.
24016
24017The expression is evaluated through the eval API and can contain the following
24018constants:
24019
24020@table @option
24021@item POS
24022Original position in the file of the frame, or undefined if undefined
24023for the current frame.
24024
24025@item PTS
24026The presentation timestamp in input.
24027
24028@item N
24029The count of the input frame for video or audio, starting from 0.
24030
24031@item T
24032The time in seconds of the current frame.
24033
24034@item TS
24035The start time in seconds of the current command interval.
24036
24037@item TE
24038The end time in seconds of the current command interval.
24039
24040@item TI
24041The interpolated time of the current command interval, TI = (T - TS) / (TE - TS).
24042@end table
24043
24044@end table
24045
24046If @var{FLAGS} is not specified, a default value of @code{[enter]} is
24047assumed.
24048
24049@var{TARGET} specifies the target of the command, usually the name of
24050the filter class or a specific filter instance name.
24051
24052@var{COMMAND} specifies the name of the command for the target filter.
24053
24054@var{ARG} is optional and specifies the optional list of argument for
24055the given @var{COMMAND}.
24056
24057Between one interval specification and another, whitespaces, or
24058sequences of characters starting with @code{#} until the end of line,
24059are ignored and can be used to annotate comments.
24060
24061A simplified BNF description of the commands specification syntax
24062follows:
24063@example
24064@var{COMMAND_FLAG}  ::= "enter" | "leave"
24065@var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
24066@var{COMMAND}       ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
24067@var{COMMANDS}      ::= @var{COMMAND} [,@var{COMMANDS}]
24068@var{INTERVAL}      ::= @var{START}[-@var{END}] @var{COMMANDS}
24069@var{INTERVALS}     ::= @var{INTERVAL}[;@var{INTERVALS}]
24070@end example
24071
24072@subsection Examples
24073
24074@itemize
24075@item
24076Specify audio tempo change at second 4:
24077@example
24078asendcmd=c='4.0 atempo tempo 1.5',atempo
24079@end example
24080
24081@item
24082Target a specific filter instance:
24083@example
24084asendcmd=c='4.0 atempo@@my tempo 1.5',atempo@@my
24085@end example
24086
24087@item
24088Specify a list of drawtext and hue commands in a file.
24089@example
24090# show text in the interval 5-10
240915.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
24092         [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
24093
24094# desaturate the image in the interval 15-20
2409515.0-20.0 [enter] hue s 0,
24096          [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
24097          [leave] hue s 1,
24098          [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
24099
24100# apply an exponential saturation fade-out effect, starting from time 25
2410125 [enter] hue s exp(25-t)
24102@end example
24103
24104A filtergraph allowing to read and process the above command list
24105stored in a file @file{test.cmd}, can be specified with:
24106@example
24107sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
24108@end example
24109@end itemize
24110
24111@anchor{setpts}
24112@section setpts, asetpts
24113
24114Change the PTS (presentation timestamp) of the input frames.
24115
24116@code{setpts} works on video frames, @code{asetpts} on audio frames.
24117
24118This filter accepts the following options:
24119
24120@table @option
24121
24122@item expr
24123The expression which is evaluated for each frame to construct its timestamp.
24124
24125@end table
24126
24127The expression is evaluated through the eval API and can contain the following
24128constants:
24129
24130@table @option
24131@item FRAME_RATE, FR
24132frame rate, only defined for constant frame-rate video
24133
24134@item PTS
24135The presentation timestamp in input
24136
24137@item N
24138The count of the input frame for video or the number of consumed samples,
24139not including the current frame for audio, starting from 0.
24140
24141@item NB_CONSUMED_SAMPLES
24142The number of consumed samples, not including the current frame (only
24143audio)
24144
24145@item NB_SAMPLES, S
24146The number of samples in the current frame (only audio)
24147
24148@item SAMPLE_RATE, SR
24149The audio sample rate.
24150
24151@item STARTPTS
24152The PTS of the first frame.
24153
24154@item STARTT
24155the time in seconds of the first frame
24156
24157@item INTERLACED
24158State whether the current frame is interlaced.
24159
24160@item T
24161the time in seconds of the current frame
24162
24163@item POS
24164original position in the file of the frame, or undefined if undefined
24165for the current frame
24166
24167@item PREV_INPTS
24168The previous input PTS.
24169
24170@item PREV_INT
24171previous input time in seconds
24172
24173@item PREV_OUTPTS
24174The previous output PTS.
24175
24176@item PREV_OUTT
24177previous output time in seconds
24178
24179@item RTCTIME
24180The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
24181instead.
24182
24183@item RTCSTART
24184The wallclock (RTC) time at the start of the movie in microseconds.
24185
24186@item TB
24187The timebase of the input timestamps.
24188
24189@end table
24190
24191@subsection Examples
24192
24193@itemize
24194@item
24195Start counting PTS from zero
24196@example
24197setpts=PTS-STARTPTS
24198@end example
24199
24200@item
24201Apply fast motion effect:
24202@example
24203setpts=0.5*PTS
24204@end example
24205
24206@item
24207Apply slow motion effect:
24208@example
24209setpts=2.0*PTS
24210@end example
24211
24212@item
24213Set fixed rate of 25 frames per second:
24214@example
24215setpts=N/(25*TB)
24216@end example
24217
24218@item
24219Set fixed rate 25 fps with some jitter:
24220@example
24221setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
24222@end example
24223
24224@item
24225Apply an offset of 10 seconds to the input PTS:
24226@example
24227setpts=PTS+10/TB
24228@end example
24229
24230@item
24231Generate timestamps from a "live source" and rebase onto the current timebase:
24232@example
24233setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
24234@end example
24235
24236@item
24237Generate timestamps by counting samples:
24238@example
24239asetpts=N/SR/TB
24240@end example
24241
24242@end itemize
24243
24244@section setrange
24245
24246Force color range for the output video frame.
24247
24248The @code{setrange} filter marks the color range property for the
24249output frames. It does not change the input frame, but only sets the
24250corresponding property, which affects how the frame is treated by
24251following filters.
24252
24253The filter accepts the following options:
24254
24255@table @option
24256
24257@item range
24258Available values are:
24259
24260@table @samp
24261@item auto
24262Keep the same color range property.
24263
24264@item unspecified, unknown
24265Set the color range as unspecified.
24266
24267@item limited, tv, mpeg
24268Set the color range as limited.
24269
24270@item full, pc, jpeg
24271Set the color range as full.
24272@end table
24273@end table
24274
24275@section settb, asettb
24276
24277Set the timebase to use for the output frames timestamps.
24278It is mainly useful for testing timebase configuration.
24279
24280It accepts the following parameters:
24281
24282@table @option
24283
24284@item expr, tb
24285The expression which is evaluated into the output timebase.
24286
24287@end table
24288
24289The value for @option{tb} is an arithmetic expression representing a
24290rational. The expression can contain the constants "AVTB" (the default
24291timebase), "intb" (the input timebase) and "sr" (the sample rate,
24292audio only). Default value is "intb".
24293
24294@subsection Examples
24295
24296@itemize
24297@item
24298Set the timebase to 1/25:
24299@example
24300settb=expr=1/25
24301@end example
24302
24303@item
24304Set the timebase to 1/10:
24305@example
24306settb=expr=0.1
24307@end example
24308
24309@item
24310Set the timebase to 1001/1000:
24311@example
24312settb=1+0.001
24313@end example
24314
24315@item
24316Set the timebase to 2*intb:
24317@example
24318settb=2*intb
24319@end example
24320
24321@item
24322Set the default timebase value:
24323@example
24324settb=AVTB
24325@end example
24326@end itemize
24327
24328@section showcqt
24329Convert input audio to a video output representing frequency spectrum
24330logarithmically using Brown-Puckette constant Q transform algorithm with
24331direct frequency domain coefficient calculation (but the transform itself
24332is not really constant Q, instead the Q factor is actually variable/clamped),
24333with musical tone scale, from E0 to D#10.
24334
24335The filter accepts the following options:
24336
24337@table @option
24338@item size, s
24339Specify the video size for the output. It must be even. For the syntax of this option,
24340check the @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
24341Default value is @code{1920x1080}.
24342
24343@item fps, rate, r
24344Set the output frame rate. Default value is @code{25}.
24345
24346@item bar_h
24347Set the bargraph height. It must be even. Default value is @code{-1} which
24348computes the bargraph height automatically.
24349
24350@item axis_h
24351Set the axis height. It must be even. Default value is @code{-1} which computes
24352the axis height automatically.
24353
24354@item sono_h
24355Set the sonogram height. It must be even. Default value is @code{-1} which
24356computes the sonogram height automatically.
24357
24358@item fullhd
24359Set the fullhd resolution. This option is deprecated, use @var{size}, @var{s}
24360instead. Default value is @code{1}.
24361
24362@item sono_v, volume
24363Specify the sonogram volume expression. It can contain variables:
24364@table @option
24365@item bar_v
24366the @var{bar_v} evaluated expression
24367@item frequency, freq, f
24368the frequency where it is evaluated
24369@item timeclamp, tc
24370the value of @var{timeclamp} option
24371@end table
24372and functions:
24373@table @option
24374@item a_weighting(f)
24375A-weighting of equal loudness
24376@item b_weighting(f)
24377B-weighting of equal loudness
24378@item c_weighting(f)
24379C-weighting of equal loudness.
24380@end table
24381Default value is @code{16}.
24382
24383@item bar_v, volume2
24384Specify the bargraph volume expression. It can contain variables:
24385@table @option
24386@item sono_v
24387the @var{sono_v} evaluated expression
24388@item frequency, freq, f
24389the frequency where it is evaluated
24390@item timeclamp, tc
24391the value of @var{timeclamp} option
24392@end table
24393and functions:
24394@table @option
24395@item a_weighting(f)
24396A-weighting of equal loudness
24397@item b_weighting(f)
24398B-weighting of equal loudness
24399@item c_weighting(f)
24400C-weighting of equal loudness.
24401@end table
24402Default value is @code{sono_v}.
24403
24404@item sono_g, gamma
24405Specify the sonogram gamma. Lower gamma makes the spectrum more contrast,
24406higher gamma makes the spectrum having more range. Default value is @code{3}.
24407Acceptable range is @code{[1, 7]}.
24408
24409@item bar_g, gamma2
24410Specify the bargraph gamma. Default value is @code{1}. Acceptable range is
24411@code{[1, 7]}.
24412
24413@item bar_t
24414Specify the bargraph transparency level. Lower value makes the bargraph sharper.
24415Default value is @code{1}. Acceptable range is @code{[0, 1]}.
24416
24417@item timeclamp, tc
24418Specify the transform timeclamp. At low frequency, there is trade-off between
24419accuracy in time domain and frequency domain. If timeclamp is lower,
24420event in time domain is represented more accurately (such as fast bass drum),
24421otherwise event in frequency domain is represented more accurately
24422(such as bass guitar). Acceptable range is @code{[0.002, 1]}. Default value is @code{0.17}.
24423
24424@item attack
24425Set attack time in seconds. The default is @code{0} (disabled). Otherwise, it
24426limits future samples by applying asymmetric windowing in time domain, useful
24427when low latency is required. Accepted range is @code{[0, 1]}.
24428
24429@item basefreq
24430Specify the transform base frequency. Default value is @code{20.01523126408007475},
24431which is frequency 50 cents below E0. Acceptable range is @code{[10, 100000]}.
24432
24433@item endfreq
24434Specify the transform end frequency. Default value is @code{20495.59681441799654},
24435which is frequency 50 cents above D#10. Acceptable range is @code{[10, 100000]}.
24436
24437@item coeffclamp
24438This option is deprecated and ignored.
24439
24440@item tlength
24441Specify the transform length in time domain. Use this option to control accuracy
24442trade-off between time domain and frequency domain at every frequency sample.
24443It can contain variables:
24444@table @option
24445@item frequency, freq, f
24446the frequency where it is evaluated
24447@item timeclamp, tc
24448the value of @var{timeclamp} option.
24449@end table
24450Default value is @code{384*tc/(384+tc*f)}.
24451
24452@item count
24453Specify the transform count for every video frame. Default value is @code{6}.
24454Acceptable range is @code{[1, 30]}.
24455
24456@item fcount
24457Specify the transform count for every single pixel. Default value is @code{0},
24458which makes it computed automatically. Acceptable range is @code{[0, 10]}.
24459
24460@item fontfile
24461Specify font file for use with freetype to draw the axis. If not specified,
24462use embedded font. Note that drawing with font file or embedded font is not
24463implemented with custom @var{basefreq} and @var{endfreq}, use @var{axisfile}
24464option instead.
24465
24466@item font
24467Specify fontconfig pattern. This has lower priority than @var{fontfile}. The
24468@code{:} in the pattern may be replaced by @code{|} to avoid unnecessary
24469escaping.
24470
24471@item fontcolor
24472Specify font color expression. This is arithmetic expression that should return
24473integer value 0xRRGGBB. It can contain variables:
24474@table @option
24475@item frequency, freq, f
24476the frequency where it is evaluated
24477@item timeclamp, tc
24478the value of @var{timeclamp} option
24479@end table
24480and functions:
24481@table @option
24482@item midi(f)
24483midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
24484@item r(x), g(x), b(x)
24485red, green, and blue value of intensity x.
24486@end table
24487Default value is @code{st(0, (midi(f)-59.5)/12);
24488st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
24489r(1-ld(1)) + b(ld(1))}.
24490
24491@item axisfile
24492Specify image file to draw the axis. This option override @var{fontfile} and
24493@var{fontcolor} option.
24494
24495@item axis, text
24496Enable/disable drawing text to the axis. If it is set to @code{0}, drawing to
24497the axis is disabled, ignoring @var{fontfile} and @var{axisfile} option.
24498Default value is @code{1}.
24499
24500@item csp
24501Set colorspace. The accepted values are:
24502@table @samp
24503@item unspecified
24504Unspecified (default)
24505
24506@item bt709
24507BT.709
24508
24509@item fcc
24510FCC
24511
24512@item bt470bg
24513BT.470BG or BT.601-6 625
24514
24515@item smpte170m
24516SMPTE-170M or BT.601-6 525
24517
24518@item smpte240m
24519SMPTE-240M
24520
24521@item bt2020ncl
24522BT.2020 with non-constant luminance
24523
24524@end table
24525
24526@item cscheme
24527Set spectrogram color scheme. This is list of floating point values with format
24528@code{left_r|left_g|left_b|right_r|right_g|right_b}.
24529The default is @code{1|0.5|0|0|0.5|1}.
24530
24531@end table
24532
24533@subsection Examples
24534
24535@itemize
24536@item
24537Playing audio while showing the spectrum:
24538@example
24539ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
24540@end example
24541
24542@item
24543Same as above, but with frame rate 30 fps:
24544@example
24545ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
24546@end example
24547
24548@item
24549Playing at 1280x720:
24550@example
24551ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=s=1280x720:count=4 [out0]'
24552@end example
24553
24554@item
24555Disable sonogram display:
24556@example
24557sono_h=0
24558@end example
24559
24560@item
24561A1 and its harmonics: A1, A2, (near)E3, A3:
24562@example
24563ffplay -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),
24564                 asplit[a][out1]; [a] showcqt [out0]'
24565@end example
24566
24567@item
24568Same as above, but with more accuracy in frequency domain:
24569@example
24570ffplay -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),
24571                 asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
24572@end example
24573
24574@item
24575Custom volume:
24576@example
24577bar_v=10:sono_v=bar_v*a_weighting(f)
24578@end example
24579
24580@item
24581Custom gamma, now spectrum is linear to the amplitude.
24582@example
24583bar_g=2:sono_g=2
24584@end example
24585
24586@item
24587Custom tlength equation:
24588@example
24589tc=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)))'
24590@end example
24591
24592@item
24593Custom fontcolor and fontfile, C-note is colored green, others are colored blue:
24594@example
24595fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))':fontfile=myfont.ttf
24596@end example
24597
24598@item
24599Custom font using fontconfig:
24600@example
24601font='Courier New,Monospace,mono|bold'
24602@end example
24603
24604@item
24605Custom frequency range with custom axis using image file:
24606@example
24607axisfile=myaxis.png:basefreq=40:endfreq=10000
24608@end example
24609@end itemize
24610
24611@section showfreqs
24612
24613Convert input audio to video output representing the audio power spectrum.
24614Audio amplitude is on Y-axis while frequency is on X-axis.
24615
24616The filter accepts the following options:
24617
24618@table @option
24619@item size, s
24620Specify size of video. For the syntax of this option, check the
24621@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
24622Default is @code{1024x512}.
24623
24624@item mode
24625Set display mode.
24626This set how each frequency bin will be represented.
24627
24628It accepts the following values:
24629@table @samp
24630@item line
24631@item bar
24632@item dot
24633@end table
24634Default is @code{bar}.
24635
24636@item ascale
24637Set amplitude scale.
24638
24639It accepts the following values:
24640@table @samp
24641@item lin
24642Linear scale.
24643
24644@item sqrt
24645Square root scale.
24646
24647@item cbrt
24648Cubic root scale.
24649
24650@item log
24651Logarithmic scale.
24652@end table
24653Default is @code{log}.
24654
24655@item fscale
24656Set frequency scale.
24657
24658It accepts the following values:
24659@table @samp
24660@item lin
24661Linear scale.
24662
24663@item log
24664Logarithmic scale.
24665
24666@item rlog
24667Reverse logarithmic scale.
24668@end table
24669Default is @code{lin}.
24670
24671@item win_size
24672Set window size. Allowed range is from 16 to 65536.
24673
24674Default is @code{2048}
24675
24676@item win_func
24677Set windowing function.
24678
24679It accepts the following values:
24680@table @samp
24681@item rect
24682@item bartlett
24683@item hanning
24684@item hamming
24685@item blackman
24686@item welch
24687@item flattop
24688@item bharris
24689@item bnuttall
24690@item bhann
24691@item sine
24692@item nuttall
24693@item lanczos
24694@item gauss
24695@item tukey
24696@item dolph
24697@item cauchy
24698@item parzen
24699@item poisson
24700@item bohman
24701@end table
24702Default is @code{hanning}.
24703
24704@item overlap
24705Set window overlap. In range @code{[0, 1]}. Default is @code{1},
24706which means optimal overlap for selected window function will be picked.
24707
24708@item averaging
24709Set time averaging. Setting this to 0 will display current maximal peaks.
24710Default is @code{1}, which means time averaging is disabled.
24711
24712@item colors
24713Specify list of colors separated by space or by '|' which will be used to
24714draw channel frequencies. Unrecognized or missing colors will be replaced
24715by white color.
24716
24717@item cmode
24718Set channel display mode.
24719
24720It accepts the following values:
24721@table @samp
24722@item combined
24723@item separate
24724@end table
24725Default is @code{combined}.
24726
24727@item minamp
24728Set minimum amplitude used in @code{log} amplitude scaler.
24729
24730@end table
24731
24732@section showspatial
24733
24734Convert stereo input audio to a video output, representing the spatial relationship
24735between two channels.
24736
24737The filter accepts the following options:
24738
24739@table @option
24740@item size, s
24741Specify the video size for the output. For the syntax of this option, check the
24742@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
24743Default value is @code{512x512}.
24744
24745@item win_size
24746Set window size. Allowed range is from @var{1024} to @var{65536}. Default size is @var{4096}.
24747
24748@item win_func
24749Set window function.
24750
24751It accepts the following values:
24752@table @samp
24753@item rect
24754@item bartlett
24755@item hann
24756@item hanning
24757@item hamming
24758@item blackman
24759@item welch
24760@item flattop
24761@item bharris
24762@item bnuttall
24763@item bhann
24764@item sine
24765@item nuttall
24766@item lanczos
24767@item gauss
24768@item tukey
24769@item dolph
24770@item cauchy
24771@item parzen
24772@item poisson
24773@item bohman
24774@end table
24775
24776Default value is @code{hann}.
24777
24778@item overlap
24779Set ratio of overlap window. Default value is @code{0.5}.
24780When value is @code{1} overlap is set to recommended size for specific
24781window function currently used.
24782@end table
24783
24784@anchor{showspectrum}
24785@section showspectrum
24786
24787Convert input audio to a video output, representing the audio frequency
24788spectrum.
24789
24790The filter accepts the following options:
24791
24792@table @option
24793@item size, s
24794Specify the video size for the output. For the syntax of this option, check the
24795@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
24796Default value is @code{640x512}.
24797
24798@item slide
24799Specify how the spectrum should slide along the window.
24800
24801It accepts the following values:
24802@table @samp
24803@item replace
24804the samples start again on the left when they reach the right
24805@item scroll
24806the samples scroll from right to left
24807@item fullframe
24808frames are only produced when the samples reach the right
24809@item rscroll
24810the samples scroll from left to right
24811@end table
24812
24813Default value is @code{replace}.
24814
24815@item mode
24816Specify display mode.
24817
24818It accepts the following values:
24819@table @samp
24820@item combined
24821all channels are displayed in the same row
24822@item separate
24823all channels are displayed in separate rows
24824@end table
24825
24826Default value is @samp{combined}.
24827
24828@item color
24829Specify display color mode.
24830
24831It accepts the following values:
24832@table @samp
24833@item channel
24834each channel is displayed in a separate color
24835@item intensity
24836each channel is displayed using the same color scheme
24837@item rainbow
24838each channel is displayed using the rainbow color scheme
24839@item moreland
24840each channel is displayed using the moreland color scheme
24841@item nebulae
24842each channel is displayed using the nebulae color scheme
24843@item fire
24844each channel is displayed using the fire color scheme
24845@item fiery
24846each channel is displayed using the fiery color scheme
24847@item fruit
24848each channel is displayed using the fruit color scheme
24849@item cool
24850each channel is displayed using the cool color scheme
24851@item magma
24852each channel is displayed using the magma color scheme
24853@item green
24854each channel is displayed using the green color scheme
24855@item viridis
24856each channel is displayed using the viridis color scheme
24857@item plasma
24858each channel is displayed using the plasma color scheme
24859@item cividis
24860each channel is displayed using the cividis color scheme
24861@item terrain
24862each channel is displayed using the terrain color scheme
24863@end table
24864
24865Default value is @samp{channel}.
24866
24867@item scale
24868Specify scale used for calculating intensity color values.
24869
24870It accepts the following values:
24871@table @samp
24872@item lin
24873linear
24874@item sqrt
24875square root, default
24876@item cbrt
24877cubic root
24878@item log
24879logarithmic
24880@item 4thrt
248814th root
24882@item 5thrt
248835th root
24884@end table
24885
24886Default value is @samp{sqrt}.
24887
24888@item fscale
24889Specify frequency scale.
24890
24891It accepts the following values:
24892@table @samp
24893@item lin
24894linear
24895@item log
24896logarithmic
24897@end table
24898
24899Default value is @samp{lin}.
24900
24901@item saturation
24902Set saturation modifier for displayed colors. Negative values provide
24903alternative color scheme. @code{0} is no saturation at all.
24904Saturation must be in [-10.0, 10.0] range.
24905Default value is @code{1}.
24906
24907@item win_func
24908Set window function.
24909
24910It accepts the following values:
24911@table @samp
24912@item rect
24913@item bartlett
24914@item hann
24915@item hanning
24916@item hamming
24917@item blackman
24918@item welch
24919@item flattop
24920@item bharris
24921@item bnuttall
24922@item bhann
24923@item sine
24924@item nuttall
24925@item lanczos
24926@item gauss
24927@item tukey
24928@item dolph
24929@item cauchy
24930@item parzen
24931@item poisson
24932@item bohman
24933@end table
24934
24935Default value is @code{hann}.
24936
24937@item orientation
24938Set orientation of time vs frequency axis. Can be @code{vertical} or
24939@code{horizontal}. Default is @code{vertical}.
24940
24941@item overlap
24942Set ratio of overlap window. Default value is @code{0}.
24943When value is @code{1} overlap is set to recommended size for specific
24944window function currently used.
24945
24946@item gain
24947Set scale gain for calculating intensity color values.
24948Default value is @code{1}.
24949
24950@item data
24951Set which data to display. Can be @code{magnitude}, default or @code{phase}.
24952
24953@item rotation
24954Set color rotation, must be in [-1.0, 1.0] range.
24955Default value is @code{0}.
24956
24957@item start
24958Set start frequency from which to display spectrogram. Default is @code{0}.
24959
24960@item stop
24961Set stop frequency to which to display spectrogram. Default is @code{0}.
24962
24963@item fps
24964Set upper frame rate limit. Default is @code{auto}, unlimited.
24965
24966@item legend
24967Draw time and frequency axes and legends. Default is disabled.
24968@end table
24969
24970The usage is very similar to the showwaves filter; see the examples in that
24971section.
24972
24973@subsection Examples
24974
24975@itemize
24976@item
24977Large window with logarithmic color scaling:
24978@example
24979showspectrum=s=1280x480:scale=log
24980@end example
24981
24982@item
24983Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
24984@example
24985ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
24986             [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
24987@end example
24988@end itemize
24989
24990@section showspectrumpic
24991
24992Convert input audio to a single video frame, representing the audio frequency
24993spectrum.
24994
24995The filter accepts the following options:
24996
24997@table @option
24998@item size, s
24999Specify the video size for the output. For the syntax of this option, check the
25000@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
25001Default value is @code{4096x2048}.
25002
25003@item mode
25004Specify display mode.
25005
25006It accepts the following values:
25007@table @samp
25008@item combined
25009all channels are displayed in the same row
25010@item separate
25011all channels are displayed in separate rows
25012@end table
25013Default value is @samp{combined}.
25014
25015@item color
25016Specify display color mode.
25017
25018It accepts the following values:
25019@table @samp
25020@item channel
25021each channel is displayed in a separate color
25022@item intensity
25023each channel is displayed using the same color scheme
25024@item rainbow
25025each channel is displayed using the rainbow color scheme
25026@item moreland
25027each channel is displayed using the moreland color scheme
25028@item nebulae
25029each channel is displayed using the nebulae color scheme
25030@item fire
25031each channel is displayed using the fire color scheme
25032@item fiery
25033each channel is displayed using the fiery color scheme
25034@item fruit
25035each channel is displayed using the fruit color scheme
25036@item cool
25037each channel is displayed using the cool color scheme
25038@item magma
25039each channel is displayed using the magma color scheme
25040@item green
25041each channel is displayed using the green color scheme
25042@item viridis
25043each channel is displayed using the viridis color scheme
25044@item plasma
25045each channel is displayed using the plasma color scheme
25046@item cividis
25047each channel is displayed using the cividis color scheme
25048@item terrain
25049each channel is displayed using the terrain color scheme
25050@end table
25051Default value is @samp{intensity}.
25052
25053@item scale
25054Specify scale used for calculating intensity color values.
25055
25056It accepts the following values:
25057@table @samp
25058@item lin
25059linear
25060@item sqrt
25061square root, default
25062@item cbrt
25063cubic root
25064@item log
25065logarithmic
25066@item 4thrt
250674th root
25068@item 5thrt
250695th root
25070@end table
25071Default value is @samp{log}.
25072
25073@item fscale
25074Specify frequency scale.
25075
25076It accepts the following values:
25077@table @samp
25078@item lin
25079linear
25080@item log
25081logarithmic
25082@end table
25083
25084Default value is @samp{lin}.
25085
25086@item saturation
25087Set saturation modifier for displayed colors. Negative values provide
25088alternative color scheme. @code{0} is no saturation at all.
25089Saturation must be in [-10.0, 10.0] range.
25090Default value is @code{1}.
25091
25092@item win_func
25093Set window function.
25094
25095It accepts the following values:
25096@table @samp
25097@item rect
25098@item bartlett
25099@item hann
25100@item hanning
25101@item hamming
25102@item blackman
25103@item welch
25104@item flattop
25105@item bharris
25106@item bnuttall
25107@item bhann
25108@item sine
25109@item nuttall
25110@item lanczos
25111@item gauss
25112@item tukey
25113@item dolph
25114@item cauchy
25115@item parzen
25116@item poisson
25117@item bohman
25118@end table
25119Default value is @code{hann}.
25120
25121@item orientation
25122Set orientation of time vs frequency axis. Can be @code{vertical} or
25123@code{horizontal}. Default is @code{vertical}.
25124
25125@item gain
25126Set scale gain for calculating intensity color values.
25127Default value is @code{1}.
25128
25129@item legend
25130Draw time and frequency axes and legends. Default is enabled.
25131
25132@item rotation
25133Set color rotation, must be in [-1.0, 1.0] range.
25134Default value is @code{0}.
25135
25136@item start
25137Set start frequency from which to display spectrogram. Default is @code{0}.
25138
25139@item stop
25140Set stop frequency to which to display spectrogram. Default is @code{0}.
25141@end table
25142
25143@subsection Examples
25144
25145@itemize
25146@item
25147Extract an audio spectrogram of a whole audio track
25148in a 1024x1024 picture using @command{ffmpeg}:
25149@example
25150ffmpeg -i audio.flac -lavfi showspectrumpic=s=1024x1024 spectrogram.png
25151@end example
25152@end itemize
25153
25154@section showvolume
25155
25156Convert input audio volume to a video output.
25157
25158The filter accepts the following options:
25159
25160@table @option
25161@item rate, r
25162Set video rate.
25163
25164@item b
25165Set border width, allowed range is [0, 5]. Default is 1.
25166
25167@item w
25168Set channel width, allowed range is [80, 8192]. Default is 400.
25169
25170@item h
25171Set channel height, allowed range is [1, 900]. Default is 20.
25172
25173@item f
25174Set fade, allowed range is [0, 1]. Default is 0.95.
25175
25176@item c
25177Set volume color expression.
25178
25179The expression can use the following variables:
25180
25181@table @option
25182@item VOLUME
25183Current max volume of channel in dB.
25184
25185@item PEAK
25186Current peak.
25187
25188@item CHANNEL
25189Current channel number, starting from 0.
25190@end table
25191
25192@item t
25193If set, displays channel names. Default is enabled.
25194
25195@item v
25196If set, displays volume values. Default is enabled.
25197
25198@item o
25199Set orientation, can be horizontal: @code{h} or vertical: @code{v},
25200default is @code{h}.
25201
25202@item s
25203Set step size, allowed range is [0, 5]. Default is 0, which means
25204step is disabled.
25205
25206@item p
25207Set background opacity, allowed range is [0, 1]. Default is 0.
25208
25209@item m
25210Set metering mode, can be peak: @code{p} or rms: @code{r},
25211default is @code{p}.
25212
25213@item ds
25214Set display scale, can be linear: @code{lin} or log: @code{log},
25215default is @code{lin}.
25216
25217@item dm
25218In second.
25219If set to > 0., display a line for the max level
25220in the previous seconds.
25221default is disabled: @code{0.}
25222
25223@item dmc
25224The color of the max line. Use when @code{dm} option is set to > 0.
25225default is: @code{orange}
25226@end table
25227
25228@section showwaves
25229
25230Convert input audio to a video output, representing the samples waves.
25231
25232The filter accepts the following options:
25233
25234@table @option
25235@item size, s
25236Specify the video size for the output. For the syntax of this option, check the
25237@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
25238Default value is @code{600x240}.
25239
25240@item mode
25241Set display mode.
25242
25243Available values are:
25244@table @samp
25245@item point
25246Draw a point for each sample.
25247
25248@item line
25249Draw a vertical line for each sample.
25250
25251@item p2p
25252Draw a point for each sample and a line between them.
25253
25254@item cline
25255Draw a centered vertical line for each sample.
25256@end table
25257
25258Default value is @code{point}.
25259
25260@item n
25261Set the number of samples which are printed on the same column. A
25262larger value will decrease the frame rate. Must be a positive
25263integer. This option can be set only if the value for @var{rate}
25264is not explicitly specified.
25265
25266@item rate, r
25267Set the (approximate) output frame rate. This is done by setting the
25268option @var{n}. Default value is "25".
25269
25270@item split_channels
25271Set if channels should be drawn separately or overlap. Default value is 0.
25272
25273@item colors
25274Set colors separated by '|' which are going to be used for drawing of each channel.
25275
25276@item scale
25277Set amplitude scale.
25278
25279Available values are:
25280@table @samp
25281@item lin
25282Linear.
25283
25284@item log
25285Logarithmic.
25286
25287@item sqrt
25288Square root.
25289
25290@item cbrt
25291Cubic root.
25292@end table
25293
25294Default is linear.
25295
25296@item draw
25297Set the draw mode. This is mostly useful to set for high @var{n}.
25298
25299Available values are:
25300@table @samp
25301@item scale
25302Scale pixel values for each drawn sample.
25303
25304@item full
25305Draw every sample directly.
25306@end table
25307
25308Default value is @code{scale}.
25309@end table
25310
25311@subsection Examples
25312
25313@itemize
25314@item
25315Output the input file audio and the corresponding video representation
25316at the same time:
25317@example
25318amovie=a.mp3,asplit[out0],showwaves[out1]
25319@end example
25320
25321@item
25322Create a synthetic signal and show it with showwaves, forcing a
25323frame rate of 30 frames per second:
25324@example
25325aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
25326@end example
25327@end itemize
25328
25329@section showwavespic
25330
25331Convert input audio to a single video frame, representing the samples waves.
25332
25333The filter accepts the following options:
25334
25335@table @option
25336@item size, s
25337Specify the video size for the output. For the syntax of this option, check the
25338@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
25339Default value is @code{600x240}.
25340
25341@item split_channels
25342Set if channels should be drawn separately or overlap. Default value is 0.
25343
25344@item colors
25345Set colors separated by '|' which are going to be used for drawing of each channel.
25346
25347@item scale
25348Set amplitude scale.
25349
25350Available values are:
25351@table @samp
25352@item lin
25353Linear.
25354
25355@item log
25356Logarithmic.
25357
25358@item sqrt
25359Square root.
25360
25361@item cbrt
25362Cubic root.
25363@end table
25364
25365Default is linear.
25366
25367@item draw
25368Set the draw mode.
25369
25370Available values are:
25371@table @samp
25372@item scale
25373Scale pixel values for each drawn sample.
25374
25375@item full
25376Draw every sample directly.
25377@end table
25378
25379Default value is @code{scale}.
25380@end table
25381
25382@subsection Examples
25383
25384@itemize
25385@item
25386Extract a channel split representation of the wave form of a whole audio track
25387in a 1024x800 picture using @command{ffmpeg}:
25388@example
25389ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
25390@end example
25391@end itemize
25392
25393@section sidedata, asidedata
25394
25395Delete frame side data, or select frames based on it.
25396
25397This filter accepts the following options:
25398
25399@table @option
25400@item mode
25401Set mode of operation of the filter.
25402
25403Can be one of the following:
25404
25405@table @samp
25406@item select
25407Select every frame with side data of @code{type}.
25408
25409@item delete
25410Delete side data of @code{type}. If @code{type} is not set, delete all side
25411data in the frame.
25412
25413@end table
25414
25415@item type
25416Set side data type used with all modes. Must be set for @code{select} mode. For
25417the list of frame side data types, refer to the @code{AVFrameSideDataType} enum
25418in @file{libavutil/frame.h}. For example, to choose
25419@code{AV_FRAME_DATA_PANSCAN} side data, you must specify @code{PANSCAN}.
25420
25421@end table
25422
25423@section spectrumsynth
25424
25425Synthesize audio from 2 input video spectrums, first input stream represents
25426magnitude across time and second represents phase across time.
25427The filter will transform from frequency domain as displayed in videos back
25428to time domain as presented in audio output.
25429
25430This filter is primarily created for reversing processed @ref{showspectrum}
25431filter outputs, but can synthesize sound from other spectrograms too.
25432But in such case results are going to be poor if the phase data is not
25433available, because in such cases phase data need to be recreated, usually
25434it's just recreated from random noise.
25435For best results use gray only output (@code{channel} color mode in
25436@ref{showspectrum} filter) and @code{log} scale for magnitude video and
25437@code{lin} scale for phase video. To produce phase, for 2nd video, use
25438@code{data} option. Inputs videos should generally use @code{fullframe}
25439slide mode as that saves resources needed for decoding video.
25440
25441The filter accepts the following options:
25442
25443@table @option
25444@item sample_rate
25445Specify sample rate of output audio, the sample rate of audio from which
25446spectrum was generated may differ.
25447
25448@item channels
25449Set number of channels represented in input video spectrums.
25450
25451@item scale
25452Set scale which was used when generating magnitude input spectrum.
25453Can be @code{lin} or @code{log}. Default is @code{log}.
25454
25455@item slide
25456Set slide which was used when generating inputs spectrums.
25457Can be @code{replace}, @code{scroll}, @code{fullframe} or @code{rscroll}.
25458Default is @code{fullframe}.
25459
25460@item win_func
25461Set window function used for resynthesis.
25462
25463@item overlap
25464Set window overlap. In range @code{[0, 1]}. Default is @code{1},
25465which means optimal overlap for selected window function will be picked.
25466
25467@item orientation
25468Set orientation of input videos. Can be @code{vertical} or @code{horizontal}.
25469Default is @code{vertical}.
25470@end table
25471
25472@subsection Examples
25473
25474@itemize
25475@item
25476First create magnitude and phase videos from audio, assuming audio is stereo with 44100 sample rate,
25477then resynthesize videos back to audio with spectrumsynth:
25478@example
25479ffmpeg -i input.flac -lavfi showspectrum=mode=separate:scale=log:overlap=0.875:color=channel:slide=fullframe:data=magnitude -an -c:v rawvideo magnitude.nut
25480ffmpeg -i input.flac -lavfi showspectrum=mode=separate:scale=lin:overlap=0.875:color=channel:slide=fullframe:data=phase -an -c:v rawvideo phase.nut
25481ffmpeg -i magnitude.nut -i phase.nut -lavfi spectrumsynth=channels=2:sample_rate=44100:win_func=hann:overlap=0.875:slide=fullframe output.flac
25482@end example
25483@end itemize
25484
25485@section split, asplit
25486
25487Split input into several identical outputs.
25488
25489@code{asplit} works with audio input, @code{split} with video.
25490
25491The filter accepts a single parameter which specifies the number of outputs. If
25492unspecified, it defaults to 2.
25493
25494@subsection Examples
25495
25496@itemize
25497@item
25498Create two separate outputs from the same input:
25499@example
25500[in] split [out0][out1]
25501@end example
25502
25503@item
25504To create 3 or more outputs, you need to specify the number of
25505outputs, like in:
25506@example
25507[in] asplit=3 [out0][out1][out2]
25508@end example
25509
25510@item
25511Create two separate outputs from the same input, one cropped and
25512one padded:
25513@example
25514[in] split [splitout1][splitout2];
25515[splitout1] crop=100:100:0:0    [cropout];
25516[splitout2] pad=200:200:100:100 [padout];
25517@end example
25518
25519@item
25520Create 5 copies of the input audio with @command{ffmpeg}:
25521@example
25522ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
25523@end example
25524@end itemize
25525
25526@section zmq, azmq
25527
25528Receive commands sent through a libzmq client, and forward them to
25529filters in the filtergraph.
25530
25531@code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
25532must be inserted between two video filters, @code{azmq} between two
25533audio filters. Both are capable to send messages to any filter type.
25534
25535To enable these filters you need to install the libzmq library and
25536headers and configure FFmpeg with @code{--enable-libzmq}.
25537
25538For more information about libzmq see:
25539@url{http://www.zeromq.org/}
25540
25541The @code{zmq} and @code{azmq} filters work as a libzmq server, which
25542receives messages sent through a network interface defined by the
25543@option{bind_address} (or the abbreviation "@option{b}") option.
25544Default value of this option is @file{tcp://localhost:5555}. You may
25545want to alter this value to your needs, but do not forget to escape any
25546':' signs (see @ref{filtergraph escaping}).
25547
25548The received message must be in the form:
25549@example
25550@var{TARGET} @var{COMMAND} [@var{ARG}]
25551@end example
25552
25553@var{TARGET} specifies the target of the command, usually the name of
25554the filter class or a specific filter instance name. The default
25555filter instance name uses the pattern @samp{Parsed_<filter_name>_<index>},
25556but you can override this by using the @samp{filter_name@@id} syntax
25557(see @ref{Filtergraph syntax}).
25558
25559@var{COMMAND} specifies the name of the command for the target filter.
25560
25561@var{ARG} is optional and specifies the optional argument list for the
25562given @var{COMMAND}.
25563
25564Upon reception, the message is processed and the corresponding command
25565is injected into the filtergraph. Depending on the result, the filter
25566will send a reply to the client, adopting the format:
25567@example
25568@var{ERROR_CODE} @var{ERROR_REASON}
25569@var{MESSAGE}
25570@end example
25571
25572@var{MESSAGE} is optional.
25573
25574@subsection Examples
25575
25576Look at @file{tools/zmqsend} for an example of a zmq client which can
25577be used to send commands processed by these filters.
25578
25579Consider the following filtergraph generated by @command{ffplay}.
25580In this example the last overlay filter has an instance name. All other
25581filters will have default instance names.
25582
25583@example
25584ffplay -dumpgraph 1 -f lavfi "
25585color=s=100x100:c=red  [l];
25586color=s=100x100:c=blue [r];
25587nullsrc=s=200x100, zmq [bg];
25588[bg][l]   overlay     [bg+l];
25589[bg+l][r] overlay@@my=x=100 "
25590@end example
25591
25592To change the color of the left side of the video, the following
25593command can be used:
25594@example
25595echo Parsed_color_0 c yellow | tools/zmqsend
25596@end example
25597
25598To change the right side:
25599@example
25600echo Parsed_color_1 c pink | tools/zmqsend
25601@end example
25602
25603To change the position of the right side:
25604@example
25605echo overlay@@my x 150 | tools/zmqsend
25606@end example
25607
25608
25609@c man end MULTIMEDIA FILTERS
25610
25611@chapter Multimedia Sources
25612@c man begin MULTIMEDIA SOURCES
25613
25614Below is a description of the currently available multimedia sources.
25615
25616@section amovie
25617
25618This is the same as @ref{movie} source, except it selects an audio
25619stream by default.
25620
25621@anchor{movie}
25622@section movie
25623
25624Read audio and/or video stream(s) from a movie container.
25625
25626It accepts the following parameters:
25627
25628@table @option
25629@item filename
25630The name of the resource to read (not necessarily a file; it can also be a
25631device or a stream accessed through some protocol).
25632
25633@item format_name, f
25634Specifies the format assumed for the movie to read, and can be either
25635the name of a container or an input device. If not specified, the
25636format is guessed from @var{movie_name} or by probing.
25637
25638@item seek_point, sp
25639Specifies the seek point in seconds. The frames will be output
25640starting from this seek point. The parameter is evaluated with
25641@code{av_strtod}, so the numerical value may be suffixed by an IS
25642postfix. The default value is "0".
25643
25644@item streams, s
25645Specifies the streams to read. Several streams can be specified,
25646separated by "+". The source will then have as many outputs, in the
25647same order. The syntax is explained in the @ref{Stream specifiers,,"Stream specifiers"
25648section in the ffmpeg manual,ffmpeg}. Two special names, "dv" and "da" specify
25649respectively the default (best suited) video and audio stream. Default
25650is "dv", or "da" if the filter is called as "amovie".
25651
25652@item stream_index, si
25653Specifies the index of the video stream to read. If the value is -1,
25654the most suitable video stream will be automatically selected. The default
25655value is "-1". Deprecated. If the filter is called "amovie", it will select
25656audio instead of video.
25657
25658@item loop
25659Specifies how many times to read the stream in sequence.
25660If the value is 0, the stream will be looped infinitely.
25661Default value is "1".
25662
25663Note that when the movie is looped the source timestamps are not
25664changed, so it will generate non monotonically increasing timestamps.
25665
25666@item discontinuity
25667Specifies the time difference between frames above which the point is
25668considered a timestamp discontinuity which is removed by adjusting the later
25669timestamps.
25670@end table
25671
25672It allows overlaying a second video on top of the main input of
25673a filtergraph, as shown in this graph:
25674@example
25675input -----------> deltapts0 --> overlay --> output
25676                                    ^
25677                                    |
25678movie --> scale--> deltapts1 -------+
25679@end example
25680@subsection Examples
25681
25682@itemize
25683@item
25684Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
25685on top of the input labelled "in":
25686@example
25687movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
25688[in] setpts=PTS-STARTPTS [main];
25689[main][over] overlay=16:16 [out]
25690@end example
25691
25692@item
25693Read from a video4linux2 device, and overlay it on top of the input
25694labelled "in":
25695@example
25696movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
25697[in] setpts=PTS-STARTPTS [main];
25698[main][over] overlay=16:16 [out]
25699@end example
25700
25701@item
25702Read the first video stream and the audio stream with id 0x81 from
25703dvd.vob; the video is connected to the pad named "video" and the audio is
25704connected to the pad named "audio":
25705@example
25706movie=dvd.vob:s=v:0+#0x81 [video] [audio]
25707@end example
25708@end itemize
25709
25710@subsection Commands
25711
25712Both movie and amovie support the following commands:
25713@table @option
25714@item seek
25715Perform seek using "av_seek_frame".
25716The syntax is: seek @var{stream_index}|@var{timestamp}|@var{flags}
25717@itemize
25718@item
25719@var{stream_index}: If stream_index is -1, a default
25720stream is selected, and @var{timestamp} is automatically converted
25721from AV_TIME_BASE units to the stream specific time_base.
25722@item
25723@var{timestamp}: Timestamp in AVStream.time_base units
25724or, if no stream is specified, in AV_TIME_BASE units.
25725@item
25726@var{flags}: Flags which select direction and seeking mode.
25727@end itemize
25728
25729@item get_duration
25730Get movie duration in AV_TIME_BASE units.
25731
25732@end table
25733
25734@c man end MULTIMEDIA SOURCES
25735