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.

6410 lines
176KB

  1. @chapter Filtering Introduction
  2. @c man begin FILTERING INTRODUCTION
  3. Filtering in FFmpeg is enabled through the libavfilter library.
  4. In libavfilter, it is possible for filters to have multiple inputs and
  5. multiple outputs.
  6. To illustrate the sorts of things that are possible, we can
  7. use a complex filter graph. For example, the following one:
  8. @example
  9. input --> split ---------------------> overlay --> output
  10. | ^
  11. | |
  12. +-----> crop --> vflip -------+
  13. @end example
  14. splits the stream in two streams, sends one stream through the crop filter
  15. and the vflip filter before merging it back with the other stream by
  16. overlaying it on top. You can use the following command to achieve this:
  17. @example
  18. ffmpeg -i input -vf "[in] split [T1], [T2] overlay=0:H/2 [out]; [T1] crop=iw:ih/2:0:ih/2, vflip [T2]" output
  19. @end example
  20. The result will be that in output the top half of the video is mirrored
  21. onto the bottom half.
  22. Filters are loaded using the @var{-vf} or @var{-af} option passed to
  23. @command{ffmpeg} or to @command{ffplay}. Filters in the same linear
  24. chain are separated by commas. In our example, @var{split,
  25. overlay} are in one linear chain, and @var{crop, vflip} are in
  26. another. The points where the linear chains join are labeled by names
  27. enclosed in square brackets. In our example, that is @var{[T1]} and
  28. @var{[T2]}. The special labels @var{[in]} and @var{[out]} are the points
  29. where video is input and output.
  30. Some filters take in input a list of parameters: they are specified
  31. after the filter name and an equal sign, and are separated from each other
  32. by a colon.
  33. There exist so-called @var{source filters} that do not have an
  34. audio/video input, and @var{sink filters} that will not have audio/video
  35. output.
  36. @c man end FILTERING INTRODUCTION
  37. @chapter graph2dot
  38. @c man begin GRAPH2DOT
  39. The @file{graph2dot} program included in the FFmpeg @file{tools}
  40. directory can be used to parse a filter graph description and issue a
  41. corresponding textual representation in the dot language.
  42. Invoke the command:
  43. @example
  44. graph2dot -h
  45. @end example
  46. to see how to use @file{graph2dot}.
  47. You can then pass the dot description to the @file{dot} program (from
  48. the graphviz suite of programs) and obtain a graphical representation
  49. of the filter graph.
  50. For example the sequence of commands:
  51. @example
  52. echo @var{GRAPH_DESCRIPTION} | \
  53. tools/graph2dot -o graph.tmp && \
  54. dot -Tpng graph.tmp -o graph.png && \
  55. display graph.png
  56. @end example
  57. can be used to create and display an image representing the graph
  58. described by the @var{GRAPH_DESCRIPTION} string. Note that this string must be
  59. a complete self-contained graph, with its inputs and outputs explicitly defined.
  60. For example if your command line is of the form:
  61. @example
  62. ffmpeg -i infile -vf scale=640:360 outfile
  63. @end example
  64. your @var{GRAPH_DESCRIPTION} string will need to be of the form:
  65. @example
  66. nullsrc,scale=640:360,nullsink
  67. @end example
  68. you may also need to set the @var{nullsrc} parameters and add a @var{format}
  69. filter in order to simulate a specific input file.
  70. @c man end GRAPH2DOT
  71. @chapter Filtergraph description
  72. @c man begin FILTERGRAPH DESCRIPTION
  73. A filtergraph is a directed graph of connected filters. It can contain
  74. cycles, and there can be multiple links between a pair of
  75. filters. Each link has one input pad on one side connecting it to one
  76. filter from which it takes its input, and one output pad on the other
  77. side connecting it to the one filter accepting its output.
  78. Each filter in a filtergraph is an instance of a filter class
  79. registered in the application, which defines the features and the
  80. number of input and output pads of the filter.
  81. A filter with no input pads is called a "source", a filter with no
  82. output pads is called a "sink".
  83. @anchor{Filtergraph syntax}
  84. @section Filtergraph syntax
  85. A filtergraph can be represented using a textual representation, which is
  86. recognized by the @option{-filter}/@option{-vf} and @option{-filter_complex}
  87. options in @command{ffmpeg} and @option{-vf} in @command{ffplay}, and by the
  88. @code{avfilter_graph_parse()}/@code{avfilter_graph_parse2()} function defined in
  89. @file{libavfilter/avfiltergraph.h}.
  90. A filterchain consists of a sequence of connected filters, each one
  91. connected to the previous one in the sequence. A filterchain is
  92. represented by a list of ","-separated filter descriptions.
  93. A filtergraph consists of a sequence of filterchains. A sequence of
  94. filterchains is represented by a list of ";"-separated filterchain
  95. descriptions.
  96. A filter is represented by a string of the form:
  97. [@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
  98. @var{filter_name} is the name of the filter class of which the
  99. described filter is an instance of, and has to be the name of one of
  100. the filter classes registered in the program.
  101. The name of the filter class is optionally followed by a string
  102. "=@var{arguments}".
  103. @var{arguments} is a string which contains the parameters used to
  104. initialize the filter instance, and are described in the filter
  105. descriptions below.
  106. The list of arguments can be quoted using the character "'" as initial
  107. and ending mark, and the character '\' for escaping the characters
  108. within the quoted text; otherwise the argument string is considered
  109. terminated when the next special character (belonging to the set
  110. "[]=;,") is encountered.
  111. The name and arguments of the filter are optionally preceded and
  112. followed by a list of link labels.
  113. A link label allows to name a link and associate it to a filter output
  114. or input pad. The preceding labels @var{in_link_1}
  115. ... @var{in_link_N}, are associated to the filter input pads,
  116. the following labels @var{out_link_1} ... @var{out_link_M}, are
  117. associated to the output pads.
  118. When two link labels with the same name are found in the
  119. filtergraph, a link between the corresponding input and output pad is
  120. created.
  121. If an output pad is not labelled, it is linked by default to the first
  122. unlabelled input pad of the next filter in the filterchain.
  123. For example in the filterchain:
  124. @example
  125. nullsrc, split[L1], [L2]overlay, nullsink
  126. @end example
  127. the split filter instance has two output pads, and the overlay filter
  128. instance two input pads. The first output pad of split is labelled
  129. "L1", the first input pad of overlay is labelled "L2", and the second
  130. output pad of split is linked to the second input pad of overlay,
  131. which are both unlabelled.
  132. In a complete filterchain all the unlabelled filter input and output
  133. pads must be connected. A filtergraph is considered valid if all the
  134. filter input and output pads of all the filterchains are connected.
  135. Libavfilter will automatically insert scale filters where format
  136. conversion is required. It is possible to specify swscale flags
  137. for those automatically inserted scalers by prepending
  138. @code{sws_flags=@var{flags};}
  139. to the filtergraph description.
  140. Follows a BNF description for the filtergraph syntax:
  141. @example
  142. @var{NAME} ::= sequence of alphanumeric characters and '_'
  143. @var{LINKLABEL} ::= "[" @var{NAME} "]"
  144. @var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
  145. @var{FILTER_ARGUMENTS} ::= sequence of chars (eventually quoted)
  146. @var{FILTER} ::= [@var{LINKNAMES}] @var{NAME} ["=" @var{ARGUMENTS}] [@var{LINKNAMES}]
  147. @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
  148. @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
  149. @end example
  150. @section Notes on filtergraph escaping
  151. Some filter arguments require the use of special characters, typically
  152. @code{:} to separate key=value pairs in a named options list. In this
  153. case the user should perform a first level escaping when specifying
  154. the filter arguments. For example, consider the following literal
  155. string to be embedded in the @ref{drawtext} filter arguments:
  156. @example
  157. this is a 'string': may contain one, or more, special characters
  158. @end example
  159. Since @code{:} is special for the filter arguments syntax, it needs to
  160. be escaped, so you get:
  161. @example
  162. text=this is a \'string\'\: may contain one, or more, special characters
  163. @end example
  164. A second level of escaping is required when embedding the filter
  165. arguments in a filtergraph description, in order to escape all the
  166. filtergraph special characters. Thus the example above becomes:
  167. @example
  168. drawtext=text=this is a \\\'string\\\'\\: may contain one\, or more\, special characters
  169. @end example
  170. Finally an additional level of escaping may be needed when writing the
  171. filtergraph description in a shell command, which depends on the
  172. escaping rules of the adopted shell. For example, assuming that
  173. @code{\} is special and needs to be escaped with another @code{\}, the
  174. previous string will finally result in:
  175. @example
  176. -vf "drawtext=text=this is a \\\\\\'string\\\\\\'\\\\: may contain one\\, or more\\, special characters"
  177. @end example
  178. Sometimes, it might be more convenient to employ quoting in place of
  179. escaping. For example the string:
  180. @example
  181. Caesar: tu quoque, Brute, fili mi
  182. @end example
  183. Can be quoted in the filter arguments as:
  184. @example
  185. text='Caesar: tu quoque, Brute, fili mi'
  186. @end example
  187. And finally inserted in a filtergraph like:
  188. @example
  189. drawtext=text=\'Caesar: tu quoque\, Brute\, fili mi\'
  190. @end example
  191. See the ``Quoting and escaping'' section in the ffmpeg-utils manual
  192. for more information about the escaping and quoting rules adopted by
  193. FFmpeg.
  194. @c man end FILTERGRAPH DESCRIPTION
  195. @chapter Audio Filters
  196. @c man begin AUDIO FILTERS
  197. When you configure your FFmpeg build, you can disable any of the
  198. existing filters using @code{--disable-filters}.
  199. The configure output will show the audio filters included in your
  200. build.
  201. Below is a description of the currently available audio filters.
  202. @section aconvert
  203. Convert the input audio format to the specified formats.
  204. The filter accepts a string of the form:
  205. "@var{sample_format}:@var{channel_layout}".
  206. @var{sample_format} specifies the sample format, and can be a string or the
  207. corresponding numeric value defined in @file{libavutil/samplefmt.h}. Use 'p'
  208. suffix for a planar sample format.
  209. @var{channel_layout} specifies the channel layout, and can be a string
  210. or the corresponding number value defined in @file{libavutil/channel_layout.h}.
  211. The special parameter "auto", signifies that the filter will
  212. automatically select the output format depending on the output filter.
  213. Some examples follow.
  214. @itemize
  215. @item
  216. Convert input to float, planar, stereo:
  217. @example
  218. aconvert=fltp:stereo
  219. @end example
  220. @item
  221. Convert input to unsigned 8-bit, automatically select out channel layout:
  222. @example
  223. aconvert=u8:auto
  224. @end example
  225. @end itemize
  226. @section allpass
  227. Apply a two-pole all-pass filter with central frequency (in Hz)
  228. @var{frequency}, and filter-width @var{width}.
  229. An all-pass filter changes the audio's frequency to phase relationship
  230. without changing its frequency to amplitude relationship.
  231. The filter accepts parameters as a list of @var{key}=@var{value}
  232. pairs, separated by ":".
  233. A description of the accepted parameters follows.
  234. @table @option
  235. @item frequency, f
  236. Set frequency in Hz.
  237. @item width_type
  238. Set method to specify band-width of filter.
  239. @table @option
  240. @item h
  241. Hz
  242. @item q
  243. Q-Factor
  244. @item o
  245. octave
  246. @item s
  247. slope
  248. @end table
  249. @item width, w
  250. Specify the band-width of a filter in width_type units.
  251. @end table
  252. @section highpass
  253. Apply a high-pass filter with 3dB point frequency.
  254. The filter can be either single-pole, or double-pole (the default).
  255. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  256. The filter accepts parameters as a list of @var{key}=@var{value}
  257. pairs, separated by ":".
  258. A description of the accepted parameters follows.
  259. @table @option
  260. @item frequency, f
  261. Set frequency in Hz. Default is 3000.
  262. @item poles, p
  263. Set number of poles. Default is 2.
  264. @item width_type
  265. Set method to specify band-width of filter.
  266. @table @option
  267. @item h
  268. Hz
  269. @item q
  270. Q-Factor
  271. @item o
  272. octave
  273. @item s
  274. slope
  275. @end table
  276. @item width, w
  277. Specify the band-width of a filter in width_type units.
  278. Applies only to double-pole filter.
  279. The default is 0.707q and gives a Butterworth response.
  280. @end table
  281. @section lowpass
  282. Apply a low-pass filter with 3dB point frequency.
  283. The filter can be either single-pole or double-pole (the default).
  284. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  285. The filter accepts parameters as a list of @var{key}=@var{value}
  286. pairs, separated by ":".
  287. A description of the accepted parameters follows.
  288. @table @option
  289. @item frequency, f
  290. Set frequency in Hz. Default is 500.
  291. @item poles, p
  292. Set number of poles. Default is 2.
  293. @item width_type
  294. Set method to specify band-width of filter.
  295. @table @option
  296. @item h
  297. Hz
  298. @item q
  299. Q-Factor
  300. @item o
  301. octave
  302. @item s
  303. slope
  304. @end table
  305. @item width, w
  306. Specify the band-width of a filter in width_type units.
  307. Applies only to double-pole filter.
  308. The default is 0.707q and gives a Butterworth response.
  309. @end table
  310. @section bass
  311. Boost or cut the bass (lower) frequencies of the audio using a two-pole
  312. shelving filter with a response similar to that of a standard
  313. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  314. The filter accepts parameters as a list of @var{key}=@var{value}
  315. pairs, separated by ":".
  316. A description of the accepted parameters follows.
  317. @table @option
  318. @item gain, g
  319. Give the gain at 0 Hz. Its useful range is about -20
  320. (for a large cut) to +20 (for a large boost).
  321. Beware of clipping when using a positive gain.
  322. @item frequency, f
  323. Set the filter's central frequency and so can be used
  324. to extend or reduce the frequency range to be boosted or cut.
  325. The default value is @code{100} Hz.
  326. @item width_type
  327. Set method to specify band-width of filter.
  328. @table @option
  329. @item h
  330. Hz
  331. @item q
  332. Q-Factor
  333. @item o
  334. octave
  335. @item s
  336. slope
  337. @end table
  338. @item width, w
  339. Determine how steep is the filter's shelf transition.
  340. @end table
  341. @section treble
  342. Boost or cut treble (upper) frequencies of the audio using a two-pole
  343. shelving filter with a response similar to that of a standard
  344. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  345. The filter accepts parameters as a list of @var{key}=@var{value}
  346. pairs, separated by ":".
  347. A description of the accepted parameters follows.
  348. @table @option
  349. @item gain, g
  350. Give the gain at whichever is the lower of ~22 kHz and the
  351. Nyquist frequency. Its useful range is about -20 (for a large cut)
  352. to +20 (for a large boost). Beware of clipping when using a positive gain.
  353. @item frequency, f
  354. Set the filter's central frequency and so can be used
  355. to extend or reduce the frequency range to be boosted or cut.
  356. The default value is @code{3000} Hz.
  357. @item width_type
  358. Set method to specify band-width of filter.
  359. @table @option
  360. @item h
  361. Hz
  362. @item q
  363. Q-Factor
  364. @item o
  365. octave
  366. @item s
  367. slope
  368. @end table
  369. @item width, w
  370. Determine how steep is the filter's shelf transition.
  371. @end table
  372. @section bandpass
  373. Apply a two-pole Butterworth band-pass filter with central
  374. frequency @var{frequency}, and (3dB-point) band-width width.
  375. The @var{csg} option selects a constant skirt gain (peak gain = Q)
  376. instead of the default: constant 0dB peak gain.
  377. The filter roll off at 6dB per octave (20dB per decade).
  378. The filter accepts parameters as a list of @var{key}=@var{value}
  379. pairs, separated by ":".
  380. A description of the accepted parameters follows.
  381. @table @option
  382. @item frequency, f
  383. Set the filter's central frequency. Default is @code{3000}.
  384. @item csg
  385. Constant skirt gain if set to 1. Defaults to 0.
  386. @item width_type
  387. Set method to specify band-width of filter.
  388. @table @option
  389. @item h
  390. Hz
  391. @item q
  392. Q-Factor
  393. @item o
  394. octave
  395. @item s
  396. slope
  397. @end table
  398. @item width, w
  399. Specify the band-width of a filter in width_type units.
  400. @end table
  401. @section bandreject
  402. Apply a two-pole Butterworth band-reject filter with central
  403. frequency @var{frequency}, and (3dB-point) band-width @var{width}.
  404. The filter roll off at 6dB per octave (20dB per decade).
  405. The filter accepts parameters as a list of @var{key}=@var{value}
  406. pairs, separated by ":".
  407. A description of the accepted parameters follows.
  408. @table @option
  409. @item frequency, f
  410. Set the filter's central frequency. Default is @code{3000}.
  411. @item width_type
  412. Set method to specify band-width of filter.
  413. @table @option
  414. @item h
  415. Hz
  416. @item q
  417. Q-Factor
  418. @item o
  419. octave
  420. @item s
  421. slope
  422. @end table
  423. @item width, w
  424. Specify the band-width of a filter in width_type units.
  425. @end table
  426. @section biquad
  427. Apply a biquad IIR filter with the given coefficients.
  428. Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
  429. are the numerator and denominator coefficients respectively.
  430. @section equalizer
  431. Apply a two-pole peaking equalisation (EQ) filter. With this
  432. filter, the signal-level at and around a selected frequency can
  433. be increased or decreased, whilst (unlike bandpass and bandreject
  434. filters) that at all other frequencies is unchanged.
  435. In order to produce complex equalisation curves, this filter can
  436. be given several times, each with a different central frequency.
  437. The filter accepts parameters as a list of @var{key}=@var{value}
  438. pairs, separated by ":".
  439. A description of the accepted parameters follows.
  440. @table @option
  441. @item frequency, f
  442. Set the filter's central frequency in Hz.
  443. @item width_type
  444. Set method to specify band-width of filter.
  445. @table @option
  446. @item h
  447. Hz
  448. @item q
  449. Q-Factor
  450. @item o
  451. octave
  452. @item s
  453. slope
  454. @end table
  455. @item width, w
  456. Specify the band-width of a filter in width_type units.
  457. @item gain, g
  458. Set the required gain or attenuation in dB.
  459. Beware of clipping when using a positive gain.
  460. @end table
  461. @section afade
  462. Apply fade-in/out effect to input audio.
  463. The filter accepts parameters as a list of @var{key}=@var{value}
  464. pairs, separated by ":".
  465. A description of the accepted parameters follows.
  466. @table @option
  467. @item type, t
  468. Specify the effect type, can be either @code{in} for fade-in, or
  469. @code{out} for a fade-out effect. Default is @code{in}.
  470. @item start_sample, ss
  471. Specify the number of the start sample for starting to apply the fade
  472. effect. Default is 0.
  473. @item nb_samples, ns
  474. Specify the number of samples for which the fade effect has to last. At
  475. the end of the fade-in effect the output audio will have the same
  476. volume as the input audio, at the end of the fade-out transition
  477. the output audio will be silence. Default is 44100.
  478. @item start_time, st
  479. Specify time in seconds for starting to apply the fade
  480. effect. Default is 0.
  481. If set this option is used instead of @var{start_sample} one.
  482. @item duration, d
  483. Specify the number of seconds for which the fade effect has to last. At
  484. the end of the fade-in effect the output audio will have the same
  485. volume as the input audio, at the end of the fade-out transition
  486. the output audio will be silence. Default is 0.
  487. If set this option is used instead of @var{nb_samples} one.
  488. @item curve
  489. Set curve for fade transition.
  490. It accepts the following values:
  491. @table @option
  492. @item tri
  493. select triangular, linear slope (default)
  494. @item qsin
  495. select quarter of sine wave
  496. @item hsin
  497. select half of sine wave
  498. @item esin
  499. select exponential sine wave
  500. @item log
  501. select logarithmic
  502. @item par
  503. select inverted parabola
  504. @item qua
  505. select quadratic
  506. @item cub
  507. select cubic
  508. @item squ
  509. select square root
  510. @item cbr
  511. select cubic root
  512. @end table
  513. @end table
  514. @subsection Examples
  515. @itemize
  516. @item
  517. Fade in first 15 seconds of audio:
  518. @example
  519. afade=t=in:ss=0:d=15
  520. @end example
  521. @item
  522. Fade out last 25 seconds of a 900 seconds audio:
  523. @example
  524. afade=t=out:ss=875:d=25
  525. @end example
  526. @end itemize
  527. @section aformat
  528. Set output format constraints for the input audio. The framework will
  529. negotiate the most appropriate format to minimize conversions.
  530. The filter accepts the following named parameters:
  531. @table @option
  532. @item sample_fmts
  533. A comma-separated list of requested sample formats.
  534. @item sample_rates
  535. A comma-separated list of requested sample rates.
  536. @item channel_layouts
  537. A comma-separated list of requested channel layouts.
  538. @end table
  539. If a parameter is omitted, all values are allowed.
  540. For example to force the output to either unsigned 8-bit or signed 16-bit stereo:
  541. @example
  542. aformat='sample_fmts=u8,s16:channel_layouts=stereo'
  543. @end example
  544. @section amerge
  545. Merge two or more audio streams into a single multi-channel stream.
  546. The filter accepts the following named options:
  547. @table @option
  548. @item inputs
  549. Set the number of inputs. Default is 2.
  550. @end table
  551. If the channel layouts of the inputs are disjoint, and therefore compatible,
  552. the channel layout of the output will be set accordingly and the channels
  553. will be reordered as necessary. If the channel layouts of the inputs are not
  554. disjoint, the output will have all the channels of the first input then all
  555. the channels of the second input, in that order, and the channel layout of
  556. the output will be the default value corresponding to the total number of
  557. channels.
  558. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  559. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  560. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  561. first input, b1 is the first channel of the second input).
  562. On the other hand, if both input are in stereo, the output channels will be
  563. in the default order: a1, a2, b1, b2, and the channel layout will be
  564. arbitrarily set to 4.0, which may or may not be the expected value.
  565. All inputs must have the same sample rate, and format.
  566. If inputs do not have the same duration, the output will stop with the
  567. shortest.
  568. Example: merge two mono files into a stereo stream:
  569. @example
  570. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  571. @end example
  572. Example: multiple merges:
  573. @example
  574. ffmpeg -f lavfi -i "
  575. amovie=input.mkv:si=0 [a0];
  576. amovie=input.mkv:si=1 [a1];
  577. amovie=input.mkv:si=2 [a2];
  578. amovie=input.mkv:si=3 [a3];
  579. amovie=input.mkv:si=4 [a4];
  580. amovie=input.mkv:si=5 [a5];
  581. [a0][a1][a2][a3][a4][a5] amerge=inputs=6" -c:a pcm_s16le output.mkv
  582. @end example
  583. @section amix
  584. Mixes multiple audio inputs into a single output.
  585. For example
  586. @example
  587. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  588. @end example
  589. will mix 3 input audio streams to a single output with the same duration as the
  590. first input and a dropout transition time of 3 seconds.
  591. The filter accepts the following named parameters:
  592. @table @option
  593. @item inputs
  594. Number of inputs. If unspecified, it defaults to 2.
  595. @item duration
  596. How to determine the end-of-stream.
  597. @table @option
  598. @item longest
  599. Duration of longest input. (default)
  600. @item shortest
  601. Duration of shortest input.
  602. @item first
  603. Duration of first input.
  604. @end table
  605. @item dropout_transition
  606. Transition time, in seconds, for volume renormalization when an input
  607. stream ends. The default value is 2 seconds.
  608. @end table
  609. @section anull
  610. Pass the audio source unchanged to the output.
  611. @section apad
  612. Pad the end of a audio stream with silence, this can be used together with
  613. -shortest to extend audio streams to the same length as the video stream.
  614. @anchor{aresample}
  615. @section aresample
  616. Resample the input audio to the specified parameters, using the
  617. libswresample library. If none are specified then the filter will
  618. automatically convert between its input and output.
  619. This filter is also able to stretch/squeeze the audio data to make it match
  620. the timestamps or to inject silence / cut out audio to make it match the
  621. timestamps, do a combination of both or do neither.
  622. The filter accepts the syntax
  623. [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
  624. expresses a sample rate and @var{resampler_options} is a list of
  625. @var{key}=@var{value} pairs, separated by ":". See the
  626. ffmpeg-resampler manual for the complete list of supported options.
  627. For example, to resample the input audio to 44100Hz:
  628. @example
  629. aresample=44100
  630. @end example
  631. To stretch/squeeze samples to the given timestamps, with a maximum of 1000
  632. samples per second compensation:
  633. @example
  634. aresample=async=1000
  635. @end example
  636. @section asetnsamples
  637. Set the number of samples per each output audio frame.
  638. The last output packet may contain a different number of samples, as
  639. the filter will flush all the remaining samples when the input audio
  640. signal its end.
  641. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  642. separated by ":".
  643. @table @option
  644. @item nb_out_samples, n
  645. Set the number of frames per each output audio frame. The number is
  646. intended as the number of samples @emph{per each channel}.
  647. Default value is 1024.
  648. @item pad, p
  649. If set to 1, the filter will pad the last audio frame with zeroes, so
  650. that the last frame will contain the same number of samples as the
  651. previous ones. Default value is 1.
  652. @end table
  653. For example, to set the number of per-frame samples to 1234 and
  654. disable padding for the last frame, use:
  655. @example
  656. asetnsamples=n=1234:p=0
  657. @end example
  658. @section ashowinfo
  659. Show a line containing various information for each input audio frame.
  660. The input audio is not modified.
  661. The shown line contains a sequence of key/value pairs of the form
  662. @var{key}:@var{value}.
  663. A description of each shown parameter follows:
  664. @table @option
  665. @item n
  666. sequential number of the input frame, starting from 0
  667. @item pts
  668. Presentation timestamp of the input frame, in time base units; the time base
  669. depends on the filter input pad, and is usually 1/@var{sample_rate}.
  670. @item pts_time
  671. presentation timestamp of the input frame in seconds
  672. @item pos
  673. position of the frame in the input stream, -1 if this information in
  674. unavailable and/or meaningless (for example in case of synthetic audio)
  675. @item fmt
  676. sample format
  677. @item chlayout
  678. channel layout
  679. @item rate
  680. sample rate for the audio frame
  681. @item nb_samples
  682. number of samples (per channel) in the frame
  683. @item checksum
  684. Adler-32 checksum (printed in hexadecimal) of the audio data. For planar audio
  685. the data is treated as if all the planes were concatenated.
  686. @item plane_checksums
  687. A list of Adler-32 checksums for each data plane.
  688. @end table
  689. @section asplit
  690. Split input audio into several identical outputs.
  691. The filter accepts a single parameter which specifies the number of outputs. If
  692. unspecified, it defaults to 2.
  693. For example:
  694. @example
  695. [in] asplit [out0][out1]
  696. @end example
  697. will create two separate outputs from the same input.
  698. To create 3 or more outputs, you need to specify the number of
  699. outputs, like in:
  700. @example
  701. [in] asplit=3 [out0][out1][out2]
  702. @end example
  703. @example
  704. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  705. @end example
  706. will create 5 copies of the input audio.
  707. @section astreamsync
  708. Forward two audio streams and control the order the buffers are forwarded.
  709. The argument to the filter is an expression deciding which stream should be
  710. forwarded next: if the result is negative, the first stream is forwarded; if
  711. the result is positive or zero, the second stream is forwarded. It can use
  712. the following variables:
  713. @table @var
  714. @item b1 b2
  715. number of buffers forwarded so far on each stream
  716. @item s1 s2
  717. number of samples forwarded so far on each stream
  718. @item t1 t2
  719. current timestamp of each stream
  720. @end table
  721. The default value is @code{t1-t2}, which means to always forward the stream
  722. that has a smaller timestamp.
  723. Example: stress-test @code{amerge} by randomly sending buffers on the wrong
  724. input, while avoiding too much of a desynchronization:
  725. @example
  726. amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
  727. [a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
  728. [a2] [b2] amerge
  729. @end example
  730. @section atempo
  731. Adjust audio tempo.
  732. The filter accepts exactly one parameter, the audio tempo. If not
  733. specified then the filter will assume nominal 1.0 tempo. Tempo must
  734. be in the [0.5, 2.0] range.
  735. For example, to slow down audio to 80% tempo:
  736. @example
  737. atempo=0.8
  738. @end example
  739. For example, to speed up audio to 125% tempo:
  740. @example
  741. atempo=1.25
  742. @end example
  743. @section earwax
  744. Make audio easier to listen to on headphones.
  745. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  746. so that when listened to on headphones the stereo image is moved from
  747. inside your head (standard for headphones) to outside and in front of
  748. the listener (standard for speakers).
  749. Ported from SoX.
  750. @section pan
  751. Mix channels with specific gain levels. The filter accepts the output
  752. channel layout followed by a set of channels definitions.
  753. This filter is also designed to remap efficiently the channels of an audio
  754. stream.
  755. The filter accepts parameters of the form:
  756. "@var{l}:@var{outdef}:@var{outdef}:..."
  757. @table @option
  758. @item l
  759. output channel layout or number of channels
  760. @item outdef
  761. output channel specification, of the form:
  762. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  763. @item out_name
  764. output channel to define, either a channel name (FL, FR, etc.) or a channel
  765. number (c0, c1, etc.)
  766. @item gain
  767. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  768. @item in_name
  769. input channel to use, see out_name for details; it is not possible to mix
  770. named and numbered input channels
  771. @end table
  772. If the `=' in a channel specification is replaced by `<', then the gains for
  773. that specification will be renormalized so that the total is 1, thus
  774. avoiding clipping noise.
  775. @subsection Mixing examples
  776. For example, if you want to down-mix from stereo to mono, but with a bigger
  777. factor for the left channel:
  778. @example
  779. pan=1:c0=0.9*c0+0.1*c1
  780. @end example
  781. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  782. 7-channels surround:
  783. @example
  784. pan=stereo: FL < FL + 0.5*FC + 0.6*BL + 0.6*SL : FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  785. @end example
  786. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  787. that should be preferred (see "-ac" option) unless you have very specific
  788. needs.
  789. @subsection Remapping examples
  790. The channel remapping will be effective if, and only if:
  791. @itemize
  792. @item gain coefficients are zeroes or ones,
  793. @item only one input per channel output,
  794. @end itemize
  795. If all these conditions are satisfied, the filter will notify the user ("Pure
  796. channel mapping detected"), and use an optimized and lossless method to do the
  797. remapping.
  798. For example, if you have a 5.1 source and want a stereo audio stream by
  799. dropping the extra channels:
  800. @example
  801. pan="stereo: c0=FL : c1=FR"
  802. @end example
  803. Given the same source, you can also switch front left and front right channels
  804. and keep the input channel layout:
  805. @example
  806. pan="5.1: c0=c1 : c1=c0 : c2=c2 : c3=c3 : c4=c4 : c5=c5"
  807. @end example
  808. If the input is a stereo audio stream, you can mute the front left channel (and
  809. still keep the stereo channel layout) with:
  810. @example
  811. pan="stereo:c1=c1"
  812. @end example
  813. Still with a stereo audio stream input, you can copy the right channel in both
  814. front left and right:
  815. @example
  816. pan="stereo: c0=FR : c1=FR"
  817. @end example
  818. @section silencedetect
  819. Detect silence in an audio stream.
  820. This filter logs a message when it detects that the input audio volume is less
  821. or equal to a noise tolerance value for a duration greater or equal to the
  822. minimum detected noise duration.
  823. The printed times and duration are expressed in seconds.
  824. @table @option
  825. @item duration, d
  826. Set silence duration until notification (default is 2 seconds).
  827. @item noise, n
  828. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  829. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  830. @end table
  831. Detect 5 seconds of silence with -50dB noise tolerance:
  832. @example
  833. silencedetect=n=-50dB:d=5
  834. @end example
  835. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  836. tolerance in @file{silence.mp3}:
  837. @example
  838. ffmpeg -f lavfi -i amovie=silence.mp3,silencedetect=noise=0.0001 -f null -
  839. @end example
  840. @section asyncts
  841. Synchronize audio data with timestamps by squeezing/stretching it and/or
  842. dropping samples/adding silence when needed.
  843. This filter is not built by default, please use @ref{aresample} to do squeezing/stretching.
  844. The filter accepts the following named parameters:
  845. @table @option
  846. @item compensate
  847. Enable stretching/squeezing the data to make it match the timestamps. Disabled
  848. by default. When disabled, time gaps are covered with silence.
  849. @item min_delta
  850. Minimum difference between timestamps and audio data (in seconds) to trigger
  851. adding/dropping samples. Default value is 0.1. If you get non-perfect sync with
  852. this filter, try setting this parameter to 0.
  853. @item max_comp
  854. Maximum compensation in samples per second. Relevant only with compensate=1.
  855. Default value 500.
  856. @item first_pts
  857. Assume the first pts should be this value. The time base is 1 / sample rate.
  858. This allows for padding/trimming at the start of stream. By default, no
  859. assumption is made about the first frame's expected pts, so no padding or
  860. trimming is done. For example, this could be set to 0 to pad the beginning with
  861. silence if an audio stream starts after the video stream or to trim any samples
  862. with a negative pts due to encoder delay.
  863. @end table
  864. @section channelsplit
  865. Split each channel in input audio stream into a separate output stream.
  866. This filter accepts the following named parameters:
  867. @table @option
  868. @item channel_layout
  869. Channel layout of the input stream. Default is "stereo".
  870. @end table
  871. For example, assuming a stereo input MP3 file
  872. @example
  873. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  874. @end example
  875. will create an output Matroska file with two audio streams, one containing only
  876. the left channel and the other the right channel.
  877. To split a 5.1 WAV file into per-channel files
  878. @example
  879. ffmpeg -i in.wav -filter_complex
  880. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  881. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  882. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  883. side_right.wav
  884. @end example
  885. @section channelmap
  886. Remap input channels to new locations.
  887. This filter accepts the following named parameters:
  888. @table @option
  889. @item channel_layout
  890. Channel layout of the output stream.
  891. @item map
  892. Map channels from input to output. The argument is a comma-separated list of
  893. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  894. @var{in_channel} form. @var{in_channel} can be either the name of the input
  895. channel (e.g. FL for front left) or its index in the input channel layout.
  896. @var{out_channel} is the name of the output channel or its index in the output
  897. channel layout. If @var{out_channel} is not given then it is implicitly an
  898. index, starting with zero and increasing by one for each mapping.
  899. @end table
  900. If no mapping is present, the filter will implicitly map input channels to
  901. output channels preserving index.
  902. For example, assuming a 5.1+downmix input MOV file
  903. @example
  904. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL\,DR-FR' out.wav
  905. @end example
  906. will create an output WAV file tagged as stereo from the downmix channels of
  907. the input.
  908. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  909. @example
  910. ffmpeg -i in.wav -filter 'channelmap=1\,2\,0\,5\,3\,4:channel_layout=5.1' out.wav
  911. @end example
  912. @section join
  913. Join multiple input streams into one multi-channel stream.
  914. The filter accepts the following named parameters:
  915. @table @option
  916. @item inputs
  917. Number of input streams. Defaults to 2.
  918. @item channel_layout
  919. Desired output channel layout. Defaults to stereo.
  920. @item map
  921. Map channels from inputs to output. The argument is a comma-separated list of
  922. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  923. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  924. can be either the name of the input channel (e.g. FL for front left) or its
  925. index in the specified input stream. @var{out_channel} is the name of the output
  926. channel.
  927. @end table
  928. The filter will attempt to guess the mappings when those are not specified
  929. explicitly. It does so by first trying to find an unused matching input channel
  930. and if that fails it picks the first unused input channel.
  931. E.g. to join 3 inputs (with properly set channel layouts)
  932. @example
  933. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  934. @end example
  935. To build a 5.1 output from 6 single-channel streams:
  936. @example
  937. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  938. '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'
  939. out
  940. @end example
  941. @section resample
  942. Convert the audio sample format, sample rate and channel layout. This filter is
  943. not meant to be used directly.
  944. @section volume
  945. Adjust the input audio volume.
  946. The filter accepts the following named parameters. If the key of the
  947. first options is omitted, the arguments are interpreted according to
  948. the following syntax:
  949. @example
  950. volume=@var{volume}:@var{precision}
  951. @end example
  952. @table @option
  953. @item volume
  954. Expresses how the audio volume will be increased or decreased.
  955. Output values are clipped to the maximum value.
  956. The output audio volume is given by the relation:
  957. @example
  958. @var{output_volume} = @var{volume} * @var{input_volume}
  959. @end example
  960. Default value for @var{volume} is 1.0.
  961. @item precision
  962. Set the mathematical precision.
  963. This determines which input sample formats will be allowed, which affects the
  964. precision of the volume scaling.
  965. @table @option
  966. @item fixed
  967. 8-bit fixed-point; limits input sample format to U8, S16, and S32.
  968. @item float
  969. 32-bit floating-point; limits input sample format to FLT. (default)
  970. @item double
  971. 64-bit floating-point; limits input sample format to DBL.
  972. @end table
  973. @end table
  974. @subsection Examples
  975. @itemize
  976. @item
  977. Halve the input audio volume:
  978. @example
  979. volume=volume=0.5
  980. volume=volume=1/2
  981. volume=volume=-6.0206dB
  982. @end example
  983. In all the above example the named key for @option{volume} can be
  984. omitted, for example like in:
  985. @example
  986. volume=0.5
  987. @end example
  988. @item
  989. Increase input audio power by 6 decibels using fixed-point precision:
  990. @example
  991. volume=volume=6dB:precision=fixed
  992. @end example
  993. @end itemize
  994. @section volumedetect
  995. Detect the volume of the input video.
  996. The filter has no parameters. The input is not modified. Statistics about
  997. the volume will be printed in the log when the input stream end is reached.
  998. In particular it will show the mean volume (root mean square), maximum
  999. volume (on a per-sample basis), and the beginning of an histogram of the
  1000. registered volume values (from the maximum value to a cumulated 1/1000 of
  1001. the samples).
  1002. All volumes are in decibels relative to the maximum PCM value.
  1003. Here is an excerpt of the output:
  1004. @example
  1005. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  1006. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  1007. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  1008. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  1009. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  1010. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  1011. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  1012. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  1013. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  1014. @end example
  1015. It means that:
  1016. @itemize
  1017. @item
  1018. The mean square energy is approximately -27 dB, or 10^-2.7.
  1019. @item
  1020. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  1021. @item
  1022. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  1023. @end itemize
  1024. In other words, raising the volume by +4 dB does not cause any clipping,
  1025. raising it by +5 dB causes clipping for 6 samples, etc.
  1026. @c man end AUDIO FILTERS
  1027. @chapter Audio Sources
  1028. @c man begin AUDIO SOURCES
  1029. Below is a description of the currently available audio sources.
  1030. @section abuffer
  1031. Buffer audio frames, and make them available to the filter chain.
  1032. This source is mainly intended for a programmatic use, in particular
  1033. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  1034. It accepts the following mandatory parameters:
  1035. @var{sample_rate}:@var{sample_fmt}:@var{channel_layout}
  1036. @table @option
  1037. @item sample_rate
  1038. The sample rate of the incoming audio buffers.
  1039. @item sample_fmt
  1040. The sample format of the incoming audio buffers.
  1041. Either a sample format name or its corresponging integer representation from
  1042. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  1043. @item channel_layout
  1044. The channel layout of the incoming audio buffers.
  1045. Either a channel layout name from channel_layout_map in
  1046. @file{libavutil/channel_layout.c} or its corresponding integer representation
  1047. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  1048. @item channels
  1049. The number of channels of the incoming audio buffers.
  1050. If both @var{channels} and @var{channel_layout} are specified, then they
  1051. must be consistent.
  1052. @end table
  1053. For example:
  1054. @example
  1055. abuffer=44100:s16p:stereo
  1056. @end example
  1057. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  1058. Since the sample format with name "s16p" corresponds to the number
  1059. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  1060. equivalent to:
  1061. @example
  1062. abuffer=44100:6:0x3
  1063. @end example
  1064. @section aevalsrc
  1065. Generate an audio signal specified by an expression.
  1066. This source accepts in input one or more expressions (one for each
  1067. channel), which are evaluated and used to generate a corresponding
  1068. audio signal.
  1069. It accepts the syntax: @var{exprs}[::@var{options}].
  1070. @var{exprs} is a list of expressions separated by ":", one for each
  1071. separate channel. In case the @var{channel_layout} is not
  1072. specified, the selected channel layout depends on the number of
  1073. provided expressions.
  1074. @var{options} is an optional sequence of @var{key}=@var{value} pairs,
  1075. separated by ":".
  1076. The description of the accepted options follows.
  1077. @table @option
  1078. @item channel_layout, c
  1079. Set the channel layout. The number of channels in the specified layout
  1080. must be equal to the number of specified expressions.
  1081. @item duration, d
  1082. Set the minimum duration of the sourced audio. See the function
  1083. @code{av_parse_time()} for the accepted format.
  1084. Note that the resulting duration may be greater than the specified
  1085. duration, as the generated audio is always cut at the end of a
  1086. complete frame.
  1087. If not specified, or the expressed duration is negative, the audio is
  1088. supposed to be generated forever.
  1089. @item nb_samples, n
  1090. Set the number of samples per channel per each output frame,
  1091. default to 1024.
  1092. @item sample_rate, s
  1093. Specify the sample rate, default to 44100.
  1094. @end table
  1095. Each expression in @var{exprs} can contain the following constants:
  1096. @table @option
  1097. @item n
  1098. number of the evaluated sample, starting from 0
  1099. @item t
  1100. time of the evaluated sample expressed in seconds, starting from 0
  1101. @item s
  1102. sample rate
  1103. @end table
  1104. @subsection Examples
  1105. @itemize
  1106. @item
  1107. Generate silence:
  1108. @example
  1109. aevalsrc=0
  1110. @end example
  1111. @item
  1112. Generate a sin signal with frequency of 440 Hz, set sample rate to
  1113. 8000 Hz:
  1114. @example
  1115. aevalsrc="sin(440*2*PI*t)::s=8000"
  1116. @end example
  1117. @item
  1118. Generate a two channels signal, specify the channel layout (Front
  1119. Center + Back Center) explicitly:
  1120. @example
  1121. aevalsrc="sin(420*2*PI*t):cos(430*2*PI*t)::c=FC|BC"
  1122. @end example
  1123. @item
  1124. Generate white noise:
  1125. @example
  1126. aevalsrc="-2+random(0)"
  1127. @end example
  1128. @item
  1129. Generate an amplitude modulated signal:
  1130. @example
  1131. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  1132. @end example
  1133. @item
  1134. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  1135. @example
  1136. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) : 0.1*sin(2*PI*(360+2.5/2)*t)"
  1137. @end example
  1138. @end itemize
  1139. @section anullsrc
  1140. Null audio source, return unprocessed audio frames. It is mainly useful
  1141. as a template and to be employed in analysis / debugging tools, or as
  1142. the source for filters which ignore the input data (for example the sox
  1143. synth filter).
  1144. It accepts an optional sequence of @var{key}=@var{value} pairs,
  1145. separated by ":".
  1146. The description of the accepted options follows.
  1147. @table @option
  1148. @item sample_rate, s
  1149. Specify the sample rate, and defaults to 44100.
  1150. @item channel_layout, cl
  1151. Specify the channel layout, and can be either an integer or a string
  1152. representing a channel layout. The default value of @var{channel_layout}
  1153. is "stereo".
  1154. Check the channel_layout_map definition in
  1155. @file{libavutil/channel_layout.c} for the mapping between strings and
  1156. channel layout values.
  1157. @item nb_samples, n
  1158. Set the number of samples per requested frames.
  1159. @end table
  1160. Follow some examples:
  1161. @example
  1162. # set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  1163. anullsrc=r=48000:cl=4
  1164. # same as
  1165. anullsrc=r=48000:cl=mono
  1166. @end example
  1167. @section abuffer
  1168. Buffer audio frames, and make them available to the filter chain.
  1169. This source is not intended to be part of user-supplied graph descriptions but
  1170. for insertion by calling programs through the interface defined in
  1171. @file{libavfilter/buffersrc.h}.
  1172. It accepts the following named parameters:
  1173. @table @option
  1174. @item time_base
  1175. Timebase which will be used for timestamps of submitted frames. It must be
  1176. either a floating-point number or in @var{numerator}/@var{denominator} form.
  1177. @item sample_rate
  1178. Audio sample rate.
  1179. @item sample_fmt
  1180. Name of the sample format, as returned by @code{av_get_sample_fmt_name()}.
  1181. @item channel_layout
  1182. Channel layout of the audio data, in the form that can be accepted by
  1183. @code{av_get_channel_layout()}.
  1184. @end table
  1185. All the parameters need to be explicitly defined.
  1186. @section flite
  1187. Synthesize a voice utterance using the libflite library.
  1188. To enable compilation of this filter you need to configure FFmpeg with
  1189. @code{--enable-libflite}.
  1190. Note that the flite library is not thread-safe.
  1191. The source accepts parameters as a list of @var{key}=@var{value} pairs,
  1192. separated by ":".
  1193. The description of the accepted parameters follows.
  1194. @table @option
  1195. @item list_voices
  1196. If set to 1, list the names of the available voices and exit
  1197. immediately. Default value is 0.
  1198. @item nb_samples, n
  1199. Set the maximum number of samples per frame. Default value is 512.
  1200. @item textfile
  1201. Set the filename containing the text to speak.
  1202. @item text
  1203. Set the text to speak.
  1204. @item voice, v
  1205. Set the voice to use for the speech synthesis. Default value is
  1206. @code{kal}. See also the @var{list_voices} option.
  1207. @end table
  1208. @subsection Examples
  1209. @itemize
  1210. @item
  1211. Read from file @file{speech.txt}, and synthetize the text using the
  1212. standard flite voice:
  1213. @example
  1214. flite=textfile=speech.txt
  1215. @end example
  1216. @item
  1217. Read the specified text selecting the @code{slt} voice:
  1218. @example
  1219. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  1220. @end example
  1221. @item
  1222. Input text to ffmpeg:
  1223. @example
  1224. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  1225. @end example
  1226. @item
  1227. Make @file{ffplay} speak the specified text, using @code{flite} and
  1228. the @code{lavfi} device:
  1229. @example
  1230. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  1231. @end example
  1232. @end itemize
  1233. For more information about libflite, check:
  1234. @url{http://www.speech.cs.cmu.edu/flite/}
  1235. @c man end AUDIO SOURCES
  1236. @chapter Audio Sinks
  1237. @c man begin AUDIO SINKS
  1238. Below is a description of the currently available audio sinks.
  1239. @section abuffersink
  1240. Buffer audio frames, and make them available to the end of filter chain.
  1241. This sink is mainly intended for programmatic use, in particular
  1242. through the interface defined in @file{libavfilter/buffersink.h}.
  1243. It requires a pointer to an AVABufferSinkContext structure, which
  1244. defines the incoming buffers' formats, to be passed as the opaque
  1245. parameter to @code{avfilter_init_filter} for initialization.
  1246. @section anullsink
  1247. Null audio sink, do absolutely nothing with the input audio. It is
  1248. mainly useful as a template and to be employed in analysis / debugging
  1249. tools.
  1250. @section abuffersink
  1251. This sink is intended for programmatic use. Frames that arrive on this sink can
  1252. be retrieved by the calling program using the interface defined in
  1253. @file{libavfilter/buffersink.h}.
  1254. This filter accepts no parameters.
  1255. @c man end AUDIO SINKS
  1256. @chapter Video Filters
  1257. @c man begin VIDEO FILTERS
  1258. When you configure your FFmpeg build, you can disable any of the
  1259. existing filters using @code{--disable-filters}.
  1260. The configure output will show the video filters included in your
  1261. build.
  1262. Below is a description of the currently available video filters.
  1263. @section alphaextract
  1264. Extract the alpha component from the input as a grayscale video. This
  1265. is especially useful with the @var{alphamerge} filter.
  1266. @section alphamerge
  1267. Add or replace the alpha component of the primary input with the
  1268. grayscale value of a second input. This is intended for use with
  1269. @var{alphaextract} to allow the transmission or storage of frame
  1270. sequences that have alpha in a format that doesn't support an alpha
  1271. channel.
  1272. For example, to reconstruct full frames from a normal YUV-encoded video
  1273. and a separate video created with @var{alphaextract}, you might use:
  1274. @example
  1275. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  1276. @end example
  1277. Since this filter is designed for reconstruction, it operates on frame
  1278. sequences without considering timestamps, and terminates when either
  1279. input reaches end of stream. This will cause problems if your encoding
  1280. pipeline drops frames. If you're trying to apply an image as an
  1281. overlay to a video stream, consider the @var{overlay} filter instead.
  1282. @section ass
  1283. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  1284. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  1285. Substation Alpha) subtitles files.
  1286. @section bbox
  1287. Compute the bounding box for the non-black pixels in the input frame
  1288. luminance plane.
  1289. This filter computes the bounding box containing all the pixels with a
  1290. luminance value greater than the minimum allowed value.
  1291. The parameters describing the bounding box are printed on the filter
  1292. log.
  1293. @section blackdetect
  1294. Detect video intervals that are (almost) completely black. Can be
  1295. useful to detect chapter transitions, commercials, or invalid
  1296. recordings. Output lines contains the time for the start, end and
  1297. duration of the detected black interval expressed in seconds.
  1298. In order to display the output lines, you need to set the loglevel at
  1299. least to the AV_LOG_INFO value.
  1300. This filter accepts a list of options in the form of
  1301. @var{key}=@var{value} pairs separated by ":". A description of the
  1302. accepted options follows.
  1303. @table @option
  1304. @item black_min_duration, d
  1305. Set the minimum detected black duration expressed in seconds. It must
  1306. be a non-negative floating point number.
  1307. Default value is 2.0.
  1308. @item picture_black_ratio_th, pic_th
  1309. Set the threshold for considering a picture "black".
  1310. Express the minimum value for the ratio:
  1311. @example
  1312. @var{nb_black_pixels} / @var{nb_pixels}
  1313. @end example
  1314. for which a picture is considered black.
  1315. Default value is 0.98.
  1316. @item pixel_black_th, pix_th
  1317. Set the threshold for considering a pixel "black".
  1318. The threshold expresses the maximum pixel luminance value for which a
  1319. pixel is considered "black". The provided value is scaled according to
  1320. the following equation:
  1321. @example
  1322. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  1323. @end example
  1324. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  1325. the input video format, the range is [0-255] for YUV full-range
  1326. formats and [16-235] for YUV non full-range formats.
  1327. Default value is 0.10.
  1328. @end table
  1329. The following example sets the maximum pixel threshold to the minimum
  1330. value, and detects only black intervals of 2 or more seconds:
  1331. @example
  1332. blackdetect=d=2:pix_th=0.00
  1333. @end example
  1334. @section blackframe
  1335. Detect frames that are (almost) completely black. Can be useful to
  1336. detect chapter transitions or commercials. Output lines consist of
  1337. the frame number of the detected frame, the percentage of blackness,
  1338. the position in the file if known or -1 and the timestamp in seconds.
  1339. In order to display the output lines, you need to set the loglevel at
  1340. least to the AV_LOG_INFO value.
  1341. The filter accepts the syntax:
  1342. @example
  1343. blackframe[=@var{amount}:[@var{threshold}]]
  1344. @end example
  1345. @var{amount} is the percentage of the pixels that have to be below the
  1346. threshold, and defaults to 98.
  1347. @var{threshold} is the threshold below which a pixel value is
  1348. considered black, and defaults to 32.
  1349. @section boxblur
  1350. Apply boxblur algorithm to the input video.
  1351. This filter accepts the parameters:
  1352. @var{luma_radius}:@var{luma_power}:@var{chroma_radius}:@var{chroma_power}:@var{alpha_radius}:@var{alpha_power}
  1353. Chroma and alpha parameters are optional, if not specified they default
  1354. to the corresponding values set for @var{luma_radius} and
  1355. @var{luma_power}.
  1356. @var{luma_radius}, @var{chroma_radius}, and @var{alpha_radius} represent
  1357. the radius in pixels of the box used for blurring the corresponding
  1358. input plane. They are expressions, and can contain the following
  1359. constants:
  1360. @table @option
  1361. @item w, h
  1362. the input width and height in pixels
  1363. @item cw, ch
  1364. the input chroma image width and height in pixels
  1365. @item hsub, vsub
  1366. horizontal and vertical chroma subsample values. For example for the
  1367. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1368. @end table
  1369. The radius must be a non-negative number, and must not be greater than
  1370. the value of the expression @code{min(w,h)/2} for the luma and alpha planes,
  1371. and of @code{min(cw,ch)/2} for the chroma planes.
  1372. @var{luma_power}, @var{chroma_power}, and @var{alpha_power} represent
  1373. how many times the boxblur filter is applied to the corresponding
  1374. plane.
  1375. Some examples follow:
  1376. @itemize
  1377. @item
  1378. Apply a boxblur filter with luma, chroma, and alpha radius
  1379. set to 2:
  1380. @example
  1381. boxblur=2:1
  1382. @end example
  1383. @item
  1384. Set luma radius to 2, alpha and chroma radius to 0
  1385. @example
  1386. boxblur=2:1:0:0:0:0
  1387. @end example
  1388. @item
  1389. Set luma and chroma radius to a fraction of the video dimension
  1390. @example
  1391. boxblur=min(h\,w)/10:1:min(cw\,ch)/10:1
  1392. @end example
  1393. @end itemize
  1394. @section colormatrix
  1395. The colormatrix filter allows conversion between any of the following color
  1396. space: BT.709 (@var{bt709}), BT.601 (@var{bt601}), SMPTE-240M (@var{smpte240m})
  1397. and FCC (@var{fcc}).
  1398. The syntax of the parameters is @var{source}:@var{destination}:
  1399. @example
  1400. colormatrix=bt601:smpte240m
  1401. @end example
  1402. @section copy
  1403. Copy the input source unchanged to the output. Mainly useful for
  1404. testing purposes.
  1405. @section crop
  1406. Crop the input video.
  1407. This filter accepts a list of @var{key}=@var{value} pairs as argument,
  1408. separated by ':'. If the key of the first options is omitted, the
  1409. arguments are interpreted according to the syntax
  1410. @var{out_w}:@var{out_h}:@var{x}:@var{y}:@var{keep_aspect}.
  1411. A description of the accepted options follows:
  1412. @table @option
  1413. @item w, out_w
  1414. Set the crop area width. It defaults to @code{iw}.
  1415. This expression is evaluated only once during the filter
  1416. configuration.
  1417. @item h, out_h
  1418. Set the crop area width. It defaults to @code{ih}.
  1419. This expression is evaluated only once during the filter
  1420. configuration.
  1421. @item x
  1422. Set the expression for the x top-left coordinate of the cropped area.
  1423. It defaults to @code{(in_w-out_w)/2}.
  1424. This expression is evaluated per-frame.
  1425. @item y
  1426. Set the expression for the y top-left coordinate of the cropped area.
  1427. It defaults to @code{(in_h-out_h)/2}.
  1428. This expression is evaluated per-frame.
  1429. @item keep_aspect
  1430. If set to 1 will force the output display aspect ratio
  1431. to be the same of the input, by changing the output sample aspect
  1432. ratio. It defaults to 0.
  1433. @end table
  1434. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  1435. expressions containing the following constants:
  1436. @table @option
  1437. @item x, y
  1438. the computed values for @var{x} and @var{y}. They are evaluated for
  1439. each new frame.
  1440. @item in_w, in_h
  1441. the input width and height
  1442. @item iw, ih
  1443. same as @var{in_w} and @var{in_h}
  1444. @item out_w, out_h
  1445. the output (cropped) width and height
  1446. @item ow, oh
  1447. same as @var{out_w} and @var{out_h}
  1448. @item a
  1449. same as @var{iw} / @var{ih}
  1450. @item sar
  1451. input sample aspect ratio
  1452. @item dar
  1453. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  1454. @item hsub, vsub
  1455. horizontal and vertical chroma subsample values. For example for the
  1456. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1457. @item n
  1458. the number of input frame, starting from 0
  1459. @item pos
  1460. the position in the file of the input frame, NAN if unknown
  1461. @item t
  1462. timestamp expressed in seconds, NAN if the input timestamp is unknown
  1463. @end table
  1464. The expression for @var{out_w} may depend on the value of @var{out_h},
  1465. and the expression for @var{out_h} may depend on @var{out_w}, but they
  1466. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  1467. evaluated after @var{out_w} and @var{out_h}.
  1468. The @var{x} and @var{y} parameters specify the expressions for the
  1469. position of the top-left corner of the output (non-cropped) area. They
  1470. are evaluated for each frame. If the evaluated value is not valid, it
  1471. is approximated to the nearest valid value.
  1472. The expression for @var{x} may depend on @var{y}, and the expression
  1473. for @var{y} may depend on @var{x}.
  1474. @subsection Examples
  1475. @itemize
  1476. @item
  1477. Crop area with size 100x100 at position (12,34).
  1478. @example
  1479. crop=100:100:12:34
  1480. @end example
  1481. Using named options, the example above becomes:
  1482. @example
  1483. crop=w=100:h=100:x=12:y=34
  1484. @end example
  1485. @item
  1486. Crop the central input area with size 100x100:
  1487. @example
  1488. crop=100:100
  1489. @end example
  1490. @item
  1491. Crop the central input area with size 2/3 of the input video:
  1492. @example
  1493. crop=2/3*in_w:2/3*in_h
  1494. @end example
  1495. @item
  1496. Crop the input video central square:
  1497. @example
  1498. crop=in_h
  1499. @end example
  1500. @item
  1501. Delimit the rectangle with the top-left corner placed at position
  1502. 100:100 and the right-bottom corner corresponding to the right-bottom
  1503. corner of the input image:
  1504. @example
  1505. crop=in_w-100:in_h-100:100:100
  1506. @end example
  1507. @item
  1508. Crop 10 pixels from the left and right borders, and 20 pixels from
  1509. the top and bottom borders
  1510. @example
  1511. crop=in_w-2*10:in_h-2*20
  1512. @end example
  1513. @item
  1514. Keep only the bottom right quarter of the input image:
  1515. @example
  1516. crop=in_w/2:in_h/2:in_w/2:in_h/2
  1517. @end example
  1518. @item
  1519. Crop height for getting Greek harmony:
  1520. @example
  1521. crop=in_w:1/PHI*in_w
  1522. @end example
  1523. @item
  1524. Appply trembling effect:
  1525. @example
  1526. 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)
  1527. @end example
  1528. @item
  1529. Apply erratic camera effect depending on timestamp:
  1530. @example
  1531. 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)"
  1532. @end example
  1533. @item
  1534. Set x depending on the value of y:
  1535. @example
  1536. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  1537. @end example
  1538. @end itemize
  1539. @section cropdetect
  1540. Auto-detect crop size.
  1541. Calculate necessary cropping parameters and prints the recommended
  1542. parameters through the logging system. The detected dimensions
  1543. correspond to the non-black area of the input video.
  1544. It accepts the syntax:
  1545. @example
  1546. cropdetect[=@var{limit}[:@var{round}[:@var{reset}]]]
  1547. @end example
  1548. @table @option
  1549. @item limit
  1550. Threshold, which can be optionally specified from nothing (0) to
  1551. everything (255), defaults to 24.
  1552. @item round
  1553. Value which the width/height should be divisible by, defaults to
  1554. 16. The offset is automatically adjusted to center the video. Use 2 to
  1555. get only even dimensions (needed for 4:2:2 video). 16 is best when
  1556. encoding to most video codecs.
  1557. @item reset
  1558. Counter that determines after how many frames cropdetect will reset
  1559. the previously detected largest video area and start over to detect
  1560. the current optimal crop area. Defaults to 0.
  1561. This can be useful when channel logos distort the video area. 0
  1562. indicates never reset and return the largest area encountered during
  1563. playback.
  1564. @end table
  1565. @section decimate
  1566. This filter drops frames that do not differ greatly from the previous
  1567. frame in order to reduce framerate. The main use of this filter is
  1568. for very-low-bitrate encoding (e.g. streaming over dialup modem), but
  1569. it could in theory be used for fixing movies that were
  1570. inverse-telecined incorrectly.
  1571. It accepts the following parameters:
  1572. @var{max}:@var{hi}:@var{lo}:@var{frac}.
  1573. @table @option
  1574. @item max
  1575. Set the maximum number of consecutive frames which can be dropped (if
  1576. positive), or the minimum interval between dropped frames (if
  1577. negative). If the value is 0, the frame is dropped unregarding the
  1578. number of previous sequentially dropped frames.
  1579. Default value is 0.
  1580. @item hi, lo, frac
  1581. Set the dropping threshold values.
  1582. Values for @var{hi} and @var{lo} are for 8x8 pixel blocks and
  1583. represent actual pixel value differences, so a threshold of 64
  1584. corresponds to 1 unit of difference for each pixel, or the same spread
  1585. out differently over the block.
  1586. A frame is a candidate for dropping if no 8x8 blocks differ by more
  1587. than a threshold of @var{hi}, and if no more than @var{frac} blocks (1
  1588. meaning the whole image) differ by more than a threshold of @var{lo}.
  1589. Default value for @var{hi} is 64*12, default value for @var{lo} is
  1590. 64*5, and default value for @var{frac} is 0.33.
  1591. @end table
  1592. @section delogo
  1593. Suppress a TV station logo by a simple interpolation of the surrounding
  1594. pixels. Just set a rectangle covering the logo and watch it disappear
  1595. (and sometimes something even uglier appear - your mileage may vary).
  1596. The filter accepts parameters as a string of the form
  1597. "@var{x}:@var{y}:@var{w}:@var{h}:@var{band}", or as a list of
  1598. @var{key}=@var{value} pairs, separated by ":".
  1599. The description of the accepted parameters follows.
  1600. @table @option
  1601. @item x, y
  1602. Specify the top left corner coordinates of the logo. They must be
  1603. specified.
  1604. @item w, h
  1605. Specify the width and height of the logo to clear. They must be
  1606. specified.
  1607. @item band, t
  1608. Specify the thickness of the fuzzy edge of the rectangle (added to
  1609. @var{w} and @var{h}). The default value is 4.
  1610. @item show
  1611. When set to 1, a green rectangle is drawn on the screen to simplify
  1612. finding the right @var{x}, @var{y}, @var{w}, @var{h} parameters, and
  1613. @var{band} is set to 4. The default value is 0.
  1614. @end table
  1615. Some examples follow.
  1616. @itemize
  1617. @item
  1618. Set a rectangle covering the area with top left corner coordinates 0,0
  1619. and size 100x77, setting a band of size 10:
  1620. @example
  1621. delogo=0:0:100:77:10
  1622. @end example
  1623. @item
  1624. As the previous example, but use named options:
  1625. @example
  1626. delogo=x=0:y=0:w=100:h=77:band=10
  1627. @end example
  1628. @end itemize
  1629. @section deshake
  1630. Attempt to fix small changes in horizontal and/or vertical shift. This
  1631. filter helps remove camera shake from hand-holding a camera, bumping a
  1632. tripod, moving on a vehicle, etc.
  1633. The filter accepts parameters as a string of the form
  1634. "@var{x}:@var{y}:@var{w}:@var{h}:@var{rx}:@var{ry}:@var{edge}:@var{blocksize}:@var{contrast}:@var{search}:@var{filename}"
  1635. A description of the accepted parameters follows.
  1636. @table @option
  1637. @item x, y, w, h
  1638. Specify a rectangular area where to limit the search for motion
  1639. vectors.
  1640. If desired the search for motion vectors can be limited to a
  1641. rectangular area of the frame defined by its top left corner, width
  1642. and height. These parameters have the same meaning as the drawbox
  1643. filter which can be used to visualise the position of the bounding
  1644. box.
  1645. This is useful when simultaneous movement of subjects within the frame
  1646. might be confused for camera motion by the motion vector search.
  1647. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  1648. then the full frame is used. This allows later options to be set
  1649. without specifying the bounding box for the motion vector search.
  1650. Default - search the whole frame.
  1651. @item rx, ry
  1652. Specify the maximum extent of movement in x and y directions in the
  1653. range 0-64 pixels. Default 16.
  1654. @item edge
  1655. Specify how to generate pixels to fill blanks at the edge of the
  1656. frame. An integer from 0 to 3 as follows:
  1657. @table @option
  1658. @item 0
  1659. Fill zeroes at blank locations
  1660. @item 1
  1661. Original image at blank locations
  1662. @item 2
  1663. Extruded edge value at blank locations
  1664. @item 3
  1665. Mirrored edge at blank locations
  1666. @end table
  1667. The default setting is mirror edge at blank locations.
  1668. @item blocksize
  1669. Specify the blocksize to use for motion search. Range 4-128 pixels,
  1670. default 8.
  1671. @item contrast
  1672. Specify the contrast threshold for blocks. Only blocks with more than
  1673. the specified contrast (difference between darkest and lightest
  1674. pixels) will be considered. Range 1-255, default 125.
  1675. @item search
  1676. Specify the search strategy 0 = exhaustive search, 1 = less exhaustive
  1677. search. Default - exhaustive search.
  1678. @item filename
  1679. If set then a detailed log of the motion search is written to the
  1680. specified file.
  1681. @end table
  1682. @section drawbox
  1683. Draw a colored box on the input image.
  1684. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  1685. separated by ":".
  1686. The description of the accepted parameters follows.
  1687. @table @option
  1688. @item x, y
  1689. Specify the top left corner coordinates of the box. Default to 0.
  1690. @item width, w
  1691. @item height, h
  1692. Specify the width and height of the box, if 0 they are interpreted as
  1693. the input width and height. Default to 0.
  1694. @item color, c
  1695. Specify the color of the box to write, it can be the name of a color
  1696. (case insensitive match) or a 0xRRGGBB[AA] sequence. If the special
  1697. value @code{invert} is used, the box edge color is the same as the
  1698. video with inverted luma.
  1699. @item thickness, t
  1700. Set the thickness of the box edge. Default value is @code{4}.
  1701. @end table
  1702. If the key of the first options is omitted, the arguments are
  1703. interpreted according to the syntax
  1704. @var{x}:@var{y}:@var{width}:@var{height}:@var{color}:@var{thickness}.
  1705. Some examples follow:
  1706. @itemize
  1707. @item
  1708. Draw a black box around the edge of the input image:
  1709. @example
  1710. drawbox
  1711. @end example
  1712. @item
  1713. Draw a box with color red and an opacity of 50%:
  1714. @example
  1715. drawbox=10:20:200:60:red@@0.5
  1716. @end example
  1717. The previous example can be specified as:
  1718. @example
  1719. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  1720. @end example
  1721. @item
  1722. Fill the box with pink color:
  1723. @example
  1724. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  1725. @end example
  1726. @end itemize
  1727. @anchor{drawtext}
  1728. @section drawtext
  1729. Draw text string or text from specified file on top of video using the
  1730. libfreetype library.
  1731. To enable compilation of this filter you need to configure FFmpeg with
  1732. @code{--enable-libfreetype}.
  1733. @subsection Syntax
  1734. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  1735. separated by ":".
  1736. The description of the accepted parameters follows.
  1737. @table @option
  1738. @item box
  1739. Used to draw a box around text using background color.
  1740. Value should be either 1 (enable) or 0 (disable).
  1741. The default value of @var{box} is 0.
  1742. @item boxcolor
  1743. The color to be used for drawing box around text.
  1744. Either a string (e.g. "yellow") or in 0xRRGGBB[AA] format
  1745. (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  1746. The default value of @var{boxcolor} is "white".
  1747. @item draw
  1748. Set an expression which specifies if the text should be drawn. If the
  1749. expression evaluates to 0, the text is not drawn. This is useful for
  1750. specifying that the text should be drawn only when specific conditions
  1751. are met.
  1752. Default value is "1".
  1753. See below for the list of accepted constants and functions.
  1754. @item expansion
  1755. Select how the @var{text} is expanded. Can be either @code{none},
  1756. @code{strftime} (deprecated) or
  1757. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  1758. below for details.
  1759. @item fix_bounds
  1760. If true, check and fix text coords to avoid clipping.
  1761. @item fontcolor
  1762. The color to be used for drawing fonts.
  1763. Either a string (e.g. "red") or in 0xRRGGBB[AA] format
  1764. (e.g. "0xff000033"), possibly followed by an alpha specifier.
  1765. The default value of @var{fontcolor} is "black".
  1766. @item fontfile
  1767. The font file to be used for drawing text. Path must be included.
  1768. This parameter is mandatory.
  1769. @item fontsize
  1770. The font size to be used for drawing text.
  1771. The default value of @var{fontsize} is 16.
  1772. @item ft_load_flags
  1773. Flags to be used for loading the fonts.
  1774. The flags map the corresponding flags supported by libfreetype, and are
  1775. a combination of the following values:
  1776. @table @var
  1777. @item default
  1778. @item no_scale
  1779. @item no_hinting
  1780. @item render
  1781. @item no_bitmap
  1782. @item vertical_layout
  1783. @item force_autohint
  1784. @item crop_bitmap
  1785. @item pedantic
  1786. @item ignore_global_advance_width
  1787. @item no_recurse
  1788. @item ignore_transform
  1789. @item monochrome
  1790. @item linear_design
  1791. @item no_autohint
  1792. @item end table
  1793. @end table
  1794. Default value is "render".
  1795. For more information consult the documentation for the FT_LOAD_*
  1796. libfreetype flags.
  1797. @item shadowcolor
  1798. The color to be used for drawing a shadow behind the drawn text. It
  1799. can be a color name (e.g. "yellow") or a string in the 0xRRGGBB[AA]
  1800. form (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  1801. The default value of @var{shadowcolor} is "black".
  1802. @item shadowx, shadowy
  1803. The x and y offsets for the text shadow position with respect to the
  1804. position of the text. They can be either positive or negative
  1805. values. Default value for both is "0".
  1806. @item tabsize
  1807. The size in number of spaces to use for rendering the tab.
  1808. Default value is 4.
  1809. @item timecode
  1810. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  1811. format. It can be used with or without text parameter. @var{timecode_rate}
  1812. option must be specified.
  1813. @item timecode_rate, rate, r
  1814. Set the timecode frame rate (timecode only).
  1815. @item text
  1816. The text string to be drawn. The text must be a sequence of UTF-8
  1817. encoded characters.
  1818. This parameter is mandatory if no file is specified with the parameter
  1819. @var{textfile}.
  1820. @item textfile
  1821. A text file containing text to be drawn. The text must be a sequence
  1822. of UTF-8 encoded characters.
  1823. This parameter is mandatory if no text string is specified with the
  1824. parameter @var{text}.
  1825. If both @var{text} and @var{textfile} are specified, an error is thrown.
  1826. @item reload
  1827. If set to 1, the @var{textfile} will be reloaded before each frame.
  1828. Be sure to update it atomically, or it may be read partially, or even fail.
  1829. @item x, y
  1830. The expressions which specify the offsets where text will be drawn
  1831. within the video frame. They are relative to the top/left border of the
  1832. output image.
  1833. The default value of @var{x} and @var{y} is "0".
  1834. See below for the list of accepted constants and functions.
  1835. @end table
  1836. The parameters for @var{x} and @var{y} are expressions containing the
  1837. following constants and functions:
  1838. @table @option
  1839. @item dar
  1840. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  1841. @item hsub, vsub
  1842. horizontal and vertical chroma subsample values. For example for the
  1843. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1844. @item line_h, lh
  1845. the height of each text line
  1846. @item main_h, h, H
  1847. the input height
  1848. @item main_w, w, W
  1849. the input width
  1850. @item max_glyph_a, ascent
  1851. the maximum distance from the baseline to the highest/upper grid
  1852. coordinate used to place a glyph outline point, for all the rendered
  1853. glyphs.
  1854. It is a positive value, due to the grid's orientation with the Y axis
  1855. upwards.
  1856. @item max_glyph_d, descent
  1857. the maximum distance from the baseline to the lowest grid coordinate
  1858. used to place a glyph outline point, for all the rendered glyphs.
  1859. This is a negative value, due to the grid's orientation, with the Y axis
  1860. upwards.
  1861. @item max_glyph_h
  1862. maximum glyph height, that is the maximum height for all the glyphs
  1863. contained in the rendered text, it is equivalent to @var{ascent} -
  1864. @var{descent}.
  1865. @item max_glyph_w
  1866. maximum glyph width, that is the maximum width for all the glyphs
  1867. contained in the rendered text
  1868. @item n
  1869. the number of input frame, starting from 0
  1870. @item rand(min, max)
  1871. return a random number included between @var{min} and @var{max}
  1872. @item sar
  1873. input sample aspect ratio
  1874. @item t
  1875. timestamp expressed in seconds, NAN if the input timestamp is unknown
  1876. @item text_h, th
  1877. the height of the rendered text
  1878. @item text_w, tw
  1879. the width of the rendered text
  1880. @item x, y
  1881. the x and y offset coordinates where the text is drawn.
  1882. These parameters allow the @var{x} and @var{y} expressions to refer
  1883. each other, so you can for example specify @code{y=x/dar}.
  1884. @end table
  1885. If libavfilter was built with @code{--enable-fontconfig}, then
  1886. @option{fontfile} can be a fontconfig pattern or omitted.
  1887. @anchor{drawtext_expansion}
  1888. @subsection Text expansion
  1889. If @option{expansion} is set to @code{strftime},
  1890. the filter recognizes strftime() sequences in the provided text and
  1891. expands them accordingly. Check the documentation of strftime(). This
  1892. feature is deprecated.
  1893. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  1894. If @option{expansion} is set to @code{normal} (which is the default),
  1895. the following expansion mechanism is used.
  1896. The backslash character '\', followed by any character, always expands to
  1897. the second character.
  1898. Sequence of the form @code{%@{...@}} are expanded. The text between the
  1899. braces is a function name, possibly followed by arguments separated by ':'.
  1900. If the arguments contain special characters or delimiters (':' or '@}'),
  1901. they should be escaped.
  1902. Note that they probably must also be escaped as the value for the
  1903. @option{text} option in the filter argument string and as the filter
  1904. argument in the filter graph description, and possibly also for the shell,
  1905. that makes up to four levels of escaping; using a text file avoids these
  1906. problems.
  1907. The following functions are available:
  1908. @table @command
  1909. @item expr, e
  1910. The expression evaluation result.
  1911. It must take one argument specifying the expression to be evaluated,
  1912. which accepts the same constants and functions as the @var{x} and
  1913. @var{y} values. Note that not all constants should be used, for
  1914. example the text size is not known when evaluating the expression, so
  1915. the constants @var{text_w} and @var{text_h} will have an undefined
  1916. value.
  1917. @item gmtime
  1918. The time at which the filter is running, expressed in UTC.
  1919. It can accept an argument: a strftime() format string.
  1920. @item localtime
  1921. The time at which the filter is running, expressed in the local time zone.
  1922. It can accept an argument: a strftime() format string.
  1923. @item n, frame_num
  1924. The frame number, starting from 0.
  1925. @item pts
  1926. The timestamp of the current frame, in seconds, with microsecond accuracy.
  1927. @end table
  1928. @subsection Examples
  1929. Some examples follow.
  1930. @itemize
  1931. @item
  1932. Draw "Test Text" with font FreeSerif, using the default values for the
  1933. optional parameters.
  1934. @example
  1935. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  1936. @end example
  1937. @item
  1938. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  1939. and y=50 (counting from the top-left corner of the screen), text is
  1940. yellow with a red box around it. Both the text and the box have an
  1941. opacity of 20%.
  1942. @example
  1943. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  1944. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  1945. @end example
  1946. Note that the double quotes are not necessary if spaces are not used
  1947. within the parameter list.
  1948. @item
  1949. Show the text at the center of the video frame:
  1950. @example
  1951. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  1952. @end example
  1953. @item
  1954. Show a text line sliding from right to left in the last row of the video
  1955. frame. The file @file{LONG_LINE} is assumed to contain a single line
  1956. with no newlines.
  1957. @example
  1958. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  1959. @end example
  1960. @item
  1961. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  1962. @example
  1963. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  1964. @end example
  1965. @item
  1966. Draw a single green letter "g", at the center of the input video.
  1967. The glyph baseline is placed at half screen height.
  1968. @example
  1969. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  1970. @end example
  1971. @item
  1972. Show text for 1 second every 3 seconds:
  1973. @example
  1974. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:draw=lt(mod(t\,3)\,1):text='blink'"
  1975. @end example
  1976. @item
  1977. Use fontconfig to set the font. Note that the colons need to be escaped.
  1978. @example
  1979. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  1980. @end example
  1981. @item
  1982. Print the date of a real-time encoding (see strftime(3)):
  1983. @example
  1984. drawtext='fontfile=FreeSans.ttf:text=%@{localtime:%a %b %d %Y@}'
  1985. @end example
  1986. @end itemize
  1987. For more information about libfreetype, check:
  1988. @url{http://www.freetype.org/}.
  1989. For more information about fontconfig, check:
  1990. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  1991. @section edgedetect
  1992. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  1993. This filter accepts the following optional named parameters:
  1994. @table @option
  1995. @item low, high
  1996. Set low and high threshold values used by the Canny thresholding
  1997. algorithm.
  1998. The high threshold selects the "strong" edge pixels, which are then
  1999. connected through 8-connectivity with the "weak" edge pixels selected
  2000. by the low threshold.
  2001. @var{low} and @var{high} threshold values must be choosen in the range
  2002. [0,1], and @var{low} should be lesser or equal to @var{high}.
  2003. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  2004. is @code{50/255}.
  2005. @end table
  2006. Example:
  2007. @example
  2008. edgedetect=low=0.1:high=0.4
  2009. @end example
  2010. @section fade
  2011. Apply fade-in/out effect to input video.
  2012. The filter accepts parameters as a list of @var{key}=@var{value}
  2013. pairs, separated by ":". If the key of the first options is omitted,
  2014. the arguments are interpreted according to the syntax
  2015. @var{type}:@var{start_frame}:@var{nb_frames}.
  2016. A description of the accepted parameters follows.
  2017. @table @option
  2018. @item type, t
  2019. Specify if the effect type, can be either @code{in} for fade-in, or
  2020. @code{out} for a fade-out effect. Default is @code{in}.
  2021. @item start_frame, s
  2022. Specify the number of the start frame for starting to apply the fade
  2023. effect. Default is 0.
  2024. @item nb_frames, n
  2025. Specify the number of frames for which the fade effect has to last. At
  2026. the end of the fade-in effect the output video will have the same
  2027. intensity as the input video, at the end of the fade-out transition
  2028. the output video will be completely black. Default is 25.
  2029. @item alpha
  2030. If set to 1, fade only alpha channel, if one exists on the input.
  2031. Default value is 0.
  2032. @end table
  2033. @subsection Examples
  2034. @itemize
  2035. @item
  2036. Fade in first 30 frames of video:
  2037. @example
  2038. fade=in:0:30
  2039. @end example
  2040. The command above is equivalent to:
  2041. @example
  2042. fade=t=in:s=0:n=30
  2043. @end example
  2044. @item
  2045. Fade out last 45 frames of a 200-frame video:
  2046. @example
  2047. fade=out:155:45
  2048. @end example
  2049. @item
  2050. Fade in first 25 frames and fade out last 25 frames of a 1000-frame video:
  2051. @example
  2052. fade=in:0:25, fade=out:975:25
  2053. @end example
  2054. @item
  2055. Make first 5 frames black, then fade in from frame 5-24:
  2056. @example
  2057. fade=in:5:20
  2058. @end example
  2059. @item
  2060. Fade in alpha over first 25 frames of video:
  2061. @example
  2062. fade=in:0:25:alpha=1
  2063. @end example
  2064. @end itemize
  2065. @section field
  2066. Extract a single field from an interlaced image using stride
  2067. arithmetic to avoid wasting CPU time. The output frames are marked as
  2068. non-interlaced.
  2069. This filter accepts the following named options:
  2070. @table @option
  2071. @item type
  2072. Specify whether to extract the top (if the value is @code{0} or
  2073. @code{top}) or the bottom field (if the value is @code{1} or
  2074. @code{bottom}).
  2075. @end table
  2076. If the option key is not specified, the first value sets the @var{type}
  2077. option. For example:
  2078. @example
  2079. field=bottom
  2080. @end example
  2081. is equivalent to:
  2082. @example
  2083. field=type=bottom
  2084. @end example
  2085. @section fieldorder
  2086. Transform the field order of the input video.
  2087. It accepts one parameter which specifies the required field order that
  2088. the input interlaced video will be transformed to. The parameter can
  2089. assume one of the following values:
  2090. @table @option
  2091. @item 0 or bff
  2092. output bottom field first
  2093. @item 1 or tff
  2094. output top field first
  2095. @end table
  2096. Default value is "tff".
  2097. Transformation is achieved by shifting the picture content up or down
  2098. by one line, and filling the remaining line with appropriate picture content.
  2099. This method is consistent with most broadcast field order converters.
  2100. If the input video is not flagged as being interlaced, or it is already
  2101. flagged as being of the required output field order then this filter does
  2102. not alter the incoming video.
  2103. This filter is very useful when converting to or from PAL DV material,
  2104. which is bottom field first.
  2105. For example:
  2106. @example
  2107. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  2108. @end example
  2109. @section fifo
  2110. Buffer input images and send them when they are requested.
  2111. This filter is mainly useful when auto-inserted by the libavfilter
  2112. framework.
  2113. The filter does not take parameters.
  2114. @section format
  2115. Convert the input video to one of the specified pixel formats.
  2116. Libavfilter will try to pick one that is supported for the input to
  2117. the next filter.
  2118. The filter accepts a list of pixel format names, separated by ":",
  2119. for example "yuv420p:monow:rgb24".
  2120. Some examples follow:
  2121. @example
  2122. # convert the input video to the format "yuv420p"
  2123. format=yuv420p
  2124. # convert the input video to any of the formats in the list
  2125. format=yuv420p:yuv444p:yuv410p
  2126. @end example
  2127. @section fps
  2128. Convert the video to specified constant framerate by duplicating or dropping
  2129. frames as necessary.
  2130. This filter accepts the following named parameters:
  2131. @table @option
  2132. @item fps
  2133. Desired output framerate. The default is @code{25}.
  2134. @item round
  2135. Rounding method.
  2136. Possible values are:
  2137. @table @option
  2138. @item zero
  2139. zero round towards 0
  2140. @item inf
  2141. round away from 0
  2142. @item down
  2143. round towards -infinity
  2144. @item up
  2145. round towards +infinity
  2146. @item near
  2147. round to nearest
  2148. @end table
  2149. The default is @code{near}.
  2150. @end table
  2151. Alternatively, the options can be specified as a flat string:
  2152. @var{fps}[:@var{round}].
  2153. See also the @ref{setpts} filter.
  2154. @section framestep
  2155. Select one frame every N.
  2156. This filter accepts in input a string representing a positive
  2157. integer. Default argument is @code{1}.
  2158. @anchor{frei0r}
  2159. @section frei0r
  2160. Apply a frei0r effect to the input video.
  2161. To enable compilation of this filter you need to install the frei0r
  2162. header and configure FFmpeg with @code{--enable-frei0r}.
  2163. The filter supports the syntax:
  2164. @example
  2165. @var{filter_name}[@{:|=@}@var{param1}:@var{param2}:...:@var{paramN}]
  2166. @end example
  2167. @var{filter_name} is the name of the frei0r effect to load. If the
  2168. environment variable @env{FREI0R_PATH} is defined, the frei0r effect
  2169. is searched in each one of the directories specified by the colon (or
  2170. semicolon on Windows platforms) separated list in @env{FREIOR_PATH},
  2171. otherwise in the standard frei0r paths, which are in this order:
  2172. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  2173. @file{/usr/lib/frei0r-1/}.
  2174. @var{param1}, @var{param2}, ... , @var{paramN} specify the parameters
  2175. for the frei0r effect.
  2176. A frei0r effect parameter can be a boolean (whose values are specified
  2177. with "y" and "n"), a double, a color (specified by the syntax
  2178. @var{R}/@var{G}/@var{B}, @var{R}, @var{G}, and @var{B} being float
  2179. numbers from 0.0 to 1.0) or by an @code{av_parse_color()} color
  2180. description), a position (specified by the syntax @var{X}/@var{Y},
  2181. @var{X} and @var{Y} being float numbers) and a string.
  2182. The number and kind of parameters depend on the loaded effect. If an
  2183. effect parameter is not specified the default value is set.
  2184. Some examples follow:
  2185. @itemize
  2186. @item
  2187. Apply the distort0r effect, set the first two double parameters:
  2188. @example
  2189. frei0r=distort0r:0.5:0.01
  2190. @end example
  2191. @item
  2192. Apply the colordistance effect, take a color as first parameter:
  2193. @example
  2194. frei0r=colordistance:0.2/0.3/0.4
  2195. frei0r=colordistance:violet
  2196. frei0r=colordistance:0x112233
  2197. @end example
  2198. @item
  2199. Apply the perspective effect, specify the top left and top right image
  2200. positions:
  2201. @example
  2202. frei0r=perspective:0.2/0.2:0.8/0.2
  2203. @end example
  2204. @end itemize
  2205. For more information see:
  2206. @url{http://frei0r.dyne.org}
  2207. @section geq
  2208. The filter takes one, two or three equations as parameter, separated by ':'.
  2209. The first equation is mandatory and applies to the luma plane. The two
  2210. following are respectively for chroma blue and chroma red planes.
  2211. The filter syntax allows named parameters:
  2212. @table @option
  2213. @item lum_expr
  2214. the luminance expression
  2215. @item cb_expr
  2216. the chrominance blue expression
  2217. @item cr_expr
  2218. the chrominance red expression
  2219. @end table
  2220. If one of the chrominance expression is not defined, it falls back on the other
  2221. one. If none of them are specified, they will evaluate the luminance
  2222. expression.
  2223. The expressions can use the following variables and functions:
  2224. @table @option
  2225. @item N
  2226. The sequential number of the filtered frame, starting from @code{0}.
  2227. @item X, Y
  2228. The coordinates of the current sample.
  2229. @item W, H
  2230. The width and height of the image.
  2231. @item SW, SH
  2232. Width and height scale depending on the currently filtered plane. It is the
  2233. ratio between the corresponding luma plane number of pixels and the current
  2234. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  2235. @code{0.5,0.5} for chroma planes.
  2236. @item T
  2237. Time of the current frame, expressed in seconds.
  2238. @item p(x, y)
  2239. Return the value of the pixel at location (@var{x},@var{y}) of the current
  2240. plane.
  2241. @item lum(x, y)
  2242. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  2243. plane.
  2244. @item cb(x, y)
  2245. Return the value of the pixel at location (@var{x},@var{y}) of the
  2246. blue-difference chroma plane.
  2247. @item cr(x, y)
  2248. Return the value of the pixel at location (@var{x},@var{y}) of the
  2249. red-difference chroma plane.
  2250. @end table
  2251. For functions, if @var{x} and @var{y} are outside the area, the value will be
  2252. automatically clipped to the closer edge.
  2253. Some examples follow:
  2254. @itemize
  2255. @item
  2256. Flip the image horizontally:
  2257. @example
  2258. geq=p(W-X\,Y)
  2259. @end example
  2260. @item
  2261. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  2262. wavelength of 100 pixels:
  2263. @example
  2264. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  2265. @end example
  2266. @item
  2267. Generate a fancy enigmatic moving light:
  2268. @example
  2269. nullsrc=s=256x256,geq=random(1)/hypot(X-cos(N*0.07)*W/2-W/2\,Y-sin(N*0.09)*H/2-H/2)^2*1000000*sin(N*0.02):128:128
  2270. @end example
  2271. @end itemize
  2272. @section gradfun
  2273. Fix the banding artifacts that are sometimes introduced into nearly flat
  2274. regions by truncation to 8bit color depth.
  2275. Interpolate the gradients that should go where the bands are, and
  2276. dither them.
  2277. This filter is designed for playback only. Do not use it prior to
  2278. lossy compression, because compression tends to lose the dither and
  2279. bring back the bands.
  2280. The filter accepts a list of options in the form of @var{key}=@var{value} pairs
  2281. separated by ":". A description of the accepted options follows.
  2282. @table @option
  2283. @item strength
  2284. The maximum amount by which the filter will change
  2285. any one pixel. Also the threshold for detecting nearly flat
  2286. regions. Acceptable values range from @code{0.51} to @code{64}, default value
  2287. is @code{1.2}.
  2288. @item radius
  2289. The neighborhood to fit the gradient to. A larger
  2290. radius makes for smoother gradients, but also prevents the filter from
  2291. modifying the pixels near detailed regions. Acceptable values are
  2292. @code{8-32}, default value is @code{16}.
  2293. @end table
  2294. Alternatively, the options can be specified as a flat string:
  2295. @var{strength}[:@var{radius}]
  2296. @subsection Examples
  2297. @itemize
  2298. @item
  2299. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  2300. @example
  2301. gradfun=3.5:8
  2302. @end example
  2303. @item
  2304. Specify radius, omitting the strength (which will fall-back to the default
  2305. value):
  2306. @example
  2307. gradfun=radius=8
  2308. @end example
  2309. @end itemize
  2310. @section hflip
  2311. Flip the input video horizontally.
  2312. For example to horizontally flip the input video with @command{ffmpeg}:
  2313. @example
  2314. ffmpeg -i in.avi -vf "hflip" out.avi
  2315. @end example
  2316. @section histeq
  2317. This filter applies a global color histogram equalization on a
  2318. per-frame basis.
  2319. It can be used to correct video that has a compressed range of pixel
  2320. intensities. The filter redistributes the pixel intensities to
  2321. equalize their distribution across the intensity range. It may be
  2322. viewed as an "automatically adjusting contrast filter". This filter is
  2323. useful only for correcting degraded or poorly captured source
  2324. video.
  2325. The filter accepts parameters as a list of @var{key}=@var{value}
  2326. pairs, separated by ":". If the key of the first options is omitted,
  2327. the arguments are interpreted according to syntax
  2328. @var{strength}:@var{intensity}:@var{antibanding}.
  2329. This filter accepts the following named options:
  2330. @table @option
  2331. @item strength
  2332. Determine the amount of equalization to be applied. As the strength
  2333. is reduced, the distribution of pixel intensities more-and-more
  2334. approaches that of the input frame. The value must be a float number
  2335. in the range [0,1] and defaults to 0.200.
  2336. @item intensity
  2337. Set the maximum intensity that can generated and scale the output
  2338. values appropriately. The strength should be set as desired and then
  2339. the intensity can be limited if needed to avoid washing-out. The value
  2340. must be a float number in the range [0,1] and defaults to 0.210.
  2341. @item antibanding
  2342. Set the antibanding level. If enabled the filter will randomly vary
  2343. the luminance of output pixels by a small amount to avoid banding of
  2344. the histogram. Possible values are @code{none}, @code{weak} or
  2345. @code{strong}. It defaults to @code{none}.
  2346. @end table
  2347. @section histogram
  2348. Compute and draw a color distribution histogram for the input video.
  2349. The computed histogram is a representation of distribution of color components
  2350. in an image.
  2351. The filter accepts the following named parameters:
  2352. @table @option
  2353. @item mode
  2354. Set histogram mode.
  2355. It accepts the following values:
  2356. @table @samp
  2357. @item levels
  2358. standard histogram that display color components distribution in an image.
  2359. Displays color graph for each color component. Shows distribution
  2360. of the Y, U, V, A or G, B, R components, depending on input format,
  2361. in current frame. Bellow each graph is color component scale meter.
  2362. @item color
  2363. chroma values in vectorscope, if brighter more such chroma values are
  2364. distributed in an image.
  2365. Displays chroma values (U/V color placement) in two dimensional graph
  2366. (which is called a vectorscope). It can be used to read of the hue and
  2367. saturation of the current frame. At a same time it is a histogram.
  2368. The whiter a pixel in the vectorscope, the more pixels of the input frame
  2369. correspond to that pixel (that is the more pixels have this chroma value).
  2370. The V component is displayed on the horizontal (X) axis, with the leftmost
  2371. side being V = 0 and the rightmost side being V = 255.
  2372. The U component is displayed on the vertical (Y) axis, with the top
  2373. representing U = 0 and the bottom representing U = 255.
  2374. The position of a white pixel in the graph corresponds to the chroma value
  2375. of a pixel of the input clip. So the graph can be used to read of the
  2376. hue (color flavor) and the saturation (the dominance of the hue in the color).
  2377. As the hue of a color changes, it moves around the square. At the center of
  2378. the square, the saturation is zero, which means that the corresponding pixel
  2379. has no color. If you increase the amount of a specific color, while leaving
  2380. the other colors unchanged, the saturation increases, and you move towards
  2381. the edge of the square.
  2382. @item color2
  2383. chroma values in vectorscope, similar as @code{color} but actual chroma values
  2384. are displayed.
  2385. @item waveform
  2386. per row/column color component graph. In row mode graph in the left side represents
  2387. color component value 0 and right side represents value = 255. In column mode top
  2388. side represents color component value = 0 and bottom side represents value = 255.
  2389. @end table
  2390. Default value is @code{levels}.
  2391. @item level_height
  2392. Set height of level in @code{levels}. Default value is @code{200}.
  2393. Allowed range is [50, 2048].
  2394. @item scale_height
  2395. Set height of color scale in @code{levels}. Default value is @code{12}.
  2396. Allowed range is [0, 40].
  2397. @item step
  2398. Set step for @code{waveform} mode. Smaller values are useful to find out how much
  2399. of same luminance values across input rows/columns are distributed.
  2400. Default value is @code{10}. Allowed range is [1, 255].
  2401. @item waveform_mode
  2402. Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
  2403. Default is @code{row}.
  2404. @item display_mode
  2405. Set display mode for @code{waveform}.
  2406. It accepts the following values:
  2407. @table @samp
  2408. @item parade
  2409. Display separate waveforms for the color components side by side in
  2410. @code{row} mode or one below other in @code{column} mode.
  2411. In this display mode it is easy to spot color casts in the highlights and
  2412. shadows of an image, by comparing the contours of the top and the bottom
  2413. of each waveform. Since whites, grays, and blacks are characterized by
  2414. exactly equal amounts of red, green, and blue, neutral areas of the
  2415. picture should display three waveforms of roughly equal height.
  2416. If not, the correction is easy to make by making adjustments to level the
  2417. three waveforms.
  2418. @item overlay
  2419. Presents information that's identical to that in the @code{parade}, except
  2420. that the waveforms representing color components are superimposed directly
  2421. over one another.
  2422. This display mode can make it easier to spot the relative differences or
  2423. similarities in overlapping areas of the color components that are supposed
  2424. to be identical, such as neutral whites, grays, or blacks.
  2425. @end table
  2426. Default is @code{parade}.
  2427. @end table
  2428. @subsection Examples
  2429. @itemize
  2430. @item
  2431. Calculate and draw histogram:
  2432. @example
  2433. ffplay -i input -vf histogram
  2434. @end example
  2435. @end itemize
  2436. @section hqdn3d
  2437. High precision/quality 3d denoise filter. This filter aims to reduce
  2438. image noise producing smooth images and making still images really
  2439. still. It should enhance compressibility.
  2440. It accepts the following optional parameters:
  2441. @var{luma_spatial}:@var{chroma_spatial}:@var{luma_tmp}:@var{chroma_tmp}
  2442. @table @option
  2443. @item luma_spatial
  2444. a non-negative float number which specifies spatial luma strength,
  2445. defaults to 4.0
  2446. @item chroma_spatial
  2447. a non-negative float number which specifies spatial chroma strength,
  2448. defaults to 3.0*@var{luma_spatial}/4.0
  2449. @item luma_tmp
  2450. a float number which specifies luma temporal strength, defaults to
  2451. 6.0*@var{luma_spatial}/4.0
  2452. @item chroma_tmp
  2453. a float number which specifies chroma temporal strength, defaults to
  2454. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
  2455. @end table
  2456. @section hue
  2457. Modify the hue and/or the saturation of the input.
  2458. This filter accepts the following optional named options:
  2459. @table @option
  2460. @item h
  2461. Specify the hue angle as a number of degrees. It accepts a float
  2462. number or an expression, and defaults to 0.0.
  2463. @item H
  2464. Specify the hue angle as a number of degrees. It accepts a float
  2465. number or an expression, and defaults to 0.0.
  2466. @item s
  2467. Specify the saturation in the [-10,10] range. It accepts a float number and
  2468. defaults to 1.0.
  2469. @end table
  2470. The @var{h}, @var{H} and @var{s} parameters are expressions containing the
  2471. following constants:
  2472. @table @option
  2473. @item n
  2474. frame count of the input frame starting from 0
  2475. @item pts
  2476. presentation timestamp of the input frame expressed in time base units
  2477. @item r
  2478. frame rate of the input video, NAN if the input frame rate is unknown
  2479. @item t
  2480. timestamp expressed in seconds, NAN if the input timestamp is unknown
  2481. @item tb
  2482. time base of the input video
  2483. @end table
  2484. The options can also be set using the syntax: @var{hue}:@var{saturation}
  2485. In this case @var{hue} is expressed in degrees.
  2486. Some examples follow:
  2487. @itemize
  2488. @item
  2489. Set the hue to 90 degrees and the saturation to 1.0:
  2490. @example
  2491. hue=h=90:s=1
  2492. @end example
  2493. @item
  2494. Same command but expressing the hue in radians:
  2495. @example
  2496. hue=H=PI/2:s=1
  2497. @end example
  2498. @item
  2499. Same command without named options, hue must be expressed in degrees:
  2500. @example
  2501. hue=90:1
  2502. @end example
  2503. @item
  2504. Note that "h:s" syntax does not support expressions for the values of
  2505. h and s, so the following example will issue an error:
  2506. @example
  2507. hue=PI/2:1
  2508. @end example
  2509. @item
  2510. Rotate hue and make the saturation swing between 0
  2511. and 2 over a period of 1 second:
  2512. @example
  2513. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  2514. @end example
  2515. @item
  2516. Apply a 3 seconds saturation fade-in effect starting at 0:
  2517. @example
  2518. hue="s=min(t/3\,1)"
  2519. @end example
  2520. The general fade-in expression can be written as:
  2521. @example
  2522. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  2523. @end example
  2524. @item
  2525. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  2526. @example
  2527. hue="s=max(0\, min(1\, (8-t)/3))"
  2528. @end example
  2529. The general fade-out expression can be written as:
  2530. @example
  2531. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  2532. @end example
  2533. @end itemize
  2534. @subsection Commands
  2535. This filter supports the following command:
  2536. @table @option
  2537. @item reinit
  2538. Modify the hue and/or the saturation of the input video.
  2539. The command accepts the same named options and syntax than when calling the
  2540. filter from the command-line.
  2541. If a parameter is omitted, it is kept at its current value.
  2542. @end table
  2543. @section idet
  2544. Detect video interlacing type.
  2545. This filter tries to detect if the input is interlaced or progressive,
  2546. top or bottom field first.
  2547. @section il
  2548. Deinterleave or interleave fields.
  2549. This filter allows to process interlaced images fields without
  2550. deinterlacing them. Deinterleaving splits the input frame into 2
  2551. fields (so called half pictures). Odd lines are moved to the top
  2552. half of the output image, even lines to the bottom half.
  2553. You can process (filter) them independently and then re-interleave them.
  2554. It accepts a list of options in the form of @var{key}=@var{value} pairs
  2555. separated by ":". A description of the accepted options follows.
  2556. @table @option
  2557. @item luma_mode, l
  2558. @item chroma_mode, s
  2559. @item alpha_mode, a
  2560. Available values for @var{luma_mode}, @var{chroma_mode} and
  2561. @var{alpha_mode} are:
  2562. @table @samp
  2563. @item none
  2564. Do nothing.
  2565. @item deinterleave, d
  2566. Deinterleave fields, placing one above the other.
  2567. @item interleave, i
  2568. Interleave fields. Reverse the effect of deinterleaving.
  2569. @end table
  2570. Default value is @code{none}.
  2571. @item luma_swap, ls
  2572. @item chroma_swap, cs
  2573. @item alpha_swap, as
  2574. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  2575. @end table
  2576. @section kerndeint
  2577. Deinterlace input video by applying Donald Graft's adaptive kernel
  2578. deinterling. Work on interlaced parts of a video to produce
  2579. progressive frames.
  2580. This filter accepts parameters as a list of @var{key}=@var{value}
  2581. pairs, separated by ":". If the key of the first options is omitted,
  2582. the arguments are interpreted according to the following syntax:
  2583. @var{thresh}:@var{map}:@var{order}:@var{sharp}:@var{twoway}.
  2584. The description of the accepted parameters follows.
  2585. @table @option
  2586. @item thresh
  2587. Set the threshold which affects the filter's tolerance when
  2588. determining if a pixel line must be processed. It must be an integer
  2589. in the range [0,255] and defaults to 10. A value of 0 will result in
  2590. applying the process on every pixels.
  2591. @item map
  2592. Paint pixels exceeding the threshold value to white if set to 1.
  2593. Default is 0.
  2594. @item order
  2595. Set the fields order. Swap fields if set to 1, leave fields alone if
  2596. 0. Default is 0.
  2597. @item sharp
  2598. Enable additional sharpening if set to 1. Default is 0.
  2599. @item twoway
  2600. Enable twoway sharpening if set to 1. Default is 0.
  2601. @end table
  2602. @subsection Examples
  2603. @itemize
  2604. @item
  2605. Apply default values:
  2606. @example
  2607. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  2608. @end example
  2609. @item
  2610. Enable additional sharpening:
  2611. @example
  2612. kerndeint=sharp=1
  2613. @end example
  2614. @item
  2615. Paint processed pixels in white:
  2616. @example
  2617. kerndeint=map=1
  2618. @end example
  2619. @end itemize
  2620. @section lut, lutrgb, lutyuv
  2621. Compute a look-up table for binding each pixel component input value
  2622. to an output value, and apply it to input video.
  2623. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  2624. to an RGB input video.
  2625. These filters accept in input a ":"-separated list of options, which
  2626. specify the expressions used for computing the lookup table for the
  2627. corresponding pixel component values.
  2628. The @var{lut} filter requires either YUV or RGB pixel formats in
  2629. input, and accepts the options:
  2630. @table @option
  2631. @item c0
  2632. set first pixel component expression
  2633. @item c1
  2634. set second pixel component expression
  2635. @item c2
  2636. set third pixel component expression
  2637. @item c3
  2638. set fourth pixel component expression, corresponds to the alpha component
  2639. @end table
  2640. The exact component associated to each option depends on the format in
  2641. input.
  2642. The @var{lutrgb} filter requires RGB pixel formats in input, and
  2643. accepts the options:
  2644. @table @option
  2645. @item r
  2646. set red component expression
  2647. @item g
  2648. set green component expression
  2649. @item b
  2650. set blue component expression
  2651. @item a
  2652. alpha component expression
  2653. @end table
  2654. The @var{lutyuv} filter requires YUV pixel formats in input, and
  2655. accepts the options:
  2656. @table @option
  2657. @item y
  2658. set Y/luminance component expression
  2659. @item u
  2660. set U/Cb component expression
  2661. @item v
  2662. set V/Cr component expression
  2663. @item a
  2664. set alpha component expression
  2665. @end table
  2666. The expressions can contain the following constants and functions:
  2667. @table @option
  2668. @item w, h
  2669. the input width and height
  2670. @item val
  2671. input value for the pixel component
  2672. @item clipval
  2673. the input value clipped in the @var{minval}-@var{maxval} range
  2674. @item maxval
  2675. maximum value for the pixel component
  2676. @item minval
  2677. minimum value for the pixel component
  2678. @item negval
  2679. the negated value for the pixel component value clipped in the
  2680. @var{minval}-@var{maxval} range , it corresponds to the expression
  2681. "maxval-clipval+minval"
  2682. @item clip(val)
  2683. the computed value in @var{val} clipped in the
  2684. @var{minval}-@var{maxval} range
  2685. @item gammaval(gamma)
  2686. the computed gamma correction value of the pixel component value
  2687. clipped in the @var{minval}-@var{maxval} range, corresponds to the
  2688. expression
  2689. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  2690. @end table
  2691. All expressions default to "val".
  2692. @subsection Examples
  2693. @itemize
  2694. @item
  2695. Negate input video:
  2696. @example
  2697. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  2698. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  2699. @end example
  2700. The above is the same as:
  2701. @example
  2702. lutrgb="r=negval:g=negval:b=negval"
  2703. lutyuv="y=negval:u=negval:v=negval"
  2704. @end example
  2705. @item
  2706. Negate luminance:
  2707. @example
  2708. lutyuv=y=negval
  2709. @end example
  2710. @item
  2711. Remove chroma components, turns the video into a graytone image:
  2712. @example
  2713. lutyuv="u=128:v=128"
  2714. @end example
  2715. @item
  2716. Apply a luma burning effect:
  2717. @example
  2718. lutyuv="y=2*val"
  2719. @end example
  2720. @item
  2721. Remove green and blue components:
  2722. @example
  2723. lutrgb="g=0:b=0"
  2724. @end example
  2725. @item
  2726. Set a constant alpha channel value on input:
  2727. @example
  2728. format=rgba,lutrgb=a="maxval-minval/2"
  2729. @end example
  2730. @item
  2731. Correct luminance gamma by a 0.5 factor:
  2732. @example
  2733. lutyuv=y=gammaval(0.5)
  2734. @end example
  2735. @end itemize
  2736. @section mp
  2737. Apply an MPlayer filter to the input video.
  2738. This filter provides a wrapper around most of the filters of
  2739. MPlayer/MEncoder.
  2740. This wrapper is considered experimental. Some of the wrapped filters
  2741. may not work properly and we may drop support for them, as they will
  2742. be implemented natively into FFmpeg. Thus you should avoid
  2743. depending on them when writing portable scripts.
  2744. The filters accepts the parameters:
  2745. @var{filter_name}[:=]@var{filter_params}
  2746. @var{filter_name} is the name of a supported MPlayer filter,
  2747. @var{filter_params} is a string containing the parameters accepted by
  2748. the named filter.
  2749. The list of the currently supported filters follows:
  2750. @table @var
  2751. @item detc
  2752. @item dint
  2753. @item divtc
  2754. @item down3dright
  2755. @item eq2
  2756. @item eq
  2757. @item fil
  2758. @item fspp
  2759. @item harddup
  2760. @item ilpack
  2761. @item ivtc
  2762. @item kerndeint
  2763. @item mcdeint
  2764. @item noise
  2765. @item ow
  2766. @item perspective
  2767. @item phase
  2768. @item pp7
  2769. @item pullup
  2770. @item qp
  2771. @item sab
  2772. @item softpulldown
  2773. @item spp
  2774. @item telecine
  2775. @item tinterlace
  2776. @item unsharp
  2777. @item uspp
  2778. @end table
  2779. The parameter syntax and behavior for the listed filters are the same
  2780. of the corresponding MPlayer filters. For detailed instructions check
  2781. the "VIDEO FILTERS" section in the MPlayer manual.
  2782. Some examples follow:
  2783. @itemize
  2784. @item
  2785. Adjust gamma, brightness, contrast:
  2786. @example
  2787. mp=eq2=1.0:2:0.5
  2788. @end example
  2789. @item
  2790. Add temporal noise to input video:
  2791. @example
  2792. mp=noise=20t
  2793. @end example
  2794. @end itemize
  2795. See also mplayer(1), @url{http://www.mplayerhq.hu/}.
  2796. @section negate
  2797. Negate input video.
  2798. This filter accepts an integer in input, if non-zero it negates the
  2799. alpha component (if available). The default value in input is 0.
  2800. @section noformat
  2801. Force libavfilter not to use any of the specified pixel formats for the
  2802. input to the next filter.
  2803. The filter accepts a list of pixel format names, separated by ":",
  2804. for example "yuv420p:monow:rgb24".
  2805. Some examples follow:
  2806. @example
  2807. # force libavfilter to use a format different from "yuv420p" for the
  2808. # input to the vflip filter
  2809. noformat=yuv420p,vflip
  2810. # convert the input video to any of the formats not contained in the list
  2811. noformat=yuv420p:yuv444p:yuv410p
  2812. @end example
  2813. @section null
  2814. Pass the video source unchanged to the output.
  2815. @section ocv
  2816. Apply video transform using libopencv.
  2817. To enable this filter install libopencv library and headers and
  2818. configure FFmpeg with @code{--enable-libopencv}.
  2819. The filter takes the parameters: @var{filter_name}@{:=@}@var{filter_params}.
  2820. @var{filter_name} is the name of the libopencv filter to apply.
  2821. @var{filter_params} specifies the parameters to pass to the libopencv
  2822. filter. If not specified the default values are assumed.
  2823. Refer to the official libopencv documentation for more precise
  2824. information:
  2825. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  2826. Follows the list of supported libopencv filters.
  2827. @anchor{dilate}
  2828. @subsection dilate
  2829. Dilate an image by using a specific structuring element.
  2830. This filter corresponds to the libopencv function @code{cvDilate}.
  2831. It accepts the parameters: @var{struct_el}:@var{nb_iterations}.
  2832. @var{struct_el} represents a structuring element, and has the syntax:
  2833. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  2834. @var{cols} and @var{rows} represent the number of columns and rows of
  2835. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  2836. point, and @var{shape} the shape for the structuring element, and
  2837. can be one of the values "rect", "cross", "ellipse", "custom".
  2838. If the value for @var{shape} is "custom", it must be followed by a
  2839. string of the form "=@var{filename}". The file with name
  2840. @var{filename} is assumed to represent a binary image, with each
  2841. printable character corresponding to a bright pixel. When a custom
  2842. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  2843. or columns and rows of the read file are assumed instead.
  2844. The default value for @var{struct_el} is "3x3+0x0/rect".
  2845. @var{nb_iterations} specifies the number of times the transform is
  2846. applied to the image, and defaults to 1.
  2847. Follow some example:
  2848. @example
  2849. # use the default values
  2850. ocv=dilate
  2851. # dilate using a structuring element with a 5x5 cross, iterate two times
  2852. ocv=dilate=5x5+2x2/cross:2
  2853. # read the shape from the file diamond.shape, iterate two times
  2854. # the file diamond.shape may contain a pattern of characters like this:
  2855. # *
  2856. # ***
  2857. # *****
  2858. # ***
  2859. # *
  2860. # the specified cols and rows are ignored (but not the anchor point coordinates)
  2861. ocv=0x0+2x2/custom=diamond.shape:2
  2862. @end example
  2863. @subsection erode
  2864. Erode an image by using a specific structuring element.
  2865. This filter corresponds to the libopencv function @code{cvErode}.
  2866. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
  2867. with the same syntax and semantics as the @ref{dilate} filter.
  2868. @subsection smooth
  2869. Smooth the input video.
  2870. The filter takes the following parameters:
  2871. @var{type}:@var{param1}:@var{param2}:@var{param3}:@var{param4}.
  2872. @var{type} is the type of smooth filter to apply, and can be one of
  2873. the following values: "blur", "blur_no_scale", "median", "gaussian",
  2874. "bilateral". The default value is "gaussian".
  2875. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  2876. parameters whose meanings depend on smooth type. @var{param1} and
  2877. @var{param2} accept integer positive values or 0, @var{param3} and
  2878. @var{param4} accept float values.
  2879. The default value for @var{param1} is 3, the default value for the
  2880. other parameters is 0.
  2881. These parameters correspond to the parameters assigned to the
  2882. libopencv function @code{cvSmooth}.
  2883. @anchor{overlay}
  2884. @section overlay
  2885. Overlay one video on top of another.
  2886. It takes two inputs and one output, the first input is the "main"
  2887. video on which the second input is overlayed.
  2888. This filter accepts a list of @var{key}=@var{value} pairs as argument,
  2889. separated by ":". If the key of the first options is omitted, the
  2890. arguments are interpreted according to the syntax @var{x}:@var{y}.
  2891. A description of the accepted options follows.
  2892. @table @option
  2893. @item x, y
  2894. Set the expression for the x and y coordinates of the overlayed video
  2895. on the main video. Default value is 0.
  2896. The @var{x} and @var{y} expressions can contain the following
  2897. parameters:
  2898. @table @option
  2899. @item main_w, main_h
  2900. main input width and height
  2901. @item W, H
  2902. same as @var{main_w} and @var{main_h}
  2903. @item overlay_w, overlay_h
  2904. overlay input width and height
  2905. @item w, h
  2906. same as @var{overlay_w} and @var{overlay_h}
  2907. @end table
  2908. @item rgb
  2909. If set to 1, force the filter to accept inputs in the RGB
  2910. color space. Default value is 0.
  2911. @end table
  2912. Be aware that frames are taken from each input video in timestamp
  2913. order, hence, if their initial timestamps differ, it is a a good idea
  2914. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  2915. have them begin in the same zero timestamp, as it does the example for
  2916. the @var{movie} filter.
  2917. You can chain together more overlays but you should test the
  2918. efficiency of such approach.
  2919. @subsection Examples
  2920. @itemize
  2921. @item
  2922. Draw the overlay at 10 pixels from the bottom right corner of the main
  2923. video:
  2924. @example
  2925. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  2926. @end example
  2927. Using named options the example above becomes:
  2928. @example
  2929. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  2930. @end example
  2931. @item
  2932. Insert a transparent PNG logo in the bottom left corner of the input,
  2933. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  2934. @example
  2935. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  2936. @end example
  2937. @item
  2938. Insert 2 different transparent PNG logos (second logo on bottom
  2939. right corner) using the @command{ffmpeg} tool:
  2940. @example
  2941. ffmpeg -i input -i logo1 -i logo2 -filter_complex 'overlay=10:H-h-10,overlay=W-w-10:H-h-10' output
  2942. @end example
  2943. @item
  2944. Add a transparent color layer on top of the main video, WxH specifies
  2945. the size of the main input to the overlay filter:
  2946. @example
  2947. color=red@@.3:WxH [over]; [in][over] overlay [out]
  2948. @end example
  2949. @item
  2950. Play an original video and a filtered version (here with the deshake
  2951. filter) side by side using the @command{ffplay} tool:
  2952. @example
  2953. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  2954. @end example
  2955. The above command is the same as:
  2956. @example
  2957. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  2958. @end example
  2959. @item
  2960. Chain several overlays in cascade:
  2961. @example
  2962. nullsrc=s=200x200 [bg];
  2963. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  2964. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  2965. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  2966. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  2967. [in3] null, [mid2] overlay=100:100 [out0]
  2968. @end example
  2969. @end itemize
  2970. @section pad
  2971. Add paddings to the input image, and place the original input at the
  2972. given coordinates @var{x}, @var{y}.
  2973. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  2974. separated by ":".
  2975. If the key of the first options is omitted, the arguments are
  2976. interpreted according to the syntax
  2977. @var{width}:@var{height}:@var{x}:@var{y}:@var{color}.
  2978. A description of the accepted options follows.
  2979. @table @option
  2980. @item width, w
  2981. @item height, h
  2982. Specify an expression for the size of the output image with the
  2983. paddings added. If the value for @var{width} or @var{height} is 0, the
  2984. corresponding input size is used for the output.
  2985. The @var{width} expression can reference the value set by the
  2986. @var{height} expression, and vice versa.
  2987. The default value of @var{width} and @var{height} is 0.
  2988. @item x
  2989. @item y
  2990. Specify an expression for the offsets where to place the input image
  2991. in the padded area with respect to the top/left border of the output
  2992. image.
  2993. The @var{x} expression can reference the value set by the @var{y}
  2994. expression, and vice versa.
  2995. The default value of @var{x} and @var{y} is 0.
  2996. @item color
  2997. Specify the color of the padded area, it can be the name of a color
  2998. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  2999. The default value of @var{color} is "black".
  3000. @end table
  3001. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  3002. options are expressions containing the following constants:
  3003. @table @option
  3004. @item in_w, in_h
  3005. the input video width and height
  3006. @item iw, ih
  3007. same as @var{in_w} and @var{in_h}
  3008. @item out_w, out_h
  3009. the output width and height, that is the size of the padded area as
  3010. specified by the @var{width} and @var{height} expressions
  3011. @item ow, oh
  3012. same as @var{out_w} and @var{out_h}
  3013. @item x, y
  3014. x and y offsets as specified by the @var{x} and @var{y}
  3015. expressions, or NAN if not yet specified
  3016. @item a
  3017. same as @var{iw} / @var{ih}
  3018. @item sar
  3019. input sample aspect ratio
  3020. @item dar
  3021. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  3022. @item hsub, vsub
  3023. horizontal and vertical chroma subsample values. For example for the
  3024. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3025. @end table
  3026. @subsection Examples
  3027. @itemize
  3028. @item
  3029. Add paddings with color "violet" to the input video. Output video
  3030. size is 640x480, the top-left corner of the input video is placed at
  3031. column 0, row 40:
  3032. @example
  3033. pad=640:480:0:40:violet
  3034. @end example
  3035. The example above is equivalent to the following command:
  3036. @example
  3037. pad=width=640:height=480:x=0:y=40:color=violet
  3038. @end example
  3039. @item
  3040. Pad the input to get an output with dimensions increased by 3/2,
  3041. and put the input video at the center of the padded area:
  3042. @example
  3043. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  3044. @end example
  3045. @item
  3046. Pad the input to get a squared output with size equal to the maximum
  3047. value between the input width and height, and put the input video at
  3048. the center of the padded area:
  3049. @example
  3050. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  3051. @end example
  3052. @item
  3053. Pad the input to get a final w/h ratio of 16:9:
  3054. @example
  3055. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  3056. @end example
  3057. @item
  3058. In case of anamorphic video, in order to set the output display aspect
  3059. correctly, it is necessary to use @var{sar} in the expression,
  3060. according to the relation:
  3061. @example
  3062. (ih * X / ih) * sar = output_dar
  3063. X = output_dar / sar
  3064. @end example
  3065. Thus the previous example needs to be modified to:
  3066. @example
  3067. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  3068. @end example
  3069. @item
  3070. Double output size and put the input video in the bottom-right
  3071. corner of the output padded area:
  3072. @example
  3073. pad="2*iw:2*ih:ow-iw:oh-ih"
  3074. @end example
  3075. @end itemize
  3076. @section pixdesctest
  3077. Pixel format descriptor test filter, mainly useful for internal
  3078. testing. The output video should be equal to the input video.
  3079. For example:
  3080. @example
  3081. format=monow, pixdesctest
  3082. @end example
  3083. can be used to test the monowhite pixel format descriptor definition.
  3084. @section pp
  3085. Enable the specified chain of postprocessing subfilters using libpostproc. This
  3086. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  3087. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  3088. Each subfilter and some options have a short and a long name that can be used
  3089. interchangeably, i.e. dr/dering are the same.
  3090. All subfilters share common options to determine their scope:
  3091. @table @option
  3092. @item a/autoq
  3093. Honor the quality commands for this subfilter.
  3094. @item c/chrom
  3095. Do chrominance filtering, too (default).
  3096. @item y/nochrom
  3097. Do luminance filtering only (no chrominance).
  3098. @item n/noluma
  3099. Do chrominance filtering only (no luminance).
  3100. @end table
  3101. These options can be appended after the subfilter name, separated by a ':'.
  3102. Available subfilters are:
  3103. @table @option
  3104. @item hb/hdeblock[:difference[:flatness]]
  3105. Horizontal deblocking filter
  3106. @table @option
  3107. @item difference
  3108. Difference factor where higher values mean more deblocking (default: @code{32}).
  3109. @item flatness
  3110. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  3111. @end table
  3112. @item vb/vdeblock[:difference[:flatness]]
  3113. Vertical deblocking filter
  3114. @table @option
  3115. @item difference
  3116. Difference factor where higher values mean more deblocking (default: @code{32}).
  3117. @item flatness
  3118. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  3119. @end table
  3120. @item ha/hadeblock[:difference[:flatness]]
  3121. Accurate horizontal deblocking filter
  3122. @table @option
  3123. @item difference
  3124. Difference factor where higher values mean more deblocking (default: @code{32}).
  3125. @item flatness
  3126. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  3127. @end table
  3128. @item va/vadeblock[:difference[:flatness]]
  3129. Accurate vertical deblocking filter
  3130. @table @option
  3131. @item difference
  3132. Difference factor where higher values mean more deblocking (default: @code{32}).
  3133. @item flatness
  3134. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  3135. @end table
  3136. @end table
  3137. The horizontal and vertical deblocking filters share the difference and
  3138. flatness values so you cannot set different horizontal and vertical
  3139. thresholds.
  3140. @table @option
  3141. @item h1/x1hdeblock
  3142. Experimental horizontal deblocking filter
  3143. @item v1/x1vdeblock
  3144. Experimental vertical deblocking filter
  3145. @item dr/dering
  3146. Deringing filter
  3147. @item tn/tmpnoise[:threshold1[:threshold2[:threshold3]]], temporal noise reducer
  3148. @table @option
  3149. @item threshold1
  3150. larger -> stronger filtering
  3151. @item threshold2
  3152. larger -> stronger filtering
  3153. @item threshold3
  3154. larger -> stronger filtering
  3155. @end table
  3156. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  3157. @table @option
  3158. @item f/fullyrange
  3159. Stretch luminance to @code{0-255}.
  3160. @end table
  3161. @item lb/linblenddeint
  3162. Linear blend deinterlacing filter that deinterlaces the given block by
  3163. filtering all lines with a @code{(1 2 1)} filter.
  3164. @item li/linipoldeint
  3165. Linear interpolating deinterlacing filter that deinterlaces the given block by
  3166. linearly interpolating every second line.
  3167. @item ci/cubicipoldeint
  3168. Cubic interpolating deinterlacing filter deinterlaces the given block by
  3169. cubically interpolating every second line.
  3170. @item md/mediandeint
  3171. Median deinterlacing filter that deinterlaces the given block by applying a
  3172. median filter to every second line.
  3173. @item fd/ffmpegdeint
  3174. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  3175. second line with a @code{(-1 4 2 4 -1)} filter.
  3176. @item l5/lowpass5
  3177. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  3178. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  3179. @item fq/forceQuant[:quantizer]
  3180. Overrides the quantizer table from the input with the constant quantizer you
  3181. specify.
  3182. @table @option
  3183. @item quantizer
  3184. Quantizer to use
  3185. @end table
  3186. @item de/default
  3187. Default pp filter combination (@code{hb:a,vb:a,dr:a})
  3188. @item fa/fast
  3189. Fast pp filter combination (@code{h1:a,v1:a,dr:a})
  3190. @item ac
  3191. High quality pp filter combination (@code{ha:a:128:7,va:a,dr:a})
  3192. @end table
  3193. @subsection Examples
  3194. @itemize
  3195. @item
  3196. Apply horizontal and vertical deblocking, deringing and automatic
  3197. brightness/contrast:
  3198. @example
  3199. pp=hb/vb/dr/al
  3200. @end example
  3201. @item
  3202. Apply default filters without brightness/contrast correction:
  3203. @example
  3204. pp=de/-al
  3205. @end example
  3206. @item
  3207. Apply default filters and temporal denoiser:
  3208. @example
  3209. pp=default/tmpnoise:1:2:3
  3210. @end example
  3211. @item
  3212. Apply deblocking on luminance only, and switch vertical deblocking on or off
  3213. automatically depending on available CPU time:
  3214. @example
  3215. pp=hb:y/vb:a
  3216. @end example
  3217. @end itemize
  3218. @section removelogo
  3219. Suppress a TV station logo, using an image file to determine which
  3220. pixels comprise the logo. It works by filling in the pixels that
  3221. comprise the logo with neighboring pixels.
  3222. This filter requires one argument which specifies the filter bitmap
  3223. file, which can be any image format supported by libavformat. The
  3224. width and height of the image file must match those of the video
  3225. stream being processed.
  3226. Pixels in the provided bitmap image with a value of zero are not
  3227. considered part of the logo, non-zero pixels are considered part of
  3228. the logo. If you use white (255) for the logo and black (0) for the
  3229. rest, you will be safe. For making the filter bitmap, it is
  3230. recommended to take a screen capture of a black frame with the logo
  3231. visible, and then using a threshold filter followed by the erode
  3232. filter once or twice.
  3233. If needed, little splotches can be fixed manually. Remember that if
  3234. logo pixels are not covered, the filter quality will be much
  3235. reduced. Marking too many pixels as part of the logo does not hurt as
  3236. much, but it will increase the amount of blurring needed to cover over
  3237. the image and will destroy more information than necessary, and extra
  3238. pixels will slow things down on a large logo.
  3239. @section scale
  3240. Scale (resize) the input video, using the libswscale library.
  3241. The scale filter forces the output display aspect ratio to be the same
  3242. of the input, by changing the output sample aspect ratio.
  3243. This filter accepts a list of named options in the form of
  3244. @var{key}=@var{value} pairs separated by ":". If the key for the first
  3245. two options is not specified, the assumed keys for the first two
  3246. values are @code{w} and @code{h}. If the first option has no key and
  3247. can be interpreted like a video size specification, it will be used
  3248. to set the video size.
  3249. A description of the accepted options follows.
  3250. @table @option
  3251. @item width, w
  3252. Set the video width expression, default value is @code{iw}. See below
  3253. for the list of accepted constants.
  3254. @item height, h
  3255. Set the video heiht expression, default value is @code{ih}.
  3256. See below for the list of accepted constants.
  3257. @item interl
  3258. Set the interlacing. It accepts the following values:
  3259. @table @option
  3260. @item 1
  3261. force interlaced aware scaling
  3262. @item 0
  3263. do not apply interlaced scaling
  3264. @item -1
  3265. select interlaced aware scaling depending on whether the source frames
  3266. are flagged as interlaced or not
  3267. @end table
  3268. Default value is @code{0}.
  3269. @item flags
  3270. Set libswscale scaling flags. If not explictly specified the filter
  3271. applies a bilinear scaling algorithm.
  3272. @item size, s
  3273. Set the video size, the value must be a valid abbreviation or in the
  3274. form @var{width}x@var{height}.
  3275. @end table
  3276. The values of the @var{w} and @var{h} options are expressions
  3277. containing the following constants:
  3278. @table @option
  3279. @item in_w, in_h
  3280. the input width and height
  3281. @item iw, ih
  3282. same as @var{in_w} and @var{in_h}
  3283. @item out_w, out_h
  3284. the output (cropped) width and height
  3285. @item ow, oh
  3286. same as @var{out_w} and @var{out_h}
  3287. @item a
  3288. same as @var{iw} / @var{ih}
  3289. @item sar
  3290. input sample aspect ratio
  3291. @item dar
  3292. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  3293. @item hsub, vsub
  3294. horizontal and vertical chroma subsample values. For example for the
  3295. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3296. @end table
  3297. If the input image format is different from the format requested by
  3298. the next filter, the scale filter will convert the input to the
  3299. requested format.
  3300. If the value for @var{width} or @var{height} is 0, the respective input
  3301. size is used for the output.
  3302. If the value for @var{width} or @var{height} is -1, the scale filter will
  3303. use, for the respective output size, a value that maintains the aspect
  3304. ratio of the input image.
  3305. @subsection Examples
  3306. @itemize
  3307. @item
  3308. Scale the input video to a size of 200x100:
  3309. @example
  3310. scale=200:100
  3311. @end example
  3312. This is equivalent to:
  3313. @example
  3314. scale=w=200:h=100
  3315. @end example
  3316. or:
  3317. @example
  3318. scale=200x100
  3319. @end example
  3320. @item
  3321. Specify a size abbreviation for the output size:
  3322. @example
  3323. scale=qcif
  3324. @end example
  3325. which can also be written as:
  3326. @example
  3327. scale=size=qcif
  3328. @end example
  3329. @item
  3330. Scale the input to 2x:
  3331. @example
  3332. scale=2*iw:2*ih
  3333. @end example
  3334. @item
  3335. The above is the same as:
  3336. @example
  3337. scale=2*in_w:2*in_h
  3338. @end example
  3339. @item
  3340. Scale the input to 2x with forced interlaced scaling:
  3341. @example
  3342. scale=2*iw:2*ih:interl=1
  3343. @end example
  3344. @item
  3345. Scale the input to half size:
  3346. @example
  3347. scale=iw/2:ih/2
  3348. @end example
  3349. @item
  3350. Increase the width, and set the height to the same size:
  3351. @example
  3352. scale=3/2*iw:ow
  3353. @end example
  3354. @item
  3355. Seek for Greek harmony:
  3356. @example
  3357. scale=iw:1/PHI*iw
  3358. scale=ih*PHI:ih
  3359. @end example
  3360. @item
  3361. Increase the height, and set the width to 3/2 of the height:
  3362. @example
  3363. scale=3/2*oh:3/5*ih
  3364. @end example
  3365. @item
  3366. Increase the size, but make the size a multiple of the chroma:
  3367. @example
  3368. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  3369. @end example
  3370. @item
  3371. Increase the width to a maximum of 500 pixels, keep the same input
  3372. aspect ratio:
  3373. @example
  3374. scale='min(500\, iw*3/2):-1'
  3375. @end example
  3376. @end itemize
  3377. @section setdar, setsar
  3378. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  3379. output video.
  3380. This is done by changing the specified Sample (aka Pixel) Aspect
  3381. Ratio, according to the following equation:
  3382. @example
  3383. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  3384. @end example
  3385. Keep in mind that the @code{setdar} filter does not modify the pixel
  3386. dimensions of the video frame. Also the display aspect ratio set by
  3387. this filter may be changed by later filters in the filterchain,
  3388. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  3389. applied.
  3390. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  3391. the filter output video.
  3392. Note that as a consequence of the application of this filter, the
  3393. output display aspect ratio will change according to the equation
  3394. above.
  3395. Keep in mind that the sample aspect ratio set by the @code{setsar}
  3396. filter may be changed by later filters in the filterchain, e.g. if
  3397. another "setsar" or a "setdar" filter is applied.
  3398. The @code{setdar} and @code{setsar} filters accept a string in the
  3399. form @var{num}:@var{den} expressing an aspect ratio, or the following
  3400. named options, expressed as a sequence of @var{key}=@var{value} pairs,
  3401. separated by ":".
  3402. @table @option
  3403. @item max
  3404. Set the maximum integer value to use for expressing numerator and
  3405. denominator when reducing the expressed aspect ratio to a rational.
  3406. Default value is @code{100}.
  3407. @item r, ratio:
  3408. Set the aspect ratio used by the filter.
  3409. The parameter can be a floating point number string, an expression, or
  3410. a string of the form @var{num}:@var{den}, where @var{num} and
  3411. @var{den} are the numerator and denominator of the aspect ratio. If
  3412. the parameter is not specified, it is assumed the value "0".
  3413. In case the form "@var{num}:@var{den}" the @code{:} character should
  3414. be escaped.
  3415. @end table
  3416. If the keys are omitted in the named options list, the specifed values
  3417. are assumed to be @var{ratio} and @var{max} in that order.
  3418. For example to change the display aspect ratio to 16:9, specify:
  3419. @example
  3420. setdar='16:9'
  3421. @end example
  3422. The example above is equivalent to:
  3423. @example
  3424. setdar=1.77777
  3425. @end example
  3426. To change the sample aspect ratio to 10:11, specify:
  3427. @example
  3428. setsar='10:11'
  3429. @end example
  3430. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  3431. 1000 in the aspect ratio reduction, use the command:
  3432. @example
  3433. setdar=ratio='16:9':max=1000
  3434. @end example
  3435. @section setfield
  3436. Force field for the output video frame.
  3437. The @code{setfield} filter marks the interlace type field for the
  3438. output frames. It does not change the input frame, but only sets the
  3439. corresponding property, which affects how the frame is treated by
  3440. following filters (e.g. @code{fieldorder} or @code{yadif}).
  3441. This filter accepts a single option @option{mode}, which can be
  3442. specified either by setting @code{mode=VALUE} or setting the value
  3443. alone. Available values are:
  3444. @table @samp
  3445. @item auto
  3446. Keep the same field property.
  3447. @item bff
  3448. Mark the frame as bottom-field-first.
  3449. @item tff
  3450. Mark the frame as top-field-first.
  3451. @item prog
  3452. Mark the frame as progressive.
  3453. @end table
  3454. @section showinfo
  3455. Show a line containing various information for each input video frame.
  3456. The input video is not modified.
  3457. The shown line contains a sequence of key/value pairs of the form
  3458. @var{key}:@var{value}.
  3459. A description of each shown parameter follows:
  3460. @table @option
  3461. @item n
  3462. sequential number of the input frame, starting from 0
  3463. @item pts
  3464. Presentation TimeStamp of the input frame, expressed as a number of
  3465. time base units. The time base unit depends on the filter input pad.
  3466. @item pts_time
  3467. Presentation TimeStamp of the input frame, expressed as a number of
  3468. seconds
  3469. @item pos
  3470. position of the frame in the input stream, -1 if this information in
  3471. unavailable and/or meaningless (for example in case of synthetic video)
  3472. @item fmt
  3473. pixel format name
  3474. @item sar
  3475. sample aspect ratio of the input frame, expressed in the form
  3476. @var{num}/@var{den}
  3477. @item s
  3478. size of the input frame, expressed in the form
  3479. @var{width}x@var{height}
  3480. @item i
  3481. interlaced mode ("P" for "progressive", "T" for top field first, "B"
  3482. for bottom field first)
  3483. @item iskey
  3484. 1 if the frame is a key frame, 0 otherwise
  3485. @item type
  3486. picture type of the input frame ("I" for an I-frame, "P" for a
  3487. P-frame, "B" for a B-frame, "?" for unknown type).
  3488. Check also the documentation of the @code{AVPictureType} enum and of
  3489. the @code{av_get_picture_type_char} function defined in
  3490. @file{libavutil/avutil.h}.
  3491. @item checksum
  3492. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  3493. @item plane_checksum
  3494. Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  3495. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]"
  3496. @end table
  3497. @section smartblur
  3498. Blur the input video without impacting the outlines.
  3499. The filter accepts the following parameters:
  3500. @var{luma_radius}:@var{luma_strength}:@var{luma_threshold}[:@var{chroma_radius}:@var{chroma_strength}:@var{chroma_threshold}]
  3501. Parameters prefixed by @var{luma} indicate that they work on the
  3502. luminance of the pixels whereas parameters prefixed by @var{chroma}
  3503. refer to the chrominance of the pixels.
  3504. If the chroma parameters are not set, the luma parameters are used for
  3505. either the luminance and the chrominance of the pixels.
  3506. @var{luma_radius} or @var{chroma_radius} must be a float number in the
  3507. range [0.1,5.0] that specifies the variance of the gaussian filter
  3508. used to blur the image (slower if larger).
  3509. @var{luma_strength} or @var{chroma_strength} must be a float number in
  3510. the range [-1.0,1.0] that configures the blurring. A value included in
  3511. [0.0,1.0] will blur the image whereas a value included in [-1.0,0.0]
  3512. will sharpen the image.
  3513. @var{luma_threshold} or @var{chroma_threshold} must be an integer in
  3514. the range [-30,30] that is used as a coefficient to determine whether
  3515. a pixel should be blurred or not. A value of 0 will filter all the
  3516. image, a value included in [0,30] will filter flat areas and a value
  3517. included in [-30,0] will filter edges.
  3518. @anchor{subtitles}
  3519. @section subtitles
  3520. Draw subtitles on top of input video using the libass library.
  3521. To enable compilation of this filter you need to configure FFmpeg with
  3522. @code{--enable-libass}. This filter also requires a build with libavcodec and
  3523. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  3524. Alpha) subtitles format.
  3525. This filter accepts the following named options, expressed as a
  3526. sequence of @var{key}=@var{value} pairs, separated by ":".
  3527. @table @option
  3528. @item filename, f
  3529. Set the filename of the subtitle file to read. It must be specified.
  3530. @item original_size
  3531. Specify the size of the original video, the video for which the ASS file
  3532. was composed. Due to a misdesign in ASS aspect ratio arithmetic, this is
  3533. necessary to correctly scale the fonts if the aspect ratio has been changed.
  3534. @end table
  3535. If the first key is not specified, it is assumed that the first value
  3536. specifies the @option{filename}.
  3537. For example, to render the file @file{sub.srt} on top of the input
  3538. video, use the command:
  3539. @example
  3540. subtitles=sub.srt
  3541. @end example
  3542. which is equivalent to:
  3543. @example
  3544. subtitles=filename=sub.srt
  3545. @end example
  3546. @section split
  3547. Split input video into several identical outputs.
  3548. The filter accepts a single parameter which specifies the number of outputs. If
  3549. unspecified, it defaults to 2.
  3550. For example
  3551. @example
  3552. ffmpeg -i INPUT -filter_complex split=5 OUTPUT
  3553. @end example
  3554. will create 5 copies of the input video.
  3555. For example:
  3556. @example
  3557. [in] split [splitout1][splitout2];
  3558. [splitout1] crop=100:100:0:0 [cropout];
  3559. [splitout2] pad=200:200:100:100 [padout];
  3560. @end example
  3561. will create two separate outputs from the same input, one cropped and
  3562. one padded.
  3563. @section super2xsai
  3564. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  3565. Interpolate) pixel art scaling algorithm.
  3566. Useful for enlarging pixel art images without reducing sharpness.
  3567. @section swapuv
  3568. Swap U & V plane.
  3569. @section thumbnail
  3570. Select the most representative frame in a given sequence of consecutive frames.
  3571. It accepts as argument the frames batch size to analyze (default @var{N}=100);
  3572. in a set of @var{N} frames, the filter will pick one of them, and then handle
  3573. the next batch of @var{N} frames until the end.
  3574. Since the filter keeps track of the whole frames sequence, a bigger @var{N}
  3575. value will result in a higher memory usage, so a high value is not recommended.
  3576. The following example extract one picture each 50 frames:
  3577. @example
  3578. thumbnail=50
  3579. @end example
  3580. Complete example of a thumbnail creation with @command{ffmpeg}:
  3581. @example
  3582. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  3583. @end example
  3584. @section tile
  3585. Tile several successive frames together.
  3586. It accepts a list of options in the form of @var{key}=@var{value} pairs
  3587. separated by ":". A description of the accepted options follows.
  3588. @table @option
  3589. @item layout
  3590. Set the grid size (i.e. the number of lines and columns) in the form
  3591. "@var{w}x@var{h}".
  3592. @item margin
  3593. Set the outer border margin in pixels.
  3594. @item padding
  3595. Set the inner border thickness (i.e. the number of pixels between frames). For
  3596. more advanced padding options (such as having different values for the edges),
  3597. refer to the pad video filter.
  3598. @item nb_frames
  3599. Set the maximum number of frames to render in the given area. It must be less
  3600. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  3601. the area will be used.
  3602. @end table
  3603. Alternatively, the options can be specified as a flat string:
  3604. @var{layout}[:@var{nb_frames}[:@var{margin}[:@var{padding}]]]
  3605. For example, produce 8x8 PNG tiles of all keyframes (@option{-skip_frame
  3606. nokey}) in a movie:
  3607. @example
  3608. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  3609. @end example
  3610. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  3611. duplicating each output frame to accomodate the originally detected frame
  3612. rate.
  3613. Another example to display @code{5} pictures in an area of @code{3x2} frames,
  3614. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  3615. mixed flat and named options:
  3616. @example
  3617. tile=3x2:nb_frames=5:padding=7:margin=2
  3618. @end example
  3619. @section tinterlace
  3620. Perform various types of temporal field interlacing.
  3621. Frames are counted starting from 1, so the first input frame is
  3622. considered odd.
  3623. This filter accepts options in the form of @var{key}=@var{value} pairs
  3624. separated by ":".
  3625. Alternatively, the @var{mode} option can be specified as a value alone,
  3626. optionally followed by a ":" and further ":" separated @var{key}=@var{value}
  3627. pairs.
  3628. A description of the accepted options follows.
  3629. @table @option
  3630. @item mode
  3631. Specify the mode of the interlacing. This option can also be specified
  3632. as a value alone. See below for a list of values for this option.
  3633. Available values are:
  3634. @table @samp
  3635. @item merge, 0
  3636. Move odd frames into the upper field, even into the lower field,
  3637. generating a double height frame at half framerate.
  3638. @item drop_odd, 1
  3639. Only output even frames, odd frames are dropped, generating a frame with
  3640. unchanged height at half framerate.
  3641. @item drop_even, 2
  3642. Only output odd frames, even frames are dropped, generating a frame with
  3643. unchanged height at half framerate.
  3644. @item pad, 3
  3645. Expand each frame to full height, but pad alternate lines with black,
  3646. generating a frame with double height at the same input framerate.
  3647. @item interleave_top, 4
  3648. Interleave the upper field from odd frames with the lower field from
  3649. even frames, generating a frame with unchanged height at half framerate.
  3650. @item interleave_bottom, 5
  3651. Interleave the lower field from odd frames with the upper field from
  3652. even frames, generating a frame with unchanged height at half framerate.
  3653. @item interlacex2, 6
  3654. Double frame rate with unchanged height. Frames are inserted each
  3655. containing the second temporal field from the previous input frame and
  3656. the first temporal field from the next input frame. This mode relies on
  3657. the top_field_first flag. Useful for interlaced video displays with no
  3658. field synchronisation.
  3659. @end table
  3660. Numeric values are deprecated but are accepted for backward
  3661. compatibility reasons.
  3662. Default mode is @code{merge}.
  3663. @item flags
  3664. Specify flags influencing the filter process.
  3665. Available value for @var{flags} is:
  3666. @table @option
  3667. @item low_pass_filter, vlfp
  3668. Enable vertical low-pass filtering in the filter.
  3669. Vertical low-pass filtering is required when creating an interlaced
  3670. destination from a progressive source which contains high-frequency
  3671. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  3672. patterning.
  3673. Vertical low-pass filtering can only be enabled for @option{mode}
  3674. @var{interleave_top} and @var{interleave_bottom}.
  3675. @end table
  3676. @end table
  3677. @section transpose
  3678. Transpose rows with columns in the input video and optionally flip it.
  3679. The filter accepts parameters as a list of @var{key}=@var{value}
  3680. pairs, separated by ':'. If the key of the first options is omitted,
  3681. the arguments are interpreted according to the syntax
  3682. @var{dir}:@var{passthrough}.
  3683. @table @option
  3684. @item dir
  3685. Specify the transposition direction. Can assume the following values:
  3686. @table @samp
  3687. @item 0, 4
  3688. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  3689. @example
  3690. L.R L.l
  3691. . . -> . .
  3692. l.r R.r
  3693. @end example
  3694. @item 1, 5
  3695. Rotate by 90 degrees clockwise, that is:
  3696. @example
  3697. L.R l.L
  3698. . . -> . .
  3699. l.r r.R
  3700. @end example
  3701. @item 2, 6
  3702. Rotate by 90 degrees counterclockwise, that is:
  3703. @example
  3704. L.R R.r
  3705. . . -> . .
  3706. l.r L.l
  3707. @end example
  3708. @item 3, 7
  3709. Rotate by 90 degrees clockwise and vertically flip, that is:
  3710. @example
  3711. L.R r.R
  3712. . . -> . .
  3713. l.r l.L
  3714. @end example
  3715. @end table
  3716. For values between 4-7, the transposition is only done if the input
  3717. video geometry is portrait and not landscape. These values are
  3718. deprecated, the @code{passthrough} option should be used instead.
  3719. @item passthrough
  3720. Do not apply the transposition if the input geometry matches the one
  3721. specified by the specified value. It accepts the following values:
  3722. @table @samp
  3723. @item none
  3724. Always apply transposition.
  3725. @item portrait
  3726. Preserve portrait geometry (when @var{height} >= @var{width}).
  3727. @item landscape
  3728. Preserve landscape geometry (when @var{width} >= @var{height}).
  3729. @end table
  3730. Default value is @code{none}.
  3731. @end table
  3732. For example to rotate by 90 degrees clockwise and preserve portrait
  3733. layout:
  3734. @example
  3735. transpose=dir=1:passthrough=portrait
  3736. @end example
  3737. The command above can also be specified as:
  3738. @example
  3739. transpose=1:portrait
  3740. @end example
  3741. @section unsharp
  3742. Sharpen or blur the input video.
  3743. This filter accepts parameters as a list of @var{key}=@var{value} pairs,
  3744. separated by ":".
  3745. If the key of the first options is omitted, the arguments are
  3746. interpreted according to the syntax:
  3747. @var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount}
  3748. A description of the accepted options follows.
  3749. @table @option
  3750. @item luma_msize_x, lx
  3751. @item chroma_msize_x, cx
  3752. Set the luma/chroma matrix horizontal size. It can be an integer
  3753. between 3 and 63, default value is 5.
  3754. @item luma_msize_y, ly
  3755. @item chroma_msize_y, cy
  3756. Set the luma/chroma matrix vertical size. It can be an integer between
  3757. 3 and 63, default value is 5.
  3758. @item luma_amount, la
  3759. @item chroma_amount, ca
  3760. Set the luma/chroma effect strength. It can be a float number between
  3761. -2.0 and 5.0. Default value is 1.0 for @option{luma_amount}, 0.0 for
  3762. @option{chroma_amount}.
  3763. Negative values will blur the input video, while positive values will
  3764. sharpen.
  3765. @end table
  3766. Some examples follow:
  3767. @itemize
  3768. @item
  3769. Apply strong luma sharpen effect:
  3770. @example
  3771. unsharp=7:7:2.5
  3772. @end example
  3773. @item
  3774. Apply strong blur of both luma and chroma parameters:
  3775. @example
  3776. unsharp=7:7:-2:7:7:-2
  3777. @end example
  3778. @end itemize
  3779. @section vflip
  3780. Flip the input video vertically.
  3781. @example
  3782. ffmpeg -i in.avi -vf "vflip" out.avi
  3783. @end example
  3784. @section yadif
  3785. Deinterlace the input video ("yadif" means "yet another deinterlacing
  3786. filter").
  3787. The filter accepts parameters as a list of @var{key}=@var{value}
  3788. pairs, separated by ":". If the key of the first options is omitted,
  3789. the arguments are interpreted according to syntax
  3790. @var{mode}:@var{parity}:@var{deint}.
  3791. The description of the accepted parameters follows.
  3792. @table @option
  3793. @item mode
  3794. Specify the interlacing mode to adopt. Accept one of the following
  3795. values:
  3796. @table @option
  3797. @item 0, send_frame
  3798. output 1 frame for each frame
  3799. @item 1, send_field
  3800. output 1 frame for each field
  3801. @item 2, send_frame_nospatial
  3802. like @code{send_frame} but skip spatial interlacing check
  3803. @item 3, send_field_nospatial
  3804. like @code{send_field} but skip spatial interlacing check
  3805. @end table
  3806. Default value is @code{send_frame}.
  3807. @item parity
  3808. Specify the picture field parity assumed for the input interlaced
  3809. video. Accept one of the following values:
  3810. @table @option
  3811. @item 0, tff
  3812. assume top field first
  3813. @item 1, bff
  3814. assume bottom field first
  3815. @item -1, auto
  3816. enable automatic detection
  3817. @end table
  3818. Default value is @code{auto}.
  3819. If interlacing is unknown or decoder does not export this information,
  3820. top field first will be assumed.
  3821. @item deint
  3822. Specify which frames to deinterlace. Accept one of the following
  3823. values:
  3824. @table @option
  3825. @item 0, all
  3826. deinterlace all frames
  3827. @item 1, interlaced
  3828. only deinterlace frames marked as interlaced
  3829. @end table
  3830. Default value is @code{all}.
  3831. @end table
  3832. @c man end VIDEO FILTERS
  3833. @chapter Video Sources
  3834. @c man begin VIDEO SOURCES
  3835. Below is a description of the currently available video sources.
  3836. @section buffer
  3837. Buffer video frames, and make them available to the filter chain.
  3838. This source is mainly intended for a programmatic use, in particular
  3839. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  3840. It accepts a list of options in the form of @var{key}=@var{value} pairs
  3841. separated by ":". A description of the accepted options follows.
  3842. @table @option
  3843. @item video_size
  3844. Specify the size (width and height) of the buffered video frames.
  3845. @item pix_fmt
  3846. A string representing the pixel format of the buffered video frames.
  3847. It may be a number corresponding to a pixel format, or a pixel format
  3848. name.
  3849. @item time_base
  3850. Specify the timebase assumed by the timestamps of the buffered frames.
  3851. @item time_base
  3852. Specify the frame rate expected for the video stream.
  3853. @item pixel_aspect
  3854. Specify the sample aspect ratio assumed by the video frames.
  3855. @item sws_param
  3856. Specify the optional parameters to be used for the scale filter which
  3857. is automatically inserted when an input change is detected in the
  3858. input size or format.
  3859. @end table
  3860. For example:
  3861. @example
  3862. buffer=size=320x240:pix_fmt=yuv410p:time_base=1/24:pixel_aspect=1/1
  3863. @end example
  3864. will instruct the source to accept video frames with size 320x240 and
  3865. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  3866. square pixels (1:1 sample aspect ratio).
  3867. Since the pixel format with name "yuv410p" corresponds to the number 6
  3868. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  3869. this example corresponds to:
  3870. @example
  3871. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  3872. @end example
  3873. Alternatively, the options can be specified as a flat string, but this
  3874. syntax is deprecated:
  3875. @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}]
  3876. @section cellauto
  3877. Create a pattern generated by an elementary cellular automaton.
  3878. The initial state of the cellular automaton can be defined through the
  3879. @option{filename}, and @option{pattern} options. If such options are
  3880. not specified an initial state is created randomly.
  3881. At each new frame a new row in the video is filled with the result of
  3882. the cellular automaton next generation. The behavior when the whole
  3883. frame is filled is defined by the @option{scroll} option.
  3884. This source accepts a list of options in the form of
  3885. @var{key}=@var{value} pairs separated by ":". A description of the
  3886. accepted options follows.
  3887. @table @option
  3888. @item filename, f
  3889. Read the initial cellular automaton state, i.e. the starting row, from
  3890. the specified file.
  3891. In the file, each non-whitespace character is considered an alive
  3892. cell, a newline will terminate the row, and further characters in the
  3893. file will be ignored.
  3894. @item pattern, p
  3895. Read the initial cellular automaton state, i.e. the starting row, from
  3896. the specified string.
  3897. Each non-whitespace character in the string is considered an alive
  3898. cell, a newline will terminate the row, and further characters in the
  3899. string will be ignored.
  3900. @item rate, r
  3901. Set the video rate, that is the number of frames generated per second.
  3902. Default is 25.
  3903. @item random_fill_ratio, ratio
  3904. Set the random fill ratio for the initial cellular automaton row. It
  3905. is a floating point number value ranging from 0 to 1, defaults to
  3906. 1/PHI.
  3907. This option is ignored when a file or a pattern is specified.
  3908. @item random_seed, seed
  3909. Set the seed for filling randomly the initial row, must be an integer
  3910. included between 0 and UINT32_MAX. If not specified, or if explicitly
  3911. set to -1, the filter will try to use a good random seed on a best
  3912. effort basis.
  3913. @item rule
  3914. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  3915. Default value is 110.
  3916. @item size, s
  3917. Set the size of the output video.
  3918. If @option{filename} or @option{pattern} is specified, the size is set
  3919. by default to the width of the specified initial state row, and the
  3920. height is set to @var{width} * PHI.
  3921. If @option{size} is set, it must contain the width of the specified
  3922. pattern string, and the specified pattern will be centered in the
  3923. larger row.
  3924. If a filename or a pattern string is not specified, the size value
  3925. defaults to "320x518" (used for a randomly generated initial state).
  3926. @item scroll
  3927. If set to 1, scroll the output upward when all the rows in the output
  3928. have been already filled. If set to 0, the new generated row will be
  3929. written over the top row just after the bottom row is filled.
  3930. Defaults to 1.
  3931. @item start_full, full
  3932. If set to 1, completely fill the output with generated rows before
  3933. outputting the first frame.
  3934. This is the default behavior, for disabling set the value to 0.
  3935. @item stitch
  3936. If set to 1, stitch the left and right row edges together.
  3937. This is the default behavior, for disabling set the value to 0.
  3938. @end table
  3939. @subsection Examples
  3940. @itemize
  3941. @item
  3942. Read the initial state from @file{pattern}, and specify an output of
  3943. size 200x400.
  3944. @example
  3945. cellauto=f=pattern:s=200x400
  3946. @end example
  3947. @item
  3948. Generate a random initial row with a width of 200 cells, with a fill
  3949. ratio of 2/3:
  3950. @example
  3951. cellauto=ratio=2/3:s=200x200
  3952. @end example
  3953. @item
  3954. Create a pattern generated by rule 18 starting by a single alive cell
  3955. centered on an initial row with width 100:
  3956. @example
  3957. cellauto=p=@@:s=100x400:full=0:rule=18
  3958. @end example
  3959. @item
  3960. Specify a more elaborated initial pattern:
  3961. @example
  3962. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  3963. @end example
  3964. @end itemize
  3965. @section mandelbrot
  3966. Generate a Mandelbrot set fractal, and progressively zoom towards the
  3967. point specified with @var{start_x} and @var{start_y}.
  3968. This source accepts a list of options in the form of
  3969. @var{key}=@var{value} pairs separated by ":". A description of the
  3970. accepted options follows.
  3971. @table @option
  3972. @item end_pts
  3973. Set the terminal pts value. Default value is 400.
  3974. @item end_scale
  3975. Set the terminal scale value.
  3976. Must be a floating point value. Default value is 0.3.
  3977. @item inner
  3978. Set the inner coloring mode, that is the algorithm used to draw the
  3979. Mandelbrot fractal internal region.
  3980. It shall assume one of the following values:
  3981. @table @option
  3982. @item black
  3983. Set black mode.
  3984. @item convergence
  3985. Show time until convergence.
  3986. @item mincol
  3987. Set color based on point closest to the origin of the iterations.
  3988. @item period
  3989. Set period mode.
  3990. @end table
  3991. Default value is @var{mincol}.
  3992. @item bailout
  3993. Set the bailout value. Default value is 10.0.
  3994. @item maxiter
  3995. Set the maximum of iterations performed by the rendering
  3996. algorithm. Default value is 7189.
  3997. @item outer
  3998. Set outer coloring mode.
  3999. It shall assume one of following values:
  4000. @table @option
  4001. @item iteration_count
  4002. Set iteration cound mode.
  4003. @item normalized_iteration_count
  4004. set normalized iteration count mode.
  4005. @end table
  4006. Default value is @var{normalized_iteration_count}.
  4007. @item rate, r
  4008. Set frame rate, expressed as number of frames per second. Default
  4009. value is "25".
  4010. @item size, s
  4011. Set frame size. Default value is "640x480".
  4012. @item start_scale
  4013. Set the initial scale value. Default value is 3.0.
  4014. @item start_x
  4015. Set the initial x position. Must be a floating point value between
  4016. -100 and 100. Default value is -0.743643887037158704752191506114774.
  4017. @item start_y
  4018. Set the initial y position. Must be a floating point value between
  4019. -100 and 100. Default value is -0.131825904205311970493132056385139.
  4020. @end table
  4021. @section mptestsrc
  4022. Generate various test patterns, as generated by the MPlayer test filter.
  4023. The size of the generated video is fixed, and is 256x256.
  4024. This source is useful in particular for testing encoding features.
  4025. This source accepts an optional sequence of @var{key}=@var{value} pairs,
  4026. separated by ":". The description of the accepted options follows.
  4027. @table @option
  4028. @item rate, r
  4029. Specify the frame rate of the sourced video, as the number of frames
  4030. generated per second. It has to be a string in the format
  4031. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  4032. number or a valid video frame rate abbreviation. The default value is
  4033. "25".
  4034. @item duration, d
  4035. Set the video duration of the sourced video. The accepted syntax is:
  4036. @example
  4037. [-]HH:MM:SS[.m...]
  4038. [-]S+[.m...]
  4039. @end example
  4040. See also the function @code{av_parse_time()}.
  4041. If not specified, or the expressed duration is negative, the video is
  4042. supposed to be generated forever.
  4043. @item test, t
  4044. Set the number or the name of the test to perform. Supported tests are:
  4045. @table @option
  4046. @item dc_luma
  4047. @item dc_chroma
  4048. @item freq_luma
  4049. @item freq_chroma
  4050. @item amp_luma
  4051. @item amp_chroma
  4052. @item cbp
  4053. @item mv
  4054. @item ring1
  4055. @item ring2
  4056. @item all
  4057. @end table
  4058. Default value is "all", which will cycle through the list of all tests.
  4059. @end table
  4060. For example the following:
  4061. @example
  4062. testsrc=t=dc_luma
  4063. @end example
  4064. will generate a "dc_luma" test pattern.
  4065. @section frei0r_src
  4066. Provide a frei0r source.
  4067. To enable compilation of this filter you need to install the frei0r
  4068. header and configure FFmpeg with @code{--enable-frei0r}.
  4069. The source supports the syntax:
  4070. @example
  4071. @var{size}:@var{rate}:@var{src_name}[@{=|:@}@var{param1}:@var{param2}:...:@var{paramN}]
  4072. @end example
  4073. @var{size} is the size of the video to generate, may be a string of the
  4074. form @var{width}x@var{height} or a frame size abbreviation.
  4075. @var{rate} is the rate of the video to generate, may be a string of
  4076. the form @var{num}/@var{den} or a frame rate abbreviation.
  4077. @var{src_name} is the name to the frei0r source to load. For more
  4078. information regarding frei0r and how to set the parameters read the
  4079. section @ref{frei0r} in the description of the video filters.
  4080. For example, to generate a frei0r partik0l source with size 200x200
  4081. and frame rate 10 which is overlayed on the overlay filter main input:
  4082. @example
  4083. frei0r_src=200x200:10:partik0l=1234 [overlay]; [in][overlay] overlay
  4084. @end example
  4085. @section life
  4086. Generate a life pattern.
  4087. This source is based on a generalization of John Conway's life game.
  4088. The sourced input represents a life grid, each pixel represents a cell
  4089. which can be in one of two possible states, alive or dead. Every cell
  4090. interacts with its eight neighbours, which are the cells that are
  4091. horizontally, vertically, or diagonally adjacent.
  4092. At each interaction the grid evolves according to the adopted rule,
  4093. which specifies the number of neighbor alive cells which will make a
  4094. cell stay alive or born. The @option{rule} option allows to specify
  4095. the rule to adopt.
  4096. This source accepts a list of options in the form of
  4097. @var{key}=@var{value} pairs separated by ":". A description of the
  4098. accepted options follows.
  4099. @table @option
  4100. @item filename, f
  4101. Set the file from which to read the initial grid state. In the file,
  4102. each non-whitespace character is considered an alive cell, and newline
  4103. is used to delimit the end of each row.
  4104. If this option is not specified, the initial grid is generated
  4105. randomly.
  4106. @item rate, r
  4107. Set the video rate, that is the number of frames generated per second.
  4108. Default is 25.
  4109. @item random_fill_ratio, ratio
  4110. Set the random fill ratio for the initial random grid. It is a
  4111. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  4112. It is ignored when a file is specified.
  4113. @item random_seed, seed
  4114. Set the seed for filling the initial random grid, must be an integer
  4115. included between 0 and UINT32_MAX. If not specified, or if explicitly
  4116. set to -1, the filter will try to use a good random seed on a best
  4117. effort basis.
  4118. @item rule
  4119. Set the life rule.
  4120. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  4121. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  4122. @var{NS} specifies the number of alive neighbor cells which make a
  4123. live cell stay alive, and @var{NB} the number of alive neighbor cells
  4124. which make a dead cell to become alive (i.e. to "born").
  4125. "s" and "b" can be used in place of "S" and "B", respectively.
  4126. Alternatively a rule can be specified by an 18-bits integer. The 9
  4127. high order bits are used to encode the next cell state if it is alive
  4128. for each number of neighbor alive cells, the low order bits specify
  4129. the rule for "borning" new cells. Higher order bits encode for an
  4130. higher number of neighbor cells.
  4131. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  4132. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  4133. Default value is "S23/B3", which is the original Conway's game of life
  4134. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  4135. cells, and will born a new cell if there are three alive cells around
  4136. a dead cell.
  4137. @item size, s
  4138. Set the size of the output video.
  4139. If @option{filename} is specified, the size is set by default to the
  4140. same size of the input file. If @option{size} is set, it must contain
  4141. the size specified in the input file, and the initial grid defined in
  4142. that file is centered in the larger resulting area.
  4143. If a filename is not specified, the size value defaults to "320x240"
  4144. (used for a randomly generated initial grid).
  4145. @item stitch
  4146. If set to 1, stitch the left and right grid edges together, and the
  4147. top and bottom edges also. Defaults to 1.
  4148. @item mold
  4149. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  4150. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  4151. value from 0 to 255.
  4152. @item life_color
  4153. Set the color of living (or new born) cells.
  4154. @item death_color
  4155. Set the color of dead cells. If @option{mold} is set, this is the first color
  4156. used to represent a dead cell.
  4157. @item mold_color
  4158. Set mold color, for definitely dead and moldy cells.
  4159. @end table
  4160. @subsection Examples
  4161. @itemize
  4162. @item
  4163. Read a grid from @file{pattern}, and center it on a grid of size
  4164. 300x300 pixels:
  4165. @example
  4166. life=f=pattern:s=300x300
  4167. @end example
  4168. @item
  4169. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  4170. @example
  4171. life=ratio=2/3:s=200x200
  4172. @end example
  4173. @item
  4174. Specify a custom rule for evolving a randomly generated grid:
  4175. @example
  4176. life=rule=S14/B34
  4177. @end example
  4178. @item
  4179. Full example with slow death effect (mold) using @command{ffplay}:
  4180. @example
  4181. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  4182. @end example
  4183. @end itemize
  4184. @section color, nullsrc, rgbtestsrc, smptebars, testsrc
  4185. The @code{color} source provides an uniformly colored input.
  4186. The @code{nullsrc} source returns unprocessed video frames. It is
  4187. mainly useful to be employed in analysis / debugging tools, or as the
  4188. source for filters which ignore the input data.
  4189. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  4190. detecting RGB vs BGR issues. You should see a red, green and blue
  4191. stripe from top to bottom.
  4192. The @code{smptebars} source generates a color bars pattern, based on
  4193. the SMPTE Engineering Guideline EG 1-1990.
  4194. The @code{testsrc} source generates a test video pattern, showing a
  4195. color pattern, a scrolling gradient and a timestamp. This is mainly
  4196. intended for testing purposes.
  4197. These sources accept an optional sequence of @var{key}=@var{value} pairs,
  4198. separated by ":". The description of the accepted options follows.
  4199. @table @option
  4200. @item color, c
  4201. Specify the color of the source, only used in the @code{color}
  4202. source. It can be the name of a color (case insensitive match) or a
  4203. 0xRRGGBB[AA] sequence, possibly followed by an alpha specifier. The
  4204. default value is "black".
  4205. @item size, s
  4206. Specify the size of the sourced video, it may be a string of the form
  4207. @var{width}x@var{height}, or the name of a size abbreviation. The
  4208. default value is "320x240".
  4209. @item rate, r
  4210. Specify the frame rate of the sourced video, as the number of frames
  4211. generated per second. It has to be a string in the format
  4212. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  4213. number or a valid video frame rate abbreviation. The default value is
  4214. "25".
  4215. @item sar
  4216. Set the sample aspect ratio of the sourced video.
  4217. @item duration, d
  4218. Set the video duration of the sourced video. The accepted syntax is:
  4219. @example
  4220. [-]HH[:MM[:SS[.m...]]]
  4221. [-]S+[.m...]
  4222. @end example
  4223. See also the function @code{av_parse_time()}.
  4224. If not specified, or the expressed duration is negative, the video is
  4225. supposed to be generated forever.
  4226. @item decimals, n
  4227. Set the number of decimals to show in the timestamp, only used in the
  4228. @code{testsrc} source.
  4229. The displayed timestamp value will correspond to the original
  4230. timestamp value multiplied by the power of 10 of the specified
  4231. value. Default value is 0.
  4232. @end table
  4233. For example the following:
  4234. @example
  4235. testsrc=duration=5.3:size=qcif:rate=10
  4236. @end example
  4237. will generate a video with a duration of 5.3 seconds, with size
  4238. 176x144 and a frame rate of 10 frames per second.
  4239. The following graph description will generate a red source
  4240. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  4241. frames per second.
  4242. @example
  4243. color=c=red@@0.2:s=qcif:r=10
  4244. @end example
  4245. If the input content is to be ignored, @code{nullsrc} can be used. The
  4246. following command generates noise in the luminance plane by employing
  4247. the @code{geq} filter:
  4248. @example
  4249. nullsrc=s=256x256, geq=random(1)*255:128:128
  4250. @end example
  4251. @c man end VIDEO SOURCES
  4252. @chapter Video Sinks
  4253. @c man begin VIDEO SINKS
  4254. Below is a description of the currently available video sinks.
  4255. @section buffersink
  4256. Buffer video frames, and make them available to the end of the filter
  4257. graph.
  4258. This sink is mainly intended for a programmatic use, in particular
  4259. through the interface defined in @file{libavfilter/buffersink.h}.
  4260. It does not require a string parameter in input, but you need to
  4261. specify a pointer to a list of supported pixel formats terminated by
  4262. -1 in the opaque parameter provided to @code{avfilter_init_filter}
  4263. when initializing this sink.
  4264. @section nullsink
  4265. Null video sink, do absolutely nothing with the input video. It is
  4266. mainly useful as a template and to be employed in analysis / debugging
  4267. tools.
  4268. @c man end VIDEO SINKS
  4269. @chapter Multimedia Filters
  4270. @c man begin MULTIMEDIA FILTERS
  4271. Below is a description of the currently available multimedia filters.
  4272. @section aselect, select
  4273. Select frames to pass in output.
  4274. These filters accept a single option @option{expr} or @option{e}
  4275. specifying the select expression, which can be specified either by
  4276. specyfing @code{expr=VALUE} or specifying the expression
  4277. alone.
  4278. The select expression is evaluated for each input frame. If the
  4279. evaluation result is a non-zero value, the frame is selected and
  4280. passed to the output, otherwise it is discarded.
  4281. The expression can contain the following constants:
  4282. @table @option
  4283. @item n
  4284. the sequential number of the filtered frame, starting from 0
  4285. @item selected_n
  4286. the sequential number of the selected frame, starting from 0
  4287. @item prev_selected_n
  4288. the sequential number of the last selected frame, NAN if undefined
  4289. @item TB
  4290. timebase of the input timestamps
  4291. @item pts
  4292. the PTS (Presentation TimeStamp) of the filtered video frame,
  4293. expressed in @var{TB} units, NAN if undefined
  4294. @item t
  4295. the PTS (Presentation TimeStamp) of the filtered video frame,
  4296. expressed in seconds, NAN if undefined
  4297. @item prev_pts
  4298. the PTS of the previously filtered video frame, NAN if undefined
  4299. @item prev_selected_pts
  4300. the PTS of the last previously filtered video frame, NAN if undefined
  4301. @item prev_selected_t
  4302. the PTS of the last previously selected video frame, NAN if undefined
  4303. @item start_pts
  4304. the PTS of the first video frame in the video, NAN if undefined
  4305. @item start_t
  4306. the time of the first video frame in the video, NAN if undefined
  4307. @item pict_type @emph{(video only)}
  4308. the type of the filtered frame, can assume one of the following
  4309. values:
  4310. @table @option
  4311. @item I
  4312. @item P
  4313. @item B
  4314. @item S
  4315. @item SI
  4316. @item SP
  4317. @item BI
  4318. @end table
  4319. @item interlace_type @emph{(video only)}
  4320. the frame interlace type, can assume one of the following values:
  4321. @table @option
  4322. @item PROGRESSIVE
  4323. the frame is progressive (not interlaced)
  4324. @item TOPFIRST
  4325. the frame is top-field-first
  4326. @item BOTTOMFIRST
  4327. the frame is bottom-field-first
  4328. @end table
  4329. @item consumed_sample_n @emph{(audio only)}
  4330. the number of selected samples before the current frame
  4331. @item samples_n @emph{(audio only)}
  4332. the number of samples in the current frame
  4333. @item sample_rate @emph{(audio only)}
  4334. the input sample rate
  4335. @item key
  4336. 1 if the filtered frame is a key-frame, 0 otherwise
  4337. @item pos
  4338. the position in the file of the filtered frame, -1 if the information
  4339. is not available (e.g. for synthetic video)
  4340. @item scene @emph{(video only)}
  4341. value between 0 and 1 to indicate a new scene; a low value reflects a low
  4342. probability for the current frame to introduce a new scene, while a higher
  4343. value means the current frame is more likely to be one (see the example below)
  4344. @end table
  4345. The default value of the select expression is "1".
  4346. @subsection Examples
  4347. @itemize
  4348. @item
  4349. Select all frames in input:
  4350. @example
  4351. select
  4352. @end example
  4353. The example above is the same as:
  4354. @example
  4355. select=1
  4356. @end example
  4357. @item
  4358. Skip all frames:
  4359. @example
  4360. select=0
  4361. @end example
  4362. @item
  4363. Select only I-frames:
  4364. @example
  4365. select='eq(pict_type\,I)'
  4366. @end example
  4367. @item
  4368. Select one frame every 100:
  4369. @example
  4370. select='not(mod(n\,100))'
  4371. @end example
  4372. @item
  4373. Select only frames contained in the 10-20 time interval:
  4374. @example
  4375. select='gte(t\,10)*lte(t\,20)'
  4376. @end example
  4377. @item
  4378. Select only I frames contained in the 10-20 time interval:
  4379. @example
  4380. select='gte(t\,10)*lte(t\,20)*eq(pict_type\,I)'
  4381. @end example
  4382. @item
  4383. Select frames with a minimum distance of 10 seconds:
  4384. @example
  4385. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  4386. @end example
  4387. @item
  4388. Use aselect to select only audio frames with samples number > 100:
  4389. @example
  4390. aselect='gt(samples_n\,100)'
  4391. @end example
  4392. @item
  4393. Create a mosaic of the first scenes:
  4394. @example
  4395. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  4396. @end example
  4397. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  4398. choice.
  4399. @end itemize
  4400. @section asendcmd, sendcmd
  4401. Send commands to filters in the filtergraph.
  4402. These filters read commands to be sent to other filters in the
  4403. filtergraph.
  4404. @code{asendcmd} must be inserted between two audio filters,
  4405. @code{sendcmd} must be inserted between two video filters, but apart
  4406. from that they act the same way.
  4407. The specification of commands can be provided in the filter arguments
  4408. with the @var{commands} option, or in a file specified by the
  4409. @var{filename} option.
  4410. These filters accept the following options:
  4411. @table @option
  4412. @item commands, c
  4413. Set the commands to be read and sent to the other filters.
  4414. @item filename, f
  4415. Set the filename of the commands to be read and sent to the other
  4416. filters.
  4417. @end table
  4418. @subsection Commands syntax
  4419. A commands description consists of a sequence of interval
  4420. specifications, comprising a list of commands to be executed when a
  4421. particular event related to that interval occurs. The occurring event
  4422. is typically the current frame time entering or leaving a given time
  4423. interval.
  4424. An interval is specified by the following syntax:
  4425. @example
  4426. @var{START}[-@var{END}] @var{COMMANDS};
  4427. @end example
  4428. The time interval is specified by the @var{START} and @var{END} times.
  4429. @var{END} is optional and defaults to the maximum time.
  4430. The current frame time is considered within the specified interval if
  4431. it is included in the interval [@var{START}, @var{END}), that is when
  4432. the time is greater or equal to @var{START} and is lesser than
  4433. @var{END}.
  4434. @var{COMMANDS} consists of a sequence of one or more command
  4435. specifications, separated by ",", relating to that interval. The
  4436. syntax of a command specification is given by:
  4437. @example
  4438. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  4439. @end example
  4440. @var{FLAGS} is optional and specifies the type of events relating to
  4441. the time interval which enable sending the specified command, and must
  4442. be a non-null sequence of identifier flags separated by "+" or "|" and
  4443. enclosed between "[" and "]".
  4444. The following flags are recognized:
  4445. @table @option
  4446. @item enter
  4447. The command is sent when the current frame timestamp enters the
  4448. specified interval. In other words, the command is sent when the
  4449. previous frame timestamp was not in the given interval, and the
  4450. current is.
  4451. @item leave
  4452. The command is sent when the current frame timestamp leaves the
  4453. specified interval. In other words, the command is sent when the
  4454. previous frame timestamp was in the given interval, and the
  4455. current is not.
  4456. @end table
  4457. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  4458. assumed.
  4459. @var{TARGET} specifies the target of the command, usually the name of
  4460. the filter class or a specific filter instance name.
  4461. @var{COMMAND} specifies the name of the command for the target filter.
  4462. @var{ARG} is optional and specifies the optional list of argument for
  4463. the given @var{COMMAND}.
  4464. Between one interval specification and another, whitespaces, or
  4465. sequences of characters starting with @code{#} until the end of line,
  4466. are ignored and can be used to annotate comments.
  4467. A simplified BNF description of the commands specification syntax
  4468. follows:
  4469. @example
  4470. @var{COMMAND_FLAG} ::= "enter" | "leave"
  4471. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  4472. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  4473. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  4474. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  4475. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  4476. @end example
  4477. @subsection Examples
  4478. @itemize
  4479. @item
  4480. Specify audio tempo change at second 4:
  4481. @example
  4482. asendcmd=c='4.0 atempo tempo 1.5',atempo
  4483. @end example
  4484. @item
  4485. Specify a list of drawtext and hue commands in a file.
  4486. @example
  4487. # show text in the interval 5-10
  4488. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  4489. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  4490. # desaturate the image in the interval 15-20
  4491. 15.0-20.0 [enter] hue reinit s=0,
  4492. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  4493. [leave] hue reinit s=1,
  4494. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  4495. # apply an exponential saturation fade-out effect, starting from time 25
  4496. 25 [enter] hue s=exp(t-25)
  4497. @end example
  4498. A filtergraph allowing to read and process the above command list
  4499. stored in a file @file{test.cmd}, can be specified with:
  4500. @example
  4501. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  4502. @end example
  4503. @end itemize
  4504. @anchor{setpts}
  4505. @section asetpts, setpts
  4506. Change the PTS (presentation timestamp) of the input frames.
  4507. @code{asetpts} works on audio frames, @code{setpts} on video frames.
  4508. Accept in input an expression evaluated through the eval API, which
  4509. can contain the following constants:
  4510. @table @option
  4511. @item FRAME_RATE
  4512. frame rate, only defined for constant frame-rate video
  4513. @item PTS
  4514. the presentation timestamp in input
  4515. @item N
  4516. the count of the input frame, starting from 0.
  4517. @item NB_CONSUMED_SAMPLES
  4518. the number of consumed samples, not including the current frame (only
  4519. audio)
  4520. @item NB_SAMPLES
  4521. the number of samples in the current frame (only audio)
  4522. @item SAMPLE_RATE
  4523. audio sample rate
  4524. @item STARTPTS
  4525. the PTS of the first frame
  4526. @item STARTT
  4527. the time in seconds of the first frame
  4528. @item INTERLACED
  4529. tell if the current frame is interlaced
  4530. @item T
  4531. the time in seconds of the current frame
  4532. @item TB
  4533. the time base
  4534. @item POS
  4535. original position in the file of the frame, or undefined if undefined
  4536. for the current frame
  4537. @item PREV_INPTS
  4538. previous input PTS
  4539. @item PREV_INT
  4540. previous input time in seconds
  4541. @item PREV_OUTPTS
  4542. previous output PTS
  4543. @item PREV_OUTT
  4544. previous output time in seconds
  4545. @item RTCTIME
  4546. wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  4547. instead.
  4548. @item RTCSTART
  4549. wallclock (RTC) time at the start of the movie in microseconds
  4550. @end table
  4551. @subsection Examples
  4552. @itemize
  4553. @item
  4554. Start counting PTS from zero
  4555. @example
  4556. setpts=PTS-STARTPTS
  4557. @end example
  4558. @item
  4559. Apply fast motion effect:
  4560. @example
  4561. setpts=0.5*PTS
  4562. @end example
  4563. @item
  4564. Apply slow motion effect:
  4565. @example
  4566. setpts=2.0*PTS
  4567. @end example
  4568. @item
  4569. Set fixed rate of 25 frames per second:
  4570. @example
  4571. setpts=N/(25*TB)
  4572. @end example
  4573. @item
  4574. Set fixed rate 25 fps with some jitter:
  4575. @example
  4576. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  4577. @end example
  4578. @item
  4579. Apply an offset of 10 seconds to the input PTS:
  4580. @example
  4581. setpts=PTS+10/TB
  4582. @end example
  4583. @item
  4584. Generate timestamps from a "live source" and rebase onto the current timebase:
  4585. @example
  4586. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  4587. @end example
  4588. @end itemize
  4589. @section ebur128
  4590. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  4591. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  4592. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  4593. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  4594. The filter also has a video output (see the @var{video} option) with a real
  4595. time graph to observe the loudness evolution. The graphic contains the logged
  4596. message mentioned above, so it is not printed anymore when this option is set,
  4597. unless the verbose logging is set. The main graphing area contains the
  4598. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  4599. the momentary loudness (400 milliseconds).
  4600. More information about the Loudness Recommendation EBU R128 on
  4601. @url{http://tech.ebu.ch/loudness}.
  4602. The filter accepts the following named parameters:
  4603. @table @option
  4604. @item video
  4605. Activate the video output. The audio stream is passed unchanged whether this
  4606. option is set or no. The video stream will be the first output stream if
  4607. activated. Default is @code{0}.
  4608. @item size
  4609. Set the video size. This option is for video only. Default and minimum
  4610. resolution is @code{640x480}.
  4611. @item meter
  4612. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  4613. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  4614. other integer value between this range is allowed.
  4615. @end table
  4616. Example of real-time graph using @command{ffplay}, with a EBU scale meter +18:
  4617. @example
  4618. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  4619. @end example
  4620. Run an analysis with @command{ffmpeg}:
  4621. @example
  4622. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  4623. @end example
  4624. @section settb, asettb
  4625. Set the timebase to use for the output frames timestamps.
  4626. It is mainly useful for testing timebase configuration.
  4627. It accepts in input an arithmetic expression representing a rational.
  4628. The expression can contain the constants "AVTB" (the
  4629. default timebase), "intb" (the input timebase) and "sr" (the sample rate,
  4630. audio only).
  4631. The default value for the input is "intb".
  4632. @subsection Examples
  4633. @itemize
  4634. @item
  4635. Set the timebase to 1/25:
  4636. @example
  4637. settb=1/25
  4638. @end example
  4639. @item
  4640. Set the timebase to 1/10:
  4641. @example
  4642. settb=0.1
  4643. @end example
  4644. @item
  4645. Set the timebase to 1001/1000:
  4646. @example
  4647. settb=1+0.001
  4648. @end example
  4649. @item
  4650. Set the timebase to 2*intb:
  4651. @example
  4652. settb=2*intb
  4653. @end example
  4654. @item
  4655. Set the default timebase value:
  4656. @example
  4657. settb=AVTB
  4658. @end example
  4659. @end itemize
  4660. @section concat
  4661. Concatenate audio and video streams, joining them together one after the
  4662. other.
  4663. The filter works on segments of synchronized video and audio streams. All
  4664. segments must have the same number of streams of each type, and that will
  4665. also be the number of streams at output.
  4666. The filter accepts the following named parameters:
  4667. @table @option
  4668. @item n
  4669. Set the number of segments. Default is 2.
  4670. @item v
  4671. Set the number of output video streams, that is also the number of video
  4672. streams in each segment. Default is 1.
  4673. @item a
  4674. Set the number of output audio streams, that is also the number of video
  4675. streams in each segment. Default is 0.
  4676. @item unsafe
  4677. Activate unsafe mode: do not fail if segments have a different format.
  4678. @end table
  4679. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  4680. @var{a} audio outputs.
  4681. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  4682. segment, in the same order as the outputs, then the inputs for the second
  4683. segment, etc.
  4684. Related streams do not always have exactly the same duration, for various
  4685. reasons including codec frame size or sloppy authoring. For that reason,
  4686. related synchronized streams (e.g. a video and its audio track) should be
  4687. concatenated at once. The concat filter will use the duration of the longest
  4688. stream in each segment (except the last one), and if necessary pad shorter
  4689. audio streams with silence.
  4690. For this filter to work correctly, all segments must start at timestamp 0.
  4691. All corresponding streams must have the same parameters in all segments; the
  4692. filtering system will automatically select a common pixel format for video
  4693. streams, and a common sample format, sample rate and channel layout for
  4694. audio streams, but other settings, such as resolution, must be converted
  4695. explicitly by the user.
  4696. Different frame rates are acceptable but will result in variable frame rate
  4697. at output; be sure to configure the output file to handle it.
  4698. Examples:
  4699. @itemize
  4700. @item
  4701. Concatenate an opening, an episode and an ending, all in bilingual version
  4702. (video in stream 0, audio in streams 1 and 2):
  4703. @example
  4704. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  4705. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  4706. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  4707. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  4708. @end example
  4709. @item
  4710. Concatenate two parts, handling audio and video separately, using the
  4711. (a)movie sources, and adjusting the resolution:
  4712. @example
  4713. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  4714. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  4715. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  4716. @end example
  4717. Note that a desync will happen at the stitch if the audio and video streams
  4718. do not have exactly the same duration in the first file.
  4719. @end itemize
  4720. @section showspectrum
  4721. Convert input audio to a video output, representing the audio frequency
  4722. spectrum.
  4723. The filter accepts the following named parameters:
  4724. @table @option
  4725. @item size, s
  4726. Specify the video size for the output. Default value is @code{640x512}.
  4727. @item slide
  4728. Specify if the spectrum should slide along the window. Default value is
  4729. @code{0}.
  4730. @item mode
  4731. Specify display mode.
  4732. It accepts the following values:
  4733. @table @samp
  4734. @item combined
  4735. all channels are displayed in the same row
  4736. @item separate
  4737. all channels are displayed in separate rows
  4738. @end table
  4739. Default value is @samp{combined}.
  4740. @item color
  4741. Specify display color mode.
  4742. It accepts the following values:
  4743. @table @samp
  4744. @item channel
  4745. each channel is displayed in a separate color
  4746. @item intensity
  4747. each channel is is displayed using the same color scheme
  4748. @end table
  4749. Default value is @samp{channel}.
  4750. @item scale
  4751. Specify scale used for calculating intensity color values.
  4752. It accepts the following values:
  4753. @table @samp
  4754. @item lin
  4755. linear
  4756. @item sqrt
  4757. square root, default
  4758. @item cbrt
  4759. cubic root
  4760. @item log
  4761. logarithmic
  4762. @end table
  4763. Default value is @samp{sqrt}.
  4764. @item saturation
  4765. Set saturation modifier for displayed colors. Negative values provide
  4766. alternative color scheme. @code{0} is no saturation at all.
  4767. Saturation must be in [-10.0, 10.0] range.
  4768. Default value is @code{1}.
  4769. @end table
  4770. The usage is very similar to the showwaves filter; see the examples in that
  4771. section.
  4772. @section showwaves
  4773. Convert input audio to a video output, representing the samples waves.
  4774. The filter accepts the following named parameters:
  4775. @table @option
  4776. @item mode
  4777. Set display mode.
  4778. Available values are:
  4779. @table @samp
  4780. @item point
  4781. Draw a point for each sample.
  4782. @item line
  4783. Draw a vertical line for each sample.
  4784. @end table
  4785. Default value is @code{point}.
  4786. @item n
  4787. Set the number of samples which are printed on the same column. A
  4788. larger value will decrease the frame rate. Must be a positive
  4789. integer. This option can be set only if the value for @var{rate}
  4790. is not explicitly specified.
  4791. @item rate, r
  4792. Set the (approximate) output frame rate. This is done by setting the
  4793. option @var{n}. Default value is "25".
  4794. @item size, s
  4795. Specify the video size for the output. Default value is "600x240".
  4796. @end table
  4797. Some examples follow.
  4798. @itemize
  4799. @item
  4800. Output the input file audio and the corresponding video representation
  4801. at the same time:
  4802. @example
  4803. amovie=a.mp3,asplit[out0],showwaves[out1]
  4804. @end example
  4805. @item
  4806. Create a synthetic signal and show it with showwaves, forcing a
  4807. framerate of 30 frames per second:
  4808. @example
  4809. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  4810. @end example
  4811. @end itemize
  4812. @c man end MULTIMEDIA FILTERS
  4813. @chapter Multimedia Sources
  4814. @c man begin MULTIMEDIA SOURCES
  4815. Below is a description of the currently available multimedia sources.
  4816. @section amovie
  4817. This is the same as @ref{movie} source, except it selects an audio
  4818. stream by default.
  4819. @anchor{movie}
  4820. @section movie
  4821. Read audio and/or video stream(s) from a movie container.
  4822. It accepts the syntax: @var{movie_name}[:@var{options}] where
  4823. @var{movie_name} is the name of the resource to read (not necessarily
  4824. a file but also a device or a stream accessed through some protocol),
  4825. and @var{options} is an optional sequence of @var{key}=@var{value}
  4826. pairs, separated by ":".
  4827. The description of the accepted options follows.
  4828. @table @option
  4829. @item format_name, f
  4830. Specifies the format assumed for the movie to read, and can be either
  4831. the name of a container or an input device. If not specified the
  4832. format is guessed from @var{movie_name} or by probing.
  4833. @item seek_point, sp
  4834. Specifies the seek point in seconds, the frames will be output
  4835. starting from this seek point, the parameter is evaluated with
  4836. @code{av_strtod} so the numerical value may be suffixed by an IS
  4837. postfix. Default value is "0".
  4838. @item streams, s
  4839. Specifies the streams to read. Several streams can be specified,
  4840. separated by "+". The source will then have as many outputs, in the
  4841. same order. The syntax is explained in the ``Stream specifiers''
  4842. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  4843. respectively the default (best suited) video and audio stream. Default
  4844. is "dv", or "da" if the filter is called as "amovie".
  4845. @item stream_index, si
  4846. Specifies the index of the video stream to read. If the value is -1,
  4847. the best suited video stream will be automatically selected. Default
  4848. value is "-1". Deprecated. If the filter is called "amovie", it will select
  4849. audio instead of video.
  4850. @item loop
  4851. Specifies how many times to read the stream in sequence.
  4852. If the value is less than 1, the stream will be read again and again.
  4853. Default value is "1".
  4854. Note that when the movie is looped the source timestamps are not
  4855. changed, so it will generate non monotonically increasing timestamps.
  4856. @end table
  4857. This filter allows to overlay a second video on top of main input of
  4858. a filtergraph as shown in this graph:
  4859. @example
  4860. input -----------> deltapts0 --> overlay --> output
  4861. ^
  4862. |
  4863. movie --> scale--> deltapts1 -------+
  4864. @end example
  4865. Some examples follow.
  4866. @itemize
  4867. @item
  4868. Skip 3.2 seconds from the start of the avi file in.avi, and overlay it
  4869. on top of the input labelled as "in":
  4870. @example
  4871. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  4872. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  4873. @end example
  4874. @item
  4875. Read from a video4linux2 device, and overlay it on top of the input
  4876. labelled as "in":
  4877. @example
  4878. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  4879. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  4880. @end example
  4881. @item
  4882. Read the first video stream and the audio stream with id 0x81 from
  4883. dvd.vob; the video is connected to the pad named "video" and the audio is
  4884. connected to the pad named "audio":
  4885. @example
  4886. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  4887. @end example
  4888. @end itemize
  4889. @c man end MULTIMEDIA SOURCES