lavfi: add a filter for uploading normal frames to CUDA
[libav.git] / doc / filters.texi
CommitLineData
1ebe5c4c
SS
1@chapter Filtergraph description
2@c man begin FILTERGRAPH DESCRIPTION
3
4A filtergraph is a directed graph of connected filters. It can contain
5cycles, and there can be multiple links between a pair of
6filters. Each link has one input pad on one side connecting it to one
7filter from which it takes its input, and one output pad on the other
d4a8a86c 8side connecting it to one filter accepting its output.
1ebe5c4c
SS
9
10Each filter in a filtergraph is an instance of a filter class
11registered in the application, which defines the features and the
12number of input and output pads of the filter.
13
d4a8a86c 14A filter with no input pads is called a "source", and a filter with no
1ebe5c4c
SS
15output pads is called a "sink".
16
3b266da3 17@anchor{Filtergraph syntax}
1ebe5c4c
SS
18@section Filtergraph syntax
19
d4a8a86c 20A filtergraph has a textual representation, which is
7ce118ba
AK
21recognized by the @option{-filter}/@option{-vf} and @option{-filter_complex}
22options in @command{avconv} and @option{-vf} in @command{avplay}, and by the
d4a8a86c 23@code{avfilter_graph_parse()}/@code{avfilter_graph_parse2()} functions defined in
38f0c078 24@file{libavfilter/avfilter.h}.
1ebe5c4c
SS
25
26A filterchain consists of a sequence of connected filters, each one
27connected to the previous one in the sequence. A filterchain is
28represented by a list of ","-separated filter descriptions.
29
30A filtergraph consists of a sequence of filterchains. A sequence of
31filterchains is represented by a list of ";"-separated filterchain
32descriptions.
33
34A filter is represented by a string of the form:
35[@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
36
37@var{filter_name} is the name of the filter class of which the
38described filter is an instance of, and has to be the name of one of
39the filter classes registered in the program.
40The name of the filter class is optionally followed by a string
41"=@var{arguments}".
42
43@var{arguments} is a string which contains the parameters used to
d4a8a86c 44initialize the filter instance. It may have one of two forms:
b439c992
AK
45@itemize
46
47@item
48A ':'-separated list of @var{key=value} pairs.
49
50@item
51A ':'-separated list of @var{value}. In this case, the keys are assumed to be
52the option names in the order they are declared. E.g. the @code{fade} filter
53declares three options in this order -- @option{type}, @option{start_frame} and
54@option{nb_frames}. Then the parameter list @var{in:0:30} means that the value
55@var{in} is assigned to the option @option{type}, @var{0} to
56@option{start_frame} and @var{30} to @option{nb_frames}.
57
58@end itemize
59
60If the option value itself is a list of items (e.g. the @code{format} filter
61takes a list of pixel formats), the items in the list are usually separated by
62'|'.
1ebe5c4c
SS
63
64The list of arguments can be quoted using the character "'" as initial
65and ending mark, and the character '\' for escaping the characters
66within the quoted text; otherwise the argument string is considered
67terminated when the next special character (belonging to the set
68"[]=;,") is encountered.
69
70The name and arguments of the filter are optionally preceded and
71followed by a list of link labels.
72A link label allows to name a link and associate it to a filter output
73or input pad. The preceding labels @var{in_link_1}
74... @var{in_link_N}, are associated to the filter input pads,
75the following labels @var{out_link_1} ... @var{out_link_M}, are
76associated to the output pads.
77
78When two link labels with the same name are found in the
79filtergraph, a link between the corresponding input and output pad is
80created.
81
82If an output pad is not labelled, it is linked by default to the first
83unlabelled input pad of the next filter in the filterchain.
d4a8a86c 84For example in the filterchain
1ebe5c4c
SS
85@example
86nullsrc, split[L1], [L2]overlay, nullsink
87@end example
88the split filter instance has two output pads, and the overlay filter
89instance two input pads. The first output pad of split is labelled
90"L1", the first input pad of overlay is labelled "L2", and the second
91output pad of split is linked to the second input pad of overlay,
92which are both unlabelled.
93
94In a complete filterchain all the unlabelled filter input and output
95pads must be connected. A filtergraph is considered valid if all the
96filter input and output pads of all the filterchains are connected.
97
dd249245 98Libavfilter will automatically insert @ref{scale} filters where format
12e7e1d0
AK
99conversion is required. It is possible to specify swscale flags
100for those automatically inserted scalers by prepending
101@code{sws_flags=@var{flags};}
102to the filtergraph description.
103
d4a8a86c 104Here is a BNF description of the filtergraph syntax:
1ebe5c4c
SS
105@example
106@var{NAME} ::= sequence of alphanumeric characters and '_'
107@var{LINKLABEL} ::= "[" @var{NAME} "]"
108@var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
d4a8a86c 109@var{FILTER_ARGUMENTS} ::= sequence of chars (possibly quoted)
b5ad422b 110@var{FILTER} ::= [@var{LINKLABELS}] @var{NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}]
1ebe5c4c 111@var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
12e7e1d0 112@var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
1ebe5c4c
SS
113@end example
114
115@c man end FILTERGRAPH DESCRIPTION
116
f59e9eaf
SS
117@chapter Audio Filters
118@c man begin AUDIO FILTERS
119
f8a45fa1 120When you configure your Libav build, you can disable any of the
f59e9eaf
SS
121existing filters using --disable-filters.
122The configure output will show the audio filters included in your
123build.
124
125Below is a description of the currently available audio filters.
126
fb604ae8
AK
127@section aformat
128
129Convert the input audio to one of the specified formats. The framework will
130negotiate the most appropriate format to minimize conversions.
131
d4a8a86c 132It accepts the following parameters:
fb604ae8
AK
133@table @option
134
135@item sample_fmts
0af7fe1f 136A '|'-separated list of requested sample formats.
fb604ae8
AK
137
138@item sample_rates
0af7fe1f 139A '|'-separated list of requested sample rates.
fb604ae8
AK
140
141@item channel_layouts
0af7fe1f 142A '|'-separated list of requested channel layouts.
fb604ae8
AK
143
144@end table
145
146If a parameter is omitted, all values are allowed.
147
d4a8a86c 148Force the output to either unsigned 8-bit or signed 16-bit stereo
fb604ae8 149@example
0af7fe1f 150aformat=sample_fmts=u8|s16:channel_layouts=stereo
fb604ae8
AK
151@end example
152
c7448c18
JR
153@section amix
154
155Mixes multiple audio inputs into a single output.
156
157For example
158@example
159avconv -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
160@end example
161will mix 3 input audio streams to a single output with the same duration as the
162first input and a dropout transition time of 3 seconds.
163
d4a8a86c 164It accepts the following parameters:
c7448c18
JR
165@table @option
166
167@item inputs
d4a8a86c 168The number of inputs. If unspecified, it defaults to 2.
c7448c18
JR
169
170@item duration
171How to determine the end-of-stream.
172@table @option
173
174@item longest
d4a8a86c 175The duration of the longest input. (default)
c7448c18
JR
176
177@item shortest
d4a8a86c 178The duration of the shortest input.
c7448c18
JR
179
180@item first
d4a8a86c 181The duration of the first input.
c7448c18
JR
182
183@end table
184
185@item dropout_transition
d4a8a86c 186The transition time, in seconds, for volume renormalization when an input
c7448c18
JR
187stream ends. The default value is 2 seconds.
188
189@end table
190
99046339
HM
191@section anull
192
193Pass the audio source unchanged to the output.
194
b4729382
AK
195@section asetpts
196
197Change the PTS (presentation timestamp) of the input audio frames.
198
d4a8a86c 199It accepts the following parameters:
b4729382
AK
200
201@table @option
202
203@item expr
204The expression which is evaluated for each frame to construct its timestamp.
205
206@end table
207
208The expression is evaluated through the eval API and can contain the following
209constants:
210
211@table @option
018bdaed
SS
212@item FRAME_RATE
213frame rate, only defined for constant frame-rate video
214
b4729382
AK
215@item PTS
216the presentation timestamp in input
217
d4a8a86c
KBA
218@item E, PI, PHI
219These are approximated values for the mathematical constants e
220(Euler's number), pi (Greek pi), and phi (the golden ratio).
b4729382
AK
221
222@item N
d4a8a86c 223The number of audio samples passed through the filter so far, starting at 0.
b4729382
AK
224
225@item S
d4a8a86c 226The number of audio samples in the current frame.
b4729382
AK
227
228@item SR
d4a8a86c 229The audio sample rate.
b4729382
AK
230
231@item STARTPTS
d4a8a86c 232The PTS of the first frame.
b4729382
AK
233
234@item PREV_INPTS
d4a8a86c 235The previous input PTS.
b4729382
AK
236
237@item PREV_OUTPTS
d4a8a86c 238The previous output PTS.
b4729382
AK
239
240@item RTCTIME
d4a8a86c 241The wallclock (RTC) time in microseconds.
b4729382
AK
242
243@item RTCSTART
d4a8a86c 244The wallclock (RTC) time at the start of the movie in microseconds.
b4729382
AK
245
246@end table
247
d4a8a86c 248Some examples:
b4729382
AK
249
250@example
d4a8a86c 251# Start counting PTS from zero
b4729382
AK
252asetpts=expr=PTS-STARTPTS
253
d4a8a86c 254# Generate timestamps by counting samples
b4729382
AK
255asetpts=expr=N/SR/TB
256
d4a8a86c 257# Generate timestamps from a "live source" and rebase onto the current timebase
b4729382
AK
258asetpts='(RTCTIME - RTCSTART) / (TB * 1000000)"
259@end example
260
ad8159e0
NG
261@section asettb
262
263Set the timebase to use for the output frames timestamps.
264It is mainly useful for testing timebase configuration.
265
266This filter accepts the following parameters:
267
268@table @option
269
270@item expr
271The expression which is evaluated into the output timebase.
272
273@end table
274
275The expression can contain the constants @var{PI}, @var{E}, @var{PHI}, @var{AVTB} (the
276default timebase), @var{intb} (the input timebase), and @var{sr} (the sample rate,
277audio only).
278
279The default value for the input is @var{intb}.
280
281Some examples:
282
283@example
284# Set the timebase to 1/25:
285settb=1/25
286
287# Set the timebase to 1/10:
288settb=0.1
289
290# Set the timebase to 1001/1000:
291settb=1+0.001
292
293# Set the timebase to 2*intb:
294settb=2*intb
295
296# Set the default timebase value:
297settb=AVTB
298
299# Set the timebase to twice the sample rate:
300asettb=sr*2
301@end example
b4729382 302
20dd41af
AK
303@section ashowinfo
304
305Show a line containing various information for each input audio frame.
306The input audio is not modified.
307
308The shown line contains a sequence of key/value pairs of the form
309@var{key}:@var{value}.
310
d4a8a86c 311It accepts the following parameters:
20dd41af
AK
312
313@table @option
314@item n
d4a8a86c 315The (sequential) number of the input frame, starting from 0.
20dd41af
AK
316
317@item pts
d4a8a86c 318The presentation timestamp of the input frame, in time base units; the time base
20dd41af
AK
319depends on the filter input pad, and is usually 1/@var{sample_rate}.
320
321@item pts_time
d4a8a86c 322The presentation timestamp of the input frame in seconds.
20dd41af
AK
323
324@item fmt
d4a8a86c 325The sample format.
20dd41af
AK
326
327@item chlayout
d4a8a86c 328The channel layout.
20dd41af
AK
329
330@item rate
d4a8a86c 331The sample rate for the audio frame.
20dd41af
AK
332
333@item nb_samples
d4a8a86c 334The number of samples (per channel) in the frame.
20dd41af
AK
335
336@item checksum
d4a8a86c
KBA
337The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
338audio, the data is treated as if all the planes were concatenated.
20dd41af
AK
339
340@item plane_checksums
341A list of Adler-32 checksums for each data plane.
342@end table
343
afeb3590
JR
344@section asplit
345
346Split input audio into several identical outputs.
347
d4a8a86c 348It accepts a single parameter, which specifies the number of outputs. If
afeb3590
JR
349unspecified, it defaults to 2.
350
d4a8a86c 351For example,
afeb3590
JR
352@example
353avconv -i INPUT -filter_complex asplit=5 OUTPUT
354@end example
355will create 5 copies of the input audio.
356
9f26421b
AK
357@section asyncts
358Synchronize audio data with timestamps by squeezing/stretching it and/or
359dropping samples/adding silence when needed.
360
d4a8a86c 361It accepts the following parameters:
9f26421b
AK
362@table @option
363
364@item compensate
04438790
AU
365Enable stretching/squeezing the data to make it match the timestamps. Disabled
366by default. When disabled, time gaps are covered with silence.
9f26421b
AK
367
368@item min_delta
d4a8a86c
KBA
369The minimum difference between timestamps and audio data (in seconds) to trigger
370adding/dropping samples. The default value is 0.1. If you get an imperfect
371sync with this filter, try setting this parameter to 0.
9f26421b
AK
372
373@item max_comp
d4a8a86c
KBA
374The maximum compensation in samples per second. Only relevant with compensate=1.
375The default value is 500.
9f26421b 376
70d71b58 377@item first_pts
d4a8a86c
KBA
378Assume that the first PTS should be this value. The time base is 1 / sample
379rate. This allows for padding/trimming at the start of the stream. By default,
380no assumption is made about the first frame's expected PTS, so no padding or
70d71b58 381trimming is done. For example, this could be set to 0 to pad the beginning with
b35e5d98 382silence if an audio stream starts after the video stream or to trim any samples
d4a8a86c 383with a negative PTS due to encoder delay.
70d71b58 384
9f26421b
AK
385@end table
386
a1e05b04
AK
387@section atrim
388Trim the input so that the output contains one continuous subpart of the input.
389
d4a8a86c 390It accepts the following parameters:
a1e05b04
AK
391@table @option
392@item start
d4a8a86c
KBA
393Timestamp (in seconds) of the start of the section to keep. I.e. the audio
394sample with the timestamp @var{start} will be the first sample in the output.
a1e05b04
AK
395
396@item end
397Timestamp (in seconds) of the first audio sample that will be dropped. I.e. the
398audio sample immediately preceding the one with the timestamp @var{end} will be
399the last sample in the output.
400
401@item start_pts
402Same as @var{start}, except this option sets the start timestamp in samples
403instead of seconds.
404
405@item end_pts
406Same as @var{end}, except this option sets the end timestamp in samples instead
407of seconds.
408
409@item duration
d4a8a86c 410The maximum duration of the output in seconds.
a1e05b04
AK
411
412@item start_sample
d4a8a86c 413The number of the first sample that should be output.
a1e05b04
AK
414
415@item end_sample
d4a8a86c 416The number of the first sample that should be dropped.
a1e05b04
AK
417@end table
418
419Note that the first two sets of the start/end options and the @option{duration}
420option look at the frame timestamp, while the _sample options simply count the
421samples that pass through the filter. So start/end_pts and start/end_sample will
422give different results when the timestamps are wrong, inexact or do not start at
423zero. Also note that this filter does not modify the timestamps. If you wish
d4a8a86c 424to have the output timestamps start at zero, insert the asetpts filter after the
a1e05b04
AK
425atrim filter.
426
427If multiple start or end options are set, this filter tries to be greedy and
428keep all samples that match at least one of the specified constraints. To keep
429only the part that matches all the constraints at once, chain multiple atrim
430filters.
431
432The defaults are such that all the input is kept. So it is possible to set e.g.
433just the end values to keep everything before the specified time.
434
435Examples:
436@itemize
437@item
d4a8a86c 438Drop everything except the second minute of input:
a1e05b04
AK
439@example
440avconv -i INPUT -af atrim=60:120
441@end example
442
443@item
d4a8a86c 444Keep only the first 1000 samples:
a1e05b04
AK
445@example
446avconv -i INPUT -af atrim=end_sample=1000
447@end example
448
449@end itemize
450
1c0210c7
AG
451@section bs2b
452Bauer stereo to binaural transformation, which improves headphone listening of
453stereo audio records.
454
455It accepts the following parameters:
456@table @option
457
458@item profile
459Pre-defined crossfeed level.
460@table @option
461
462@item default
463Default level (fcut=700, feed=50).
464
465@item cmoy
466Chu Moy circuit (fcut=700, feed=60).
467
468@item jmeier
469Jan Meier circuit (fcut=650, feed=95).
470
471@end table
472
473@item fcut
474Cut frequency (in Hz).
475
476@item feed
477Feed level (in Hz).
478
479@end table
480
d6251368 481@section channelsplit
d4a8a86c 482Split each channel from an input audio stream into a separate output stream.
d6251368 483
d4a8a86c 484It accepts the following parameters:
d6251368
AK
485@table @option
486@item channel_layout
d4a8a86c 487The channel layout of the input stream. The default is "stereo".
d6251368
AK
488@end table
489
d4a8a86c 490For example, assuming a stereo input MP3 file,
d6251368
AK
491@example
492avconv -i in.mp3 -filter_complex channelsplit out.mkv
493@end example
494will create an output Matroska file with two audio streams, one containing only
495the left channel and the other the right channel.
496
d4a8a86c 497Split a 5.1 WAV file into per-channel files:
d6251368
AK
498@example
499avconv -i in.wav -filter_complex
500'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
f428893c
VJA
501-map '[FL]' front_left.wav -map '[FR]' front_right.wav
502-map '[FC]' front_center.wav -map '[LFE]' low_frequency_effects.wav
503-map '[SL]' side_left.wav -map '[SR]' side_right.wav
d6251368
AK
504@end example
505
41e637e4
AC
506@section channelmap
507Remap input channels to new locations.
508
d4a8a86c 509It accepts the following parameters:
41e637e4
AC
510@table @option
511@item channel_layout
d4a8a86c 512The channel layout of the output stream.
41e637e4
AC
513
514@item map
ba8efac9 515Map channels from input to output. The argument is a '|'-separated list of
41e637e4
AC
516mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
517@var{in_channel} form. @var{in_channel} can be either the name of the input
518channel (e.g. FL for front left) or its index in the input channel layout.
519@var{out_channel} is the name of the output channel or its index in the output
520channel layout. If @var{out_channel} is not given then it is implicitly an
521index, starting with zero and increasing by one for each mapping.
522@end table
523
524If no mapping is present, the filter will implicitly map input channels to
d4a8a86c 525output channels, preserving indices.
41e637e4 526
d4a8a86c 527For example, assuming a 5.1+downmix input MOV file,
41e637e4 528@example
ba8efac9 529avconv -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
41e637e4
AC
530@end example
531will create an output WAV file tagged as stereo from the downmix channels of
532the input.
533
534To fix a 5.1 WAV improperly encoded in AAC's native channel order
535@example
8fcd121b 536avconv -i in.wav -filter 'channelmap=1|2|0|5|3|4:5.1' out.wav
41e637e4
AC
537@end example
538
738f8358 539@section compand
d4a8a86c 540Compress or expand the audio's dynamic range.
738f8358 541
d4a8a86c 542It accepts the following parameters:
738f8358
AK
543
544@table @option
545
546@item attacks
547@item decays
d4a8a86c 548A list of times in seconds for each channel over which the instantaneous level
738f8358
AK
549of the input signal is averaged to determine its volume. @var{attacks} refers to
550increase of volume and @var{decays} refers to decrease of volume. For most
551situations, the attack time (response to the audio getting louder) should be
d4a8a86c 552shorter than the decay time, because the human ear is more sensitive to sudden
738f8358
AK
553loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
554a typical value for decay is 0.8 seconds.
555
556@item points
d4a8a86c 557A list of points for the transfer function, specified in dB relative to the
738f8358
AK
558maximum possible signal amplitude. Each key points list must be defined using
559the following syntax: @code{x0/y0|x1/y1|x2/y2|....}
560
561The input values must be in strictly increasing order but the transfer function
562does not have to be monotonically rising. The point @code{0/0} is assumed but
563may be overridden (by @code{0/out-dBn}). Typical values for the transfer
564function are @code{-70/-70|-60/-20}.
565
566@item soft-knee
d4a8a86c 567Set the curve radius in dB for all joints. It defaults to 0.01.
738f8358
AK
568
569@item gain
d4a8a86c
KBA
570Set the additional gain in dB to be applied at all points on the transfer
571function. This allows for easy adjustment of the overall gain.
572It defaults to 0.
738f8358
AK
573
574@item volume
d4a8a86c
KBA
575Set an initial volume, in dB, to be assumed for each channel when filtering
576starts. This permits the user to supply a nominal level initially, so that, for
738f8358
AK
577example, a very large gain is not applied to initial signal levels before the
578companding has begun to operate. A typical value for audio which is initially
d4a8a86c 579quiet is -90 dB. It defaults to 0.
738f8358
AK
580
581@item delay
d4a8a86c 582Set a delay, in seconds. The input audio is analyzed immediately, but audio is
738f8358
AK
583delayed before being fed to the volume adjuster. Specifying a delay
584approximately equal to the attack/decay times allows the filter to effectively
d4a8a86c 585operate in predictive rather than reactive mode. It defaults to 0.
738f8358
AK
586
587@end table
588
589@subsection Examples
590
591@itemize
592@item
d4a8a86c
KBA
593Make music with both quiet and loud passages suitable for listening to in a
594noisy environment:
738f8358
AK
595@example
596compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
597@end example
598
599@item
d4a8a86c 600A noise gate for when the noise is at a lower level than the signal:
738f8358
AK
601@example
602compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
603@end example
604
605@item
606Here is another noise gate, this time for when the noise is at a higher level
607than the signal (making it, in some ways, similar to squelch):
608@example
609compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
610@end example
611@end itemize
612
dc07fb6f
AK
613@section join
614Join multiple input streams into one multi-channel stream.
615
d4a8a86c 616It accepts the following parameters:
dc07fb6f
AK
617@table @option
618
619@item inputs
d4a8a86c 620The number of input streams. It defaults to 2.
dc07fb6f
AK
621
622@item channel_layout
d4a8a86c 623The desired output channel layout. It defaults to stereo.
dc07fb6f
AK
624
625@item map
dd7fc37c 626Map channels from inputs to output. The argument is a '|'-separated list of
dc07fb6f
AK
627mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
628form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
7a8059eb 629can be either the name of the input channel (e.g. FL for front left) or its
dc07fb6f
AK
630index in the specified input stream. @var{out_channel} is the name of the output
631channel.
632@end table
633
d4a8a86c 634The filter will attempt to guess the mappings when they are not specified
dc07fb6f
AK
635explicitly. It does so by first trying to find an unused matching input channel
636and if that fails it picks the first unused input channel.
637
d4a8a86c 638Join 3 inputs (with properly set channel layouts):
dc07fb6f
AK
639@example
640avconv -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
641@end example
642
d4a8a86c 643Build a 5.1 output from 6 single-channel streams:
dc07fb6f
AK
644@example
645avconv -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
dd7fc37c 646'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'
dc07fb6f
AK
647out
648@end example
649
d371e7b9 650@section resample
d4a8a86c
KBA
651Convert the audio sample format, sample rate and channel layout. It is
652not meant to be used directly; it is inserted automatically by libavfilter
d371e7b9
AK
653whenever conversion is needed. Use the @var{aformat} filter to force a specific
654conversion.
655
b384e031
JR
656@section volume
657
658Adjust the input audio volume.
659
d4a8a86c 660It accepts the following parameters:
b384e031
JR
661@table @option
662
663@item volume
d4a8a86c 664This expresses how the audio volume will be increased or decreased.
b384e031
JR
665
666Output values are clipped to the maximum value.
667
668The output audio volume is given by the relation:
669@example
670@var{output_volume} = @var{volume} * @var{input_volume}
671@end example
672
d4a8a86c 673The default value for @var{volume} is 1.0.
b384e031
JR
674
675@item precision
d4a8a86c 676This parameter represents the mathematical precision.
b384e031 677
d4a8a86c 678It determines which input sample formats will be allowed, which affects the
b384e031
JR
679precision of the volume scaling.
680
681@table @option
682@item fixed
d4a8a86c 6838-bit fixed-point; this limits input sample format to U8, S16, and S32.
b384e031 684@item float
d4a8a86c 68532-bit floating-point; this limits input sample format to FLT. (default)
b384e031 686@item double
d4a8a86c 68764-bit floating-point; this limits input sample format to DBL.
b384e031 688@end table
06c3cd3c
AK
689
690@item replaygain
d4a8a86c 691Choose the behaviour on encountering ReplayGain side data in input frames.
06c3cd3c
AK
692
693@table @option
694@item drop
695Remove ReplayGain side data, ignoring its contents (the default).
696
697@item ignore
698Ignore ReplayGain side data, but leave it in the frame.
699
700@item track
d4a8a86c 701Prefer the track gain, if present.
06c3cd3c
AK
702
703@item album
d4a8a86c 704Prefer the album gain, if present.
06c3cd3c 705@end table
a49aa440
AG
706
707@item replaygain_preamp
708Pre-amplification gain in dB to apply to the selected replaygain gain.
709
710Default value for @var{replaygain_preamp} is 0.0.
711
aaab192d
AG
712@item replaygain_noclip
713Prevent clipping by limiting the gain applied.
714
715Default value for @var{replaygain_noclip} is 1.
716
b384e031
JR
717@end table
718
719@subsection Examples
720
721@itemize
722@item
723Halve the input audio volume:
724@example
725volume=volume=0.5
726volume=volume=1/2
727volume=volume=-6.0206dB
728@end example
729
730@item
731Increase input audio power by 6 decibels using fixed-point precision:
732@example
733volume=volume=6dB:precision=fixed
734@end example
735@end itemize
736
f59e9eaf
SS
737@c man end AUDIO FILTERS
738
1ee410f3
SS
739@chapter Audio Sources
740@c man begin AUDIO SOURCES
741
742Below is a description of the currently available audio sources.
743
744@section anullsrc
745
d4a8a86c
KBA
746The null audio source; it never returns audio frames. It is mainly useful as a
747template and for use in analysis / debugging tools.
1ee410f3 748
d4a8a86c 749It accepts, as an optional parameter, a string of the form
1ee410f3
SS
750@var{sample_rate}:@var{channel_layout}.
751
d4a8a86c 752@var{sample_rate} specifies the sample rate, and defaults to 44100.
1ee410f3 753
d4a8a86c 754@var{channel_layout} specifies the channel layout, and can be either an
1ee410f3
SS
755integer or a string representing a channel layout. The default value
756of @var{channel_layout} is 3, which corresponds to CH_LAYOUT_STEREO.
757
758Check the channel_layout_map definition in
a903f8f0 759@file{libavutil/channel_layout.c} for the mapping between strings and
6ef93402 760channel layout values.
1ee410f3 761
d4a8a86c 762Some examples:
1ee410f3 763@example
d4a8a86c 764# Set the sample rate to 48000 Hz and the channel layout to CH_LAYOUT_MONO
1ee410f3
SS
765anullsrc=48000:4
766
d4a8a86c 767# The same as above
1ee410f3
SS
768anullsrc=48000:mono
769@end example
770
4c66c407
AK
771@section abuffer
772Buffer audio frames, and make them available to the filter chain.
773
d4a8a86c
KBA
774This source is not intended to be part of user-supplied graph descriptions; it
775is for insertion by calling programs, through the interface defined in
4c66c407
AK
776@file{libavfilter/buffersrc.h}.
777
d4a8a86c 778It accepts the following parameters:
4c66c407
AK
779@table @option
780
781@item time_base
d4a8a86c 782The timebase which will be used for timestamps of submitted frames. It must be
4c66c407
AK
783either a floating-point number or in @var{numerator}/@var{denominator} form.
784
785@item sample_rate
d4a8a86c 786The audio sample rate.
4c66c407
AK
787
788@item sample_fmt
d4a8a86c 789The name of the sample format, as returned by @code{av_get_sample_fmt_name()}.
4c66c407
AK
790
791@item channel_layout
d4a8a86c 792The channel layout of the audio data, in the form that can be accepted by
4c66c407
AK
793@code{av_get_channel_layout()}.
794@end table
795
796All the parameters need to be explicitly defined.
797
1ee410f3
SS
798@c man end AUDIO SOURCES
799
f0a55438
HM
800@chapter Audio Sinks
801@c man begin AUDIO SINKS
802
803Below is a description of the currently available audio sinks.
804
805@section anullsink
806
d4a8a86c
KBA
807Null audio sink; do absolutely nothing with the input audio. It is
808mainly useful as a template and for use in analysis / debugging
f0a55438
HM
809tools.
810
a2cd9be2
AK
811@section abuffersink
812This sink is intended for programmatic use. Frames that arrive on this sink can
d4a8a86c 813be retrieved by the calling program, using the interface defined in
a2cd9be2
AK
814@file{libavfilter/buffersink.h}.
815
d4a8a86c 816It does not accept any parameters.
a2cd9be2 817
f0a55438
HM
818@c man end AUDIO SINKS
819
3275ac6a
SS
820@chapter Video Filters
821@c man begin VIDEO FILTERS
822
f8a45fa1 823When you configure your Libav build, you can disable any of the
3275ac6a
SS
824existing filters using --disable-filters.
825The configure output will show the video filters included in your
826build.
827
828Below is a description of the currently available video filters.
829
13fabd7a
SS
830@section blackframe
831
832Detect frames that are (almost) completely black. Can be useful to
833detect chapter transitions or commercials. Output lines consist of
834the frame number of the detected frame, the percentage of blackness,
835the position in the file if known or -1 and the timestamp in seconds.
836
837In order to display the output lines, you need to set the loglevel at
838least to the AV_LOG_INFO value.
839
d4a8a86c 840It accepts the following parameters:
62dcdb02
AK
841
842@table @option
843
844@item amount
d4a8a86c 845The percentage of the pixels that have to be below the threshold; it defaults to
62dcdb02 84698.
13fabd7a 847
62dcdb02 848@item threshold
d4a8a86c 849The threshold below which a pixel value is considered black; it defaults to 32.
13fabd7a 850
62dcdb02 851@end table
13fabd7a 852
ce6b6ef6
SS
853@section boxblur
854
d4a8a86c 855Apply a boxblur algorithm to the input video.
ce6b6ef6 856
d4a8a86c 857It accepts the following parameters:
51def31d
AK
858
859@table @option
860
861@item luma_radius
862@item luma_power
863@item chroma_radius
864@item chroma_power
865@item alpha_radius
866@item alpha_power
867
868@end table
ce6b6ef6 869
d4a8a86c 870The chroma and alpha parameters are optional. If not specified, they default
ce6b6ef6
SS
871to the corresponding values set for @var{luma_radius} and
872@var{luma_power}.
873
874@var{luma_radius}, @var{chroma_radius}, and @var{alpha_radius} represent
875the radius in pixels of the box used for blurring the corresponding
876input plane. They are expressions, and can contain the following
877constants:
878@table @option
879@item w, h
d4a8a86c 880The input width and height in pixels.
ce6b6ef6
SS
881
882@item cw, ch
d4a8a86c 883The input chroma image width and height in pixels.
ce6b6ef6
SS
884
885@item hsub, vsub
d4a8a86c
KBA
886The horizontal and vertical chroma subsample values. For example, for the
887pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
ce6b6ef6
SS
888@end table
889
890The radius must be a non-negative number, and must not be greater than
891the value of the expression @code{min(w,h)/2} for the luma and alpha planes,
892and of @code{min(cw,ch)/2} for the chroma planes.
893
894@var{luma_power}, @var{chroma_power}, and @var{alpha_power} represent
895how many times the boxblur filter is applied to the corresponding
896plane.
897
d4a8a86c 898Some examples:
ce6b6ef6
SS
899
900@itemize
901
902@item
d4a8a86c 903Apply a boxblur filter with the luma, chroma, and alpha radii
ce6b6ef6
SS
904set to 2:
905@example
51def31d 906boxblur=luma_radius=2:luma_power=1
ce6b6ef6
SS
907@end example
908
909@item
d4a8a86c 910Set the luma radius to 2, and alpha and chroma radius to 0:
ce6b6ef6
SS
911@example
912boxblur=2:1:0:0:0:0
913@end example
914
915@item
d4a8a86c 916Set the luma and chroma radii to a fraction of the video dimension:
ce6b6ef6 917@example
51def31d 918boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
ce6b6ef6
SS
919@end example
920
921@end itemize
922
b5670209
SS
923@section copy
924
d4a8a86c 925Copy the input source unchanged to the output. This is mainly useful for
b5670209
SS
926testing purposes.
927
3275ac6a
SS
928@section crop
929
fba0156a
AK
930Crop the input video to given dimensions.
931
d4a8a86c 932It accepts the following parameters:
fba0156a
AK
933
934@table @option
935
936@item out_w
d4a8a86c 937The width of the output video.
fba0156a
AK
938
939@item out_h
d4a8a86c 940The height of the output video.
fba0156a
AK
941
942@item x
d4a8a86c
KBA
943The horizontal position, in the input video, of the left edge of the output
944video.
fba0156a
AK
945
946@item y
d4a8a86c 947The vertical position, in the input video, of the top edge of the output video.
fba0156a
AK
948
949@end table
3275ac6a 950
75b67a8a
SS
951The parameters are expressions containing the following constants:
952
953@table @option
954@item E, PI, PHI
d4a8a86c
KBA
955These are approximated values for the mathematical constants e
956(Euler's number), pi (Greek pi), and phi (the golden ratio).
75b67a8a
SS
957
958@item x, y
d4a8a86c 959The computed values for @var{x} and @var{y}. They are evaluated for
75b67a8a
SS
960each new frame.
961
962@item in_w, in_h
d4a8a86c 963The input width and height.
75b67a8a
SS
964
965@item iw, ih
d4a8a86c 966These are the same as @var{in_w} and @var{in_h}.
75b67a8a
SS
967
968@item out_w, out_h
d4a8a86c 969The output (cropped) width and height.
75b67a8a
SS
970
971@item ow, oh
d4a8a86c 972These are the same as @var{out_w} and @var{out_h}.
75b67a8a
SS
973
974@item n
d4a8a86c 975The number of the input frame, starting from 0.
75b67a8a 976
75b67a8a 977@item t
d4a8a86c 978The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
3275ac6a 979
75b67a8a 980@end table
3275ac6a 981
75b67a8a 982The @var{out_w} and @var{out_h} parameters specify the expressions for
d4a8a86c
KBA
983the width and height of the output (cropped) video. They are only
984evaluated during the configuration of the filter.
3275ac6a 985
75b67a8a
SS
986The default value of @var{out_w} is "in_w", and the default value of
987@var{out_h} is "in_h".
2bc05d35 988
75b67a8a
SS
989The expression for @var{out_w} may depend on the value of @var{out_h},
990and the expression for @var{out_h} may depend on @var{out_w}, but they
991cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
992evaluated after @var{out_w} and @var{out_h}.
2bc05d35 993
75b67a8a
SS
994The @var{x} and @var{y} parameters specify the expressions for the
995position of the top-left corner of the output (non-cropped) area. They
996are evaluated for each frame. If the evaluated value is not valid, it
997is approximated to the nearest valid value.
3275ac6a 998
75b67a8a
SS
999The default value of @var{x} is "(in_w-out_w)/2", and the default
1000value for @var{y} is "(in_h-out_h)/2", which set the cropped area at
1001the center of the input image.
1002
1003The expression for @var{x} may depend on @var{y}, and the expression
1004for @var{y} may depend on @var{x}.
1005
d4a8a86c 1006Some examples:
3275ac6a 1007@example
d4a8a86c 1008# Crop the central input area with size 100x100
fba0156a 1009crop=out_w=100:out_h=100
75b67a8a 1010
d4a8a86c 1011# Crop the central input area with size 2/3 of the input video
fba0156a 1012"crop=out_w=2/3*in_w:out_h=2/3*in_h"
75b67a8a 1013
d4a8a86c 1014# Crop the input video central square
fba0156a 1015crop=out_w=in_h
75b67a8a 1016
d4a8a86c 1017# Delimit the rectangle with the top-left corner placed at position
75b67a8a 1018# 100:100 and the right-bottom corner corresponding to the right-bottom
d4a8a86c 1019# corner of the input image
fba0156a 1020crop=out_w=in_w-100:out_h=in_h-100:x=100:y=100
3275ac6a 1021
d4a8a86c 1022# Crop 10 pixels from the left and right borders, and 20 pixels from
75b67a8a 1023# the top and bottom borders
fba0156a 1024"crop=out_w=in_w-2*10:out_h=in_h-2*20"
3275ac6a 1025
d4a8a86c 1026# Keep only the bottom right quarter of the input image
fba0156a 1027"crop=out_w=in_w/2:out_h=in_h/2:x=in_w/2:y=in_h/2"
75b67a8a 1028
d4a8a86c 1029# Crop height for getting Greek harmony
fba0156a 1030"crop=out_w=in_w:out_h=1/PHI*in_w"
75b67a8a 1031
d4a8a86c 1032# Trembling effect
75b67a8a
SS
1033"crop=in_w/2:in_h/2:(in_w-out_w)/2+((in_w-out_w)/2)*sin(n/10):(in_h-out_h)/2 +((in_h-out_h)/2)*sin(n/7)"
1034
d4a8a86c 1035# Erratic camera effect depending on timestamp
fba0156a 1036"crop=out_w=in_w/2:out_h=in_h/2:x=(in_w-out_w)/2+((in_w-out_w)/2)*sin(t*10):y=(in_h-out_h)/2 +((in_h-out_h)/2)*sin(t*13)"
75b67a8a 1037
d4a8a86c 1038# Set x depending on the value of y
75b67a8a
SS
1039"crop=in_w/2:in_h/2:y:10+10*sin(n/10)"
1040@end example
3275ac6a 1041
68b79bfc
SS
1042@section cropdetect
1043
d4a8a86c 1044Auto-detect the crop size.
68b79bfc 1045
d4a8a86c
KBA
1046It calculates the necessary cropping parameters and prints the
1047recommended parameters via the logging system. The detected dimensions
68b79bfc
SS
1048correspond to the non-black area of the input video.
1049
d4a8a86c 1050It accepts the following parameters:
68b79bfc
SS
1051
1052@table @option
1053
1054@item limit
d4a8a86c
KBA
1055The threshold, an optional parameter between nothing (0) and
1056everything (255). It defaults to 24.
68b79bfc
SS
1057
1058@item round
d4a8a86c 1059The value which the width/height should be divisible by. It defaults to
68b79bfc
SS
106016. The offset is automatically adjusted to center the video. Use 2 to
1061get only even dimensions (needed for 4:2:2 video). 16 is best when
1062encoding to most video codecs.
1063
1064@item reset
d4a8a86c
KBA
1065A counter that determines how many frames cropdetect will reset
1066the previously detected largest video area after. It will then start over
1067and detect the current optimal crop area. It defaults to 0.
68b79bfc
SS
1068
1069This can be useful when channel logos distort the video area. 0
d4a8a86c 1070indicates 'never reset', and returns the largest area encountered during
68b79bfc
SS
1071playback.
1072@end table
1073
b157be1f
SS
1074@section delogo
1075
1076Suppress a TV station logo by a simple interpolation of the surrounding
1077pixels. Just set a rectangle covering the logo and watch it disappear
1078(and sometimes something even uglier appear - your mileage may vary).
1079
d4a8a86c 1080It accepts the following parameters:
b157be1f
SS
1081@table @option
1082
1083@item x, y
1084Specify the top left corner coordinates of the logo. They must be
1085specified.
1086
1087@item w, h
1088Specify the width and height of the logo to clear. They must be
1089specified.
1090
1091@item band, t
1092Specify the thickness of the fuzzy edge of the rectangle (added to
1093@var{w} and @var{h}). The default value is 4.
1094
1095@item show
1096When set to 1, a green rectangle is drawn on the screen to simplify
1097finding the right @var{x}, @var{y}, @var{w}, @var{h} parameters, and
1098@var{band} is set to 4. The default value is 0.
1099
1100@end table
1101
d4a8a86c 1102An example:
b157be1f
SS
1103
1104@itemize
1105
1106@item
1107Set a rectangle covering the area with top left corner coordinates 0,0
d4a8a86c 1108and size 100x77, and a band of size 10:
b157be1f 1109@example
b157be1f
SS
1110delogo=x=0:y=0:w=100:h=77:band=10
1111@end example
1112
1113@end itemize
1114
e40032e2
SS
1115@section drawbox
1116
1117Draw a colored box on the input image.
1118
d4a8a86c 1119It accepts the following parameters:
e40032e2
SS
1120
1121@table @option
1122
1123@item x, y
d4a8a86c 1124Specify the top left corner coordinates of the box. It defaults to 0.
e40032e2
SS
1125
1126@item width, height
d4a8a86c
KBA
1127Specify the width and height of the box; if 0 they are interpreted as
1128the input width and height. It defaults to 0.
e40032e2
SS
1129
1130@item color
d4a8a86c 1131Specify the color of the box to write. It can be the name of a color
e40032e2
SS
1132(case insensitive match) or a 0xRRGGBB[AA] sequence.
1133@end table
1134
d4a8a86c 1135Some examples:
e40032e2 1136@example
d4a8a86c 1137# Draw a black box around the edge of the input image
e40032e2
SS
1138drawbox
1139
d4a8a86c 1140# Draw a box with color red and an opacity of 50%
335c3129 1141drawbox=x=10:y=20:width=200:height=60:color=red@@0.5"
e40032e2
SS
1142@end example
1143
a5b64584
SS
1144@section drawtext
1145
d4a8a86c 1146Draw a text string or text from a specified file on top of a video, using the
a5b64584
SS
1147libfreetype library.
1148
d4a8a86c 1149To enable compilation of this filter, you need to configure Libav with
a5b64584 1150@code{--enable-libfreetype}.
f1b239ec
LB
1151To enable default font fallback and the @var{font} option you need to
1152configure Libav with @code{--enable-libfontconfig}.
a5b64584
SS
1153
1154The filter also recognizes strftime() sequences in the provided text
1155and expands them accordingly. Check the documentation of strftime().
1156
d4a8a86c 1157It accepts the following parameters:
a5b64584
SS
1158
1159@table @option
1160
f1b239ec
LB
1161@item font
1162The font family to be used for drawing text. By default Sans.
1163
a5b64584 1164@item fontfile
d4a8a86c 1165The font file to be used for drawing text. The path must be included.
f1b239ec 1166This parameter is mandatory if the fontconfig support is disabled.
a5b64584
SS
1167
1168@item text
1169The text string to be drawn. The text must be a sequence of UTF-8
1170encoded characters.
1171This parameter is mandatory if no file is specified with the parameter
1172@var{textfile}.
1173
1174@item textfile
1175A text file containing text to be drawn. The text must be a sequence
1176of UTF-8 encoded characters.
1177
1178This parameter is mandatory if no text string is specified with the
1179parameter @var{text}.
1180
1181If both text and textfile are specified, an error is thrown.
1182
1183@item x, y
1184The offsets where text will be drawn within the video frame.
d4a8a86c 1185It is relative to the top/left border of the output image.
2cf74eca
LB
1186They accept expressions similar to the @ref{overlay} filter:
1187@table @option
1188
1189@item x, y
d4a8a86c 1190The computed values for @var{x} and @var{y}. They are evaluated for
2cf74eca
LB
1191each new frame.
1192
1193@item main_w, main_h
d4a8a86c 1194The main input width and height.
2cf74eca
LB
1195
1196@item W, H
d4a8a86c 1197These are the same as @var{main_w} and @var{main_h}.
2cf74eca
LB
1198
1199@item text_w, text_h
d4a8a86c 1200The rendered text's width and height.
2cf74eca
LB
1201
1202@item w, h
d4a8a86c 1203These are the same as @var{text_w} and @var{text_h}.
2cf74eca
LB
1204
1205@item n
d4a8a86c 1206The number of frames processed, starting from 0.
2cf74eca
LB
1207
1208@item t
d4a8a86c 1209The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
2cf74eca
LB
1210
1211@end table
a5b64584
SS
1212
1213The default value of @var{x} and @var{y} is 0.
1214
9b2c57be
LB
1215@item draw
1216Draw the text only if the expression evaluates as non-zero.
1217The expression accepts the same variables @var{x, y} do.
1218The default value is 1.
1219
1220@item alpha
1221Draw the text applying alpha blending. The value can
1222be either a number between 0.0 and 1.0
1223The expression accepts the same variables @var{x, y} do.
1224The default value is 1.
1225
a5b64584
SS
1226@item fontsize
1227The font size to be used for drawing text.
1228The default value of @var{fontsize} is 16.
1229
1230@item fontcolor
1231The color to be used for drawing fonts.
d4a8a86c 1232It is either a string (e.g. "red"), or in 0xRRGGBB[AA] format
a5b64584
SS
1233(e.g. "0xff000033"), possibly followed by an alpha specifier.
1234The default value of @var{fontcolor} is "black".
1235
1236@item boxcolor
1237The color to be used for drawing box around text.
d4a8a86c 1238It is either a string (e.g. "yellow") or in 0xRRGGBB[AA] format
a5b64584
SS
1239(e.g. "0xff00ff"), possibly followed by an alpha specifier.
1240The default value of @var{boxcolor} is "white".
1241
1242@item box
d4a8a86c
KBA
1243Used to draw a box around text using the background color.
1244The value must be either 1 (enable) or 0 (disable).
a5b64584
SS
1245The default value of @var{box} is 0.
1246
994de197
SS
1247@item shadowx, shadowy
1248The x and y offsets for the text shadow position with respect to the
1249position of the text. They can be either positive or negative
d4a8a86c 1250values. The default value for both is "0".
994de197
SS
1251
1252@item shadowcolor
1253The color to be used for drawing a shadow behind the drawn text. It
1254can be a color name (e.g. "yellow") or a string in the 0xRRGGBB[AA]
1255form (e.g. "0xff00ff"), possibly followed by an alpha specifier.
1256The default value of @var{shadowcolor} is "black".
1257
a5b64584 1258@item ft_load_flags
d4a8a86c 1259The flags to be used for loading the fonts.
a5b64584
SS
1260
1261The flags map the corresponding flags supported by libfreetype, and are
1262a combination of the following values:
1263@table @var
1264@item default
1265@item no_scale
1266@item no_hinting
1267@item render
1268@item no_bitmap
1269@item vertical_layout
1270@item force_autohint
1271@item crop_bitmap
1272@item pedantic
1273@item ignore_global_advance_width
1274@item no_recurse
1275@item ignore_transform
1276@item monochrome
1277@item linear_design
1278@item no_autohint
1279@item end table
1280@end table
1281
1282Default value is "render".
1283
1284For more information consult the documentation for the FT_LOAD_*
1285libfreetype flags.
1286
1287@item tabsize
1288The size in number of spaces to use for rendering the tab.
1289Default value is 4.
e496c45d
AU
1290
1291@item fix_bounds
1292If true, check and fix text coords to avoid clipping.
a5b64584
SS
1293@end table
1294
1295For example the command:
1296@example
1297drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
1298@end example
1299
1300will draw "Test Text" with font FreeSerif, using the default values
1301for the optional parameters.
1302
1303The command:
1304@example
1305drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
1306 x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
1307@end example
1308
1309will draw 'Test Text' with font FreeSerif of size 24 at position x=100
1310and y=50 (counting from the top-left corner of the screen), text is
1311yellow with a red box around it. Both the text and the box have an
1312opacity of 20%.
1313
1314Note that the double quotes are not necessary if spaces are not used
1315within the parameter list.
1316
1317For more information about libfreetype, check:
1318@url{http://www.freetype.org/}.
1319
aadfc9ee
BM
1320@section fade
1321
d4a8a86c 1322Apply a fade-in/out effect to the input video.
aadfc9ee 1323
d4a8a86c 1324It accepts the following parameters:
b9dfee9f
AK
1325
1326@table @option
aadfc9ee 1327
b9dfee9f 1328@item type
d4a8a86c 1329The effect type can be either "in" for a fade-in, or "out" for a fade-out
b9dfee9f 1330effect.
aadfc9ee 1331
b9dfee9f 1332@item start_frame
d4a8a86c 1333The number of the frame to start applying the fade effect at.
aadfc9ee 1334
b9dfee9f 1335@item nb_frames
d4a8a86c
KBA
1336The number of frames that the fade effect lasts. At the end of the
1337fade-in effect, the output video will have the same intensity as the input video.
1338At the end of the fade-out transition, the output video will be completely black.
b9dfee9f
AK
1339
1340@end table
aadfc9ee 1341
d4a8a86c 1342Some examples:
aadfc9ee 1343@example
d4a8a86c 1344# Fade in the first 30 frames of video
b9dfee9f 1345fade=type=in:nb_frames=30
aadfc9ee 1346
d4a8a86c 1347# Fade out the last 45 frames of a 200-frame video
b9dfee9f 1348fade=type=out:start_frame=155:nb_frames=45
aadfc9ee 1349
d4a8a86c 1350# Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video
b9dfee9f 1351fade=type=in:start_frame=0:nb_frames=25, fade=type=out:start_frame=975:nb_frames=25
aadfc9ee 1352
d4a8a86c 1353# Make the first 5 frames black, then fade in from frame 5-24
b9dfee9f 1354fade=type=in:start_frame=5:nb_frames=20
aadfc9ee
BM
1355@end example
1356
2f84bb42
MH
1357@section fieldorder
1358
1359Transform the field order of the input video.
1360
d4a8a86c 1361It accepts the following parameters:
2f84bb42
MH
1362
1363@table @option
a39c1540
AK
1364
1365@item order
d4a8a86c 1366The output field order. Valid values are @var{tff} for top field first or @var{bff}
a39c1540 1367for bottom field first.
2f84bb42
MH
1368@end table
1369
d4a8a86c 1370The default value is "tff".
2f84bb42 1371
d4a8a86c 1372The transformation is done by shifting the picture content up or down
2f84bb42
MH
1373by one line, and filling the remaining line with appropriate picture content.
1374This method is consistent with most broadcast field order converters.
1375
1376If the input video is not flagged as being interlaced, or it is already
d4a8a86c 1377flagged as being of the required output field order, then this filter does
2f84bb42
MH
1378not alter the incoming video.
1379
d4a8a86c 1380It is very useful when converting to or from PAL DV material,
2f84bb42
MH
1381which is bottom field first.
1382
1383For example:
1384@example
a39c1540 1385./avconv -i in.vob -vf "fieldorder=order=bff" out.dv
2f84bb42
MH
1386@end example
1387
7f1af825
SS
1388@section fifo
1389
1390Buffer input images and send them when they are requested.
1391
d4a8a86c 1392It is mainly useful when auto-inserted by the libavfilter
7f1af825
SS
1393framework.
1394
d4a8a86c 1395It does not take parameters.
7f1af825 1396
3275ac6a
SS
1397@section format
1398
1399Convert the input video to one of the specified pixel formats.
d4a8a86c 1400Libavfilter will try to pick one that is suitable as input to
3275ac6a
SS
1401the next filter.
1402
d4a8a86c 1403It accepts the following parameters:
e67a87ea
AK
1404@table @option
1405
1406@item pix_fmts
d4a8a86c 1407A '|'-separated list of pixel format names, such as
e67a87ea
AK
1408"pix_fmts=yuv420p|monow|rgb24".
1409
1410@end table
3275ac6a 1411
d4a8a86c 1412Some examples:
3275ac6a 1413@example
d4a8a86c 1414# Convert the input video to the "yuv420p" format
e67a87ea 1415format=pix_fmts=yuv420p
3275ac6a 1416
d4a8a86c 1417# Convert the input video to any of the formats in the list
e67a87ea 1418format=pix_fmts=yuv420p|yuv444p|yuv410p
f150e4dc 1419@end example
3275ac6a 1420
dd249245 1421@anchor{fps}
54c5dd89
AK
1422@section fps
1423
1424Convert the video to specified constant framerate by duplicating or dropping
1425frames as necessary.
1426
d4a8a86c 1427It accepts the following parameters:
54c5dd89
AK
1428@table @option
1429
1430@item fps
d4a8a86c 1431The desired output framerate.
54c5dd89 1432
545a0b80
JR
1433@item start_time
1434Assume the first PTS should be the given value, in seconds. This allows for
1435padding/trimming at the start of stream. By default, no assumption is made
1436about the first frame's expected PTS, so no padding or trimming is done.
1437For example, this could be set to 0 to pad the beginning with duplicates of
1438the first frame if a video stream starts after the audio stream or to trim any
1439frames with a negative PTS.
1440
54c5dd89
AK
1441@end table
1442
a7d0e7ea
VG
1443@section framepack
1444
1445Pack two different video streams into a stereoscopic video, setting proper
1446metadata on supported codecs. The two views should have the same size and
1447framerate and processing will stop when the shorter video ends. Please note
1448that you may conveniently adjust view properties with the @ref{scale} and
1449@ref{fps} filters.
1450
d4a8a86c 1451It accepts the following parameters:
a7d0e7ea
VG
1452@table @option
1453
1454@item format
d4a8a86c 1455The desired packing format. Supported values are:
a7d0e7ea
VG
1456
1457@table @option
1458
1459@item sbs
d4a8a86c 1460The views are next to each other (default).
a7d0e7ea
VG
1461
1462@item tab
d4a8a86c 1463The views are on top of each other.
a7d0e7ea
VG
1464
1465@item lines
d4a8a86c 1466The views are packed by line.
a7d0e7ea
VG
1467
1468@item columns
d4a8a86c 1469The views are packed by column.
a7d0e7ea
VG
1470
1471@item frameseq
d4a8a86c 1472The views are temporally interleaved.
a7d0e7ea
VG
1473
1474@end table
1475
1476@end table
1477
d4a8a86c 1478Some examples:
a7d0e7ea
VG
1479
1480@example
d4a8a86c 1481# Convert left and right views into a frame-sequential video
a7d0e7ea
VG
1482avconv -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
1483
d4a8a86c 1484# Convert views into a side-by-side video with the same output resolution as the input
a7d0e7ea
VG
1485avconv -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
1486@end example
1487
f8608dca 1488@anchor{frei0r}
47941088
SS
1489@section frei0r
1490
1491Apply a frei0r effect to the input video.
1492
d4a8a86c 1493To enable the compilation of this filter, you need to install the frei0r
f8a45fa1 1494header and configure Libav with --enable-frei0r.
47941088 1495
d4a8a86c 1496It accepts the following parameters:
5aa1a668
AK
1497
1498@table @option
1499
1500@item filter_name
d4a8a86c
KBA
1501The name of the frei0r effect to load. If the environment variable
1502@env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
1503directories specified by the colon-separated list in @env{FREIOR_PATH}.
1504Otherwise, the standard frei0r paths are searched, in this order:
5aa1a668
AK
1505@file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
1506@file{/usr/lib/frei0r-1/}.
47941088 1507
5aa1a668
AK
1508@item filter_params
1509A '|'-separated list of parameters to pass to the frei0r effect.
47941088 1510
5aa1a668 1511@end table
47941088 1512
d4a8a86c
KBA
1513A frei0r effect parameter can be a boolean (its value is either
1514"y" or "n"), a double, a color (specified as
1515@var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
1516numbers between 0.0 and 1.0, inclusive) or by an @code{av_parse_color()} color
1517description), a position (specified as @var{X}/@var{Y}, where
1518@var{X} and @var{Y} are floating point numbers) and/or a string.
47941088 1519
d4a8a86c
KBA
1520The number and types of parameters depend on the loaded effect. If an
1521effect parameter is not specified, the default value is set.
47941088 1522
d4a8a86c 1523Some examples:
47941088 1524@example
d4a8a86c 1525# Apply the distort0r effect, setting the first two double parameters
5aa1a668 1526frei0r=filter_name=distort0r:filter_params=0.5|0.01
47941088 1527
d4a8a86c 1528# Apply the colordistance effect, taking a color as the first parameter
47941088
SS
1529frei0r=colordistance:0.2/0.3/0.4
1530frei0r=colordistance:violet
1531frei0r=colordistance:0x112233
1532
d4a8a86c 1533# Apply the perspective effect, specifying the top left and top right
47941088 1534# image positions
5aa1a668 1535frei0r=perspective:0.2/0.2|0.8/0.2
47941088
SS
1536@end example
1537
d4a8a86c 1538For more information, see
47941088
SS
1539@url{http://piksel.org/frei0r}
1540
d5f187fd
N
1541@section gradfun
1542
1543Fix the banding artifacts that are sometimes introduced into nearly flat
1544regions by truncation to 8bit colordepth.
1545Interpolate the gradients that should go where the bands are, and
1546dither them.
1547
d4a8a86c 1548It is designed for playback only. Do not use it prior to
3eccfaa0
SS
1549lossy compression, because compression tends to lose the dither and
1550bring back the bands.
1551
d4a8a86c 1552It accepts the following parameters:
7ed833d7
AK
1553
1554@table @option
d5f187fd 1555
7ed833d7 1556@item strength
d4a8a86c
KBA
1557The maximum amount by which the filter will change any one pixel. This is also
1558the threshold for detecting nearly flat regions. Acceptable values range from
1559.51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
1560valid range.
d5f187fd 1561
7ed833d7
AK
1562@item radius
1563The neighborhood to fit the gradient to. A larger radius makes for smoother
1564gradients, but also prevents the filter from modifying the pixels near detailed
d4a8a86c
KBA
1565regions. Acceptable values are 8-32; the default value is 16. Out-of-range
1566values will be clipped to the valid range.
7ed833d7
AK
1567
1568@end table
d5f187fd
N
1569
1570@example
d4a8a86c 1571# Default parameters
7ed833d7 1572gradfun=strength=1.2:radius=16
d5f187fd 1573
d4a8a86c 1574# Omitting the radius
d5f187fd
N
1575gradfun=1.2
1576@end example
1577
a1e171df
SS
1578@section hflip
1579
1580Flip the input video horizontally.
1581
d4a8a86c 1582For example, to horizontally flip the input video with @command{avconv}:
a1e171df 1583@example
9270b8a3 1584avconv -i in.avi -vf "hflip" out.avi
a1e171df
SS
1585@end example
1586
a4dc7aa5
BC
1587@section hqdn3d
1588
d4a8a86c
KBA
1589This is a high precision/quality 3d denoise filter. It aims to reduce
1590image noise, producing smooth images and making still images really
a4dc7aa5
BC
1591still. It should enhance compressibility.
1592
1593It accepts the following optional parameters:
a4dc7aa5
BC
1594
1595@table @option
1596@item luma_spatial
d4a8a86c
KBA
1597A non-negative floating point number which specifies spatial luma strength.
1598It defaults to 4.0.
a4dc7aa5
BC
1599
1600@item chroma_spatial
d4a8a86c
KBA
1601A non-negative floating point number which specifies spatial chroma strength.
1602It defaults to 3.0*@var{luma_spatial}/4.0.
a4dc7aa5
BC
1603
1604@item luma_tmp
d4a8a86c
KBA
1605A floating point number which specifies luma temporal strength. It defaults to
16066.0*@var{luma_spatial}/4.0.
a4dc7aa5
BC
1607
1608@item chroma_tmp
d4a8a86c
KBA
1609A floating point number which specifies chroma temporal strength. It defaults to
1610@var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
a4dc7aa5
BC
1611@end table
1612
21f7cd4a
AK
1613@section hwupload_cuda
1614
1615Upload system memory frames to a CUDA device.
1616
1617It accepts the following optional parameters:
1618
1619@table @option
1620@item device
1621The number of the CUDA device to use
1622@end table
1623
3fce1367
VG
1624@section interlace
1625
1626Simple interlacing filter from progressive contents. This interleaves upper (or
1627lower) lines from odd frames with lower (or upper) lines from even frames,
52269f48 1628halving the frame rate and preserving image height.
3fce1367
VG
1629
1630@example
1631 Original Original New Frame
1632 Frame 'j' Frame 'j+1' (tff)
1633 ========== =========== ==================
1634 Line 0 --------------------> Frame 'j' Line 0
1635 Line 1 Line 1 ----> Frame 'j+1' Line 1
1636 Line 2 ---------------------> Frame 'j' Line 2
1637 Line 3 Line 3 ----> Frame 'j+1' Line 3
1638 ... ... ...
1639New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
1640@end example
1641
1642It accepts the following optional parameters:
1643
1644@table @option
1645@item scan
d4a8a86c
KBA
1646This determines whether the interlaced frame is taken from the even
1647(tff - default) or odd (bff) lines of the progressive frame.
52269f48
VG
1648
1649@item lowpass
1650Enable (default) or disable the vertical lowpass filter to avoid twitter
1651interlacing and reduce moire patterns.
3fce1367
VG
1652@end table
1653
8fe0c527
SS
1654@section lut, lutrgb, lutyuv
1655
1656Compute a look-up table for binding each pixel component input value
d4a8a86c 1657to an output value, and apply it to the input video.
8fe0c527
SS
1658
1659@var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
1660to an RGB input video.
1661
d4a8a86c 1662These filters accept the following parameters:
8fe0c527 1663@table @option
91f5f875
LB
1664@item @var{c0} (first pixel component)
1665@item @var{c1} (second pixel component)
1666@item @var{c2} (third pixel component)
1667@item @var{c3} (fourth pixel component, corresponds to the alpha component)
8fe0c527 1668
91f5f875
LB
1669@item @var{r} (red component)
1670@item @var{g} (green component)
1671@item @var{b} (blue component)
1672@item @var{a} (alpha component)
8fe0c527 1673
91f5f875
LB
1674@item @var{y} (Y/luminance component)
1675@item @var{u} (U/Cb component)
1676@item @var{v} (V/Cr component)
8fe0c527
SS
1677@end table
1678
20b46f8f
AK
1679Each of them specifies the expression to use for computing the lookup table for
1680the corresponding pixel component values.
1681
1682The exact component associated to each of the @var{c*} options depends on the
1683format in input.
1684
1685The @var{lut} filter requires either YUV or RGB pixel formats in input,
1686@var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
1687
8fe0c527
SS
1688The expressions can contain the following constants and functions:
1689
1690@table @option
1691@item E, PI, PHI
d4a8a86c
KBA
1692These are approximated values for the mathematical constants e
1693(Euler's number), pi (Greek pi), and phi (the golden ratio).
8fe0c527
SS
1694
1695@item w, h
d4a8a86c 1696The input width and height.
8fe0c527
SS
1697
1698@item val
d4a8a86c 1699The input value for the pixel component.
8fe0c527
SS
1700
1701@item clipval
d4a8a86c 1702The input value, clipped to the @var{minval}-@var{maxval} range.
8fe0c527
SS
1703
1704@item maxval
d4a8a86c 1705The maximum value for the pixel component.
8fe0c527
SS
1706
1707@item minval
d4a8a86c 1708The minimum value for the pixel component.
8fe0c527
SS
1709
1710@item negval
d4a8a86c
KBA
1711The negated value for the pixel component value, clipped to the
1712@var{minval}-@var{maxval} range; it corresponds to the expression
1713"maxval-clipval+minval".
8fe0c527
SS
1714
1715@item clip(val)
d4a8a86c
KBA
1716The computed value in @var{val}, clipped to the
1717@var{minval}-@var{maxval} range.
8fe0c527
SS
1718
1719@item gammaval(gamma)
d4a8a86c
KBA
1720The computed gamma correction value of the pixel component value,
1721clipped to the @var{minval}-@var{maxval} range. It corresponds to the
8fe0c527
SS
1722expression
1723"pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
1724
1725@end table
1726
1727All expressions default to "val".
1728
d4a8a86c 1729Some examples:
8fe0c527 1730@example
d4a8a86c 1731# Negate input video
8fe0c527
SS
1732lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
1733lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
1734
d4a8a86c 1735# The above is the same as
8fe0c527
SS
1736lutrgb="r=negval:g=negval:b=negval"
1737lutyuv="y=negval:u=negval:v=negval"
1738
d4a8a86c 1739# Negate luminance
8fe0c527
SS
1740lutyuv=negval
1741
d4a8a86c 1742# Remove chroma components, turning the video into a graytone image
8fe0c527
SS
1743lutyuv="u=128:v=128"
1744
d4a8a86c 1745# Apply a luma burning effect
8fe0c527
SS
1746lutyuv="y=2*val"
1747
d4a8a86c 1748# Remove green and blue components
8fe0c527
SS
1749lutrgb="g=0:b=0"
1750
d4a8a86c 1751# Set a constant alpha channel value on input
8fe0c527
SS
1752format=rgba,lutrgb=a="maxval-minval/2"
1753
d4a8a86c 1754# Correct luminance gamma by a factor of 0.5
8fe0c527
SS
1755lutyuv=y=gammaval(0.5)
1756@end example
1757
171868e2
SS
1758@section negate
1759
1760Negate input video.
1761
d4a8a86c 1762It accepts an integer in input; if non-zero it negates the
171868e2 1763alpha component (if available). The default value in input is 0.
3275ac6a 1764
ef4d34aa
AK
1765@section noformat
1766
3275ac6a
SS
1767Force libavfilter not to use any of the specified pixel formats for the
1768input to the next filter.
1769
d4a8a86c 1770It accepts the following parameters:
e67a87ea
AK
1771@table @option
1772
1773@item pix_fmts
d4a8a86c
KBA
1774A '|'-separated list of pixel format names, such as
1775apix_fmts=yuv420p|monow|rgb24".
e67a87ea
AK
1776
1777@end table
3275ac6a 1778
d4a8a86c 1779Some examples:
3275ac6a 1780@example
d4a8a86c 1781# Force libavfilter to use a format different from "yuv420p" for the
f150e4dc 1782# input to the vflip filter
e67a87ea 1783noformat=pix_fmts=yuv420p,vflip
3275ac6a 1784
d4a8a86c 1785# Convert the input video to any of the formats not contained in the list
e67a87ea 1786noformat=yuv420p|yuv444p|yuv410p
f150e4dc 1787@end example
3275ac6a
SS
1788
1789@section null
1790
99046339 1791Pass the video source unchanged to the output.
3275ac6a 1792
cf69ad35 1793@section ocv
6ebf0bfc 1794
d4a8a86c 1795Apply a video transform using libopencv.
6ebf0bfc 1796
d4a8a86c 1797To enable this filter, install the libopencv library and headers and
f8a45fa1 1798configure Libav with --enable-libopencv.
6ebf0bfc 1799
d4a8a86c 1800It accepts the following parameters:
ee0e8d4b
AK
1801
1802@table @option
cf69ad35 1803
ee0e8d4b
AK
1804@item filter_name
1805The name of the libopencv filter to apply.
cf69ad35 1806
ee0e8d4b 1807@item filter_params
d4a8a86c 1808The parameters to pass to the libopencv filter. If not specified, the default
ee0e8d4b
AK
1809values are assumed.
1810
1811@end table
cf69ad35
SS
1812
1813Refer to the official libopencv documentation for more precise
da9cea77 1814information:
cf69ad35
SS
1815@url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
1816
d4a8a86c 1817Several libopencv filters are supported; see the following subsections.
cf69ad35 1818
17fc9493 1819@anchor{dilate}
91cbb6ba
SS
1820@subsection dilate
1821
1822Dilate an image by using a specific structuring element.
d4a8a86c 1823It corresponds to the libopencv function @code{cvDilate}.
91cbb6ba 1824
ee0e8d4b 1825It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
91cbb6ba
SS
1826
1827@var{struct_el} represents a structuring element, and has the syntax:
1828@var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
1829
da9cea77 1830@var{cols} and @var{rows} represent the number of columns and rows of
91cbb6ba 1831the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
d4a8a86c
KBA
1832point, and @var{shape} the shape for the structuring element. @var{shape}
1833must be "rect", "cross", "ellipse", or "custom".
91cbb6ba
SS
1834
1835If the value for @var{shape} is "custom", it must be followed by a
1836string of the form "=@var{filename}". The file with name
1837@var{filename} is assumed to represent a binary image, with each
1838printable character corresponding to a bright pixel. When a custom
1839@var{shape} is used, @var{cols} and @var{rows} are ignored, the number
1840or columns and rows of the read file are assumed instead.
1841
1842The default value for @var{struct_el} is "3x3+0x0/rect".
1843
1844@var{nb_iterations} specifies the number of times the transform is
1845applied to the image, and defaults to 1.
1846
d4a8a86c 1847Some examples:
91cbb6ba 1848@example
d4a8a86c 1849# Use the default values
91cbb6ba
SS
1850ocv=dilate
1851
d4a8a86c 1852# Dilate using a structuring element with a 5x5 cross, iterating two times
ee0e8d4b 1853ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
91cbb6ba 1854
d4a8a86c
KBA
1855# Read the shape from the file diamond.shape, iterating two times.
1856# The file diamond.shape may contain a pattern of characters like this
91cbb6ba
SS
1857# *
1858# ***
1859# *****
1860# ***
1861# *
d4a8a86c
KBA
1862# The specified columns and rows are ignored
1863# but the anchor point coordinates are not
ee0e8d4b 1864ocv=dilate:0x0+2x2/custom=diamond.shape|2
91cbb6ba
SS
1865@end example
1866
17fc9493
SS
1867@subsection erode
1868
1869Erode an image by using a specific structuring element.
d4a8a86c 1870It corresponds to the libopencv function @code{cvErode}.
17fc9493 1871
d4a8a86c 1872It accepts the parameters: @var{struct_el}:@var{nb_iterations},
4c989761 1873with the same syntax and semantics as the @ref{dilate} filter.
17fc9493 1874
cf69ad35
SS
1875@subsection smooth
1876
1877Smooth the input video.
1878
1879The filter takes the following parameters:
ee0e8d4b 1880@var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
6ebf0bfc 1881
d4a8a86c 1882@var{type} is the type of smooth filter to apply, and must be one of
58d94364 1883the following values: "blur", "blur_no_scale", "median", "gaussian",
d4a8a86c 1884or "bilateral". The default value is "gaussian".
6ebf0bfc 1885
d4a8a86c
KBA
1886The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
1887depend on the smooth type. @var{param1} and
1888@var{param2} accept integer positive values or 0. @var{param3} and
1889@var{param4} accept floating point values.
6ebf0bfc 1890
d4a8a86c 1891The default value for @var{param1} is 3. The default value for the
6ebf0bfc
SS
1892other parameters is 0.
1893
58d94364 1894These parameters correspond to the parameters assigned to the
cf69ad35 1895libopencv function @code{cvSmooth}.
6ebf0bfc 1896
2cf74eca 1897@anchor{overlay}
58935b25
SS
1898@section overlay
1899
1900Overlay one video on top of another.
1901
d4a8a86c 1902It takes two inputs and has one output. The first input is the "main"
58935b25
SS
1903video on which the second input is overlayed.
1904
d4a8a86c 1905It accepts the following parameters:
9087eaf1
AK
1906
1907@table @option
1908
1909@item x
1910The horizontal position of the left edge of the overlaid video on the main video.
1911
1912@item y
1913The vertical position of the top edge of the overlaid video on the main video.
1914
1915@end table
58935b25 1916
9087eaf1 1917The parameters are expressions containing the following parameters:
58935b25
SS
1918
1919@table @option
1920@item main_w, main_h
d4a8a86c 1921The main input width and height.
58935b25
SS
1922
1923@item W, H
d4a8a86c 1924These are the same as @var{main_w} and @var{main_h}.
58935b25
SS
1925
1926@item overlay_w, overlay_h
d4a8a86c 1927The overlay input width and height.
58935b25
SS
1928
1929@item w, h
d4a8a86c 1930These are the same as @var{overlay_w} and @var{overlay_h}.
de203abd
KL
1931
1932@item eof_action
d4a8a86c
KBA
1933The action to take when EOF is encountered on the secondary input; it accepts
1934one of the following values:
de203abd
KL
1935
1936@table @option
1937@item repeat
d4a8a86c 1938Repeat the last frame (the default).
de203abd 1939@item endall
d4a8a86c 1940End both streams.
de203abd 1941@item pass
d4a8a86c 1942Pass the main input through.
de203abd
KL
1943@end table
1944
58935b25
SS
1945@end table
1946
1947Be aware that frames are taken from each input video in timestamp
1948order, hence, if their initial timestamps differ, it is a a good idea
1949to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
d4a8a86c
KBA
1950have them begin in the same zero timestamp, as the example for
1951the @var{movie} filter does.
58935b25 1952
d4a8a86c 1953Some examples:
58935b25 1954@example
d4a8a86c
KBA
1955# Draw the overlay at 10 pixels from the bottom right
1956# corner of the main video
9087eaf1 1957overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
58935b25 1958
d4a8a86c 1959# Insert a transparent PNG logo in the bottom left corner of the input
9087eaf1 1960avconv -i input -i logo -filter_complex 'overlay=x=10:y=main_h-overlay_h-10' output
58935b25 1961
d4a8a86c
KBA
1962# Insert 2 different transparent PNG logos (second logo on bottom
1963# right corner)
7ce118ba 1964avconv -i input -i logo1 -i logo2 -filter_complex
9087eaf1 1965'overlay=x=10:y=H-h-10,overlay=x=W-w-10:y=H-h-10' output
58935b25 1966
d4a8a86c 1967# Add a transparent color layer on top of the main video;
58935b25
SS
1968# WxH specifies the size of the main input to the overlay filter
1969color=red@.3:WxH [over]; [in][over] overlay [out]
de203abd 1970
d4a8a86c 1971# Mask 10-20 seconds of a video by applying the delogo filter to a section
de203abd
KL
1972avconv -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
1973-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]'
1974masked.avi
58935b25
SS
1975@end example
1976
b0641ab7 1977You can chain together more overlays but the efficiency of such
58935b25
SS
1978approach is yet to be tested.
1979
3275ac6a
SS
1980@section pad
1981
d4a8a86c
KBA
1982Add paddings to the input image, and place the original input at the
1983provided @var{x}, @var{y} coordinates.
3275ac6a 1984
d4a8a86c 1985It accepts the following parameters:
40c885c5
AK
1986
1987@table @option
1988@item width, height
1989
1990Specify the size of the output image with the paddings added. If the
1991value for @var{width} or @var{height} is 0, the corresponding input size
1992is used for the output.
1993
1994The @var{width} expression can reference the value set by the
1995@var{height} expression, and vice versa.
1996
1997The default value of @var{width} and @var{height} is 0.
1998
1999@item x, y
2000
d4a8a86c 2001Specify the offsets to place the input image at within the padded area,
40c885c5
AK
2002with respect to the top/left border of the output image.
2003
2004The @var{x} expression can reference the value set by the @var{y}
2005expression, and vice versa.
2006
2007The default value of @var{x} and @var{y} is 0.
2008
2009@item color
2010
d4a8a86c
KBA
2011Specify the color of the padded area. It can be the name of a color
2012(case insensitive match) or an 0xRRGGBB[AA] sequence.
40c885c5
AK
2013
2014The default value of @var{color} is "black".
2015
2016@end table
3275ac6a 2017
73a4f7c2
SS
2018The parameters @var{width}, @var{height}, @var{x}, and @var{y} are
2019expressions containing the following constants:
2020
2021@table @option
2022@item E, PI, PHI
d4a8a86c
KBA
2023These are approximated values for the mathematical constants e
2024(Euler's number), pi (Greek pi), and phi (the golden ratio).
73a4f7c2
SS
2025
2026@item in_w, in_h
d4a8a86c 2027The input video width and height.
73a4f7c2
SS
2028
2029@item iw, ih
d4a8a86c 2030These are the same as @var{in_w} and @var{in_h}.
73a4f7c2
SS
2031
2032@item out_w, out_h
d4a8a86c
KBA
2033The output width and height (the size of the padded area), as
2034specified by the @var{width} and @var{height} expressions.
73a4f7c2
SS
2035
2036@item ow, oh
d4a8a86c 2037These are the same as @var{out_w} and @var{out_h}.
73a4f7c2
SS
2038
2039@item x, y
d4a8a86c
KBA
2040The x and y offsets as specified by the @var{x} and @var{y}
2041expressions, or NAN if not yet specified.
73a4f7c2
SS
2042
2043@item a
d4a8a86c 2044The input display aspect ratio, same as @var{iw} / @var{ih}.
73a4f7c2
SS
2045
2046@item hsub, vsub
d4a8a86c 2047The horizontal and vertical chroma subsample values. For example for the
73a4f7c2
SS
2048pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
2049@end table
2050
d4a8a86c 2051Some examples:
3d17f4b9
SS
2052
2053@example
d4a8a86c
KBA
2054# Add paddings with the color "violet" to the input video. The output video
2055# size is 640x480, and the top-left corner of the input video is placed at
2056# column 0, row 40
40c885c5 2057pad=width=640:height=480:x=0:y=40:color=violet
73a4f7c2 2058
d4a8a86c 2059# Pad the input to get an output with dimensions increased by 3/2,
73a4f7c2
SS
2060# and put the input video at the center of the padded area
2061pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
2062
d4a8a86c 2063# Pad the input to get a squared output with size equal to the maximum
73a4f7c2
SS
2064# value between the input width and height, and put the input video at
2065# the center of the padded area
2066pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
2067
d4a8a86c 2068# Pad the input to get a final w/h ratio of 16:9
73a4f7c2
SS
2069pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
2070
d4a8a86c 2071# Double the output size and put the input video in the bottom-right
73a4f7c2
SS
2072# corner of the output padded area
2073pad="2*iw:2*ih:ow-iw:oh-ih"
3d17f4b9
SS
2074@end example
2075
ce2e4ae3
SS
2076@section pixdesctest
2077
2078Pixel format descriptor test filter, mainly useful for internal
2079testing. The output video should be equal to the input video.
2080
2081For example:
2082@example
2083format=monow, pixdesctest
2084@end example
2085
2086can be used to test the monowhite pixel format descriptor definition.
2087
dd249245 2088@anchor{scale}
3275ac6a
SS
2089@section scale
2090
c334c113 2091Scale the input video and/or convert the image format.
3275ac6a 2092
d4a8a86c 2093It accepts the following parameters:
c334c113
AK
2094
2095@table @option
2096
2097@item w
d4a8a86c 2098The output video width.
c334c113
AK
2099
2100@item h
d4a8a86c 2101The output video height.
c334c113
AK
2102
2103@end table
2104
2105The parameters @var{w} and @var{h} are expressions containing
68e23c08 2106the following constants:
3275ac6a 2107
68e23c08
SS
2108@table @option
2109@item E, PI, PHI
d4a8a86c
KBA
2110These are approximated values for the mathematical constants e
2111(Euler's number), pi (Greek pi), and phi (the golden ratio).
68e23c08
SS
2112
2113@item in_w, in_h
d4a8a86c 2114The input width and height.
68e23c08
SS
2115
2116@item iw, ih
d4a8a86c 2117These are the same as @var{in_w} and @var{in_h}.
68e23c08
SS
2118
2119@item out_w, out_h
d4a8a86c 2120The output (cropped) width and height.
68e23c08
SS
2121
2122@item ow, oh
d4a8a86c 2123These are the same as @var{out_w} and @var{out_h}.
3275ac6a 2124
3a14b160 2125@item a
d4a8a86c 2126This is the same as @var{iw} / @var{ih}.
68e23c08 2127
46b29397
SS
2128@item sar
2129input sample aspect ratio
2130
3a14b160 2131@item dar
d4a8a86c
KBA
2132The input display aspect ratio; it is the same as
2133(@var{iw} / @var{ih}) * @var{sar}.
3a14b160 2134
68e23c08 2135@item hsub, vsub
d4a8a86c 2136The horizontal and vertical chroma subsample values. For example, for the
68e23c08
SS
2137pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
2138@end table
3275ac6a
SS
2139
2140If the input image format is different from the format requested by
2141the next filter, the scale filter will convert the input to the
2142requested format.
2143
c334c113 2144If the value for @var{w} or @var{h} is 0, the respective input
3275ac6a
SS
2145size is used for the output.
2146
c334c113
AK
2147If the value for @var{w} or @var{h} is -1, the scale filter will use, for the
2148respective output size, a value that maintains the aspect ratio of the input
2149image.
3275ac6a 2150
c334c113 2151The default value of @var{w} and @var{h} is 0.
3275ac6a 2152
d4a8a86c 2153Some examples:
68e23c08 2154@example
d4a8a86c 2155# Scale the input video to a size of 200x100
c334c113 2156scale=w=200:h=100
68e23c08 2157
d4a8a86c 2158# Scale the input to 2x
c334c113 2159scale=w=2*iw:h=2*ih
d4a8a86c 2160# The above is the same as
68e23c08
SS
2161scale=2*in_w:2*in_h
2162
d4a8a86c 2163# Scale the input to half the original size
c334c113 2164scale=w=iw/2:h=ih/2
68e23c08 2165
d4a8a86c 2166# Increase the width, and set the height to the same size
68e23c08
SS
2167scale=3/2*iw:ow
2168
d4a8a86c 2169# Seek Greek harmony
68e23c08
SS
2170scale=iw:1/PHI*iw
2171scale=ih*PHI:ih
2172
d4a8a86c 2173# Increase the height, and set the width to 3/2 of the height
c334c113 2174scale=w=3/2*oh:h=3/5*ih
68e23c08 2175
d4a8a86c 2176# Increase the size, making the size a multiple of the chroma
68e23c08
SS
2177scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
2178
d4a8a86c
KBA
2179# Increase the width to a maximum of 500 pixels,
2180# keeping the same aspect ratio as the input
c334c113 2181scale=w='min(500\, iw*3/2):h=-1'
68e23c08
SS
2182@end example
2183
d763fb7d
SS
2184@section select
2185Select frames to pass in output.
2186
d4a8a86c 2187It accepts the following parameters:
95f1f56a
AK
2188
2189@table @option
2190
2191@item expr
2192An expression, which is evaluated for each input frame. If the expression is
2193evaluated to a non-zero value, the frame is selected and passed to the output,
2194otherwise it is discarded.
2195
2196@end table
d763fb7d
SS
2197
2198The expression can contain the following constants:
2199
2200@table @option
d4a8a86c
KBA
2201@item E, PI, PHI
2202These are approximated values for the mathematical constants e
2203(Euler's number), pi (Greek pi), and phi (the golden ratio).
d763fb7d
SS
2204
2205@item n
d4a8a86c 2206The (sequential) number of the filtered frame, starting from 0.
d763fb7d
SS
2207
2208@item selected_n
d4a8a86c 2209The (sequential) number of the selected frame, starting from 0.
d763fb7d
SS
2210
2211@item prev_selected_n
d4a8a86c 2212The sequential number of the last selected frame. It's NAN if undefined.
d763fb7d
SS
2213
2214@item TB
d4a8a86c 2215The timebase of the input timestamps.
d763fb7d
SS
2216
2217@item pts
d4a8a86c
KBA
2218The PTS (Presentation TimeStamp) of the filtered video frame,
2219expressed in @var{TB} units. It's NAN if undefined.
d763fb7d
SS
2220
2221@item t
d4a8a86c
KBA
2222The PTS of the filtered video frame,
2223expressed in seconds. It's NAN if undefined.
d763fb7d
SS
2224
2225@item prev_pts
d4a8a86c 2226The PTS of the previously filtered video frame. It's NAN if undefined.
d763fb7d
SS
2227
2228@item prev_selected_pts
d4a8a86c 2229The PTS of the last previously filtered video frame. It's NAN if undefined.
d763fb7d
SS
2230
2231@item prev_selected_t
d4a8a86c 2232The PTS of the last previously selected video frame. It's NAN if undefined.
d763fb7d
SS
2233
2234@item start_pts
d4a8a86c 2235The PTS of the first video frame in the video. It's NAN if undefined.
d763fb7d
SS
2236
2237@item start_t
d4a8a86c 2238The time of the first video frame in the video. It's NAN if undefined.
d763fb7d
SS
2239
2240@item pict_type
d4a8a86c 2241The type of the filtered frame. It can assume one of the following
d763fb7d
SS
2242values:
2243@table @option
2244@item I
2245@item P
2246@item B
2247@item S
2248@item SI
2249@item SP
2250@item BI
2251@end table
2252
2253@item interlace_type
d4a8a86c 2254The frame interlace type. It can assume one of the following values:
d763fb7d
SS
2255@table @option
2256@item PROGRESSIVE
d4a8a86c 2257The frame is progressive (not interlaced).
d763fb7d 2258@item TOPFIRST
d4a8a86c 2259The frame is top-field-first.
d763fb7d 2260@item BOTTOMFIRST
d4a8a86c 2261The frame is bottom-field-first.
d763fb7d
SS
2262@end table
2263
2264@item key
d4a8a86c 2265This is 1 if the filtered frame is a key-frame, 0 otherwise.
d763fb7d 2266
d763fb7d
SS
2267@end table
2268
2269The default value of the select expression is "1".
2270
d4a8a86c 2271Some examples:
d763fb7d
SS
2272
2273@example
d4a8a86c 2274# Select all the frames in input
d763fb7d
SS
2275select
2276
d4a8a86c 2277# The above is the same as
95f1f56a 2278select=expr=1
d763fb7d 2279
d4a8a86c 2280# Skip all frames
95f1f56a 2281select=expr=0
d763fb7d 2282
d4a8a86c 2283# Select only I-frames
95f1f56a 2284select='expr=eq(pict_type\,I)'
d763fb7d 2285
d4a8a86c 2286# Select one frame per 100
d763fb7d
SS
2287select='not(mod(n\,100))'
2288
d4a8a86c 2289# Select only frames contained in the 10-20 time interval
d763fb7d
SS
2290select='gte(t\,10)*lte(t\,20)'
2291
d4a8a86c 2292# Select only I frames contained in the 10-20 time interval
d763fb7d
SS
2293select='gte(t\,10)*lte(t\,20)*eq(pict_type\,I)'
2294
d4a8a86c 2295# Select frames with a minimum distance of 10 seconds
d763fb7d
SS
2296select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
2297@end example
2298
2fd8756b
SS
2299@anchor{setdar}
2300@section setdar
2301
2302Set the Display Aspect Ratio for the filter output video.
2303
2304This is done by changing the specified Sample (aka Pixel) Aspect
2305Ratio, according to the following equation:
2306@math{DAR = HORIZONTAL_RESOLUTION / VERTICAL_RESOLUTION * SAR}
2307
2308Keep in mind that this filter does not modify the pixel dimensions of
d4a8a86c 2309the video frame. Also, the display aspect ratio set by this filter may
2fd8756b
SS
2310be changed by later filters in the filterchain, e.g. in case of
2311scaling or if another "setdar" or a "setsar" filter is applied.
2312
d4a8a86c 2313It accepts the following parameters:
2831b307
AK
2314
2315@table @option
2316
2317@item dar
d4a8a86c 2318The output display aspect ratio.
2831b307
AK
2319
2320@end table
2fd8756b 2321
34a0ac41
RP
2322The parameter @var{dar} is an expression containing
2323the following constants:
2324
2325@table @option
2326@item E, PI, PHI
d4a8a86c
KBA
2327These are approximated values for the mathematical constants e
2328(Euler's number), pi (Greek pi), and phi (the golden ratio).
34a0ac41
RP
2329
2330@item w, h
d4a8a86c 2331The input width and height.
34a0ac41
RP
2332
2333@item a
d4a8a86c 2334This is the same as @var{w} / @var{h}.
34a0ac41
RP
2335
2336@item sar
d4a8a86c 2337The input sample aspect ratio.
34a0ac41
RP
2338
2339@item dar
d4a8a86c
KBA
2340The input display aspect ratio. It is the same as
2341(@var{w} / @var{h}) * @var{sar}.
34a0ac41
RP
2342
2343@item hsub, vsub
d4a8a86c 2344The horizontal and vertical chroma subsample values. For example, for the
34a0ac41
RP
2345pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
2346@end table
2347
d4a8a86c 2348To change the display aspect ratio to 16:9, specify:
2fd8756b 2349@example
2831b307 2350setdar=dar=16/9
d4a8a86c 2351# The above is equivalent to
2831b307 2352setdar=dar=1.77777
2fd8756b
SS
2353@end example
2354
d4a8a86c 2355Also see the the @ref{setsar} filter documentation.
2fd8756b 2356
a532bb39
SS
2357@section setpts
2358
2359Change the PTS (presentation timestamp) of the input video frames.
2360
d4a8a86c 2361It accepts the following parameters:
33b97faa
AK
2362
2363@table @option
2364
2365@item expr
2366The expression which is evaluated for each frame to construct its timestamp.
2367
2368@end table
2369
2370The expression is evaluated through the eval API and can contain the following
2371constants:
a532bb39
SS
2372
2373@table @option
2374@item PTS
d4a8a86c 2375The presentation timestamp in input.
a532bb39 2376
d4a8a86c
KBA
2377@item E, PI, PHI
2378These are approximated values for the mathematical constants e
2379(Euler's number), pi (Greek pi), and phi (the golden ratio).
a532bb39
SS
2380
2381@item N
d4a8a86c 2382The count of the input frame, starting from 0.
a532bb39
SS
2383
2384@item STARTPTS
d4a8a86c 2385The PTS of the first video frame.
a532bb39
SS
2386
2387@item INTERLACED
d4a8a86c 2388State whether the current frame is interlaced.
a532bb39 2389
a532bb39 2390@item PREV_INPTS
d4a8a86c 2391The previous input PTS.
a532bb39
SS
2392
2393@item PREV_OUTPTS
d4a8a86c 2394The previous output PTS.
a532bb39 2395
0b55b16a 2396@item RTCTIME
d4a8a86c 2397The wallclock (RTC) time in microseconds.
0b55b16a
VP
2398
2399@item RTCSTART
d4a8a86c 2400The wallclock (RTC) time at the start of the movie in microseconds.
0b55b16a 2401
0ebfdae0 2402@item TB
d4a8a86c 2403The timebase of the input timestamps.
0ebfdae0 2404
a532bb39
SS
2405@end table
2406
d4a8a86c 2407Some examples:
a532bb39
SS
2408
2409@example
d4a8a86c 2410# Start counting the PTS from zero
33b97faa 2411setpts=expr=PTS-STARTPTS
a532bb39 2412
d4a8a86c 2413# Fast motion
33b97faa 2414setpts=expr=0.5*PTS
a532bb39 2415
d4a8a86c 2416# Slow motion
a532bb39
SS
2417setpts=2.0*PTS
2418
d4a8a86c 2419# Fixed rate 25 fps
a532bb39
SS
2420setpts=N/(25*TB)
2421
d4a8a86c 2422# Fixed rate 25 fps with some jitter
a532bb39 2423setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
0b55b16a 2424
d4a8a86c 2425# Generate timestamps from a "live source" and rebase onto the current timebase
0b55b16a 2426setpts='(RTCTIME - RTCSTART) / (TB * 1000000)"
a532bb39
SS
2427@end example
2428
2fd8756b
SS
2429@anchor{setsar}
2430@section setsar
2431
2432Set the Sample (aka Pixel) Aspect Ratio for the filter output video.
2433
2434Note that as a consequence of the application of this filter, the
2435output display aspect ratio will change according to the following
2436equation:
2437@math{DAR = HORIZONTAL_RESOLUTION / VERTICAL_RESOLUTION * SAR}
2438
2439Keep in mind that the sample aspect ratio set by this filter may be
2440changed by later filters in the filterchain, e.g. if another "setsar"
2441or a "setdar" filter is applied.
2442
d4a8a86c 2443It accepts the following parameters:
2831b307
AK
2444
2445@table @option
2446
2447@item sar
d4a8a86c 2448The output sample aspect ratio.
2831b307
AK
2449
2450@end table
2fd8756b 2451
34a0ac41
RP
2452The parameter @var{sar} is an expression containing
2453the following constants:
2454
2455@table @option
2456@item E, PI, PHI
d4a8a86c
KBA
2457These are approximated values for the mathematical constants e
2458(Euler's number), pi (Greek pi), and phi (the golden ratio).
34a0ac41
RP
2459
2460@item w, h
d4a8a86c 2461The input width and height.
34a0ac41
RP
2462
2463@item a
d4a8a86c 2464These are the same as @var{w} / @var{h}.
34a0ac41
RP
2465
2466@item sar
d4a8a86c 2467The input sample aspect ratio.
34a0ac41
RP
2468
2469@item dar
d4a8a86c
KBA
2470The input display aspect ratio. It is the same as
2471(@var{w} / @var{h}) * @var{sar}.
34a0ac41
RP
2472
2473@item hsub, vsub
d4a8a86c 2474Horizontal and vertical chroma subsample values. For example, for the
34a0ac41
RP
2475pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
2476@end table
2477
d4a8a86c 2478To change the sample aspect ratio to 10:11, specify:
2fd8756b 2479@example
2831b307 2480setsar=sar=10/11
2fd8756b
SS
2481@end example
2482
d89e3b36
SS
2483@section settb
2484
2485Set the timebase to use for the output frames timestamps.
2486It is mainly useful for testing timebase configuration.
2487
d4a8a86c 2488It accepts the following parameters:
ffea3b00
AK
2489
2490@table @option
2491
2492@item expr
2493The expression which is evaluated into the output timebase.
2494
2495@end table
2496
d89e3b36
SS
2497The expression can contain the constants "PI", "E", "PHI", "AVTB" (the
2498default timebase), and "intb" (the input timebase).
2499
2500The default value for the input is "intb".
2501
d4a8a86c 2502Some examples:
d89e3b36
SS
2503
2504@example
d4a8a86c 2505# Set the timebase to 1/25
ffea3b00 2506settb=expr=1/25
d89e3b36 2507
d4a8a86c 2508# Set the timebase to 1/10
ffea3b00 2509settb=expr=0.1
d89e3b36 2510
d4a8a86c 2511# Set the timebase to 1001/1000
d89e3b36
SS
2512settb=1+0.001
2513
d4a8a86c 2514#Set the timebase to 2*intb
d89e3b36
SS
2515settb=2*intb
2516
d4a8a86c 2517#Set the default timebase value
d89e3b36
SS
2518settb=AVTB
2519@end example
2520
ee42716b
SS
2521@section showinfo
2522
2523Show a line containing various information for each input video frame.
2524The input video is not modified.
2525
2526The shown line contains a sequence of key/value pairs of the form
2527@var{key}:@var{value}.
2528
d4a8a86c 2529It accepts the following parameters:
ee42716b
SS
2530
2531@table @option
2532@item n
d4a8a86c 2533The (sequential) number of the input frame, starting from 0.
ee42716b
SS
2534
2535@item pts
d4a8a86c 2536The Presentation TimeStamp of the input frame, expressed as a number of
ee42716b
SS
2537time base units. The time base unit depends on the filter input pad.
2538
2539@item pts_time
d4a8a86c
KBA
2540The Presentation TimeStamp of the input frame, expressed as a number of
2541seconds.
ee42716b
SS
2542
2543@item pos
d4a8a86c
KBA
2544The position of the frame in the input stream, or -1 if this information is
2545unavailable and/or meaningless (for example in case of synthetic video).
ee42716b
SS
2546
2547@item fmt
d4a8a86c 2548The pixel format name.
ee42716b
SS
2549
2550@item sar
d4a8a86c
KBA
2551The sample aspect ratio of the input frame, expressed in the form
2552@var{num}/@var{den}.
ee42716b
SS
2553
2554@item s
d4a8a86c
KBA
2555The size of the input frame, expressed in the form
2556@var{width}x@var{height}.
ee42716b
SS
2557
2558@item i
d4a8a86c
KBA
2559The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
2560for bottom field first).
ee42716b
SS
2561
2562@item iskey
d4a8a86c 2563This is 1 if the frame is a key frame, 0 otherwise.
ee42716b
SS
2564
2565@item type
d4a8a86c
KBA
2566The picture type of the input frame ("I" for an I-frame, "P" for a
2567P-frame, "B" for a B-frame, or "?" for an unknown type).
2568Also refer to the documentation of the @code{AVPictureType} enum and of
ee42716b
SS
2569the @code{av_get_picture_type_char} function defined in
2570@file{libavutil/avutil.h}.
2571
2572@item checksum
d4a8a86c 2573The Adler-32 checksum of all the planes of the input frame.
ee42716b
SS
2574
2575@item plane_checksum
d4a8a86c
KBA
2576The Adler-32 checksum of each plane of the input frame, expressed in the form
2577"[@var{c0} @var{c1} @var{c2} @var{c3}]".
ee42716b
SS
2578@end table
2579
599b81ca
AK
2580@section shuffleplanes
2581
2582Reorder and/or duplicate video planes.
2583
d4a8a86c 2584It accepts the following parameters:
599b81ca
AK
2585
2586@table @option
2587
2588@item map0
2589The index of the input plane to be used as the first output plane.
2590
2591@item map1
2592The index of the input plane to be used as the second output plane.
2593
2594@item map2
2595The index of the input plane to be used as the third output plane.
2596
2597@item map3
2598The index of the input plane to be used as the fourth output plane.
2599
2600@end table
2601
2602The first plane has the index 0. The default is to keep the input unchanged.
2603
d4a8a86c 2604Swap the second and third planes of the input:
599b81ca
AK
2605@example
2606avconv -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
2607@end example
599b81ca 2608
fd18ee0f
AK
2609@section split
2610
2611Split input video into several identical outputs.
2612
d4a8a86c 2613It accepts a single parameter, which specifies the number of outputs. If
fd18ee0f
AK
2614unspecified, it defaults to 2.
2615
d4a8a86c 2616Create 5 copies of the input video:
fd18ee0f
AK
2617@example
2618avconv -i INPUT -filter_complex split=5 OUTPUT
2619@end example
fd18ee0f 2620
43945b27
SS
2621@section transpose
2622
2623Transpose rows with columns in the input video and optionally flip it.
2624
d4a8a86c 2625It accepts the following parameters:
0c2466de
AK
2626
2627@table @option
2628
2629@item dir
2630The direction of the transpose.
2631
2632@end table
2633
2634The direction can assume the following values:
43945b27
SS
2635
2636@table @samp
0c2466de 2637@item cclock_flip
43945b27
SS
2638Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
2639@example
2640L.R L.l
2641. . -> . .
2642l.r R.r
2643@end example
2644
0c2466de 2645@item clock
43945b27
SS
2646Rotate by 90 degrees clockwise, that is:
2647@example
2648L.R l.L
2649. . -> . .
2650l.r r.R
2651@end example
2652
0c2466de 2653@item cclock
43945b27
SS
2654Rotate by 90 degrees counterclockwise, that is:
2655@example
2656L.R R.r
2657. . -> . .
2658l.r L.l
2659@end example
2660
0c2466de 2661@item clock_flip
43945b27
SS
2662Rotate by 90 degrees clockwise and vertically flip, that is:
2663@example
2664L.R r.R
2665. . -> . .
2666l.r l.L
2667@end example
2668@end table
2669
a1e05b04
AK
2670@section trim
2671Trim the input so that the output contains one continuous subpart of the input.
2672
d4a8a86c 2673It accepts the following parameters:
a1e05b04
AK
2674@table @option
2675@item start
d4a8a86c 2676The timestamp (in seconds) of the start of the kept section. The frame with the
a1e05b04
AK
2677timestamp @var{start} will be the first frame in the output.
2678
2679@item end
d4a8a86c 2680The timestamp (in seconds) of the first frame that will be dropped. The frame
a1e05b04
AK
2681immediately preceding the one with the timestamp @var{end} will be the last
2682frame in the output.
2683
2684@item start_pts
d4a8a86c
KBA
2685This is the same as @var{start}, except this option sets the start timestamp
2686in timebase units instead of seconds.
a1e05b04
AK
2687
2688@item end_pts
d4a8a86c
KBA
2689This is the same as @var{end}, except this option sets the end timestamp
2690in timebase units instead of seconds.
a1e05b04
AK
2691
2692@item duration
d4a8a86c 2693The maximum duration of the output in seconds.
a1e05b04
AK
2694
2695@item start_frame
d4a8a86c 2696The number of the first frame that should be passed to the output.
a1e05b04
AK
2697
2698@item end_frame
d4a8a86c 2699The number of the first frame that should be dropped.
a1e05b04
AK
2700@end table
2701
2702Note that the first two sets of the start/end options and the @option{duration}
2703option look at the frame timestamp, while the _frame variants simply count the
2704frames that pass through the filter. Also note that this filter does not modify
d4a8a86c 2705the timestamps. If you wish for the output timestamps to start at zero, insert a
a1e05b04
AK
2706setpts filter after the trim filter.
2707
2708If multiple start or end options are set, this filter tries to be greedy and
2709keep all the frames that match at least one of the specified constraints. To keep
2710only the part that matches all the constraints at once, chain multiple trim
2711filters.
2712
2713The defaults are such that all the input is kept. So it is possible to set e.g.
2714just the end values to keep everything before the specified time.
2715
2716Examples:
2717@itemize
2718@item
d4a8a86c 2719Drop everything except the second minute of input:
a1e05b04
AK
2720@example
2721avconv -i INPUT -vf trim=60:120
2722@end example
2723
2724@item
d4a8a86c 2725Keep only the first second:
a1e05b04
AK
2726@example
2727avconv -i INPUT -vf trim=duration=1
2728@end example
2729
2730@end itemize
3275ac6a
SS
2731@section unsharp
2732
843b5fd0
SS
2733Sharpen or blur the input video.
2734
2735It accepts the following parameters:
3275ac6a
SS
2736
2737@table @option
2738
2739@item luma_msize_x
d4a8a86c
KBA
2740Set the luma matrix horizontal size. It must be an integer between 3
2741and 13. The default value is 5.
3275ac6a
SS
2742
2743@item luma_msize_y
d4a8a86c
KBA
2744Set the luma matrix vertical size. It must be an integer between 3
2745and 13. The default value is 5.
3275ac6a
SS
2746
2747@item luma_amount
d4a8a86c
KBA
2748Set the luma effect strength. It must be a floating point number between -2.0
2749and 5.0. The default value is 1.0.
3275ac6a
SS
2750
2751@item chroma_msize_x
d4a8a86c
KBA
2752Set the chroma matrix horizontal size. It must be an integer between 3
2753and 13. The default value is 5.
3275ac6a
SS
2754
2755@item chroma_msize_y
d4a8a86c
KBA
2756Set the chroma matrix vertical size. It must be an integer between 3
2757and 13. The default value is 5.
3275ac6a 2758
2725f2d4 2759@item chroma_amount
d4a8a86c
KBA
2760Set the chroma effect strength. It must be a floating point number between -2.0
2761and 5.0. The default value is 0.0.
3275ac6a
SS
2762
2763@end table
2764
b83e9efc
AK
2765Negative values for the amount will blur the input video, while positive
2766values will sharpen. All parameters are optional and default to the
2767equivalent of the string '5:5:1.0:5:5:0.0'.
2768
3275ac6a
SS
2769@example
2770# Strong luma sharpen effect parameters
b83e9efc 2771unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
3275ac6a 2772
d4a8a86c 2773# A strong blur of both luma and chroma parameters
3275ac6a
SS
2774unsharp=7:7:-2:7:7:-2
2775
9270b8a3
LB
2776# Use the default values with @command{avconv}
2777./avconv -i in.avi -vf "unsharp" out.mp4
3275ac6a
SS
2778@end example
2779
2780@section vflip
2781
2782Flip the input video vertically.
2783
2784@example
9270b8a3 2785./avconv -i in.avi -vf "vflip" out.avi
3275ac6a
SS
2786@end example
2787
acbac567
MN
2788@section yadif
2789
1653027a
SS
2790Deinterlace the input video ("yadif" means "yet another deinterlacing
2791filter").
acbac567 2792
d4a8a86c 2793It accepts the following parameters:
7536c671
AK
2794
2795@table @option
acbac567 2796
7536c671 2797@item mode
d4a8a86c 2798The interlacing mode to adopt. It accepts one of the following values:
acbac567 2799
1653027a
SS
2800@table @option
2801@item 0
d4a8a86c 2802Output one frame for each frame.
1653027a 2803@item 1
d4a8a86c 2804Output one frame for each field.
1653027a 2805@item 2
d4a8a86c 2806Like 0, but it skips the spatial interlacing check.
1653027a 2807@item 3
d4a8a86c 2808Like 1, but it skips the spatial interlacing check.
1653027a 2809@end table
acbac567 2810
d4a8a86c 2811The default value is 0.
acbac567 2812
7536c671 2813@item parity
d4a8a86c
KBA
2814The picture field parity assumed for the input interlaced video. It accepts one
2815of the following values:
acbac567 2816
1653027a
SS
2817@table @option
2818@item 0
d4a8a86c 2819Assume the top field is first.
4703a7b5 2820@item 1
d4a8a86c 2821Assume the bottom field is first.
1653027a 2822@item -1
d4a8a86c 2823Enable automatic detection of field parity.
acbac567
MN
2824@end table
2825
d4a8a86c
KBA
2826The default value is -1.
2827If the interlacing is unknown or the decoder does not export this information,
a51c71bb 2828top field first will be assumed.
1653027a 2829
7536c671 2830@item auto
d4a8a86c
KBA
2831Whether the deinterlacer should trust the interlaced flag and only deinterlace
2832frames marked as interlaced.
ab09df9d
JP
2833
2834@table @option
2835@item 0
d4a8a86c 2836Deinterlace all frames.
ab09df9d 2837@item 1
d4a8a86c 2838Only deinterlace frames marked as interlaced.
ab09df9d
JP
2839@end table
2840
d4a8a86c 2841The default value is 0.
ab09df9d 2842
7536c671
AK
2843@end table
2844
3275ac6a
SS
2845@c man end VIDEO FILTERS
2846
2847@chapter Video Sources
2848@c man begin VIDEO SOURCES
2849
2850Below is a description of the currently available video sources.
2851
24413399
SS
2852@section buffer
2853
2854Buffer video frames, and make them available to the filter chain.
2855
2856This source is mainly intended for a programmatic use, in particular
ac1a31ab 2857through the interface defined in @file{libavfilter/vsrc_buffer.h}.
24413399 2858
d4a8a86c 2859It accepts the following parameters:
24413399 2860
d28cb849 2861@table @option
24413399 2862
d28cb849 2863@item width
d4a8a86c 2864The input video width.
24413399 2865
d28cb849 2866@item height
d4a8a86c 2867The input video height.
24413399 2868
d28cb849 2869@item pix_fmt
d4a8a86c 2870The name of the input video pixel format.
24413399 2871
d28cb849
AK
2872@item time_base
2873The time base used for input timestamps.
24413399 2874
d28cb849 2875@item sar
d4a8a86c 2876The sample (pixel) aspect ratio of the input video.
7a11c82f 2877
b3dd30db
AK
2878@item hw_frames_ctx
2879When using a hardware pixel format, this should be a reference to an
2880AVHWFramesContext describing input frames.
2881
24413399
SS
2882@end table
2883
2884For example:
2885@example
d28cb849 2886buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
24413399
SS
2887@end example
2888
2889will instruct the source to accept video frames with size 320x240 and
7a11c82f
MN
2890with format "yuv410p", assuming 1/24 as the timestamps timebase and
2891square pixels (1:1 sample aspect ratio).
24413399 2892
23ccf3c7
SS
2893@section color
2894
2895Provide an uniformly colored input.
2896
2897It accepts the following parameters:
23ccf3c7
SS
2898
2899@table @option
2900
2901@item color
2902Specify the color of the source. It can be the name of a color (case
2903insensitive match) or a 0xRRGGBB[AA] sequence, possibly followed by an
2904alpha specifier. The default value is "black".
2905
7bc1a883 2906@item size
23ccf3c7 2907Specify the size of the sourced video, it may be a string of the form
e83c2dde 2908@var{width}x@var{height}, or the name of a size abbreviation. The
23ccf3c7
SS
2909default value is "320x240".
2910
7bc1a883 2911@item framerate
23ccf3c7
SS
2912Specify the frame rate of the sourced video, as the number of frames
2913generated per second. It has to be a string in the format
d4a8a86c 2914@var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
23ccf3c7
SS
2915number or a valid video frame rate abbreviation. The default value is
2916"25".
2917
2918@end table
2919
d4a8a86c 2920The following graph description will generate a red source
23ccf3c7
SS
2921with an opacity of 0.2, with size "qcif" and a frame rate of 10
2922frames per second, which will be overlayed over the source connected
d4a8a86c 2923to the pad with identifier "in":
23ccf3c7
SS
2924
2925@example
2926"color=red@@0.2:qcif:10 [color]; [in][color] overlay [out]"
2927@end example
2928
9409c381
SS
2929@section movie
2930
2931Read a video stream from a movie container.
2932
7ca14c73
AK
2933Note that this source is a hack that bypasses the standard input path. It can be
2934useful in applications that do not support arbitrary filter graphs, but its use
d4a8a86c
KBA
2935is discouraged in those that do. It should never be used with
2936@command{avconv}; the @option{-filter_complex} option fully replaces it.
7ca14c73 2937
d4a8a86c 2938It accepts the following parameters:
9409c381
SS
2939
2940@table @option
2941
a42d6e6c 2942@item filename
d4a8a86c
KBA
2943The name of the resource to read (not necessarily a file; it can also be a
2944device or a stream accessed through some protocol).
a42d6e6c 2945
9409c381
SS
2946@item format_name, f
2947Specifies the format assumed for the movie to read, and can be either
d4a8a86c 2948the name of a container or an input device. If not specified, the
9409c381
SS
2949format is guessed from @var{movie_name} or by probing.
2950
2951@item seek_point, sp
d4a8a86c
KBA
2952Specifies the seek point in seconds. The frames will be output
2953starting from this seek point. The parameter is evaluated with
2954@code{av_strtod}, so the numerical value may be suffixed by an IS
2955postfix. The default value is "0".
9409c381
SS
2956
2957@item stream_index, si
2958Specifies the index of the video stream to read. If the value is -1,
d4a8a86c 2959the most suitable video stream will be automatically selected. The default
9409c381
SS
2960value is "-1".
2961
2962@end table
2963
d4a8a86c
KBA
2964It allows overlaying a second video on top of the main input of
2965a filtergraph, as shown in this graph:
9409c381
SS
2966@example
2967input -----------> deltapts0 --> overlay --> output
2968 ^
2969 |
2970movie --> scale--> deltapts1 -------+
2971@end example
2972
d4a8a86c 2973Some examples:
9409c381 2974@example
d4a8a86c
KBA
2975# Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
2976# on top of the input labelled "in"
9409c381
SS
2977movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [movie];
2978[in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
2979
d4a8a86c
KBA
2980# Read from a video4linux2 device, and overlay it on top of the input
2981# labelled "in"
9409c381
SS
2982movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [movie];
2983[in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
2984
2985@end example
2986
3275ac6a
SS
2987@section nullsrc
2988
d4a8a86c 2989Null video source: never return images. It is mainly useful as a
3275ac6a
SS
2990template and to be employed in analysis / debugging tools.
2991
d4a8a86c
KBA
2992It accepts a string of the form
2993@var{width}:@var{height}:@var{timebase} as an optional parameter.
3275ac6a 2994
16134b7c
SS
2995@var{width} and @var{height} specify the size of the configured
2996source. The default values of @var{width} and @var{height} are
2997respectively 352 and 288 (corresponding to the CIF size format).
2998
2999@var{timebase} specifies an arithmetic expression representing a
d4a8a86c 3000timebase. The expression can contain the constants "PI", "E", "PHI", and
16134b7c 3001"AVTB" (the default timebase), and defaults to the value "AVTB".
3275ac6a 3002
f8608dca
SS
3003@section frei0r_src
3004
3005Provide a frei0r source.
3006
3007To enable compilation of this filter you need to install the frei0r
f8a45fa1 3008header and configure Libav with --enable-frei0r.
f8608dca 3009
d4a8a86c 3010This source accepts the following parameters:
5aa1a668
AK
3011
3012@table @option
3013
3014@item size
d4a8a86c 3015The size of the video to generate. It may be a string of the form
5aa1a668 3016@var{width}x@var{height} or a frame size abbreviation.
f8608dca 3017
5aa1a668 3018@item framerate
d4a8a86c 3019The framerate of the generated video. It may be a string of the form
5aa1a668
AK
3020@var{num}/@var{den} or a frame rate abbreviation.
3021
3022@item filter_name
3023The name to the frei0r source to load. For more information regarding frei0r and
d4a8a86c
KBA
3024how to set the parameters, read the @ref{frei0r} section in the video filters
3025documentation.
5aa1a668
AK
3026
3027@item filter_params
3028A '|'-separated list of parameters to pass to the frei0r source.
3029
3030@end table
f8608dca 3031
d4a8a86c 3032An example:
f8608dca 3033@example
d4a8a86c 3034# Generate a frei0r partik0l source with size 200x200 and framerate 10
f8608dca 3035# which is overlayed on the overlay filter main input
5aa1a668 3036frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
f8608dca
SS
3037@end example
3038
ec2ac927 3039@section rgbtestsrc, testsrc
0244879f 3040
ec2ac927
SS
3041The @code{rgbtestsrc} source generates an RGB test pattern useful for
3042detecting RGB vs BGR issues. You should see a red, green and blue
3043stripe from top to bottom.
0244879f 3044
ec2ac927
SS
3045The @code{testsrc} source generates a test video pattern, showing a
3046color pattern, a scrolling gradient and a timestamp. This is mainly
3047intended for testing purposes.
3048
d4a8a86c 3049The sources accept the following parameters:
0244879f
SS
3050
3051@table @option
3052
3053@item size, s
3054Specify the size of the sourced video, it may be a string of the form
da9cea77 3055@var{width}x@var{height}, or the name of a size abbreviation. The
0244879f
SS
3056default value is "320x240".
3057
3058@item rate, r
3059Specify the frame rate of the sourced video, as the number of frames
3060generated per second. It has to be a string in the format
d4a8a86c 3061@var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
0244879f
SS
3062number or a valid video frame rate abbreviation. The default value is
3063"25".
3064
3065@item sar
3066Set the sample aspect ratio of the sourced video.
3067
3068@item duration
3069Set the video duration of the sourced video. The accepted syntax is:
3070@example
3071[-]HH[:MM[:SS[.m...]]]
3072[-]S+[.m...]
3073@end example
d4a8a86c 3074Also see the the @code{av_parse_time()} function.
0244879f
SS
3075
3076If not specified, or the expressed duration is negative, the video is
3077supposed to be generated forever.
3078@end table
3079
3080For example the following:
3081@example
3082testsrc=duration=5.3:size=qcif:rate=10
3083@end example
3084
3085will generate a video with a duration of 5.3 seconds, with size
3086176x144 and a framerate of 10 frames per second.
3087
3275ac6a
SS
3088@c man end VIDEO SOURCES
3089
3090@chapter Video Sinks
3091@c man begin VIDEO SINKS
3092
3093Below is a description of the currently available video sinks.
3094
ac712309
AK
3095@section buffersink
3096
3097Buffer video frames, and make them available to the end of the filter
3098graph.
3099
d4a8a86c 3100This sink is intended for programmatic use through the interface defined in
ac712309
AK
3101@file{libavfilter/buffersink.h}.
3102
3275ac6a
SS
3103@section nullsink
3104
d4a8a86c
KBA
3105Null video sink: do absolutely nothing with the input video. It is
3106mainly useful as a template and for use in analysis / debugging
3275ac6a
SS
3107tools.
3108
3109@c man end VIDEO SINKS