• 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 for each band split. This controls filter roll-off or steepness
527of filter transfer function.
528Available values are:
529
530@table @samp
531@item 2nd
53212 dB per octave.
533@item 4th
53424 dB per octave.
535@item 6th
53636 dB per octave.
537@item 8th
53848 dB per octave.
539@item 10th
54060 dB per octave.
541@item 12th
54272 dB per octave.
543@item 14th
54484 dB per octave.
545@item 16th
54696 dB per octave.
547@item 18th
548108 dB per octave.
549@item 20th
550120 dB per octave.
551@end table
552
553Default is @var{4th}.
554
555@item level
556Set input gain level. Allowed range is from 0 to 1. Default value is 1.
557
558@item gains
559Set output gain for each band. Default value is 1 for all bands.
560
561@item precision
562Set which precision to use when processing samples.
563
564@table @option
565@item auto
566Auto pick internal sample format depending on other filters.
567
568@item float
569Always use single-floating point precision sample format.
570
571@item double
572Always use double-floating point precision sample format.
573@end table
574
575Default value is @code{auto}.
576@end table
577
578@subsection Examples
579
580@itemize
581@item
582Split input audio stream into two bands (low and high) with split frequency of 1500 Hz,
583each band will be in separate stream:
584@example
585ffmpeg -i in.flac -filter_complex 'acrossover=split=1500[LOW][HIGH]' -map '[LOW]' low.wav -map '[HIGH]' high.wav
586@end example
587
588@item
589Same as above, but with higher filter order:
590@example
591ffmpeg -i in.flac -filter_complex 'acrossover=split=1500:order=8th[LOW][HIGH]' -map '[LOW]' low.wav -map '[HIGH]' high.wav
592@end example
593
594@item
595Same as above, but also with additional middle band (frequencies between 1500 and 8000):
596@example
597ffmpeg -i in.flac -filter_complex 'acrossover=split=1500 8000:order=8th[LOW][MID][HIGH]' -map '[LOW]' low.wav -map '[MID]' mid.wav -map '[HIGH]' high.wav
598@end example
599@end itemize
600
601@section acrusher
602
603Reduce audio bit resolution.
604
605This filter is bit crusher with enhanced functionality. A bit crusher
606is used to audibly reduce number of bits an audio signal is sampled
607with. This doesn't change the bit depth at all, it just produces the
608effect. Material reduced in bit depth sounds more harsh and "digital".
609This filter is able to even round to continuous values instead of discrete
610bit depths.
611Additionally it has a D/C offset which results in different crushing of
612the lower and the upper half of the signal.
613An Anti-Aliasing setting is able to produce "softer" crushing sounds.
614
615Another feature of this filter is the logarithmic mode.
616This setting switches from linear distances between bits to logarithmic ones.
617The result is a much more "natural" sounding crusher which doesn't gate low
618signals for example. The human ear has a logarithmic perception,
619so this kind of crushing is much more pleasant.
620Logarithmic crushing is also able to get anti-aliased.
621
622The filter accepts the following options:
623
624@table @option
625@item level_in
626Set level in.
627
628@item level_out
629Set level out.
630
631@item bits
632Set bit reduction.
633
634@item mix
635Set mixing amount.
636
637@item mode
638Can be linear: @code{lin} or logarithmic: @code{log}.
639
640@item dc
641Set DC.
642
643@item aa
644Set anti-aliasing.
645
646@item samples
647Set sample reduction.
648
649@item lfo
650Enable LFO. By default disabled.
651
652@item lforange
653Set LFO range.
654
655@item lforate
656Set LFO rate.
657@end table
658
659@subsection Commands
660
661This filter supports the all above options as @ref{commands}.
662
663@section acue
664
665Delay audio filtering until a given wallclock timestamp. See the @ref{cue}
666filter.
667
668@section adeclick
669Remove impulsive noise from input audio.
670
671Samples detected as impulsive noise are replaced by interpolated samples using
672autoregressive modelling.
673
674@table @option
675@item window, w
676Set window size, in milliseconds. Allowed range is from @code{10} to
677@code{100}. Default value is @code{55} milliseconds.
678This sets size of window which will be processed at once.
679
680@item overlap, o
681Set window overlap, in percentage of window size. Allowed range is from
682@code{50} to @code{95}. Default value is @code{75} percent.
683Setting this to a very high value increases impulsive noise removal but makes
684whole process much slower.
685
686@item arorder, a
687Set autoregression order, in percentage of window size. Allowed range is from
688@code{0} to @code{25}. Default value is @code{2} percent. This option also
689controls quality of interpolated samples using neighbour good samples.
690
691@item threshold, t
692Set threshold value. Allowed range is from @code{1} to @code{100}.
693Default value is @code{2}.
694This controls the strength of impulsive noise which is going to be removed.
695The lower value, the more samples will be detected as impulsive noise.
696
697@item burst, b
698Set burst fusion, in percentage of window size. Allowed range is @code{0} to
699@code{10}. Default value is @code{2}.
700If any two samples detected as noise are spaced less than this value then any
701sample between those two samples will be also detected as noise.
702
703@item method, m
704Set overlap method.
705
706It accepts the following values:
707@table @option
708@item add, a
709Select overlap-add method. Even not interpolated samples are slightly
710changed with this method.
711
712@item save, s
713Select overlap-save method. Not interpolated samples remain unchanged.
714@end table
715
716Default value is @code{a}.
717@end table
718
719@section adeclip
720Remove clipped samples from input audio.
721
722Samples detected as clipped are replaced by interpolated samples using
723autoregressive modelling.
724
725@table @option
726@item window, w
727Set window size, in milliseconds. Allowed range is from @code{10} to @code{100}.
728Default value is @code{55} milliseconds.
729This sets size of window which will be processed at once.
730
731@item overlap, o
732Set window overlap, in percentage of window size. Allowed range is from @code{50}
733to @code{95}. Default value is @code{75} percent.
734
735@item arorder, a
736Set autoregression order, in percentage of window size. Allowed range is from
737@code{0} to @code{25}. Default value is @code{8} percent. This option also controls
738quality of interpolated samples using neighbour good samples.
739
740@item threshold, t
741Set threshold value. Allowed range is from @code{1} to @code{100}.
742Default value is @code{10}. Higher values make clip detection less aggressive.
743
744@item hsize, n
745Set size of histogram used to detect clips. Allowed range is from @code{100} to @code{9999}.
746Default value is @code{1000}. Higher values make clip detection less aggressive.
747
748@item method, m
749Set overlap method.
750
751It accepts the following values:
752@table @option
753@item add, a
754Select overlap-add method. Even not interpolated samples are slightly changed
755with this method.
756
757@item save, s
758Select overlap-save method. Not interpolated samples remain unchanged.
759@end table
760
761Default value is @code{a}.
762@end table
763
764@section adecorrelate
765Apply decorrelation to input audio stream.
766
767The filter accepts the following options:
768
769@table @option
770@item stages
771Set decorrelation stages of filtering. Allowed
772range is from 1 to 16. Default value is 6.
773
774@item seed
775Set random seed used for setting delay in samples across channels.
776@end table
777
778@section adelay
779
780Delay one or more audio channels.
781
782Samples in delayed channel are filled with silence.
783
784The filter accepts the following option:
785
786@table @option
787@item delays
788Set list of delays in milliseconds for each channel separated by '|'.
789Unused delays will be silently ignored. If number of given delays is
790smaller than number of channels all remaining channels will not be delayed.
791If you want to delay exact number of samples, append 'S' to number.
792If you want instead to delay in seconds, append 's' to number.
793
794@item all
795Use last set delay for all remaining channels. By default is disabled.
796This option if enabled changes how option @code{delays} is interpreted.
797@end table
798
799@subsection Examples
800
801@itemize
802@item
803Delay first channel by 1.5 seconds, the third channel by 0.5 seconds and leave
804the second channel (and any other channels that may be present) unchanged.
805@example
806adelay=1500|0|500
807@end example
808
809@item
810Delay second channel by 500 samples, the third channel by 700 samples and leave
811the first channel (and any other channels that may be present) unchanged.
812@example
813adelay=0|500S|700S
814@end example
815
816@item
817Delay all channels by same number of samples:
818@example
819adelay=delays=64S:all=1
820@end example
821@end itemize
822
823@section adenorm
824Remedy denormals in audio by adding extremely low-level noise.
825
826This filter shall be placed before any filter that can produce denormals.
827
828A description of the accepted parameters follows.
829
830@table @option
831@item level
832Set level of added noise in dB. Default is @code{-351}.
833Allowed range is from -451 to -90.
834
835@item type
836Set type of added noise.
837
838@table @option
839@item dc
840Add DC signal.
841@item ac
842Add AC signal.
843@item square
844Add square signal.
845@item pulse
846Add pulse signal.
847@end table
848
849Default is @code{dc}.
850@end table
851
852@subsection Commands
853
854This filter supports the all above options as @ref{commands}.
855
856@section aderivative, aintegral
857
858Compute derivative/integral of audio stream.
859
860Applying both filters one after another produces original audio.
861
862@section adynamicequalizer
863
864Apply dynamic equalization to input audio stream.
865
866A description of the accepted options follows.
867
868@table @option
869@item threshold
870Set the detection threshold used to trigger equalization.
871Threshold detection is using bandpass filter.
872Default value is 0. Allowed range is from 0 to 100.
873
874@item dfrequency
875Set the detection frequency in Hz used for bandpass filter used to trigger equalization.
876Default value is 1000 Hz. Allowed range is between 2 and 1000000 Hz.
877
878@item dqfactor
879Set the detection resonance factor for bandpass filter used to trigger equalization.
880Default value is 1. Allowed range is from 0.001 to 1000.
881
882@item tfrequency
883Set the target frequency of equalization filter.
884Default value is 1000 Hz. Allowed range is between 2 and 1000000 Hz.
885
886@item tqfactor
887Set the target resonance factor for target equalization filter.
888Default value is 1. Allowed range is from 0.001 to 1000.
889
890@item attack
891Set the amount of milliseconds the signal from detection has to rise above
892the detection threshold before equalization starts.
893Default is 20. Allowed range is between 1 and 2000.
894
895@item release
896Set the amount of milliseconds the signal from detection has to fall below the
897detection threshold before equalization ends.
898Default is 200. Allowed range is between 1 and 2000.
899
900@item knee
901Curve the sharp knee around the detection threshold to calculate
902equalization gain more softly.
903Default is 1. Allowed range is between 0 and 8.
904
905@item ratio
906Set the ratio by which the equalization gain is raised.
907Default is 1. Allowed range is between 1 and 20.
908
909@item makeup
910Set the makeup offset in dB by which the equalization gain is raised.
911Default is 0. Allowed range is between 0 and 30.
912
913@item range
914Set the max allowed cut/boost amount in dB. Default is 0.
915Allowed range is from 0 to 200.
916
917@item slew
918Set the slew factor. Default is 1. Allowed range is from 1 to 200.
919
920@item mode
921Set the mode of filter operation, can be one of the following:
922
923@table @samp
924@item listen
925Output only isolated bandpass signal.
926@item cut
927Cut frequencies above detection threshold.
928@item boost
929Boost frequencies bellow detection threshold.
930@end table
931Default mode is @samp{cut}.
932
933@item tftype
934Set the type of target filter, can be one of the following:
935
936@table @samp
937@item bell
938@item lowshelf
939@item highshelf
940@end table
941Default type is @samp{bell}.
942@end table
943
944@subsection Commands
945
946This filter supports the all above options as @ref{commands}.
947
948@section adynamicsmooth
949
950Apply dynamic smoothing to input audio stream.
951
952A description of the accepted options follows.
953
954@table @option
955@item sensitivity
956Set an amount of sensitivity to frequency fluctations. Default is 2.
957Allowed range is from 0 to 1e+06.
958
959@item basefreq
960Set a base frequency for smoothing. Default value is 22050.
961Allowed range is from 2 to 1e+06.
962@end table
963
964@subsection Commands
965
966This filter supports the all above options as @ref{commands}.
967
968@section aecho
969
970Apply echoing to the input audio.
971
972Echoes are reflected sound and can occur naturally amongst mountains
973(and sometimes large buildings) when talking or shouting; digital echo
974effects emulate this behaviour and are often used to help fill out the
975sound of a single instrument or vocal. The time difference between the
976original signal and the reflection is the @code{delay}, and the
977loudness of the reflected signal is the @code{decay}.
978Multiple echoes can have different delays and decays.
979
980A description of the accepted parameters follows.
981
982@table @option
983@item in_gain
984Set input gain of reflected signal. Default is @code{0.6}.
985
986@item out_gain
987Set output gain of reflected signal. Default is @code{0.3}.
988
989@item delays
990Set list of time intervals in milliseconds between original signal and reflections
991separated by '|'. Allowed range for each @code{delay} is @code{(0 - 90000.0]}.
992Default is @code{1000}.
993
994@item decays
995Set list of loudness of reflected signals separated by '|'.
996Allowed range for each @code{decay} is @code{(0 - 1.0]}.
997Default is @code{0.5}.
998@end table
999
1000@subsection Examples
1001
1002@itemize
1003@item
1004Make it sound as if there are twice as many instruments as are actually playing:
1005@example
1006aecho=0.8:0.88:60:0.4
1007@end example
1008
1009@item
1010If delay is very short, then it sounds like a (metallic) robot playing music:
1011@example
1012aecho=0.8:0.88:6:0.4
1013@end example
1014
1015@item
1016A longer delay will sound like an open air concert in the mountains:
1017@example
1018aecho=0.8:0.9:1000:0.3
1019@end example
1020
1021@item
1022Same as above but with one more mountain:
1023@example
1024aecho=0.8:0.9:1000|1800:0.3|0.25
1025@end example
1026@end itemize
1027
1028@section aemphasis
1029Audio emphasis filter creates or restores material directly taken from LPs or
1030emphased CDs with different filter curves. E.g. to store music on vinyl the
1031signal has to be altered by a filter first to even out the disadvantages of
1032this recording medium.
1033Once the material is played back the inverse filter has to be applied to
1034restore the distortion of the frequency response.
1035
1036The filter accepts the following options:
1037
1038@table @option
1039@item level_in
1040Set input gain.
1041
1042@item level_out
1043Set output gain.
1044
1045@item mode
1046Set filter mode. For restoring material use @code{reproduction} mode, otherwise
1047use @code{production} mode. Default is @code{reproduction} mode.
1048
1049@item type
1050Set filter type. Selects medium. Can be one of the following:
1051
1052@table @option
1053@item col
1054select Columbia.
1055@item emi
1056select EMI.
1057@item bsi
1058select BSI (78RPM).
1059@item riaa
1060select RIAA.
1061@item cd
1062select Compact Disc (CD).
1063@item 50fm
1064select 50µs (FM).
1065@item 75fm
1066select 75µs (FM).
1067@item 50kf
1068select 50µs (FM-KF).
1069@item 75kf
1070select 75µs (FM-KF).
1071@end table
1072@end table
1073
1074@subsection Commands
1075
1076This filter supports the all above options as @ref{commands}.
1077
1078@section aeval
1079
1080Modify an audio signal according to the specified expressions.
1081
1082This filter accepts one or more expressions (one for each channel),
1083which are evaluated and used to modify a corresponding audio signal.
1084
1085It accepts the following parameters:
1086
1087@table @option
1088@item exprs
1089Set the '|'-separated expressions list for each separate channel. If
1090the number of input channels is greater than the number of
1091expressions, the last specified expression is used for the remaining
1092output channels.
1093
1094@item channel_layout, c
1095Set output channel layout. If not specified, the channel layout is
1096specified by the number of expressions. If set to @samp{same}, it will
1097use by default the same input channel layout.
1098@end table
1099
1100Each expression in @var{exprs} can contain the following constants and functions:
1101
1102@table @option
1103@item ch
1104channel number of the current expression
1105
1106@item n
1107number of the evaluated sample, starting from 0
1108
1109@item s
1110sample rate
1111
1112@item t
1113time of the evaluated sample expressed in seconds
1114
1115@item nb_in_channels
1116@item nb_out_channels
1117input and output number of channels
1118
1119@item val(CH)
1120the value of input channel with number @var{CH}
1121@end table
1122
1123Note: this filter is slow. For faster processing you should use a
1124dedicated filter.
1125
1126@subsection Examples
1127
1128@itemize
1129@item
1130Half volume:
1131@example
1132aeval=val(ch)/2:c=same
1133@end example
1134
1135@item
1136Invert phase of the second channel:
1137@example
1138aeval=val(0)|-val(1)
1139@end example
1140@end itemize
1141
1142@section aexciter
1143
1144An exciter is used to produce high sound that is not present in the
1145original signal. This is done by creating harmonic distortions of the
1146signal which are restricted in range and added to the original signal.
1147An Exciter raises the upper end of an audio signal without simply raising
1148the higher frequencies like an equalizer would do to create a more
1149"crisp" or "brilliant" sound.
1150
1151The filter accepts the following options:
1152
1153@table @option
1154@item level_in
1155Set input level prior processing of signal.
1156Allowed range is from 0 to 64.
1157Default value is 1.
1158
1159@item level_out
1160Set output level after processing of signal.
1161Allowed range is from 0 to 64.
1162Default value is 1.
1163
1164@item amount
1165Set the amount of harmonics added to original signal.
1166Allowed range is from 0 to 64.
1167Default value is 1.
1168
1169@item drive
1170Set the amount of newly created harmonics.
1171Allowed range is from 0.1 to 10.
1172Default value is 8.5.
1173
1174@item blend
1175Set the octave of newly created harmonics.
1176Allowed range is from -10 to 10.
1177Default value is 0.
1178
1179@item freq
1180Set the lower frequency limit of producing harmonics in Hz.
1181Allowed range is from 2000 to 12000 Hz.
1182Default is 7500 Hz.
1183
1184@item ceil
1185Set the upper frequency limit of producing harmonics.
1186Allowed range is from 9999 to 20000 Hz.
1187If value is lower than 10000 Hz no limit is applied.
1188
1189@item listen
1190Mute the original signal and output only added harmonics.
1191By default is disabled.
1192@end table
1193
1194@subsection Commands
1195
1196This filter supports the all above options as @ref{commands}.
1197
1198@anchor{afade}
1199@section afade
1200
1201Apply fade-in/out effect to input audio.
1202
1203A description of the accepted parameters follows.
1204
1205@table @option
1206@item type, t
1207Specify the effect type, can be either @code{in} for fade-in, or
1208@code{out} for a fade-out effect. Default is @code{in}.
1209
1210@item start_sample, ss
1211Specify the number of the start sample for starting to apply the fade
1212effect. Default is 0.
1213
1214@item nb_samples, ns
1215Specify the number of samples for which the fade effect has to last. At
1216the end of the fade-in effect the output audio will have the same
1217volume as the input audio, at the end of the fade-out transition
1218the output audio will be silence. Default is 44100.
1219
1220@item start_time, st
1221Specify the start time of the fade effect. Default is 0.
1222The value must be specified as a time duration; see
1223@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
1224for the accepted syntax.
1225If set this option is used instead of @var{start_sample}.
1226
1227@item duration, d
1228Specify the duration of the fade effect. See
1229@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
1230for the accepted syntax.
1231At the end of the fade-in effect the output audio will have the same
1232volume as the input audio, at the end of the fade-out transition
1233the output audio will be silence.
1234By default the duration is determined by @var{nb_samples}.
1235If set this option is used instead of @var{nb_samples}.
1236
1237@item curve
1238Set curve for fade transition.
1239
1240It accepts the following values:
1241@table @option
1242@item tri
1243select triangular, linear slope (default)
1244@item qsin
1245select quarter of sine wave
1246@item hsin
1247select half of sine wave
1248@item esin
1249select exponential sine wave
1250@item log
1251select logarithmic
1252@item ipar
1253select inverted parabola
1254@item qua
1255select quadratic
1256@item cub
1257select cubic
1258@item squ
1259select square root
1260@item cbr
1261select cubic root
1262@item par
1263select parabola
1264@item exp
1265select exponential
1266@item iqsin
1267select inverted quarter of sine wave
1268@item ihsin
1269select inverted half of sine wave
1270@item dese
1271select double-exponential seat
1272@item desi
1273select double-exponential sigmoid
1274@item losi
1275select logistic sigmoid
1276@item sinc
1277select sine cardinal function
1278@item isinc
1279select inverted sine cardinal function
1280@item nofade
1281no fade applied
1282@end table
1283@end table
1284
1285@subsection Commands
1286
1287This filter supports the all above options as @ref{commands}.
1288
1289@subsection Examples
1290
1291@itemize
1292@item
1293Fade in first 15 seconds of audio:
1294@example
1295afade=t=in:ss=0:d=15
1296@end example
1297
1298@item
1299Fade out last 25 seconds of a 900 seconds audio:
1300@example
1301afade=t=out:st=875:d=25
1302@end example
1303@end itemize
1304
1305@section afftdn
1306Denoise audio samples with FFT.
1307
1308A description of the accepted parameters follows.
1309
1310@table @option
1311@item noise_reduction, nr
1312Set the noise reduction in dB, allowed range is 0.01 to 97.
1313Default value is 12 dB.
1314
1315@item noise_floor, nf
1316Set the noise floor in dB, allowed range is -80 to -20.
1317Default value is -50 dB.
1318
1319@item noise_type, nt
1320Set the noise type.
1321
1322It accepts the following values:
1323@table @option
1324@item white, w
1325Select white noise.
1326
1327@item vinyl, v
1328Select vinyl noise.
1329
1330@item shellac, s
1331Select shellac noise.
1332
1333@item custom, c
1334Select custom noise, defined in @code{bn} option.
1335
1336Default value is white noise.
1337@end table
1338
1339@item band_noise, bn
1340Set custom band noise profile for every one of 15 bands.
1341Bands are separated by ' ' or '|'.
1342
1343@item residual_floor, rf
1344Set the residual floor in dB, allowed range is -80 to -20.
1345Default value is -38 dB.
1346
1347@item track_noise, tn
1348Enable noise floor tracking. By default is disabled.
1349With this enabled, noise floor is automatically adjusted.
1350
1351@item track_residual, tr
1352Enable residual tracking. By default is disabled.
1353
1354@item output_mode, om
1355Set the output mode.
1356
1357It accepts the following values:
1358@table @option
1359@item input, i
1360Pass input unchanged.
1361
1362@item output, o
1363Pass noise filtered out.
1364
1365@item noise, n
1366Pass only noise.
1367
1368Default value is @var{output}.
1369@end table
1370
1371@item adaptivity, ad
1372Set the adaptivity factor, used how fast to adapt gains adjustments per
1373each frequency bin. Value @var{0} enables instant adaptation, while higher values
1374react much slower.
1375Allowed range is from @var{0} to @var{1}. Default value is @var{0.5}.
1376
1377@item floor_offset, fo
1378Set the noise floor offset factor. This option is used to adjust offset applied to measured
1379noise floor. It is only effective when noise floor tracking is enabled.
1380Allowed range is from @var{-2.0} to @var{2.0}. Default value is @var{1.0}.
1381
1382@item noise_link, nl
1383Set the noise link used for multichannel audio.
1384
1385It accepts the following values:
1386@table @option
1387@item none
1388Use unchanged channel's noise floor.
1389
1390@item min
1391Use measured min noise floor of all channels.
1392
1393@item max
1394Use measured max noise floor of all channels.
1395
1396@item average
1397Use measured average noise floor of all channels.
1398
1399Default value is @var{min}.
1400@end table
1401
1402@item band_multiplier, bm
1403Set the band multiplier factor, used how much to spread bands across frequency bins.
1404Allowed range is from @var{0.2} to @var{5}. Default value is @var{1.25}.
1405
1406@item sample_noise, sn
1407Toggle capturing and measurement of noise profile from input audio.
1408
1409It accepts the following values:
1410@table @option
1411@item start, begin
1412Start sample noise capture.
1413
1414@item stop, end
1415Stop sample noise capture and measure new noise band profile.
1416
1417Default value is @code{none}.
1418@end table
1419
1420@item gain_smooth, gs
1421Set gain smooth spatial radius, used to smooth gains applied to each frequency bin.
1422Useful to reduce random music noise artefacts.
1423Higher values increases smoothing of gains.
1424Allowed range is from @code{0} to @code{50}.
1425Default value is @code{0}.
1426@end table
1427
1428@subsection Commands
1429
1430This filter supports the some above mentioned options as @ref{commands}.
1431
1432@subsection Examples
1433
1434@itemize
1435@item
1436Reduce white noise by 10dB, and use previously measured noise floor of -40dB:
1437@example
1438afftdn=nr=10:nf=-40
1439@end example
1440
1441@item
1442Reduce white noise by 10dB, also set initial noise floor to -80dB and enable automatic
1443tracking of noise floor so noise floor will gradually change during processing:
1444@example
1445afftdn=nr=10:nf=-80:tn=1
1446@end example
1447
1448@item
1449Reduce noise by 20dB, using noise floor of -40dB and using commands to take noise profile
1450of first 0.4 seconds of input audio:
1451@example
1452asendcmd=0.0 afftdn sn start,asendcmd=0.4 afftdn sn stop,afftdn=nr=20:nf=-40
1453@end example
1454@end itemize
1455
1456@section afftfilt
1457Apply arbitrary expressions to samples in frequency domain.
1458
1459@table @option
1460@item real
1461Set frequency domain real expression for each separate channel separated
1462by '|'. Default is "re".
1463If the number of input channels is greater than the number of
1464expressions, the last specified expression is used for the remaining
1465output channels.
1466
1467@item imag
1468Set frequency domain imaginary expression for each separate channel
1469separated by '|'. Default is "im".
1470
1471Each expression in @var{real} and @var{imag} can contain the following
1472constants and functions:
1473
1474@table @option
1475@item sr
1476sample rate
1477
1478@item b
1479current frequency bin number
1480
1481@item nb
1482number of available bins
1483
1484@item ch
1485channel number of the current expression
1486
1487@item chs
1488number of channels
1489
1490@item pts
1491current frame pts
1492
1493@item re
1494current real part of frequency bin of current channel
1495
1496@item im
1497current imaginary part of frequency bin of current channel
1498
1499@item real(b, ch)
1500Return the value of real part of frequency bin at location (@var{bin},@var{channel})
1501
1502@item imag(b, ch)
1503Return the value of imaginary part of frequency bin at location (@var{bin},@var{channel})
1504@end table
1505
1506@item win_size
1507Set window size. Allowed range is from 16 to 131072.
1508Default is @code{4096}
1509
1510@item win_func
1511Set window function.
1512
1513It accepts the following values:
1514@table @samp
1515@item rect
1516@item bartlett
1517@item hann, hanning
1518@item hamming
1519@item blackman
1520@item welch
1521@item flattop
1522@item bharris
1523@item bnuttall
1524@item bhann
1525@item sine
1526@item nuttall
1527@item lanczos
1528@item gauss
1529@item tukey
1530@item dolph
1531@item cauchy
1532@item parzen
1533@item poisson
1534@item bohman
1535@end table
1536Default is @code{hann}.
1537
1538@item overlap
1539Set window overlap. If set to 1, the recommended overlap for selected
1540window function will be picked. Default is @code{0.75}.
1541@end table
1542
1543@subsection Examples
1544
1545@itemize
1546@item
1547Leave almost only low frequencies in audio:
1548@example
1549afftfilt="'real=re * (1-clip((b/nb)*b,0,1))':imag='im * (1-clip((b/nb)*b,0,1))'"
1550@end example
1551
1552@item
1553Apply robotize effect:
1554@example
1555afftfilt="real='hypot(re,im)*sin(0)':imag='hypot(re,im)*cos(0)':win_size=512:overlap=0.75"
1556@end example
1557
1558@item
1559Apply whisper effect:
1560@example
1561afftfilt="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"
1562@end example
1563@end itemize
1564
1565@anchor{afir}
1566@section afir
1567
1568Apply an arbitrary Finite Impulse Response filter.
1569
1570This filter is designed for applying long FIR filters,
1571up to 60 seconds long.
1572
1573It can be used as component for digital crossover filters,
1574room equalization, cross talk cancellation, wavefield synthesis,
1575auralization, ambiophonics, ambisonics and spatialization.
1576
1577This filter uses the streams higher than first one as FIR coefficients.
1578If the non-first stream holds a single channel, it will be used
1579for all input channels in the first stream, otherwise
1580the number of channels in the non-first stream must be same as
1581the number of channels in the first stream.
1582
1583It accepts the following parameters:
1584
1585@table @option
1586@item dry
1587Set dry gain. This sets input gain.
1588
1589@item wet
1590Set wet gain. This sets final output gain.
1591
1592@item length
1593Set Impulse Response filter length. Default is 1, which means whole IR is processed.
1594
1595@item gtype
1596Enable applying gain measured from power of IR.
1597
1598Set which approach to use for auto gain measurement.
1599
1600@table @option
1601@item none
1602Do not apply any gain.
1603
1604@item peak
1605select peak gain, very conservative approach. This is default value.
1606
1607@item dc
1608select DC gain, limited application.
1609
1610@item gn
1611select gain to noise approach, this is most popular one.
1612@end table
1613
1614@item irgain
1615Set gain to be applied to IR coefficients before filtering.
1616Allowed range is 0 to 1. This gain is applied after any gain applied with @var{gtype} option.
1617
1618@item irfmt
1619Set format of IR stream. Can be @code{mono} or @code{input}.
1620Default is @code{input}.
1621
1622@item maxir
1623Set max allowed Impulse Response filter duration in seconds. Default is 30 seconds.
1624Allowed range is 0.1 to 60 seconds.
1625
1626@item response
1627Show IR frequency response, magnitude(magenta), phase(green) and group delay(yellow) in additional video stream.
1628By default it is disabled.
1629
1630@item channel
1631Set for which IR channel to display frequency response. By default is first channel
1632displayed. This option is used only when @var{response} is enabled.
1633
1634@item size
1635Set video stream size. This option is used only when @var{response} is enabled.
1636
1637@item rate
1638Set video stream frame rate. This option is used only when @var{response} is enabled.
1639
1640@item minp
1641Set minimal partition size used for convolution. Default is @var{8192}.
1642Allowed range is from @var{1} to @var{32768}.
1643Lower values decreases latency at cost of higher CPU usage.
1644
1645@item maxp
1646Set maximal partition size used for convolution. Default is @var{8192}.
1647Allowed range is from @var{8} to @var{32768}.
1648Lower values may increase CPU usage.
1649
1650@item nbirs
1651Set number of input impulse responses streams which will be switchable at runtime.
1652Allowed range is from @var{1} to @var{32}. Default is @var{1}.
1653
1654@item ir
1655Set IR stream which will be used for convolution, starting from @var{0}, should always be
1656lower than supplied value by @code{nbirs} option. Default is @var{0}.
1657This option can be changed at runtime via @ref{commands}.
1658
1659@item precision
1660Set which precision to use when processing samples.
1661
1662@table @option
1663@item auto
1664Auto pick internal sample format depending on other filters.
1665
1666@item float
1667Always use single-floating point precision sample format.
1668
1669@item double
1670Always use double-floating point precision sample format.
1671@end table
1672
1673Default value is auto.
1674@end table
1675
1676@subsection Examples
1677
1678@itemize
1679@item
1680Apply reverb to stream using mono IR file as second input, complete command using ffmpeg:
1681@example
1682ffmpeg -i input.wav -i middle_tunnel_1way_mono.wav -lavfi afir output.wav
1683@end example
1684@end itemize
1685
1686@anchor{aformat}
1687@section aformat
1688
1689Set output format constraints for the input audio. The framework will
1690negotiate the most appropriate format to minimize conversions.
1691
1692It accepts the following parameters:
1693@table @option
1694
1695@item sample_fmts, f
1696A '|'-separated list of requested sample formats.
1697
1698@item sample_rates, r
1699A '|'-separated list of requested sample rates.
1700
1701@item channel_layouts, cl
1702A '|'-separated list of requested channel layouts.
1703
1704See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
1705for the required syntax.
1706@end table
1707
1708If a parameter is omitted, all values are allowed.
1709
1710Force the output to either unsigned 8-bit or signed 16-bit stereo
1711@example
1712aformat=sample_fmts=u8|s16:channel_layouts=stereo
1713@end example
1714
1715@section afreqshift
1716Apply frequency shift to input audio samples.
1717
1718The filter accepts the following options:
1719
1720@table @option
1721@item shift
1722Specify frequency shift. Allowed range is -INT_MAX to INT_MAX.
1723Default value is 0.0.
1724
1725@item level
1726Set output gain applied to final output. Allowed range is from 0.0 to 1.0.
1727Default value is 1.0.
1728
1729@item order
1730Set filter order used for filtering. Allowed range is from 1 to 16.
1731Default value is 8.
1732@end table
1733
1734@subsection Commands
1735
1736This filter supports the all above options as @ref{commands}.
1737
1738@section afwtdn
1739Reduce broadband noise from input samples using Wavelets.
1740
1741A description of the accepted options follows.
1742
1743@table @option
1744@item sigma
1745Set the noise sigma, allowed range is from 0 to 1.
1746Default value is 0.
1747This option controls strength of denoising applied to input samples.
1748Most useful way to set this option is via decibels, eg. -45dB.
1749
1750@item levels
1751Set the number of wavelet levels of decomposition.
1752Allowed range is from 1 to 12.
1753Default value is 10.
1754Setting this too low make denoising performance very poor.
1755
1756@item wavet
1757Set wavelet type for decomposition of input frame.
1758They are sorted by number of coefficients, from lowest to highest.
1759More coefficients means worse filtering speed, but overall better quality.
1760Available wavelets are:
1761
1762@table @samp
1763@item sym2
1764@item sym4
1765@item rbior68
1766@item deb10
1767@item sym10
1768@item coif5
1769@item bl3
1770@end table
1771
1772@item percent
1773Set percent of full denoising. Allowed range is from 0 to 100 percent.
1774Default value is 85 percent or partial denoising.
1775
1776@item profile
1777If enabled, first input frame will be used as noise profile.
1778If first frame samples contain non-noise performance will be very poor.
1779
1780@item adaptive
1781If enabled, input frames are analyzed for presence of noise.
1782If noise is detected with high possibility then input frame profile will be
1783used for processing following frames, until new noise frame is detected.
1784
1785@item samples
1786Set size of single frame in number of samples. Allowed range is from 512 to
178765536. Default frame size is 8192 samples.
1788
1789@item softness
1790Set softness applied inside thresholding function. Allowed range is from 0 to
179110. Default softness is 1.
1792@end table
1793
1794@subsection Commands
1795
1796This filter supports the all above options as @ref{commands}.
1797
1798@section agate
1799
1800A gate is mainly used to reduce lower parts of a signal. This kind of signal
1801processing reduces disturbing noise between useful signals.
1802
1803Gating is done by detecting the volume below a chosen level @var{threshold}
1804and dividing it by the factor set with @var{ratio}. The bottom of the noise
1805floor is set via @var{range}. Because an exact manipulation of the signal
1806would cause distortion of the waveform the reduction can be levelled over
1807time. This is done by setting @var{attack} and @var{release}.
1808
1809@var{attack} determines how long the signal has to fall below the threshold
1810before any reduction will occur and @var{release} sets the time the signal
1811has to rise above the threshold to reduce the reduction again.
1812Shorter signals than the chosen attack time will be left untouched.
1813
1814@table @option
1815@item level_in
1816Set input level before filtering.
1817Default is 1. Allowed range is from 0.015625 to 64.
1818
1819@item mode
1820Set the mode of operation. Can be @code{upward} or @code{downward}.
1821Default is @code{downward}. If set to @code{upward} mode, higher parts of signal
1822will be amplified, expanding dynamic range in upward direction.
1823Otherwise, in case of @code{downward} lower parts of signal will be reduced.
1824
1825@item range
1826Set the level of gain reduction when the signal is below the threshold.
1827Default is 0.06125. Allowed range is from 0 to 1.
1828Setting this to 0 disables reduction and then filter behaves like expander.
1829
1830@item threshold
1831If a signal rises above this level the gain reduction is released.
1832Default is 0.125. Allowed range is from 0 to 1.
1833
1834@item ratio
1835Set a ratio by which the signal is reduced.
1836Default is 2. Allowed range is from 1 to 9000.
1837
1838@item attack
1839Amount of milliseconds the signal has to rise above the threshold before gain
1840reduction stops.
1841Default is 20 milliseconds. Allowed range is from 0.01 to 9000.
1842
1843@item release
1844Amount of milliseconds the signal has to fall below the threshold before the
1845reduction is increased again. Default is 250 milliseconds.
1846Allowed range is from 0.01 to 9000.
1847
1848@item makeup
1849Set amount of amplification of signal after processing.
1850Default is 1. Allowed range is from 1 to 64.
1851
1852@item knee
1853Curve the sharp knee around the threshold to enter gain reduction more softly.
1854Default is 2.828427125. Allowed range is from 1 to 8.
1855
1856@item detection
1857Choose if exact signal should be taken for detection or an RMS like one.
1858Default is @code{rms}. Can be @code{peak} or @code{rms}.
1859
1860@item link
1861Choose if the average level between all channels or the louder channel affects
1862the reduction.
1863Default is @code{average}. Can be @code{average} or @code{maximum}.
1864@end table
1865
1866@subsection Commands
1867
1868This filter supports the all above options as @ref{commands}.
1869
1870@section aiir
1871
1872Apply an arbitrary Infinite Impulse Response filter.
1873
1874It accepts the following parameters:
1875
1876@table @option
1877@item zeros, z
1878Set B/numerator/zeros/reflection coefficients.
1879
1880@item poles, p
1881Set A/denominator/poles/ladder coefficients.
1882
1883@item gains, k
1884Set channels gains.
1885
1886@item dry_gain
1887Set input gain.
1888
1889@item wet_gain
1890Set output gain.
1891
1892@item format, f
1893Set coefficients format.
1894
1895@table @samp
1896@item ll
1897lattice-ladder function
1898@item sf
1899analog transfer function
1900@item tf
1901digital transfer function
1902@item zp
1903Z-plane zeros/poles, cartesian (default)
1904@item pr
1905Z-plane zeros/poles, polar radians
1906@item pd
1907Z-plane zeros/poles, polar degrees
1908@item sp
1909S-plane zeros/poles
1910@end table
1911
1912@item process, r
1913Set type of processing.
1914
1915@table @samp
1916@item d
1917direct processing
1918@item s
1919serial processing
1920@item p
1921parallel processing
1922@end table
1923
1924@item precision, e
1925Set filtering precision.
1926
1927@table @samp
1928@item dbl
1929double-precision floating-point (default)
1930@item flt
1931single-precision floating-point
1932@item i32
193332-bit integers
1934@item i16
193516-bit integers
1936@end table
1937
1938@item normalize, n
1939Normalize filter coefficients, by default is enabled.
1940Enabling it will normalize magnitude response at DC to 0dB.
1941
1942@item mix
1943How much to use filtered signal in output. Default is 1.
1944Range is between 0 and 1.
1945
1946@item response
1947Show IR frequency response, magnitude(magenta), phase(green) and group delay(yellow) in additional video stream.
1948By default it is disabled.
1949
1950@item channel
1951Set for which IR channel to display frequency response. By default is first channel
1952displayed. This option is used only when @var{response} is enabled.
1953
1954@item size
1955Set video stream size. This option is used only when @var{response} is enabled.
1956@end table
1957
1958Coefficients in @code{tf} and @code{sf} format are separated by spaces and are in ascending
1959order.
1960
1961Coefficients in @code{zp} format are separated by spaces and order of coefficients
1962doesn't matter. Coefficients in @code{zp} format are complex numbers with @var{i}
1963imaginary unit.
1964
1965Different coefficients and gains can be provided for every channel, in such case
1966use '|' to separate coefficients or gains. Last provided coefficients will be
1967used for all remaining channels.
1968
1969@subsection Examples
1970
1971@itemize
1972@item
1973Apply 2 pole elliptic notch at around 5000Hz for 48000 Hz sample rate:
1974@example
1975aiir=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
1976@end example
1977
1978@item
1979Same as above but in @code{zp} format:
1980@example
1981aiir=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
1982@end example
1983
1984@item
1985Apply 3-rd order analog normalized Butterworth low-pass filter, using analog transfer function format:
1986@example
1987aiir=z=1.3057 0 0 0:p=1.3057 2.3892 2.1860 1:f=sf:r=d
1988@end example
1989@end itemize
1990
1991@section alimiter
1992
1993The limiter prevents an input signal from rising over a desired threshold.
1994This limiter uses lookahead technology to prevent your signal from distorting.
1995It means that there is a small delay after the signal is processed. Keep in mind
1996that the delay it produces is the attack time you set.
1997
1998The filter accepts the following options:
1999
2000@table @option
2001@item level_in
2002Set input gain. Default is 1.
2003
2004@item level_out
2005Set output gain. Default is 1.
2006
2007@item limit
2008Don't let signals above this level pass the limiter. Default is 1.
2009
2010@item attack
2011The limiter will reach its attenuation level in this amount of time in
2012milliseconds. Default is 5 milliseconds.
2013
2014@item release
2015Come back from limiting to attenuation 1.0 in this amount of milliseconds.
2016Default is 50 milliseconds.
2017
2018@item asc
2019When gain reduction is always needed ASC takes care of releasing to an
2020average reduction level rather than reaching a reduction of 0 in the release
2021time.
2022
2023@item asc_level
2024Select how much the release time is affected by ASC, 0 means nearly no changes
2025in release time while 1 produces higher release times.
2026
2027@item level
2028Auto level output signal. Default is enabled.
2029This normalizes audio back to 0dB if enabled.
2030
2031@item latency
2032Compensate the delay introduced by using the lookahead buffer set with attack
2033parameter. Also flush the valid audio data in the lookahead buffer when the
2034stream hits EOF.
2035@end table
2036
2037Depending on picked setting it is recommended to upsample input 2x or 4x times
2038with @ref{aresample} before applying this filter.
2039
2040@section allpass
2041
2042Apply a two-pole all-pass filter with central frequency (in Hz)
2043@var{frequency}, and filter-width @var{width}.
2044An all-pass filter changes the audio's frequency to phase relationship
2045without changing its frequency to amplitude relationship.
2046
2047The filter accepts the following options:
2048
2049@table @option
2050@item frequency, f
2051Set frequency in Hz.
2052
2053@item width_type, t
2054Set method to specify band-width of filter.
2055@table @option
2056@item h
2057Hz
2058@item q
2059Q-Factor
2060@item o
2061octave
2062@item s
2063slope
2064@item k
2065kHz
2066@end table
2067
2068@item width, w
2069Specify the band-width of a filter in width_type units.
2070
2071@item mix, m
2072How much to use filtered signal in output. Default is 1.
2073Range is between 0 and 1.
2074
2075@item channels, c
2076Specify which channels to filter, by default all available are filtered.
2077
2078@item normalize, n
2079Normalize biquad coefficients, by default is disabled.
2080Enabling it will normalize magnitude response at DC to 0dB.
2081
2082@item order, o
2083Set the filter order, can be 1 or 2. Default is 2.
2084
2085@item transform, a
2086Set transform type of IIR filter.
2087@table @option
2088@item di
2089@item dii
2090@item tdi
2091@item tdii
2092@item latt
2093@item svf
2094@item zdf
2095@end table
2096
2097@item precision, r
2098Set precison of filtering.
2099@table @option
2100@item auto
2101Pick automatic sample format depending on surround filters.
2102@item s16
2103Always use signed 16-bit.
2104@item s32
2105Always use signed 32-bit.
2106@item f32
2107Always use float 32-bit.
2108@item f64
2109Always use float 64-bit.
2110@end table
2111@end table
2112
2113@subsection Commands
2114
2115This filter supports the following commands:
2116@table @option
2117@item frequency, f
2118Change allpass frequency.
2119Syntax for the command is : "@var{frequency}"
2120
2121@item width_type, t
2122Change allpass width_type.
2123Syntax for the command is : "@var{width_type}"
2124
2125@item width, w
2126Change allpass width.
2127Syntax for the command is : "@var{width}"
2128
2129@item mix, m
2130Change allpass mix.
2131Syntax for the command is : "@var{mix}"
2132@end table
2133
2134@section aloop
2135
2136Loop audio samples.
2137
2138The filter accepts the following options:
2139
2140@table @option
2141@item loop
2142Set the number of loops. Setting this value to -1 will result in infinite loops.
2143Default is 0.
2144
2145@item size
2146Set maximal number of samples. Default is 0.
2147
2148@item start
2149Set first sample of loop. Default is 0.
2150@end table
2151
2152@anchor{amerge}
2153@section amerge
2154
2155Merge two or more audio streams into a single multi-channel stream.
2156
2157The filter accepts the following options:
2158
2159@table @option
2160
2161@item inputs
2162Set the number of inputs. Default is 2.
2163
2164@end table
2165
2166If the channel layouts of the inputs are disjoint, and therefore compatible,
2167the channel layout of the output will be set accordingly and the channels
2168will be reordered as necessary. If the channel layouts of the inputs are not
2169disjoint, the output will have all the channels of the first input then all
2170the channels of the second input, in that order, and the channel layout of
2171the output will be the default value corresponding to the total number of
2172channels.
2173
2174For example, if the first input is in 2.1 (FL+FR+LF) and the second input
2175is FC+BL+BR, then the output will be in 5.1, with the channels in the
2176following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
2177first input, b1 is the first channel of the second input).
2178
2179On the other hand, if both input are in stereo, the output channels will be
2180in the default order: a1, a2, b1, b2, and the channel layout will be
2181arbitrarily set to 4.0, which may or may not be the expected value.
2182
2183All inputs must have the same sample rate, and format.
2184
2185If inputs do not have the same duration, the output will stop with the
2186shortest.
2187
2188@subsection Examples
2189
2190@itemize
2191@item
2192Merge two mono files into a stereo stream:
2193@example
2194amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
2195@end example
2196
2197@item
2198Multiple merges assuming 1 video stream and 6 audio streams in @file{input.mkv}:
2199@example
2200ffmpeg -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
2201@end example
2202@end itemize
2203
2204@section amix
2205
2206Mixes multiple audio inputs into a single output.
2207
2208Note that this filter only supports float samples (the @var{amerge}
2209and @var{pan} audio filters support many formats). If the @var{amix}
2210input has integer samples then @ref{aresample} will be automatically
2211inserted to perform the conversion to float samples.
2212
2213For example
2214@example
2215ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
2216@end example
2217will mix 3 input audio streams to a single output with the same duration as the
2218first input and a dropout transition time of 3 seconds.
2219
2220It accepts the following parameters:
2221@table @option
2222
2223@item inputs
2224The number of inputs. If unspecified, it defaults to 2.
2225
2226@item duration
2227How to determine the end-of-stream.
2228@table @option
2229
2230@item longest
2231The duration of the longest input. (default)
2232
2233@item shortest
2234The duration of the shortest input.
2235
2236@item first
2237The duration of the first input.
2238
2239@end table
2240
2241@item dropout_transition
2242The transition time, in seconds, for volume renormalization when an input
2243stream ends. The default value is 2 seconds.
2244
2245@item weights
2246Specify weight of each input audio stream as sequence.
2247Each weight is separated by space. By default all inputs have same weight.
2248
2249@item normalize
2250Always scale inputs instead of only doing summation of samples.
2251Beware of heavy clipping if inputs are not normalized prior or after filtering
2252by this filter if this option is disabled. By default is enabled.
2253@end table
2254
2255@subsection Commands
2256
2257This filter supports the following commands:
2258@table @option
2259@item weights
2260@item normalize
2261Syntax is same as option with same name.
2262@end table
2263
2264@section amultiply
2265
2266Multiply first audio stream with second audio stream and store result
2267in output audio stream. Multiplication is done by multiplying each
2268sample from first stream with sample at same position from second stream.
2269
2270With this element-wise multiplication one can create amplitude fades and
2271amplitude modulations.
2272
2273@section anequalizer
2274
2275High-order parametric multiband equalizer for each channel.
2276
2277It accepts the following parameters:
2278@table @option
2279@item params
2280
2281This option string is in format:
2282"c@var{chn} f=@var{cf} w=@var{w} g=@var{g} t=@var{f} | ..."
2283Each equalizer band is separated by '|'.
2284
2285@table @option
2286@item chn
2287Set channel number to which equalization will be applied.
2288If input doesn't have that channel the entry is ignored.
2289
2290@item f
2291Set central frequency for band.
2292If input doesn't have that frequency the entry is ignored.
2293
2294@item w
2295Set band width in Hertz.
2296
2297@item g
2298Set band gain in dB.
2299
2300@item t
2301Set filter type for band, optional, can be:
2302
2303@table @samp
2304@item 0
2305Butterworth, this is default.
2306
2307@item 1
2308Chebyshev type 1.
2309
2310@item 2
2311Chebyshev type 2.
2312@end table
2313@end table
2314
2315@item curves
2316With this option activated frequency response of anequalizer is displayed
2317in video stream.
2318
2319@item size
2320Set video stream size. Only useful if curves option is activated.
2321
2322@item mgain
2323Set max gain that will be displayed. Only useful if curves option is activated.
2324Setting this to a reasonable value makes it possible to display gain which is derived from
2325neighbour bands which are too close to each other and thus produce higher gain
2326when both are activated.
2327
2328@item fscale
2329Set frequency scale used to draw frequency response in video output.
2330Can be linear or logarithmic. Default is logarithmic.
2331
2332@item colors
2333Set color for each channel curve which is going to be displayed in video stream.
2334This is list of color names separated by space or by '|'.
2335Unrecognised or missing colors will be replaced by white color.
2336@end table
2337
2338@subsection Examples
2339
2340@itemize
2341@item
2342Lower gain by 10 of central frequency 200Hz and width 100 Hz
2343for first 2 channels using Chebyshev type 1 filter:
2344@example
2345anequalizer=c0 f=200 w=100 g=-10 t=1|c1 f=200 w=100 g=-10 t=1
2346@end example
2347@end itemize
2348
2349@subsection Commands
2350
2351This filter supports the following commands:
2352@table @option
2353@item change
2354Alter existing filter parameters.
2355Syntax for the commands is : "@var{fN}|f=@var{freq}|w=@var{width}|g=@var{gain}"
2356
2357@var{fN} is existing filter number, starting from 0, if no such filter is available
2358error is returned.
2359@var{freq} set new frequency parameter.
2360@var{width} set new width parameter in Hertz.
2361@var{gain} set new gain parameter in dB.
2362
2363Full filter invocation with asendcmd may look like this:
2364asendcmd=c='4.0 anequalizer change 0|f=200|w=50|g=1',anequalizer=...
2365@end table
2366
2367@section anlmdn
2368
2369Reduce broadband noise in audio samples using Non-Local Means algorithm.
2370
2371Each sample is adjusted by looking for other samples with similar contexts. This
2372context similarity is defined by comparing their surrounding patches of size
2373@option{p}. Patches are searched in an area of @option{r} around the sample.
2374
2375The filter accepts the following options:
2376
2377@table @option
2378@item strength, s
2379Set denoising strength. Allowed range is from 0.00001 to 10000. Default value is 0.00001.
2380
2381@item patch, p
2382Set patch radius duration. Allowed range is from 1 to 100 milliseconds.
2383Default value is 2 milliseconds.
2384
2385@item research, r
2386Set research radius duration. Allowed range is from 2 to 300 milliseconds.
2387Default value is 6 milliseconds.
2388
2389@item output, o
2390Set the output mode.
2391
2392It accepts the following values:
2393@table @option
2394@item i
2395Pass input unchanged.
2396
2397@item o
2398Pass noise filtered out.
2399
2400@item n
2401Pass only noise.
2402
2403Default value is @var{o}.
2404@end table
2405
2406@item smooth, m
2407Set smooth factor. Default value is @var{11}. Allowed range is from @var{1} to @var{1000}.
2408@end table
2409
2410@subsection Commands
2411
2412This filter supports the all above options as @ref{commands}.
2413
2414@section anlmf, anlms
2415Apply Normalized Least-Mean-(Squares|Fourth) algorithm to the first audio stream using the second audio stream.
2416
2417This adaptive filter is used to mimic a desired filter by finding the filter coefficients that
2418relate to producing the least mean square of the error signal (difference between the desired,
24192nd input audio stream and the actual signal, the 1st input audio stream).
2420
2421A description of the accepted options follows.
2422
2423@table @option
2424@item order
2425Set filter order.
2426
2427@item mu
2428Set filter mu.
2429
2430@item eps
2431Set the filter eps.
2432
2433@item leakage
2434Set the filter leakage.
2435
2436@item out_mode
2437It accepts the following values:
2438@table @option
2439@item i
2440Pass the 1st input.
2441
2442@item d
2443Pass the 2nd input.
2444
2445@item o
2446Pass filtered samples.
2447
2448@item n
2449Pass difference between desired and filtered samples.
2450
2451Default value is @var{o}.
2452@end table
2453@end table
2454
2455@subsection Examples
2456
2457@itemize
2458@item
2459One of many usages of this filter is noise reduction, input audio is filtered
2460with same samples that are delayed by fixed amount, one such example for stereo audio is:
2461@example
2462asplit[a][b],[a]adelay=32S|32S[a],[b][a]anlms=order=128:leakage=0.0005:mu=.5:out_mode=o
2463@end example
2464@end itemize
2465
2466@subsection Commands
2467
2468This filter supports the same commands as options, excluding option @code{order}.
2469
2470@section anull
2471
2472Pass the audio source unchanged to the output.
2473
2474@section apad
2475
2476Pad the end of an audio stream with silence.
2477
2478This can be used together with @command{ffmpeg} @option{-shortest} to
2479extend audio streams to the same length as the video stream.
2480
2481A description of the accepted options follows.
2482
2483@table @option
2484@item packet_size
2485Set silence packet size. Default value is 4096.
2486
2487@item pad_len
2488Set the number of samples of silence to add to the end. After the
2489value is reached, the stream is terminated. This option is mutually
2490exclusive with @option{whole_len}.
2491
2492@item whole_len
2493Set the minimum total number of samples in the output audio stream. If
2494the value is longer than the input audio length, silence is added to
2495the end, until the value is reached. This option is mutually exclusive
2496with @option{pad_len}.
2497
2498@item pad_dur
2499Specify the duration of samples of silence to add. See
2500@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
2501for the accepted syntax. Used only if set to non-negative value.
2502
2503@item whole_dur
2504Specify the minimum total duration in the output audio stream. See
2505@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
2506for the accepted syntax. Used only if set to non-negative value. If the value is longer than
2507the input audio length, silence is added to the end, until the value is reached.
2508This option is mutually exclusive with @option{pad_dur}
2509@end table
2510
2511If neither the @option{pad_len} nor the @option{whole_len} nor @option{pad_dur}
2512nor @option{whole_dur} option is set, the filter will add silence to the end of
2513the input stream indefinitely.
2514
2515Note that for ffmpeg 4.4 and earlier a zero @option{pad_dur} or
2516@option{whole_dur} also caused the filter to add silence indefinitely.
2517
2518@subsection Examples
2519
2520@itemize
2521@item
2522Add 1024 samples of silence to the end of the input:
2523@example
2524apad=pad_len=1024
2525@end example
2526
2527@item
2528Make sure the audio output will contain at least 10000 samples, pad
2529the input with silence if required:
2530@example
2531apad=whole_len=10000
2532@end example
2533
2534@item
2535Use @command{ffmpeg} to pad the audio input with silence, so that the
2536video stream will always result the shortest and will be converted
2537until the end in the output file when using the @option{shortest}
2538option:
2539@example
2540ffmpeg -i VIDEO -i AUDIO -filter_complex "[1:0]apad" -shortest OUTPUT
2541@end example
2542@end itemize
2543
2544@section aphaser
2545Add a phasing effect to the input audio.
2546
2547A phaser filter creates series of peaks and troughs in the frequency spectrum.
2548The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
2549
2550A description of the accepted parameters follows.
2551
2552@table @option
2553@item in_gain
2554Set input gain. Default is 0.4.
2555
2556@item out_gain
2557Set output gain. Default is 0.74
2558
2559@item delay
2560Set delay in milliseconds. Default is 3.0.
2561
2562@item decay
2563Set decay. Default is 0.4.
2564
2565@item speed
2566Set modulation speed in Hz. Default is 0.5.
2567
2568@item type
2569Set modulation type. Default is triangular.
2570
2571It accepts the following values:
2572@table @samp
2573@item triangular, t
2574@item sinusoidal, s
2575@end table
2576@end table
2577
2578@section aphaseshift
2579Apply phase shift to input audio samples.
2580
2581The filter accepts the following options:
2582
2583@table @option
2584@item shift
2585Specify phase shift. Allowed range is from -1.0 to 1.0.
2586Default value is 0.0.
2587
2588@item level
2589Set output gain applied to final output. Allowed range is from 0.0 to 1.0.
2590Default value is 1.0.
2591
2592@item order
2593Set filter order used for filtering. Allowed range is from 1 to 16.
2594Default value is 8.
2595@end table
2596
2597@subsection Commands
2598
2599This filter supports the all above options as @ref{commands}.
2600
2601@section apsyclip
2602Apply Psychoacoustic clipper to input audio stream.
2603
2604The filter accepts the following options:
2605
2606@table @option
2607@item level_in
2608Set input gain. By default it is 1. Range is [0.015625 - 64].
2609
2610@item level_out
2611Set output gain. By default it is 1. Range is [0.015625 - 64].
2612
2613@item clip
2614Set the clipping start value. Default value is 0dBFS or 1.
2615
2616@item diff
2617Output only difference samples, useful to hear introduced distortions.
2618By default is disabled.
2619
2620@item adaptive
2621Set strength of adaptive distortion applied. Default value is 0.5.
2622Allowed range is from 0 to 1.
2623
2624@item iterations
2625Set number of iterations of psychoacoustic clipper.
2626Allowed range is from 1 to 20. Default value is 10.
2627
2628@item level
2629Auto level output signal. Default is disabled.
2630This normalizes audio back to 0dBFS if enabled.
2631@end table
2632
2633@subsection Commands
2634
2635This filter supports the all above options as @ref{commands}.
2636
2637@section apulsator
2638
2639Audio pulsator is something between an autopanner and a tremolo.
2640But it can produce funny stereo effects as well. Pulsator changes the volume
2641of the left and right channel based on a LFO (low frequency oscillator) with
2642different waveforms and shifted phases.
2643This filter have the ability to define an offset between left and right
2644channel. An offset of 0 means that both LFO shapes match each other.
2645The left and right channel are altered equally - a conventional tremolo.
2646An offset of 50% means that the shape of the right channel is exactly shifted
2647in phase (or moved backwards about half of the frequency) - pulsator acts as
2648an autopanner. At 1 both curves match again. Every setting in between moves the
2649phase shift gapless between all stages and produces some "bypassing" sounds with
2650sine and triangle waveforms. The more you set the offset near 1 (starting from
2651the 0.5) the faster the signal passes from the left to the right speaker.
2652
2653The filter accepts the following options:
2654
2655@table @option
2656@item level_in
2657Set input gain. By default it is 1. Range is [0.015625 - 64].
2658
2659@item level_out
2660Set output gain. By default it is 1. Range is [0.015625 - 64].
2661
2662@item mode
2663Set waveform shape the LFO will use. Can be one of: sine, triangle, square,
2664sawup or sawdown. Default is sine.
2665
2666@item amount
2667Set modulation. Define how much of original signal is affected by the LFO.
2668
2669@item offset_l
2670Set left channel offset. Default is 0. Allowed range is [0 - 1].
2671
2672@item offset_r
2673Set right channel offset. Default is 0.5. Allowed range is [0 - 1].
2674
2675@item width
2676Set pulse width. Default is 1. Allowed range is [0 - 2].
2677
2678@item timing
2679Set possible timing mode. Can be one of: bpm, ms or hz. Default is hz.
2680
2681@item bpm
2682Set bpm. Default is 120. Allowed range is [30 - 300]. Only used if timing
2683is set to bpm.
2684
2685@item ms
2686Set ms. Default is 500. Allowed range is [10 - 2000]. Only used if timing
2687is set to ms.
2688
2689@item hz
2690Set frequency in Hz. Default is 2. Allowed range is [0.01 - 100]. Only used
2691if timing is set to hz.
2692@end table
2693
2694@anchor{aresample}
2695@section aresample
2696
2697Resample the input audio to the specified parameters, using the
2698libswresample library. If none are specified then the filter will
2699automatically convert between its input and output.
2700
2701This filter is also able to stretch/squeeze the audio data to make it match
2702the timestamps or to inject silence / cut out audio to make it match the
2703timestamps, do a combination of both or do neither.
2704
2705The filter accepts the syntax
2706[@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
2707expresses a sample rate and @var{resampler_options} is a list of
2708@var{key}=@var{value} pairs, separated by ":". See the
2709@ref{Resampler Options,,"Resampler Options" section in the
2710ffmpeg-resampler(1) manual,ffmpeg-resampler}
2711for the complete list of supported options.
2712
2713@subsection Examples
2714
2715@itemize
2716@item
2717Resample the input audio to 44100Hz:
2718@example
2719aresample=44100
2720@end example
2721
2722@item
2723Stretch/squeeze samples to the given timestamps, with a maximum of 1000
2724samples per second compensation:
2725@example
2726aresample=async=1000
2727@end example
2728@end itemize
2729
2730@section areverse
2731
2732Reverse an audio clip.
2733
2734Warning: This filter requires memory to buffer the entire clip, so trimming
2735is suggested.
2736
2737@subsection Examples
2738
2739@itemize
2740@item
2741Take the first 5 seconds of a clip, and reverse it.
2742@example
2743atrim=end=5,areverse
2744@end example
2745@end itemize
2746
2747@section arnndn
2748
2749Reduce noise from speech using Recurrent Neural Networks.
2750
2751This filter accepts the following options:
2752
2753@table @option
2754@item model, m
2755Set train model file to load. This option is always required.
2756
2757@item mix
2758Set how much to mix filtered samples into final output.
2759Allowed range is from -1 to 1. Default value is 1.
2760Negative values are special, they set how much to keep filtered noise
2761in the final filter output. Set this option to -1 to hear actual
2762noise removed from input signal.
2763@end table
2764
2765@subsection Commands
2766
2767This filter supports the all above options as @ref{commands}.
2768
2769@section asdr
2770Measure Audio Signal-to-Distortion Ratio.
2771
2772This filter takes two audio streams for input, and outputs first
2773audio stream.
2774Results are in dB per channel at end of either input.
2775
2776@section asetnsamples
2777
2778Set the number of samples per each output audio frame.
2779
2780The last output packet may contain a different number of samples, as
2781the filter will flush all the remaining samples when the input audio
2782signals its end.
2783
2784The filter accepts the following options:
2785
2786@table @option
2787
2788@item nb_out_samples, n
2789Set the number of frames per each output audio frame. The number is
2790intended as the number of samples @emph{per each channel}.
2791Default value is 1024.
2792
2793@item pad, p
2794If set to 1, the filter will pad the last audio frame with zeroes, so
2795that the last frame will contain the same number of samples as the
2796previous ones. Default value is 1.
2797@end table
2798
2799For example, to set the number of per-frame samples to 1234 and
2800disable padding for the last frame, use:
2801@example
2802asetnsamples=n=1234:p=0
2803@end example
2804
2805@section asetrate
2806
2807Set the sample rate without altering the PCM data.
2808This will result in a change of speed and pitch.
2809
2810The filter accepts the following options:
2811
2812@table @option
2813@item sample_rate, r
2814Set the output sample rate. Default is 44100 Hz.
2815@end table
2816
2817@section ashowinfo
2818
2819Show a line containing various information for each input audio frame.
2820The input audio is not modified.
2821
2822The shown line contains a sequence of key/value pairs of the form
2823@var{key}:@var{value}.
2824
2825The following values are shown in the output:
2826
2827@table @option
2828@item n
2829The (sequential) number of the input frame, starting from 0.
2830
2831@item pts
2832The presentation timestamp of the input frame, in time base units; the time base
2833depends on the filter input pad, and is usually 1/@var{sample_rate}.
2834
2835@item pts_time
2836The presentation timestamp of the input frame in seconds.
2837
2838@item pos
2839position of the frame in the input stream, -1 if this information in
2840unavailable and/or meaningless (for example in case of synthetic audio)
2841
2842@item fmt
2843The sample format.
2844
2845@item chlayout
2846The channel layout.
2847
2848@item rate
2849The sample rate for the audio frame.
2850
2851@item nb_samples
2852The number of samples (per channel) in the frame.
2853
2854@item checksum
2855The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
2856audio, the data is treated as if all the planes were concatenated.
2857
2858@item plane_checksums
2859A list of Adler-32 checksums for each data plane.
2860@end table
2861
2862@section asoftclip
2863Apply audio soft clipping.
2864
2865Soft clipping is a type of distortion effect where the amplitude of a signal is saturated
2866along a smooth curve, rather than the abrupt shape of hard-clipping.
2867
2868This filter accepts the following options:
2869
2870@table @option
2871@item type
2872Set type of soft-clipping.
2873
2874It accepts the following values:
2875@table @option
2876@item hard
2877@item tanh
2878@item atan
2879@item cubic
2880@item exp
2881@item alg
2882@item quintic
2883@item sin
2884@item erf
2885@end table
2886
2887@item threshold
2888Set threshold from where to start clipping. Default value is 0dB or 1.
2889
2890@item output
2891Set gain applied to output. Default value is 0dB or 1.
2892
2893@item param
2894Set additional parameter which controls sigmoid function.
2895
2896@item oversample
2897Set oversampling factor.
2898@end table
2899
2900@subsection Commands
2901
2902This filter supports the all above options as @ref{commands}.
2903
2904@section aspectralstats
2905
2906Display frequency domain statistical information about the audio channels.
2907Statistics are calculated and stored as metadata for each audio channel and for each audio frame.
2908
2909It accepts the following option:
2910@table @option
2911@item win_size
2912Set the window length in samples. Default value is 2048.
2913Allowed range is from 32 to 65536.
2914
2915@item win_func
2916Set window function.
2917
2918It accepts the following values:
2919@table @samp
2920@item rect
2921@item bartlett
2922@item hann, hanning
2923@item hamming
2924@item blackman
2925@item welch
2926@item flattop
2927@item bharris
2928@item bnuttall
2929@item bhann
2930@item sine
2931@item nuttall
2932@item lanczos
2933@item gauss
2934@item tukey
2935@item dolph
2936@item cauchy
2937@item parzen
2938@item poisson
2939@item bohman
2940@end table
2941Default is @code{hann}.
2942
2943@item overlap
2944Set window overlap. Allowed range is from @code{0}
2945to @code{1}. Default value is @code{0.5}.
2946
2947@end table
2948
2949A list of each metadata key follows:
2950
2951@table @option
2952@item mean
2953@item variance
2954@item centroid
2955@item spread
2956@item skewness
2957@item kurtosis
2958@item entropy
2959@item flatness
2960@item crest
2961@item flux
2962@item slope
2963@item decrease
2964@item rolloff
2965@end table
2966
2967@section asr
2968Automatic Speech Recognition
2969
2970This filter uses PocketSphinx for speech recognition. To enable
2971compilation of this filter, you need to configure FFmpeg with
2972@code{--enable-pocketsphinx}.
2973
2974It accepts the following options:
2975
2976@table @option
2977@item rate
2978Set sampling rate of input audio. Defaults is @code{16000}.
2979This need to match speech models, otherwise one will get poor results.
2980
2981@item hmm
2982Set dictionary containing acoustic model files.
2983
2984@item dict
2985Set pronunciation dictionary.
2986
2987@item lm
2988Set language model file.
2989
2990@item lmctl
2991Set language model set.
2992
2993@item lmname
2994Set which language model to use.
2995
2996@item logfn
2997Set output for log messages.
2998@end table
2999
3000The filter exports recognized speech as the frame metadata @code{lavfi.asr.text}.
3001
3002@anchor{astats}
3003@section astats
3004
3005Display time domain statistical information about the audio channels.
3006Statistics are calculated and displayed for each audio channel and,
3007where applicable, an overall figure is also given.
3008
3009It accepts the following option:
3010@table @option
3011@item length
3012Short window length in seconds, used for peak and trough RMS measurement.
3013Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0 - 10]}.
3014
3015@item metadata
3016
3017Set metadata injection. All the metadata keys are prefixed with @code{lavfi.astats.X},
3018where @code{X} is channel number starting from 1 or string @code{Overall}. Default is
3019disabled.
3020
3021Available keys for each channel are:
3022DC_offset
3023Min_level
3024Max_level
3025Min_difference
3026Max_difference
3027Mean_difference
3028RMS_difference
3029Peak_level
3030RMS_peak
3031RMS_trough
3032Crest_factor
3033Flat_factor
3034Peak_count
3035Noise_floor
3036Noise_floor_count
3037Entropy
3038Bit_depth
3039Dynamic_range
3040Zero_crossings
3041Zero_crossings_rate
3042Number_of_NaNs
3043Number_of_Infs
3044Number_of_denormals
3045
3046and for Overall:
3047DC_offset
3048Min_level
3049Max_level
3050Min_difference
3051Max_difference
3052Mean_difference
3053RMS_difference
3054Peak_level
3055RMS_level
3056RMS_peak
3057RMS_trough
3058Flat_factor
3059Peak_count
3060Noise_floor
3061Noise_floor_count
3062Entropy
3063Bit_depth
3064Number_of_samples
3065Number_of_NaNs
3066Number_of_Infs
3067Number_of_denormals
3068
3069For example full key look like this @code{lavfi.astats.1.DC_offset} or
3070this @code{lavfi.astats.Overall.Peak_count}.
3071
3072For description what each key means read below.
3073
3074@item reset
3075Set the number of frames over which cumulative stats are calculated before
3076being reset
3077Default is disabled.
3078
3079@item measure_perchannel
3080Select the parameters which are measured per channel. The metadata keys can
3081be used as flags, default is @option{all} which measures everything.
3082@option{none} disables all per channel measurement.
3083
3084@item measure_overall
3085Select the parameters which are measured overall. The metadata keys can
3086be used as flags, default is @option{all} which measures everything.
3087@option{none} disables all overall measurement.
3088
3089@end table
3090
3091A description of each shown parameter follows:
3092
3093@table @option
3094@item DC offset
3095Mean amplitude displacement from zero.
3096
3097@item Min level
3098Minimal sample level.
3099
3100@item Max level
3101Maximal sample level.
3102
3103@item Min difference
3104Minimal difference between two consecutive samples.
3105
3106@item Max difference
3107Maximal difference between two consecutive samples.
3108
3109@item Mean difference
3110Mean difference between two consecutive samples.
3111The average of each difference between two consecutive samples.
3112
3113@item RMS difference
3114Root Mean Square difference between two consecutive samples.
3115
3116@item Peak level dB
3117@item RMS level dB
3118Standard peak and RMS level measured in dBFS.
3119
3120@item RMS peak dB
3121@item RMS trough dB
3122Peak and trough values for RMS level measured over a short window.
3123
3124@item Crest factor
3125Standard ratio of peak to RMS level (note: not in dB).
3126
3127@item Flat factor
3128Flatness (i.e. consecutive samples with the same value) of the signal at its peak levels
3129(i.e. either @var{Min level} or @var{Max level}).
3130
3131@item Peak count
3132Number of occasions (not the number of samples) that the signal attained either
3133@var{Min level} or @var{Max level}.
3134
3135@item Noise floor dB
3136Minimum local peak measured in dBFS over a short window.
3137
3138@item Noise floor count
3139Number of occasions (not the number of samples) that the signal attained
3140@var{Noise floor}.
3141
3142@item Entropy
3143Entropy measured across whole audio. Entropy of value near 1.0 is typically measured for white noise.
3144
3145@item Bit depth
3146Overall bit depth of audio. Number of bits used for each sample.
3147
3148@item Dynamic range
3149Measured dynamic range of audio in dB.
3150
3151@item Zero crossings
3152Number of points where the waveform crosses the zero level axis.
3153
3154@item Zero crossings rate
3155Rate of Zero crossings and number of audio samples.
3156@end table
3157
3158@section asubboost
3159Boost subwoofer frequencies.
3160
3161The filter accepts the following options:
3162
3163@table @option
3164@item dry
3165Set dry gain, how much of original signal is kept. Allowed range is from 0 to 1.
3166Default value is 1.0.
3167
3168@item wet
3169Set wet gain, how much of filtered signal is kept. Allowed range is from 0 to 1.
3170Default value is 1.0.
3171
3172@item boost
3173Set max boost factor. Allowed range is from 1 to 12. Default value is 2.
3174
3175@item decay
3176Set delay line decay gain value. Allowed range is from 0 to 1.
3177Default value is 0.0.
3178
3179@item feedback
3180Set delay line feedback gain value. Allowed range is from 0 to 1.
3181Default value is 0.9.
3182
3183@item cutoff
3184Set cutoff frequency in Hertz. Allowed range is 50 to 900.
3185Default value is 100.
3186
3187@item slope
3188Set slope amount for cutoff frequency. Allowed range is 0.0001 to 1.
3189Default value is 0.5.
3190
3191@item delay
3192Set delay. Allowed range is from 1 to 100.
3193Default value is 20.
3194
3195@item channels
3196Set the channels to process. Default value is all available.
3197@end table
3198
3199@subsection Commands
3200
3201This filter supports the all above options as @ref{commands}.
3202
3203@section asubcut
3204Cut subwoofer frequencies.
3205
3206This filter allows to set custom, steeper
3207roll off than highpass filter, and thus is able to more attenuate
3208frequency content in stop-band.
3209
3210The filter accepts the following options:
3211
3212@table @option
3213@item cutoff
3214Set cutoff frequency in Hertz. Allowed range is 2 to 200.
3215Default value is 20.
3216
3217@item order
3218Set filter order. Available values are from 3 to 20.
3219Default value is 10.
3220
3221@item level
3222Set input gain level. Allowed range is from 0 to 1. Default value is 1.
3223@end table
3224
3225@subsection Commands
3226
3227This filter supports the all above options as @ref{commands}.
3228
3229@section asupercut
3230Cut super frequencies.
3231
3232The filter accepts the following options:
3233
3234@table @option
3235@item cutoff
3236Set cutoff frequency in Hertz. Allowed range is 20000 to 192000.
3237Default value is 20000.
3238
3239@item order
3240Set filter order. Available values are from 3 to 20.
3241Default value is 10.
3242
3243@item level
3244Set input gain level. Allowed range is from 0 to 1. Default value is 1.
3245@end table
3246
3247@subsection Commands
3248
3249This filter supports the all above options as @ref{commands}.
3250
3251@section asuperpass
3252Apply high order Butterworth band-pass filter.
3253
3254The filter accepts the following options:
3255
3256@table @option
3257@item centerf
3258Set center frequency in Hertz. Allowed range is 2 to 999999.
3259Default value is 1000.
3260
3261@item order
3262Set filter order. Available values are from 4 to 20.
3263Default value is 4.
3264
3265@item qfactor
3266Set Q-factor. Allowed range is from 0.01 to 100. Default value is 1.
3267
3268@item level
3269Set input gain level. Allowed range is from 0 to 2. Default value is 1.
3270@end table
3271
3272@subsection Commands
3273
3274This filter supports the all above options as @ref{commands}.
3275
3276@section asuperstop
3277Apply high order Butterworth band-stop filter.
3278
3279The filter accepts the following options:
3280
3281@table @option
3282@item centerf
3283Set center frequency in Hertz. Allowed range is 2 to 999999.
3284Default value is 1000.
3285
3286@item order
3287Set filter order. Available values are from 4 to 20.
3288Default value is 4.
3289
3290@item qfactor
3291Set Q-factor. Allowed range is from 0.01 to 100. Default value is 1.
3292
3293@item level
3294Set input gain level. Allowed range is from 0 to 2. Default value is 1.
3295@end table
3296
3297@subsection Commands
3298
3299This filter supports the all above options as @ref{commands}.
3300
3301@section atempo
3302
3303Adjust audio tempo.
3304
3305The filter accepts exactly one parameter, the audio tempo. If not
3306specified then the filter will assume nominal 1.0 tempo. Tempo must
3307be in the [0.5, 100.0] range.
3308
3309Note that tempo greater than 2 will skip some samples rather than
3310blend them in.  If for any reason this is a concern it is always
3311possible to daisy-chain several instances of atempo to achieve the
3312desired product tempo.
3313
3314@subsection Examples
3315
3316@itemize
3317@item
3318Slow down audio to 80% tempo:
3319@example
3320atempo=0.8
3321@end example
3322
3323@item
3324To speed up audio to 300% tempo:
3325@example
3326atempo=3
3327@end example
3328
3329@item
3330To speed up audio to 300% tempo by daisy-chaining two atempo instances:
3331@example
3332atempo=sqrt(3),atempo=sqrt(3)
3333@end example
3334@end itemize
3335
3336@subsection Commands
3337
3338This filter supports the following commands:
3339@table @option
3340@item tempo
3341Change filter tempo scale factor.
3342Syntax for the command is : "@var{tempo}"
3343@end table
3344
3345@section atilt
3346Apply spectral tilt filter to audio stream.
3347
3348This filter apply any spectral roll-off slope over any specified frequency band.
3349
3350The filter accepts the following options:
3351
3352@table @option
3353@item freq
3354Set central frequency of tilt in Hz. Default is 10000 Hz.
3355
3356@item slope
3357Set slope direction of tilt. Default is 0. Allowed range is from -1 to 1.
3358
3359@item width
3360Set width of tilt. Default is 1000. Allowed range is from 100 to 10000.
3361
3362@item order
3363Set order of tilt filter.
3364
3365@item level
3366Set input volume level. Allowed range is from 0 to 4.
3367Defalt is 1.
3368@end table
3369
3370@subsection Commands
3371
3372This filter supports the all above options as @ref{commands}.
3373
3374@section atrim
3375
3376Trim the input so that the output contains one continuous subpart of the input.
3377
3378It accepts the following parameters:
3379@table @option
3380@item start
3381Timestamp (in seconds) of the start of the section to keep. I.e. the audio
3382sample with the timestamp @var{start} will be the first sample in the output.
3383
3384@item end
3385Specify time of the first audio sample that will be dropped, i.e. the
3386audio sample immediately preceding the one with the timestamp @var{end} will be
3387the last sample in the output.
3388
3389@item start_pts
3390Same as @var{start}, except this option sets the start timestamp in samples
3391instead of seconds.
3392
3393@item end_pts
3394Same as @var{end}, except this option sets the end timestamp in samples instead
3395of seconds.
3396
3397@item duration
3398The maximum duration of the output in seconds.
3399
3400@item start_sample
3401The number of the first sample that should be output.
3402
3403@item end_sample
3404The number of the first sample that should be dropped.
3405@end table
3406
3407@option{start}, @option{end}, and @option{duration} are expressed as time
3408duration specifications; see
3409@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
3410
3411Note that the first two sets of the start/end options and the @option{duration}
3412option look at the frame timestamp, while the _sample options simply count the
3413samples that pass through the filter. So start/end_pts and start/end_sample will
3414give different results when the timestamps are wrong, inexact or do not start at
3415zero. Also note that this filter does not modify the timestamps. If you wish
3416to have the output timestamps start at zero, insert the asetpts filter after the
3417atrim filter.
3418
3419If multiple start or end options are set, this filter tries to be greedy and
3420keep all samples that match at least one of the specified constraints. To keep
3421only the part that matches all the constraints at once, chain multiple atrim
3422filters.
3423
3424The defaults are such that all the input is kept. So it is possible to set e.g.
3425just the end values to keep everything before the specified time.
3426
3427Examples:
3428@itemize
3429@item
3430Drop everything except the second minute of input:
3431@example
3432ffmpeg -i INPUT -af atrim=60:120
3433@end example
3434
3435@item
3436Keep only the first 1000 samples:
3437@example
3438ffmpeg -i INPUT -af atrim=end_sample=1000
3439@end example
3440
3441@end itemize
3442
3443@section axcorrelate
3444Calculate normalized windowed cross-correlation between two input audio streams.
3445
3446Resulted samples are always between -1 and 1 inclusive.
3447If result is 1 it means two input samples are highly correlated in that selected segment.
3448Result 0 means they are not correlated at all.
3449If result is -1 it means two input samples are out of phase, which means they cancel each
3450other.
3451
3452The filter accepts the following options:
3453
3454@table @option
3455@item size
3456Set size of segment over which cross-correlation is calculated.
3457Default is 256. Allowed range is from 2 to 131072.
3458
3459@item algo
3460Set algorithm for cross-correlation. Can be @code{slow} or @code{fast}.
3461Default is @code{slow}. Fast algorithm assumes mean values over any given segment
3462are always zero and thus need much less calculations to make.
3463This is generally not true, but is valid for typical audio streams.
3464@end table
3465
3466@subsection Examples
3467
3468@itemize
3469@item
3470Calculate correlation between channels in stereo audio stream:
3471@example
3472ffmpeg -i stereo.wav -af channelsplit,axcorrelate=size=1024:algo=fast correlation.wav
3473@end example
3474@end itemize
3475
3476@section bandpass
3477
3478Apply a two-pole Butterworth band-pass filter with central
3479frequency @var{frequency}, and (3dB-point) band-width width.
3480The @var{csg} option selects a constant skirt gain (peak gain = Q)
3481instead of the default: constant 0dB peak gain.
3482The filter roll off at 6dB per octave (20dB per decade).
3483
3484The filter accepts the following options:
3485
3486@table @option
3487@item frequency, f
3488Set the filter's central frequency. Default is @code{3000}.
3489
3490@item csg
3491Constant skirt gain if set to 1. Defaults to 0.
3492
3493@item width_type, t
3494Set method to specify band-width of filter.
3495@table @option
3496@item h
3497Hz
3498@item q
3499Q-Factor
3500@item o
3501octave
3502@item s
3503slope
3504@item k
3505kHz
3506@end table
3507
3508@item width, w
3509Specify the band-width of a filter in width_type units.
3510
3511@item mix, m
3512How much to use filtered signal in output. Default is 1.
3513Range is between 0 and 1.
3514
3515@item channels, c
3516Specify which channels to filter, by default all available are filtered.
3517
3518@item normalize, n
3519Normalize biquad coefficients, by default is disabled.
3520Enabling it will normalize magnitude response at DC to 0dB.
3521
3522@item transform, a
3523Set transform type of IIR filter.
3524@table @option
3525@item di
3526@item dii
3527@item tdi
3528@item tdii
3529@item latt
3530@item svf
3531@item zdf
3532@end table
3533
3534@item precision, r
3535Set precison of filtering.
3536@table @option
3537@item auto
3538Pick automatic sample format depending on surround filters.
3539@item s16
3540Always use signed 16-bit.
3541@item s32
3542Always use signed 32-bit.
3543@item f32
3544Always use float 32-bit.
3545@item f64
3546Always use float 64-bit.
3547@end table
3548
3549@item block_size, b
3550Set block size used for reverse IIR processing. If this value is set to high enough
3551value (higher than impulse response length truncated when reaches near zero values) filtering
3552will become linear phase otherwise if not big enough it will just produce nasty artifacts.
3553
3554Note that filter delay will be exactly this many samples when set to non-zero value.
3555@end table
3556
3557@subsection Commands
3558
3559This filter supports the following commands:
3560@table @option
3561@item frequency, f
3562Change bandpass frequency.
3563Syntax for the command is : "@var{frequency}"
3564
3565@item width_type, t
3566Change bandpass width_type.
3567Syntax for the command is : "@var{width_type}"
3568
3569@item width, w
3570Change bandpass width.
3571Syntax for the command is : "@var{width}"
3572
3573@item mix, m
3574Change bandpass mix.
3575Syntax for the command is : "@var{mix}"
3576@end table
3577
3578@section bandreject
3579
3580Apply a two-pole Butterworth band-reject filter with central
3581frequency @var{frequency}, and (3dB-point) band-width @var{width}.
3582The filter roll off at 6dB per octave (20dB per decade).
3583
3584The filter accepts the following options:
3585
3586@table @option
3587@item frequency, f
3588Set the filter's central frequency. Default is @code{3000}.
3589
3590@item width_type, t
3591Set method to specify band-width of filter.
3592@table @option
3593@item h
3594Hz
3595@item q
3596Q-Factor
3597@item o
3598octave
3599@item s
3600slope
3601@item k
3602kHz
3603@end table
3604
3605@item width, w
3606Specify the band-width of a filter in width_type units.
3607
3608@item mix, m
3609How much to use filtered signal in output. Default is 1.
3610Range is between 0 and 1.
3611
3612@item channels, c
3613Specify which channels to filter, by default all available are filtered.
3614
3615@item normalize, n
3616Normalize biquad coefficients, by default is disabled.
3617Enabling it will normalize magnitude response at DC to 0dB.
3618
3619@item transform, a
3620Set transform type of IIR filter.
3621@table @option
3622@item di
3623@item dii
3624@item tdi
3625@item tdii
3626@item latt
3627@item svf
3628@item zdf
3629@end table
3630
3631@item precision, r
3632Set precison of filtering.
3633@table @option
3634@item auto
3635Pick automatic sample format depending on surround filters.
3636@item s16
3637Always use signed 16-bit.
3638@item s32
3639Always use signed 32-bit.
3640@item f32
3641Always use float 32-bit.
3642@item f64
3643Always use float 64-bit.
3644@end table
3645
3646@item block_size, b
3647Set block size used for reverse IIR processing. If this value is set to high enough
3648value (higher than impulse response length truncated when reaches near zero values) filtering
3649will become linear phase otherwise if not big enough it will just produce nasty artifacts.
3650
3651Note that filter delay will be exactly this many samples when set to non-zero value.
3652@end table
3653
3654@subsection Commands
3655
3656This filter supports the following commands:
3657@table @option
3658@item frequency, f
3659Change bandreject frequency.
3660Syntax for the command is : "@var{frequency}"
3661
3662@item width_type, t
3663Change bandreject width_type.
3664Syntax for the command is : "@var{width_type}"
3665
3666@item width, w
3667Change bandreject width.
3668Syntax for the command is : "@var{width}"
3669
3670@item mix, m
3671Change bandreject mix.
3672Syntax for the command is : "@var{mix}"
3673@end table
3674
3675@section bass, lowshelf
3676
3677Boost or cut the bass (lower) frequencies of the audio using a two-pole
3678shelving filter with a response similar to that of a standard
3679hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
3680
3681The filter accepts the following options:
3682
3683@table @option
3684@item gain, g
3685Give the gain at 0 Hz. Its useful range is about -20
3686(for a large cut) to +20 (for a large boost).
3687Beware of clipping when using a positive gain.
3688
3689@item frequency, f
3690Set the filter's central frequency and so can be used
3691to extend or reduce the frequency range to be boosted or cut.
3692The default value is @code{100} Hz.
3693
3694@item width_type, t
3695Set method to specify band-width of filter.
3696@table @option
3697@item h
3698Hz
3699@item q
3700Q-Factor
3701@item o
3702octave
3703@item s
3704slope
3705@item k
3706kHz
3707@end table
3708
3709@item width, w
3710Determine how steep is the filter's shelf transition.
3711
3712@item poles, p
3713Set number of poles. Default is 2.
3714
3715@item mix, m
3716How much to use filtered signal in output. Default is 1.
3717Range is between 0 and 1.
3718
3719@item channels, c
3720Specify which channels to filter, by default all available are filtered.
3721
3722@item normalize, n
3723Normalize biquad coefficients, by default is disabled.
3724Enabling it will normalize magnitude response at DC to 0dB.
3725
3726@item transform, a
3727Set transform type of IIR filter.
3728@table @option
3729@item di
3730@item dii
3731@item tdi
3732@item tdii
3733@item latt
3734@item svf
3735@item zdf
3736@end table
3737
3738@item precision, r
3739Set precison of filtering.
3740@table @option
3741@item auto
3742Pick automatic sample format depending on surround filters.
3743@item s16
3744Always use signed 16-bit.
3745@item s32
3746Always use signed 32-bit.
3747@item f32
3748Always use float 32-bit.
3749@item f64
3750Always use float 64-bit.
3751@end table
3752
3753@item block_size, b
3754Set block size used for reverse IIR processing. If this value is set to high enough
3755value (higher than impulse response length truncated when reaches near zero values) filtering
3756will become linear phase otherwise if not big enough it will just produce nasty artifacts.
3757
3758Note that filter delay will be exactly this many samples when set to non-zero value.
3759@end table
3760
3761@subsection Commands
3762
3763This filter supports the following commands:
3764@table @option
3765@item frequency, f
3766Change bass frequency.
3767Syntax for the command is : "@var{frequency}"
3768
3769@item width_type, t
3770Change bass width_type.
3771Syntax for the command is : "@var{width_type}"
3772
3773@item width, w
3774Change bass width.
3775Syntax for the command is : "@var{width}"
3776
3777@item gain, g
3778Change bass gain.
3779Syntax for the command is : "@var{gain}"
3780
3781@item mix, m
3782Change bass mix.
3783Syntax for the command is : "@var{mix}"
3784@end table
3785
3786@section biquad
3787
3788Apply a biquad IIR filter with the given coefficients.
3789Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
3790are the numerator and denominator coefficients respectively.
3791and @var{channels}, @var{c} specify which channels to filter, by default all
3792available are filtered.
3793
3794@subsection Commands
3795
3796This filter supports the following commands:
3797@table @option
3798@item a0
3799@item a1
3800@item a2
3801@item b0
3802@item b1
3803@item b2
3804Change biquad parameter.
3805Syntax for the command is : "@var{value}"
3806
3807@item mix, m
3808How much to use filtered signal in output. Default is 1.
3809Range is between 0 and 1.
3810
3811@item channels, c
3812Specify which channels to filter, by default all available are filtered.
3813
3814@item normalize, n
3815Normalize biquad coefficients, by default is disabled.
3816Enabling it will normalize magnitude response at DC to 0dB.
3817
3818@item transform, a
3819Set transform type of IIR filter.
3820@table @option
3821@item di
3822@item dii
3823@item tdi
3824@item tdii
3825@item latt
3826@item svf
3827@item zdf
3828@end table
3829
3830@item precision, r
3831Set precison of filtering.
3832@table @option
3833@item auto
3834Pick automatic sample format depending on surround filters.
3835@item s16
3836Always use signed 16-bit.
3837@item s32
3838Always use signed 32-bit.
3839@item f32
3840Always use float 32-bit.
3841@item f64
3842Always use float 64-bit.
3843@end table
3844
3845@item block_size, b
3846Set block size used for reverse IIR processing. If this value is set to high enough
3847value (higher than impulse response length truncated when reaches near zero values) filtering
3848will become linear phase otherwise if not big enough it will just produce nasty artifacts.
3849
3850Note that filter delay will be exactly this many samples when set to non-zero value.
3851@end table
3852
3853@section bs2b
3854Bauer stereo to binaural transformation, which improves headphone listening of
3855stereo audio records.
3856
3857To enable compilation of this filter you need to configure FFmpeg with
3858@code{--enable-libbs2b}.
3859
3860It accepts the following parameters:
3861@table @option
3862
3863@item profile
3864Pre-defined crossfeed level.
3865@table @option
3866
3867@item default
3868Default level (fcut=700, feed=50).
3869
3870@item cmoy
3871Chu Moy circuit (fcut=700, feed=60).
3872
3873@item jmeier
3874Jan Meier circuit (fcut=650, feed=95).
3875
3876@end table
3877
3878@item fcut
3879Cut frequency (in Hz).
3880
3881@item feed
3882Feed level (in Hz).
3883
3884@end table
3885
3886@section channelmap
3887
3888Remap input channels to new locations.
3889
3890It accepts the following parameters:
3891@table @option
3892@item map
3893Map channels from input to output. The argument is a '|'-separated list of
3894mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
3895@var{in_channel} form. @var{in_channel} can be either the name of the input
3896channel (e.g. FL for front left) or its index in the input channel layout.
3897@var{out_channel} is the name of the output channel or its index in the output
3898channel layout. If @var{out_channel} is not given then it is implicitly an
3899index, starting with zero and increasing by one for each mapping.
3900
3901@item channel_layout
3902The channel layout of the output stream.
3903@end table
3904
3905If no mapping is present, the filter will implicitly map input channels to
3906output channels, preserving indices.
3907
3908@subsection Examples
3909
3910@itemize
3911@item
3912For example, assuming a 5.1+downmix input MOV file,
3913@example
3914ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
3915@end example
3916will create an output WAV file tagged as stereo from the downmix channels of
3917the input.
3918
3919@item
3920To fix a 5.1 WAV improperly encoded in AAC's native channel order
3921@example
3922ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:5.1' out.wav
3923@end example
3924@end itemize
3925
3926@section channelsplit
3927
3928Split each channel from an input audio stream into a separate output stream.
3929
3930It accepts the following parameters:
3931@table @option
3932@item channel_layout
3933The channel layout of the input stream. The default is "stereo".
3934@item channels
3935A channel layout describing the channels to be extracted as separate output streams
3936or "all" to extract each input channel as a separate stream. The default is "all".
3937
3938Choosing channels not present in channel layout in the input will result in an error.
3939@end table
3940
3941@subsection Examples
3942
3943@itemize
3944@item
3945For example, assuming a stereo input MP3 file,
3946@example
3947ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
3948@end example
3949will create an output Matroska file with two audio streams, one containing only
3950the left channel and the other the right channel.
3951
3952@item
3953Split a 5.1 WAV file into per-channel files:
3954@example
3955ffmpeg -i in.wav -filter_complex
3956'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
3957-map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
3958front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
3959side_right.wav
3960@end example
3961
3962@item
3963Extract only LFE from a 5.1 WAV file:
3964@example
3965ffmpeg -i in.wav -filter_complex 'channelsplit=channel_layout=5.1:channels=LFE[LFE]'
3966-map '[LFE]' lfe.wav
3967@end example
3968@end itemize
3969
3970@section chorus
3971Add a chorus effect to the audio.
3972
3973Can make a single vocal sound like a chorus, but can also be applied to instrumentation.
3974
3975Chorus resembles an echo effect with a short delay, but whereas with echo the delay is
3976constant, with chorus, it is varied using using sinusoidal or triangular modulation.
3977The modulation depth defines the range the modulated delay is played before or after
3978the delay. Hence the delayed sound will sound slower or faster, that is the delayed
3979sound tuned around the original one, like in a chorus where some vocals are slightly
3980off key.
3981
3982It accepts the following parameters:
3983@table @option
3984@item in_gain
3985Set input gain. Default is 0.4.
3986
3987@item out_gain
3988Set output gain. Default is 0.4.
3989
3990@item delays
3991Set delays. A typical delay is around 40ms to 60ms.
3992
3993@item decays
3994Set decays.
3995
3996@item speeds
3997Set speeds.
3998
3999@item depths
4000Set depths.
4001@end table
4002
4003@subsection Examples
4004
4005@itemize
4006@item
4007A single delay:
4008@example
4009chorus=0.7:0.9:55:0.4:0.25:2
4010@end example
4011
4012@item
4013Two delays:
4014@example
4015chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3
4016@end example
4017
4018@item
4019Fuller sounding chorus with three delays:
4020@example
4021chorus=0.5:0.9:50|60|40:0.4|0.32|0.3:0.25|0.4|0.3:2|2.3|1.3
4022@end example
4023@end itemize
4024
4025@section compand
4026Compress or expand the audio's dynamic range.
4027
4028It accepts the following parameters:
4029
4030@table @option
4031
4032@item attacks
4033@item decays
4034A list of times in seconds for each channel over which the instantaneous level
4035of the input signal is averaged to determine its volume. @var{attacks} refers to
4036increase of volume and @var{decays} refers to decrease of volume. For most
4037situations, the attack time (response to the audio getting louder) should be
4038shorter than the decay time, because the human ear is more sensitive to sudden
4039loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
4040a typical value for decay is 0.8 seconds.
4041If specified number of attacks & decays is lower than number of channels, the last
4042set attack/decay will be used for all remaining channels.
4043
4044@item points
4045A list of points for the transfer function, specified in dB relative to the
4046maximum possible signal amplitude. Each key points list must be defined using
4047the following syntax: @code{x0/y0|x1/y1|x2/y2|....} or
4048@code{x0/y0 x1/y1 x2/y2 ....}
4049
4050The input values must be in strictly increasing order but the transfer function
4051does not have to be monotonically rising. The point @code{0/0} is assumed but
4052may be overridden (by @code{0/out-dBn}). Typical values for the transfer
4053function are @code{-70/-70|-60/-20|1/0}.
4054
4055@item soft-knee
4056Set the curve radius in dB for all joints. It defaults to 0.01.
4057
4058@item gain
4059Set the additional gain in dB to be applied at all points on the transfer
4060function. This allows for easy adjustment of the overall gain.
4061It defaults to 0.
4062
4063@item volume
4064Set an initial volume, in dB, to be assumed for each channel when filtering
4065starts. This permits the user to supply a nominal level initially, so that, for
4066example, a very large gain is not applied to initial signal levels before the
4067companding has begun to operate. A typical value for audio which is initially
4068quiet is -90 dB. It defaults to 0.
4069
4070@item delay
4071Set a delay, in seconds. The input audio is analyzed immediately, but audio is
4072delayed before being fed to the volume adjuster. Specifying a delay
4073approximately equal to the attack/decay times allows the filter to effectively
4074operate in predictive rather than reactive mode. It defaults to 0.
4075
4076@end table
4077
4078@subsection Examples
4079
4080@itemize
4081@item
4082Make music with both quiet and loud passages suitable for listening to in a
4083noisy environment:
4084@example
4085compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
4086@end example
4087
4088Another example for audio with whisper and explosion parts:
4089@example
4090compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0
4091@end example
4092
4093@item
4094A noise gate for when the noise is at a lower level than the signal:
4095@example
4096compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
4097@end example
4098
4099@item
4100Here is another noise gate, this time for when the noise is at a higher level
4101than the signal (making it, in some ways, similar to squelch):
4102@example
4103compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
4104@end example
4105
4106@item
41072:1 compression starting at -6dB:
4108@example
4109compand=points=-80/-80|-6/-6|0/-3.8|20/3.5
4110@end example
4111
4112@item
41132:1 compression starting at -9dB:
4114@example
4115compand=points=-80/-80|-9/-9|0/-5.3|20/2.9
4116@end example
4117
4118@item
41192:1 compression starting at -12dB:
4120@example
4121compand=points=-80/-80|-12/-12|0/-6.8|20/1.9
4122@end example
4123
4124@item
41252:1 compression starting at -18dB:
4126@example
4127compand=points=-80/-80|-18/-18|0/-9.8|20/0.7
4128@end example
4129
4130@item
41313:1 compression starting at -15dB:
4132@example
4133compand=points=-80/-80|-15/-15|0/-10.8|20/-5.2
4134@end example
4135
4136@item
4137Compressor/Gate:
4138@example
4139compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6
4140@end example
4141
4142@item
4143Expander:
4144@example
4145compand=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
4146@end example
4147
4148@item
4149Hard limiter at -6dB:
4150@example
4151compand=attacks=0:points=-80/-80|-6/-6|20/-6
4152@end example
4153
4154@item
4155Hard limiter at -12dB:
4156@example
4157compand=attacks=0:points=-80/-80|-12/-12|20/-12
4158@end example
4159
4160@item
4161Hard noise gate at -35 dB:
4162@example
4163compand=attacks=0:points=-80/-115|-35.1/-80|-35/-35|20/20
4164@end example
4165
4166@item
4167Soft limiter:
4168@example
4169compand=attacks=0:points=-80/-80|-12.4/-12.4|-6/-8|0/-6.8|20/-2.8
4170@end example
4171@end itemize
4172
4173@section compensationdelay
4174
4175Compensation Delay Line is a metric based delay to compensate differing
4176positions of microphones or speakers.
4177
4178For example, you have recorded guitar with two microphones placed in
4179different locations. Because the front of sound wave has fixed speed in
4180normal conditions, the phasing of microphones can vary and depends on
4181their location and interposition. The best sound mix can be achieved when
4182these microphones are in phase (synchronized). Note that a distance of
4183~30 cm between microphones makes one microphone capture the signal in
4184antiphase to the other microphone. That makes the final mix sound moody.
4185This filter helps to solve phasing problems by adding different delays
4186to each microphone track and make them synchronized.
4187
4188The best result can be reached when you take one track as base and
4189synchronize other tracks one by one with it.
4190Remember that synchronization/delay tolerance depends on sample rate, too.
4191Higher sample rates will give more tolerance.
4192
4193The filter accepts the following parameters:
4194
4195@table @option
4196@item mm
4197Set millimeters distance. This is compensation distance for fine tuning.
4198Default is 0.
4199
4200@item cm
4201Set cm distance. This is compensation distance for tightening distance setup.
4202Default is 0.
4203
4204@item m
4205Set meters distance. This is compensation distance for hard distance setup.
4206Default is 0.
4207
4208@item dry
4209Set dry amount. Amount of unprocessed (dry) signal.
4210Default is 0.
4211
4212@item wet
4213Set wet amount. Amount of processed (wet) signal.
4214Default is 1.
4215
4216@item temp
4217Set temperature in degrees Celsius. This is the temperature of the environment.
4218Default is 20.
4219@end table
4220
4221@subsection Commands
4222
4223This filter supports the all above options as @ref{commands}.
4224
4225@section crossfeed
4226Apply headphone crossfeed filter.
4227
4228Crossfeed is the process of blending the left and right channels of stereo
4229audio recording.
4230It is mainly used to reduce extreme stereo separation of low frequencies.
4231
4232The intent is to produce more speaker like sound to the listener.
4233
4234The filter accepts the following options:
4235
4236@table @option
4237@item strength
4238Set strength of crossfeed. Default is 0.2. Allowed range is from 0 to 1.
4239This sets gain of low shelf filter for side part of stereo image.
4240Default is -6dB. Max allowed is -30db when strength is set to 1.
4241
4242@item range
4243Set soundstage wideness. Default is 0.5. Allowed range is from 0 to 1.
4244This sets cut off frequency of low shelf filter. Default is cut off near
42451550 Hz. With range set to 1 cut off frequency is set to 2100 Hz.
4246
4247@item slope
4248Set curve slope of low shelf filter. Default is 0.5.
4249Allowed range is from 0.01 to 1.
4250
4251@item level_in
4252Set input gain. Default is 0.9.
4253
4254@item level_out
4255Set output gain. Default is 1.
4256
4257@item block_size
4258Set block size used for reverse IIR processing. If this value is set to high enough
4259value (higher than impulse response length truncated when reaches near zero values) filtering
4260will become linear phase otherwise if not big enough it will just produce nasty artifacts.
4261
4262Note that filter delay will be exactly this many samples when set to non-zero value.
4263@end table
4264
4265@subsection Commands
4266
4267This filter supports the all above options as @ref{commands}.
4268
4269@section crystalizer
4270Simple algorithm for audio noise sharpening.
4271
4272This filter linearly increases differences betweeen each audio sample.
4273
4274The filter accepts the following options:
4275
4276@table @option
4277@item i
4278Sets the intensity of effect (default: 2.0). Must be in range between -10.0 to 0
4279(unchanged sound) to 10.0 (maximum effect).
4280To inverse filtering use negative value.
4281
4282@item c
4283Enable clipping. By default is enabled.
4284@end table
4285
4286@subsection Commands
4287
4288This filter supports the all above options as @ref{commands}.
4289
4290@section dcshift
4291Apply a DC shift to the audio.
4292
4293This can be useful to remove a DC offset (caused perhaps by a hardware problem
4294in the recording chain) from the audio. The effect of a DC offset is reduced
4295headroom and hence volume. The @ref{astats} filter can be used to determine if
4296a signal has a DC offset.
4297
4298@table @option
4299@item shift
4300Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift
4301the audio.
4302
4303@item limitergain
4304Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
4305used to prevent clipping.
4306@end table
4307
4308@section deesser
4309
4310Apply de-essing to the audio samples.
4311
4312@table @option
4313@item i
4314Set intensity for triggering de-essing. Allowed range is from 0 to 1.
4315Default is 0.
4316
4317@item m
4318Set amount of ducking on treble part of sound. Allowed range is from 0 to 1.
4319Default is 0.5.
4320
4321@item f
4322How much of original frequency content to keep when de-essing. Allowed range is from 0 to 1.
4323Default is 0.5.
4324
4325@item s
4326Set the output mode.
4327
4328It accepts the following values:
4329@table @option
4330@item i
4331Pass input unchanged.
4332
4333@item o
4334Pass ess filtered out.
4335
4336@item e
4337Pass only ess.
4338
4339Default value is @var{o}.
4340@end table
4341
4342@end table
4343
4344@section dialoguenhance
4345Enhance dialogue in stereo audio.
4346
4347This filter accepts stereo input and produce surround (3.0) channels output.
4348The newly produced front center channel have enhanced speech dialogue originally
4349available in both stereo channels.
4350This filter outputs front left and front right channels same as available in stereo input.
4351
4352The filter accepts the following options:
4353
4354@table @option
4355@item original
4356Set the original center factor to keep in front center channel output.
4357Allowed range is from 0 to 1. Default value is 1.
4358
4359@item enhance
4360Set the dialogue enhance factor to put in front center channel output.
4361Allowed range is from 0 to 3. Default value is 1.
4362
4363@item voice
4364Set the voice detection factor.
4365Allowed range is from 2 to 32. Default value is 2.
4366@end table
4367
4368@subsection Commands
4369
4370This filter supports the all above options as @ref{commands}.
4371
4372@section drmeter
4373Measure audio dynamic range.
4374
4375DR values of 14 and higher is found in very dynamic material. DR of 8 to 13
4376is found in transition material. And anything less that 8 have very poor dynamics
4377and is very compressed.
4378
4379The filter accepts the following options:
4380
4381@table @option
4382@item length
4383Set window length in seconds used to split audio into segments of equal length.
4384Default is 3 seconds.
4385@end table
4386
4387@section dynaudnorm
4388Dynamic Audio Normalizer.
4389
4390This filter applies a certain amount of gain to the input audio in order
4391to bring its peak magnitude to a target level (e.g. 0 dBFS). However, in
4392contrast to more "simple" normalization algorithms, the Dynamic Audio
4393Normalizer *dynamically* re-adjusts the gain factor to the input audio.
4394This allows for applying extra gain to the "quiet" sections of the audio
4395while avoiding distortions or clipping the "loud" sections. In other words:
4396The Dynamic Audio Normalizer will "even out" the volume of quiet and loud
4397sections, in the sense that the volume of each section is brought to the
4398same target level. Note, however, that the Dynamic Audio Normalizer achieves
4399this goal *without* applying "dynamic range compressing". It will retain 100%
4400of the dynamic range *within* each section of the audio file.
4401
4402@table @option
4403@item framelen, f
4404Set the frame length in milliseconds. In range from 10 to 8000 milliseconds.
4405Default is 500 milliseconds.
4406The Dynamic Audio Normalizer processes the input audio in small chunks,
4407referred to as frames. This is required, because a peak magnitude has no
4408meaning for just a single sample value. Instead, we need to determine the
4409peak magnitude for a contiguous sequence of sample values. While a "standard"
4410normalizer would simply use the peak magnitude of the complete file, the
4411Dynamic Audio Normalizer determines the peak magnitude individually for each
4412frame. The length of a frame is specified in milliseconds. By default, the
4413Dynamic Audio Normalizer uses a frame length of 500 milliseconds, which has
4414been found to give good results with most files.
4415Note that the exact frame length, in number of samples, will be determined
4416automatically, based on the sampling rate of the individual input audio file.
4417
4418@item gausssize, g
4419Set the Gaussian filter window size. In range from 3 to 301, must be odd
4420number. Default is 31.
4421Probably the most important parameter of the Dynamic Audio Normalizer is the
4422@code{window size} of the Gaussian smoothing filter. The filter's window size
4423is specified in frames, centered around the current frame. For the sake of
4424simplicity, this must be an odd number. Consequently, the default value of 31
4425takes into account the current frame, as well as the 15 preceding frames and
4426the 15 subsequent frames. Using a larger window results in a stronger
4427smoothing effect and thus in less gain variation, i.e. slower gain
4428adaptation. Conversely, using a smaller window results in a weaker smoothing
4429effect and thus in more gain variation, i.e. faster gain adaptation.
4430In other words, the more you increase this value, the more the Dynamic Audio
4431Normalizer will behave like a "traditional" normalization filter. On the
4432contrary, the more you decrease this value, the more the Dynamic Audio
4433Normalizer will behave like a dynamic range compressor.
4434
4435@item peak, p
4436Set the target peak value. This specifies the highest permissible magnitude
4437level for the normalized audio input. This filter will try to approach the
4438target peak magnitude as closely as possible, but at the same time it also
4439makes sure that the normalized signal will never exceed the peak magnitude.
4440A frame's maximum local gain factor is imposed directly by the target peak
4441magnitude. The default value is 0.95 and thus leaves a headroom of 5%*.
4442It is not recommended to go above this value.
4443
4444@item maxgain, m
4445Set the maximum gain factor. In range from 1.0 to 100.0. Default is 10.0.
4446The Dynamic Audio Normalizer determines the maximum possible (local) gain
4447factor for each input frame, i.e. the maximum gain factor that does not
4448result in clipping or distortion. The maximum gain factor is determined by
4449the frame's highest magnitude sample. However, the Dynamic Audio Normalizer
4450additionally bounds the frame's maximum gain factor by a predetermined
4451(global) maximum gain factor. This is done in order to avoid excessive gain
4452factors in "silent" or almost silent frames. By default, the maximum gain
4453factor is 10.0, For most inputs the default value should be sufficient and
4454it usually is not recommended to increase this value. Though, for input
4455with an extremely low overall volume level, it may be necessary to allow even
4456higher gain factors. Note, however, that the Dynamic Audio Normalizer does
4457not simply apply a "hard" threshold (i.e. cut off values above the threshold).
4458Instead, a "sigmoid" threshold function will be applied. This way, the
4459gain factors will smoothly approach the threshold value, but never exceed that
4460value.
4461
4462@item targetrms, r
4463Set the target RMS. In range from 0.0 to 1.0. Default is 0.0 - disabled.
4464By default, the Dynamic Audio Normalizer performs "peak" normalization.
4465This means that the maximum local gain factor for each frame is defined
4466(only) by the frame's highest magnitude sample. This way, the samples can
4467be amplified as much as possible without exceeding the maximum signal
4468level, i.e. without clipping. Optionally, however, the Dynamic Audio
4469Normalizer can also take into account the frame's root mean square,
4470abbreviated RMS. In electrical engineering, the RMS is commonly used to
4471determine the power of a time-varying signal. It is therefore considered
4472that the RMS is a better approximation of the "perceived loudness" than
4473just looking at the signal's peak magnitude. Consequently, by adjusting all
4474frames to a constant RMS value, a uniform "perceived loudness" can be
4475established. If a target RMS value has been specified, a frame's local gain
4476factor is defined as the factor that would result in exactly that RMS value.
4477Note, however, that the maximum local gain factor is still restricted by the
4478frame's highest magnitude sample, in order to prevent clipping.
4479
4480@item coupling, n
4481Enable channels coupling. By default is enabled.
4482By default, the Dynamic Audio Normalizer will amplify all channels by the same
4483amount. This means the same gain factor will be applied to all channels, i.e.
4484the maximum possible gain factor is determined by the "loudest" channel.
4485However, in some recordings, it may happen that the volume of the different
4486channels is uneven, e.g. one channel may be "quieter" than the other one(s).
4487In this case, this option can be used to disable the channel coupling. This way,
4488the gain factor will be determined independently for each channel, depending
4489only on the individual channel's highest magnitude sample. This allows for
4490harmonizing the volume of the different channels.
4491
4492@item correctdc, c
4493Enable DC bias correction. By default is disabled.
4494An audio signal (in the time domain) is a sequence of sample values.
4495In the Dynamic Audio Normalizer these sample values are represented in the
4496-1.0 to 1.0 range, regardless of the original input format. Normally, the
4497audio signal, or "waveform", should be centered around the zero point.
4498That means if we calculate the mean value of all samples in a file, or in a
4499single frame, then the result should be 0.0 or at least very close to that
4500value. If, however, there is a significant deviation of the mean value from
45010.0, in either positive or negative direction, this is referred to as a
4502DC bias or DC offset. Since a DC bias is clearly undesirable, the Dynamic
4503Audio Normalizer provides optional DC bias correction.
4504With DC bias correction enabled, the Dynamic Audio Normalizer will determine
4505the mean value, or "DC correction" offset, of each input frame and subtract
4506that value from all of the frame's sample values which ensures those samples
4507are centered around 0.0 again. Also, in order to avoid "gaps" at the frame
4508boundaries, the DC correction offset values will be interpolated smoothly
4509between neighbouring frames.
4510
4511@item altboundary, b
4512Enable alternative boundary mode. By default is disabled.
4513The Dynamic Audio Normalizer takes into account a certain neighbourhood
4514around each frame. This includes the preceding frames as well as the
4515subsequent frames. However, for the "boundary" frames, located at the very
4516beginning and at the very end of the audio file, not all neighbouring
4517frames are available. In particular, for the first few frames in the audio
4518file, the preceding frames are not known. And, similarly, for the last few
4519frames in the audio file, the subsequent frames are not known. Thus, the
4520question arises which gain factors should be assumed for the missing frames
4521in the "boundary" region. The Dynamic Audio Normalizer implements two modes
4522to deal with this situation. The default boundary mode assumes a gain factor
4523of exactly 1.0 for the missing frames, resulting in a smooth "fade in" and
4524"fade out" at the beginning and at the end of the input, respectively.
4525
4526@item compress, s
4527Set the compress factor. In range from 0.0 to 30.0. Default is 0.0.
4528By default, the Dynamic Audio Normalizer does not apply "traditional"
4529compression. This means that signal peaks will not be pruned and thus the
4530full dynamic range will be retained within each local neighbourhood. However,
4531in some cases it may be desirable to combine the Dynamic Audio Normalizer's
4532normalization algorithm with a more "traditional" compression.
4533For this purpose, the Dynamic Audio Normalizer provides an optional compression
4534(thresholding) function. If (and only if) the compression feature is enabled,
4535all input frames will be processed by a soft knee thresholding function prior
4536to the actual normalization process. Put simply, the thresholding function is
4537going to prune all samples whose magnitude exceeds a certain threshold value.
4538However, the Dynamic Audio Normalizer does not simply apply a fixed threshold
4539value. Instead, the threshold value will be adjusted for each individual
4540frame.
4541In general, smaller parameters result in stronger compression, and vice versa.
4542Values below 3.0 are not recommended, because audible distortion may appear.
4543
4544@item threshold, t
4545Set the target threshold value. This specifies the lowest permissible
4546magnitude level for the audio input which will be normalized.
4547If input frame volume is above this value frame will be normalized.
4548Otherwise frame may not be normalized at all. The default value is set
4549to 0, which means all input frames will be normalized.
4550This option is mostly useful if digital noise is not wanted to be amplified.
4551
4552@item channels, h
4553Specify which channels to filter, by default all available channels are filtered.
4554
4555@item overlap, o
4556Specify overlap for frames. If set to 0 (default) no frame overlapping is done.
4557Using >0 and <1 values will make less conservative gain adjustments, like
4558when framelen option is set to smaller value, if framelen option value is
4559compensated for non-zero overlap then gain adjustments will be smoother across time
4560compared to zero overlap case.
4561@end table
4562
4563@subsection Commands
4564
4565This filter supports the all above options as @ref{commands}.
4566
4567@section earwax
4568
4569Make audio easier to listen to on headphones.
4570
4571This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
4572so that when listened to on headphones the stereo image is moved from
4573inside your head (standard for headphones) to outside and in front of
4574the listener (standard for speakers).
4575
4576Ported from SoX.
4577
4578@section equalizer
4579
4580Apply a two-pole peaking equalisation (EQ) filter. With this
4581filter, the signal-level at and around a selected frequency can
4582be increased or decreased, whilst (unlike bandpass and bandreject
4583filters) that at all other frequencies is unchanged.
4584
4585In order to produce complex equalisation curves, this filter can
4586be given several times, each with a different central frequency.
4587
4588The filter accepts the following options:
4589
4590@table @option
4591@item frequency, f
4592Set the filter's central frequency in Hz.
4593
4594@item width_type, t
4595Set method to specify band-width of filter.
4596@table @option
4597@item h
4598Hz
4599@item q
4600Q-Factor
4601@item o
4602octave
4603@item s
4604slope
4605@item k
4606kHz
4607@end table
4608
4609@item width, w
4610Specify the band-width of a filter in width_type units.
4611
4612@item gain, g
4613Set the required gain or attenuation in dB.
4614Beware of clipping when using a positive gain.
4615
4616@item mix, m
4617How much to use filtered signal in output. Default is 1.
4618Range is between 0 and 1.
4619
4620@item channels, c
4621Specify which channels to filter, by default all available are filtered.
4622
4623@item normalize, n
4624Normalize biquad coefficients, by default is disabled.
4625Enabling it will normalize magnitude response at DC to 0dB.
4626
4627@item transform, a
4628Set transform type of IIR filter.
4629@table @option
4630@item di
4631@item dii
4632@item tdi
4633@item tdii
4634@item latt
4635@item svf
4636@item zdf
4637@end table
4638
4639@item precision, r
4640Set precison of filtering.
4641@table @option
4642@item auto
4643Pick automatic sample format depending on surround filters.
4644@item s16
4645Always use signed 16-bit.
4646@item s32
4647Always use signed 32-bit.
4648@item f32
4649Always use float 32-bit.
4650@item f64
4651Always use float 64-bit.
4652@end table
4653
4654@item block_size, b
4655Set block size used for reverse IIR processing. If this value is set to high enough
4656value (higher than impulse response length truncated when reaches near zero values) filtering
4657will become linear phase otherwise if not big enough it will just produce nasty artifacts.
4658
4659Note that filter delay will be exactly this many samples when set to non-zero value.
4660@end table
4661
4662@subsection Examples
4663@itemize
4664@item
4665Attenuate 10 dB at 1000 Hz, with a bandwidth of 200 Hz:
4666@example
4667equalizer=f=1000:t=h:width=200:g=-10
4668@end example
4669
4670@item
4671Apply 2 dB gain at 1000 Hz with Q 1 and attenuate 5 dB at 100 Hz with Q 2:
4672@example
4673equalizer=f=1000:t=q:w=1:g=2,equalizer=f=100:t=q:w=2:g=-5
4674@end example
4675@end itemize
4676
4677@subsection Commands
4678
4679This filter supports the following commands:
4680@table @option
4681@item frequency, f
4682Change equalizer frequency.
4683Syntax for the command is : "@var{frequency}"
4684
4685@item width_type, t
4686Change equalizer width_type.
4687Syntax for the command is : "@var{width_type}"
4688
4689@item width, w
4690Change equalizer width.
4691Syntax for the command is : "@var{width}"
4692
4693@item gain, g
4694Change equalizer gain.
4695Syntax for the command is : "@var{gain}"
4696
4697@item mix, m
4698Change equalizer mix.
4699Syntax for the command is : "@var{mix}"
4700@end table
4701
4702@section extrastereo
4703
4704Linearly increases the difference between left and right channels which
4705adds some sort of "live" effect to playback.
4706
4707The filter accepts the following options:
4708
4709@table @option
4710@item m
4711Sets the difference coefficient (default: 2.5). 0.0 means mono sound
4712(average of both channels), with 1.0 sound will be unchanged, with
4713-1.0 left and right channels will be swapped.
4714
4715@item c
4716Enable clipping. By default is enabled.
4717@end table
4718
4719@subsection Commands
4720
4721This filter supports the all above options as @ref{commands}.
4722
4723@section firequalizer
4724Apply FIR Equalization using arbitrary frequency response.
4725
4726The filter accepts the following option:
4727
4728@table @option
4729@item gain
4730Set gain curve equation (in dB). The expression can contain variables:
4731@table @option
4732@item f
4733the evaluated frequency
4734@item sr
4735sample rate
4736@item ch
4737channel number, set to 0 when multichannels evaluation is disabled
4738@item chid
4739channel id, see libavutil/channel_layout.h, set to the first channel id when
4740multichannels evaluation is disabled
4741@item chs
4742number of channels
4743@item chlayout
4744channel_layout, see libavutil/channel_layout.h
4745
4746@end table
4747and functions:
4748@table @option
4749@item gain_interpolate(f)
4750interpolate gain on frequency f based on gain_entry
4751@item cubic_interpolate(f)
4752same as gain_interpolate, but smoother
4753@end table
4754This option is also available as command. Default is @code{gain_interpolate(f)}.
4755
4756@item gain_entry
4757Set gain entry for gain_interpolate function. The expression can
4758contain functions:
4759@table @option
4760@item entry(f, g)
4761store gain entry at frequency f with value g
4762@end table
4763This option is also available as command.
4764
4765@item delay
4766Set filter delay in seconds. Higher value means more accurate.
4767Default is @code{0.01}.
4768
4769@item accuracy
4770Set filter accuracy in Hz. Lower value means more accurate.
4771Default is @code{5}.
4772
4773@item wfunc
4774Set window function. Acceptable values are:
4775@table @option
4776@item rectangular
4777rectangular window, useful when gain curve is already smooth
4778@item hann
4779hann window (default)
4780@item hamming
4781hamming window
4782@item blackman
4783blackman window
4784@item nuttall3
47853-terms continuous 1st derivative nuttall window
4786@item mnuttall3
4787minimum 3-terms discontinuous nuttall window
4788@item nuttall
47894-terms continuous 1st derivative nuttall window
4790@item bnuttall
4791minimum 4-terms discontinuous nuttall (blackman-nuttall) window
4792@item bharris
4793blackman-harris window
4794@item tukey
4795tukey window
4796@end table
4797
4798@item fixed
4799If enabled, use fixed number of audio samples. This improves speed when
4800filtering with large delay. Default is disabled.
4801
4802@item multi
4803Enable multichannels evaluation on gain. Default is disabled.
4804
4805@item zero_phase
4806Enable zero phase mode by subtracting timestamp to compensate delay.
4807Default is disabled.
4808
4809@item scale
4810Set scale used by gain. Acceptable values are:
4811@table @option
4812@item linlin
4813linear frequency, linear gain
4814@item linlog
4815linear frequency, logarithmic (in dB) gain (default)
4816@item loglin
4817logarithmic (in octave scale where 20 Hz is 0) frequency, linear gain
4818@item loglog
4819logarithmic frequency, logarithmic gain
4820@end table
4821
4822@item dumpfile
4823Set file for dumping, suitable for gnuplot.
4824
4825@item dumpscale
4826Set scale for dumpfile. Acceptable values are same with scale option.
4827Default is linlog.
4828
4829@item fft2
4830Enable 2-channel convolution using complex FFT. This improves speed significantly.
4831Default is disabled.
4832
4833@item min_phase
4834Enable minimum phase impulse response. Default is disabled.
4835@end table
4836
4837@subsection Examples
4838@itemize
4839@item
4840lowpass at 1000 Hz:
4841@example
4842firequalizer=gain='if(lt(f,1000), 0, -INF)'
4843@end example
4844@item
4845lowpass at 1000 Hz with gain_entry:
4846@example
4847firequalizer=gain_entry='entry(1000,0); entry(1001, -INF)'
4848@end example
4849@item
4850custom equalization:
4851@example
4852firequalizer=gain_entry='entry(100,0); entry(400, -4); entry(1000, -6); entry(2000, 0)'
4853@end example
4854@item
4855higher delay with zero phase to compensate delay:
4856@example
4857firequalizer=delay=0.1:fixed=on:zero_phase=on
4858@end example
4859@item
4860lowpass on left channel, highpass on right channel:
4861@example
4862firequalizer=gain='if(eq(chid,1), gain_interpolate(f), if(eq(chid,2), gain_interpolate(1e6+f), 0))'
4863:gain_entry='entry(1000, 0); entry(1001,-INF); entry(1e6+1000,0)':multi=on
4864@end example
4865@end itemize
4866
4867@section flanger
4868Apply a flanging effect to the audio.
4869
4870The filter accepts the following options:
4871
4872@table @option
4873@item delay
4874Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
4875
4876@item depth
4877Set added sweep delay in milliseconds. Range from 0 to 10. Default value is 2.
4878
4879@item regen
4880Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
4881Default value is 0.
4882
4883@item width
4884Set percentage of delayed signal mixed with original. Range from 0 to 100.
4885Default value is 71.
4886
4887@item speed
4888Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
4889
4890@item shape
4891Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
4892Default value is @var{sinusoidal}.
4893
4894@item phase
4895Set swept wave percentage-shift for multi channel. Range from 0 to 100.
4896Default value is 25.
4897
4898@item interp
4899Set delay-line interpolation, @var{linear} or @var{quadratic}.
4900Default is @var{linear}.
4901@end table
4902
4903@section haas
4904Apply Haas effect to audio.
4905
4906Note that this makes most sense to apply on mono signals.
4907With this filter applied to mono signals it give some directionality and
4908stretches its stereo image.
4909
4910The filter accepts the following options:
4911
4912@table @option
4913@item level_in
4914Set input level. By default is @var{1}, or 0dB
4915
4916@item level_out
4917Set output level. By default is @var{1}, or 0dB.
4918
4919@item side_gain
4920Set gain applied to side part of signal. By default is @var{1}.
4921
4922@item middle_source
4923Set kind of middle source. Can be one of the following:
4924
4925@table @samp
4926@item left
4927Pick left channel.
4928
4929@item right
4930Pick right channel.
4931
4932@item mid
4933Pick middle part signal of stereo image.
4934
4935@item side
4936Pick side part signal of stereo image.
4937@end table
4938
4939@item middle_phase
4940Change middle phase. By default is disabled.
4941
4942@item left_delay
4943Set left channel delay. By default is @var{2.05} milliseconds.
4944
4945@item left_balance
4946Set left channel balance. By default is @var{-1}.
4947
4948@item left_gain
4949Set left channel gain. By default is @var{1}.
4950
4951@item left_phase
4952Change left phase. By default is disabled.
4953
4954@item right_delay
4955Set right channel delay. By defaults is @var{2.12} milliseconds.
4956
4957@item right_balance
4958Set right channel balance. By default is @var{1}.
4959
4960@item right_gain
4961Set right channel gain. By default is @var{1}.
4962
4963@item right_phase
4964Change right phase. By default is enabled.
4965@end table
4966
4967@section hdcd
4968
4969Decodes High Definition Compatible Digital (HDCD) data. A 16-bit PCM stream with
4970embedded HDCD codes is expanded into a 20-bit PCM stream.
4971
4972The filter supports the Peak Extend and Low-level Gain Adjustment features
4973of HDCD, and detects the Transient Filter flag.
4974
4975@example
4976ffmpeg -i HDCD16.flac -af hdcd OUT24.flac
4977@end example
4978
4979When using the filter with wav, note the default encoding for wav is 16-bit,
4980so the resulting 20-bit stream will be truncated back to 16-bit. Use something
4981like @command{-acodec pcm_s24le} after the filter to get 24-bit PCM output.
4982@example
4983ffmpeg -i HDCD16.wav -af hdcd OUT16.wav
4984ffmpeg -i HDCD16.wav -af hdcd -c:a pcm_s24le OUT24.wav
4985@end example
4986
4987The filter accepts the following options:
4988
4989@table @option
4990@item disable_autoconvert
4991Disable any automatic format conversion or resampling in the filter graph.
4992
4993@item process_stereo
4994Process the stereo channels together. If target_gain does not match between
4995channels, consider it invalid and use the last valid target_gain.
4996
4997@item cdt_ms
4998Set the code detect timer period in ms.
4999
5000@item force_pe
5001Always extend peaks above -3dBFS even if PE isn't signaled.
5002
5003@item analyze_mode
5004Replace audio with a solid tone and adjust the amplitude to signal some
5005specific aspect of the decoding process. The output file can be loaded in
5006an audio editor alongside the original to aid analysis.
5007
5008@code{analyze_mode=pe:force_pe=true} can be used to see all samples above the PE level.
5009
5010Modes are:
5011@table @samp
5012@item 0, off
5013Disabled
5014@item 1, lle
5015Gain adjustment level at each sample
5016@item 2, pe
5017Samples where peak extend occurs
5018@item 3, cdt
5019Samples where the code detect timer is active
5020@item 4, tgm
5021Samples where the target gain does not match between channels
5022@end table
5023@end table
5024
5025@section headphone
5026
5027Apply head-related transfer functions (HRTFs) to create virtual
5028loudspeakers around the user for binaural listening via headphones.
5029The HRIRs are provided via additional streams, for each channel
5030one stereo input stream is needed.
5031
5032The filter accepts the following options:
5033
5034@table @option
5035@item map
5036Set mapping of input streams for convolution.
5037The argument is a '|'-separated list of channel names in order as they
5038are given as additional stream inputs for filter.
5039This also specify number of input streams. Number of input streams
5040must be not less than number of channels in first stream plus one.
5041
5042@item gain
5043Set gain applied to audio. Value is in dB. Default is 0.
5044
5045@item type
5046Set processing type. Can be @var{time} or @var{freq}. @var{time} is
5047processing audio in time domain which is slow.
5048@var{freq} is processing audio in frequency domain which is fast.
5049Default is @var{freq}.
5050
5051@item lfe
5052Set custom gain for LFE channels. Value is in dB. Default is 0.
5053
5054@item size
5055Set size of frame in number of samples which will be processed at once.
5056Default value is @var{1024}. Allowed range is from 1024 to 96000.
5057
5058@item hrir
5059Set format of hrir stream.
5060Default value is @var{stereo}. Alternative value is @var{multich}.
5061If value is set to @var{stereo}, number of additional streams should
5062be greater or equal to number of input channels in first input stream.
5063Also each additional stream should have stereo number of channels.
5064If value is set to @var{multich}, number of additional streams should
5065be exactly one. Also number of input channels of additional stream
5066should be equal or greater than twice number of channels of first input
5067stream.
5068@end table
5069
5070@subsection Examples
5071
5072@itemize
5073@item
5074Full example using wav files as coefficients with amovie filters for 7.1 downmix,
5075each amovie filter use stereo file with IR coefficients as input.
5076The files give coefficients for each position of virtual loudspeaker:
5077@example
5078ffmpeg -i input.wav
5079-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"
5080output.wav
5081@end example
5082
5083@item
5084Full example using wav files as coefficients with amovie filters for 7.1 downmix,
5085but now in @var{multich} @var{hrir} format.
5086@example
5087ffmpeg -i input.wav -filter_complex "amovie=minp.wav[hrirs];[0:a][hrirs]headphone=map=FL|FR|FC|LFE|BL|BR|SL|SR:hrir=multich"
5088output.wav
5089@end example
5090@end itemize
5091
5092@section highpass
5093
5094Apply a high-pass filter with 3dB point frequency.
5095The filter can be either single-pole, or double-pole (the default).
5096The filter roll off at 6dB per pole per octave (20dB per pole per decade).
5097
5098The filter accepts the following options:
5099
5100@table @option
5101@item frequency, f
5102Set frequency in Hz. Default is 3000.
5103
5104@item poles, p
5105Set number of poles. Default is 2.
5106
5107@item width_type, t
5108Set method to specify band-width of filter.
5109@table @option
5110@item h
5111Hz
5112@item q
5113Q-Factor
5114@item o
5115octave
5116@item s
5117slope
5118@item k
5119kHz
5120@end table
5121
5122@item width, w
5123Specify the band-width of a filter in width_type units.
5124Applies only to double-pole filter.
5125The default is 0.707q and gives a Butterworth response.
5126
5127@item mix, m
5128How much to use filtered signal in output. Default is 1.
5129Range is between 0 and 1.
5130
5131@item channels, c
5132Specify which channels to filter, by default all available are filtered.
5133
5134@item normalize, n
5135Normalize biquad coefficients, by default is disabled.
5136Enabling it will normalize magnitude response at DC to 0dB.
5137
5138@item transform, a
5139Set transform type of IIR filter.
5140@table @option
5141@item di
5142@item dii
5143@item tdi
5144@item tdii
5145@item latt
5146@item svf
5147@item zdf
5148@end table
5149
5150@item precision, r
5151Set precison of filtering.
5152@table @option
5153@item auto
5154Pick automatic sample format depending on surround filters.
5155@item s16
5156Always use signed 16-bit.
5157@item s32
5158Always use signed 32-bit.
5159@item f32
5160Always use float 32-bit.
5161@item f64
5162Always use float 64-bit.
5163@end table
5164
5165@item block_size, b
5166Set block size used for reverse IIR processing. If this value is set to high enough
5167value (higher than impulse response length truncated when reaches near zero values) filtering
5168will become linear phase otherwise if not big enough it will just produce nasty artifacts.
5169
5170Note that filter delay will be exactly this many samples when set to non-zero value.
5171@end table
5172
5173@subsection Commands
5174
5175This filter supports the following commands:
5176@table @option
5177@item frequency, f
5178Change highpass frequency.
5179Syntax for the command is : "@var{frequency}"
5180
5181@item width_type, t
5182Change highpass width_type.
5183Syntax for the command is : "@var{width_type}"
5184
5185@item width, w
5186Change highpass width.
5187Syntax for the command is : "@var{width}"
5188
5189@item mix, m
5190Change highpass mix.
5191Syntax for the command is : "@var{mix}"
5192@end table
5193
5194@section join
5195
5196Join multiple input streams into one multi-channel stream.
5197
5198It accepts the following parameters:
5199@table @option
5200
5201@item inputs
5202The number of input streams. It defaults to 2.
5203
5204@item channel_layout
5205The desired output channel layout. It defaults to stereo.
5206
5207@item map
5208Map channels from inputs to output. The argument is a '|'-separated list of
5209mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
5210form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
5211can be either the name of the input channel (e.g. FL for front left) or its
5212index in the specified input stream. @var{out_channel} is the name of the output
5213channel.
5214@end table
5215
5216The filter will attempt to guess the mappings when they are not specified
5217explicitly. It does so by first trying to find an unused matching input channel
5218and if that fails it picks the first unused input channel.
5219
5220Join 3 inputs (with properly set channel layouts):
5221@example
5222ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
5223@end example
5224
5225Build a 5.1 output from 6 single-channel streams:
5226@example
5227ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
5228'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'
5229out
5230@end example
5231
5232@section ladspa
5233
5234Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
5235
5236To enable compilation of this filter you need to configure FFmpeg with
5237@code{--enable-ladspa}.
5238
5239@table @option
5240@item file, f
5241Specifies the name of LADSPA plugin library to load. If the environment
5242variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
5243each one of the directories specified by the colon separated list in
5244@env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
5245this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
5246@file{/usr/lib/ladspa/}.
5247
5248@item plugin, p
5249Specifies the plugin within the library. Some libraries contain only
5250one plugin, but others contain many of them. If this is not set filter
5251will list all available plugins within the specified library.
5252
5253@item controls, c
5254Set the '|' separated list of controls which are zero or more floating point
5255values that determine the behavior of the loaded plugin (for example delay,
5256threshold or gain).
5257Controls need to be defined using the following syntax:
5258c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
5259@var{valuei} is the value set on the @var{i}-th control.
5260Alternatively they can be also defined using the following syntax:
5261@var{value0}|@var{value1}|@var{value2}|..., where
5262@var{valuei} is the value set on the @var{i}-th control.
5263If @option{controls} is set to @code{help}, all available controls and
5264their valid ranges are printed.
5265
5266@item sample_rate, s
5267Specify the sample rate, default to 44100. Only used if plugin have
5268zero inputs.
5269
5270@item nb_samples, n
5271Set the number of samples per channel per each output frame, default
5272is 1024. Only used if plugin have zero inputs.
5273
5274@item duration, d
5275Set the minimum duration of the sourced audio. See
5276@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
5277for the accepted syntax.
5278Note that the resulting duration may be greater than the specified duration,
5279as the generated audio is always cut at the end of a complete frame.
5280If not specified, or the expressed duration is negative, the audio is
5281supposed to be generated forever.
5282Only used if plugin have zero inputs.
5283
5284@item latency, l
5285Enable latency compensation, by default is disabled.
5286Only used if plugin have inputs.
5287@end table
5288
5289@subsection Examples
5290
5291@itemize
5292@item
5293List all available plugins within amp (LADSPA example plugin) library:
5294@example
5295ladspa=file=amp
5296@end example
5297
5298@item
5299List all available controls and their valid ranges for @code{vcf_notch}
5300plugin from @code{VCF} library:
5301@example
5302ladspa=f=vcf:p=vcf_notch:c=help
5303@end example
5304
5305@item
5306Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
5307plugin library:
5308@example
5309ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
5310@end example
5311
5312@item
5313Add reverberation to the audio using TAP-plugins
5314(Tom's Audio Processing plugins):
5315@example
5316ladspa=file=tap_reverb:tap_reverb
5317@end example
5318
5319@item
5320Generate white noise, with 0.2 amplitude:
5321@example
5322ladspa=file=cmt:noise_source_white:c=c0=.2
5323@end example
5324
5325@item
5326Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
5327@code{C* Audio Plugin Suite} (CAPS) library:
5328@example
5329ladspa=file=caps:Click:c=c1=20'
5330@end example
5331
5332@item
5333Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
5334@example
5335ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
5336@end example
5337
5338@item
5339Increase volume by 20dB using fast lookahead limiter from Steve Harris
5340@code{SWH Plugins} collection:
5341@example
5342ladspa=fast_lookahead_limiter_1913:fastLookaheadLimiter:20|0|2
5343@end example
5344
5345@item
5346Attenuate low frequencies using Multiband EQ from Steve Harris
5347@code{SWH Plugins} collection:
5348@example
5349ladspa=mbeq_1197:mbeq:-24|-24|-24|0|0|0|0|0|0|0|0|0|0|0|0
5350@end example
5351
5352@item
5353Reduce stereo image using @code{Narrower} from the @code{C* Audio Plugin Suite}
5354(CAPS) library:
5355@example
5356ladspa=caps:Narrower
5357@end example
5358
5359@item
5360Another white noise, now using @code{C* Audio Plugin Suite} (CAPS) library:
5361@example
5362ladspa=caps:White:.2
5363@end example
5364
5365@item
5366Some fractal noise, using @code{C* Audio Plugin Suite} (CAPS) library:
5367@example
5368ladspa=caps:Fractal:c=c1=1
5369@end example
5370
5371@item
5372Dynamic volume normalization using @code{VLevel} plugin:
5373@example
5374ladspa=vlevel-ladspa:vlevel_mono
5375@end example
5376@end itemize
5377
5378@subsection Commands
5379
5380This filter supports the following commands:
5381@table @option
5382@item cN
5383Modify the @var{N}-th control value.
5384
5385If the specified value is not valid, it is ignored and prior one is kept.
5386@end table
5387
5388@section loudnorm
5389
5390EBU R128 loudness normalization. Includes both dynamic and linear normalization modes.
5391Support for both single pass (livestreams, files) and double pass (files) modes.
5392This algorithm can target IL, LRA, and maximum true peak. In dynamic mode, to accurately
5393detect true peaks, the audio stream will be upsampled to 192 kHz.
5394Use the @code{-ar} option or @code{aresample} filter to explicitly set an output sample rate.
5395
5396The filter accepts the following options:
5397
5398@table @option
5399@item I, i
5400Set integrated loudness target.
5401Range is -70.0 - -5.0. Default value is -24.0.
5402
5403@item LRA, lra
5404Set loudness range target.
5405Range is 1.0 - 50.0. Default value is 7.0.
5406
5407@item TP, tp
5408Set maximum true peak.
5409Range is -9.0 - +0.0. Default value is -2.0.
5410
5411@item measured_I, measured_i
5412Measured IL of input file.
5413Range is -99.0 - +0.0.
5414
5415@item measured_LRA, measured_lra
5416Measured LRA of input file.
5417Range is  0.0 - 99.0.
5418
5419@item measured_TP, measured_tp
5420Measured true peak of input file.
5421Range is  -99.0 - +99.0.
5422
5423@item measured_thresh
5424Measured threshold of input file.
5425Range is -99.0 - +0.0.
5426
5427@item offset
5428Set offset gain. Gain is applied before the true-peak limiter.
5429Range is  -99.0 - +99.0. Default is +0.0.
5430
5431@item linear
5432Normalize by linearly scaling the source audio.
5433@code{measured_I}, @code{measured_LRA}, @code{measured_TP},
5434and @code{measured_thresh} must all be specified. Target LRA shouldn't
5435be lower than source LRA and the change in integrated loudness shouldn't
5436result in a true peak which exceeds the target TP. If any of these
5437conditions aren't met, normalization mode will revert to @var{dynamic}.
5438Options are @code{true} or @code{false}. Default is @code{true}.
5439
5440@item dual_mono
5441Treat mono input files as "dual-mono". If a mono file is intended for playback
5442on a stereo system, its EBU R128 measurement will be perceptually incorrect.
5443If set to @code{true}, this option will compensate for this effect.
5444Multi-channel input files are not affected by this option.
5445Options are true or false. Default is false.
5446
5447@item print_format
5448Set print format for stats. Options are summary, json, or none.
5449Default value is none.
5450@end table
5451
5452@section lowpass
5453
5454Apply a low-pass filter with 3dB point frequency.
5455The filter can be either single-pole or double-pole (the default).
5456The filter roll off at 6dB per pole per octave (20dB per pole per decade).
5457
5458The filter accepts the following options:
5459
5460@table @option
5461@item frequency, f
5462Set frequency in Hz. Default is 500.
5463
5464@item poles, p
5465Set number of poles. Default is 2.
5466
5467@item width_type, t
5468Set method to specify band-width of filter.
5469@table @option
5470@item h
5471Hz
5472@item q
5473Q-Factor
5474@item o
5475octave
5476@item s
5477slope
5478@item k
5479kHz
5480@end table
5481
5482@item width, w
5483Specify the band-width of a filter in width_type units.
5484Applies only to double-pole filter.
5485The default is 0.707q and gives a Butterworth response.
5486
5487@item mix, m
5488How much to use filtered signal in output. Default is 1.
5489Range is between 0 and 1.
5490
5491@item channels, c
5492Specify which channels to filter, by default all available are filtered.
5493
5494@item normalize, n
5495Normalize biquad coefficients, by default is disabled.
5496Enabling it will normalize magnitude response at DC to 0dB.
5497
5498@item transform, a
5499Set transform type of IIR filter.
5500@table @option
5501@item di
5502@item dii
5503@item tdi
5504@item tdii
5505@item latt
5506@item svf
5507@item zdf
5508@end table
5509
5510@item precision, r
5511Set precison of filtering.
5512@table @option
5513@item auto
5514Pick automatic sample format depending on surround filters.
5515@item s16
5516Always use signed 16-bit.
5517@item s32
5518Always use signed 32-bit.
5519@item f32
5520Always use float 32-bit.
5521@item f64
5522Always use float 64-bit.
5523@end table
5524
5525@item block_size, b
5526Set block size used for reverse IIR processing. If this value is set to high enough
5527value (higher than impulse response length truncated when reaches near zero values) filtering
5528will become linear phase otherwise if not big enough it will just produce nasty artifacts.
5529
5530Note that filter delay will be exactly this many samples when set to non-zero value.
5531@end table
5532
5533@subsection Examples
5534@itemize
5535@item
5536Lowpass only LFE channel, it LFE is not present it does nothing:
5537@example
5538lowpass=c=LFE
5539@end example
5540@end itemize
5541
5542@subsection Commands
5543
5544This filter supports the following commands:
5545@table @option
5546@item frequency, f
5547Change lowpass frequency.
5548Syntax for the command is : "@var{frequency}"
5549
5550@item width_type, t
5551Change lowpass width_type.
5552Syntax for the command is : "@var{width_type}"
5553
5554@item width, w
5555Change lowpass width.
5556Syntax for the command is : "@var{width}"
5557
5558@item mix, m
5559Change lowpass mix.
5560Syntax for the command is : "@var{mix}"
5561@end table
5562
5563@section lv2
5564
5565Load a LV2 (LADSPA Version 2) plugin.
5566
5567To enable compilation of this filter you need to configure FFmpeg with
5568@code{--enable-lv2}.
5569
5570@table @option
5571@item plugin, p
5572Specifies the plugin URI. You may need to escape ':'.
5573
5574@item controls, c
5575Set the '|' separated list of controls which are zero or more floating point
5576values that determine the behavior of the loaded plugin (for example delay,
5577threshold or gain).
5578If @option{controls} is set to @code{help}, all available controls and
5579their valid ranges are printed.
5580
5581@item sample_rate, s
5582Specify the sample rate, default to 44100. Only used if plugin have
5583zero inputs.
5584
5585@item nb_samples, n
5586Set the number of samples per channel per each output frame, default
5587is 1024. Only used if plugin have zero inputs.
5588
5589@item duration, d
5590Set the minimum duration of the sourced audio. See
5591@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
5592for the accepted syntax.
5593Note that the resulting duration may be greater than the specified duration,
5594as the generated audio is always cut at the end of a complete frame.
5595If not specified, or the expressed duration is negative, the audio is
5596supposed to be generated forever.
5597Only used if plugin have zero inputs.
5598@end table
5599
5600@subsection Examples
5601
5602@itemize
5603@item
5604Apply bass enhancer plugin from Calf:
5605@example
5606lv2=p=http\\\\://calf.sourceforge.net/plugins/BassEnhancer:c=amount=2
5607@end example
5608
5609@item
5610Apply vinyl plugin from Calf:
5611@example
5612lv2=p=http\\\\://calf.sourceforge.net/plugins/Vinyl:c=drone=0.2|aging=0.5
5613@end example
5614
5615@item
5616Apply bit crusher plugin from ArtyFX:
5617@example
5618lv2=p=http\\\\://www.openavproductions.com/artyfx#bitta:c=crush=0.3
5619@end example
5620@end itemize
5621
5622@subsection Commands
5623
5624This filter supports all options that are exported by plugin as commands.
5625
5626@section mcompand
5627Multiband Compress or expand the audio's dynamic range.
5628
5629The input audio is divided into bands using 4th order Linkwitz-Riley IIRs.
5630This is akin to the crossover of a loudspeaker, and results in flat frequency
5631response when absent compander action.
5632
5633It accepts the following parameters:
5634
5635@table @option
5636@item args
5637This option syntax is:
5638attack,decay,[attack,decay..] soft-knee points crossover_frequency [delay [initial_volume [gain]]] | attack,decay ...
5639For explanation of each item refer to compand filter documentation.
5640@end table
5641
5642@anchor{pan}
5643@section pan
5644
5645Mix channels with specific gain levels. The filter accepts the output
5646channel layout followed by a set of channels definitions.
5647
5648This filter is also designed to efficiently remap the channels of an audio
5649stream.
5650
5651The filter accepts parameters of the form:
5652"@var{l}|@var{outdef}|@var{outdef}|..."
5653
5654@table @option
5655@item l
5656output channel layout or number of channels
5657
5658@item outdef
5659output channel specification, of the form:
5660"@var{out_name}=[@var{gain}*]@var{in_name}[(+-)[@var{gain}*]@var{in_name}...]"
5661
5662@item out_name
5663output channel to define, either a channel name (FL, FR, etc.) or a channel
5664number (c0, c1, etc.)
5665
5666@item gain
5667multiplicative coefficient for the channel, 1 leaving the volume unchanged
5668
5669@item in_name
5670input channel to use, see out_name for details; it is not possible to mix
5671named and numbered input channels
5672@end table
5673
5674If the `=' in a channel specification is replaced by `<', then the gains for
5675that specification will be renormalized so that the total is 1, thus
5676avoiding clipping noise.
5677
5678@subsection Mixing examples
5679
5680For example, if you want to down-mix from stereo to mono, but with a bigger
5681factor for the left channel:
5682@example
5683pan=1c|c0=0.9*c0+0.1*c1
5684@end example
5685
5686A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
56877-channels surround:
5688@example
5689pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
5690@end example
5691
5692Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
5693that should be preferred (see "-ac" option) unless you have very specific
5694needs.
5695
5696@subsection Remapping examples
5697
5698The channel remapping will be effective if, and only if:
5699
5700@itemize
5701@item gain coefficients are zeroes or ones,
5702@item only one input per channel output,
5703@end itemize
5704
5705If all these conditions are satisfied, the filter will notify the user ("Pure
5706channel mapping detected"), and use an optimized and lossless method to do the
5707remapping.
5708
5709For example, if you have a 5.1 source and want a stereo audio stream by
5710dropping the extra channels:
5711@example
5712pan="stereo| c0=FL | c1=FR"
5713@end example
5714
5715Given the same source, you can also switch front left and front right channels
5716and keep the input channel layout:
5717@example
5718pan="5.1| c0=c1 | c1=c0 | c2=c2 | c3=c3 | c4=c4 | c5=c5"
5719@end example
5720
5721If the input is a stereo audio stream, you can mute the front left channel (and
5722still keep the stereo channel layout) with:
5723@example
5724pan="stereo|c1=c1"
5725@end example
5726
5727Still with a stereo audio stream input, you can copy the right channel in both
5728front left and right:
5729@example
5730pan="stereo| c0=FR | c1=FR"
5731@end example
5732
5733@section replaygain
5734
5735ReplayGain scanner filter. This filter takes an audio stream as an input and
5736outputs it unchanged.
5737At end of filtering it displays @code{track_gain} and @code{track_peak}.
5738
5739@section resample
5740
5741Convert the audio sample format, sample rate and channel layout. It is
5742not meant to be used directly.
5743
5744@section rubberband
5745Apply time-stretching and pitch-shifting with librubberband.
5746
5747To enable compilation of this filter, you need to configure FFmpeg with
5748@code{--enable-librubberband}.
5749
5750The filter accepts the following options:
5751
5752@table @option
5753@item tempo
5754Set tempo scale factor.
5755
5756@item pitch
5757Set pitch scale factor.
5758
5759@item transients
5760Set transients detector.
5761Possible values are:
5762@table @var
5763@item crisp
5764@item mixed
5765@item smooth
5766@end table
5767
5768@item detector
5769Set detector.
5770Possible values are:
5771@table @var
5772@item compound
5773@item percussive
5774@item soft
5775@end table
5776
5777@item phase
5778Set phase.
5779Possible values are:
5780@table @var
5781@item laminar
5782@item independent
5783@end table
5784
5785@item window
5786Set processing window size.
5787Possible values are:
5788@table @var
5789@item standard
5790@item short
5791@item long
5792@end table
5793
5794@item smoothing
5795Set smoothing.
5796Possible values are:
5797@table @var
5798@item off
5799@item on
5800@end table
5801
5802@item formant
5803Enable formant preservation when shift pitching.
5804Possible values are:
5805@table @var
5806@item shifted
5807@item preserved
5808@end table
5809
5810@item pitchq
5811Set pitch quality.
5812Possible values are:
5813@table @var
5814@item quality
5815@item speed
5816@item consistency
5817@end table
5818
5819@item channels
5820Set channels.
5821Possible values are:
5822@table @var
5823@item apart
5824@item together
5825@end table
5826@end table
5827
5828@subsection Commands
5829
5830This filter supports the following commands:
5831@table @option
5832@item tempo
5833Change filter tempo scale factor.
5834Syntax for the command is : "@var{tempo}"
5835
5836@item pitch
5837Change filter pitch scale factor.
5838Syntax for the command is : "@var{pitch}"
5839@end table
5840
5841@section sidechaincompress
5842
5843This filter acts like normal compressor but has the ability to compress
5844detected signal using second input signal.
5845It needs two input streams and returns one output stream.
5846First input stream will be processed depending on second stream signal.
5847The filtered signal then can be filtered with other filters in later stages of
5848processing. See @ref{pan} and @ref{amerge} filter.
5849
5850The filter accepts the following options:
5851
5852@table @option
5853@item level_in
5854Set input gain. Default is 1. Range is between 0.015625 and 64.
5855
5856@item mode
5857Set mode of compressor operation. Can be @code{upward} or @code{downward}.
5858Default is @code{downward}.
5859
5860@item threshold
5861If a signal of second stream raises above this level it will affect the gain
5862reduction of first stream.
5863By default is 0.125. Range is between 0.00097563 and 1.
5864
5865@item ratio
5866Set a ratio about which the signal is reduced. 1:2 means that if the level
5867raised 4dB above the threshold, it will be only 2dB above after the reduction.
5868Default is 2. Range is between 1 and 20.
5869
5870@item attack
5871Amount of milliseconds the signal has to rise above the threshold before gain
5872reduction starts. Default is 20. Range is between 0.01 and 2000.
5873
5874@item release
5875Amount of milliseconds the signal has to fall below the threshold before
5876reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
5877
5878@item makeup
5879Set the amount by how much signal will be amplified after processing.
5880Default is 1. Range is from 1 to 64.
5881
5882@item knee
5883Curve the sharp knee around the threshold to enter gain reduction more softly.
5884Default is 2.82843. Range is between 1 and 8.
5885
5886@item link
5887Choose if the @code{average} level between all channels of side-chain stream
5888or the louder(@code{maximum}) channel of side-chain stream affects the
5889reduction. Default is @code{average}.
5890
5891@item detection
5892Should the exact signal be taken in case of @code{peak} or an RMS one in case
5893of @code{rms}. Default is @code{rms} which is mainly smoother.
5894
5895@item level_sc
5896Set sidechain gain. Default is 1. Range is between 0.015625 and 64.
5897
5898@item mix
5899How much to use compressed signal in output. Default is 1.
5900Range is between 0 and 1.
5901@end table
5902
5903@subsection Commands
5904
5905This filter supports the all above options as @ref{commands}.
5906
5907@subsection Examples
5908
5909@itemize
5910@item
5911Full ffmpeg example taking 2 audio inputs, 1st input to be compressed
5912depending on the signal of 2nd input and later compressed signal to be
5913merged with 2nd input:
5914@example
5915ffmpeg -i main.flac -i sidechain.flac -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge"
5916@end example
5917@end itemize
5918
5919@section sidechaingate
5920
5921A sidechain gate acts like a normal (wideband) gate but has the ability to
5922filter the detected signal before sending it to the gain reduction stage.
5923Normally a gate uses the full range signal to detect a level above the
5924threshold.
5925For example: If you cut all lower frequencies from your sidechain signal
5926the gate will decrease the volume of your track only if not enough highs
5927appear. With this technique you are able to reduce the resonation of a
5928natural drum or remove "rumbling" of muted strokes from a heavily distorted
5929guitar.
5930It needs two input streams and returns one output stream.
5931First input stream will be processed depending on second stream signal.
5932
5933The filter accepts the following options:
5934
5935@table @option
5936@item level_in
5937Set input level before filtering.
5938Default is 1. Allowed range is from 0.015625 to 64.
5939
5940@item mode
5941Set the mode of operation. Can be @code{upward} or @code{downward}.
5942Default is @code{downward}. If set to @code{upward} mode, higher parts of signal
5943will be amplified, expanding dynamic range in upward direction.
5944Otherwise, in case of @code{downward} lower parts of signal will be reduced.
5945
5946@item range
5947Set the level of gain reduction when the signal is below the threshold.
5948Default is 0.06125. Allowed range is from 0 to 1.
5949Setting this to 0 disables reduction and then filter behaves like expander.
5950
5951@item threshold
5952If a signal rises above this level the gain reduction is released.
5953Default is 0.125. Allowed range is from 0 to 1.
5954
5955@item ratio
5956Set a ratio about which the signal is reduced.
5957Default is 2. Allowed range is from 1 to 9000.
5958
5959@item attack
5960Amount of milliseconds the signal has to rise above the threshold before gain
5961reduction stops.
5962Default is 20 milliseconds. Allowed range is from 0.01 to 9000.
5963
5964@item release
5965Amount of milliseconds the signal has to fall below the threshold before the
5966reduction is increased again. Default is 250 milliseconds.
5967Allowed range is from 0.01 to 9000.
5968
5969@item makeup
5970Set amount of amplification of signal after processing.
5971Default is 1. Allowed range is from 1 to 64.
5972
5973@item knee
5974Curve the sharp knee around the threshold to enter gain reduction more softly.
5975Default is 2.828427125. Allowed range is from 1 to 8.
5976
5977@item detection
5978Choose if exact signal should be taken for detection or an RMS like one.
5979Default is rms. Can be peak or rms.
5980
5981@item link
5982Choose if the average level between all channels or the louder channel affects
5983the reduction.
5984Default is average. Can be average or maximum.
5985
5986@item level_sc
5987Set sidechain gain. Default is 1. Range is from 0.015625 to 64.
5988@end table
5989
5990@subsection Commands
5991
5992This filter supports the all above options as @ref{commands}.
5993
5994@section silencedetect
5995
5996Detect silence in an audio stream.
5997
5998This filter logs a message when it detects that the input audio volume is less
5999or equal to a noise tolerance value for a duration greater or equal to the
6000minimum detected noise duration.
6001
6002The printed times and duration are expressed in seconds. The
6003@code{lavfi.silence_start} or @code{lavfi.silence_start.X} metadata key
6004is set on the first frame whose timestamp equals or exceeds the detection
6005duration and it contains the timestamp of the first frame of the silence.
6006
6007The @code{lavfi.silence_duration} or @code{lavfi.silence_duration.X}
6008and @code{lavfi.silence_end} or @code{lavfi.silence_end.X} metadata
6009keys are set on the first frame after the silence. If @option{mono} is
6010enabled, and each channel is evaluated separately, the @code{.X}
6011suffixed keys are used, and @code{X} corresponds to the channel number.
6012
6013The filter accepts the following options:
6014
6015@table @option
6016@item noise, n
6017Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
6018specified value) or amplitude ratio. Default is -60dB, or 0.001.
6019
6020@item duration, d
6021Set silence duration until notification (default is 2 seconds). See
6022@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
6023for the accepted syntax.
6024
6025@item mono, m
6026Process each channel separately, instead of combined. By default is disabled.
6027@end table
6028
6029@subsection Examples
6030
6031@itemize
6032@item
6033Detect 5 seconds of silence with -50dB noise tolerance:
6034@example
6035silencedetect=n=-50dB:d=5
6036@end example
6037
6038@item
6039Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
6040tolerance in @file{silence.mp3}:
6041@example
6042ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
6043@end example
6044@end itemize
6045
6046@section silenceremove
6047
6048Remove silence from the beginning, middle or end of the audio.
6049
6050The filter accepts the following options:
6051
6052@table @option
6053@item start_periods
6054This value is used to indicate if audio should be trimmed at beginning of
6055the audio. A value of zero indicates no silence should be trimmed from the
6056beginning. When specifying a non-zero value, it trims audio up until it
6057finds non-silence. Normally, when trimming silence from beginning of audio
6058the @var{start_periods} will be @code{1} but it can be increased to higher
6059values to trim all audio up to specific count of non-silence periods.
6060Default value is @code{0}.
6061
6062@item start_duration
6063Specify the amount of time that non-silence must be detected before it stops
6064trimming audio. By increasing the duration, bursts of noises can be treated
6065as silence and trimmed off. Default value is @code{0}.
6066
6067@item start_threshold
6068This indicates what sample value should be treated as silence. For digital
6069audio, a value of @code{0} may be fine but for audio recorded from analog,
6070you may wish to increase the value to account for background noise.
6071Can be specified in dB (in case "dB" is appended to the specified value)
6072or amplitude ratio. Default value is @code{0}.
6073
6074@item start_silence
6075Specify max duration of silence at beginning that will be kept after
6076trimming. Default is 0, which is equal to trimming all samples detected
6077as silence.
6078
6079@item start_mode
6080Specify mode of detection of silence end in start of multi-channel audio.
6081Can be @var{any} or @var{all}. Default is @var{any}.
6082With @var{any}, any sample that is detected as non-silence will cause
6083stopped trimming of silence.
6084With @var{all}, only if all channels are detected as non-silence will cause
6085stopped trimming of silence.
6086
6087@item stop_periods
6088Set the count for trimming silence from the end of audio.
6089To remove silence from the middle of a file, specify a @var{stop_periods}
6090that is negative. This value is then treated as a positive value and is
6091used to indicate the effect should restart processing as specified by
6092@var{start_periods}, making it suitable for removing periods of silence
6093in the middle of the audio.
6094Default value is @code{0}.
6095
6096@item stop_duration
6097Specify a duration of silence that must exist before audio is not copied any
6098more. By specifying a higher duration, silence that is wanted can be left in
6099the audio.
6100Default value is @code{0}.
6101
6102@item stop_threshold
6103This is the same as @option{start_threshold} but for trimming silence from
6104the end of audio.
6105Can be specified in dB (in case "dB" is appended to the specified value)
6106or amplitude ratio. Default value is @code{0}.
6107
6108@item stop_silence
6109Specify max duration of silence at end that will be kept after
6110trimming. Default is 0, which is equal to trimming all samples detected
6111as silence.
6112
6113@item stop_mode
6114Specify mode of detection of silence start in end of multi-channel audio.
6115Can be @var{any} or @var{all}. Default is @var{any}.
6116With @var{any}, any sample that is detected as non-silence will cause
6117stopped trimming of silence.
6118With @var{all}, only if all channels are detected as non-silence will cause
6119stopped trimming of silence.
6120
6121@item detection
6122Set how is silence detected. Can be @code{rms} or @code{peak}. Second is faster
6123and works better with digital silence which is exactly 0.
6124Default value is @code{rms}.
6125
6126@item window
6127Set duration in number of seconds used to calculate size of window in number
6128of samples for detecting silence.
6129Default value is @code{0.02}. Allowed range is from @code{0} to @code{10}.
6130@end table
6131
6132@subsection Examples
6133
6134@itemize
6135@item
6136The following example shows how this filter can be used to start a recording
6137that does not contain the delay at the start which usually occurs between
6138pressing the record button and the start of the performance:
6139@example
6140silenceremove=start_periods=1:start_duration=5:start_threshold=0.02
6141@end example
6142
6143@item
6144Trim all silence encountered from beginning to end where there is more than 1
6145second of silence in audio:
6146@example
6147silenceremove=stop_periods=-1:stop_duration=1:stop_threshold=-90dB
6148@end example
6149
6150@item
6151Trim all digital silence samples, using peak detection, from beginning to end
6152where there is more than 0 samples of digital silence in audio and digital
6153silence is detected in all channels at same positions in stream:
6154@example
6155silenceremove=window=0:detection=peak:stop_mode=all:start_mode=all:stop_periods=-1:stop_threshold=0
6156@end example
6157@end itemize
6158
6159@section sofalizer
6160
6161SOFAlizer uses head-related transfer functions (HRTFs) to create virtual
6162loudspeakers around the user for binaural listening via headphones (audio
6163formats up to 9 channels supported).
6164The HRTFs are stored in SOFA files (see @url{http://www.sofacoustics.org/} for a database).
6165SOFAlizer is developed at the Acoustics Research Institute (ARI) of the
6166Austrian Academy of Sciences.
6167
6168To enable compilation of this filter you need to configure FFmpeg with
6169@code{--enable-libmysofa}.
6170
6171The filter accepts the following options:
6172
6173@table @option
6174@item sofa
6175Set the SOFA file used for rendering.
6176
6177@item gain
6178Set gain applied to audio. Value is in dB. Default is 0.
6179
6180@item rotation
6181Set rotation of virtual loudspeakers in deg. Default is 0.
6182
6183@item elevation
6184Set elevation of virtual speakers in deg. Default is 0.
6185
6186@item radius
6187Set distance in meters between loudspeakers and the listener with near-field
6188HRTFs. Default is 1.
6189
6190@item type
6191Set processing type. Can be @var{time} or @var{freq}. @var{time} is
6192processing audio in time domain which is slow.
6193@var{freq} is processing audio in frequency domain which is fast.
6194Default is @var{freq}.
6195
6196@item speakers
6197Set custom positions of virtual loudspeakers. Syntax for this option is:
6198<CH> <AZIM> <ELEV>[|<CH> <AZIM> <ELEV>|...].
6199Each virtual loudspeaker is described with short channel name following with
6200azimuth and elevation in degrees.
6201Each virtual loudspeaker description is separated by '|'.
6202For example to override front left and front right channel positions use:
6203'speakers=FL 45 15|FR 345 15'.
6204Descriptions with unrecognised channel names are ignored.
6205
6206@item lfegain
6207Set custom gain for LFE channels. Value is in dB. Default is 0.
6208
6209@item framesize
6210Set custom frame size in number of samples. Default is 1024.
6211Allowed range is from 1024 to 96000. Only used if option @samp{type}
6212is set to @var{freq}.
6213
6214@item normalize
6215Should all IRs be normalized upon importing SOFA file.
6216By default is enabled.
6217
6218@item interpolate
6219Should nearest IRs be interpolated with neighbor IRs if exact position
6220does not match. By default is disabled.
6221
6222@item minphase
6223Minphase all IRs upon loading of SOFA file. By default is disabled.
6224
6225@item anglestep
6226Set neighbor search angle step. Only used if option @var{interpolate} is enabled.
6227
6228@item radstep
6229Set neighbor search radius step. Only used if option @var{interpolate} is enabled.
6230@end table
6231
6232@subsection Examples
6233
6234@itemize
6235@item
6236Using ClubFritz6 sofa file:
6237@example
6238sofalizer=sofa=/path/to/ClubFritz6.sofa:type=freq:radius=1
6239@end example
6240
6241@item
6242Using ClubFritz12 sofa file and bigger radius with small rotation:
6243@example
6244sofalizer=sofa=/path/to/ClubFritz12.sofa:type=freq:radius=2:rotation=5
6245@end example
6246
6247@item
6248Similar as above but with custom speaker positions for front left, front right, back left and back right
6249and also with custom gain:
6250@example
6251"sofalizer=sofa=/path/to/ClubFritz6.sofa:type=freq:radius=2:speakers=FL 45|FR 315|BL 135|BR 225:gain=28"
6252@end example
6253@end itemize
6254
6255@section speechnorm
6256Speech Normalizer.
6257
6258This filter expands or compresses each half-cycle of audio samples
6259(local set of samples all above or all below zero and between two nearest zero crossings) depending
6260on threshold value, so audio reaches target peak value under conditions controlled by below options.
6261
6262The filter accepts the following options:
6263
6264@table @option
6265@item peak, p
6266Set the expansion target peak value. This specifies the highest allowed absolute amplitude
6267level for the normalized audio input. Default value is 0.95. Allowed range is from 0.0 to 1.0.
6268
6269@item expansion, e
6270Set the maximum expansion factor. Allowed range is from 1.0 to 50.0. Default value is 2.0.
6271This option controls maximum local half-cycle of samples expansion. The maximum expansion
6272would be such that local peak value reaches target peak value but never to surpass it and that
6273ratio between new and previous peak value does not surpass this option value.
6274
6275@item compression, c
6276Set the maximum compression factor. Allowed range is from 1.0 to 50.0. Default value is 2.0.
6277This option controls maximum local half-cycle of samples compression. This option is used
6278only if @option{threshold} option is set to value greater than 0.0, then in such cases
6279when local peak is lower or same as value set by @option{threshold} all samples belonging to
6280that peak's half-cycle will be compressed by current compression factor.
6281
6282@item threshold, t
6283Set the threshold value. Default value is 0.0. Allowed range is from 0.0 to 1.0.
6284This option specifies which half-cycles of samples will be compressed and which will be expanded.
6285Any half-cycle samples with their local peak value below or same as this option value will be
6286compressed by current compression factor, otherwise, if greater than threshold value they will be
6287expanded with expansion factor so that it could reach peak target value but never surpass it.
6288
6289@item raise, r
6290Set the expansion raising amount per each half-cycle of samples. Default value is 0.001.
6291Allowed range is from 0.0 to 1.0. This controls how fast expansion factor is raised per
6292each new half-cycle until it reaches @option{expansion} value.
6293Setting this options too high may lead to distortions.
6294
6295@item fall, f
6296Set the compression raising amount per each half-cycle of samples. Default value is 0.001.
6297Allowed range is from 0.0 to 1.0. This controls how fast compression factor is raised per
6298each new half-cycle until it reaches @option{compression} value.
6299
6300@item channels, h
6301Specify which channels to filter, by default all available channels are filtered.
6302
6303@item invert, i
6304Enable inverted filtering, by default is disabled. This inverts interpretation of @option{threshold}
6305option. When enabled any half-cycle of samples with their local peak value below or same as
6306@option{threshold} option will be expanded otherwise it will be compressed.
6307
6308@item link, l
6309Link channels when calculating gain applied to each filtered channel sample, by default is disabled.
6310When disabled each filtered channel gain calculation is independent, otherwise when this option
6311is enabled the minimum of all possible gains for each filtered channel is used.
6312@end table
6313
6314@subsection Commands
6315
6316This filter supports the all above options as @ref{commands}.
6317
6318@section stereotools
6319
6320This filter has some handy utilities to manage stereo signals, for converting
6321M/S stereo recordings to L/R signal while having control over the parameters
6322or spreading the stereo image of master track.
6323
6324The filter accepts the following options:
6325
6326@table @option
6327@item level_in
6328Set input level before filtering for both channels. Defaults is 1.
6329Allowed range is from 0.015625 to 64.
6330
6331@item level_out
6332Set output level after filtering for both channels. Defaults is 1.
6333Allowed range is from 0.015625 to 64.
6334
6335@item balance_in
6336Set input balance between both channels. Default is 0.
6337Allowed range is from -1 to 1.
6338
6339@item balance_out
6340Set output balance between both channels. Default is 0.
6341Allowed range is from -1 to 1.
6342
6343@item softclip
6344Enable softclipping. Results in analog distortion instead of harsh digital 0dB
6345clipping. Disabled by default.
6346
6347@item mutel
6348Mute the left channel. Disabled by default.
6349
6350@item muter
6351Mute the right channel. Disabled by default.
6352
6353@item phasel
6354Change the phase of the left channel. Disabled by default.
6355
6356@item phaser
6357Change the phase of the right channel. Disabled by default.
6358
6359@item mode
6360Set stereo mode. Available values are:
6361
6362@table @samp
6363@item lr>lr
6364Left/Right to Left/Right, this is default.
6365
6366@item lr>ms
6367Left/Right to Mid/Side.
6368
6369@item ms>lr
6370Mid/Side to Left/Right.
6371
6372@item lr>ll
6373Left/Right to Left/Left.
6374
6375@item lr>rr
6376Left/Right to Right/Right.
6377
6378@item lr>l+r
6379Left/Right to Left + Right.
6380
6381@item lr>rl
6382Left/Right to Right/Left.
6383
6384@item ms>ll
6385Mid/Side to Left/Left.
6386
6387@item ms>rr
6388Mid/Side to Right/Right.
6389
6390@item ms>rl
6391Mid/Side to Right/Left.
6392
6393@item lr>l-r
6394Left/Right to Left - Right.
6395@end table
6396
6397@item slev
6398Set level of side signal. Default is 1.
6399Allowed range is from 0.015625 to 64.
6400
6401@item sbal
6402Set balance of side signal. Default is 0.
6403Allowed range is from -1 to 1.
6404
6405@item mlev
6406Set level of the middle signal. Default is 1.
6407Allowed range is from 0.015625 to 64.
6408
6409@item mpan
6410Set middle signal pan. Default is 0. Allowed range is from -1 to 1.
6411
6412@item base
6413Set stereo base between mono and inversed channels. Default is 0.
6414Allowed range is from -1 to 1.
6415
6416@item delay
6417Set delay in milliseconds how much to delay left from right channel and
6418vice versa. Default is 0. Allowed range is from -20 to 20.
6419
6420@item sclevel
6421Set S/C level. Default is 1. Allowed range is from 1 to 100.
6422
6423@item phase
6424Set the stereo phase in degrees. Default is 0. Allowed range is from 0 to 360.
6425
6426@item bmode_in, bmode_out
6427Set balance mode for balance_in/balance_out option.
6428
6429Can be one of the following:
6430
6431@table @samp
6432@item balance
6433Classic balance mode. Attenuate one channel at time.
6434Gain is raised up to 1.
6435
6436@item amplitude
6437Similar as classic mode above but gain is raised up to 2.
6438
6439@item power
6440Equal power distribution, from -6dB to +6dB range.
6441@end table
6442@end table
6443
6444@subsection Commands
6445
6446This filter supports the all above options as @ref{commands}.
6447
6448@subsection Examples
6449
6450@itemize
6451@item
6452Apply karaoke like effect:
6453@example
6454stereotools=mlev=0.015625
6455@end example
6456
6457@item
6458Convert M/S signal to L/R:
6459@example
6460"stereotools=mode=ms>lr"
6461@end example
6462@end itemize
6463
6464@section stereowiden
6465
6466This filter enhance the stereo effect by suppressing signal common to both
6467channels and by delaying the signal of left into right and vice versa,
6468thereby widening the stereo effect.
6469
6470The filter accepts the following options:
6471
6472@table @option
6473@item delay
6474Time in milliseconds of the delay of left signal into right and vice versa.
6475Default is 20 milliseconds.
6476
6477@item feedback
6478Amount of gain in delayed signal into right and vice versa. Gives a delay
6479effect of left signal in right output and vice versa which gives widening
6480effect. Default is 0.3.
6481
6482@item crossfeed
6483Cross feed of left into right with inverted phase. This helps in suppressing
6484the mono. If the value is 1 it will cancel all the signal common to both
6485channels. Default is 0.3.
6486
6487@item drymix
6488Set level of input signal of original channel. Default is 0.8.
6489@end table
6490
6491@subsection Commands
6492
6493This filter supports the all above options except @code{delay} as @ref{commands}.
6494
6495@section superequalizer
6496Apply 18 band equalizer.
6497
6498The filter accepts the following options:
6499@table @option
6500@item 1b
6501Set 65Hz band gain.
6502@item 2b
6503Set 92Hz band gain.
6504@item 3b
6505Set 131Hz band gain.
6506@item 4b
6507Set 185Hz band gain.
6508@item 5b
6509Set 262Hz band gain.
6510@item 6b
6511Set 370Hz band gain.
6512@item 7b
6513Set 523Hz band gain.
6514@item 8b
6515Set 740Hz band gain.
6516@item 9b
6517Set 1047Hz band gain.
6518@item 10b
6519Set 1480Hz band gain.
6520@item 11b
6521Set 2093Hz band gain.
6522@item 12b
6523Set 2960Hz band gain.
6524@item 13b
6525Set 4186Hz band gain.
6526@item 14b
6527Set 5920Hz band gain.
6528@item 15b
6529Set 8372Hz band gain.
6530@item 16b
6531Set 11840Hz band gain.
6532@item 17b
6533Set 16744Hz band gain.
6534@item 18b
6535Set 20000Hz band gain.
6536@end table
6537
6538@section surround
6539Apply audio surround upmix filter.
6540
6541This filter allows to produce multichannel output from audio stream.
6542
6543The filter accepts the following options:
6544
6545@table @option
6546@item chl_out
6547Set output channel layout. By default, this is @var{5.1}.
6548
6549See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
6550for the required syntax.
6551
6552@item chl_in
6553Set input channel layout. By default, this is @var{stereo}.
6554
6555See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
6556for the required syntax.
6557
6558@item level_in
6559Set input volume level. By default, this is @var{1}.
6560
6561@item level_out
6562Set output volume level. By default, this is @var{1}.
6563
6564@item lfe
6565Enable LFE channel output if output channel layout has it. By default, this is enabled.
6566
6567@item lfe_low
6568Set LFE low cut off frequency. By default, this is @var{128} Hz.
6569
6570@item lfe_high
6571Set LFE high cut off frequency. By default, this is @var{256} Hz.
6572
6573@item lfe_mode
6574Set LFE mode, can be @var{add} or @var{sub}. Default is @var{add}.
6575In @var{add} mode, LFE channel is created from input audio and added to output.
6576In @var{sub} mode, LFE channel is created from input audio and added to output but
6577also all non-LFE output channels are subtracted with output LFE channel.
6578
6579@item angle
6580Set angle of stereo surround transform, Allowed range is from @var{0} to @var{360}.
6581Default is @var{90}.
6582
6583@item fc_in
6584Set front center input volume. By default, this is @var{1}.
6585
6586@item fc_out
6587Set front center output volume. By default, this is @var{1}.
6588
6589@item fl_in
6590Set front left input volume. By default, this is @var{1}.
6591
6592@item fl_out
6593Set front left output volume. By default, this is @var{1}.
6594
6595@item fr_in
6596Set front right input volume. By default, this is @var{1}.
6597
6598@item fr_out
6599Set front right output volume. By default, this is @var{1}.
6600
6601@item sl_in
6602Set side left input volume. By default, this is @var{1}.
6603
6604@item sl_out
6605Set side left output volume. By default, this is @var{1}.
6606
6607@item sr_in
6608Set side right input volume. By default, this is @var{1}.
6609
6610@item sr_out
6611Set side right output volume. By default, this is @var{1}.
6612
6613@item bl_in
6614Set back left input volume. By default, this is @var{1}.
6615
6616@item bl_out
6617Set back left output volume. By default, this is @var{1}.
6618
6619@item br_in
6620Set back right input volume. By default, this is @var{1}.
6621
6622@item br_out
6623Set back right output volume. By default, this is @var{1}.
6624
6625@item bc_in
6626Set back center input volume. By default, this is @var{1}.
6627
6628@item bc_out
6629Set back center output volume. By default, this is @var{1}.
6630
6631@item lfe_in
6632Set LFE input volume. By default, this is @var{1}.
6633
6634@item lfe_out
6635Set LFE output volume. By default, this is @var{1}.
6636
6637@item allx
6638Set spread usage of stereo image across X axis for all channels.
6639Allowed range is from @var{-1} to @var{15}.
6640By default this value is negative @var{-1}, and thus unused.
6641
6642@item ally
6643Set spread usage of stereo image across Y axis for all channels.
6644Allowed range is from @var{-1} to @var{15}.
6645By default this value is negative @var{-1}, and thus unused.
6646
6647@item fcx, flx, frx, blx, brx, slx, srx, bcx
6648Set spread usage of stereo image across X axis for each channel.
6649Allowed range is from @var{0.06} to @var{15}.
6650By default this value is @var{0.5}.
6651
6652@item fcy, fly, fry, bly, bry, sly, sry, bcy
6653Set spread usage of stereo image across Y axis for each channel.
6654Allowed range is from @var{0.06} to @var{15}.
6655By default this value is @var{0.5}.
6656
6657@item win_size
6658Set window size. Allowed range is from @var{1024} to @var{65536}. Default size is @var{4096}.
6659
6660@item win_func
6661Set window function.
6662
6663It accepts the following values:
6664@table @samp
6665@item rect
6666@item bartlett
6667@item hann, hanning
6668@item hamming
6669@item blackman
6670@item welch
6671@item flattop
6672@item bharris
6673@item bnuttall
6674@item bhann
6675@item sine
6676@item nuttall
6677@item lanczos
6678@item gauss
6679@item tukey
6680@item dolph
6681@item cauchy
6682@item parzen
6683@item poisson
6684@item bohman
6685@end table
6686Default is @code{hann}.
6687
6688@item overlap
6689Set window overlap. If set to 1, the recommended overlap for selected
6690window function will be picked. Default is @code{0.5}.
6691@end table
6692
6693@section tiltshelf
6694
6695Boost or cut the lower frequencies and cut or boost higher frequencies
6696of the audio using a two-pole shelving filter with a response similar to
6697that of a standard hi-fi's tone-controls.
6698This is also known as shelving equalisation (EQ).
6699
6700The filter accepts the following options:
6701
6702@table @option
6703@item gain, g
6704Give the gain at 0 Hz. Its useful range is about -20
6705(for a large cut) to +20 (for a large boost).
6706Beware of clipping when using a positive gain.
6707
6708@item frequency, f
6709Set the filter's central frequency and so can be used
6710to extend or reduce the frequency range to be boosted or cut.
6711The default value is @code{3000} Hz.
6712
6713@item width_type, t
6714Set method to specify band-width of filter.
6715@table @option
6716@item h
6717Hz
6718@item q
6719Q-Factor
6720@item o
6721octave
6722@item s
6723slope
6724@item k
6725kHz
6726@end table
6727
6728@item width, w
6729Determine how steep is the filter's shelf transition.
6730
6731@item poles, p
6732Set number of poles. Default is 2.
6733
6734@item mix, m
6735How much to use filtered signal in output. Default is 1.
6736Range is between 0 and 1.
6737
6738@item channels, c
6739Specify which channels to filter, by default all available are filtered.
6740
6741@item normalize, n
6742Normalize biquad coefficients, by default is disabled.
6743Enabling it will normalize magnitude response at DC to 0dB.
6744
6745@item transform, a
6746Set transform type of IIR filter.
6747@table @option
6748@item di
6749@item dii
6750@item tdi
6751@item tdii
6752@item latt
6753@item svf
6754@item zdf
6755@end table
6756
6757@item precision, r
6758Set precison of filtering.
6759@table @option
6760@item auto
6761Pick automatic sample format depending on surround filters.
6762@item s16
6763Always use signed 16-bit.
6764@item s32
6765Always use signed 32-bit.
6766@item f32
6767Always use float 32-bit.
6768@item f64
6769Always use float 64-bit.
6770@end table
6771
6772@item block_size, b
6773Set block size used for reverse IIR processing. If this value is set to high enough
6774value (higher than impulse response length truncated when reaches near zero values) filtering
6775will become linear phase otherwise if not big enough it will just produce nasty artifacts.
6776
6777Note that filter delay will be exactly this many samples when set to non-zero value.
6778@end table
6779
6780@subsection Commands
6781
6782This filter supports some options as @ref{commands}.
6783
6784@section treble, highshelf
6785
6786Boost or cut treble (upper) frequencies of the audio using a two-pole
6787shelving filter with a response similar to that of a standard
6788hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
6789
6790The filter accepts the following options:
6791
6792@table @option
6793@item gain, g
6794Give the gain at whichever is the lower of ~22 kHz and the
6795Nyquist frequency. Its useful range is about -20 (for a large cut)
6796to +20 (for a large boost). Beware of clipping when using a positive gain.
6797
6798@item frequency, f
6799Set the filter's central frequency and so can be used
6800to extend or reduce the frequency range to be boosted or cut.
6801The default value is @code{3000} Hz.
6802
6803@item width_type, t
6804Set method to specify band-width of filter.
6805@table @option
6806@item h
6807Hz
6808@item q
6809Q-Factor
6810@item o
6811octave
6812@item s
6813slope
6814@item k
6815kHz
6816@end table
6817
6818@item width, w
6819Determine how steep is the filter's shelf transition.
6820
6821@item poles, p
6822Set number of poles. Default is 2.
6823
6824@item mix, m
6825How much to use filtered signal in output. Default is 1.
6826Range is between 0 and 1.
6827
6828@item channels, c
6829Specify which channels to filter, by default all available are filtered.
6830
6831@item normalize, n
6832Normalize biquad coefficients, by default is disabled.
6833Enabling it will normalize magnitude response at DC to 0dB.
6834
6835@item transform, a
6836Set transform type of IIR filter.
6837@table @option
6838@item di
6839@item dii
6840@item tdi
6841@item tdii
6842@item latt
6843@item svf
6844@item zdf
6845@end table
6846
6847@item precision, r
6848Set precison of filtering.
6849@table @option
6850@item auto
6851Pick automatic sample format depending on surround filters.
6852@item s16
6853Always use signed 16-bit.
6854@item s32
6855Always use signed 32-bit.
6856@item f32
6857Always use float 32-bit.
6858@item f64
6859Always use float 64-bit.
6860@end table
6861
6862@item block_size, b
6863Set block size used for reverse IIR processing. If this value is set to high enough
6864value (higher than impulse response length truncated when reaches near zero values) filtering
6865will become linear phase otherwise if not big enough it will just produce nasty artifacts.
6866
6867Note that filter delay will be exactly this many samples when set to non-zero value.
6868@end table
6869
6870@subsection Commands
6871
6872This filter supports the following commands:
6873@table @option
6874@item frequency, f
6875Change treble frequency.
6876Syntax for the command is : "@var{frequency}"
6877
6878@item width_type, t
6879Change treble width_type.
6880Syntax for the command is : "@var{width_type}"
6881
6882@item width, w
6883Change treble width.
6884Syntax for the command is : "@var{width}"
6885
6886@item gain, g
6887Change treble gain.
6888Syntax for the command is : "@var{gain}"
6889
6890@item mix, m
6891Change treble mix.
6892Syntax for the command is : "@var{mix}"
6893@end table
6894
6895@section tremolo
6896
6897Sinusoidal amplitude modulation.
6898
6899The filter accepts the following options:
6900
6901@table @option
6902@item f
6903Modulation frequency in Hertz. Modulation frequencies in the subharmonic range
6904(20 Hz or lower) will result in a tremolo effect.
6905This filter may also be used as a ring modulator by specifying
6906a modulation frequency higher than 20 Hz.
6907Range is 0.1 - 20000.0. Default value is 5.0 Hz.
6908
6909@item d
6910Depth of modulation as a percentage. Range is 0.0 - 1.0.
6911Default value is 0.5.
6912@end table
6913
6914@section vibrato
6915
6916Sinusoidal phase modulation.
6917
6918The filter accepts the following options:
6919
6920@table @option
6921@item f
6922Modulation frequency in Hertz.
6923Range is 0.1 - 20000.0. Default value is 5.0 Hz.
6924
6925@item d
6926Depth of modulation as a percentage. Range is 0.0 - 1.0.
6927Default value is 0.5.
6928@end table
6929
6930@section virtualbass
6931
6932Apply audio Virtual Bass filter.
6933
6934This filter accepts stereo input and produce stereo with LFE (2.1) channels output.
6935The newly produced LFE channel have enhanced virtual bass originally obtained from both stereo channels.
6936This filter outputs front left and front right channels unchanged as available in stereo input.
6937
6938The filter accepts the following options:
6939
6940@table @option
6941@item cutoff
6942Set the virtual bass cutoff frequency. Default value is 250 Hz.
6943Allowed range is from 100 to 500 Hz.
6944
6945@item strength
6946Set the virtual bass strength. Allowed range is from 0.5 to 3.
6947Default value is 3.
6948@end table
6949
6950@section volume
6951
6952Adjust the input audio volume.
6953
6954It accepts the following parameters:
6955@table @option
6956
6957@item volume
6958Set audio volume expression.
6959
6960Output values are clipped to the maximum value.
6961
6962The output audio volume is given by the relation:
6963@example
6964@var{output_volume} = @var{volume} * @var{input_volume}
6965@end example
6966
6967The default value for @var{volume} is "1.0".
6968
6969@item precision
6970This parameter represents the mathematical precision.
6971
6972It determines which input sample formats will be allowed, which affects the
6973precision of the volume scaling.
6974
6975@table @option
6976@item fixed
69778-bit fixed-point; this limits input sample format to U8, S16, and S32.
6978@item float
697932-bit floating-point; this limits input sample format to FLT. (default)
6980@item double
698164-bit floating-point; this limits input sample format to DBL.
6982@end table
6983
6984@item replaygain
6985Choose the behaviour on encountering ReplayGain side data in input frames.
6986
6987@table @option
6988@item drop
6989Remove ReplayGain side data, ignoring its contents (the default).
6990
6991@item ignore
6992Ignore ReplayGain side data, but leave it in the frame.
6993
6994@item track
6995Prefer the track gain, if present.
6996
6997@item album
6998Prefer the album gain, if present.
6999@end table
7000
7001@item replaygain_preamp
7002Pre-amplification gain in dB to apply to the selected replaygain gain.
7003
7004Default value for @var{replaygain_preamp} is 0.0.
7005
7006@item replaygain_noclip
7007Prevent clipping by limiting the gain applied.
7008
7009Default value for @var{replaygain_noclip} is 1.
7010
7011@item eval
7012Set when the volume expression is evaluated.
7013
7014It accepts the following values:
7015@table @samp
7016@item once
7017only evaluate expression once during the filter initialization, or
7018when the @samp{volume} command is sent
7019
7020@item frame
7021evaluate expression for each incoming frame
7022@end table
7023
7024Default value is @samp{once}.
7025@end table
7026
7027The volume expression can contain the following parameters.
7028
7029@table @option
7030@item n
7031frame number (starting at zero)
7032@item nb_channels
7033number of channels
7034@item nb_consumed_samples
7035number of samples consumed by the filter
7036@item nb_samples
7037number of samples in the current frame
7038@item pos
7039original frame position in the file
7040@item pts
7041frame PTS
7042@item sample_rate
7043sample rate
7044@item startpts
7045PTS at start of stream
7046@item startt
7047time at start of stream
7048@item t
7049frame time
7050@item tb
7051timestamp timebase
7052@item volume
7053last set volume value
7054@end table
7055
7056Note that when @option{eval} is set to @samp{once} only the
7057@var{sample_rate} and @var{tb} variables are available, all other
7058variables will evaluate to NAN.
7059
7060@subsection Commands
7061
7062This filter supports the following commands:
7063@table @option
7064@item volume
7065Modify the volume expression.
7066The command accepts the same syntax of the corresponding option.
7067
7068If the specified expression is not valid, it is kept at its current
7069value.
7070@end table
7071
7072@subsection Examples
7073
7074@itemize
7075@item
7076Halve the input audio volume:
7077@example
7078volume=volume=0.5
7079volume=volume=1/2
7080volume=volume=-6.0206dB
7081@end example
7082
7083In all the above example the named key for @option{volume} can be
7084omitted, for example like in:
7085@example
7086volume=0.5
7087@end example
7088
7089@item
7090Increase input audio power by 6 decibels using fixed-point precision:
7091@example
7092volume=volume=6dB:precision=fixed
7093@end example
7094
7095@item
7096Fade volume after time 10 with an annihilation period of 5 seconds:
7097@example
7098volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
7099@end example
7100@end itemize
7101
7102@section volumedetect
7103
7104Detect the volume of the input video.
7105
7106The filter has no parameters. It supports only 16-bit signed integer samples,
7107so the input will be converted when needed. Statistics about the volume will
7108be printed in the log when the input stream end is reached.
7109
7110In particular it will show the mean volume (root mean square), maximum
7111volume (on a per-sample basis), and the beginning of a histogram of the
7112registered volume values (from the maximum value to a cumulated 1/1000 of
7113the samples).
7114
7115All volumes are in decibels relative to the maximum PCM value.
7116
7117@subsection Examples
7118
7119Here is an excerpt of the output:
7120@example
7121[Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
7122[Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
7123[Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
7124[Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
7125[Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
7126[Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
7127[Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
7128[Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
7129[Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
7130@end example
7131
7132It means that:
7133@itemize
7134@item
7135The mean square energy is approximately -27 dB, or 10^-2.7.
7136@item
7137The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
7138@item
7139There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
7140@end itemize
7141
7142In other words, raising the volume by +4 dB does not cause any clipping,
7143raising it by +5 dB causes clipping for 6 samples, etc.
7144
7145@c man end AUDIO FILTERS
7146
7147@chapter Audio Sources
7148@c man begin AUDIO SOURCES
7149
7150Below is a description of the currently available audio sources.
7151
7152@section abuffer
7153
7154Buffer audio frames, and make them available to the filter chain.
7155
7156This source is mainly intended for a programmatic use, in particular
7157through the interface defined in @file{libavfilter/buffersrc.h}.
7158
7159It accepts the following parameters:
7160@table @option
7161
7162@item time_base
7163The timebase which will be used for timestamps of submitted frames. It must be
7164either a floating-point number or in @var{numerator}/@var{denominator} form.
7165
7166@item sample_rate
7167The sample rate of the incoming audio buffers.
7168
7169@item sample_fmt
7170The sample format of the incoming audio buffers.
7171Either a sample format name or its corresponding integer representation from
7172the enum AVSampleFormat in @file{libavutil/samplefmt.h}
7173
7174@item channel_layout
7175The channel layout of the incoming audio buffers.
7176Either a channel layout name from channel_layout_map in
7177@file{libavutil/channel_layout.c} or its corresponding integer representation
7178from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
7179
7180@item channels
7181The number of channels of the incoming audio buffers.
7182If both @var{channels} and @var{channel_layout} are specified, then they
7183must be consistent.
7184
7185@end table
7186
7187@subsection Examples
7188
7189@example
7190abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
7191@end example
7192
7193will instruct the source to accept planar 16bit signed stereo at 44100Hz.
7194Since the sample format with name "s16p" corresponds to the number
71956 and the "stereo" channel layout corresponds to the value 0x3, this is
7196equivalent to:
7197@example
7198abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
7199@end example
7200
7201@section aevalsrc
7202
7203Generate an audio signal specified by an expression.
7204
7205This source accepts in input one or more expressions (one for each
7206channel), which are evaluated and used to generate a corresponding
7207audio signal.
7208
7209This source accepts the following options:
7210
7211@table @option
7212@item exprs
7213Set the '|'-separated expressions list for each separate channel. In case the
7214@option{channel_layout} option is not specified, the selected channel layout
7215depends on the number of provided expressions. Otherwise the last
7216specified expression is applied to the remaining output channels.
7217
7218@item channel_layout, c
7219Set the channel layout. The number of channels in the specified layout
7220must be equal to the number of specified expressions.
7221
7222@item duration, d
7223Set the minimum duration of the sourced audio. See
7224@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
7225for the accepted syntax.
7226Note that the resulting duration may be greater than the specified
7227duration, as the generated audio is always cut at the end of a
7228complete frame.
7229
7230If not specified, or the expressed duration is negative, the audio is
7231supposed to be generated forever.
7232
7233@item nb_samples, n
7234Set the number of samples per channel per each output frame,
7235default to 1024.
7236
7237@item sample_rate, s
7238Specify the sample rate, default to 44100.
7239@end table
7240
7241Each expression in @var{exprs} can contain the following constants:
7242
7243@table @option
7244@item n
7245number of the evaluated sample, starting from 0
7246
7247@item t
7248time of the evaluated sample expressed in seconds, starting from 0
7249
7250@item s
7251sample rate
7252
7253@end table
7254
7255@subsection Examples
7256
7257@itemize
7258@item
7259Generate silence:
7260@example
7261aevalsrc=0
7262@end example
7263
7264@item
7265Generate a sin signal with frequency of 440 Hz, set sample rate to
72668000 Hz:
7267@example
7268aevalsrc="sin(440*2*PI*t):s=8000"
7269@end example
7270
7271@item
7272Generate a two channels signal, specify the channel layout (Front
7273Center + Back Center) explicitly:
7274@example
7275aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
7276@end example
7277
7278@item
7279Generate white noise:
7280@example
7281aevalsrc="-2+random(0)"
7282@end example
7283
7284@item
7285Generate an amplitude modulated signal:
7286@example
7287aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
7288@end example
7289
7290@item
7291Generate 2.5 Hz binaural beats on a 360 Hz carrier:
7292@example
7293aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
7294@end example
7295
7296@end itemize
7297
7298@section afirsrc
7299
7300Generate a FIR coefficients using frequency sampling method.
7301
7302The resulting stream can be used with @ref{afir} filter for filtering the audio signal.
7303
7304The filter accepts the following options:
7305
7306@table @option
7307@item taps, t
7308Set number of filter coefficents in output audio stream.
7309Default value is 1025.
7310
7311@item frequency, f
7312Set frequency points from where magnitude and phase are set.
7313This must be in non decreasing order, and first element must be 0, while last element
7314must be 1. Elements are separated by white spaces.
7315
7316@item magnitude, m
7317Set magnitude value for every frequency point set by @option{frequency}.
7318Number of values must be same as number of frequency points.
7319Values are separated by white spaces.
7320
7321@item phase, p
7322Set phase value for every frequency point set by @option{frequency}.
7323Number of values must be same as number of frequency points.
7324Values are separated by white spaces.
7325
7326@item sample_rate, r
7327Set sample rate, default is 44100.
7328
7329@item nb_samples, n
7330Set number of samples per each frame. Default is 1024.
7331
7332@item win_func, w
7333Set window function. Default is blackman.
7334@end table
7335
7336@section anullsrc
7337
7338The null audio source, return unprocessed audio frames. It is mainly useful
7339as a template and to be employed in analysis / debugging tools, or as
7340the source for filters which ignore the input data (for example the sox
7341synth filter).
7342
7343This source accepts the following options:
7344
7345@table @option
7346
7347@item channel_layout, cl
7348
7349Specifies the channel layout, and can be either an integer or a string
7350representing a channel layout. The default value of @var{channel_layout}
7351is "stereo".
7352
7353Check the channel_layout_map definition in
7354@file{libavutil/channel_layout.c} for the mapping between strings and
7355channel layout values.
7356
7357@item sample_rate, r
7358Specifies the sample rate, and defaults to 44100.
7359
7360@item nb_samples, n
7361Set the number of samples per requested frames.
7362
7363@item duration, d
7364Set the duration of the sourced audio. See
7365@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
7366for the accepted syntax.
7367
7368If not specified, or the expressed duration is negative, the audio is
7369supposed to be generated forever.
7370@end table
7371
7372@subsection Examples
7373
7374@itemize
7375@item
7376Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
7377@example
7378anullsrc=r=48000:cl=4
7379@end example
7380
7381@item
7382Do the same operation with a more obvious syntax:
7383@example
7384anullsrc=r=48000:cl=mono
7385@end example
7386@end itemize
7387
7388All the parameters need to be explicitly defined.
7389
7390@section flite
7391
7392Synthesize a voice utterance using the libflite library.
7393
7394To enable compilation of this filter you need to configure FFmpeg with
7395@code{--enable-libflite}.
7396
7397Note that versions of the flite library prior to 2.0 are not thread-safe.
7398
7399The filter accepts the following options:
7400
7401@table @option
7402
7403@item list_voices
7404If set to 1, list the names of the available voices and exit
7405immediately. Default value is 0.
7406
7407@item nb_samples, n
7408Set the maximum number of samples per frame. Default value is 512.
7409
7410@item textfile
7411Set the filename containing the text to speak.
7412
7413@item text
7414Set the text to speak.
7415
7416@item voice, v
7417Set the voice to use for the speech synthesis. Default value is
7418@code{kal}. See also the @var{list_voices} option.
7419@end table
7420
7421@subsection Examples
7422
7423@itemize
7424@item
7425Read from file @file{speech.txt}, and synthesize the text using the
7426standard flite voice:
7427@example
7428flite=textfile=speech.txt
7429@end example
7430
7431@item
7432Read the specified text selecting the @code{slt} voice:
7433@example
7434flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
7435@end example
7436
7437@item
7438Input text to ffmpeg:
7439@example
7440ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
7441@end example
7442
7443@item
7444Make @file{ffplay} speak the specified text, using @code{flite} and
7445the @code{lavfi} device:
7446@example
7447ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
7448@end example
7449@end itemize
7450
7451For more information about libflite, check:
7452@url{http://www.festvox.org/flite/}
7453
7454@section anoisesrc
7455
7456Generate a noise audio signal.
7457
7458The filter accepts the following options:
7459
7460@table @option
7461@item sample_rate, r
7462Specify the sample rate. Default value is 48000 Hz.
7463
7464@item amplitude, a
7465Specify the amplitude (0.0 - 1.0) of the generated audio stream. Default value
7466is 1.0.
7467
7468@item duration, d
7469Specify the duration of the generated audio stream. Not specifying this option
7470results in noise with an infinite length.
7471
7472@item color, colour, c
7473Specify the color of noise. Available noise colors are white, pink, brown,
7474blue, violet and velvet. Default color is white.
7475
7476@item seed, s
7477Specify a value used to seed the PRNG.
7478
7479@item nb_samples, n
7480Set the number of samples per each output frame, default is 1024.
7481@end table
7482
7483@subsection Examples
7484
7485@itemize
7486
7487@item
7488Generate 60 seconds of pink noise, with a 44.1 kHz sampling rate and an amplitude of 0.5:
7489@example
7490anoisesrc=d=60:c=pink:r=44100:a=0.5
7491@end example
7492@end itemize
7493
7494@section hilbert
7495
7496Generate odd-tap Hilbert transform FIR coefficients.
7497
7498The resulting stream can be used with @ref{afir} filter for phase-shifting
7499the signal by 90 degrees.
7500
7501This is used in many matrix coding schemes and for analytic signal generation.
7502The process is often written as a multiplication by i (or j), the imaginary unit.
7503
7504The filter accepts the following options:
7505
7506@table @option
7507
7508@item sample_rate, s
7509Set sample rate, default is 44100.
7510
7511@item taps, t
7512Set length of FIR filter, default is 22051.
7513
7514@item nb_samples, n
7515Set number of samples per each frame.
7516
7517@item win_func, w
7518Set window function to be used when generating FIR coefficients.
7519@end table
7520
7521@section sinc
7522
7523Generate a sinc kaiser-windowed low-pass, high-pass, band-pass, or band-reject FIR coefficients.
7524
7525The resulting stream can be used with @ref{afir} filter for filtering the audio signal.
7526
7527The filter accepts the following options:
7528
7529@table @option
7530@item sample_rate, r
7531Set sample rate, default is 44100.
7532
7533@item nb_samples, n
7534Set number of samples per each frame. Default is 1024.
7535
7536@item hp
7537Set high-pass frequency. Default is 0.
7538
7539@item lp
7540Set low-pass frequency. Default is 0.
7541If high-pass frequency is lower than low-pass frequency and low-pass frequency
7542is higher than 0 then filter will create band-pass filter coefficients,
7543otherwise band-reject filter coefficients.
7544
7545@item phase
7546Set filter phase response. Default is 50. Allowed range is from 0 to 100.
7547
7548@item beta
7549Set Kaiser window beta.
7550
7551@item att
7552Set stop-band attenuation. Default is 120dB, allowed range is from 40 to 180 dB.
7553
7554@item round
7555Enable rounding, by default is disabled.
7556
7557@item hptaps
7558Set number of taps for high-pass filter.
7559
7560@item lptaps
7561Set number of taps for low-pass filter.
7562@end table
7563
7564@section sine
7565
7566Generate an audio signal made of a sine wave with amplitude 1/8.
7567
7568The audio signal is bit-exact.
7569
7570The filter accepts the following options:
7571
7572@table @option
7573
7574@item frequency, f
7575Set the carrier frequency. Default is 440 Hz.
7576
7577@item beep_factor, b
7578Enable a periodic beep every second with frequency @var{beep_factor} times
7579the carrier frequency. Default is 0, meaning the beep is disabled.
7580
7581@item sample_rate, r
7582Specify the sample rate, default is 44100.
7583
7584@item duration, d
7585Specify the duration of the generated audio stream.
7586
7587@item samples_per_frame
7588Set the number of samples per output frame.
7589
7590The expression can contain the following constants:
7591
7592@table @option
7593@item n
7594The (sequential) number of the output audio frame, starting from 0.
7595
7596@item pts
7597The PTS (Presentation TimeStamp) of the output audio frame,
7598expressed in @var{TB} units.
7599
7600@item t
7601The PTS of the output audio frame, expressed in seconds.
7602
7603@item TB
7604The timebase of the output audio frames.
7605@end table
7606
7607Default is @code{1024}.
7608@end table
7609
7610@subsection Examples
7611
7612@itemize
7613
7614@item
7615Generate a simple 440 Hz sine wave:
7616@example
7617sine
7618@end example
7619
7620@item
7621Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
7622@example
7623sine=220:4:d=5
7624sine=f=220:b=4:d=5
7625sine=frequency=220:beep_factor=4:duration=5
7626@end example
7627
7628@item
7629Generate a 1 kHz sine wave following @code{1602,1601,1602,1601,1602} NTSC
7630pattern:
7631@example
7632sine=1000:samples_per_frame='st(0,mod(n,5)); 1602-not(not(eq(ld(0),1)+eq(ld(0),3)))'
7633@end example
7634@end itemize
7635
7636@c man end AUDIO SOURCES
7637
7638@chapter Audio Sinks
7639@c man begin AUDIO SINKS
7640
7641Below is a description of the currently available audio sinks.
7642
7643@section abuffersink
7644
7645Buffer audio frames, and make them available to the end of filter chain.
7646
7647This sink is mainly intended for programmatic use, in particular
7648through the interface defined in @file{libavfilter/buffersink.h}
7649or the options system.
7650
7651It accepts a pointer to an AVABufferSinkContext structure, which
7652defines the incoming buffers' formats, to be passed as the opaque
7653parameter to @code{avfilter_init_filter} for initialization.
7654@section anullsink
7655
7656Null audio sink; do absolutely nothing with the input audio. It is
7657mainly useful as a template and for use in analysis / debugging
7658tools.
7659
7660@c man end AUDIO SINKS
7661
7662@chapter Video Filters
7663@c man begin VIDEO FILTERS
7664
7665When you configure your FFmpeg build, you can disable any of the
7666existing filters using @code{--disable-filters}.
7667The configure output will show the video filters included in your
7668build.
7669
7670Below is a description of the currently available video filters.
7671
7672@section addroi
7673
7674Mark a region of interest in a video frame.
7675
7676The frame data is passed through unchanged, but metadata is attached
7677to the frame indicating regions of interest which can affect the
7678behaviour of later encoding.  Multiple regions can be marked by
7679applying the filter multiple times.
7680
7681@table @option
7682@item x
7683Region distance in pixels from the left edge of the frame.
7684@item y
7685Region distance in pixels from the top edge of the frame.
7686@item w
7687Region width in pixels.
7688@item h
7689Region height in pixels.
7690
7691The parameters @var{x}, @var{y}, @var{w} and @var{h} are expressions,
7692and may contain the following variables:
7693@table @option
7694@item iw
7695Width of the input frame.
7696@item ih
7697Height of the input frame.
7698@end table
7699
7700@item qoffset
7701Quantisation offset to apply within the region.
7702
7703This must be a real value in the range -1 to +1.  A value of zero
7704indicates no quality change.  A negative value asks for better quality
7705(less quantisation), while a positive value asks for worse quality
7706(greater quantisation).
7707
7708The range is calibrated so that the extreme values indicate the
7709largest possible offset - if the rest of the frame is encoded with the
7710worst possible quality, an offset of -1 indicates that this region
7711should be encoded with the best possible quality anyway.  Intermediate
7712values are then interpolated in some codec-dependent way.
7713
7714For example, in 10-bit H.264 the quantisation parameter varies between
7715-12 and 51.  A typical qoffset value of -1/10 therefore indicates that
7716this region should be encoded with a QP around one-tenth of the full
7717range better than the rest of the frame.  So, if most of the frame
7718were to be encoded with a QP of around 30, this region would get a QP
7719of around 24 (an offset of approximately -1/10 * (51 - -12) = -6.3).
7720An extreme value of -1 would indicate that this region should be
7721encoded with the best possible quality regardless of the treatment of
7722the rest of the frame - that is, should be encoded at a QP of -12.
7723@item clear
7724If set to true, remove any existing regions of interest marked on the
7725frame before adding the new one.
7726@end table
7727
7728@subsection Examples
7729
7730@itemize
7731@item
7732Mark the centre quarter of the frame as interesting.
7733@example
7734addroi=iw/4:ih/4:iw/2:ih/2:-1/10
7735@end example
7736@item
7737Mark the 100-pixel-wide region on the left edge of the frame as very
7738uninteresting (to be encoded at much lower quality than the rest of
7739the frame).
7740@example
7741addroi=0:0:100:ih:+1/5
7742@end example
7743@end itemize
7744
7745@section alphaextract
7746
7747Extract the alpha component from the input as a grayscale video. This
7748is especially useful with the @var{alphamerge} filter.
7749
7750@section alphamerge
7751
7752Add or replace the alpha component of the primary input with the
7753grayscale value of a second input. This is intended for use with
7754@var{alphaextract} to allow the transmission or storage of frame
7755sequences that have alpha in a format that doesn't support an alpha
7756channel.
7757
7758For example, to reconstruct full frames from a normal YUV-encoded video
7759and a separate video created with @var{alphaextract}, you might use:
7760@example
7761movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
7762@end example
7763
7764@section amplify
7765
7766Amplify differences between current pixel and pixels of adjacent frames in
7767same pixel location.
7768
7769This filter accepts the following options:
7770
7771@table @option
7772@item radius
7773Set frame radius. Default is 2. Allowed range is from 1 to 63.
7774For example radius of 3 will instruct filter to calculate average of 7 frames.
7775
7776@item factor
7777Set factor to amplify difference. Default is 2. Allowed range is from 0 to 65535.
7778
7779@item threshold
7780Set threshold for difference amplification. Any difference greater or equal to
7781this value will not alter source pixel. Default is 10.
7782Allowed range is from 0 to 65535.
7783
7784@item tolerance
7785Set tolerance for difference amplification. Any difference lower to
7786this value will not alter source pixel. Default is 0.
7787Allowed range is from 0 to 65535.
7788
7789@item low
7790Set lower limit for changing source pixel. Default is 65535. Allowed range is from 0 to 65535.
7791This option controls maximum possible value that will decrease source pixel value.
7792
7793@item high
7794Set high limit for changing source pixel. Default is 65535. Allowed range is from 0 to 65535.
7795This option controls maximum possible value that will increase source pixel value.
7796
7797@item planes
7798Set which planes to filter. Default is all. Allowed range is from 0 to 15.
7799@end table
7800
7801@subsection Commands
7802
7803This filter supports the following @ref{commands} that corresponds to option of same name:
7804@table @option
7805@item factor
7806@item threshold
7807@item tolerance
7808@item low
7809@item high
7810@item planes
7811@end table
7812
7813@section ass
7814
7815Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
7816and libavformat to work. On the other hand, it is limited to ASS (Advanced
7817Substation Alpha) subtitles files.
7818
7819This filter accepts the following option in addition to the common options from
7820the @ref{subtitles} filter:
7821
7822@table @option
7823@item shaping
7824Set the shaping engine
7825
7826Available values are:
7827@table @samp
7828@item auto
7829The default libass shaping engine, which is the best available.
7830@item simple
7831Fast, font-agnostic shaper that can do only substitutions
7832@item complex
7833Slower shaper using OpenType for substitutions and positioning
7834@end table
7835
7836The default is @code{auto}.
7837@end table
7838
7839@section atadenoise
7840Apply an Adaptive Temporal Averaging Denoiser to the video input.
7841
7842The filter accepts the following options:
7843
7844@table @option
7845@item 0a
7846Set threshold A for 1st plane. Default is 0.02.
7847Valid range is 0 to 0.3.
7848
7849@item 0b
7850Set threshold B for 1st plane. Default is 0.04.
7851Valid range is 0 to 5.
7852
7853@item 1a
7854Set threshold A for 2nd plane. Default is 0.02.
7855Valid range is 0 to 0.3.
7856
7857@item 1b
7858Set threshold B for 2nd plane. Default is 0.04.
7859Valid range is 0 to 5.
7860
7861@item 2a
7862Set threshold A for 3rd plane. Default is 0.02.
7863Valid range is 0 to 0.3.
7864
7865@item 2b
7866Set threshold B for 3rd plane. Default is 0.04.
7867Valid range is 0 to 5.
7868
7869Threshold A is designed to react on abrupt changes in the input signal and
7870threshold B is designed to react on continuous changes in the input signal.
7871
7872@item s
7873Set number of frames filter will use for averaging. Default is 9. Must be odd
7874number in range [5, 129].
7875
7876@item p
7877Set what planes of frame filter will use for averaging. Default is all.
7878
7879@item a
7880Set what variant of algorithm filter will use for averaging. Default is @code{p} parallel.
7881Alternatively can be set to @code{s} serial.
7882
7883Parallel can be faster then serial, while other way around is never true.
7884Parallel will abort early on first change being greater then thresholds, while serial
7885will continue processing other side of frames if they are equal or below thresholds.
7886
7887@item 0s
7888@item 1s
7889@item 2s
7890Set sigma for 1st plane, 2nd plane or 3rd plane. Default is 32767.
7891Valid range is from 0 to 32767.
7892This options controls weight for each pixel in radius defined by size.
7893Default value means every pixel have same weight.
7894Setting this option to 0 effectively disables filtering.
7895@end table
7896
7897@subsection Commands
7898This filter supports same @ref{commands} as options except option @code{s}.
7899The command accepts the same syntax of the corresponding option.
7900
7901@section avgblur
7902
7903Apply average blur filter.
7904
7905The filter accepts the following options:
7906
7907@table @option
7908@item sizeX
7909Set horizontal radius size.
7910
7911@item planes
7912Set which planes to filter. By default all planes are filtered.
7913
7914@item sizeY
7915Set vertical radius size, if zero it will be same as @code{sizeX}.
7916Default is @code{0}.
7917@end table
7918
7919@subsection Commands
7920This filter supports same commands as options.
7921The command accepts the same syntax of the corresponding option.
7922
7923If the specified expression is not valid, it is kept at its current
7924value.
7925
7926@section bbox
7927
7928Compute the bounding box for the non-black pixels in the input frame
7929luminance plane.
7930
7931This filter computes the bounding box containing all the pixels with a
7932luminance value greater than the minimum allowed value.
7933The parameters describing the bounding box are printed on the filter
7934log.
7935
7936The filter accepts the following option:
7937
7938@table @option
7939@item min_val
7940Set the minimal luminance value. Default is @code{16}.
7941@end table
7942
7943@subsection Commands
7944
7945This filter supports the all above options as @ref{commands}.
7946
7947@section bilateral
7948Apply bilateral filter, spatial smoothing while preserving edges.
7949
7950The filter accepts the following options:
7951@table @option
7952@item sigmaS
7953Set sigma of gaussian function to calculate spatial weight.
7954Allowed range is 0 to 512. Default is 0.1.
7955
7956@item sigmaR
7957Set sigma of gaussian function to calculate range weight.
7958Allowed range is 0 to 1. Default is 0.1.
7959
7960@item planes
7961Set planes to filter. Default is first only.
7962@end table
7963
7964@subsection Commands
7965
7966This filter supports the all above options as @ref{commands}.
7967
7968@section bitplanenoise
7969
7970Show and measure bit plane noise.
7971
7972The filter accepts the following options:
7973
7974@table @option
7975@item bitplane
7976Set which plane to analyze. Default is @code{1}.
7977
7978@item filter
7979Filter out noisy pixels from @code{bitplane} set above.
7980Default is disabled.
7981@end table
7982
7983@section blackdetect
7984
7985Detect video intervals that are (almost) completely black. Can be
7986useful to detect chapter transitions, commercials, or invalid
7987recordings.
7988
7989The filter outputs its detection analysis to both the log as well as
7990frame metadata. If a black segment of at least the specified minimum
7991duration is found, a line with the start and end timestamps as well
7992as duration is printed to the log with level @code{info}. In addition,
7993a log line with level @code{debug} is printed per frame showing the
7994black amount detected for that frame.
7995
7996The filter also attaches metadata to the first frame of a black
7997segment with key @code{lavfi.black_start} and to the first frame
7998after the black segment ends with key @code{lavfi.black_end}. The
7999value is the frame's timestamp. This metadata is added regardless
8000of the minimum duration specified.
8001
8002The filter accepts the following options:
8003
8004@table @option
8005@item black_min_duration, d
8006Set the minimum detected black duration expressed in seconds. It must
8007be a non-negative floating point number.
8008
8009Default value is 2.0.
8010
8011@item picture_black_ratio_th, pic_th
8012Set the threshold for considering a picture "black".
8013Express the minimum value for the ratio:
8014@example
8015@var{nb_black_pixels} / @var{nb_pixels}
8016@end example
8017
8018for which a picture is considered black.
8019Default value is 0.98.
8020
8021@item pixel_black_th, pix_th
8022Set the threshold for considering a pixel "black".
8023
8024The threshold expresses the maximum pixel luminance value for which a
8025pixel is considered "black". The provided value is scaled according to
8026the following equation:
8027@example
8028@var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
8029@end example
8030
8031@var{luminance_range_size} and @var{luminance_minimum_value} depend on
8032the input video format, the range is [0-255] for YUV full-range
8033formats and [16-235] for YUV non full-range formats.
8034
8035Default value is 0.10.
8036@end table
8037
8038The following example sets the maximum pixel threshold to the minimum
8039value, and detects only black intervals of 2 or more seconds:
8040@example
8041blackdetect=d=2:pix_th=0.00
8042@end example
8043
8044@section blackframe
8045
8046Detect frames that are (almost) completely black. Can be useful to
8047detect chapter transitions or commercials. Output lines consist of
8048the frame number of the detected frame, the percentage of blackness,
8049the position in the file if known or -1 and the timestamp in seconds.
8050
8051In order to display the output lines, you need to set the loglevel at
8052least to the AV_LOG_INFO value.
8053
8054This filter exports frame metadata @code{lavfi.blackframe.pblack}.
8055The value represents the percentage of pixels in the picture that
8056are below the threshold value.
8057
8058It accepts the following parameters:
8059
8060@table @option
8061
8062@item amount
8063The percentage of the pixels that have to be below the threshold; it defaults to
8064@code{98}.
8065
8066@item threshold, thresh
8067The threshold below which a pixel value is considered black; it defaults to
8068@code{32}.
8069
8070@end table
8071
8072@anchor{blend}
8073@section blend
8074
8075Blend two video frames into each other.
8076
8077The @code{blend} filter takes two input streams and outputs one
8078stream, the first input is the "top" layer and second input is
8079"bottom" layer.  By default, the output terminates when the longest input terminates.
8080
8081The @code{tblend} (time blend) filter takes two consecutive frames
8082from one single stream, and outputs the result obtained by blending
8083the new frame on top of the old frame.
8084
8085A description of the accepted options follows.
8086
8087@table @option
8088@item c0_mode
8089@item c1_mode
8090@item c2_mode
8091@item c3_mode
8092@item all_mode
8093Set blend mode for specific pixel component or all pixel components in case
8094of @var{all_mode}. Default value is @code{normal}.
8095
8096Available values for component modes are:
8097@table @samp
8098@item addition
8099@item and
8100@item average
8101@item bleach
8102@item burn
8103@item darken
8104@item difference
8105@item divide
8106@item dodge
8107@item exclusion
8108@item extremity
8109@item freeze
8110@item geometric
8111@item glow
8112@item grainextract
8113@item grainmerge
8114@item hardlight
8115@item hardmix
8116@item hardoverlay
8117@item harmonic
8118@item heat
8119@item interpolate
8120@item lighten
8121@item linearlight
8122@item multiply
8123@item multiply128
8124@item negation
8125@item normal
8126@item or
8127@item overlay
8128@item phoenix
8129@item pinlight
8130@item reflect
8131@item screen
8132@item softdifference
8133@item softlight
8134@item stain
8135@item subtract
8136@item vividlight
8137@item xor
8138@end table
8139
8140@item c0_opacity
8141@item c1_opacity
8142@item c2_opacity
8143@item c3_opacity
8144@item all_opacity
8145Set blend opacity for specific pixel component or all pixel components in case
8146of @var{all_opacity}. Only used in combination with pixel component blend modes.
8147
8148@item c0_expr
8149@item c1_expr
8150@item c2_expr
8151@item c3_expr
8152@item all_expr
8153Set blend expression for specific pixel component or all pixel components in case
8154of @var{all_expr}. Note that related mode options will be ignored if those are set.
8155
8156The expressions can use the following variables:
8157
8158@table @option
8159@item N
8160The sequential number of the filtered frame, starting from @code{0}.
8161
8162@item X
8163@item Y
8164the coordinates of the current sample
8165
8166@item W
8167@item H
8168the width and height of currently filtered plane
8169
8170@item SW
8171@item SH
8172Width and height scale for the plane being filtered. It is the
8173ratio between the dimensions of the current plane to the luma plane,
8174e.g. for a @code{yuv420p} frame, the values are @code{1,1} for
8175the luma plane and @code{0.5,0.5} for the chroma planes.
8176
8177@item T
8178Time of the current frame, expressed in seconds.
8179
8180@item TOP, A
8181Value of pixel component at current location for first video frame (top layer).
8182
8183@item BOTTOM, B
8184Value of pixel component at current location for second video frame (bottom layer).
8185@end table
8186@end table
8187
8188The @code{blend} filter also supports the @ref{framesync} options.
8189
8190@subsection Examples
8191
8192@itemize
8193@item
8194Apply transition from bottom layer to top layer in first 10 seconds:
8195@example
8196blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
8197@end example
8198
8199@item
8200Apply linear horizontal transition from top layer to bottom layer:
8201@example
8202blend=all_expr='A*(X/W)+B*(1-X/W)'
8203@end example
8204
8205@item
8206Apply 1x1 checkerboard effect:
8207@example
8208blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
8209@end example
8210
8211@item
8212Apply uncover left effect:
8213@example
8214blend=all_expr='if(gte(N*SW+X,W),A,B)'
8215@end example
8216
8217@item
8218Apply uncover down effect:
8219@example
8220blend=all_expr='if(gte(Y-N*SH,0),A,B)'
8221@end example
8222
8223@item
8224Apply uncover up-left effect:
8225@example
8226blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
8227@end example
8228
8229@item
8230Split diagonally video and shows top and bottom layer on each side:
8231@example
8232blend=all_expr='if(gt(X,Y*(W/H)),A,B)'
8233@end example
8234
8235@item
8236Display differences between the current and the previous frame:
8237@example
8238tblend=all_mode=grainextract
8239@end example
8240@end itemize
8241
8242@subsection Commands
8243This filter supports same @ref{commands} as options.
8244
8245@anchor{blockdetect}
8246@section blockdetect
8247
8248Determines blockiness of frames without altering the input frames.
8249
8250Based on Remco Muijs and Ihor Kirenko: "A no-reference blocking artifact measure for adaptive video processing." 2005 13th European signal processing conference.
8251
8252The filter accepts the following options:
8253
8254@table @option
8255@item period_min
8256@item period_max
8257Set minimum and maximum values for determining pixel grids (periods).
8258Default values are [3,24].
8259
8260@item planes
8261Set planes to filter. Default is first only.
8262@end table
8263
8264@subsection Examples
8265
8266@itemize
8267@item
8268Determine blockiness for the first plane and search for periods within [8,32]:
8269@example
8270blockdetect=period_min=8:period_max=32:planes=1
8271@end example
8272@end itemize
8273
8274@anchor{blurdetect}
8275@section blurdetect
8276
8277Determines blurriness of frames without altering the input frames.
8278
8279Based on Marziliano, Pina, et al. "A no-reference perceptual blur metric."
8280Allows for a block-based abbreviation.
8281
8282The filter accepts the following options:
8283
8284@table @option
8285@item low
8286@item high
8287Set low and high threshold values used by the Canny thresholding
8288algorithm.
8289
8290The high threshold selects the "strong" edge pixels, which are then
8291connected through 8-connectivity with the "weak" edge pixels selected
8292by the low threshold.
8293
8294@var{low} and @var{high} threshold values must be chosen in the range
8295[0,1], and @var{low} should be lesser or equal to @var{high}.
8296
8297Default value for @var{low} is @code{20/255}, and default value for @var{high}
8298is @code{50/255}.
8299
8300@item radius
8301Define the radius to search around an edge pixel for local maxima.
8302
8303@item block_pct
8304Determine blurriness only for the most significant blocks, given in percentage.
8305
8306@item block_width
8307Determine blurriness for blocks of width @var{block_width}. If set to any value smaller 1, no blocks are used and the whole image is processed as one no matter of @var{block_height}.
8308
8309@item block_height
8310Determine blurriness for blocks of height @var{block_height}. If set to any value smaller 1, no blocks are used and the whole image is processed as one no matter of @var{block_width}.
8311
8312@item planes
8313Set planes to filter. Default is first only.
8314@end table
8315
8316@subsection Examples
8317
8318@itemize
8319@item
8320Determine blur for 80% of most significant 32x32 blocks:
8321@example
8322blurdetect=block_width=32:block_height=32:block_pct=80
8323@end example
8324@end itemize
8325
8326@section bm3d
8327
8328Denoise frames using Block-Matching 3D algorithm.
8329
8330The filter accepts the following options.
8331
8332@table @option
8333@item sigma
8334Set denoising strength. Default value is 1.
8335Allowed range is from 0 to 999.9.
8336The denoising algorithm is very sensitive to sigma, so adjust it
8337according to the source.
8338
8339@item block
8340Set local patch size. This sets dimensions in 2D.
8341
8342@item bstep
8343Set sliding step for processing blocks. Default value is 4.
8344Allowed range is from 1 to 64.
8345Smaller values allows processing more reference blocks and is slower.
8346
8347@item group
8348Set maximal number of similar blocks for 3rd dimension. Default value is 1.
8349When set to 1, no block matching is done. Larger values allows more blocks
8350in single group.
8351Allowed range is from 1 to 256.
8352
8353@item range
8354Set radius for search block matching. Default is 9.
8355Allowed range is from 1 to INT32_MAX.
8356
8357@item mstep
8358Set step between two search locations for block matching. Default is 1.
8359Allowed range is from 1 to 64. Smaller is slower.
8360
8361@item thmse
8362Set threshold of mean square error for block matching. Valid range is 0 to
8363INT32_MAX.
8364
8365@item hdthr
8366Set thresholding parameter for hard thresholding in 3D transformed domain.
8367Larger values results in stronger hard-thresholding filtering in frequency
8368domain.
8369
8370@item estim
8371Set filtering estimation mode. Can be @code{basic} or @code{final}.
8372Default is @code{basic}.
8373
8374@item ref
8375If enabled, filter will use 2nd stream for block matching.
8376Default is disabled for @code{basic} value of @var{estim} option,
8377and always enabled if value of @var{estim} is @code{final}.
8378
8379@item planes
8380Set planes to filter. Default is all available except alpha.
8381@end table
8382
8383@subsection Examples
8384
8385@itemize
8386@item
8387Basic filtering with bm3d:
8388@example
8389bm3d=sigma=3:block=4:bstep=2:group=1:estim=basic
8390@end example
8391
8392@item
8393Same as above, but filtering only luma:
8394@example
8395bm3d=sigma=3:block=4:bstep=2:group=1:estim=basic:planes=1
8396@end example
8397
8398@item
8399Same as above, but with both estimation modes:
8400@example
8401split[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
8402@end example
8403
8404@item
8405Same as above, but prefilter with @ref{nlmeans} filter instead:
8406@example
8407split[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
8408@end example
8409@end itemize
8410
8411@section boxblur
8412
8413Apply a boxblur algorithm to the input video.
8414
8415It accepts the following parameters:
8416
8417@table @option
8418
8419@item luma_radius, lr
8420@item luma_power, lp
8421@item chroma_radius, cr
8422@item chroma_power, cp
8423@item alpha_radius, ar
8424@item alpha_power, ap
8425
8426@end table
8427
8428A description of the accepted options follows.
8429
8430@table @option
8431@item luma_radius, lr
8432@item chroma_radius, cr
8433@item alpha_radius, ar
8434Set an expression for the box radius in pixels used for blurring the
8435corresponding input plane.
8436
8437The radius value must be a non-negative number, and must not be
8438greater than the value of the expression @code{min(w,h)/2} for the
8439luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
8440planes.
8441
8442Default value for @option{luma_radius} is "2". If not specified,
8443@option{chroma_radius} and @option{alpha_radius} default to the
8444corresponding value set for @option{luma_radius}.
8445
8446The expressions can contain the following constants:
8447@table @option
8448@item w
8449@item h
8450The input width and height in pixels.
8451
8452@item cw
8453@item ch
8454The input chroma image width and height in pixels.
8455
8456@item hsub
8457@item vsub
8458The horizontal and vertical chroma subsample values. For example, for the
8459pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
8460@end table
8461
8462@item luma_power, lp
8463@item chroma_power, cp
8464@item alpha_power, ap
8465Specify how many times the boxblur filter is applied to the
8466corresponding plane.
8467
8468Default value for @option{luma_power} is 2. If not specified,
8469@option{chroma_power} and @option{alpha_power} default to the
8470corresponding value set for @option{luma_power}.
8471
8472A value of 0 will disable the effect.
8473@end table
8474
8475@subsection Examples
8476
8477@itemize
8478@item
8479Apply a boxblur filter with the luma, chroma, and alpha radii
8480set to 2:
8481@example
8482boxblur=luma_radius=2:luma_power=1
8483boxblur=2:1
8484@end example
8485
8486@item
8487Set the luma radius to 2, and alpha and chroma radius to 0:
8488@example
8489boxblur=2:1:cr=0:ar=0
8490@end example
8491
8492@item
8493Set the luma and chroma radii to a fraction of the video dimension:
8494@example
8495boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
8496@end example
8497@end itemize
8498
8499@section bwdif
8500
8501Deinterlace the input video ("bwdif" stands for "Bob Weaver
8502Deinterlacing Filter").
8503
8504Motion adaptive deinterlacing based on yadif with the use of w3fdif and cubic
8505interpolation algorithms.
8506It accepts the following parameters:
8507
8508@table @option
8509@item mode
8510The interlacing mode to adopt. It accepts one of the following values:
8511
8512@table @option
8513@item 0, send_frame
8514Output one frame for each frame.
8515@item 1, send_field
8516Output one frame for each field.
8517@end table
8518
8519The default value is @code{send_field}.
8520
8521@item parity
8522The picture field parity assumed for the input interlaced video. It accepts one
8523of the following values:
8524
8525@table @option
8526@item 0, tff
8527Assume the top field is first.
8528@item 1, bff
8529Assume the bottom field is first.
8530@item -1, auto
8531Enable automatic detection of field parity.
8532@end table
8533
8534The default value is @code{auto}.
8535If the interlacing is unknown or the decoder does not export this information,
8536top field first will be assumed.
8537
8538@item deint
8539Specify which frames to deinterlace. Accepts one of the following
8540values:
8541
8542@table @option
8543@item 0, all
8544Deinterlace all frames.
8545@item 1, interlaced
8546Only deinterlace frames marked as interlaced.
8547@end table
8548
8549The default value is @code{all}.
8550@end table
8551
8552@section cas
8553
8554Apply Contrast Adaptive Sharpen filter to video stream.
8555
8556The filter accepts the following options:
8557
8558@table @option
8559@item strength
8560Set the sharpening strength. Default value is 0.
8561
8562@item planes
8563Set planes to filter. Default value is to filter all
8564planes except alpha plane.
8565@end table
8566
8567@subsection Commands
8568This filter supports same @ref{commands} as options.
8569
8570@section chromahold
8571Remove all color information for all colors except for certain one.
8572
8573The filter accepts the following options:
8574
8575@table @option
8576@item color
8577The color which will not be replaced with neutral chroma.
8578
8579@item similarity
8580Similarity percentage with the above color.
85810.01 matches only the exact key color, while 1.0 matches everything.
8582
8583@item blend
8584Blend percentage.
85850.0 makes pixels either fully gray, or not gray at all.
8586Higher values result in more preserved color.
8587
8588@item yuv
8589Signals that the color passed is already in YUV instead of RGB.
8590
8591Literal colors like "green" or "red" don't make sense with this enabled anymore.
8592This can be used to pass exact YUV values as hexadecimal numbers.
8593@end table
8594
8595@subsection Commands
8596This filter supports same @ref{commands} as options.
8597The command accepts the same syntax of the corresponding option.
8598
8599If the specified expression is not valid, it is kept at its current
8600value.
8601
8602@anchor{chromakey}
8603@section chromakey
8604YUV colorspace color/chroma keying.
8605
8606The filter accepts the following options:
8607
8608@table @option
8609@item color
8610The color which will be replaced with transparency.
8611
8612@item similarity
8613Similarity percentage with the key color.
8614
86150.01 matches only the exact key color, while 1.0 matches everything.
8616
8617@item blend
8618Blend percentage.
8619
86200.0 makes pixels either fully transparent, or not transparent at all.
8621
8622Higher values result in semi-transparent pixels, with a higher transparency
8623the more similar the pixels color is to the key color.
8624
8625@item yuv
8626Signals that the color passed is already in YUV instead of RGB.
8627
8628Literal colors like "green" or "red" don't make sense with this enabled anymore.
8629This can be used to pass exact YUV values as hexadecimal numbers.
8630@end table
8631
8632@subsection Commands
8633This filter supports same @ref{commands} as options.
8634The command accepts the same syntax of the corresponding option.
8635
8636If the specified expression is not valid, it is kept at its current
8637value.
8638
8639@subsection Examples
8640
8641@itemize
8642@item
8643Make every green pixel in the input image transparent:
8644@example
8645ffmpeg -i input.png -vf chromakey=green out.png
8646@end example
8647
8648@item
8649Overlay a greenscreen-video on top of a static black background.
8650@example
8651ffmpeg -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
8652@end example
8653@end itemize
8654
8655@section chromakey_cuda
8656CUDA accelerated YUV colorspace color/chroma keying.
8657
8658This filter works like normal chromakey filter but operates on CUDA frames.
8659for more details and parameters see @ref{chromakey}.
8660
8661@subsection Examples
8662
8663@itemize
8664@item
8665Make all the green pixels in the input video transparent and use it as an overlay for another video:
8666
8667@example
8668./ffmpeg \
8669    -hwaccel cuda -hwaccel_output_format cuda -i input_green.mp4  \
8670    -hwaccel cuda -hwaccel_output_format cuda -i base_video.mp4 \
8671    -init_hw_device cuda \
8672    -filter_complex \
8673    " \
8674        [0:v]chromakey_cuda=0x25302D:0.1:0.12:1[overlay_video]; \
8675        [1:v]scale_cuda=format=yuv420p[base]; \
8676        [base][overlay_video]overlay_cuda" \
8677    -an -sn -c:v h264_nvenc -cq 20 output.mp4
8678@end example
8679
8680@item
8681Process two software sources, explicitly uploading the frames:
8682
8683@example
8684./ffmpeg -init_hw_device cuda=cuda -filter_hw_device cuda \
8685    -f lavfi -i color=size=800x600:color=white,format=yuv420p \
8686    -f lavfi -i yuvtestsrc=size=200x200,format=yuv420p \
8687    -filter_complex \
8688    " \
8689        [0]hwupload[under]; \
8690        [1]hwupload,chromakey_cuda=green:0.1:0.12[over]; \
8691        [under][over]overlay_cuda" \
8692    -c:v hevc_nvenc -cq 18 -preset slow output.mp4
8693@end example
8694
8695@end itemize
8696
8697@section chromanr
8698Reduce chrominance noise.
8699
8700The filter accepts the following options:
8701
8702@table @option
8703@item thres
8704Set threshold for averaging chrominance values.
8705Sum of absolute difference of Y, U and V pixel components of current
8706pixel and neighbour pixels lower than this threshold will be used in
8707averaging. Luma component is left unchanged and is copied to output.
8708Default value is 30. Allowed range is from 1 to 200.
8709
8710@item sizew
8711Set horizontal radius of rectangle used for averaging.
8712Allowed range is from 1 to 100. Default value is 5.
8713
8714@item sizeh
8715Set vertical radius of rectangle used for averaging.
8716Allowed range is from 1 to 100. Default value is 5.
8717
8718@item stepw
8719Set horizontal step when averaging. Default value is 1.
8720Allowed range is from 1 to 50.
8721Mostly useful to speed-up filtering.
8722
8723@item steph
8724Set vertical step when averaging. Default value is 1.
8725Allowed range is from 1 to 50.
8726Mostly useful to speed-up filtering.
8727
8728@item threy
8729Set Y threshold for averaging chrominance values.
8730Set finer control for max allowed difference between Y components
8731of current pixel and neigbour pixels.
8732Default value is 200. Allowed range is from 1 to 200.
8733
8734@item threu
8735Set U threshold for averaging chrominance values.
8736Set finer control for max allowed difference between U components
8737of current pixel and neigbour pixels.
8738Default value is 200. Allowed range is from 1 to 200.
8739
8740@item threv
8741Set V threshold for averaging chrominance values.
8742Set finer control for max allowed difference between V components
8743of current pixel and neigbour pixels.
8744Default value is 200. Allowed range is from 1 to 200.
8745
8746@item distance
8747Set distance type used in calculations.
8748
8749@table @samp
8750@item manhattan
8751Absolute difference.
8752@item euclidean
8753Difference squared.
8754@end table
8755
8756Default distance type is manhattan.
8757@end table
8758
8759@subsection Commands
8760This filter supports same @ref{commands} as options.
8761The command accepts the same syntax of the corresponding option.
8762
8763@section chromashift
8764Shift chroma pixels horizontally and/or vertically.
8765
8766The filter accepts the following options:
8767@table @option
8768@item cbh
8769Set amount to shift chroma-blue horizontally.
8770@item cbv
8771Set amount to shift chroma-blue vertically.
8772@item crh
8773Set amount to shift chroma-red horizontally.
8774@item crv
8775Set amount to shift chroma-red vertically.
8776@item edge
8777Set edge mode, can be @var{smear}, default, or @var{warp}.
8778@end table
8779
8780@subsection Commands
8781
8782This filter supports the all above options as @ref{commands}.
8783
8784@section ciescope
8785
8786Display CIE color diagram with pixels overlaid onto it.
8787
8788The filter accepts the following options:
8789
8790@table @option
8791@item system
8792Set color system.
8793
8794@table @samp
8795@item ntsc, 470m
8796@item ebu, 470bg
8797@item smpte
8798@item 240m
8799@item apple
8800@item widergb
8801@item cie1931
8802@item rec709, hdtv
8803@item uhdtv, rec2020
8804@item dcip3
8805@end table
8806
8807@item cie
8808Set CIE system.
8809
8810@table @samp
8811@item xyy
8812@item ucs
8813@item luv
8814@end table
8815
8816@item gamuts
8817Set what gamuts to draw.
8818
8819See @code{system} option for available values.
8820
8821@item size, s
8822Set ciescope size, by default set to 512.
8823
8824@item intensity, i
8825Set intensity used to map input pixel values to CIE diagram.
8826
8827@item contrast
8828Set contrast used to draw tongue colors that are out of active color system gamut.
8829
8830@item corrgamma
8831Correct gamma displayed on scope, by default enabled.
8832
8833@item showwhite
8834Show white point on CIE diagram, by default disabled.
8835
8836@item gamma
8837Set input gamma. Used only with XYZ input color space.
8838
8839@item fill
8840Fill with CIE colors. By default is enabled.
8841@end table
8842
8843@section codecview
8844
8845Visualize information exported by some codecs.
8846
8847Some codecs can export information through frames using side-data or other
8848means. For example, some MPEG based codecs export motion vectors through the
8849@var{export_mvs} flag in the codec @option{flags2} option.
8850
8851The filter accepts the following option:
8852
8853@table @option
8854@item block
8855Display block partition structure using the luma plane.
8856
8857@item mv
8858Set motion vectors to visualize.
8859
8860Available flags for @var{mv} are:
8861
8862@table @samp
8863@item pf
8864forward predicted MVs of P-frames
8865@item bf
8866forward predicted MVs of B-frames
8867@item bb
8868backward predicted MVs of B-frames
8869@end table
8870
8871@item qp
8872Display quantization parameters using the chroma planes.
8873
8874@item mv_type, mvt
8875Set motion vectors type to visualize. Includes MVs from all frames unless specified by @var{frame_type} option.
8876
8877Available flags for @var{mv_type} are:
8878
8879@table @samp
8880@item fp
8881forward predicted MVs
8882@item bp
8883backward predicted MVs
8884@end table
8885
8886@item frame_type, ft
8887Set frame type to visualize motion vectors of.
8888
8889Available flags for @var{frame_type} are:
8890
8891@table @samp
8892@item if
8893intra-coded frames (I-frames)
8894@item pf
8895predicted frames (P-frames)
8896@item bf
8897bi-directionally predicted frames (B-frames)
8898@end table
8899@end table
8900
8901@subsection Examples
8902
8903@itemize
8904@item
8905Visualize forward predicted MVs of all frames using @command{ffplay}:
8906@example
8907ffplay -flags2 +export_mvs input.mp4 -vf codecview=mv_type=fp
8908@end example
8909
8910@item
8911Visualize multi-directionals MVs of P and B-Frames using @command{ffplay}:
8912@example
8913ffplay -flags2 +export_mvs input.mp4 -vf codecview=mv=pf+bf+bb
8914@end example
8915@end itemize
8916
8917@section colorbalance
8918Modify intensity of primary colors (red, green and blue) of input frames.
8919
8920The filter allows an input frame to be adjusted in the shadows, midtones or highlights
8921regions for the red-cyan, green-magenta or blue-yellow balance.
8922
8923A positive adjustment value shifts the balance towards the primary color, a negative
8924value towards the complementary color.
8925
8926The filter accepts the following options:
8927
8928@table @option
8929@item rs
8930@item gs
8931@item bs
8932Adjust red, green and blue shadows (darkest pixels).
8933
8934@item rm
8935@item gm
8936@item bm
8937Adjust red, green and blue midtones (medium pixels).
8938
8939@item rh
8940@item gh
8941@item bh
8942Adjust red, green and blue highlights (brightest pixels).
8943
8944Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
8945
8946@item pl
8947Preserve lightness when changing color balance. Default is disabled.
8948@end table
8949
8950@subsection Examples
8951
8952@itemize
8953@item
8954Add red color cast to shadows:
8955@example
8956colorbalance=rs=.3
8957@end example
8958@end itemize
8959
8960@subsection Commands
8961
8962This filter supports the all above options as @ref{commands}.
8963
8964@section colorcontrast
8965
8966Adjust color contrast between RGB components.
8967
8968The filter accepts the following options:
8969
8970@table @option
8971@item rc
8972Set the red-cyan contrast. Defaults is 0.0. Allowed range is from -1.0 to 1.0.
8973
8974@item gm
8975Set the green-magenta contrast. Defaults is 0.0. Allowed range is from -1.0 to 1.0.
8976
8977@item by
8978Set the blue-yellow contrast. Defaults is 0.0. Allowed range is from -1.0 to 1.0.
8979
8980@item rcw
8981@item gmw
8982@item byw
8983Set the weight of each @code{rc}, @code{gm}, @code{by} option value. Default value is 0.0.
8984Allowed range is from 0.0 to 1.0. If all weights are 0.0 filtering is disabled.
8985
8986@item pl
8987Set the amount of preserving lightness. Default value is 0.0. Allowed range is from 0.0 to 1.0.
8988@end table
8989
8990@subsection Commands
8991
8992This filter supports the all above options as @ref{commands}.
8993
8994@section colorcorrect
8995
8996Adjust color white balance selectively for blacks and whites.
8997This filter operates in YUV colorspace.
8998
8999The filter accepts the following options:
9000
9001@table @option
9002@item rl
9003Set the red shadow spot. Allowed range is from -1.0 to 1.0.
9004Default value is 0.
9005
9006@item bl
9007Set the blue shadow spot. Allowed range is from -1.0 to 1.0.
9008Default value is 0.
9009
9010@item rh
9011Set the red highlight spot. Allowed range is from -1.0 to 1.0.
9012Default value is 0.
9013
9014@item bh
9015Set the red highlight spot. Allowed range is from -1.0 to 1.0.
9016Default value is 0.
9017
9018@item saturation
9019Set the amount of saturation. Allowed range is from -3.0 to 3.0.
9020Default value is 1.
9021
9022@item analyze
9023If set to anything other than @code{manual} it will analyze every frame and use derived
9024parameters for filtering output frame.
9025
9026Possible values are:
9027@table @samp
9028@item manual
9029@item average
9030@item minmax
9031@item median
9032@end table
9033Default value is @code{manual}.
9034@end table
9035
9036@subsection Commands
9037
9038This filter supports the all above options as @ref{commands}.
9039
9040@section colorchannelmixer
9041
9042Adjust video input frames by re-mixing color channels.
9043
9044This filter modifies a color channel by adding the values associated to
9045the other channels of the same pixels. For example if the value to
9046modify is red, the output value will be:
9047@example
9048@var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
9049@end example
9050
9051The filter accepts the following options:
9052
9053@table @option
9054@item rr
9055@item rg
9056@item rb
9057@item ra
9058Adjust contribution of input red, green, blue and alpha channels for output red channel.
9059Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
9060
9061@item gr
9062@item gg
9063@item gb
9064@item ga
9065Adjust contribution of input red, green, blue and alpha channels for output green channel.
9066Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
9067
9068@item br
9069@item bg
9070@item bb
9071@item ba
9072Adjust contribution of input red, green, blue and alpha channels for output blue channel.
9073Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
9074
9075@item ar
9076@item ag
9077@item ab
9078@item aa
9079Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
9080Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
9081
9082Allowed ranges for options are @code{[-2.0, 2.0]}.
9083
9084@item pc
9085Set preserve color mode. The accepted values are:
9086@table @samp
9087@item none
9088Disable color preserving, this is default.
9089@item lum
9090Preserve luminance.
9091@item max
9092Preserve max value of RGB triplet.
9093@item avg
9094Preserve average value of RGB triplet.
9095@item sum
9096Preserve sum value of RGB triplet.
9097@item nrm
9098Preserve normalized value of RGB triplet.
9099@item pwr
9100Preserve power value of RGB triplet.
9101@end table
9102
9103@item pa
9104Set the preserve color amount when changing colors. Allowed range is from @code{[0.0, 1.0]}.
9105Default is @code{0.0}, thus disabled.
9106@end table
9107
9108@subsection Examples
9109
9110@itemize
9111@item
9112Convert source to grayscale:
9113@example
9114colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
9115@end example
9116@item
9117Simulate sepia tones:
9118@example
9119colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
9120@end example
9121@end itemize
9122
9123@subsection Commands
9124
9125This filter supports the all above options as @ref{commands}.
9126
9127@section colorize
9128Overlay a solid color on the video stream.
9129
9130The filter accepts the following options:
9131
9132@table @option
9133@item hue
9134Set the color hue. Allowed range is from 0 to 360.
9135Default value is 0.
9136
9137@item saturation
9138Set the color saturation. Allowed range is from 0 to 1.
9139Default value is 0.5.
9140
9141@item lightness
9142Set the color lightness. Allowed range is from 0 to 1.
9143Default value is 0.5.
9144
9145@item mix
9146Set the mix of source lightness. By default is set to 1.0.
9147Allowed range is from 0.0 to 1.0.
9148@end table
9149
9150@subsection Commands
9151
9152This filter supports the all above options as @ref{commands}.
9153
9154@section colorkey
9155RGB colorspace color keying.
9156This filter operates on 8-bit RGB format frames by setting the alpha component of each pixel
9157which falls within the similarity radius of the key color to 0. The alpha value for pixels outside
9158the similarity radius depends on the value of the blend option.
9159
9160The filter accepts the following options:
9161
9162@table @option
9163@item color
9164Set the color for which alpha will be set to 0 (full transparency).
9165See @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.
9166Default is @code{black}.
9167
9168@item similarity
9169Set the radius from the key color within which other colors also have full transparency.
9170The computed distance is related to the unit fractional distance in 3D space between the RGB values
9171of the key color and the pixel's color. Range is 0.01 to 1.0. 0.01 matches within a very small radius
9172around the exact key color, while 1.0 matches everything.
9173Default is @code{0.01}.
9174
9175@item blend
9176Set how the alpha value for pixels that fall outside the similarity radius is computed.
91770.0 makes pixels either fully transparent or fully opaque.
9178Higher values result in semi-transparent pixels, with greater transparency
9179the more similar the pixel color is to the key color.
9180Range is 0.0 to 1.0. Default is @code{0.0}.
9181@end table
9182
9183@subsection Examples
9184
9185@itemize
9186@item
9187Make every green pixel in the input image transparent:
9188@example
9189ffmpeg -i input.png -vf colorkey=green out.png
9190@end example
9191
9192@item
9193Overlay a greenscreen-video on top of a static background image.
9194@example
9195ffmpeg -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
9196@end example
9197@end itemize
9198
9199@subsection Commands
9200This filter supports same @ref{commands} as options.
9201The command accepts the same syntax of the corresponding option.
9202
9203If the specified expression is not valid, it is kept at its current
9204value.
9205
9206@section colorhold
9207Remove all color information for all RGB colors except for certain one.
9208
9209The filter accepts the following options:
9210
9211@table @option
9212@item color
9213The color which will not be replaced with neutral gray.
9214
9215@item similarity
9216Similarity percentage with the above color.
92170.01 matches only the exact key color, while 1.0 matches everything.
9218
9219@item blend
9220Blend percentage. 0.0 makes pixels fully gray.
9221Higher values result in more preserved color.
9222@end table
9223
9224@subsection Commands
9225This filter supports same @ref{commands} as options.
9226The command accepts the same syntax of the corresponding option.
9227
9228If the specified expression is not valid, it is kept at its current
9229value.
9230
9231@section colorlevels
9232
9233Adjust video input frames using levels.
9234
9235The filter accepts the following options:
9236
9237@table @option
9238@item rimin
9239@item gimin
9240@item bimin
9241@item aimin
9242Adjust red, green, blue and alpha input black point.
9243Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
9244
9245@item rimax
9246@item gimax
9247@item bimax
9248@item aimax
9249Adjust red, green, blue and alpha input white point.
9250Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
9251
9252Input levels are used to lighten highlights (bright tones), darken shadows
9253(dark tones), change the balance of bright and dark tones.
9254
9255@item romin
9256@item gomin
9257@item bomin
9258@item aomin
9259Adjust red, green, blue and alpha output black point.
9260Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
9261
9262@item romax
9263@item gomax
9264@item bomax
9265@item aomax
9266Adjust red, green, blue and alpha output white point.
9267Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
9268
9269Output levels allows manual selection of a constrained output level range.
9270
9271@item preserve
9272Set preserve color mode. The accepted values are:
9273@table @samp
9274@item none
9275Disable color preserving, this is default.
9276@item lum
9277Preserve luminance.
9278@item max
9279Preserve max value of RGB triplet.
9280@item avg
9281Preserve average value of RGB triplet.
9282@item sum
9283Preserve sum value of RGB triplet.
9284@item nrm
9285Preserve normalized value of RGB triplet.
9286@item pwr
9287Preserve power value of RGB triplet.
9288@end table
9289@end table
9290
9291@subsection Examples
9292
9293@itemize
9294@item
9295Make video output darker:
9296@example
9297colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
9298@end example
9299
9300@item
9301Increase contrast:
9302@example
9303colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
9304@end example
9305
9306@item
9307Make video output lighter:
9308@example
9309colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
9310@end example
9311
9312@item
9313Increase brightness:
9314@example
9315colorlevels=romin=0.5:gomin=0.5:bomin=0.5
9316@end example
9317@end itemize
9318
9319@subsection Commands
9320
9321This filter supports the all above options as @ref{commands}.
9322
9323@section colormap
9324Apply custom color maps to video stream.
9325
9326This filter needs three input video streams.
9327First stream is video stream that is going to be filtered out.
9328Second and third video stream specify color patches for source
9329color to target color mapping.
9330
9331The filter accepts the following options:
9332
9333@table @option
9334@item patch_size
9335Set the source and target video stream patch size in pixels.
9336
9337@item nb_patches
9338Set the max number of used patches from source and target video stream.
9339Default value is number of patches available in additional video streams.
9340Max allowed number of patches is @code{64}.
9341
9342@item type
9343Set the adjustments used for target colors. Can be @code{relative} or @code{absolute}.
9344Defaults is @code{absolute}.
9345
9346@item kernel
9347Set the kernel used to measure color differences between mapped colors.
9348
9349The accepted values are:
9350@table @samp
9351@item euclidean
9352@item weuclidean
9353@end table
9354
9355Default is @code{euclidean}.
9356@end table
9357
9358@section colormatrix
9359
9360Convert color matrix.
9361
9362The filter accepts the following options:
9363
9364@table @option
9365@item src
9366@item dst
9367Specify the source and destination color matrix. Both values must be
9368specified.
9369
9370The accepted values are:
9371@table @samp
9372@item bt709
9373BT.709
9374
9375@item fcc
9376FCC
9377
9378@item bt601
9379BT.601
9380
9381@item bt470
9382BT.470
9383
9384@item bt470bg
9385BT.470BG
9386
9387@item smpte170m
9388SMPTE-170M
9389
9390@item smpte240m
9391SMPTE-240M
9392
9393@item bt2020
9394BT.2020
9395@end table
9396@end table
9397
9398For example to convert from BT.601 to SMPTE-240M, use the command:
9399@example
9400colormatrix=bt601:smpte240m
9401@end example
9402
9403@section colorspace
9404
9405Convert colorspace, transfer characteristics or color primaries.
9406Input video needs to have an even size.
9407
9408The filter accepts the following options:
9409
9410@table @option
9411@anchor{all}
9412@item all
9413Specify all color properties at once.
9414
9415The accepted values are:
9416@table @samp
9417@item bt470m
9418BT.470M
9419
9420@item bt470bg
9421BT.470BG
9422
9423@item bt601-6-525
9424BT.601-6 525
9425
9426@item bt601-6-625
9427BT.601-6 625
9428
9429@item bt709
9430BT.709
9431
9432@item smpte170m
9433SMPTE-170M
9434
9435@item smpte240m
9436SMPTE-240M
9437
9438@item bt2020
9439BT.2020
9440
9441@end table
9442
9443@anchor{space}
9444@item space
9445Specify output colorspace.
9446
9447The accepted values are:
9448@table @samp
9449@item bt709
9450BT.709
9451
9452@item fcc
9453FCC
9454
9455@item bt470bg
9456BT.470BG or BT.601-6 625
9457
9458@item smpte170m
9459SMPTE-170M or BT.601-6 525
9460
9461@item smpte240m
9462SMPTE-240M
9463
9464@item ycgco
9465YCgCo
9466
9467@item bt2020ncl
9468BT.2020 with non-constant luminance
9469
9470@end table
9471
9472@anchor{trc}
9473@item trc
9474Specify output transfer characteristics.
9475
9476The accepted values are:
9477@table @samp
9478@item bt709
9479BT.709
9480
9481@item bt470m
9482BT.470M
9483
9484@item bt470bg
9485BT.470BG
9486
9487@item gamma22
9488Constant gamma of 2.2
9489
9490@item gamma28
9491Constant gamma of 2.8
9492
9493@item smpte170m
9494SMPTE-170M, BT.601-6 625 or BT.601-6 525
9495
9496@item smpte240m
9497SMPTE-240M
9498
9499@item srgb
9500SRGB
9501
9502@item iec61966-2-1
9503iec61966-2-1
9504
9505@item iec61966-2-4
9506iec61966-2-4
9507
9508@item xvycc
9509xvycc
9510
9511@item bt2020-10
9512BT.2020 for 10-bits content
9513
9514@item bt2020-12
9515BT.2020 for 12-bits content
9516
9517@end table
9518
9519@anchor{primaries}
9520@item primaries
9521Specify output color primaries.
9522
9523The accepted values are:
9524@table @samp
9525@item bt709
9526BT.709
9527
9528@item bt470m
9529BT.470M
9530
9531@item bt470bg
9532BT.470BG or BT.601-6 625
9533
9534@item smpte170m
9535SMPTE-170M or BT.601-6 525
9536
9537@item smpte240m
9538SMPTE-240M
9539
9540@item film
9541film
9542
9543@item smpte431
9544SMPTE-431
9545
9546@item smpte432
9547SMPTE-432
9548
9549@item bt2020
9550BT.2020
9551
9552@item jedec-p22
9553JEDEC P22 phosphors
9554
9555@end table
9556
9557@anchor{range}
9558@item range
9559Specify output color range.
9560
9561The accepted values are:
9562@table @samp
9563@item tv
9564TV (restricted) range
9565
9566@item mpeg
9567MPEG (restricted) range
9568
9569@item pc
9570PC (full) range
9571
9572@item jpeg
9573JPEG (full) range
9574
9575@end table
9576
9577@item format
9578Specify output color format.
9579
9580The accepted values are:
9581@table @samp
9582@item yuv420p
9583YUV 4:2:0 planar 8-bits
9584
9585@item yuv420p10
9586YUV 4:2:0 planar 10-bits
9587
9588@item yuv420p12
9589YUV 4:2:0 planar 12-bits
9590
9591@item yuv422p
9592YUV 4:2:2 planar 8-bits
9593
9594@item yuv422p10
9595YUV 4:2:2 planar 10-bits
9596
9597@item yuv422p12
9598YUV 4:2:2 planar 12-bits
9599
9600@item yuv444p
9601YUV 4:4:4 planar 8-bits
9602
9603@item yuv444p10
9604YUV 4:4:4 planar 10-bits
9605
9606@item yuv444p12
9607YUV 4:4:4 planar 12-bits
9608
9609@end table
9610
9611@item fast
9612Do a fast conversion, which skips gamma/primary correction. This will take
9613significantly less CPU, but will be mathematically incorrect. To get output
9614compatible with that produced by the colormatrix filter, use fast=1.
9615
9616@item dither
9617Specify dithering mode.
9618
9619The accepted values are:
9620@table @samp
9621@item none
9622No dithering
9623
9624@item fsb
9625Floyd-Steinberg dithering
9626@end table
9627
9628@item wpadapt
9629Whitepoint adaptation mode.
9630
9631The accepted values are:
9632@table @samp
9633@item bradford
9634Bradford whitepoint adaptation
9635
9636@item vonkries
9637von Kries whitepoint adaptation
9638
9639@item identity
9640identity whitepoint adaptation (i.e. no whitepoint adaptation)
9641@end table
9642
9643@item iall
9644Override all input properties at once. Same accepted values as @ref{all}.
9645
9646@item ispace
9647Override input colorspace. Same accepted values as @ref{space}.
9648
9649@item iprimaries
9650Override input color primaries. Same accepted values as @ref{primaries}.
9651
9652@item itrc
9653Override input transfer characteristics. Same accepted values as @ref{trc}.
9654
9655@item irange
9656Override input color range. Same accepted values as @ref{range}.
9657
9658@end table
9659
9660The filter converts the transfer characteristics, color space and color
9661primaries to the specified user values. The output value, if not specified,
9662is set to a default value based on the "all" property. If that property is
9663also not specified, the filter will log an error. The output color range and
9664format default to the same value as the input color range and format. The
9665input transfer characteristics, color space, color primaries and color range
9666should be set on the input data. If any of these are missing, the filter will
9667log an error and no conversion will take place.
9668
9669For example to convert the input to SMPTE-240M, use the command:
9670@example
9671colorspace=smpte240m
9672@end example
9673
9674@section colortemperature
9675Adjust color temperature in video to simulate variations in ambient color temperature.
9676
9677The filter accepts the following options:
9678
9679@table @option
9680@item temperature
9681Set the temperature in Kelvin. Allowed range is from 1000 to 40000.
9682Default value is 6500 K.
9683
9684@item mix
9685Set mixing with filtered output. Allowed range is from 0 to 1.
9686Default value is 1.
9687
9688@item pl
9689Set the amount of preserving lightness. Allowed range is from 0 to 1.
9690Default value is 0.
9691@end table
9692
9693@subsection Commands
9694This filter supports same @ref{commands} as options.
9695
9696@section convolution
9697
9698Apply convolution of 3x3, 5x5, 7x7 or horizontal/vertical up to 49 elements.
9699
9700The filter accepts the following options:
9701
9702@table @option
9703@item 0m
9704@item 1m
9705@item 2m
9706@item 3m
9707Set matrix for each plane.
9708Matrix is sequence of 9, 25 or 49 signed integers in @var{square} mode,
9709and from 1 to 49 odd number of signed integers in @var{row} mode.
9710
9711@item 0rdiv
9712@item 1rdiv
9713@item 2rdiv
9714@item 3rdiv
9715Set multiplier for calculated value for each plane.
9716If unset or 0, it will be sum of all matrix elements.
9717
9718@item 0bias
9719@item 1bias
9720@item 2bias
9721@item 3bias
9722Set bias for each plane. This value is added to the result of the multiplication.
9723Useful for making the overall image brighter or darker. Default is 0.0.
9724
9725@item 0mode
9726@item 1mode
9727@item 2mode
9728@item 3mode
9729Set matrix mode for each plane. Can be @var{square}, @var{row} or @var{column}.
9730Default is @var{square}.
9731@end table
9732
9733@subsection Commands
9734
9735This filter supports the all above options as @ref{commands}.
9736
9737@subsection Examples
9738
9739@itemize
9740@item
9741Apply sharpen:
9742@example
9743convolution="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"
9744@end example
9745
9746@item
9747Apply blur:
9748@example
9749convolution="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"
9750@end example
9751
9752@item
9753Apply edge enhance:
9754@example
9755convolution="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"
9756@end example
9757
9758@item
9759Apply edge detect:
9760@example
9761convolution="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"
9762@end example
9763
9764@item
9765Apply laplacian edge detector which includes diagonals:
9766@example
9767convolution="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"
9768@end example
9769
9770@item
9771Apply emboss:
9772@example
9773convolution="-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"
9774@end example
9775@end itemize
9776
9777@section convolve
9778
9779Apply 2D convolution of video stream in frequency domain using second stream
9780as impulse.
9781
9782The filter accepts the following options:
9783
9784@table @option
9785@item planes
9786Set which planes to process.
9787
9788@item impulse
9789Set which impulse video frames will be processed, can be @var{first}
9790or @var{all}. Default is @var{all}.
9791@end table
9792
9793The @code{convolve} filter also supports the @ref{framesync} options.
9794
9795@section copy
9796
9797Copy the input video source unchanged to the output. This is mainly useful for
9798testing purposes.
9799
9800@anchor{coreimage}
9801@section coreimage
9802Video filtering on GPU using Apple's CoreImage API on OSX.
9803
9804Hardware acceleration is based on an OpenGL context. Usually, this means it is
9805processed by video hardware. However, software-based OpenGL implementations
9806exist which means there is no guarantee for hardware processing. It depends on
9807the respective OSX.
9808
9809There are many filters and image generators provided by Apple that come with a
9810large variety of options. The filter has to be referenced by its name along
9811with its options.
9812
9813The coreimage filter accepts the following options:
9814@table @option
9815@item list_filters
9816List all available filters and generators along with all their respective
9817options as well as possible minimum and maximum values along with the default
9818values.
9819@example
9820list_filters=true
9821@end example
9822
9823@item filter
9824Specify all filters by their respective name and options.
9825Use @var{list_filters} to determine all valid filter names and options.
9826Numerical options are specified by a float value and are automatically clamped
9827to their respective value range.  Vector and color options have to be specified
9828by a list of space separated float values. Character escaping has to be done.
9829A special option name @code{default} is available to use default options for a
9830filter.
9831
9832It is required to specify either @code{default} or at least one of the filter options.
9833All omitted options are used with their default values.
9834The syntax of the filter string is as follows:
9835@example
9836filter=<NAME>@@<OPTION>=<VALUE>[@@<OPTION>=<VALUE>][@@...][#<NAME>@@<OPTION>=<VALUE>[@@<OPTION>=<VALUE>][@@...]][#...]
9837@end example
9838
9839@item output_rect
9840Specify a rectangle where the output of the filter chain is copied into the
9841input image. It is given by a list of space separated float values:
9842@example
9843output_rect=x\ y\ width\ height
9844@end example
9845If not given, the output rectangle equals the dimensions of the input image.
9846The output rectangle is automatically cropped at the borders of the input
9847image. Negative values are valid for each component.
9848@example
9849output_rect=25\ 25\ 100\ 100
9850@end example
9851@end table
9852
9853Several filters can be chained for successive processing without GPU-HOST
9854transfers allowing for fast processing of complex filter chains.
9855Currently, only filters with zero (generators) or exactly one (filters) input
9856image and one output image are supported. Also, transition filters are not yet
9857usable as intended.
9858
9859Some filters generate output images with additional padding depending on the
9860respective filter kernel. The padding is automatically removed to ensure the
9861filter output has the same size as the input image.
9862
9863For image generators, the size of the output image is determined by the
9864previous output image of the filter chain or the input image of the whole
9865filterchain, respectively. The generators do not use the pixel information of
9866this image to generate their output. However, the generated output is
9867blended onto this image, resulting in partial or complete coverage of the
9868output image.
9869
9870The @ref{coreimagesrc} video source can be used for generating input images
9871which are directly fed into the filter chain. By using it, providing input
9872images by another video source or an input video is not required.
9873
9874@subsection Examples
9875
9876@itemize
9877
9878@item
9879List all filters available:
9880@example
9881coreimage=list_filters=true
9882@end example
9883
9884@item
9885Use the CIBoxBlur filter with default options to blur an image:
9886@example
9887coreimage=filter=CIBoxBlur@@default
9888@end example
9889
9890@item
9891Use a filter chain with CISepiaTone at default values and CIVignetteEffect with
9892its center at 100x100 and a radius of 50 pixels:
9893@example
9894coreimage=filter=CIBoxBlur@@default#CIVignetteEffect@@inputCenter=100\ 100@@inputRadius=50
9895@end example
9896
9897@item
9898Use nullsrc and CIQRCodeGenerator to create a QR code for the FFmpeg homepage,
9899given as complete and escaped command-line for Apple's standard bash shell:
9900@example
9901ffmpeg -f lavfi -i nullsrc=s=100x100,coreimage=filter=CIQRCodeGenerator@@inputMessage=https\\\\\://FFmpeg.org/@@inputCorrectionLevel=H -frames:v 1 QRCode.png
9902@end example
9903@end itemize
9904
9905@section cover_rect
9906
9907Cover a rectangular object
9908
9909It accepts the following options:
9910
9911@table @option
9912@item cover
9913Filepath of the optional cover image, needs to be in yuv420.
9914
9915@item mode
9916Set covering mode.
9917
9918It accepts the following values:
9919@table @samp
9920@item cover
9921cover it by the supplied image
9922@item blur
9923cover it by interpolating the surrounding pixels
9924@end table
9925
9926Default value is @var{blur}.
9927@end table
9928
9929@subsection Examples
9930
9931@itemize
9932@item
9933Cover a rectangular object by the supplied image of a given video using @command{ffmpeg}:
9934@example
9935ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
9936@end example
9937@end itemize
9938
9939@section crop
9940
9941Crop the input video to given dimensions.
9942
9943It accepts the following parameters:
9944
9945@table @option
9946@item w, out_w
9947The width of the output video. It defaults to @code{iw}.
9948This expression is evaluated only once during the filter
9949configuration, or when the @samp{w} or @samp{out_w} command is sent.
9950
9951@item h, out_h
9952The height of the output video. It defaults to @code{ih}.
9953This expression is evaluated only once during the filter
9954configuration, or when the @samp{h} or @samp{out_h} command is sent.
9955
9956@item x
9957The horizontal position, in the input video, of the left edge of the output
9958video. It defaults to @code{(in_w-out_w)/2}.
9959This expression is evaluated per-frame.
9960
9961@item y
9962The vertical position, in the input video, of the top edge of the output video.
9963It defaults to @code{(in_h-out_h)/2}.
9964This expression is evaluated per-frame.
9965
9966@item keep_aspect
9967If set to 1 will force the output display aspect ratio
9968to be the same of the input, by changing the output sample aspect
9969ratio. It defaults to 0.
9970
9971@item exact
9972Enable exact cropping. If enabled, subsampled videos will be cropped at exact
9973width/height/x/y as specified and will not be rounded to nearest smaller value.
9974It defaults to 0.
9975@end table
9976
9977The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
9978expressions containing the following constants:
9979
9980@table @option
9981@item x
9982@item y
9983The computed values for @var{x} and @var{y}. They are evaluated for
9984each new frame.
9985
9986@item in_w
9987@item in_h
9988The input width and height.
9989
9990@item iw
9991@item ih
9992These are the same as @var{in_w} and @var{in_h}.
9993
9994@item out_w
9995@item out_h
9996The output (cropped) width and height.
9997
9998@item ow
9999@item oh
10000These are the same as @var{out_w} and @var{out_h}.
10001
10002@item a
10003same as @var{iw} / @var{ih}
10004
10005@item sar
10006input sample aspect ratio
10007
10008@item dar
10009input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
10010
10011@item hsub
10012@item vsub
10013horizontal and vertical chroma subsample values. For example for the
10014pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
10015
10016@item n
10017The number of the input frame, starting from 0.
10018
10019@item pos
10020the position in the file of the input frame, NAN if unknown
10021
10022@item t
10023The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
10024
10025@end table
10026
10027The expression for @var{out_w} may depend on the value of @var{out_h},
10028and the expression for @var{out_h} may depend on @var{out_w}, but they
10029cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
10030evaluated after @var{out_w} and @var{out_h}.
10031
10032The @var{x} and @var{y} parameters specify the expressions for the
10033position of the top-left corner of the output (non-cropped) area. They
10034are evaluated for each frame. If the evaluated value is not valid, it
10035is approximated to the nearest valid value.
10036
10037The expression for @var{x} may depend on @var{y}, and the expression
10038for @var{y} may depend on @var{x}.
10039
10040@subsection Examples
10041
10042@itemize
10043@item
10044Crop area with size 100x100 at position (12,34).
10045@example
10046crop=100:100:12:34
10047@end example
10048
10049Using named options, the example above becomes:
10050@example
10051crop=w=100:h=100:x=12:y=34
10052@end example
10053
10054@item
10055Crop the central input area with size 100x100:
10056@example
10057crop=100:100
10058@end example
10059
10060@item
10061Crop the central input area with size 2/3 of the input video:
10062@example
10063crop=2/3*in_w:2/3*in_h
10064@end example
10065
10066@item
10067Crop the input video central square:
10068@example
10069crop=out_w=in_h
10070crop=in_h
10071@end example
10072
10073@item
10074Delimit the rectangle with the top-left corner placed at position
10075100:100 and the right-bottom corner corresponding to the right-bottom
10076corner of the input image.
10077@example
10078crop=in_w-100:in_h-100:100:100
10079@end example
10080
10081@item
10082Crop 10 pixels from the left and right borders, and 20 pixels from
10083the top and bottom borders
10084@example
10085crop=in_w-2*10:in_h-2*20
10086@end example
10087
10088@item
10089Keep only the bottom right quarter of the input image:
10090@example
10091crop=in_w/2:in_h/2:in_w/2:in_h/2
10092@end example
10093
10094@item
10095Crop height for getting Greek harmony:
10096@example
10097crop=in_w:1/PHI*in_w
10098@end example
10099
10100@item
10101Apply trembling effect:
10102@example
10103crop=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)
10104@end example
10105
10106@item
10107Apply erratic camera effect depending on timestamp:
10108@example
10109crop=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)"
10110@end example
10111
10112@item
10113Set x depending on the value of y:
10114@example
10115crop=in_w/2:in_h/2:y:10+10*sin(n/10)
10116@end example
10117@end itemize
10118
10119@subsection Commands
10120
10121This filter supports the following commands:
10122@table @option
10123@item w, out_w
10124@item h, out_h
10125@item x
10126@item y
10127Set width/height of the output video and the horizontal/vertical position
10128in the input video.
10129The command accepts the same syntax of the corresponding option.
10130
10131If the specified expression is not valid, it is kept at its current
10132value.
10133@end table
10134
10135@section cropdetect
10136
10137Auto-detect the crop size.
10138
10139It calculates the necessary cropping parameters and prints the
10140recommended parameters via the logging system. The detected dimensions
10141correspond to the non-black area of the input video.
10142
10143It accepts the following parameters:
10144
10145@table @option
10146
10147@item limit
10148Set higher black value threshold, which can be optionally specified
10149from nothing (0) to everything (255 for 8-bit based formats). An intensity
10150value greater to the set value is considered non-black. It defaults to 24.
10151You can also specify a value between 0.0 and 1.0 which will be scaled depending
10152on the bitdepth of the pixel format.
10153
10154@item round
10155The value which the width/height should be divisible by. It defaults to
1015616. The offset is automatically adjusted to center the video. Use 2 to
10157get only even dimensions (needed for 4:2:2 video). 16 is best when
10158encoding to most video codecs.
10159
10160@item skip
10161Set the number of initial frames for which evaluation is skipped.
10162Default is 2. Range is 0 to INT_MAX.
10163
10164@item reset_count, reset
10165Set the counter that determines after how many frames cropdetect will
10166reset the previously detected largest video area and start over to
10167detect the current optimal crop area. Default value is 0.
10168
10169This can be useful when channel logos distort the video area. 0
10170indicates 'never reset', and returns the largest area encountered during
10171playback.
10172@end table
10173
10174@anchor{cue}
10175@section cue
10176
10177Delay video filtering until a given wallclock timestamp. The filter first
10178passes on @option{preroll} amount of frames, then it buffers at most
10179@option{buffer} amount of frames and waits for the cue. After reaching the cue
10180it forwards the buffered frames and also any subsequent frames coming in its
10181input.
10182
10183The filter can be used synchronize the output of multiple ffmpeg processes for
10184realtime output devices like decklink. By putting the delay in the filtering
10185chain and pre-buffering frames the process can pass on data to output almost
10186immediately after the target wallclock timestamp is reached.
10187
10188Perfect frame accuracy cannot be guaranteed, but the result is good enough for
10189some use cases.
10190
10191@table @option
10192
10193@item cue
10194The cue timestamp expressed in a UNIX timestamp in microseconds. Default is 0.
10195
10196@item preroll
10197The duration of content to pass on as preroll expressed in seconds. Default is 0.
10198
10199@item buffer
10200The maximum duration of content to buffer before waiting for the cue expressed
10201in seconds. Default is 0.
10202
10203@end table
10204
10205@anchor{curves}
10206@section curves
10207
10208Apply color adjustments using curves.
10209
10210This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
10211component (red, green and blue) has its values defined by @var{N} key points
10212tied from each other using a smooth curve. The x-axis represents the pixel
10213values from the input frame, and the y-axis the new pixel values to be set for
10214the output frame.
10215
10216By default, a component curve is defined by the two points @var{(0;0)} and
10217@var{(1;1)}. This creates a straight line where each original pixel value is
10218"adjusted" to its own value, which means no change to the image.
10219
10220The filter allows you to redefine these two points and add some more. A new
10221curve (using a natural cubic spline interpolation) will be define to pass
10222smoothly through all these new coordinates. The new defined points needs to be
10223strictly increasing over the x-axis, and their @var{x} and @var{y} values must
10224be in the @var{[0;1]} interval.  If the computed curves happened to go outside
10225the vector spaces, the values will be clipped accordingly.
10226
10227The filter accepts the following options:
10228
10229@table @option
10230@item preset
10231Select one of the available color presets. This option can be used in addition
10232to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
10233options takes priority on the preset values.
10234Available presets are:
10235@table @samp
10236@item none
10237@item color_negative
10238@item cross_process
10239@item darker
10240@item increase_contrast
10241@item lighter
10242@item linear_contrast
10243@item medium_contrast
10244@item negative
10245@item strong_contrast
10246@item vintage
10247@end table
10248Default is @code{none}.
10249@item master, m
10250Set the master key points. These points will define a second pass mapping. It
10251is sometimes called a "luminance" or "value" mapping. It can be used with
10252@option{r}, @option{g}, @option{b} or @option{all} since it acts like a
10253post-processing LUT.
10254@item red, r
10255Set the key points for the red component.
10256@item green, g
10257Set the key points for the green component.
10258@item blue, b
10259Set the key points for the blue component.
10260@item all
10261Set the key points for all components (not including master).
10262Can be used in addition to the other key points component
10263options. In this case, the unset component(s) will fallback on this
10264@option{all} setting.
10265@item psfile
10266Specify a Photoshop curves file (@code{.acv}) to import the settings from.
10267@item plot
10268Save Gnuplot script of the curves in specified file.
10269@end table
10270
10271To avoid some filtergraph syntax conflicts, each key points list need to be
10272defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
10273
10274@subsection Commands
10275
10276This filter supports same @ref{commands} as options.
10277
10278@subsection Examples
10279
10280@itemize
10281@item
10282Increase slightly the middle level of blue:
10283@example
10284curves=blue='0/0 0.5/0.58 1/1'
10285@end example
10286
10287@item
10288Vintage effect:
10289@example
10290curves=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'
10291@end example
10292Here we obtain the following coordinates for each components:
10293@table @var
10294@item red
10295@code{(0;0.11) (0.42;0.51) (1;0.95)}
10296@item green
10297@code{(0;0) (0.50;0.48) (1;1)}
10298@item blue
10299@code{(0;0.22) (0.49;0.44) (1;0.80)}
10300@end table
10301
10302@item
10303The previous example can also be achieved with the associated built-in preset:
10304@example
10305curves=preset=vintage
10306@end example
10307
10308@item
10309Or simply:
10310@example
10311curves=vintage
10312@end example
10313
10314@item
10315Use a Photoshop preset and redefine the points of the green component:
10316@example
10317curves=psfile='MyCurvesPresets/purple.acv':green='0/0 0.45/0.53 1/1'
10318@end example
10319
10320@item
10321Check out the curves of the @code{cross_process} profile using @command{ffmpeg}
10322and @command{gnuplot}:
10323@example
10324ffmpeg -f lavfi -i color -vf curves=cross_process:plot=/tmp/curves.plt -frames:v 1 -f null -
10325gnuplot -p /tmp/curves.plt
10326@end example
10327@end itemize
10328
10329@section datascope
10330
10331Video data analysis filter.
10332
10333This filter shows hexadecimal pixel values of part of video.
10334
10335The filter accepts the following options:
10336
10337@table @option
10338@item size, s
10339Set output video size.
10340
10341@item x
10342Set x offset from where to pick pixels.
10343
10344@item y
10345Set y offset from where to pick pixels.
10346
10347@item mode
10348Set scope mode, can be one of the following:
10349@table @samp
10350@item mono
10351Draw hexadecimal pixel values with white color on black background.
10352
10353@item color
10354Draw hexadecimal pixel values with input video pixel color on black
10355background.
10356
10357@item color2
10358Draw hexadecimal pixel values on color background picked from input video,
10359the text color is picked in such way so its always visible.
10360@end table
10361
10362@item axis
10363Draw rows and columns numbers on left and top of video.
10364
10365@item opacity
10366Set background opacity.
10367
10368@item format
10369Set display number format. Can be @code{hex}, or @code{dec}. Default is @code{hex}.
10370
10371@item components
10372Set pixel components to display. By default all pixel components are displayed.
10373@end table
10374
10375@subsection Commands
10376
10377This filter supports same @ref{commands} as options excluding @code{size} option.
10378
10379@section dblur
10380Apply Directional blur filter.
10381
10382The filter accepts the following options:
10383
10384@table @option
10385@item angle
10386Set angle of directional blur. Default is @code{45}.
10387
10388@item radius
10389Set radius of directional blur. Default is @code{5}.
10390
10391@item planes
10392Set which planes to filter. By default all planes are filtered.
10393@end table
10394
10395@subsection Commands
10396This filter supports same @ref{commands} as options.
10397The command accepts the same syntax of the corresponding option.
10398
10399If the specified expression is not valid, it is kept at its current
10400value.
10401
10402@section dctdnoiz
10403
10404Denoise frames using 2D DCT (frequency domain filtering).
10405
10406This filter is not designed for real time.
10407
10408The filter accepts the following options:
10409
10410@table @option
10411@item sigma, s
10412Set the noise sigma constant.
10413
10414This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
10415coefficient (absolute value) below this threshold with be dropped.
10416
10417If you need a more advanced filtering, see @option{expr}.
10418
10419Default is @code{0}.
10420
10421@item overlap
10422Set number overlapping pixels for each block. Since the filter can be slow, you
10423may want to reduce this value, at the cost of a less effective filter and the
10424risk of various artefacts.
10425
10426If the overlapping value doesn't permit processing the whole input width or
10427height, a warning will be displayed and according borders won't be denoised.
10428
10429Default value is @var{blocksize}-1, which is the best possible setting.
10430
10431@item expr, e
10432Set the coefficient factor expression.
10433
10434For each coefficient of a DCT block, this expression will be evaluated as a
10435multiplier value for the coefficient.
10436
10437If this is option is set, the @option{sigma} option will be ignored.
10438
10439The absolute value of the coefficient can be accessed through the @var{c}
10440variable.
10441
10442@item n
10443Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
10444@var{blocksize}, which is the width and height of the processed blocks.
10445
10446The default value is @var{3} (8x8) and can be raised to @var{4} for a
10447@var{blocksize} of 16x16. Note that changing this setting has huge consequences
10448on the speed processing. Also, a larger block size does not necessarily means a
10449better de-noising.
10450@end table
10451
10452@subsection Examples
10453
10454Apply a denoise with a @option{sigma} of @code{4.5}:
10455@example
10456dctdnoiz=4.5
10457@end example
10458
10459The same operation can be achieved using the expression system:
10460@example
10461dctdnoiz=e='gte(c, 4.5*3)'
10462@end example
10463
10464Violent denoise using a block size of @code{16x16}:
10465@example
10466dctdnoiz=15:n=4
10467@end example
10468
10469@section deband
10470
10471Remove banding artifacts from input video.
10472It works by replacing banded pixels with average value of referenced pixels.
10473
10474The filter accepts the following options:
10475
10476@table @option
10477@item 1thr
10478@item 2thr
10479@item 3thr
10480@item 4thr
10481Set banding detection threshold for each plane. Default is 0.02.
10482Valid range is 0.00003 to 0.5.
10483If difference between current pixel and reference pixel is less than threshold,
10484it will be considered as banded.
10485
10486@item range, r
10487Banding detection range in pixels. Default is 16. If positive, random number
10488in range 0 to set value will be used. If negative, exact absolute value
10489will be used.
10490The range defines square of four pixels around current pixel.
10491
10492@item direction, d
10493Set direction in radians from which four pixel will be compared. If positive,
10494random direction from 0 to set direction will be picked. If negative, exact of
10495absolute value will be picked. For example direction 0, -PI or -2*PI radians
10496will pick only pixels on same row and -PI/2 will pick only pixels on same
10497column.
10498
10499@item blur, b
10500If enabled, current pixel is compared with average value of all four
10501surrounding pixels. The default is enabled. If disabled current pixel is
10502compared with all four surrounding pixels. The pixel is considered banded
10503if only all four differences with surrounding pixels are less than threshold.
10504
10505@item coupling, c
10506If enabled, current pixel is changed if and only if all pixel components are banded,
10507e.g. banding detection threshold is triggered for all color components.
10508The default is disabled.
10509@end table
10510
10511@subsection Commands
10512
10513This filter supports the all above options as @ref{commands}.
10514
10515@section deblock
10516
10517Remove blocking artifacts from input video.
10518
10519The filter accepts the following options:
10520
10521@table @option
10522@item filter
10523Set filter type, can be @var{weak} or @var{strong}. Default is @var{strong}.
10524This controls what kind of deblocking is applied.
10525
10526@item block
10527Set size of block, allowed range is from 4 to 512. Default is @var{8}.
10528
10529@item alpha
10530@item beta
10531@item gamma
10532@item delta
10533Set blocking detection thresholds. Allowed range is 0 to 1.
10534Defaults are: @var{0.098} for @var{alpha} and @var{0.05} for the rest.
10535Using higher threshold gives more deblocking strength.
10536Setting @var{alpha} controls threshold detection at exact edge of block.
10537Remaining options controls threshold detection near the edge. Each one for
10538below/above or left/right. Setting any of those to @var{0} disables
10539deblocking.
10540
10541@item planes
10542Set planes to filter. Default is to filter all available planes.
10543@end table
10544
10545@subsection Examples
10546
10547@itemize
10548@item
10549Deblock using weak filter and block size of 4 pixels.
10550@example
10551deblock=filter=weak:block=4
10552@end example
10553
10554@item
10555Deblock using strong filter, block size of 4 pixels and custom thresholds for
10556deblocking more edges.
10557@example
10558deblock=filter=strong:block=4:alpha=0.12:beta=0.07:gamma=0.06:delta=0.05
10559@end example
10560
10561@item
10562Similar as above, but filter only first plane.
10563@example
10564deblock=filter=strong:block=4:alpha=0.12:beta=0.07:gamma=0.06:delta=0.05:planes=1
10565@end example
10566
10567@item
10568Similar as above, but filter only second and third plane.
10569@example
10570deblock=filter=strong:block=4:alpha=0.12:beta=0.07:gamma=0.06:delta=0.05:planes=6
10571@end example
10572@end itemize
10573
10574@subsection Commands
10575
10576This filter supports the all above options as @ref{commands}.
10577
10578@anchor{decimate}
10579@section decimate
10580
10581Drop duplicated frames at regular intervals.
10582
10583The filter accepts the following options:
10584
10585@table @option
10586@item cycle
10587Set the number of frames from which one will be dropped. Setting this to
10588@var{N} means one frame in every batch of @var{N} frames will be dropped.
10589Default is @code{5}.
10590
10591@item dupthresh
10592Set the threshold for duplicate detection. If the difference metric for a frame
10593is less than or equal to this value, then it is declared as duplicate. Default
10594is @code{1.1}
10595
10596@item scthresh
10597Set scene change threshold. Default is @code{15}.
10598
10599@item blockx
10600@item blocky
10601Set the size of the x and y-axis blocks used during metric calculations.
10602Larger blocks give better noise suppression, but also give worse detection of
10603small movements. Must be a power of two. Default is @code{32}.
10604
10605@item ppsrc
10606Mark main input as a pre-processed input and activate clean source input
10607stream. This allows the input to be pre-processed with various filters to help
10608the metrics calculation while keeping the frame selection lossless. When set to
10609@code{1}, the first stream is for the pre-processed input, and the second
10610stream is the clean source from where the kept frames are chosen. Default is
10611@code{0}.
10612
10613@item chroma
10614Set whether or not chroma is considered in the metric calculations. Default is
10615@code{1}.
10616@end table
10617
10618@section deconvolve
10619
10620Apply 2D deconvolution of video stream in frequency domain using second stream
10621as impulse.
10622
10623The filter accepts the following options:
10624
10625@table @option
10626@item planes
10627Set which planes to process.
10628
10629@item impulse
10630Set which impulse video frames will be processed, can be @var{first}
10631or @var{all}. Default is @var{all}.
10632
10633@item noise
10634Set noise when doing divisions. Default is @var{0.0000001}. Useful when width
10635and height are not same and not power of 2 or if stream prior to convolving
10636had noise.
10637@end table
10638
10639The @code{deconvolve} filter also supports the @ref{framesync} options.
10640
10641@section dedot
10642
10643Reduce cross-luminance (dot-crawl) and cross-color (rainbows) from video.
10644
10645It accepts the following options:
10646
10647@table @option
10648@item m
10649Set mode of operation. Can be combination of @var{dotcrawl} for cross-luminance reduction and/or
10650@var{rainbows} for cross-color reduction.
10651
10652@item lt
10653Set spatial luma threshold. Lower values increases reduction of cross-luminance.
10654
10655@item tl
10656Set tolerance for temporal luma. Higher values increases reduction of cross-luminance.
10657
10658@item tc
10659Set tolerance for chroma temporal variation. Higher values increases reduction of cross-color.
10660
10661@item ct
10662Set temporal chroma threshold. Lower values increases reduction of cross-color.
10663@end table
10664
10665@section deflate
10666
10667Apply deflate effect to the video.
10668
10669This filter replaces the pixel by the local(3x3) average by taking into account
10670only values lower than the pixel.
10671
10672It accepts the following options:
10673
10674@table @option
10675@item threshold0
10676@item threshold1
10677@item threshold2
10678@item threshold3
10679Limit the maximum change for each plane, default is 65535.
10680If 0, plane will remain unchanged.
10681@end table
10682
10683@subsection Commands
10684
10685This filter supports the all above options as @ref{commands}.
10686
10687@section deflicker
10688
10689Remove temporal frame luminance variations.
10690
10691It accepts the following options:
10692
10693@table @option
10694@item size, s
10695Set moving-average filter size in frames. Default is 5. Allowed range is 2 - 129.
10696
10697@item mode, m
10698Set averaging mode to smooth temporal luminance variations.
10699
10700Available values are:
10701@table @samp
10702@item am
10703Arithmetic mean
10704
10705@item gm
10706Geometric mean
10707
10708@item hm
10709Harmonic mean
10710
10711@item qm
10712Quadratic mean
10713
10714@item cm
10715Cubic mean
10716
10717@item pm
10718Power mean
10719
10720@item median
10721Median
10722@end table
10723
10724@item bypass
10725Do not actually modify frame. Useful when one only wants metadata.
10726@end table
10727
10728@section dejudder
10729
10730Remove judder produced by partially interlaced telecined content.
10731
10732Judder can be introduced, for instance, by @ref{pullup} filter. If the original
10733source was partially telecined content then the output of @code{pullup,dejudder}
10734will have a variable frame rate. May change the recorded frame rate of the
10735container. Aside from that change, this filter will not affect constant frame
10736rate video.
10737
10738The option available in this filter is:
10739@table @option
10740
10741@item cycle
10742Specify the length of the window over which the judder repeats.
10743
10744Accepts any integer greater than 1. Useful values are:
10745@table @samp
10746
10747@item 4
10748If the original was telecined from 24 to 30 fps (Film to NTSC).
10749
10750@item 5
10751If the original was telecined from 25 to 30 fps (PAL to NTSC).
10752
10753@item 20
10754If a mixture of the two.
10755@end table
10756
10757The default is @samp{4}.
10758@end table
10759
10760@section delogo
10761
10762Suppress a TV station logo by a simple interpolation of the surrounding
10763pixels. Just set a rectangle covering the logo and watch it disappear
10764(and sometimes something even uglier appear - your mileage may vary).
10765
10766It accepts the following parameters:
10767@table @option
10768
10769@item x
10770@item y
10771Specify the top left corner coordinates of the logo. They must be
10772specified.
10773
10774@item w
10775@item h
10776Specify the width and height of the logo to clear. They must be
10777specified.
10778
10779@item show
10780When set to 1, a green rectangle is drawn on the screen to simplify
10781finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
10782The default value is 0.
10783
10784The rectangle is drawn on the outermost pixels which will be (partly)
10785replaced with interpolated values. The values of the next pixels
10786immediately outside this rectangle in each direction will be used to
10787compute the interpolated pixel values inside the rectangle.
10788
10789@end table
10790
10791@subsection Examples
10792
10793@itemize
10794@item
10795Set a rectangle covering the area with top left corner coordinates 0,0
10796and size 100x77:
10797@example
10798delogo=x=0:y=0:w=100:h=77
10799@end example
10800
10801@end itemize
10802
10803@anchor{derain}
10804@section derain
10805
10806Remove the rain in the input image/video by applying the derain methods based on
10807convolutional neural networks. Supported models:
10808
10809@itemize
10810@item
10811Recurrent Squeeze-and-Excitation Context Aggregation Net (RESCAN).
10812See @url{http://openaccess.thecvf.com/content_ECCV_2018/papers/Xia_Li_Recurrent_Squeeze-and-Excitation_Context_ECCV_2018_paper.pdf}.
10813@end itemize
10814
10815Training as well as model generation scripts are provided in
10816the repository at @url{https://github.com/XueweiMeng/derain_filter.git}.
10817
10818Native model files (.model) can be generated from TensorFlow model
10819files (.pb) by using tools/python/convert.py
10820
10821The filter accepts the following options:
10822
10823@table @option
10824@item filter_type
10825Specify which filter to use. This option accepts the following values:
10826
10827@table @samp
10828@item derain
10829Derain filter. To conduct derain filter, you need to use a derain model.
10830
10831@item dehaze
10832Dehaze filter. To conduct dehaze filter, you need to use a dehaze model.
10833@end table
10834Default value is @samp{derain}.
10835
10836@item dnn_backend
10837Specify which DNN backend to use for model loading and execution. This option accepts
10838the following values:
10839
10840@table @samp
10841@item native
10842Native implementation of DNN loading and execution.
10843
10844@item tensorflow
10845TensorFlow backend. To enable this backend you
10846need to install the TensorFlow for C library (see
10847@url{https://www.tensorflow.org/install/lang_c}) and configure FFmpeg with
10848@code{--enable-libtensorflow}
10849@end table
10850Default value is @samp{native}.
10851
10852@item model
10853Set path to model file specifying network architecture and its parameters.
10854Note that different backends use different file formats. TensorFlow and native
10855backend can load files for only its format.
10856@end table
10857
10858To get full functionality (such as async execution), please use the @ref{dnn_processing} filter.
10859
10860@section deshake
10861
10862Attempt to fix small changes in horizontal and/or vertical shift. This
10863filter helps remove camera shake from hand-holding a camera, bumping a
10864tripod, moving on a vehicle, etc.
10865
10866The filter accepts the following options:
10867
10868@table @option
10869
10870@item x
10871@item y
10872@item w
10873@item h
10874Specify a rectangular area where to limit the search for motion
10875vectors.
10876If desired the search for motion vectors can be limited to a
10877rectangular area of the frame defined by its top left corner, width
10878and height. These parameters have the same meaning as the drawbox
10879filter which can be used to visualise the position of the bounding
10880box.
10881
10882This is useful when simultaneous movement of subjects within the frame
10883might be confused for camera motion by the motion vector search.
10884
10885If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
10886then the full frame is used. This allows later options to be set
10887without specifying the bounding box for the motion vector search.
10888
10889Default - search the whole frame.
10890
10891@item rx
10892@item ry
10893Specify the maximum extent of movement in x and y directions in the
10894range 0-64 pixels. Default 16.
10895
10896@item edge
10897Specify how to generate pixels to fill blanks at the edge of the
10898frame. Available values are:
10899@table @samp
10900@item blank, 0
10901Fill zeroes at blank locations
10902@item original, 1
10903Original image at blank locations
10904@item clamp, 2
10905Extruded edge value at blank locations
10906@item mirror, 3
10907Mirrored edge at blank locations
10908@end table
10909Default value is @samp{mirror}.
10910
10911@item blocksize
10912Specify the blocksize to use for motion search. Range 4-128 pixels,
10913default 8.
10914
10915@item contrast
10916Specify the contrast threshold for blocks. Only blocks with more than
10917the specified contrast (difference between darkest and lightest
10918pixels) will be considered. Range 1-255, default 125.
10919
10920@item search
10921Specify the search strategy. Available values are:
10922@table @samp
10923@item exhaustive, 0
10924Set exhaustive search
10925@item less, 1
10926Set less exhaustive search.
10927@end table
10928Default value is @samp{exhaustive}.
10929
10930@item filename
10931If set then a detailed log of the motion search is written to the
10932specified file.
10933
10934@end table
10935
10936@section despill
10937
10938Remove unwanted contamination of foreground colors, caused by reflected color of
10939greenscreen or bluescreen.
10940
10941This filter accepts the following options:
10942
10943@table @option
10944@item type
10945Set what type of despill to use.
10946
10947@item mix
10948Set how spillmap will be generated.
10949
10950@item expand
10951Set how much to get rid of still remaining spill.
10952
10953@item red
10954Controls amount of red in spill area.
10955
10956@item green
10957Controls amount of green in spill area.
10958Should be -1 for greenscreen.
10959
10960@item blue
10961Controls amount of blue in spill area.
10962Should be -1 for bluescreen.
10963
10964@item brightness
10965Controls brightness of spill area, preserving colors.
10966
10967@item alpha
10968Modify alpha from generated spillmap.
10969@end table
10970
10971@subsection Commands
10972
10973This filter supports the all above options as @ref{commands}.
10974
10975@section detelecine
10976
10977Apply an exact inverse of the telecine operation. It requires a predefined
10978pattern specified using the pattern option which must be the same as that passed
10979to the telecine filter.
10980
10981This filter accepts the following options:
10982
10983@table @option
10984@item first_field
10985@table @samp
10986@item top, t
10987top field first
10988@item bottom, b
10989bottom field first
10990The default value is @code{top}.
10991@end table
10992
10993@item pattern
10994A string of numbers representing the pulldown pattern you wish to apply.
10995The default value is @code{23}.
10996
10997@item start_frame
10998A number representing position of the first frame with respect to the telecine
10999pattern. This is to be used if the stream is cut. The default value is @code{0}.
11000@end table
11001
11002@anchor{dilation}
11003@section dilation
11004
11005Apply dilation effect to the video.
11006
11007This filter replaces the pixel by the local(3x3) maximum.
11008
11009It accepts the following options:
11010
11011@table @option
11012@item threshold0
11013@item threshold1
11014@item threshold2
11015@item threshold3
11016Limit the maximum change for each plane, default is 65535.
11017If 0, plane will remain unchanged.
11018
11019@item coordinates
11020Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
11021pixels are used.
11022
11023Flags to local 3x3 coordinates maps like this:
11024
11025    1 2 3
11026    4   5
11027    6 7 8
11028@end table
11029
11030@subsection Commands
11031
11032This filter supports the all above options as @ref{commands}.
11033
11034@section displace
11035
11036Displace pixels as indicated by second and third input stream.
11037
11038It takes three input streams and outputs one stream, the first input is the
11039source, and second and third input are displacement maps.
11040
11041The second input specifies how much to displace pixels along the
11042x-axis, while the third input specifies how much to displace pixels
11043along the y-axis.
11044If one of displacement map streams terminates, last frame from that
11045displacement map will be used.
11046
11047Note that once generated, displacements maps can be reused over and over again.
11048
11049A description of the accepted options follows.
11050
11051@table @option
11052@item edge
11053Set displace behavior for pixels that are out of range.
11054
11055Available values are:
11056@table @samp
11057@item blank
11058Missing pixels are replaced by black pixels.
11059
11060@item smear
11061Adjacent pixels will spread out to replace missing pixels.
11062
11063@item wrap
11064Out of range pixels are wrapped so they point to pixels of other side.
11065
11066@item mirror
11067Out of range pixels will be replaced with mirrored pixels.
11068@end table
11069Default is @samp{smear}.
11070
11071@end table
11072
11073@subsection Examples
11074
11075@itemize
11076@item
11077Add ripple effect to rgb input of video size hd720:
11078@example
11079ffmpeg -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
11080@end example
11081
11082@item
11083Add wave effect to rgb input of video size hd720:
11084@example
11085ffmpeg -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
11086@end example
11087@end itemize
11088
11089@section dnn_classify
11090
11091Do classification with deep neural networks based on bounding boxes.
11092
11093The filter accepts the following options:
11094
11095@table @option
11096@item dnn_backend
11097Specify which DNN backend to use for model loading and execution. This option accepts
11098only openvino now, tensorflow backends will be added.
11099
11100@item model
11101Set path to model file specifying network architecture and its parameters.
11102Note that different backends use different file formats.
11103
11104@item input
11105Set the input name of the dnn network.
11106
11107@item output
11108Set the output name of the dnn network.
11109
11110@item confidence
11111Set the confidence threshold (default: 0.5).
11112
11113@item labels
11114Set path to label file specifying the mapping between label id and name.
11115Each label name is written in one line, tailing spaces and empty lines are skipped.
11116The first line is the name of label id 0,
11117and the second line is the name of label id 1, etc.
11118The label id is considered as name if the label file is not provided.
11119
11120@item backend_configs
11121Set the configs to be passed into backend
11122
11123For tensorflow backend, you can set its configs with @option{sess_config} options,
11124please use tools/python/tf_sess_config.py to get the configs for your system.
11125
11126@end table
11127
11128@section dnn_detect
11129
11130Do object detection with deep neural networks.
11131
11132The filter accepts the following options:
11133
11134@table @option
11135@item dnn_backend
11136Specify which DNN backend to use for model loading and execution. This option accepts
11137only openvino now, tensorflow backends will be added.
11138
11139@item model
11140Set path to model file specifying network architecture and its parameters.
11141Note that different backends use different file formats.
11142
11143@item input
11144Set the input name of the dnn network.
11145
11146@item output
11147Set the output name of the dnn network.
11148
11149@item confidence
11150Set the confidence threshold (default: 0.5).
11151
11152@item labels
11153Set path to label file specifying the mapping between label id and name.
11154Each label name is written in one line, tailing spaces and empty lines are skipped.
11155The first line is the name of label id 0 (usually it is 'background'),
11156and the second line is the name of label id 1, etc.
11157The label id is considered as name if the label file is not provided.
11158
11159@item backend_configs
11160Set the configs to be passed into backend. To use async execution, set async (default: set).
11161Roll back to sync execution if the backend does not support async.
11162
11163@end table
11164
11165@anchor{dnn_processing}
11166@section dnn_processing
11167
11168Do image processing with deep neural networks. It works together with another filter
11169which converts the pixel format of the Frame to what the dnn network requires.
11170
11171The filter accepts the following options:
11172
11173@table @option
11174@item dnn_backend
11175Specify which DNN backend to use for model loading and execution. This option accepts
11176the following values:
11177
11178@table @samp
11179@item native
11180Native implementation of DNN loading and execution.
11181
11182@item tensorflow
11183TensorFlow backend. To enable this backend you
11184need to install the TensorFlow for C library (see
11185@url{https://www.tensorflow.org/install/lang_c}) and configure FFmpeg with
11186@code{--enable-libtensorflow}
11187
11188@item openvino
11189OpenVINO backend. To enable this backend you
11190need to build and install the OpenVINO for C library (see
11191@url{https://github.com/openvinotoolkit/openvino/blob/master/build-instruction.md}) and configure FFmpeg with
11192@code{--enable-libopenvino} (--extra-cflags=-I... --extra-ldflags=-L... might
11193be needed if the header files and libraries are not installed into system path)
11194
11195@end table
11196
11197Default value is @samp{native}.
11198
11199@item model
11200Set path to model file specifying network architecture and its parameters.
11201Note that different backends use different file formats. TensorFlow, OpenVINO and native
11202backend can load files for only its format.
11203
11204Native model file (.model) can be generated from TensorFlow model file (.pb) by using tools/python/convert.py
11205
11206@item input
11207Set the input name of the dnn network.
11208
11209@item output
11210Set the output name of the dnn network.
11211
11212@item backend_configs
11213Set the configs to be passed into backend. To use async execution, set async (default: set).
11214Roll back to sync execution if the backend does not support async.
11215
11216For tensorflow backend, you can set its configs with @option{sess_config} options,
11217please use tools/python/tf_sess_config.py to get the configs of TensorFlow backend for your system.
11218
11219@end table
11220
11221@subsection Examples
11222
11223@itemize
11224@item
11225Remove rain in rgb24 frame with can.pb (see @ref{derain} filter):
11226@example
11227./ffmpeg -i rain.jpg -vf format=rgb24,dnn_processing=dnn_backend=tensorflow:model=can.pb:input=x:output=y derain.jpg
11228@end example
11229
11230@item
11231Halve the pixel value of the frame with format gray32f:
11232@example
11233ffmpeg -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
11234@end example
11235
11236@item
11237Handle the Y channel with srcnn.pb (see @ref{sr} filter) for frame with yuv420p (planar YUV formats supported):
11238@example
11239./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
11240@end example
11241
11242@item
11243Handle the Y channel with espcn.pb (see @ref{sr} filter), which changes frame size, for format yuv420p (planar YUV formats supported),
11244please use tools/python/tf_sess_config.py to get the configs of TensorFlow backend for your system.
11245@example
11246./ffmpeg -i 480p.jpg -vf format=yuv420p,dnn_processing=dnn_backend=tensorflow:model=espcn.pb:input=x:output=y:backend_configs=sess_config=0x10022805320e09cdccccccccccec3f20012a01303801 -y tmp.espcn.jpg
11247@end example
11248
11249@end itemize
11250
11251@section drawbox
11252
11253Draw a colored box on the input image.
11254
11255It accepts the following parameters:
11256
11257@table @option
11258@item x
11259@item y
11260The expressions which specify the top left corner coordinates of the box. It defaults to 0.
11261
11262@item width, w
11263@item height, h
11264The expressions which specify the width and height of the box; if 0 they are interpreted as
11265the input width and height. It defaults to 0.
11266
11267@item color, c
11268Specify the color of the box to write. For the general syntax of this option,
11269check the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}. If the special
11270value @code{invert} is used, the box edge color is the same as the
11271video with inverted luma.
11272
11273@item thickness, t
11274The expression which sets the thickness of the box edge.
11275A value of @code{fill} will create a filled box. Default value is @code{3}.
11276
11277See below for the list of accepted constants.
11278
11279@item replace
11280Applicable if the input has alpha. With value @code{1}, the pixels of the painted box
11281will overwrite the video's color and alpha pixels.
11282Default is @code{0}, which composites the box onto the input, leaving the video's alpha intact.
11283@end table
11284
11285The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
11286following constants:
11287
11288@table @option
11289@item dar
11290The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
11291
11292@item hsub
11293@item vsub
11294horizontal and vertical chroma subsample values. For example for the
11295pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
11296
11297@item in_h, ih
11298@item in_w, iw
11299The input width and height.
11300
11301@item sar
11302The input sample aspect ratio.
11303
11304@item x
11305@item y
11306The x and y offset coordinates where the box is drawn.
11307
11308@item w
11309@item h
11310The width and height of the drawn box.
11311
11312@item box_source
11313Box source can be set as side_data_detection_bboxes if you want to use box data in
11314detection bboxes of side data.
11315
11316If @var{box_source} is set, the @var{x}, @var{y}, @var{width} and @var{height} will be ignored and
11317still use box data in detection bboxes of side data. So please do not use this parameter if you were
11318not sure about the box source.
11319
11320@item t
11321The thickness of the drawn box.
11322
11323These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
11324each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
11325
11326@end table
11327
11328@subsection Examples
11329
11330@itemize
11331@item
11332Draw a black box around the edge of the input image:
11333@example
11334drawbox
11335@end example
11336
11337@item
11338Draw a box with color red and an opacity of 50%:
11339@example
11340drawbox=10:20:200:60:red@@0.5
11341@end example
11342
11343The previous example can be specified as:
11344@example
11345drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
11346@end example
11347
11348@item
11349Fill the box with pink color:
11350@example
11351drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=fill
11352@end example
11353
11354@item
11355Draw a 2-pixel red 2.40:1 mask:
11356@example
11357drawbox=x=-t:y=0.5*(ih-iw/2.4)-t:w=iw+t*2:h=iw/2.4+t*2:t=2:c=red
11358@end example
11359@end itemize
11360
11361@subsection Commands
11362This filter supports same commands as options.
11363The command accepts the same syntax of the corresponding option.
11364
11365If the specified expression is not valid, it is kept at its current
11366value.
11367
11368@anchor{drawgraph}
11369@section drawgraph
11370Draw a graph using input video metadata.
11371
11372It accepts the following parameters:
11373
11374@table @option
11375@item m1
11376Set 1st frame metadata key from which metadata values will be used to draw a graph.
11377
11378@item fg1
11379Set 1st foreground color expression.
11380
11381@item m2
11382Set 2nd frame metadata key from which metadata values will be used to draw a graph.
11383
11384@item fg2
11385Set 2nd foreground color expression.
11386
11387@item m3
11388Set 3rd frame metadata key from which metadata values will be used to draw a graph.
11389
11390@item fg3
11391Set 3rd foreground color expression.
11392
11393@item m4
11394Set 4th frame metadata key from which metadata values will be used to draw a graph.
11395
11396@item fg4
11397Set 4th foreground color expression.
11398
11399@item min
11400Set minimal value of metadata value.
11401
11402@item max
11403Set maximal value of metadata value.
11404
11405@item bg
11406Set graph background color. Default is white.
11407
11408@item mode
11409Set graph mode.
11410
11411Available values for mode is:
11412@table @samp
11413@item bar
11414@item dot
11415@item line
11416@end table
11417
11418Default is @code{line}.
11419
11420@item slide
11421Set slide mode.
11422
11423Available values for slide is:
11424@table @samp
11425@item frame
11426Draw new frame when right border is reached.
11427
11428@item replace
11429Replace old columns with new ones.
11430
11431@item scroll
11432Scroll from right to left.
11433
11434@item rscroll
11435Scroll from left to right.
11436
11437@item picture
11438Draw single picture.
11439@end table
11440
11441Default is @code{frame}.
11442
11443@item size
11444Set size of graph video. For the syntax of this option, check the
11445@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
11446The default value is @code{900x256}.
11447
11448@item rate, r
11449Set the output frame rate. Default value is @code{25}.
11450
11451The foreground color expressions can use the following variables:
11452@table @option
11453@item MIN
11454Minimal value of metadata value.
11455
11456@item MAX
11457Maximal value of metadata value.
11458
11459@item VAL
11460Current metadata key value.
11461@end table
11462
11463The color is defined as 0xAABBGGRR.
11464@end table
11465
11466Example using metadata from @ref{signalstats} filter:
11467@example
11468signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255
11469@end example
11470
11471Example using metadata from @ref{ebur128} filter:
11472@example
11473ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5
11474@end example
11475
11476@section drawgrid
11477
11478Draw a grid on the input image.
11479
11480It accepts the following parameters:
11481
11482@table @option
11483@item x
11484@item y
11485The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
11486
11487@item width, w
11488@item height, h
11489The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
11490input width and height, respectively, minus @code{thickness}, so image gets
11491framed. Default to 0.
11492
11493@item color, c
11494Specify the color of the grid. For the general syntax of this option,
11495check the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}. If the special
11496value @code{invert} is used, the grid color is the same as the
11497video with inverted luma.
11498
11499@item thickness, t
11500The expression which sets the thickness of the grid line. Default value is @code{1}.
11501
11502See below for the list of accepted constants.
11503
11504@item replace
11505Applicable if the input has alpha. With @code{1} the pixels of the painted grid
11506will overwrite the video's color and alpha pixels.
11507Default is @code{0}, which composites the grid onto the input, leaving the video's alpha intact.
11508@end table
11509
11510The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
11511following constants:
11512
11513@table @option
11514@item dar
11515The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
11516
11517@item hsub
11518@item vsub
11519horizontal and vertical chroma subsample values. For example for the
11520pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
11521
11522@item in_h, ih
11523@item in_w, iw
11524The input grid cell width and height.
11525
11526@item sar
11527The input sample aspect ratio.
11528
11529@item x
11530@item y
11531The x and y coordinates of some point of grid intersection (meant to configure offset).
11532
11533@item w
11534@item h
11535The width and height of the drawn cell.
11536
11537@item t
11538The thickness of the drawn cell.
11539
11540These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
11541each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
11542
11543@end table
11544
11545@subsection Examples
11546
11547@itemize
11548@item
11549Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
11550@example
11551drawgrid=width=100:height=100:thickness=2:color=red@@0.5
11552@end example
11553
11554@item
11555Draw a white 3x3 grid with an opacity of 50%:
11556@example
11557drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
11558@end example
11559@end itemize
11560
11561@subsection Commands
11562This filter supports same commands as options.
11563The command accepts the same syntax of the corresponding option.
11564
11565If the specified expression is not valid, it is kept at its current
11566value.
11567
11568@anchor{drawtext}
11569@section drawtext
11570
11571Draw a text string or text from a specified file on top of a video, using the
11572libfreetype library.
11573
11574To enable compilation of this filter, you need to configure FFmpeg with
11575@code{--enable-libfreetype}.
11576To enable default font fallback and the @var{font} option you need to
11577configure FFmpeg with @code{--enable-libfontconfig}.
11578To enable the @var{text_shaping} option, you need to configure FFmpeg with
11579@code{--enable-libfribidi}.
11580
11581@subsection Syntax
11582
11583It accepts the following parameters:
11584
11585@table @option
11586
11587@item box
11588Used to draw a box around text using the background color.
11589The value must be either 1 (enable) or 0 (disable).
11590The default value of @var{box} is 0.
11591
11592@item boxborderw
11593Set the width of the border to be drawn around the box using @var{boxcolor}.
11594The default value of @var{boxborderw} is 0.
11595
11596@item boxcolor
11597The color to be used for drawing box around text. For the syntax of this
11598option, check the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.
11599
11600The default value of @var{boxcolor} is "white".
11601
11602@item line_spacing
11603Set the line spacing in pixels of the border to be drawn around the box using @var{box}.
11604The default value of @var{line_spacing} is 0.
11605
11606@item borderw
11607Set the width of the border to be drawn around the text using @var{bordercolor}.
11608The default value of @var{borderw} is 0.
11609
11610@item bordercolor
11611Set the color to be used for drawing border around text. For the syntax of this
11612option, check the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.
11613
11614The default value of @var{bordercolor} is "black".
11615
11616@item expansion
11617Select how the @var{text} is expanded. Can be either @code{none},
11618@code{strftime} (deprecated) or
11619@code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
11620below for details.
11621
11622@item basetime
11623Set a start time for the count. Value is in microseconds. Only applied
11624in the deprecated strftime expansion mode. To emulate in normal expansion
11625mode use the @code{pts} function, supplying the start time (in seconds)
11626as the second argument.
11627
11628@item fix_bounds
11629If true, check and fix text coords to avoid clipping.
11630
11631@item fontcolor
11632The color to be used for drawing fonts. For the syntax of this option, check
11633the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.
11634
11635The default value of @var{fontcolor} is "black".
11636
11637@item fontcolor_expr
11638String which is expanded the same way as @var{text} to obtain dynamic
11639@var{fontcolor} value. By default this option has empty value and is not
11640processed. When this option is set, it overrides @var{fontcolor} option.
11641
11642@item font
11643The font family to be used for drawing text. By default Sans.
11644
11645@item fontfile
11646The font file to be used for drawing text. The path must be included.
11647This parameter is mandatory if the fontconfig support is disabled.
11648
11649@item alpha
11650Draw the text applying alpha blending. The value can
11651be a number between 0.0 and 1.0.
11652The expression accepts the same variables @var{x, y} as well.
11653The default value is 1.
11654Please see @var{fontcolor_expr}.
11655
11656@item fontsize
11657The font size to be used for drawing text.
11658The default value of @var{fontsize} is 16.
11659
11660@item text_shaping
11661If set to 1, attempt to shape the text (for example, reverse the order of
11662right-to-left text and join Arabic characters) before drawing it.
11663Otherwise, just draw the text exactly as given.
11664By default 1 (if supported).
11665
11666@item ft_load_flags
11667The flags to be used for loading the fonts.
11668
11669The flags map the corresponding flags supported by libfreetype, and are
11670a combination of the following values:
11671@table @var
11672@item default
11673@item no_scale
11674@item no_hinting
11675@item render
11676@item no_bitmap
11677@item vertical_layout
11678@item force_autohint
11679@item crop_bitmap
11680@item pedantic
11681@item ignore_global_advance_width
11682@item no_recurse
11683@item ignore_transform
11684@item monochrome
11685@item linear_design
11686@item no_autohint
11687@end table
11688
11689Default value is "default".
11690
11691For more information consult the documentation for the FT_LOAD_*
11692libfreetype flags.
11693
11694@item shadowcolor
11695The color to be used for drawing a shadow behind the drawn text. For the
11696syntax of this option, check the @ref{color syntax,,"Color" section in the
11697ffmpeg-utils manual,ffmpeg-utils}.
11698
11699The default value of @var{shadowcolor} is "black".
11700
11701@item shadowx
11702@item shadowy
11703The x and y offsets for the text shadow position with respect to the
11704position of the text. They can be either positive or negative
11705values. The default value for both is "0".
11706
11707@item start_number
11708The starting frame number for the n/frame_num variable. The default value
11709is "0".
11710
11711@item tabsize
11712The size in number of spaces to use for rendering the tab.
11713Default value is 4.
11714
11715@item timecode
11716Set the initial timecode representation in "hh:mm:ss[:;.]ff"
11717format. It can be used with or without text parameter. @var{timecode_rate}
11718option must be specified.
11719
11720@item timecode_rate, rate, r
11721Set the timecode frame rate (timecode only). Value will be rounded to nearest
11722integer. Minimum value is "1".
11723Drop-frame timecode is supported for frame rates 30 & 60.
11724
11725@item tc24hmax
11726If set to 1, the output of the timecode option will wrap around at 24 hours.
11727Default is 0 (disabled).
11728
11729@item text
11730The text string to be drawn. The text must be a sequence of UTF-8
11731encoded characters.
11732This parameter is mandatory if no file is specified with the parameter
11733@var{textfile}.
11734
11735@item textfile
11736A text file containing text to be drawn. The text must be a sequence
11737of UTF-8 encoded characters.
11738
11739This parameter is mandatory if no text string is specified with the
11740parameter @var{text}.
11741
11742If both @var{text} and @var{textfile} are specified, an error is thrown.
11743
11744@item text_source
11745Text source should be set as side_data_detection_bboxes if you want to use text data in
11746detection bboxes of side data.
11747
11748If text source is set, @var{text} and @var{textfile} will be ignored and still use
11749text data in detection bboxes of side data. So please do not use this parameter
11750if you are not sure about the text source.
11751
11752@item reload
11753The @var{textfile} will be reloaded at specified frame interval.
11754Be sure to update @var{textfile} atomically, or it may be read partially,
11755or even fail.
11756Range is 0 to INT_MAX. Default is 0.
11757
11758@item x
11759@item y
11760The expressions which specify the offsets where text will be drawn
11761within the video frame. They are relative to the top/left border of the
11762output image.
11763
11764The default value of @var{x} and @var{y} is "0".
11765
11766See below for the list of accepted constants and functions.
11767@end table
11768
11769The parameters for @var{x} and @var{y} are expressions containing the
11770following constants and functions:
11771
11772@table @option
11773@item dar
11774input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
11775
11776@item hsub
11777@item vsub
11778horizontal and vertical chroma subsample values. For example for the
11779pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
11780
11781@item line_h, lh
11782the height of each text line
11783
11784@item main_h, h, H
11785the input height
11786
11787@item main_w, w, W
11788the input width
11789
11790@item max_glyph_a, ascent
11791the maximum distance from the baseline to the highest/upper grid
11792coordinate used to place a glyph outline point, for all the rendered
11793glyphs.
11794It is a positive value, due to the grid's orientation with the Y axis
11795upwards.
11796
11797@item max_glyph_d, descent
11798the maximum distance from the baseline to the lowest grid coordinate
11799used to place a glyph outline point, for all the rendered glyphs.
11800This is a negative value, due to the grid's orientation, with the Y axis
11801upwards.
11802
11803@item max_glyph_h
11804maximum glyph height, that is the maximum height for all the glyphs
11805contained in the rendered text, it is equivalent to @var{ascent} -
11806@var{descent}.
11807
11808@item max_glyph_w
11809maximum glyph width, that is the maximum width for all the glyphs
11810contained in the rendered text
11811
11812@item n
11813the number of input frame, starting from 0
11814
11815@item rand(min, max)
11816return a random number included between @var{min} and @var{max}
11817
11818@item sar
11819The input sample aspect ratio.
11820
11821@item t
11822timestamp expressed in seconds, NAN if the input timestamp is unknown
11823
11824@item text_h, th
11825the height of the rendered text
11826
11827@item text_w, tw
11828the width of the rendered text
11829
11830@item x
11831@item y
11832the x and y offset coordinates where the text is drawn.
11833
11834These parameters allow the @var{x} and @var{y} expressions to refer
11835to each other, so you can for example specify @code{y=x/dar}.
11836
11837@item pict_type
11838A one character description of the current frame's picture type.
11839
11840@item pkt_pos
11841The current packet's position in the input file or stream
11842(in bytes, from the start of the input). A value of -1 indicates
11843this info is not available.
11844
11845@item pkt_duration
11846The current packet's duration, in seconds.
11847
11848@item pkt_size
11849The current packet's size (in bytes).
11850@end table
11851
11852@anchor{drawtext_expansion}
11853@subsection Text expansion
11854
11855If @option{expansion} is set to @code{strftime},
11856the filter recognizes strftime() sequences in the provided text and
11857expands them accordingly. Check the documentation of strftime(). This
11858feature is deprecated.
11859
11860If @option{expansion} is set to @code{none}, the text is printed verbatim.
11861
11862If @option{expansion} is set to @code{normal} (which is the default),
11863the following expansion mechanism is used.
11864
11865The backslash character @samp{\}, followed by any character, always expands to
11866the second character.
11867
11868Sequences of the form @code{%@{...@}} are expanded. The text between the
11869braces is a function name, possibly followed by arguments separated by ':'.
11870If the arguments contain special characters or delimiters (':' or '@}'),
11871they should be escaped.
11872
11873Note that they probably must also be escaped as the value for the
11874@option{text} option in the filter argument string and as the filter
11875argument in the filtergraph description, and possibly also for the shell,
11876that makes up to four levels of escaping; using a text file avoids these
11877problems.
11878
11879The following functions are available:
11880
11881@table @command
11882
11883@item expr, e
11884The expression evaluation result.
11885
11886It must take one argument specifying the expression to be evaluated,
11887which accepts the same constants and functions as the @var{x} and
11888@var{y} values. Note that not all constants should be used, for
11889example the text size is not known when evaluating the expression, so
11890the constants @var{text_w} and @var{text_h} will have an undefined
11891value.
11892
11893@item expr_int_format, eif
11894Evaluate the expression's value and output as formatted integer.
11895
11896The first argument is the expression to be evaluated, just as for the @var{expr} function.
11897The second argument specifies the output format. Allowed values are @samp{x},
11898@samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
11899@code{printf} function.
11900The third parameter is optional and sets the number of positions taken by the output.
11901It can be used to add padding with zeros from the left.
11902
11903@item gmtime
11904The time at which the filter is running, expressed in UTC.
11905It can accept an argument: a strftime() format string.
11906The format string is extended to support the variable @var{%[1-6]N}
11907which prints fractions of the second with optionally specified number of digits.
11908
11909@item localtime
11910The time at which the filter is running, expressed in the local time zone.
11911It can accept an argument: a strftime() format string.
11912The format string is extended to support the variable @var{%[1-6]N}
11913which prints fractions of the second with optionally specified number of digits.
11914
11915@item metadata
11916Frame metadata. Takes one or two arguments.
11917
11918The first argument is mandatory and specifies the metadata key.
11919
11920The second argument is optional and specifies a default value, used when the
11921metadata key is not found or empty.
11922
11923Available metadata can be identified by inspecting entries
11924starting with TAG included within each frame section
11925printed by running @code{ffprobe -show_frames}.
11926
11927String metadata generated in filters leading to
11928the drawtext filter are also available.
11929
11930@item n, frame_num
11931The frame number, starting from 0.
11932
11933@item pict_type
11934A one character description of the current picture type.
11935
11936@item pts
11937The timestamp of the current frame.
11938It can take up to three arguments.
11939
11940The first argument is the format of the timestamp; it defaults to @code{flt}
11941for seconds as a decimal number with microsecond accuracy; @code{hms} stands
11942for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
11943@code{gmtime} stands for the timestamp of the frame formatted as UTC time;
11944@code{localtime} stands for the timestamp of the frame formatted as
11945local time zone time.
11946
11947The second argument is an offset added to the timestamp.
11948
11949If the format is set to @code{hms}, a third argument @code{24HH} may be
11950supplied to present the hour part of the formatted timestamp in 24h format
11951(00-23).
11952
11953If the format is set to @code{localtime} or @code{gmtime},
11954a third argument may be supplied: a strftime() format string.
11955By default, @var{YYYY-MM-DD HH:MM:SS} format will be used.
11956@end table
11957
11958@subsection Commands
11959
11960This filter supports altering parameters via commands:
11961@table @option
11962@item reinit
11963Alter existing filter parameters.
11964
11965Syntax for the argument is the same as for filter invocation, e.g.
11966
11967@example
11968fontsize=56:fontcolor=green:text='Hello World'
11969@end example
11970
11971Full filter invocation with sendcmd would look like this:
11972
11973@example
11974sendcmd=c='56.0 drawtext reinit fontsize=56\:fontcolor=green\:text=Hello\\ World'
11975@end example
11976@end table
11977
11978If the entire argument can't be parsed or applied as valid values then the filter will
11979continue with its existing parameters.
11980
11981@subsection Examples
11982
11983@itemize
11984@item
11985Draw "Test Text" with font FreeSerif, using the default values for the
11986optional parameters.
11987
11988@example
11989drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
11990@end example
11991
11992@item
11993Draw 'Test Text' with font FreeSerif of size 24 at position x=100
11994and y=50 (counting from the top-left corner of the screen), text is
11995yellow with a red box around it. Both the text and the box have an
11996opacity of 20%.
11997
11998@example
11999drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
12000          x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
12001@end example
12002
12003Note that the double quotes are not necessary if spaces are not used
12004within the parameter list.
12005
12006@item
12007Show the text at the center of the video frame:
12008@example
12009drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2"
12010@end example
12011
12012@item
12013Show the text at a random position, switching to a new position every 30 seconds:
12014@example
12015drawtext="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)"
12016@end example
12017
12018@item
12019Show a text line sliding from right to left in the last row of the video
12020frame. The file @file{LONG_LINE} is assumed to contain a single line
12021with no newlines.
12022@example
12023drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
12024@end example
12025
12026@item
12027Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
12028@example
12029drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
12030@end example
12031
12032@item
12033Draw a single green letter "g", at the center of the input video.
12034The glyph baseline is placed at half screen height.
12035@example
12036drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
12037@end example
12038
12039@item
12040Show text for 1 second every 3 seconds:
12041@example
12042drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
12043@end example
12044
12045@item
12046Use fontconfig to set the font. Note that the colons need to be escaped.
12047@example
12048drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
12049@end example
12050
12051@item
12052Draw "Test Text" with font size dependent on height of the video.
12053@example
12054drawtext="text='Test Text': fontsize=h/30: x=(w-text_w)/2: y=(h-text_h*2)"
12055@end example
12056
12057@item
12058Print the date of a real-time encoding (see strftime(3)):
12059@example
12060drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
12061@end example
12062
12063@item
12064Show text fading in and out (appearing/disappearing):
12065@example
12066#!/bin/sh
12067DS=1.0 # display start
12068DE=10.0 # display end
12069FID=1.5 # fade in duration
12070FOD=5 # fade out duration
12071ffplay -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 @}"
12072@end example
12073
12074@item
12075Horizontally align multiple separate texts. Note that @option{max_glyph_a}
12076and the @option{fontsize} value are included in the @option{y} offset.
12077@example
12078drawtext=fontfile=FreeSans.ttf:text=DOG:fontsize=24:x=10:y=20+24-max_glyph_a,
12079drawtext=fontfile=FreeSans.ttf:text=cow:fontsize=24:x=80:y=20+24-max_glyph_a
12080@end example
12081
12082@item
12083Plot special @var{lavf.image2dec.source_basename} metadata onto each frame if
12084such metadata exists. Otherwise, plot the string "NA". Note that image2 demuxer
12085must have option @option{-export_path_metadata 1} for the special metadata fields
12086to be available for filters.
12087@example
12088drawtext="fontsize=20:fontcolor=white:fontfile=FreeSans.ttf:text='%@{metadata\:lavf.image2dec.source_basename\:NA@}':x=10:y=10"
12089@end example
12090
12091@end itemize
12092
12093For more information about libfreetype, check:
12094@url{http://www.freetype.org/}.
12095
12096For more information about fontconfig, check:
12097@url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
12098
12099For more information about libfribidi, check:
12100@url{http://fribidi.org/}.
12101
12102@section edgedetect
12103
12104Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
12105
12106The filter accepts the following options:
12107
12108@table @option
12109@item low
12110@item high
12111Set low and high threshold values used by the Canny thresholding
12112algorithm.
12113
12114The high threshold selects the "strong" edge pixels, which are then
12115connected through 8-connectivity with the "weak" edge pixels selected
12116by the low threshold.
12117
12118@var{low} and @var{high} threshold values must be chosen in the range
12119[0,1], and @var{low} should be lesser or equal to @var{high}.
12120
12121Default value for @var{low} is @code{20/255}, and default value for @var{high}
12122is @code{50/255}.
12123
12124@item mode
12125Define the drawing mode.
12126
12127@table @samp
12128@item wires
12129Draw white/gray wires on black background.
12130
12131@item colormix
12132Mix the colors to create a paint/cartoon effect.
12133
12134@item canny
12135Apply Canny edge detector on all selected planes.
12136@end table
12137Default value is @var{wires}.
12138
12139@item planes
12140Select planes for filtering. By default all available planes are filtered.
12141@end table
12142
12143@subsection Examples
12144
12145@itemize
12146@item
12147Standard edge detection with custom values for the hysteresis thresholding:
12148@example
12149edgedetect=low=0.1:high=0.4
12150@end example
12151
12152@item
12153Painting effect without thresholding:
12154@example
12155edgedetect=mode=colormix:high=0
12156@end example
12157@end itemize
12158
12159@section elbg
12160
12161Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
12162
12163For each input image, the filter will compute the optimal mapping from
12164the input to the output given the codebook length, that is the number
12165of distinct output colors.
12166
12167This filter accepts the following options.
12168
12169@table @option
12170@item codebook_length, l
12171Set codebook length. The value must be a positive integer, and
12172represents the number of distinct output colors. Default value is 256.
12173
12174@item nb_steps, n
12175Set the maximum number of iterations to apply for computing the optimal
12176mapping. The higher the value the better the result and the higher the
12177computation time. Default value is 1.
12178
12179@item seed, s
12180Set a random seed, must be an integer included between 0 and
12181UINT32_MAX. If not specified, or if explicitly set to -1, the filter
12182will try to use a good random seed on a best effort basis.
12183
12184@item pal8
12185Set pal8 output pixel format. This option does not work with codebook
12186length greater than 256. Default is disabled.
12187
12188@item use_alpha
12189Include alpha values in the quantization calculation. Allows creating
12190palettized output images (e.g. PNG8) with multiple alpha smooth blending.
12191@end table
12192
12193@section entropy
12194
12195Measure graylevel entropy in histogram of color channels of video frames.
12196
12197It accepts the following parameters:
12198
12199@table @option
12200@item mode
12201Can be either @var{normal} or @var{diff}. Default is @var{normal}.
12202
12203@var{diff} mode measures entropy of histogram delta values, absolute differences
12204between neighbour histogram values.
12205@end table
12206
12207@section epx
12208Apply the EPX magnification filter which is designed for pixel art.
12209
12210It accepts the following option:
12211
12212@table @option
12213@item n
12214Set the scaling dimension: @code{2} for @code{2xEPX}, @code{3} for
12215@code{3xEPX}.
12216Default is @code{3}.
12217@end table
12218
12219@section eq
12220Set brightness, contrast, saturation and approximate gamma adjustment.
12221
12222The filter accepts the following options:
12223
12224@table @option
12225@item contrast
12226Set the contrast expression. The value must be a float value in range
12227@code{-1000.0} to @code{1000.0}. The default value is "1".
12228
12229@item brightness
12230Set the brightness expression. The value must be a float value in
12231range @code{-1.0} to @code{1.0}. The default value is "0".
12232
12233@item saturation
12234Set the saturation expression. The value must be a float in
12235range @code{0.0} to @code{3.0}. The default value is "1".
12236
12237@item gamma
12238Set the gamma expression. The value must be a float in range
12239@code{0.1} to @code{10.0}.  The default value is "1".
12240
12241@item gamma_r
12242Set the gamma expression for red. The value must be a float in
12243range @code{0.1} to @code{10.0}. The default value is "1".
12244
12245@item gamma_g
12246Set the gamma expression for green. The value must be a float in range
12247@code{0.1} to @code{10.0}. The default value is "1".
12248
12249@item gamma_b
12250Set the gamma expression for blue. The value must be a float in range
12251@code{0.1} to @code{10.0}. The default value is "1".
12252
12253@item gamma_weight
12254Set the gamma weight expression. It can be used to reduce the effect
12255of a high gamma value on bright image areas, e.g. keep them from
12256getting overamplified and just plain white. The value must be a float
12257in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
12258gamma correction all the way down while @code{1.0} leaves it at its
12259full strength. Default is "1".
12260
12261@item eval
12262Set when the expressions for brightness, contrast, saturation and
12263gamma expressions are evaluated.
12264
12265It accepts the following values:
12266@table @samp
12267@item init
12268only evaluate expressions once during the filter initialization or
12269when a command is processed
12270
12271@item frame
12272evaluate expressions for each incoming frame
12273@end table
12274
12275Default value is @samp{init}.
12276@end table
12277
12278The expressions accept the following parameters:
12279@table @option
12280@item n
12281frame count of the input frame starting from 0
12282
12283@item pos
12284byte position of the corresponding packet in the input file, NAN if
12285unspecified
12286
12287@item r
12288frame rate of the input video, NAN if the input frame rate is unknown
12289
12290@item t
12291timestamp expressed in seconds, NAN if the input timestamp is unknown
12292@end table
12293
12294@subsection Commands
12295The filter supports the following commands:
12296
12297@table @option
12298@item contrast
12299Set the contrast expression.
12300
12301@item brightness
12302Set the brightness expression.
12303
12304@item saturation
12305Set the saturation expression.
12306
12307@item gamma
12308Set the gamma expression.
12309
12310@item gamma_r
12311Set the gamma_r expression.
12312
12313@item gamma_g
12314Set gamma_g expression.
12315
12316@item gamma_b
12317Set gamma_b expression.
12318
12319@item gamma_weight
12320Set gamma_weight expression.
12321
12322The command accepts the same syntax of the corresponding option.
12323
12324If the specified expression is not valid, it is kept at its current
12325value.
12326
12327@end table
12328
12329@anchor{erosion}
12330@section erosion
12331
12332Apply erosion effect to the video.
12333
12334This filter replaces the pixel by the local(3x3) minimum.
12335
12336It accepts the following options:
12337
12338@table @option
12339@item threshold0
12340@item threshold1
12341@item threshold2
12342@item threshold3
12343Limit the maximum change for each plane, default is 65535.
12344If 0, plane will remain unchanged.
12345
12346@item coordinates
12347Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
12348pixels are used.
12349
12350Flags to local 3x3 coordinates maps like this:
12351
12352    1 2 3
12353    4   5
12354    6 7 8
12355@end table
12356
12357@subsection Commands
12358
12359This filter supports the all above options as @ref{commands}.
12360
12361@section estdif
12362
12363Deinterlace the input video ("estdif" stands for "Edge Slope
12364Tracing Deinterlacing Filter").
12365
12366Spatial only filter that uses edge slope tracing algorithm
12367to interpolate missing lines.
12368It accepts the following parameters:
12369
12370@table @option
12371@item mode
12372The interlacing mode to adopt. It accepts one of the following values:
12373
12374@table @option
12375@item frame
12376Output one frame for each frame.
12377@item field
12378Output one frame for each field.
12379@end table
12380
12381The default value is @code{field}.
12382
12383@item parity
12384The picture field parity assumed for the input interlaced video. It accepts one
12385of the following values:
12386
12387@table @option
12388@item tff
12389Assume the top field is first.
12390@item bff
12391Assume the bottom field is first.
12392@item auto
12393Enable automatic detection of field parity.
12394@end table
12395
12396The default value is @code{auto}.
12397If the interlacing is unknown or the decoder does not export this information,
12398top field first will be assumed.
12399
12400@item deint
12401Specify which frames to deinterlace. Accepts one of the following
12402values:
12403
12404@table @option
12405@item all
12406Deinterlace all frames.
12407@item interlaced
12408Only deinterlace frames marked as interlaced.
12409@end table
12410
12411The default value is @code{all}.
12412
12413@item rslope
12414Specify the search radius for edge slope tracing. Default value is 1.
12415Allowed range is from 1 to 15.
12416
12417@item redge
12418Specify the search radius for best edge matching. Default value is 2.
12419Allowed range is from 0 to 15.
12420
12421@item ecost
12422Specify the edge cost for edge matching. Default value is 1.0.
12423Allowed range is from 0 to 9.
12424
12425@item mcost
12426Specify the middle cost for edge matching. Default value is 0.5.
12427Allowed range is from 0 to 1.
12428
12429@item dcost
12430Specify the distance cost for edge matching. Default value is 0.5.
12431Allowed range is from 0 to 1.
12432
12433@item interp
12434Specify the interpolation used. Default is 4-point interpolation. It accepts one
12435of the following values:
12436
12437@table @option
12438@item 2p
12439Two-point interpolation.
12440@item 4p
12441Four-point interpolation.
12442@item 6p
12443Six-point interpolation.
12444@end table
12445@end table
12446
12447@subsection Commands
12448This filter supports same @ref{commands} as options.
12449
12450@section exposure
12451Adjust exposure of the video stream.
12452
12453The filter accepts the following options:
12454
12455@table @option
12456@item exposure
12457Set the exposure correction in EV. Allowed range is from -3.0 to 3.0 EV
12458Default value is 0 EV.
12459
12460@item black
12461Set the black level correction. Allowed range is from -1.0 to 1.0.
12462Default value is 0.
12463@end table
12464
12465@subsection Commands
12466
12467This filter supports same @ref{commands} as options.
12468
12469@section extractplanes
12470
12471Extract color channel components from input video stream into
12472separate grayscale video streams.
12473
12474The filter accepts the following option:
12475
12476@table @option
12477@item planes
12478Set plane(s) to extract.
12479
12480Available values for planes are:
12481@table @samp
12482@item y
12483@item u
12484@item v
12485@item a
12486@item r
12487@item g
12488@item b
12489@end table
12490
12491Choosing planes not available in the input will result in an error.
12492That means you cannot select @code{r}, @code{g}, @code{b} planes
12493with @code{y}, @code{u}, @code{v} planes at same time.
12494@end table
12495
12496@subsection Examples
12497
12498@itemize
12499@item
12500Extract luma, u and v color channel component from input video frame
12501into 3 grayscale outputs:
12502@example
12503ffmpeg -i video.avi -filter_complex 'extractplanes=y+u+v[y][u][v]' -map '[y]' y.avi -map '[u]' u.avi -map '[v]' v.avi
12504@end example
12505@end itemize
12506
12507@section fade
12508
12509Apply a fade-in/out effect to the input video.
12510
12511It accepts the following parameters:
12512
12513@table @option
12514@item type, t
12515The effect type can be either "in" for a fade-in, or "out" for a fade-out
12516effect.
12517Default is @code{in}.
12518
12519@item start_frame, s
12520Specify the number of the frame to start applying the fade
12521effect at. Default is 0.
12522
12523@item nb_frames, n
12524The number of frames that the fade effect lasts. At the end of the
12525fade-in effect, the output video will have the same intensity as the input video.
12526At the end of the fade-out transition, the output video will be filled with the
12527selected @option{color}.
12528Default is 25.
12529
12530@item alpha
12531If set to 1, fade only alpha channel, if one exists on the input.
12532Default value is 0.
12533
12534@item start_time, st
12535Specify the timestamp (in seconds) of the frame to start to apply the fade
12536effect. If both start_frame and start_time are specified, the fade will start at
12537whichever comes last.  Default is 0.
12538
12539@item duration, d
12540The number of seconds for which the fade effect has to last. At the end of the
12541fade-in effect the output video will have the same intensity as the input video,
12542at the end of the fade-out transition the output video will be filled with the
12543selected @option{color}.
12544If both duration and nb_frames are specified, duration is used. Default is 0
12545(nb_frames is used by default).
12546
12547@item color, c
12548Specify the color of the fade. Default is "black".
12549@end table
12550
12551@subsection Examples
12552
12553@itemize
12554@item
12555Fade in the first 30 frames of video:
12556@example
12557fade=in:0:30
12558@end example
12559
12560The command above is equivalent to:
12561@example
12562fade=t=in:s=0:n=30
12563@end example
12564
12565@item
12566Fade out the last 45 frames of a 200-frame video:
12567@example
12568fade=out:155:45
12569fade=type=out:start_frame=155:nb_frames=45
12570@end example
12571
12572@item
12573Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
12574@example
12575fade=in:0:25, fade=out:975:25
12576@end example
12577
12578@item
12579Make the first 5 frames yellow, then fade in from frame 5-24:
12580@example
12581fade=in:5:20:color=yellow
12582@end example
12583
12584@item
12585Fade in alpha over first 25 frames of video:
12586@example
12587fade=in:0:25:alpha=1
12588@end example
12589
12590@item
12591Make the first 5.5 seconds black, then fade in for 0.5 seconds:
12592@example
12593fade=t=in:st=5.5:d=0.5
12594@end example
12595
12596@end itemize
12597
12598@section feedback
12599Apply feedback video filter.
12600
12601This filter pass cropped input frames to 2nd output.
12602From there it can be filtered with other video filters.
12603After filter receives frame from 2nd input, that frame
12604is combined on top of original frame from 1st input and passed
12605to 1st output.
12606
12607The typical usage is filter only part of frame.
12608
12609The filter accepts the following options:
12610@table @option
12611@item x
12612@item y
12613Set the top left crop position.
12614
12615@item w
12616@item h
12617Set the crop size.
12618@end table
12619
12620@subsection Examples
12621
12622@itemize
12623@item
12624Blur only top left rectangular part of video frame size 100x100 with gblur filter.
12625@example
12626[in][blurin]feedback=x=0:y=0:w=100:h=100[out][blurout];[blurout]gblur=8[blurin]
12627@end example
12628
12629@item
12630Draw black box on top left part of video frame of size 100x100 with drawbox filter.
12631@example
12632[in][blurin]feedback=x=0:y=0:w=100:h=100[out][blurout];[blurout]drawbox=x=0:y=0:w=100:h=100:t=100[blurin]
12633@end example
12634@end itemize
12635
12636@section fftdnoiz
12637Denoise frames using 3D FFT (frequency domain filtering).
12638
12639The filter accepts the following options:
12640
12641@table @option
12642@item sigma
12643Set the noise sigma constant. This sets denoising strength.
12644Default value is 1. Allowed range is from 0 to 30.
12645Using very high sigma with low overlap may give blocking artifacts.
12646
12647@item amount
12648Set amount of denoising. By default all detected noise is reduced.
12649Default value is 1. Allowed range is from 0 to 1.
12650
12651@item block
12652Set size of block in pixels, Default is 32, can be 8 to 256.
12653
12654@item overlap
12655Set block overlap. Default is 0.5. Allowed range is from 0.2 to 0.8.
12656
12657@item method
12658Set denoising method. Default is @code{wiener}, can also be @code{hard}.
12659
12660@item prev
12661Set number of previous frames to use for denoising. By default is set to 0.
12662
12663@item next
12664Set number of next frames to to use for denoising. By default is set to 0.
12665
12666@item planes
12667Set planes which will be filtered, by default are all available filtered
12668except alpha.
12669@end table
12670
12671@section fftfilt
12672Apply arbitrary expressions to samples in frequency domain
12673
12674@table @option
12675@item dc_Y
12676Adjust the dc value (gain) of the luma plane of the image. The filter
12677accepts an integer value in range @code{0} to @code{1000}. The default
12678value is set to @code{0}.
12679
12680@item dc_U
12681Adjust the dc value (gain) of the 1st chroma plane of the image. The
12682filter accepts an integer value in range @code{0} to @code{1000}. The
12683default value is set to @code{0}.
12684
12685@item dc_V
12686Adjust the dc value (gain) of the 2nd chroma plane of the image. The
12687filter accepts an integer value in range @code{0} to @code{1000}. The
12688default value is set to @code{0}.
12689
12690@item weight_Y
12691Set the frequency domain weight expression for the luma plane.
12692
12693@item weight_U
12694Set the frequency domain weight expression for the 1st chroma plane.
12695
12696@item weight_V
12697Set the frequency domain weight expression for the 2nd chroma plane.
12698
12699@item eval
12700Set when the expressions are evaluated.
12701
12702It accepts the following values:
12703@table @samp
12704@item init
12705Only evaluate expressions once during the filter initialization.
12706
12707@item frame
12708Evaluate expressions for each incoming frame.
12709@end table
12710
12711Default value is @samp{init}.
12712
12713The filter accepts the following variables:
12714@item X
12715@item Y
12716The coordinates of the current sample.
12717
12718@item W
12719@item H
12720The width and height of the image.
12721
12722@item N
12723The number of input frame, starting from 0.
12724
12725@item WS
12726@item HS
12727The size of FFT array for horizontal and vertical processing.
12728@end table
12729
12730@subsection Examples
12731
12732@itemize
12733@item
12734High-pass:
12735@example
12736fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
12737@end example
12738
12739@item
12740Low-pass:
12741@example
12742fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
12743@end example
12744
12745@item
12746Sharpen:
12747@example
12748fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
12749@end example
12750
12751@item
12752Blur:
12753@example
12754fftfilt=dc_Y=0:weight_Y='exp(-4 * ((Y+X)/(W+H)))'
12755@end example
12756
12757@end itemize
12758
12759@section field
12760
12761Extract a single field from an interlaced image using stride
12762arithmetic to avoid wasting CPU time. The output frames are marked as
12763non-interlaced.
12764
12765The filter accepts the following options:
12766
12767@table @option
12768@item type
12769Specify whether to extract the top (if the value is @code{0} or
12770@code{top}) or the bottom field (if the value is @code{1} or
12771@code{bottom}).
12772@end table
12773
12774@section fieldhint
12775
12776Create new frames by copying the top and bottom fields from surrounding frames
12777supplied as numbers by the hint file.
12778
12779@table @option
12780@item hint
12781Set file containing hints: absolute/relative frame numbers.
12782
12783There must be one line for each frame in a clip. Each line must contain two
12784numbers separated by the comma, optionally followed by @code{-} or @code{+}.
12785Numbers supplied on each line of file can not be out of [N-1,N+1] where N
12786is current frame number for @code{absolute} mode or out of [-1, 1] range
12787for @code{relative} mode. First number tells from which frame to pick up top
12788field and second number tells from which frame to pick up bottom field.
12789
12790If optionally followed by @code{+} output frame will be marked as interlaced,
12791else if followed by @code{-} output frame will be marked as progressive, else
12792it will be marked same as input frame.
12793If optionally followed by @code{t} output frame will use only top field, or in
12794case of @code{b} it will use only bottom field.
12795If line starts with @code{#} or @code{;} that line is skipped.
12796
12797@item mode
12798Can be item @code{absolute} or @code{relative} or @code{pattern}. Default is @code{absolute}.
12799The @code{pattern} mode is same as @code{relative} mode, except at last entry of file if there
12800are more frames to process than @code{hint} file is seek back to start.
12801@end table
12802
12803Example of first several lines of @code{hint} file for @code{relative} mode:
12804@example
128050,0 - # first frame
128061,0 - # second frame, use third's frame top field and second's frame bottom field
128071,0 - # third frame, use fourth's frame top field and third's frame bottom field
128081,0 -
128090,0 -
128100,0 -
128111,0 -
128121,0 -
128131,0 -
128140,0 -
128150,0 -
128161,0 -
128171,0 -
128181,0 -
128190,0 -
12820@end example
12821
12822@section fieldmatch
12823
12824Field matching filter for inverse telecine. It is meant to reconstruct the
12825progressive frames from a telecined stream. The filter does not drop duplicated
12826frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
12827followed by a decimation filter such as @ref{decimate} in the filtergraph.
12828
12829The separation of the field matching and the decimation is notably motivated by
12830the possibility of inserting a de-interlacing filter fallback between the two.
12831If the source has mixed telecined and real interlaced content,
12832@code{fieldmatch} will not be able to match fields for the interlaced parts.
12833But these remaining combed frames will be marked as interlaced, and thus can be
12834de-interlaced by a later filter such as @ref{yadif} before decimation.
12835
12836In addition to the various configuration options, @code{fieldmatch} can take an
12837optional second stream, activated through the @option{ppsrc} option. If
12838enabled, the frames reconstruction will be based on the fields and frames from
12839this second stream. This allows the first input to be pre-processed in order to
12840help the various algorithms of the filter, while keeping the output lossless
12841(assuming the fields are matched properly). Typically, a field-aware denoiser,
12842or brightness/contrast adjustments can help.
12843
12844Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
12845and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
12846which @code{fieldmatch} is based on. While the semantic and usage are very
12847close, some behaviour and options names can differ.
12848
12849The @ref{decimate} filter currently only works for constant frame rate input.
12850If your input has mixed telecined (30fps) and progressive content with a lower
12851framerate like 24fps use the following filterchain to produce the necessary cfr
12852stream: @code{dejudder,fps=30000/1001,fieldmatch,decimate}.
12853
12854The filter accepts the following options:
12855
12856@table @option
12857@item order
12858Specify the assumed field order of the input stream. Available values are:
12859
12860@table @samp
12861@item auto
12862Auto detect parity (use FFmpeg's internal parity value).
12863@item bff
12864Assume bottom field first.
12865@item tff
12866Assume top field first.
12867@end table
12868
12869Note that it is sometimes recommended not to trust the parity announced by the
12870stream.
12871
12872Default value is @var{auto}.
12873
12874@item mode
12875Set the matching mode or strategy to use. @option{pc} mode is the safest in the
12876sense that it won't risk creating jerkiness due to duplicate frames when
12877possible, but if there are bad edits or blended fields it will end up
12878outputting combed frames when a good match might actually exist. On the other
12879hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
12880but will almost always find a good frame if there is one. The other values are
12881all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
12882jerkiness and creating duplicate frames versus finding good matches in sections
12883with bad edits, orphaned fields, blended fields, etc.
12884
12885More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
12886
12887Available values are:
12888
12889@table @samp
12890@item pc
128912-way matching (p/c)
12892@item pc_n
128932-way matching, and trying 3rd match if still combed (p/c + n)
12894@item pc_u
128952-way matching, and trying 3rd match (same order) if still combed (p/c + u)
12896@item pc_n_ub
128972-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
12898still combed (p/c + n + u/b)
12899@item pcn
129003-way matching (p/c/n)
12901@item pcn_ub
129023-way matching, and trying 4th/5th matches if all 3 of the original matches are
12903detected as combed (p/c/n + u/b)
12904@end table
12905
12906The parenthesis at the end indicate the matches that would be used for that
12907mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
12908@var{top}).
12909
12910In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
12911the slowest.
12912
12913Default value is @var{pc_n}.
12914
12915@item ppsrc
12916Mark the main input stream as a pre-processed input, and enable the secondary
12917input stream as the clean source to pick the fields from. See the filter
12918introduction for more details. It is similar to the @option{clip2} feature from
12919VFM/TFM.
12920
12921Default value is @code{0} (disabled).
12922
12923@item field
12924Set the field to match from. It is recommended to set this to the same value as
12925@option{order} unless you experience matching failures with that setting. In
12926certain circumstances changing the field that is used to match from can have a
12927large impact on matching performance. Available values are:
12928
12929@table @samp
12930@item auto
12931Automatic (same value as @option{order}).
12932@item bottom
12933Match from the bottom field.
12934@item top
12935Match from the top field.
12936@end table
12937
12938Default value is @var{auto}.
12939
12940@item mchroma
12941Set whether or not chroma is included during the match comparisons. In most
12942cases it is recommended to leave this enabled. You should set this to @code{0}
12943only if your clip has bad chroma problems such as heavy rainbowing or other
12944artifacts. Setting this to @code{0} could also be used to speed things up at
12945the cost of some accuracy.
12946
12947Default value is @code{1}.
12948
12949@item y0
12950@item y1
12951These define an exclusion band which excludes the lines between @option{y0} and
12952@option{y1} from being included in the field matching decision. An exclusion
12953band can be used to ignore subtitles, a logo, or other things that may
12954interfere with the matching. @option{y0} sets the starting scan line and
12955@option{y1} sets the ending line; all lines in between @option{y0} and
12956@option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
12957@option{y0} and @option{y1} to the same value will disable the feature.
12958@option{y0} and @option{y1} defaults to @code{0}.
12959
12960@item scthresh
12961Set the scene change detection threshold as a percentage of maximum change on
12962the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
12963detection is only relevant in case @option{combmatch}=@var{sc}.  The range for
12964@option{scthresh} is @code{[0.0, 100.0]}.
12965
12966Default value is @code{12.0}.
12967
12968@item combmatch
12969When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
12970account the combed scores of matches when deciding what match to use as the
12971final match. Available values are:
12972
12973@table @samp
12974@item none
12975No final matching based on combed scores.
12976@item sc
12977Combed scores are only used when a scene change is detected.
12978@item full
12979Use combed scores all the time.
12980@end table
12981
12982Default is @var{sc}.
12983
12984@item combdbg
12985Force @code{fieldmatch} to calculate the combed metrics for certain matches and
12986print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
12987Available values are:
12988
12989@table @samp
12990@item none
12991No forced calculation.
12992@item pcn
12993Force p/c/n calculations.
12994@item pcnub
12995Force p/c/n/u/b calculations.
12996@end table
12997
12998Default value is @var{none}.
12999
13000@item cthresh
13001This is the area combing threshold used for combed frame detection. This
13002essentially controls how "strong" or "visible" combing must be to be detected.
13003Larger values mean combing must be more visible and smaller values mean combing
13004can be less visible or strong and still be detected. Valid settings are from
13005@code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
13006be detected as combed). This is basically a pixel difference value. A good
13007range is @code{[8, 12]}.
13008
13009Default value is @code{9}.
13010
13011@item chroma
13012Sets whether or not chroma is considered in the combed frame decision.  Only
13013disable this if your source has chroma problems (rainbowing, etc.) that are
13014causing problems for the combed frame detection with chroma enabled. Actually,
13015using @option{chroma}=@var{0} is usually more reliable, except for the case
13016where there is chroma only combing in the source.
13017
13018Default value is @code{0}.
13019
13020@item blockx
13021@item blocky
13022Respectively set the x-axis and y-axis size of the window used during combed
13023frame detection. This has to do with the size of the area in which
13024@option{combpel} pixels are required to be detected as combed for a frame to be
13025declared combed. See the @option{combpel} parameter description for more info.
13026Possible values are any number that is a power of 2 starting at 4 and going up
13027to 512.
13028
13029Default value is @code{16}.
13030
13031@item combpel
13032The number of combed pixels inside any of the @option{blocky} by
13033@option{blockx} size blocks on the frame for the frame to be detected as
13034combed. While @option{cthresh} controls how "visible" the combing must be, this
13035setting controls "how much" combing there must be in any localized area (a
13036window defined by the @option{blockx} and @option{blocky} settings) on the
13037frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
13038which point no frames will ever be detected as combed). This setting is known
13039as @option{MI} in TFM/VFM vocabulary.
13040
13041Default value is @code{80}.
13042@end table
13043
13044@anchor{p/c/n/u/b meaning}
13045@subsection p/c/n/u/b meaning
13046
13047@subsubsection p/c/n
13048
13049We assume the following telecined stream:
13050
13051@example
13052Top fields:     1 2 2 3 4
13053Bottom fields:  1 2 3 4 4
13054@end example
13055
13056The numbers correspond to the progressive frame the fields relate to. Here, the
13057first two frames are progressive, the 3rd and 4th are combed, and so on.
13058
13059When @code{fieldmatch} is configured to run a matching from bottom
13060(@option{field}=@var{bottom}) this is how this input stream get transformed:
13061
13062@example
13063Input stream:
13064                T     1 2 2 3 4
13065                B     1 2 3 4 4   <-- matching reference
13066
13067Matches:              c c n n c
13068
13069Output stream:
13070                T     1 2 3 4 4
13071                B     1 2 3 4 4
13072@end example
13073
13074As a result of the field matching, we can see that some frames get duplicated.
13075To perform a complete inverse telecine, you need to rely on a decimation filter
13076after this operation. See for instance the @ref{decimate} filter.
13077
13078The same operation now matching from top fields (@option{field}=@var{top})
13079looks like this:
13080
13081@example
13082Input stream:
13083                T     1 2 2 3 4   <-- matching reference
13084                B     1 2 3 4 4
13085
13086Matches:              c c p p c
13087
13088Output stream:
13089                T     1 2 2 3 4
13090                B     1 2 2 3 4
13091@end example
13092
13093In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
13094basically, they refer to the frame and field of the opposite parity:
13095
13096@itemize
13097@item @var{p} matches the field of the opposite parity in the previous frame
13098@item @var{c} matches the field of the opposite parity in the current frame
13099@item @var{n} matches the field of the opposite parity in the next frame
13100@end itemize
13101
13102@subsubsection u/b
13103
13104The @var{u} and @var{b} matching are a bit special in the sense that they match
13105from the opposite parity flag. In the following examples, we assume that we are
13106currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
13107'x' is placed above and below each matched fields.
13108
13109With bottom matching (@option{field}=@var{bottom}):
13110@example
13111Match:           c         p           n          b          u
13112
13113                 x       x               x        x          x
13114  Top          1 2 2     1 2 2       1 2 2      1 2 2      1 2 2
13115  Bottom       1 2 3     1 2 3       1 2 3      1 2 3      1 2 3
13116                 x         x           x        x              x
13117
13118Output frames:
13119                 2          1          2          2          2
13120                 2          2          2          1          3
13121@end example
13122
13123With top matching (@option{field}=@var{top}):
13124@example
13125Match:           c         p           n          b          u
13126
13127                 x         x           x        x              x
13128  Top          1 2 2     1 2 2       1 2 2      1 2 2      1 2 2
13129  Bottom       1 2 3     1 2 3       1 2 3      1 2 3      1 2 3
13130                 x       x               x        x          x
13131
13132Output frames:
13133                 2          2          2          1          2
13134                 2          1          3          2          2
13135@end example
13136
13137@subsection Examples
13138
13139Simple IVTC of a top field first telecined stream:
13140@example
13141fieldmatch=order=tff:combmatch=none, decimate
13142@end example
13143
13144Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
13145@example
13146fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
13147@end example
13148
13149@section fieldorder
13150
13151Transform the field order of the input video.
13152
13153It accepts the following parameters:
13154
13155@table @option
13156
13157@item order
13158The output field order. Valid values are @var{tff} for top field first or @var{bff}
13159for bottom field first.
13160@end table
13161
13162The default value is @samp{tff}.
13163
13164The transformation is done by shifting the picture content up or down
13165by one line, and filling the remaining line with appropriate picture content.
13166This method is consistent with most broadcast field order converters.
13167
13168If the input video is not flagged as being interlaced, or it is already
13169flagged as being of the required output field order, then this filter does
13170not alter the incoming video.
13171
13172It is very useful when converting to or from PAL DV material,
13173which is bottom field first.
13174
13175For example:
13176@example
13177ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
13178@end example
13179
13180@section fifo, afifo
13181
13182Buffer input images and send them when they are requested.
13183
13184It is mainly useful when auto-inserted by the libavfilter
13185framework.
13186
13187It does not take parameters.
13188
13189@section fillborders
13190
13191Fill borders of the input video, without changing video stream dimensions.
13192Sometimes video can have garbage at the four edges and you may not want to
13193crop video input to keep size multiple of some number.
13194
13195This filter accepts the following options:
13196
13197@table @option
13198@item left
13199Number of pixels to fill from left border.
13200
13201@item right
13202Number of pixels to fill from right border.
13203
13204@item top
13205Number of pixels to fill from top border.
13206
13207@item bottom
13208Number of pixels to fill from bottom border.
13209
13210@item mode
13211Set fill mode.
13212
13213It accepts the following values:
13214@table @samp
13215@item smear
13216fill pixels using outermost pixels
13217
13218@item mirror
13219fill pixels using mirroring (half sample symmetric)
13220
13221@item fixed
13222fill pixels with constant value
13223
13224@item reflect
13225fill pixels using reflecting (whole sample symmetric)
13226
13227@item wrap
13228fill pixels using wrapping
13229
13230@item fade
13231fade pixels to constant value
13232
13233@item margins
13234fill pixels at top and bottom with weighted averages pixels near borders
13235@end table
13236
13237Default is @var{smear}.
13238
13239@item color
13240Set color for pixels in fixed or fade mode. Default is @var{black}.
13241@end table
13242
13243@subsection Commands
13244This filter supports same @ref{commands} as options.
13245The command accepts the same syntax of the corresponding option.
13246
13247If the specified expression is not valid, it is kept at its current
13248value.
13249
13250@section find_rect
13251
13252Find a rectangular object
13253
13254It accepts the following options:
13255
13256@table @option
13257@item object
13258Filepath of the object image, needs to be in gray8.
13259
13260@item threshold
13261Detection threshold, default is 0.5.
13262
13263@item mipmaps
13264Number of mipmaps, default is 3.
13265
13266@item xmin, ymin, xmax, ymax
13267Specifies the rectangle in which to search.
13268
13269@item discard
13270Discard frames where object is not detected. Default is disabled.
13271@end table
13272
13273@subsection Examples
13274
13275@itemize
13276@item
13277Cover a rectangular object by the supplied image of a given video using @command{ffmpeg}:
13278@example
13279ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
13280@end example
13281@end itemize
13282
13283@section floodfill
13284
13285Flood area with values of same pixel components with another values.
13286
13287It accepts the following options:
13288@table @option
13289@item x
13290Set pixel x coordinate.
13291
13292@item y
13293Set pixel y coordinate.
13294
13295@item s0
13296Set source #0 component value.
13297
13298@item s1
13299Set source #1 component value.
13300
13301@item s2
13302Set source #2 component value.
13303
13304@item s3
13305Set source #3 component value.
13306
13307@item d0
13308Set destination #0 component value.
13309
13310@item d1
13311Set destination #1 component value.
13312
13313@item d2
13314Set destination #2 component value.
13315
13316@item d3
13317Set destination #3 component value.
13318@end table
13319
13320@anchor{format}
13321@section format
13322
13323Convert the input video to one of the specified pixel formats.
13324Libavfilter will try to pick one that is suitable as input to
13325the next filter.
13326
13327It accepts the following parameters:
13328@table @option
13329
13330@item pix_fmts
13331A '|'-separated list of pixel format names, such as
13332"pix_fmts=yuv420p|monow|rgb24".
13333
13334@end table
13335
13336@subsection Examples
13337
13338@itemize
13339@item
13340Convert the input video to the @var{yuv420p} format
13341@example
13342format=pix_fmts=yuv420p
13343@end example
13344
13345Convert the input video to any of the formats in the list
13346@example
13347format=pix_fmts=yuv420p|yuv444p|yuv410p
13348@end example
13349@end itemize
13350
13351@anchor{fps}
13352@section fps
13353
13354Convert the video to specified constant frame rate by duplicating or dropping
13355frames as necessary.
13356
13357It accepts the following parameters:
13358@table @option
13359
13360@item fps
13361The desired output frame rate. It accepts expressions containing the following
13362constants:
13363
13364@table @samp
13365@item source_fps
13366The input's frame rate
13367
13368@item ntsc
13369NTSC frame rate of @code{30000/1001}
13370
13371@item pal
13372PAL frame rate of @code{25.0}
13373
13374@item film
13375Film frame rate of @code{24.0}
13376
13377@item ntsc_film
13378NTSC-film frame rate of @code{24000/1001}
13379@end table
13380
13381The default is @code{25}.
13382
13383@item start_time
13384Assume the first PTS should be the given value, in seconds. This allows for
13385padding/trimming at the start of stream. By default, no assumption is made
13386about the first frame's expected PTS, so no padding or trimming is done.
13387For example, this could be set to 0 to pad the beginning with duplicates of
13388the first frame if a video stream starts after the audio stream or to trim any
13389frames with a negative PTS.
13390
13391@item round
13392Timestamp (PTS) rounding method.
13393
13394Possible values are:
13395@table @option
13396@item zero
13397round towards 0
13398@item inf
13399round away from 0
13400@item down
13401round towards -infinity
13402@item up
13403round towards +infinity
13404@item near
13405round to nearest
13406@end table
13407The default is @code{near}.
13408
13409@item eof_action
13410Action performed when reading the last frame.
13411
13412Possible values are:
13413@table @option
13414@item round
13415Use same timestamp rounding method as used for other frames.
13416@item pass
13417Pass through last frame if input duration has not been reached yet.
13418@end table
13419The default is @code{round}.
13420
13421@end table
13422
13423Alternatively, the options can be specified as a flat string:
13424@var{fps}[:@var{start_time}[:@var{round}]].
13425
13426See also the @ref{setpts} filter.
13427
13428@subsection Examples
13429
13430@itemize
13431@item
13432A typical usage in order to set the fps to 25:
13433@example
13434fps=fps=25
13435@end example
13436
13437@item
13438Sets the fps to 24, using abbreviation and rounding method to round to nearest:
13439@example
13440fps=fps=film:round=near
13441@end example
13442@end itemize
13443
13444@section framepack
13445
13446Pack two different video streams into a stereoscopic video, setting proper
13447metadata on supported codecs. The two views should have the same size and
13448framerate and processing will stop when the shorter video ends. Please note
13449that you may conveniently adjust view properties with the @ref{scale} and
13450@ref{fps} filters.
13451
13452It accepts the following parameters:
13453@table @option
13454
13455@item format
13456The desired packing format. Supported values are:
13457
13458@table @option
13459
13460@item sbs
13461The views are next to each other (default).
13462
13463@item tab
13464The views are on top of each other.
13465
13466@item lines
13467The views are packed by line.
13468
13469@item columns
13470The views are packed by column.
13471
13472@item frameseq
13473The views are temporally interleaved.
13474
13475@end table
13476
13477@end table
13478
13479Some examples:
13480
13481@example
13482# Convert left and right views into a frame-sequential video
13483ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
13484
13485# Convert views into a side-by-side video with the same output resolution as the input
13486ffmpeg -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
13487@end example
13488
13489@section framerate
13490
13491Change the frame rate by interpolating new video output frames from the source
13492frames.
13493
13494This filter is not designed to function correctly with interlaced media. If
13495you wish to change the frame rate of interlaced media then you are required
13496to deinterlace before this filter and re-interlace after this filter.
13497
13498A description of the accepted options follows.
13499
13500@table @option
13501@item fps
13502Specify the output frames per second. This option can also be specified
13503as a value alone. The default is @code{50}.
13504
13505@item interp_start
13506Specify the start of a range where the output frame will be created as a
13507linear interpolation of two frames. The range is [@code{0}-@code{255}],
13508the default is @code{15}.
13509
13510@item interp_end
13511Specify the end of a range where the output frame will be created as a
13512linear interpolation of two frames. The range is [@code{0}-@code{255}],
13513the default is @code{240}.
13514
13515@item scene
13516Specify the level at which a scene change is detected as a value between
135170 and 100 to indicate a new scene; a low value reflects a low
13518probability for the current frame to introduce a new scene, while a higher
13519value means the current frame is more likely to be one.
13520The default is @code{8.2}.
13521
13522@item flags
13523Specify flags influencing the filter process.
13524
13525Available value for @var{flags} is:
13526
13527@table @option
13528@item scene_change_detect, scd
13529Enable scene change detection using the value of the option @var{scene}.
13530This flag is enabled by default.
13531@end table
13532@end table
13533
13534@section framestep
13535
13536Select one frame every N-th frame.
13537
13538This filter accepts the following option:
13539@table @option
13540@item step
13541Select frame after every @code{step} frames.
13542Allowed values are positive integers higher than 0. Default value is @code{1}.
13543@end table
13544
13545@section freezedetect
13546
13547Detect frozen video.
13548
13549This filter logs a message and sets frame metadata when it detects that the
13550input video has no significant change in content during a specified duration.
13551Video freeze detection calculates the mean average absolute difference of all
13552the components of video frames and compares it to a noise floor.
13553
13554The printed times and duration are expressed in seconds. The
13555@code{lavfi.freezedetect.freeze_start} metadata key is set on the first frame
13556whose timestamp equals or exceeds the detection duration and it contains the
13557timestamp of the first frame of the freeze. The
13558@code{lavfi.freezedetect.freeze_duration} and
13559@code{lavfi.freezedetect.freeze_end} metadata keys are set on the first frame
13560after the freeze.
13561
13562The filter accepts the following options:
13563
13564@table @option
13565@item noise, n
13566Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
13567specified value) or as a difference ratio between 0 and 1. Default is -60dB, or
135680.001.
13569
13570@item duration, d
13571Set freeze duration until notification (default is 2 seconds).
13572@end table
13573
13574@section freezeframes
13575
13576Freeze video frames.
13577
13578This filter freezes video frames using frame from 2nd input.
13579
13580The filter accepts the following options:
13581
13582@table @option
13583@item first
13584Set number of first frame from which to start freeze.
13585
13586@item last
13587Set number of last frame from which to end freeze.
13588
13589@item replace
13590Set number of frame from 2nd input which will be used instead of replaced frames.
13591@end table
13592
13593@anchor{frei0r}
13594@section frei0r
13595
13596Apply a frei0r effect to the input video.
13597
13598To enable the compilation of this filter, you need to install the frei0r
13599header and configure FFmpeg with @code{--enable-frei0r}.
13600
13601It accepts the following parameters:
13602
13603@table @option
13604
13605@item filter_name
13606The name of the frei0r effect to load. If the environment variable
13607@env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
13608directories specified by the colon-separated list in @env{FREI0R_PATH}.
13609Otherwise, the standard frei0r paths are searched, in this order:
13610@file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
13611@file{/usr/lib/frei0r-1/}.
13612
13613@item filter_params
13614A '|'-separated list of parameters to pass to the frei0r effect.
13615
13616@end table
13617
13618A frei0r effect parameter can be a boolean (its value is either
13619"y" or "n"), a double, a color (specified as
13620@var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
13621numbers between 0.0 and 1.0, inclusive) or a color description as specified in the
13622@ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils},
13623a position (specified as @var{X}/@var{Y}, where
13624@var{X} and @var{Y} are floating point numbers) and/or a string.
13625
13626The number and types of parameters depend on the loaded effect. If an
13627effect parameter is not specified, the default value is set.
13628
13629@subsection Examples
13630
13631@itemize
13632@item
13633Apply the distort0r effect, setting the first two double parameters:
13634@example
13635frei0r=filter_name=distort0r:filter_params=0.5|0.01
13636@end example
13637
13638@item
13639Apply the colordistance effect, taking a color as the first parameter:
13640@example
13641frei0r=colordistance:0.2/0.3/0.4
13642frei0r=colordistance:violet
13643frei0r=colordistance:0x112233
13644@end example
13645
13646@item
13647Apply the perspective effect, specifying the top left and top right image
13648positions:
13649@example
13650frei0r=perspective:0.2/0.2|0.8/0.2
13651@end example
13652@end itemize
13653
13654For more information, see
13655@url{http://frei0r.dyne.org}
13656
13657@subsection Commands
13658
13659This filter supports the @option{filter_params} option as @ref{commands}.
13660
13661@section fspp
13662
13663Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
13664
13665It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
13666processing filter, one of them is performed once per block, not per pixel.
13667This allows for much higher speed.
13668
13669The filter accepts the following options:
13670
13671@table @option
13672@item quality
13673Set quality. This option defines the number of levels for averaging. It accepts
13674an integer in the range 4-5. Default value is @code{4}.
13675
13676@item qp
13677Force a constant quantization parameter. It accepts an integer in range 0-63.
13678If not set, the filter will use the QP from the video stream (if available).
13679
13680@item strength
13681Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
13682more details but also more artifacts, while higher values make the image smoother
13683but also blurrier. Default value is @code{0} − PSNR optimal.
13684
13685@item use_bframe_qp
13686Enable the use of the QP from the B-Frames if set to @code{1}. Using this
13687option may cause flicker since the B-Frames have often larger QP. Default is
13688@code{0} (not enabled).
13689
13690@end table
13691
13692@section gblur
13693
13694Apply Gaussian blur filter.
13695
13696The filter accepts the following options:
13697
13698@table @option
13699@item sigma
13700Set horizontal sigma, standard deviation of Gaussian blur. Default is @code{0.5}.
13701
13702@item steps
13703Set number of steps for Gaussian approximation. Default is @code{1}.
13704
13705@item planes
13706Set which planes to filter. By default all planes are filtered.
13707
13708@item sigmaV
13709Set vertical sigma, if negative it will be same as @code{sigma}.
13710Default is @code{-1}.
13711@end table
13712
13713@subsection Commands
13714This filter supports same commands as options.
13715The command accepts the same syntax of the corresponding option.
13716
13717If the specified expression is not valid, it is kept at its current
13718value.
13719
13720@section geq
13721
13722Apply generic equation to each pixel.
13723
13724The filter accepts the following options:
13725
13726@table @option
13727@item lum_expr, lum
13728Set the luminance expression.
13729@item cb_expr, cb
13730Set the chrominance blue expression.
13731@item cr_expr, cr
13732Set the chrominance red expression.
13733@item alpha_expr, a
13734Set the alpha expression.
13735@item red_expr, r
13736Set the red expression.
13737@item green_expr, g
13738Set the green expression.
13739@item blue_expr, b
13740Set the blue expression.
13741@end table
13742
13743The colorspace is selected according to the specified options. If one
13744of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
13745options is specified, the filter will automatically select a YCbCr
13746colorspace. If one of the @option{red_expr}, @option{green_expr}, or
13747@option{blue_expr} options is specified, it will select an RGB
13748colorspace.
13749
13750If one of the chrominance expression is not defined, it falls back on the other
13751one. If no alpha expression is specified it will evaluate to opaque value.
13752If none of chrominance expressions are specified, they will evaluate
13753to the luminance expression.
13754
13755The expressions can use the following variables and functions:
13756
13757@table @option
13758@item N
13759The sequential number of the filtered frame, starting from @code{0}.
13760
13761@item X
13762@item Y
13763The coordinates of the current sample.
13764
13765@item W
13766@item H
13767The width and height of the image.
13768
13769@item SW
13770@item SH
13771Width and height scale depending on the currently filtered plane. It is the
13772ratio between the corresponding luma plane number of pixels and the current
13773plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
13774@code{0.5,0.5} for chroma planes.
13775
13776@item T
13777Time of the current frame, expressed in seconds.
13778
13779@item p(x, y)
13780Return the value of the pixel at location (@var{x},@var{y}) of the current
13781plane.
13782
13783@item lum(x, y)
13784Return the value of the pixel at location (@var{x},@var{y}) of the luminance
13785plane.
13786
13787@item cb(x, y)
13788Return the value of the pixel at location (@var{x},@var{y}) of the
13789blue-difference chroma plane. Return 0 if there is no such plane.
13790
13791@item cr(x, y)
13792Return the value of the pixel at location (@var{x},@var{y}) of the
13793red-difference chroma plane. Return 0 if there is no such plane.
13794
13795@item r(x, y)
13796@item g(x, y)
13797@item b(x, y)
13798Return the value of the pixel at location (@var{x},@var{y}) of the
13799red/green/blue component. Return 0 if there is no such component.
13800
13801@item alpha(x, y)
13802Return the value of the pixel at location (@var{x},@var{y}) of the alpha
13803plane. Return 0 if there is no such plane.
13804
13805@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)
13806Sum of sample values in the rectangle from (0,0) to (x,y), this allows obtaining
13807sums of samples within a rectangle. See the functions without the sum postfix.
13808
13809@item interpolation
13810Set one of interpolation methods:
13811@table @option
13812@item nearest, n
13813@item bilinear, b
13814@end table
13815Default is bilinear.
13816@end table
13817
13818For functions, if @var{x} and @var{y} are outside the area, the value will be
13819automatically clipped to the closer edge.
13820
13821Please note that this filter can use multiple threads in which case each slice
13822will have its own expression state. If you want to use only a single expression
13823state because your expressions depend on previous state then you should limit
13824the number of filter threads to 1.
13825
13826@subsection Examples
13827
13828@itemize
13829@item
13830Flip the image horizontally:
13831@example
13832geq=p(W-X\,Y)
13833@end example
13834
13835@item
13836Generate a bidimensional sine wave, with angle @code{PI/3} and a
13837wavelength of 100 pixels:
13838@example
13839geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
13840@end example
13841
13842@item
13843Generate a fancy enigmatic moving light:
13844@example
13845nullsrc=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
13846@end example
13847
13848@item
13849Generate a quick emboss effect:
13850@example
13851format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
13852@end example
13853
13854@item
13855Modify RGB components depending on pixel position:
13856@example
13857geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
13858@end example
13859
13860@item
13861Create a radial gradient that is the same size as the input (also see
13862the @ref{vignette} filter):
13863@example
13864geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
13865@end example
13866@end itemize
13867
13868@section gradfun
13869
13870Fix the banding artifacts that are sometimes introduced into nearly flat
13871regions by truncation to 8-bit color depth.
13872Interpolate the gradients that should go where the bands are, and
13873dither them.
13874
13875It is designed for playback only.  Do not use it prior to
13876lossy compression, because compression tends to lose the dither and
13877bring back the bands.
13878
13879It accepts the following parameters:
13880
13881@table @option
13882
13883@item strength
13884The maximum amount by which the filter will change any one pixel. This is also
13885the threshold for detecting nearly flat regions. Acceptable values range from
13886.51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
13887valid range.
13888
13889@item radius
13890The neighborhood to fit the gradient to. A larger radius makes for smoother
13891gradients, but also prevents the filter from modifying the pixels near detailed
13892regions. Acceptable values are 8-32; the default value is 16. Out-of-range
13893values will be clipped to the valid range.
13894
13895@end table
13896
13897Alternatively, the options can be specified as a flat string:
13898@var{strength}[:@var{radius}]
13899
13900@subsection Examples
13901
13902@itemize
13903@item
13904Apply the filter with a @code{3.5} strength and radius of @code{8}:
13905@example
13906gradfun=3.5:8
13907@end example
13908
13909@item
13910Specify radius, omitting the strength (which will fall-back to the default
13911value):
13912@example
13913gradfun=radius=8
13914@end example
13915
13916@end itemize
13917
13918@anchor{graphmonitor}
13919@section graphmonitor
13920Show various filtergraph stats.
13921
13922With this filter one can debug complete filtergraph.
13923Especially issues with links filling with queued frames.
13924
13925The filter accepts the following options:
13926
13927@table @option
13928@item size, s
13929Set video output size. Default is @var{hd720}.
13930
13931@item opacity, o
13932Set video opacity. Default is @var{0.9}. Allowed range is from @var{0} to @var{1}.
13933
13934@item mode, m
13935Set output mode, can be @var{fulll} or @var{compact}.
13936In @var{compact} mode only filters with some queued frames have displayed stats.
13937
13938@item flags, f
13939Set flags which enable which stats are shown in video.
13940
13941Available values for flags are:
13942@table @samp
13943@item queue
13944Display number of queued frames in each link.
13945
13946@item frame_count_in
13947Display number of frames taken from filter.
13948
13949@item frame_count_out
13950Display number of frames given out from filter.
13951
13952@item frame_count_delta
13953Display delta number of frames between above two values.
13954
13955@item pts
13956Display current filtered frame pts.
13957
13958@item pts_delta
13959Display pts delta between current and previous frame.
13960
13961@item time
13962Display current filtered frame time.
13963
13964@item time_delta
13965Display time delta between current and previous frame.
13966
13967@item timebase
13968Display time base for filter link.
13969
13970@item format
13971Display used format for filter link.
13972
13973@item size
13974Display video size or number of audio channels in case of audio used by filter link.
13975
13976@item rate
13977Display video frame rate or sample rate in case of audio used by filter link.
13978
13979@item eof
13980Display link output status.
13981
13982@item sample_count_in
13983Display number of samples taken from filter.
13984
13985@item sample_count_out
13986Display number of samples given out from filter.
13987
13988@item sample_count_delta
13989Display delta number of samples between above two values.
13990@end table
13991
13992@item rate, r
13993Set upper limit for video rate of output stream, Default value is @var{25}.
13994This guarantee that output video frame rate will not be higher than this value.
13995@end table
13996
13997@section grayworld
13998A color constancy filter that applies color correction based on the grayworld assumption
13999
14000See: @url{https://www.researchgate.net/publication/275213614_A_New_Color_Correction_Method_for_Underwater_Imaging}
14001
14002The algorithm  uses linear light, so input
14003data should be linearized beforehand (and possibly correctly tagged).
14004
14005@example
14006ffmpeg -i INPUT -vf zscale=transfer=linear,grayworld,zscale=transfer=bt709,format=yuv420p OUTPUT
14007@end example
14008
14009@section greyedge
14010A color constancy variation filter which estimates scene illumination via grey edge algorithm
14011and corrects the scene colors accordingly.
14012
14013See: @url{https://staff.science.uva.nl/th.gevers/pub/GeversTIP07.pdf}
14014
14015The filter accepts the following options:
14016
14017@table @option
14018@item difford
14019The order of differentiation to be applied on the scene. Must be chosen in the range
14020[0,2] and default value is 1.
14021
14022@item minknorm
14023The Minkowski parameter to be used for calculating the Minkowski distance. Must
14024be chosen in the range [0,20] and default value is 1. Set to 0 for getting
14025max value instead of calculating Minkowski distance.
14026
14027@item sigma
14028The standard deviation of Gaussian blur to be applied on the scene. Must be
14029chosen in the range [0,1024.0] and default value = 1. floor( @var{sigma} * break_off_sigma(3) )
14030can't be equal to 0 if @var{difford} is greater than 0.
14031@end table
14032
14033@subsection Examples
14034@itemize
14035
14036@item
14037Grey Edge:
14038@example
14039greyedge=difford=1:minknorm=5:sigma=2
14040@end example
14041
14042@item
14043Max Edge:
14044@example
14045greyedge=difford=1:minknorm=0:sigma=2
14046@end example
14047
14048@end itemize
14049
14050@section guided
14051Apply guided filter for edge-preserving smoothing, dehazing and so on.
14052
14053The filter accepts the following options:
14054@table @option
14055@item radius
14056Set the box radius in pixels.
14057Allowed range is 1 to 20. Default is 3.
14058
14059@item eps
14060Set regularization parameter (with square).
14061Allowed range is 0 to 1. Default is 0.01.
14062
14063@item mode
14064Set filter mode. Can be @code{basic} or @code{fast}.
14065Default is @code{basic}.
14066
14067@item sub
14068Set subsampling ratio for @code{fast} mode.
14069Range is 2 to 64. Default is 4.
14070No subsampling occurs in @code{basic} mode.
14071
14072@item guidance
14073Set guidance mode. Can be @code{off} or @code{on}. Default is @code{off}.
14074If @code{off}, single input is required.
14075If @code{on}, two inputs of the same resolution and pixel format are required.
14076The second input serves as the guidance.
14077
14078@item planes
14079Set planes to filter. Default is first only.
14080@end table
14081
14082@subsection Commands
14083This filter supports the all above options as @ref{commands}.
14084
14085@subsection Examples
14086@itemize
14087@item
14088Edge-preserving smoothing with guided filter:
14089@example
14090ffmpeg -i in.png -vf guided out.png
14091@end example
14092
14093@item
14094Dehazing, structure-transferring filtering, detail enhancement with guided filter.
14095For the generation of guidance image, refer to paper "Guided Image Filtering".
14096See: @url{http://kaiminghe.com/publications/pami12guidedfilter.pdf}.
14097@example
14098ffmpeg -i in.png -i guidance.png -filter_complex guided=guidance=on out.png
14099@end example
14100
14101@end itemize
14102
14103@anchor{haldclut}
14104@section haldclut
14105
14106Apply a Hald CLUT to a video stream.
14107
14108First input is the video stream to process, and second one is the Hald CLUT.
14109The Hald CLUT input can be a simple picture or a complete video stream.
14110
14111The filter accepts the following options:
14112
14113@table @option
14114@item clut
14115Set which CLUT video frames will be processed from second input stream,
14116can be @var{first} or @var{all}. Default is @var{all}.
14117
14118@item shortest
14119Force termination when the shortest input terminates. Default is @code{0}.
14120@item repeatlast
14121Continue applying the last CLUT after the end of the stream. A value of
14122@code{0} disable the filter after the last frame of the CLUT is reached.
14123Default is @code{1}.
14124@end table
14125
14126@code{haldclut} also has the same interpolation options as @ref{lut3d} (both
14127filters share the same internals).
14128
14129This filter also supports the @ref{framesync} options.
14130
14131More information about the Hald CLUT can be found on Eskil Steenberg's website
14132(Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
14133
14134@subsection Commands
14135
14136This filter supports the @code{interp} option as @ref{commands}.
14137
14138@subsection Workflow examples
14139
14140@subsubsection Hald CLUT video stream
14141
14142Generate an identity Hald CLUT stream altered with various effects:
14143@example
14144ffmpeg -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
14145@end example
14146
14147Note: make sure you use a lossless codec.
14148
14149Then use it with @code{haldclut} to apply it on some random stream:
14150@example
14151ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
14152@end example
14153
14154The Hald CLUT will be applied to the 10 first seconds (duration of
14155@file{clut.nut}), then the latest picture of that CLUT stream will be applied
14156to the remaining frames of the @code{mandelbrot} stream.
14157
14158@subsubsection Hald CLUT with preview
14159
14160A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
14161@code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
14162biggest possible square starting at the top left of the picture. The remaining
14163padding pixels (bottom or right) will be ignored. This area can be used to add
14164a preview of the Hald CLUT.
14165
14166Typically, the following generated Hald CLUT will be supported by the
14167@code{haldclut} filter:
14168
14169@example
14170ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
14171   pad=iw+320 [padded_clut];
14172   smptebars=s=320x256, split [a][b];
14173   [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
14174   [main][b] overlay=W-320" -frames:v 1 clut.png
14175@end example
14176
14177It contains the original and a preview of the effect of the CLUT: SMPTE color
14178bars are displayed on the right-top, and below the same color bars processed by
14179the color changes.
14180
14181Then, the effect of this Hald CLUT can be visualized with:
14182@example
14183ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
14184@end example
14185
14186@section hflip
14187
14188Flip the input video horizontally.
14189
14190For example, to horizontally flip the input video with @command{ffmpeg}:
14191@example
14192ffmpeg -i in.avi -vf "hflip" out.avi
14193@end example
14194
14195@section histeq
14196This filter applies a global color histogram equalization on a
14197per-frame basis.
14198
14199It can be used to correct video that has a compressed range of pixel
14200intensities.  The filter redistributes the pixel intensities to
14201equalize their distribution across the intensity range. It may be
14202viewed as an "automatically adjusting contrast filter". This filter is
14203useful only for correcting degraded or poorly captured source
14204video.
14205
14206The filter accepts the following options:
14207
14208@table @option
14209@item strength
14210Determine the amount of equalization to be applied.  As the strength
14211is reduced, the distribution of pixel intensities more-and-more
14212approaches that of the input frame. The value must be a float number
14213in the range [0,1] and defaults to 0.200.
14214
14215@item intensity
14216Set the maximum intensity that can generated and scale the output
14217values appropriately.  The strength should be set as desired and then
14218the intensity can be limited if needed to avoid washing-out. The value
14219must be a float number in the range [0,1] and defaults to 0.210.
14220
14221@item antibanding
14222Set the antibanding level. If enabled the filter will randomly vary
14223the luminance of output pixels by a small amount to avoid banding of
14224the histogram. Possible values are @code{none}, @code{weak} or
14225@code{strong}. It defaults to @code{none}.
14226@end table
14227
14228@anchor{histogram}
14229@section histogram
14230
14231Compute and draw a color distribution histogram for the input video.
14232
14233The computed histogram is a representation of the color component
14234distribution in an image.
14235
14236Standard histogram displays the color components distribution in an image.
14237Displays color graph for each color component. Shows distribution of
14238the Y, U, V, A or R, G, B components, depending on input format, in the
14239current frame. Below each graph a color component scale meter is shown.
14240
14241The filter accepts the following options:
14242
14243@table @option
14244@item level_height
14245Set height of level. Default value is @code{200}.
14246Allowed range is [50, 2048].
14247
14248@item scale_height
14249Set height of color scale. Default value is @code{12}.
14250Allowed range is [0, 40].
14251
14252@item display_mode
14253Set display mode.
14254It accepts the following values:
14255@table @samp
14256@item stack
14257Per color component graphs are placed below each other.
14258
14259@item parade
14260Per color component graphs are placed side by side.
14261
14262@item overlay
14263Presents information identical to that in the @code{parade}, except
14264that the graphs representing color components are superimposed directly
14265over one another.
14266@end table
14267Default is @code{stack}.
14268
14269@item levels_mode
14270Set mode. Can be either @code{linear}, or @code{logarithmic}.
14271Default is @code{linear}.
14272
14273@item components
14274Set what color components to display.
14275Default is @code{7}.
14276
14277@item fgopacity
14278Set foreground opacity. Default is @code{0.7}.
14279
14280@item bgopacity
14281Set background opacity. Default is @code{0.5}.
14282
14283@item colors_mode
14284Set colors mode.
14285It accepts the following values:
14286@table @samp
14287@item whiteonblack
14288@item blackonwhite
14289@item whiteongray
14290@item blackongray
14291@item coloronblack
14292@item coloronwhite
14293@item colorongray
14294@item blackoncolor
14295@item whiteoncolor
14296@item grayoncolor
14297@end table
14298Default is @code{whiteonblack}.
14299@end table
14300
14301@subsection Examples
14302
14303@itemize
14304
14305@item
14306Calculate and draw histogram:
14307@example
14308ffplay -i input -vf histogram
14309@end example
14310
14311@end itemize
14312
14313@anchor{hqdn3d}
14314@section hqdn3d
14315
14316This is a high precision/quality 3d denoise filter. It aims to reduce
14317image noise, producing smooth images and making still images really
14318still. It should enhance compressibility.
14319
14320It accepts the following optional parameters:
14321
14322@table @option
14323@item luma_spatial
14324A non-negative floating point number which specifies spatial luma strength.
14325It defaults to 4.0.
14326
14327@item chroma_spatial
14328A non-negative floating point number which specifies spatial chroma strength.
14329It defaults to 3.0*@var{luma_spatial}/4.0.
14330
14331@item luma_tmp
14332A floating point number which specifies luma temporal strength. It defaults to
143336.0*@var{luma_spatial}/4.0.
14334
14335@item chroma_tmp
14336A floating point number which specifies chroma temporal strength. It defaults to
14337@var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
14338@end table
14339
14340@subsection Commands
14341This filter supports same @ref{commands} as options.
14342The command accepts the same syntax of the corresponding option.
14343
14344If the specified expression is not valid, it is kept at its current
14345value.
14346
14347@anchor{hwdownload}
14348@section hwdownload
14349
14350Download hardware frames to system memory.
14351
14352The input must be in hardware frames, and the output a non-hardware format.
14353Not all formats will be supported on the output - it may be necessary to insert
14354an additional @option{format} filter immediately following in the graph to get
14355the output in a supported format.
14356
14357@section hwmap
14358
14359Map hardware frames to system memory or to another device.
14360
14361This filter has several different modes of operation; which one is used depends
14362on the input and output formats:
14363@itemize
14364@item
14365Hardware frame input, normal frame output
14366
14367Map the input frames to system memory and pass them to the output.  If the
14368original hardware frame is later required (for example, after overlaying
14369something else on part of it), the @option{hwmap} filter can be used again
14370in the next mode to retrieve it.
14371@item
14372Normal frame input, hardware frame output
14373
14374If the input is actually a software-mapped hardware frame, then unmap it -
14375that is, return the original hardware frame.
14376
14377Otherwise, a device must be provided.  Create new hardware surfaces on that
14378device for the output, then map them back to the software format at the input
14379and give those frames to the preceding filter.  This will then act like the
14380@option{hwupload} filter, but may be able to avoid an additional copy when
14381the input is already in a compatible format.
14382@item
14383Hardware frame input and output
14384
14385A device must be supplied for the output, either directly or with the
14386@option{derive_device} option.  The input and output devices must be of
14387different types and compatible - the exact meaning of this is
14388system-dependent, but typically it means that they must refer to the same
14389underlying hardware context (for example, refer to the same graphics card).
14390
14391If the input frames were originally created on the output device, then unmap
14392to retrieve the original frames.
14393
14394Otherwise, map the frames to the output device - create new hardware frames
14395on the output corresponding to the frames on the input.
14396@end itemize
14397
14398The following additional parameters are accepted:
14399
14400@table @option
14401@item mode
14402Set the frame mapping mode.  Some combination of:
14403@table @var
14404@item read
14405The mapped frame should be readable.
14406@item write
14407The mapped frame should be writeable.
14408@item overwrite
14409The mapping will always overwrite the entire frame.
14410
14411This may improve performance in some cases, as the original contents of the
14412frame need not be loaded.
14413@item direct
14414The mapping must not involve any copying.
14415
14416Indirect mappings to copies of frames are created in some cases where either
14417direct mapping is not possible or it would have unexpected properties.
14418Setting this flag ensures that the mapping is direct and will fail if that is
14419not possible.
14420@end table
14421Defaults to @var{read+write} if not specified.
14422
14423@item derive_device @var{type}
14424Rather than using the device supplied at initialisation, instead derive a new
14425device of type @var{type} from the device the input frames exist on.
14426
14427@item reverse
14428In a hardware to hardware mapping, map in reverse - create frames in the sink
14429and map them back to the source.  This may be necessary in some cases where
14430a mapping in one direction is required but only the opposite direction is
14431supported by the devices being used.
14432
14433This option is dangerous - it may break the preceding filter in undefined
14434ways if there are any additional constraints on that filter's output.
14435Do not use it without fully understanding the implications of its use.
14436@end table
14437
14438@anchor{hwupload}
14439@section hwupload
14440
14441Upload system memory frames to hardware surfaces.
14442
14443The device to upload to must be supplied when the filter is initialised.  If
14444using ffmpeg, select the appropriate device with the @option{-filter_hw_device}
14445option or with the @option{derive_device} option.  The input and output devices
14446must be of different types and compatible - the exact meaning of this is
14447system-dependent, but typically it means that they must refer to the same
14448underlying hardware context (for example, refer to the same graphics card).
14449
14450The following additional parameters are accepted:
14451
14452@table @option
14453@item derive_device @var{type}
14454Rather than using the device supplied at initialisation, instead derive a new
14455device of type @var{type} from the device the input frames exist on.
14456@end table
14457
14458@anchor{hwupload_cuda}
14459@section hwupload_cuda
14460
14461Upload system memory frames to a CUDA device.
14462
14463It accepts the following optional parameters:
14464
14465@table @option
14466@item device
14467The number of the CUDA device to use
14468@end table
14469
14470@section hqx
14471
14472Apply a high-quality magnification filter designed for pixel art. This filter
14473was originally created by Maxim Stepin.
14474
14475It accepts the following option:
14476
14477@table @option
14478@item n
14479Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
14480@code{hq3x} and @code{4} for @code{hq4x}.
14481Default is @code{3}.
14482@end table
14483
14484@section hstack
14485Stack input videos horizontally.
14486
14487All streams must be of same pixel format and of same height.
14488
14489Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
14490to create same output.
14491
14492The filter accepts the following option:
14493
14494@table @option
14495@item inputs
14496Set number of input streams. Default is 2.
14497
14498@item shortest
14499If set to 1, force the output to terminate when the shortest input
14500terminates. Default value is 0.
14501@end table
14502
14503@section hsvhold
14504Turns a certain HSV range into gray values.
14505
14506This filter measures color difference between set HSV color in options
14507and ones measured in video stream. Depending on options, output
14508colors can be changed to be gray or not.
14509
14510The filter accepts the following options:
14511
14512@table @option
14513@item hue
14514Set the hue value which will be used in color difference calculation.
14515Allowed range is from -360 to 360. Default value is 0.
14516
14517@item sat
14518Set the saturation value which will be used in color difference calculation.
14519Allowed range is from -1 to 1. Default value is 0.
14520
14521@item val
14522Set the value which will be used in color difference calculation.
14523Allowed range is from -1 to 1. Default value is 0.
14524
14525@item similarity
14526Set similarity percentage with the key color.
14527Allowed range is from 0 to 1. Default value is 0.01.
14528
145290.00001 matches only the exact key color, while 1.0 matches everything.
14530
14531@item blend
14532Blend percentage.
14533Allowed range is from 0 to 1. Default value is 0.
14534
145350.0 makes pixels either fully gray, or not gray at all.
14536
14537Higher values result in more gray pixels, with a higher gray pixel
14538the more similar the pixels color is to the key color.
14539@end table
14540
14541@section hsvkey
14542Turns a certain HSV range into transparency.
14543
14544This filter measures color difference between set HSV color in options
14545and ones measured in video stream. Depending on options, output
14546colors can be changed to transparent by adding alpha channel.
14547
14548The filter accepts the following options:
14549
14550@table @option
14551@item hue
14552Set the hue value which will be used in color difference calculation.
14553Allowed range is from -360 to 360. Default value is 0.
14554
14555@item sat
14556Set the saturation value which will be used in color difference calculation.
14557Allowed range is from -1 to 1. Default value is 0.
14558
14559@item val
14560Set the value which will be used in color difference calculation.
14561Allowed range is from -1 to 1. Default value is 0.
14562
14563@item similarity
14564Set similarity percentage with the key color.
14565Allowed range is from 0 to 1. Default value is 0.01.
14566
145670.00001 matches only the exact key color, while 1.0 matches everything.
14568
14569@item blend
14570Blend percentage.
14571Allowed range is from 0 to 1. Default value is 0.
14572
145730.0 makes pixels either fully transparent, or not transparent at all.
14574
14575Higher values result in semi-transparent pixels, with a higher transparency
14576the more similar the pixels color is to the key color.
14577@end table
14578
14579@section hue
14580
14581Modify the hue and/or the saturation of the input.
14582
14583It accepts the following parameters:
14584
14585@table @option
14586@item h
14587Specify the hue angle as a number of degrees. It accepts an expression,
14588and defaults to "0".
14589
14590@item s
14591Specify the saturation in the [-10,10] range. It accepts an expression and
14592defaults to "1".
14593
14594@item H
14595Specify the hue angle as a number of radians. It accepts an
14596expression, and defaults to "0".
14597
14598@item b
14599Specify the brightness in the [-10,10] range. It accepts an expression and
14600defaults to "0".
14601@end table
14602
14603@option{h} and @option{H} are mutually exclusive, and can't be
14604specified at the same time.
14605
14606The @option{b}, @option{h}, @option{H} and @option{s} option values are
14607expressions containing the following constants:
14608
14609@table @option
14610@item n
14611frame count of the input frame starting from 0
14612
14613@item pts
14614presentation timestamp of the input frame expressed in time base units
14615
14616@item r
14617frame rate of the input video, NAN if the input frame rate is unknown
14618
14619@item t
14620timestamp expressed in seconds, NAN if the input timestamp is unknown
14621
14622@item tb
14623time base of the input video
14624@end table
14625
14626@subsection Examples
14627
14628@itemize
14629@item
14630Set the hue to 90 degrees and the saturation to 1.0:
14631@example
14632hue=h=90:s=1
14633@end example
14634
14635@item
14636Same command but expressing the hue in radians:
14637@example
14638hue=H=PI/2:s=1
14639@end example
14640
14641@item
14642Rotate hue and make the saturation swing between 0
14643and 2 over a period of 1 second:
14644@example
14645hue="H=2*PI*t: s=sin(2*PI*t)+1"
14646@end example
14647
14648@item
14649Apply a 3 seconds saturation fade-in effect starting at 0:
14650@example
14651hue="s=min(t/3\,1)"
14652@end example
14653
14654The general fade-in expression can be written as:
14655@example
14656hue="s=min(0\, max((t-START)/DURATION\, 1))"
14657@end example
14658
14659@item
14660Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
14661@example
14662hue="s=max(0\, min(1\, (8-t)/3))"
14663@end example
14664
14665The general fade-out expression can be written as:
14666@example
14667hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
14668@end example
14669
14670@end itemize
14671
14672@subsection Commands
14673
14674This filter supports the following commands:
14675@table @option
14676@item b
14677@item s
14678@item h
14679@item H
14680Modify the hue and/or the saturation and/or brightness of the input video.
14681The command accepts the same syntax of the corresponding option.
14682
14683If the specified expression is not valid, it is kept at its current
14684value.
14685@end table
14686
14687@section huesaturation
14688Apply hue-saturation-intensity adjustments to input video stream.
14689
14690This filter operates in RGB colorspace.
14691
14692This filter accepts the following options:
14693
14694@table @option
14695@item hue
14696Set the hue shift in degrees to apply. Default is 0.
14697Allowed range is from -180 to 180.
14698
14699@item saturation
14700Set the saturation shift. Default is 0.
14701Allowed range is from -1 to 1.
14702
14703@item intensity
14704Set the intensity shift. Default is 0.
14705Allowed range is from -1 to 1.
14706
14707@item colors
14708Set which primary and complementary colors are going to be adjusted.
14709This options is set by providing one or multiple values.
14710This can select multiple colors at once. By default all colors are selected.
14711@table @samp
14712@item r
14713Adjust reds.
14714@item y
14715Adjust yellows.
14716@item g
14717Adjust greens.
14718@item c
14719Adjust cyans.
14720@item b
14721Adjust blues.
14722@item m
14723Adjust magentas.
14724@item a
14725Adjust all colors.
14726@end table
14727
14728@item strength
14729Set strength of filtering. Allowed range is from 0 to 100.
14730Default value is 1.
14731
14732@item rw, gw, bw
14733Set weight for each RGB component. Allowed range is from 0 to 1.
14734By default is set to 0.333, 0.334, 0.333.
14735Those options are used in saturation and lightess processing.
14736
14737@item lightness
14738Set preserving lightness, by default is disabled.
14739Adjusting hues can change lightness from original RGB triplet,
14740with this option enabled lightness is kept at same value.
14741@end table
14742
14743@section hysteresis
14744
14745Grow first stream into second stream by connecting components.
14746This makes it possible to build more robust edge masks.
14747
14748This filter accepts the following options:
14749
14750@table @option
14751@item planes
14752Set which planes will be processed as bitmap, unprocessed planes will be
14753copied from first stream.
14754By default value 0xf, all planes will be processed.
14755
14756@item threshold
14757Set threshold which is used in filtering. If pixel component value is higher than
14758this value filter algorithm for connecting components is activated.
14759By default value is 0.
14760@end table
14761
14762The @code{hysteresis} filter also supports the @ref{framesync} options.
14763
14764@section iccdetect
14765
14766Detect the colorspace  from an embedded ICC profile (if present), and update
14767the frame's tags accordingly.
14768
14769This filter accepts the following options:
14770
14771@table @option
14772@item force
14773If true, the frame's existing colorspace tags will always be overridden by
14774values detected from an ICC profile. Otherwise, they will only be assigned if
14775they contain @code{unknown}. Enabled by default.
14776@end table
14777
14778@section iccgen
14779
14780Generate ICC profiles and attach them to frames.
14781
14782This filter accepts the following options:
14783
14784@table @option
14785@item color_primaries
14786@item color_trc
14787Configure the colorspace that the ICC profile will be generated for. The
14788default value of @code{auto} infers the value from the input frame's metadata,
14789defaulting to BT.709/sRGB as appropriate.
14790
14791See the @ref{setparams} filter for a list of possible values, but note that
14792@code{unknown} are not valid values for this filter.
14793
14794@item force
14795If true, an ICC profile will be generated even if it would overwrite an
14796already existing ICC profile. Disabled by default.
14797@end table
14798
14799@section identity
14800
14801Obtain the identity score between two input videos.
14802
14803This filter takes two input videos.
14804
14805Both input videos must have the same resolution and pixel format for
14806this filter to work correctly. Also it assumes that both inputs
14807have the same number of frames, which are compared one by one.
14808
14809The obtained per component, average, min and max identity score is printed through
14810the logging system.
14811
14812The filter stores the calculated identity scores of each frame in frame metadata.
14813
14814In the below example the input file @file{main.mpg} being processed is compared
14815with the reference file @file{ref.mpg}.
14816
14817@example
14818ffmpeg -i main.mpg -i ref.mpg -lavfi identity -f null -
14819@end example
14820
14821@section idet
14822
14823Detect video interlacing type.
14824
14825This filter tries to detect if the input frames are interlaced, progressive,
14826top or bottom field first. It will also try to detect fields that are
14827repeated between adjacent frames (a sign of telecine).
14828
14829Single frame detection considers only immediately adjacent frames when classifying each frame.
14830Multiple frame detection incorporates the classification history of previous frames.
14831
14832The filter will log these metadata values:
14833
14834@table @option
14835@item single.current_frame
14836Detected type of current frame using single-frame detection. One of:
14837``tff'' (top field first), ``bff'' (bottom field first),
14838``progressive'', or ``undetermined''
14839
14840@item single.tff
14841Cumulative number of frames detected as top field first using single-frame detection.
14842
14843@item multiple.tff
14844Cumulative number of frames detected as top field first using multiple-frame detection.
14845
14846@item single.bff
14847Cumulative number of frames detected as bottom field first using single-frame detection.
14848
14849@item multiple.current_frame
14850Detected type of current frame using multiple-frame detection. One of:
14851``tff'' (top field first), ``bff'' (bottom field first),
14852``progressive'', or ``undetermined''
14853
14854@item multiple.bff
14855Cumulative number of frames detected as bottom field first using multiple-frame detection.
14856
14857@item single.progressive
14858Cumulative number of frames detected as progressive using single-frame detection.
14859
14860@item multiple.progressive
14861Cumulative number of frames detected as progressive using multiple-frame detection.
14862
14863@item single.undetermined
14864Cumulative number of frames that could not be classified using single-frame detection.
14865
14866@item multiple.undetermined
14867Cumulative number of frames that could not be classified using multiple-frame detection.
14868
14869@item repeated.current_frame
14870Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
14871
14872@item repeated.neither
14873Cumulative number of frames with no repeated field.
14874
14875@item repeated.top
14876Cumulative number of frames with the top field repeated from the previous frame's top field.
14877
14878@item repeated.bottom
14879Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
14880@end table
14881
14882The filter accepts the following options:
14883
14884@table @option
14885@item intl_thres
14886Set interlacing threshold.
14887@item prog_thres
14888Set progressive threshold.
14889@item rep_thres
14890Threshold for repeated field detection.
14891@item half_life
14892Number of frames after which a given frame's contribution to the
14893statistics is halved (i.e., it contributes only 0.5 to its
14894classification). The default of 0 means that all frames seen are given
14895full weight of 1.0 forever.
14896@item analyze_interlaced_flag
14897When this is not 0 then idet will use the specified number of frames to determine
14898if the interlaced flag is accurate, it will not count undetermined frames.
14899If the flag is found to be accurate it will be used without any further
14900computations, if it is found to be inaccurate it will be cleared without any
14901further computations. This allows inserting the idet filter as a low computational
14902method to clean up the interlaced flag
14903@end table
14904
14905@section il
14906
14907Deinterleave or interleave fields.
14908
14909This filter allows one to process interlaced images fields without
14910deinterlacing them. Deinterleaving splits the input frame into 2
14911fields (so called half pictures). Odd lines are moved to the top
14912half of the output image, even lines to the bottom half.
14913You can process (filter) them independently and then re-interleave them.
14914
14915The filter accepts the following options:
14916
14917@table @option
14918@item luma_mode, l
14919@item chroma_mode, c
14920@item alpha_mode, a
14921Available values for @var{luma_mode}, @var{chroma_mode} and
14922@var{alpha_mode} are:
14923
14924@table @samp
14925@item none
14926Do nothing.
14927
14928@item deinterleave, d
14929Deinterleave fields, placing one above the other.
14930
14931@item interleave, i
14932Interleave fields. Reverse the effect of deinterleaving.
14933@end table
14934Default value is @code{none}.
14935
14936@item luma_swap, ls
14937@item chroma_swap, cs
14938@item alpha_swap, as
14939Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
14940@end table
14941
14942@subsection Commands
14943
14944This filter supports the all above options as @ref{commands}.
14945
14946@section inflate
14947
14948Apply inflate effect to the video.
14949
14950This filter replaces the pixel by the local(3x3) average by taking into account
14951only values higher than the pixel.
14952
14953It accepts the following options:
14954
14955@table @option
14956@item threshold0
14957@item threshold1
14958@item threshold2
14959@item threshold3
14960Limit the maximum change for each plane, default is 65535.
14961If 0, plane will remain unchanged.
14962@end table
14963
14964@subsection Commands
14965
14966This filter supports the all above options as @ref{commands}.
14967
14968@section interlace
14969
14970Simple interlacing filter from progressive contents. This interleaves upper (or
14971lower) lines from odd frames with lower (or upper) lines from even frames,
14972halving the frame rate and preserving image height.
14973
14974@example
14975   Original        Original             New Frame
14976   Frame 'j'      Frame 'j+1'             (tff)
14977  ==========      ===========       ==================
14978    Line 0  -------------------->    Frame 'j' Line 0
14979    Line 1          Line 1  ---->   Frame 'j+1' Line 1
14980    Line 2 --------------------->    Frame 'j' Line 2
14981    Line 3          Line 3  ---->   Frame 'j+1' Line 3
14982     ...             ...                   ...
14983New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
14984@end example
14985
14986It accepts the following optional parameters:
14987
14988@table @option
14989@item scan
14990This determines whether the interlaced frame is taken from the even
14991(tff - default) or odd (bff) lines of the progressive frame.
14992
14993@item lowpass
14994Vertical lowpass filter to avoid twitter interlacing and
14995reduce moire patterns.
14996
14997@table @samp
14998@item 0, off
14999Disable vertical lowpass filter
15000
15001@item 1, linear
15002Enable linear filter (default)
15003
15004@item 2, complex
15005Enable complex filter. This will slightly less reduce twitter and moire
15006but better retain detail and subjective sharpness impression.
15007
15008@end table
15009@end table
15010
15011@section kerndeint
15012
15013Deinterlace input video by applying Donald Graft's adaptive kernel
15014deinterling. Work on interlaced parts of a video to produce
15015progressive frames.
15016
15017The description of the accepted parameters follows.
15018
15019@table @option
15020@item thresh
15021Set the threshold which affects the filter's tolerance when
15022determining if a pixel line must be processed. It must be an integer
15023in the range [0,255] and defaults to 10. A value of 0 will result in
15024applying the process on every pixels.
15025
15026@item map
15027Paint pixels exceeding the threshold value to white if set to 1.
15028Default is 0.
15029
15030@item order
15031Set the fields order. Swap fields if set to 1, leave fields alone if
150320. Default is 0.
15033
15034@item sharp
15035Enable additional sharpening if set to 1. Default is 0.
15036
15037@item twoway
15038Enable twoway sharpening if set to 1. Default is 0.
15039@end table
15040
15041@subsection Examples
15042
15043@itemize
15044@item
15045Apply default values:
15046@example
15047kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
15048@end example
15049
15050@item
15051Enable additional sharpening:
15052@example
15053kerndeint=sharp=1
15054@end example
15055
15056@item
15057Paint processed pixels in white:
15058@example
15059kerndeint=map=1
15060@end example
15061@end itemize
15062
15063@section kirsch
15064Apply kirsch operator to input video stream.
15065
15066The filter accepts the following option:
15067
15068@table @option
15069@item planes
15070Set which planes will be processed, unprocessed planes will be copied.
15071By default value 0xf, all planes will be processed.
15072
15073@item scale
15074Set value which will be multiplied with filtered result.
15075
15076@item delta
15077Set value which will be added to filtered result.
15078@end table
15079
15080@subsection Commands
15081
15082This filter supports the all above options as @ref{commands}.
15083
15084@section lagfun
15085
15086Slowly update darker pixels.
15087
15088This filter makes short flashes of light appear longer.
15089This filter accepts the following options:
15090
15091@table @option
15092@item decay
15093Set factor for decaying. Default is .95. Allowed range is from 0 to 1.
15094
15095@item planes
15096Set which planes to filter. Default is all. Allowed range is from 0 to 15.
15097@end table
15098
15099@subsection Commands
15100
15101This filter supports the all above options as @ref{commands}.
15102
15103@section lenscorrection
15104
15105Correct radial lens distortion
15106
15107This filter can be used to correct for radial distortion as can result from the use
15108of wide angle lenses, and thereby re-rectify the image. To find the right parameters
15109one can use tools available for example as part of opencv or simply trial-and-error.
15110To use opencv use the calibration sample (under samples/cpp) from the opencv sources
15111and extract the k1 and k2 coefficients from the resulting matrix.
15112
15113Note that effectively the same filter is available in the open-source tools Krita and
15114Digikam from the KDE project.
15115
15116In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
15117this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
15118brightness distribution, so you may want to use both filters together in certain
15119cases, though you will have to take care of ordering, i.e. whether vignetting should
15120be applied before or after lens correction.
15121
15122@subsection Options
15123
15124The filter accepts the following options:
15125
15126@table @option
15127@item cx
15128Relative x-coordinate of the focal point of the image, and thereby the center of the
15129distortion. This value has a range [0,1] and is expressed as fractions of the image
15130width. Default is 0.5.
15131@item cy
15132Relative y-coordinate of the focal point of the image, and thereby the center of the
15133distortion. This value has a range [0,1] and is expressed as fractions of the image
15134height. Default is 0.5.
15135@item k1
15136Coefficient of the quadratic correction term. This value has a range [-1,1]. 0 means
15137no correction. Default is 0.
15138@item k2
15139Coefficient of the double quadratic correction term. This value has a range [-1,1].
151400 means no correction. Default is 0.
15141@item i
15142Set interpolation type. Can be @code{nearest} or @code{bilinear}.
15143Default is @code{nearest}.
15144@item fc
15145Specify the color of the unmapped pixels. For the syntax of this option,
15146check the @ref{color syntax,,"Color" section in the ffmpeg-utils
15147manual,ffmpeg-utils}. Default color is @code{black@@0}.
15148@end table
15149
15150The formula that generates the correction is:
15151
15152@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)
15153
15154where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
15155distances from the focal point in the source and target images, respectively.
15156
15157@subsection Commands
15158
15159This filter supports the all above options as @ref{commands}.
15160
15161@section lensfun
15162
15163Apply lens correction via the lensfun library (@url{http://lensfun.sourceforge.net/}).
15164
15165The @code{lensfun} filter requires the camera make, camera model, and lens model
15166to apply the lens correction. The filter will load the lensfun database and
15167query it to find the corresponding camera and lens entries in the database. As
15168long as these entries can be found with the given options, the filter can
15169perform corrections on frames. Note that incomplete strings will result in the
15170filter choosing the best match with the given options, and the filter will
15171output the chosen camera and lens models (logged with level "info"). You must
15172provide the make, camera model, and lens model as they are required.
15173
15174To obtain a list of available makes and models, leave out one or both of @code{make} and
15175@code{model} options. The filter will send the full list to the log with level @code{INFO}.
15176The first column is the make and the second column is the model.
15177To obtain a list of available lenses, set any values for make and model and leave out the
15178@code{lens_model} option. The filter will send the full list of lenses in the log with level
15179@code{INFO}. The ffmpeg tool will exit after the list is printed.
15180
15181The filter accepts the following options:
15182
15183@table @option
15184@item make
15185The make of the camera (for example, "Canon"). This option is required.
15186
15187@item model
15188The model of the camera (for example, "Canon EOS 100D"). This option is
15189required.
15190
15191@item lens_model
15192The model of the lens (for example, "Canon EF-S 18-55mm f/3.5-5.6 IS STM"). This
15193option is required.
15194
15195@item db_path
15196The full path to the lens database folder. If not set, the filter will attempt to
15197load the database from the install path when the library was built. Default is unset.
15198
15199@item mode
15200The type of correction to apply. The following values are valid options:
15201
15202@table @samp
15203@item vignetting
15204Enables fixing lens vignetting.
15205
15206@item geometry
15207Enables fixing lens geometry. This is the default.
15208
15209@item subpixel
15210Enables fixing chromatic aberrations.
15211
15212@item vig_geo
15213Enables fixing lens vignetting and lens geometry.
15214
15215@item vig_subpixel
15216Enables fixing lens vignetting and chromatic aberrations.
15217
15218@item distortion
15219Enables fixing both lens geometry and chromatic aberrations.
15220
15221@item all
15222Enables all possible corrections.
15223
15224@end table
15225@item focal_length
15226The focal length of the image/video (zoom; expected constant for video). For
15227example, a 18--55mm lens has focal length range of [18--55], so a value in that
15228range should be chosen when using that lens. Default 18.
15229
15230@item aperture
15231The aperture of the image/video (expected constant for video). Note that
15232aperture is only used for vignetting correction. Default 3.5.
15233
15234@item focus_distance
15235The focus distance of the image/video (expected constant for video). Note that
15236focus distance is only used for vignetting and only slightly affects the
15237vignetting correction process. If unknown, leave it at the default value (which
15238is 1000).
15239
15240@item scale
15241The scale factor which is applied after transformation. After correction the
15242video is no longer necessarily rectangular. This parameter controls how much of
15243the resulting image is visible. The value 0 means that a value will be chosen
15244automatically such that there is little or no unmapped area in the output
15245image. 1.0 means that no additional scaling is done. Lower values may result
15246in more of the corrected image being visible, while higher values may avoid
15247unmapped areas in the output.
15248
15249@item target_geometry
15250The target geometry of the output image/video. The following values are valid
15251options:
15252
15253@table @samp
15254@item rectilinear (default)
15255@item fisheye
15256@item panoramic
15257@item equirectangular
15258@item fisheye_orthographic
15259@item fisheye_stereographic
15260@item fisheye_equisolid
15261@item fisheye_thoby
15262@end table
15263@item reverse
15264Apply the reverse of image correction (instead of correcting distortion, apply
15265it).
15266
15267@item interpolation
15268The type of interpolation used when correcting distortion. The following values
15269are valid options:
15270
15271@table @samp
15272@item nearest
15273@item linear (default)
15274@item lanczos
15275@end table
15276@end table
15277
15278@subsection Examples
15279
15280@itemize
15281@item
15282Apply lens correction with make "Canon", camera model "Canon EOS 100D", and lens
15283model "Canon EF-S 18-55mm f/3.5-5.6 IS STM" with focal length of "18" and
15284aperture of "8.0".
15285
15286@example
15287ffmpeg -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
15288@end example
15289
15290@item
15291Apply the same as before, but only for the first 5 seconds of video.
15292
15293@example
15294ffmpeg -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
15295@end example
15296
15297@end itemize
15298
15299@section libplacebo
15300
15301Flexible GPU-accelerated processing filter based on libplacebo
15302(@url{https://code.videolan.org/videolan/libplacebo}). Note that this filter
15303currently only accepts Vulkan input frames.
15304
15305@subsection Options
15306
15307The options for this filter are divided into the following sections:
15308
15309@subsubsection Output mode
15310These options control the overall output mode. By default, libplacebo will try
15311to preserve the source colorimetry and size as best as it can, but it will
15312apply any embedded film grain, dolby vision metadata or anamorphic SAR present
15313in source frames.
15314@table @option
15315@item w
15316@item h
15317Set the output video dimension expression. Default value is the input dimension.
15318
15319Allows for the same expressions as the @ref{scale} filter.
15320
15321@item format
15322Set the output format override. If unset (the default), frames will be output
15323in the same format as the respective input frames. Otherwise, format conversion
15324will be performed.
15325
15326@item force_original_aspect_ratio
15327@item force_divisible_by
15328Work the same as the identical @ref{scale} filter options.
15329
15330@item normalize_sar
15331If enabled (the default), output frames will always have a pixel aspect ratio
15332of 1:1. If disabled, any aspect ratio mismatches, including those from e.g.
15333anamorphic video sources, are forwarded to the output pixel aspect ratio.
15334
15335@item pad_crop_ratio
15336Specifies a ratio (between @code{0.0} and @code{1.0}) between padding and
15337cropping when the input aspect ratio does not match the output aspect ratio and
15338@option{normalize_sar} is in effect. The default of @code{0.0} always pads the
15339content with black borders, while a value of @code{1.0} always crops off parts
15340of the content. Intermediate values are possible, leading to a mix of the two
15341approaches.
15342
15343@item colorspace
15344@item color_primaries
15345@item color_trc
15346@item range
15347Configure the colorspace that output frames will be delivered in. The default
15348value of @code{auto} outputs frames in the same format as the input frames,
15349leading to no change. For any other value, conversion will be performed.
15350
15351See the @ref{setparams} filter for a list of possible values.
15352
15353@item apply_filmgrain
15354Apply film grain (e.g. AV1 or H.274) if present in source frames, and strip
15355it from the output. Enabled by default.
15356
15357@item apply_dolbyvision
15358Apply Dolby Vision RPU metadata if present in source frames, and strip it from
15359the output. Enabled by default. Note that Dolby Vision will always output
15360BT.2020+PQ, overriding the usual input frame metadata. These will also be
15361picked as the values of @code{auto} for the respective frame output options.
15362@end table
15363
15364@subsubsection Scaling
15365The options in this section control how libplacebo performs upscaling and (if
15366necessary) downscaling. Note that libplacebo will always internally operate on
153674:4:4 content, so any sub-sampled chroma formats such as @code{yuv420p} will
15368necessarily be upsampled and downsampled as part of the rendering process. That
15369means scaling might be in effect even if the source and destination resolution
15370are the same.
15371@table @option
15372@item upscaler
15373@item downscaler
15374Configure the filter kernel used for upscaling and downscaling. The respective
15375defaults are @code{spline36} and @code{mitchell}. For a full list of possible
15376values, pass @code{help} to these options. The most important values are:
15377@table @samp
15378
15379@item none
15380Forces the use of built-in GPU texture sampling (typically bilinear). Extremely
15381fast but poor quality, especially when downscaling.
15382
15383@item bilinear
15384Bilinear interpolation. Can generally be done for free on GPUs, except when
15385doing so would lead to aliasing. Fast and low quality.
15386
15387@item nearest
15388Nearest-neighbour interpolation. Sharp but highly aliasing.
15389
15390@item oversample
15391Algorithm that looks visually similar to nearest-neighbour interpolation but
15392tries to preserve pixel aspect ratio. Good for pixel art, since it results in
15393minimal distortion of the artistic appearance.
15394
15395@item lanczos
15396Standard sinc-sinc interpolation kernel.
15397
15398@item spline36
15399Cubic spline approximation of lanczos. No difference in performance, but has
15400very slightly less ringing.
15401
15402@item ewa_lanczos
15403Elliptically weighted average version of lanczos, based on a jinc-sinc kernel.
15404This is also popularly referred to as just "Jinc scaling". Slow but very high
15405quality.
15406
15407@item gaussian
15408Gaussian kernel. Has certain ideal mathematical properties, but subjectively
15409very blurry.
15410
15411@item mitchell
15412Cubic BC spline with parameters recommended by Mitchell and Netravali. Very
15413little ringing.
15414@end table
15415
15416@item lut_entries
15417Configures the size of scaler LUTs, ranging from @code{1} to @code{256}. The
15418default of @code{0} will pick libplacebo's internal default, typically
15419@code{64}.
15420
15421@item antiringing
15422Enables anti-ringing (for non-EWA filters). The value (between @code{0.0} and
15423@code{1.0}) configures the strength of the anti-ringing algorithm. May increase
15424aliasing if set too high. Disabled by default.
15425
15426@item sigmoid
15427Enable sigmoidal compression during upscaling. Reduces ringing slightly.
15428Enabled by default.
15429@end table
15430
15431@subsubsection Debanding
15432Libplacebo comes with a built-in debanding filter that is good at counteracting
15433many common sources of banding and blocking. Turning this on is highly
15434recommended whenever quality is desired.
15435@table @option
15436@item deband
15437Enable (fast) debanding algorithm. Disabled by default.
15438
15439@item deband_iterations
15440Number of deband iterations of the debanding algorithm. Each iteration is
15441performed with progressively increased radius (and diminished threshold).
15442Recommended values are in the range @code{1} to @code{4}. Defaults to @code{1}.
15443
15444@item deband_threshold
15445Debanding filter strength. Higher numbers lead to more aggressive debanding.
15446Defaults to @code{4.0}.
15447
15448@item deband_radius
15449Debanding filter radius. A higher radius is better for slow gradients, while
15450a lower radius is better for steep gradients. Defaults to @code{16.0}.
15451
15452@item deband_grain
15453Amount of extra output grain to add. Helps hide imperfections. Defaults to
15454@code{6.0}.
15455@end table
15456
15457@subsubsection Color adjustment
15458A collection of subjective color controls. Not very rigorous, so the exact
15459effect will vary somewhat depending on the input primaries and colorspace.
15460@table @option
15461@item brightness
15462Brightness boost, between @code{-1.0} and @code{1.0}. Defaults to @code{0.0}.
15463
15464@item contrast
15465Contrast gain, between @code{0.0} and @code{16.0}. Defaults to @code{1.0}.
15466
15467@item saturation
15468Saturation gain, between @code{0.0} and @code{16.0}. Defaults to @code{1.0}.
15469
15470@item hue
15471Hue shift in radians, between @code{-3.14} and @code{3.14}. Defaults to
15472@code{0.0}. This will rotate the UV subvector, defaulting to BT.709
15473coefficients for RGB inputs.
15474
15475@item gamma
15476Gamma adjustment, between @code{0.0} and @code{16.0}. Defaults to @code{1.0}.
15477
15478@item cones
15479Cone model to use for color blindness simulation. Accepts any combination of
15480@code{l}, @code{m} and @code{s}. Here are some examples:
15481@table @samp
15482@item m
15483Deuteranomaly / deuteranopia (affecting 3%-4% of the population)
15484@item l
15485Protanomaly / protanopia (affecting 1%-2% of the population)
15486@item l+m
15487Monochromacy (very rare)
15488@item l+m+s
15489Achromatopsy (complete loss of daytime vision, extremely rare)
15490@end table
15491
15492@item cone-strength
15493Gain factor for the cones specified by @code{cones}, between @code{0.0} and
15494@code{10.0}. A value of @code{1.0} results in no change to color vision. A
15495value of @code{0.0} (the default) simulates complete loss of those cones. Values
15496above @code{1.0} result in exaggerating the differences between cones, which
15497may help compensate for reduced color vision.
15498@end table
15499
15500@subsubsection Peak detection
15501To help deal with sources that only have static HDR10 metadata (or no tagging
15502whatsoever), libplacebo uses its own internal frame analysis compute shader to
15503analyze source frames and adapt the tone mapping function in realtime. If this
15504is too slow, or if exactly reproducible frame-perfect results are needed, it's
15505recommended to turn this feature off.
15506@table @option
15507@item peak_detect
15508Enable HDR peak detection. Ignores static MaxCLL/MaxFALL values in favor of
15509dynamic detection from the input. Note that the detected values do not get
15510written back to the output frames, they merely guide the internal tone mapping
15511process. Enabled by default.
15512
15513@item smoothing_period
15514Peak detection smoothing period, between @code{0.0} and @code{1000.0}. Higher
15515values result in peak detection becoming less responsive to changes in the
15516input. Defaults to @code{100.0}.
15517
15518@item minimum_peak
15519Lower bound on the detected peak (relative to SDR white), between @code{0.0}
15520and @code{100.0}. Defaults to @code{1.0}.
15521
15522@item scene_threshold_low
15523@item scene_threshold_high
15524Lower and upper thresholds for scene change detection. Expressed in a
15525logarithmic scale between @code{0.0} and @code{100.0}. Default to @code{5.5}
15526and @code{10.0}, respectively. Setting either to a negative value disables
15527this functionality.
15528
15529@item overshoot
15530Peak smoothing overshoot margin, between @code{0.0} and @code{1.0}. Provides a
15531safety margin to prevent clipping as a result of peak smoothing. Defaults to
15532@code{0.05}, corresponding to a margin of 5%.
15533@end table
15534
15535@subsubsection Tone mapping
15536The options in this section control how libplacebo performs tone-mapping and
15537gamut-mapping when dealing with mismatches between wide-gamut or HDR content.
15538In general, libplacebo relies on accurate source tagging and mastering display
15539gamut information to produce the best results.
15540@table @option
15541@item intent
15542Rendering intent to use when adapting between different primary color gamuts
15543(after tone-mapping).
15544@table @samp
15545@item perceptual
15546Perceptual gamut mapping. Currently equivalent to relative colorimetric.
15547@item relative
15548Relative colorimetric. This is the default.
15549@item absolute
15550Absolute colorimetric.
15551@item saturation
15552Saturation mapping. Forcibly stretches the source gamut to the target gamut.
15553@end table
15554
15555@item gamut_mode
15556How to handle out-of-gamut colors that can occur as a result of colorimetric
15557gamut mapping.
15558@table @samp
15559@item clip
15560Do nothing, simply clip out-of-range colors to the RGB volume. This is the
15561default.
15562@item warn
15563Highlight out-of-gamut pixels (by coloring them pink).
15564@item darken
15565Linearly reduces content brightness to preserves saturated details, followed by
15566clipping the remaining out-of-gamut colors. As the name implies, this makes
15567everything darker, but provides a good balance between preserving details and
15568colors.
15569@item desaturate
15570Hard-desaturates out-of-gamut colors towards white, while preserving the
15571luminance. Has a tendency to shift colors.
15572@end table
15573
15574@item tonemapping
15575Tone-mapping algorithm to use. Available values are:
15576@table @samp
15577@item auto
15578Automatic selection based on internal heuristics. This is the default.
15579@item clip
15580Performs no tone-mapping, just clips out-of-range colors. Retains perfect color
15581accuracy for in-range colors but completely destroys out-of-range information.
15582Does not perform any black point adaptation. Not configurable.
15583@item bt.2390
15584EETF from the ITU-R Report BT.2390, a hermite spline roll-off with linear
15585segment. The knee point offset is configurable. Note that this parameter
15586defaults to @code{1.0}, rather than the value of @code{0.5} from the ITU-R
15587spec.
15588@item bt.2446a
15589EETF from ITU-R Report BT.2446, method A. Designed for well-mastered HDR
15590sources. Can be used for both forward and inverse tone mapping. Not
15591configurable.
15592@item spline
15593Simple spline consisting of two polynomials, joined by a single pivot point.
15594The parameter gives the pivot point (in PQ space), defaulting to @code{0.30}.
15595Can be used for both forward and inverse tone mapping.
15596@item reinhard
15597Simple non-linear, global tone mapping algorithm. The parameter specifies the
15598local contrast coefficient at the display peak. Essentially, a parameter of
15599@code{0.5} implies that the reference white will be about half as bright as
15600when clipping. Defaults to @code{0.5}, which results in the simplest
15601formulation of this function.
15602@item mobius
15603Generalization of the reinhard tone mapping algorithm to support an additional
15604linear slope near black. The tone mapping parameter indicates the trade-off
15605between the linear section and the non-linear section. Essentially, for a given
15606parameter @var{x}, every color value below @var{x} will be mapped linearly,
15607while higher values get non-linearly tone-mapped. Values near @code{1.0} make
15608this curve behave like @code{clip}, while values near @code{0.0} make this
15609curve behave like @code{reinhard}. The default value is @code{0.3}, which
15610provides a good balance between colorimetric accuracy and preserving
15611out-of-gamut details.
15612@item hable
15613Piece-wise, filmic tone-mapping algorithm developed by John Hable for use in
15614Uncharted 2, inspired by a similar tone-mapping algorithm used by Kodak.
15615Popularized by its use in video games with HDR rendering. Preserves both dark
15616and bright details very well, but comes with the drawback of changing the
15617average brightness quite significantly. This is sort of similar to
15618@code{reinhard} with parameter @code{0.24}.
15619@item gamma
15620Fits a gamma (power) function to transfer between the source and target color
15621spaces, effectively resulting in a perceptual hard-knee joining two roughly
15622linear sections. This preserves details at all scales fairly accurately, but
15623can result in an image with a muted or dull appearance. The parameter is used
15624as the cutoff point, defaulting to @code{0.5}.
15625@item linear
15626Linearly stretches the input range to the output range, in PQ space. This will
15627preserve all details accurately, but results in a significantly different
15628average brightness. Can be used for inverse tone-mapping in addition to regular
15629tone-mapping. The parameter can be used as an additional linear gain
15630coefficient (defaulting to @code{1.0}).
15631@end table
15632
15633@item tonemapping_param
15634For tunable tone mapping functions, this parameter can be used to fine-tune the
15635curve behavior. Refer to the documentation of @code{tonemapping}. The default
15636value of @code{0.0} is replaced by the curve's preferred default setting.
15637
15638@item tonemapping_mode
15639This option determines how the tone mapping function specified by
15640@code{tonemapping} is applied to the colors in a scene. Possible values are:
15641@table @samp
15642@item auto
15643Automatic selection based on internal heuristics. This is the default.
15644@item rgb
15645Apply the function per-channel in the RGB colorspace.
15646Per-channel tone-mapping in RGB. Guarantees no clipping and heavily desaturates
15647the output, but distorts the colors quite significantly. Very similar to the
15648"Hollywood" look and feel.
15649@item max
15650Tone-mapping is performed on the brightest component found in the signal. Good
15651at preserving details in highlights, but has a tendency to crush blacks.
15652@item hybrid
15653Tone-map per-channel for highlights and linearly (luma-based) for
15654midtones/shadows, based on a fixed gamma @code{2.4} coefficient curve.
15655@item luma
15656Tone-map linearly on the luma component (CIE Y), and adjust (desaturate) the
15657chromaticities to compensate using a simple constant factor. This is
15658essentially the mode used in ITU-R BT.2446 method A.
15659@end table
15660
15661@item inverse_tonemapping
15662If enabled, this filter will also attempt stretching SDR signals to fill HDR
15663output color volumes. Disabled by default.
15664
15665@item tonemapping_crosstalk
15666Extra tone-mapping crosstalk factor, between @code{0.0} and @code{0.3}. This
15667can help reduce issues tone-mapping certain bright spectral colors. Defaults to
15668@code{0.04}.
15669
15670@item tonemapping_lut_size
15671Size of the tone-mapping LUT, between @code{2} and @code{1024}. Defaults to
15672@code{256}. Note that this figure is squared when combined with
15673@code{peak_detect}.
15674@end table
15675
15676@subsubsection Dithering
15677By default, libplacebo will dither whenever necessary, which includes rendering
15678to any integer format below 16-bit precision. It's recommended to always leave
15679this on, since not doing so may result in visible banding in the output, even
15680if the @code{debanding} filter is enabled. If maximum performance is needed,
15681use @code{ordered_fixed} instead of disabling dithering.
15682@table @option
15683@item dithering
15684Dithering method to use. Accepts the following values:
15685@table @samp
15686@item none
15687Disables dithering completely. May result in visible banding.
15688@item blue
15689Dither with pseudo-blue noise. This is the default.
15690@item ordered
15691Tunable ordered dither pattern.
15692@item ordered_fixed
15693Faster ordered dither with a fixed size of @code{6}. Texture-less.
15694@item white
15695Dither with white noise. Texture-less.
15696@end table
15697
15698@item dither_lut_size
15699Dither LUT size, as log base2 between @code{1} and @code{8}. Defaults to
15700@code{6}, corresponding to a LUT size of @code{64x64}.
15701
15702@item dither_temporal
15703Enables temporal dithering. Disabled by default.
15704@end table
15705
15706@subsubsection Custom shaders
15707libplacebo supports a number of custom shaders based on the mpv .hook GLSL
15708syntax. A collection of such shaders can be found here:
15709@url{https://github.com/mpv-player/mpv/wiki/User-Scripts#user-shaders}
15710
15711A full description of the mpv shader format is beyond the scope of this
15712section, but a summary can be found here:
15713@url{https://mpv.io/manual/master/#options-glsl-shader}
15714@table @option
15715@item custom_shader_path
15716Specifies a path to a custom shader file to load at runtime.
15717
15718@item custom_shader_bin
15719Specifies a complete custom shader as a raw string.
15720@end table
15721
15722@subsubsection Debugging / performance
15723All of the options in this section default off. They may be of assistance when
15724attempting to squeeze the maximum performance at the cost of quality.
15725@table @option
15726@item skip_aa
15727Disable anti-aliasing when downscaling.
15728
15729@item polar_cutoff
15730Truncate polar (EWA) scaler kernels below this absolute magnitude, between
15731@code{0.0} and @code{1.0}.
15732
15733@item disable_linear
15734Disable linear light scaling.
15735
15736@item disable_builtin
15737Disable built-in GPU sampling (forces LUT).
15738
15739@item force_icc_lut
15740Force the use of a full ICC 3DLUT for gamut mapping.
15741
15742@item disable_fbos
15743Forcibly disable FBOs, resulting in loss of almost all functionality, but
15744offering the maximum possible speed.
15745@end table
15746
15747@subsection Commands
15748This filter supports almost all of the above options as @ref{commands}.
15749
15750@subsection Examples
15751@itemize
15752@item
15753Complete example for how to initialize the Vulkan device, upload frames to the
15754GPU, perform filter conversion to yuv420p, and download frames back to the CPU
15755for output. Note that in specific cases you can get around the need to perform
15756format conversion by specifying the correct @code{format} filter option
15757corresponding to the input frames.
15758@example
15759ffmpeg -i $INPUT -init_hw_device vulkan -vf hwupload,libplacebo=format=yuv420p,hwdownload,format=yuv420p $OUTPUT
15760@end example
15761
15762@item
15763Tone-map input to standard gamut BT.709 output:
15764@example
15765libplacebo=colorspace=bt709:color_primaries=bt709:color_trc=bt709:range=tv
15766@end example
15767
15768@item
15769Rescale input to fit into standard 1080p, with high quality scaling:
15770@example
15771libplacebo=w=1920:h=1080:force_original_aspect_ratio=decrease:normalize_sar=true:upscaler=ewa_lanczos:downscaler=ewa_lanczos
15772@end example
15773
15774@item
15775Convert input to standard sRGB JPEG:
15776@example
15777libplacebo=format=yuv420p:colorspace=bt470bg:color_primaries=bt709:color_trc=iec61966-2-1:range=pc
15778@end example
15779
15780@item
15781Use higher quality debanding settings:
15782@example
15783libplacebo=deband=true:deband_iterations=3:deband_radius=8:deband_threshold=6
15784@end example
15785
15786@item
15787Run this filter on the CPU, on systems with Mesa installed (and with the most
15788expensive options disabled):
15789@example
15790ffmpeg ... -init_hw_device vulkan:llvmpipe ... -vf libplacebo=upscaler=none:downscaler=none:peak_detect=false
15791@end example
15792
15793@item
15794Suppress CPU-based AV1/H.274 film grain application in the decoder, in favor of
15795doing it with this filter. Note that this is only a gain if the frames are
15796either already on the GPU, or if you're using libplacebo for other purposes,
15797since otherwise the VRAM roundtrip will more than offset any expected speedup.
15798@example
15799ffmpeg -export_side_data +film_grain ... -vf libplacebo=apply_filmgrain=true
15800@end example
15801@end itemize
15802
15803@section libvmaf
15804
15805Calulate the VMAF (Video Multi-Method Assessment Fusion) score for a
15806reference/distorted pair of input videos.
15807
15808The first input is the distorted video, and the second input is the reference video.
15809
15810The obtained VMAF score is printed through the logging system.
15811
15812It requires Netflix's vmaf library (libvmaf) as a pre-requisite.
15813After installing the library it can be enabled using:
15814@code{./configure --enable-libvmaf}.
15815
15816The filter has following options:
15817
15818@table @option
15819@item model
15820A `|` delimited list of vmaf models. Each model can be configured with a number of parameters.
15821Default value: @code{"version=vmaf_v0.6.1"}
15822
15823@item model_path
15824Deprecated, use model='path=...'.
15825
15826@item enable_transform
15827Deprecated, use model='enable_transform=true'.
15828
15829@item phone_model
15830Deprecated, use model='enable_transform=true'.
15831
15832@item enable_conf_interval
15833Deprecated, use model='enable_conf_interval=true'.
15834
15835@item feature
15836A `|` delimited list of features. Each feature can be configured with a number of parameters.
15837
15838@item psnr
15839Deprecated, use feature='name=psnr'.
15840
15841@item ssim
15842Deprecated, use feature='name=ssim'.
15843
15844@item ms_ssim
15845Deprecated, use feature='name=ms_ssim'.
15846
15847@item log_path
15848Set the file path to be used to store log files.
15849
15850@item log_fmt
15851Set the format of the log file (xml, json, csv, or sub).
15852
15853@item n_threads
15854Set number of threads to be used when initializing libvmaf.
15855Default value: @code{0}, no threads.
15856
15857@item n_subsample
15858Set frame subsampling interval to be used.
15859@end table
15860
15861This filter also supports the @ref{framesync} options.
15862
15863@subsection Examples
15864@itemize
15865@item
15866In the examples below, a distorted video @file{distorted.mpg} is
15867compared with a reference file @file{reference.mpg}.
15868
15869@item
15870Basic usage:
15871@example
15872ffmpeg -i distorted.mpg -i reference.mpg -lavfi libvmaf=log_path=output.xml -f null -
15873@end example
15874
15875@item
15876Example with multiple models:
15877@example
15878ffmpeg -i distorted.mpg -i reference.mpg -lavfi libvmaf='model=version=vmaf_v0.6.1\\:name=vmaf|version=vmaf_v0.6.1neg\\:name=vmaf_neg' -f null -
15879@end example
15880
15881@item
15882Example with multiple addtional features:
15883@example
15884ffmpeg -i distorted.mpg -i reference.mpg -lavfi libvmaf='feature=name=psnr|name=ciede' -f null -
15885@end example
15886
15887@item
15888Example with options and different containers:
15889@example
15890ffmpeg -i distorted.mpg -i reference.mkv -lavfi "[0:v]settb=AVTB,setpts=PTS-STARTPTS[main];[1:v]settb=AVTB,setpts=PTS-STARTPTS[ref];[main][ref]libvmaf=log_fmt=json:log_path=output.json" -f null -
15891@end example
15892@end itemize
15893
15894@section limitdiff
15895Apply limited difference filter using second and optionally third video stream.
15896
15897The filter accepts the following options:
15898
15899@table @option
15900@item threshold
15901Set the threshold to use when allowing certain differences between video streams.
15902Any absolute difference value lower or exact than this threshold will pick pixel components from
15903first video stream.
15904
15905@item elasticity
15906Set the elasticity of soft thresholding when processing video streams.
15907This value multiplied with first one sets second threshold.
15908Any absolute difference value greater or exact than second threshold will pick pixel components
15909from second video stream. For values between those two threshold
15910linear interpolation between first and second video stream will be used.
15911
15912@item reference
15913Enable the reference (third) video stream processing. By default is disabled.
15914If set, this video stream will be used for calculating absolute difference with first video
15915stream.
15916
15917@item planes
15918Specify which planes will be processed. Defaults to all available.
15919@end table
15920
15921@subsection Commands
15922
15923This filter supports the all above options as @ref{commands} except option @samp{reference}.
15924
15925@section limiter
15926
15927Limits the pixel components values to the specified range [min, max].
15928
15929The filter accepts the following options:
15930
15931@table @option
15932@item min
15933Lower bound. Defaults to the lowest allowed value for the input.
15934
15935@item max
15936Upper bound. Defaults to the highest allowed value for the input.
15937
15938@item planes
15939Specify which planes will be processed. Defaults to all available.
15940@end table
15941
15942@subsection Commands
15943
15944This filter supports the all above options as @ref{commands}.
15945
15946@section loop
15947
15948Loop video frames.
15949
15950The filter accepts the following options:
15951
15952@table @option
15953@item loop
15954Set the number of loops. Setting this value to -1 will result in infinite loops.
15955Default is 0.
15956
15957@item size
15958Set maximal size in number of frames. Default is 0.
15959
15960@item start
15961Set first frame of loop. Default is 0.
15962@end table
15963
15964@subsection Examples
15965
15966@itemize
15967@item
15968Loop single first frame infinitely:
15969@example
15970loop=loop=-1:size=1:start=0
15971@end example
15972
15973@item
15974Loop single first frame 10 times:
15975@example
15976loop=loop=10:size=1:start=0
15977@end example
15978
15979@item
15980Loop 10 first frames 5 times:
15981@example
15982loop=loop=5:size=10:start=0
15983@end example
15984@end itemize
15985
15986@section lut1d
15987
15988Apply a 1D LUT to an input video.
15989
15990The filter accepts the following options:
15991
15992@table @option
15993@item file
15994Set the 1D LUT file name.
15995
15996Currently supported formats:
15997@table @samp
15998@item cube
15999Iridas
16000@item csp
16001cineSpace
16002@end table
16003
16004@item interp
16005Select interpolation mode.
16006
16007Available values are:
16008
16009@table @samp
16010@item nearest
16011Use values from the nearest defined point.
16012@item linear
16013Interpolate values using the linear interpolation.
16014@item cosine
16015Interpolate values using the cosine interpolation.
16016@item cubic
16017Interpolate values using the cubic interpolation.
16018@item spline
16019Interpolate values using the spline interpolation.
16020@end table
16021@end table
16022
16023@subsection Commands
16024
16025This filter supports the all above options as @ref{commands}.
16026
16027@anchor{lut3d}
16028@section lut3d
16029
16030Apply a 3D LUT to an input video.
16031
16032The filter accepts the following options:
16033
16034@table @option
16035@item file
16036Set the 3D LUT file name.
16037
16038Currently supported formats:
16039@table @samp
16040@item 3dl
16041AfterEffects
16042@item cube
16043Iridas
16044@item dat
16045DaVinci
16046@item m3d
16047Pandora
16048@item csp
16049cineSpace
16050@end table
16051@item interp
16052Select interpolation mode.
16053
16054Available values are:
16055
16056@table @samp
16057@item nearest
16058Use values from the nearest defined point.
16059@item trilinear
16060Interpolate values using the 8 points defining a cube.
16061@item tetrahedral
16062Interpolate values using a tetrahedron.
16063@item pyramid
16064Interpolate values using a pyramid.
16065@item prism
16066Interpolate values using a prism.
16067@end table
16068@end table
16069
16070@subsection Commands
16071
16072This filter supports the @code{interp} option as @ref{commands}.
16073
16074@section lumakey
16075
16076Turn certain luma values into transparency.
16077
16078The filter accepts the following options:
16079
16080@table @option
16081@item threshold
16082Set the luma which will be used as base for transparency.
16083Default value is @code{0}.
16084
16085@item tolerance
16086Set the range of luma values to be keyed out.
16087Default value is @code{0.01}.
16088
16089@item softness
16090Set the range of softness. Default value is @code{0}.
16091Use this to control gradual transition from zero to full transparency.
16092@end table
16093
16094@subsection Commands
16095This filter supports same @ref{commands} as options.
16096The command accepts the same syntax of the corresponding option.
16097
16098If the specified expression is not valid, it is kept at its current
16099value.
16100
16101@section lut, lutrgb, lutyuv
16102
16103Compute a look-up table for binding each pixel component input value
16104to an output value, and apply it to the input video.
16105
16106@var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
16107to an RGB input video.
16108
16109These filters accept the following parameters:
16110@table @option
16111@item c0
16112set first pixel component expression
16113@item c1
16114set second pixel component expression
16115@item c2
16116set third pixel component expression
16117@item c3
16118set fourth pixel component expression, corresponds to the alpha component
16119
16120@item r
16121set red component expression
16122@item g
16123set green component expression
16124@item b
16125set blue component expression
16126@item a
16127alpha component expression
16128
16129@item y
16130set Y/luminance component expression
16131@item u
16132set U/Cb component expression
16133@item v
16134set V/Cr component expression
16135@end table
16136
16137Each of them specifies the expression to use for computing the lookup table for
16138the corresponding pixel component values.
16139
16140The exact component associated to each of the @var{c*} options depends on the
16141format in input.
16142
16143The @var{lut} filter requires either YUV or RGB pixel formats in input,
16144@var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
16145
16146The expressions can contain the following constants and functions:
16147
16148@table @option
16149@item w
16150@item h
16151The input width and height.
16152
16153@item val
16154The input value for the pixel component.
16155
16156@item clipval
16157The input value, clipped to the @var{minval}-@var{maxval} range.
16158
16159@item maxval
16160The maximum value for the pixel component.
16161
16162@item minval
16163The minimum value for the pixel component.
16164
16165@item negval
16166The negated value for the pixel component value, clipped to the
16167@var{minval}-@var{maxval} range; it corresponds to the expression
16168"maxval-clipval+minval".
16169
16170@item clip(val)
16171The computed value in @var{val}, clipped to the
16172@var{minval}-@var{maxval} range.
16173
16174@item gammaval(gamma)
16175The computed gamma correction value of the pixel component value,
16176clipped to the @var{minval}-@var{maxval} range. It corresponds to the
16177expression
16178"pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
16179
16180@end table
16181
16182All expressions default to "clipval".
16183
16184@subsection Commands
16185
16186This filter supports same @ref{commands} as options.
16187
16188@subsection Examples
16189
16190@itemize
16191@item
16192Negate input video:
16193@example
16194lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
16195lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
16196@end example
16197
16198The above is the same as:
16199@example
16200lutrgb="r=negval:g=negval:b=negval"
16201lutyuv="y=negval:u=negval:v=negval"
16202@end example
16203
16204@item
16205Negate luminance:
16206@example
16207lutyuv=y=negval
16208@end example
16209
16210@item
16211Remove chroma components, turning the video into a graytone image:
16212@example
16213lutyuv="u=128:v=128"
16214@end example
16215
16216@item
16217Apply a luma burning effect:
16218@example
16219lutyuv="y=2*val"
16220@end example
16221
16222@item
16223Remove green and blue components:
16224@example
16225lutrgb="g=0:b=0"
16226@end example
16227
16228@item
16229Set a constant alpha channel value on input:
16230@example
16231format=rgba,lutrgb=a="maxval-minval/2"
16232@end example
16233
16234@item
16235Correct luminance gamma by a factor of 0.5:
16236@example
16237lutyuv=y=gammaval(0.5)
16238@end example
16239
16240@item
16241Discard least significant bits of luma:
16242@example
16243lutyuv=y='bitand(val, 128+64+32)'
16244@end example
16245
16246@item
16247Technicolor like effect:
16248@example
16249lutyuv=u='(val-maxval/2)*2+maxval/2':v='(val-maxval/2)*2+maxval/2'
16250@end example
16251@end itemize
16252
16253@section lut2, tlut2
16254
16255The @code{lut2} filter takes two input streams and outputs one
16256stream.
16257
16258The @code{tlut2} (time lut2) filter takes two consecutive frames
16259from one single stream.
16260
16261This filter accepts the following parameters:
16262@table @option
16263@item c0
16264set first pixel component expression
16265@item c1
16266set second pixel component expression
16267@item c2
16268set third pixel component expression
16269@item c3
16270set fourth pixel component expression, corresponds to the alpha component
16271
16272@item d
16273set output bit depth, only available for @code{lut2} filter. By default is 0,
16274which means bit depth is automatically picked from first input format.
16275@end table
16276
16277The @code{lut2} filter also supports the @ref{framesync} options.
16278
16279Each of them specifies the expression to use for computing the lookup table for
16280the corresponding pixel component values.
16281
16282The exact component associated to each of the @var{c*} options depends on the
16283format in inputs.
16284
16285The expressions can contain the following constants:
16286
16287@table @option
16288@item w
16289@item h
16290The input width and height.
16291
16292@item x
16293The first input value for the pixel component.
16294
16295@item y
16296The second input value for the pixel component.
16297
16298@item bdx
16299The first input video bit depth.
16300
16301@item bdy
16302The second input video bit depth.
16303@end table
16304
16305All expressions default to "x".
16306
16307@subsection Commands
16308
16309This filter supports the all above options as @ref{commands} except option @code{d}.
16310
16311@subsection Examples
16312
16313@itemize
16314@item
16315Highlight differences between two RGB video streams:
16316@example
16317lut2='ifnot(x-y,0,pow(2,bdx)-1):ifnot(x-y,0,pow(2,bdx)-1):ifnot(x-y,0,pow(2,bdx)-1)'
16318@end example
16319
16320@item
16321Highlight differences between two YUV video streams:
16322@example
16323lut2='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)'
16324@end example
16325
16326@item
16327Show max difference between two video streams:
16328@example
16329lut2='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)))'
16330@end example
16331@end itemize
16332
16333@section maskedclamp
16334
16335Clamp the first input stream with the second input and third input stream.
16336
16337Returns the value of first stream to be between second input
16338stream - @code{undershoot} and third input stream + @code{overshoot}.
16339
16340This filter accepts the following options:
16341@table @option
16342@item undershoot
16343Default value is @code{0}.
16344
16345@item overshoot
16346Default value is @code{0}.
16347
16348@item planes
16349Set which planes will be processed as bitmap, unprocessed planes will be
16350copied from first stream.
16351By default value 0xf, all planes will be processed.
16352@end table
16353
16354@subsection Commands
16355
16356This filter supports the all above options as @ref{commands}.
16357
16358@section maskedmax
16359
16360Merge the second and third input stream into output stream using absolute differences
16361between second input stream and first input stream and absolute difference between
16362third input stream and first input stream. The picked value will be from second input
16363stream if second absolute difference is greater than first one or from third input stream
16364otherwise.
16365
16366This filter accepts the following options:
16367@table @option
16368@item planes
16369Set which planes will be processed as bitmap, unprocessed planes will be
16370copied from first stream.
16371By default value 0xf, all planes will be processed.
16372@end table
16373
16374@subsection Commands
16375
16376This filter supports the all above options as @ref{commands}.
16377
16378@section maskedmerge
16379
16380Merge the first input stream with the second input stream using per pixel
16381weights in the third input stream.
16382
16383A value of 0 in the third stream pixel component means that pixel component
16384from first stream is returned unchanged, while maximum value (eg. 255 for
163858-bit videos) means that pixel component from second stream is returned
16386unchanged. Intermediate values define the amount of merging between both
16387input stream's pixel components.
16388
16389This filter accepts the following options:
16390@table @option
16391@item planes
16392Set which planes will be processed as bitmap, unprocessed planes will be
16393copied from first stream.
16394By default value 0xf, all planes will be processed.
16395@end table
16396
16397@subsection Commands
16398
16399This filter supports the all above options as @ref{commands}.
16400
16401@section maskedmin
16402
16403Merge the second and third input stream into output stream using absolute differences
16404between second input stream and first input stream and absolute difference between
16405third input stream and first input stream. The picked value will be from second input
16406stream if second absolute difference is less than first one or from third input stream
16407otherwise.
16408
16409This filter accepts the following options:
16410@table @option
16411@item planes
16412Set which planes will be processed as bitmap, unprocessed planes will be
16413copied from first stream.
16414By default value 0xf, all planes will be processed.
16415@end table
16416
16417@subsection Commands
16418
16419This filter supports the all above options as @ref{commands}.
16420
16421@section maskedthreshold
16422Pick pixels comparing absolute difference of two video streams with fixed
16423threshold.
16424
16425If absolute difference between pixel component of first and second video
16426stream is equal or lower than user supplied threshold than pixel component
16427from first video stream is picked, otherwise pixel component from second
16428video stream is picked.
16429
16430This filter accepts the following options:
16431@table @option
16432@item threshold
16433Set threshold used when picking pixels from absolute difference from two input
16434video streams.
16435
16436@item planes
16437Set which planes will be processed as bitmap, unprocessed planes will be
16438copied from second stream.
16439By default value 0xf, all planes will be processed.
16440@end table
16441
16442@subsection Commands
16443
16444This filter supports the all above options as @ref{commands}.
16445
16446@section maskfun
16447Create mask from input video.
16448
16449For example it is useful to create motion masks after @code{tblend} filter.
16450
16451This filter accepts the following options:
16452
16453@table @option
16454@item low
16455Set low threshold. Any pixel component lower or exact than this value will be set to 0.
16456
16457@item high
16458Set high threshold. Any pixel component higher than this value will be set to max value
16459allowed for current pixel format.
16460
16461@item planes
16462Set planes to filter, by default all available planes are filtered.
16463
16464@item fill
16465Fill all frame pixels with this value.
16466
16467@item sum
16468Set max average pixel value for frame. If sum of all pixel components is higher that this
16469average, output frame will be completely filled with value set by @var{fill} option.
16470Typically useful for scene changes when used in combination with @code{tblend} filter.
16471@end table
16472
16473@subsection Commands
16474
16475This filter supports the all above options as @ref{commands}.
16476
16477@section mcdeint
16478
16479Apply motion-compensation deinterlacing.
16480
16481It needs one field per frame as input and must thus be used together
16482with yadif=1/3 or equivalent.
16483
16484This filter is only available in ffmpeg version 4.4 or earlier.
16485
16486This filter accepts the following options:
16487@table @option
16488@item mode
16489Set the deinterlacing mode.
16490
16491It accepts one of the following values:
16492@table @samp
16493@item fast
16494@item medium
16495@item slow
16496use iterative motion estimation
16497@item extra_slow
16498like @samp{slow}, but use multiple reference frames.
16499@end table
16500Default value is @samp{fast}.
16501
16502@item parity
16503Set the picture field parity assumed for the input video. It must be
16504one of the following values:
16505
16506@table @samp
16507@item 0, tff
16508assume top field first
16509@item 1, bff
16510assume bottom field first
16511@end table
16512
16513Default value is @samp{bff}.
16514
16515@item qp
16516Set per-block quantization parameter (QP) used by the internal
16517encoder.
16518
16519Higher values should result in a smoother motion vector field but less
16520optimal individual vectors. Default value is 1.
16521@end table
16522
16523@section median
16524
16525Pick median pixel from certain rectangle defined by radius.
16526
16527This filter accepts the following options:
16528
16529@table @option
16530@item radius
16531Set horizontal radius size. Default value is @code{1}.
16532Allowed range is integer from 1 to 127.
16533
16534@item planes
16535Set which planes to process. Default is @code{15}, which is all available planes.
16536
16537@item radiusV
16538Set vertical radius size. Default value is @code{0}.
16539Allowed range is integer from 0 to 127.
16540If it is 0, value will be picked from horizontal @code{radius} option.
16541
16542@item percentile
16543Set median percentile. Default value is @code{0.5}.
16544Default value of @code{0.5} will pick always median values, while @code{0} will pick
16545minimum values, and @code{1} maximum values.
16546@end table
16547
16548@subsection Commands
16549This filter supports same @ref{commands} as options.
16550The command accepts the same syntax of the corresponding option.
16551
16552If the specified expression is not valid, it is kept at its current
16553value.
16554
16555@section mergeplanes
16556
16557Merge color channel components from several video streams.
16558
16559The filter accepts up to 4 input streams, and merge selected input
16560planes to the output video.
16561
16562This filter accepts the following options:
16563@table @option
16564@item mapping
16565Set input to output plane mapping. Default is @code{0}.
16566
16567The mappings is specified as a bitmap. It should be specified as a
16568hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
16569mapping for the first plane of the output stream. 'A' sets the number of
16570the input stream to use (from 0 to 3), and 'a' the plane number of the
16571corresponding input to use (from 0 to 3). The rest of the mappings is
16572similar, 'Bb' describes the mapping for the output stream second
16573plane, 'Cc' describes the mapping for the output stream third plane and
16574'Dd' describes the mapping for the output stream fourth plane.
16575
16576@item format
16577Set output pixel format. Default is @code{yuva444p}.
16578
16579@item map0s
16580@item map1s
16581@item map2s
16582@item map3s
16583Set input to output stream mapping for output Nth plane. Default is @code{0}.
16584
16585@item map0p
16586@item map1p
16587@item map2p
16588@item map3p
16589Set input to output plane mapping for output Nth plane. Default is @code{0}.
16590@end table
16591
16592@subsection Examples
16593
16594@itemize
16595@item
16596Merge three gray video streams of same width and height into single video stream:
16597@example
16598[a0][a1][a2]mergeplanes=0x001020:yuv444p
16599@end example
16600
16601@item
16602Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
16603@example
16604[a0][a1]mergeplanes=0x00010210:yuva444p
16605@end example
16606
16607@item
16608Swap Y and A plane in yuva444p stream:
16609@example
16610format=yuva444p,mergeplanes=0x03010200:yuva444p
16611@end example
16612
16613@item
16614Swap U and V plane in yuv420p stream:
16615@example
16616format=yuv420p,mergeplanes=0x000201:yuv420p
16617@end example
16618
16619@item
16620Cast a rgb24 clip to yuv444p:
16621@example
16622format=rgb24,mergeplanes=0x000102:yuv444p
16623@end example
16624@end itemize
16625
16626@section mestimate
16627
16628Estimate and export motion vectors using block matching algorithms.
16629Motion vectors are stored in frame side data to be used by other filters.
16630
16631This filter accepts the following options:
16632@table @option
16633@item method
16634Specify the motion estimation method. Accepts one of the following values:
16635
16636@table @samp
16637@item esa
16638Exhaustive search algorithm.
16639@item tss
16640Three step search algorithm.
16641@item tdls
16642Two dimensional logarithmic search algorithm.
16643@item ntss
16644New three step search algorithm.
16645@item fss
16646Four step search algorithm.
16647@item ds
16648Diamond search algorithm.
16649@item hexbs
16650Hexagon-based search algorithm.
16651@item epzs
16652Enhanced predictive zonal search algorithm.
16653@item umh
16654Uneven multi-hexagon search algorithm.
16655@end table
16656Default value is @samp{esa}.
16657
16658@item mb_size
16659Macroblock size. Default @code{16}.
16660
16661@item search_param
16662Search parameter. Default @code{7}.
16663@end table
16664
16665@section midequalizer
16666
16667Apply Midway Image Equalization effect using two video streams.
16668
16669Midway Image Equalization adjusts a pair of images to have the same
16670histogram, while maintaining their dynamics as much as possible. It's
16671useful for e.g. matching exposures from a pair of stereo cameras.
16672
16673This filter has two inputs and one output, which must be of same pixel format, but
16674may be of different sizes. The output of filter is first input adjusted with
16675midway histogram of both inputs.
16676
16677This filter accepts the following option:
16678
16679@table @option
16680@item planes
16681Set which planes to process. Default is @code{15}, which is all available planes.
16682@end table
16683
16684@section minterpolate
16685
16686Convert the video to specified frame rate using motion interpolation.
16687
16688This filter accepts the following options:
16689@table @option
16690@item fps
16691Specify 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}.
16692
16693@item mi_mode
16694Motion interpolation mode. Following values are accepted:
16695@table @samp
16696@item dup
16697Duplicate previous or next frame for interpolating new ones.
16698@item blend
16699Blend source frames. Interpolated frame is mean of previous and next frames.
16700@item mci
16701Motion compensated interpolation. Following options are effective when this mode is selected:
16702
16703@table @samp
16704@item mc_mode
16705Motion compensation mode. Following values are accepted:
16706@table @samp
16707@item obmc
16708Overlapped block motion compensation.
16709@item aobmc
16710Adaptive overlapped block motion compensation. Window weighting coefficients are controlled adaptively according to the reliabilities of the neighboring motion vectors to reduce oversmoothing.
16711@end table
16712Default mode is @samp{obmc}.
16713
16714@item me_mode
16715Motion estimation mode. Following values are accepted:
16716@table @samp
16717@item bidir
16718Bidirectional motion estimation. Motion vectors are estimated for each source frame in both forward and backward directions.
16719@item bilat
16720Bilateral motion estimation. Motion vectors are estimated directly for interpolated frame.
16721@end table
16722Default mode is @samp{bilat}.
16723
16724@item me
16725The algorithm to be used for motion estimation. Following values are accepted:
16726@table @samp
16727@item esa
16728Exhaustive search algorithm.
16729@item tss
16730Three step search algorithm.
16731@item tdls
16732Two dimensional logarithmic search algorithm.
16733@item ntss
16734New three step search algorithm.
16735@item fss
16736Four step search algorithm.
16737@item ds
16738Diamond search algorithm.
16739@item hexbs
16740Hexagon-based search algorithm.
16741@item epzs
16742Enhanced predictive zonal search algorithm.
16743@item umh
16744Uneven multi-hexagon search algorithm.
16745@end table
16746Default algorithm is @samp{epzs}.
16747
16748@item mb_size
16749Macroblock size. Default @code{16}.
16750
16751@item search_param
16752Motion estimation search parameter. Default @code{32}.
16753
16754@item vsbmc
16755Enable 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).
16756@end table
16757@end table
16758
16759@item scd
16760Scene 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:
16761@table @samp
16762@item none
16763Disable scene change detection.
16764@item fdiff
16765Frame difference. Corresponding pixel values are compared and if it satisfies @var{scd_threshold} scene change is detected.
16766@end table
16767Default method is @samp{fdiff}.
16768
16769@item scd_threshold
16770Scene change detection threshold. Default is @code{10.}.
16771@end table
16772
16773@section mix
16774
16775Mix several video input streams into one video stream.
16776
16777A description of the accepted options follows.
16778
16779@table @option
16780@item inputs
16781The number of inputs. If unspecified, it defaults to 2.
16782
16783@item weights
16784Specify weight of each input video stream as sequence.
16785Each weight is separated by space. If number of weights
16786is smaller than number of @var{frames} last specified
16787weight will be used for all remaining unset weights.
16788
16789@item scale
16790Specify scale, if it is set it will be multiplied with sum
16791of each weight multiplied with pixel values to give final destination
16792pixel value. By default @var{scale} is auto scaled to sum of weights.
16793
16794@item planes
16795Set which planes to filter. Default is all. Allowed range is from 0 to 15.
16796
16797@item duration
16798Specify how end of stream is determined.
16799@table @samp
16800@item longest
16801The duration of the longest input. (default)
16802
16803@item shortest
16804The duration of the shortest input.
16805
16806@item first
16807The duration of the first input.
16808@end table
16809@end table
16810
16811@subsection Commands
16812
16813This filter supports the following commands:
16814@table @option
16815@item weights
16816@item scale
16817@item planes
16818Syntax is same as option with same name.
16819@end table
16820
16821@section monochrome
16822Convert video to gray using custom color filter.
16823
16824A description of the accepted options follows.
16825
16826@table @option
16827@item cb
16828Set the chroma blue spot. Allowed range is from -1 to 1.
16829Default value is 0.
16830
16831@item cr
16832Set the chroma red spot. Allowed range is from -1 to 1.
16833Default value is 0.
16834
16835@item size
16836Set the color filter size. Allowed range is from .1 to 10.
16837Default value is 1.
16838
16839@item high
16840Set the highlights strength. Allowed range is from 0 to 1.
16841Default value is 0.
16842@end table
16843
16844@subsection Commands
16845
16846This filter supports the all above options as @ref{commands}.
16847
16848@section morpho
16849
16850This filter allows to apply main morphological grayscale transforms,
16851erode and dilate with arbitrary structures set in second input stream.
16852
16853Unlike naive implementation and much slower performance in @ref{erosion}
16854and @ref{dilation} filters, when speed is critical @code{morpho} filter
16855should be used instead.
16856
16857A description of accepted options follows,
16858
16859@table @option
16860@item mode
16861Set morphological transform to apply, can be:
16862
16863@table @samp
16864@item erode
16865@item dilate
16866@item open
16867@item close
16868@item gradient
16869@item tophat
16870@item blackhat
16871@end table
16872Default is @code{erode}.
16873
16874@item planes
16875Set planes to filter, by default all planes except alpha are filtered.
16876
16877@item structure
16878Set which structure video frames will be processed from second input stream,
16879can be @var{first} or @var{all}. Default is @var{all}.
16880@end table
16881
16882The @code{morpho} filter also supports the @ref{framesync} options.
16883
16884@subsection Commands
16885
16886This filter supports same @ref{commands} as options.
16887
16888@section mpdecimate
16889
16890Drop frames that do not differ greatly from the previous frame in
16891order to reduce frame rate.
16892
16893The main use of this filter is for very-low-bitrate encoding
16894(e.g. streaming over dialup modem), but it could in theory be used for
16895fixing movies that were inverse-telecined incorrectly.
16896
16897A description of the accepted options follows.
16898
16899@table @option
16900@item max
16901Set the maximum number of consecutive frames which can be dropped (if
16902positive), or the minimum interval between dropped frames (if
16903negative). If the value is 0, the frame is dropped disregarding the
16904number of previous sequentially dropped frames.
16905
16906Default value is 0.
16907
16908@item hi
16909@item lo
16910@item frac
16911Set the dropping threshold values.
16912
16913Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
16914represent actual pixel value differences, so a threshold of 64
16915corresponds to 1 unit of difference for each pixel, or the same spread
16916out differently over the block.
16917
16918A frame is a candidate for dropping if no 8x8 blocks differ by more
16919than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
16920meaning the whole image) differ by more than a threshold of @option{lo}.
16921
16922Default value for @option{hi} is 64*12, default value for @option{lo} is
1692364*5, and default value for @option{frac} is 0.33.
16924@end table
16925
16926@section msad
16927
16928Obtain the MSAD (Mean Sum of Absolute Differences) between two input videos.
16929
16930This filter takes two input videos.
16931
16932Both input videos must have the same resolution and pixel format for
16933this filter to work correctly. Also it assumes that both inputs
16934have the same number of frames, which are compared one by one.
16935
16936The obtained per component, average, min and max MSAD is printed through
16937the logging system.
16938
16939The filter stores the calculated MSAD of each frame in frame metadata.
16940
16941In the below example the input file @file{main.mpg} being processed is compared
16942with the reference file @file{ref.mpg}.
16943
16944@example
16945ffmpeg -i main.mpg -i ref.mpg -lavfi msad -f null -
16946@end example
16947
16948@section multiply
16949Multiply first video stream pixels values with second video stream pixels values.
16950
16951The filter accepts the following options:
16952
16953@table @option
16954@item scale
16955Set the scale applied to second video stream. By default is @code{1}.
16956Allowed range is from @code{0} to @code{9}.
16957
16958@item offset
16959Set the offset applied to second video stream. By default is @code{0.5}.
16960Allowed range is from @code{-1} to @code{1}.
16961
16962@item planes
16963Specify planes from input video stream that will be processed.
16964By default all planes are processed.
16965@end table
16966
16967@subsection Commands
16968
16969This filter supports same @ref{commands} as options.
16970
16971@section negate
16972
16973Negate (invert) the input video.
16974
16975It accepts the following option:
16976
16977@table @option
16978@item components
16979Set components to negate.
16980
16981Available values for components are:
16982@table @samp
16983@item y
16984@item u
16985@item v
16986@item a
16987@item r
16988@item g
16989@item b
16990@end table
16991
16992@item negate_alpha
16993With value 1, it negates the alpha component, if present. Default value is 0.
16994@end table
16995
16996@subsection Commands
16997
16998This filter supports same @ref{commands} as options.
16999
17000@anchor{nlmeans}
17001@section nlmeans
17002
17003Denoise frames using Non-Local Means algorithm.
17004
17005Each pixel is adjusted by looking for other pixels with similar contexts. This
17006context similarity is defined by comparing their surrounding patches of size
17007@option{p}x@option{p}. Patches are searched in an area of @option{r}x@option{r}
17008around the pixel.
17009
17010Note that the research area defines centers for patches, which means some
17011patches will be made of pixels outside that research area.
17012
17013The filter accepts the following options.
17014
17015@table @option
17016@item s
17017Set denoising strength. Default is 1.0. Must be in range [1.0, 30.0].
17018
17019@item p
17020Set patch size. Default is 7. Must be odd number in range [0, 99].
17021
17022@item pc
17023Same as @option{p} but for chroma planes.
17024
17025The default value is @var{0} and means automatic.
17026
17027@item r
17028Set research size. Default is 15. Must be odd number in range [0, 99].
17029
17030@item rc
17031Same as @option{r} but for chroma planes.
17032
17033The default value is @var{0} and means automatic.
17034@end table
17035
17036@section nnedi
17037
17038Deinterlace video using neural network edge directed interpolation.
17039
17040This filter accepts the following options:
17041
17042@table @option
17043@item weights
17044Mandatory option, without binary file filter can not work.
17045Currently file can be found here:
17046https://github.com/dubhater/vapoursynth-nnedi3/blob/master/src/nnedi3_weights.bin
17047
17048@item deint
17049Set which frames to deinterlace, by default it is @code{all}.
17050Can be @code{all} or @code{interlaced}.
17051
17052@item field
17053Set mode of operation.
17054
17055Can be one of the following:
17056
17057@table @samp
17058@item af
17059Use frame flags, both fields.
17060@item a
17061Use frame flags, single field.
17062@item t
17063Use top field only.
17064@item b
17065Use bottom field only.
17066@item tf
17067Use both fields, top first.
17068@item bf
17069Use both fields, bottom first.
17070@end table
17071
17072@item planes
17073Set which planes to process, by default filter process all frames.
17074
17075@item nsize
17076Set size of local neighborhood around each pixel, used by the predictor neural
17077network.
17078
17079Can be one of the following:
17080
17081@table @samp
17082@item s8x6
17083@item s16x6
17084@item s32x6
17085@item s48x6
17086@item s8x4
17087@item s16x4
17088@item s32x4
17089@end table
17090
17091@item nns
17092Set the number of neurons in predictor neural network.
17093Can be one of the following:
17094
17095@table @samp
17096@item n16
17097@item n32
17098@item n64
17099@item n128
17100@item n256
17101@end table
17102
17103@item qual
17104Controls the number of different neural network predictions that are blended
17105together to compute the final output value. Can be @code{fast}, default or
17106@code{slow}.
17107
17108@item etype
17109Set which set of weights to use in the predictor.
17110Can be one of the following:
17111
17112@table @samp
17113@item a, abs
17114weights trained to minimize absolute error
17115@item s, mse
17116weights trained to minimize squared error
17117@end table
17118
17119@item pscrn
17120Controls whether or not the prescreener neural network is used to decide
17121which pixels should be processed by the predictor neural network and which
17122can be handled by simple cubic interpolation.
17123The prescreener is trained to know whether cubic interpolation will be
17124sufficient for a pixel or whether it should be predicted by the predictor nn.
17125The computational complexity of the prescreener nn is much less than that of
17126the predictor nn. Since most pixels can be handled by cubic interpolation,
17127using the prescreener generally results in much faster processing.
17128The prescreener is pretty accurate, so the difference between using it and not
17129using it is almost always unnoticeable.
17130
17131Can be one of the following:
17132
17133@table @samp
17134@item none
17135@item original
17136@item new
17137@item new2
17138@item new3
17139@end table
17140
17141Default is @code{new}.
17142@end table
17143
17144@subsection Commands
17145This filter supports same @ref{commands} as options, excluding @var{weights} option.
17146
17147@section noformat
17148
17149Force libavfilter not to use any of the specified pixel formats for the
17150input to the next filter.
17151
17152It accepts the following parameters:
17153@table @option
17154
17155@item pix_fmts
17156A '|'-separated list of pixel format names, such as
17157pix_fmts=yuv420p|monow|rgb24".
17158
17159@end table
17160
17161@subsection Examples
17162
17163@itemize
17164@item
17165Force libavfilter to use a format different from @var{yuv420p} for the
17166input to the vflip filter:
17167@example
17168noformat=pix_fmts=yuv420p,vflip
17169@end example
17170
17171@item
17172Convert the input video to any of the formats not contained in the list:
17173@example
17174noformat=yuv420p|yuv444p|yuv410p
17175@end example
17176@end itemize
17177
17178@section noise
17179
17180Add noise on video input frame.
17181
17182The filter accepts the following options:
17183
17184@table @option
17185@item all_seed
17186@item c0_seed
17187@item c1_seed
17188@item c2_seed
17189@item c3_seed
17190Set noise seed for specific pixel component or all pixel components in case
17191of @var{all_seed}. Default value is @code{123457}.
17192
17193@item all_strength, alls
17194@item c0_strength, c0s
17195@item c1_strength, c1s
17196@item c2_strength, c2s
17197@item c3_strength, c3s
17198Set noise strength for specific pixel component or all pixel components in case
17199@var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
17200
17201@item all_flags, allf
17202@item c0_flags, c0f
17203@item c1_flags, c1f
17204@item c2_flags, c2f
17205@item c3_flags, c3f
17206Set pixel component flags or set flags for all components if @var{all_flags}.
17207Available values for component flags are:
17208@table @samp
17209@item a
17210averaged temporal noise (smoother)
17211@item p
17212mix random noise with a (semi)regular pattern
17213@item t
17214temporal noise (noise pattern changes between frames)
17215@item u
17216uniform noise (gaussian otherwise)
17217@end table
17218@end table
17219
17220@subsection Examples
17221
17222Add temporal and uniform noise to input video:
17223@example
17224noise=alls=20:allf=t+u
17225@end example
17226
17227@section normalize
17228
17229Normalize RGB video (aka histogram stretching, contrast stretching).
17230See: https://en.wikipedia.org/wiki/Normalization_(image_processing)
17231
17232For each channel of each frame, the filter computes the input range and maps
17233it linearly to the user-specified output range. The output range defaults
17234to the full dynamic range from pure black to pure white.
17235
17236Temporal smoothing can be used on the input range to reduce flickering (rapid
17237changes in brightness) caused when small dark or bright objects enter or leave
17238the scene. This is similar to the auto-exposure (automatic gain control) on a
17239video camera, and, like a video camera, it may cause a period of over- or
17240under-exposure of the video.
17241
17242The R,G,B channels can be normalized independently, which may cause some
17243color shifting, or linked together as a single channel, which prevents
17244color shifting. Linked normalization preserves hue. Independent normalization
17245does not, so it can be used to remove some color casts. Independent and linked
17246normalization can be combined in any ratio.
17247
17248The normalize filter accepts the following options:
17249
17250@table @option
17251@item blackpt
17252@item whitept
17253Colors which define the output range. The minimum input value is mapped to
17254the @var{blackpt}. The maximum input value is mapped to the @var{whitept}.
17255The defaults are black and white respectively. Specifying white for
17256@var{blackpt} and black for @var{whitept} will give color-inverted,
17257normalized video. Shades of grey can be used to reduce the dynamic range
17258(contrast). Specifying saturated colors here can create some interesting
17259effects.
17260
17261@item smoothing
17262The number of previous frames to use for temporal smoothing. The input range
17263of each channel is smoothed using a rolling average over the current frame
17264and the @var{smoothing} previous frames. The default is 0 (no temporal
17265smoothing).
17266
17267@item independence
17268Controls the ratio of independent (color shifting) channel normalization to
17269linked (color preserving) normalization. 0.0 is fully linked, 1.0 is fully
17270independent. Defaults to 1.0 (fully independent).
17271
17272@item strength
17273Overall strength of the filter. 1.0 is full strength. 0.0 is a rather
17274expensive no-op. Defaults to 1.0 (full strength).
17275
17276@end table
17277
17278@subsection Commands
17279This filter supports same @ref{commands} as options, excluding @var{smoothing} option.
17280The command accepts the same syntax of the corresponding option.
17281
17282If the specified expression is not valid, it is kept at its current
17283value.
17284
17285@subsection Examples
17286
17287Stretch video contrast to use the full dynamic range, with no temporal
17288smoothing; may flicker depending on the source content:
17289@example
17290normalize=blackpt=black:whitept=white:smoothing=0
17291@end example
17292
17293As above, but with 50 frames of temporal smoothing; flicker should be
17294reduced, depending on the source content:
17295@example
17296normalize=blackpt=black:whitept=white:smoothing=50
17297@end example
17298
17299As above, but with hue-preserving linked channel normalization:
17300@example
17301normalize=blackpt=black:whitept=white:smoothing=50:independence=0
17302@end example
17303
17304As above, but with half strength:
17305@example
17306normalize=blackpt=black:whitept=white:smoothing=50:independence=0:strength=0.5
17307@end example
17308
17309Map the darkest input color to red, the brightest input color to cyan:
17310@example
17311normalize=blackpt=red:whitept=cyan
17312@end example
17313
17314@section null
17315
17316Pass the video source unchanged to the output.
17317
17318@section ocr
17319Optical Character Recognition
17320
17321This filter uses Tesseract for optical character recognition. To enable
17322compilation of this filter, you need to configure FFmpeg with
17323@code{--enable-libtesseract}.
17324
17325It accepts the following options:
17326
17327@table @option
17328@item datapath
17329Set datapath to tesseract data. Default is to use whatever was
17330set at installation.
17331
17332@item language
17333Set language, default is "eng".
17334
17335@item whitelist
17336Set character whitelist.
17337
17338@item blacklist
17339Set character blacklist.
17340@end table
17341
17342The filter exports recognized text as the frame metadata @code{lavfi.ocr.text}.
17343The filter exports confidence of recognized words as the frame metadata @code{lavfi.ocr.confidence}.
17344
17345@section ocv
17346
17347Apply a video transform using libopencv.
17348
17349To enable this filter, install the libopencv library and headers and
17350configure FFmpeg with @code{--enable-libopencv}.
17351
17352It accepts the following parameters:
17353
17354@table @option
17355
17356@item filter_name
17357The name of the libopencv filter to apply.
17358
17359@item filter_params
17360The parameters to pass to the libopencv filter. If not specified, the default
17361values are assumed.
17362
17363@end table
17364
17365Refer to the official libopencv documentation for more precise
17366information:
17367@url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
17368
17369Several libopencv filters are supported; see the following subsections.
17370
17371@anchor{dilate}
17372@subsection dilate
17373
17374Dilate an image by using a specific structuring element.
17375It corresponds to the libopencv function @code{cvDilate}.
17376
17377It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
17378
17379@var{struct_el} represents a structuring element, and has the syntax:
17380@var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
17381
17382@var{cols} and @var{rows} represent the number of columns and rows of
17383the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
17384point, and @var{shape} the shape for the structuring element. @var{shape}
17385must be "rect", "cross", "ellipse", or "custom".
17386
17387If the value for @var{shape} is "custom", it must be followed by a
17388string of the form "=@var{filename}". The file with name
17389@var{filename} is assumed to represent a binary image, with each
17390printable character corresponding to a bright pixel. When a custom
17391@var{shape} is used, @var{cols} and @var{rows} are ignored, the number
17392or columns and rows of the read file are assumed instead.
17393
17394The default value for @var{struct_el} is "3x3+0x0/rect".
17395
17396@var{nb_iterations} specifies the number of times the transform is
17397applied to the image, and defaults to 1.
17398
17399Some examples:
17400@example
17401# Use the default values
17402ocv=dilate
17403
17404# Dilate using a structuring element with a 5x5 cross, iterating two times
17405ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
17406
17407# Read the shape from the file diamond.shape, iterating two times.
17408# The file diamond.shape may contain a pattern of characters like this
17409#   *
17410#  ***
17411# *****
17412#  ***
17413#   *
17414# The specified columns and rows are ignored
17415# but the anchor point coordinates are not
17416ocv=dilate:0x0+2x2/custom=diamond.shape|2
17417@end example
17418
17419@subsection erode
17420
17421Erode an image by using a specific structuring element.
17422It corresponds to the libopencv function @code{cvErode}.
17423
17424It accepts the parameters: @var{struct_el}:@var{nb_iterations},
17425with the same syntax and semantics as the @ref{dilate} filter.
17426
17427@subsection smooth
17428
17429Smooth the input video.
17430
17431The filter takes the following parameters:
17432@var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
17433
17434@var{type} is the type of smooth filter to apply, and must be one of
17435the following values: "blur", "blur_no_scale", "median", "gaussian",
17436or "bilateral". The default value is "gaussian".
17437
17438The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
17439depends on the smooth type. @var{param1} and
17440@var{param2} accept integer positive values or 0. @var{param3} and
17441@var{param4} accept floating point values.
17442
17443The default value for @var{param1} is 3. The default value for the
17444other parameters is 0.
17445
17446These parameters correspond to the parameters assigned to the
17447libopencv function @code{cvSmooth}.
17448
17449@section oscilloscope
17450
174512D Video Oscilloscope.
17452
17453Useful to measure spatial impulse, step responses, chroma delays, etc.
17454
17455It accepts the following parameters:
17456
17457@table @option
17458@item x
17459Set scope center x position.
17460
17461@item y
17462Set scope center y position.
17463
17464@item s
17465Set scope size, relative to frame diagonal.
17466
17467@item t
17468Set scope tilt/rotation.
17469
17470@item o
17471Set trace opacity.
17472
17473@item tx
17474Set trace center x position.
17475
17476@item ty
17477Set trace center y position.
17478
17479@item tw
17480Set trace width, relative to width of frame.
17481
17482@item th
17483Set trace height, relative to height of frame.
17484
17485@item c
17486Set which components to trace. By default it traces first three components.
17487
17488@item g
17489Draw trace grid. By default is enabled.
17490
17491@item st
17492Draw some statistics. By default is enabled.
17493
17494@item sc
17495Draw scope. By default is enabled.
17496@end table
17497
17498@subsection Commands
17499This filter supports same @ref{commands} as options.
17500The command accepts the same syntax of the corresponding option.
17501
17502If the specified expression is not valid, it is kept at its current
17503value.
17504
17505@subsection Examples
17506
17507@itemize
17508@item
17509Inspect full first row of video frame.
17510@example
17511oscilloscope=x=0.5:y=0:s=1
17512@end example
17513
17514@item
17515Inspect full last row of video frame.
17516@example
17517oscilloscope=x=0.5:y=1:s=1
17518@end example
17519
17520@item
17521Inspect full 5th line of video frame of height 1080.
17522@example
17523oscilloscope=x=0.5:y=5/1080:s=1
17524@end example
17525
17526@item
17527Inspect full last column of video frame.
17528@example
17529oscilloscope=x=1:y=0.5:s=1:t=1
17530@end example
17531
17532@end itemize
17533
17534@anchor{overlay}
17535@section overlay
17536
17537Overlay one video on top of another.
17538
17539It takes two inputs and has one output. The first input is the "main"
17540video on which the second input is overlaid.
17541
17542It accepts the following parameters:
17543
17544A description of the accepted options follows.
17545
17546@table @option
17547@item x
17548@item y
17549Set the expression for the x and y coordinates of the overlaid video
17550on the main video. Default value is "0" for both expressions. In case
17551the expression is invalid, it is set to a huge value (meaning that the
17552overlay will not be displayed within the output visible area).
17553
17554@item eof_action
17555See @ref{framesync}.
17556
17557@item eval
17558Set when the expressions for @option{x}, and @option{y} are evaluated.
17559
17560It accepts the following values:
17561@table @samp
17562@item init
17563only evaluate expressions once during the filter initialization or
17564when a command is processed
17565
17566@item frame
17567evaluate expressions for each incoming frame
17568@end table
17569
17570Default value is @samp{frame}.
17571
17572@item shortest
17573See @ref{framesync}.
17574
17575@item format
17576Set the format for the output video.
17577
17578It accepts the following values:
17579@table @samp
17580@item yuv420
17581force YUV420 output
17582
17583@item yuv420p10
17584force YUV420p10 output
17585
17586@item yuv422
17587force YUV422 output
17588
17589@item yuv422p10
17590force YUV422p10 output
17591
17592@item yuv444
17593force YUV444 output
17594
17595@item rgb
17596force packed RGB output
17597
17598@item gbrp
17599force planar RGB output
17600
17601@item auto
17602automatically pick format
17603@end table
17604
17605Default value is @samp{yuv420}.
17606
17607@item repeatlast
17608See @ref{framesync}.
17609
17610@item alpha
17611Set format of alpha of the overlaid video, it can be @var{straight} or
17612@var{premultiplied}. Default is @var{straight}.
17613@end table
17614
17615The @option{x}, and @option{y} expressions can contain the following
17616parameters.
17617
17618@table @option
17619@item main_w, W
17620@item main_h, H
17621The main input width and height.
17622
17623@item overlay_w, w
17624@item overlay_h, h
17625The overlay input width and height.
17626
17627@item x
17628@item y
17629The computed values for @var{x} and @var{y}. They are evaluated for
17630each new frame.
17631
17632@item hsub
17633@item vsub
17634horizontal and vertical chroma subsample values of the output
17635format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
17636@var{vsub} is 1.
17637
17638@item n
17639the number of input frame, starting from 0
17640
17641@item pos
17642the position in the file of the input frame, NAN if unknown
17643
17644@item t
17645The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
17646
17647@end table
17648
17649This filter also supports the @ref{framesync} options.
17650
17651Note that the @var{n}, @var{pos}, @var{t} variables are available only
17652when evaluation is done @emph{per frame}, and will evaluate to NAN
17653when @option{eval} is set to @samp{init}.
17654
17655Be aware that frames are taken from each input video in timestamp
17656order, hence, if their initial timestamps differ, it is a good idea
17657to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
17658have them begin in the same zero timestamp, as the example for
17659the @var{movie} filter does.
17660
17661You can chain together more overlays but you should test the
17662efficiency of such approach.
17663
17664@subsection Commands
17665
17666This filter supports the following commands:
17667@table @option
17668@item x
17669@item y
17670Modify the x and y of the overlay input.
17671The command accepts the same syntax of the corresponding option.
17672
17673If the specified expression is not valid, it is kept at its current
17674value.
17675@end table
17676
17677@subsection Examples
17678
17679@itemize
17680@item
17681Draw the overlay at 10 pixels from the bottom right corner of the main
17682video:
17683@example
17684overlay=main_w-overlay_w-10:main_h-overlay_h-10
17685@end example
17686
17687Using named options the example above becomes:
17688@example
17689overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
17690@end example
17691
17692@item
17693Insert a transparent PNG logo in the bottom left corner of the input,
17694using the @command{ffmpeg} tool with the @code{-filter_complex} option:
17695@example
17696ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
17697@end example
17698
17699@item
17700Insert 2 different transparent PNG logos (second logo on bottom
17701right corner) using the @command{ffmpeg} tool:
17702@example
17703ffmpeg -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
17704@end example
17705
17706@item
17707Add a transparent color layer on top of the main video; @code{WxH}
17708must specify the size of the main input to the overlay filter:
17709@example
17710color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
17711@end example
17712
17713@item
17714Play an original video and a filtered version (here with the deshake
17715filter) side by side using the @command{ffplay} tool:
17716@example
17717ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
17718@end example
17719
17720The above command is the same as:
17721@example
17722ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
17723@end example
17724
17725@item
17726Make a sliding overlay appearing from the left to the right top part of the
17727screen starting since time 2:
17728@example
17729overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
17730@end example
17731
17732@item
17733Compose output by putting two input videos side to side:
17734@example
17735ffmpeg -i left.avi -i right.avi -filter_complex "
17736nullsrc=size=200x100 [background];
17737[0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
17738[1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
17739[background][left]       overlay=shortest=1       [background+left];
17740[background+left][right] overlay=shortest=1:x=100 [left+right]
17741"
17742@end example
17743
17744@item
17745Mask 10-20 seconds of a video by applying the delogo filter to a section
17746@example
17747ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
17748-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]'
17749masked.avi
17750@end example
17751
17752@item
17753Chain several overlays in cascade:
17754@example
17755nullsrc=s=200x200 [bg];
17756testsrc=s=100x100, split=4 [in0][in1][in2][in3];
17757[in0] lutrgb=r=0, [bg]   overlay=0:0     [mid0];
17758[in1] lutrgb=g=0, [mid0] overlay=100:0   [mid1];
17759[in2] lutrgb=b=0, [mid1] overlay=0:100   [mid2];
17760[in3] null,       [mid2] overlay=100:100 [out0]
17761@end example
17762
17763@end itemize
17764
17765@anchor{overlay_cuda}
17766@section overlay_cuda
17767
17768Overlay one video on top of another.
17769
17770This is the CUDA variant of the @ref{overlay} filter.
17771It only accepts CUDA frames. The underlying input pixel formats have to match.
17772
17773It takes two inputs and has one output. The first input is the "main"
17774video on which the second input is overlaid.
17775
17776It accepts the following parameters:
17777
17778@table @option
17779@item x
17780@item y
17781Set expressions for the x and y coordinates of the overlaid video
17782on the main video.
17783
17784They can contain the following parameters:
17785
17786@table @option
17787
17788@item main_w, W
17789@item main_h, H
17790The main input width and height.
17791
17792@item overlay_w, w
17793@item overlay_h, h
17794The overlay input width and height.
17795
17796@item x
17797@item y
17798The computed values for @var{x} and @var{y}. They are evaluated for
17799each new frame.
17800
17801@item n
17802The ordinal index of the main input frame, starting from 0.
17803
17804@item pos
17805The byte offset position in the file of the main input frame, NAN if unknown.
17806
17807@item t
17808The timestamp of the main input frame, expressed in seconds, NAN if unknown.
17809
17810@end table
17811
17812Default value is "0" for both expressions.
17813
17814@item eval
17815Set when the expressions for @option{x} and @option{y} are evaluated.
17816
17817It accepts the following values:
17818@table @option
17819@item init
17820Evaluate expressions once during filter initialization or
17821when a command is processed.
17822
17823@item frame
17824Evaluate expressions for each incoming frame
17825@end table
17826
17827Default value is @option{frame}.
17828
17829@item eof_action
17830See @ref{framesync}.
17831
17832@item shortest
17833See @ref{framesync}.
17834
17835@item repeatlast
17836See @ref{framesync}.
17837
17838@end table
17839
17840This filter also supports the @ref{framesync} options.
17841
17842@section owdenoise
17843
17844Apply Overcomplete Wavelet denoiser.
17845
17846The filter accepts the following options:
17847
17848@table @option
17849@item depth
17850Set depth.
17851
17852Larger depth values will denoise lower frequency components more, but
17853slow down filtering.
17854
17855Must be an int in the range 8-16, default is @code{8}.
17856
17857@item luma_strength, ls
17858Set luma strength.
17859
17860Must be a double value in the range 0-1000, default is @code{1.0}.
17861
17862@item chroma_strength, cs
17863Set chroma strength.
17864
17865Must be a double value in the range 0-1000, default is @code{1.0}.
17866@end table
17867
17868@anchor{pad}
17869@section pad
17870
17871Add paddings to the input image, and place the original input at the
17872provided @var{x}, @var{y} coordinates.
17873
17874It accepts the following parameters:
17875
17876@table @option
17877@item width, w
17878@item height, h
17879Specify an expression for the size of the output image with the
17880paddings added. If the value for @var{width} or @var{height} is 0, the
17881corresponding input size is used for the output.
17882
17883The @var{width} expression can reference the value set by the
17884@var{height} expression, and vice versa.
17885
17886The default value of @var{width} and @var{height} is 0.
17887
17888@item x
17889@item y
17890Specify the offsets to place the input image at within the padded area,
17891with respect to the top/left border of the output image.
17892
17893The @var{x} expression can reference the value set by the @var{y}
17894expression, and vice versa.
17895
17896The default value of @var{x} and @var{y} is 0.
17897
17898If @var{x} or @var{y} evaluate to a negative number, they'll be changed
17899so the input image is centered on the padded area.
17900
17901@item color
17902Specify the color of the padded area. For the syntax of this option,
17903check the @ref{color syntax,,"Color" section in the ffmpeg-utils
17904manual,ffmpeg-utils}.
17905
17906The default value of @var{color} is "black".
17907
17908@item eval
17909Specify when to evaluate  @var{width}, @var{height}, @var{x} and @var{y} expression.
17910
17911It accepts the following values:
17912
17913@table @samp
17914@item init
17915Only evaluate expressions once during the filter initialization or when
17916a command is processed.
17917
17918@item frame
17919Evaluate expressions for each incoming frame.
17920
17921@end table
17922
17923Default value is @samp{init}.
17924
17925@item aspect
17926Pad to aspect instead to a resolution.
17927
17928@end table
17929
17930The value for the @var{width}, @var{height}, @var{x}, and @var{y}
17931options are expressions containing the following constants:
17932
17933@table @option
17934@item in_w
17935@item in_h
17936The input video width and height.
17937
17938@item iw
17939@item ih
17940These are the same as @var{in_w} and @var{in_h}.
17941
17942@item out_w
17943@item out_h
17944The output width and height (the size of the padded area), as
17945specified by the @var{width} and @var{height} expressions.
17946
17947@item ow
17948@item oh
17949These are the same as @var{out_w} and @var{out_h}.
17950
17951@item x
17952@item y
17953The x and y offsets as specified by the @var{x} and @var{y}
17954expressions, or NAN if not yet specified.
17955
17956@item a
17957same as @var{iw} / @var{ih}
17958
17959@item sar
17960input sample aspect ratio
17961
17962@item dar
17963input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
17964
17965@item hsub
17966@item vsub
17967The horizontal and vertical chroma subsample values. For example for the
17968pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
17969@end table
17970
17971@subsection Examples
17972
17973@itemize
17974@item
17975Add paddings with the color "violet" to the input video. The output video
17976size is 640x480, and the top-left corner of the input video is placed at
17977column 0, row 40
17978@example
17979pad=640:480:0:40:violet
17980@end example
17981
17982The example above is equivalent to the following command:
17983@example
17984pad=width=640:height=480:x=0:y=40:color=violet
17985@end example
17986
17987@item
17988Pad the input to get an output with dimensions increased by 3/2,
17989and put the input video at the center of the padded area:
17990@example
17991pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
17992@end example
17993
17994@item
17995Pad the input to get a squared output with size equal to the maximum
17996value between the input width and height, and put the input video at
17997the center of the padded area:
17998@example
17999pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
18000@end example
18001
18002@item
18003Pad the input to get a final w/h ratio of 16:9:
18004@example
18005pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
18006@end example
18007
18008@item
18009In case of anamorphic video, in order to set the output display aspect
18010correctly, it is necessary to use @var{sar} in the expression,
18011according to the relation:
18012@example
18013(ih * X / ih) * sar = output_dar
18014X = output_dar / sar
18015@end example
18016
18017Thus the previous example needs to be modified to:
18018@example
18019pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
18020@end example
18021
18022@item
18023Double the output size and put the input video in the bottom-right
18024corner of the output padded area:
18025@example
18026pad="2*iw:2*ih:ow-iw:oh-ih"
18027@end example
18028@end itemize
18029
18030@anchor{palettegen}
18031@section palettegen
18032
18033Generate one palette for a whole video stream.
18034
18035It accepts the following options:
18036
18037@table @option
18038@item max_colors
18039Set the maximum number of colors to quantize in the palette.
18040Note: the palette will still contain 256 colors; the unused palette entries
18041will be black.
18042
18043@item reserve_transparent
18044Create a palette of 255 colors maximum and reserve the last one for
18045transparency. Reserving the transparency color is useful for GIF optimization.
18046If not set, the maximum of colors in the palette will be 256. You probably want
18047to disable this option for a standalone image.
18048Set by default.
18049
18050@item transparency_color
18051Set the color that will be used as background for transparency.
18052
18053@item stats_mode
18054Set statistics mode.
18055
18056It accepts the following values:
18057@table @samp
18058@item full
18059Compute full frame histograms.
18060@item diff
18061Compute histograms only for the part that differs from previous frame. This
18062might be relevant to give more importance to the moving part of your input if
18063the background is static.
18064@item single
18065Compute new histogram for each frame.
18066@end table
18067
18068Default value is @var{full}.
18069@item use_alpha
18070Create a palette of colors with alpha components.
18071Setting this, will automatically disable 'reserve_transparent'.
18072@end table
18073
18074The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
18075(@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
18076color quantization of the palette. This information is also visible at
18077@var{info} logging level.
18078
18079@subsection Examples
18080
18081@itemize
18082@item
18083Generate a representative palette of a given video using @command{ffmpeg}:
18084@example
18085ffmpeg -i input.mkv -vf palettegen palette.png
18086@end example
18087@end itemize
18088
18089@section paletteuse
18090
18091Use a palette to downsample an input video stream.
18092
18093The filter takes two inputs: one video stream and a palette. The palette must
18094be a 256 pixels image.
18095
18096It accepts the following options:
18097
18098@table @option
18099@item dither
18100Select dithering mode. Available algorithms are:
18101@table @samp
18102@item bayer
18103Ordered 8x8 bayer dithering (deterministic)
18104@item heckbert
18105Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
18106Note: this dithering is sometimes considered "wrong" and is included as a
18107reference.
18108@item floyd_steinberg
18109Floyd and Steingberg dithering (error diffusion)
18110@item sierra2
18111Frankie Sierra dithering v2 (error diffusion)
18112@item sierra2_4a
18113Frankie Sierra dithering v2 "Lite" (error diffusion)
18114@end table
18115
18116Default is @var{sierra2_4a}.
18117
18118@item bayer_scale
18119When @var{bayer} dithering is selected, this option defines the scale of the
18120pattern (how much the crosshatch pattern is visible). A low value means more
18121visible pattern for less banding, and higher value means less visible pattern
18122at the cost of more banding.
18123
18124The option must be an integer value in the range [0,5]. Default is @var{2}.
18125
18126@item diff_mode
18127If set, define the zone to process
18128
18129@table @samp
18130@item rectangle
18131Only the changing rectangle will be reprocessed. This is similar to GIF
18132cropping/offsetting compression mechanism. This option can be useful for speed
18133if only a part of the image is changing, and has use cases such as limiting the
18134scope of the error diffusal @option{dither} to the rectangle that bounds the
18135moving scene (it leads to more deterministic output if the scene doesn't change
18136much, and as a result less moving noise and better GIF compression).
18137@end table
18138
18139Default is @var{none}.
18140
18141@item new
18142Take new palette for each output frame.
18143
18144@item alpha_threshold
18145Sets the alpha threshold for transparency. Alpha values above this threshold
18146will be treated as completely opaque, and values below this threshold will be
18147treated as completely transparent.
18148
18149The option must be an integer value in the range [0,255]. Default is @var{128}.
18150
18151@item use_alpha
18152Apply the palette by taking alpha values into account. Only useful with
18153palettes that are containing multiple colors with alpha components.
18154Setting this will automatically disable 'alpha_treshold'.
18155@end table
18156
18157@subsection Examples
18158
18159@itemize
18160@item
18161Use a palette (generated for example with @ref{palettegen}) to encode a GIF
18162using @command{ffmpeg}:
18163@example
18164ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
18165@end example
18166@end itemize
18167
18168@section perspective
18169
18170Correct perspective of video not recorded perpendicular to the screen.
18171
18172A description of the accepted parameters follows.
18173
18174@table @option
18175@item x0
18176@item y0
18177@item x1
18178@item y1
18179@item x2
18180@item y2
18181@item x3
18182@item y3
18183Set coordinates expression for top left, top right, bottom left and bottom right corners.
18184Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
18185If the @code{sense} option is set to @code{source}, then the specified points will be sent
18186to the corners of the destination. If the @code{sense} option is set to @code{destination},
18187then the corners of the source will be sent to the specified coordinates.
18188
18189The expressions can use the following variables:
18190
18191@table @option
18192@item W
18193@item H
18194the width and height of video frame.
18195@item in
18196Input frame count.
18197@item on
18198Output frame count.
18199@end table
18200
18201@item interpolation
18202Set interpolation for perspective correction.
18203
18204It accepts the following values:
18205@table @samp
18206@item linear
18207@item cubic
18208@end table
18209
18210Default value is @samp{linear}.
18211
18212@item sense
18213Set interpretation of coordinate options.
18214
18215It accepts the following values:
18216@table @samp
18217@item 0, source
18218
18219Send point in the source specified by the given coordinates to
18220the corners of the destination.
18221
18222@item 1, destination
18223
18224Send the corners of the source to the point in the destination specified
18225by the given coordinates.
18226
18227Default value is @samp{source}.
18228@end table
18229
18230@item eval
18231Set when the expressions for coordinates @option{x0,y0,...x3,y3} are evaluated.
18232
18233It accepts the following values:
18234@table @samp
18235@item init
18236only evaluate expressions once during the filter initialization or
18237when a command is processed
18238
18239@item frame
18240evaluate expressions for each incoming frame
18241@end table
18242
18243Default value is @samp{init}.
18244@end table
18245
18246@section phase
18247
18248Delay interlaced video by one field time so that the field order changes.
18249
18250The intended use is to fix PAL movies that have been captured with the
18251opposite field order to the film-to-video transfer.
18252
18253A description of the accepted parameters follows.
18254
18255@table @option
18256@item mode
18257Set phase mode.
18258
18259It accepts the following values:
18260@table @samp
18261@item t
18262Capture field order top-first, transfer bottom-first.
18263Filter will delay the bottom field.
18264
18265@item b
18266Capture field order bottom-first, transfer top-first.
18267Filter will delay the top field.
18268
18269@item p
18270Capture and transfer with the same field order. This mode only exists
18271for the documentation of the other options to refer to, but if you
18272actually select it, the filter will faithfully do nothing.
18273
18274@item a
18275Capture field order determined automatically by field flags, transfer
18276opposite.
18277Filter selects among @samp{t} and @samp{b} modes on a frame by frame
18278basis using field flags. If no field information is available,
18279then this works just like @samp{u}.
18280
18281@item u
18282Capture unknown or varying, transfer opposite.
18283Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
18284analyzing the images and selecting the alternative that produces best
18285match between the fields.
18286
18287@item T
18288Capture top-first, transfer unknown or varying.
18289Filter selects among @samp{t} and @samp{p} using image analysis.
18290
18291@item B
18292Capture bottom-first, transfer unknown or varying.
18293Filter selects among @samp{b} and @samp{p} using image analysis.
18294
18295@item A
18296Capture determined by field flags, transfer unknown or varying.
18297Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
18298image analysis. If no field information is available, then this works just
18299like @samp{U}. This is the default mode.
18300
18301@item U
18302Both capture and transfer unknown or varying.
18303Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
18304@end table
18305@end table
18306
18307@subsection Commands
18308
18309This filter supports the all above options as @ref{commands}.
18310
18311@section photosensitivity
18312Reduce various flashes in video, so to help users with epilepsy.
18313
18314It accepts the following options:
18315@table @option
18316@item frames, f
18317Set how many frames to use when filtering. Default is 30.
18318
18319@item threshold, t
18320Set detection threshold factor. Default is 1.
18321Lower is stricter.
18322
18323@item skip
18324Set how many pixels to skip when sampling frames. Default is 1.
18325Allowed range is from 1 to 1024.
18326
18327@item bypass
18328Leave frames unchanged. Default is disabled.
18329@end table
18330
18331@section pixdesctest
18332
18333Pixel format descriptor test filter, mainly useful for internal
18334testing. The output video should be equal to the input video.
18335
18336For example:
18337@example
18338format=monow, pixdesctest
18339@end example
18340
18341can be used to test the monowhite pixel format descriptor definition.
18342
18343@section pixelize
18344Apply pixelization to video stream.
18345
18346The filter accepts the following options:
18347@table @option
18348@item width, w
18349@item height, h
18350Set block dimensions that will be used for pixelization.
18351Default value is @code{16}.
18352
18353@item mode, m
18354Set the mode of pixelization used.
18355
18356Possible values are:
18357@table @samp
18358@item avg
18359@item min
18360@item max
18361@end table
18362Default value is @code{avg}.
18363
18364@item planes, p
18365Set what planes to filter. Default is to filter all planes.
18366@end table
18367
18368@subsection Commands
18369
18370This filter supports all options as @ref{commands}.
18371
18372@section pixscope
18373
18374Display sample values of color channels. Mainly useful for checking color
18375and levels. Minimum supported resolution is 640x480.
18376
18377The filters accept the following options:
18378
18379@table @option
18380@item x
18381Set scope X position, relative offset on X axis.
18382
18383@item y
18384Set scope Y position, relative offset on Y axis.
18385
18386@item w
18387Set scope width.
18388
18389@item h
18390Set scope height.
18391
18392@item o
18393Set window opacity. This window also holds statistics about pixel area.
18394
18395@item wx
18396Set window X position, relative offset on X axis.
18397
18398@item wy
18399Set window Y position, relative offset on Y axis.
18400@end table
18401
18402@subsection Commands
18403
18404This filter supports same @ref{commands} as options.
18405
18406@section pp
18407
18408Enable the specified chain of postprocessing subfilters using libpostproc. This
18409library should be automatically selected with a GPL build (@code{--enable-gpl}).
18410Subfilters must be separated by '/' and can be disabled by prepending a '-'.
18411Each subfilter and some options have a short and a long name that can be used
18412interchangeably, i.e. dr/dering are the same.
18413
18414The filters accept the following options:
18415
18416@table @option
18417@item subfilters
18418Set postprocessing subfilters string.
18419@end table
18420
18421All subfilters share common options to determine their scope:
18422
18423@table @option
18424@item a/autoq
18425Honor the quality commands for this subfilter.
18426
18427@item c/chrom
18428Do chrominance filtering, too (default).
18429
18430@item y/nochrom
18431Do luminance filtering only (no chrominance).
18432
18433@item n/noluma
18434Do chrominance filtering only (no luminance).
18435@end table
18436
18437These options can be appended after the subfilter name, separated by a '|'.
18438
18439Available subfilters are:
18440
18441@table @option
18442@item hb/hdeblock[|difference[|flatness]]
18443Horizontal deblocking filter
18444@table @option
18445@item difference
18446Difference factor where higher values mean more deblocking (default: @code{32}).
18447@item flatness
18448Flatness threshold where lower values mean more deblocking (default: @code{39}).
18449@end table
18450
18451@item vb/vdeblock[|difference[|flatness]]
18452Vertical deblocking filter
18453@table @option
18454@item difference
18455Difference factor where higher values mean more deblocking (default: @code{32}).
18456@item flatness
18457Flatness threshold where lower values mean more deblocking (default: @code{39}).
18458@end table
18459
18460@item ha/hadeblock[|difference[|flatness]]
18461Accurate horizontal deblocking filter
18462@table @option
18463@item difference
18464Difference factor where higher values mean more deblocking (default: @code{32}).
18465@item flatness
18466Flatness threshold where lower values mean more deblocking (default: @code{39}).
18467@end table
18468
18469@item va/vadeblock[|difference[|flatness]]
18470Accurate vertical deblocking filter
18471@table @option
18472@item difference
18473Difference factor where higher values mean more deblocking (default: @code{32}).
18474@item flatness
18475Flatness threshold where lower values mean more deblocking (default: @code{39}).
18476@end table
18477@end table
18478
18479The horizontal and vertical deblocking filters share the difference and
18480flatness values so you cannot set different horizontal and vertical
18481thresholds.
18482
18483@table @option
18484@item h1/x1hdeblock
18485Experimental horizontal deblocking filter
18486
18487@item v1/x1vdeblock
18488Experimental vertical deblocking filter
18489
18490@item dr/dering
18491Deringing filter
18492
18493@item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
18494@table @option
18495@item threshold1
18496larger -> stronger filtering
18497@item threshold2
18498larger -> stronger filtering
18499@item threshold3
18500larger -> stronger filtering
18501@end table
18502
18503@item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
18504@table @option
18505@item f/fullyrange
18506Stretch luminance to @code{0-255}.
18507@end table
18508
18509@item lb/linblenddeint
18510Linear blend deinterlacing filter that deinterlaces the given block by
18511filtering all lines with a @code{(1 2 1)} filter.
18512
18513@item li/linipoldeint
18514Linear interpolating deinterlacing filter that deinterlaces the given block by
18515linearly interpolating every second line.
18516
18517@item ci/cubicipoldeint
18518Cubic interpolating deinterlacing filter deinterlaces the given block by
18519cubically interpolating every second line.
18520
18521@item md/mediandeint
18522Median deinterlacing filter that deinterlaces the given block by applying a
18523median filter to every second line.
18524
18525@item fd/ffmpegdeint
18526FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
18527second line with a @code{(-1 4 2 4 -1)} filter.
18528
18529@item l5/lowpass5
18530Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
18531block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
18532
18533@item fq/forceQuant[|quantizer]
18534Overrides the quantizer table from the input with the constant quantizer you
18535specify.
18536@table @option
18537@item quantizer
18538Quantizer to use
18539@end table
18540
18541@item de/default
18542Default pp filter combination (@code{hb|a,vb|a,dr|a})
18543
18544@item fa/fast
18545Fast pp filter combination (@code{h1|a,v1|a,dr|a})
18546
18547@item ac
18548High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
18549@end table
18550
18551@subsection Examples
18552
18553@itemize
18554@item
18555Apply horizontal and vertical deblocking, deringing and automatic
18556brightness/contrast:
18557@example
18558pp=hb/vb/dr/al
18559@end example
18560
18561@item
18562Apply default filters without brightness/contrast correction:
18563@example
18564pp=de/-al
18565@end example
18566
18567@item
18568Apply default filters and temporal denoiser:
18569@example
18570pp=default/tmpnoise|1|2|3
18571@end example
18572
18573@item
18574Apply deblocking on luminance only, and switch vertical deblocking on or off
18575automatically depending on available CPU time:
18576@example
18577pp=hb|y/vb|a
18578@end example
18579@end itemize
18580
18581@section pp7
18582Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
18583similar to spp = 6 with 7 point DCT, where only the center sample is
18584used after IDCT.
18585
18586The filter accepts the following options:
18587
18588@table @option
18589@item qp
18590Force a constant quantization parameter. It accepts an integer in range
185910 to 63. If not set, the filter will use the QP from the video stream
18592(if available).
18593
18594@item mode
18595Set thresholding mode. Available modes are:
18596
18597@table @samp
18598@item hard
18599Set hard thresholding.
18600@item soft
18601Set soft thresholding (better de-ringing effect, but likely blurrier).
18602@item medium
18603Set medium thresholding (good results, default).
18604@end table
18605@end table
18606
18607@section premultiply
18608Apply alpha premultiply effect to input video stream using first plane
18609of second stream as alpha.
18610
18611Both streams must have same dimensions and same pixel format.
18612
18613The filter accepts the following option:
18614
18615@table @option
18616@item planes
18617Set which planes will be processed, unprocessed planes will be copied.
18618By default value 0xf, all planes will be processed.
18619
18620@item inplace
18621Do not require 2nd input for processing, instead use alpha plane from input stream.
18622@end table
18623
18624@section prewitt
18625Apply prewitt operator to input video stream.
18626
18627The filter accepts the following option:
18628
18629@table @option
18630@item planes
18631Set which planes will be processed, unprocessed planes will be copied.
18632By default value 0xf, all planes will be processed.
18633
18634@item scale
18635Set value which will be multiplied with filtered result.
18636
18637@item delta
18638Set value which will be added to filtered result.
18639@end table
18640
18641@subsection Commands
18642
18643This filter supports the all above options as @ref{commands}.
18644
18645@section pseudocolor
18646
18647Alter frame colors in video with pseudocolors.
18648
18649This filter accepts the following options:
18650
18651@table @option
18652@item c0
18653set pixel first component expression
18654
18655@item c1
18656set pixel second component expression
18657
18658@item c2
18659set pixel third component expression
18660
18661@item c3
18662set pixel fourth component expression, corresponds to the alpha component
18663
18664@item index, i
18665set component to use as base for altering colors
18666
18667@item preset, p
18668Pick one of built-in LUTs. By default is set to none.
18669
18670Available LUTs:
18671@table @samp
18672@item magma
18673@item inferno
18674@item plasma
18675@item viridis
18676@item turbo
18677@item cividis
18678@item range1
18679@item range2
18680@item shadows
18681@item highlights
18682@item solar
18683@item nominal
18684@item preferred
18685@item total
18686@end table
18687
18688@item opacity
18689Set opacity of output colors. Allowed range is from 0 to 1.
18690Default value is set to 1.
18691@end table
18692
18693Each of the expression options specifies the expression to use for computing
18694the lookup table for the corresponding pixel component values.
18695
18696The expressions can contain the following constants and functions:
18697
18698@table @option
18699@item w
18700@item h
18701The input width and height.
18702
18703@item val
18704The input value for the pixel component.
18705
18706@item ymin, umin, vmin, amin
18707The minimum allowed component value.
18708
18709@item ymax, umax, vmax, amax
18710The maximum allowed component value.
18711@end table
18712
18713All expressions default to "val".
18714
18715@subsection Commands
18716
18717This filter supports the all above options as @ref{commands}.
18718
18719@subsection Examples
18720
18721@itemize
18722@item
18723Change too high luma values to gradient:
18724@example
18725pseudocolor="'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'"
18726@end example
18727@end itemize
18728
18729@section psnr
18730
18731Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
18732Ratio) between two input videos.
18733
18734This filter takes in input two input videos, the first input is
18735considered the "main" source and is passed unchanged to the
18736output. The second input is used as a "reference" video for computing
18737the PSNR.
18738
18739Both video inputs must have the same resolution and pixel format for
18740this filter to work correctly. Also it assumes that both inputs
18741have the same number of frames, which are compared one by one.
18742
18743The obtained average PSNR is printed through the logging system.
18744
18745The filter stores the accumulated MSE (mean squared error) of each
18746frame, and at the end of the processing it is averaged across all frames
18747equally, and the following formula is applied to obtain the PSNR:
18748
18749@example
18750PSNR = 10*log10(MAX^2/MSE)
18751@end example
18752
18753Where MAX is the average of the maximum values of each component of the
18754image.
18755
18756The description of the accepted parameters follows.
18757
18758@table @option
18759@item stats_file, f
18760If specified the filter will use the named file to save the PSNR of
18761each individual frame. When filename equals "-" the data is sent to
18762standard output.
18763
18764@item stats_version
18765Specifies which version of the stats file format to use. Details of
18766each format are written below.
18767Default value is 1.
18768
18769@item stats_add_max
18770Determines whether the max value is output to the stats log.
18771Default value is 0.
18772Requires stats_version >= 2. If this is set and stats_version < 2,
18773the filter will return an error.
18774@end table
18775
18776This filter also supports the @ref{framesync} options.
18777
18778The file printed if @var{stats_file} is selected, contains a sequence of
18779key/value pairs of the form @var{key}:@var{value} for each compared
18780couple of frames.
18781
18782If a @var{stats_version} greater than 1 is specified, a header line precedes
18783the list of per-frame-pair stats, with key value pairs following the frame
18784format with the following parameters:
18785
18786@table @option
18787@item psnr_log_version
18788The version of the log file format. Will match @var{stats_version}.
18789
18790@item fields
18791A comma separated list of the per-frame-pair parameters included in
18792the log.
18793@end table
18794
18795A description of each shown per-frame-pair parameter follows:
18796
18797@table @option
18798@item n
18799sequential number of the input frame, starting from 1
18800
18801@item mse_avg
18802Mean Square Error pixel-by-pixel average difference of the compared
18803frames, averaged over all the image components.
18804
18805@item mse_y, mse_u, mse_v, mse_r, mse_g, mse_b, mse_a
18806Mean Square Error pixel-by-pixel average difference of the compared
18807frames for the component specified by the suffix.
18808
18809@item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
18810Peak Signal to Noise ratio of the compared frames for the component
18811specified by the suffix.
18812
18813@item max_avg, max_y, max_u, max_v
18814Maximum allowed value for each channel, and average over all
18815channels.
18816@end table
18817
18818@subsection Examples
18819@itemize
18820@item
18821For example:
18822@example
18823movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
18824[main][ref] psnr="stats_file=stats.log" [out]
18825@end example
18826
18827On this example the input file being processed is compared with the
18828reference file @file{ref_movie.mpg}. The PSNR of each individual frame
18829is stored in @file{stats.log}.
18830
18831@item
18832Another example with different containers:
18833@example
18834ffmpeg -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 -
18835@end example
18836@end itemize
18837
18838@anchor{pullup}
18839@section pullup
18840
18841Pulldown reversal (inverse telecine) filter, capable of handling mixed
18842hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
18843content.
18844
18845The pullup filter is designed to take advantage of future context in making
18846its decisions. This filter is stateless in the sense that it does not lock
18847onto a pattern to follow, but it instead looks forward to the following
18848fields in order to identify matches and rebuild progressive frames.
18849
18850To produce content with an even framerate, insert the fps filter after
18851pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
18852@code{fps=24} for 30fps and the (rare) telecined 25fps input.
18853
18854The filter accepts the following options:
18855
18856@table @option
18857@item jl
18858@item jr
18859@item jt
18860@item jb
18861These options set the amount of "junk" to ignore at the left, right, top, and
18862bottom of the image, respectively. Left and right are in units of 8 pixels,
18863while top and bottom are in units of 2 lines.
18864The default is 8 pixels on each side.
18865
18866@item sb
18867Set the strict breaks. Setting this option to 1 will reduce the chances of
18868filter generating an occasional mismatched frame, but it may also cause an
18869excessive number of frames to be dropped during high motion sequences.
18870Conversely, setting it to -1 will make filter match fields more easily.
18871This may help processing of video where there is slight blurring between
18872the fields, but may also cause there to be interlaced frames in the output.
18873Default value is @code{0}.
18874
18875@item mp
18876Set the metric plane to use. It accepts the following values:
18877@table @samp
18878@item l
18879Use luma plane.
18880
18881@item u
18882Use chroma blue plane.
18883
18884@item v
18885Use chroma red plane.
18886@end table
18887
18888This option may be set to use chroma plane instead of the default luma plane
18889for doing filter's computations. This may improve accuracy on very clean
18890source material, but more likely will decrease accuracy, especially if there
18891is chroma noise (rainbow effect) or any grayscale video.
18892The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
18893load and make pullup usable in realtime on slow machines.
18894@end table
18895
18896For best results (without duplicated frames in the output file) it is
18897necessary to change the output frame rate. For example, to inverse
18898telecine NTSC input:
18899@example
18900ffmpeg -i input -vf pullup -r 24000/1001 ...
18901@end example
18902
18903@section qp
18904
18905Change video quantization parameters (QP).
18906
18907The filter accepts the following option:
18908
18909@table @option
18910@item qp
18911Set expression for quantization parameter.
18912@end table
18913
18914The expression is evaluated through the eval API and can contain, among others,
18915the following constants:
18916
18917@table @var
18918@item known
189191 if index is not 129, 0 otherwise.
18920
18921@item qp
18922Sequential index starting from -129 to 128.
18923@end table
18924
18925@subsection Examples
18926
18927@itemize
18928@item
18929Some equation like:
18930@example
18931qp=2+2*sin(PI*qp)
18932@end example
18933@end itemize
18934
18935@section random
18936
18937Flush video frames from internal cache of frames into a random order.
18938No frame is discarded.
18939Inspired by @ref{frei0r} nervous filter.
18940
18941@table @option
18942@item frames
18943Set size in number of frames of internal cache, in range from @code{2} to
18944@code{512}. Default is @code{30}.
18945
18946@item seed
18947Set seed for random number generator, must be an integer included between
18948@code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
18949less than @code{0}, the filter will try to use a good random seed on a
18950best effort basis.
18951@end table
18952
18953@section readeia608
18954
18955Read closed captioning (EIA-608) information from the top lines of a video frame.
18956
18957This filter adds frame metadata for @code{lavfi.readeia608.X.cc} and
18958@code{lavfi.readeia608.X.line}, where @code{X} is the number of the identified line
18959with EIA-608 data (starting from 0). A description of each metadata value follows:
18960
18961@table @option
18962@item lavfi.readeia608.X.cc
18963The two bytes stored as EIA-608 data (printed in hexadecimal).
18964
18965@item lavfi.readeia608.X.line
18966The number of the line on which the EIA-608 data was identified and read.
18967@end table
18968
18969This filter accepts the following options:
18970
18971@table @option
18972@item scan_min
18973Set the line to start scanning for EIA-608 data. Default is @code{0}.
18974
18975@item scan_max
18976Set the line to end scanning for EIA-608 data. Default is @code{29}.
18977
18978@item spw
18979Set the ratio of width reserved for sync code detection.
18980Default is @code{0.27}. Allowed range is @code{[0.1 - 0.7]}.
18981
18982@item chp
18983Enable checking the parity bit. In the event of a parity error, the filter will output
18984@code{0x00} for that character. Default is false.
18985
18986@item lp
18987Lowpass lines prior to further processing. Default is enabled.
18988@end table
18989
18990@subsection Commands
18991
18992This filter supports the all above options as @ref{commands}.
18993
18994@subsection Examples
18995
18996@itemize
18997@item
18998Output a csv with presentation time and the first two lines of identified EIA-608 captioning data.
18999@example
19000ffprobe -f lavfi -i movie=captioned_video.mov,readeia608 -show_entries frame=pts_time:frame_tags=lavfi.readeia608.0.cc,lavfi.readeia608.1.cc -of csv
19001@end example
19002@end itemize
19003
19004@section readvitc
19005
19006Read vertical interval timecode (VITC) information from the top lines of a
19007video frame.
19008
19009The filter adds frame metadata key @code{lavfi.readvitc.tc_str} with the
19010timecode value, if a valid timecode has been detected. Further metadata key
19011@code{lavfi.readvitc.found} is set to 0/1 depending on whether
19012timecode data has been found or not.
19013
19014This filter accepts the following options:
19015
19016@table @option
19017@item scan_max
19018Set the maximum number of lines to scan for VITC data. If the value is set to
19019@code{-1} the full video frame is scanned. Default is @code{45}.
19020
19021@item thr_b
19022Set the luma threshold for black. Accepts float numbers in the range [0.0,1.0],
19023default value is @code{0.2}. The value must be equal or less than @code{thr_w}.
19024
19025@item thr_w
19026Set the luma threshold for white. Accepts float numbers in the range [0.0,1.0],
19027default value is @code{0.6}. The value must be equal or greater than @code{thr_b}.
19028@end table
19029
19030@subsection Examples
19031
19032@itemize
19033@item
19034Detect and draw VITC data onto the video frame; if no valid VITC is detected,
19035draw @code{--:--:--:--} as a placeholder:
19036@example
19037ffmpeg -i input.avi -filter:v 'readvitc,drawtext=fontfile=FreeMono.ttf:text=%@{metadata\\:lavfi.readvitc.tc_str\\:--\\\\\\:--\\\\\\:--\\\\\\:--@}:x=(w-tw)/2:y=400-ascent'
19038@end example
19039@end itemize
19040
19041@section remap
19042
19043Remap pixels using 2nd: Xmap and 3rd: Ymap input video stream.
19044
19045Destination pixel at position (X, Y) will be picked from source (x, y) position
19046where x = Xmap(X, Y) and y = Ymap(X, Y). If mapping values are out of range, zero
19047value for pixel will be used for destination pixel.
19048
19049Xmap and Ymap input video streams must be of same dimensions. Output video stream
19050will have Xmap/Ymap video stream dimensions.
19051Xmap and Ymap input video streams are 16bit depth, single channel.
19052
19053@table @option
19054@item format
19055Specify pixel format of output from this filter. Can be @code{color} or @code{gray}.
19056Default is @code{color}.
19057
19058@item fill
19059Specify the color of the unmapped pixels. For the syntax of this option,
19060check the @ref{color syntax,,"Color" section in the ffmpeg-utils
19061manual,ffmpeg-utils}. Default color is @code{black}.
19062@end table
19063
19064@section removegrain
19065
19066The removegrain filter is a spatial denoiser for progressive video.
19067
19068@table @option
19069@item m0
19070Set mode for the first plane.
19071
19072@item m1
19073Set mode for the second plane.
19074
19075@item m2
19076Set mode for the third plane.
19077
19078@item m3
19079Set mode for the fourth plane.
19080@end table
19081
19082Range of mode is from 0 to 24. Description of each mode follows:
19083
19084@table @var
19085@item 0
19086Leave input plane unchanged. Default.
19087
19088@item 1
19089Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
19090
19091@item 2
19092Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
19093
19094@item 3
19095Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
19096
19097@item 4
19098Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
19099This is equivalent to a median filter.
19100
19101@item 5
19102Line-sensitive clipping giving the minimal change.
19103
19104@item 6
19105Line-sensitive clipping, intermediate.
19106
19107@item 7
19108Line-sensitive clipping, intermediate.
19109
19110@item 8
19111Line-sensitive clipping, intermediate.
19112
19113@item 9
19114Line-sensitive clipping on a line where the neighbours pixels are the closest.
19115
19116@item 10
19117Replaces the target pixel with the closest neighbour.
19118
19119@item 11
19120[1 2 1] horizontal and vertical kernel blur.
19121
19122@item 12
19123Same as mode 11.
19124
19125@item 13
19126Bob mode, interpolates top field from the line where the neighbours
19127pixels are the closest.
19128
19129@item 14
19130Bob mode, interpolates bottom field from the line where the neighbours
19131pixels are the closest.
19132
19133@item 15
19134Bob mode, interpolates top field. Same as 13 but with a more complicated
19135interpolation formula.
19136
19137@item 16
19138Bob mode, interpolates bottom field. Same as 14 but with a more complicated
19139interpolation formula.
19140
19141@item 17
19142Clips the pixel with the minimum and maximum of respectively the maximum and
19143minimum of each pair of opposite neighbour pixels.
19144
19145@item 18
19146Line-sensitive clipping using opposite neighbours whose greatest distance from
19147the current pixel is minimal.
19148
19149@item 19
19150Replaces the pixel with the average of its 8 neighbours.
19151
19152@item 20
19153Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
19154
19155@item 21
19156Clips pixels using the averages of opposite neighbour.
19157
19158@item 22
19159Same as mode 21 but simpler and faster.
19160
19161@item 23
19162Small edge and halo removal, but reputed useless.
19163
19164@item 24
19165Similar as 23.
19166@end table
19167
19168@section removelogo
19169
19170Suppress a TV station logo, using an image file to determine which
19171pixels comprise the logo. It works by filling in the pixels that
19172comprise the logo with neighboring pixels.
19173
19174The filter accepts the following options:
19175
19176@table @option
19177@item filename, f
19178Set the filter bitmap file, which can be any image format supported by
19179libavformat. The width and height of the image file must match those of the
19180video stream being processed.
19181@end table
19182
19183Pixels in the provided bitmap image with a value of zero are not
19184considered part of the logo, non-zero pixels are considered part of
19185the logo. If you use white (255) for the logo and black (0) for the
19186rest, you will be safe. For making the filter bitmap, it is
19187recommended to take a screen capture of a black frame with the logo
19188visible, and then using a threshold filter followed by the erode
19189filter once or twice.
19190
19191If needed, little splotches can be fixed manually. Remember that if
19192logo pixels are not covered, the filter quality will be much
19193reduced. Marking too many pixels as part of the logo does not hurt as
19194much, but it will increase the amount of blurring needed to cover over
19195the image and will destroy more information than necessary, and extra
19196pixels will slow things down on a large logo.
19197
19198@section repeatfields
19199
19200This filter uses the repeat_field flag from the Video ES headers and hard repeats
19201fields based on its value.
19202
19203@section reverse
19204
19205Reverse a video clip.
19206
19207Warning: This filter requires memory to buffer the entire clip, so trimming
19208is suggested.
19209
19210@subsection Examples
19211
19212@itemize
19213@item
19214Take the first 5 seconds of a clip, and reverse it.
19215@example
19216trim=end=5,reverse
19217@end example
19218@end itemize
19219
19220@section rgbashift
19221Shift R/G/B/A pixels horizontally and/or vertically.
19222
19223The filter accepts the following options:
19224@table @option
19225@item rh
19226Set amount to shift red horizontally.
19227@item rv
19228Set amount to shift red vertically.
19229@item gh
19230Set amount to shift green horizontally.
19231@item gv
19232Set amount to shift green vertically.
19233@item bh
19234Set amount to shift blue horizontally.
19235@item bv
19236Set amount to shift blue vertically.
19237@item ah
19238Set amount to shift alpha horizontally.
19239@item av
19240Set amount to shift alpha vertically.
19241@item edge
19242Set edge mode, can be @var{smear}, default, or @var{warp}.
19243@end table
19244
19245@subsection Commands
19246
19247This filter supports the all above options as @ref{commands}.
19248
19249@section roberts
19250Apply roberts cross operator to input video stream.
19251
19252The filter accepts the following option:
19253
19254@table @option
19255@item planes
19256Set which planes will be processed, unprocessed planes will be copied.
19257By default value 0xf, all planes will be processed.
19258
19259@item scale
19260Set value which will be multiplied with filtered result.
19261
19262@item delta
19263Set value which will be added to filtered result.
19264@end table
19265
19266@subsection Commands
19267
19268This filter supports the all above options as @ref{commands}.
19269
19270@section rotate
19271
19272Rotate video by an arbitrary angle expressed in radians.
19273
19274The filter accepts the following options:
19275
19276A description of the optional parameters follows.
19277@table @option
19278@item angle, a
19279Set an expression for the angle by which to rotate the input video
19280clockwise, expressed as a number of radians. A negative value will
19281result in a counter-clockwise rotation. By default it is set to "0".
19282
19283This expression is evaluated for each frame.
19284
19285@item out_w, ow
19286Set the output width expression, default value is "iw".
19287This expression is evaluated just once during configuration.
19288
19289@item out_h, oh
19290Set the output height expression, default value is "ih".
19291This expression is evaluated just once during configuration.
19292
19293@item bilinear
19294Enable bilinear interpolation if set to 1, a value of 0 disables
19295it. Default value is 1.
19296
19297@item fillcolor, c
19298Set the color used to fill the output area not covered by the rotated
19299image. For the general syntax of this option, check the
19300@ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.
19301If the special value "none" is selected then no
19302background is printed (useful for example if the background is never shown).
19303
19304Default value is "black".
19305@end table
19306
19307The expressions for the angle and the output size can contain the
19308following constants and functions:
19309
19310@table @option
19311@item n
19312sequential number of the input frame, starting from 0. It is always NAN
19313before the first frame is filtered.
19314
19315@item t
19316time in seconds of the input frame, it is set to 0 when the filter is
19317configured. It is always NAN before the first frame is filtered.
19318
19319@item hsub
19320@item vsub
19321horizontal and vertical chroma subsample values. For example for the
19322pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
19323
19324@item in_w, iw
19325@item in_h, ih
19326the input video width and height
19327
19328@item out_w, ow
19329@item out_h, oh
19330the output width and height, that is the size of the padded area as
19331specified by the @var{width} and @var{height} expressions
19332
19333@item rotw(a)
19334@item roth(a)
19335the minimal width/height required for completely containing the input
19336video rotated by @var{a} radians.
19337
19338These are only available when computing the @option{out_w} and
19339@option{out_h} expressions.
19340@end table
19341
19342@subsection Examples
19343
19344@itemize
19345@item
19346Rotate the input by PI/6 radians clockwise:
19347@example
19348rotate=PI/6
19349@end example
19350
19351@item
19352Rotate the input by PI/6 radians counter-clockwise:
19353@example
19354rotate=-PI/6
19355@end example
19356
19357@item
19358Rotate the input by 45 degrees clockwise:
19359@example
19360rotate=45*PI/180
19361@end example
19362
19363@item
19364Apply a constant rotation with period T, starting from an angle of PI/3:
19365@example
19366rotate=PI/3+2*PI*t/T
19367@end example
19368
19369@item
19370Make the input video rotation oscillating with a period of T
19371seconds and an amplitude of A radians:
19372@example
19373rotate=A*sin(2*PI/T*t)
19374@end example
19375
19376@item
19377Rotate the video, output size is chosen so that the whole rotating
19378input video is always completely contained in the output:
19379@example
19380rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
19381@end example
19382
19383@item
19384Rotate the video, reduce the output size so that no background is ever
19385shown:
19386@example
19387rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
19388@end example
19389@end itemize
19390
19391@subsection Commands
19392
19393The filter supports the following commands:
19394
19395@table @option
19396@item a, angle
19397Set the angle expression.
19398The command accepts the same syntax of the corresponding option.
19399
19400If the specified expression is not valid, it is kept at its current
19401value.
19402@end table
19403
19404@section sab
19405
19406Apply Shape Adaptive Blur.
19407
19408The filter accepts the following options:
19409
19410@table @option
19411@item luma_radius, lr
19412Set luma blur filter strength, must be a value in range 0.1-4.0, default
19413value is 1.0. A greater value will result in a more blurred image, and
19414in slower processing.
19415
19416@item luma_pre_filter_radius, lpfr
19417Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
19418value is 1.0.
19419
19420@item luma_strength, ls
19421Set luma maximum difference between pixels to still be considered, must
19422be a value in the 0.1-100.0 range, default value is 1.0.
19423
19424@item chroma_radius, cr
19425Set chroma blur filter strength, must be a value in range -0.9-4.0. A
19426greater value will result in a more blurred image, and in slower
19427processing.
19428
19429@item chroma_pre_filter_radius, cpfr
19430Set chroma pre-filter radius, must be a value in the -0.9-2.0 range.
19431
19432@item chroma_strength, cs
19433Set chroma maximum difference between pixels to still be considered,
19434must be a value in the -0.9-100.0 range.
19435@end table
19436
19437Each chroma option value, if not explicitly specified, is set to the
19438corresponding luma option value.
19439
19440@anchor{scale}
19441@section scale
19442
19443Scale (resize) the input video, using the libswscale library.
19444
19445The scale filter forces the output display aspect ratio to be the same
19446of the input, by changing the output sample aspect ratio.
19447
19448If the input image format is different from the format requested by
19449the next filter, the scale filter will convert the input to the
19450requested format.
19451
19452@subsection Options
19453The filter accepts the following options, or any of the options
19454supported by the libswscale scaler.
19455
19456See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
19457the complete list of scaler options.
19458
19459@table @option
19460@item width, w
19461@item height, h
19462Set the output video dimension expression. Default value is the input
19463dimension.
19464
19465If the @var{width} or @var{w} value is 0, the input width is used for
19466the output. If the @var{height} or @var{h} value is 0, the input height
19467is used for the output.
19468
19469If one and only one of the values is -n with n >= 1, the scale filter
19470will use a value that maintains the aspect ratio of the input image,
19471calculated from the other specified dimension. After that it will,
19472however, make sure that the calculated dimension is divisible by n and
19473adjust the value if necessary.
19474
19475If both values are -n with n >= 1, the behavior will be identical to
19476both values being set to 0 as previously detailed.
19477
19478See below for the list of accepted constants for use in the dimension
19479expression.
19480
19481@item eval
19482Specify when to evaluate @var{width} and @var{height} expression. It accepts the following values:
19483
19484@table @samp
19485@item init
19486Only evaluate expressions once during the filter initialization or when a command is processed.
19487
19488@item frame
19489Evaluate expressions for each incoming frame.
19490
19491@end table
19492
19493Default value is @samp{init}.
19494
19495
19496@item interl
19497Set the interlacing mode. It accepts the following values:
19498
19499@table @samp
19500@item 1
19501Force interlaced aware scaling.
19502
19503@item 0
19504Do not apply interlaced scaling.
19505
19506@item -1
19507Select interlaced aware scaling depending on whether the source frames
19508are flagged as interlaced or not.
19509@end table
19510
19511Default value is @samp{0}.
19512
19513@item flags
19514Set libswscale scaling flags. See
19515@ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
19516complete list of values. If not explicitly specified the filter applies
19517the default flags.
19518
19519
19520@item param0, param1
19521Set libswscale input parameters for scaling algorithms that need them. See
19522@ref{sws_params,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
19523complete documentation. If not explicitly specified the filter applies
19524empty parameters.
19525
19526
19527
19528@item size, s
19529Set the video size. For the syntax of this option, check the
19530@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
19531
19532@item in_color_matrix
19533@item out_color_matrix
19534Set in/output YCbCr color space type.
19535
19536This allows the autodetected value to be overridden as well as allows forcing
19537a specific value used for the output and encoder.
19538
19539If not specified, the color space type depends on the pixel format.
19540
19541Possible values:
19542
19543@table @samp
19544@item auto
19545Choose automatically.
19546
19547@item bt709
19548Format conforming to International Telecommunication Union (ITU)
19549Recommendation BT.709.
19550
19551@item fcc
19552Set color space conforming to the United States Federal Communications
19553Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
19554
19555@item bt601
19556@item bt470
19557@item smpte170m
19558Set color space conforming to:
19559
19560@itemize
19561@item
19562ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
19563
19564@item
19565ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
19566
19567@item
19568Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
19569
19570@end itemize
19571
19572@item smpte240m
19573Set color space conforming to SMPTE ST 240:1999.
19574
19575@item bt2020
19576Set color space conforming to ITU-R BT.2020 non-constant luminance system.
19577@end table
19578
19579@item in_range
19580@item out_range
19581Set in/output YCbCr sample range.
19582
19583This allows the autodetected value to be overridden as well as allows forcing
19584a specific value used for the output and encoder. If not specified, the
19585range depends on the pixel format. Possible values:
19586
19587@table @samp
19588@item auto/unknown
19589Choose automatically.
19590
19591@item jpeg/full/pc
19592Set full range (0-255 in case of 8-bit luma).
19593
19594@item mpeg/limited/tv
19595Set "MPEG" range (16-235 in case of 8-bit luma).
19596@end table
19597
19598@item force_original_aspect_ratio
19599Enable decreasing or increasing output video width or height if necessary to
19600keep the original aspect ratio. Possible values:
19601
19602@table @samp
19603@item disable
19604Scale the video as specified and disable this feature.
19605
19606@item decrease
19607The output video dimensions will automatically be decreased if needed.
19608
19609@item increase
19610The output video dimensions will automatically be increased if needed.
19611
19612@end table
19613
19614One useful instance of this option is that when you know a specific device's
19615maximum allowed resolution, you can use this to limit the output video to
19616that, while retaining the aspect ratio. For example, device A allows
196171280x720 playback, and your video is 1920x800. Using this option (set it to
19618decrease) and specifying 1280x720 to the command line makes the output
196191280x533.
19620
19621Please note that this is a different thing than specifying -1 for @option{w}
19622or @option{h}, you still need to specify the output resolution for this option
19623to work.
19624
19625@item force_divisible_by
19626Ensures that both the output dimensions, width and height, are divisible by the
19627given integer when used together with @option{force_original_aspect_ratio}. This
19628works similar to using @code{-n} in the @option{w} and @option{h} options.
19629
19630This option respects the value set for @option{force_original_aspect_ratio},
19631increasing or decreasing the resolution accordingly. The video's aspect ratio
19632may be slightly modified.
19633
19634This option can be handy if you need to have a video fit within or exceed
19635a defined resolution using @option{force_original_aspect_ratio} but also have
19636encoder restrictions on width or height divisibility.
19637
19638@end table
19639
19640The values of the @option{w} and @option{h} options are expressions
19641containing the following constants:
19642
19643@table @var
19644@item in_w
19645@item in_h
19646The input width and height
19647
19648@item iw
19649@item ih
19650These are the same as @var{in_w} and @var{in_h}.
19651
19652@item out_w
19653@item out_h
19654The output (scaled) width and height
19655
19656@item ow
19657@item oh
19658These are the same as @var{out_w} and @var{out_h}
19659
19660@item a
19661The same as @var{iw} / @var{ih}
19662
19663@item sar
19664input sample aspect ratio
19665
19666@item dar
19667The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
19668
19669@item hsub
19670@item vsub
19671horizontal and vertical input chroma subsample values. For example for the
19672pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
19673
19674@item ohsub
19675@item ovsub
19676horizontal and vertical output chroma subsample values. For example for the
19677pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
19678
19679@item n
19680The (sequential) number of the input frame, starting from 0.
19681Only available with @code{eval=frame}.
19682
19683@item t
19684The presentation timestamp of the input frame, expressed as a number of
19685seconds. Only available with @code{eval=frame}.
19686
19687@item pos
19688The position (byte offset) of the frame in the input stream, or NaN if
19689this information is unavailable and/or meaningless (for example in case of synthetic video).
19690Only available with @code{eval=frame}.
19691@end table
19692
19693@subsection Examples
19694
19695@itemize
19696@item
19697Scale the input video to a size of 200x100
19698@example
19699scale=w=200:h=100
19700@end example
19701
19702This is equivalent to:
19703@example
19704scale=200:100
19705@end example
19706
19707or:
19708@example
19709scale=200x100
19710@end example
19711
19712@item
19713Specify a size abbreviation for the output size:
19714@example
19715scale=qcif
19716@end example
19717
19718which can also be written as:
19719@example
19720scale=size=qcif
19721@end example
19722
19723@item
19724Scale the input to 2x:
19725@example
19726scale=w=2*iw:h=2*ih
19727@end example
19728
19729@item
19730The above is the same as:
19731@example
19732scale=2*in_w:2*in_h
19733@end example
19734
19735@item
19736Scale the input to 2x with forced interlaced scaling:
19737@example
19738scale=2*iw:2*ih:interl=1
19739@end example
19740
19741@item
19742Scale the input to half size:
19743@example
19744scale=w=iw/2:h=ih/2
19745@end example
19746
19747@item
19748Increase the width, and set the height to the same size:
19749@example
19750scale=3/2*iw:ow
19751@end example
19752
19753@item
19754Seek Greek harmony:
19755@example
19756scale=iw:1/PHI*iw
19757scale=ih*PHI:ih
19758@end example
19759
19760@item
19761Increase the height, and set the width to 3/2 of the height:
19762@example
19763scale=w=3/2*oh:h=3/5*ih
19764@end example
19765
19766@item
19767Increase the size, making the size a multiple of the chroma
19768subsample values:
19769@example
19770scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
19771@end example
19772
19773@item
19774Increase the width to a maximum of 500 pixels,
19775keeping the same aspect ratio as the input:
19776@example
19777scale=w='min(500\, iw*3/2):h=-1'
19778@end example
19779
19780@item
19781Make pixels square by combining scale and setsar:
19782@example
19783scale='trunc(ih*dar):ih',setsar=1/1
19784@end example
19785
19786@item
19787Make pixels square by combining scale and setsar,
19788making sure the resulting resolution is even (required by some codecs):
19789@example
19790scale='trunc(ih*dar/2)*2:trunc(ih/2)*2',setsar=1/1
19791@end example
19792@end itemize
19793
19794@subsection Commands
19795
19796This filter supports the following commands:
19797@table @option
19798@item width, w
19799@item height, h
19800Set the output video dimension expression.
19801The command accepts the same syntax of the corresponding option.
19802
19803If the specified expression is not valid, it is kept at its current
19804value.
19805@end table
19806
19807@section scale_cuda
19808
19809Scale (resize) and convert (pixel format) the input video, using accelerated CUDA kernels.
19810Setting the output width and height works in the same way as for the @ref{scale} filter.
19811
19812The filter accepts the following options:
19813@table @option
19814@item w
19815@item h
19816Set the output video dimension expression. Default value is the input dimension.
19817
19818Allows for the same expressions as the @ref{scale} filter.
19819
19820@item interp_algo
19821Sets the algorithm used for scaling:
19822
19823@table @var
19824@item nearest
19825Nearest neighbour
19826
19827Used by default if input parameters match the desired output.
19828
19829@item bilinear
19830Bilinear
19831
19832@item bicubic
19833Bicubic
19834
19835This is the default.
19836
19837@item lanczos
19838Lanczos
19839
19840@end table
19841
19842@item format
19843Controls the output pixel format. By default, or if none is specified, the input
19844pixel format is used.
19845
19846The filter does not support converting between YUV and RGB pixel formats.
19847
19848@item passthrough
19849If set to 0, every frame is processed, even if no conversion is neccesary.
19850This mode can be useful to use the filter as a buffer for a downstream
19851frame-consumer that exhausts the limited decoder frame pool.
19852
19853If set to 1, frames are passed through as-is if they match the desired output
19854parameters. This is the default behaviour.
19855
19856@item param
19857Algorithm-Specific parameter.
19858
19859Affects the curves of the bicubic algorithm.
19860
19861@item force_original_aspect_ratio
19862@item force_divisible_by
19863Work the same as the identical @ref{scale} filter options.
19864
19865@end table
19866
19867@subsection Examples
19868
19869@itemize
19870@item
19871Scale input to 720p, keeping aspect ratio and ensuring the output is yuv420p.
19872@example
19873scale_cuda=-2:720:format=yuv420p
19874@end example
19875
19876@item
19877Upscale to 4K using nearest neighbour algorithm.
19878@example
19879scale_cuda=4096:2160:interp_algo=nearest
19880@end example
19881
19882@item
19883Don't do any conversion or scaling, but copy all input frames into newly allocated ones.
19884This can be useful to deal with a filter and encode chain that otherwise exhausts the
19885decoders frame pool.
19886@example
19887scale_cuda=passthrough=0
19888@end example
19889@end itemize
19890
19891@anchor{scale_npp}
19892@section scale_npp
19893
19894Use the NVIDIA Performance Primitives (libnpp) to perform scaling and/or pixel
19895format conversion on CUDA video frames. Setting the output width and height
19896works in the same way as for the @var{scale} filter.
19897
19898The following additional options are accepted:
19899@table @option
19900@item format
19901The pixel format of the output CUDA frames. If set to the string "same" (the
19902default), the input format will be kept. Note that automatic format negotiation
19903and conversion is not yet supported for hardware frames
19904
19905@item interp_algo
19906The interpolation algorithm used for resizing. One of the following:
19907@table @option
19908@item nn
19909Nearest neighbour.
19910
19911@item linear
19912@item cubic
19913@item cubic2p_bspline
199142-parameter cubic (B=1, C=0)
19915
19916@item cubic2p_catmullrom
199172-parameter cubic (B=0, C=1/2)
19918
19919@item cubic2p_b05c03
199202-parameter cubic (B=1/2, C=3/10)
19921
19922@item super
19923Supersampling
19924
19925@item lanczos
19926@end table
19927
19928@item force_original_aspect_ratio
19929Enable decreasing or increasing output video width or height if necessary to
19930keep the original aspect ratio. Possible values:
19931
19932@table @samp
19933@item disable
19934Scale the video as specified and disable this feature.
19935
19936@item decrease
19937The output video dimensions will automatically be decreased if needed.
19938
19939@item increase
19940The output video dimensions will automatically be increased if needed.
19941
19942@end table
19943
19944One useful instance of this option is that when you know a specific device's
19945maximum allowed resolution, you can use this to limit the output video to
19946that, while retaining the aspect ratio. For example, device A allows
199471280x720 playback, and your video is 1920x800. Using this option (set it to
19948decrease) and specifying 1280x720 to the command line makes the output
199491280x533.
19950
19951Please note that this is a different thing than specifying -1 for @option{w}
19952or @option{h}, you still need to specify the output resolution for this option
19953to work.
19954
19955@item force_divisible_by
19956Ensures that both the output dimensions, width and height, are divisible by the
19957given integer when used together with @option{force_original_aspect_ratio}. This
19958works similar to using @code{-n} in the @option{w} and @option{h} options.
19959
19960This option respects the value set for @option{force_original_aspect_ratio},
19961increasing or decreasing the resolution accordingly. The video's aspect ratio
19962may be slightly modified.
19963
19964This option can be handy if you need to have a video fit within or exceed
19965a defined resolution using @option{force_original_aspect_ratio} but also have
19966encoder restrictions on width or height divisibility.
19967
19968@item eval
19969Specify when to evaluate @var{width} and @var{height} expression. It accepts the following values:
19970
19971@table @samp
19972@item init
19973Only evaluate expressions once during the filter initialization or when a command is processed.
19974
19975@item frame
19976Evaluate expressions for each incoming frame.
19977
19978@end table
19979
19980@end table
19981
19982The values of the @option{w} and @option{h} options are expressions
19983containing the following constants:
19984
19985@table @var
19986@item in_w
19987@item in_h
19988The input width and height
19989
19990@item iw
19991@item ih
19992These are the same as @var{in_w} and @var{in_h}.
19993
19994@item out_w
19995@item out_h
19996The output (scaled) width and height
19997
19998@item ow
19999@item oh
20000These are the same as @var{out_w} and @var{out_h}
20001
20002@item a
20003The same as @var{iw} / @var{ih}
20004
20005@item sar
20006input sample aspect ratio
20007
20008@item dar
20009The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
20010
20011@item n
20012The (sequential) number of the input frame, starting from 0.
20013Only available with @code{eval=frame}.
20014
20015@item t
20016The presentation timestamp of the input frame, expressed as a number of
20017seconds. Only available with @code{eval=frame}.
20018
20019@item pos
20020The position (byte offset) of the frame in the input stream, or NaN if
20021this information is unavailable and/or meaningless (for example in case of synthetic video).
20022Only available with @code{eval=frame}.
20023@end table
20024
20025@section scale2ref
20026
20027Scale (resize) the input video, based on a reference video.
20028
20029See the scale filter for available options, scale2ref supports the same but
20030uses the reference video instead of the main input as basis. scale2ref also
20031supports the following additional constants for the @option{w} and
20032@option{h} options:
20033
20034@table @var
20035@item main_w
20036@item main_h
20037The main input video's width and height
20038
20039@item main_a
20040The same as @var{main_w} / @var{main_h}
20041
20042@item main_sar
20043The main input video's sample aspect ratio
20044
20045@item main_dar, mdar
20046The main input video's display aspect ratio. Calculated from
20047@code{(main_w / main_h) * main_sar}.
20048
20049@item main_hsub
20050@item main_vsub
20051The main input video's horizontal and vertical chroma subsample values.
20052For example for the pixel format "yuv422p" @var{hsub} is 2 and @var{vsub}
20053is 1.
20054
20055@item main_n
20056The (sequential) number of the main input frame, starting from 0.
20057Only available with @code{eval=frame}.
20058
20059@item main_t
20060The presentation timestamp of the main input frame, expressed as a number of
20061seconds. Only available with @code{eval=frame}.
20062
20063@item main_pos
20064The position (byte offset) of the frame in the main input stream, or NaN if
20065this information is unavailable and/or meaningless (for example in case of synthetic video).
20066Only available with @code{eval=frame}.
20067@end table
20068
20069@subsection Examples
20070
20071@itemize
20072@item
20073Scale a subtitle stream (b) to match the main video (a) in size before overlaying
20074@example
20075'scale2ref[b][a];[a][b]overlay'
20076@end example
20077
20078@item
20079Scale a logo to 1/10th the height of a video, while preserving its display aspect ratio.
20080@example
20081[logo-in][video-in]scale2ref=w=oh*mdar:h=ih/10[logo-out][video-out]
20082@end example
20083@end itemize
20084
20085@subsection Commands
20086
20087This filter supports the following commands:
20088@table @option
20089@item width, w
20090@item height, h
20091Set the output video dimension expression.
20092The command accepts the same syntax of the corresponding option.
20093
20094If the specified expression is not valid, it is kept at its current
20095value.
20096@end table
20097
20098@section scale2ref_npp
20099
20100Use the NVIDIA Performance Primitives (libnpp) to scale (resize) the input
20101video, based on a reference video.
20102
20103See the @ref{scale_npp} filter for available options, scale2ref_npp supports the same
20104but uses the reference video instead of the main input as basis. scale2ref_npp
20105also supports the following additional constants for the @option{w} and
20106@option{h} options:
20107
20108@table @var
20109@item main_w
20110@item main_h
20111The main input video's width and height
20112
20113@item main_a
20114The same as @var{main_w} / @var{main_h}
20115
20116@item main_sar
20117The main input video's sample aspect ratio
20118
20119@item main_dar, mdar
20120The main input video's display aspect ratio. Calculated from
20121@code{(main_w / main_h) * main_sar}.
20122
20123@item main_n
20124The (sequential) number of the main input frame, starting from 0.
20125Only available with @code{eval=frame}.
20126
20127@item main_t
20128The presentation timestamp of the main input frame, expressed as a number of
20129seconds. Only available with @code{eval=frame}.
20130
20131@item main_pos
20132The position (byte offset) of the frame in the main input stream, or NaN if
20133this information is unavailable and/or meaningless (for example in case of synthetic video).
20134Only available with @code{eval=frame}.
20135@end table
20136
20137@subsection Examples
20138
20139@itemize
20140@item
20141Scale a subtitle stream (b) to match the main video (a) in size before overlaying
20142@example
20143'scale2ref_npp[b][a];[a][b]overlay_cuda'
20144@end example
20145
20146@item
20147Scale a logo to 1/10th the height of a video, while preserving its display aspect ratio.
20148@example
20149[logo-in][video-in]scale2ref_npp=w=oh*mdar:h=ih/10[logo-out][video-out]
20150@end example
20151@end itemize
20152
20153@section scharr
20154Apply scharr operator to input video stream.
20155
20156The filter accepts the following option:
20157
20158@table @option
20159@item planes
20160Set which planes will be processed, unprocessed planes will be copied.
20161By default value 0xf, all planes will be processed.
20162
20163@item scale
20164Set value which will be multiplied with filtered result.
20165
20166@item delta
20167Set value which will be added to filtered result.
20168@end table
20169
20170@subsection Commands
20171
20172This filter supports the all above options as @ref{commands}.
20173
20174@section scroll
20175Scroll input video horizontally and/or vertically by constant speed.
20176
20177The filter accepts the following options:
20178@table @option
20179@item horizontal, h
20180Set the horizontal scrolling speed. Default is 0. Allowed range is from -1 to 1.
20181Negative values changes scrolling direction.
20182
20183@item vertical, v
20184Set the vertical scrolling speed. Default is 0. Allowed range is from -1 to 1.
20185Negative values changes scrolling direction.
20186
20187@item hpos
20188Set the initial horizontal scrolling position. Default is 0. Allowed range is from 0 to 1.
20189
20190@item vpos
20191Set the initial vertical scrolling position. Default is 0. Allowed range is from 0 to 1.
20192@end table
20193
20194@subsection Commands
20195
20196This filter supports the following @ref{commands}:
20197@table @option
20198@item horizontal, h
20199Set the horizontal scrolling speed.
20200@item vertical, v
20201Set the vertical scrolling speed.
20202@end table
20203
20204@anchor{scdet}
20205@section scdet
20206
20207Detect video scene change.
20208
20209This filter sets frame metadata with mafd between frame, the scene score, and
20210forward the frame to the next filter, so they can use these metadata to detect
20211scene change or others.
20212
20213In addition, this filter logs a message and sets frame metadata when it detects
20214a scene change by @option{threshold}.
20215
20216@code{lavfi.scd.mafd} metadata keys are set with mafd for every frame.
20217
20218@code{lavfi.scd.score} metadata keys are set with scene change score for every frame
20219to detect scene change.
20220
20221@code{lavfi.scd.time} metadata keys are set with current filtered frame time which
20222detect scene change with @option{threshold}.
20223
20224The filter accepts the following options:
20225
20226@table @option
20227@item threshold, t
20228Set the scene change detection threshold as a percentage of maximum change. Good
20229values are in the @code{[8.0, 14.0]} range. The range for @option{threshold} is
20230@code{[0., 100.]}.
20231
20232Default value is @code{10.}.
20233
20234@item sc_pass, s
20235Set the flag to pass scene change frames to the next filter. Default value is @code{0}
20236You can enable it if you want to get snapshot of scene change frames only.
20237@end table
20238
20239@anchor{selectivecolor}
20240@section selectivecolor
20241
20242Adjust cyan, magenta, yellow and black (CMYK) to certain ranges of colors (such
20243as "reds", "yellows", "greens", "cyans", ...). The adjustment range is defined
20244by the "purity" of the color (that is, how saturated it already is).
20245
20246This filter is similar to the Adobe Photoshop Selective Color tool.
20247
20248The filter accepts the following options:
20249
20250@table @option
20251@item correction_method
20252Select color correction method.
20253
20254Available values are:
20255@table @samp
20256@item absolute
20257Specified adjustments are applied "as-is" (added/subtracted to original pixel
20258component value).
20259@item relative
20260Specified adjustments are relative to the original component value.
20261@end table
20262Default is @code{absolute}.
20263@item reds
20264Adjustments for red pixels (pixels where the red component is the maximum)
20265@item yellows
20266Adjustments for yellow pixels (pixels where the blue component is the minimum)
20267@item greens
20268Adjustments for green pixels (pixels where the green component is the maximum)
20269@item cyans
20270Adjustments for cyan pixels (pixels where the red component is the minimum)
20271@item blues
20272Adjustments for blue pixels (pixels where the blue component is the maximum)
20273@item magentas
20274Adjustments for magenta pixels (pixels where the green component is the minimum)
20275@item whites
20276Adjustments for white pixels (pixels where all components are greater than 128)
20277@item neutrals
20278Adjustments for all pixels except pure black and pure white
20279@item blacks
20280Adjustments for black pixels (pixels where all components are lesser than 128)
20281@item psfile
20282Specify a Photoshop selective color file (@code{.asv}) to import the settings from.
20283@end table
20284
20285All the adjustment settings (@option{reds}, @option{yellows}, ...) accept up to
202864 space separated floating point adjustment values in the [-1,1] range,
20287respectively to adjust the amount of cyan, magenta, yellow and black for the
20288pixels of its range.
20289
20290@subsection Examples
20291
20292@itemize
20293@item
20294Increase cyan by 50% and reduce yellow by 33% in every green areas, and
20295increase magenta by 27% in blue areas:
20296@example
20297selectivecolor=greens=.5 0 -.33 0:blues=0 .27
20298@end example
20299
20300@item
20301Use a Photoshop selective color preset:
20302@example
20303selectivecolor=psfile=MySelectiveColorPresets/Misty.asv
20304@end example
20305@end itemize
20306
20307@anchor{separatefields}
20308@section separatefields
20309
20310The @code{separatefields} takes a frame-based video input and splits
20311each frame into its components fields, producing a new half height clip
20312with twice the frame rate and twice the frame count.
20313
20314This filter use field-dominance information in frame to decide which
20315of each pair of fields to place first in the output.
20316If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
20317
20318@section setdar, setsar
20319
20320The @code{setdar} filter sets the Display Aspect Ratio for the filter
20321output video.
20322
20323This is done by changing the specified Sample (aka Pixel) Aspect
20324Ratio, according to the following equation:
20325@example
20326@var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
20327@end example
20328
20329Keep in mind that the @code{setdar} filter does not modify the pixel
20330dimensions of the video frame. Also, the display aspect ratio set by
20331this filter may be changed by later filters in the filterchain,
20332e.g. in case of scaling or if another "setdar" or a "setsar" filter is
20333applied.
20334
20335The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
20336the filter output video.
20337
20338Note that as a consequence of the application of this filter, the
20339output display aspect ratio will change according to the equation
20340above.
20341
20342Keep in mind that the sample aspect ratio set by the @code{setsar}
20343filter may be changed by later filters in the filterchain, e.g. if
20344another "setsar" or a "setdar" filter is applied.
20345
20346It accepts the following parameters:
20347
20348@table @option
20349@item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
20350Set the aspect ratio used by the filter.
20351
20352The parameter can be a floating point number string, an expression, or
20353a string of the form @var{num}:@var{den}, where @var{num} and
20354@var{den} are the numerator and denominator of the aspect ratio. If
20355the parameter is not specified, it is assumed the value "0".
20356In case the form "@var{num}:@var{den}" is used, the @code{:} character
20357should be escaped.
20358
20359@item max
20360Set the maximum integer value to use for expressing numerator and
20361denominator when reducing the expressed aspect ratio to a rational.
20362Default value is @code{100}.
20363
20364@end table
20365
20366The parameter @var{sar} is an expression containing
20367the following constants:
20368
20369@table @option
20370@item E, PI, PHI
20371These are approximated values for the mathematical constants e
20372(Euler's number), pi (Greek pi), and phi (the golden ratio).
20373
20374@item w, h
20375The input width and height.
20376
20377@item a
20378These are the same as @var{w} / @var{h}.
20379
20380@item sar
20381The input sample aspect ratio.
20382
20383@item dar
20384The input display aspect ratio. It is the same as
20385(@var{w} / @var{h}) * @var{sar}.
20386
20387@item hsub, vsub
20388Horizontal and vertical chroma subsample values. For example, for the
20389pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
20390@end table
20391
20392@subsection Examples
20393
20394@itemize
20395
20396@item
20397To change the display aspect ratio to 16:9, specify one of the following:
20398@example
20399setdar=dar=1.77777
20400setdar=dar=16/9
20401@end example
20402
20403@item
20404To change the sample aspect ratio to 10:11, specify:
20405@example
20406setsar=sar=10/11
20407@end example
20408
20409@item
20410To set a display aspect ratio of 16:9, and specify a maximum integer value of
204111000 in the aspect ratio reduction, use the command:
20412@example
20413setdar=ratio=16/9:max=1000
20414@end example
20415
20416@end itemize
20417
20418@anchor{setfield}
20419@section setfield
20420
20421Force field for the output video frame.
20422
20423The @code{setfield} filter marks the interlace type field for the
20424output frames. It does not change the input frame, but only sets the
20425corresponding property, which affects how the frame is treated by
20426following filters (e.g. @code{fieldorder} or @code{yadif}).
20427
20428The filter accepts the following options:
20429
20430@table @option
20431
20432@item mode
20433Available values are:
20434
20435@table @samp
20436@item auto
20437Keep the same field property.
20438
20439@item bff
20440Mark the frame as bottom-field-first.
20441
20442@item tff
20443Mark the frame as top-field-first.
20444
20445@item prog
20446Mark the frame as progressive.
20447@end table
20448@end table
20449
20450@anchor{setparams}
20451@section setparams
20452
20453Force frame parameter for the output video frame.
20454
20455The @code{setparams} filter marks interlace and color range for the
20456output frames. It does not change the input frame, but only sets the
20457corresponding property, which affects how the frame is treated by
20458filters/encoders.
20459
20460@table @option
20461@item field_mode
20462Available values are:
20463
20464@table @samp
20465@item auto
20466Keep the same field property (default).
20467
20468@item bff
20469Mark the frame as bottom-field-first.
20470
20471@item tff
20472Mark the frame as top-field-first.
20473
20474@item prog
20475Mark the frame as progressive.
20476@end table
20477
20478@item range
20479Available values are:
20480
20481@table @samp
20482@item auto
20483Keep the same color range property (default).
20484
20485@item unspecified, unknown
20486Mark the frame as unspecified color range.
20487
20488@item limited, tv, mpeg
20489Mark the frame as limited range.
20490
20491@item full, pc, jpeg
20492Mark the frame as full range.
20493@end table
20494
20495@item color_primaries
20496Set the color primaries.
20497Available values are:
20498
20499@table @samp
20500@item auto
20501Keep the same color primaries property (default).
20502
20503@item bt709
20504@item unknown
20505@item bt470m
20506@item bt470bg
20507@item smpte170m
20508@item smpte240m
20509@item film
20510@item bt2020
20511@item smpte428
20512@item smpte431
20513@item smpte432
20514@item jedec-p22
20515@end table
20516
20517@item color_trc
20518Set the color transfer.
20519Available values are:
20520
20521@table @samp
20522@item auto
20523Keep the same color trc property (default).
20524
20525@item bt709
20526@item unknown
20527@item bt470m
20528@item bt470bg
20529@item smpte170m
20530@item smpte240m
20531@item linear
20532@item log100
20533@item log316
20534@item iec61966-2-4
20535@item bt1361e
20536@item iec61966-2-1
20537@item bt2020-10
20538@item bt2020-12
20539@item smpte2084
20540@item smpte428
20541@item arib-std-b67
20542@end table
20543
20544@item colorspace
20545Set the colorspace.
20546Available values are:
20547
20548@table @samp
20549@item auto
20550Keep the same colorspace property (default).
20551
20552@item gbr
20553@item bt709
20554@item unknown
20555@item fcc
20556@item bt470bg
20557@item smpte170m
20558@item smpte240m
20559@item ycgco
20560@item bt2020nc
20561@item bt2020c
20562@item smpte2085
20563@item chroma-derived-nc
20564@item chroma-derived-c
20565@item ictcp
20566@end table
20567@end table
20568
20569@section sharpen_npp
20570Use the NVIDIA Performance Primitives (libnpp) to perform image sharpening with
20571border control.
20572
20573The following additional options are accepted:
20574@table @option
20575
20576@item border_type
20577Type of sampling to be used ad frame borders. One of the following:
20578@table @option
20579
20580@item replicate
20581Replicate pixel values.
20582
20583@end table
20584@end table
20585
20586@section shear
20587Apply shear transform to input video.
20588
20589This filter supports the following options:
20590
20591@table @option
20592@item shx
20593Shear factor in X-direction. Default value is 0.
20594Allowed range is from -2 to 2.
20595
20596@item shy
20597Shear factor in Y-direction. Default value is 0.
20598Allowed range is from -2 to 2.
20599
20600@item fillcolor, c
20601Set the color used to fill the output area not covered by the transformed
20602video. For the general syntax of this option, check the
20603@ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.
20604If the special value "none" is selected then no
20605background is printed (useful for example if the background is never shown).
20606
20607Default value is "black".
20608
20609@item interp
20610Set interpolation type. Can be @code{bilinear} or @code{nearest}. Default is @code{bilinear}.
20611@end table
20612
20613@subsection Commands
20614
20615This filter supports the all above options as @ref{commands}.
20616
20617@section showinfo
20618
20619Show a line containing various information for each input video frame.
20620The input video is not modified.
20621
20622This filter supports the following options:
20623
20624@table @option
20625@item checksum
20626Calculate checksums of each plane. By default enabled.
20627@end table
20628
20629The shown line contains a sequence of key/value pairs of the form
20630@var{key}:@var{value}.
20631
20632The following values are shown in the output:
20633
20634@table @option
20635@item n
20636The (sequential) number of the input frame, starting from 0.
20637
20638@item pts
20639The Presentation TimeStamp of the input frame, expressed as a number of
20640time base units. The time base unit depends on the filter input pad.
20641
20642@item pts_time
20643The Presentation TimeStamp of the input frame, expressed as a number of
20644seconds.
20645
20646@item pos
20647The position of the frame in the input stream, or -1 if this information is
20648unavailable and/or meaningless (for example in case of synthetic video).
20649
20650@item fmt
20651The pixel format name.
20652
20653@item sar
20654The sample aspect ratio of the input frame, expressed in the form
20655@var{num}/@var{den}.
20656
20657@item s
20658The size of the input frame. For the syntax of this option, check the
20659@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
20660
20661@item i
20662The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
20663for bottom field first).
20664
20665@item iskey
20666This is 1 if the frame is a key frame, 0 otherwise.
20667
20668@item type
20669The picture type of the input frame ("I" for an I-frame, "P" for a
20670P-frame, "B" for a B-frame, or "?" for an unknown type).
20671Also refer to the documentation of the @code{AVPictureType} enum and of
20672the @code{av_get_picture_type_char} function defined in
20673@file{libavutil/avutil.h}.
20674
20675@item checksum
20676The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
20677
20678@item plane_checksum
20679The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
20680expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
20681
20682@item mean
20683The mean value of pixels in each plane of the input frame, expressed in the form
20684"[@var{mean0} @var{mean1} @var{mean2} @var{mean3}]".
20685
20686@item stdev
20687The standard deviation of pixel values in each plane of the input frame, expressed
20688in the form "[@var{stdev0} @var{stdev1} @var{stdev2} @var{stdev3}]".
20689
20690@end table
20691
20692@section showpalette
20693
20694Displays the 256 colors palette of each frame. This filter is only relevant for
20695@var{pal8} pixel format frames.
20696
20697It accepts the following option:
20698
20699@table @option
20700@item s
20701Set the size of the box used to represent one palette color entry. Default is
20702@code{30} (for a @code{30x30} pixel box).
20703@end table
20704
20705@section shuffleframes
20706
20707Reorder and/or duplicate and/or drop video frames.
20708
20709It accepts the following parameters:
20710
20711@table @option
20712@item mapping
20713Set the destination indexes of input frames.
20714This is space or '|' separated list of indexes that maps input frames to output
20715frames. Number of indexes also sets maximal value that each index may have.
20716'-1' index have special meaning and that is to drop frame.
20717@end table
20718
20719The first frame has the index 0. The default is to keep the input unchanged.
20720
20721@subsection Examples
20722
20723@itemize
20724@item
20725Swap second and third frame of every three frames of the input:
20726@example
20727ffmpeg -i INPUT -vf "shuffleframes=0 2 1" OUTPUT
20728@end example
20729
20730@item
20731Swap 10th and 1st frame of every ten frames of the input:
20732@example
20733ffmpeg -i INPUT -vf "shuffleframes=9 1 2 3 4 5 6 7 8 0" OUTPUT
20734@end example
20735@end itemize
20736
20737@section shufflepixels
20738
20739Reorder pixels in video frames.
20740
20741This filter accepts the following options:
20742
20743@table @option
20744@item direction, d
20745Set shuffle direction. Can be forward or inverse direction.
20746Default direction is forward.
20747
20748@item mode, m
20749Set shuffle mode. Can be horizontal, vertical or block mode.
20750
20751@item width, w
20752@item height, h
20753Set shuffle block_size. In case of horizontal shuffle mode only width
20754part of size is used, and in case of vertical shuffle mode only height
20755part of size is used.
20756
20757@item seed, s
20758Set random seed used with shuffling pixels. Mainly useful to set to be able
20759to reverse filtering process to get original input.
20760For example, to reverse forward shuffle you need to use same parameters
20761and exact same seed and to set direction to inverse.
20762@end table
20763
20764@section shuffleplanes
20765
20766Reorder and/or duplicate video planes.
20767
20768It accepts the following parameters:
20769
20770@table @option
20771
20772@item map0
20773The index of the input plane to be used as the first output plane.
20774
20775@item map1
20776The index of the input plane to be used as the second output plane.
20777
20778@item map2
20779The index of the input plane to be used as the third output plane.
20780
20781@item map3
20782The index of the input plane to be used as the fourth output plane.
20783
20784@end table
20785
20786The first plane has the index 0. The default is to keep the input unchanged.
20787
20788@subsection Examples
20789
20790@itemize
20791@item
20792Swap the second and third planes of the input:
20793@example
20794ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
20795@end example
20796@end itemize
20797
20798@anchor{signalstats}
20799@section signalstats
20800Evaluate various visual metrics that assist in determining issues associated
20801with the digitization of analog video media.
20802
20803By default the filter will log these metadata values:
20804
20805@table @option
20806@item YMIN
20807Display the minimal Y value contained within the input frame. Expressed in
20808range of [0-255].
20809
20810@item YLOW
20811Display the Y value at the 10% percentile within the input frame. Expressed in
20812range of [0-255].
20813
20814@item YAVG
20815Display the average Y value within the input frame. Expressed in range of
20816[0-255].
20817
20818@item YHIGH
20819Display the Y value at the 90% percentile within the input frame. Expressed in
20820range of [0-255].
20821
20822@item YMAX
20823Display the maximum Y value contained within the input frame. Expressed in
20824range of [0-255].
20825
20826@item UMIN
20827Display the minimal U value contained within the input frame. Expressed in
20828range of [0-255].
20829
20830@item ULOW
20831Display the U value at the 10% percentile within the input frame. Expressed in
20832range of [0-255].
20833
20834@item UAVG
20835Display the average U value within the input frame. Expressed in range of
20836[0-255].
20837
20838@item UHIGH
20839Display the U value at the 90% percentile within the input frame. Expressed in
20840range of [0-255].
20841
20842@item UMAX
20843Display the maximum U value contained within the input frame. Expressed in
20844range of [0-255].
20845
20846@item VMIN
20847Display the minimal V value contained within the input frame. Expressed in
20848range of [0-255].
20849
20850@item VLOW
20851Display the V value at the 10% percentile within the input frame. Expressed in
20852range of [0-255].
20853
20854@item VAVG
20855Display the average V value within the input frame. Expressed in range of
20856[0-255].
20857
20858@item VHIGH
20859Display the V value at the 90% percentile within the input frame. Expressed in
20860range of [0-255].
20861
20862@item VMAX
20863Display the maximum V value contained within the input frame. Expressed in
20864range of [0-255].
20865
20866@item SATMIN
20867Display the minimal saturation value contained within the input frame.
20868Expressed in range of [0-~181.02].
20869
20870@item SATLOW
20871Display the saturation value at the 10% percentile within the input frame.
20872Expressed in range of [0-~181.02].
20873
20874@item SATAVG
20875Display the average saturation value within the input frame. Expressed in range
20876of [0-~181.02].
20877
20878@item SATHIGH
20879Display the saturation value at the 90% percentile within the input frame.
20880Expressed in range of [0-~181.02].
20881
20882@item SATMAX
20883Display the maximum saturation value contained within the input frame.
20884Expressed in range of [0-~181.02].
20885
20886@item HUEMED
20887Display the median value for hue within the input frame. Expressed in range of
20888[0-360].
20889
20890@item HUEAVG
20891Display the average value for hue within the input frame. Expressed in range of
20892[0-360].
20893
20894@item YDIF
20895Display the average of sample value difference between all values of the Y
20896plane in the current frame and corresponding values of the previous input frame.
20897Expressed in range of [0-255].
20898
20899@item UDIF
20900Display the average of sample value difference between all values of the U
20901plane in the current frame and corresponding values of the previous input frame.
20902Expressed in range of [0-255].
20903
20904@item VDIF
20905Display the average of sample value difference between all values of the V
20906plane in the current frame and corresponding values of the previous input frame.
20907Expressed in range of [0-255].
20908
20909@item YBITDEPTH
20910Display bit depth of Y plane in current frame.
20911Expressed in range of [0-16].
20912
20913@item UBITDEPTH
20914Display bit depth of U plane in current frame.
20915Expressed in range of [0-16].
20916
20917@item VBITDEPTH
20918Display bit depth of V plane in current frame.
20919Expressed in range of [0-16].
20920@end table
20921
20922The filter accepts the following options:
20923
20924@table @option
20925@item stat
20926@item out
20927
20928@option{stat} specify an additional form of image analysis.
20929@option{out} output video with the specified type of pixel highlighted.
20930
20931Both options accept the following values:
20932
20933@table @samp
20934@item tout
20935Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
20936unlike the neighboring pixels of the same field. Examples of temporal outliers
20937include the results of video dropouts, head clogs, or tape tracking issues.
20938
20939@item vrep
20940Identify @var{vertical line repetition}. Vertical line repetition includes
20941similar rows of pixels within a frame. In born-digital video vertical line
20942repetition is common, but this pattern is uncommon in video digitized from an
20943analog source. When it occurs in video that results from the digitization of an
20944analog source it can indicate concealment from a dropout compensator.
20945
20946@item brng
20947Identify pixels that fall outside of legal broadcast range.
20948@end table
20949
20950@item color, c
20951Set the highlight color for the @option{out} option. The default color is
20952yellow.
20953@end table
20954
20955@subsection Examples
20956
20957@itemize
20958@item
20959Output data of various video metrics:
20960@example
20961ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
20962@end example
20963
20964@item
20965Output specific data about the minimum and maximum values of the Y plane per frame:
20966@example
20967ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
20968@end example
20969
20970@item
20971Playback video while highlighting pixels that are outside of broadcast range in red.
20972@example
20973ffplay example.mov -vf signalstats="out=brng:color=red"
20974@end example
20975
20976@item
20977Playback video with signalstats metadata drawn over the frame.
20978@example
20979ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
20980@end example
20981
20982The contents of signalstat_drawtext.txt used in the command are:
20983@example
20984time %@{pts:hms@}
20985Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
20986U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
20987V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
20988saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
20989
20990@end example
20991@end itemize
20992
20993@anchor{signature}
20994@section signature
20995
20996Calculates the MPEG-7 Video Signature. The filter can handle more than one
20997input. In this case the matching between the inputs can be calculated additionally.
20998The filter always passes through the first input. The signature of each stream can
20999be written into a file.
21000
21001It accepts the following options:
21002
21003@table @option
21004@item detectmode
21005Enable or disable the matching process.
21006
21007Available values are:
21008
21009@table @samp
21010@item off
21011Disable the calculation of a matching (default).
21012@item full
21013Calculate the matching for the whole video and output whether the whole video
21014matches or only parts.
21015@item fast
21016Calculate only until a matching is found or the video ends. Should be faster in
21017some cases.
21018@end table
21019
21020@item nb_inputs
21021Set the number of inputs. The option value must be a non negative integer.
21022Default value is 1.
21023
21024@item filename
21025Set the path to which the output is written. If there is more than one input,
21026the path must be a prototype, i.e. must contain %d or %0nd (where n is a positive
21027integer), that will be replaced with the input number. If no filename is
21028specified, no output will be written. This is the default.
21029
21030@item format
21031Choose the output format.
21032
21033Available values are:
21034
21035@table @samp
21036@item binary
21037Use the specified binary representation (default).
21038@item xml
21039Use the specified xml representation.
21040@end table
21041
21042@item th_d
21043Set threshold to detect one word as similar. The option value must be an integer
21044greater than zero. The default value is 9000.
21045
21046@item th_dc
21047Set threshold to detect all words as similar. The option value must be an integer
21048greater than zero. The default value is 60000.
21049
21050@item th_xh
21051Set threshold to detect frames as similar. The option value must be an integer
21052greater than zero. The default value is 116.
21053
21054@item th_di
21055Set the minimum length of a sequence in frames to recognize it as matching
21056sequence. The option value must be a non negative integer value.
21057The default value is 0.
21058
21059@item th_it
21060Set the minimum relation, that matching frames to all frames must have.
21061The option value must be a double value between 0 and 1. The default value is 0.5.
21062@end table
21063
21064@subsection Examples
21065
21066@itemize
21067@item
21068To calculate the signature of an input video and store it in signature.bin:
21069@example
21070ffmpeg -i input.mkv -vf signature=filename=signature.bin -map 0:v -f null -
21071@end example
21072
21073@item
21074To detect whether two videos match and store the signatures in XML format in
21075signature0.xml and signature1.xml:
21076@example
21077ffmpeg -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 -
21078@end example
21079
21080@end itemize
21081
21082@anchor{siti}
21083@section siti
21084
21085Calculate Spatial Info (SI) and Temporal Info (TI) scores for a video, as defined
21086in ITU-T P.910: Subjective video quality assessment methods for multimedia
21087applications. Available PDF at @url{https://www.itu.int/rec/T-REC-P.910-199909-S/en }.
21088
21089It accepts the following option:
21090
21091@table @option
21092@item print_summary
21093If set to 1, Summary statistics will be printed to the console. Default 0.
21094@end table
21095
21096@subsection Examples
21097@itemize
21098@item
21099To calculate SI/TI metrics and print summary:
21100@example
21101ffmpeg -i input.mp4 -vf siti=print_summary=1 -f null -
21102@end example
21103@end itemize
21104
21105@anchor{smartblur}
21106@section smartblur
21107
21108Blur the input video without impacting the outlines.
21109
21110It accepts the following options:
21111
21112@table @option
21113@item luma_radius, lr
21114Set the luma radius. The option value must be a float number in
21115the range [0.1,5.0] that specifies the variance of the gaussian filter
21116used to blur the image (slower if larger). Default value is 1.0.
21117
21118@item luma_strength, ls
21119Set the luma strength. The option value must be a float number
21120in the range [-1.0,1.0] that configures the blurring. A value included
21121in [0.0,1.0] will blur the image whereas a value included in
21122[-1.0,0.0] will sharpen the image. Default value is 1.0.
21123
21124@item luma_threshold, lt
21125Set the luma threshold used as a coefficient to determine
21126whether a pixel should be blurred or not. The option value must be an
21127integer in the range [-30,30]. A value of 0 will filter all the image,
21128a value included in [0,30] will filter flat areas and a value included
21129in [-30,0] will filter edges. Default value is 0.
21130
21131@item chroma_radius, cr
21132Set the chroma radius. The option value must be a float number in
21133the range [0.1,5.0] that specifies the variance of the gaussian filter
21134used to blur the image (slower if larger). Default value is @option{luma_radius}.
21135
21136@item chroma_strength, cs
21137Set the chroma strength. The option value must be a float number
21138in the range [-1.0,1.0] that configures the blurring. A value included
21139in [0.0,1.0] will blur the image whereas a value included in
21140[-1.0,0.0] will sharpen the image. Default value is @option{luma_strength}.
21141
21142@item chroma_threshold, ct
21143Set the chroma threshold used as a coefficient to determine
21144whether a pixel should be blurred or not. The option value must be an
21145integer in the range [-30,30]. A value of 0 will filter all the image,
21146a value included in [0,30] will filter flat areas and a value included
21147in [-30,0] will filter edges. Default value is @option{luma_threshold}.
21148@end table
21149
21150If a chroma option is not explicitly set, the corresponding luma value
21151is set.
21152
21153@section sobel
21154Apply sobel operator to input video stream.
21155
21156The filter accepts the following option:
21157
21158@table @option
21159@item planes
21160Set which planes will be processed, unprocessed planes will be copied.
21161By default value 0xf, all planes will be processed.
21162
21163@item scale
21164Set value which will be multiplied with filtered result.
21165
21166@item delta
21167Set value which will be added to filtered result.
21168@end table
21169
21170@subsection Commands
21171
21172This filter supports the all above options as @ref{commands}.
21173
21174@anchor{spp}
21175@section spp
21176
21177Apply a simple postprocessing filter that compresses and decompresses the image
21178at several (or - in the case of @option{quality} level @code{6} - all) shifts
21179and average the results.
21180
21181The filter accepts the following options:
21182
21183@table @option
21184@item quality
21185Set quality. This option defines the number of levels for averaging. It accepts
21186an integer in the range 0-6. If set to @code{0}, the filter will have no
21187effect. A value of @code{6} means the higher quality. For each increment of
21188that value the speed drops by a factor of approximately 2.  Default value is
21189@code{3}.
21190
21191@item qp
21192Force a constant quantization parameter. If not set, the filter will use the QP
21193from the video stream (if available).
21194
21195@item mode
21196Set thresholding mode. Available modes are:
21197
21198@table @samp
21199@item hard
21200Set hard thresholding (default).
21201@item soft
21202Set soft thresholding (better de-ringing effect, but likely blurrier).
21203@end table
21204
21205@item use_bframe_qp
21206Enable the use of the QP from the B-Frames if set to @code{1}. Using this
21207option may cause flicker since the B-Frames have often larger QP. Default is
21208@code{0} (not enabled).
21209@end table
21210
21211@subsection Commands
21212
21213This filter supports the following commands:
21214@table @option
21215@item quality, level
21216Set quality level. The value @code{max} can be used to set the maximum level,
21217currently @code{6}.
21218@end table
21219
21220@anchor{sr}
21221@section sr
21222
21223Scale the input by applying one of the super-resolution methods based on
21224convolutional neural networks. Supported models:
21225
21226@itemize
21227@item
21228Super-Resolution Convolutional Neural Network model (SRCNN).
21229See @url{https://arxiv.org/abs/1501.00092}.
21230
21231@item
21232Efficient Sub-Pixel Convolutional Neural Network model (ESPCN).
21233See @url{https://arxiv.org/abs/1609.05158}.
21234@end itemize
21235
21236Training scripts as well as scripts for model file (.pb) saving can be found at
21237@url{https://github.com/XueweiMeng/sr/tree/sr_dnn_native}. Original repository
21238is at @url{https://github.com/HighVoltageRocknRoll/sr.git}.
21239
21240Native model files (.model) can be generated from TensorFlow model
21241files (.pb) by using tools/python/convert.py
21242
21243The filter accepts the following options:
21244
21245@table @option
21246@item dnn_backend
21247Specify which DNN backend to use for model loading and execution. This option accepts
21248the following values:
21249
21250@table @samp
21251@item native
21252Native implementation of DNN loading and execution.
21253
21254@item tensorflow
21255TensorFlow backend. To enable this backend you
21256need to install the TensorFlow for C library (see
21257@url{https://www.tensorflow.org/install/lang_c}) and configure FFmpeg with
21258@code{--enable-libtensorflow}
21259@end table
21260
21261Default value is @samp{native}.
21262
21263@item model
21264Set path to model file specifying network architecture and its parameters.
21265Note that different backends use different file formats. TensorFlow backend
21266can load files for both formats, while native backend can load files for only
21267its format.
21268
21269@item scale_factor
21270Set scale factor for SRCNN model. Allowed values are @code{2}, @code{3} and @code{4}.
21271Default value is @code{2}. Scale factor is necessary for SRCNN model, because it accepts
21272input upscaled using bicubic upscaling with proper scale factor.
21273@end table
21274
21275To get full functionality (such as async execution), please use the @ref{dnn_processing} filter.
21276
21277@section ssim
21278
21279Obtain the SSIM (Structural SImilarity Metric) between two input videos.
21280
21281This filter takes in input two input videos, the first input is
21282considered the "main" source and is passed unchanged to the
21283output. The second input is used as a "reference" video for computing
21284the SSIM.
21285
21286Both video inputs must have the same resolution and pixel format for
21287this filter to work correctly. Also it assumes that both inputs
21288have the same number of frames, which are compared one by one.
21289
21290The filter stores the calculated SSIM of each frame.
21291
21292The description of the accepted parameters follows.
21293
21294@table @option
21295@item stats_file, f
21296If specified the filter will use the named file to save the SSIM of
21297each individual frame. When filename equals "-" the data is sent to
21298standard output.
21299@end table
21300
21301The file printed if @var{stats_file} is selected, contains a sequence of
21302key/value pairs of the form @var{key}:@var{value} for each compared
21303couple of frames.
21304
21305A description of each shown parameter follows:
21306
21307@table @option
21308@item n
21309sequential number of the input frame, starting from 1
21310
21311@item Y, U, V, R, G, B
21312SSIM of the compared frames for the component specified by the suffix.
21313
21314@item All
21315SSIM of the compared frames for the whole frame.
21316
21317@item dB
21318Same as above but in dB representation.
21319@end table
21320
21321This filter also supports the @ref{framesync} options.
21322
21323@subsection Examples
21324@itemize
21325@item
21326For example:
21327@example
21328movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
21329[main][ref] ssim="stats_file=stats.log" [out]
21330@end example
21331
21332On this example the input file being processed is compared with the
21333reference file @file{ref_movie.mpg}. The SSIM of each individual frame
21334is stored in @file{stats.log}.
21335
21336@item
21337Another example with both psnr and ssim at same time:
21338@example
21339ffmpeg -i main.mpg -i ref.mpg -lavfi  "ssim;[0:v][1:v]psnr" -f null -
21340@end example
21341
21342@item
21343Another example with different containers:
21344@example
21345ffmpeg -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 -
21346@end example
21347@end itemize
21348
21349@section stereo3d
21350
21351Convert between different stereoscopic image formats.
21352
21353The filters accept the following options:
21354
21355@table @option
21356@item in
21357Set stereoscopic image format of input.
21358
21359Available values for input image formats are:
21360@table @samp
21361@item sbsl
21362side by side parallel (left eye left, right eye right)
21363
21364@item sbsr
21365side by side crosseye (right eye left, left eye right)
21366
21367@item sbs2l
21368side by side parallel with half width resolution
21369(left eye left, right eye right)
21370
21371@item sbs2r
21372side by side crosseye with half width resolution
21373(right eye left, left eye right)
21374
21375@item abl
21376@item tbl
21377above-below (left eye above, right eye below)
21378
21379@item abr
21380@item tbr
21381above-below (right eye above, left eye below)
21382
21383@item ab2l
21384@item tb2l
21385above-below with half height resolution
21386(left eye above, right eye below)
21387
21388@item ab2r
21389@item tb2r
21390above-below with half height resolution
21391(right eye above, left eye below)
21392
21393@item al
21394alternating frames (left eye first, right eye second)
21395
21396@item ar
21397alternating frames (right eye first, left eye second)
21398
21399@item irl
21400interleaved rows (left eye has top row, right eye starts on next row)
21401
21402@item irr
21403interleaved rows (right eye has top row, left eye starts on next row)
21404
21405@item icl
21406interleaved columns, left eye first
21407
21408@item icr
21409interleaved columns, right eye first
21410
21411Default value is @samp{sbsl}.
21412@end table
21413
21414@item out
21415Set stereoscopic image format of output.
21416
21417@table @samp
21418@item sbsl
21419side by side parallel (left eye left, right eye right)
21420
21421@item sbsr
21422side by side crosseye (right eye left, left eye right)
21423
21424@item sbs2l
21425side by side parallel with half width resolution
21426(left eye left, right eye right)
21427
21428@item sbs2r
21429side by side crosseye with half width resolution
21430(right eye left, left eye right)
21431
21432@item abl
21433@item tbl
21434above-below (left eye above, right eye below)
21435
21436@item abr
21437@item tbr
21438above-below (right eye above, left eye below)
21439
21440@item ab2l
21441@item tb2l
21442above-below with half height resolution
21443(left eye above, right eye below)
21444
21445@item ab2r
21446@item tb2r
21447above-below with half height resolution
21448(right eye above, left eye below)
21449
21450@item al
21451alternating frames (left eye first, right eye second)
21452
21453@item ar
21454alternating frames (right eye first, left eye second)
21455
21456@item irl
21457interleaved rows (left eye has top row, right eye starts on next row)
21458
21459@item irr
21460interleaved rows (right eye has top row, left eye starts on next row)
21461
21462@item arbg
21463anaglyph red/blue gray
21464(red filter on left eye, blue filter on right eye)
21465
21466@item argg
21467anaglyph red/green gray
21468(red filter on left eye, green filter on right eye)
21469
21470@item arcg
21471anaglyph red/cyan gray
21472(red filter on left eye, cyan filter on right eye)
21473
21474@item arch
21475anaglyph red/cyan half colored
21476(red filter on left eye, cyan filter on right eye)
21477
21478@item arcc
21479anaglyph red/cyan color
21480(red filter on left eye, cyan filter on right eye)
21481
21482@item arcd
21483anaglyph red/cyan color optimized with the least squares projection of dubois
21484(red filter on left eye, cyan filter on right eye)
21485
21486@item agmg
21487anaglyph green/magenta gray
21488(green filter on left eye, magenta filter on right eye)
21489
21490@item agmh
21491anaglyph green/magenta half colored
21492(green filter on left eye, magenta filter on right eye)
21493
21494@item agmc
21495anaglyph green/magenta colored
21496(green filter on left eye, magenta filter on right eye)
21497
21498@item agmd
21499anaglyph green/magenta color optimized with the least squares projection of dubois
21500(green filter on left eye, magenta filter on right eye)
21501
21502@item aybg
21503anaglyph yellow/blue gray
21504(yellow filter on left eye, blue filter on right eye)
21505
21506@item aybh
21507anaglyph yellow/blue half colored
21508(yellow filter on left eye, blue filter on right eye)
21509
21510@item aybc
21511anaglyph yellow/blue colored
21512(yellow filter on left eye, blue filter on right eye)
21513
21514@item aybd
21515anaglyph yellow/blue color optimized with the least squares projection of dubois
21516(yellow filter on left eye, blue filter on right eye)
21517
21518@item ml
21519mono output (left eye only)
21520
21521@item mr
21522mono output (right eye only)
21523
21524@item chl
21525checkerboard, left eye first
21526
21527@item chr
21528checkerboard, right eye first
21529
21530@item icl
21531interleaved columns, left eye first
21532
21533@item icr
21534interleaved columns, right eye first
21535
21536@item hdmi
21537HDMI frame pack
21538@end table
21539
21540Default value is @samp{arcd}.
21541@end table
21542
21543@subsection Examples
21544
21545@itemize
21546@item
21547Convert input video from side by side parallel to anaglyph yellow/blue dubois:
21548@example
21549stereo3d=sbsl:aybd
21550@end example
21551
21552@item
21553Convert input video from above below (left eye above, right eye below) to side by side crosseye.
21554@example
21555stereo3d=abl:sbsr
21556@end example
21557@end itemize
21558
21559@section streamselect, astreamselect
21560Select video or audio streams.
21561
21562The filter accepts the following options:
21563
21564@table @option
21565@item inputs
21566Set number of inputs. Default is 2.
21567
21568@item map
21569Set input indexes to remap to outputs.
21570@end table
21571
21572@subsection Commands
21573
21574The @code{streamselect} and @code{astreamselect} filter supports the following
21575commands:
21576
21577@table @option
21578@item map
21579Set input indexes to remap to outputs.
21580@end table
21581
21582@subsection Examples
21583
21584@itemize
21585@item
21586Select first 5 seconds 1st stream and rest of time 2nd stream:
21587@example
21588sendcmd='5.0 streamselect map 1',streamselect=inputs=2:map=0
21589@end example
21590
21591@item
21592Same as above, but for audio:
21593@example
21594asendcmd='5.0 astreamselect map 1',astreamselect=inputs=2:map=0
21595@end example
21596@end itemize
21597
21598@anchor{subtitles}
21599@section subtitles
21600
21601Draw subtitles on top of input video using the libass library.
21602
21603To enable compilation of this filter you need to configure FFmpeg with
21604@code{--enable-libass}. This filter also requires a build with libavcodec and
21605libavformat to convert the passed subtitles file to ASS (Advanced Substation
21606Alpha) subtitles format.
21607
21608The filter accepts the following options:
21609
21610@table @option
21611@item filename, f
21612Set the filename of the subtitle file to read. It must be specified.
21613
21614@item original_size
21615Specify the size of the original video, the video for which the ASS file
21616was composed. For the syntax of this option, check the
21617@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
21618Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
21619correctly scale the fonts if the aspect ratio has been changed.
21620
21621@item fontsdir
21622Set a directory path containing fonts that can be used by the filter.
21623These fonts will be used in addition to whatever the font provider uses.
21624
21625@item alpha
21626Process alpha channel, by default alpha channel is untouched.
21627
21628@item charenc
21629Set subtitles input character encoding. @code{subtitles} filter only. Only
21630useful if not UTF-8.
21631
21632@item stream_index, si
21633Set subtitles stream index. @code{subtitles} filter only.
21634
21635@item force_style
21636Override default style or script info parameters of the subtitles. It accepts a
21637string containing ASS style format @code{KEY=VALUE} couples separated by ",".
21638@end table
21639
21640If the first key is not specified, it is assumed that the first value
21641specifies the @option{filename}.
21642
21643For example, to render the file @file{sub.srt} on top of the input
21644video, use the command:
21645@example
21646subtitles=sub.srt
21647@end example
21648
21649which is equivalent to:
21650@example
21651subtitles=filename=sub.srt
21652@end example
21653
21654To render the default subtitles stream from file @file{video.mkv}, use:
21655@example
21656subtitles=video.mkv
21657@end example
21658
21659To render the second subtitles stream from that file, use:
21660@example
21661subtitles=video.mkv:si=1
21662@end example
21663
21664To make the subtitles stream from @file{sub.srt} appear in 80% transparent blue
21665@code{DejaVu Serif}, use:
21666@example
21667subtitles=sub.srt:force_style='Fontname=DejaVu Serif,PrimaryColour=&HCCFF0000'
21668@end example
21669
21670@section super2xsai
21671
21672Scale the input by 2x and smooth using the Super2xSaI (Scale and
21673Interpolate) pixel art scaling algorithm.
21674
21675Useful for enlarging pixel art images without reducing sharpness.
21676
21677@section swaprect
21678
21679Swap two rectangular objects in video.
21680
21681This filter accepts the following options:
21682
21683@table @option
21684@item w
21685Set object width.
21686
21687@item h
21688Set object height.
21689
21690@item x1
21691Set 1st rect x coordinate.
21692
21693@item y1
21694Set 1st rect y coordinate.
21695
21696@item x2
21697Set 2nd rect x coordinate.
21698
21699@item y2
21700Set 2nd rect y coordinate.
21701
21702All expressions are evaluated once for each frame.
21703@end table
21704
21705The all options are expressions containing the following constants:
21706
21707@table @option
21708@item w
21709@item h
21710The input width and height.
21711
21712@item a
21713same as @var{w} / @var{h}
21714
21715@item sar
21716input sample aspect ratio
21717
21718@item dar
21719input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
21720
21721@item n
21722The number of the input frame, starting from 0.
21723
21724@item t
21725The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
21726
21727@item pos
21728the position in the file of the input frame, NAN if unknown
21729@end table
21730
21731@subsection Commands
21732
21733This filter supports the all above options as @ref{commands}.
21734
21735@section swapuv
21736Swap U & V plane.
21737
21738@section tblend
21739Blend successive video frames.
21740
21741See @ref{blend}
21742
21743@section telecine
21744
21745Apply telecine process to the video.
21746
21747This filter accepts the following options:
21748
21749@table @option
21750@item first_field
21751@table @samp
21752@item top, t
21753top field first
21754@item bottom, b
21755bottom field first
21756The default value is @code{top}.
21757@end table
21758
21759@item pattern
21760A string of numbers representing the pulldown pattern you wish to apply.
21761The default value is @code{23}.
21762@end table
21763
21764@example
21765Some typical patterns:
21766
21767NTSC output (30i):
2176827.5p: 32222
2176924p: 23 (classic)
2177024p: 2332 (preferred)
2177120p: 33
2177218p: 334
2177316p: 3444
21774
21775PAL output (25i):
2177627.5p: 12222
2177724p: 222222222223 ("Euro pulldown")
2177816.67p: 33
2177916p: 33333334
21780@end example
21781
21782@section thistogram
21783
21784Compute and draw a color distribution histogram for the input video across time.
21785
21786Unlike @ref{histogram} video filter which only shows histogram of single input frame
21787at certain time, this filter shows also past histograms of number of frames defined
21788by @code{width} option.
21789
21790The computed histogram is a representation of the color component
21791distribution in an image.
21792
21793The filter accepts the following options:
21794
21795@table @option
21796@item width, w
21797Set width of single color component output. Default value is @code{0}.
21798Value of @code{0} means width will be picked from input video.
21799This also set number of passed histograms to keep.
21800Allowed range is [0, 8192].
21801
21802@item display_mode, d
21803Set display mode.
21804It accepts the following values:
21805@table @samp
21806@item stack
21807Per color component graphs are placed below each other.
21808
21809@item parade
21810Per color component graphs are placed side by side.
21811
21812@item overlay
21813Presents information identical to that in the @code{parade}, except
21814that the graphs representing color components are superimposed directly
21815over one another.
21816@end table
21817Default is @code{stack}.
21818
21819@item levels_mode, m
21820Set mode. Can be either @code{linear}, or @code{logarithmic}.
21821Default is @code{linear}.
21822
21823@item components, c
21824Set what color components to display.
21825Default is @code{7}.
21826
21827@item bgopacity, b
21828Set background opacity. Default is @code{0.9}.
21829
21830@item envelope, e
21831Show envelope. Default is disabled.
21832
21833@item ecolor, ec
21834Set envelope color. Default is @code{gold}.
21835
21836@item slide
21837Set slide mode.
21838
21839Available values for slide is:
21840@table @samp
21841@item frame
21842Draw new frame when right border is reached.
21843
21844@item replace
21845Replace old columns with new ones.
21846
21847@item scroll
21848Scroll from right to left.
21849
21850@item rscroll
21851Scroll from left to right.
21852
21853@item picture
21854Draw single picture.
21855@end table
21856
21857Default is @code{replace}.
21858@end table
21859
21860@section threshold
21861
21862Apply threshold effect to video stream.
21863
21864This filter needs four video streams to perform thresholding.
21865First stream is stream we are filtering.
21866Second stream is holding threshold values, third stream is holding min values,
21867and last, fourth stream is holding max values.
21868
21869The filter accepts the following option:
21870
21871@table @option
21872@item planes
21873Set which planes will be processed, unprocessed planes will be copied.
21874By default value 0xf, all planes will be processed.
21875@end table
21876
21877For example if first stream pixel's component value is less then threshold value
21878of pixel component from 2nd threshold stream, third stream value will picked,
21879otherwise fourth stream pixel component value will be picked.
21880
21881Using color source filter one can perform various types of thresholding:
21882
21883@subsection Commands
21884
21885This filter supports the all options as @ref{commands}.
21886
21887@subsection Examples
21888
21889@itemize
21890@item
21891Binary threshold, using gray color as threshold:
21892@example
21893ffmpeg -i 320x240.avi -f lavfi -i color=gray -f lavfi -i color=black -f lavfi -i color=white -lavfi threshold output.avi
21894@end example
21895
21896@item
21897Inverted binary threshold, using gray color as threshold:
21898@example
21899ffmpeg -i 320x240.avi -f lavfi -i color=gray -f lavfi -i color=white -f lavfi -i color=black -lavfi threshold output.avi
21900@end example
21901
21902@item
21903Truncate binary threshold, using gray color as threshold:
21904@example
21905ffmpeg -i 320x240.avi -f lavfi -i color=gray -i 320x240.avi -f lavfi -i color=gray -lavfi threshold output.avi
21906@end example
21907
21908@item
21909Threshold to zero, using gray color as threshold:
21910@example
21911ffmpeg -i 320x240.avi -f lavfi -i color=gray -f lavfi -i color=white -i 320x240.avi -lavfi threshold output.avi
21912@end example
21913
21914@item
21915Inverted threshold to zero, using gray color as threshold:
21916@example
21917ffmpeg -i 320x240.avi -f lavfi -i color=gray -i 320x240.avi -f lavfi -i color=white -lavfi threshold output.avi
21918@end example
21919@end itemize
21920
21921@section thumbnail
21922Select the most representative frame in a given sequence of consecutive frames.
21923
21924The filter accepts the following options:
21925
21926@table @option
21927@item n
21928Set the frames batch size to analyze; in a set of @var{n} frames, the filter
21929will pick one of them, and then handle the next batch of @var{n} frames until
21930the end. Default is @code{100}.
21931@end table
21932
21933Since the filter keeps track of the whole frames sequence, a bigger @var{n}
21934value will result in a higher memory usage, so a high value is not recommended.
21935
21936@subsection Examples
21937
21938@itemize
21939@item
21940Extract one picture each 50 frames:
21941@example
21942thumbnail=50
21943@end example
21944
21945@item
21946Complete example of a thumbnail creation with @command{ffmpeg}:
21947@example
21948ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
21949@end example
21950@end itemize
21951
21952@anchor{tile}
21953@section tile
21954
21955Tile several successive frames together.
21956
21957The @ref{untile} filter can do the reverse.
21958
21959The filter accepts the following options:
21960
21961@table @option
21962
21963@item layout
21964Set the grid size in the form @code{COLUMNSxROWS}. Range is upto UINT_MAX cells.
21965Default is @code{6x5}.
21966
21967@item nb_frames
21968Set the maximum number of frames to render in the given area. It must be less
21969than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
21970the area will be used.
21971
21972@item margin
21973Set the outer border margin in pixels. Range is 0 to 1024. Default is @code{0}.
21974
21975@item padding
21976Set the inner border thickness (i.e. the number of pixels between frames). For
21977more advanced padding options (such as having different values for the edges),
21978refer to the pad video filter. Range is 0 to 1024. Default is @code{0}.
21979
21980@item color
21981Specify the color of the unused area. For the syntax of this option, check the
21982@ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.
21983The default value of @var{color} is "black".
21984
21985@item overlap
21986Set the number of frames to overlap when tiling several successive frames together.
21987The value must be between @code{0} and @var{nb_frames - 1}. Default is @code{0}.
21988
21989@item init_padding
21990Set the number of frames to initially be empty before displaying first output frame.
21991This controls how soon will one get first output frame.
21992The value must be between @code{0} and @var{nb_frames - 1}. Default is @code{0}.
21993@end table
21994
21995@subsection Examples
21996
21997@itemize
21998@item
21999Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
22000@example
22001ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
22002@end example
22003The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
22004duplicating each output frame to accommodate the originally detected frame
22005rate.
22006
22007@item
22008Display @code{5} pictures in an area of @code{3x2} frames,
22009with @code{7} pixels between them, and @code{2} pixels of initial margin, using
22010mixed flat and named options:
22011@example
22012tile=3x2:nb_frames=5:padding=7:margin=2
22013@end example
22014@end itemize
22015
22016@section tinterlace
22017
22018Perform various types of temporal field interlacing.
22019
22020Frames are counted starting from 1, so the first input frame is
22021considered odd.
22022
22023The filter accepts the following options:
22024
22025@table @option
22026
22027@item mode
22028Specify the mode of the interlacing. This option can also be specified
22029as a value alone. See below for a list of values for this option.
22030
22031Available values are:
22032
22033@table @samp
22034@item merge, 0
22035Move odd frames into the upper field, even into the lower field,
22036generating a double height frame at half frame rate.
22037@example
22038 ------> time
22039Input:
22040Frame 1         Frame 2         Frame 3         Frame 4
22041
2204211111           22222           33333           44444
2204311111           22222           33333           44444
2204411111           22222           33333           44444
2204511111           22222           33333           44444
22046
22047Output:
2204811111                           33333
2204922222                           44444
2205011111                           33333
2205122222                           44444
2205211111                           33333
2205322222                           44444
2205411111                           33333
2205522222                           44444
22056@end example
22057
22058@item drop_even, 1
22059Only output odd frames, even frames are dropped, generating a frame with
22060unchanged height at half frame rate.
22061
22062@example
22063 ------> time
22064Input:
22065Frame 1         Frame 2         Frame 3         Frame 4
22066
2206711111           22222           33333           44444
2206811111           22222           33333           44444
2206911111           22222           33333           44444
2207011111           22222           33333           44444
22071
22072Output:
2207311111                           33333
2207411111                           33333
2207511111                           33333
2207611111                           33333
22077@end example
22078
22079@item drop_odd, 2
22080Only output even frames, odd frames are dropped, generating a frame with
22081unchanged height at half frame rate.
22082
22083@example
22084 ------> time
22085Input:
22086Frame 1         Frame 2         Frame 3         Frame 4
22087
2208811111           22222           33333           44444
2208911111           22222           33333           44444
2209011111           22222           33333           44444
2209111111           22222           33333           44444
22092
22093Output:
22094                22222                           44444
22095                22222                           44444
22096                22222                           44444
22097                22222                           44444
22098@end example
22099
22100@item pad, 3
22101Expand each frame to full height, but pad alternate lines with black,
22102generating a frame with double height at the same input frame rate.
22103
22104@example
22105 ------> time
22106Input:
22107Frame 1         Frame 2         Frame 3         Frame 4
22108
2210911111           22222           33333           44444
2211011111           22222           33333           44444
2211111111           22222           33333           44444
2211211111           22222           33333           44444
22113
22114Output:
2211511111           .....           33333           .....
22116.....           22222           .....           44444
2211711111           .....           33333           .....
22118.....           22222           .....           44444
2211911111           .....           33333           .....
22120.....           22222           .....           44444
2212111111           .....           33333           .....
22122.....           22222           .....           44444
22123@end example
22124
22125
22126@item interleave_top, 4
22127Interleave the upper field from odd frames with the lower field from
22128even frames, generating a frame with unchanged height at half frame rate.
22129
22130@example
22131 ------> time
22132Input:
22133Frame 1         Frame 2         Frame 3         Frame 4
22134
2213511111<-         22222           33333<-         44444
2213611111           22222<-         33333           44444<-
2213711111<-         22222           33333<-         44444
2213811111           22222<-         33333           44444<-
22139
22140Output:
2214111111                           33333
2214222222                           44444
2214311111                           33333
2214422222                           44444
22145@end example
22146
22147
22148@item interleave_bottom, 5
22149Interleave the lower field from odd frames with the upper field from
22150even frames, generating a frame with unchanged height at half frame rate.
22151
22152@example
22153 ------> time
22154Input:
22155Frame 1         Frame 2         Frame 3         Frame 4
22156
2215711111           22222<-         33333           44444<-
2215811111<-         22222           33333<-         44444
2215911111           22222<-         33333           44444<-
2216011111<-         22222           33333<-         44444
22161
22162Output:
2216322222                           44444
2216411111                           33333
2216522222                           44444
2216611111                           33333
22167@end example
22168
22169
22170@item interlacex2, 6
22171Double frame rate with unchanged height. Frames are inserted each
22172containing the second temporal field from the previous input frame and
22173the first temporal field from the next input frame. This mode relies on
22174the top_field_first flag. Useful for interlaced video displays with no
22175field synchronisation.
22176
22177@example
22178 ------> time
22179Input:
22180Frame 1         Frame 2         Frame 3         Frame 4
22181
2218211111           22222           33333           44444
22183 11111           22222           33333           44444
2218411111           22222           33333           44444
22185 11111           22222           33333           44444
22186
22187Output:
2218811111   22222   22222   33333   33333   44444   44444
22189 11111   11111   22222   22222   33333   33333   44444
2219011111   22222   22222   33333   33333   44444   44444
22191 11111   11111   22222   22222   33333   33333   44444
22192@end example
22193
22194
22195@item mergex2, 7
22196Move odd frames into the upper field, even into the lower field,
22197generating a double height frame at same frame rate.
22198
22199@example
22200 ------> time
22201Input:
22202Frame 1         Frame 2         Frame 3         Frame 4
22203
2220411111           22222           33333           44444
2220511111           22222           33333           44444
2220611111           22222           33333           44444
2220711111           22222           33333           44444
22208
22209Output:
2221011111           33333           33333           55555
2221122222           22222           44444           44444
2221211111           33333           33333           55555
2221322222           22222           44444           44444
2221411111           33333           33333           55555
2221522222           22222           44444           44444
2221611111           33333           33333           55555
2221722222           22222           44444           44444
22218@end example
22219
22220@end table
22221
22222Numeric values are deprecated but are accepted for backward
22223compatibility reasons.
22224
22225Default mode is @code{merge}.
22226
22227@item flags
22228Specify flags influencing the filter process.
22229
22230Available value for @var{flags} is:
22231
22232@table @option
22233@item low_pass_filter, vlpf
22234Enable linear vertical low-pass filtering in the filter.
22235Vertical low-pass filtering is required when creating an interlaced
22236destination from a progressive source which contains high-frequency
22237vertical detail. Filtering will reduce interlace 'twitter' and Moire
22238patterning.
22239
22240@item complex_filter, cvlpf
22241Enable complex vertical low-pass filtering.
22242This will slightly less reduce interlace 'twitter' and Moire
22243patterning but better retain detail and subjective sharpness impression.
22244
22245@item bypass_il
22246Bypass already interlaced frames, only adjust the frame rate.
22247@end table
22248
22249Vertical low-pass filtering and bypassing already interlaced frames can only be
22250enabled for @option{mode} @var{interleave_top} and @var{interleave_bottom}.
22251
22252@end table
22253
22254@section tmedian
22255Pick median pixels from several successive input video frames.
22256
22257The filter accepts the following options:
22258
22259@table @option
22260@item radius
22261Set radius of median filter.
22262Default is 1. Allowed range is from 1 to 127.
22263
22264@item planes
22265Set which planes to filter. Default value is @code{15}, by which all planes are processed.
22266
22267@item percentile
22268Set median percentile. Default value is @code{0.5}.
22269Default value of @code{0.5} will pick always median values, while @code{0} will pick
22270minimum values, and @code{1} maximum values.
22271@end table
22272
22273@subsection Commands
22274
22275This filter supports all above options as @ref{commands}, excluding option @code{radius}.
22276
22277@section tmidequalizer
22278
22279Apply Temporal Midway Video Equalization effect.
22280
22281Midway Video Equalization adjusts a sequence of video frames to have the same
22282histograms, while maintaining their dynamics as much as possible. It's
22283useful for e.g. matching exposures from a video frames sequence.
22284
22285This filter accepts the following option:
22286
22287@table @option
22288@item radius
22289Set filtering radius. Default is @code{5}. Allowed range is from 1 to 127.
22290
22291@item sigma
22292Set filtering sigma. Default is @code{0.5}. This controls strength of filtering.
22293Setting this option to 0 effectively does nothing.
22294
22295@item planes
22296Set which planes to process. Default is @code{15}, which is all available planes.
22297@end table
22298
22299@section tmix
22300
22301Mix successive video frames.
22302
22303A description of the accepted options follows.
22304
22305@table @option
22306@item frames
22307The number of successive frames to mix. If unspecified, it defaults to 3.
22308
22309@item weights
22310Specify weight of each input video frame.
22311Each weight is separated by space. If number of weights is smaller than
22312number of @var{frames} last specified weight will be used for all remaining
22313unset weights.
22314
22315@item scale
22316Specify scale, if it is set it will be multiplied with sum
22317of each weight multiplied with pixel values to give final destination
22318pixel value. By default @var{scale} is auto scaled to sum of weights.
22319
22320@item planes
22321Set which planes to filter. Default is all. Allowed range is from 0 to 15.
22322@end table
22323
22324@subsection Examples
22325
22326@itemize
22327@item
22328Average 7 successive frames:
22329@example
22330tmix=frames=7:weights="1 1 1 1 1 1 1"
22331@end example
22332
22333@item
22334Apply simple temporal convolution:
22335@example
22336tmix=frames=3:weights="-1 3 -1"
22337@end example
22338
22339@item
22340Similar as above but only showing temporal differences:
22341@example
22342tmix=frames=3:weights="-1 2 -1":scale=1
22343@end example
22344@end itemize
22345
22346@subsection Commands
22347
22348This filter supports the following commands:
22349@table @option
22350@item weights
22351@item scale
22352@item planes
22353Syntax is same as option with same name.
22354@end table
22355
22356@anchor{tonemap}
22357@section tonemap
22358Tone map colors from different dynamic ranges.
22359
22360This filter expects data in single precision floating point, as it needs to
22361operate on (and can output) out-of-range values. Another filter, such as
22362@ref{zscale}, is needed to convert the resulting frame to a usable format.
22363
22364The tonemapping algorithms implemented only work on linear light, so input
22365data should be linearized beforehand (and possibly correctly tagged).
22366
22367@example
22368ffmpeg -i INPUT -vf zscale=transfer=linear,tonemap=clip,zscale=transfer=bt709,format=yuv420p OUTPUT
22369@end example
22370
22371@subsection Options
22372The filter accepts the following options.
22373
22374@table @option
22375@item tonemap
22376Set the tone map algorithm to use.
22377
22378Possible values are:
22379@table @var
22380@item none
22381Do not apply any tone map, only desaturate overbright pixels.
22382
22383@item clip
22384Hard-clip any out-of-range values. Use it for perfect color accuracy for
22385in-range values, while distorting out-of-range values.
22386
22387@item linear
22388Stretch the entire reference gamut to a linear multiple of the display.
22389
22390@item gamma
22391Fit a logarithmic transfer between the tone curves.
22392
22393@item reinhard
22394Preserve overall image brightness with a simple curve, using nonlinear
22395contrast, which results in flattening details and degrading color accuracy.
22396
22397@item hable
22398Preserve both dark and bright details better than @var{reinhard}, at the cost
22399of slightly darkening everything. Use it when detail preservation is more
22400important than color and brightness accuracy.
22401
22402@item mobius
22403Smoothly map out-of-range values, while retaining contrast and colors for
22404in-range material as much as possible. Use it when color accuracy is more
22405important than detail preservation.
22406@end table
22407
22408Default is none.
22409
22410@item param
22411Tune the tone mapping algorithm.
22412
22413This affects the following algorithms:
22414@table @var
22415@item none
22416Ignored.
22417
22418@item linear
22419Specifies the scale factor to use while stretching.
22420Default to 1.0.
22421
22422@item gamma
22423Specifies the exponent of the function.
22424Default to 1.8.
22425
22426@item clip
22427Specify an extra linear coefficient to multiply into the signal before clipping.
22428Default to 1.0.
22429
22430@item reinhard
22431Specify the local contrast coefficient at the display peak.
22432Default to 0.5, which means that in-gamut values will be about half as bright
22433as when clipping.
22434
22435@item hable
22436Ignored.
22437
22438@item mobius
22439Specify the transition point from linear to mobius transform. Every value
22440below this point is guaranteed to be mapped 1:1. The higher the value, the
22441more accurate the result will be, at the cost of losing bright details.
22442Default to 0.3, which due to the steep initial slope still preserves in-range
22443colors fairly accurately.
22444@end table
22445
22446@item desat
22447Apply desaturation for highlights that exceed this level of brightness. The
22448higher the parameter, the more color information will be preserved. This
22449setting helps prevent unnaturally blown-out colors for super-highlights, by
22450(smoothly) turning into white instead. This makes images feel more natural,
22451at the cost of reducing information about out-of-range colors.
22452
22453The default of 2.0 is somewhat conservative and will mostly just apply to
22454skies or directly sunlit surfaces. A setting of 0.0 disables this option.
22455
22456This option works only if the input frame has a supported color tag.
22457
22458@item peak
22459Override signal/nominal/reference peak with this value. Useful when the
22460embedded peak information in display metadata is not reliable or when tone
22461mapping from a lower range to a higher range.
22462@end table
22463
22464@section tpad
22465
22466Temporarily pad video frames.
22467
22468The filter accepts the following options:
22469
22470@table @option
22471@item start
22472Specify number of delay frames before input video stream. Default is 0.
22473
22474@item stop
22475Specify number of padding frames after input video stream.
22476Set to -1 to pad indefinitely. Default is 0.
22477
22478@item start_mode
22479Set kind of frames added to beginning of stream.
22480Can be either @var{add} or @var{clone}.
22481With @var{add} frames of solid-color are added.
22482With @var{clone} frames are clones of first frame.
22483Default is @var{add}.
22484
22485@item stop_mode
22486Set kind of frames added to end of stream.
22487Can be either @var{add} or @var{clone}.
22488With @var{add} frames of solid-color are added.
22489With @var{clone} frames are clones of last frame.
22490Default is @var{add}.
22491
22492@item start_duration, stop_duration
22493Specify the duration of the start/stop delay. See
22494@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
22495for the accepted syntax.
22496These options override @var{start} and @var{stop}. Default is 0.
22497
22498@item color
22499Specify the color of the padded area. For the syntax of this option,
22500check the @ref{color syntax,,"Color" section in the ffmpeg-utils
22501manual,ffmpeg-utils}.
22502
22503The default value of @var{color} is "black".
22504@end table
22505
22506@anchor{transpose}
22507@section transpose
22508
22509Transpose rows with columns in the input video and optionally flip it.
22510
22511It accepts the following parameters:
22512
22513@table @option
22514
22515@item dir
22516Specify the transposition direction.
22517
22518Can assume the following values:
22519@table @samp
22520@item 0, 4, cclock_flip
22521Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
22522@example
22523L.R     L.l
22524. . ->  . .
22525l.r     R.r
22526@end example
22527
22528@item 1, 5, clock
22529Rotate by 90 degrees clockwise, that is:
22530@example
22531L.R     l.L
22532. . ->  . .
22533l.r     r.R
22534@end example
22535
22536@item 2, 6, cclock
22537Rotate by 90 degrees counterclockwise, that is:
22538@example
22539L.R     R.r
22540. . ->  . .
22541l.r     L.l
22542@end example
22543
22544@item 3, 7, clock_flip
22545Rotate by 90 degrees clockwise and vertically flip, that is:
22546@example
22547L.R     r.R
22548. . ->  . .
22549l.r     l.L
22550@end example
22551@end table
22552
22553For values between 4-7, the transposition is only done if the input
22554video geometry is portrait and not landscape. These values are
22555deprecated, the @code{passthrough} option should be used instead.
22556
22557Numerical values are deprecated, and should be dropped in favor of
22558symbolic constants.
22559
22560@item passthrough
22561Do not apply the transposition if the input geometry matches the one
22562specified by the specified value. It accepts the following values:
22563@table @samp
22564@item none
22565Always apply transposition.
22566@item portrait
22567Preserve portrait geometry (when @var{height} >= @var{width}).
22568@item landscape
22569Preserve landscape geometry (when @var{width} >= @var{height}).
22570@end table
22571
22572Default value is @code{none}.
22573@end table
22574
22575For example to rotate by 90 degrees clockwise and preserve portrait
22576layout:
22577@example
22578transpose=dir=1:passthrough=portrait
22579@end example
22580
22581The command above can also be specified as:
22582@example
22583transpose=1:portrait
22584@end example
22585
22586@section transpose_npp
22587
22588Transpose rows with columns in the input video and optionally flip it.
22589For more in depth examples see the @ref{transpose} video filter, which shares mostly the same options.
22590
22591It accepts the following parameters:
22592
22593@table @option
22594
22595@item dir
22596Specify the transposition direction.
22597
22598Can assume the following values:
22599@table @samp
22600@item cclock_flip
22601Rotate by 90 degrees counterclockwise and vertically flip. (default)
22602
22603@item clock
22604Rotate by 90 degrees clockwise.
22605
22606@item cclock
22607Rotate by 90 degrees counterclockwise.
22608
22609@item clock_flip
22610Rotate by 90 degrees clockwise and vertically flip.
22611@end table
22612
22613@item passthrough
22614Do not apply the transposition if the input geometry matches the one
22615specified by the specified value. It accepts the following values:
22616@table @samp
22617@item none
22618Always apply transposition. (default)
22619@item portrait
22620Preserve portrait geometry (when @var{height} >= @var{width}).
22621@item landscape
22622Preserve landscape geometry (when @var{width} >= @var{height}).
22623@end table
22624
22625@end table
22626
22627@section trim
22628Trim the input so that the output contains one continuous subpart of the input.
22629
22630It accepts the following parameters:
22631@table @option
22632@item start
22633Specify the time of the start of the kept section, i.e. the frame with the
22634timestamp @var{start} will be the first frame in the output.
22635
22636@item end
22637Specify the time of the first frame that will be dropped, i.e. the frame
22638immediately preceding the one with the timestamp @var{end} will be the last
22639frame in the output.
22640
22641@item start_pts
22642This is the same as @var{start}, except this option sets the start timestamp
22643in timebase units instead of seconds.
22644
22645@item end_pts
22646This is the same as @var{end}, except this option sets the end timestamp
22647in timebase units instead of seconds.
22648
22649@item duration
22650The maximum duration of the output in seconds.
22651
22652@item start_frame
22653The number of the first frame that should be passed to the output.
22654
22655@item end_frame
22656The number of the first frame that should be dropped.
22657@end table
22658
22659@option{start}, @option{end}, and @option{duration} are expressed as time
22660duration specifications; see
22661@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
22662for the accepted syntax.
22663
22664Note that the first two sets of the start/end options and the @option{duration}
22665option look at the frame timestamp, while the _frame variants simply count the
22666frames that pass through the filter. Also note that this filter does not modify
22667the timestamps. If you wish for the output timestamps to start at zero, insert a
22668setpts filter after the trim filter.
22669
22670If multiple start or end options are set, this filter tries to be greedy and
22671keep all the frames that match at least one of the specified constraints. To keep
22672only the part that matches all the constraints at once, chain multiple trim
22673filters.
22674
22675The defaults are such that all the input is kept. So it is possible to set e.g.
22676just the end values to keep everything before the specified time.
22677
22678Examples:
22679@itemize
22680@item
22681Drop everything except the second minute of input:
22682@example
22683ffmpeg -i INPUT -vf trim=60:120
22684@end example
22685
22686@item
22687Keep only the first second:
22688@example
22689ffmpeg -i INPUT -vf trim=duration=1
22690@end example
22691
22692@end itemize
22693
22694@section unpremultiply
22695Apply alpha unpremultiply effect to input video stream using first plane
22696of second stream as alpha.
22697
22698Both streams must have same dimensions and same pixel format.
22699
22700The filter accepts the following option:
22701
22702@table @option
22703@item planes
22704Set which planes will be processed, unprocessed planes will be copied.
22705By default value 0xf, all planes will be processed.
22706
22707If the format has 1 or 2 components, then luma is bit 0.
22708If the format has 3 or 4 components:
22709for RGB formats bit 0 is green, bit 1 is blue and bit 2 is red;
22710for YUV formats bit 0 is luma, bit 1 is chroma-U and bit 2 is chroma-V.
22711If present, the alpha channel is always the last bit.
22712
22713@item inplace
22714Do not require 2nd input for processing, instead use alpha plane from input stream.
22715@end table
22716
22717@anchor{unsharp}
22718@section unsharp
22719
22720Sharpen or blur the input video.
22721
22722It accepts the following parameters:
22723
22724@table @option
22725@item luma_msize_x, lx
22726Set the luma matrix horizontal size. It must be an odd integer between
227273 and 23. The default value is 5.
22728
22729@item luma_msize_y, ly
22730Set the luma matrix vertical size. It must be an odd integer between 3
22731and 23. The default value is 5.
22732
22733@item luma_amount, la
22734Set the luma effect strength. It must be a floating point number, reasonable
22735values lay between -1.5 and 1.5.
22736
22737Negative values will blur the input video, while positive values will
22738sharpen it, a value of zero will disable the effect.
22739
22740Default value is 1.0.
22741
22742@item chroma_msize_x, cx
22743Set the chroma matrix horizontal size. It must be an odd integer
22744between 3 and 23. The default value is 5.
22745
22746@item chroma_msize_y, cy
22747Set the chroma matrix vertical size. It must be an odd integer
22748between 3 and 23. The default value is 5.
22749
22750@item chroma_amount, ca
22751Set the chroma effect strength. It must be a floating point number, reasonable
22752values lay between -1.5 and 1.5.
22753
22754Negative values will blur the input video, while positive values will
22755sharpen it, a value of zero will disable the effect.
22756
22757Default value is 0.0.
22758
22759@item alpha_msize_x, ax
22760Set the alpha matrix horizontal size. It must be an odd integer
22761between 3 and 23. The default value is 5.
22762
22763@item alpha_msize_y, ay
22764Set the alpha matrix vertical size. It must be an odd integer
22765between 3 and 23. The default value is 5.
22766
22767@item alpha_amount, aa
22768Set the alpha effect strength. It must be a floating point number, reasonable
22769values lay between -1.5 and 1.5.
22770
22771Negative values will blur the input video, while positive values will
22772sharpen it, a value of zero will disable the effect.
22773
22774Default value is 0.0.
22775
22776@end table
22777
22778All parameters are optional and default to the equivalent of the
22779string '5:5:1.0:5:5:0.0'.
22780
22781@subsection Examples
22782
22783@itemize
22784@item
22785Apply strong luma sharpen effect:
22786@example
22787unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
22788@end example
22789
22790@item
22791Apply a strong blur of both luma and chroma parameters:
22792@example
22793unsharp=7:7:-2:7:7:-2
22794@end example
22795@end itemize
22796
22797@anchor{untile}
22798@section untile
22799
22800Decompose a video made of tiled images into the individual images.
22801
22802The frame rate of the output video is the frame rate of the input video
22803multiplied by the number of tiles.
22804
22805This filter does the reverse of @ref{tile}.
22806
22807The filter accepts the following options:
22808
22809@table @option
22810
22811@item layout
22812Set the grid size (i.e. the number of lines and columns). For the syntax of
22813this option, check the
22814@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
22815@end table
22816
22817@subsection Examples
22818
22819@itemize
22820@item
22821Produce a 1-second video from a still image file made of 25 frames stacked
22822vertically, like an analogic film reel:
22823@example
22824ffmpeg -r 1 -i image.jpg -vf untile=1x25 movie.mkv
22825@end example
22826@end itemize
22827
22828@section uspp
22829
22830Apply ultra slow/simple postprocessing filter that compresses and decompresses
22831the image at several (or - in the case of @option{quality} level @code{8} - all)
22832shifts and average the results.
22833
22834The way this differs from the behavior of spp is that uspp actually encodes &
22835decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
22836DCT similar to MJPEG.
22837
22838This filter is only available in ffmpeg version 4.4 or earlier.
22839
22840The filter accepts the following options:
22841
22842@table @option
22843@item quality
22844Set quality. This option defines the number of levels for averaging. It accepts
22845an integer in the range 0-8. If set to @code{0}, the filter will have no
22846effect. A value of @code{8} means the higher quality. For each increment of
22847that value the speed drops by a factor of approximately 2.  Default value is
22848@code{3}.
22849
22850@item qp
22851Force a constant quantization parameter. If not set, the filter will use the QP
22852from the video stream (if available).
22853@end table
22854
22855@section v360
22856
22857Convert 360 videos between various formats.
22858
22859The filter accepts the following options:
22860
22861@table @option
22862
22863@item input
22864@item output
22865Set format of the input/output video.
22866
22867Available formats:
22868
22869@table @samp
22870
22871@item e
22872@item equirect
22873Equirectangular projection.
22874
22875@item c3x2
22876@item c6x1
22877@item c1x6
22878Cubemap with 3x2/6x1/1x6 layout.
22879
22880Format specific options:
22881
22882@table @option
22883@item in_pad
22884@item out_pad
22885Set padding proportion for the input/output cubemap. Values in decimals.
22886
22887Example values:
22888@table @samp
22889@item 0
22890No padding.
22891@item 0.01
228921% 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)
22893@end table
22894
22895Default value is @b{@samp{0}}.
22896Maximum value is @b{@samp{0.1}}.
22897
22898@item fin_pad
22899@item fout_pad
22900Set fixed padding for the input/output cubemap. Values in pixels.
22901
22902Default value is @b{@samp{0}}. If greater than zero it overrides other padding options.
22903
22904@item in_forder
22905@item out_forder
22906Set order of faces for the input/output cubemap. Choose one direction for each position.
22907
22908Designation of directions:
22909@table @samp
22910@item r
22911right
22912@item l
22913left
22914@item u
22915up
22916@item d
22917down
22918@item f
22919forward
22920@item b
22921back
22922@end table
22923
22924Default value is @b{@samp{rludfb}}.
22925
22926@item in_frot
22927@item out_frot
22928Set rotation of faces for the input/output cubemap. Choose one angle for each position.
22929
22930Designation of angles:
22931@table @samp
22932@item 0
229330 degrees clockwise
22934@item 1
2293590 degrees clockwise
22936@item 2
22937180 degrees clockwise
22938@item 3
22939270 degrees clockwise
22940@end table
22941
22942Default value is @b{@samp{000000}}.
22943@end table
22944
22945@item eac
22946Equi-Angular Cubemap.
22947
22948@item flat
22949@item gnomonic
22950@item rectilinear
22951Regular video.
22952
22953Format specific options:
22954@table @option
22955@item h_fov
22956@item v_fov
22957@item d_fov
22958Set output horizontal/vertical/diagonal field of view. Values in degrees.
22959
22960If diagonal field of view is set it overrides horizontal and vertical field of view.
22961
22962@item ih_fov
22963@item iv_fov
22964@item id_fov
22965Set input horizontal/vertical/diagonal field of view. Values in degrees.
22966
22967If diagonal field of view is set it overrides horizontal and vertical field of view.
22968@end table
22969
22970@item dfisheye
22971Dual fisheye.
22972
22973Format specific options:
22974@table @option
22975@item h_fov
22976@item v_fov
22977@item d_fov
22978Set output horizontal/vertical/diagonal field of view. Values in degrees.
22979
22980If diagonal field of view is set it overrides horizontal and vertical field of view.
22981
22982@item ih_fov
22983@item iv_fov
22984@item id_fov
22985Set input horizontal/vertical/diagonal field of view. Values in degrees.
22986
22987If diagonal field of view is set it overrides horizontal and vertical field of view.
22988@end table
22989
22990@item barrel
22991@item fb
22992@item barrelsplit
22993Facebook's 360 formats.
22994
22995@item sg
22996Stereographic format.
22997
22998Format specific options:
22999@table @option
23000@item h_fov
23001@item v_fov
23002@item d_fov
23003Set output horizontal/vertical/diagonal field of view. Values in degrees.
23004
23005If diagonal field of view is set it overrides horizontal and vertical field of view.
23006
23007@item ih_fov
23008@item iv_fov
23009@item id_fov
23010Set input horizontal/vertical/diagonal field of view. Values in degrees.
23011
23012If diagonal field of view is set it overrides horizontal and vertical field of view.
23013@end table
23014
23015@item mercator
23016Mercator format.
23017
23018@item ball
23019Ball format, gives significant distortion toward the back.
23020
23021@item hammer
23022Hammer-Aitoff map projection format.
23023
23024@item sinusoidal
23025Sinusoidal map projection format.
23026
23027@item fisheye
23028Fisheye projection.
23029
23030Format specific options:
23031@table @option
23032@item h_fov
23033@item v_fov
23034@item d_fov
23035Set output horizontal/vertical/diagonal field of view. Values in degrees.
23036
23037If diagonal field of view is set it overrides horizontal and vertical field of view.
23038
23039@item ih_fov
23040@item iv_fov
23041@item id_fov
23042Set input horizontal/vertical/diagonal field of view. Values in degrees.
23043
23044If diagonal field of view is set it overrides horizontal and vertical field of view.
23045@end table
23046
23047@item pannini
23048Pannini projection.
23049
23050Format specific options:
23051@table @option
23052@item h_fov
23053Set output pannini parameter.
23054
23055@item ih_fov
23056Set input pannini parameter.
23057@end table
23058
23059@item cylindrical
23060Cylindrical projection.
23061
23062Format specific options:
23063@table @option
23064@item h_fov
23065@item v_fov
23066@item d_fov
23067Set output horizontal/vertical/diagonal field of view. Values in degrees.
23068
23069If diagonal field of view is set it overrides horizontal and vertical field of view.
23070
23071@item ih_fov
23072@item iv_fov
23073@item id_fov
23074Set input horizontal/vertical/diagonal field of view. Values in degrees.
23075
23076If diagonal field of view is set it overrides horizontal and vertical field of view.
23077@end table
23078
23079@item perspective
23080Perspective projection. @i{(output only)}
23081
23082Format specific options:
23083@table @option
23084@item v_fov
23085Set perspective parameter.
23086@end table
23087
23088@item tetrahedron
23089Tetrahedron projection.
23090
23091@item tsp
23092Truncated square pyramid projection.
23093
23094@item he
23095@item hequirect
23096Half equirectangular projection.
23097
23098@item equisolid
23099Equisolid format.
23100
23101Format specific options:
23102@table @option
23103@item h_fov
23104@item v_fov
23105@item d_fov
23106Set output horizontal/vertical/diagonal field of view. Values in degrees.
23107
23108If diagonal field of view is set it overrides horizontal and vertical field of view.
23109
23110@item ih_fov
23111@item iv_fov
23112@item id_fov
23113Set input horizontal/vertical/diagonal field of view. Values in degrees.
23114
23115If diagonal field of view is set it overrides horizontal and vertical field of view.
23116@end table
23117
23118@item og
23119Orthographic format.
23120
23121Format specific options:
23122@table @option
23123@item h_fov
23124@item v_fov
23125@item d_fov
23126Set output horizontal/vertical/diagonal field of view. Values in degrees.
23127
23128If diagonal field of view is set it overrides horizontal and vertical field of view.
23129
23130@item ih_fov
23131@item iv_fov
23132@item id_fov
23133Set input horizontal/vertical/diagonal field of view. Values in degrees.
23134
23135If diagonal field of view is set it overrides horizontal and vertical field of view.
23136@end table
23137
23138@item octahedron
23139Octahedron projection.
23140
23141@item cylindricalea
23142Cylindrical Equal Area projection.
23143@end table
23144
23145@item interp
23146Set interpolation method.@*
23147@i{Note: more complex interpolation methods require much more memory to run.}
23148
23149Available methods:
23150
23151@table @samp
23152@item near
23153@item nearest
23154Nearest neighbour.
23155@item line
23156@item linear
23157Bilinear interpolation.
23158@item lagrange9
23159Lagrange9 interpolation.
23160@item cube
23161@item cubic
23162Bicubic interpolation.
23163@item lanc
23164@item lanczos
23165Lanczos interpolation.
23166@item sp16
23167@item spline16
23168Spline16 interpolation.
23169@item gauss
23170@item gaussian
23171Gaussian interpolation.
23172@item mitchell
23173Mitchell interpolation.
23174@end table
23175
23176Default value is @b{@samp{line}}.
23177
23178@item w
23179@item h
23180Set the output video resolution.
23181
23182Default resolution depends on formats.
23183
23184@item in_stereo
23185@item out_stereo
23186Set the input/output stereo format.
23187
23188@table @samp
23189@item 2d
231902D mono
23191@item sbs
23192Side by side
23193@item tb
23194Top bottom
23195@end table
23196
23197Default value is @b{@samp{2d}} for input and output format.
23198
23199@item yaw
23200@item pitch
23201@item roll
23202Set rotation for the output video. Values in degrees.
23203
23204@item rorder
23205Set rotation order for the output video. Choose one item for each position.
23206
23207@table @samp
23208@item y, Y
23209yaw
23210@item p, P
23211pitch
23212@item r, R
23213roll
23214@end table
23215
23216Default value is @b{@samp{ypr}}.
23217
23218@item h_flip
23219@item v_flip
23220@item d_flip
23221Flip the output video horizontally(swaps left-right)/vertically(swaps up-down)/in-depth(swaps back-forward). Boolean values.
23222
23223@item ih_flip
23224@item iv_flip
23225Set if input video is flipped horizontally/vertically. Boolean values.
23226
23227@item in_trans
23228Set if input video is transposed. Boolean value, by default disabled.
23229
23230@item out_trans
23231Set if output video needs to be transposed. Boolean value, by default disabled.
23232
23233@item h_offset
23234@item v_offset
23235Set output horizontal/vertical off-axis offset. Default is set to 0.
23236Allowed range is from -1 to 1.
23237
23238@item alpha_mask
23239Build mask in alpha plane for all unmapped pixels by marking them fully transparent. Boolean value, by default disabled.
23240
23241@item reset_rot
23242Reset rotation of output video. Boolean value, by default disabled.
23243@end table
23244
23245@subsection Examples
23246
23247@itemize
23248@item
23249Convert equirectangular video to cubemap with 3x2 layout and 1% padding using bicubic interpolation:
23250@example
23251ffmpeg -i input.mkv -vf v360=e:c3x2:cubic:out_pad=0.01 output.mkv
23252@end example
23253@item
23254Extract back view of Equi-Angular Cubemap:
23255@example
23256ffmpeg -i input.mkv -vf v360=eac:flat:yaw=180 output.mkv
23257@end example
23258@item
23259Convert transposed and horizontally flipped Equi-Angular Cubemap in side-by-side stereo format to equirectangular top-bottom stereo format:
23260@example
23261v360=eac:equirect:in_stereo=sbs:in_trans=1:ih_flip=1:out_stereo=tb
23262@end example
23263@end itemize
23264
23265@subsection Commands
23266
23267This filter supports subset of above options as @ref{commands}.
23268
23269@section vaguedenoiser
23270
23271Apply a wavelet based denoiser.
23272
23273It transforms each frame from the video input into the wavelet domain,
23274using Cohen-Daubechies-Feauveau 9/7. Then it applies some filtering to
23275the obtained coefficients. It does an inverse wavelet transform after.
23276Due to wavelet properties, it should give a nice smoothed result, and
23277reduced noise, without blurring picture features.
23278
23279This filter accepts the following options:
23280
23281@table @option
23282@item threshold
23283The filtering strength. The higher, the more filtered the video will be.
23284Hard thresholding can use a higher threshold than soft thresholding
23285before the video looks overfiltered. Default value is 2.
23286
23287@item method
23288The filtering method the filter will use.
23289
23290It accepts the following values:
23291@table @samp
23292@item hard
23293All values under the threshold will be zeroed.
23294
23295@item soft
23296All values under the threshold will be zeroed. All values above will be
23297reduced by the threshold.
23298
23299@item garrote
23300Scales or nullifies coefficients - intermediary between (more) soft and
23301(less) hard thresholding.
23302@end table
23303
23304Default is garrote.
23305
23306@item nsteps
23307Number of times, the wavelet will decompose the picture. Picture can't
23308be decomposed beyond a particular point (typically, 8 for a 640x480
23309frame - as 2^9 = 512 > 480). Valid values are integers between 1 and 32. Default value is 6.
23310
23311@item percent
23312Partial of full denoising (limited coefficients shrinking), from 0 to 100. Default value is 85.
23313
23314@item planes
23315A list of the planes to process. By default all planes are processed.
23316
23317@item type
23318The threshold type the filter will use.
23319
23320It accepts the following values:
23321@table @samp
23322@item universal
23323Threshold used is same for all decompositions.
23324
23325@item bayes
23326Threshold used depends also on each decomposition coefficients.
23327@end table
23328
23329Default is universal.
23330@end table
23331
23332@section varblur
23333Apply variable blur filter by using 2nd video stream to set blur radius.
23334The 2nd stream must have the same dimensions.
23335
23336This filter accepts the following options:
23337
23338@table @option
23339@item min_r
23340Set min allowed radius. Allowed range is from 0 to 254. Default is 0.
23341@item max_r
23342Set max allowed radius. Allowed range is from 1 to 255. Default is 8.
23343@item planes
23344Set which planes to process. By default, all are used.
23345@end table
23346
23347The @code{varblur} filter also supports the @ref{framesync} options.
23348
23349@subsection Commands
23350
23351This filter supports all the above options as @ref{commands}.
23352
23353@section vectorscope
23354
23355Display 2 color component values in the two dimensional graph (which is called
23356a vectorscope).
23357
23358This filter accepts the following options:
23359
23360@table @option
23361@item mode, m
23362Set vectorscope mode.
23363
23364It accepts the following values:
23365@table @samp
23366@item gray
23367@item tint
23368Gray values are displayed on graph, higher brightness means more pixels have
23369same component color value on location in graph. This is the default mode.
23370
23371@item color
23372Gray values are displayed on graph. Surrounding pixels values which are not
23373present in video frame are drawn in gradient of 2 color components which are
23374set by option @code{x} and @code{y}. The 3rd color component is static.
23375
23376@item color2
23377Actual color components values present in video frame are displayed on graph.
23378
23379@item color3
23380Similar as color2 but higher frequency of same values @code{x} and @code{y}
23381on graph increases value of another color component, which is luminance by
23382default values of @code{x} and @code{y}.
23383
23384@item color4
23385Actual colors present in video frame are displayed on graph. If two different
23386colors map to same position on graph then color with higher value of component
23387not present in graph is picked.
23388
23389@item color5
23390Gray values are displayed on graph. Similar to @code{color} but with 3rd color
23391component picked from radial gradient.
23392@end table
23393
23394@item x
23395Set which color component will be represented on X-axis. Default is @code{1}.
23396
23397@item y
23398Set which color component will be represented on Y-axis. Default is @code{2}.
23399
23400@item intensity, i
23401Set intensity, used by modes: gray, color, color3 and color5 for increasing brightness
23402of color component which represents frequency of (X, Y) location in graph.
23403
23404@item envelope, e
23405@table @samp
23406@item none
23407No envelope, this is default.
23408
23409@item instant
23410Instant envelope, even darkest single pixel will be clearly highlighted.
23411
23412@item peak
23413Hold maximum and minimum values presented in graph over time. This way you
23414can still spot out of range values without constantly looking at vectorscope.
23415
23416@item peak+instant
23417Peak and instant envelope combined together.
23418@end table
23419
23420@item graticule, g
23421Set what kind of graticule to draw.
23422@table @samp
23423@item none
23424@item green
23425@item color
23426@item invert
23427@end table
23428
23429@item opacity, o
23430Set graticule opacity.
23431
23432@item flags, f
23433Set graticule flags.
23434
23435@table @samp
23436@item white
23437Draw graticule for white point.
23438
23439@item black
23440Draw graticule for black point.
23441
23442@item name
23443Draw color points short names.
23444@end table
23445
23446@item bgopacity, b
23447Set background opacity.
23448
23449@item lthreshold, l
23450Set low threshold for color component not represented on X or Y axis.
23451Values lower than this value will be ignored. Default is 0.
23452Note this value is multiplied with actual max possible value one pixel component
23453can have. So for 8-bit input and low threshold value of 0.1 actual threshold
23454is 0.1 * 255 = 25.
23455
23456@item hthreshold, h
23457Set high threshold for color component not represented on X or Y axis.
23458Values higher than this value will be ignored. Default is 1.
23459Note this value is multiplied with actual max possible value one pixel component
23460can have. So for 8-bit input and high threshold value of 0.9 actual threshold
23461is 0.9 * 255 = 230.
23462
23463@item colorspace, c
23464Set what kind of colorspace to use when drawing graticule.
23465@table @samp
23466@item auto
23467@item 601
23468@item 709
23469@end table
23470Default is auto.
23471
23472@item tint0, t0
23473@item tint1, t1
23474Set color tint for gray/tint vectorscope mode. By default both options are zero.
23475This means no tint, and output will remain gray.
23476@end table
23477
23478@anchor{vidstabdetect}
23479@section vidstabdetect
23480
23481Analyze video stabilization/deshaking. Perform pass 1 of 2, see
23482@ref{vidstabtransform} for pass 2.
23483
23484This filter generates a file with relative translation and rotation
23485transform information about subsequent frames, which is then used by
23486the @ref{vidstabtransform} filter.
23487
23488To enable compilation of this filter you need to configure FFmpeg with
23489@code{--enable-libvidstab}.
23490
23491This filter accepts the following options:
23492
23493@table @option
23494@item result
23495Set the path to the file used to write the transforms information.
23496Default value is @file{transforms.trf}.
23497
23498@item shakiness
23499Set how shaky the video is and how quick the camera is. It accepts an
23500integer in the range 1-10, a value of 1 means little shakiness, a
23501value of 10 means strong shakiness. Default value is 5.
23502
23503@item accuracy
23504Set the accuracy of the detection process. It must be a value in the
23505range 1-15. A value of 1 means low accuracy, a value of 15 means high
23506accuracy. Default value is 15.
23507
23508@item stepsize
23509Set stepsize of the search process. The region around minimum is
23510scanned with 1 pixel resolution. Default value is 6.
23511
23512@item mincontrast
23513Set minimum contrast. Below this value a local measurement field is
23514discarded. Must be a floating point value in the range 0-1. Default
23515value is 0.3.
23516
23517@item tripod
23518Set reference frame number for tripod mode.
23519
23520If enabled, the motion of the frames is compared to a reference frame
23521in the filtered stream, identified by the specified number. The idea
23522is to compensate all movements in a more-or-less static scene and keep
23523the camera view absolutely still.
23524
23525If set to 0, it is disabled. The frames are counted starting from 1.
23526
23527@item show
23528Show fields and transforms in the resulting frames. It accepts an
23529integer in the range 0-2. Default value is 0, which disables any
23530visualization.
23531@end table
23532
23533@subsection Examples
23534
23535@itemize
23536@item
23537Use default values:
23538@example
23539vidstabdetect
23540@end example
23541
23542@item
23543Analyze strongly shaky movie and put the results in file
23544@file{mytransforms.trf}:
23545@example
23546vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
23547@end example
23548
23549@item
23550Visualize the result of internal transformations in the resulting
23551video:
23552@example
23553vidstabdetect=show=1
23554@end example
23555
23556@item
23557Analyze a video with medium shakiness using @command{ffmpeg}:
23558@example
23559ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
23560@end example
23561@end itemize
23562
23563@anchor{vidstabtransform}
23564@section vidstabtransform
23565
23566Video stabilization/deshaking: pass 2 of 2,
23567see @ref{vidstabdetect} for pass 1.
23568
23569Read a file with transform information for each frame and
23570apply/compensate them. Together with the @ref{vidstabdetect}
23571filter this can be used to deshake videos. See also
23572@url{http://public.hronopik.de/vid.stab}. It is important to also use
23573the @ref{unsharp} filter, see below.
23574
23575To enable compilation of this filter you need to configure FFmpeg with
23576@code{--enable-libvidstab}.
23577
23578@subsection Options
23579
23580@table @option
23581@item input
23582Set path to the file used to read the transforms. Default value is
23583@file{transforms.trf}.
23584
23585@item smoothing
23586Set the number of frames (value*2 + 1) used for lowpass filtering the
23587camera movements. Default value is 10.
23588
23589For example a number of 10 means that 21 frames are used (10 in the
23590past and 10 in the future) to smoothen the motion in the video. A
23591larger value leads to a smoother video, but limits the acceleration of
23592the camera (pan/tilt movements). 0 is a special case where a static
23593camera is simulated.
23594
23595@item optalgo
23596Set the camera path optimization algorithm.
23597
23598Accepted values are:
23599@table @samp
23600@item gauss
23601gaussian kernel low-pass filter on camera motion (default)
23602@item avg
23603averaging on transformations
23604@end table
23605
23606@item maxshift
23607Set maximal number of pixels to translate frames. Default value is -1,
23608meaning no limit.
23609
23610@item maxangle
23611Set maximal angle in radians (degree*PI/180) to rotate frames. Default
23612value is -1, meaning no limit.
23613
23614@item crop
23615Specify how to deal with borders that may be visible due to movement
23616compensation.
23617
23618Available values are:
23619@table @samp
23620@item keep
23621keep image information from previous frame (default)
23622@item black
23623fill the border black
23624@end table
23625
23626@item invert
23627Invert transforms if set to 1. Default value is 0.
23628
23629@item relative
23630Consider transforms as relative to previous frame if set to 1,
23631absolute if set to 0. Default value is 0.
23632
23633@item zoom
23634Set percentage to zoom. A positive value will result in a zoom-in
23635effect, a negative value in a zoom-out effect. Default value is 0 (no
23636zoom).
23637
23638@item optzoom
23639Set optimal zooming to avoid borders.
23640
23641Accepted values are:
23642@table @samp
23643@item 0
23644disabled
23645@item 1
23646optimal static zoom value is determined (only very strong movements
23647will lead to visible borders) (default)
23648@item 2
23649optimal adaptive zoom value is determined (no borders will be
23650visible), see @option{zoomspeed}
23651@end table
23652
23653Note that the value given at zoom is added to the one calculated here.
23654
23655@item zoomspeed
23656Set percent to zoom maximally each frame (enabled when
23657@option{optzoom} is set to 2). Range is from 0 to 5, default value is
236580.25.
23659
23660@item interpol
23661Specify type of interpolation.
23662
23663Available values are:
23664@table @samp
23665@item no
23666no interpolation
23667@item linear
23668linear only horizontal
23669@item bilinear
23670linear in both directions (default)
23671@item bicubic
23672cubic in both directions (slow)
23673@end table
23674
23675@item tripod
23676Enable virtual tripod mode if set to 1, which is equivalent to
23677@code{relative=0:smoothing=0}. Default value is 0.
23678
23679Use also @code{tripod} option of @ref{vidstabdetect}.
23680
23681@item debug
23682Increase log verbosity if set to 1. Also the detected global motions
23683are written to the temporary file @file{global_motions.trf}. Default
23684value is 0.
23685@end table
23686
23687@subsection Examples
23688
23689@itemize
23690@item
23691Use @command{ffmpeg} for a typical stabilization with default values:
23692@example
23693ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
23694@end example
23695
23696Note the use of the @ref{unsharp} filter which is always recommended.
23697
23698@item
23699Zoom in a bit more and load transform data from a given file:
23700@example
23701vidstabtransform=zoom=5:input="mytransforms.trf"
23702@end example
23703
23704@item
23705Smoothen the video even more:
23706@example
23707vidstabtransform=smoothing=30
23708@end example
23709@end itemize
23710
23711@section vflip
23712
23713Flip the input video vertically.
23714
23715For example, to vertically flip a video with @command{ffmpeg}:
23716@example
23717ffmpeg -i in.avi -vf "vflip" out.avi
23718@end example
23719
23720@section vfrdet
23721
23722Detect variable frame rate video.
23723
23724This filter tries to detect if the input is variable or constant frame rate.
23725
23726At end it will output number of frames detected as having variable delta pts,
23727and ones with constant delta pts.
23728If there was frames with variable delta, than it will also show min, max and
23729average delta encountered.
23730
23731@section vibrance
23732
23733Boost or alter saturation.
23734
23735The filter accepts the following options:
23736@table @option
23737@item intensity
23738Set strength of boost if positive value or strength of alter if negative value.
23739Default is 0. Allowed range is from -2 to 2.
23740
23741@item rbal
23742Set the red balance. Default is 1. Allowed range is from -10 to 10.
23743
23744@item gbal
23745Set the green balance. Default is 1. Allowed range is from -10 to 10.
23746
23747@item bbal
23748Set the blue balance. Default is 1. Allowed range is from -10 to 10.
23749
23750@item rlum
23751Set the red luma coefficient.
23752
23753@item glum
23754Set the green luma coefficient.
23755
23756@item blum
23757Set the blue luma coefficient.
23758
23759@item alternate
23760If @code{intensity} is negative and this is set to 1, colors will change,
23761otherwise colors will be less saturated, more towards gray.
23762@end table
23763
23764@subsection Commands
23765
23766This filter supports the all above options as @ref{commands}.
23767
23768@section vif
23769
23770Obtain the average VIF (Visual Information Fidelity) between two input videos.
23771
23772This filter takes two input videos.
23773
23774Both input videos must have the same resolution and pixel format for
23775this filter to work correctly. Also it assumes that both inputs
23776have the same number of frames, which are compared one by one.
23777
23778The obtained average VIF score is printed through the logging system.
23779
23780The filter stores the calculated VIF score of each frame.
23781
23782In the below example the input file @file{main.mpg} being processed is compared
23783with the reference file @file{ref.mpg}.
23784
23785@example
23786ffmpeg -i main.mpg -i ref.mpg -lavfi vif -f null -
23787@end example
23788
23789@anchor{vignette}
23790@section vignette
23791
23792Make or reverse a natural vignetting effect.
23793
23794The filter accepts the following options:
23795
23796@table @option
23797@item angle, a
23798Set lens angle expression as a number of radians.
23799
23800The value is clipped in the @code{[0,PI/2]} range.
23801
23802Default value: @code{"PI/5"}
23803
23804@item x0
23805@item y0
23806Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
23807by default.
23808
23809@item mode
23810Set forward/backward mode.
23811
23812Available modes are:
23813@table @samp
23814@item forward
23815The larger the distance from the central point, the darker the image becomes.
23816
23817@item backward
23818The larger the distance from the central point, the brighter the image becomes.
23819This can be used to reverse a vignette effect, though there is no automatic
23820detection to extract the lens @option{angle} and other settings (yet). It can
23821also be used to create a burning effect.
23822@end table
23823
23824Default value is @samp{forward}.
23825
23826@item eval
23827Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
23828
23829It accepts the following values:
23830@table @samp
23831@item init
23832Evaluate expressions only once during the filter initialization.
23833
23834@item frame
23835Evaluate expressions for each incoming frame. This is way slower than the
23836@samp{init} mode since it requires all the scalers to be re-computed, but it
23837allows advanced dynamic expressions.
23838@end table
23839
23840Default value is @samp{init}.
23841
23842@item dither
23843Set dithering to reduce the circular banding effects. Default is @code{1}
23844(enabled).
23845
23846@item aspect
23847Set vignette aspect. This setting allows one to adjust the shape of the vignette.
23848Setting this value to the SAR of the input will make a rectangular vignetting
23849following the dimensions of the video.
23850
23851Default is @code{1/1}.
23852@end table
23853
23854@subsection Expressions
23855
23856The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
23857following parameters.
23858
23859@table @option
23860@item w
23861@item h
23862input width and height
23863
23864@item n
23865the number of input frame, starting from 0
23866
23867@item pts
23868the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
23869@var{TB} units, NAN if undefined
23870
23871@item r
23872frame rate of the input video, NAN if the input frame rate is unknown
23873
23874@item t
23875the PTS (Presentation TimeStamp) of the filtered video frame,
23876expressed in seconds, NAN if undefined
23877
23878@item tb
23879time base of the input video
23880@end table
23881
23882
23883@subsection Examples
23884
23885@itemize
23886@item
23887Apply simple strong vignetting effect:
23888@example
23889vignette=PI/4
23890@end example
23891
23892@item
23893Make a flickering vignetting:
23894@example
23895vignette='PI/4+random(1)*PI/50':eval=frame
23896@end example
23897
23898@end itemize
23899
23900@section vmafmotion
23901
23902Obtain the average VMAF motion score of a video.
23903It is one of the component metrics of VMAF.
23904
23905The obtained average motion score is printed through the logging system.
23906
23907The filter accepts the following options:
23908
23909@table @option
23910@item stats_file
23911If specified, the filter will use the named file to save the motion score of
23912each frame with respect to the previous frame.
23913When filename equals "-" the data is sent to standard output.
23914@end table
23915
23916Example:
23917@example
23918ffmpeg -i ref.mpg -vf vmafmotion -f null -
23919@end example
23920
23921@section vstack
23922Stack input videos vertically.
23923
23924All streams must be of same pixel format and of same width.
23925
23926Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
23927to create same output.
23928
23929The filter accepts the following options:
23930
23931@table @option
23932@item inputs
23933Set number of input streams. Default is 2.
23934
23935@item shortest
23936If set to 1, force the output to terminate when the shortest input
23937terminates. Default value is 0.
23938@end table
23939
23940@section w3fdif
23941
23942Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
23943Deinterlacing Filter").
23944
23945Based on the process described by Martin Weston for BBC R&D, and
23946implemented based on the de-interlace algorithm written by Jim
23947Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
23948uses filter coefficients calculated by BBC R&D.
23949
23950This filter uses field-dominance information in frame to decide which
23951of each pair of fields to place first in the output.
23952If it gets it wrong use @ref{setfield} filter before @code{w3fdif} filter.
23953
23954There are two sets of filter coefficients, so called "simple"
23955and "complex". Which set of filter coefficients is used can
23956be set by passing an optional parameter:
23957
23958@table @option
23959@item filter
23960Set the interlacing filter coefficients. Accepts one of the following values:
23961
23962@table @samp
23963@item simple
23964Simple filter coefficient set.
23965@item complex
23966More-complex filter coefficient set.
23967@end table
23968Default value is @samp{complex}.
23969
23970@item mode
23971The interlacing mode to adopt. It accepts one of the following values:
23972
23973@table @option
23974@item frame
23975Output one frame for each frame.
23976@item field
23977Output one frame for each field.
23978@end table
23979
23980The default value is @code{field}.
23981
23982@item parity
23983The picture field parity assumed for the input interlaced video. It accepts one
23984of the following values:
23985
23986@table @option
23987@item tff
23988Assume the top field is first.
23989@item bff
23990Assume the bottom field is first.
23991@item auto
23992Enable automatic detection of field parity.
23993@end table
23994
23995The default value is @code{auto}.
23996If the interlacing is unknown or the decoder does not export this information,
23997top field first will be assumed.
23998
23999@item deint
24000Specify which frames to deinterlace. Accepts one of the following values:
24001
24002@table @samp
24003@item all
24004Deinterlace all frames,
24005@item interlaced
24006Only deinterlace frames marked as interlaced.
24007@end table
24008
24009Default value is @samp{all}.
24010@end table
24011
24012@subsection Commands
24013This filter supports same @ref{commands} as options.
24014
24015@section waveform
24016Video waveform monitor.
24017
24018The waveform monitor plots color component intensity. By default luminance
24019only. Each column of the waveform corresponds to a column of pixels in the
24020source video.
24021
24022It accepts the following options:
24023
24024@table @option
24025@item mode, m
24026Can be either @code{row}, or @code{column}. Default is @code{column}.
24027In row mode, the graph on the left side represents color component value 0 and
24028the right side represents value = 255. In column mode, the top side represents
24029color component value = 0 and bottom side represents value = 255.
24030
24031@item intensity, i
24032Set intensity. Smaller values are useful to find out how many values of the same
24033luminance are distributed across input rows/columns.
24034Default value is @code{0.04}. Allowed range is [0, 1].
24035
24036@item mirror, r
24037Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored.
24038In mirrored mode, higher values will be represented on the left
24039side for @code{row} mode and at the top for @code{column} mode. Default is
24040@code{1} (mirrored).
24041
24042@item display, d
24043Set display mode.
24044It accepts the following values:
24045@table @samp
24046@item overlay
24047Presents information identical to that in the @code{parade}, except
24048that the graphs representing color components are superimposed directly
24049over one another.
24050
24051This display mode makes it easier to spot relative differences or similarities
24052in overlapping areas of the color components that are supposed to be identical,
24053such as neutral whites, grays, or blacks.
24054
24055@item stack
24056Display separate graph for the color components side by side in
24057@code{row} mode or one below the other in @code{column} mode.
24058
24059@item parade
24060Display separate graph for the color components side by side in
24061@code{column} mode or one below the other in @code{row} mode.
24062
24063Using this display mode makes it easy to spot color casts in the highlights
24064and shadows of an image, by comparing the contours of the top and the bottom
24065graphs of each waveform. Since whites, grays, and blacks are characterized
24066by exactly equal amounts of red, green, and blue, neutral areas of the picture
24067should display three waveforms of roughly equal width/height. If not, the
24068correction is easy to perform by making level adjustments the three waveforms.
24069@end table
24070Default is @code{stack}.
24071
24072@item components, c
24073Set which color components to display. Default is 1, which means only luminance
24074or red color component if input is in RGB colorspace. If is set for example to
240757 it will display all 3 (if) available color components.
24076
24077@item envelope, e
24078@table @samp
24079@item none
24080No envelope, this is default.
24081
24082@item instant
24083Instant envelope, minimum and maximum values presented in graph will be easily
24084visible even with small @code{step} value.
24085
24086@item peak
24087Hold minimum and maximum values presented in graph across time. This way you
24088can still spot out of range values without constantly looking at waveforms.
24089
24090@item peak+instant
24091Peak and instant envelope combined together.
24092@end table
24093
24094@item filter, f
24095@table @samp
24096@item lowpass
24097No filtering, this is default.
24098
24099@item flat
24100Luma and chroma combined together.
24101
24102@item aflat
24103Similar as above, but shows difference between blue and red chroma.
24104
24105@item xflat
24106Similar as above, but use different colors.
24107
24108@item yflat
24109Similar as above, but again with different colors.
24110
24111@item chroma
24112Displays only chroma.
24113
24114@item color
24115Displays actual color value on waveform.
24116
24117@item acolor
24118Similar as above, but with luma showing frequency of chroma values.
24119@end table
24120
24121@item graticule, g
24122Set which graticule to display.
24123
24124@table @samp
24125@item none
24126Do not display graticule.
24127
24128@item green
24129Display green graticule showing legal broadcast ranges.
24130
24131@item orange
24132Display orange graticule showing legal broadcast ranges.
24133
24134@item invert
24135Display invert graticule showing legal broadcast ranges.
24136@end table
24137
24138@item opacity, o
24139Set graticule opacity.
24140
24141@item flags, fl
24142Set graticule flags.
24143
24144@table @samp
24145@item numbers
24146Draw numbers above lines. By default enabled.
24147
24148@item dots
24149Draw dots instead of lines.
24150@end table
24151
24152@item scale, s
24153Set scale used for displaying graticule.
24154
24155@table @samp
24156@item digital
24157@item millivolts
24158@item ire
24159@end table
24160Default is digital.
24161
24162@item bgopacity, b
24163Set background opacity.
24164
24165@item tint0, t0
24166@item tint1, t1
24167Set tint for output.
24168Only used with lowpass filter and when display is not overlay and input
24169pixel formats are not RGB.
24170
24171@item fitmode, fm
24172Set sample aspect ratio of video output frames.
24173Can be used to configure waveform so it is not
24174streched too much in one of directions.
24175
24176@table @samp
24177@item none
24178Set sample aspect ration to 1/1.
24179@item size
24180Set sample aspect ratio to match input size of video
24181@end table
24182Default is @samp{none}.
24183@end table
24184
24185@section weave, doubleweave
24186
24187The @code{weave} takes a field-based video input and join
24188each two sequential fields into single frame, producing a new double
24189height clip with half the frame rate and half the frame count.
24190
24191The @code{doubleweave} works same as @code{weave} but without
24192halving frame rate and frame count.
24193
24194It accepts the following option:
24195
24196@table @option
24197@item first_field
24198Set first field. Available values are:
24199
24200@table @samp
24201@item top, t
24202Set the frame as top-field-first.
24203
24204@item bottom, b
24205Set the frame as bottom-field-first.
24206@end table
24207@end table
24208
24209@subsection Examples
24210
24211@itemize
24212@item
24213Interlace video using @ref{select} and @ref{separatefields} filter:
24214@example
24215separatefields,select=eq(mod(n,4),0)+eq(mod(n,4),3),weave
24216@end example
24217@end itemize
24218
24219@section xbr
24220Apply the xBR high-quality magnification filter which is designed for pixel
24221art. It follows a set of edge-detection rules, see
24222@url{https://forums.libretro.com/t/xbr-algorithm-tutorial/123}.
24223
24224It accepts the following option:
24225
24226@table @option
24227@item n
24228Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
24229@code{3xBR} and @code{4} for @code{4xBR}.
24230Default is @code{3}.
24231@end table
24232
24233@section xcorrelate
24234Apply normalized cross-correlation between first and second input video stream.
24235
24236Second input video stream dimensions must be lower than first input video stream.
24237
24238The filter accepts the following options:
24239
24240@table @option
24241@item planes
24242Set which planes to process.
24243
24244@item secondary
24245Set which secondary video frames will be processed from second input video stream,
24246can be @var{first} or @var{all}. Default is @var{all}.
24247@end table
24248
24249The @code{xcorrelate} filter also supports the @ref{framesync} options.
24250
24251@section xfade
24252
24253Apply cross fade from one input video stream to another input video stream.
24254The cross fade is applied for specified duration.
24255
24256Both inputs must be constant frame-rate and have the same resolution, pixel format,
24257frame rate and timebase.
24258
24259The filter accepts the following options:
24260
24261@table @option
24262@item transition
24263Set one of available transition effects:
24264
24265@table @samp
24266@item custom
24267@item fade
24268@item wipeleft
24269@item wiperight
24270@item wipeup
24271@item wipedown
24272@item slideleft
24273@item slideright
24274@item slideup
24275@item slidedown
24276@item circlecrop
24277@item rectcrop
24278@item distance
24279@item fadeblack
24280@item fadewhite
24281@item radial
24282@item smoothleft
24283@item smoothright
24284@item smoothup
24285@item smoothdown
24286@item circleopen
24287@item circleclose
24288@item vertopen
24289@item vertclose
24290@item horzopen
24291@item horzclose
24292@item dissolve
24293@item pixelize
24294@item diagtl
24295@item diagtr
24296@item diagbl
24297@item diagbr
24298@item hlslice
24299@item hrslice
24300@item vuslice
24301@item vdslice
24302@item hblur
24303@item fadegrays
24304@item wipetl
24305@item wipetr
24306@item wipebl
24307@item wipebr
24308@item squeezeh
24309@item squeezev
24310@item zoomin
24311@item fadefast
24312@item fadeslow
24313@end table
24314Default transition effect is fade.
24315
24316@item duration
24317Set cross fade duration in seconds.
24318Range is 0 to 60 seconds.
24319Default duration is 1 second.
24320
24321@item offset
24322Set cross fade start relative to first input stream in seconds.
24323Default offset is 0.
24324
24325@item expr
24326Set expression for custom transition effect.
24327
24328The expressions can use the following variables and functions:
24329
24330@table @option
24331@item X
24332@item Y
24333The coordinates of the current sample.
24334
24335@item W
24336@item H
24337The width and height of the image.
24338
24339@item P
24340Progress of transition effect.
24341
24342@item PLANE
24343Currently processed plane.
24344
24345@item A
24346Return value of first input at current location and plane.
24347
24348@item B
24349Return value of second input at current location and plane.
24350
24351@item a0(x, y)
24352@item a1(x, y)
24353@item a2(x, y)
24354@item a3(x, y)
24355Return the value of the pixel at location (@var{x},@var{y}) of the
24356first/second/third/fourth component of first input.
24357
24358@item b0(x, y)
24359@item b1(x, y)
24360@item b2(x, y)
24361@item b3(x, y)
24362Return the value of the pixel at location (@var{x},@var{y}) of the
24363first/second/third/fourth component of second input.
24364@end table
24365@end table
24366
24367@subsection Examples
24368
24369@itemize
24370@item
24371Cross fade from one input video to another input video, with fade transition and duration of transition
24372of 2 seconds starting at offset of 5 seconds:
24373@example
24374ffmpeg -i first.mp4 -i second.mp4 -filter_complex xfade=transition=fade:duration=2:offset=5 output.mp4
24375@end example
24376@end itemize
24377
24378@section xmedian
24379Pick median pixels from several input videos.
24380
24381The filter accepts the following options:
24382
24383@table @option
24384@item inputs
24385Set number of inputs.
24386Default is 3. Allowed range is from 3 to 255.
24387If number of inputs is even number, than result will be mean value between two median values.
24388
24389@item planes
24390Set which planes to filter. Default value is @code{15}, by which all planes are processed.
24391
24392@item percentile
24393Set median percentile. Default value is @code{0.5}.
24394Default value of @code{0.5} will pick always median values, while @code{0} will pick
24395minimum values, and @code{1} maximum values.
24396@end table
24397
24398@subsection Commands
24399
24400This filter supports all above options as @ref{commands}, excluding option @code{inputs}.
24401
24402@section xstack
24403Stack video inputs into custom layout.
24404
24405All streams must be of same pixel format.
24406
24407The filter accepts the following options:
24408
24409@table @option
24410@item inputs
24411Set number of input streams. Default is 2.
24412
24413@item layout
24414Specify layout of inputs.
24415This option requires the desired layout configuration to be explicitly set by the user.
24416This sets position of each video input in output. Each input
24417is separated by '|'.
24418The first number represents the column, and the second number represents the row.
24419Numbers start at 0 and are separated by '_'. Optionally one can use wX and hX,
24420where X is video input from which to take width or height.
24421Multiple values can be used when separated by '+'. In such
24422case values are summed together.
24423
24424Note that if inputs are of different sizes gaps may appear, as not all of
24425the output video frame will be filled. Similarly, videos can overlap each
24426other if their position doesn't leave enough space for the full frame of
24427adjoining videos.
24428
24429For 2 inputs, a default layout of @code{0_0|w0_0} (equivalent to
24430@code{grid=2x1}) is set. In all other cases, a layout or a grid must be set by
24431the user. Either @code{grid} or @code{layout} can be specified at a time.
24432Specifying both will result in an error.
24433
24434@item grid
24435Specify a fixed size grid of inputs.
24436This option is used to create a fixed size grid of the input streams. Set the
24437grid size in the form @code{COLUMNSxROWS}. There must be @code{ROWS * COLUMNS}
24438input streams and they will be arranged as a grid with @code{ROWS} rows and
24439@code{COLUMNS} columns. When using this option, each input stream within a row
24440must have the same height and all the rows must have the same width.
24441
24442If @code{grid} is set, then @code{inputs} option is ignored and is implicitly
24443set to @code{ROWS * COLUMNS}.
24444
24445For 2 inputs, a default grid of @code{2x1} (equivalent to
24446@code{layout=0_0|w0_0}) is set. In all other cases, a layout or a grid must be
24447set by the user. Either @code{grid} or @code{layout} can be specified at a time.
24448Specifying both will result in an error.
24449
24450@item shortest
24451If set to 1, force the output to terminate when the shortest input
24452terminates. Default value is 0.
24453
24454@item fill
24455If set to valid color, all unused pixels will be filled with that color.
24456By default fill is set to none, so it is disabled.
24457@end table
24458
24459@subsection Examples
24460
24461@itemize
24462@item
24463Display 4 inputs into 2x2 grid.
24464
24465Layout:
24466@example
24467input1(0, 0)  | input3(w0, 0)
24468input2(0, h0) | input4(w0, h0)
24469@end example
24470
24471@example
24472xstack=inputs=4:layout=0_0|0_h0|w0_0|w0_h0
24473@end example
24474
24475Note that if inputs are of different sizes, gaps or overlaps may occur.
24476
24477@item
24478Display 4 inputs into 1x4 grid.
24479
24480Layout:
24481@example
24482input1(0, 0)
24483input2(0, h0)
24484input3(0, h0+h1)
24485input4(0, h0+h1+h2)
24486@end example
24487
24488@example
24489xstack=inputs=4:layout=0_0|0_h0|0_h0+h1|0_h0+h1+h2
24490@end example
24491
24492Note that if inputs are of different widths, unused space will appear.
24493
24494@item
24495Display 9 inputs into 3x3 grid.
24496
24497Layout:
24498@example
24499input1(0, 0)       | input4(w0, 0)      | input7(w0+w3, 0)
24500input2(0, h0)      | input5(w0, h0)     | input8(w0+w3, h0)
24501input3(0, h0+h1)   | input6(w0, h0+h1)  | input9(w0+w3, h0+h1)
24502@end example
24503
24504@example
24505xstack=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
24506@end example
24507
24508Note that if inputs are of different sizes, gaps or overlaps may occur.
24509
24510@item
24511Display 16 inputs into 4x4 grid.
24512
24513Layout:
24514@example
24515input1(0, 0)       | input5(w0, 0)       | input9 (w0+w4, 0)       | input13(w0+w4+w8, 0)
24516input2(0, h0)      | input6(w0, h0)      | input10(w0+w4, h0)      | input14(w0+w4+w8, h0)
24517input3(0, h0+h1)   | input7(w0, h0+h1)   | input11(w0+w4, h0+h1)   | input15(w0+w4+w8, h0+h1)
24518input4(0, h0+h1+h2)| input8(w0, h0+h1+h2)| input12(w0+w4, h0+h1+h2)| input16(w0+w4+w8, h0+h1+h2)
24519@end example
24520
24521@example
24522xstack=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|
24523w0+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
24524@end example
24525
24526Note that if inputs are of different sizes, gaps or overlaps may occur.
24527
24528@end itemize
24529
24530@anchor{yadif}
24531@section yadif
24532
24533Deinterlace the input video ("yadif" means "yet another deinterlacing
24534filter").
24535
24536It accepts the following parameters:
24537
24538
24539@table @option
24540
24541@item mode
24542The interlacing mode to adopt. It accepts one of the following values:
24543
24544@table @option
24545@item 0, send_frame
24546Output one frame for each frame.
24547@item 1, send_field
24548Output one frame for each field.
24549@item 2, send_frame_nospatial
24550Like @code{send_frame}, but it skips the spatial interlacing check.
24551@item 3, send_field_nospatial
24552Like @code{send_field}, but it skips the spatial interlacing check.
24553@end table
24554
24555The default value is @code{send_frame}.
24556
24557@item parity
24558The picture field parity assumed for the input interlaced video. It accepts one
24559of the following values:
24560
24561@table @option
24562@item 0, tff
24563Assume the top field is first.
24564@item 1, bff
24565Assume the bottom field is first.
24566@item -1, auto
24567Enable automatic detection of field parity.
24568@end table
24569
24570The default value is @code{auto}.
24571If the interlacing is unknown or the decoder does not export this information,
24572top field first will be assumed.
24573
24574@item deint
24575Specify which frames to deinterlace. Accepts one of the following
24576values:
24577
24578@table @option
24579@item 0, all
24580Deinterlace all frames.
24581@item 1, interlaced
24582Only deinterlace frames marked as interlaced.
24583@end table
24584
24585The default value is @code{all}.
24586@end table
24587
24588@section yadif_cuda
24589
24590Deinterlace the input video using the @ref{yadif} algorithm, but implemented
24591in CUDA so that it can work as part of a GPU accelerated pipeline with nvdec
24592and/or nvenc.
24593
24594It accepts the following parameters:
24595
24596
24597@table @option
24598
24599@item mode
24600The interlacing mode to adopt. It accepts one of the following values:
24601
24602@table @option
24603@item 0, send_frame
24604Output one frame for each frame.
24605@item 1, send_field
24606Output one frame for each field.
24607@item 2, send_frame_nospatial
24608Like @code{send_frame}, but it skips the spatial interlacing check.
24609@item 3, send_field_nospatial
24610Like @code{send_field}, but it skips the spatial interlacing check.
24611@end table
24612
24613The default value is @code{send_frame}.
24614
24615@item parity
24616The picture field parity assumed for the input interlaced video. It accepts one
24617of the following values:
24618
24619@table @option
24620@item 0, tff
24621Assume the top field is first.
24622@item 1, bff
24623Assume the bottom field is first.
24624@item -1, auto
24625Enable automatic detection of field parity.
24626@end table
24627
24628The default value is @code{auto}.
24629If the interlacing is unknown or the decoder does not export this information,
24630top field first will be assumed.
24631
24632@item deint
24633Specify which frames to deinterlace. Accepts one of the following
24634values:
24635
24636@table @option
24637@item 0, all
24638Deinterlace all frames.
24639@item 1, interlaced
24640Only deinterlace frames marked as interlaced.
24641@end table
24642
24643The default value is @code{all}.
24644@end table
24645
24646@section yaepblur
24647
24648Apply blur filter while preserving edges ("yaepblur" means "yet another edge preserving blur filter").
24649The algorithm is described in
24650"J. S. Lee, Digital image enhancement and noise filtering by use of local statistics, IEEE Trans. Pattern Anal. Mach. Intell. PAMI-2, 1980."
24651
24652It accepts the following parameters:
24653
24654@table @option
24655@item radius, r
24656Set the window radius. Default value is 3.
24657
24658@item planes, p
24659Set which planes to filter. Default is only the first plane.
24660
24661@item sigma, s
24662Set blur strength. Default value is 128.
24663@end table
24664
24665@subsection Commands
24666This filter supports same @ref{commands} as options.
24667
24668@section zoompan
24669
24670Apply Zoom & Pan effect.
24671
24672This filter accepts the following options:
24673
24674@table @option
24675@item zoom, z
24676Set the zoom expression. Range is 1-10. Default is 1.
24677
24678@item x
24679@item y
24680Set the x and y expression. Default is 0.
24681
24682@item d
24683Set the duration expression in number of frames.
24684This sets for how many number of frames effect will last for
24685single input image. Default is 90.
24686
24687@item s
24688Set the output image size, default is 'hd720'.
24689
24690@item fps
24691Set the output frame rate, default is '25'.
24692@end table
24693
24694Each expression can contain the following constants:
24695
24696@table @option
24697@item in_w, iw
24698Input width.
24699
24700@item in_h, ih
24701Input height.
24702
24703@item out_w, ow
24704Output width.
24705
24706@item out_h, oh
24707Output height.
24708
24709@item in
24710Input frame count.
24711
24712@item on
24713Output frame count.
24714
24715@item in_time, it
24716The input timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
24717
24718@item out_time, time, ot
24719The output timestamp expressed in seconds.
24720
24721@item x
24722@item y
24723Last calculated 'x' and 'y' position from 'x' and 'y' expression
24724for current input frame.
24725
24726@item px
24727@item py
24728'x' and 'y' of last output frame of previous input frame or 0 when there was
24729not yet such frame (first input frame).
24730
24731@item zoom
24732Last calculated zoom from 'z' expression for current input frame.
24733
24734@item pzoom
24735Last calculated zoom of last output frame of previous input frame.
24736
24737@item duration
24738Number of output frames for current input frame. Calculated from 'd' expression
24739for each input frame.
24740
24741@item pduration
24742number of output frames created for previous input frame
24743
24744@item a
24745Rational number: input width / input height
24746
24747@item sar
24748sample aspect ratio
24749
24750@item dar
24751display aspect ratio
24752
24753@end table
24754
24755@subsection Examples
24756
24757@itemize
24758@item
24759Zoom in up to 1.5x and pan at same time to some spot near center of picture:
24760@example
24761zoompan=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
24762@end example
24763
24764@item
24765Zoom in up to 1.5x and pan always at center of picture:
24766@example
24767zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
24768@end example
24769
24770@item
24771Same as above but without pausing:
24772@example
24773zoompan=z='min(max(zoom,pzoom)+0.0015,1.5)':d=1:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
24774@end example
24775
24776@item
24777Zoom in 2x into center of picture only for the first second of the input video:
24778@example
24779zoompan=z='if(between(in_time,0,1),2,1)':d=1:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
24780@end example
24781
24782@end itemize
24783
24784@anchor{zscale}
24785@section zscale
24786Scale (resize) the input video, using the z.lib library:
24787@url{https://github.com/sekrit-twc/zimg}. To enable compilation of this
24788filter, you need to configure FFmpeg with @code{--enable-libzimg}.
24789
24790The zscale filter forces the output display aspect ratio to be the same
24791as the input, by changing the output sample aspect ratio.
24792
24793If the input image format is different from the format requested by
24794the next filter, the zscale filter will convert the input to the
24795requested format.
24796
24797@subsection Options
24798The filter accepts the following options.
24799
24800@table @option
24801@item width, w
24802@item height, h
24803Set the output video dimension expression. Default value is the input
24804dimension.
24805
24806If the @var{width} or @var{w} value is 0, the input width is used for
24807the output. If the @var{height} or @var{h} value is 0, the input height
24808is used for the output.
24809
24810If one and only one of the values is -n with n >= 1, the zscale filter
24811will use a value that maintains the aspect ratio of the input image,
24812calculated from the other specified dimension. After that it will,
24813however, make sure that the calculated dimension is divisible by n and
24814adjust the value if necessary.
24815
24816If both values are -n with n >= 1, the behavior will be identical to
24817both values being set to 0 as previously detailed.
24818
24819See below for the list of accepted constants for use in the dimension
24820expression.
24821
24822@item size, s
24823Set the video size. For the syntax of this option, check the
24824@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
24825
24826@item dither, d
24827Set the dither type.
24828
24829Possible values are:
24830@table @var
24831@item none
24832@item ordered
24833@item random
24834@item error_diffusion
24835@end table
24836
24837Default is none.
24838
24839@item filter, f
24840Set the resize filter type.
24841
24842Possible values are:
24843@table @var
24844@item point
24845@item bilinear
24846@item bicubic
24847@item spline16
24848@item spline36
24849@item lanczos
24850@end table
24851
24852Default is bilinear.
24853
24854@item range, r
24855Set the color range.
24856
24857Possible values are:
24858@table @var
24859@item input
24860@item limited
24861@item full
24862@end table
24863
24864Default is same as input.
24865
24866@item primaries, p
24867Set the color primaries.
24868
24869Possible values are:
24870@table @var
24871@item input
24872@item 709
24873@item unspecified
24874@item 170m
24875@item 240m
24876@item 2020
24877@end table
24878
24879Default is same as input.
24880
24881@item transfer, t
24882Set the transfer characteristics.
24883
24884Possible values are:
24885@table @var
24886@item input
24887@item 709
24888@item unspecified
24889@item 601
24890@item linear
24891@item 2020_10
24892@item 2020_12
24893@item smpte2084
24894@item iec61966-2-1
24895@item arib-std-b67
24896@end table
24897
24898Default is same as input.
24899
24900@item matrix, m
24901Set the colorspace matrix.
24902
24903Possible value are:
24904@table @var
24905@item input
24906@item 709
24907@item unspecified
24908@item 470bg
24909@item 170m
24910@item 2020_ncl
24911@item 2020_cl
24912@end table
24913
24914Default is same as input.
24915
24916@item rangein, rin
24917Set the input color range.
24918
24919Possible values are:
24920@table @var
24921@item input
24922@item limited
24923@item full
24924@end table
24925
24926Default is same as input.
24927
24928@item primariesin, pin
24929Set the input color primaries.
24930
24931Possible values are:
24932@table @var
24933@item input
24934@item 709
24935@item unspecified
24936@item 170m
24937@item 240m
24938@item 2020
24939@end table
24940
24941Default is same as input.
24942
24943@item transferin, tin
24944Set the input transfer characteristics.
24945
24946Possible values are:
24947@table @var
24948@item input
24949@item 709
24950@item unspecified
24951@item 601
24952@item linear
24953@item 2020_10
24954@item 2020_12
24955@end table
24956
24957Default is same as input.
24958
24959@item matrixin, min
24960Set the input colorspace matrix.
24961
24962Possible value are:
24963@table @var
24964@item input
24965@item 709
24966@item unspecified
24967@item 470bg
24968@item 170m
24969@item 2020_ncl
24970@item 2020_cl
24971@end table
24972
24973@item chromal, c
24974Set the output chroma location.
24975
24976Possible values are:
24977@table @var
24978@item input
24979@item left
24980@item center
24981@item topleft
24982@item top
24983@item bottomleft
24984@item bottom
24985@end table
24986
24987@item chromalin, cin
24988Set the input chroma location.
24989
24990Possible values are:
24991@table @var
24992@item input
24993@item left
24994@item center
24995@item topleft
24996@item top
24997@item bottomleft
24998@item bottom
24999@end table
25000
25001@item npl
25002Set the nominal peak luminance.
25003
25004@item param_a
25005Parameter A for scaling filters. Parameter "b" for bicubic, and the number of
25006filter taps for lanczos.
25007
25008@item param_b
25009Parameter B for scaling filters. Parameter "c" for bicubic.
25010@end table
25011
25012The values of the @option{w} and @option{h} options are expressions
25013containing the following constants:
25014
25015@table @var
25016@item in_w
25017@item in_h
25018The input width and height
25019
25020@item iw
25021@item ih
25022These are the same as @var{in_w} and @var{in_h}.
25023
25024@item out_w
25025@item out_h
25026The output (scaled) width and height
25027
25028@item ow
25029@item oh
25030These are the same as @var{out_w} and @var{out_h}
25031
25032@item a
25033The same as @var{iw} / @var{ih}
25034
25035@item sar
25036input sample aspect ratio
25037
25038@item dar
25039The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
25040
25041@item hsub
25042@item vsub
25043horizontal and vertical input chroma subsample values. For example for the
25044pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
25045
25046@item ohsub
25047@item ovsub
25048horizontal and vertical output chroma subsample values. For example for the
25049pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
25050@end table
25051
25052@subsection Commands
25053
25054This filter supports the following commands:
25055@table @option
25056@item width, w
25057@item height, h
25058Set the output video dimension expression.
25059The command accepts the same syntax of the corresponding option.
25060
25061If the specified expression is not valid, it is kept at its current
25062value.
25063@end table
25064
25065@c man end VIDEO FILTERS
25066
25067@chapter OpenCL Video Filters
25068@c man begin OPENCL VIDEO FILTERS
25069
25070Below is a description of the currently available OpenCL video filters.
25071
25072To enable compilation of these filters you need to configure FFmpeg with
25073@code{--enable-opencl}.
25074
25075Running OpenCL filters requires you to initialize a hardware device and to pass that device to all filters in any filter graph.
25076@table @option
25077
25078@item -init_hw_device opencl[=@var{name}][:@var{device}[,@var{key=value}...]]
25079Initialise a new hardware device of type @var{opencl} called @var{name}, using the
25080given device parameters.
25081
25082@item -filter_hw_device @var{name}
25083Pass the hardware device called @var{name} to all filters in any filter graph.
25084
25085@end table
25086
25087For more detailed information see @url{https://www.ffmpeg.org/ffmpeg.html#Advanced-Video-options}
25088
25089@itemize
25090@item
25091Example of choosing the first device on the second platform and running avgblur_opencl filter with default parameters on it.
25092@example
25093-init_hw_device opencl=gpu:1.0 -filter_hw_device gpu -i INPUT -vf "hwupload, avgblur_opencl, hwdownload" OUTPUT
25094@end example
25095@end itemize
25096
25097Since 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.
25098
25099@section avgblur_opencl
25100
25101Apply average blur filter.
25102
25103The filter accepts the following options:
25104
25105@table @option
25106@item sizeX
25107Set horizontal radius size.
25108Range is @code{[1, 1024]} and default value is @code{1}.
25109
25110@item planes
25111Set which planes to filter. Default value is @code{0xf}, by which all planes are processed.
25112
25113@item sizeY
25114Set vertical radius size. Range is @code{[1, 1024]} and default value is @code{0}. If zero, @code{sizeX} value will be used.
25115@end table
25116
25117@subsection Example
25118
25119@itemize
25120@item
25121Apply 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.
25122@example
25123-i INPUT -vf "hwupload, avgblur_opencl=3, hwdownload" OUTPUT
25124@end example
25125@end itemize
25126
25127@section boxblur_opencl
25128
25129Apply a boxblur algorithm to the input video.
25130
25131It accepts the following parameters:
25132
25133@table @option
25134
25135@item luma_radius, lr
25136@item luma_power, lp
25137@item chroma_radius, cr
25138@item chroma_power, cp
25139@item alpha_radius, ar
25140@item alpha_power, ap
25141
25142@end table
25143
25144A description of the accepted options follows.
25145
25146@table @option
25147@item luma_radius, lr
25148@item chroma_radius, cr
25149@item alpha_radius, ar
25150Set an expression for the box radius in pixels used for blurring the
25151corresponding input plane.
25152
25153The radius value must be a non-negative number, and must not be
25154greater than the value of the expression @code{min(w,h)/2} for the
25155luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
25156planes.
25157
25158Default value for @option{luma_radius} is "2". If not specified,
25159@option{chroma_radius} and @option{alpha_radius} default to the
25160corresponding value set for @option{luma_radius}.
25161
25162The expressions can contain the following constants:
25163@table @option
25164@item w
25165@item h
25166The input width and height in pixels.
25167
25168@item cw
25169@item ch
25170The input chroma image width and height in pixels.
25171
25172@item hsub
25173@item vsub
25174The horizontal and vertical chroma subsample values. For example, for the
25175pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
25176@end table
25177
25178@item luma_power, lp
25179@item chroma_power, cp
25180@item alpha_power, ap
25181Specify how many times the boxblur filter is applied to the
25182corresponding plane.
25183
25184Default value for @option{luma_power} is 2. If not specified,
25185@option{chroma_power} and @option{alpha_power} default to the
25186corresponding value set for @option{luma_power}.
25187
25188A value of 0 will disable the effect.
25189@end table
25190
25191@subsection Examples
25192
25193Apply 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.
25194
25195@itemize
25196@item
25197Apply a boxblur filter with the luma, chroma, and alpha radius
25198set 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.
25199@example
25200-i INPUT -vf "hwupload, boxblur_opencl=luma_radius=2:luma_power=3, hwdownload" OUTPUT
25201-i INPUT -vf "hwupload, boxblur_opencl=2:3, hwdownload" OUTPUT
25202@end example
25203
25204@item
25205Apply 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.
25206
25207For the luma plane, a 2x2 box radius will be run once.
25208
25209For the chroma plane, a 4x4 box radius will be run 5 times.
25210
25211For the alpha plane, a 3x3 box radius will be run 7 times.
25212@example
25213-i INPUT -vf "hwupload, boxblur_opencl=2:1:4:5:3:7, hwdownload" OUTPUT
25214@end example
25215@end itemize
25216
25217@section colorkey_opencl
25218RGB colorspace color keying.
25219
25220The filter accepts the following options:
25221
25222@table @option
25223@item color
25224The color which will be replaced with transparency.
25225
25226@item similarity
25227Similarity percentage with the key color.
25228
252290.01 matches only the exact key color, while 1.0 matches everything.
25230
25231@item blend
25232Blend percentage.
25233
252340.0 makes pixels either fully transparent, or not transparent at all.
25235
25236Higher values result in semi-transparent pixels, with a higher transparency
25237the more similar the pixels color is to the key color.
25238@end table
25239
25240@subsection Examples
25241
25242@itemize
25243@item
25244Make every semi-green pixel in the input transparent with some slight blending:
25245@example
25246-i INPUT -vf "hwupload, colorkey_opencl=green:0.3:0.1, hwdownload" OUTPUT
25247@end example
25248@end itemize
25249
25250@section convolution_opencl
25251
25252Apply convolution of 3x3, 5x5, 7x7 matrix.
25253
25254The filter accepts the following options:
25255
25256@table @option
25257@item 0m
25258@item 1m
25259@item 2m
25260@item 3m
25261Set matrix for each plane.
25262Matrix is sequence of 9, 25 or 49 signed numbers.
25263Default value for each plane is @code{0 0 0 0 1 0 0 0 0}.
25264
25265@item 0rdiv
25266@item 1rdiv
25267@item 2rdiv
25268@item 3rdiv
25269Set multiplier for calculated value for each plane.
25270If unset or 0, it will be sum of all matrix elements.
25271The option value must be a float number greater or equal to @code{0.0}. Default value is @code{1.0}.
25272
25273@item 0bias
25274@item 1bias
25275@item 2bias
25276@item 3bias
25277Set bias for each plane. This value is added to the result of the multiplication.
25278Useful for making the overall image brighter or darker.
25279The option value must be a float number greater or equal to @code{0.0}. Default value is @code{0.0}.
25280
25281@end table
25282
25283@subsection Examples
25284
25285@itemize
25286@item
25287Apply sharpen:
25288@example
25289-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
25290@end example
25291
25292@item
25293Apply blur:
25294@example
25295-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
25296@end example
25297
25298@item
25299Apply edge enhance:
25300@example
25301-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
25302@end example
25303
25304@item
25305Apply edge detect:
25306@example
25307-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
25308@end example
25309
25310@item
25311Apply laplacian edge detector which includes diagonals:
25312@example
25313-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
25314@end example
25315
25316@item
25317Apply emboss:
25318@example
25319-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
25320@end example
25321@end itemize
25322
25323@section erosion_opencl
25324
25325Apply erosion effect to the video.
25326
25327This filter replaces the pixel by the local(3x3) minimum.
25328
25329It accepts the following options:
25330
25331@table @option
25332@item threshold0
25333@item threshold1
25334@item threshold2
25335@item threshold3
25336Limit the maximum change for each plane. Range is @code{[0, 65535]} and default value is @code{65535}.
25337If @code{0}, plane will remain unchanged.
25338
25339@item coordinates
25340Flag which specifies the pixel to refer to.
25341Range is @code{[0, 255]} and default value is @code{255}, i.e. all eight pixels are used.
25342
25343Flags to local 3x3 coordinates region centered on @code{x}:
25344
25345    1 2 3
25346
25347    4 x 5
25348
25349    6 7 8
25350@end table
25351
25352@subsection Example
25353
25354@itemize
25355@item
25356Apply 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.
25357@example
25358-i INPUT -vf "hwupload, erosion_opencl=30:40:50:coordinates=231, hwdownload" OUTPUT
25359@end example
25360@end itemize
25361
25362@section deshake_opencl
25363Feature-point based video stabilization filter.
25364
25365The filter accepts the following options:
25366
25367@table @option
25368@item tripod
25369Simulates a tripod by preventing any camera movement whatsoever from the original frame. Defaults to @code{0}.
25370
25371@item debug
25372Whether or not additional debug info should be displayed, both in the processed output and in the console.
25373
25374Note that in order to see console debug output you will also need to pass @code{-v verbose} to ffmpeg.
25375
25376Viewing point matches in the output video is only supported for RGB input.
25377
25378Defaults to @code{0}.
25379
25380@item adaptive_crop
25381Whether or not to do a tiny bit of cropping at the borders to cut down on the amount of mirrored pixels.
25382
25383Defaults to @code{1}.
25384
25385@item refine_features
25386Whether or not feature points should be refined at a sub-pixel level.
25387
25388This can be turned off for a slight performance gain at the cost of precision.
25389
25390Defaults to @code{1}.
25391
25392@item smooth_strength
25393The strength of the smoothing applied to the camera path from @code{0.0} to @code{1.0}.
25394
25395@code{1.0} is the maximum smoothing strength while values less than that result in less smoothing.
25396
25397@code{0.0} causes the filter to adaptively choose a smoothing strength on a per-frame basis.
25398
25399Defaults to @code{0.0}.
25400
25401@item smooth_window_multiplier
25402Controls the size of the smoothing window (the number of frames buffered to determine motion information from).
25403
25404The size of the smoothing window is determined by multiplying the framerate of the video by this number.
25405
25406Acceptable values range from @code{0.1} to @code{10.0}.
25407
25408Larger values increase the amount of motion data available for determining how to smooth the camera path,
25409potentially improving smoothness, but also increase latency and memory usage.
25410
25411Defaults to @code{2.0}.
25412
25413@end table
25414
25415@subsection Examples
25416
25417@itemize
25418@item
25419Stabilize a video with a fixed, medium smoothing strength:
25420@example
25421-i INPUT -vf "hwupload, deshake_opencl=smooth_strength=0.5, hwdownload" OUTPUT
25422@end example
25423
25424@item
25425Stabilize a video with debugging (both in console and in rendered video):
25426@example
25427-i INPUT -filter_complex "[0:v]format=rgba, hwupload, deshake_opencl=debug=1, hwdownload, format=rgba, format=yuv420p" -v verbose OUTPUT
25428@end example
25429@end itemize
25430
25431@section dilation_opencl
25432
25433Apply dilation effect to the video.
25434
25435This filter replaces the pixel by the local(3x3) maximum.
25436
25437It accepts the following options:
25438
25439@table @option
25440@item threshold0
25441@item threshold1
25442@item threshold2
25443@item threshold3
25444Limit the maximum change for each plane. Range is @code{[0, 65535]} and default value is @code{65535}.
25445If @code{0}, plane will remain unchanged.
25446
25447@item coordinates
25448Flag which specifies the pixel to refer to.
25449Range is @code{[0, 255]} and default value is @code{255}, i.e. all eight pixels are used.
25450
25451Flags to local 3x3 coordinates region centered on @code{x}:
25452
25453    1 2 3
25454
25455    4 x 5
25456
25457    6 7 8
25458@end table
25459
25460@subsection Example
25461
25462@itemize
25463@item
25464Apply 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.
25465@example
25466-i INPUT -vf "hwupload, dilation_opencl=30:40:50:coordinates=231, hwdownload" OUTPUT
25467@end example
25468@end itemize
25469
25470@section nlmeans_opencl
25471
25472Non-local Means denoise filter through OpenCL, this filter accepts same options as @ref{nlmeans}.
25473
25474@section overlay_opencl
25475
25476Overlay one video on top of another.
25477
25478It takes two inputs and has one output. The first input is the "main" video on which the second input is overlaid.
25479This filter requires same memory layout for all the inputs. So, format conversion may be needed.
25480
25481The filter accepts the following options:
25482
25483@table @option
25484
25485@item x
25486Set the x coordinate of the overlaid video on the main video.
25487Default value is @code{0}.
25488
25489@item y
25490Set the y coordinate of the overlaid video on the main video.
25491Default value is @code{0}.
25492
25493@end table
25494
25495@subsection Examples
25496
25497@itemize
25498@item
25499Overlay an image LOGO at the top-left corner of the INPUT video. Both inputs are yuv420p format.
25500@example
25501-i INPUT -i LOGO -filter_complex "[0:v]hwupload[a], [1:v]format=yuv420p, hwupload[b], [a][b]overlay_opencl, hwdownload" OUTPUT
25502@end example
25503@item
25504The inputs have same memory layout for color channels , the overlay has additional alpha plane, like INPUT is yuv420p, and the LOGO is yuva420p.
25505@example
25506-i INPUT -i LOGO -filter_complex "[0:v]hwupload[a], [1:v]format=yuva420p, hwupload[b], [a][b]overlay_opencl, hwdownload" OUTPUT
25507@end example
25508
25509@end itemize
25510
25511@section pad_opencl
25512
25513Add paddings to the input image, and place the original input at the
25514provided @var{x}, @var{y} coordinates.
25515
25516It accepts the following options:
25517
25518@table @option
25519@item width, w
25520@item height, h
25521Specify an expression for the size of the output image with the
25522paddings added. If the value for @var{width} or @var{height} is 0, the
25523corresponding input size is used for the output.
25524
25525The @var{width} expression can reference the value set by the
25526@var{height} expression, and vice versa.
25527
25528The default value of @var{width} and @var{height} is 0.
25529
25530@item x
25531@item y
25532Specify the offsets to place the input image at within the padded area,
25533with respect to the top/left border of the output image.
25534
25535The @var{x} expression can reference the value set by the @var{y}
25536expression, and vice versa.
25537
25538The default value of @var{x} and @var{y} is 0.
25539
25540If @var{x} or @var{y} evaluate to a negative number, they'll be changed
25541so the input image is centered on the padded area.
25542
25543@item color
25544Specify the color of the padded area. For the syntax of this option,
25545check the @ref{color syntax,,"Color" section in the ffmpeg-utils
25546manual,ffmpeg-utils}.
25547
25548@item aspect
25549Pad to an aspect instead to a resolution.
25550@end table
25551
25552The value for the @var{width}, @var{height}, @var{x}, and @var{y}
25553options are expressions containing the following constants:
25554
25555@table @option
25556@item in_w
25557@item in_h
25558The input video width and height.
25559
25560@item iw
25561@item ih
25562These are the same as @var{in_w} and @var{in_h}.
25563
25564@item out_w
25565@item out_h
25566The output width and height (the size of the padded area), as
25567specified by the @var{width} and @var{height} expressions.
25568
25569@item ow
25570@item oh
25571These are the same as @var{out_w} and @var{out_h}.
25572
25573@item x
25574@item y
25575The x and y offsets as specified by the @var{x} and @var{y}
25576expressions, or NAN if not yet specified.
25577
25578@item a
25579same as @var{iw} / @var{ih}
25580
25581@item sar
25582input sample aspect ratio
25583
25584@item dar
25585input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
25586@end table
25587
25588@section prewitt_opencl
25589
25590Apply the Prewitt operator (@url{https://en.wikipedia.org/wiki/Prewitt_operator}) to input video stream.
25591
25592The filter accepts the following option:
25593
25594@table @option
25595@item planes
25596Set which planes to filter. Default value is @code{0xf}, by which all planes are processed.
25597
25598@item scale
25599Set value which will be multiplied with filtered result.
25600Range is @code{[0.0, 65535]} and default value is @code{1.0}.
25601
25602@item delta
25603Set value which will be added to filtered result.
25604Range is @code{[-65535, 65535]} and default value is @code{0.0}.
25605@end table
25606
25607@subsection Example
25608
25609@itemize
25610@item
25611Apply the Prewitt operator with scale set to 2 and delta set to 10.
25612@example
25613-i INPUT -vf "hwupload, prewitt_opencl=scale=2:delta=10, hwdownload" OUTPUT
25614@end example
25615@end itemize
25616
25617@anchor{program_opencl}
25618@section program_opencl
25619
25620Filter video using an OpenCL program.
25621
25622@table @option
25623
25624@item source
25625OpenCL program source file.
25626
25627@item kernel
25628Kernel name in program.
25629
25630@item inputs
25631Number of inputs to the filter.  Defaults to 1.
25632
25633@item size, s
25634Size of output frames.  Defaults to the same as the first input.
25635
25636@end table
25637
25638The @code{program_opencl} filter also supports the @ref{framesync} options.
25639
25640The program source file must contain a kernel function with the given name,
25641which will be run once for each plane of the output.  Each run on a plane
25642gets enqueued as a separate 2D global NDRange with one work-item for each
25643pixel to be generated.  The global ID offset for each work-item is therefore
25644the coordinates of a pixel in the destination image.
25645
25646The kernel function needs to take the following arguments:
25647@itemize
25648@item
25649Destination image, @var{__write_only image2d_t}.
25650
25651This image will become the output; the kernel should write all of it.
25652@item
25653Frame index, @var{unsigned int}.
25654
25655This is a counter starting from zero and increasing by one for each frame.
25656@item
25657Source images, @var{__read_only image2d_t}.
25658
25659These are the most recent images on each input.  The kernel may read from
25660them to generate the output, but they can't be written to.
25661@end itemize
25662
25663Example programs:
25664
25665@itemize
25666@item
25667Copy the input to the output (output must be the same size as the input).
25668@verbatim
25669__kernel void copy(__write_only image2d_t destination,
25670                   unsigned int index,
25671                   __read_only  image2d_t source)
25672{
25673    const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE;
25674
25675    int2 location = (int2)(get_global_id(0), get_global_id(1));
25676
25677    float4 value = read_imagef(source, sampler, location);
25678
25679    write_imagef(destination, location, value);
25680}
25681@end verbatim
25682
25683@item
25684Apply a simple transformation, rotating the input by an amount increasing
25685with the index counter.  Pixel values are linearly interpolated by the
25686sampler, and the output need not have the same dimensions as the input.
25687@verbatim
25688__kernel void rotate_image(__write_only image2d_t dst,
25689                           unsigned int index,
25690                           __read_only  image2d_t src)
25691{
25692    const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
25693                               CLK_FILTER_LINEAR);
25694
25695    float angle = (float)index / 100.0f;
25696
25697    float2 dst_dim = convert_float2(get_image_dim(dst));
25698    float2 src_dim = convert_float2(get_image_dim(src));
25699
25700    float2 dst_cen = dst_dim / 2.0f;
25701    float2 src_cen = src_dim / 2.0f;
25702
25703    int2   dst_loc = (int2)(get_global_id(0), get_global_id(1));
25704
25705    float2 dst_pos = convert_float2(dst_loc) - dst_cen;
25706    float2 src_pos = {
25707        cos(angle) * dst_pos.x - sin(angle) * dst_pos.y,
25708        sin(angle) * dst_pos.x + cos(angle) * dst_pos.y
25709    };
25710    src_pos = src_pos * src_dim / dst_dim;
25711
25712    float2 src_loc = src_pos + src_cen;
25713
25714    if (src_loc.x < 0.0f      || src_loc.y < 0.0f ||
25715        src_loc.x > src_dim.x || src_loc.y > src_dim.y)
25716        write_imagef(dst, dst_loc, 0.5f);
25717    else
25718        write_imagef(dst, dst_loc, read_imagef(src, sampler, src_loc));
25719}
25720@end verbatim
25721
25722@item
25723Blend two inputs together, with the amount of each input used varying
25724with the index counter.
25725@verbatim
25726__kernel void blend_images(__write_only image2d_t dst,
25727                           unsigned int index,
25728                           __read_only  image2d_t src1,
25729                           __read_only  image2d_t src2)
25730{
25731    const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
25732                               CLK_FILTER_LINEAR);
25733
25734    float blend = (cos((float)index / 50.0f) + 1.0f) / 2.0f;
25735
25736    int2  dst_loc = (int2)(get_global_id(0), get_global_id(1));
25737    int2 src1_loc = dst_loc * get_image_dim(src1) / get_image_dim(dst);
25738    int2 src2_loc = dst_loc * get_image_dim(src2) / get_image_dim(dst);
25739
25740    float4 val1 = read_imagef(src1, sampler, src1_loc);
25741    float4 val2 = read_imagef(src2, sampler, src2_loc);
25742
25743    write_imagef(dst, dst_loc, val1 * blend + val2 * (1.0f - blend));
25744}
25745@end verbatim
25746
25747@end itemize
25748
25749@section remap_opencl
25750
25751Remap pixels using 2nd: Xmap and 3rd: Ymap input video stream.
25752
25753Destination pixel at position (X, Y) will be picked from source (x, y) position
25754where x = Xmap(X, Y) and y = Ymap(X, Y). If mapping values are out of range, zero
25755value for pixel will be used for destination pixel.
25756
25757Xmap and Ymap input video streams must be of same dimensions. Output video stream
25758will have Xmap/Ymap video stream dimensions.
25759Xmap and Ymap input video streams are 32bit float pixel format, single channel.
25760
25761@table @option
25762@item interp
25763Specify interpolation used for remapping of pixels.
25764Allowed values are @code{near} and @code{linear}.
25765Default value is @code{linear}.
25766
25767@item fill
25768Specify the color of the unmapped pixels. For the syntax of this option,
25769check the @ref{color syntax,,"Color" section in the ffmpeg-utils
25770manual,ffmpeg-utils}. Default color is @code{black}.
25771@end table
25772
25773@section roberts_opencl
25774Apply the Roberts cross operator (@url{https://en.wikipedia.org/wiki/Roberts_cross}) to input video stream.
25775
25776The filter accepts the following option:
25777
25778@table @option
25779@item planes
25780Set which planes to filter. Default value is @code{0xf}, by which all planes are processed.
25781
25782@item scale
25783Set value which will be multiplied with filtered result.
25784Range is @code{[0.0, 65535]} and default value is @code{1.0}.
25785
25786@item delta
25787Set value which will be added to filtered result.
25788Range is @code{[-65535, 65535]} and default value is @code{0.0}.
25789@end table
25790
25791@subsection Example
25792
25793@itemize
25794@item
25795Apply the Roberts cross operator with scale set to 2 and delta set to 10
25796@example
25797-i INPUT -vf "hwupload, roberts_opencl=scale=2:delta=10, hwdownload" OUTPUT
25798@end example
25799@end itemize
25800
25801@section sobel_opencl
25802
25803Apply the Sobel operator (@url{https://en.wikipedia.org/wiki/Sobel_operator}) to input video stream.
25804
25805The filter accepts the following option:
25806
25807@table @option
25808@item planes
25809Set which planes to filter. Default value is @code{0xf}, by which all planes are processed.
25810
25811@item scale
25812Set value which will be multiplied with filtered result.
25813Range is @code{[0.0, 65535]} and default value is @code{1.0}.
25814
25815@item delta
25816Set value which will be added to filtered result.
25817Range is @code{[-65535, 65535]} and default value is @code{0.0}.
25818@end table
25819
25820@subsection Example
25821
25822@itemize
25823@item
25824Apply sobel operator with scale set to 2 and delta set to 10
25825@example
25826-i INPUT -vf "hwupload, sobel_opencl=scale=2:delta=10, hwdownload" OUTPUT
25827@end example
25828@end itemize
25829
25830@section tonemap_opencl
25831
25832Perform HDR(PQ/HLG) to SDR conversion with tone-mapping.
25833
25834It accepts the following parameters:
25835
25836@table @option
25837@item tonemap
25838Specify the tone-mapping operator to be used. Same as tonemap option in @ref{tonemap}.
25839
25840@item param
25841Tune the tone mapping algorithm. same as param option in @ref{tonemap}.
25842
25843@item desat
25844Apply desaturation for highlights that exceed this level of brightness. The
25845higher the parameter, the more color information will be preserved. This
25846setting helps prevent unnaturally blown-out colors for super-highlights, by
25847(smoothly) turning into white instead. This makes images feel more natural,
25848at the cost of reducing information about out-of-range colors.
25849
25850The default value is 0.5, and the algorithm here is a little different from
25851the cpu version tonemap currently. A setting of 0.0 disables this option.
25852
25853@item threshold
25854The tonemapping algorithm parameters is fine-tuned per each scene. And a threshold
25855is used to detect whether the scene has changed or not. If the distance between
25856the current frame average brightness and the current running average exceeds
25857a threshold value, we would re-calculate scene average and peak brightness.
25858The default value is 0.2.
25859
25860@item format
25861Specify the output pixel format.
25862
25863Currently supported formats are:
25864@table @var
25865@item p010
25866@item nv12
25867@end table
25868
25869@item range, r
25870Set the output color range.
25871
25872Possible values are:
25873@table @var
25874@item tv/mpeg
25875@item pc/jpeg
25876@end table
25877
25878Default is same as input.
25879
25880@item primaries, p
25881Set the output color primaries.
25882
25883Possible values are:
25884@table @var
25885@item bt709
25886@item bt2020
25887@end table
25888
25889Default is same as input.
25890
25891@item transfer, t
25892Set the output transfer characteristics.
25893
25894Possible values are:
25895@table @var
25896@item bt709
25897@item bt2020
25898@end table
25899
25900Default is bt709.
25901
25902@item matrix, m
25903Set the output colorspace matrix.
25904
25905Possible value are:
25906@table @var
25907@item bt709
25908@item bt2020
25909@end table
25910
25911Default is same as input.
25912
25913@end table
25914
25915@subsection Example
25916
25917@itemize
25918@item
25919Convert HDR(PQ/HLG) video to bt2020-transfer-characteristic p010 format using linear operator.
25920@example
25921-i INPUT -vf "format=p010,hwupload,tonemap_opencl=t=bt2020:tonemap=linear:format=p010,hwdownload,format=p010" OUTPUT
25922@end example
25923@end itemize
25924
25925@section unsharp_opencl
25926
25927Sharpen or blur the input video.
25928
25929It accepts the following parameters:
25930
25931@table @option
25932@item luma_msize_x, lx
25933Set the luma matrix horizontal size.
25934Range is @code{[1, 23]} and default value is @code{5}.
25935
25936@item luma_msize_y, ly
25937Set the luma matrix vertical size.
25938Range is @code{[1, 23]} and default value is @code{5}.
25939
25940@item luma_amount, la
25941Set the luma effect strength.
25942Range is @code{[-10, 10]} and default value is @code{1.0}.
25943
25944Negative values will blur the input video, while positive values will
25945sharpen it, a value of zero will disable the effect.
25946
25947@item chroma_msize_x, cx
25948Set the chroma matrix horizontal size.
25949Range is @code{[1, 23]} and default value is @code{5}.
25950
25951@item chroma_msize_y, cy
25952Set the chroma matrix vertical size.
25953Range is @code{[1, 23]} and default value is @code{5}.
25954
25955@item chroma_amount, ca
25956Set the chroma effect strength.
25957Range is @code{[-10, 10]} and default value is @code{0.0}.
25958
25959Negative values will blur the input video, while positive values will
25960sharpen it, a value of zero will disable the effect.
25961
25962@end table
25963
25964All parameters are optional and default to the equivalent of the
25965string '5:5:1.0:5:5:0.0'.
25966
25967@subsection Examples
25968
25969@itemize
25970@item
25971Apply strong luma sharpen effect:
25972@example
25973-i INPUT -vf "hwupload, unsharp_opencl=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5, hwdownload" OUTPUT
25974@end example
25975
25976@item
25977Apply a strong blur of both luma and chroma parameters:
25978@example
25979-i INPUT -vf "hwupload, unsharp_opencl=7:7:-2:7:7:-2, hwdownload" OUTPUT
25980@end example
25981@end itemize
25982
25983@section xfade_opencl
25984
25985Cross fade two videos with custom transition effect by using OpenCL.
25986
25987It accepts the following options:
25988
25989@table @option
25990@item transition
25991Set one of possible transition effects.
25992
25993@table @option
25994@item custom
25995Select custom transition effect, the actual transition description
25996will be picked from source and kernel options.
25997
25998@item fade
25999@item wipeleft
26000@item wiperight
26001@item wipeup
26002@item wipedown
26003@item slideleft
26004@item slideright
26005@item slideup
26006@item slidedown
26007
26008Default transition is fade.
26009@end table
26010
26011@item source
26012OpenCL program source file for custom transition.
26013
26014@item kernel
26015Set name of kernel to use for custom transition from program source file.
26016
26017@item duration
26018Set duration of video transition.
26019
26020@item offset
26021Set time of start of transition relative to first video.
26022@end table
26023
26024The program source file must contain a kernel function with the given name,
26025which will be run once for each plane of the output.  Each run on a plane
26026gets enqueued as a separate 2D global NDRange with one work-item for each
26027pixel to be generated.  The global ID offset for each work-item is therefore
26028the coordinates of a pixel in the destination image.
26029
26030The kernel function needs to take the following arguments:
26031@itemize
26032@item
26033Destination image, @var{__write_only image2d_t}.
26034
26035This image will become the output; the kernel should write all of it.
26036
26037@item
26038First Source image, @var{__read_only image2d_t}.
26039Second Source image, @var{__read_only image2d_t}.
26040
26041These are the most recent images on each input.  The kernel may read from
26042them to generate the output, but they can't be written to.
26043
26044@item
26045Transition progress, @var{float}. This value is always between 0 and 1 inclusive.
26046@end itemize
26047
26048Example programs:
26049
26050@itemize
26051@item
26052Apply dots curtain transition effect:
26053@verbatim
26054__kernel void blend_images(__write_only image2d_t dst,
26055                           __read_only  image2d_t src1,
26056                           __read_only  image2d_t src2,
26057                           float progress)
26058{
26059    const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
26060                               CLK_FILTER_LINEAR);
26061    int2  p = (int2)(get_global_id(0), get_global_id(1));
26062    float2 rp = (float2)(get_global_id(0), get_global_id(1));
26063    float2 dim = (float2)(get_image_dim(src1).x, get_image_dim(src1).y);
26064    rp = rp / dim;
26065
26066    float2 dots = (float2)(20.0, 20.0);
26067    float2 center = (float2)(0,0);
26068    float2 unused;
26069
26070    float4 val1 = read_imagef(src1, sampler, p);
26071    float4 val2 = read_imagef(src2, sampler, p);
26072    bool next = distance(fract(rp * dots, &unused), (float2)(0.5, 0.5)) < (progress / distance(rp, center));
26073
26074    write_imagef(dst, p, next ? val1 : val2);
26075}
26076@end verbatim
26077
26078@end itemize
26079
26080@c man end OPENCL VIDEO FILTERS
26081
26082@chapter VAAPI Video Filters
26083@c man begin VAAPI VIDEO FILTERS
26084
26085VAAPI Video filters are usually used with VAAPI decoder and VAAPI encoder. Below is a description of VAAPI video filters.
26086
26087To enable compilation of these filters you need to configure FFmpeg with
26088@code{--enable-vaapi}.
26089
26090To use vaapi filters, you need to setup the vaapi device correctly. For more information, please read @url{https://trac.ffmpeg.org/wiki/Hardware/VAAPI}
26091
26092@section overlay_vaapi
26093
26094Overlay one video on the top of another.
26095
26096It takes two inputs and has one output. The first input is the "main" video on which the second input is overlaid.
26097This filter requires same memory layout for all the inputs. So, format conversion may be needed.
26098
26099The filter accepts the following options:
26100
26101@table @option
26102
26103@item x
26104Set the x coordinate of the overlaid video on the main video.
26105Default value is @code{0}.
26106
26107@item y
26108Set the y coordinate of the overlaid video on the main video.
26109Default value is @code{0}.
26110
26111@item w
26112Set the width of the overlaid video on the main video.
26113Default value is the width of input overlay video.
26114
26115@item h
26116Set the height of the overlaid video on the main video.
26117Default value is the height of input overlay video.
26118
26119@item alpha
26120Set blocking detection thresholds. Allowed range is 0.0 to 1.0, it
26121requires an input video with alpha channel.
26122Default value is @code{0.0}.
26123
26124@end table
26125
26126@subsection Examples
26127
26128@itemize
26129@item
26130Overlay an image LOGO at the top-left corner of the INPUT video. Both inputs for this filter are yuv420p format.
26131@example
26132-i INPUT -i LOGO -filter_complex "[0:v]hwupload[a], [1:v]format=yuv420p, hwupload[b], [a][b]overlay_vaapi" OUTPUT
26133@end example
26134@item
26135Overlay an image LOGO at the offset (200, 100) from the top-left corner of the INPUT video.
26136The inputs have same memory layout for color channels, the overlay has additional alpha plane, like INPUT is yuv420p, and the LOGO is yuva420p.
26137@example
26138-i INPUT -i LOGO -filter_complex "[0:v]hwupload[a], [1:v]format=yuva420p, hwupload[b], [a][b]overlay_vaapi=x=200:y=100:w=400:h=300:alpha=1.0, hwdownload, format=nv12" OUTPUT
26139@end example
26140
26141@end itemize
26142
26143@section tonemap_vaapi
26144
26145Perform HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion with tone-mapping.
26146It maps the dynamic range of HDR10 content to the SDR content.
26147It currently only accepts HDR10 as input.
26148
26149It accepts the following parameters:
26150
26151@table @option
26152@item format
26153Specify the output pixel format.
26154
26155Currently supported formats are:
26156@table @var
26157@item p010
26158@item nv12
26159@end table
26160
26161Default is nv12.
26162
26163@item primaries, p
26164Set the output color primaries.
26165
26166Default is same as input.
26167
26168@item transfer, t
26169Set the output transfer characteristics.
26170
26171Default is bt709.
26172
26173@item matrix, m
26174Set the output colorspace matrix.
26175
26176Default is same as input.
26177
26178@end table
26179
26180@subsection Example
26181
26182@itemize
26183@item
26184Convert HDR(HDR10) video to bt2020-transfer-characteristic p010 format
26185@example
26186tonemap_vaapi=format=p010:t=bt2020-10
26187@end example
26188@end itemize
26189
26190@c man end VAAPI VIDEO FILTERS
26191
26192@chapter Video Sources
26193@c man begin VIDEO SOURCES
26194
26195Below is a description of the currently available video sources.
26196
26197@section buffer
26198
26199Buffer video frames, and make them available to the filter chain.
26200
26201This source is mainly intended for a programmatic use, in particular
26202through the interface defined in @file{libavfilter/buffersrc.h}.
26203
26204It accepts the following parameters:
26205
26206@table @option
26207
26208@item video_size
26209Specify the size (width and height) of the buffered video frames. For the
26210syntax of this option, check the
26211@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
26212
26213@item width
26214The input video width.
26215
26216@item height
26217The input video height.
26218
26219@item pix_fmt
26220A string representing the pixel format of the buffered video frames.
26221It may be a number corresponding to a pixel format, or a pixel format
26222name.
26223
26224@item time_base
26225Specify the timebase assumed by the timestamps of the buffered frames.
26226
26227@item frame_rate
26228Specify the frame rate expected for the video stream.
26229
26230@item pixel_aspect, sar
26231The sample (pixel) aspect ratio of the input video.
26232
26233@item sws_param
26234This option is deprecated and ignored. Prepend @code{sws_flags=@var{flags};}
26235to the filtergraph description to specify swscale flags for automatically
26236inserted scalers. See @ref{Filtergraph syntax}.
26237
26238@item hw_frames_ctx
26239When using a hardware pixel format, this should be a reference to an
26240AVHWFramesContext describing input frames.
26241@end table
26242
26243For example:
26244@example
26245buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
26246@end example
26247
26248will instruct the source to accept video frames with size 320x240 and
26249with format "yuv410p", assuming 1/24 as the timestamps timebase and
26250square pixels (1:1 sample aspect ratio).
26251Since the pixel format with name "yuv410p" corresponds to the number 6
26252(check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
26253this example corresponds to:
26254@example
26255buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
26256@end example
26257
26258Alternatively, the options can be specified as a flat string, but this
26259syntax is deprecated:
26260
26261@var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}
26262
26263@section cellauto
26264
26265Create a pattern generated by an elementary cellular automaton.
26266
26267The initial state of the cellular automaton can be defined through the
26268@option{filename} and @option{pattern} options. If such options are
26269not specified an initial state is created randomly.
26270
26271At each new frame a new row in the video is filled with the result of
26272the cellular automaton next generation. The behavior when the whole
26273frame is filled is defined by the @option{scroll} option.
26274
26275This source accepts the following options:
26276
26277@table @option
26278@item filename, f
26279Read the initial cellular automaton state, i.e. the starting row, from
26280the specified file.
26281In the file, each non-whitespace character is considered an alive
26282cell, a newline will terminate the row, and further characters in the
26283file will be ignored.
26284
26285@item pattern, p
26286Read the initial cellular automaton state, i.e. the starting row, from
26287the specified string.
26288
26289Each non-whitespace character in the string is considered an alive
26290cell, a newline will terminate the row, and further characters in the
26291string will be ignored.
26292
26293@item rate, r
26294Set the video rate, that is the number of frames generated per second.
26295Default is 25.
26296
26297@item random_fill_ratio, ratio
26298Set the random fill ratio for the initial cellular automaton row. It
26299is a floating point number value ranging from 0 to 1, defaults to
263001/PHI.
26301
26302This option is ignored when a file or a pattern is specified.
26303
26304@item random_seed, seed
26305Set the seed for filling randomly the initial row, must be an integer
26306included between 0 and UINT32_MAX. If not specified, or if explicitly
26307set to -1, the filter will try to use a good random seed on a best
26308effort basis.
26309
26310@item rule
26311Set the cellular automaton rule, it is a number ranging from 0 to 255.
26312Default value is 110.
26313
26314@item size, s
26315Set the size of the output video. For the syntax of this option, check the
26316@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
26317
26318If @option{filename} or @option{pattern} is specified, the size is set
26319by default to the width of the specified initial state row, and the
26320height is set to @var{width} * PHI.
26321
26322If @option{size} is set, it must contain the width of the specified
26323pattern string, and the specified pattern will be centered in the
26324larger row.
26325
26326If a filename or a pattern string is not specified, the size value
26327defaults to "320x518" (used for a randomly generated initial state).
26328
26329@item scroll
26330If set to 1, scroll the output upward when all the rows in the output
26331have been already filled. If set to 0, the new generated row will be
26332written over the top row just after the bottom row is filled.
26333Defaults to 1.
26334
26335@item start_full, full
26336If set to 1, completely fill the output with generated rows before
26337outputting the first frame.
26338This is the default behavior, for disabling set the value to 0.
26339
26340@item stitch
26341If set to 1, stitch the left and right row edges together.
26342This is the default behavior, for disabling set the value to 0.
26343@end table
26344
26345@subsection Examples
26346
26347@itemize
26348@item
26349Read the initial state from @file{pattern}, and specify an output of
26350size 200x400.
26351@example
26352cellauto=f=pattern:s=200x400
26353@end example
26354
26355@item
26356Generate a random initial row with a width of 200 cells, with a fill
26357ratio of 2/3:
26358@example
26359cellauto=ratio=2/3:s=200x200
26360@end example
26361
26362@item
26363Create a pattern generated by rule 18 starting by a single alive cell
26364centered on an initial row with width 100:
26365@example
26366cellauto=p=@@:s=100x400:full=0:rule=18
26367@end example
26368
26369@item
26370Specify a more elaborated initial pattern:
26371@example
26372cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
26373@end example
26374
26375@end itemize
26376
26377@anchor{coreimagesrc}
26378@section coreimagesrc
26379Video source generated on GPU using Apple's CoreImage API on OSX.
26380
26381This video source is a specialized version of the @ref{coreimage} video filter.
26382Use a core image generator at the beginning of the applied filterchain to
26383generate the content.
26384
26385The coreimagesrc video source accepts the following options:
26386@table @option
26387@item list_generators
26388List all available generators along with all their respective options as well as
26389possible minimum and maximum values along with the default values.
26390@example
26391list_generators=true
26392@end example
26393
26394@item size, s
26395Specify the size of the sourced video. For the syntax of this option, check the
26396@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
26397The default value is @code{320x240}.
26398
26399@item rate, r
26400Specify the frame rate of the sourced video, as the number of frames
26401generated per second. It has to be a string in the format
26402@var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
26403number or a valid video frame rate abbreviation. The default value is
26404"25".
26405
26406@item sar
26407Set the sample aspect ratio of the sourced video.
26408
26409@item duration, d
26410Set the duration of the sourced video. See
26411@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
26412for the accepted syntax.
26413
26414If not specified, or the expressed duration is negative, the video is
26415supposed to be generated forever.
26416@end table
26417
26418Additionally, all options of the @ref{coreimage} video filter are accepted.
26419A complete filterchain can be used for further processing of the
26420generated input without CPU-HOST transfer. See @ref{coreimage} documentation
26421and examples for details.
26422
26423@subsection Examples
26424
26425@itemize
26426
26427@item
26428Use CIQRCodeGenerator to create a QR code for the FFmpeg homepage,
26429given as complete and escaped command-line for Apple's standard bash shell:
26430@example
26431ffmpeg -f lavfi -i coreimagesrc=s=100x100:filter=CIQRCodeGenerator@@inputMessage=https\\\\\://FFmpeg.org/@@inputCorrectionLevel=H -frames:v 1 QRCode.png
26432@end example
26433This example is equivalent to the QRCode example of @ref{coreimage} without the
26434need for a nullsrc video source.
26435@end itemize
26436
26437
26438@section gradients
26439Generate several gradients.
26440
26441@table @option
26442@item size, s
26443Set frame size. For the syntax of this option, check the @ref{video size syntax,,"Video
26444size" section in the ffmpeg-utils manual,ffmpeg-utils}. Default value is "640x480".
26445
26446@item rate, r
26447Set frame rate, expressed as number of frames per second. Default
26448value is "25".
26449
26450@item c0, c1, c2, c3, c4, c5, c6, c7
26451Set 8 colors. Default values for colors is to pick random one.
26452
26453@item x0, y0, y0, y1
26454Set gradient line source and destination points. If negative or out of range, random ones
26455are picked.
26456
26457@item nb_colors, n
26458Set number of colors to use at once. Allowed range is from 2 to 8. Default value is 2.
26459
26460@item seed
26461Set seed for picking gradient line points.
26462
26463@item duration, d
26464Set the duration of the sourced video. See
26465@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
26466for the accepted syntax.
26467
26468If not specified, or the expressed duration is negative, the video is
26469supposed to be generated forever.
26470
26471@item speed
26472Set speed of gradients rotation.
26473
26474@item type, t
26475Set type of gradients, can be @code{linear} or @code{radial} or @code{circular} or @code{spiral}.
26476@end table
26477
26478
26479@section mandelbrot
26480
26481Generate a Mandelbrot set fractal, and progressively zoom towards the
26482point specified with @var{start_x} and @var{start_y}.
26483
26484This source accepts the following options:
26485
26486@table @option
26487
26488@item end_pts
26489Set the terminal pts value. Default value is 400.
26490
26491@item end_scale
26492Set the terminal scale value.
26493Must be a floating point value. Default value is 0.3.
26494
26495@item inner
26496Set the inner coloring mode, that is the algorithm used to draw the
26497Mandelbrot fractal internal region.
26498
26499It shall assume one of the following values:
26500@table @option
26501@item black
26502Set black mode.
26503@item convergence
26504Show time until convergence.
26505@item mincol
26506Set color based on point closest to the origin of the iterations.
26507@item period
26508Set period mode.
26509@end table
26510
26511Default value is @var{mincol}.
26512
26513@item bailout
26514Set the bailout value. Default value is 10.0.
26515
26516@item maxiter
26517Set the maximum of iterations performed by the rendering
26518algorithm. Default value is 7189.
26519
26520@item outer
26521Set outer coloring mode.
26522It shall assume one of following values:
26523@table @option
26524@item iteration_count
26525Set iteration count mode.
26526@item normalized_iteration_count
26527set normalized iteration count mode.
26528@end table
26529Default value is @var{normalized_iteration_count}.
26530
26531@item rate, r
26532Set frame rate, expressed as number of frames per second. Default
26533value is "25".
26534
26535@item size, s
26536Set frame size. For the syntax of this option, check the @ref{video size syntax,,"Video
26537size" section in the ffmpeg-utils manual,ffmpeg-utils}. Default value is "640x480".
26538
26539@item start_scale
26540Set the initial scale value. Default value is 3.0.
26541
26542@item start_x
26543Set the initial x position. Must be a floating point value between
26544-100 and 100. Default value is -0.743643887037158704752191506114774.
26545
26546@item start_y
26547Set the initial y position. Must be a floating point value between
26548-100 and 100. Default value is -0.131825904205311970493132056385139.
26549@end table
26550
26551@section mptestsrc
26552
26553Generate various test patterns, as generated by the MPlayer test filter.
26554
26555The size of the generated video is fixed, and is 256x256.
26556This source is useful in particular for testing encoding features.
26557
26558This source accepts the following options:
26559
26560@table @option
26561
26562@item rate, r
26563Specify the frame rate of the sourced video, as the number of frames
26564generated per second. It has to be a string in the format
26565@var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
26566number or a valid video frame rate abbreviation. The default value is
26567"25".
26568
26569@item duration, d
26570Set the duration of the sourced video. See
26571@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
26572for the accepted syntax.
26573
26574If not specified, or the expressed duration is negative, the video is
26575supposed to be generated forever.
26576
26577@item test, t
26578
26579Set the number or the name of the test to perform. Supported tests are:
26580@table @option
26581@item dc_luma
26582@item dc_chroma
26583@item freq_luma
26584@item freq_chroma
26585@item amp_luma
26586@item amp_chroma
26587@item cbp
26588@item mv
26589@item ring1
26590@item ring2
26591@item all
26592
26593@item max_frames, m
26594Set the maximum number of frames generated for each test, default value is 30.
26595
26596@end table
26597
26598Default value is "all", which will cycle through the list of all tests.
26599@end table
26600
26601Some examples:
26602@example
26603mptestsrc=t=dc_luma
26604@end example
26605
26606will generate a "dc_luma" test pattern.
26607
26608@section frei0r_src
26609
26610Provide a frei0r source.
26611
26612To enable compilation of this filter you need to install the frei0r
26613header and configure FFmpeg with @code{--enable-frei0r}.
26614
26615This source accepts the following parameters:
26616
26617@table @option
26618
26619@item size
26620The size of the video to generate. For the syntax of this option, check the
26621@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
26622
26623@item framerate
26624The framerate of the generated video. It may be a string of the form
26625@var{num}/@var{den} or a frame rate abbreviation.
26626
26627@item filter_name
26628The name to the frei0r source to load. For more information regarding frei0r and
26629how to set the parameters, read the @ref{frei0r} section in the video filters
26630documentation.
26631
26632@item filter_params
26633A '|'-separated list of parameters to pass to the frei0r source.
26634
26635@end table
26636
26637For example, to generate a frei0r partik0l source with size 200x200
26638and frame rate 10 which is overlaid on the overlay filter main input:
26639@example
26640frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
26641@end example
26642
26643@section life
26644
26645Generate a life pattern.
26646
26647This source is based on a generalization of John Conway's life game.
26648
26649The sourced input represents a life grid, each pixel represents a cell
26650which can be in one of two possible states, alive or dead. Every cell
26651interacts with its eight neighbours, which are the cells that are
26652horizontally, vertically, or diagonally adjacent.
26653
26654At each interaction the grid evolves according to the adopted rule,
26655which specifies the number of neighbor alive cells which will make a
26656cell stay alive or born. The @option{rule} option allows one to specify
26657the rule to adopt.
26658
26659This source accepts the following options:
26660
26661@table @option
26662@item filename, f
26663Set the file from which to read the initial grid state. In the file,
26664each non-whitespace character is considered an alive cell, and newline
26665is used to delimit the end of each row.
26666
26667If this option is not specified, the initial grid is generated
26668randomly.
26669
26670@item rate, r
26671Set the video rate, that is the number of frames generated per second.
26672Default is 25.
26673
26674@item random_fill_ratio, ratio
26675Set the random fill ratio for the initial random grid. It is a
26676floating point number value ranging from 0 to 1, defaults to 1/PHI.
26677It is ignored when a file is specified.
26678
26679@item random_seed, seed
26680Set the seed for filling the initial random grid, must be an integer
26681included between 0 and UINT32_MAX. If not specified, or if explicitly
26682set to -1, the filter will try to use a good random seed on a best
26683effort basis.
26684
26685@item rule
26686Set the life rule.
26687
26688A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
26689where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
26690@var{NS} specifies the number of alive neighbor cells which make a
26691live cell stay alive, and @var{NB} the number of alive neighbor cells
26692which make a dead cell to become alive (i.e. to "born").
26693"s" and "b" can be used in place of "S" and "B", respectively.
26694
26695Alternatively a rule can be specified by an 18-bits integer. The 9
26696high order bits are used to encode the next cell state if it is alive
26697for each number of neighbor alive cells, the low order bits specify
26698the rule for "borning" new cells. Higher order bits encode for an
26699higher number of neighbor cells.
26700For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
26701rule of 12 and a born rule of 9, which corresponds to "S23/B03".
26702
26703Default value is "S23/B3", which is the original Conway's game of life
26704rule, and will keep a cell alive if it has 2 or 3 neighbor alive
26705cells, and will born a new cell if there are three alive cells around
26706a dead cell.
26707
26708@item size, s
26709Set the size of the output video. For the syntax of this option, check the
26710@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
26711
26712If @option{filename} is specified, the size is set by default to the
26713same size of the input file. If @option{size} is set, it must contain
26714the size specified in the input file, and the initial grid defined in
26715that file is centered in the larger resulting area.
26716
26717If a filename is not specified, the size value defaults to "320x240"
26718(used for a randomly generated initial grid).
26719
26720@item stitch
26721If set to 1, stitch the left and right grid edges together, and the
26722top and bottom edges also. Defaults to 1.
26723
26724@item mold
26725Set cell mold speed. If set, a dead cell will go from @option{death_color} to
26726@option{mold_color} with a step of @option{mold}. @option{mold} can have a
26727value from 0 to 255.
26728
26729@item life_color
26730Set the color of living (or new born) cells.
26731
26732@item death_color
26733Set the color of dead cells. If @option{mold} is set, this is the first color
26734used to represent a dead cell.
26735
26736@item mold_color
26737Set mold color, for definitely dead and moldy cells.
26738
26739For the syntax of these 3 color options, check the @ref{color syntax,,"Color" section in the
26740ffmpeg-utils manual,ffmpeg-utils}.
26741@end table
26742
26743@subsection Examples
26744
26745@itemize
26746@item
26747Read a grid from @file{pattern}, and center it on a grid of size
26748300x300 pixels:
26749@example
26750life=f=pattern:s=300x300
26751@end example
26752
26753@item
26754Generate a random grid of size 200x200, with a fill ratio of 2/3:
26755@example
26756life=ratio=2/3:s=200x200
26757@end example
26758
26759@item
26760Specify a custom rule for evolving a randomly generated grid:
26761@example
26762life=rule=S14/B34
26763@end example
26764
26765@item
26766Full example with slow death effect (mold) using @command{ffplay}:
26767@example
26768ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
26769@end example
26770@end itemize
26771
26772@anchor{allrgb}
26773@anchor{allyuv}
26774@anchor{color}
26775@anchor{colorchart}
26776@anchor{colorspectrum}
26777@anchor{haldclutsrc}
26778@anchor{nullsrc}
26779@anchor{pal75bars}
26780@anchor{pal100bars}
26781@anchor{rgbtestsrc}
26782@anchor{smptebars}
26783@anchor{smptehdbars}
26784@anchor{testsrc}
26785@anchor{testsrc2}
26786@anchor{yuvtestsrc}
26787@section allrgb, allyuv, color, colorchart, colorspectrum, haldclutsrc, nullsrc, pal75bars, pal100bars, rgbtestsrc, smptebars, smptehdbars, testsrc, testsrc2, yuvtestsrc
26788
26789The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
26790
26791The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
26792
26793The @code{color} source provides an uniformly colored input.
26794
26795The @code{colorchart} source provides a colors checker chart.
26796
26797The @code{colorspectrum} source provides a color spectrum input.
26798
26799The @code{haldclutsrc} source provides an identity Hald CLUT. See also
26800@ref{haldclut} filter.
26801
26802The @code{nullsrc} source returns unprocessed video frames. It is
26803mainly useful to be employed in analysis / debugging tools, or as the
26804source for filters which ignore the input data.
26805
26806The @code{pal75bars} source generates a color bars pattern, based on
26807EBU PAL recommendations with 75% color levels.
26808
26809The @code{pal100bars} source generates a color bars pattern, based on
26810EBU PAL recommendations with 100% color levels.
26811
26812The @code{rgbtestsrc} source generates an RGB test pattern useful for
26813detecting RGB vs BGR issues. You should see a red, green and blue
26814stripe from top to bottom.
26815
26816The @code{smptebars} source generates a color bars pattern, based on
26817the SMPTE Engineering Guideline EG 1-1990.
26818
26819The @code{smptehdbars} source generates a color bars pattern, based on
26820the SMPTE RP 219-2002.
26821
26822The @code{testsrc} source generates a test video pattern, showing a
26823color pattern, a scrolling gradient and a timestamp. This is mainly
26824intended for testing purposes.
26825
26826The @code{testsrc2} source is similar to testsrc, but supports more
26827pixel formats instead of just @code{rgb24}. This allows using it as an
26828input for other tests without requiring a format conversion.
26829
26830The @code{yuvtestsrc} source generates an YUV test pattern. You should
26831see a y, cb and cr stripe from top to bottom.
26832
26833The sources accept the following parameters:
26834
26835@table @option
26836
26837@item level
26838Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
26839source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
26840pixels to be used as identity matrix for 3D lookup tables. Each component is
26841coded on a @code{1/(N*N)} scale.
26842
26843@item color, c
26844Specify the color of the source, only available in the @code{color}
26845source. For the syntax of this option, check the
26846@ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}.
26847
26848@item size, s
26849Specify the size of the sourced video. For the syntax of this option, check the
26850@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
26851The default value is @code{320x240}.
26852
26853This option is not available with the @code{allrgb}, @code{allyuv}, and
26854@code{haldclutsrc} filters.
26855
26856@item rate, r
26857Specify the frame rate of the sourced video, as the number of frames
26858generated per second. It has to be a string in the format
26859@var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
26860number or a valid video frame rate abbreviation. The default value is
26861"25".
26862
26863@item duration, d
26864Set the duration of the sourced video. See
26865@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
26866for the accepted syntax.
26867
26868If not specified, or the expressed duration is negative, the video is
26869supposed to be generated forever.
26870
26871Since the frame rate is used as time base, all frames including the last one
26872will have their full duration. If the specified duration is not a multiple
26873of the frame duration, it will be rounded up.
26874
26875@item sar
26876Set the sample aspect ratio of the sourced video.
26877
26878@item alpha
26879Specify the alpha (opacity) of the background, only available in the
26880@code{testsrc2} source. The value must be between 0 (fully transparent) and
26881255 (fully opaque, the default).
26882
26883@item decimals, n
26884Set the number of decimals to show in the timestamp, only available in the
26885@code{testsrc} source.
26886
26887The displayed timestamp value will correspond to the original
26888timestamp value multiplied by the power of 10 of the specified
26889value. Default value is 0.
26890
26891@item type
26892Set the type of the color spectrum, only available in the
26893@code{colorspectrum} source. Can be one of the following:
26894
26895@table @samp
26896@item black
26897@item white
26898@item all
26899@end table
26900
26901@item patch_size
26902Set patch size of single color patch, only available in the
26903@code{colorchart} source. Default is @code{64x64}.
26904
26905@item preset
26906Set colorchecker colors preset, only available in the
26907@code{colorchart} source.
26908
26909Available values are:
26910@table @samp
26911@item reference
26912@item skintones
26913@end table
26914
26915Default value is @code{reference}.
26916@end table
26917
26918@subsection Examples
26919
26920@itemize
26921@item
26922Generate a video with a duration of 5.3 seconds, with size
26923176x144 and a frame rate of 10 frames per second:
26924@example
26925testsrc=duration=5.3:size=qcif:rate=10
26926@end example
26927
26928@item
26929The following graph description will generate a red source
26930with an opacity of 0.2, with size "qcif" and a frame rate of 10
26931frames per second:
26932@example
26933color=c=red@@0.2:s=qcif:r=10
26934@end example
26935
26936@item
26937If the input content is to be ignored, @code{nullsrc} can be used. The
26938following command generates noise in the luminance plane by employing
26939the @code{geq} filter:
26940@example
26941nullsrc=s=256x256, geq=random(1)*255:128:128
26942@end example
26943@end itemize
26944
26945@subsection Commands
26946
26947The @code{color} source supports the following commands:
26948
26949@table @option
26950@item c, color
26951Set the color of the created image. Accepts the same syntax of the
26952corresponding @option{color} option.
26953@end table
26954
26955@section openclsrc
26956
26957Generate video using an OpenCL program.
26958
26959@table @option
26960
26961@item source
26962OpenCL program source file.
26963
26964@item kernel
26965Kernel name in program.
26966
26967@item size, s
26968Size of frames to generate.  This must be set.
26969
26970@item format
26971Pixel format to use for the generated frames.  This must be set.
26972
26973@item rate, r
26974Number of frames generated every second.  Default value is '25'.
26975
26976@end table
26977
26978For details of how the program loading works, see the @ref{program_opencl}
26979filter.
26980
26981Example programs:
26982
26983@itemize
26984@item
26985Generate a colour ramp by setting pixel values from the position of the pixel
26986in the output image.  (Note that this will work with all pixel formats, but
26987the generated output will not be the same.)
26988@verbatim
26989__kernel void ramp(__write_only image2d_t dst,
26990                   unsigned int index)
26991{
26992    int2 loc = (int2)(get_global_id(0), get_global_id(1));
26993
26994    float4 val;
26995    val.xy = val.zw = convert_float2(loc) / convert_float2(get_image_dim(dst));
26996
26997    write_imagef(dst, loc, val);
26998}
26999@end verbatim
27000
27001@item
27002Generate a Sierpinski carpet pattern, panning by a single pixel each frame.
27003@verbatim
27004__kernel void sierpinski_carpet(__write_only image2d_t dst,
27005                                unsigned int index)
27006{
27007    int2 loc = (int2)(get_global_id(0), get_global_id(1));
27008
27009    float4 value = 0.0f;
27010    int x = loc.x + index;
27011    int y = loc.y + index;
27012    while (x > 0 || y > 0) {
27013        if (x % 3 == 1 && y % 3 == 1) {
27014            value = 1.0f;
27015            break;
27016        }
27017        x /= 3;
27018        y /= 3;
27019    }
27020
27021    write_imagef(dst, loc, value);
27022}
27023@end verbatim
27024
27025@end itemize
27026
27027@section sierpinski
27028
27029Generate a Sierpinski carpet/triangle fractal, and randomly pan around.
27030
27031This source accepts the following options:
27032
27033@table @option
27034@item size, s
27035Set frame size. For the syntax of this option, check the @ref{video size syntax,,"Video
27036size" section in the ffmpeg-utils manual,ffmpeg-utils}. Default value is "640x480".
27037
27038@item rate, r
27039Set frame rate, expressed as number of frames per second. Default
27040value is "25".
27041
27042@item seed
27043Set seed which is used for random panning.
27044
27045@item jump
27046Set max jump for single pan destination. Allowed range is from 1 to 10000.
27047
27048@item type
27049Set fractal type, can be default @code{carpet} or @code{triangle}.
27050@end table
27051
27052@c man end VIDEO SOURCES
27053
27054@chapter Video Sinks
27055@c man begin VIDEO SINKS
27056
27057Below is a description of the currently available video sinks.
27058
27059@section buffersink
27060
27061Buffer video frames, and make them available to the end of the filter
27062graph.
27063
27064This sink is mainly intended for programmatic use, in particular
27065through the interface defined in @file{libavfilter/buffersink.h}
27066or the options system.
27067
27068It accepts a pointer to an AVBufferSinkContext structure, which
27069defines the incoming buffers' formats, to be passed as the opaque
27070parameter to @code{avfilter_init_filter} for initialization.
27071
27072@section nullsink
27073
27074Null video sink: do absolutely nothing with the input video. It is
27075mainly useful as a template and for use in analysis / debugging
27076tools.
27077
27078@c man end VIDEO SINKS
27079
27080@chapter Multimedia Filters
27081@c man begin MULTIMEDIA FILTERS
27082
27083Below is a description of the currently available multimedia filters.
27084
27085@section abitscope
27086
27087Convert input audio to a video output, displaying the audio bit scope.
27088
27089The filter accepts the following options:
27090
27091@table @option
27092@item rate, r
27093Set frame rate, expressed as number of frames per second. Default
27094value is "25".
27095
27096@item size, s
27097Specify the video size for the output. For the syntax of this option, check the
27098@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
27099Default value is @code{1024x256}.
27100
27101@item colors
27102Specify list of colors separated by space or by '|' which will be used to
27103draw channels. Unrecognized or missing colors will be replaced
27104by white color.
27105
27106@item mode, m
27107Set output mode. Can be @code{bars} or @code{trace}. Default is @code{bars}.
27108@end table
27109
27110@section adrawgraph
27111Draw a graph using input audio metadata.
27112
27113See @ref{drawgraph}
27114
27115@section agraphmonitor
27116
27117See @ref{graphmonitor}.
27118
27119@section ahistogram
27120
27121Convert input audio to a video output, displaying the volume histogram.
27122
27123The filter accepts the following options:
27124
27125@table @option
27126@item dmode
27127Specify how histogram is calculated.
27128
27129It accepts the following values:
27130@table @samp
27131@item single
27132Use single histogram for all channels.
27133@item separate
27134Use separate histogram for each channel.
27135@end table
27136Default is @code{single}.
27137
27138@item rate, r
27139Set frame rate, expressed as number of frames per second. Default
27140value is "25".
27141
27142@item size, s
27143Specify the video size for the output. For the syntax of this option, check the
27144@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
27145Default value is @code{hd720}.
27146
27147@item scale
27148Set display scale.
27149
27150It accepts the following values:
27151@table @samp
27152@item log
27153logarithmic
27154@item sqrt
27155square root
27156@item cbrt
27157cubic root
27158@item lin
27159linear
27160@item rlog
27161reverse logarithmic
27162@end table
27163Default is @code{log}.
27164
27165@item ascale
27166Set amplitude scale.
27167
27168It accepts the following values:
27169@table @samp
27170@item log
27171logarithmic
27172@item lin
27173linear
27174@end table
27175Default is @code{log}.
27176
27177@item acount
27178Set how much frames to accumulate in histogram.
27179Default is 1. Setting this to -1 accumulates all frames.
27180
27181@item rheight
27182Set histogram ratio of window height.
27183
27184@item slide
27185Set sonogram sliding.
27186
27187It accepts the following values:
27188@table @samp
27189@item replace
27190replace old rows with new ones.
27191@item scroll
27192scroll from top to bottom.
27193@end table
27194Default is @code{replace}.
27195
27196@item hmode
27197Set histogram mode.
27198
27199It accepts the following values:
27200@table @samp
27201@item abs
27202Use absolute values of samples.
27203@item sign
27204Use untouched values of samples.
27205@end table
27206Default is @code{abs}.
27207@end table
27208
27209@section aphasemeter
27210
27211Measures phase of input audio, which is exported as metadata @code{lavfi.aphasemeter.phase},
27212representing mean phase of current audio frame. A video output can also be produced and is
27213enabled by default. The audio is passed through as first output.
27214
27215Audio will be rematrixed to stereo if it has a different channel layout. Phase value is in
27216range @code{[-1, 1]} where @code{-1} means left and right channels are completely out of phase
27217and @code{1} means channels are in phase.
27218
27219The filter accepts the following options, all related to its video output:
27220
27221@table @option
27222@item rate, r
27223Set the output frame rate. Default value is @code{25}.
27224
27225@item size, s
27226Set the video size for the output. For the syntax of this option, check the
27227@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
27228Default value is @code{800x400}.
27229
27230@item rc
27231@item gc
27232@item bc
27233Specify the red, green, blue contrast. Default values are @code{2},
27234@code{7} and @code{1}.
27235Allowed range is @code{[0, 255]}.
27236
27237@item mpc
27238Set color which will be used for drawing median phase. If color is
27239@code{none} which is default, no median phase value will be drawn.
27240
27241@item video
27242Enable video output. Default is enabled.
27243@end table
27244
27245@subsection phasing detection
27246
27247The filter also detects out of phase and mono sequences in stereo streams.
27248It logs the sequence start, end and duration when it lasts longer or as long as the minimum set.
27249
27250The filter accepts the following options for this detection:
27251
27252@table @option
27253@item phasing
27254Enable mono and out of phase detection. Default is disabled.
27255
27256@item tolerance, t
27257Set phase tolerance for mono detection, in amplitude ratio. Default is @code{0}.
27258Allowed range is @code{[0, 1]}.
27259
27260@item angle, a
27261Set angle threshold for out of phase detection, in degree. Default is @code{170}.
27262Allowed range is @code{[90, 180]}.
27263
27264@item duration, d
27265Set mono or out of phase duration until notification, expressed in seconds. Default is @code{2}.
27266@end table
27267
27268@subsection Examples
27269
27270@itemize
27271@item
27272Complete example with @command{ffmpeg} to detect 1 second of mono with 0.001 phase tolerance:
27273@example
27274ffmpeg -i stereo.wav -af aphasemeter=video=0:phasing=1:duration=1:tolerance=0.001 -f null -
27275@end example
27276@end itemize
27277
27278@section avectorscope
27279
27280Convert input audio to a video output, representing the audio vector
27281scope.
27282
27283The filter is used to measure the difference between channels of stereo
27284audio stream. A monaural signal, consisting of identical left and right
27285signal, results in straight vertical line. Any stereo separation is visible
27286as a deviation from this line, creating a Lissajous figure.
27287If the straight (or deviation from it) but horizontal line appears this
27288indicates that the left and right channels are out of phase.
27289
27290The filter accepts the following options:
27291
27292@table @option
27293@item mode, m
27294Set the vectorscope mode.
27295
27296Available values are:
27297@table @samp
27298@item lissajous
27299Lissajous rotated by 45 degrees.
27300
27301@item lissajous_xy
27302Same as above but not rotated.
27303
27304@item polar
27305Shape resembling half of circle.
27306@end table
27307
27308Default value is @samp{lissajous}.
27309
27310@item size, s
27311Set the video size for the output. For the syntax of this option, check the
27312@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
27313Default value is @code{400x400}.
27314
27315@item rate, r
27316Set the output frame rate. Default value is @code{25}.
27317
27318@item rc
27319@item gc
27320@item bc
27321@item ac
27322Specify the red, green, blue and alpha contrast. Default values are @code{40},
27323@code{160}, @code{80} and @code{255}.
27324Allowed range is @code{[0, 255]}.
27325
27326@item rf
27327@item gf
27328@item bf
27329@item af
27330Specify the red, green, blue and alpha fade. Default values are @code{15},
27331@code{10}, @code{5} and @code{5}.
27332Allowed range is @code{[0, 255]}.
27333
27334@item zoom
27335Set the zoom factor. Default value is @code{1}. Allowed range is @code{[0, 10]}.
27336Values lower than @var{1} will auto adjust zoom factor to maximal possible value.
27337
27338@item draw
27339Set the vectorscope drawing mode.
27340
27341Available values are:
27342@table @samp
27343@item dot
27344Draw dot for each sample.
27345
27346@item line
27347Draw line between previous and current sample.
27348@end table
27349
27350Default value is @samp{dot}.
27351
27352@item scale
27353Specify amplitude scale of audio samples.
27354
27355Available values are:
27356@table @samp
27357@item lin
27358Linear.
27359
27360@item sqrt
27361Square root.
27362
27363@item cbrt
27364Cubic root.
27365
27366@item log
27367Logarithmic.
27368@end table
27369
27370@item swap
27371Swap left channel axis with right channel axis.
27372
27373@item mirror
27374Mirror axis.
27375
27376@table @samp
27377@item none
27378No mirror.
27379
27380@item x
27381Mirror only x axis.
27382
27383@item y
27384Mirror only y axis.
27385
27386@item xy
27387Mirror both axis.
27388@end table
27389
27390@end table
27391
27392@subsection Examples
27393
27394@itemize
27395@item
27396Complete example using @command{ffplay}:
27397@example
27398ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
27399             [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
27400@end example
27401@end itemize
27402
27403@subsection Commands
27404
27405This filter supports the all above options as commands except options @code{size} and @code{rate}.
27406
27407@section bench, abench
27408
27409Benchmark part of a filtergraph.
27410
27411The filter accepts the following options:
27412
27413@table @option
27414@item action
27415Start or stop a timer.
27416
27417Available values are:
27418@table @samp
27419@item start
27420Get the current time, set it as frame metadata (using the key
27421@code{lavfi.bench.start_time}), and forward the frame to the next filter.
27422
27423@item stop
27424Get the current time and fetch the @code{lavfi.bench.start_time} metadata from
27425the input frame metadata to get the time difference. Time difference, average,
27426maximum and minimum time (respectively @code{t}, @code{avg}, @code{max} and
27427@code{min}) are then printed. The timestamps are expressed in seconds.
27428@end table
27429@end table
27430
27431@subsection Examples
27432
27433@itemize
27434@item
27435Benchmark @ref{selectivecolor} filter:
27436@example
27437bench=start,selectivecolor=reds=-.2 .12 -.49,bench=stop
27438@end example
27439@end itemize
27440
27441@section concat
27442
27443Concatenate audio and video streams, joining them together one after the
27444other.
27445
27446The filter works on segments of synchronized video and audio streams. All
27447segments must have the same number of streams of each type, and that will
27448also be the number of streams at output.
27449
27450The filter accepts the following options:
27451
27452@table @option
27453
27454@item n
27455Set the number of segments. Default is 2.
27456
27457@item v
27458Set the number of output video streams, that is also the number of video
27459streams in each segment. Default is 1.
27460
27461@item a
27462Set the number of output audio streams, that is also the number of audio
27463streams in each segment. Default is 0.
27464
27465@item unsafe
27466Activate unsafe mode: do not fail if segments have a different format.
27467
27468@end table
27469
27470The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
27471@var{a} audio outputs.
27472
27473There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
27474segment, in the same order as the outputs, then the inputs for the second
27475segment, etc.
27476
27477Related streams do not always have exactly the same duration, for various
27478reasons including codec frame size or sloppy authoring. For that reason,
27479related synchronized streams (e.g. a video and its audio track) should be
27480concatenated at once. The concat filter will use the duration of the longest
27481stream in each segment (except the last one), and if necessary pad shorter
27482audio streams with silence.
27483
27484For this filter to work correctly, all segments must start at timestamp 0.
27485
27486All corresponding streams must have the same parameters in all segments; the
27487filtering system will automatically select a common pixel format for video
27488streams, and a common sample format, sample rate and channel layout for
27489audio streams, but other settings, such as resolution, must be converted
27490explicitly by the user.
27491
27492Different frame rates are acceptable but will result in variable frame rate
27493at output; be sure to configure the output file to handle it.
27494
27495@subsection Examples
27496
27497@itemize
27498@item
27499Concatenate an opening, an episode and an ending, all in bilingual version
27500(video in stream 0, audio in streams 1 and 2):
27501@example
27502ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
27503  '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
27504   concat=n=3:v=1:a=2 [v] [a1] [a2]' \
27505  -map '[v]' -map '[a1]' -map '[a2]' output.mkv
27506@end example
27507
27508@item
27509Concatenate two parts, handling audio and video separately, using the
27510(a)movie sources, and adjusting the resolution:
27511@example
27512movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
27513movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
27514[v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
27515@end example
27516Note that a desync will happen at the stitch if the audio and video streams
27517do not have exactly the same duration in the first file.
27518
27519@end itemize
27520
27521@subsection Commands
27522
27523This filter supports the following commands:
27524@table @option
27525@item next
27526Close the current segment and step to the next one
27527@end table
27528
27529@anchor{ebur128}
27530@section ebur128
27531
27532EBU R128 scanner filter. This filter takes an audio stream and analyzes its loudness
27533level. By default, it logs a message at a frequency of 10Hz with the
27534Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
27535Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
27536
27537The filter can only analyze streams which have
27538sample format is double-precision floating point. The input stream will be converted to
27539this specification, if needed. Users may need to insert aformat and/or aresample filters
27540after this filter to obtain the original parameters.
27541
27542The filter also has a video output (see the @var{video} option) with a real
27543time graph to observe the loudness evolution. The graphic contains the logged
27544message mentioned above, so it is not printed anymore when this option is set,
27545unless the verbose logging is set. The main graphing area contains the
27546short-term loudness (3 seconds of analysis), and the gauge on the right is for
27547the momentary loudness (400 milliseconds), but can optionally be configured
27548to instead display short-term loudness (see @var{gauge}).
27549
27550The green area marks a  +/- 1LU target range around the target loudness
27551(-23LUFS by default, unless modified through @var{target}).
27552
27553More information about the Loudness Recommendation EBU R128 on
27554@url{http://tech.ebu.ch/loudness}.
27555
27556The filter accepts the following options:
27557
27558@table @option
27559
27560@item video
27561Activate the video output. The audio stream is passed unchanged whether this
27562option is set or no. The video stream will be the first output stream if
27563activated. Default is @code{0}.
27564
27565@item size
27566Set the video size. This option is for video only. For the syntax of this
27567option, check the
27568@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
27569Default and minimum resolution is @code{640x480}.
27570
27571@item meter
27572Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
27573@code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
27574other integer value between this range is allowed.
27575
27576@item metadata
27577Set metadata injection. If set to @code{1}, the audio input will be segmented
27578into 100ms output frames, each of them containing various loudness information
27579in metadata.  All the metadata keys are prefixed with @code{lavfi.r128.}.
27580
27581Default is @code{0}.
27582
27583@item framelog
27584Force the frame logging level.
27585
27586Available values are:
27587@table @samp
27588@item info
27589information logging level
27590@item verbose
27591verbose logging level
27592@end table
27593
27594By default, the logging level is set to @var{info}. If the @option{video} or
27595the @option{metadata} options are set, it switches to @var{verbose}.
27596
27597@item peak
27598Set peak mode(s).
27599
27600Available modes can be cumulated (the option is a @code{flag} type). Possible
27601values are:
27602@table @samp
27603@item none
27604Disable any peak mode (default).
27605@item sample
27606Enable sample-peak mode.
27607
27608Simple peak mode looking for the higher sample value. It logs a message
27609for sample-peak (identified by @code{SPK}).
27610@item true
27611Enable true-peak mode.
27612
27613If enabled, the peak lookup is done on an over-sampled version of the input
27614stream for better peak accuracy. It logs a message for true-peak.
27615(identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
27616This mode requires a build with @code{libswresample}.
27617@end table
27618
27619@item dualmono
27620Treat mono input files as "dual mono". If a mono file is intended for playback
27621on a stereo system, its EBU R128 measurement will be perceptually incorrect.
27622If set to @code{true}, this option will compensate for this effect.
27623Multi-channel input files are not affected by this option.
27624
27625@item panlaw
27626Set a specific pan law to be used for the measurement of dual mono files.
27627This parameter is optional, and has a default value of -3.01dB.
27628
27629@item target
27630Set a specific target level (in LUFS) used as relative zero in the visualization.
27631This parameter is optional and has a default value of -23LUFS as specified
27632by EBU R128. However, material published online may prefer a level of -16LUFS
27633(e.g. for use with podcasts or video platforms).
27634
27635@item gauge
27636Set the value displayed by the gauge. Valid values are @code{momentary} and s
27637@code{shortterm}. By default the momentary value will be used, but in certain
27638scenarios it may be more useful to observe the short term value instead (e.g.
27639live mixing).
27640
27641@item scale
27642Sets the display scale for the loudness. Valid parameters are @code{absolute}
27643(in LUFS) or @code{relative} (LU) relative to the target. This only affects the
27644video output, not the summary or continuous log output.
27645@end table
27646
27647@subsection Examples
27648
27649@itemize
27650@item
27651Real-time graph using @command{ffplay}, with a EBU scale meter +18:
27652@example
27653ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
27654@end example
27655
27656@item
27657Run an analysis with @command{ffmpeg}:
27658@example
27659ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
27660@end example
27661@end itemize
27662
27663@section interleave, ainterleave
27664
27665Temporally interleave frames from several inputs.
27666
27667@code{interleave} works with video inputs, @code{ainterleave} with audio.
27668
27669These filters read frames from several inputs and send the oldest
27670queued frame to the output.
27671
27672Input streams must have well defined, monotonically increasing frame
27673timestamp values.
27674
27675In order to submit one frame to output, these filters need to enqueue
27676at least one frame for each input, so they cannot work in case one
27677input is not yet terminated and will not receive incoming frames.
27678
27679For example consider the case when one input is a @code{select} filter
27680which always drops input frames. The @code{interleave} filter will keep
27681reading from that input, but it will never be able to send new frames
27682to output until the input sends an end-of-stream signal.
27683
27684Also, depending on inputs synchronization, the filters will drop
27685frames in case one input receives more frames than the other ones, and
27686the queue is already filled.
27687
27688These filters accept the following options:
27689
27690@table @option
27691@item nb_inputs, n
27692Set the number of different inputs, it is 2 by default.
27693
27694@item duration
27695How to determine the end-of-stream.
27696
27697@table @option
27698@item longest
27699The duration of the longest input. (default)
27700
27701@item shortest
27702The duration of the shortest input.
27703
27704@item first
27705The duration of the first input.
27706@end table
27707
27708@end table
27709
27710@subsection Examples
27711
27712@itemize
27713@item
27714Interleave frames belonging to different streams using @command{ffmpeg}:
27715@example
27716ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
27717@end example
27718
27719@item
27720Add flickering blur effect:
27721@example
27722select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
27723@end example
27724@end itemize
27725
27726@section latency, alatency
27727Measure filtering latency.
27728
27729Report previous filter filtering latency, delay in number of audio samples for audio filters
27730or number of video frames for video filters.
27731
27732On end of input stream, filter will report min and max measured latency for previous running filter
27733in filtergraph.
27734
27735@section metadata, ametadata
27736
27737Manipulate frame metadata.
27738
27739This filter accepts the following options:
27740
27741@table @option
27742@item mode
27743Set mode of operation of the filter.
27744
27745Can be one of the following:
27746
27747@table @samp
27748@item select
27749If both @code{value} and @code{key} is set, select frames
27750which have such metadata. If only @code{key} is set, select
27751every frame that has such key in metadata.
27752
27753@item add
27754Add new metadata @code{key} and @code{value}. If key is already available
27755do nothing.
27756
27757@item modify
27758Modify value of already present key.
27759
27760@item delete
27761If @code{value} is set, delete only keys that have such value.
27762Otherwise, delete key. If @code{key} is not set, delete all metadata values in
27763the frame.
27764
27765@item print
27766Print key and its value if metadata was found. If @code{key} is not set print all
27767metadata values available in frame.
27768@end table
27769
27770@item key
27771Set key used with all modes. Must be set for all modes except @code{print} and @code{delete}.
27772
27773@item value
27774Set metadata value which will be used. This option is mandatory for
27775@code{modify} and @code{add} mode.
27776
27777@item function
27778Which function to use when comparing metadata value and @code{value}.
27779
27780Can be one of following:
27781
27782@table @samp
27783@item same_str
27784Values are interpreted as strings, returns true if metadata value is same as @code{value}.
27785
27786@item starts_with
27787Values are interpreted as strings, returns true if metadata value starts with
27788the @code{value} option string.
27789
27790@item less
27791Values are interpreted as floats, returns true if metadata value is less than @code{value}.
27792
27793@item equal
27794Values are interpreted as floats, returns true if @code{value} is equal with metadata value.
27795
27796@item greater
27797Values are interpreted as floats, returns true if metadata value is greater than @code{value}.
27798
27799@item expr
27800Values are interpreted as floats, returns true if expression from option @code{expr}
27801evaluates to true.
27802
27803@item ends_with
27804Values are interpreted as strings, returns true if metadata value ends with
27805the @code{value} option string.
27806@end table
27807
27808@item expr
27809Set expression which is used when @code{function} is set to @code{expr}.
27810The expression is evaluated through the eval API and can contain the following
27811constants:
27812
27813@table @option
27814@item VALUE1, FRAMEVAL
27815Float representation of @code{value} from metadata key.
27816
27817@item VALUE2, USERVAL
27818Float representation of @code{value} as supplied by user in @code{value} option.
27819@end table
27820
27821@item file
27822If specified in @code{print} mode, output is written to the named file. Instead of
27823plain filename any writable url can be specified. Filename ``-'' is a shorthand
27824for standard output. If @code{file} option is not set, output is written to the log
27825with AV_LOG_INFO loglevel.
27826
27827@item direct
27828Reduces buffering in print mode when output is written to a URL set using @var{file}.
27829
27830@end table
27831
27832@subsection Examples
27833
27834@itemize
27835@item
27836Print all metadata values for frames with key @code{lavfi.signalstats.YDIF} with values
27837between 0 and 1.
27838@example
27839signalstats,metadata=print:key=lavfi.signalstats.YDIF:value=0:function=expr:expr='between(VALUE1,0,1)'
27840@end example
27841@item
27842Print silencedetect output to file @file{metadata.txt}.
27843@example
27844silencedetect,ametadata=mode=print:file=metadata.txt
27845@end example
27846@item
27847Direct all metadata to a pipe with file descriptor 4.
27848@example
27849metadata=mode=print:file='pipe\:4'
27850@end example
27851@end itemize
27852
27853@section perms, aperms
27854
27855Set read/write permissions for the output frames.
27856
27857These filters are mainly aimed at developers to test direct path in the
27858following filter in the filtergraph.
27859
27860The filters accept the following options:
27861
27862@table @option
27863@item mode
27864Select the permissions mode.
27865
27866It accepts the following values:
27867@table @samp
27868@item none
27869Do nothing. This is the default.
27870@item ro
27871Set all the output frames read-only.
27872@item rw
27873Set all the output frames directly writable.
27874@item toggle
27875Make the frame read-only if writable, and writable if read-only.
27876@item random
27877Set each output frame read-only or writable randomly.
27878@end table
27879
27880@item seed
27881Set the seed for the @var{random} mode, must be an integer included between
27882@code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
27883@code{-1}, the filter will try to use a good random seed on a best effort
27884basis.
27885@end table
27886
27887Note: in case of auto-inserted filter between the permission filter and the
27888following one, the permission might not be received as expected in that
27889following filter. Inserting a @ref{format} or @ref{aformat} filter before the
27890perms/aperms filter can avoid this problem.
27891
27892@section realtime, arealtime
27893
27894Slow down filtering to match real time approximately.
27895
27896These filters will pause the filtering for a variable amount of time to
27897match the output rate with the input timestamps.
27898They are similar to the @option{re} option to @code{ffmpeg}.
27899
27900They accept the following options:
27901
27902@table @option
27903@item limit
27904Time limit for the pauses. Any pause longer than that will be considered
27905a timestamp discontinuity and reset the timer. Default is 2 seconds.
27906@item speed
27907Speed factor for processing. The value must be a float larger than zero.
27908Values larger than 1.0 will result in faster than realtime processing,
27909smaller will slow processing down. The @var{limit} is automatically adapted
27910accordingly. Default is 1.0.
27911
27912A processing speed faster than what is possible without these filters cannot
27913be achieved.
27914@end table
27915
27916@subsection Commands
27917
27918Both filters supports the all above options as @ref{commands}.
27919
27920@section segment, asegment
27921
27922Split single input stream into multiple streams.
27923
27924This filter does opposite of concat filters.
27925
27926@code{segment} works on video frames, @code{asegment} on audio samples.
27927
27928This filter accepts the following options:
27929
27930@table @option
27931@item timestamps
27932Timestamps of output segments separated by '|'. The first segment will run
27933from the beginning of the input stream. The last segment will run until
27934the end of the input stream
27935
27936@item frames, samples
27937Exact frame/sample count to split the segments.
27938@end table
27939
27940In all cases, prefixing an each segment with '+' will make it relative to the
27941previous segment.
27942
27943@subsection Examples
27944
27945@itemize
27946
27947@item
27948Split input audio stream into three output audio streams, starting at start of input audio stream
27949and storing that in 1st output audio stream, then following at 60th second and storing than in 2nd
27950output audio stream, and last after 150th second of input audio stream store in 3rd output audio stream:
27951@example
27952asegment=timestamps="60|150"
27953@end example
27954
27955@end itemize
27956
27957@anchor{select}
27958@section select, aselect
27959
27960Select frames to pass in output.
27961
27962This filter accepts the following options:
27963
27964@table @option
27965
27966@item expr, e
27967Set expression, which is evaluated for each input frame.
27968
27969If the expression is evaluated to zero, the frame is discarded.
27970
27971If the evaluation result is negative or NaN, the frame is sent to the
27972first output; otherwise it is sent to the output with index
27973@code{ceil(val)-1}, assuming that the input index starts from 0.
27974
27975For example a value of @code{1.2} corresponds to the output with index
27976@code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
27977
27978@item outputs, n
27979Set the number of outputs. The output to which to send the selected
27980frame is based on the result of the evaluation. Default value is 1.
27981@end table
27982
27983The expression can contain the following constants:
27984
27985@table @option
27986@item n
27987The (sequential) number of the filtered frame, starting from 0.
27988
27989@item selected_n
27990The (sequential) number of the selected frame, starting from 0.
27991
27992@item prev_selected_n
27993The sequential number of the last selected frame. It's NAN if undefined.
27994
27995@item TB
27996The timebase of the input timestamps.
27997
27998@item pts
27999The PTS (Presentation TimeStamp) of the filtered frame,
28000expressed in @var{TB} units. It's NAN if undefined.
28001
28002@item t
28003The PTS of the filtered frame,
28004expressed in seconds. It's NAN if undefined.
28005
28006@item prev_pts
28007The PTS of the previously filtered frame. It's NAN if undefined.
28008
28009@item prev_selected_pts
28010The PTS of the last previously filtered frame. It's NAN if undefined.
28011
28012@item prev_selected_t
28013The PTS of the last previously selected frame, expressed in seconds. It's NAN if undefined.
28014
28015@item start_pts
28016The first PTS in the stream which is not NAN. It remains NAN if not found.
28017
28018@item start_t
28019The first PTS, in seconds, in the stream which is not NAN. It remains NAN if not found.
28020
28021@item pict_type @emph{(video only)}
28022The type of the filtered frame. It can assume one of the following
28023values:
28024@table @option
28025@item I
28026@item P
28027@item B
28028@item S
28029@item SI
28030@item SP
28031@item BI
28032@end table
28033
28034@item interlace_type @emph{(video only)}
28035The frame interlace type. It can assume one of the following values:
28036@table @option
28037@item PROGRESSIVE
28038The frame is progressive (not interlaced).
28039@item TOPFIRST
28040The frame is top-field-first.
28041@item BOTTOMFIRST
28042The frame is bottom-field-first.
28043@end table
28044
28045@item consumed_sample_n @emph{(audio only)}
28046the number of selected samples before the current frame
28047
28048@item samples_n @emph{(audio only)}
28049the number of samples in the current frame
28050
28051@item sample_rate @emph{(audio only)}
28052the input sample rate
28053
28054@item key
28055This is 1 if the filtered frame is a key-frame, 0 otherwise.
28056
28057@item pos
28058the position in the file of the filtered frame, -1 if the information
28059is not available (e.g. for synthetic video)
28060
28061@item scene @emph{(video only)}
28062value between 0 and 1 to indicate a new scene; a low value reflects a low
28063probability for the current frame to introduce a new scene, while a higher
28064value means the current frame is more likely to be one (see the example below)
28065
28066@item concatdec_select
28067The concat demuxer can select only part of a concat input file by setting an
28068inpoint and an outpoint, but the output packets may not be entirely contained
28069in the selected interval. By using this variable, it is possible to skip frames
28070generated by the concat demuxer which are not exactly contained in the selected
28071interval.
28072
28073This works by comparing the frame pts against the @var{lavf.concat.start_time}
28074and the @var{lavf.concat.duration} packet metadata values which are also
28075present in the decoded frames.
28076
28077The @var{concatdec_select} variable is -1 if the frame pts is at least
28078start_time and either the duration metadata is missing or the frame pts is less
28079than start_time + duration, 0 otherwise, and NaN if the start_time metadata is
28080missing.
28081
28082That basically means that an input frame is selected if its pts is within the
28083interval set by the concat demuxer.
28084
28085@end table
28086
28087The default value of the select expression is "1".
28088
28089@subsection Examples
28090
28091@itemize
28092@item
28093Select all frames in input:
28094@example
28095select
28096@end example
28097
28098The example above is the same as:
28099@example
28100select=1
28101@end example
28102
28103@item
28104Skip all frames:
28105@example
28106select=0
28107@end example
28108
28109@item
28110Select only I-frames:
28111@example
28112select='eq(pict_type\,I)'
28113@end example
28114
28115@item
28116Select one frame every 100:
28117@example
28118select='not(mod(n\,100))'
28119@end example
28120
28121@item
28122Select only frames contained in the 10-20 time interval:
28123@example
28124select=between(t\,10\,20)
28125@end example
28126
28127@item
28128Select only I-frames contained in the 10-20 time interval:
28129@example
28130select=between(t\,10\,20)*eq(pict_type\,I)
28131@end example
28132
28133@item
28134Select frames with a minimum distance of 10 seconds:
28135@example
28136select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
28137@end example
28138
28139@item
28140Use aselect to select only audio frames with samples number > 100:
28141@example
28142aselect='gt(samples_n\,100)'
28143@end example
28144
28145@item
28146Create a mosaic of the first scenes:
28147@example
28148ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
28149@end example
28150
28151Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
28152choice.
28153
28154@item
28155Send even and odd frames to separate outputs, and compose them:
28156@example
28157select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
28158@end example
28159
28160@item
28161Select useful frames from an ffconcat file which is using inpoints and
28162outpoints but where the source files are not intra frame only.
28163@example
28164ffmpeg -copyts -vsync 0 -segment_time_metadata 1 -i input.ffconcat -vf select=concatdec_select -af aselect=concatdec_select output.avi
28165@end example
28166@end itemize
28167
28168@section sendcmd, asendcmd
28169
28170Send commands to filters in the filtergraph.
28171
28172These filters read commands to be sent to other filters in the
28173filtergraph.
28174
28175@code{sendcmd} must be inserted between two video filters,
28176@code{asendcmd} must be inserted between two audio filters, but apart
28177from that they act the same way.
28178
28179The specification of commands can be provided in the filter arguments
28180with the @var{commands} option, or in a file specified by the
28181@var{filename} option.
28182
28183These filters accept the following options:
28184@table @option
28185@item commands, c
28186Set the commands to be read and sent to the other filters.
28187@item filename, f
28188Set the filename of the commands to be read and sent to the other
28189filters.
28190@end table
28191
28192@subsection Commands syntax
28193
28194A commands description consists of a sequence of interval
28195specifications, comprising a list of commands to be executed when a
28196particular event related to that interval occurs. The occurring event
28197is typically the current frame time entering or leaving a given time
28198interval.
28199
28200An interval is specified by the following syntax:
28201@example
28202@var{START}[-@var{END}] @var{COMMANDS};
28203@end example
28204
28205The time interval is specified by the @var{START} and @var{END} times.
28206@var{END} is optional and defaults to the maximum time.
28207
28208The current frame time is considered within the specified interval if
28209it is included in the interval [@var{START}, @var{END}), that is when
28210the time is greater or equal to @var{START} and is lesser than
28211@var{END}.
28212
28213@var{COMMANDS} consists of a sequence of one or more command
28214specifications, separated by ",", relating to that interval.  The
28215syntax of a command specification is given by:
28216@example
28217[@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
28218@end example
28219
28220@var{FLAGS} is optional and specifies the type of events relating to
28221the time interval which enable sending the specified command, and must
28222be a non-null sequence of identifier flags separated by "+" or "|" and
28223enclosed between "[" and "]".
28224
28225The following flags are recognized:
28226@table @option
28227@item enter
28228The command is sent when the current frame timestamp enters the
28229specified interval. In other words, the command is sent when the
28230previous frame timestamp was not in the given interval, and the
28231current is.
28232
28233@item leave
28234The command is sent when the current frame timestamp leaves the
28235specified interval. In other words, the command is sent when the
28236previous frame timestamp was in the given interval, and the
28237current is not.
28238
28239@item expr
28240The command @var{ARG} is interpreted as expression and result of
28241expression is passed as @var{ARG}.
28242
28243The expression is evaluated through the eval API and can contain the following
28244constants:
28245
28246@table @option
28247@item POS
28248Original position in the file of the frame, or undefined if undefined
28249for the current frame.
28250
28251@item PTS
28252The presentation timestamp in input.
28253
28254@item N
28255The count of the input frame for video or audio, starting from 0.
28256
28257@item T
28258The time in seconds of the current frame.
28259
28260@item TS
28261The start time in seconds of the current command interval.
28262
28263@item TE
28264The end time in seconds of the current command interval.
28265
28266@item TI
28267The interpolated time of the current command interval, TI = (T - TS) / (TE - TS).
28268
28269@item W
28270The video frame width.
28271
28272@item H
28273The video frame height.
28274@end table
28275
28276@end table
28277
28278If @var{FLAGS} is not specified, a default value of @code{[enter]} is
28279assumed.
28280
28281@var{TARGET} specifies the target of the command, usually the name of
28282the filter class or a specific filter instance name.
28283
28284@var{COMMAND} specifies the name of the command for the target filter.
28285
28286@var{ARG} is optional and specifies the optional list of argument for
28287the given @var{COMMAND}.
28288
28289Between one interval specification and another, whitespaces, or
28290sequences of characters starting with @code{#} until the end of line,
28291are ignored and can be used to annotate comments.
28292
28293A simplified BNF description of the commands specification syntax
28294follows:
28295@example
28296@var{COMMAND_FLAG}  ::= "enter" | "leave"
28297@var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
28298@var{COMMAND}       ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
28299@var{COMMANDS}      ::= @var{COMMAND} [,@var{COMMANDS}]
28300@var{INTERVAL}      ::= @var{START}[-@var{END}] @var{COMMANDS}
28301@var{INTERVALS}     ::= @var{INTERVAL}[;@var{INTERVALS}]
28302@end example
28303
28304@subsection Examples
28305
28306@itemize
28307@item
28308Specify audio tempo change at second 4:
28309@example
28310asendcmd=c='4.0 atempo tempo 1.5',atempo
28311@end example
28312
28313@item
28314Target a specific filter instance:
28315@example
28316asendcmd=c='4.0 atempo@@my tempo 1.5',atempo@@my
28317@end example
28318
28319@item
28320Specify a list of drawtext and hue commands in a file.
28321@example
28322# show text in the interval 5-10
283235.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
28324         [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
28325
28326# desaturate the image in the interval 15-20
2832715.0-20.0 [enter] hue s 0,
28328          [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
28329          [leave] hue s 1,
28330          [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
28331
28332# apply an exponential saturation fade-out effect, starting from time 25
2833325 [enter] hue s exp(25-t)
28334@end example
28335
28336A filtergraph allowing to read and process the above command list
28337stored in a file @file{test.cmd}, can be specified with:
28338@example
28339sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
28340@end example
28341@end itemize
28342
28343@anchor{setpts}
28344@section setpts, asetpts
28345
28346Change the PTS (presentation timestamp) of the input frames.
28347
28348@code{setpts} works on video frames, @code{asetpts} on audio frames.
28349
28350This filter accepts the following options:
28351
28352@table @option
28353
28354@item expr
28355The expression which is evaluated for each frame to construct its timestamp.
28356
28357@end table
28358
28359The expression is evaluated through the eval API and can contain the following
28360constants:
28361
28362@table @option
28363@item FRAME_RATE, FR
28364frame rate, only defined for constant frame-rate video
28365
28366@item PTS
28367The presentation timestamp in input
28368
28369@item N
28370The count of the input frame for video or the number of consumed samples,
28371not including the current frame for audio, starting from 0.
28372
28373@item NB_CONSUMED_SAMPLES
28374The number of consumed samples, not including the current frame (only
28375audio)
28376
28377@item NB_SAMPLES, S
28378The number of samples in the current frame (only audio)
28379
28380@item SAMPLE_RATE, SR
28381The audio sample rate.
28382
28383@item STARTPTS
28384The PTS of the first frame.
28385
28386@item STARTT
28387the time in seconds of the first frame
28388
28389@item INTERLACED
28390State whether the current frame is interlaced.
28391
28392@item T
28393the time in seconds of the current frame
28394
28395@item POS
28396original position in the file of the frame, or undefined if undefined
28397for the current frame
28398
28399@item PREV_INPTS
28400The previous input PTS.
28401
28402@item PREV_INT
28403previous input time in seconds
28404
28405@item PREV_OUTPTS
28406The previous output PTS.
28407
28408@item PREV_OUTT
28409previous output time in seconds
28410
28411@item RTCTIME
28412The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
28413instead.
28414
28415@item RTCSTART
28416The wallclock (RTC) time at the start of the movie in microseconds.
28417
28418@item TB
28419The timebase of the input timestamps.
28420
28421@end table
28422
28423@subsection Examples
28424
28425@itemize
28426@item
28427Start counting PTS from zero
28428@example
28429setpts=PTS-STARTPTS
28430@end example
28431
28432@item
28433Apply fast motion effect:
28434@example
28435setpts=0.5*PTS
28436@end example
28437
28438@item
28439Apply slow motion effect:
28440@example
28441setpts=2.0*PTS
28442@end example
28443
28444@item
28445Set fixed rate of 25 frames per second:
28446@example
28447setpts=N/(25*TB)
28448@end example
28449
28450@item
28451Set fixed rate 25 fps with some jitter:
28452@example
28453setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
28454@end example
28455
28456@item
28457Apply an offset of 10 seconds to the input PTS:
28458@example
28459setpts=PTS+10/TB
28460@end example
28461
28462@item
28463Generate timestamps from a "live source" and rebase onto the current timebase:
28464@example
28465setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
28466@end example
28467
28468@item
28469Generate timestamps by counting samples:
28470@example
28471asetpts=N/SR/TB
28472@end example
28473
28474@end itemize
28475
28476@section setrange
28477
28478Force color range for the output video frame.
28479
28480The @code{setrange} filter marks the color range property for the
28481output frames. It does not change the input frame, but only sets the
28482corresponding property, which affects how the frame is treated by
28483following filters.
28484
28485The filter accepts the following options:
28486
28487@table @option
28488
28489@item range
28490Available values are:
28491
28492@table @samp
28493@item auto
28494Keep the same color range property.
28495
28496@item unspecified, unknown
28497Set the color range as unspecified.
28498
28499@item limited, tv, mpeg
28500Set the color range as limited.
28501
28502@item full, pc, jpeg
28503Set the color range as full.
28504@end table
28505@end table
28506
28507@section settb, asettb
28508
28509Set the timebase to use for the output frames timestamps.
28510It is mainly useful for testing timebase configuration.
28511
28512It accepts the following parameters:
28513
28514@table @option
28515
28516@item expr, tb
28517The expression which is evaluated into the output timebase.
28518
28519@end table
28520
28521The value for @option{tb} is an arithmetic expression representing a
28522rational. The expression can contain the constants "AVTB" (the default
28523timebase), "intb" (the input timebase) and "sr" (the sample rate,
28524audio only). Default value is "intb".
28525
28526@subsection Examples
28527
28528@itemize
28529@item
28530Set the timebase to 1/25:
28531@example
28532settb=expr=1/25
28533@end example
28534
28535@item
28536Set the timebase to 1/10:
28537@example
28538settb=expr=0.1
28539@end example
28540
28541@item
28542Set the timebase to 1001/1000:
28543@example
28544settb=1+0.001
28545@end example
28546
28547@item
28548Set the timebase to 2*intb:
28549@example
28550settb=2*intb
28551@end example
28552
28553@item
28554Set the default timebase value:
28555@example
28556settb=AVTB
28557@end example
28558@end itemize
28559
28560@section showcqt
28561Convert input audio to a video output representing frequency spectrum
28562logarithmically using Brown-Puckette constant Q transform algorithm with
28563direct frequency domain coefficient calculation (but the transform itself
28564is not really constant Q, instead the Q factor is actually variable/clamped),
28565with musical tone scale, from E0 to D#10.
28566
28567The filter accepts the following options:
28568
28569@table @option
28570@item size, s
28571Specify the video size for the output. It must be even. For the syntax of this option,
28572check the @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
28573Default value is @code{1920x1080}.
28574
28575@item fps, rate, r
28576Set the output frame rate. Default value is @code{25}.
28577
28578@item bar_h
28579Set the bargraph height. It must be even. Default value is @code{-1} which
28580computes the bargraph height automatically.
28581
28582@item axis_h
28583Set the axis height. It must be even. Default value is @code{-1} which computes
28584the axis height automatically.
28585
28586@item sono_h
28587Set the sonogram height. It must be even. Default value is @code{-1} which
28588computes the sonogram height automatically.
28589
28590@item fullhd
28591Set the fullhd resolution. This option is deprecated, use @var{size}, @var{s}
28592instead. Default value is @code{1}.
28593
28594@item sono_v, volume
28595Specify the sonogram volume expression. It can contain variables:
28596@table @option
28597@item bar_v
28598the @var{bar_v} evaluated expression
28599@item frequency, freq, f
28600the frequency where it is evaluated
28601@item timeclamp, tc
28602the value of @var{timeclamp} option
28603@end table
28604and functions:
28605@table @option
28606@item a_weighting(f)
28607A-weighting of equal loudness
28608@item b_weighting(f)
28609B-weighting of equal loudness
28610@item c_weighting(f)
28611C-weighting of equal loudness.
28612@end table
28613Default value is @code{16}.
28614
28615@item bar_v, volume2
28616Specify the bargraph volume expression. It can contain variables:
28617@table @option
28618@item sono_v
28619the @var{sono_v} evaluated expression
28620@item frequency, freq, f
28621the frequency where it is evaluated
28622@item timeclamp, tc
28623the value of @var{timeclamp} option
28624@end table
28625and functions:
28626@table @option
28627@item a_weighting(f)
28628A-weighting of equal loudness
28629@item b_weighting(f)
28630B-weighting of equal loudness
28631@item c_weighting(f)
28632C-weighting of equal loudness.
28633@end table
28634Default value is @code{sono_v}.
28635
28636@item sono_g, gamma
28637Specify the sonogram gamma. Lower gamma makes the spectrum more contrast,
28638higher gamma makes the spectrum having more range. Default value is @code{3}.
28639Acceptable range is @code{[1, 7]}.
28640
28641@item bar_g, gamma2
28642Specify the bargraph gamma. Default value is @code{1}. Acceptable range is
28643@code{[1, 7]}.
28644
28645@item bar_t
28646Specify the bargraph transparency level. Lower value makes the bargraph sharper.
28647Default value is @code{1}. Acceptable range is @code{[0, 1]}.
28648
28649@item timeclamp, tc
28650Specify the transform timeclamp. At low frequency, there is trade-off between
28651accuracy in time domain and frequency domain. If timeclamp is lower,
28652event in time domain is represented more accurately (such as fast bass drum),
28653otherwise event in frequency domain is represented more accurately
28654(such as bass guitar). Acceptable range is @code{[0.002, 1]}. Default value is @code{0.17}.
28655
28656@item attack
28657Set attack time in seconds. The default is @code{0} (disabled). Otherwise, it
28658limits future samples by applying asymmetric windowing in time domain, useful
28659when low latency is required. Accepted range is @code{[0, 1]}.
28660
28661@item basefreq
28662Specify the transform base frequency. Default value is @code{20.01523126408007475},
28663which is frequency 50 cents below E0. Acceptable range is @code{[10, 100000]}.
28664
28665@item endfreq
28666Specify the transform end frequency. Default value is @code{20495.59681441799654},
28667which is frequency 50 cents above D#10. Acceptable range is @code{[10, 100000]}.
28668
28669@item coeffclamp
28670This option is deprecated and ignored.
28671
28672@item tlength
28673Specify the transform length in time domain. Use this option to control accuracy
28674trade-off between time domain and frequency domain at every frequency sample.
28675It can contain variables:
28676@table @option
28677@item frequency, freq, f
28678the frequency where it is evaluated
28679@item timeclamp, tc
28680the value of @var{timeclamp} option.
28681@end table
28682Default value is @code{384*tc/(384+tc*f)}.
28683
28684@item count
28685Specify the transform count for every video frame. Default value is @code{6}.
28686Acceptable range is @code{[1, 30]}.
28687
28688@item fcount
28689Specify the transform count for every single pixel. Default value is @code{0},
28690which makes it computed automatically. Acceptable range is @code{[0, 10]}.
28691
28692@item fontfile
28693Specify font file for use with freetype to draw the axis. If not specified,
28694use embedded font. Note that drawing with font file or embedded font is not
28695implemented with custom @var{basefreq} and @var{endfreq}, use @var{axisfile}
28696option instead.
28697
28698@item font
28699Specify fontconfig pattern. This has lower priority than @var{fontfile}. The
28700@code{:} in the pattern may be replaced by @code{|} to avoid unnecessary
28701escaping.
28702
28703@item fontcolor
28704Specify font color expression. This is arithmetic expression that should return
28705integer value 0xRRGGBB. It can contain variables:
28706@table @option
28707@item frequency, freq, f
28708the frequency where it is evaluated
28709@item timeclamp, tc
28710the value of @var{timeclamp} option
28711@end table
28712and functions:
28713@table @option
28714@item midi(f)
28715midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
28716@item r(x), g(x), b(x)
28717red, green, and blue value of intensity x.
28718@end table
28719Default value is @code{st(0, (midi(f)-59.5)/12);
28720st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
28721r(1-ld(1)) + b(ld(1))}.
28722
28723@item axisfile
28724Specify image file to draw the axis. This option override @var{fontfile} and
28725@var{fontcolor} option.
28726
28727@item axis, text
28728Enable/disable drawing text to the axis. If it is set to @code{0}, drawing to
28729the axis is disabled, ignoring @var{fontfile} and @var{axisfile} option.
28730Default value is @code{1}.
28731
28732@item csp
28733Set colorspace. The accepted values are:
28734@table @samp
28735@item unspecified
28736Unspecified (default)
28737
28738@item bt709
28739BT.709
28740
28741@item fcc
28742FCC
28743
28744@item bt470bg
28745BT.470BG or BT.601-6 625
28746
28747@item smpte170m
28748SMPTE-170M or BT.601-6 525
28749
28750@item smpte240m
28751SMPTE-240M
28752
28753@item bt2020ncl
28754BT.2020 with non-constant luminance
28755
28756@end table
28757
28758@item cscheme
28759Set spectrogram color scheme. This is list of floating point values with format
28760@code{left_r|left_g|left_b|right_r|right_g|right_b}.
28761The default is @code{1|0.5|0|0|0.5|1}.
28762
28763@end table
28764
28765@subsection Examples
28766
28767@itemize
28768@item
28769Playing audio while showing the spectrum:
28770@example
28771ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
28772@end example
28773
28774@item
28775Same as above, but with frame rate 30 fps:
28776@example
28777ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
28778@end example
28779
28780@item
28781Playing at 1280x720:
28782@example
28783ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=s=1280x720:count=4 [out0]'
28784@end example
28785
28786@item
28787Disable sonogram display:
28788@example
28789sono_h=0
28790@end example
28791
28792@item
28793A1 and its harmonics: A1, A2, (near)E3, A3:
28794@example
28795ffplay -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),
28796                 asplit[a][out1]; [a] showcqt [out0]'
28797@end example
28798
28799@item
28800Same as above, but with more accuracy in frequency domain:
28801@example
28802ffplay -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),
28803                 asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
28804@end example
28805
28806@item
28807Custom volume:
28808@example
28809bar_v=10:sono_v=bar_v*a_weighting(f)
28810@end example
28811
28812@item
28813Custom gamma, now spectrum is linear to the amplitude.
28814@example
28815bar_g=2:sono_g=2
28816@end example
28817
28818@item
28819Custom tlength equation:
28820@example
28821tc=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)))'
28822@end example
28823
28824@item
28825Custom fontcolor and fontfile, C-note is colored green, others are colored blue:
28826@example
28827fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))':fontfile=myfont.ttf
28828@end example
28829
28830@item
28831Custom font using fontconfig:
28832@example
28833font='Courier New,Monospace,mono|bold'
28834@end example
28835
28836@item
28837Custom frequency range with custom axis using image file:
28838@example
28839axisfile=myaxis.png:basefreq=40:endfreq=10000
28840@end example
28841@end itemize
28842
28843@section showfreqs
28844
28845Convert input audio to video output representing the audio power spectrum.
28846Audio amplitude is on Y-axis while frequency is on X-axis.
28847
28848The filter accepts the following options:
28849
28850@table @option
28851@item size, s
28852Specify size of video. For the syntax of this option, check the
28853@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
28854Default is @code{1024x512}.
28855
28856@item rate, r
28857Set video rate. Default is @code{25}.
28858
28859@item mode
28860Set display mode.
28861This set how each frequency bin will be represented.
28862
28863It accepts the following values:
28864@table @samp
28865@item line
28866@item bar
28867@item dot
28868@end table
28869Default is @code{bar}.
28870
28871@item ascale
28872Set amplitude scale.
28873
28874It accepts the following values:
28875@table @samp
28876@item lin
28877Linear scale.
28878
28879@item sqrt
28880Square root scale.
28881
28882@item cbrt
28883Cubic root scale.
28884
28885@item log
28886Logarithmic scale.
28887@end table
28888Default is @code{log}.
28889
28890@item fscale
28891Set frequency scale.
28892
28893It accepts the following values:
28894@table @samp
28895@item lin
28896Linear scale.
28897
28898@item log
28899Logarithmic scale.
28900
28901@item rlog
28902Reverse logarithmic scale.
28903@end table
28904Default is @code{lin}.
28905
28906@item win_size
28907Set window size. Allowed range is from 16 to 65536.
28908
28909Default is @code{2048}
28910
28911@item win_func
28912Set windowing function.
28913
28914It accepts the following values:
28915@table @samp
28916@item rect
28917@item bartlett
28918@item hanning
28919@item hamming
28920@item blackman
28921@item welch
28922@item flattop
28923@item bharris
28924@item bnuttall
28925@item bhann
28926@item sine
28927@item nuttall
28928@item lanczos
28929@item gauss
28930@item tukey
28931@item dolph
28932@item cauchy
28933@item parzen
28934@item poisson
28935@item bohman
28936@end table
28937Default is @code{hanning}.
28938
28939@item overlap
28940Set window overlap. In range @code{[0, 1]}. Default is @code{1},
28941which means optimal overlap for selected window function will be picked.
28942
28943@item averaging
28944Set time averaging. Setting this to 0 will display current maximal peaks.
28945Default is @code{1}, which means time averaging is disabled.
28946
28947@item colors
28948Specify list of colors separated by space or by '|' which will be used to
28949draw channel frequencies. Unrecognized or missing colors will be replaced
28950by white color.
28951
28952@item cmode
28953Set channel display mode.
28954
28955It accepts the following values:
28956@table @samp
28957@item combined
28958@item separate
28959@end table
28960Default is @code{combined}.
28961
28962@item minamp
28963Set minimum amplitude used in @code{log} amplitude scaler.
28964
28965@item data
28966Set data display mode.
28967
28968It accepts the following values:
28969@table @samp
28970@item magnitude
28971@item phase
28972@item delay
28973@end table
28974Default is @code{magnitude}.
28975
28976@item channels
28977Set channels to use when processing audio. By default all are processed.
28978@end table
28979
28980@section showspatial
28981
28982Convert stereo input audio to a video output, representing the spatial relationship
28983between two channels.
28984
28985The filter accepts the following options:
28986
28987@table @option
28988@item size, s
28989Specify the video size for the output. For the syntax of this option, check the
28990@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
28991Default value is @code{512x512}.
28992
28993@item win_size
28994Set window size. Allowed range is from @var{1024} to @var{65536}. Default size is @var{4096}.
28995
28996@item win_func
28997Set window function.
28998
28999It accepts the following values:
29000@table @samp
29001@item rect
29002@item bartlett
29003@item hann
29004@item hanning
29005@item hamming
29006@item blackman
29007@item welch
29008@item flattop
29009@item bharris
29010@item bnuttall
29011@item bhann
29012@item sine
29013@item nuttall
29014@item lanczos
29015@item gauss
29016@item tukey
29017@item dolph
29018@item cauchy
29019@item parzen
29020@item poisson
29021@item bohman
29022@end table
29023
29024Default value is @code{hann}.
29025
29026@item overlap
29027Set ratio of overlap window. Default value is @code{0.5}.
29028When value is @code{1} overlap is set to recommended size for specific
29029window function currently used.
29030@end table
29031
29032@anchor{showspectrum}
29033@section showspectrum
29034
29035Convert input audio to a video output, representing the audio frequency
29036spectrum.
29037
29038The filter accepts the following options:
29039
29040@table @option
29041@item size, s
29042Specify the video size for the output. For the syntax of this option, check the
29043@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
29044Default value is @code{640x512}.
29045
29046@item slide
29047Specify how the spectrum should slide along the window.
29048
29049It accepts the following values:
29050@table @samp
29051@item replace
29052the samples start again on the left when they reach the right
29053@item scroll
29054the samples scroll from right to left
29055@item fullframe
29056frames are only produced when the samples reach the right
29057@item rscroll
29058the samples scroll from left to right
29059@item lreplace
29060the samples start again on the right when they reach the left
29061@end table
29062
29063Default value is @code{replace}.
29064
29065@item mode
29066Specify display mode.
29067
29068It accepts the following values:
29069@table @samp
29070@item combined
29071all channels are displayed in the same row
29072@item separate
29073all channels are displayed in separate rows
29074@end table
29075
29076Default value is @samp{combined}.
29077
29078@item color
29079Specify display color mode.
29080
29081It accepts the following values:
29082@table @samp
29083@item channel
29084each channel is displayed in a separate color
29085@item intensity
29086each channel is displayed using the same color scheme
29087@item rainbow
29088each channel is displayed using the rainbow color scheme
29089@item moreland
29090each channel is displayed using the moreland color scheme
29091@item nebulae
29092each channel is displayed using the nebulae color scheme
29093@item fire
29094each channel is displayed using the fire color scheme
29095@item fiery
29096each channel is displayed using the fiery color scheme
29097@item fruit
29098each channel is displayed using the fruit color scheme
29099@item cool
29100each channel is displayed using the cool color scheme
29101@item magma
29102each channel is displayed using the magma color scheme
29103@item green
29104each channel is displayed using the green color scheme
29105@item viridis
29106each channel is displayed using the viridis color scheme
29107@item plasma
29108each channel is displayed using the plasma color scheme
29109@item cividis
29110each channel is displayed using the cividis color scheme
29111@item terrain
29112each channel is displayed using the terrain color scheme
29113@end table
29114
29115Default value is @samp{channel}.
29116
29117@item scale
29118Specify scale used for calculating intensity color values.
29119
29120It accepts the following values:
29121@table @samp
29122@item lin
29123linear
29124@item sqrt
29125square root, default
29126@item cbrt
29127cubic root
29128@item log
29129logarithmic
29130@item 4thrt
291314th root
29132@item 5thrt
291335th root
29134@end table
29135
29136Default value is @samp{sqrt}.
29137
29138@item fscale
29139Specify frequency scale.
29140
29141It accepts the following values:
29142@table @samp
29143@item lin
29144linear
29145@item log
29146logarithmic
29147@end table
29148
29149Default value is @samp{lin}.
29150
29151@item saturation
29152Set saturation modifier for displayed colors. Negative values provide
29153alternative color scheme. @code{0} is no saturation at all.
29154Saturation must be in [-10.0, 10.0] range.
29155Default value is @code{1}.
29156
29157@item win_func
29158Set window function.
29159
29160It accepts the following values:
29161@table @samp
29162@item rect
29163@item bartlett
29164@item hann
29165@item hanning
29166@item hamming
29167@item blackman
29168@item welch
29169@item flattop
29170@item bharris
29171@item bnuttall
29172@item bhann
29173@item sine
29174@item nuttall
29175@item lanczos
29176@item gauss
29177@item tukey
29178@item dolph
29179@item cauchy
29180@item parzen
29181@item poisson
29182@item bohman
29183@end table
29184
29185Default value is @code{hann}.
29186
29187@item orientation
29188Set orientation of time vs frequency axis. Can be @code{vertical} or
29189@code{horizontal}. Default is @code{vertical}.
29190
29191@item overlap
29192Set ratio of overlap window. Default value is @code{0}.
29193When value is @code{1} overlap is set to recommended size for specific
29194window function currently used.
29195
29196@item gain
29197Set scale gain for calculating intensity color values.
29198Default value is @code{1}.
29199
29200@item data
29201Set which data to display. Can be @code{magnitude}, default or @code{phase},
29202or unwrapped phase: @code{uphase}.
29203
29204@item rotation
29205Set color rotation, must be in [-1.0, 1.0] range.
29206Default value is @code{0}.
29207
29208@item start
29209Set start frequency from which to display spectrogram. Default is @code{0}.
29210
29211@item stop
29212Set stop frequency to which to display spectrogram. Default is @code{0}.
29213
29214@item fps
29215Set upper frame rate limit. Default is @code{auto}, unlimited.
29216
29217@item legend
29218Draw time and frequency axes and legends. Default is disabled.
29219
29220@item drange
29221Set dynamic range used to calculate intensity color values. Default is 120 dBFS.
29222Allowed range is from 10 to 200.
29223
29224@item limit
29225Set upper limit of input audio samples volume in dBFS. Default is 0 dBFS.
29226Allowed range is from -100 to 100.
29227
29228@item opacity
29229Set opacity strength when using pixel format output with alpha component.
29230@end table
29231
29232The usage is very similar to the showwaves filter; see the examples in that
29233section.
29234
29235@subsection Examples
29236
29237@itemize
29238@item
29239Large window with logarithmic color scaling:
29240@example
29241showspectrum=s=1280x480:scale=log
29242@end example
29243
29244@item
29245Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
29246@example
29247ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
29248             [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
29249@end example
29250@end itemize
29251
29252@section showspectrumpic
29253
29254Convert input audio to a single video frame, representing the audio frequency
29255spectrum.
29256
29257The filter accepts the following options:
29258
29259@table @option
29260@item size, s
29261Specify the video size for the output. For the syntax of this option, check the
29262@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
29263Default value is @code{4096x2048}.
29264
29265@item mode
29266Specify display mode.
29267
29268It accepts the following values:
29269@table @samp
29270@item combined
29271all channels are displayed in the same row
29272@item separate
29273all channels are displayed in separate rows
29274@end table
29275Default value is @samp{combined}.
29276
29277@item color
29278Specify display color mode.
29279
29280It accepts the following values:
29281@table @samp
29282@item channel
29283each channel is displayed in a separate color
29284@item intensity
29285each channel is displayed using the same color scheme
29286@item rainbow
29287each channel is displayed using the rainbow color scheme
29288@item moreland
29289each channel is displayed using the moreland color scheme
29290@item nebulae
29291each channel is displayed using the nebulae color scheme
29292@item fire
29293each channel is displayed using the fire color scheme
29294@item fiery
29295each channel is displayed using the fiery color scheme
29296@item fruit
29297each channel is displayed using the fruit color scheme
29298@item cool
29299each channel is displayed using the cool color scheme
29300@item magma
29301each channel is displayed using the magma color scheme
29302@item green
29303each channel is displayed using the green color scheme
29304@item viridis
29305each channel is displayed using the viridis color scheme
29306@item plasma
29307each channel is displayed using the plasma color scheme
29308@item cividis
29309each channel is displayed using the cividis color scheme
29310@item terrain
29311each channel is displayed using the terrain color scheme
29312@end table
29313Default value is @samp{intensity}.
29314
29315@item scale
29316Specify scale used for calculating intensity color values.
29317
29318It accepts the following values:
29319@table @samp
29320@item lin
29321linear
29322@item sqrt
29323square root, default
29324@item cbrt
29325cubic root
29326@item log
29327logarithmic
29328@item 4thrt
293294th root
29330@item 5thrt
293315th root
29332@end table
29333Default value is @samp{log}.
29334
29335@item fscale
29336Specify frequency scale.
29337
29338It accepts the following values:
29339@table @samp
29340@item lin
29341linear
29342@item log
29343logarithmic
29344@end table
29345
29346Default value is @samp{lin}.
29347
29348@item saturation
29349Set saturation modifier for displayed colors. Negative values provide
29350alternative color scheme. @code{0} is no saturation at all.
29351Saturation must be in [-10.0, 10.0] range.
29352Default value is @code{1}.
29353
29354@item win_func
29355Set window function.
29356
29357It accepts the following values:
29358@table @samp
29359@item rect
29360@item bartlett
29361@item hann
29362@item hanning
29363@item hamming
29364@item blackman
29365@item welch
29366@item flattop
29367@item bharris
29368@item bnuttall
29369@item bhann
29370@item sine
29371@item nuttall
29372@item lanczos
29373@item gauss
29374@item tukey
29375@item dolph
29376@item cauchy
29377@item parzen
29378@item poisson
29379@item bohman
29380@end table
29381Default value is @code{hann}.
29382
29383@item orientation
29384Set orientation of time vs frequency axis. Can be @code{vertical} or
29385@code{horizontal}. Default is @code{vertical}.
29386
29387@item gain
29388Set scale gain for calculating intensity color values.
29389Default value is @code{1}.
29390
29391@item legend
29392Draw time and frequency axes and legends. Default is enabled.
29393
29394@item rotation
29395Set color rotation, must be in [-1.0, 1.0] range.
29396Default value is @code{0}.
29397
29398@item start
29399Set start frequency from which to display spectrogram. Default is @code{0}.
29400
29401@item stop
29402Set stop frequency to which to display spectrogram. Default is @code{0}.
29403
29404@item drange
29405Set dynamic range used to calculate intensity color values. Default is 120 dBFS.
29406Allowed range is from 10 to 200.
29407
29408@item limit
29409Set upper limit of input audio samples volume in dBFS. Default is 0 dBFS.
29410Allowed range is from -100 to 100.
29411
29412@item opacity
29413Set opacity strength when using pixel format output with alpha component.
29414@end table
29415
29416@subsection Examples
29417
29418@itemize
29419@item
29420Extract an audio spectrogram of a whole audio track
29421in a 1024x1024 picture using @command{ffmpeg}:
29422@example
29423ffmpeg -i audio.flac -lavfi showspectrumpic=s=1024x1024 spectrogram.png
29424@end example
29425@end itemize
29426
29427@section showvolume
29428
29429Convert input audio volume to a video output.
29430
29431The filter accepts the following options:
29432
29433@table @option
29434@item rate, r
29435Set video rate.
29436
29437@item b
29438Set border width, allowed range is [0, 5]. Default is 1.
29439
29440@item w
29441Set channel width, allowed range is [80, 8192]. Default is 400.
29442
29443@item h
29444Set channel height, allowed range is [1, 900]. Default is 20.
29445
29446@item f
29447Set fade, allowed range is [0, 1]. Default is 0.95.
29448
29449@item c
29450Set volume color expression.
29451
29452The expression can use the following variables:
29453
29454@table @option
29455@item VOLUME
29456Current max volume of channel in dB.
29457
29458@item PEAK
29459Current peak.
29460
29461@item CHANNEL
29462Current channel number, starting from 0.
29463@end table
29464
29465@item t
29466If set, displays channel names. Default is enabled.
29467
29468@item v
29469If set, displays volume values. Default is enabled.
29470
29471@item o
29472Set orientation, can be horizontal: @code{h} or vertical: @code{v},
29473default is @code{h}.
29474
29475@item s
29476Set step size, allowed range is [0, 5]. Default is 0, which means
29477step is disabled.
29478
29479@item p
29480Set background opacity, allowed range is [0, 1]. Default is 0.
29481
29482@item m
29483Set metering mode, can be peak: @code{p} or rms: @code{r},
29484default is @code{p}.
29485
29486@item ds
29487Set display scale, can be linear: @code{lin} or log: @code{log},
29488default is @code{lin}.
29489
29490@item dm
29491In second.
29492If set to > 0., display a line for the max level
29493in the previous seconds.
29494default is disabled: @code{0.}
29495
29496@item dmc
29497The color of the max line. Use when @code{dm} option is set to > 0.
29498default is: @code{orange}
29499@end table
29500
29501@section showwaves
29502
29503Convert input audio to a video output, representing the samples waves.
29504
29505The filter accepts the following options:
29506
29507@table @option
29508@item size, s
29509Specify the video size for the output. For the syntax of this option, check the
29510@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
29511Default value is @code{600x240}.
29512
29513@item mode
29514Set display mode.
29515
29516Available values are:
29517@table @samp
29518@item point
29519Draw a point for each sample.
29520
29521@item line
29522Draw a vertical line for each sample.
29523
29524@item p2p
29525Draw a point for each sample and a line between them.
29526
29527@item cline
29528Draw a centered vertical line for each sample.
29529@end table
29530
29531Default value is @code{point}.
29532
29533@item n
29534Set the number of samples which are printed on the same column. A
29535larger value will decrease the frame rate. Must be a positive
29536integer. This option can be set only if the value for @var{rate}
29537is not explicitly specified.
29538
29539@item rate, r
29540Set the (approximate) output frame rate. This is done by setting the
29541option @var{n}. Default value is "25".
29542
29543@item split_channels
29544Set if channels should be drawn separately or overlap. Default value is 0.
29545
29546@item colors
29547Set colors separated by '|' which are going to be used for drawing of each channel.
29548
29549@item scale
29550Set amplitude scale.
29551
29552Available values are:
29553@table @samp
29554@item lin
29555Linear.
29556
29557@item log
29558Logarithmic.
29559
29560@item sqrt
29561Square root.
29562
29563@item cbrt
29564Cubic root.
29565@end table
29566
29567Default is linear.
29568
29569@item draw
29570Set the draw mode. This is mostly useful to set for high @var{n}.
29571
29572Available values are:
29573@table @samp
29574@item scale
29575Scale pixel values for each drawn sample.
29576
29577@item full
29578Draw every sample directly.
29579@end table
29580
29581Default value is @code{scale}.
29582@end table
29583
29584@subsection Examples
29585
29586@itemize
29587@item
29588Output the input file audio and the corresponding video representation
29589at the same time:
29590@example
29591amovie=a.mp3,asplit[out0],showwaves[out1]
29592@end example
29593
29594@item
29595Create a synthetic signal and show it with showwaves, forcing a
29596frame rate of 30 frames per second:
29597@example
29598aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
29599@end example
29600@end itemize
29601
29602@section showwavespic
29603
29604Convert input audio to a single video frame, representing the samples waves.
29605
29606The filter accepts the following options:
29607
29608@table @option
29609@item size, s
29610Specify the video size for the output. For the syntax of this option, check the
29611@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
29612Default value is @code{600x240}.
29613
29614@item split_channels
29615Set if channels should be drawn separately or overlap. Default value is 0.
29616
29617@item colors
29618Set colors separated by '|' which are going to be used for drawing of each channel.
29619
29620@item scale
29621Set amplitude scale.
29622
29623Available values are:
29624@table @samp
29625@item lin
29626Linear.
29627
29628@item log
29629Logarithmic.
29630
29631@item sqrt
29632Square root.
29633
29634@item cbrt
29635Cubic root.
29636@end table
29637
29638Default is linear.
29639
29640@item draw
29641Set the draw mode.
29642
29643Available values are:
29644@table @samp
29645@item scale
29646Scale pixel values for each drawn sample.
29647
29648@item full
29649Draw every sample directly.
29650@end table
29651
29652Default value is @code{scale}.
29653
29654@item filter
29655Set the filter mode.
29656
29657Available values are:
29658@table @samp
29659@item average
29660Use average samples values for each drawn sample.
29661
29662@item peak
29663Use peak samples values for each drawn sample.
29664@end table
29665
29666Default value is @code{average}.
29667@end table
29668
29669@subsection Examples
29670
29671@itemize
29672@item
29673Extract a channel split representation of the wave form of a whole audio track
29674in a 1024x800 picture using @command{ffmpeg}:
29675@example
29676ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
29677@end example
29678@end itemize
29679
29680@section sidedata, asidedata
29681
29682Delete frame side data, or select frames based on it.
29683
29684This filter accepts the following options:
29685
29686@table @option
29687@item mode
29688Set mode of operation of the filter.
29689
29690Can be one of the following:
29691
29692@table @samp
29693@item select
29694Select every frame with side data of @code{type}.
29695
29696@item delete
29697Delete side data of @code{type}. If @code{type} is not set, delete all side
29698data in the frame.
29699
29700@end table
29701
29702@item type
29703Set side data type used with all modes. Must be set for @code{select} mode. For
29704the list of frame side data types, refer to the @code{AVFrameSideDataType} enum
29705in @file{libavutil/frame.h}. For example, to choose
29706@code{AV_FRAME_DATA_PANSCAN} side data, you must specify @code{PANSCAN}.
29707
29708@end table
29709
29710@section spectrumsynth
29711
29712Synthesize audio from 2 input video spectrums, first input stream represents
29713magnitude across time and second represents phase across time.
29714The filter will transform from frequency domain as displayed in videos back
29715to time domain as presented in audio output.
29716
29717This filter is primarily created for reversing processed @ref{showspectrum}
29718filter outputs, but can synthesize sound from other spectrograms too.
29719But in such case results are going to be poor if the phase data is not
29720available, because in such cases phase data need to be recreated, usually
29721it's just recreated from random noise.
29722For best results use gray only output (@code{channel} color mode in
29723@ref{showspectrum} filter) and @code{log} scale for magnitude video and
29724@code{lin} scale for phase video. To produce phase, for 2nd video, use
29725@code{data} option. Inputs videos should generally use @code{fullframe}
29726slide mode as that saves resources needed for decoding video.
29727
29728The filter accepts the following options:
29729
29730@table @option
29731@item sample_rate
29732Specify sample rate of output audio, the sample rate of audio from which
29733spectrum was generated may differ.
29734
29735@item channels
29736Set number of channels represented in input video spectrums.
29737
29738@item scale
29739Set scale which was used when generating magnitude input spectrum.
29740Can be @code{lin} or @code{log}. Default is @code{log}.
29741
29742@item slide
29743Set slide which was used when generating inputs spectrums.
29744Can be @code{replace}, @code{scroll}, @code{fullframe} or @code{rscroll}.
29745Default is @code{fullframe}.
29746
29747@item win_func
29748Set window function used for resynthesis.
29749
29750@item overlap
29751Set window overlap. In range @code{[0, 1]}. Default is @code{1},
29752which means optimal overlap for selected window function will be picked.
29753
29754@item orientation
29755Set orientation of input videos. Can be @code{vertical} or @code{horizontal}.
29756Default is @code{vertical}.
29757@end table
29758
29759@subsection Examples
29760
29761@itemize
29762@item
29763First create magnitude and phase videos from audio, assuming audio is stereo with 44100 sample rate,
29764then resynthesize videos back to audio with spectrumsynth:
29765@example
29766ffmpeg -i input.flac -lavfi showspectrum=mode=separate:scale=log:overlap=0.875:color=channel:slide=fullframe:data=magnitude -an -c:v rawvideo magnitude.nut
29767ffmpeg -i input.flac -lavfi showspectrum=mode=separate:scale=lin:overlap=0.875:color=channel:slide=fullframe:data=phase -an -c:v rawvideo phase.nut
29768ffmpeg -i magnitude.nut -i phase.nut -lavfi spectrumsynth=channels=2:sample_rate=44100:win_func=hann:overlap=0.875:slide=fullframe output.flac
29769@end example
29770@end itemize
29771
29772@section split, asplit
29773
29774Split input into several identical outputs.
29775
29776@code{asplit} works with audio input, @code{split} with video.
29777
29778The filter accepts a single parameter which specifies the number of outputs. If
29779unspecified, it defaults to 2.
29780
29781@subsection Examples
29782
29783@itemize
29784@item
29785Create two separate outputs from the same input:
29786@example
29787[in] split [out0][out1]
29788@end example
29789
29790@item
29791To create 3 or more outputs, you need to specify the number of
29792outputs, like in:
29793@example
29794[in] asplit=3 [out0][out1][out2]
29795@end example
29796
29797@item
29798Create two separate outputs from the same input, one cropped and
29799one padded:
29800@example
29801[in] split [splitout1][splitout2];
29802[splitout1] crop=100:100:0:0    [cropout];
29803[splitout2] pad=200:200:100:100 [padout];
29804@end example
29805
29806@item
29807Create 5 copies of the input audio with @command{ffmpeg}:
29808@example
29809ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
29810@end example
29811@end itemize
29812
29813@section zmq, azmq
29814
29815Receive commands sent through a libzmq client, and forward them to
29816filters in the filtergraph.
29817
29818@code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
29819must be inserted between two video filters, @code{azmq} between two
29820audio filters. Both are capable to send messages to any filter type.
29821
29822To enable these filters you need to install the libzmq library and
29823headers and configure FFmpeg with @code{--enable-libzmq}.
29824
29825For more information about libzmq see:
29826@url{http://www.zeromq.org/}
29827
29828The @code{zmq} and @code{azmq} filters work as a libzmq server, which
29829receives messages sent through a network interface defined by the
29830@option{bind_address} (or the abbreviation "@option{b}") option.
29831Default value of this option is @file{tcp://localhost:5555}. You may
29832want to alter this value to your needs, but do not forget to escape any
29833':' signs (see @ref{filtergraph escaping}).
29834
29835The received message must be in the form:
29836@example
29837@var{TARGET} @var{COMMAND} [@var{ARG}]
29838@end example
29839
29840@var{TARGET} specifies the target of the command, usually the name of
29841the filter class or a specific filter instance name. The default
29842filter instance name uses the pattern @samp{Parsed_<filter_name>_<index>},
29843but you can override this by using the @samp{filter_name@@id} syntax
29844(see @ref{Filtergraph syntax}).
29845
29846@var{COMMAND} specifies the name of the command for the target filter.
29847
29848@var{ARG} is optional and specifies the optional argument list for the
29849given @var{COMMAND}.
29850
29851Upon reception, the message is processed and the corresponding command
29852is injected into the filtergraph. Depending on the result, the filter
29853will send a reply to the client, adopting the format:
29854@example
29855@var{ERROR_CODE} @var{ERROR_REASON}
29856@var{MESSAGE}
29857@end example
29858
29859@var{MESSAGE} is optional.
29860
29861@subsection Examples
29862
29863Look at @file{tools/zmqsend} for an example of a zmq client which can
29864be used to send commands processed by these filters.
29865
29866Consider the following filtergraph generated by @command{ffplay}.
29867In this example the last overlay filter has an instance name. All other
29868filters will have default instance names.
29869
29870@example
29871ffplay -dumpgraph 1 -f lavfi "
29872color=s=100x100:c=red  [l];
29873color=s=100x100:c=blue [r];
29874nullsrc=s=200x100, zmq [bg];
29875[bg][l]   overlay     [bg+l];
29876[bg+l][r] overlay@@my=x=100 "
29877@end example
29878
29879To change the color of the left side of the video, the following
29880command can be used:
29881@example
29882echo Parsed_color_0 c yellow | tools/zmqsend
29883@end example
29884
29885To change the right side:
29886@example
29887echo Parsed_color_1 c pink | tools/zmqsend
29888@end example
29889
29890To change the position of the right side:
29891@example
29892echo overlay@@my x 150 | tools/zmqsend
29893@end example
29894
29895
29896@c man end MULTIMEDIA FILTERS
29897
29898@chapter Multimedia Sources
29899@c man begin MULTIMEDIA SOURCES
29900
29901Below is a description of the currently available multimedia sources.
29902
29903@section amovie
29904
29905This is the same as @ref{movie} source, except it selects an audio
29906stream by default.
29907
29908@section avsynctest
29909Generate an Audio/Video Sync Test.
29910
29911Generated stream periodically shows flash video frame and emits beep in audio.
29912Useful to inspect A/V sync issues.
29913
29914It accepts the following options:
29915
29916@table @option
29917@item size, s
29918Set output video size. Default value is @code{hd720}.
29919
29920@item framerate, fr
29921Set output video frame rate. Default value is @code{30}.
29922
29923@item samplerate, sr
29924Set output audio sample rate. Default value is @code{44100}.
29925
29926@item amplitude, a
29927Set output audio beep amplitude. Default value is @code{0.7}.
29928
29929@item period, p
29930Set output audio beep period in seconds. Default value is @code{3}.
29931
29932@item delay, dl
29933Set output video flash delay in number of frames. Default value is @code{0}.
29934
29935@item cycle, c
29936Enable cycling of video delays, by default is disabled.
29937
29938@item duration, d
29939Set stream output duration. By default duration is unlimited.
29940
29941@item fg, bg, ag
29942Set foreground/background/additional color.
29943@end table
29944
29945@anchor{movie}
29946@section movie
29947
29948Read audio and/or video stream(s) from a movie container.
29949
29950It accepts the following parameters:
29951
29952@table @option
29953@item filename
29954The name of the resource to read (not necessarily a file; it can also be a
29955device or a stream accessed through some protocol).
29956
29957@item format_name, f
29958Specifies the format assumed for the movie to read, and can be either
29959the name of a container or an input device. If not specified, the
29960format is guessed from @var{movie_name} or by probing.
29961
29962@item seek_point, sp
29963Specifies the seek point in seconds. The frames will be output
29964starting from this seek point. The parameter is evaluated with
29965@code{av_strtod}, so the numerical value may be suffixed by an IS
29966postfix. The default value is "0".
29967
29968@item streams, s
29969Specifies the streams to read. Several streams can be specified,
29970separated by "+". The source will then have as many outputs, in the
29971same order. The syntax is explained in the @ref{Stream specifiers,,"Stream specifiers"
29972section in the ffmpeg manual,ffmpeg}. Two special names, "dv" and "da" specify
29973respectively the default (best suited) video and audio stream. Default
29974is "dv", or "da" if the filter is called as "amovie".
29975
29976@item stream_index, si
29977Specifies the index of the video stream to read. If the value is -1,
29978the most suitable video stream will be automatically selected. The default
29979value is "-1". Deprecated. If the filter is called "amovie", it will select
29980audio instead of video.
29981
29982@item loop
29983Specifies how many times to read the stream in sequence.
29984If the value is 0, the stream will be looped infinitely.
29985Default value is "1".
29986
29987Note that when the movie is looped the source timestamps are not
29988changed, so it will generate non monotonically increasing timestamps.
29989
29990@item discontinuity
29991Specifies the time difference between frames above which the point is
29992considered a timestamp discontinuity which is removed by adjusting the later
29993timestamps.
29994
29995@item dec_threads
29996Specifies the number of threads for decoding
29997
29998@item format_opts
29999Specify format options for the opened file. Format options can be specified
30000as a list of @var{key}=@var{value} pairs separated by ':'. The following example
30001shows how to add protocol_whitelist and protocol_blacklist options:
30002@example
30003ffplay -f lavfi
30004"movie=filename='1.sdp':format_opts='protocol_whitelist=file,rtp,udp\:protocol_blacklist=http'"
30005@end example
30006@end table
30007
30008It allows overlaying a second video on top of the main input of
30009a filtergraph, as shown in this graph:
30010@example
30011input -----------> deltapts0 --> overlay --> output
30012                                    ^
30013                                    |
30014movie --> scale--> deltapts1 -------+
30015@end example
30016@subsection Examples
30017
30018@itemize
30019@item
30020Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
30021on top of the input labelled "in":
30022@example
30023movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
30024[in] setpts=PTS-STARTPTS [main];
30025[main][over] overlay=16:16 [out]
30026@end example
30027
30028@item
30029Read from a video4linux2 device, and overlay it on top of the input
30030labelled "in":
30031@example
30032movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
30033[in] setpts=PTS-STARTPTS [main];
30034[main][over] overlay=16:16 [out]
30035@end example
30036
30037@item
30038Read the first video stream and the audio stream with id 0x81 from
30039dvd.vob; the video is connected to the pad named "video" and the audio is
30040connected to the pad named "audio":
30041@example
30042movie=dvd.vob:s=v:0+#0x81 [video] [audio]
30043@end example
30044@end itemize
30045
30046@subsection Commands
30047
30048Both movie and amovie support the following commands:
30049@table @option
30050@item seek
30051Perform seek using "av_seek_frame".
30052The syntax is: seek @var{stream_index}|@var{timestamp}|@var{flags}
30053@itemize
30054@item
30055@var{stream_index}: If stream_index is -1, a default
30056stream is selected, and @var{timestamp} is automatically converted
30057from AV_TIME_BASE units to the stream specific time_base.
30058@item
30059@var{timestamp}: Timestamp in AVStream.time_base units
30060or, if no stream is specified, in AV_TIME_BASE units.
30061@item
30062@var{flags}: Flags which select direction and seeking mode.
30063@end itemize
30064
30065@item get_duration
30066Get movie duration in AV_TIME_BASE units.
30067
30068@end table
30069
30070@c man end MULTIMEDIA SOURCES
30071