1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
3 <!-- Created on September 2, 2011 by texi2html 1.82
4 texi2html was written by:
5 Lionel Cons <Lionel.Cons@cern.ch> (original author)
6 Karl Berry <karl@freefriends.org>
7 Olaf Bachmann <obachman@mathematik.uni-kl.de>
9 Maintained by: Many creative people.
10 Send bugs and suggestions to <texi2html-bug@nongnu.org>
13 <title>Libavfilter Documentation</title>
15 <meta name="description" content="Libavfilter Documentation">
16 <meta name="keywords" content="Libavfilter Documentation">
17 <meta name="resource-type" content="document">
18 <meta name="distribution" content="global">
19 <meta name="Generator" content="texi2html 1.82">
20 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
21 <style type="text/css">
23 a.summary-letter {text-decoration: none}
24 blockquote.smallquotation {font-size: smaller}
25 pre.display {font-family: serif}
26 pre.format {font-family: serif}
27 pre.menu-comment {font-family: serif}
28 pre.menu-preformatted {font-family: serif}
29 pre.smalldisplay {font-family: serif; font-size: smaller}
30 pre.smallexample {font-size: smaller}
31 pre.smallformat {font-family: serif; font-size: smaller}
32 pre.smalllisp {font-size: smaller}
33 span.roman {font-family:serif; font-weight:normal;}
34 span.sansserif {font-family:sans-serif; font-weight:normal;}
35 ul.toc {list-style: none}
42 <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
44 <a name="SEC_Top"></a>
45 <h1 class="settitle">Libavfilter Documentation</h1>
47 <a name="SEC_Contents"></a>
48 <h1>Table of Contents</h1>
49 <div class="contents">
52 <li><a name="toc-Introduction" href="#Introduction">1. Introduction</a></li>
53 <li><a name="toc-Tutorial" href="#Tutorial">2. Tutorial</a></li>
54 <li><a name="toc-graph2dot" href="#graph2dot">3. graph2dot</a></li>
55 <li><a name="toc-Filtergraph-description" href="#Filtergraph-description">4. Filtergraph description</a>
57 <li><a name="toc-Filtergraph-syntax" href="#Filtergraph-syntax">4.1 Filtergraph syntax</a></li>
59 <li><a name="toc-Audio-Filters" href="#Audio-Filters">5. Audio Filters</a>
61 <li><a name="toc-aformat" href="#aformat">5.1 aformat</a></li>
62 <li><a name="toc-anull" href="#anull">5.2 anull</a></li>
63 <li><a name="toc-aresample" href="#aresample">5.3 aresample</a></li>
64 <li><a name="toc-ashowinfo" href="#ashowinfo">5.4 ashowinfo</a></li>
66 <li><a name="toc-Audio-Sources" href="#Audio-Sources">6. Audio Sources</a>
68 <li><a name="toc-abuffer" href="#abuffer">6.1 abuffer</a></li>
69 <li><a name="toc-amovie" href="#amovie">6.2 amovie</a></li>
70 <li><a name="toc-anullsrc" href="#anullsrc">6.3 anullsrc</a></li>
72 <li><a name="toc-Audio-Sinks" href="#Audio-Sinks">7. Audio Sinks</a>
74 <li><a name="toc-abuffersink" href="#abuffersink">7.1 abuffersink</a></li>
75 <li><a name="toc-anullsink" href="#anullsink">7.2 anullsink</a></li>
77 <li><a name="toc-Video-Filters" href="#Video-Filters">8. Video Filters</a>
79 <li><a name="toc-blackframe" href="#blackframe">8.1 blackframe</a></li>
80 <li><a name="toc-boxblur" href="#boxblur">8.2 boxblur</a></li>
81 <li><a name="toc-copy" href="#copy">8.3 copy</a></li>
82 <li><a name="toc-crop" href="#crop">8.4 crop</a></li>
83 <li><a name="toc-cropdetect" href="#cropdetect">8.5 cropdetect</a></li>
84 <li><a name="toc-delogo" href="#delogo">8.6 delogo</a></li>
85 <li><a name="toc-drawbox" href="#drawbox">8.7 drawbox</a></li>
86 <li><a name="toc-drawtext" href="#drawtext">8.8 drawtext</a></li>
87 <li><a name="toc-fade" href="#fade">8.9 fade</a></li>
88 <li><a name="toc-fieldorder" href="#fieldorder">8.10 fieldorder</a></li>
89 <li><a name="toc-fifo" href="#fifo">8.11 fifo</a></li>
90 <li><a name="toc-format" href="#format">8.12 format</a></li>
91 <li><a name="toc-frei0r-1" href="#frei0r-1">8.13 frei0r</a></li>
92 <li><a name="toc-gradfun" href="#gradfun">8.14 gradfun</a></li>
93 <li><a name="toc-hflip" href="#hflip">8.15 hflip</a></li>
94 <li><a name="toc-hqdn3d" href="#hqdn3d">8.16 hqdn3d</a></li>
95 <li><a name="toc-lut_002c-lutrgb_002c-lutyuv" href="#lut_002c-lutrgb_002c-lutyuv">8.17 lut, lutrgb, lutyuv</a></li>
96 <li><a name="toc-mp" href="#mp">8.18 mp</a></li>
97 <li><a name="toc-negate" href="#negate">8.19 negate</a></li>
98 <li><a name="toc-noformat" href="#noformat">8.20 noformat</a></li>
99 <li><a name="toc-null" href="#null">8.21 null</a></li>
100 <li><a name="toc-ocv" href="#ocv">8.22 ocv</a>
102 <li><a name="toc-dilate-1" href="#dilate-1">8.22.1 dilate</a></li>
103 <li><a name="toc-erode" href="#erode">8.22.2 erode</a></li>
104 <li><a name="toc-smooth" href="#smooth">8.22.3 smooth</a></li>
106 <li><a name="toc-overlay" href="#overlay">8.23 overlay</a></li>
107 <li><a name="toc-pad" href="#pad">8.24 pad</a></li>
108 <li><a name="toc-pixdesctest" href="#pixdesctest">8.25 pixdesctest</a></li>
109 <li><a name="toc-scale" href="#scale">8.26 scale</a></li>
110 <li><a name="toc-select" href="#select">8.27 select</a></li>
111 <li><a name="toc-setdar-1" href="#setdar-1">8.28 setdar</a></li>
112 <li><a name="toc-setpts" href="#setpts">8.29 setpts</a></li>
113 <li><a name="toc-setsar-1" href="#setsar-1">8.30 setsar</a></li>
114 <li><a name="toc-settb" href="#settb">8.31 settb</a></li>
115 <li><a name="toc-showinfo" href="#showinfo">8.32 showinfo</a></li>
116 <li><a name="toc-slicify" href="#slicify">8.33 slicify</a></li>
117 <li><a name="toc-split" href="#split">8.34 split</a></li>
118 <li><a name="toc-transpose" href="#transpose">8.35 transpose</a></li>
119 <li><a name="toc-unsharp" href="#unsharp">8.36 unsharp</a></li>
120 <li><a name="toc-vflip" href="#vflip">8.37 vflip</a></li>
121 <li><a name="toc-yadif" href="#yadif">8.38 yadif</a></li>
123 <li><a name="toc-Video-Sources" href="#Video-Sources">9. Video Sources</a>
125 <li><a name="toc-buffer" href="#buffer">9.1 buffer</a></li>
126 <li><a name="toc-color" href="#color">9.2 color</a></li>
127 <li><a name="toc-movie" href="#movie">9.3 movie</a></li>
128 <li><a name="toc-mptestsrc" href="#mptestsrc">9.4 mptestsrc</a></li>
129 <li><a name="toc-nullsrc" href="#nullsrc">9.5 nullsrc</a></li>
130 <li><a name="toc-frei0r_005fsrc" href="#frei0r_005fsrc">9.6 frei0r_src</a></li>
131 <li><a name="toc-rgbtestsrc_002c-testsrc" href="#rgbtestsrc_002c-testsrc">9.7 rgbtestsrc, testsrc</a></li>
133 <li><a name="toc-Video-Sinks" href="#Video-Sinks">10. Video Sinks</a>
135 <li><a name="toc-buffersink" href="#buffersink">10.1 buffersink</a></li>
136 <li><a name="toc-nullsink" href="#nullsink">10.2 nullsink</a></li>
143 <a name="Introduction"></a>
144 <h1 class="chapter"><a href="libavfilter.html#toc-Introduction">1. Introduction</a></h1>
146 <p>Libavfilter is the filtering API of FFmpeg. It is the substitute of the
147 now deprecated ’vhooks’ and started as a Google Summer of Code project.
149 <p>Integrating libavfilter into the main FFmpeg repository is a work in
150 progress. If you wish to try the unfinished development code of
151 libavfilter then check it out from the libavfilter repository into
152 some directory of your choice by:
154 <table><tr><td> </td><td><pre class="example"> svn checkout svn://svn.ffmpeg.org/soc/libavfilter
155 </pre></td></tr></table>
157 <p>And then read the README file in the top directory to learn how to
158 integrate it into ffmpeg and ffplay.
160 <p>But note that there may still be serious bugs in the code and its API
161 and ABI should not be considered stable yet!
163 <a name="Tutorial"></a>
164 <h1 class="chapter"><a href="libavfilter.html#toc-Tutorial">2. Tutorial</a></h1>
166 <p>In libavfilter, it is possible for filters to have multiple inputs and
168 To illustrate the sorts of things that are possible, we can
169 use a complex filter graph. For example, the following one:
171 <table><tr><td> </td><td><pre class="example">input --> split --> fifo -----------------------> overlay --> output
174 +------> fifo --> crop --> vflip --------+
175 </pre></td></tr></table>
177 <p>splits the stream in two streams, sends one stream through the crop filter
178 and the vflip filter before merging it back with the other stream by
179 overlaying it on top. You can use the following command to achieve this:
181 <table><tr><td> </td><td><pre class="example">./ffmpeg -i in.avi -s 240x320 -vf "[in] split [T1], fifo, [T2] overlay= 0:240 [out]; [T1] fifo, crop=0:0:-1:240, vflip [T2]
182 </pre></td></tr></table>
184 <p>where input_video.avi has a vertical resolution of 480 pixels. The
185 result will be that in output the top half of the video is mirrored
186 onto the bottom half.
188 <p>Video filters are loaded using the <var>-vf</var> option passed to
189 ffmpeg or to ffplay. Filters in the same linear chain are separated by
190 commas. In our example, <var>split, fifo, overlay</var> are in one linear
191 chain, and <var>fifo, crop, vflip</var> are in another. The points where
192 the linear chains join are labeled by names enclosed in square
193 brackets. In our example, that is <var>[T1]</var> and <var>[T2]</var>. The magic
194 labels <var>[in]</var> and <var>[out]</var> are the points where video is input
197 <p>Some filters take in input a list of parameters: they are specified
198 after the filter name and an equal sign, and are separated each other
201 <p>There exist so-called <var>source filters</var> that do not have a video
202 input, and we expect in the future some <var>sink filters</var> that will
203 not have video output.
205 <a name="graph2dot"></a>
206 <h1 class="chapter"><a href="libavfilter.html#toc-graph2dot">3. graph2dot</a></h1>
208 <p>The ‘<tt>graph2dot</tt>’ program included in the FFmpeg ‘<tt>tools</tt>’
209 directory can be used to parse a filter graph description and issue a
210 corresponding textual representation in the dot language.
212 <p>Invoke the command:
213 </p><table><tr><td> </td><td><pre class="example">graph2dot -h
214 </pre></td></tr></table>
216 <p>to see how to use ‘<tt>graph2dot</tt>’.
218 <p>You can then pass the dot description to the ‘<tt>dot</tt>’ program (from
219 the graphviz suite of programs) and obtain a graphical representation
222 <p>For example the sequence of commands:
223 </p><table><tr><td> </td><td><pre class="example">echo <var>GRAPH_DESCRIPTION</var> | \
224 tools/graph2dot -o graph.tmp && \
225 dot -Tpng graph.tmp -o graph.png && \
227 </pre></td></tr></table>
229 <p>can be used to create and display an image representing the graph
230 described by the <var>GRAPH_DESCRIPTION</var> string.
232 <a name="Filtergraph-description"></a>
233 <h1 class="chapter"><a href="libavfilter.html#toc-Filtergraph-description">4. Filtergraph description</a></h1>
235 <p>A filtergraph is a directed graph of connected filters. It can contain
236 cycles, and there can be multiple links between a pair of
237 filters. Each link has one input pad on one side connecting it to one
238 filter from which it takes its input, and one output pad on the other
239 side connecting it to the one filter accepting its output.
241 <p>Each filter in a filtergraph is an instance of a filter class
242 registered in the application, which defines the features and the
243 number of input and output pads of the filter.
245 <p>A filter with no input pads is called a "source", a filter with no
246 output pads is called a "sink".
248 <a name="Filtergraph-syntax"></a>
249 <h2 class="section"><a href="libavfilter.html#toc-Filtergraph-syntax">4.1 Filtergraph syntax</a></h2>
251 <p>A filtergraph can be represented using a textual representation, which
252 is recognized by the <code>-vf</code> and <code>-af</code> options of the ff*
253 tools, and by the <code>avfilter_graph_parse()</code> function defined in
254 ‘<tt>libavfilter/avfiltergraph.h</tt>’.
256 <p>A filterchain consists of a sequence of connected filters, each one
257 connected to the previous one in the sequence. A filterchain is
258 represented by a list of ","-separated filter descriptions.
260 <p>A filtergraph consists of a sequence of filterchains. A sequence of
261 filterchains is represented by a list of ";"-separated filterchain
264 <p>A filter is represented by a string of the form:
265 [<var>in_link_1</var>]...[<var>in_link_N</var>]<var>filter_name</var>=<var>arguments</var>[<var>out_link_1</var>]...[<var>out_link_M</var>]
267 <p><var>filter_name</var> is the name of the filter class of which the
268 described filter is an instance of, and has to be the name of one of
269 the filter classes registered in the program.
270 The name of the filter class is optionally followed by a string
271 "=<var>arguments</var>".
273 <p><var>arguments</var> is a string which contains the parameters used to
274 initialize the filter instance, and are described in the filter
277 <p>The list of arguments can be quoted using the character "’" as initial
278 and ending mark, and the character ’\’ for escaping the characters
279 within the quoted text; otherwise the argument string is considered
280 terminated when the next special character (belonging to the set
281 "[]=;,") is encountered.
283 <p>The name and arguments of the filter are optionally preceded and
284 followed by a list of link labels.
285 A link label allows to name a link and associate it to a filter output
286 or input pad. The preceding labels <var>in_link_1</var>
287 ... <var>in_link_N</var>, are associated to the filter input pads,
288 the following labels <var>out_link_1</var> ... <var>out_link_M</var>, are
289 associated to the output pads.
291 <p>When two link labels with the same name are found in the
292 filtergraph, a link between the corresponding input and output pad is
295 <p>If an output pad is not labelled, it is linked by default to the first
296 unlabelled input pad of the next filter in the filterchain.
297 For example in the filterchain:
298 </p><table><tr><td> </td><td><pre class="example">nullsrc, split[L1], [L2]overlay, nullsink
299 </pre></td></tr></table>
300 <p>the split filter instance has two output pads, and the overlay filter
301 instance two input pads. The first output pad of split is labelled
302 "L1", the first input pad of overlay is labelled "L2", and the second
303 output pad of split is linked to the second input pad of overlay,
304 which are both unlabelled.
306 <p>In a complete filterchain all the unlabelled filter input and output
307 pads must be connected. A filtergraph is considered valid if all the
308 filter input and output pads of all the filterchains are connected.
310 <p>Follows a BNF description for the filtergraph syntax:
311 </p><table><tr><td> </td><td><pre class="example"><var>NAME</var> ::= sequence of alphanumeric characters and '_'
312 <var>LINKLABEL</var> ::= "[" <var>NAME</var> "]"
313 <var>LINKLABELS</var> ::= <var>LINKLABEL</var> [<var>LINKLABELS</var>]
314 <var>FILTER_ARGUMENTS</var> ::= sequence of chars (eventually quoted)
315 <var>FILTER</var> ::= [<var>LINKNAMES</var>] <var>NAME</var> ["=" <var>ARGUMENTS</var>] [<var>LINKNAMES</var>]
316 <var>FILTERCHAIN</var> ::= <var>FILTER</var> [,<var>FILTERCHAIN</var>]
317 <var>FILTERGRAPH</var> ::= <var>FILTERCHAIN</var> [;<var>FILTERGRAPH</var>]
318 </pre></td></tr></table>
321 <a name="Audio-Filters"></a>
322 <h1 class="chapter"><a href="libavfilter.html#toc-Audio-Filters">5. Audio Filters</a></h1>
324 <p>When you configure your FFmpeg build, you can disable any of the
325 existing filters using –disable-filters.
326 The configure output will show the audio filters included in your
329 <p>Below is a description of the currently available audio filters.
331 <a name="aformat"></a>
332 <h2 class="section"><a href="libavfilter.html#toc-aformat">5.1 aformat</a></h2>
334 <p>Convert the input audio to one of the specified formats. The framework will
335 negotiate the most appropriate format to minimize conversions.
337 <p>The filter accepts three lists of formats, separated by ":", in the form:
338 "<var>sample_formats</var>:<var>channel_layouts</var>:<var>packing_formats</var>".
340 <p>Elements in each list are separated by "," which has to be escaped in the
341 filtergraph specification.
343 <p>The special parameter "all", in place of a list of elements, signifies all
346 <p>Some examples follow:
347 </p><table><tr><td> </td><td><pre class="example">aformat=u8\\,s16:mono:packed
349 aformat=s16:mono\\,stereo:all
350 </pre></td></tr></table>
353 <h2 class="section"><a href="libavfilter.html#toc-anull">5.2 anull</a></h2>
355 <p>Pass the audio source unchanged to the output.
357 <a name="aresample"></a>
358 <h2 class="section"><a href="libavfilter.html#toc-aresample">5.3 aresample</a></h2>
360 <p>Resample the input audio to the specified sample rate.
362 <p>The filter accepts exactly one parameter, the output sample rate. If not
363 specified then the filter will automatically convert between its input
364 and output sample rates.
366 <p>For example, to resample the input audio to 44100Hz:
367 </p><table><tr><td> </td><td><pre class="example">aresample=44100
368 </pre></td></tr></table>
370 <a name="ashowinfo"></a>
371 <h2 class="section"><a href="libavfilter.html#toc-ashowinfo">5.4 ashowinfo</a></h2>
373 <p>Show a line containing various information for each input audio frame.
374 The input audio is not modified.
376 <p>The shown line contains a sequence of key/value pairs of the form
377 <var>key</var>:<var>value</var>.
379 <p>A description of each shown parameter follows:
381 <dl compact="compact">
382 <dt> ‘<samp>n</samp>’</dt>
383 <dd><p>sequential number of the input frame, starting from 0
386 <dt> ‘<samp>pts</samp>’</dt>
387 <dd><p>presentation TimeStamp of the input frame, expressed as a number of
388 time base units. The time base unit depends on the filter input pad, and
389 is usually 1/<var>sample_rate</var>.
392 <dt> ‘<samp>pts_time</samp>’</dt>
393 <dd><p>presentation TimeStamp of the input frame, expressed as a number of
397 <dt> ‘<samp>pos</samp>’</dt>
398 <dd><p>position of the frame in the input stream, -1 if this information in
399 unavailable and/or meanigless (for example in case of synthetic audio)
402 <dt> ‘<samp>fmt</samp>’</dt>
403 <dd><p>sample format name
406 <dt> ‘<samp>chlayout</samp>’</dt>
407 <dd><p>channel layout description
410 <dt> ‘<samp>nb_samples</samp>’</dt>
411 <dd><p>number of samples (per each channel) contained in the filtered frame
414 <dt> ‘<samp>rate</samp>’</dt>
415 <dd><p>sample rate for the audio frame
418 <dt> ‘<samp>planar</samp>’</dt>
419 <dd><p>if the packing format is planar, 0 if packed
422 <dt> ‘<samp>checksum</samp>’</dt>
423 <dd><p>Adler-32 checksum of all the planes of the input frame
426 <dt> ‘<samp>plane_checksum</samp>’</dt>
427 <dd><p>Adler-32 checksum for each input frame plane, expressed in the form
428 "[<var>c0</var> <var>c1</var> <var>c2</var> <var>c3</var> <var>c4</var> <var>c5</var> <var>c6</var> <var>c7</var>]"
433 <a name="Audio-Sources"></a>
434 <h1 class="chapter"><a href="libavfilter.html#toc-Audio-Sources">6. Audio Sources</a></h1>
436 <p>Below is a description of the currently available audio sources.
438 <a name="abuffer"></a>
439 <h2 class="section"><a href="libavfilter.html#toc-abuffer">6.1 abuffer</a></h2>
441 <p>Buffer audio frames, and make them available to the filter chain.
443 <p>This source is mainly intended for a programmatic use, in particular
444 through the interface defined in ‘<tt>libavfilter/asrc_abuffer.h</tt>’.
446 <p>It accepts the following mandatory parameters:
447 <var>sample_rate</var>:<var>sample_fmt</var>:<var>channel_layout</var>:<var>packing</var>
449 <dl compact="compact">
450 <dt> ‘<samp>sample_rate</samp>’</dt>
451 <dd><p>The sample rate of the incoming audio buffers.
454 <dt> ‘<samp>sample_fmt</samp>’</dt>
455 <dd><p>The sample format of the incoming audio buffers.
456 Either a sample format name or its corresponging integer representation from
457 the enum AVSampleFormat in ‘<tt>libavutil/samplefmt.h</tt>’
460 <dt> ‘<samp>channel_layout</samp>’</dt>
461 <dd><p>The channel layout of the incoming audio buffers.
462 Either a channel layout name from channel_layout_map in
463 ‘<tt>libavutil/audioconvert.c</tt>’ or its corresponding integer representation
464 from the AV_CH_LAYOUT_* macros in ‘<tt>libavutil/audioconvert.h</tt>’
467 <dt> ‘<samp>packing</samp>’</dt>
468 <dd><p>Either "packed" or "planar", or their integer representation: 0 or 1
475 </p><table><tr><td> </td><td><pre class="example">abuffer=44100:s16:stereo:planar
476 </pre></td></tr></table>
478 <p>will instruct the source to accept planar 16bit signed stereo at 44100Hz.
479 Since the sample format with name "s16" corresponds to the number
480 1 and the "stereo" channel layout corresponds to the value 3, this is
482 </p><table><tr><td> </td><td><pre class="example">abuffer=44100:1:3:1
483 </pre></td></tr></table>
485 <a name="amovie"></a>
486 <h2 class="section"><a href="libavfilter.html#toc-amovie">6.2 amovie</a></h2>
488 <p>Read an audio stream from a movie container.
490 <p>It accepts the syntax: <var>movie_name</var>[:<var>options</var>] where
491 <var>movie_name</var> is the name of the resource to read (not necessarily
492 a file but also a device or a stream accessed through some protocol),
493 and <var>options</var> is an optional sequence of <var>key</var>=<var>value</var>
494 pairs, separated by ":".
496 <p>The description of the accepted options follows.
498 <dl compact="compact">
499 <dt> ‘<samp>format_name, f</samp>’</dt>
500 <dd><p>Specify the format assumed for the movie to read, and can be either
501 the name of a container or an input device. If not specified the
502 format is guessed from <var>movie_name</var> or by probing.
505 <dt> ‘<samp>seek_point, sp</samp>’</dt>
506 <dd><p>Specify the seek point in seconds, the frames will be output
507 starting from this seek point, the parameter is evaluated with
508 <code>av_strtod</code> so the numerical value may be suffixed by an IS
509 postfix. Default value is "0".
512 <dt> ‘<samp>stream_index, si</samp>’</dt>
513 <dd><p>Specify the index of the audio stream to read. If the value is -1,
514 the best suited audio stream will be automatically selected. Default
515 value is "-1".
520 <a name="anullsrc"></a>
521 <h2 class="section"><a href="libavfilter.html#toc-anullsrc">6.3 anullsrc</a></h2>
523 <p>Null audio source, never return audio frames. It is mainly useful as a
524 template and to be employed in analysis / debugging tools.
526 <p>It accepts as optional parameter a string of the form
527 <var>sample_rate</var>:<var>channel_layout</var>.
529 <p><var>sample_rate</var> specify the sample rate, and defaults to 44100.
531 <p><var>channel_layout</var> specify the channel layout, and can be either an
532 integer or a string representing a channel layout. The default value
533 of <var>channel_layout</var> is 3, which corresponds to CH_LAYOUT_STEREO.
535 <p>Check the channel_layout_map definition in
536 ‘<tt>libavcodec/audioconvert.c</tt>’ for the mapping between strings and
537 channel layout values.
539 <p>Follow some examples:
540 </p><table><tr><td> </td><td><pre class="example"># set the sample rate to 48000 Hz and the channel layout to CH_LAYOUT_MONO.
545 </pre></td></tr></table>
548 <a name="Audio-Sinks"></a>
549 <h1 class="chapter"><a href="libavfilter.html#toc-Audio-Sinks">7. Audio Sinks</a></h1>
551 <p>Below is a description of the currently available audio sinks.
553 <a name="abuffersink"></a>
554 <h2 class="section"><a href="libavfilter.html#toc-abuffersink">7.1 abuffersink</a></h2>
556 <p>Buffer audio frames, and make them available to the end of filter chain.
558 <p>This sink is mainly intended for programmatic use, in particular
559 through the interface defined in ‘<tt>libavfilter/asink_abuffer.h</tt>’.
561 <p>It requires a pointer to a ABufferSinkContext structure, which defines the
562 incoming buffers’ format, to be passed as the opaque parameter to
563 <code>avfilter_init_filter</code> for initialization.
565 <a name="anullsink"></a>
566 <h2 class="section"><a href="libavfilter.html#toc-anullsink">7.2 anullsink</a></h2>
568 <p>Null audio sink, do absolutely nothing with the input audio. It is
569 mainly useful as a template and to be employed in analysis / debugging
573 <a name="Video-Filters"></a>
574 <h1 class="chapter"><a href="libavfilter.html#toc-Video-Filters">8. Video Filters</a></h1>
576 <p>When you configure your FFmpeg build, you can disable any of the
577 existing filters using –disable-filters.
578 The configure output will show the video filters included in your
581 <p>Below is a description of the currently available video filters.
583 <a name="blackframe"></a>
584 <h2 class="section"><a href="libavfilter.html#toc-blackframe">8.1 blackframe</a></h2>
586 <p>Detect frames that are (almost) completely black. Can be useful to
587 detect chapter transitions or commercials. Output lines consist of
588 the frame number of the detected frame, the percentage of blackness,
589 the position in the file if known or -1 and the timestamp in seconds.
591 <p>In order to display the output lines, you need to set the loglevel at
592 least to the AV_LOG_INFO value.
594 <p>The filter accepts the syntax:
595 </p><table><tr><td> </td><td><pre class="example">blackframe[=<var>amount</var>:[<var>threshold</var>]]
596 </pre></td></tr></table>
598 <p><var>amount</var> is the percentage of the pixels that have to be below the
599 threshold, and defaults to 98.
601 <p><var>threshold</var> is the threshold below which a pixel value is
602 considered black, and defaults to 32.
604 <a name="boxblur"></a>
605 <h2 class="section"><a href="libavfilter.html#toc-boxblur">8.2 boxblur</a></h2>
607 <p>Apply boxblur algorithm to the input video.
609 <p>This filter accepts the parameters:
610 <var>luma_power</var>:<var>luma_radius</var>:<var>chroma_radius</var>:<var>chroma_power</var>:<var>alpha_radius</var>:<var>alpha_power</var>
612 <p>Chroma and alpha parameters are optional, if not specified they default
613 to the corresponding values set for <var>luma_radius</var> and
614 <var>luma_power</var>.
616 <p><var>luma_radius</var>, <var>chroma_radius</var>, and <var>alpha_radius</var> represent
617 the radius in pixels of the box used for blurring the corresponding
618 input plane. They are expressions, and can contain the following
620 </p><dl compact="compact">
621 <dt> ‘<samp>w, h</samp>’</dt>
622 <dd><p>the input width and heigth in pixels
625 <dt> ‘<samp>cw, ch</samp>’</dt>
626 <dd><p>the input chroma image width and height in pixels
629 <dt> ‘<samp>hsub, vsub</samp>’</dt>
630 <dd><p>horizontal and vertical chroma subsample values. For example for the
631 pixel format "yuv422p" <var>hsub</var> is 2 and <var>vsub</var> is 1.
635 <p>The radius must be a non-negative number, and must be not greater than
636 the value of the expression <code>min(w,h)/2</code> for the luma and alpha planes,
637 and of <code>min(cw,ch)/2</code> for the chroma planes.
639 <p><var>luma_power</var>, <var>chroma_power</var>, and <var>alpha_power</var> represent
640 how many times the boxblur filter is applied to the corresponding
643 <p>Some examples follow:
647 Apply a boxblur filter with luma, chroma, and alpha radius
649 <table><tr><td> </td><td><pre class="example">boxblur=2:1
650 </pre></td></tr></table>
653 Set luma radius to 2, alpha and chroma radius to 0
654 <table><tr><td> </td><td><pre class="example">boxblur=2:1:0:0:0:0
655 </pre></td></tr></table>
658 Set luma and chroma radius to a fraction of the video dimension
659 <table><tr><td> </td><td><pre class="example">boxblur=min(h\,w)/10:1:min(cw\,ch)/10:1
660 </pre></td></tr></table>
665 <h2 class="section"><a href="libavfilter.html#toc-copy">8.3 copy</a></h2>
667 <p>Copy the input source unchanged to the output. Mainly useful for
671 <h2 class="section"><a href="libavfilter.html#toc-crop">8.4 crop</a></h2>
673 <p>Crop the input video to <var>out_w</var>:<var>out_h</var>:<var>x</var>:<var>y</var>.
675 <p>The parameters are expressions containing the following constants:
677 <dl compact="compact">
678 <dt> ‘<samp>E, PI, PHI</samp>’</dt>
679 <dd><p>the corresponding mathematical approximated values for e
680 (euler number), pi (greek PI), PHI (golden ratio)
683 <dt> ‘<samp>x, y</samp>’</dt>
684 <dd><p>the computed values for <var>x</var> and <var>y</var>. They are evaluated for
688 <dt> ‘<samp>in_w, in_h</samp>’</dt>
689 <dd><p>the input width and heigth
692 <dt> ‘<samp>iw, ih</samp>’</dt>
693 <dd><p>same as <var>in_w</var> and <var>in_h</var>
696 <dt> ‘<samp>out_w, out_h</samp>’</dt>
697 <dd><p>the output (cropped) width and heigth
700 <dt> ‘<samp>ow, oh</samp>’</dt>
701 <dd><p>same as <var>out_w</var> and <var>out_h</var>
704 <dt> ‘<samp>a</samp>’</dt>
705 <dd><p>same as <var>iw</var> / <var>ih</var>
708 <dt> ‘<samp>sar</samp>’</dt>
709 <dd><p>input sample aspect ratio
712 <dt> ‘<samp>dar</samp>’</dt>
713 <dd><p>input display aspect ratio, it is the same as (<var>iw</var> / <var>ih</var>) * <var>sar</var>
716 <dt> ‘<samp>hsub, vsub</samp>’</dt>
717 <dd><p>horizontal and vertical chroma subsample values. For example for the
718 pixel format "yuv422p" <var>hsub</var> is 2 and <var>vsub</var> is 1.
721 <dt> ‘<samp>n</samp>’</dt>
722 <dd><p>the number of input frame, starting from 0
725 <dt> ‘<samp>pos</samp>’</dt>
726 <dd><p>the position in the file of the input frame, NAN if unknown
729 <dt> ‘<samp>t</samp>’</dt>
730 <dd><p>timestamp expressed in seconds, NAN if the input timestamp is unknown
735 <p>The <var>out_w</var> and <var>out_h</var> parameters specify the expressions for
736 the width and height of the output (cropped) video. They are
737 evaluated just at the configuration of the filter.
739 <p>The default value of <var>out_w</var> is "in_w", and the default value of
740 <var>out_h</var> is "in_h".
742 <p>The expression for <var>out_w</var> may depend on the value of <var>out_h</var>,
743 and the expression for <var>out_h</var> may depend on <var>out_w</var>, but they
744 cannot depend on <var>x</var> and <var>y</var>, as <var>x</var> and <var>y</var> are
745 evaluated after <var>out_w</var> and <var>out_h</var>.
747 <p>The <var>x</var> and <var>y</var> parameters specify the expressions for the
748 position of the top-left corner of the output (non-cropped) area. They
749 are evaluated for each frame. If the evaluated value is not valid, it
750 is approximated to the nearest valid value.
752 <p>The default value of <var>x</var> is "(in_w-out_w)/2", and the default
753 value for <var>y</var> is "(in_h-out_h)/2", which set the cropped area at
754 the center of the input image.
756 <p>The expression for <var>x</var> may depend on <var>y</var>, and the expression
757 for <var>y</var> may depend on <var>x</var>.
759 <p>Follow some examples:
760 </p><table><tr><td> </td><td><pre class="example"># crop the central input area with size 100x100
763 # crop the central input area with size 2/3 of the input video
764 "crop=2/3*in_w:2/3*in_h"
766 # crop the input video central square
769 # delimit the rectangle with the top-left corner placed at position
770 # 100:100 and the right-bottom corner corresponding to the right-bottom
771 # corner of the input image.
772 crop=in_w-100:in_h-100:100:100
774 # crop 10 pixels from the left and right borders, and 20 pixels from
775 # the top and bottom borders
776 "crop=in_w-2*10:in_h-2*20"
778 # keep only the bottom right quarter of the input image
779 "crop=in_w/2:in_h/2:in_w/2:in_h/2"
781 # crop height for getting Greek harmony
782 "crop=in_w:1/PHI*in_w"
785 "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)"
787 # erratic camera effect depending on timestamp
788 "crop=in_w/2:in_h/2:(in_w-out_w)/2+((in_w-out_w)/2)*sin(t*10):(in_h-out_h)/2 +((in_h-out_h)/2)*sin(t*13)"
790 # set x depending on the value of y
791 "crop=in_w/2:in_h/2:y:10+10*sin(n/10)"
792 </pre></td></tr></table>
794 <a name="cropdetect"></a>
795 <h2 class="section"><a href="libavfilter.html#toc-cropdetect">8.5 cropdetect</a></h2>
797 <p>Auto-detect crop size.
799 <p>Calculate necessary cropping parameters and prints the recommended
800 parameters through the logging system. The detected dimensions
801 correspond to the non-black area of the input video.
803 <p>It accepts the syntax:
804 </p><table><tr><td> </td><td><pre class="example">cropdetect[=<var>limit</var>[:<var>round</var>[:<var>reset</var>]]]
805 </pre></td></tr></table>
807 <dl compact="compact">
808 <dt> ‘<samp>limit</samp>’</dt>
809 <dd><p>Threshold, which can be optionally specified from nothing (0) to
810 everything (255), defaults to 24.
813 <dt> ‘<samp>round</samp>’</dt>
814 <dd><p>Value which the width/height should be divisible by, defaults to
815 16. The offset is automatically adjusted to center the video. Use 2 to
816 get only even dimensions (needed for 4:2:2 video). 16 is best when
817 encoding to most video codecs.
820 <dt> ‘<samp>reset</samp>’</dt>
821 <dd><p>Counter that determines after how many frames cropdetect will reset
822 the previously detected largest video area and start over to detect
823 the current optimal crop area. Defaults to 0.
825 <p>This can be useful when channel logos distort the video area. 0
826 indicates never reset and return the largest area encountered during
831 <a name="delogo"></a>
832 <h2 class="section"><a href="libavfilter.html#toc-delogo">8.6 delogo</a></h2>
834 <p>Suppress a TV station logo by a simple interpolation of the surrounding
835 pixels. Just set a rectangle covering the logo and watch it disappear
836 (and sometimes something even uglier appear - your mileage may vary).
838 <p>The filter accepts parameters as a string of the form
839 "<var>x</var>:<var>y</var>:<var>w</var>:<var>h</var>:<var>band</var>", or as a list of
840 <var>key</var>=<var>value</var> pairs, separated by ":".
842 <p>The description of the accepted parameters follows.
844 <dl compact="compact">
845 <dt> ‘<samp>x, y</samp>’</dt>
846 <dd><p>Specify the top left corner coordinates of the logo. They must be
850 <dt> ‘<samp>w, h</samp>’</dt>
851 <dd><p>Specify the width and height of the logo to clear. They must be
855 <dt> ‘<samp>band, t</samp>’</dt>
856 <dd><p>Specify the thickness of the fuzzy edge of the rectangle (added to
857 <var>w</var> and <var>h</var>). The default value is 4.
860 <dt> ‘<samp>show</samp>’</dt>
861 <dd><p>When set to 1, a green rectangle is drawn on the screen to simplify
862 finding the right <var>x</var>, <var>y</var>, <var>w</var>, <var>h</var> parameters, and
863 <var>band</var> is set to 4. The default value is 0.
868 <p>Some examples follow.
872 Set a rectangle covering the area with top left corner coordinates 0,0
873 and size 100x77, setting a band of size 10:
874 <table><tr><td> </td><td><pre class="example">delogo=0:0:100:77:10
875 </pre></td></tr></table>
878 As the previous example, but use named options:
879 <table><tr><td> </td><td><pre class="example">delogo=x=0:y=0:w=100:h=77:band=10
880 </pre></td></tr></table>
884 <a name="drawbox"></a>
885 <h2 class="section"><a href="libavfilter.html#toc-drawbox">8.7 drawbox</a></h2>
887 <p>Draw a colored box on the input image.
889 <p>It accepts the syntax:
890 </p><table><tr><td> </td><td><pre class="example">drawbox=<var>x</var>:<var>y</var>:<var>width</var>:<var>height</var>:<var>color</var>
891 </pre></td></tr></table>
893 <dl compact="compact">
894 <dt> ‘<samp>x, y</samp>’</dt>
895 <dd><p>Specify the top left corner coordinates of the box. Default to 0.
898 <dt> ‘<samp>width, height</samp>’</dt>
899 <dd><p>Specify the width and height of the box, if 0 they are interpreted as
900 the input width and height. Default to 0.
903 <dt> ‘<samp>color</samp>’</dt>
904 <dd><p>Specify the color of the box to write, it can be the name of a color
905 (case insensitive match) or a 0xRRGGBB[AA] sequence.
909 <p>Follow some examples:
910 </p><table><tr><td> </td><td><pre class="example"># draw a black box around the edge of the input image
913 # draw a box with color red and an opacity of 50%
914 drawbox=10:20:200:60:red@0.5"
915 </pre></td></tr></table>
917 <a name="drawtext"></a>
918 <h2 class="section"><a href="libavfilter.html#toc-drawtext">8.8 drawtext</a></h2>
920 <p>Draw text string or text from specified file on top of video using the
923 <p>To enable compilation of this filter you need to configure FFmpeg with
924 <code>--enable-libfreetype</code>.
926 <p>The filter also recognizes strftime() sequences in the provided text
927 and expands them accordingly. Check the documentation of strftime().
929 <p>The filter accepts parameters as a list of <var>key</var>=<var>value</var> pairs,
930 separated by ":".
932 <p>The description of the accepted parameters follows.
934 <dl compact="compact">
935 <dt> ‘<samp>fontfile</samp>’</dt>
936 <dd><p>The font file to be used for drawing text. Path must be included.
937 This parameter is mandatory.
940 <dt> ‘<samp>text</samp>’</dt>
941 <dd><p>The text string to be drawn. The text must be a sequence of UTF-8
943 This parameter is mandatory if no file is specified with the parameter
947 <dt> ‘<samp>textfile</samp>’</dt>
948 <dd><p>A text file containing text to be drawn. The text must be a sequence
949 of UTF-8 encoded characters.
951 <p>This parameter is mandatory if no text string is specified with the
952 parameter <var>text</var>.
954 <p>If both text and textfile are specified, an error is thrown.
957 <dt> ‘<samp>x, y</samp>’</dt>
958 <dd><p>The offsets where text will be drawn within the video frame.
959 Relative to the top/left border of the output image.
961 <p>The default value of <var>x</var> and <var>y</var> is 0.
964 <dt> ‘<samp>fontsize</samp>’</dt>
965 <dd><p>The font size to be used for drawing text.
966 The default value of <var>fontsize</var> is 16.
969 <dt> ‘<samp>fontcolor</samp>’</dt>
970 <dd><p>The color to be used for drawing fonts.
971 Either a string (e.g. "red") or in 0xRRGGBB[AA] format
972 (e.g. "0xff000033"), possibly followed by an alpha specifier.
973 The default value of <var>fontcolor</var> is "black".
976 <dt> ‘<samp>boxcolor</samp>’</dt>
977 <dd><p>The color to be used for drawing box around text.
978 Either a string (e.g. "yellow") or in 0xRRGGBB[AA] format
979 (e.g. "0xff00ff"), possibly followed by an alpha specifier.
980 The default value of <var>boxcolor</var> is "white".
983 <dt> ‘<samp>box</samp>’</dt>
984 <dd><p>Used to draw a box around text using background color.
985 Value should be either 1 (enable) or 0 (disable).
986 The default value of <var>box</var> is 0.
989 <dt> ‘<samp>shadowx, shadowy</samp>’</dt>
990 <dd><p>The x and y offsets for the text shadow position with respect to the
991 position of the text. They can be either positive or negative
992 values. Default value for both is "0".
995 <dt> ‘<samp>shadowcolor</samp>’</dt>
996 <dd><p>The color to be used for drawing a shadow behind the drawn text. It
997 can be a color name (e.g. "yellow") or a string in the 0xRRGGBB[AA]
998 form (e.g. "0xff00ff"), possibly followed by an alpha specifier.
999 The default value of <var>shadowcolor</var> is "black".
1002 <dt> ‘<samp>ft_load_flags</samp>’</dt>
1003 <dd><p>Flags to be used for loading the fonts.
1005 <p>The flags map the corresponding flags supported by libfreetype, and are
1006 a combination of the following values:
1007 </p><dl compact="compact">
1008 <dt> <var>default</var></dt>
1009 <dt> <var>no_scale</var></dt>
1010 <dt> <var>no_hinting</var></dt>
1011 <dt> <var>render</var></dt>
1012 <dt> <var>no_bitmap</var></dt>
1013 <dt> <var>vertical_layout</var></dt>
1014 <dt> <var>force_autohint</var></dt>
1015 <dt> <var>crop_bitmap</var></dt>
1016 <dt> <var>pedantic</var></dt>
1017 <dt> <var>ignore_global_advance_width</var></dt>
1018 <dt> <var>no_recurse</var></dt>
1019 <dt> <var>ignore_transform</var></dt>
1020 <dt> <var>monochrome</var></dt>
1021 <dt> <var>linear_design</var></dt>
1022 <dt> <var>no_autohint</var></dt>
1023 <dt> <var>end table</var></dt>
1026 <p>Default value is "render".
1028 <p>For more information consult the documentation for the FT_LOAD_*
1032 <dt> ‘<samp>tabsize</samp>’</dt>
1033 <dd><p>The size in number of spaces to use for rendering the tab.
1038 <p>For example the command:
1039 </p><table><tr><td> </td><td><pre class="example">drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
1040 </pre></td></tr></table>
1042 <p>will draw "Test Text" with font FreeSerif, using the default values
1043 for the optional parameters.
1046 </p><table><tr><td> </td><td><pre class="example">drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
1047 x=100: y=50: fontsize=24: fontcolor=yellow@0.2: box=1: boxcolor=red@0.2"
1048 </pre></td></tr></table>
1050 <p>will draw ’Test Text’ with font FreeSerif of size 24 at position x=100
1051 and y=50 (counting from the top-left corner of the screen), text is
1052 yellow with a red box around it. Both the text and the box have an
1055 <p>Note that the double quotes are not necessary if spaces are not used
1056 within the parameter list.
1058 <p>For more information about libfreetype, check:
1059 <a href="http://www.freetype.org/">http://www.freetype.org/</a>.
1062 <h2 class="section"><a href="libavfilter.html#toc-fade">8.9 fade</a></h2>
1064 <p>Apply fade-in/out effect to input video.
1066 <p>It accepts the parameters:
1067 <var>type</var>:<var>start_frame</var>:<var>nb_frames</var>
1069 <p><var>type</var> specifies if the effect type, can be either "in" for
1070 fade-in, or "out" for a fade-out effect.
1072 <p><var>start_frame</var> specifies the number of the start frame for starting
1073 to apply the fade effect.
1075 <p><var>nb_frames</var> specifies the number of frames for which the fade
1076 effect has to last. At the end of the fade-in effect the output video
1077 will have the same intensity as the input video, at the end of the
1078 fade-out transition the output video will be completely black.
1080 <p>A few usage examples follow, usable too as test scenarios.
1081 </p><table><tr><td> </td><td><pre class="example"># fade in first 30 frames of video
1084 # fade out last 45 frames of a 200-frame video
1087 # fade in first 25 frames and fade out last 25 frames of a 1000-frame video
1088 fade=in:0:25, fade=out:975:25
1090 # make first 5 frames black, then fade in from frame 5-24
1092 </pre></td></tr></table>
1094 <a name="fieldorder"></a>
1095 <h2 class="section"><a href="libavfilter.html#toc-fieldorder">8.10 fieldorder</a></h2>
1097 <p>Transform the field order of the input video.
1099 <p>It accepts one parameter which specifies the required field order that
1100 the input interlaced video will be transformed to. The parameter can
1101 assume one of the following values:
1103 <dl compact="compact">
1104 <dt> ‘<samp>0 or bff</samp>’</dt>
1105 <dd><p>output bottom field first
1107 <dt> ‘<samp>1 or tff</samp>’</dt>
1108 <dd><p>output top field first
1112 <p>Default value is "tff".
1114 <p>Transformation is achieved by shifting the picture content up or down
1115 by one line, and filling the remaining line with appropriate picture content.
1116 This method is consistent with most broadcast field order converters.
1118 <p>If the input video is not flagged as being interlaced, or it is already
1119 flagged as being of the required output field order then this filter does
1120 not alter the incoming video.
1122 <p>This filter is very useful when converting to or from PAL DV material,
1123 which is bottom field first.
1126 </p><table><tr><td> </td><td><pre class="example">./ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
1127 </pre></td></tr></table>
1130 <h2 class="section"><a href="libavfilter.html#toc-fifo">8.11 fifo</a></h2>
1132 <p>Buffer input images and send them when they are requested.
1134 <p>This filter is mainly useful when auto-inserted by the libavfilter
1137 <p>The filter does not take parameters.
1139 <a name="format"></a>
1140 <h2 class="section"><a href="libavfilter.html#toc-format">8.12 format</a></h2>
1142 <p>Convert the input video to one of the specified pixel formats.
1143 Libavfilter will try to pick one that is supported for the input to
1146 <p>The filter accepts a list of pixel format names, separated by ":",
1147 for example "yuv420p:monow:rgb24".
1149 <p>Some examples follow:
1150 </p><table><tr><td> </td><td><pre class="example"># convert the input video to the format "yuv420p"
1153 # convert the input video to any of the formats in the list
1154 format=yuv420p:yuv444p:yuv410p
1155 </pre></td></tr></table>
1157 <p><a name="frei0r"></a>
1158 </p><a name="frei0r-1"></a>
1159 <h2 class="section"><a href="libavfilter.html#toc-frei0r-1">8.13 frei0r</a></h2>
1161 <p>Apply a frei0r effect to the input video.
1163 <p>To enable compilation of this filter you need to install the frei0r
1164 header and configure FFmpeg with –enable-frei0r.
1166 <p>The filter supports the syntax:
1167 </p><table><tr><td> </td><td><pre class="example"><var>filter_name</var>[{:|=}<var>param1</var>:<var>param2</var>:...:<var>paramN</var>]
1168 </pre></td></tr></table>
1170 <p><var>filter_name</var> is the name to the frei0r effect to load. If the
1171 environment variable <code>FREI0R_PATH</code> is defined, the frei0r effect
1172 is searched in each one of the directories specified by the colon
1173 separated list in <code>FREIOR_PATH</code>, otherwise in the standard frei0r
1174 paths, which are in this order: ‘<tt>HOME/.frei0r-1/lib/</tt>’,
1175 ‘<tt>/usr/local/lib/frei0r-1/</tt>’, ‘<tt>/usr/lib/frei0r-1/</tt>’.
1177 <p><var>param1</var>, <var>param2</var>, ... , <var>paramN</var> specify the parameters
1178 for the frei0r effect.
1180 <p>A frei0r effect parameter can be a boolean (whose values are specified
1181 with "y" and "n"), a double, a color (specified by the syntax
1182 <var>R</var>/<var>G</var>/<var>B</var>, <var>R</var>, <var>G</var>, and <var>B</var> being float
1183 numbers from 0.0 to 1.0) or by an <code>av_parse_color()</code> color
1184 description), a position (specified by the syntax <var>X</var>/<var>Y</var>,
1185 <var>X</var> and <var>Y</var> being float numbers) and a string.
1187 <p>The number and kind of parameters depend on the loaded effect. If an
1188 effect parameter is not specified the default value is set.
1190 <p>Some examples follow:
1191 </p><table><tr><td> </td><td><pre class="example"># apply the distort0r effect, set the first two double parameters
1192 frei0r=distort0r:0.5:0.01
1194 # apply the colordistance effect, takes a color as first parameter
1195 frei0r=colordistance:0.2/0.3/0.4
1196 frei0r=colordistance:violet
1197 frei0r=colordistance:0x112233
1199 # apply the perspective effect, specify the top left and top right
1201 frei0r=perspective:0.2/0.2:0.8/0.2
1202 </pre></td></tr></table>
1204 <p>For more information see:
1205 <a href="http://piksel.org/frei0r">http://piksel.org/frei0r</a>
1207 <a name="gradfun"></a>
1208 <h2 class="section"><a href="libavfilter.html#toc-gradfun">8.14 gradfun</a></h2>
1210 <p>Fix the banding artifacts that are sometimes introduced into nearly flat
1211 regions by truncation to 8bit colordepth.
1212 Interpolate the gradients that should go where the bands are, and
1215 <p>This filter is designed for playback only. Do not use it prior to
1216 lossy compression, because compression tends to lose the dither and
1217 bring back the bands.
1219 <p>The filter takes two optional parameters, separated by ’:’:
1220 <var>strength</var>:<var>radius</var>
1222 <p><var>strength</var> is the maximum amount by which the filter will change
1223 any one pixel. Also the threshold for detecting nearly flat
1224 regions. Acceptable values range from .51 to 255, default value is
1225 1.2, out-of-range values will be clipped to the valid range.
1227 <p><var>radius</var> is the neighborhood to fit the gradient to. A larger
1228 radius makes for smoother gradients, but also prevents the filter from
1229 modifying the pixels near detailed regions. Acceptable values are
1230 8-32, default value is 16, out-of-range values will be clipped to the
1233 <table><tr><td> </td><td><pre class="example"># default parameters
1238 </pre></td></tr></table>
1240 <a name="hflip"></a>
1241 <h2 class="section"><a href="libavfilter.html#toc-hflip">8.15 hflip</a></h2>
1243 <p>Flip the input video horizontally.
1245 <p>For example to horizontally flip the video in input with
1246 ‘<tt>ffmpeg</tt>’:
1247 </p><table><tr><td> </td><td><pre class="example">ffmpeg -i in.avi -vf "hflip" out.avi
1248 </pre></td></tr></table>
1250 <a name="hqdn3d"></a>
1251 <h2 class="section"><a href="libavfilter.html#toc-hqdn3d">8.16 hqdn3d</a></h2>
1253 <p>High precision/quality 3d denoise filter. This filter aims to reduce
1254 image noise producing smooth images and making still images really
1255 still. It should enhance compressibility.
1257 <p>It accepts the following optional parameters:
1258 <var>luma_spatial</var>:<var>chroma_spatial</var>:<var>luma_tmp</var>:<var>chroma_tmp</var>
1260 <dl compact="compact">
1261 <dt> ‘<samp>luma_spatial</samp>’</dt>
1262 <dd><p>a non-negative float number which specifies spatial luma strength,
1266 <dt> ‘<samp>chroma_spatial</samp>’</dt>
1267 <dd><p>a non-negative float number which specifies spatial chroma strength,
1268 defaults to 3.0*<var>luma_spatial</var>/4.0
1271 <dt> ‘<samp>luma_tmp</samp>’</dt>
1272 <dd><p>a float number which specifies luma temporal strength, defaults to
1273 6.0*<var>luma_spatial</var>/4.0
1276 <dt> ‘<samp>chroma_tmp</samp>’</dt>
1277 <dd><p>a float number which specifies chroma temporal strength, defaults to
1278 <var>luma_tmp</var>*<var>chroma_spatial</var>/<var>luma_spatial</var>
1282 <a name="lut_002c-lutrgb_002c-lutyuv"></a>
1283 <h2 class="section"><a href="libavfilter.html#toc-lut_002c-lutrgb_002c-lutyuv">8.17 lut, lutrgb, lutyuv</a></h2>
1285 <p>Compute a look-up table for binding each pixel component input value
1286 to an output value, and apply it to input video.
1288 <p><var>lutyuv</var> applies a lookup table to a YUV input video, <var>lutrgb</var>
1289 to an RGB input video.
1291 <p>These filters accept in input a ":"-separated list of options, which
1292 specify the expressions used for computing the lookup table for the
1293 corresponding pixel component values.
1295 <p>The <var>lut</var> filter requires either YUV or RGB pixel formats in
1296 input, and accepts the options:
1297 </p><dl compact="compact">
1298 <dd><p><var>c0</var> (first pixel component)
1299 <var>c1</var> (second pixel component)
1300 <var>c2</var> (third pixel component)
1301 <var>c3</var> (fourth pixel component, corresponds to the alpha component)
1305 <p>The exact component associated to each option depends on the format in
1308 <p>The <var>lutrgb</var> filter requires RGB pixel formats in input, and
1309 accepts the options:
1310 </p><dl compact="compact">
1311 <dd><p><var>r</var> (red component)
1312 <var>g</var> (green component)
1313 <var>b</var> (blue component)
1314 <var>a</var> (alpha component)
1318 <p>The <var>lutyuv</var> filter requires YUV pixel formats in input, and
1319 accepts the options:
1320 </p><dl compact="compact">
1321 <dd><p><var>y</var> (Y/luminance component)
1322 <var>u</var> (U/Cb component)
1323 <var>v</var> (V/Cr component)
1324 <var>a</var> (alpha component)
1328 <p>The expressions can contain the following constants and functions:
1330 <dl compact="compact">
1331 <dt> ‘<samp>E, PI, PHI</samp>’</dt>
1332 <dd><p>the corresponding mathematical approximated values for e
1333 (euler number), pi (greek PI), PHI (golden ratio)
1336 <dt> ‘<samp>w, h</samp>’</dt>
1337 <dd><p>the input width and heigth
1340 <dt> ‘<samp>val</samp>’</dt>
1341 <dd><p>input value for the pixel component
1344 <dt> ‘<samp>clipval</samp>’</dt>
1345 <dd><p>the input value clipped in the <var>minval</var>-<var>maxval</var> range
1348 <dt> ‘<samp>maxval</samp>’</dt>
1349 <dd><p>maximum value for the pixel component
1352 <dt> ‘<samp>minval</samp>’</dt>
1353 <dd><p>minimum value for the pixel component
1356 <dt> ‘<samp>negval</samp>’</dt>
1357 <dd><p>the negated value for the pixel component value clipped in the
1358 <var>minval</var>-<var>maxval</var> range , it corresponds to the expression
1359 "maxval-clipval+minval"
1362 <dt> ‘<samp>clip(val)</samp>’</dt>
1363 <dd><p>the computed value in <var>val</var> clipped in the
1364 <var>minval</var>-<var>maxval</var> range
1367 <dt> ‘<samp>gammaval(gamma)</samp>’</dt>
1368 <dd><p>the computed gamma correction value of the pixel component value
1369 clipped in the <var>minval</var>-<var>maxval</var> range, corresponds to the
1371 "pow((clipval-minval)/(maxval-minval)\,<var>gamma</var>)*(maxval-minval)+minval"
1376 <p>All expressions default to "val".
1378 <p>Some examples follow:
1379 </p><table><tr><td> </td><td><pre class="example"># negate input video
1380 lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
1381 lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
1383 # the above is the same as
1384 lutrgb="r=negval:g=negval:b=negval"
1385 lutyuv="y=negval:u=negval:v=negval"
1390 # remove chroma components, turns the video into a graytone image
1391 lutyuv="u=128:v=128"
1393 # apply a luma burning effect
1394 lutyuv="y=2*val"
1396 # remove green and blue components
1397 lutrgb="g=0:b=0"
1399 # set a constant alpha channel value on input
1400 format=rgba,lutrgb=a="maxval-minval/2"
1402 # correct luminance gamma by a 0.5 factor
1403 lutyuv=y=gammaval(0.5)
1404 </pre></td></tr></table>
1407 <h2 class="section"><a href="libavfilter.html#toc-mp">8.18 mp</a></h2>
1409 <p>Apply an MPlayer filter to the input video.
1411 <p>This filter provides a wrapper around most of the filters of
1414 <p>This wrapper is considered experimental. Some of the wrapped filters
1415 may not work properly and we may drop support for them, as they will
1416 be implemented natively into FFmpeg. Thus you should avoid
1417 depending on them when writing portable scripts.
1419 <p>The filters accepts the parameters:
1420 <var>filter_name</var>[:=]<var>filter_params</var>
1422 <p><var>filter_name</var> is the name of a supported MPlayer filter,
1423 <var>filter_params</var> is a string containing the parameters accepted by
1426 <p>The list of the currently supported filters follows:
1427 </p><dl compact="compact">
1428 <dt> <var>2xsai</var></dt>
1429 <dt> <var>decimate</var></dt>
1430 <dt> <var>denoise3d</var></dt>
1431 <dt> <var>detc</var></dt>
1432 <dt> <var>dint</var></dt>
1433 <dt> <var>divtc</var></dt>
1434 <dt> <var>down3dright</var></dt>
1435 <dt> <var>dsize</var></dt>
1436 <dt> <var>eq2</var></dt>
1437 <dt> <var>eq</var></dt>
1438 <dt> <var>field</var></dt>
1439 <dt> <var>fil</var></dt>
1440 <dt> <var>fixpts</var></dt>
1441 <dt> <var>framestep</var></dt>
1442 <dt> <var>fspp</var></dt>
1443 <dt> <var>geq</var></dt>
1444 <dt> <var>harddup</var></dt>
1445 <dt> <var>hqdn3d</var></dt>
1446 <dt> <var>hue</var></dt>
1447 <dt> <var>il</var></dt>
1448 <dt> <var>ilpack</var></dt>
1449 <dt> <var>ivtc</var></dt>
1450 <dt> <var>kerndeint</var></dt>
1451 <dt> <var>mcdeint</var></dt>
1452 <dt> <var>mirror</var></dt>
1453 <dt> <var>noise</var></dt>
1454 <dt> <var>ow</var></dt>
1455 <dt> <var>palette</var></dt>
1456 <dt> <var>perspective</var></dt>
1457 <dt> <var>phase</var></dt>
1458 <dt> <var>pp7</var></dt>
1459 <dt> <var>pullup</var></dt>
1460 <dt> <var>qp</var></dt>
1461 <dt> <var>rectangle</var></dt>
1462 <dt> <var>remove-logo</var></dt>
1463 <dt> <var>rotate</var></dt>
1464 <dt> <var>sab</var></dt>
1465 <dt> <var>screenshot</var></dt>
1466 <dt> <var>smartblur</var></dt>
1467 <dt> <var>softpulldown</var></dt>
1468 <dt> <var>softskip</var></dt>
1469 <dt> <var>spp</var></dt>
1470 <dt> <var>swapuv</var></dt>
1471 <dt> <var>telecine</var></dt>
1472 <dt> <var>tile</var></dt>
1473 <dt> <var>tinterlace</var></dt>
1474 <dt> <var>unsharp</var></dt>
1475 <dt> <var>uspp</var></dt>
1476 <dt> <var>yuvcsp</var></dt>
1477 <dt> <var>yvu9</var></dt>
1480 <p>The parameter syntax and behavior for the listed filters are the same
1481 of the corresponding MPlayer filters. For detailed instructions check
1482 the "VIDEO FILTERS" section in the MPlayer manual.
1484 <p>Some examples follow:
1485 </p><table><tr><td> </td><td><pre class="example"># remove a logo by interpolating the surrounding pixels
1486 mp=delogo=200:200:80:20:1
1488 # adjust gamma, brightness, contrast
1491 # tweak hue and saturation
1493 </pre></td></tr></table>
1495 <p>See also mplayer(1), <a href="http://www.mplayerhq.hu/">http://www.mplayerhq.hu/</a>.
1497 <a name="negate"></a>
1498 <h2 class="section"><a href="libavfilter.html#toc-negate">8.19 negate</a></h2>
1500 <p>Negate input video.
1502 <p>This filter accepts an integer in input, if non-zero it negates the
1503 alpha component (if available). The default value in input is 0.
1505 <a name="noformat"></a>
1506 <h2 class="section"><a href="libavfilter.html#toc-noformat">8.20 noformat</a></h2>
1508 <p>Force libavfilter not to use any of the specified pixel formats for the
1509 input to the next filter.
1511 <p>The filter accepts a list of pixel format names, separated by ":",
1512 for example "yuv420p:monow:rgb24".
1514 <p>Some examples follow:
1515 </p><table><tr><td> </td><td><pre class="example"># force libavfilter to use a format different from "yuv420p" for the
1516 # input to the vflip filter
1517 noformat=yuv420p,vflip
1519 # convert the input video to any of the formats not contained in the list
1520 noformat=yuv420p:yuv444p:yuv410p
1521 </pre></td></tr></table>
1524 <h2 class="section"><a href="libavfilter.html#toc-null">8.21 null</a></h2>
1526 <p>Pass the video source unchanged to the output.
1529 <h2 class="section"><a href="libavfilter.html#toc-ocv">8.22 ocv</a></h2>
1531 <p>Apply video transform using libopencv.
1533 <p>To enable this filter install libopencv library and headers and
1534 configure FFmpeg with –enable-libopencv.
1536 <p>The filter takes the parameters: <var>filter_name</var>{:=}<var>filter_params</var>.
1538 <p><var>filter_name</var> is the name of the libopencv filter to apply.
1540 <p><var>filter_params</var> specifies the parameters to pass to the libopencv
1541 filter. If not specified the default values are assumed.
1543 <p>Refer to the official libopencv documentation for more precise
1545 <a href="http://opencv.willowgarage.com/documentation/c/image_filtering.html">http://opencv.willowgarage.com/documentation/c/image_filtering.html</a>
1547 <p>Follows the list of supported libopencv filters.
1549 <p><a name="dilate"></a>
1550 </p><a name="dilate-1"></a>
1551 <h3 class="subsection"><a href="libavfilter.html#toc-dilate-1">8.22.1 dilate</a></h3>
1553 <p>Dilate an image by using a specific structuring element.
1554 This filter corresponds to the libopencv function <code>cvDilate</code>.
1556 <p>It accepts the parameters: <var>struct_el</var>:<var>nb_iterations</var>.
1558 <p><var>struct_el</var> represents a structuring element, and has the syntax:
1559 <var>cols</var>x<var>rows</var>+<var>anchor_x</var>x<var>anchor_y</var>/<var>shape</var>
1561 <p><var>cols</var> and <var>rows</var> represent the number of colums and rows of
1562 the structuring element, <var>anchor_x</var> and <var>anchor_y</var> the anchor
1563 point, and <var>shape</var> the shape for the structuring element, and
1564 can be one of the values "rect", "cross", "ellipse", "custom".
1566 <p>If the value for <var>shape</var> is "custom", it must be followed by a
1567 string of the form "=<var>filename</var>". The file with name
1568 <var>filename</var> is assumed to represent a binary image, with each
1569 printable character corresponding to a bright pixel. When a custom
1570 <var>shape</var> is used, <var>cols</var> and <var>rows</var> are ignored, the number
1571 or columns and rows of the read file are assumed instead.
1573 <p>The default value for <var>struct_el</var> is "3x3+0x0/rect".
1575 <p><var>nb_iterations</var> specifies the number of times the transform is
1576 applied to the image, and defaults to 1.
1578 <p>Follow some example:
1579 </p><table><tr><td> </td><td><pre class="example"># use the default values
1582 # dilate using a structuring element with a 5x5 cross, iterate two times
1583 ocv=dilate=5x5+2x2/cross:2
1585 # read the shape from the file diamond.shape, iterate two times
1586 # the file diamond.shape may contain a pattern of characters like this:
1592 # the specified cols and rows are ignored (but not the anchor point coordinates)
1593 ocv=0x0+2x2/custom=diamond.shape:2
1594 </pre></td></tr></table>
1596 <a name="erode"></a>
1597 <h3 class="subsection"><a href="libavfilter.html#toc-erode">8.22.2 erode</a></h3>
1599 <p>Erode an image by using a specific structuring element.
1600 This filter corresponds to the libopencv function <code>cvErode</code>.
1602 <p>The filter accepts the parameters: <var>struct_el</var>:<var>nb_iterations</var>,
1603 with the same syntax and semantics as the <a href="#dilate">dilate</a> filter.
1605 <a name="smooth"></a>
1606 <h3 class="subsection"><a href="libavfilter.html#toc-smooth">8.22.3 smooth</a></h3>
1608 <p>Smooth the input video.
1610 <p>The filter takes the following parameters:
1611 <var>type</var>:<var>param1</var>:<var>param2</var>:<var>param3</var>:<var>param4</var>.
1613 <p><var>type</var> is the type of smooth filter to apply, and can be one of
1614 the following values: "blur", "blur_no_scale", "median", "gaussian",
1615 "bilateral". The default value is "gaussian".
1617 <p><var>param1</var>, <var>param2</var>, <var>param3</var>, and <var>param4</var> are
1618 parameters whose meanings depend on smooth type. <var>param1</var> and
1619 <var>param2</var> accept integer positive values or 0, <var>param3</var> and
1620 <var>param4</var> accept float values.
1622 <p>The default value for <var>param1</var> is 3, the default value for the
1623 other parameters is 0.
1625 <p>These parameters correspond to the parameters assigned to the
1626 libopencv function <code>cvSmooth</code>.
1628 <a name="overlay"></a>
1629 <h2 class="section"><a href="libavfilter.html#toc-overlay">8.23 overlay</a></h2>
1631 <p>Overlay one video on top of another.
1633 <p>It takes two inputs and one output, the first input is the "main"
1634 video on which the second input is overlayed.
1636 <p>It accepts the parameters: <var>x</var>:<var>y</var>.
1638 <p><var>x</var> is the x coordinate of the overlayed video on the main video,
1639 <var>y</var> is the y coordinate. The parameters are expressions containing
1640 the following parameters:
1642 <dl compact="compact">
1643 <dt> ‘<samp>main_w, main_h</samp>’</dt>
1644 <dd><p>main input width and height
1647 <dt> ‘<samp>W, H</samp>’</dt>
1648 <dd><p>same as <var>main_w</var> and <var>main_h</var>
1651 <dt> ‘<samp>overlay_w, overlay_h</samp>’</dt>
1652 <dd><p>overlay input width and height
1655 <dt> ‘<samp>w, h</samp>’</dt>
1656 <dd><p>same as <var>overlay_w</var> and <var>overlay_h</var>
1660 <p>Be aware that frames are taken from each input video in timestamp
1661 order, hence, if their initial timestamps differ, it is a a good idea
1662 to pass the two inputs through a <var>setpts=PTS-STARTPTS</var> filter to
1663 have them begin in the same zero timestamp, as it does the example for
1664 the <var>movie</var> filter.
1666 <p>Follow some examples:
1667 </p><table><tr><td> </td><td><pre class="example"># draw the overlay at 10 pixels from the bottom right
1668 # corner of the main video.
1669 overlay=main_w-overlay_w-10:main_h-overlay_h-10
1671 # insert a transparent PNG logo in the bottom left corner of the input
1672 movie=logo.png [logo];
1673 [in][logo] overlay=10:main_h-overlay_h-10 [out]
1675 # insert 2 different transparent PNG logos (second logo on bottom
1677 movie=logo1.png [logo1];
1678 movie=logo2.png [logo2];
1679 [in][logo1] overlay=10:H-h-10 [in+logo1];
1680 [in+logo1][logo2] overlay=W-w-10:H-h-10 [out]
1682 # add a transparent color layer on top of the main video,
1683 # WxH specifies the size of the main input to the overlay filter
1684 color=red.3:WxH [over]; [in][over] overlay [out]
1685 </pre></td></tr></table>
1687 <p>You can chain togheter more overlays but the efficiency of such
1688 approach is yet to be tested.
1691 <h2 class="section"><a href="libavfilter.html#toc-pad">8.24 pad</a></h2>
1693 <p>Add paddings to the input image, and places the original input at the
1694 given coordinates <var>x</var>, <var>y</var>.
1696 <p>It accepts the following parameters:
1697 <var>width</var>:<var>height</var>:<var>x</var>:<var>y</var>:<var>color</var>.
1699 <p>The parameters <var>width</var>, <var>height</var>, <var>x</var>, and <var>y</var> are
1700 expressions containing the following constants:
1702 <dl compact="compact">
1703 <dt> ‘<samp>E, PI, PHI</samp>’</dt>
1704 <dd><p>the corresponding mathematical approximated values for e
1705 (euler number), pi (greek PI), phi (golden ratio)
1708 <dt> ‘<samp>in_w, in_h</samp>’</dt>
1709 <dd><p>the input video width and heigth
1712 <dt> ‘<samp>iw, ih</samp>’</dt>
1713 <dd><p>same as <var>in_w</var> and <var>in_h</var>
1716 <dt> ‘<samp>out_w, out_h</samp>’</dt>
1717 <dd><p>the output width and heigth, that is the size of the padded area as
1718 specified by the <var>width</var> and <var>height</var> expressions
1721 <dt> ‘<samp>ow, oh</samp>’</dt>
1722 <dd><p>same as <var>out_w</var> and <var>out_h</var>
1725 <dt> ‘<samp>x, y</samp>’</dt>
1726 <dd><p>x and y offsets as specified by the <var>x</var> and <var>y</var>
1727 expressions, or NAN if not yet specified
1730 <dt> ‘<samp>a</samp>’</dt>
1731 <dd><p>same as <var>iw</var> / <var>ih</var>
1734 <dt> ‘<samp>sar</samp>’</dt>
1735 <dd><p>input sample aspect ratio
1738 <dt> ‘<samp>dar</samp>’</dt>
1739 <dd><p>input display aspect ratio, it is the same as (<var>iw</var> / <var>ih</var>) * <var>sar</var>
1742 <dt> ‘<samp>hsub, vsub</samp>’</dt>
1743 <dd><p>horizontal and vertical chroma subsample values. For example for the
1744 pixel format "yuv422p" <var>hsub</var> is 2 and <var>vsub</var> is 1.
1748 <p>Follows the description of the accepted parameters.
1750 <dl compact="compact">
1751 <dt> ‘<samp>width, height</samp>’</dt>
1753 <p>Specify the size of the output image with the paddings added. If the
1754 value for <var>width</var> or <var>height</var> is 0, the corresponding input size
1755 is used for the output.
1757 <p>The <var>width</var> expression can reference the value set by the
1758 <var>height</var> expression, and viceversa.
1760 <p>The default value of <var>width</var> and <var>height</var> is 0.
1763 <dt> ‘<samp>x, y</samp>’</dt>
1765 <p>Specify the offsets where to place the input image in the padded area
1766 with respect to the top/left border of the output image.
1768 <p>The <var>x</var> expression can reference the value set by the <var>y</var>
1769 expression, and viceversa.
1771 <p>The default value of <var>x</var> and <var>y</var> is 0.
1774 <dt> ‘<samp>color</samp>’</dt>
1776 <p>Specify the color of the padded area, it can be the name of a color
1777 (case insensitive match) or a 0xRRGGBB[AA] sequence.
1779 <p>The default value of <var>color</var> is "black".
1784 <p>Some examples follow:
1786 <table><tr><td> </td><td><pre class="example"># Add paddings with color "violet" to the input video. Output video
1787 # size is 640x480, the top-left corner of the input video is placed at
1789 pad=640:480:0:40:violet
1791 # pad the input to get an output with dimensions increased bt 3/2,
1792 # and put the input video at the center of the padded area
1793 pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
1795 # pad the input to get a squared output with size equal to the maximum
1796 # value between the input width and height, and put the input video at
1797 # the center of the padded area
1798 pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
1800 # pad the input to get a final w/h ratio of 16:9
1801 pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
1803 # for anamorphic video, in order to set the output display aspect ratio,
1804 # it is necessary to use sar in the expression, according to the relation:
1805 # (ih * X / ih) * sar = output_dar
1806 # X = output_dar / sar
1807 pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
1809 # double output size and put the input video in the bottom-right
1810 # corner of the output padded area
1811 pad="2*iw:2*ih:ow-iw:oh-ih"
1812 </pre></td></tr></table>
1814 <a name="pixdesctest"></a>
1815 <h2 class="section"><a href="libavfilter.html#toc-pixdesctest">8.25 pixdesctest</a></h2>
1817 <p>Pixel format descriptor test filter, mainly useful for internal
1818 testing. The output video should be equal to the input video.
1821 </p><table><tr><td> </td><td><pre class="example">format=monow, pixdesctest
1822 </pre></td></tr></table>
1824 <p>can be used to test the monowhite pixel format descriptor definition.
1826 <a name="scale"></a>
1827 <h2 class="section"><a href="libavfilter.html#toc-scale">8.26 scale</a></h2>
1829 <p>Scale the input video to <var>width</var>:<var>height</var> and/or convert the image format.
1831 <p>The parameters <var>width</var> and <var>height</var> are expressions containing
1832 the following constants:
1834 <dl compact="compact">
1835 <dt> ‘<samp>E, PI, PHI</samp>’</dt>
1836 <dd><p>the corresponding mathematical approximated values for e
1837 (euler number), pi (greek PI), phi (golden ratio)
1840 <dt> ‘<samp>in_w, in_h</samp>’</dt>
1841 <dd><p>the input width and heigth
1844 <dt> ‘<samp>iw, ih</samp>’</dt>
1845 <dd><p>same as <var>in_w</var> and <var>in_h</var>
1848 <dt> ‘<samp>out_w, out_h</samp>’</dt>
1849 <dd><p>the output (cropped) width and heigth
1852 <dt> ‘<samp>ow, oh</samp>’</dt>
1853 <dd><p>same as <var>out_w</var> and <var>out_h</var>
1856 <dt> ‘<samp>a</samp>’</dt>
1857 <dd><p>same as <var>iw</var> / <var>ih</var>
1860 <dt> ‘<samp>sar</samp>’</dt>
1861 <dd><p>input sample aspect ratio
1864 <dt> ‘<samp>dar</samp>’</dt>
1865 <dd><p>input display aspect ratio, it is the same as (<var>iw</var> / <var>ih</var>) * <var>sar</var>
1868 <dt> ‘<samp>hsub, vsub</samp>’</dt>
1869 <dd><p>horizontal and vertical chroma subsample values. For example for the
1870 pixel format "yuv422p" <var>hsub</var> is 2 and <var>vsub</var> is 1.
1874 <p>If the input image format is different from the format requested by
1875 the next filter, the scale filter will convert the input to the
1878 <p>If the value for <var>width</var> or <var>height</var> is 0, the respective input
1879 size is used for the output.
1881 <p>If the value for <var>width</var> or <var>height</var> is -1, the scale filter will
1882 use, for the respective output size, a value that maintains the aspect
1883 ratio of the input image.
1885 <p>The default value of <var>width</var> and <var>height</var> is 0.
1887 <p>Some examples follow:
1888 </p><table><tr><td> </td><td><pre class="example"># scale the input video to a size of 200x100.
1891 # scale the input to 2x
1893 # the above is the same as
1896 # scale the input to half size
1899 # increase the width, and set the height to the same size
1902 # seek for Greek harmony
1906 # increase the height, and set the width to 3/2 of the height
1909 # increase the size, but make the size a multiple of the chroma
1910 scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
1912 # increase the width to a maximum of 500 pixels, keep the same input aspect ratio
1913 scale='min(500\, iw*3/2):-1'
1914 </pre></td></tr></table>
1916 <a name="select"></a>
1917 <h2 class="section"><a href="libavfilter.html#toc-select">8.27 select</a></h2>
1918 <p>Select frames to pass in output.
1920 <p>It accepts in input an expression, which is evaluated for each input
1921 frame. If the expression is evaluated to a non-zero value, the frame
1922 is selected and passed to the output, otherwise it is discarded.
1924 <p>The expression can contain the following constants:
1926 <dl compact="compact">
1927 <dt> ‘<samp>PI</samp>’</dt>
1931 <dt> ‘<samp>PHI</samp>’</dt>
1935 <dt> ‘<samp>E</samp>’</dt>
1939 <dt> ‘<samp>n</samp>’</dt>
1940 <dd><p>the sequential number of the filtered frame, starting from 0
1943 <dt> ‘<samp>selected_n</samp>’</dt>
1944 <dd><p>the sequential number of the selected frame, starting from 0
1947 <dt> ‘<samp>prev_selected_n</samp>’</dt>
1948 <dd><p>the sequential number of the last selected frame, NAN if undefined
1951 <dt> ‘<samp>TB</samp>’</dt>
1952 <dd><p>timebase of the input timestamps
1955 <dt> ‘<samp>pts</samp>’</dt>
1956 <dd><p>the PTS (Presentation TimeStamp) of the filtered video frame,
1957 expressed in <var>TB</var> units, NAN if undefined
1960 <dt> ‘<samp>t</samp>’</dt>
1961 <dd><p>the PTS (Presentation TimeStamp) of the filtered video frame,
1962 expressed in seconds, NAN if undefined
1965 <dt> ‘<samp>prev_pts</samp>’</dt>
1966 <dd><p>the PTS of the previously filtered video frame, NAN if undefined
1969 <dt> ‘<samp>prev_selected_pts</samp>’</dt>
1970 <dd><p>the PTS of the last previously filtered video frame, NAN if undefined
1973 <dt> ‘<samp>prev_selected_t</samp>’</dt>
1974 <dd><p>the PTS of the last previously selected video frame, NAN if undefined
1977 <dt> ‘<samp>start_pts</samp>’</dt>
1978 <dd><p>the PTS of the first video frame in the video, NAN if undefined
1981 <dt> ‘<samp>start_t</samp>’</dt>
1982 <dd><p>the time of the first video frame in the video, NAN if undefined
1985 <dt> ‘<samp>pict_type</samp>’</dt>
1986 <dd><p>the picture type of the filtered frame, can assume one of the following
1988 </p><dl compact="compact">
1989 <dt> ‘<samp>PICT_TYPE_I</samp>’</dt>
1990 <dt> ‘<samp>PICT_TYPE_P</samp>’</dt>
1991 <dt> ‘<samp>PICT_TYPE_B</samp>’</dt>
1992 <dt> ‘<samp>PICT_TYPE_S</samp>’</dt>
1993 <dt> ‘<samp>PICT_TYPE_SI</samp>’</dt>
1994 <dt> ‘<samp>PICT_TYPE_SP</samp>’</dt>
1995 <dt> ‘<samp>PICT_TYPE_BI</samp>’</dt>
1999 <dt> ‘<samp>interlace_type</samp>’</dt>
2000 <dd><p>the frame interlace type, can assume one of the following values:
2001 </p><dl compact="compact">
2002 <dt> ‘<samp>INTERLACE_TYPE_P</samp>’</dt>
2003 <dd><p>the frame is progressive (not interlaced)
2005 <dt> ‘<samp>INTERLACE_TYPE_T</samp>’</dt>
2006 <dd><p>the frame is top-field-first
2008 <dt> ‘<samp>INTERLACE_TYPE_B</samp>’</dt>
2009 <dd><p>the frame is bottom-field-first
2014 <dt> ‘<samp>key</samp>’</dt>
2015 <dd><p>1 if the filtered frame is a key-frame, 0 otherwise
2018 <dt> ‘<samp>pos</samp>’</dt>
2019 <dd><p>the position in the file of the filtered frame, -1 if the information
2020 is not available (e.g. for synthetic video)
2024 <p>The default value of the select expression is "1".
2026 <p>Some examples follow:
2028 <table><tr><td> </td><td><pre class="example"># select all frames in input
2031 # the above is the same as:
2037 # select only I-frames
2038 select='eq(pict_type\,PICT_TYPE_I)'
2040 # select one frame every 100
2041 select='not(mod(n\,100))'
2043 # select only frames contained in the 10-20 time interval
2044 select='gte(t\,10)*lte(t\,20)'
2046 # select only I frames contained in the 10-20 time interval
2047 select='gte(t\,10)*lte(t\,20)*eq(pict_type\,PICT_TYPE_I)'
2049 # select frames with a minimum distance of 10 seconds
2050 select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
2051 </pre></td></tr></table>
2053 <p><a name="setdar"></a>
2054 </p><a name="setdar-1"></a>
2055 <h2 class="section"><a href="libavfilter.html#toc-setdar-1">8.28 setdar</a></h2>
2057 <p>Set the Display Aspect Ratio for the filter output video.
2059 <p>This is done by changing the specified Sample (aka Pixel) Aspect
2060 Ratio, according to the following equation:
2061 <em>DAR = HORIZONTAL_RESOLUTION / VERTICAL_RESOLUTION * SAR</em>
2063 <p>Keep in mind that this filter does not modify the pixel dimensions of
2064 the video frame. Also the display aspect ratio set by this filter may
2065 be changed by later filters in the filterchain, e.g. in case of
2066 scaling or if another "setdar" or a "setsar" filter is applied.
2068 <p>The filter accepts a parameter string which represents the wanted
2069 display aspect ratio.
2070 The parameter can be a floating point number string, or an expression
2071 of the form <var>num</var>:<var>den</var>, where <var>num</var> and <var>den</var> are the
2072 numerator and denominator of the aspect ratio.
2073 If the parameter is not specified, it is assumed the value "0:1".
2075 <p>For example to change the display aspect ratio to 16:9, specify:
2076 </p><table><tr><td> </td><td><pre class="example">setdar=16:9
2077 # the above is equivalent to
2079 </pre></td></tr></table>
2081 <p>See also the <a href="#setsar">setsar</a> filter documentation.
2083 <a name="setpts"></a>
2084 <h2 class="section"><a href="libavfilter.html#toc-setpts">8.29 setpts</a></h2>
2086 <p>Change the PTS (presentation timestamp) of the input video frames.
2088 <p>Accept in input an expression evaluated through the eval API, which
2089 can contain the following constants:
2091 <dl compact="compact">
2092 <dt> ‘<samp>PTS</samp>’</dt>
2093 <dd><p>the presentation timestamp in input
2096 <dt> ‘<samp>PI</samp>’</dt>
2100 <dt> ‘<samp>PHI</samp>’</dt>
2104 <dt> ‘<samp>E</samp>’</dt>
2108 <dt> ‘<samp>N</samp>’</dt>
2109 <dd><p>the count of the input frame, starting from 0.
2112 <dt> ‘<samp>STARTPTS</samp>’</dt>
2113 <dd><p>the PTS of the first video frame
2116 <dt> ‘<samp>INTERLACED</samp>’</dt>
2117 <dd><p>tell if the current frame is interlaced
2120 <dt> ‘<samp>POS</samp>’</dt>
2121 <dd><p>original position in the file of the frame, or undefined if undefined
2122 for the current frame
2125 <dt> ‘<samp>PREV_INPTS</samp>’</dt>
2126 <dd><p>previous input PTS
2129 <dt> ‘<samp>PREV_OUTPTS</samp>’</dt>
2130 <dd><p>previous output PTS
2135 <p>Some examples follow:
2137 <table><tr><td> </td><td><pre class="example"># start counting PTS from zero
2149 # fixed rate 25 fps with some jitter
2150 setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
2151 </pre></td></tr></table>
2153 <p><a name="setsar"></a>
2154 </p><a name="setsar-1"></a>
2155 <h2 class="section"><a href="libavfilter.html#toc-setsar-1">8.30 setsar</a></h2>
2157 <p>Set the Sample (aka Pixel) Aspect Ratio for the filter output video.
2159 <p>Note that as a consequence of the application of this filter, the
2160 output display aspect ratio will change according to the following
2162 <em>DAR = HORIZONTAL_RESOLUTION / VERTICAL_RESOLUTION * SAR</em>
2164 <p>Keep in mind that the sample aspect ratio set by this filter may be
2165 changed by later filters in the filterchain, e.g. if another "setsar"
2166 or a "setdar" filter is applied.
2168 <p>The filter accepts a parameter string which represents the wanted
2169 sample aspect ratio.
2170 The parameter can be a floating point number string, or an expression
2171 of the form <var>num</var>:<var>den</var>, where <var>num</var> and <var>den</var> are the
2172 numerator and denominator of the aspect ratio.
2173 If the parameter is not specified, it is assumed the value "0:1".
2175 <p>For example to change the sample aspect ratio to 10:11, specify:
2176 </p><table><tr><td> </td><td><pre class="example">setsar=10:11
2177 </pre></td></tr></table>
2179 <a name="settb"></a>
2180 <h2 class="section"><a href="libavfilter.html#toc-settb">8.31 settb</a></h2>
2182 <p>Set the timebase to use for the output frames timestamps.
2183 It is mainly useful for testing timebase configuration.
2185 <p>It accepts in input an arithmetic expression representing a rational.
2186 The expression can contain the constants "PI", "E", "PHI", "AVTB" (the
2187 default timebase), and "intb" (the input timebase).
2189 <p>The default value for the input is "intb".
2191 <p>Follow some examples.
2193 <table><tr><td> </td><td><pre class="example"># set the timebase to 1/25
2196 # set the timebase to 1/10
2199 #set the timebase to 1001/1000
2202 #set the timebase to 2*intb
2205 #set the default timebase value
2207 </pre></td></tr></table>
2209 <a name="showinfo"></a>
2210 <h2 class="section"><a href="libavfilter.html#toc-showinfo">8.32 showinfo</a></h2>
2212 <p>Show a line containing various information for each input video frame.
2213 The input video is not modified.
2215 <p>The shown line contains a sequence of key/value pairs of the form
2216 <var>key</var>:<var>value</var>.
2218 <p>A description of each shown parameter follows:
2220 <dl compact="compact">
2221 <dt> ‘<samp>n</samp>’</dt>
2222 <dd><p>sequential number of the input frame, starting from 0
2225 <dt> ‘<samp>pts</samp>’</dt>
2226 <dd><p>Presentation TimeStamp of the input frame, expressed as a number of
2227 time base units. The time base unit depends on the filter input pad.
2230 <dt> ‘<samp>pts_time</samp>’</dt>
2231 <dd><p>Presentation TimeStamp of the input frame, expressed as a number of
2235 <dt> ‘<samp>pos</samp>’</dt>
2236 <dd><p>position of the frame in the input stream, -1 if this information in
2237 unavailable and/or meanigless (for example in case of synthetic video)
2240 <dt> ‘<samp>fmt</samp>’</dt>
2241 <dd><p>pixel format name
2244 <dt> ‘<samp>sar</samp>’</dt>
2245 <dd><p>sample aspect ratio of the input frame, expressed in the form
2246 <var>num</var>/<var>den</var>
2249 <dt> ‘<samp>s</samp>’</dt>
2250 <dd><p>size of the input frame, expressed in the form
2251 <var>width</var>x<var>height</var>
2254 <dt> ‘<samp>i</samp>’</dt>
2255 <dd><p>interlaced mode ("P" for "progressive", "T" for top field first, "B"
2256 for bottom field first)
2259 <dt> ‘<samp>iskey</samp>’</dt>
2260 <dd><p>1 if the frame is a key frame, 0 otherwise
2263 <dt> ‘<samp>type</samp>’</dt>
2264 <dd><p>picture type of the input frame ("I" for an I-frame, "P" for a
2265 P-frame, "B" for a B-frame, "?" for unknown type).
2266 Check also the documentation of the <code>AVPictureType</code> enum and of
2267 the <code>av_get_picture_type_char</code> function defined in
2268 ‘<tt>libavutil/avutil.h</tt>’.
2271 <dt> ‘<samp>checksum</samp>’</dt>
2272 <dd><p>Adler-32 checksum of all the planes of the input frame
2275 <dt> ‘<samp>plane_checksum</samp>’</dt>
2276 <dd><p>Adler-32 checksum of each plane of the input frame, expressed in the form
2277 "[<var>c0</var> <var>c1</var> <var>c2</var> <var>c3</var>]"
2281 <a name="slicify"></a>
2282 <h2 class="section"><a href="libavfilter.html#toc-slicify">8.33 slicify</a></h2>
2284 <p>Pass the images of input video on to next video filter as multiple
2287 <table><tr><td> </td><td><pre class="example">./ffmpeg -i in.avi -vf "slicify=32" out.avi
2288 </pre></td></tr></table>
2290 <p>The filter accepts the slice height as parameter. If the parameter is
2291 not specified it will use the default value of 16.
2293 <p>Adding this in the beginning of filter chains should make filtering
2294 faster due to better use of the memory cache.
2296 <a name="split"></a>
2297 <h2 class="section"><a href="libavfilter.html#toc-split">8.34 split</a></h2>
2299 <p>Pass on the input video to two outputs. Both outputs are identical to
2303 </p><table><tr><td> </td><td><pre class="example">[in] split [splitout1][splitout2];
2304 [splitout1] crop=100:100:0:0 [cropout];
2305 [splitout2] pad=200:200:100:100 [padout];
2306 </pre></td></tr></table>
2308 <p>will create two separate outputs from the same input, one cropped and
2311 <a name="transpose"></a>
2312 <h2 class="section"><a href="libavfilter.html#toc-transpose">8.35 transpose</a></h2>
2314 <p>Transpose rows with columns in the input video and optionally flip it.
2316 <p>It accepts a parameter representing an integer, which can assume the
2319 <dl compact="compact">
2320 <dt> ‘<samp>0</samp>’</dt>
2321 <dd><p>Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
2322 </p><table><tr><td> </td><td><pre class="example">L.R L.l
2325 </pre></td></tr></table>
2328 <dt> ‘<samp>1</samp>’</dt>
2329 <dd><p>Rotate by 90 degrees clockwise, that is:
2330 </p><table><tr><td> </td><td><pre class="example">L.R l.L
2333 </pre></td></tr></table>
2336 <dt> ‘<samp>2</samp>’</dt>
2337 <dd><p>Rotate by 90 degrees counterclockwise, that is:
2338 </p><table><tr><td> </td><td><pre class="example">L.R R.r
2341 </pre></td></tr></table>
2344 <dt> ‘<samp>3</samp>’</dt>
2345 <dd><p>Rotate by 90 degrees clockwise and vertically flip, that is:
2346 </p><table><tr><td> </td><td><pre class="example">L.R r.R
2349 </pre></td></tr></table>
2353 <a name="unsharp"></a>
2354 <h2 class="section"><a href="libavfilter.html#toc-unsharp">8.36 unsharp</a></h2>
2356 <p>Sharpen or blur the input video.
2358 <p>It accepts the following parameters:
2359 <var>luma_msize_x</var>:<var>luma_msize_y</var>:<var>luma_amount</var>:<var>chroma_msize_x</var>:<var>chroma_msize_y</var>:<var>chroma_amount</var>
2361 <p>Negative values for the amount will blur the input video, while positive
2362 values will sharpen. All parameters are optional and default to the
2363 equivalent of the string ’5:5:1.0:5:5:0.0’.
2365 <dl compact="compact">
2366 <dt> ‘<samp>luma_msize_x</samp>’</dt>
2367 <dd><p>Set the luma matrix horizontal size. It can be an integer between 3
2368 and 13, default value is 5.
2371 <dt> ‘<samp>luma_msize_y</samp>’</dt>
2372 <dd><p>Set the luma matrix vertical size. It can be an integer between 3
2373 and 13, default value is 5.
2376 <dt> ‘<samp>luma_amount</samp>’</dt>
2377 <dd><p>Set the luma effect strength. It can be a float number between -2.0
2378 and 5.0, default value is 1.0.
2381 <dt> ‘<samp>chroma_msize_x</samp>’</dt>
2382 <dd><p>Set the chroma matrix horizontal size. It can be an integer between 3
2383 and 13, default value is 5.
2386 <dt> ‘<samp>chroma_msize_y</samp>’</dt>
2387 <dd><p>Set the chroma matrix vertical size. It can be an integer between 3
2388 and 13, default value is 5.
2391 <dt> ‘<samp>chroma_amount</samp>’</dt>
2392 <dd><p>Set the chroma effect strength. It can be a float number between -2.0
2393 and 5.0, default value is 0.0.
2398 <table><tr><td> </td><td><pre class="example"># Strong luma sharpen effect parameters
2401 # Strong blur of both luma and chroma parameters
2402 unsharp=7:7:-2:7:7:-2
2404 # Use the default values with <code>ffmpeg</code>
2405 ./ffmpeg -i in.avi -vf "unsharp" out.mp4
2406 </pre></td></tr></table>
2408 <a name="vflip"></a>
2409 <h2 class="section"><a href="libavfilter.html#toc-vflip">8.37 vflip</a></h2>
2411 <p>Flip the input video vertically.
2413 <table><tr><td> </td><td><pre class="example">./ffmpeg -i in.avi -vf "vflip" out.avi
2414 </pre></td></tr></table>
2416 <a name="yadif"></a>
2417 <h2 class="section"><a href="libavfilter.html#toc-yadif">8.38 yadif</a></h2>
2419 <p>Deinterlace the input video ("yadif" means "yet another deinterlacing
2422 <p>It accepts the optional parameters: <var>mode</var>:<var>parity</var>:<var>auto</var>.
2424 <p><var>mode</var> specifies the interlacing mode to adopt, accepts one of the
2427 <dl compact="compact">
2428 <dt> ‘<samp>0</samp>’</dt>
2429 <dd><p>output 1 frame for each frame
2431 <dt> ‘<samp>1</samp>’</dt>
2432 <dd><p>output 1 frame for each field
2434 <dt> ‘<samp>2</samp>’</dt>
2435 <dd><p>like 0 but skips spatial interlacing check
2437 <dt> ‘<samp>3</samp>’</dt>
2438 <dd><p>like 1 but skips spatial interlacing check
2442 <p>Default value is 0.
2444 <p><var>parity</var> specifies the picture field parity assumed for the input
2445 interlaced video, accepts one of the following values:
2447 <dl compact="compact">
2448 <dt> ‘<samp>0</samp>’</dt>
2449 <dd><p>assume top field first
2451 <dt> ‘<samp>1</samp>’</dt>
2452 <dd><p>assume bottom field first
2454 <dt> ‘<samp>-1</samp>’</dt>
2455 <dd><p>enable automatic detection
2459 <p>Default value is -1.
2460 If interlacing is unknown or decoder does not export this information,
2461 top field first will be assumed.
2463 <p><var>auto</var> specifies if deinterlacer should trust the interlaced flag
2464 and only deinterlace frames marked as interlaced
2466 <dl compact="compact">
2467 <dt> ‘<samp>0</samp>’</dt>
2468 <dd><p>deinterlace all frames
2470 <dt> ‘<samp>1</samp>’</dt>
2471 <dd><p>only deinterlace frames marked as interlaced
2475 <p>Default value is 0.
2478 <a name="Video-Sources"></a>
2479 <h1 class="chapter"><a href="libavfilter.html#toc-Video-Sources">9. Video Sources</a></h1>
2481 <p>Below is a description of the currently available video sources.
2483 <a name="buffer"></a>
2484 <h2 class="section"><a href="libavfilter.html#toc-buffer">9.1 buffer</a></h2>
2486 <p>Buffer video frames, and make them available to the filter chain.
2488 <p>This source is mainly intended for a programmatic use, in particular
2489 through the interface defined in ‘<tt>libavfilter/vsrc_buffer.h</tt>’.
2491 <p>It accepts the following parameters:
2492 <var>width</var>:<var>height</var>:<var>pix_fmt_string</var>:<var>timebase_num</var>:<var>timebase_den</var>:<var>sample_aspect_ratio_num</var>:<var>sample_aspect_ratio.den</var>:<var>scale_params</var>
2494 <p>All the parameters but <var>scale_params</var> need to be explicitely
2497 <p>Follows the list of the accepted parameters.
2499 <dl compact="compact">
2500 <dt> ‘<samp>width, height</samp>’</dt>
2501 <dd><p>Specify the width and height of the buffered video frames.
2504 <dt> ‘<samp>pix_fmt_string</samp>’</dt>
2505 <dd><p>A string representing the pixel format of the buffered video frames.
2506 It may be a number corresponding to a pixel format, or a pixel format
2510 <dt> ‘<samp>timebase_num, timebase_den</samp>’</dt>
2511 <dd><p>Specify numerator and denomitor of the timebase assumed by the
2512 timestamps of the buffered frames.
2515 <dt> ‘<samp>sample_aspect_ratio.num, sample_aspect_ratio.den</samp>’</dt>
2516 <dd><p>Specify numerator and denominator of the sample aspect ratio assumed
2517 by the video frames.
2520 <dt> ‘<samp>scale_params</samp>’</dt>
2521 <dd><p>Specify the optional parameters to be used for the scale filter which
2522 is automatically inserted when an input change is detected in the
2523 input size or format.
2528 </p><table><tr><td> </td><td><pre class="example">buffer=320:240:yuv410p:1:24:1:1
2529 </pre></td></tr></table>
2531 <p>will instruct the source to accept video frames with size 320x240 and
2532 with format "yuv410p", assuming 1/24 as the timestamps timebase and
2533 square pixels (1:1 sample aspect ratio).
2534 Since the pixel format with name "yuv410p" corresponds to the number 6
2535 (check the enum PixelFormat definition in ‘<tt>libavutil/pixfmt.h</tt>’),
2536 this example corresponds to:
2537 </p><table><tr><td> </td><td><pre class="example">buffer=320:240:6:1:24:1:1
2538 </pre></td></tr></table>
2540 <a name="color"></a>
2541 <h2 class="section"><a href="libavfilter.html#toc-color">9.2 color</a></h2>
2543 <p>Provide an uniformly colored input.
2545 <p>It accepts the following parameters:
2546 <var>color</var>:<var>frame_size</var>:<var>frame_rate</var>
2548 <p>Follows the description of the accepted parameters.
2550 <dl compact="compact">
2551 <dt> ‘<samp>color</samp>’</dt>
2552 <dd><p>Specify the color of the source. It can be the name of a color (case
2553 insensitive match) or a 0xRRGGBB[AA] sequence, possibly followed by an
2554 alpha specifier. The default value is "black".
2557 <dt> ‘<samp>frame_size</samp>’</dt>
2558 <dd><p>Specify the size of the sourced video, it may be a string of the form
2559 <var>width</var>x<var>heigth</var>, or the name of a size abbreviation. The
2560 default value is "320x240".
2563 <dt> ‘<samp>frame_rate</samp>’</dt>
2564 <dd><p>Specify the frame rate of the sourced video, as the number of frames
2565 generated per second. It has to be a string in the format
2566 <var>frame_rate_num</var>/<var>frame_rate_den</var>, an integer number, a float
2567 number or a valid video frame rate abbreviation. The default value is
2573 <p>For example the following graph description will generate a red source
2574 with an opacity of 0.2, with size "qcif" and a frame rate of 10
2575 frames per second, which will be overlayed over the source connected
2576 to the pad with identifier "in".
2578 <table><tr><td> </td><td><pre class="example">"color=red@0.2:qcif:10 [color]; [in][color] overlay [out]"
2579 </pre></td></tr></table>
2581 <a name="movie"></a>
2582 <h2 class="section"><a href="libavfilter.html#toc-movie">9.3 movie</a></h2>
2584 <p>Read a video stream from a movie container.
2586 <p>It accepts the syntax: <var>movie_name</var>[:<var>options</var>] where
2587 <var>movie_name</var> is the name of the resource to read (not necessarily
2588 a file but also a device or a stream accessed through some protocol),
2589 and <var>options</var> is an optional sequence of <var>key</var>=<var>value</var>
2590 pairs, separated by ":".
2592 <p>The description of the accepted options follows.
2594 <dl compact="compact">
2595 <dt> ‘<samp>format_name, f</samp>’</dt>
2596 <dd><p>Specifies the format assumed for the movie to read, and can be either
2597 the name of a container or an input device. If not specified the
2598 format is guessed from <var>movie_name</var> or by probing.
2601 <dt> ‘<samp>seek_point, sp</samp>’</dt>
2602 <dd><p>Specifies the seek point in seconds, the frames will be output
2603 starting from this seek point, the parameter is evaluated with
2604 <code>av_strtod</code> so the numerical value may be suffixed by an IS
2605 postfix. Default value is "0".
2608 <dt> ‘<samp>stream_index, si</samp>’</dt>
2609 <dd><p>Specifies the index of the video stream to read. If the value is -1,
2610 the best suited video stream will be automatically selected. Default
2611 value is "-1".
2616 <p>This filter allows to overlay a second video on top of main input of
2617 a filtergraph as shown in this graph:
2618 </p><table><tr><td> </td><td><pre class="example">input -----------> deltapts0 --> overlay --> output
2621 movie --> scale--> deltapts1 -------+
2622 </pre></td></tr></table>
2624 <p>Some examples follow:
2625 </p><table><tr><td> </td><td><pre class="example"># skip 3.2 seconds from the start of the avi file in.avi, and overlay it
2626 # on top of the input labelled as "in".
2627 movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [movie];
2628 [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
2630 # read from a video4linux2 device, and overlay it on top of the input
2631 # labelled as "in"
2632 movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [movie];
2633 [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
2635 </pre></td></tr></table>
2637 <a name="mptestsrc"></a>
2638 <h2 class="section"><a href="libavfilter.html#toc-mptestsrc">9.4 mptestsrc</a></h2>
2640 <p>Generate various test patterns, as generated by the MPlayer test filter.
2642 <p>The size of the generated video is fixed, and is 256x256.
2643 This source is useful in particular for testing encoding features.
2645 <p>This source accepts an optional sequence of <var>key</var>=<var>value</var> pairs,
2646 separated by ":". The description of the accepted options follows.
2648 <dl compact="compact">
2649 <dt> ‘<samp>rate, r</samp>’</dt>
2650 <dd><p>Specify the frame rate of the sourced video, as the number of frames
2651 generated per second. It has to be a string in the format
2652 <var>frame_rate_num</var>/<var>frame_rate_den</var>, an integer number, a float
2653 number or a valid video frame rate abbreviation. The default value is
2657 <dt> ‘<samp>duration, d</samp>’</dt>
2658 <dd><p>Set the video duration of the sourced video. The accepted syntax is:
2659 </p><table><tr><td> </td><td><pre class="example">[-]HH[:MM[:SS[.m...]]]
2661 </pre></td></tr></table>
2662 <p>See also the function <code>av_parse_time()</code>.
2664 <p>If not specified, or the expressed duration is negative, the video is
2665 supposed to be generated forever.
2668 <dt> ‘<samp>test, t</samp>’</dt>
2670 <p>Set the number or the name of the test to perform. Supported tests are:
2671 </p><dl compact="compact">
2672 <dt> ‘<samp>dc_luma</samp>’</dt>
2673 <dt> ‘<samp>dc_chroma</samp>’</dt>
2674 <dt> ‘<samp>freq_luma</samp>’</dt>
2675 <dt> ‘<samp>freq_chroma</samp>’</dt>
2676 <dt> ‘<samp>amp_luma</samp>’</dt>
2677 <dt> ‘<samp>amp_chroma</samp>’</dt>
2678 <dt> ‘<samp>cbp</samp>’</dt>
2679 <dt> ‘<samp>mv</samp>’</dt>
2680 <dt> ‘<samp>ring1</samp>’</dt>
2681 <dt> ‘<samp>ring2</samp>’</dt>
2682 <dt> ‘<samp>all</samp>’</dt>
2685 <p>Default value is "all", which will cycle through the list of all tests.
2689 <p>For example the following:
2690 </p><table><tr><td> </td><td><pre class="example">testsrc=t=dc_luma
2691 </pre></td></tr></table>
2693 <p>will generate a "dc_luma" test pattern.
2695 <a name="nullsrc"></a>
2696 <h2 class="section"><a href="libavfilter.html#toc-nullsrc">9.5 nullsrc</a></h2>
2698 <p>Null video source, never return images. It is mainly useful as a
2699 template and to be employed in analysis / debugging tools.
2701 <p>It accepts as optional parameter a string of the form
2702 <var>width</var>:<var>height</var>:<var>timebase</var>.
2704 <p><var>width</var> and <var>height</var> specify the size of the configured
2705 source. The default values of <var>width</var> and <var>height</var> are
2706 respectively 352 and 288 (corresponding to the CIF size format).
2708 <p><var>timebase</var> specifies an arithmetic expression representing a
2709 timebase. The expression can contain the constants "PI", "E", "PHI",
2710 "AVTB" (the default timebase), and defaults to the value "AVTB".
2712 <a name="frei0r_005fsrc"></a>
2713 <h2 class="section"><a href="libavfilter.html#toc-frei0r_005fsrc">9.6 frei0r_src</a></h2>
2715 <p>Provide a frei0r source.
2717 <p>To enable compilation of this filter you need to install the frei0r
2718 header and configure FFmpeg with –enable-frei0r.
2720 <p>The source supports the syntax:
2721 </p><table><tr><td> </td><td><pre class="example"><var>size</var>:<var>rate</var>:<var>src_name</var>[{=|:}<var>param1</var>:<var>param2</var>:...:<var>paramN</var>]
2722 </pre></td></tr></table>
2724 <p><var>size</var> is the size of the video to generate, may be a string of the
2725 form <var>width</var>x<var>height</var> or a frame size abbreviation.
2726 <var>rate</var> is the rate of the video to generate, may be a string of
2727 the form <var>num</var>/<var>den</var> or a frame rate abbreviation.
2728 <var>src_name</var> is the name to the frei0r source to load. For more
2729 information regarding frei0r and how to set the parameters read the
2730 section <a href="#frei0r">frei0r</a> in the description of the video filters.
2732 <p>Some examples follow:
2733 </p><table><tr><td> </td><td><pre class="example"># generate a frei0r partik0l source with size 200x200 and framerate 10
2734 # which is overlayed on the overlay filter main input
2735 frei0r_src=200x200:10:partik0l=1234 [overlay]; [in][overlay] overlay
2736 </pre></td></tr></table>
2738 <a name="rgbtestsrc_002c-testsrc"></a>
2739 <h2 class="section"><a href="libavfilter.html#toc-rgbtestsrc_002c-testsrc">9.7 rgbtestsrc, testsrc</a></h2>
2741 <p>The <code>rgbtestsrc</code> source generates an RGB test pattern useful for
2742 detecting RGB vs BGR issues. You should see a red, green and blue
2743 stripe from top to bottom.
2745 <p>The <code>testsrc</code> source generates a test video pattern, showing a
2746 color pattern, a scrolling gradient and a timestamp. This is mainly
2747 intended for testing purposes.
2749 <p>Both sources accept an optional sequence of <var>key</var>=<var>value</var> pairs,
2750 separated by ":". The description of the accepted options follows.
2752 <dl compact="compact">
2753 <dt> ‘<samp>size, s</samp>’</dt>
2754 <dd><p>Specify the size of the sourced video, it may be a string of the form
2755 <var>width</var>x<var>heigth</var>, or the name of a size abbreviation. The
2756 default value is "320x240".
2759 <dt> ‘<samp>rate, r</samp>’</dt>
2760 <dd><p>Specify the frame rate of the sourced video, as the number of frames
2761 generated per second. It has to be a string in the format
2762 <var>frame_rate_num</var>/<var>frame_rate_den</var>, an integer number, a float
2763 number or a valid video frame rate abbreviation. The default value is
2767 <dt> ‘<samp>sar</samp>’</dt>
2768 <dd><p>Set the sample aspect ratio of the sourced video.
2771 <dt> ‘<samp>duration</samp>’</dt>
2772 <dd><p>Set the video duration of the sourced video. The accepted syntax is:
2773 </p><table><tr><td> </td><td><pre class="example">[-]HH[:MM[:SS[.m...]]]
2775 </pre></td></tr></table>
2776 <p>See also the function <code>av_parse_time()</code>.
2778 <p>If not specified, or the expressed duration is negative, the video is
2779 supposed to be generated forever.
2783 <p>For example the following:
2784 </p><table><tr><td> </td><td><pre class="example">testsrc=duration=5.3:size=qcif:rate=10
2785 </pre></td></tr></table>
2787 <p>will generate a video with a duration of 5.3 seconds, with size
2788 176x144 and a framerate of 10 frames per second.
2791 <a name="Video-Sinks"></a>
2792 <h1 class="chapter"><a href="libavfilter.html#toc-Video-Sinks">10. Video Sinks</a></h1>
2794 <p>Below is a description of the currently available video sinks.
2796 <a name="buffersink"></a>
2797 <h2 class="section"><a href="libavfilter.html#toc-buffersink">10.1 buffersink</a></h2>
2799 <p>Buffer video frames, and make them available to the end of the filter
2802 <p>This sink is mainly intended for a programmatic use, in particular
2803 through the interface defined in ‘<tt>libavfilter/vsink_buffer.h</tt>’.
2805 <p>It does not require a string parameter in input, but you need to
2806 specify a pointer to a list of supported pixel formats terminated by
2807 -1 in the opaque parameter provided to <code>avfilter_init_filter</code>
2808 when initializing this sink.
2810 <a name="nullsink"></a>
2811 <h2 class="section"><a href="libavfilter.html#toc-nullsink">10.2 nullsink</a></h2>
2813 <p>Null video sink, do absolutely nothing with the input video. It is
2814 mainly useful as a template and to be employed in analysis / debugging
2822 This document was generated by <em>Kyle Schwarz</em> on <em>September 2, 2011</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.82</em></a>.