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.

3945 lines
111KB

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