You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4194 lines
119KB

  1. @chapter Filtering Introduction
  2. @c man begin FILTERING INTRODUCTION
  3. Filtering in FFmpeg is enabled through the libavfilter library.
  4. Libavfilter is the filtering API of FFmpeg. It is the substitute of
  5. the now deprecated 'vhooks' and started as a Google Summer of Code
  6. project.
  7. Audio filtering integration into the main FFmpeg repository is a work in
  8. progress, so audio API and ABI should not be considered stable yet.
  9. In libavfilter, it is possible for filters to have multiple inputs and
  10. multiple outputs.
  11. To illustrate the sorts of things that are possible, we can
  12. use a complex filter graph. For example, the following one:
  13. @example
  14. input --> split --> fifo -----------------------> overlay --> output
  15. | ^
  16. | |
  17. +------> fifo --> crop --> vflip --------+
  18. @end example
  19. splits the stream in two streams, sends one stream through the crop filter
  20. and the vflip filter before merging it back with the other stream by
  21. overlaying it on top. You can use the following command to achieve this:
  22. @example
  23. ffmpeg -i input -vf "[in] split [T1], fifo, [T2] overlay=0:H/2 [out]; [T1] fifo, crop=iw:ih/2:0:ih/2, vflip [T2]" output
  24. @end example
  25. The result will be that in output the top half of the video is mirrored
  26. onto the bottom half.
  27. Filters are loaded using the @var{-vf} or @var{-af} option passed to
  28. @command{ffmpeg} or to @command{ffplay}. Filters in the same linear
  29. chain are separated by commas. In our example, @var{split, fifo,
  30. overlay} are in one linear chain, and @var{fifo, crop, vflip} are in
  31. another. The points where the linear chains join are labeled by names
  32. enclosed in square brackets. In our example, that is @var{[T1]} and
  33. @var{[T2]}. The special labels @var{[in]} and @var{[out]} are the points
  34. where video is input and output.
  35. Some filters take in input a list of parameters: they are specified
  36. after the filter name and an equal sign, and are separated from each other
  37. by a colon.
  38. There exist so-called @var{source filters} that do not have an
  39. audio/video input, and @var{sink filters} that will not have audio/video
  40. output.
  41. @c man end FILTERING INTRODUCTION
  42. @chapter graph2dot
  43. @c man begin GRAPH2DOT
  44. The @file{graph2dot} program included in the FFmpeg @file{tools}
  45. directory can be used to parse a filter graph description and issue a
  46. corresponding textual representation in the dot language.
  47. Invoke the command:
  48. @example
  49. graph2dot -h
  50. @end example
  51. to see how to use @file{graph2dot}.
  52. You can then pass the dot description to the @file{dot} program (from
  53. the graphviz suite of programs) and obtain a graphical representation
  54. of the filter graph.
  55. For example the sequence of commands:
  56. @example
  57. echo @var{GRAPH_DESCRIPTION} | \
  58. tools/graph2dot -o graph.tmp && \
  59. dot -Tpng graph.tmp -o graph.png && \
  60. display graph.png
  61. @end example
  62. can be used to create and display an image representing the graph
  63. described by the @var{GRAPH_DESCRIPTION} string.
  64. @c man end GRAPH2DOT
  65. @chapter Filtergraph description
  66. @c man begin FILTERGRAPH DESCRIPTION
  67. A filtergraph is a directed graph of connected filters. It can contain
  68. cycles, and there can be multiple links between a pair of
  69. filters. Each link has one input pad on one side connecting it to one
  70. filter from which it takes its input, and one output pad on the other
  71. side connecting it to the one filter accepting its output.
  72. Each filter in a filtergraph is an instance of a filter class
  73. registered in the application, which defines the features and the
  74. number of input and output pads of the filter.
  75. A filter with no input pads is called a "source", a filter with no
  76. output pads is called a "sink".
  77. @anchor{Filtergraph syntax}
  78. @section Filtergraph syntax
  79. A filtergraph can be represented using a textual representation, which is
  80. recognized by the @option{-filter}/@option{-vf} and @option{-filter_complex}
  81. options in @command{ffmpeg} and @option{-vf} in @command{ffplay}, and by the
  82. @code{avfilter_graph_parse()}/@code{avfilter_graph_parse2()} function defined in
  83. @file{libavfilter/avfiltergraph.h}.
  84. A filterchain consists of a sequence of connected filters, each one
  85. connected to the previous one in the sequence. A filterchain is
  86. represented by a list of ","-separated filter descriptions.
  87. A filtergraph consists of a sequence of filterchains. A sequence of
  88. filterchains is represented by a list of ";"-separated filterchain
  89. descriptions.
  90. A filter is represented by a string of the form:
  91. [@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
  92. @var{filter_name} is the name of the filter class of which the
  93. described filter is an instance of, and has to be the name of one of
  94. the filter classes registered in the program.
  95. The name of the filter class is optionally followed by a string
  96. "=@var{arguments}".
  97. @var{arguments} is a string which contains the parameters used to
  98. initialize the filter instance, and are described in the filter
  99. descriptions below.
  100. The list of arguments can be quoted using the character "'" as initial
  101. and ending mark, and the character '\' for escaping the characters
  102. within the quoted text; otherwise the argument string is considered
  103. terminated when the next special character (belonging to the set
  104. "[]=;,") is encountered.
  105. The name and arguments of the filter are optionally preceded and
  106. followed by a list of link labels.
  107. A link label allows to name a link and associate it to a filter output
  108. or input pad. The preceding labels @var{in_link_1}
  109. ... @var{in_link_N}, are associated to the filter input pads,
  110. the following labels @var{out_link_1} ... @var{out_link_M}, are
  111. associated to the output pads.
  112. When two link labels with the same name are found in the
  113. filtergraph, a link between the corresponding input and output pad is
  114. created.
  115. If an output pad is not labelled, it is linked by default to the first
  116. unlabelled input pad of the next filter in the filterchain.
  117. For example in the filterchain:
  118. @example
  119. nullsrc, split[L1], [L2]overlay, nullsink
  120. @end example
  121. the split filter instance has two output pads, and the overlay filter
  122. instance two input pads. The first output pad of split is labelled
  123. "L1", the first input pad of overlay is labelled "L2", and the second
  124. output pad of split is linked to the second input pad of overlay,
  125. which are both unlabelled.
  126. In a complete filterchain all the unlabelled filter input and output
  127. pads must be connected. A filtergraph is considered valid if all the
  128. filter input and output pads of all the filterchains are connected.
  129. Libavfilter will automatically insert scale filters where format
  130. conversion is required. It is possible to specify swscale flags
  131. for those automatically inserted scalers by prepending
  132. @code{sws_flags=@var{flags};}
  133. to the filtergraph description.
  134. Follows a BNF description for the filtergraph syntax:
  135. @example
  136. @var{NAME} ::= sequence of alphanumeric characters and '_'
  137. @var{LINKLABEL} ::= "[" @var{NAME} "]"
  138. @var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
  139. @var{FILTER_ARGUMENTS} ::= sequence of chars (eventually quoted)
  140. @var{FILTER} ::= [@var{LINKNAMES}] @var{NAME} ["=" @var{ARGUMENTS}] [@var{LINKNAMES}]
  141. @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
  142. @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
  143. @end example
  144. @c man end FILTERGRAPH DESCRIPTION
  145. @chapter Audio Filters
  146. @c man begin AUDIO FILTERS
  147. When you configure your FFmpeg build, you can disable any of the
  148. existing filters using @code{--disable-filters}.
  149. The configure output will show the audio filters included in your
  150. build.
  151. Below is a description of the currently available audio filters.
  152. @section aconvert
  153. Convert the input audio format to the specified formats.
  154. The filter accepts a string of the form:
  155. "@var{sample_format}:@var{channel_layout}".
  156. @var{sample_format} specifies the sample format, and can be a string or the
  157. corresponding numeric value defined in @file{libavutil/samplefmt.h}. Use 'p'
  158. suffix for a planar sample format.
  159. @var{channel_layout} specifies the channel layout, and can be a string
  160. or the corresponding number value defined in @file{libavutil/audioconvert.h}.
  161. The special parameter "auto", signifies that the filter will
  162. automatically select the output format depending on the output filter.
  163. Some examples follow.
  164. @itemize
  165. @item
  166. Convert input to float, planar, stereo:
  167. @example
  168. aconvert=fltp:stereo
  169. @end example
  170. @item
  171. Convert input to unsigned 8-bit, automatically select out channel layout:
  172. @example
  173. aconvert=u8:auto
  174. @end example
  175. @end itemize
  176. @section aformat
  177. Convert the input audio to one of the specified formats. The framework will
  178. negotiate the most appropriate format to minimize conversions.
  179. The filter accepts the following named parameters:
  180. @table @option
  181. @item sample_fmts
  182. A comma-separated list of requested sample formats.
  183. @item sample_rates
  184. A comma-separated list of requested sample rates.
  185. @item channel_layouts
  186. A comma-separated list of requested channel layouts.
  187. @end table
  188. If a parameter is omitted, all values are allowed.
  189. For example to force the output to either unsigned 8-bit or signed 16-bit stereo:
  190. @example
  191. aformat=sample_fmts\=u8\,s16:channel_layouts\=stereo
  192. @end example
  193. @section amerge
  194. Merge two or more audio streams into a single multi-channel stream.
  195. The filter accepts the following named options:
  196. @table @option
  197. @item inputs
  198. Set the number of inputs. Default is 2.
  199. @end table
  200. If the channel layouts of the inputs are disjoint, and therefore compatible,
  201. the channel layout of the output will be set accordingly and the channels
  202. will be reordered as necessary. If the channel layouts of the inputs are not
  203. disjoint, the output will have all the channels of the first input then all
  204. the channels of the second input, in that order, and the channel layout of
  205. the output will be the default value corresponding to the total number of
  206. channels.
  207. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  208. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  209. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  210. first input, b1 is the first channel of the second input).
  211. On the other hand, if both input are in stereo, the output channels will be
  212. in the default order: a1, a2, b1, b2, and the channel layout will be
  213. arbitrarily set to 4.0, which may or may not be the expected value.
  214. All inputs must have the same sample rate, and format.
  215. If inputs do not have the same duration, the output will stop with the
  216. shortest.
  217. Example: merge two mono files into a stereo stream:
  218. @example
  219. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  220. @end example
  221. Example: multiple merges:
  222. @example
  223. ffmpeg -f lavfi -i "
  224. amovie=input.mkv:si=0 [a0];
  225. amovie=input.mkv:si=1 [a1];
  226. amovie=input.mkv:si=2 [a2];
  227. amovie=input.mkv:si=3 [a3];
  228. amovie=input.mkv:si=4 [a4];
  229. amovie=input.mkv:si=5 [a5];
  230. [a0][a1][a2][a3][a4][a5] amerge=inputs=6" -c:a pcm_s16le output.mkv
  231. @end example
  232. @section amix
  233. Mixes multiple audio inputs into a single output.
  234. For example
  235. @example
  236. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  237. @end example
  238. will mix 3 input audio streams to a single output with the same duration as the
  239. first input and a dropout transition time of 3 seconds.
  240. The filter accepts the following named parameters:
  241. @table @option
  242. @item inputs
  243. Number of inputs. If unspecified, it defaults to 2.
  244. @item duration
  245. How to determine the end-of-stream.
  246. @table @option
  247. @item longest
  248. Duration of longest input. (default)
  249. @item shortest
  250. Duration of shortest input.
  251. @item first
  252. Duration of first input.
  253. @end table
  254. @item dropout_transition
  255. Transition time, in seconds, for volume renormalization when an input
  256. stream ends. The default value is 2 seconds.
  257. @end table
  258. @section anull
  259. Pass the audio source unchanged to the output.
  260. @section aresample
  261. Resample the input audio to the specified sample rate.
  262. The filter accepts exactly one parameter, the output sample rate. If not
  263. specified then the filter will automatically convert between its input
  264. and output sample rates.
  265. For example, to resample the input audio to 44100Hz:
  266. @example
  267. aresample=44100
  268. @end example
  269. @section asetnsamples
  270. Set the number of samples per each output audio frame.
  271. The last output packet may contain a different number of samples, as
  272. the filter will flush all the remaining samples when the input audio
  273. signal its end.
  274. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  275. separated by ":".
  276. @table @option
  277. @item nb_out_samples, n
  278. Set the number of frames per each output audio frame. The number is
  279. intended as the number of samples @emph{per each channel}.
  280. Default value is 1024.
  281. @item pad, p
  282. If set to 1, the filter will pad the last audio frame with zeroes, so
  283. that the last frame will contain the same number of samples as the
  284. previous ones. Default value is 1.
  285. @end table
  286. For example, to set the number of per-frame samples to 1234 and
  287. disable padding for the last frame, use:
  288. @example
  289. asetnsamples=n=1234:p=0
  290. @end example
  291. @section ashowinfo
  292. Show a line containing various information for each input audio frame.
  293. The input audio is not modified.
  294. The shown line contains a sequence of key/value pairs of the form
  295. @var{key}:@var{value}.
  296. A description of each shown parameter follows:
  297. @table @option
  298. @item n
  299. sequential number of the input frame, starting from 0
  300. @item pts
  301. presentation TimeStamp of the input frame, expressed as a number of
  302. time base units. The time base unit depends on the filter input pad, and
  303. is usually 1/@var{sample_rate}.
  304. @item pts_time
  305. presentation TimeStamp of the input frame, expressed as a number of
  306. seconds
  307. @item pos
  308. position of the frame in the input stream, -1 if this information in
  309. unavailable and/or meaningless (for example in case of synthetic audio)
  310. @item fmt
  311. sample format name
  312. @item chlayout
  313. channel layout description
  314. @item nb_samples
  315. number of samples (per each channel) contained in the filtered frame
  316. @item rate
  317. sample rate for the audio frame
  318. @item checksum
  319. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  320. @item plane_checksum
  321. Adler-32 checksum (printed in hexadecimal) for each input frame plane,
  322. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3} @var{c4} @var{c5}
  323. @var{c6} @var{c7}]"
  324. @end table
  325. @section asplit
  326. Split input audio into several identical outputs.
  327. The filter accepts a single parameter which specifies the number of outputs. If
  328. unspecified, it defaults to 2.
  329. For example:
  330. @example
  331. [in] asplit [out0][out1]
  332. @end example
  333. will create two separate outputs from the same input.
  334. To create 3 or more outputs, you need to specify the number of
  335. outputs, like in:
  336. @example
  337. [in] asplit=3 [out0][out1][out2]
  338. @end example
  339. @example
  340. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  341. @end example
  342. will create 5 copies of the input audio.
  343. @section astreamsync
  344. Forward two audio streams and control the order the buffers are forwarded.
  345. The argument to the filter is an expression deciding which stream should be
  346. forwarded next: if the result is negative, the first stream is forwarded; if
  347. the result is positive or zero, the second stream is forwarded. It can use
  348. the following variables:
  349. @table @var
  350. @item b1 b2
  351. number of buffers forwarded so far on each stream
  352. @item s1 s2
  353. number of samples forwarded so far on each stream
  354. @item t1 t2
  355. current timestamp of each stream
  356. @end table
  357. The default value is @code{t1-t2}, which means to always forward the stream
  358. that has a smaller timestamp.
  359. Example: stress-test @code{amerge} by randomly sending buffers on the wrong
  360. input, while avoiding too much of a desynchronization:
  361. @example
  362. amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
  363. [a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
  364. [a2] [b2] amerge
  365. @end example
  366. @section atempo
  367. Adjust audio tempo.
  368. The filter accepts exactly one parameter, the audio tempo. If not
  369. specified then the filter will assume nominal 1.0 tempo. Tempo must
  370. be in the [0.5, 2.0] range.
  371. For example, to slow down audio to 80% tempo:
  372. @example
  373. atempo=0.8
  374. @end example
  375. For example, to speed up audio to 125% tempo:
  376. @example
  377. atempo=1.25
  378. @end example
  379. @section earwax
  380. Make audio easier to listen to on headphones.
  381. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  382. so that when listened to on headphones the stereo image is moved from
  383. inside your head (standard for headphones) to outside and in front of
  384. the listener (standard for speakers).
  385. Ported from SoX.
  386. @section pan
  387. Mix channels with specific gain levels. The filter accepts the output
  388. channel layout followed by a set of channels definitions.
  389. This filter is also designed to remap efficiently the channels of an audio
  390. stream.
  391. The filter accepts parameters of the form:
  392. "@var{l}:@var{outdef}:@var{outdef}:..."
  393. @table @option
  394. @item l
  395. output channel layout or number of channels
  396. @item outdef
  397. output channel specification, of the form:
  398. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  399. @item out_name
  400. output channel to define, either a channel name (FL, FR, etc.) or a channel
  401. number (c0, c1, etc.)
  402. @item gain
  403. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  404. @item in_name
  405. input channel to use, see out_name for details; it is not possible to mix
  406. named and numbered input channels
  407. @end table
  408. If the `=' in a channel specification is replaced by `<', then the gains for
  409. that specification will be renormalized so that the total is 1, thus
  410. avoiding clipping noise.
  411. @subsection Mixing examples
  412. For example, if you want to down-mix from stereo to mono, but with a bigger
  413. factor for the left channel:
  414. @example
  415. pan=1:c0=0.9*c0+0.1*c1
  416. @end example
  417. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  418. 7-channels surround:
  419. @example
  420. pan=stereo: FL < FL + 0.5*FC + 0.6*BL + 0.6*SL : FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  421. @end example
  422. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  423. that should be preferred (see "-ac" option) unless you have very specific
  424. needs.
  425. @subsection Remapping examples
  426. The channel remapping will be effective if, and only if:
  427. @itemize
  428. @item gain coefficients are zeroes or ones,
  429. @item only one input per channel output,
  430. @end itemize
  431. If all these conditions are satisfied, the filter will notify the user ("Pure
  432. channel mapping detected"), and use an optimized and lossless method to do the
  433. remapping.
  434. For example, if you have a 5.1 source and want a stereo audio stream by
  435. dropping the extra channels:
  436. @example
  437. pan="stereo: c0=FL : c1=FR"
  438. @end example
  439. Given the same source, you can also switch front left and front right channels
  440. and keep the input channel layout:
  441. @example
  442. pan="5.1: c0=c1 : c1=c0 : c2=c2 : c3=c3 : c4=c4 : c5=c5"
  443. @end example
  444. If the input is a stereo audio stream, you can mute the front left channel (and
  445. still keep the stereo channel layout) with:
  446. @example
  447. pan="stereo:c1=c1"
  448. @end example
  449. Still with a stereo audio stream input, you can copy the right channel in both
  450. front left and right:
  451. @example
  452. pan="stereo: c0=FR : c1=FR"
  453. @end example
  454. @section silencedetect
  455. Detect silence in an audio stream.
  456. This filter logs a message when it detects that the input audio volume is less
  457. or equal to a noise tolerance value for a duration greater or equal to the
  458. minimum detected noise duration.
  459. The printed times and duration are expressed in seconds.
  460. @table @option
  461. @item duration, d
  462. Set silence duration until notification (default is 2 seconds).
  463. @item noise, n
  464. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  465. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  466. @end table
  467. Detect 5 seconds of silence with -50dB noise tolerance:
  468. @example
  469. silencedetect=n=-50dB:d=5
  470. @end example
  471. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  472. tolerance in @file{silence.mp3}:
  473. @example
  474. ffmpeg -f lavfi -i amovie=silence.mp3,silencedetect=noise=0.0001 -f null -
  475. @end example
  476. @section volume
  477. Adjust the input audio volume.
  478. The filter accepts exactly one parameter @var{vol}, which expresses
  479. how the audio volume will be increased or decreased.
  480. Output values are clipped to the maximum value.
  481. If @var{vol} is expressed as a decimal number, the output audio
  482. volume is given by the relation:
  483. @example
  484. @var{output_volume} = @var{vol} * @var{input_volume}
  485. @end example
  486. If @var{vol} is expressed as a decimal number followed by the string
  487. "dB", the value represents the requested change in decibels of the
  488. input audio power, and the output audio volume is given by the
  489. relation:
  490. @example
  491. @var{output_volume} = 10^(@var{vol}/20) * @var{input_volume}
  492. @end example
  493. Otherwise @var{vol} is considered an expression and its evaluated
  494. value is used for computing the output audio volume according to the
  495. first relation.
  496. Default value for @var{vol} is 1.0.
  497. @subsection Examples
  498. @itemize
  499. @item
  500. Half the input audio volume:
  501. @example
  502. volume=0.5
  503. @end example
  504. The above example is equivalent to:
  505. @example
  506. volume=1/2
  507. @end example
  508. @item
  509. Decrease input audio power by 12 decibels:
  510. @example
  511. volume=-12dB
  512. @end example
  513. @end itemize
  514. @section asyncts
  515. Synchronize audio data with timestamps by squeezing/stretching it and/or
  516. dropping samples/adding silence when needed.
  517. The filter accepts the following named parameters:
  518. @table @option
  519. @item compensate
  520. Enable stretching/squeezing the data to make it match the timestamps.
  521. @item min_delta
  522. Minimum difference between timestamps and audio data (in seconds) to trigger
  523. adding/dropping samples.
  524. @item max_comp
  525. Maximum compensation in samples per second.
  526. @end table
  527. @section channelsplit
  528. Split each channel in input audio stream into a separate output stream.
  529. This filter accepts the following named parameters:
  530. @table @option
  531. @item channel_layout
  532. Channel layout of the input stream. Default is "stereo".
  533. @end table
  534. For example, assuming a stereo input MP3 file
  535. @example
  536. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  537. @end example
  538. will create an output Matroska file with two audio streams, one containing only
  539. the left channel and the other the right channel.
  540. To split a 5.1 WAV file into per-channel files
  541. @example
  542. ffmpeg -i in.wav -filter_complex
  543. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  544. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  545. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  546. side_right.wav
  547. @end example
  548. @section channelmap
  549. Remap input channels to new locations.
  550. This filter accepts the following named parameters:
  551. @table @option
  552. @item channel_layout
  553. Channel layout of the output stream.
  554. @item map
  555. Map channels from input to output. The argument is a comma-separated list of
  556. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  557. @var{in_channel} form. @var{in_channel} can be either the name of the input
  558. channel (e.g. FL for front left) or its index in the input channel layout.
  559. @var{out_channel} is the name of the output channel or its index in the output
  560. channel layout. If @var{out_channel} is not given then it is implicitly an
  561. index, starting with zero and increasing by one for each mapping.
  562. @end table
  563. If no mapping is present, the filter will implicitly map input channels to
  564. output channels preserving index.
  565. For example, assuming a 5.1+downmix input MOV file
  566. @example
  567. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL\,DR-FR' out.wav
  568. @end example
  569. will create an output WAV file tagged as stereo from the downmix channels of
  570. the input.
  571. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  572. @example
  573. ffmpeg -i in.wav -filter 'channelmap=1\,2\,0\,5\,3\,4:channel_layout=5.1' out.wav
  574. @end example
  575. @section join
  576. Join multiple input streams into one multi-channel stream.
  577. The filter accepts the following named parameters:
  578. @table @option
  579. @item inputs
  580. Number of input streams. Defaults to 2.
  581. @item channel_layout
  582. Desired output channel layout. Defaults to stereo.
  583. @item map
  584. Map channels from inputs to output. The argument is a comma-separated list of
  585. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  586. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  587. can be either the name of the input channel (e.g. FL for front left) or its
  588. index in the specified input stream. @var{out_channel} is the name of the output
  589. channel.
  590. @end table
  591. The filter will attempt to guess the mappings when those are not specified
  592. explicitly. It does so by first trying to find an unused matching input channel
  593. and if that fails it picks the first unused input channel.
  594. E.g. to join 3 inputs (with properly set channel layouts)
  595. @example
  596. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  597. @end example
  598. To build a 5.1 output from 6 single-channel streams:
  599. @example
  600. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  601. 'join=inputs=6:channel_layout=5.1:map=0.0-FL\,1.0-FR\,2.0-FC\,3.0-SL\,4.0-SR\,5.0-LFE'
  602. out
  603. @end example
  604. @section resample
  605. Convert the audio sample format, sample rate and channel layout. This filter is
  606. not meant to be used directly.
  607. @c man end AUDIO FILTERS
  608. @chapter Audio Sources
  609. @c man begin AUDIO SOURCES
  610. Below is a description of the currently available audio sources.
  611. @section abuffer
  612. Buffer audio frames, and make them available to the filter chain.
  613. This source is mainly intended for a programmatic use, in particular
  614. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  615. It accepts the following mandatory parameters:
  616. @var{sample_rate}:@var{sample_fmt}:@var{channel_layout}
  617. @table @option
  618. @item sample_rate
  619. The sample rate of the incoming audio buffers.
  620. @item sample_fmt
  621. The sample format of the incoming audio buffers.
  622. Either a sample format name or its corresponging integer representation from
  623. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  624. @item channel_layout
  625. The channel layout of the incoming audio buffers.
  626. Either a channel layout name from channel_layout_map in
  627. @file{libavutil/audioconvert.c} or its corresponding integer representation
  628. from the AV_CH_LAYOUT_* macros in @file{libavutil/audioconvert.h}
  629. @end table
  630. For example:
  631. @example
  632. abuffer=44100:s16p:stereo
  633. @end example
  634. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  635. Since the sample format with name "s16p" corresponds to the number
  636. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  637. equivalent to:
  638. @example
  639. abuffer=44100:6:0x3
  640. @end example
  641. @section aevalsrc
  642. Generate an audio signal specified by an expression.
  643. This source accepts in input one or more expressions (one for each
  644. channel), which are evaluated and used to generate a corresponding
  645. audio signal.
  646. It accepts the syntax: @var{exprs}[::@var{options}].
  647. @var{exprs} is a list of expressions separated by ":", one for each
  648. separate channel. In case the @var{channel_layout} is not
  649. specified, the selected channel layout depends on the number of
  650. provided expressions.
  651. @var{options} is an optional sequence of @var{key}=@var{value} pairs,
  652. separated by ":".
  653. The description of the accepted options follows.
  654. @table @option
  655. @item channel_layout, c
  656. Set the channel layout. The number of channels in the specified layout
  657. must be equal to the number of specified expressions.
  658. @item duration, d
  659. Set the minimum duration of the sourced audio. See the function
  660. @code{av_parse_time()} for the accepted format.
  661. Note that the resulting duration may be greater than the specified
  662. duration, as the generated audio is always cut at the end of a
  663. complete frame.
  664. If not specified, or the expressed duration is negative, the audio is
  665. supposed to be generated forever.
  666. @item nb_samples, n
  667. Set the number of samples per channel per each output frame,
  668. default to 1024.
  669. @item sample_rate, s
  670. Specify the sample rate, default to 44100.
  671. @end table
  672. Each expression in @var{exprs} can contain the following constants:
  673. @table @option
  674. @item n
  675. number of the evaluated sample, starting from 0
  676. @item t
  677. time of the evaluated sample expressed in seconds, starting from 0
  678. @item s
  679. sample rate
  680. @end table
  681. @subsection Examples
  682. @itemize
  683. @item
  684. Generate silence:
  685. @example
  686. aevalsrc=0
  687. @end example
  688. @item
  689. Generate a sin signal with frequency of 440 Hz, set sample rate to
  690. 8000 Hz:
  691. @example
  692. aevalsrc="sin(440*2*PI*t)::s=8000"
  693. @end example
  694. @item
  695. Generate a two channels signal, specify the channel layout (Front
  696. Center + Back Center) explicitly:
  697. @example
  698. aevalsrc="sin(420*2*PI*t):cos(430*2*PI*t)::c=FC|BC"
  699. @end example
  700. @item
  701. Generate white noise:
  702. @example
  703. aevalsrc="-2+random(0)"
  704. @end example
  705. @item
  706. Generate an amplitude modulated signal:
  707. @example
  708. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  709. @end example
  710. @item
  711. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  712. @example
  713. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) : 0.1*sin(2*PI*(360+2.5/2)*t)"
  714. @end example
  715. @end itemize
  716. @section anullsrc
  717. Null audio source, return unprocessed audio frames. It is mainly useful
  718. as a template and to be employed in analysis / debugging tools, or as
  719. the source for filters which ignore the input data (for example the sox
  720. synth filter).
  721. It accepts an optional sequence of @var{key}=@var{value} pairs,
  722. separated by ":".
  723. The description of the accepted options follows.
  724. @table @option
  725. @item sample_rate, s
  726. Specify the sample rate, and defaults to 44100.
  727. @item channel_layout, cl
  728. Specify the channel layout, and can be either an integer or a string
  729. representing a channel layout. The default value of @var{channel_layout}
  730. is "stereo".
  731. Check the channel_layout_map definition in
  732. @file{libavcodec/audioconvert.c} for the mapping between strings and
  733. channel layout values.
  734. @item nb_samples, n
  735. Set the number of samples per requested frames.
  736. @end table
  737. Follow some examples:
  738. @example
  739. # set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  740. anullsrc=r=48000:cl=4
  741. # same as
  742. anullsrc=r=48000:cl=mono
  743. @end example
  744. @section abuffer
  745. Buffer audio frames, and make them available to the filter chain.
  746. This source is not intended to be part of user-supplied graph descriptions but
  747. for insertion by calling programs through the interface defined in
  748. @file{libavfilter/buffersrc.h}.
  749. It accepts the following named parameters:
  750. @table @option
  751. @item time_base
  752. Timebase which will be used for timestamps of submitted frames. It must be
  753. either a floating-point number or in @var{numerator}/@var{denominator} form.
  754. @item sample_rate
  755. Audio sample rate.
  756. @item sample_fmt
  757. Name of the sample format, as returned by @code{av_get_sample_fmt_name()}.
  758. @item channel_layout
  759. Channel layout of the audio data, in the form that can be accepted by
  760. @code{av_get_channel_layout()}.
  761. @end table
  762. All the parameters need to be explicitly defined.
  763. @section flite
  764. Synthesize a voice utterance using the libflite library.
  765. To enable compilation of this filter you need to configure FFmpeg with
  766. @code{--enable-libflite}.
  767. Note that the flite library is not thread-safe.
  768. The source accepts parameters as a list of @var{key}=@var{value} pairs,
  769. separated by ":".
  770. The description of the accepted parameters follows.
  771. @table @option
  772. @item list_voices
  773. If set to 1, list the names of the available voices and exit
  774. immediately. Default value is 0.
  775. @item nb_samples, n
  776. Set the maximum number of samples per frame. Default value is 512.
  777. @item textfile
  778. Set the filename containing the text to speak.
  779. @item text
  780. Set the text to speak.
  781. @item voice, v
  782. Set the voice to use for the speech synthesis. Default value is
  783. @code{kal}. See also the @var{list_voices} option.
  784. @end table
  785. @section Examples
  786. @itemize
  787. @item
  788. Read from file @file{speech.txt}, and synthetize the text using the
  789. standard flite voice:
  790. @example
  791. flite=textfile=speech.txt
  792. @end example
  793. @item
  794. Read the specified text selecting the @code{slt} voice:
  795. @example
  796. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  797. @end example
  798. @item
  799. Make @file{ffplay} speech the specified text, using @code{flite} and
  800. the @code{lavfi} device:
  801. @example
  802. ffplay -f lavfi flite='No more be grieved for which that thou hast done.'
  803. @end example
  804. @end itemize
  805. For more information about libflite, check:
  806. @url{http://www.speech.cs.cmu.edu/flite/}
  807. @c man end AUDIO SOURCES
  808. @chapter Audio Sinks
  809. @c man begin AUDIO SINKS
  810. Below is a description of the currently available audio sinks.
  811. @section abuffersink
  812. Buffer audio frames, and make them available to the end of filter chain.
  813. This sink is mainly intended for programmatic use, in particular
  814. through the interface defined in @file{libavfilter/buffersink.h}.
  815. It requires a pointer to an AVABufferSinkContext structure, which
  816. defines the incoming buffers' formats, to be passed as the opaque
  817. parameter to @code{avfilter_init_filter} for initialization.
  818. @section anullsink
  819. Null audio sink, do absolutely nothing with the input audio. It is
  820. mainly useful as a template and to be employed in analysis / debugging
  821. tools.
  822. @section abuffersink
  823. This sink is intended for programmatic use. Frames that arrive on this sink can
  824. be retrieved by the calling program using the interface defined in
  825. @file{libavfilter/buffersink.h}.
  826. This filter accepts no parameters.
  827. @c man end AUDIO SINKS
  828. @chapter Video Filters
  829. @c man begin VIDEO FILTERS
  830. When you configure your FFmpeg build, you can disable any of the
  831. existing filters using @code{--disable-filters}.
  832. The configure output will show the video filters included in your
  833. build.
  834. Below is a description of the currently available video filters.
  835. @section alphaextract
  836. Extract the alpha component from the input as a grayscale video. This
  837. is especially useful with the @var{alphamerge} filter.
  838. @section alphamerge
  839. Add or replace the alpha component of the primary input with the
  840. grayscale value of a second input. This is intended for use with
  841. @var{alphaextract} to allow the transmission or storage of frame
  842. sequences that have alpha in a format that doesn't support an alpha
  843. channel.
  844. For example, to reconstruct full frames from a normal YUV-encoded video
  845. and a separate video created with @var{alphaextract}, you might use:
  846. @example
  847. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  848. @end example
  849. Since this filter is designed for reconstruction, it operates on frame
  850. sequences without considering timestamps, and terminates when either
  851. input reaches end of stream. This will cause problems if your encoding
  852. pipeline drops frames. If you're trying to apply an image as an
  853. overlay to a video stream, consider the @var{overlay} filter instead.
  854. @section ass
  855. Draw ASS (Advanced Substation Alpha) subtitles on top of input video
  856. using the libass library.
  857. To enable compilation of this filter you need to configure FFmpeg with
  858. @code{--enable-libass}.
  859. This filter accepts the syntax: @var{ass_filename}[:@var{options}],
  860. where @var{ass_filename} is the filename of the ASS file to read, and
  861. @var{options} is an optional sequence of @var{key}=@var{value} pairs,
  862. separated by ":".
  863. A description of the accepted options follows.
  864. @table @option
  865. @item original_size
  866. Specifies the size of the original video, the video for which the ASS file
  867. was composed. Due to a misdesign in ASS aspect ratio arithmetic, this is
  868. necessary to correctly scale the fonts if the aspect ratio has been changed.
  869. @end table
  870. For example, to render the file @file{sub.ass} on top of the input
  871. video, use the command:
  872. @example
  873. ass=sub.ass
  874. @end example
  875. @section bbox
  876. Compute the bounding box for the non-black pixels in the input frame
  877. luminance plane.
  878. This filter computes the bounding box containing all the pixels with a
  879. luminance value greater than the minimum allowed value.
  880. The parameters describing the bounding box are printed on the filter
  881. log.
  882. @section blackdetect
  883. Detect video intervals that are (almost) completely black. Can be
  884. useful to detect chapter transitions, commercials, or invalid
  885. recordings. Output lines contains the time for the start, end and
  886. duration of the detected black interval expressed in seconds.
  887. In order to display the output lines, you need to set the loglevel at
  888. least to the AV_LOG_INFO value.
  889. This filter accepts a list of options in the form of
  890. @var{key}=@var{value} pairs separated by ":". A description of the
  891. accepted options follows.
  892. @table @option
  893. @item black_min_duration, d
  894. Set the minimum detected black duration expressed in seconds. It must
  895. be a non-negative floating point number.
  896. Default value is 2.0.
  897. @item picture_black_ratio_th, pic_th
  898. Set the threshold for considering a picture "black".
  899. Express the minimum value for the ratio:
  900. @example
  901. @var{nb_black_pixels} / @var{nb_pixels}
  902. @end example
  903. for which a picture is considered black.
  904. Default value is 0.98.
  905. @item pixel_black_th, pix_th
  906. Set the threshold for considering a pixel "black".
  907. The threshold expresses the maximum pixel luminance value for which a
  908. pixel is considered "black". The provided value is scaled according to
  909. the following equation:
  910. @example
  911. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  912. @end example
  913. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  914. the input video format, the range is [0-255] for YUV full-range
  915. formats and [16-235] for YUV non full-range formats.
  916. Default value is 0.10.
  917. @end table
  918. The following example sets the maximum pixel threshold to the minimum
  919. value, and detects only black intervals of 2 or more seconds:
  920. @example
  921. blackdetect=d=2:pix_th=0.00
  922. @end example
  923. @section blackframe
  924. Detect frames that are (almost) completely black. Can be useful to
  925. detect chapter transitions or commercials. Output lines consist of
  926. the frame number of the detected frame, the percentage of blackness,
  927. the position in the file if known or -1 and the timestamp in seconds.
  928. In order to display the output lines, you need to set the loglevel at
  929. least to the AV_LOG_INFO value.
  930. The filter accepts the syntax:
  931. @example
  932. blackframe[=@var{amount}:[@var{threshold}]]
  933. @end example
  934. @var{amount} is the percentage of the pixels that have to be below the
  935. threshold, and defaults to 98.
  936. @var{threshold} is the threshold below which a pixel value is
  937. considered black, and defaults to 32.
  938. @section boxblur
  939. Apply boxblur algorithm to the input video.
  940. This filter accepts the parameters:
  941. @var{luma_radius}:@var{luma_power}:@var{chroma_radius}:@var{chroma_power}:@var{alpha_radius}:@var{alpha_power}
  942. Chroma and alpha parameters are optional, if not specified they default
  943. to the corresponding values set for @var{luma_radius} and
  944. @var{luma_power}.
  945. @var{luma_radius}, @var{chroma_radius}, and @var{alpha_radius} represent
  946. the radius in pixels of the box used for blurring the corresponding
  947. input plane. They are expressions, and can contain the following
  948. constants:
  949. @table @option
  950. @item w, h
  951. the input width and height in pixels
  952. @item cw, ch
  953. the input chroma image width and height in pixels
  954. @item hsub, vsub
  955. horizontal and vertical chroma subsample values. For example for the
  956. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  957. @end table
  958. The radius must be a non-negative number, and must not be greater than
  959. the value of the expression @code{min(w,h)/2} for the luma and alpha planes,
  960. and of @code{min(cw,ch)/2} for the chroma planes.
  961. @var{luma_power}, @var{chroma_power}, and @var{alpha_power} represent
  962. how many times the boxblur filter is applied to the corresponding
  963. plane.
  964. Some examples follow:
  965. @itemize
  966. @item
  967. Apply a boxblur filter with luma, chroma, and alpha radius
  968. set to 2:
  969. @example
  970. boxblur=2:1
  971. @end example
  972. @item
  973. Set luma radius to 2, alpha and chroma radius to 0
  974. @example
  975. boxblur=2:1:0:0:0:0
  976. @end example
  977. @item
  978. Set luma and chroma radius to a fraction of the video dimension
  979. @example
  980. boxblur=min(h\,w)/10:1:min(cw\,ch)/10:1
  981. @end example
  982. @end itemize
  983. @section colormatrix
  984. The colormatrix filter allows conversion between any of the following color
  985. space: BT.709 (@var{bt709}), BT.601 (@var{bt601}), SMPTE-240M (@var{smpte240m})
  986. and FCC (@var{fcc}).
  987. The syntax of the parameters is @var{source}:@var{destination}:
  988. @example
  989. colormatrix=bt601:smpte240m
  990. @end example
  991. @section copy
  992. Copy the input source unchanged to the output. Mainly useful for
  993. testing purposes.
  994. @section crop
  995. Crop the input video to @var{out_w}:@var{out_h}:@var{x}:@var{y}:@var{keep_aspect}
  996. The @var{keep_aspect} parameter is optional, if specified and set to a
  997. non-zero value will force the output display aspect ratio to be the
  998. same of the input, by changing the output sample aspect ratio.
  999. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  1000. expressions containing the following constants:
  1001. @table @option
  1002. @item x, y
  1003. the computed values for @var{x} and @var{y}. They are evaluated for
  1004. each new frame.
  1005. @item in_w, in_h
  1006. the input width and height
  1007. @item iw, ih
  1008. same as @var{in_w} and @var{in_h}
  1009. @item out_w, out_h
  1010. the output (cropped) width and height
  1011. @item ow, oh
  1012. same as @var{out_w} and @var{out_h}
  1013. @item a
  1014. same as @var{iw} / @var{ih}
  1015. @item sar
  1016. input sample aspect ratio
  1017. @item dar
  1018. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  1019. @item hsub, vsub
  1020. horizontal and vertical chroma subsample values. For example for the
  1021. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1022. @item n
  1023. the number of input frame, starting from 0
  1024. @item pos
  1025. the position in the file of the input frame, NAN if unknown
  1026. @item t
  1027. timestamp expressed in seconds, NAN if the input timestamp is unknown
  1028. @end table
  1029. The @var{out_w} and @var{out_h} parameters specify the expressions for
  1030. the width and height of the output (cropped) video. They are
  1031. evaluated just at the configuration of the filter.
  1032. The default value of @var{out_w} is "in_w", and the default value of
  1033. @var{out_h} is "in_h".
  1034. The expression for @var{out_w} may depend on the value of @var{out_h},
  1035. and the expression for @var{out_h} may depend on @var{out_w}, but they
  1036. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  1037. evaluated after @var{out_w} and @var{out_h}.
  1038. The @var{x} and @var{y} parameters specify the expressions for the
  1039. position of the top-left corner of the output (non-cropped) area. They
  1040. are evaluated for each frame. If the evaluated value is not valid, it
  1041. is approximated to the nearest valid value.
  1042. The default value of @var{x} is "(in_w-out_w)/2", and the default
  1043. value for @var{y} is "(in_h-out_h)/2", which set the cropped area at
  1044. the center of the input image.
  1045. The expression for @var{x} may depend on @var{y}, and the expression
  1046. for @var{y} may depend on @var{x}.
  1047. Follow some examples:
  1048. @example
  1049. # crop the central input area with size 100x100
  1050. crop=100:100
  1051. # crop the central input area with size 2/3 of the input video
  1052. "crop=2/3*in_w:2/3*in_h"
  1053. # crop the input video central square
  1054. crop=in_h
  1055. # delimit the rectangle with the top-left corner placed at position
  1056. # 100:100 and the right-bottom corner corresponding to the right-bottom
  1057. # corner of the input image.
  1058. crop=in_w-100:in_h-100:100:100
  1059. # crop 10 pixels from the left and right borders, and 20 pixels from
  1060. # the top and bottom borders
  1061. "crop=in_w-2*10:in_h-2*20"
  1062. # keep only the bottom right quarter of the input image
  1063. "crop=in_w/2:in_h/2:in_w/2:in_h/2"
  1064. # crop height for getting Greek harmony
  1065. "crop=in_w:1/PHI*in_w"
  1066. # trembling effect
  1067. "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)"
  1068. # erratic camera effect depending on timestamp
  1069. "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)"
  1070. # set x depending on the value of y
  1071. "crop=in_w/2:in_h/2:y:10+10*sin(n/10)"
  1072. @end example
  1073. @section cropdetect
  1074. Auto-detect crop size.
  1075. Calculate necessary cropping parameters and prints the recommended
  1076. parameters through the logging system. The detected dimensions
  1077. correspond to the non-black area of the input video.
  1078. It accepts the syntax:
  1079. @example
  1080. cropdetect[=@var{limit}[:@var{round}[:@var{reset}]]]
  1081. @end example
  1082. @table @option
  1083. @item limit
  1084. Threshold, which can be optionally specified from nothing (0) to
  1085. everything (255), defaults to 24.
  1086. @item round
  1087. Value which the width/height should be divisible by, defaults to
  1088. 16. The offset is automatically adjusted to center the video. Use 2 to
  1089. get only even dimensions (needed for 4:2:2 video). 16 is best when
  1090. encoding to most video codecs.
  1091. @item reset
  1092. Counter that determines after how many frames cropdetect will reset
  1093. the previously detected largest video area and start over to detect
  1094. the current optimal crop area. Defaults to 0.
  1095. This can be useful when channel logos distort the video area. 0
  1096. indicates never reset and return the largest area encountered during
  1097. playback.
  1098. @end table
  1099. @section delogo
  1100. Suppress a TV station logo by a simple interpolation of the surrounding
  1101. pixels. Just set a rectangle covering the logo and watch it disappear
  1102. (and sometimes something even uglier appear - your mileage may vary).
  1103. The filter accepts parameters as a string of the form
  1104. "@var{x}:@var{y}:@var{w}:@var{h}:@var{band}", or as a list of
  1105. @var{key}=@var{value} pairs, separated by ":".
  1106. The description of the accepted parameters follows.
  1107. @table @option
  1108. @item x, y
  1109. Specify the top left corner coordinates of the logo. They must be
  1110. specified.
  1111. @item w, h
  1112. Specify the width and height of the logo to clear. They must be
  1113. specified.
  1114. @item band, t
  1115. Specify the thickness of the fuzzy edge of the rectangle (added to
  1116. @var{w} and @var{h}). The default value is 4.
  1117. @item show
  1118. When set to 1, a green rectangle is drawn on the screen to simplify
  1119. finding the right @var{x}, @var{y}, @var{w}, @var{h} parameters, and
  1120. @var{band} is set to 4. The default value is 0.
  1121. @end table
  1122. Some examples follow.
  1123. @itemize
  1124. @item
  1125. Set a rectangle covering the area with top left corner coordinates 0,0
  1126. and size 100x77, setting a band of size 10:
  1127. @example
  1128. delogo=0:0:100:77:10
  1129. @end example
  1130. @item
  1131. As the previous example, but use named options:
  1132. @example
  1133. delogo=x=0:y=0:w=100:h=77:band=10
  1134. @end example
  1135. @end itemize
  1136. @section deshake
  1137. Attempt to fix small changes in horizontal and/or vertical shift. This
  1138. filter helps remove camera shake from hand-holding a camera, bumping a
  1139. tripod, moving on a vehicle, etc.
  1140. The filter accepts parameters as a string of the form
  1141. "@var{x}:@var{y}:@var{w}:@var{h}:@var{rx}:@var{ry}:@var{edge}:@var{blocksize}:@var{contrast}:@var{search}:@var{filename}"
  1142. A description of the accepted parameters follows.
  1143. @table @option
  1144. @item x, y, w, h
  1145. Specify a rectangular area where to limit the search for motion
  1146. vectors.
  1147. If desired the search for motion vectors can be limited to a
  1148. rectangular area of the frame defined by its top left corner, width
  1149. and height. These parameters have the same meaning as the drawbox
  1150. filter which can be used to visualise the position of the bounding
  1151. box.
  1152. This is useful when simultaneous movement of subjects within the frame
  1153. might be confused for camera motion by the motion vector search.
  1154. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  1155. then the full frame is used. This allows later options to be set
  1156. without specifying the bounding box for the motion vector search.
  1157. Default - search the whole frame.
  1158. @item rx, ry
  1159. Specify the maximum extent of movement in x and y directions in the
  1160. range 0-64 pixels. Default 16.
  1161. @item edge
  1162. Specify how to generate pixels to fill blanks at the edge of the
  1163. frame. An integer from 0 to 3 as follows:
  1164. @table @option
  1165. @item 0
  1166. Fill zeroes at blank locations
  1167. @item 1
  1168. Original image at blank locations
  1169. @item 2
  1170. Extruded edge value at blank locations
  1171. @item 3
  1172. Mirrored edge at blank locations
  1173. @end table
  1174. The default setting is mirror edge at blank locations.
  1175. @item blocksize
  1176. Specify the blocksize to use for motion search. Range 4-128 pixels,
  1177. default 8.
  1178. @item contrast
  1179. Specify the contrast threshold for blocks. Only blocks with more than
  1180. the specified contrast (difference between darkest and lightest
  1181. pixels) will be considered. Range 1-255, default 125.
  1182. @item search
  1183. Specify the search strategy 0 = exhaustive search, 1 = less exhaustive
  1184. search. Default - exhaustive search.
  1185. @item filename
  1186. If set then a detailed log of the motion search is written to the
  1187. specified file.
  1188. @end table
  1189. @section drawbox
  1190. Draw a colored box on the input image.
  1191. It accepts the syntax:
  1192. @example
  1193. drawbox=@var{x}:@var{y}:@var{width}:@var{height}:@var{color}
  1194. @end example
  1195. @table @option
  1196. @item x, y
  1197. Specify the top left corner coordinates of the box. Default to 0.
  1198. @item width, height
  1199. Specify the width and height of the box, if 0 they are interpreted as
  1200. the input width and height. Default to 0.
  1201. @item color
  1202. Specify the color of the box to write, it can be the name of a color
  1203. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  1204. @end table
  1205. Follow some examples:
  1206. @example
  1207. # draw a black box around the edge of the input image
  1208. drawbox
  1209. # draw a box with color red and an opacity of 50%
  1210. drawbox=10:20:200:60:red@@0.5"
  1211. @end example
  1212. @section drawtext
  1213. Draw text string or text from specified file on top of video using the
  1214. libfreetype library.
  1215. To enable compilation of this filter you need to configure FFmpeg with
  1216. @code{--enable-libfreetype}.
  1217. The filter also recognizes strftime() sequences in the provided text
  1218. and expands them accordingly. Check the documentation of strftime().
  1219. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  1220. separated by ":".
  1221. The description of the accepted parameters follows.
  1222. @table @option
  1223. @item box
  1224. Used to draw a box around text using background color.
  1225. Value should be either 1 (enable) or 0 (disable).
  1226. The default value of @var{box} is 0.
  1227. @item boxcolor
  1228. The color to be used for drawing box around text.
  1229. Either a string (e.g. "yellow") or in 0xRRGGBB[AA] format
  1230. (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  1231. The default value of @var{boxcolor} is "white".
  1232. @item draw
  1233. Set an expression which specifies if the text should be drawn. If the
  1234. expression evaluates to 0, the text is not drawn. This is useful for
  1235. specifying that the text should be drawn only when specific conditions
  1236. are met.
  1237. Default value is "1".
  1238. See below for the list of accepted constants and functions.
  1239. @item fix_bounds
  1240. If true, check and fix text coords to avoid clipping.
  1241. @item fontcolor
  1242. The color to be used for drawing fonts.
  1243. Either a string (e.g. "red") or in 0xRRGGBB[AA] format
  1244. (e.g. "0xff000033"), possibly followed by an alpha specifier.
  1245. The default value of @var{fontcolor} is "black".
  1246. @item fontfile
  1247. The font file to be used for drawing text. Path must be included.
  1248. This parameter is mandatory.
  1249. @item fontsize
  1250. The font size to be used for drawing text.
  1251. The default value of @var{fontsize} is 16.
  1252. @item ft_load_flags
  1253. Flags to be used for loading the fonts.
  1254. The flags map the corresponding flags supported by libfreetype, and are
  1255. a combination of the following values:
  1256. @table @var
  1257. @item default
  1258. @item no_scale
  1259. @item no_hinting
  1260. @item render
  1261. @item no_bitmap
  1262. @item vertical_layout
  1263. @item force_autohint
  1264. @item crop_bitmap
  1265. @item pedantic
  1266. @item ignore_global_advance_width
  1267. @item no_recurse
  1268. @item ignore_transform
  1269. @item monochrome
  1270. @item linear_design
  1271. @item no_autohint
  1272. @item end table
  1273. @end table
  1274. Default value is "render".
  1275. For more information consult the documentation for the FT_LOAD_*
  1276. libfreetype flags.
  1277. @item shadowcolor
  1278. The color to be used for drawing a shadow behind the drawn text. It
  1279. can be a color name (e.g. "yellow") or a string in the 0xRRGGBB[AA]
  1280. form (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  1281. The default value of @var{shadowcolor} is "black".
  1282. @item shadowx, shadowy
  1283. The x and y offsets for the text shadow position with respect to the
  1284. position of the text. They can be either positive or negative
  1285. values. Default value for both is "0".
  1286. @item tabsize
  1287. The size in number of spaces to use for rendering the tab.
  1288. Default value is 4.
  1289. @item timecode
  1290. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  1291. format. It can be used with or without text parameter. @var{timecode_rate}
  1292. option must be specified.
  1293. @item timecode_rate, rate, r
  1294. Set the timecode frame rate (timecode only).
  1295. @item text
  1296. The text string to be drawn. The text must be a sequence of UTF-8
  1297. encoded characters.
  1298. This parameter is mandatory if no file is specified with the parameter
  1299. @var{textfile}.
  1300. @item textfile
  1301. A text file containing text to be drawn. The text must be a sequence
  1302. of UTF-8 encoded characters.
  1303. This parameter is mandatory if no text string is specified with the
  1304. parameter @var{text}.
  1305. If both @var{text} and @var{textfile} are specified, an error is thrown.
  1306. @item x, y
  1307. The expressions which specify the offsets where text will be drawn
  1308. within the video frame. They are relative to the top/left border of the
  1309. output image.
  1310. The default value of @var{x} and @var{y} is "0".
  1311. See below for the list of accepted constants and functions.
  1312. @end table
  1313. The parameters for @var{x} and @var{y} are expressions containing the
  1314. following constants and functions:
  1315. @table @option
  1316. @item dar
  1317. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  1318. @item hsub, vsub
  1319. horizontal and vertical chroma subsample values. For example for the
  1320. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1321. @item line_h, lh
  1322. the height of each text line
  1323. @item main_h, h, H
  1324. the input height
  1325. @item main_w, w, W
  1326. the input width
  1327. @item max_glyph_a, ascent
  1328. the maximum distance from the baseline to the highest/upper grid
  1329. coordinate used to place a glyph outline point, for all the rendered
  1330. glyphs.
  1331. It is a positive value, due to the grid's orientation with the Y axis
  1332. upwards.
  1333. @item max_glyph_d, descent
  1334. the maximum distance from the baseline to the lowest grid coordinate
  1335. used to place a glyph outline point, for all the rendered glyphs.
  1336. This is a negative value, due to the grid's orientation, with the Y axis
  1337. upwards.
  1338. @item max_glyph_h
  1339. maximum glyph height, that is the maximum height for all the glyphs
  1340. contained in the rendered text, it is equivalent to @var{ascent} -
  1341. @var{descent}.
  1342. @item max_glyph_w
  1343. maximum glyph width, that is the maximum width for all the glyphs
  1344. contained in the rendered text
  1345. @item n
  1346. the number of input frame, starting from 0
  1347. @item rand(min, max)
  1348. return a random number included between @var{min} and @var{max}
  1349. @item sar
  1350. input sample aspect ratio
  1351. @item t
  1352. timestamp expressed in seconds, NAN if the input timestamp is unknown
  1353. @item text_h, th
  1354. the height of the rendered text
  1355. @item text_w, tw
  1356. the width of the rendered text
  1357. @item x, y
  1358. the x and y offset coordinates where the text is drawn.
  1359. These parameters allow the @var{x} and @var{y} expressions to refer
  1360. each other, so you can for example specify @code{y=x/dar}.
  1361. @end table
  1362. If libavfilter was built with @code{--enable-fontconfig}, then
  1363. @option{fontfile} can be a fontconfig pattern or omitted.
  1364. Some examples follow.
  1365. @itemize
  1366. @item
  1367. Draw "Test Text" with font FreeSerif, using the default values for the
  1368. optional parameters.
  1369. @example
  1370. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  1371. @end example
  1372. @item
  1373. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  1374. and y=50 (counting from the top-left corner of the screen), text is
  1375. yellow with a red box around it. Both the text and the box have an
  1376. opacity of 20%.
  1377. @example
  1378. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  1379. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  1380. @end example
  1381. Note that the double quotes are not necessary if spaces are not used
  1382. within the parameter list.
  1383. @item
  1384. Show the text at the center of the video frame:
  1385. @example
  1386. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  1387. @end example
  1388. @item
  1389. Show a text line sliding from right to left in the last row of the video
  1390. frame. The file @file{LONG_LINE} is assumed to contain a single line
  1391. with no newlines.
  1392. @example
  1393. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  1394. @end example
  1395. @item
  1396. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  1397. @example
  1398. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  1399. @end example
  1400. @item
  1401. Draw a single green letter "g", at the center of the input video.
  1402. The glyph baseline is placed at half screen height.
  1403. @example
  1404. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  1405. @end example
  1406. @item
  1407. Show text for 1 second every 3 seconds:
  1408. @example
  1409. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:draw=lt(mod(t\\,3)\\,1):text='blink'"
  1410. @end example
  1411. @item
  1412. Use fontconfig to set the font. Note that the colons need to be escaped.
  1413. @example
  1414. drawtext='fontfile=Linux Libertine O-40\\:style=Semibold:text=FFmpeg'
  1415. @end example
  1416. @end itemize
  1417. For more information about libfreetype, check:
  1418. @url{http://www.freetype.org/}.
  1419. For more information about fontconfig, check:
  1420. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  1421. @section fade
  1422. Apply fade-in/out effect to input video.
  1423. It accepts the parameters:
  1424. @var{type}:@var{start_frame}:@var{nb_frames}[:@var{options}]
  1425. @var{type} specifies if the effect type, can be either "in" for
  1426. fade-in, or "out" for a fade-out effect.
  1427. @var{start_frame} specifies the number of the start frame for starting
  1428. to apply the fade effect.
  1429. @var{nb_frames} specifies the number of frames for which the fade
  1430. effect has to last. At the end of the fade-in effect the output video
  1431. will have the same intensity as the input video, at the end of the
  1432. fade-out transition the output video will be completely black.
  1433. @var{options} is an optional sequence of @var{key}=@var{value} pairs,
  1434. separated by ":". The description of the accepted options follows.
  1435. @table @option
  1436. @item type, t
  1437. See @var{type}.
  1438. @item start_frame, s
  1439. See @var{start_frame}.
  1440. @item nb_frames, n
  1441. See @var{nb_frames}.
  1442. @item alpha
  1443. If set to 1, fade only alpha channel, if one exists on the input.
  1444. Default value is 0.
  1445. @end table
  1446. A few usage examples follow, usable too as test scenarios.
  1447. @example
  1448. # fade in first 30 frames of video
  1449. fade=in:0:30
  1450. # fade out last 45 frames of a 200-frame video
  1451. fade=out:155:45
  1452. # fade in first 25 frames and fade out last 25 frames of a 1000-frame video
  1453. fade=in:0:25, fade=out:975:25
  1454. # make first 5 frames black, then fade in from frame 5-24
  1455. fade=in:5:20
  1456. # fade in alpha over first 25 frames of video
  1457. fade=in:0:25:alpha=1
  1458. @end example
  1459. @section fieldorder
  1460. Transform the field order of the input video.
  1461. It accepts one parameter which specifies the required field order that
  1462. the input interlaced video will be transformed to. The parameter can
  1463. assume one of the following values:
  1464. @table @option
  1465. @item 0 or bff
  1466. output bottom field first
  1467. @item 1 or tff
  1468. output top field first
  1469. @end table
  1470. Default value is "tff".
  1471. Transformation is achieved by shifting the picture content up or down
  1472. by one line, and filling the remaining line with appropriate picture content.
  1473. This method is consistent with most broadcast field order converters.
  1474. If the input video is not flagged as being interlaced, or it is already
  1475. flagged as being of the required output field order then this filter does
  1476. not alter the incoming video.
  1477. This filter is very useful when converting to or from PAL DV material,
  1478. which is bottom field first.
  1479. For example:
  1480. @example
  1481. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  1482. @end example
  1483. @section fifo
  1484. Buffer input images and send them when they are requested.
  1485. This filter is mainly useful when auto-inserted by the libavfilter
  1486. framework.
  1487. The filter does not take parameters.
  1488. @section format
  1489. Convert the input video to one of the specified pixel formats.
  1490. Libavfilter will try to pick one that is supported for the input to
  1491. the next filter.
  1492. The filter accepts a list of pixel format names, separated by ":",
  1493. for example "yuv420p:monow:rgb24".
  1494. Some examples follow:
  1495. @example
  1496. # convert the input video to the format "yuv420p"
  1497. format=yuv420p
  1498. # convert the input video to any of the formats in the list
  1499. format=yuv420p:yuv444p:yuv410p
  1500. @end example
  1501. @section fps
  1502. Convert the video to specified constant framerate by duplicating or dropping
  1503. frames as necessary.
  1504. This filter accepts the following named parameters:
  1505. @table @option
  1506. @item fps
  1507. Desired output framerate.
  1508. @end table
  1509. @anchor{frei0r}
  1510. @section frei0r
  1511. Apply a frei0r effect to the input video.
  1512. To enable compilation of this filter you need to install the frei0r
  1513. header and configure FFmpeg with @code{--enable-frei0r}.
  1514. The filter supports the syntax:
  1515. @example
  1516. @var{filter_name}[@{:|=@}@var{param1}:@var{param2}:...:@var{paramN}]
  1517. @end example
  1518. @var{filter_name} is the name to the frei0r effect to load. If the
  1519. environment variable @env{FREI0R_PATH} is defined, the frei0r effect
  1520. is searched in each one of the directories specified by the colon
  1521. separated list in @env{FREIOR_PATH}, otherwise in the standard frei0r
  1522. paths, which are in this order: @file{HOME/.frei0r-1/lib/},
  1523. @file{/usr/local/lib/frei0r-1/}, @file{/usr/lib/frei0r-1/}.
  1524. @var{param1}, @var{param2}, ... , @var{paramN} specify the parameters
  1525. for the frei0r effect.
  1526. A frei0r effect parameter can be a boolean (whose values are specified
  1527. with "y" and "n"), a double, a color (specified by the syntax
  1528. @var{R}/@var{G}/@var{B}, @var{R}, @var{G}, and @var{B} being float
  1529. numbers from 0.0 to 1.0) or by an @code{av_parse_color()} color
  1530. description), a position (specified by the syntax @var{X}/@var{Y},
  1531. @var{X} and @var{Y} being float numbers) and a string.
  1532. The number and kind of parameters depend on the loaded effect. If an
  1533. effect parameter is not specified the default value is set.
  1534. Some examples follow:
  1535. @itemize
  1536. @item
  1537. Apply the distort0r effect, set the first two double parameters:
  1538. @example
  1539. frei0r=distort0r:0.5:0.01
  1540. @end example
  1541. @item
  1542. Apply the colordistance effect, takes a color as first parameter:
  1543. @example
  1544. frei0r=colordistance:0.2/0.3/0.4
  1545. frei0r=colordistance:violet
  1546. frei0r=colordistance:0x112233
  1547. @end example
  1548. @item
  1549. Apply the perspective effect, specify the top left and top right image
  1550. positions:
  1551. @example
  1552. frei0r=perspective:0.2/0.2:0.8/0.2
  1553. @end example
  1554. @end itemize
  1555. For more information see:
  1556. @url{http://frei0r.dyne.org}
  1557. @section gradfun
  1558. Fix the banding artifacts that are sometimes introduced into nearly flat
  1559. regions by truncation to 8bit color depth.
  1560. Interpolate the gradients that should go where the bands are, and
  1561. dither them.
  1562. This filter is designed for playback only. Do not use it prior to
  1563. lossy compression, because compression tends to lose the dither and
  1564. bring back the bands.
  1565. The filter takes two optional parameters, separated by ':':
  1566. @var{strength}:@var{radius}
  1567. @var{strength} is the maximum amount by which the filter will change
  1568. any one pixel. Also the threshold for detecting nearly flat
  1569. regions. Acceptable values range from .51 to 255, default value is
  1570. 1.2, out-of-range values will be clipped to the valid range.
  1571. @var{radius} is the neighborhood to fit the gradient to. A larger
  1572. radius makes for smoother gradients, but also prevents the filter from
  1573. modifying the pixels near detailed regions. Acceptable values are
  1574. 8-32, default value is 16, out-of-range values will be clipped to the
  1575. valid range.
  1576. @example
  1577. # default parameters
  1578. gradfun=1.2:16
  1579. # omitting radius
  1580. gradfun=1.2
  1581. @end example
  1582. @section hflip
  1583. Flip the input video horizontally.
  1584. For example to horizontally flip the input video with @command{ffmpeg}:
  1585. @example
  1586. ffmpeg -i in.avi -vf "hflip" out.avi
  1587. @end example
  1588. @section hqdn3d
  1589. High precision/quality 3d denoise filter. This filter aims to reduce
  1590. image noise producing smooth images and making still images really
  1591. still. It should enhance compressibility.
  1592. It accepts the following optional parameters:
  1593. @var{luma_spatial}:@var{chroma_spatial}:@var{luma_tmp}:@var{chroma_tmp}
  1594. @table @option
  1595. @item luma_spatial
  1596. a non-negative float number which specifies spatial luma strength,
  1597. defaults to 4.0
  1598. @item chroma_spatial
  1599. a non-negative float number which specifies spatial chroma strength,
  1600. defaults to 3.0*@var{luma_spatial}/4.0
  1601. @item luma_tmp
  1602. a float number which specifies luma temporal strength, defaults to
  1603. 6.0*@var{luma_spatial}/4.0
  1604. @item chroma_tmp
  1605. a float number which specifies chroma temporal strength, defaults to
  1606. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
  1607. @end table
  1608. @section idet
  1609. Interlaceing detect filter. This filter tries to detect if the input is
  1610. interlaced or progressive. Top or bottom field first.
  1611. @section lut, lutrgb, lutyuv
  1612. Compute a look-up table for binding each pixel component input value
  1613. to an output value, and apply it to input video.
  1614. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  1615. to an RGB input video.
  1616. These filters accept in input a ":"-separated list of options, which
  1617. specify the expressions used for computing the lookup table for the
  1618. corresponding pixel component values.
  1619. The @var{lut} filter requires either YUV or RGB pixel formats in
  1620. input, and accepts the options:
  1621. @table @option
  1622. @item c0
  1623. first pixel component
  1624. @item c1
  1625. second pixel component
  1626. @item c2
  1627. third pixel component
  1628. @item c3
  1629. fourth pixel component, corresponds to the alpha component
  1630. @end table
  1631. The exact component associated to each option depends on the format in
  1632. input.
  1633. The @var{lutrgb} filter requires RGB pixel formats in input, and
  1634. accepts the options:
  1635. @table @option
  1636. @item r
  1637. red component
  1638. @item g
  1639. green component
  1640. @item b
  1641. blue component
  1642. @item a
  1643. alpha component
  1644. @end table
  1645. The @var{lutyuv} filter requires YUV pixel formats in input, and
  1646. accepts the options:
  1647. @table @option
  1648. @item y
  1649. Y/luminance component
  1650. @item u
  1651. U/Cb component
  1652. @item v
  1653. V/Cr component
  1654. @item a
  1655. alpha component
  1656. @end table
  1657. The expressions can contain the following constants and functions:
  1658. @table @option
  1659. @item w, h
  1660. the input width and height
  1661. @item val
  1662. input value for the pixel component
  1663. @item clipval
  1664. the input value clipped in the @var{minval}-@var{maxval} range
  1665. @item maxval
  1666. maximum value for the pixel component
  1667. @item minval
  1668. minimum value for the pixel component
  1669. @item negval
  1670. the negated value for the pixel component value clipped in the
  1671. @var{minval}-@var{maxval} range , it corresponds to the expression
  1672. "maxval-clipval+minval"
  1673. @item clip(val)
  1674. the computed value in @var{val} clipped in the
  1675. @var{minval}-@var{maxval} range
  1676. @item gammaval(gamma)
  1677. the computed gamma correction value of the pixel component value
  1678. clipped in the @var{minval}-@var{maxval} range, corresponds to the
  1679. expression
  1680. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  1681. @end table
  1682. All expressions default to "val".
  1683. Some examples follow:
  1684. @example
  1685. # negate input video
  1686. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  1687. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  1688. # the above is the same as
  1689. lutrgb="r=negval:g=negval:b=negval"
  1690. lutyuv="y=negval:u=negval:v=negval"
  1691. # negate luminance
  1692. lutyuv=y=negval
  1693. # remove chroma components, turns the video into a graytone image
  1694. lutyuv="u=128:v=128"
  1695. # apply a luma burning effect
  1696. lutyuv="y=2*val"
  1697. # remove green and blue components
  1698. lutrgb="g=0:b=0"
  1699. # set a constant alpha channel value on input
  1700. format=rgba,lutrgb=a="maxval-minval/2"
  1701. # correct luminance gamma by a 0.5 factor
  1702. lutyuv=y=gammaval(0.5)
  1703. @end example
  1704. @section mp
  1705. Apply an MPlayer filter to the input video.
  1706. This filter provides a wrapper around most of the filters of
  1707. MPlayer/MEncoder.
  1708. This wrapper is considered experimental. Some of the wrapped filters
  1709. may not work properly and we may drop support for them, as they will
  1710. be implemented natively into FFmpeg. Thus you should avoid
  1711. depending on them when writing portable scripts.
  1712. The filters accepts the parameters:
  1713. @var{filter_name}[:=]@var{filter_params}
  1714. @var{filter_name} is the name of a supported MPlayer filter,
  1715. @var{filter_params} is a string containing the parameters accepted by
  1716. the named filter.
  1717. The list of the currently supported filters follows:
  1718. @table @var
  1719. @item decimate
  1720. @item denoise3d
  1721. @item detc
  1722. @item dint
  1723. @item divtc
  1724. @item down3dright
  1725. @item dsize
  1726. @item eq2
  1727. @item eq
  1728. @item field
  1729. @item fil
  1730. @item fixpts
  1731. @item framestep
  1732. @item fspp
  1733. @item geq
  1734. @item harddup
  1735. @item hqdn3d
  1736. @item hue
  1737. @item il
  1738. @item ilpack
  1739. @item ivtc
  1740. @item kerndeint
  1741. @item mcdeint
  1742. @item noise
  1743. @item ow
  1744. @item palette
  1745. @item perspective
  1746. @item phase
  1747. @item pp7
  1748. @item pullup
  1749. @item qp
  1750. @item rectangle
  1751. @item rotate
  1752. @item sab
  1753. @item smartblur
  1754. @item softpulldown
  1755. @item softskip
  1756. @item spp
  1757. @item telecine
  1758. @item tile
  1759. @item tinterlace
  1760. @item unsharp
  1761. @item uspp
  1762. @item yuvcsp
  1763. @item yvu9
  1764. @end table
  1765. The parameter syntax and behavior for the listed filters are the same
  1766. of the corresponding MPlayer filters. For detailed instructions check
  1767. the "VIDEO FILTERS" section in the MPlayer manual.
  1768. Some examples follow:
  1769. @example
  1770. # adjust gamma, brightness, contrast
  1771. mp=eq2=1.0:2:0.5
  1772. # tweak hue and saturation
  1773. mp=hue=100:-10
  1774. @end example
  1775. See also mplayer(1), @url{http://www.mplayerhq.hu/}.
  1776. @section negate
  1777. Negate input video.
  1778. This filter accepts an integer in input, if non-zero it negates the
  1779. alpha component (if available). The default value in input is 0.
  1780. @section noformat
  1781. Force libavfilter not to use any of the specified pixel formats for the
  1782. input to the next filter.
  1783. The filter accepts a list of pixel format names, separated by ":",
  1784. for example "yuv420p:monow:rgb24".
  1785. Some examples follow:
  1786. @example
  1787. # force libavfilter to use a format different from "yuv420p" for the
  1788. # input to the vflip filter
  1789. noformat=yuv420p,vflip
  1790. # convert the input video to any of the formats not contained in the list
  1791. noformat=yuv420p:yuv444p:yuv410p
  1792. @end example
  1793. @section null
  1794. Pass the video source unchanged to the output.
  1795. @section ocv
  1796. Apply video transform using libopencv.
  1797. To enable this filter install libopencv library and headers and
  1798. configure FFmpeg with @code{--enable-libopencv}.
  1799. The filter takes the parameters: @var{filter_name}@{:=@}@var{filter_params}.
  1800. @var{filter_name} is the name of the libopencv filter to apply.
  1801. @var{filter_params} specifies the parameters to pass to the libopencv
  1802. filter. If not specified the default values are assumed.
  1803. Refer to the official libopencv documentation for more precise
  1804. information:
  1805. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  1806. Follows the list of supported libopencv filters.
  1807. @anchor{dilate}
  1808. @subsection dilate
  1809. Dilate an image by using a specific structuring element.
  1810. This filter corresponds to the libopencv function @code{cvDilate}.
  1811. It accepts the parameters: @var{struct_el}:@var{nb_iterations}.
  1812. @var{struct_el} represents a structuring element, and has the syntax:
  1813. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  1814. @var{cols} and @var{rows} represent the number of columns and rows of
  1815. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  1816. point, and @var{shape} the shape for the structuring element, and
  1817. can be one of the values "rect", "cross", "ellipse", "custom".
  1818. If the value for @var{shape} is "custom", it must be followed by a
  1819. string of the form "=@var{filename}". The file with name
  1820. @var{filename} is assumed to represent a binary image, with each
  1821. printable character corresponding to a bright pixel. When a custom
  1822. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  1823. or columns and rows of the read file are assumed instead.
  1824. The default value for @var{struct_el} is "3x3+0x0/rect".
  1825. @var{nb_iterations} specifies the number of times the transform is
  1826. applied to the image, and defaults to 1.
  1827. Follow some example:
  1828. @example
  1829. # use the default values
  1830. ocv=dilate
  1831. # dilate using a structuring element with a 5x5 cross, iterate two times
  1832. ocv=dilate=5x5+2x2/cross:2
  1833. # read the shape from the file diamond.shape, iterate two times
  1834. # the file diamond.shape may contain a pattern of characters like this:
  1835. # *
  1836. # ***
  1837. # *****
  1838. # ***
  1839. # *
  1840. # the specified cols and rows are ignored (but not the anchor point coordinates)
  1841. ocv=0x0+2x2/custom=diamond.shape:2
  1842. @end example
  1843. @subsection erode
  1844. Erode an image by using a specific structuring element.
  1845. This filter corresponds to the libopencv function @code{cvErode}.
  1846. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
  1847. with the same syntax and semantics as the @ref{dilate} filter.
  1848. @subsection smooth
  1849. Smooth the input video.
  1850. The filter takes the following parameters:
  1851. @var{type}:@var{param1}:@var{param2}:@var{param3}:@var{param4}.
  1852. @var{type} is the type of smooth filter to apply, and can be one of
  1853. the following values: "blur", "blur_no_scale", "median", "gaussian",
  1854. "bilateral". The default value is "gaussian".
  1855. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  1856. parameters whose meanings depend on smooth type. @var{param1} and
  1857. @var{param2} accept integer positive values or 0, @var{param3} and
  1858. @var{param4} accept float values.
  1859. The default value for @var{param1} is 3, the default value for the
  1860. other parameters is 0.
  1861. These parameters correspond to the parameters assigned to the
  1862. libopencv function @code{cvSmooth}.
  1863. @anchor{overlay}
  1864. @section overlay
  1865. Overlay one video on top of another.
  1866. It takes two inputs and one output, the first input is the "main"
  1867. video on which the second input is overlayed.
  1868. It accepts the parameters: @var{x}:@var{y}[:@var{options}].
  1869. @var{x} is the x coordinate of the overlayed video on the main video,
  1870. @var{y} is the y coordinate. @var{x} and @var{y} are expressions containing
  1871. the following parameters:
  1872. @table @option
  1873. @item main_w, main_h
  1874. main input width and height
  1875. @item W, H
  1876. same as @var{main_w} and @var{main_h}
  1877. @item overlay_w, overlay_h
  1878. overlay input width and height
  1879. @item w, h
  1880. same as @var{overlay_w} and @var{overlay_h}
  1881. @end table
  1882. @var{options} is an optional list of @var{key}=@var{value} pairs,
  1883. separated by ":".
  1884. The description of the accepted options follows.
  1885. @table @option
  1886. @item rgb
  1887. If set to 1, force the filter to accept inputs in the RGB
  1888. color space. Default value is 0.
  1889. @end table
  1890. Be aware that frames are taken from each input video in timestamp
  1891. order, hence, if their initial timestamps differ, it is a a good idea
  1892. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  1893. have them begin in the same zero timestamp, as it does the example for
  1894. the @var{movie} filter.
  1895. Follow some examples:
  1896. @example
  1897. # draw the overlay at 10 pixels from the bottom right
  1898. # corner of the main video.
  1899. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  1900. # insert a transparent PNG logo in the bottom left corner of the input
  1901. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  1902. # insert 2 different transparent PNG logos (second logo on bottom
  1903. # right corner):
  1904. ffmpeg -i input -i logo1 -i logo2 -filter_complex
  1905. 'overlay=10:H-h-10,overlay=W-w-10:H-h-10' output
  1906. # add a transparent color layer on top of the main video,
  1907. # WxH specifies the size of the main input to the overlay filter
  1908. color=red@.3:WxH [over]; [in][over] overlay [out]
  1909. # play an original video and a filtered version (here with the deshake filter)
  1910. # side by side
  1911. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  1912. # the previous example is the same as:
  1913. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  1914. @end example
  1915. You can chain together more overlays but the efficiency of such
  1916. approach is yet to be tested.
  1917. @section pad
  1918. Add paddings to the input image, and places the original input at the
  1919. given coordinates @var{x}, @var{y}.
  1920. It accepts the following parameters:
  1921. @var{width}:@var{height}:@var{x}:@var{y}:@var{color}.
  1922. The parameters @var{width}, @var{height}, @var{x}, and @var{y} are
  1923. expressions containing the following constants:
  1924. @table @option
  1925. @item in_w, in_h
  1926. the input video width and height
  1927. @item iw, ih
  1928. same as @var{in_w} and @var{in_h}
  1929. @item out_w, out_h
  1930. the output width and height, that is the size of the padded area as
  1931. specified by the @var{width} and @var{height} expressions
  1932. @item ow, oh
  1933. same as @var{out_w} and @var{out_h}
  1934. @item x, y
  1935. x and y offsets as specified by the @var{x} and @var{y}
  1936. expressions, or NAN if not yet specified
  1937. @item a
  1938. same as @var{iw} / @var{ih}
  1939. @item sar
  1940. input sample aspect ratio
  1941. @item dar
  1942. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  1943. @item hsub, vsub
  1944. horizontal and vertical chroma subsample values. For example for the
  1945. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1946. @end table
  1947. Follows the description of the accepted parameters.
  1948. @table @option
  1949. @item width, height
  1950. Specify the size of the output image with the paddings added. If the
  1951. value for @var{width} or @var{height} is 0, the corresponding input size
  1952. is used for the output.
  1953. The @var{width} expression can reference the value set by the
  1954. @var{height} expression, and vice versa.
  1955. The default value of @var{width} and @var{height} is 0.
  1956. @item x, y
  1957. Specify the offsets where to place the input image in the padded area
  1958. with respect to the top/left border of the output image.
  1959. The @var{x} expression can reference the value set by the @var{y}
  1960. expression, and vice versa.
  1961. The default value of @var{x} and @var{y} is 0.
  1962. @item color
  1963. Specify the color of the padded area, it can be the name of a color
  1964. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  1965. The default value of @var{color} is "black".
  1966. @end table
  1967. Some examples follow:
  1968. @example
  1969. # Add paddings with color "violet" to the input video. Output video
  1970. # size is 640x480, the top-left corner of the input video is placed at
  1971. # column 0, row 40.
  1972. pad=640:480:0:40:violet
  1973. # pad the input to get an output with dimensions increased bt 3/2,
  1974. # and put the input video at the center of the padded area
  1975. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  1976. # pad the input to get a squared output with size equal to the maximum
  1977. # value between the input width and height, and put the input video at
  1978. # the center of the padded area
  1979. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  1980. # pad the input to get a final w/h ratio of 16:9
  1981. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  1982. # for anamorphic video, in order to set the output display aspect ratio,
  1983. # it is necessary to use sar in the expression, according to the relation:
  1984. # (ih * X / ih) * sar = output_dar
  1985. # X = output_dar / sar
  1986. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  1987. # double output size and put the input video in the bottom-right
  1988. # corner of the output padded area
  1989. pad="2*iw:2*ih:ow-iw:oh-ih"
  1990. @end example
  1991. @section pixdesctest
  1992. Pixel format descriptor test filter, mainly useful for internal
  1993. testing. The output video should be equal to the input video.
  1994. For example:
  1995. @example
  1996. format=monow, pixdesctest
  1997. @end example
  1998. can be used to test the monowhite pixel format descriptor definition.
  1999. @section removelogo
  2000. Suppress a TV station logo, using an image file to determine which
  2001. pixels comprise the logo. It works by filling in the pixels that
  2002. comprise the logo with neighboring pixels.
  2003. This filter requires one argument which specifies the filter bitmap
  2004. file, which can be any image format supported by libavformat. The
  2005. width and height of the image file must match those of the video
  2006. stream being processed.
  2007. Pixels in the provided bitmap image with a value of zero are not
  2008. considered part of the logo, non-zero pixels are considered part of
  2009. the logo. If you use white (255) for the logo and black (0) for the
  2010. rest, you will be safe. For making the filter bitmap, it is
  2011. recommended to take a screen capture of a black frame with the logo
  2012. visible, and then using a threshold filter followed by the erode
  2013. filter once or twice.
  2014. If needed, little splotches can be fixed manually. Remember that if
  2015. logo pixels are not covered, the filter quality will be much
  2016. reduced. Marking too many pixels as part of the logo does not hurt as
  2017. much, but it will increase the amount of blurring needed to cover over
  2018. the image and will destroy more information than necessary, and extra
  2019. pixels will slow things down on a large logo.
  2020. @section scale
  2021. Scale the input video to @var{width}:@var{height}[:@var{interl}=@{1|-1@}] and/or convert the image format.
  2022. The scale filter forces the output display aspect ratio to be the same
  2023. of the input, by changing the output sample aspect ratio.
  2024. The parameters @var{width} and @var{height} are expressions containing
  2025. the following constants:
  2026. @table @option
  2027. @item in_w, in_h
  2028. the input width and height
  2029. @item iw, ih
  2030. same as @var{in_w} and @var{in_h}
  2031. @item out_w, out_h
  2032. the output (cropped) width and height
  2033. @item ow, oh
  2034. same as @var{out_w} and @var{out_h}
  2035. @item a
  2036. same as @var{iw} / @var{ih}
  2037. @item sar
  2038. input sample aspect ratio
  2039. @item dar
  2040. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2041. @item hsub, vsub
  2042. horizontal and vertical chroma subsample values. For example for the
  2043. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2044. @end table
  2045. If the input image format is different from the format requested by
  2046. the next filter, the scale filter will convert the input to the
  2047. requested format.
  2048. If the value for @var{width} or @var{height} is 0, the respective input
  2049. size is used for the output.
  2050. If the value for @var{width} or @var{height} is -1, the scale filter will
  2051. use, for the respective output size, a value that maintains the aspect
  2052. ratio of the input image.
  2053. The default value of @var{width} and @var{height} is 0.
  2054. Valid values for the optional parameter @var{interl} are:
  2055. @table @option
  2056. @item 1
  2057. force interlaced aware scaling
  2058. @item -1
  2059. select interlaced aware scaling depending on whether the source frames
  2060. are flagged as interlaced or not
  2061. @end table
  2062. Unless @var{interl} is set to one of the above options, interlaced scaling will not be used.
  2063. Some examples follow:
  2064. @example
  2065. # scale the input video to a size of 200x100.
  2066. scale=200:100
  2067. # scale the input to 2x
  2068. scale=2*iw:2*ih
  2069. # the above is the same as
  2070. scale=2*in_w:2*in_h
  2071. # scale the input to 2x with forced interlaced scaling
  2072. scale=2*iw:2*ih:interl=1
  2073. # scale the input to half size
  2074. scale=iw/2:ih/2
  2075. # increase the width, and set the height to the same size
  2076. scale=3/2*iw:ow
  2077. # seek for Greek harmony
  2078. scale=iw:1/PHI*iw
  2079. scale=ih*PHI:ih
  2080. # increase the height, and set the width to 3/2 of the height
  2081. scale=3/2*oh:3/5*ih
  2082. # increase the size, but make the size a multiple of the chroma
  2083. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  2084. # increase the width to a maximum of 500 pixels, keep the same input aspect ratio
  2085. scale='min(500\, iw*3/2):-1'
  2086. @end example
  2087. @section select
  2088. Select frames to pass in output.
  2089. It accepts in input an expression, which is evaluated for each input
  2090. frame. If the expression is evaluated to a non-zero value, the frame
  2091. is selected and passed to the output, otherwise it is discarded.
  2092. The expression can contain the following constants:
  2093. @table @option
  2094. @item n
  2095. the sequential number of the filtered frame, starting from 0
  2096. @item selected_n
  2097. the sequential number of the selected frame, starting from 0
  2098. @item prev_selected_n
  2099. the sequential number of the last selected frame, NAN if undefined
  2100. @item TB
  2101. timebase of the input timestamps
  2102. @item pts
  2103. the PTS (Presentation TimeStamp) of the filtered video frame,
  2104. expressed in @var{TB} units, NAN if undefined
  2105. @item t
  2106. the PTS (Presentation TimeStamp) of the filtered video frame,
  2107. expressed in seconds, NAN if undefined
  2108. @item prev_pts
  2109. the PTS of the previously filtered video frame, NAN if undefined
  2110. @item prev_selected_pts
  2111. the PTS of the last previously filtered video frame, NAN if undefined
  2112. @item prev_selected_t
  2113. the PTS of the last previously selected video frame, NAN if undefined
  2114. @item start_pts
  2115. the PTS of the first video frame in the video, NAN if undefined
  2116. @item start_t
  2117. the time of the first video frame in the video, NAN if undefined
  2118. @item pict_type
  2119. the type of the filtered frame, can assume one of the following
  2120. values:
  2121. @table @option
  2122. @item I
  2123. @item P
  2124. @item B
  2125. @item S
  2126. @item SI
  2127. @item SP
  2128. @item BI
  2129. @end table
  2130. @item interlace_type
  2131. the frame interlace type, can assume one of the following values:
  2132. @table @option
  2133. @item PROGRESSIVE
  2134. the frame is progressive (not interlaced)
  2135. @item TOPFIRST
  2136. the frame is top-field-first
  2137. @item BOTTOMFIRST
  2138. the frame is bottom-field-first
  2139. @end table
  2140. @item key
  2141. 1 if the filtered frame is a key-frame, 0 otherwise
  2142. @item pos
  2143. the position in the file of the filtered frame, -1 if the information
  2144. is not available (e.g. for synthetic video)
  2145. @item scene
  2146. value between 0 and 1 to indicate a new scene; a low value reflects a low
  2147. probability for the current frame to introduce a new scene, while a higher
  2148. value means the current frame is more likely to be one (see the example below)
  2149. @end table
  2150. The default value of the select expression is "1".
  2151. Some examples follow:
  2152. @example
  2153. # select all frames in input
  2154. select
  2155. # the above is the same as:
  2156. select=1
  2157. # skip all frames:
  2158. select=0
  2159. # select only I-frames
  2160. select='eq(pict_type\,I)'
  2161. # select one frame every 100
  2162. select='not(mod(n\,100))'
  2163. # select only frames contained in the 10-20 time interval
  2164. select='gte(t\,10)*lte(t\,20)'
  2165. # select only I frames contained in the 10-20 time interval
  2166. select='gte(t\,10)*lte(t\,20)*eq(pict_type\,I)'
  2167. # select frames with a minimum distance of 10 seconds
  2168. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  2169. @end example
  2170. Complete example to create a mosaic of the first scenes:
  2171. @example
  2172. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  2173. @end example
  2174. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  2175. choice.
  2176. @section setdar, setsar
  2177. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  2178. output video.
  2179. This is done by changing the specified Sample (aka Pixel) Aspect
  2180. Ratio, according to the following equation:
  2181. @example
  2182. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  2183. @end example
  2184. Keep in mind that the @code{setdar} filter does not modify the pixel
  2185. dimensions of the video frame. Also the display aspect ratio set by
  2186. this filter may be changed by later filters in the filterchain,
  2187. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  2188. applied.
  2189. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  2190. the filter output video.
  2191. Note that as a consequence of the application of this filter, the
  2192. output display aspect ratio will change according to the equation
  2193. above.
  2194. Keep in mind that the sample aspect ratio set by the @code{setsar}
  2195. filter may be changed by later filters in the filterchain, e.g. if
  2196. another "setsar" or a "setdar" filter is applied.
  2197. The @code{setdar} and @code{setsar} filters accept a parameter string
  2198. which represents the wanted aspect ratio. The parameter can
  2199. be a floating point number string, an expression, or a string of the form
  2200. @var{num}:@var{den}, where @var{num} and @var{den} are the numerator
  2201. and denominator of the aspect ratio. If the parameter is not
  2202. specified, it is assumed the value "0:1".
  2203. For example to change the display aspect ratio to 16:9, specify:
  2204. @example
  2205. setdar=16:9
  2206. @end example
  2207. The example above is equivalent to:
  2208. @example
  2209. setdar=1.77777
  2210. @end example
  2211. To change the sample aspect ratio to 10:11, specify:
  2212. @example
  2213. setsar=10:11
  2214. @end example
  2215. @section setfield
  2216. Force field for the output video frame.
  2217. The @code{setfield} filter marks the interlace type field for the
  2218. output frames. It does not change the input frame, but only sets the
  2219. corresponding property, which affects how the frame is treated by
  2220. following filters (e.g. @code{fieldorder} or @code{yadif}).
  2221. It accepts a string parameter, which can assume the following values:
  2222. @table @samp
  2223. @item auto
  2224. Keep the same field property.
  2225. @item bff
  2226. Mark the frame as bottom-field-first.
  2227. @item tff
  2228. Mark the frame as top-field-first.
  2229. @item prog
  2230. Mark the frame as progressive.
  2231. @end table
  2232. @section setpts
  2233. Change the PTS (presentation timestamp) of the input video frames.
  2234. Accept in input an expression evaluated through the eval API, which
  2235. can contain the following constants:
  2236. @table @option
  2237. @item PTS
  2238. the presentation timestamp in input
  2239. @item N
  2240. the count of the input frame, starting from 0.
  2241. @item STARTPTS
  2242. the PTS of the first video frame
  2243. @item INTERLACED
  2244. tell if the current frame is interlaced
  2245. @item TB
  2246. the time base
  2247. @item POS
  2248. original position in the file of the frame, or undefined if undefined
  2249. for the current frame
  2250. @item PREV_INPTS
  2251. previous input PTS
  2252. @item PREV_OUTPTS
  2253. previous output PTS
  2254. @end table
  2255. Some examples follow:
  2256. @example
  2257. # start counting PTS from zero
  2258. setpts=PTS-STARTPTS
  2259. # fast motion
  2260. setpts=0.5*PTS
  2261. # slow motion
  2262. setpts=2.0*PTS
  2263. # fixed rate 25 fps
  2264. setpts=N/(25*TB)
  2265. # fixed rate 25 fps with some jitter
  2266. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  2267. @end example
  2268. @section settb, asettb
  2269. Set the timebase to use for the output frames timestamps.
  2270. It is mainly useful for testing timebase configuration.
  2271. It accepts in input an arithmetic expression representing a rational.
  2272. The expression can contain the constants "AVTB" (the
  2273. default timebase), "intb" (the input timebase) and "sr" (the sample rate,
  2274. audio only).
  2275. The default value for the input is "intb".
  2276. Follow some examples.
  2277. @example
  2278. # set the timebase to 1/25
  2279. settb=1/25
  2280. # set the timebase to 1/10
  2281. settb=0.1
  2282. #set the timebase to 1001/1000
  2283. settb=1+0.001
  2284. #set the timebase to 2*intb
  2285. settb=2*intb
  2286. #set the default timebase value
  2287. settb=AVTB
  2288. @end example
  2289. @section showinfo
  2290. Show a line containing various information for each input video frame.
  2291. The input video is not modified.
  2292. The shown line contains a sequence of key/value pairs of the form
  2293. @var{key}:@var{value}.
  2294. A description of each shown parameter follows:
  2295. @table @option
  2296. @item n
  2297. sequential number of the input frame, starting from 0
  2298. @item pts
  2299. Presentation TimeStamp of the input frame, expressed as a number of
  2300. time base units. The time base unit depends on the filter input pad.
  2301. @item pts_time
  2302. Presentation TimeStamp of the input frame, expressed as a number of
  2303. seconds
  2304. @item pos
  2305. position of the frame in the input stream, -1 if this information in
  2306. unavailable and/or meaningless (for example in case of synthetic video)
  2307. @item fmt
  2308. pixel format name
  2309. @item sar
  2310. sample aspect ratio of the input frame, expressed in the form
  2311. @var{num}/@var{den}
  2312. @item s
  2313. size of the input frame, expressed in the form
  2314. @var{width}x@var{height}
  2315. @item i
  2316. interlaced mode ("P" for "progressive", "T" for top field first, "B"
  2317. for bottom field first)
  2318. @item iskey
  2319. 1 if the frame is a key frame, 0 otherwise
  2320. @item type
  2321. picture type of the input frame ("I" for an I-frame, "P" for a
  2322. P-frame, "B" for a B-frame, "?" for unknown type).
  2323. Check also the documentation of the @code{AVPictureType} enum and of
  2324. the @code{av_get_picture_type_char} function defined in
  2325. @file{libavutil/avutil.h}.
  2326. @item checksum
  2327. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  2328. @item plane_checksum
  2329. Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  2330. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]"
  2331. @end table
  2332. @section slicify
  2333. Pass the images of input video on to next video filter as multiple
  2334. slices.
  2335. @example
  2336. ffmpeg -i in.avi -vf "slicify=32" out.avi
  2337. @end example
  2338. The filter accepts the slice height as parameter. If the parameter is
  2339. not specified it will use the default value of 16.
  2340. Adding this in the beginning of filter chains should make filtering
  2341. faster due to better use of the memory cache.
  2342. @section split
  2343. Split input video into several identical outputs.
  2344. The filter accepts a single parameter which specifies the number of outputs. If
  2345. unspecified, it defaults to 2.
  2346. For example
  2347. @example
  2348. ffmpeg -i INPUT -filter_complex split=5 OUTPUT
  2349. @end example
  2350. will create 5 copies of the input video.
  2351. For example:
  2352. @example
  2353. [in] split [splitout1][splitout2];
  2354. [splitout1] crop=100:100:0:0 [cropout];
  2355. [splitout2] pad=200:200:100:100 [padout];
  2356. @end example
  2357. will create two separate outputs from the same input, one cropped and
  2358. one padded.
  2359. @section super2xsai
  2360. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  2361. Interpolate) pixel art scaling algorithm.
  2362. Useful for enlarging pixel art images without reducing sharpness.
  2363. @section swapuv
  2364. Swap U & V plane.
  2365. @section thumbnail
  2366. Select the most representative frame in a given sequence of consecutive frames.
  2367. It accepts as argument the frames batch size to analyze (default @var{N}=100);
  2368. in a set of @var{N} frames, the filter will pick one of them, and then handle
  2369. the next batch of @var{N} frames until the end.
  2370. Since the filter keeps track of the whole frames sequence, a bigger @var{N}
  2371. value will result in a higher memory usage, so a high value is not recommended.
  2372. The following example extract one picture each 50 frames:
  2373. @example
  2374. thumbnail=50
  2375. @end example
  2376. Complete example of a thumbnail creation with @command{ffmpeg}:
  2377. @example
  2378. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  2379. @end example
  2380. @section tile
  2381. Tile several successive frames together.
  2382. It accepts as argument the tile size (i.e. the number of lines and columns)
  2383. in the form "@var{w}x@var{h}".
  2384. For example, produce 8×8 PNG tiles of all keyframes (@option{-skip_frame
  2385. nokey}) in a movie:
  2386. @example
  2387. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  2388. @end example
  2389. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  2390. duplicating each output frame to accomodate the originally detected frame
  2391. rate.
  2392. @section tinterlace
  2393. Perform various types of temporal field interlacing.
  2394. Frames are counted starting from 1, so the first input frame is
  2395. considered odd.
  2396. This filter accepts a single parameter specifying the mode. Available
  2397. modes are:
  2398. @table @samp
  2399. @item merge, 0
  2400. Move odd frames into the upper field, even into the lower field,
  2401. generating a double height frame at half framerate.
  2402. @item drop_odd, 1
  2403. Only output even frames, odd frames are dropped, generating a frame with
  2404. unchanged height at half framerate.
  2405. @item drop_even, 2
  2406. Only output odd frames, even frames are dropped, generating a frame with
  2407. unchanged height at half framerate.
  2408. @item pad, 3
  2409. Expand each frame to full height, but pad alternate lines with black,
  2410. generating a frame with double height at the same input framerate.
  2411. @item interleave_top, 4
  2412. Interleave the upper field from odd frames with the lower field from
  2413. even frames, generating a frame with unchanged height at half framerate.
  2414. @item interleave_bottom, 5
  2415. Interleave the lower field from odd frames with the upper field from
  2416. even frames, generating a frame with unchanged height at half framerate.
  2417. @item interlacex2, 6
  2418. Double frame rate with unchanged height. Frames are inserted each
  2419. containing the second temporal field from the previous input frame and
  2420. the first temporal field from the next input frame. This mode relies on
  2421. the top_field_first flag. Useful for interlaced video displays with no
  2422. field synchronisation.
  2423. @end table
  2424. Numeric values are deprecated but are accepted for backward
  2425. compatibility reasons.
  2426. Default mode is @code{merge}.
  2427. @section transpose
  2428. Transpose rows with columns in the input video and optionally flip it.
  2429. It accepts a parameter representing an integer, which can assume the
  2430. values:
  2431. @table @samp
  2432. @item 0
  2433. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  2434. @example
  2435. L.R L.l
  2436. . . -> . .
  2437. l.r R.r
  2438. @end example
  2439. @item 1
  2440. Rotate by 90 degrees clockwise, that is:
  2441. @example
  2442. L.R l.L
  2443. . . -> . .
  2444. l.r r.R
  2445. @end example
  2446. @item 2
  2447. Rotate by 90 degrees counterclockwise, that is:
  2448. @example
  2449. L.R R.r
  2450. . . -> . .
  2451. l.r L.l
  2452. @end example
  2453. @item 3
  2454. Rotate by 90 degrees clockwise and vertically flip, that is:
  2455. @example
  2456. L.R r.R
  2457. . . -> . .
  2458. l.r l.L
  2459. @end example
  2460. @end table
  2461. @section unsharp
  2462. Sharpen or blur the input video.
  2463. It accepts the following parameters:
  2464. @var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount}
  2465. Negative values for the amount will blur the input video, while positive
  2466. values will sharpen. All parameters are optional and default to the
  2467. equivalent of the string '5:5:1.0:5:5:0.0'.
  2468. @table @option
  2469. @item luma_msize_x
  2470. Set the luma matrix horizontal size. It can be an integer between 3
  2471. and 13, default value is 5.
  2472. @item luma_msize_y
  2473. Set the luma matrix vertical size. It can be an integer between 3
  2474. and 13, default value is 5.
  2475. @item luma_amount
  2476. Set the luma effect strength. It can be a float number between -2.0
  2477. and 5.0, default value is 1.0.
  2478. @item chroma_msize_x
  2479. Set the chroma matrix horizontal size. It can be an integer between 3
  2480. and 13, default value is 5.
  2481. @item chroma_msize_y
  2482. Set the chroma matrix vertical size. It can be an integer between 3
  2483. and 13, default value is 5.
  2484. @item chroma_amount
  2485. Set the chroma effect strength. It can be a float number between -2.0
  2486. and 5.0, default value is 0.0.
  2487. @end table
  2488. @example
  2489. # Strong luma sharpen effect parameters
  2490. unsharp=7:7:2.5
  2491. # Strong blur of both luma and chroma parameters
  2492. unsharp=7:7:-2:7:7:-2
  2493. # Use the default values with @command{ffmpeg}
  2494. ffmpeg -i in.avi -vf "unsharp" out.mp4
  2495. @end example
  2496. @section vflip
  2497. Flip the input video vertically.
  2498. @example
  2499. ffmpeg -i in.avi -vf "vflip" out.avi
  2500. @end example
  2501. @section yadif
  2502. Deinterlace the input video ("yadif" means "yet another deinterlacing
  2503. filter").
  2504. It accepts the optional parameters: @var{mode}:@var{parity}:@var{auto}.
  2505. @var{mode} specifies the interlacing mode to adopt, accepts one of the
  2506. following values:
  2507. @table @option
  2508. @item 0
  2509. output 1 frame for each frame
  2510. @item 1
  2511. output 1 frame for each field
  2512. @item 2
  2513. like 0 but skips spatial interlacing check
  2514. @item 3
  2515. like 1 but skips spatial interlacing check
  2516. @end table
  2517. Default value is 0.
  2518. @var{parity} specifies the picture field parity assumed for the input
  2519. interlaced video, accepts one of the following values:
  2520. @table @option
  2521. @item 0
  2522. assume top field first
  2523. @item 1
  2524. assume bottom field first
  2525. @item -1
  2526. enable automatic detection
  2527. @end table
  2528. Default value is -1.
  2529. If interlacing is unknown or decoder does not export this information,
  2530. top field first will be assumed.
  2531. @var{auto} specifies if deinterlacer should trust the interlaced flag
  2532. and only deinterlace frames marked as interlaced
  2533. @table @option
  2534. @item 0
  2535. deinterlace all frames
  2536. @item 1
  2537. only deinterlace frames marked as interlaced
  2538. @end table
  2539. Default value is 0.
  2540. @c man end VIDEO FILTERS
  2541. @chapter Video Sources
  2542. @c man begin VIDEO SOURCES
  2543. Below is a description of the currently available video sources.
  2544. @section buffer
  2545. Buffer video frames, and make them available to the filter chain.
  2546. This source is mainly intended for a programmatic use, in particular
  2547. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  2548. It accepts a list of options in the form of @var{key}=@var{value} pairs
  2549. separated by ":". A descroption of the accepted options follows.
  2550. @table @option
  2551. @item video_size
  2552. Specify the size (width and height) of the buffered video frames.
  2553. @item pix_fmt
  2554. A string representing the pixel format of the buffered video frames.
  2555. It may be a number corresponding to a pixel format, or a pixel format
  2556. name.
  2557. @item time_base
  2558. Specify the timebase assumed by the timestamps of the buffered frames.
  2559. @item time_base
  2560. Specify the frame rate expected for the video stream.
  2561. @item pixel_aspect
  2562. Specify the sample aspect ratio assumed by the video frames.
  2563. @item sws_param
  2564. Specify the optional parameters to be used for the scale filter which
  2565. is automatically inserted when an input change is detected in the
  2566. input size or format.
  2567. @end table
  2568. For example:
  2569. @example
  2570. buffer=size=320x240:pix_fmt=yuv410p:time_base=1/24:pixel_aspect=1/1
  2571. @end example
  2572. will instruct the source to accept video frames with size 320x240 and
  2573. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  2574. square pixels (1:1 sample aspect ratio).
  2575. Since the pixel format with name "yuv410p" corresponds to the number 6
  2576. (check the enum PixelFormat definition in @file{libavutil/pixfmt.h}),
  2577. this example corresponds to:
  2578. @example
  2579. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  2580. @end example
  2581. Alternatively, the options can be specified as a flat string, but this
  2582. syntax is deprecated:
  2583. @var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}[:@var{sws_param}]
  2584. @section cellauto
  2585. Create a pattern generated by an elementary cellular automaton.
  2586. The initial state of the cellular automaton can be defined through the
  2587. @option{filename}, and @option{pattern} options. If such options are
  2588. not specified an initial state is created randomly.
  2589. At each new frame a new row in the video is filled with the result of
  2590. the cellular automaton next generation. The behavior when the whole
  2591. frame is filled is defined by the @option{scroll} option.
  2592. This source accepts a list of options in the form of
  2593. @var{key}=@var{value} pairs separated by ":". A description of the
  2594. accepted options follows.
  2595. @table @option
  2596. @item filename, f
  2597. Read the initial cellular automaton state, i.e. the starting row, from
  2598. the specified file.
  2599. In the file, each non-whitespace character is considered an alive
  2600. cell, a newline will terminate the row, and further characters in the
  2601. file will be ignored.
  2602. @item pattern, p
  2603. Read the initial cellular automaton state, i.e. the starting row, from
  2604. the specified string.
  2605. Each non-whitespace character in the string is considered an alive
  2606. cell, a newline will terminate the row, and further characters in the
  2607. string will be ignored.
  2608. @item rate, r
  2609. Set the video rate, that is the number of frames generated per second.
  2610. Default is 25.
  2611. @item random_fill_ratio, ratio
  2612. Set the random fill ratio for the initial cellular automaton row. It
  2613. is a floating point number value ranging from 0 to 1, defaults to
  2614. 1/PHI.
  2615. This option is ignored when a file or a pattern is specified.
  2616. @item random_seed, seed
  2617. Set the seed for filling randomly the initial row, must be an integer
  2618. included between 0 and UINT32_MAX. If not specified, or if explicitly
  2619. set to -1, the filter will try to use a good random seed on a best
  2620. effort basis.
  2621. @item rule
  2622. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  2623. Default value is 110.
  2624. @item size, s
  2625. Set the size of the output video.
  2626. If @option{filename} or @option{pattern} is specified, the size is set
  2627. by default to the width of the specified initial state row, and the
  2628. height is set to @var{width} * PHI.
  2629. If @option{size} is set, it must contain the width of the specified
  2630. pattern string, and the specified pattern will be centered in the
  2631. larger row.
  2632. If a filename or a pattern string is not specified, the size value
  2633. defaults to "320x518" (used for a randomly generated initial state).
  2634. @item scroll
  2635. If set to 1, scroll the output upward when all the rows in the output
  2636. have been already filled. If set to 0, the new generated row will be
  2637. written over the top row just after the bottom row is filled.
  2638. Defaults to 1.
  2639. @item start_full, full
  2640. If set to 1, completely fill the output with generated rows before
  2641. outputting the first frame.
  2642. This is the default behavior, for disabling set the value to 0.
  2643. @item stitch
  2644. If set to 1, stitch the left and right row edges together.
  2645. This is the default behavior, for disabling set the value to 0.
  2646. @end table
  2647. @subsection Examples
  2648. @itemize
  2649. @item
  2650. Read the initial state from @file{pattern}, and specify an output of
  2651. size 200x400.
  2652. @example
  2653. cellauto=f=pattern:s=200x400
  2654. @end example
  2655. @item
  2656. Generate a random initial row with a width of 200 cells, with a fill
  2657. ratio of 2/3:
  2658. @example
  2659. cellauto=ratio=2/3:s=200x200
  2660. @end example
  2661. @item
  2662. Create a pattern generated by rule 18 starting by a single alive cell
  2663. centered on an initial row with width 100:
  2664. @example
  2665. cellauto=p=@@:s=100x400:full=0:rule=18
  2666. @end example
  2667. @item
  2668. Specify a more elaborated initial pattern:
  2669. @example
  2670. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  2671. @end example
  2672. @end itemize
  2673. @section color
  2674. Provide an uniformly colored input.
  2675. This source accepts list of options in the form of
  2676. @var{key}=@var{value} pairs separated by ":".
  2677. Follows the description of the accepted parameters.
  2678. @table @option
  2679. @item color, c
  2680. Specify the color of the source. It can be the name of a color (case
  2681. insensitive match) or a 0xRRGGBB[AA] sequence, possibly followed by an
  2682. alpha specifier. The default value is "black".
  2683. @item size, s
  2684. Specify the size of the sourced video, it may be a string of the form
  2685. @var{width}x@var{height}, or the name of a size abbreviation. The
  2686. default value is "320x240".
  2687. @item rate, r
  2688. Specify the frame rate of the sourced video, as the number of frames
  2689. generated per second. It has to be a string in the format
  2690. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  2691. number or a valid video frame rate abbreviation. The default value is
  2692. "25".
  2693. @end table
  2694. For example the following graph description will generate a red source
  2695. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  2696. frames per second, which will be overlayed over the source connected
  2697. to the pad with identifier "in".
  2698. @example
  2699. "color=c=red@@0.2:s=qcif:r=10 [color]; [in][color] overlay [out]"
  2700. @end example
  2701. @section mptestsrc
  2702. Generate various test patterns, as generated by the MPlayer test filter.
  2703. The size of the generated video is fixed, and is 256x256.
  2704. This source is useful in particular for testing encoding features.
  2705. This source accepts an optional sequence of @var{key}=@var{value} pairs,
  2706. separated by ":". The description of the accepted options follows.
  2707. @table @option
  2708. @item rate, r
  2709. Specify the frame rate of the sourced video, as the number of frames
  2710. generated per second. It has to be a string in the format
  2711. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  2712. number or a valid video frame rate abbreviation. The default value is
  2713. "25".
  2714. @item duration, d
  2715. Set the video duration of the sourced video. The accepted syntax is:
  2716. @example
  2717. [-]HH:MM:SS[.m...]
  2718. [-]S+[.m...]
  2719. @end example
  2720. See also the function @code{av_parse_time()}.
  2721. If not specified, or the expressed duration is negative, the video is
  2722. supposed to be generated forever.
  2723. @item test, t
  2724. Set the number or the name of the test to perform. Supported tests are:
  2725. @table @option
  2726. @item dc_luma
  2727. @item dc_chroma
  2728. @item freq_luma
  2729. @item freq_chroma
  2730. @item amp_luma
  2731. @item amp_chroma
  2732. @item cbp
  2733. @item mv
  2734. @item ring1
  2735. @item ring2
  2736. @item all
  2737. @end table
  2738. Default value is "all", which will cycle through the list of all tests.
  2739. @end table
  2740. For example the following:
  2741. @example
  2742. testsrc=t=dc_luma
  2743. @end example
  2744. will generate a "dc_luma" test pattern.
  2745. @section frei0r_src
  2746. Provide a frei0r source.
  2747. To enable compilation of this filter you need to install the frei0r
  2748. header and configure FFmpeg with @code{--enable-frei0r}.
  2749. The source supports the syntax:
  2750. @example
  2751. @var{size}:@var{rate}:@var{src_name}[@{=|:@}@var{param1}:@var{param2}:...:@var{paramN}]
  2752. @end example
  2753. @var{size} is the size of the video to generate, may be a string of the
  2754. form @var{width}x@var{height} or a frame size abbreviation.
  2755. @var{rate} is the rate of the video to generate, may be a string of
  2756. the form @var{num}/@var{den} or a frame rate abbreviation.
  2757. @var{src_name} is the name to the frei0r source to load. For more
  2758. information regarding frei0r and how to set the parameters read the
  2759. section @ref{frei0r} in the description of the video filters.
  2760. For example, to generate a frei0r partik0l source with size 200x200
  2761. and frame rate 10 which is overlayed on the overlay filter main input:
  2762. @example
  2763. frei0r_src=200x200:10:partik0l=1234 [overlay]; [in][overlay] overlay
  2764. @end example
  2765. @section life
  2766. Generate a life pattern.
  2767. This source is based on a generalization of John Conway's life game.
  2768. The sourced input represents a life grid, each pixel represents a cell
  2769. which can be in one of two possible states, alive or dead. Every cell
  2770. interacts with its eight neighbours, which are the cells that are
  2771. horizontally, vertically, or diagonally adjacent.
  2772. At each interaction the grid evolves according to the adopted rule,
  2773. which specifies the number of neighbor alive cells which will make a
  2774. cell stay alive or born. The @option{rule} option allows to specify
  2775. the rule to adopt.
  2776. This source accepts a list of options in the form of
  2777. @var{key}=@var{value} pairs separated by ":". A description of the
  2778. accepted options follows.
  2779. @table @option
  2780. @item filename, f
  2781. Set the file from which to read the initial grid state. In the file,
  2782. each non-whitespace character is considered an alive cell, and newline
  2783. is used to delimit the end of each row.
  2784. If this option is not specified, the initial grid is generated
  2785. randomly.
  2786. @item rate, r
  2787. Set the video rate, that is the number of frames generated per second.
  2788. Default is 25.
  2789. @item random_fill_ratio, ratio
  2790. Set the random fill ratio for the initial random grid. It is a
  2791. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  2792. It is ignored when a file is specified.
  2793. @item random_seed, seed
  2794. Set the seed for filling the initial random grid, must be an integer
  2795. included between 0 and UINT32_MAX. If not specified, or if explicitly
  2796. set to -1, the filter will try to use a good random seed on a best
  2797. effort basis.
  2798. @item rule
  2799. Set the life rule.
  2800. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  2801. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  2802. @var{NS} specifies the number of alive neighbor cells which make a
  2803. live cell stay alive, and @var{NB} the number of alive neighbor cells
  2804. which make a dead cell to become alive (i.e. to "born").
  2805. "s" and "b" can be used in place of "S" and "B", respectively.
  2806. Alternatively a rule can be specified by an 18-bits integer. The 9
  2807. high order bits are used to encode the next cell state if it is alive
  2808. for each number of neighbor alive cells, the low order bits specify
  2809. the rule for "borning" new cells. Higher order bits encode for an
  2810. higher number of neighbor cells.
  2811. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  2812. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  2813. Default value is "S23/B3", which is the original Conway's game of life
  2814. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  2815. cells, and will born a new cell if there are three alive cells around
  2816. a dead cell.
  2817. @item size, s
  2818. Set the size of the output video.
  2819. If @option{filename} is specified, the size is set by default to the
  2820. same size of the input file. If @option{size} is set, it must contain
  2821. the size specified in the input file, and the initial grid defined in
  2822. that file is centered in the larger resulting area.
  2823. If a filename is not specified, the size value defaults to "320x240"
  2824. (used for a randomly generated initial grid).
  2825. @item stitch
  2826. If set to 1, stitch the left and right grid edges together, and the
  2827. top and bottom edges also. Defaults to 1.
  2828. @item mold
  2829. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  2830. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  2831. value from 0 to 255.
  2832. @item life_color
  2833. Set the color of living (or new born) cells.
  2834. @item death_color
  2835. Set the color of dead cells. If @option{mold} is set, this is the first color
  2836. used to represent a dead cell.
  2837. @item mold_color
  2838. Set mold color, for definitely dead and moldy cells.
  2839. @end table
  2840. @subsection Examples
  2841. @itemize
  2842. @item
  2843. Read a grid from @file{pattern}, and center it on a grid of size
  2844. 300x300 pixels:
  2845. @example
  2846. life=f=pattern:s=300x300
  2847. @end example
  2848. @item
  2849. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  2850. @example
  2851. life=ratio=2/3:s=200x200
  2852. @end example
  2853. @item
  2854. Specify a custom rule for evolving a randomly generated grid:
  2855. @example
  2856. life=rule=S14/B34
  2857. @end example
  2858. @item
  2859. Full example with slow death effect (mold) using @command{ffplay}:
  2860. @example
  2861. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  2862. @end example
  2863. @end itemize
  2864. @section nullsrc, rgbtestsrc, testsrc
  2865. The @code{nullsrc} source returns unprocessed video frames. It is
  2866. mainly useful to be employed in analysis / debugging tools, or as the
  2867. source for filters which ignore the input data.
  2868. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  2869. detecting RGB vs BGR issues. You should see a red, green and blue
  2870. stripe from top to bottom.
  2871. The @code{testsrc} source generates a test video pattern, showing a
  2872. color pattern, a scrolling gradient and a timestamp. This is mainly
  2873. intended for testing purposes.
  2874. These sources accept an optional sequence of @var{key}=@var{value} pairs,
  2875. separated by ":". The description of the accepted options follows.
  2876. @table @option
  2877. @item size, s
  2878. Specify the size of the sourced video, it may be a string of the form
  2879. @var{width}x@var{height}, or the name of a size abbreviation. The
  2880. default value is "320x240".
  2881. @item rate, r
  2882. Specify the frame rate of the sourced video, as the number of frames
  2883. generated per second. It has to be a string in the format
  2884. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  2885. number or a valid video frame rate abbreviation. The default value is
  2886. "25".
  2887. @item sar
  2888. Set the sample aspect ratio of the sourced video.
  2889. @item duration, d
  2890. Set the video duration of the sourced video. The accepted syntax is:
  2891. @example
  2892. [-]HH[:MM[:SS[.m...]]]
  2893. [-]S+[.m...]
  2894. @end example
  2895. See also the function @code{av_parse_time()}.
  2896. If not specified, or the expressed duration is negative, the video is
  2897. supposed to be generated forever.
  2898. @item decimals, n
  2899. Set the number of decimals to show in the timestamp, only used in the
  2900. @code{testsrc} source.
  2901. The displayed timestamp value will correspond to the original
  2902. timestamp value multiplied by the power of 10 of the specified
  2903. value. Default value is 0.
  2904. @end table
  2905. For example the following:
  2906. @example
  2907. testsrc=duration=5.3:size=qcif:rate=10
  2908. @end example
  2909. will generate a video with a duration of 5.3 seconds, with size
  2910. 176x144 and a frame rate of 10 frames per second.
  2911. If the input content is to be ignored, @code{nullsrc} can be used. The
  2912. following command generates noise in the luminance plane by employing
  2913. the @code{mp=geq} filter:
  2914. @example
  2915. nullsrc=s=256x256, mp=geq=random(1)*255:128:128
  2916. @end example
  2917. @c man end VIDEO SOURCES
  2918. @chapter Video Sinks
  2919. @c man begin VIDEO SINKS
  2920. Below is a description of the currently available video sinks.
  2921. @section buffersink
  2922. Buffer video frames, and make them available to the end of the filter
  2923. graph.
  2924. This sink is mainly intended for a programmatic use, in particular
  2925. through the interface defined in @file{libavfilter/buffersink.h}.
  2926. It does not require a string parameter in input, but you need to
  2927. specify a pointer to a list of supported pixel formats terminated by
  2928. -1 in the opaque parameter provided to @code{avfilter_init_filter}
  2929. when initializing this sink.
  2930. @section nullsink
  2931. Null video sink, do absolutely nothing with the input video. It is
  2932. mainly useful as a template and to be employed in analysis / debugging
  2933. tools.
  2934. @c man end VIDEO SINKS
  2935. @chapter Multimedia Filters
  2936. @c man begin MULTIMEDIA FILTERS
  2937. Below is a description of the currently available multimedia filters.
  2938. @section concat
  2939. Concatenate audio and video streams, joining them together one after the
  2940. other.
  2941. The filter works on segments of synchronized video and audio streams. All
  2942. segments must have the same number of streams of each type, and that will
  2943. also be the number of streams at output.
  2944. The filter accepts the following named parameters:
  2945. @table @option
  2946. @item n
  2947. Set the number of segments. Default is 2.
  2948. @item v
  2949. Set the number of output video streams, that is also the number of video
  2950. streams in each segment. Default is 1.
  2951. @item a
  2952. Set the number of output audio streams, that is also the number of video
  2953. streams in each segment. Default is 0.
  2954. @end table
  2955. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  2956. @var{a} audio outputs.
  2957. There are @var{n}×(@var{v}+@var{a}) inputs: first the inputs for the first
  2958. segment, in the same order as the outputs, then the inputs for the second
  2959. segment, etc.
  2960. Related streams do not always have exactly the same duration, for various
  2961. reasons including codec frame size or sloppy authoring. For that reason,
  2962. related synchronized streams (e.g. a video and its audio track) should be
  2963. concatenated at once. The concat filter will use the duration of the longest
  2964. stream in each segment (except the last one), and if necessary pad shorter
  2965. audio streams with silence.
  2966. For this filter to work correctly, all segments must start at timestamp 0.
  2967. All corresponding streams must have the same parameters in all segments; the
  2968. filtering system will automatically select a common pixel format for video
  2969. streams, and a common sample format, sample rate and channel layout for
  2970. audio streams, but other settings, such as resolution, must be converted
  2971. explicitly by the user.
  2972. Different frame rates are acceptable but will result in variable frame rate
  2973. at output; be sure to configure the output file to handle it.
  2974. Examples:
  2975. @itemize
  2976. @item
  2977. Concatenate an opening, an episode and an ending, all in bilingual version
  2978. (video in stream 0, audio in streams 1 and 2):
  2979. @example
  2980. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  2981. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  2982. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  2983. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  2984. @end example
  2985. @item
  2986. Concatenate two parts, handling audio and video separately, using the
  2987. (a)movie sources, and adjusting the resolution:
  2988. @example
  2989. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  2990. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  2991. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  2992. @end example
  2993. Note that a desync will happen at the stitch if the audio and video streams
  2994. do not have exactly the same duration in the first file.
  2995. @end itemize
  2996. @section showwaves
  2997. Convert input audio to a video output, representing the samples waves.
  2998. The filter accepts the following named parameters:
  2999. @table @option
  3000. @item n
  3001. Set the number of samples which are printed on the same column. A
  3002. larger value will decrease the frame rate. Must be a positive
  3003. integer. This option can be set only if the value for @var{rate}
  3004. is not explicitly specified.
  3005. @item rate, r
  3006. Set the (approximate) output frame rate. This is done by setting the
  3007. option @var{n}. Default value is "25".
  3008. @item size, s
  3009. Specify the video size for the output. Default value is "600x240".
  3010. @end table
  3011. Some examples follow.
  3012. @itemize
  3013. @item
  3014. Output the input file audio and the corresponding video representation
  3015. at the same time:
  3016. @example
  3017. amovie=a.mp3,asplit[out0],showwaves[out1]
  3018. @end example
  3019. @item
  3020. Create a synthetic signal and show it with showwaves, forcing a
  3021. framerate of 30 frames per second:
  3022. @example
  3023. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  3024. @end example
  3025. @end itemize
  3026. @c man end MULTIMEDIA FILTERS
  3027. @chapter Multimedia Sources
  3028. @c man begin MULTIMEDIA SOURCES
  3029. Below is a description of the currently available multimedia sources.
  3030. @section amovie
  3031. This is the same as @ref{src_movie} source, except it selects an audio
  3032. stream by default.
  3033. @anchor{src_movie}
  3034. @section movie
  3035. Read audio and/or video stream(s) from a movie container.
  3036. It accepts the syntax: @var{movie_name}[:@var{options}] where
  3037. @var{movie_name} is the name of the resource to read (not necessarily
  3038. a file but also a device or a stream accessed through some protocol),
  3039. and @var{options} is an optional sequence of @var{key}=@var{value}
  3040. pairs, separated by ":".
  3041. The description of the accepted options follows.
  3042. @table @option
  3043. @item format_name, f
  3044. Specifies the format assumed for the movie to read, and can be either
  3045. the name of a container or an input device. If not specified the
  3046. format is guessed from @var{movie_name} or by probing.
  3047. @item seek_point, sp
  3048. Specifies the seek point in seconds, the frames will be output
  3049. starting from this seek point, the parameter is evaluated with
  3050. @code{av_strtod} so the numerical value may be suffixed by an IS
  3051. postfix. Default value is "0".
  3052. @item streams, s
  3053. Specifies the streams to read. Several streams can be specified, separated
  3054. by "+". The source will then have as many outputs, in the same order. The
  3055. syntax is explained in the @ref{Stream specifiers} chapter. Two special
  3056. names, "dv" and "da" specify respectively the default (best suited) video
  3057. and audio stream. Default is "dv", or "da" if the filter is called as
  3058. "amovie".
  3059. @item stream_index, si
  3060. Specifies the index of the video stream to read. If the value is -1,
  3061. the best suited video stream will be automatically selected. Default
  3062. value is "-1". Deprecated. If the filter is called "amovie", it will select
  3063. audio instead of video.
  3064. @item loop
  3065. Specifies how many times to read the stream in sequence.
  3066. If the value is less than 1, the stream will be read again and again.
  3067. Default value is "1".
  3068. Note that when the movie is looped the source timestamps are not
  3069. changed, so it will generate non monotonically increasing timestamps.
  3070. @end table
  3071. This filter allows to overlay a second video on top of main input of
  3072. a filtergraph as shown in this graph:
  3073. @example
  3074. input -----------> deltapts0 --> overlay --> output
  3075. ^
  3076. |
  3077. movie --> scale--> deltapts1 -------+
  3078. @end example
  3079. Some examples follow.
  3080. @itemize
  3081. @item
  3082. Skip 3.2 seconds from the start of the avi file in.avi, and overlay it
  3083. on top of the input labelled as "in":
  3084. @example
  3085. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  3086. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  3087. @end example
  3088. @item
  3089. Read from a video4linux2 device, and overlay it on top of the input
  3090. labelled as "in":
  3091. @example
  3092. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  3093. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  3094. @end example
  3095. @item
  3096. Read the first video stream and the audio stream with id 0x81 from
  3097. dvd.vob; the video is connected to the pad named "video" and the audio is
  3098. connected to the pad named "audio":
  3099. @example
  3100. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  3101. @end example
  3102. @end itemize
  3103. @c man end MULTIMEDIA SOURCES