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.

7273 lines
198KB

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