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.

7267 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. A description of the accepted options follows.
  1422. @table @option
  1423. @item amount
  1424. Set the percentage of pixels that have to be below the
  1425. threshold to enable black detection. Default value is 98.
  1426. @item threshold
  1427. Set the threshold below which a pixel value is considered
  1428. black. Default value is 32.
  1429. @end table
  1430. @section blend
  1431. Blend two video frames into each other.
  1432. It takes two input streams and outputs one stream, the first input is the
  1433. "top" layer and second input is "bottom" layer.
  1434. Output terminates when shortest input terminates.
  1435. This filter accepts a list of options in the form of @var{key}=@var{value}
  1436. pairs separated by ":". A description of the accepted options follows.
  1437. @table @option
  1438. @item c0_mode
  1439. @item c1_mode
  1440. @item c2_mode
  1441. @item c3_mode
  1442. @item all_mode
  1443. Set blend mode for specific pixel component or all pixel components in case
  1444. of @var{all_mode}. Default value is @code{normal}.
  1445. Available values for component modes are:
  1446. @table @samp
  1447. @item addition
  1448. @item and
  1449. @item average
  1450. @item burn
  1451. @item darken
  1452. @item difference
  1453. @item divide
  1454. @item dodge
  1455. @item exclusion
  1456. @item hardlight
  1457. @item lighten
  1458. @item multiply
  1459. @item negation
  1460. @item normal
  1461. @item or
  1462. @item overlay
  1463. @item phoenix
  1464. @item pinlight
  1465. @item reflect
  1466. @item screen
  1467. @item softlight
  1468. @item subtract
  1469. @item vividlight
  1470. @item xor
  1471. @end table
  1472. @item c0_opacity
  1473. @item c1_opacity
  1474. @item c2_opacity
  1475. @item c3_opacity
  1476. @item all_opacity
  1477. Set blend opacity for specific pixel component or all pixel components in case
  1478. of @var{all_opacity}. Only used in combination with pixel component blend modes.
  1479. @item c0_expr
  1480. @item c1_expr
  1481. @item c2_expr
  1482. @item c3_expr
  1483. @item all_expr
  1484. Set blend expression for specific pixel component or all pixel components in case
  1485. of @var{all_expr}. Note that related mode options will be ignored if those are set.
  1486. The expressions can use the following variables:
  1487. @table @option
  1488. @item N
  1489. The sequential number of the filtered frame, starting from @code{0}.
  1490. @item X
  1491. @item Y
  1492. the coordinates of the current sample
  1493. @item W
  1494. @item H
  1495. the width and height of currently filtered plane
  1496. @item SW
  1497. @item SH
  1498. Width and height scale depending on the currently filtered plane. It is the
  1499. ratio between the corresponding luma plane number of pixels and the current
  1500. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  1501. @code{0.5,0.5} for chroma planes.
  1502. @item T
  1503. Time of the current frame, expressed in seconds.
  1504. @item TOP, A
  1505. Value of pixel component at current location for first video frame (top layer).
  1506. @item BOTTOM, B
  1507. Value of pixel component at current location for second video frame (bottom layer).
  1508. @end table
  1509. @end table
  1510. @subsection Examples
  1511. @itemize
  1512. @item
  1513. Apply transition from bottom layer to top layer in first 10 seconds:
  1514. @example
  1515. blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
  1516. @end example
  1517. @item
  1518. Apply 1x1 checkerboard effect:
  1519. @example
  1520. blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
  1521. @end example
  1522. @end itemize
  1523. @section boxblur
  1524. Apply boxblur algorithm to the input video.
  1525. The filter accepts parameters as a list of @var{key}=@var{value}
  1526. pairs, separated by ":". If the key of the first options is omitted,
  1527. the arguments are interpreted according to the syntax
  1528. @option{luma_radius}:@option{luma_power}:@option{chroma_radius}:@option{chroma_power}:@option{alpha_radius}:@option{alpha_power}.
  1529. A description of the accepted options follows.
  1530. @table @option
  1531. @item luma_radius, lr
  1532. @item chroma_radius, cr
  1533. @item alpha_radius, ar
  1534. Set an expression for the box radius in pixels used for blurring the
  1535. corresponding input plane.
  1536. The radius value must be a non-negative number, and must not be
  1537. greater than the value of the expression @code{min(w,h)/2} for the
  1538. luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
  1539. planes.
  1540. Default value for @option{luma_radius} is "2". If not specified,
  1541. @option{chroma_radius} and @option{alpha_radius} default to the
  1542. corresponding value set for @option{luma_radius}.
  1543. The expressions can contain the following constants:
  1544. @table @option
  1545. @item w, h
  1546. the input width and height in pixels
  1547. @item cw, ch
  1548. the input chroma image width and height in pixels
  1549. @item hsub, vsub
  1550. horizontal and vertical chroma subsample values. For example for the
  1551. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1552. @end table
  1553. @item luma_power, lp
  1554. @item chroma_power, cp
  1555. @item alpha_power, ap
  1556. Specify how many times the boxblur filter is applied to the
  1557. corresponding plane.
  1558. Default value for @option{luma_power} is 2. If not specified,
  1559. @option{chroma_power} and @option{alpha_power} default to the
  1560. corresponding value set for @option{luma_power}.
  1561. A value of 0 will disable the effect.
  1562. @end table
  1563. @subsection Examples
  1564. @itemize
  1565. @item
  1566. Apply a boxblur filter with luma, chroma, and alpha radius
  1567. set to 2:
  1568. @example
  1569. boxblur=2:1
  1570. @end example
  1571. @item
  1572. Set luma radius to 2, alpha and chroma radius to 0:
  1573. @example
  1574. boxblur=2:1:cr=0:ar=0
  1575. @end example
  1576. @item
  1577. Set luma and chroma radius to a fraction of the video dimension:
  1578. @example
  1579. boxblur=min(h\,w)/10:1:min(cw\,ch)/10:1
  1580. @end example
  1581. @end itemize
  1582. @section colormatrix
  1583. Convert color matrix.
  1584. The filter accepts parameters as a list of @var{key}=@var{value}
  1585. pairs, separated by ":". If the key of the first options is omitted,
  1586. the arguments are interpreted according to the syntax
  1587. @var{src}:@var{dst}.
  1588. A description of the accepted options follows:
  1589. @table @option
  1590. @item src
  1591. @item dst
  1592. Specify the source and destination color matrix. Both values must be
  1593. specified.
  1594. The accepted values are:
  1595. @table @samp
  1596. @item bt709
  1597. BT.709
  1598. @item bt601
  1599. BT.601
  1600. @item smpte240m
  1601. SMPTE-240M
  1602. @item fcc
  1603. FCC
  1604. @end table
  1605. @end table
  1606. For example to convert from BT.601 to SMPTE-240M, use the command:
  1607. @example
  1608. colormatrix=bt601:smpte240m
  1609. @end example
  1610. @section copy
  1611. Copy the input source unchanged to the output. Mainly useful for
  1612. testing purposes.
  1613. @section crop
  1614. Crop the input video.
  1615. This filter accepts a list of @var{key}=@var{value} pairs as argument,
  1616. separated by ':'. If the key of the first options is omitted, the
  1617. arguments are interpreted according to the syntax
  1618. @var{out_w}:@var{out_h}:@var{x}:@var{y}:@var{keep_aspect}.
  1619. A description of the accepted options follows:
  1620. @table @option
  1621. @item w, out_w
  1622. Set the crop area width. It defaults to @code{iw}.
  1623. This expression is evaluated only once during the filter
  1624. configuration.
  1625. @item h, out_h
  1626. Set the crop area height. It defaults to @code{ih}.
  1627. This expression is evaluated only once during the filter
  1628. configuration.
  1629. @item x
  1630. Set the expression for the x top-left coordinate of the cropped area.
  1631. It defaults to @code{(in_w-out_w)/2}.
  1632. This expression is evaluated per-frame.
  1633. @item y
  1634. Set the expression for the y top-left coordinate of the cropped area.
  1635. It defaults to @code{(in_h-out_h)/2}.
  1636. This expression is evaluated per-frame.
  1637. @item keep_aspect
  1638. If set to 1 will force the output display aspect ratio
  1639. to be the same of the input, by changing the output sample aspect
  1640. ratio. It defaults to 0.
  1641. @end table
  1642. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  1643. expressions containing the following constants:
  1644. @table @option
  1645. @item x, y
  1646. the computed values for @var{x} and @var{y}. They are evaluated for
  1647. each new frame.
  1648. @item in_w, in_h
  1649. the input width and height
  1650. @item iw, ih
  1651. same as @var{in_w} and @var{in_h}
  1652. @item out_w, out_h
  1653. the output (cropped) width and height
  1654. @item ow, oh
  1655. same as @var{out_w} and @var{out_h}
  1656. @item a
  1657. same as @var{iw} / @var{ih}
  1658. @item sar
  1659. input sample aspect ratio
  1660. @item dar
  1661. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  1662. @item hsub, vsub
  1663. horizontal and vertical chroma subsample values. For example for the
  1664. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1665. @item n
  1666. the number of input frame, starting from 0
  1667. @item t
  1668. timestamp expressed in seconds, NAN if the input timestamp is unknown
  1669. @end table
  1670. The expression for @var{out_w} may depend on the value of @var{out_h},
  1671. and the expression for @var{out_h} may depend on @var{out_w}, but they
  1672. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  1673. evaluated after @var{out_w} and @var{out_h}.
  1674. The @var{x} and @var{y} parameters specify the expressions for the
  1675. position of the top-left corner of the output (non-cropped) area. They
  1676. are evaluated for each frame. If the evaluated value is not valid, it
  1677. is approximated to the nearest valid value.
  1678. The expression for @var{x} may depend on @var{y}, and the expression
  1679. for @var{y} may depend on @var{x}.
  1680. @subsection Examples
  1681. @itemize
  1682. @item
  1683. Crop area with size 100x100 at position (12,34).
  1684. @example
  1685. crop=100:100:12:34
  1686. @end example
  1687. Using named options, the example above becomes:
  1688. @example
  1689. crop=w=100:h=100:x=12:y=34
  1690. @end example
  1691. @item
  1692. Crop the central input area with size 100x100:
  1693. @example
  1694. crop=100:100
  1695. @end example
  1696. @item
  1697. Crop the central input area with size 2/3 of the input video:
  1698. @example
  1699. crop=2/3*in_w:2/3*in_h
  1700. @end example
  1701. @item
  1702. Crop the input video central square:
  1703. @example
  1704. crop=in_h
  1705. @end example
  1706. @item
  1707. Delimit the rectangle with the top-left corner placed at position
  1708. 100:100 and the right-bottom corner corresponding to the right-bottom
  1709. corner of the input image:
  1710. @example
  1711. crop=in_w-100:in_h-100:100:100
  1712. @end example
  1713. @item
  1714. Crop 10 pixels from the left and right borders, and 20 pixels from
  1715. the top and bottom borders
  1716. @example
  1717. crop=in_w-2*10:in_h-2*20
  1718. @end example
  1719. @item
  1720. Keep only the bottom right quarter of the input image:
  1721. @example
  1722. crop=in_w/2:in_h/2:in_w/2:in_h/2
  1723. @end example
  1724. @item
  1725. Crop height for getting Greek harmony:
  1726. @example
  1727. crop=in_w:1/PHI*in_w
  1728. @end example
  1729. @item
  1730. Appply trembling effect:
  1731. @example
  1732. 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)
  1733. @end example
  1734. @item
  1735. Apply erratic camera effect depending on timestamp:
  1736. @example
  1737. 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)"
  1738. @end example
  1739. @item
  1740. Set x depending on the value of y:
  1741. @example
  1742. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  1743. @end example
  1744. @end itemize
  1745. @section cropdetect
  1746. Auto-detect crop size.
  1747. Calculate necessary cropping parameters and prints the recommended
  1748. parameters through the logging system. The detected dimensions
  1749. correspond to the non-black area of the input video.
  1750. The filter accepts parameters as a list of @var{key}=@var{value}
  1751. pairs, separated by ":". If the key of the first options is omitted,
  1752. the arguments are interpreted according to the syntax
  1753. [@option{limit}[:@option{round}[:@option{reset}]]].
  1754. A description of the accepted options follows.
  1755. @table @option
  1756. @item limit
  1757. Set higher black value threshold, which can be optionally specified
  1758. from nothing (0) to everything (255). An intensity value greater
  1759. to the set value is considered non-black. Default value is 24.
  1760. @item round
  1761. Set the value for which the width/height should be divisible by. The
  1762. offset is automatically adjusted to center the video. Use 2 to get
  1763. only even dimensions (needed for 4:2:2 video). 16 is best when
  1764. encoding to most video codecs. Default value is 16.
  1765. @item reset
  1766. Set the counter that determines after how many frames cropdetect will
  1767. reset the previously detected largest video area and start over to
  1768. detect the current optimal crop area. Default value is 0.
  1769. This can be useful when channel logos distort the video area. 0
  1770. indicates never reset and return the largest area encountered during
  1771. playback.
  1772. @end table
  1773. @section curves
  1774. Apply color adjustments using curves.
  1775. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  1776. component (red, green and blue) has its values defined by @var{N} key points
  1777. tied from each other using a smooth curve. The x-axis represents the pixel
  1778. values from the input frame, and the y-axis the new pixel values to be set for
  1779. the output frame.
  1780. By default, a component curve is defined by the two points @var{(0;0)} and
  1781. @var{(1;1)}. This creates a straight line where each original pixel value is
  1782. "adjusted" to its own value, which means no change to the image.
  1783. The filter allows you to redefine these two points and add some more. A new
  1784. curve (using a natural cubic spline interpolation) will be define to pass
  1785. smoothly through all these new coordinates. The new defined points needs to be
  1786. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  1787. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  1788. the vector spaces, the values will be clipped accordingly.
  1789. If there is no key point defined in @code{x=0}, the filter will automatically
  1790. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  1791. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  1792. The filter accepts parameters as a list of @var{key}=@var{value}
  1793. pairs, separated by ":". If the key of the first options is omitted,
  1794. the arguments are interpreted according to the syntax
  1795. curves[=@var{preset}].
  1796. A description of the accepted parameters follows.
  1797. @table @option
  1798. @item red, r
  1799. Set the key points for the red component.
  1800. @item green, g
  1801. Set the key points for the green component.
  1802. @item blue, b
  1803. Set the key points for the blue component.
  1804. @item preset
  1805. Select one of the available color presets. This option can not be used in
  1806. addition to the @option{r}, @option{g}, @option{b} parameters.
  1807. Available presets are:
  1808. @table @samp
  1809. @item color_negative
  1810. @item cross_process
  1811. @item darker
  1812. @item increase_contrast
  1813. @item lighter
  1814. @item linear_contrast
  1815. @item medium_contrast
  1816. @item negative
  1817. @item strong_contrast
  1818. @item vintage
  1819. @end table
  1820. Default is unset.
  1821. @end table
  1822. To avoid some filtergraph syntax conflicts, each key points list need to be
  1823. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  1824. @subsection Examples
  1825. @itemize
  1826. @item
  1827. Increase slightly the middle level of blue:
  1828. @example
  1829. curves=blue='0.5/0.58'
  1830. @end example
  1831. @item
  1832. Vintage effect:
  1833. @example
  1834. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  1835. @end example
  1836. Here we obtain the following coordinates for each components:
  1837. @table @var
  1838. @item red
  1839. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  1840. @item green
  1841. @code{(0;0) (0.50;0.48) (1;1)}
  1842. @item blue
  1843. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  1844. @end table
  1845. @item
  1846. The previous example can also be achieved with the associated built-in preset:
  1847. @example
  1848. curves=preset=vintage
  1849. @end example
  1850. @item
  1851. Or simply:
  1852. @example
  1853. curves=vintage
  1854. @end example
  1855. @end itemize
  1856. @section decimate
  1857. Drop frames that do not differ greatly from the previous frame in
  1858. order to reduce frame rate.
  1859. The main use of this filter is for very-low-bitrate encoding
  1860. (e.g. streaming over dialup modem), but it could in theory be used for
  1861. fixing movies that were inverse-telecined incorrectly.
  1862. The filter accepts parameters as a list of @var{key}=@var{value}
  1863. pairs, separated by ":". If the key of the first options is omitted,
  1864. the arguments are interpreted according to the syntax:
  1865. @option{max}:@option{hi}:@option{lo}:@option{frac}.
  1866. A description of the accepted options follows.
  1867. @table @option
  1868. @item max
  1869. Set the maximum number of consecutive frames which can be dropped (if
  1870. positive), or the minimum interval between dropped frames (if
  1871. negative). If the value is 0, the frame is dropped unregarding the
  1872. number of previous sequentially dropped frames.
  1873. Default value is 0.
  1874. @item hi
  1875. @item lo
  1876. @item frac
  1877. Set the dropping threshold values.
  1878. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  1879. represent actual pixel value differences, so a threshold of 64
  1880. corresponds to 1 unit of difference for each pixel, or the same spread
  1881. out differently over the block.
  1882. A frame is a candidate for dropping if no 8x8 blocks differ by more
  1883. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  1884. meaning the whole image) differ by more than a threshold of @option{lo}.
  1885. Default value for @option{hi} is 64*12, default value for @option{lo} is
  1886. 64*5, and default value for @option{frac} is 0.33.
  1887. @end table
  1888. @section delogo
  1889. Suppress a TV station logo by a simple interpolation of the surrounding
  1890. pixels. Just set a rectangle covering the logo and watch it disappear
  1891. (and sometimes something even uglier appear - your mileage may vary).
  1892. The filter accepts parameters as a string of the form
  1893. "@var{x}:@var{y}:@var{w}:@var{h}:@var{band}", or as a list of
  1894. @var{key}=@var{value} pairs, separated by ":".
  1895. The description of the accepted parameters follows.
  1896. @table @option
  1897. @item x, y
  1898. Specify the top left corner coordinates of the logo. They must be
  1899. specified.
  1900. @item w, h
  1901. Specify the width and height of the logo to clear. They must be
  1902. specified.
  1903. @item band, t
  1904. Specify the thickness of the fuzzy edge of the rectangle (added to
  1905. @var{w} and @var{h}). The default value is 4.
  1906. @item show
  1907. When set to 1, a green rectangle is drawn on the screen to simplify
  1908. finding the right @var{x}, @var{y}, @var{w}, @var{h} parameters, and
  1909. @var{band} is set to 4. The default value is 0.
  1910. @end table
  1911. @subsection Examples
  1912. @itemize
  1913. @item
  1914. Set a rectangle covering the area with top left corner coordinates 0,0
  1915. and size 100x77, setting a band of size 10:
  1916. @example
  1917. delogo=0:0:100:77:10
  1918. @end example
  1919. @item
  1920. As the previous example, but use named options:
  1921. @example
  1922. delogo=x=0:y=0:w=100:h=77:band=10
  1923. @end example
  1924. @end itemize
  1925. @section deshake
  1926. Attempt to fix small changes in horizontal and/or vertical shift. This
  1927. filter helps remove camera shake from hand-holding a camera, bumping a
  1928. tripod, moving on a vehicle, etc.
  1929. The filter accepts parameters as a list of @var{key}=@var{value}
  1930. pairs, separated by ":". If the key of the first options is omitted,
  1931. the arguments are interpreted according to the syntax
  1932. @var{x}:@var{y}:@var{w}:@var{h}:@var{rx}:@var{ry}:@var{edge}:@var{blocksize}:@var{contrast}:@var{search}:@var{filename}:@var{opencl}.
  1933. A description of the accepted parameters follows.
  1934. @table @option
  1935. @item x, y, w, h
  1936. Specify a rectangular area where to limit the search for motion
  1937. vectors.
  1938. If desired the search for motion vectors can be limited to a
  1939. rectangular area of the frame defined by its top left corner, width
  1940. and height. These parameters have the same meaning as the drawbox
  1941. filter which can be used to visualise the position of the bounding
  1942. box.
  1943. This is useful when simultaneous movement of subjects within the frame
  1944. might be confused for camera motion by the motion vector search.
  1945. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  1946. then the full frame is used. This allows later options to be set
  1947. without specifying the bounding box for the motion vector search.
  1948. Default - search the whole frame.
  1949. @item rx, ry
  1950. Specify the maximum extent of movement in x and y directions in the
  1951. range 0-64 pixels. Default 16.
  1952. @item edge
  1953. Specify how to generate pixels to fill blanks at the edge of the
  1954. frame. Available values are:
  1955. @table @samp
  1956. @item blank, 0
  1957. Fill zeroes at blank locations
  1958. @item original, 1
  1959. Original image at blank locations
  1960. @item clamp, 2
  1961. Extruded edge value at blank locations
  1962. @item mirror, 3
  1963. Mirrored edge at blank locations
  1964. @end table
  1965. Default value is @samp{mirror}.
  1966. @item blocksize
  1967. Specify the blocksize to use for motion search. Range 4-128 pixels,
  1968. default 8.
  1969. @item contrast
  1970. Specify the contrast threshold for blocks. Only blocks with more than
  1971. the specified contrast (difference between darkest and lightest
  1972. pixels) will be considered. Range 1-255, default 125.
  1973. @item search
  1974. Specify the search strategy. Available values are:
  1975. @table @samp
  1976. @item exhaustive, 0
  1977. Set exhaustive search
  1978. @item less, 1
  1979. Set less exhaustive search.
  1980. @end table
  1981. Default value is @samp{exhaustive}.
  1982. @item filename
  1983. If set then a detailed log of the motion search is written to the
  1984. specified file.
  1985. @item opencl
  1986. If set to 1, specify using OpenCL capabilities, only available if
  1987. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  1988. @end table
  1989. @section drawbox
  1990. Draw a colored box on the input image.
  1991. The filter accepts parameters as a list of @var{key}=@var{value}
  1992. pairs, separated by ":". If the key of the first options is omitted,
  1993. the arguments are interpreted according to the syntax
  1994. @option{x}:@option{y}:@option{width}:@option{height}:@option{color}:@option{thickness}.
  1995. A description of the accepted options follows.
  1996. @table @option
  1997. @item x, y
  1998. Specify the top left corner coordinates of the box. Default to 0.
  1999. @item width, w
  2000. @item height, h
  2001. Specify the width and height of the box, if 0 they are interpreted as
  2002. the input width and height. Default to 0.
  2003. @item color, c
  2004. Specify the color of the box to write, it can be the name of a color
  2005. (case insensitive match) or a 0xRRGGBB[AA] sequence. If the special
  2006. value @code{invert} is used, the box edge color is the same as the
  2007. video with inverted luma.
  2008. @item thickness, t
  2009. Set the thickness of the box edge. Default value is @code{4}.
  2010. @end table
  2011. @subsection Examples
  2012. @itemize
  2013. @item
  2014. Draw a black box around the edge of the input image:
  2015. @example
  2016. drawbox
  2017. @end example
  2018. @item
  2019. Draw a box with color red and an opacity of 50%:
  2020. @example
  2021. drawbox=10:20:200:60:red@@0.5
  2022. @end example
  2023. The previous example can be specified as:
  2024. @example
  2025. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  2026. @end example
  2027. @item
  2028. Fill the box with pink color:
  2029. @example
  2030. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  2031. @end example
  2032. @end itemize
  2033. @anchor{drawtext}
  2034. @section drawtext
  2035. Draw text string or text from specified file on top of video using the
  2036. libfreetype library.
  2037. To enable compilation of this filter you need to configure FFmpeg with
  2038. @code{--enable-libfreetype}.
  2039. @subsection Syntax
  2040. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  2041. separated by ":".
  2042. The description of the accepted parameters follows.
  2043. @table @option
  2044. @item box
  2045. Used to draw a box around text using background color.
  2046. Value should be either 1 (enable) or 0 (disable).
  2047. The default value of @var{box} is 0.
  2048. @item boxcolor
  2049. The color to be used for drawing box around text.
  2050. Either a string (e.g. "yellow") or in 0xRRGGBB[AA] format
  2051. (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  2052. The default value of @var{boxcolor} is "white".
  2053. @item draw
  2054. Set an expression which specifies if the text should be drawn. If the
  2055. expression evaluates to 0, the text is not drawn. This is useful for
  2056. specifying that the text should be drawn only when specific conditions
  2057. are met.
  2058. Default value is "1".
  2059. See below for the list of accepted constants and functions.
  2060. @item expansion
  2061. Select how the @var{text} is expanded. Can be either @code{none},
  2062. @code{strftime} (deprecated) or
  2063. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  2064. below for details.
  2065. @item fix_bounds
  2066. If true, check and fix text coords to avoid clipping.
  2067. @item fontcolor
  2068. The color to be used for drawing fonts.
  2069. Either a string (e.g. "red") or in 0xRRGGBB[AA] format
  2070. (e.g. "0xff000033"), possibly followed by an alpha specifier.
  2071. The default value of @var{fontcolor} is "black".
  2072. @item fontfile
  2073. The font file to be used for drawing text. Path must be included.
  2074. This parameter is mandatory.
  2075. @item fontsize
  2076. The font size to be used for drawing text.
  2077. The default value of @var{fontsize} is 16.
  2078. @item ft_load_flags
  2079. Flags to be used for loading the fonts.
  2080. The flags map the corresponding flags supported by libfreetype, and are
  2081. a combination of the following values:
  2082. @table @var
  2083. @item default
  2084. @item no_scale
  2085. @item no_hinting
  2086. @item render
  2087. @item no_bitmap
  2088. @item vertical_layout
  2089. @item force_autohint
  2090. @item crop_bitmap
  2091. @item pedantic
  2092. @item ignore_global_advance_width
  2093. @item no_recurse
  2094. @item ignore_transform
  2095. @item monochrome
  2096. @item linear_design
  2097. @item no_autohint
  2098. @item end table
  2099. @end table
  2100. Default value is "render".
  2101. For more information consult the documentation for the FT_LOAD_*
  2102. libfreetype flags.
  2103. @item shadowcolor
  2104. The color to be used for drawing a shadow behind the drawn text. It
  2105. can be a color name (e.g. "yellow") or a string in the 0xRRGGBB[AA]
  2106. form (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  2107. The default value of @var{shadowcolor} is "black".
  2108. @item shadowx, shadowy
  2109. The x and y offsets for the text shadow position with respect to the
  2110. position of the text. They can be either positive or negative
  2111. values. Default value for both is "0".
  2112. @item tabsize
  2113. The size in number of spaces to use for rendering the tab.
  2114. Default value is 4.
  2115. @item timecode
  2116. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  2117. format. It can be used with or without text parameter. @var{timecode_rate}
  2118. option must be specified.
  2119. @item timecode_rate, rate, r
  2120. Set the timecode frame rate (timecode only).
  2121. @item text
  2122. The text string to be drawn. The text must be a sequence of UTF-8
  2123. encoded characters.
  2124. This parameter is mandatory if no file is specified with the parameter
  2125. @var{textfile}.
  2126. @item textfile
  2127. A text file containing text to be drawn. The text must be a sequence
  2128. of UTF-8 encoded characters.
  2129. This parameter is mandatory if no text string is specified with the
  2130. parameter @var{text}.
  2131. If both @var{text} and @var{textfile} are specified, an error is thrown.
  2132. @item reload
  2133. If set to 1, the @var{textfile} will be reloaded before each frame.
  2134. Be sure to update it atomically, or it may be read partially, or even fail.
  2135. @item x, y
  2136. The expressions which specify the offsets where text will be drawn
  2137. within the video frame. They are relative to the top/left border of the
  2138. output image.
  2139. The default value of @var{x} and @var{y} is "0".
  2140. See below for the list of accepted constants and functions.
  2141. @end table
  2142. The parameters for @var{x} and @var{y} are expressions containing the
  2143. following constants and functions:
  2144. @table @option
  2145. @item dar
  2146. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  2147. @item hsub, vsub
  2148. horizontal and vertical chroma subsample values. For example for the
  2149. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2150. @item line_h, lh
  2151. the height of each text line
  2152. @item main_h, h, H
  2153. the input height
  2154. @item main_w, w, W
  2155. the input width
  2156. @item max_glyph_a, ascent
  2157. the maximum distance from the baseline to the highest/upper grid
  2158. coordinate used to place a glyph outline point, for all the rendered
  2159. glyphs.
  2160. It is a positive value, due to the grid's orientation with the Y axis
  2161. upwards.
  2162. @item max_glyph_d, descent
  2163. the maximum distance from the baseline to the lowest grid coordinate
  2164. used to place a glyph outline point, for all the rendered glyphs.
  2165. This is a negative value, due to the grid's orientation, with the Y axis
  2166. upwards.
  2167. @item max_glyph_h
  2168. maximum glyph height, that is the maximum height for all the glyphs
  2169. contained in the rendered text, it is equivalent to @var{ascent} -
  2170. @var{descent}.
  2171. @item max_glyph_w
  2172. maximum glyph width, that is the maximum width for all the glyphs
  2173. contained in the rendered text
  2174. @item n
  2175. the number of input frame, starting from 0
  2176. @item rand(min, max)
  2177. return a random number included between @var{min} and @var{max}
  2178. @item sar
  2179. input sample aspect ratio
  2180. @item t
  2181. timestamp expressed in seconds, NAN if the input timestamp is unknown
  2182. @item text_h, th
  2183. the height of the rendered text
  2184. @item text_w, tw
  2185. the width of the rendered text
  2186. @item x, y
  2187. the x and y offset coordinates where the text is drawn.
  2188. These parameters allow the @var{x} and @var{y} expressions to refer
  2189. each other, so you can for example specify @code{y=x/dar}.
  2190. @end table
  2191. If libavfilter was built with @code{--enable-fontconfig}, then
  2192. @option{fontfile} can be a fontconfig pattern or omitted.
  2193. @anchor{drawtext_expansion}
  2194. @subsection Text expansion
  2195. If @option{expansion} is set to @code{strftime},
  2196. the filter recognizes strftime() sequences in the provided text and
  2197. expands them accordingly. Check the documentation of strftime(). This
  2198. feature is deprecated.
  2199. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  2200. If @option{expansion} is set to @code{normal} (which is the default),
  2201. the following expansion mechanism is used.
  2202. The backslash character '\', followed by any character, always expands to
  2203. the second character.
  2204. Sequence of the form @code{%@{...@}} are expanded. The text between the
  2205. braces is a function name, possibly followed by arguments separated by ':'.
  2206. If the arguments contain special characters or delimiters (':' or '@}'),
  2207. they should be escaped.
  2208. Note that they probably must also be escaped as the value for the
  2209. @option{text} option in the filter argument string and as the filter
  2210. argument in the filtergraph description, and possibly also for the shell,
  2211. that makes up to four levels of escaping; using a text file avoids these
  2212. problems.
  2213. The following functions are available:
  2214. @table @command
  2215. @item expr, e
  2216. The expression evaluation result.
  2217. It must take one argument specifying the expression to be evaluated,
  2218. which accepts the same constants and functions as the @var{x} and
  2219. @var{y} values. Note that not all constants should be used, for
  2220. example the text size is not known when evaluating the expression, so
  2221. the constants @var{text_w} and @var{text_h} will have an undefined
  2222. value.
  2223. @item gmtime
  2224. The time at which the filter is running, expressed in UTC.
  2225. It can accept an argument: a strftime() format string.
  2226. @item localtime
  2227. The time at which the filter is running, expressed in the local time zone.
  2228. It can accept an argument: a strftime() format string.
  2229. @item n, frame_num
  2230. The frame number, starting from 0.
  2231. @item pts
  2232. The timestamp of the current frame, in seconds, with microsecond accuracy.
  2233. @end table
  2234. @subsection Examples
  2235. @itemize
  2236. @item
  2237. Draw "Test Text" with font FreeSerif, using the default values for the
  2238. optional parameters.
  2239. @example
  2240. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  2241. @end example
  2242. @item
  2243. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  2244. and y=50 (counting from the top-left corner of the screen), text is
  2245. yellow with a red box around it. Both the text and the box have an
  2246. opacity of 20%.
  2247. @example
  2248. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  2249. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  2250. @end example
  2251. Note that the double quotes are not necessary if spaces are not used
  2252. within the parameter list.
  2253. @item
  2254. Show the text at the center of the video frame:
  2255. @example
  2256. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  2257. @end example
  2258. @item
  2259. Show a text line sliding from right to left in the last row of the video
  2260. frame. The file @file{LONG_LINE} is assumed to contain a single line
  2261. with no newlines.
  2262. @example
  2263. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  2264. @end example
  2265. @item
  2266. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  2267. @example
  2268. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  2269. @end example
  2270. @item
  2271. Draw a single green letter "g", at the center of the input video.
  2272. The glyph baseline is placed at half screen height.
  2273. @example
  2274. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  2275. @end example
  2276. @item
  2277. Show text for 1 second every 3 seconds:
  2278. @example
  2279. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:draw=lt(mod(t\,3)\,1):text='blink'"
  2280. @end example
  2281. @item
  2282. Use fontconfig to set the font. Note that the colons need to be escaped.
  2283. @example
  2284. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  2285. @end example
  2286. @item
  2287. Print the date of a real-time encoding (see strftime(3)):
  2288. @example
  2289. drawtext='fontfile=FreeSans.ttf:text=%@{localtime:%a %b %d %Y@}'
  2290. @end example
  2291. @end itemize
  2292. For more information about libfreetype, check:
  2293. @url{http://www.freetype.org/}.
  2294. For more information about fontconfig, check:
  2295. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  2296. @section edgedetect
  2297. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  2298. This filter accepts the following optional named parameters:
  2299. @table @option
  2300. @item low, high
  2301. Set low and high threshold values used by the Canny thresholding
  2302. algorithm.
  2303. The high threshold selects the "strong" edge pixels, which are then
  2304. connected through 8-connectivity with the "weak" edge pixels selected
  2305. by the low threshold.
  2306. @var{low} and @var{high} threshold values must be choosen in the range
  2307. [0,1], and @var{low} should be lesser or equal to @var{high}.
  2308. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  2309. is @code{50/255}.
  2310. @end table
  2311. Example:
  2312. @example
  2313. edgedetect=low=0.1:high=0.4
  2314. @end example
  2315. @section fade
  2316. Apply fade-in/out effect to input video.
  2317. The filter accepts parameters as a list of @var{key}=@var{value}
  2318. pairs, separated by ":". If the key of the first options is omitted,
  2319. the arguments are interpreted according to the syntax
  2320. @var{type}:@var{start_frame}:@var{nb_frames}.
  2321. A description of the accepted parameters follows.
  2322. @table @option
  2323. @item type, t
  2324. Specify if the effect type, can be either @code{in} for fade-in, or
  2325. @code{out} for a fade-out effect. Default is @code{in}.
  2326. @item start_frame, s
  2327. Specify the number of the start frame for starting to apply the fade
  2328. effect. Default is 0.
  2329. @item nb_frames, n
  2330. Specify the number of frames for which the fade effect has to last. At
  2331. the end of the fade-in effect the output video will have the same
  2332. intensity as the input video, at the end of the fade-out transition
  2333. the output video will be completely black. Default is 25.
  2334. @item alpha
  2335. If set to 1, fade only alpha channel, if one exists on the input.
  2336. Default value is 0.
  2337. @end table
  2338. @subsection Examples
  2339. @itemize
  2340. @item
  2341. Fade in first 30 frames of video:
  2342. @example
  2343. fade=in:0:30
  2344. @end example
  2345. The command above is equivalent to:
  2346. @example
  2347. fade=t=in:s=0:n=30
  2348. @end example
  2349. @item
  2350. Fade out last 45 frames of a 200-frame video:
  2351. @example
  2352. fade=out:155:45
  2353. @end example
  2354. @item
  2355. Fade in first 25 frames and fade out last 25 frames of a 1000-frame video:
  2356. @example
  2357. fade=in:0:25, fade=out:975:25
  2358. @end example
  2359. @item
  2360. Make first 5 frames black, then fade in from frame 5-24:
  2361. @example
  2362. fade=in:5:20
  2363. @end example
  2364. @item
  2365. Fade in alpha over first 25 frames of video:
  2366. @example
  2367. fade=in:0:25:alpha=1
  2368. @end example
  2369. @end itemize
  2370. @section field
  2371. Extract a single field from an interlaced image using stride
  2372. arithmetic to avoid wasting CPU time. The output frames are marked as
  2373. non-interlaced.
  2374. This filter accepts the following named options:
  2375. @table @option
  2376. @item type
  2377. Specify whether to extract the top (if the value is @code{0} or
  2378. @code{top}) or the bottom field (if the value is @code{1} or
  2379. @code{bottom}).
  2380. @end table
  2381. If the option key is not specified, the first value sets the @var{type}
  2382. option. For example:
  2383. @example
  2384. field=bottom
  2385. @end example
  2386. is equivalent to:
  2387. @example
  2388. field=type=bottom
  2389. @end example
  2390. @section fieldorder
  2391. Transform the field order of the input video.
  2392. This filter accepts the named option @option{order} which
  2393. specifies the required field order that the input interlaced video
  2394. will be transformed to. The option name can be omitted.
  2395. The option @option{order} can assume one of the following values:
  2396. @table @samp
  2397. @item bff
  2398. output bottom field first
  2399. @item tff
  2400. output top field first
  2401. @end table
  2402. Default value is @samp{tff}.
  2403. Transformation is achieved by shifting the picture content up or down
  2404. by one line, and filling the remaining line with appropriate picture content.
  2405. This method is consistent with most broadcast field order converters.
  2406. If the input video is not flagged as being interlaced, or it is already
  2407. flagged as being of the required output field order then this filter does
  2408. not alter the incoming video.
  2409. This filter is very useful when converting to or from PAL DV material,
  2410. which is bottom field first.
  2411. For example:
  2412. @example
  2413. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  2414. @end example
  2415. @section fifo
  2416. Buffer input images and send them when they are requested.
  2417. This filter is mainly useful when auto-inserted by the libavfilter
  2418. framework.
  2419. The filter does not take parameters.
  2420. @anchor{format}
  2421. @section format
  2422. Convert the input video to one of the specified pixel formats.
  2423. Libavfilter will try to pick one that is supported for the input to
  2424. the next filter.
  2425. This filter accepts the following parameters:
  2426. @table @option
  2427. @item pix_fmts
  2428. A '|'-separated list of pixel format names, for example
  2429. "pix_fmts=yuv420p|monow|rgb24".
  2430. @end table
  2431. @subsection Examples
  2432. @itemize
  2433. @item
  2434. Convert the input video to the format @var{yuv420p}
  2435. @example
  2436. format=pix_fmts=yuv420p
  2437. @end example
  2438. Convert the input video to any of the formats in the list
  2439. @example
  2440. format=pix_fmts=yuv420p|yuv444p|yuv410p
  2441. @end example
  2442. @end itemize
  2443. @section fps
  2444. Convert the video to specified constant frame rate by duplicating or dropping
  2445. frames as necessary.
  2446. This filter accepts the following named parameters:
  2447. @table @option
  2448. @item fps
  2449. Desired output frame rate. The default is @code{25}.
  2450. @item round
  2451. Rounding method.
  2452. Possible values are:
  2453. @table @option
  2454. @item zero
  2455. zero round towards 0
  2456. @item inf
  2457. round away from 0
  2458. @item down
  2459. round towards -infinity
  2460. @item up
  2461. round towards +infinity
  2462. @item near
  2463. round to nearest
  2464. @end table
  2465. The default is @code{near}.
  2466. @end table
  2467. Alternatively, the options can be specified as a flat string:
  2468. @var{fps}[:@var{round}].
  2469. See also the @ref{setpts} filter.
  2470. @section framestep
  2471. Select one frame every N.
  2472. This filter accepts in input a string representing a positive
  2473. integer. Default argument is @code{1}.
  2474. @anchor{frei0r}
  2475. @section frei0r
  2476. Apply a frei0r effect to the input video.
  2477. To enable compilation of this filter you need to install the frei0r
  2478. header and configure FFmpeg with @code{--enable-frei0r}.
  2479. The filter supports the syntax:
  2480. @example
  2481. @var{filter_name}[@{:|=@}@var{param1}:@var{param2}:...:@var{paramN}]
  2482. @end example
  2483. @var{filter_name} is the name of the frei0r effect to load. If the
  2484. environment variable @env{FREI0R_PATH} is defined, the frei0r effect
  2485. is searched in each one of the directories specified by the colon (or
  2486. semicolon on Windows platforms) separated list in @env{FREIOR_PATH},
  2487. otherwise in the standard frei0r paths, which are in this order:
  2488. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  2489. @file{/usr/lib/frei0r-1/}.
  2490. @var{param1}, @var{param2}, ... , @var{paramN} specify the parameters
  2491. for the frei0r effect.
  2492. A frei0r effect parameter can be a boolean (whose values are specified
  2493. with "y" and "n"), a double, a color (specified by the syntax
  2494. @var{R}/@var{G}/@var{B}, @var{R}, @var{G}, and @var{B} being float
  2495. numbers from 0.0 to 1.0) or by an @code{av_parse_color()} color
  2496. description), a position (specified by the syntax @var{X}/@var{Y},
  2497. @var{X} and @var{Y} being float numbers) and a string.
  2498. The number and kind of parameters depend on the loaded effect. If an
  2499. effect parameter is not specified the default value is set.
  2500. @subsection Examples
  2501. @itemize
  2502. @item
  2503. Apply the distort0r effect, set the first two double parameters:
  2504. @example
  2505. frei0r=distort0r:0.5:0.01
  2506. @end example
  2507. @item
  2508. Apply the colordistance effect, take a color as first parameter:
  2509. @example
  2510. frei0r=colordistance:0.2/0.3/0.4
  2511. frei0r=colordistance:violet
  2512. frei0r=colordistance:0x112233
  2513. @end example
  2514. @item
  2515. Apply the perspective effect, specify the top left and top right image
  2516. positions:
  2517. @example
  2518. frei0r=perspective:0.2/0.2:0.8/0.2
  2519. @end example
  2520. @end itemize
  2521. For more information see:
  2522. @url{http://frei0r.dyne.org}
  2523. @section geq
  2524. The filter takes one, two, three or four equations as parameter, separated by ':'.
  2525. The first equation is mandatory and applies to the luma plane. The two
  2526. following are respectively for chroma blue and chroma red planes.
  2527. The filter syntax allows named parameters:
  2528. @table @option
  2529. @item lum_expr
  2530. the luminance expression
  2531. @item cb_expr
  2532. the chrominance blue expression
  2533. @item cr_expr
  2534. the chrominance red expression
  2535. @item alpha_expr
  2536. the alpha expression
  2537. @end table
  2538. If one of the chrominance expression is not defined, it falls back on the other
  2539. one. If no alpha expression is specified it will evaluate to opaque value.
  2540. If none of chrominance expressions are
  2541. specified, they will evaluate the luminance expression.
  2542. The expressions can use the following variables and functions:
  2543. @table @option
  2544. @item N
  2545. The sequential number of the filtered frame, starting from @code{0}.
  2546. @item X
  2547. @item Y
  2548. The coordinates of the current sample.
  2549. @item W
  2550. @item H
  2551. The width and height of the image.
  2552. @item SW
  2553. @item SH
  2554. Width and height scale depending on the currently filtered plane. It is the
  2555. ratio between the corresponding luma plane number of pixels and the current
  2556. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  2557. @code{0.5,0.5} for chroma planes.
  2558. @item T
  2559. Time of the current frame, expressed in seconds.
  2560. @item p(x, y)
  2561. Return the value of the pixel at location (@var{x},@var{y}) of the current
  2562. plane.
  2563. @item lum(x, y)
  2564. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  2565. plane.
  2566. @item cb(x, y)
  2567. Return the value of the pixel at location (@var{x},@var{y}) of the
  2568. blue-difference chroma plane. Returns 0 if there is no such plane.
  2569. @item cr(x, y)
  2570. Return the value of the pixel at location (@var{x},@var{y}) of the
  2571. red-difference chroma plane. Returns 0 if there is no such plane.
  2572. @item alpha(x, y)
  2573. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  2574. plane. Returns 0 if there is no such plane.
  2575. @end table
  2576. For functions, if @var{x} and @var{y} are outside the area, the value will be
  2577. automatically clipped to the closer edge.
  2578. @subsection Examples
  2579. @itemize
  2580. @item
  2581. Flip the image horizontally:
  2582. @example
  2583. geq=p(W-X\,Y)
  2584. @end example
  2585. @item
  2586. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  2587. wavelength of 100 pixels:
  2588. @example
  2589. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  2590. @end example
  2591. @item
  2592. Generate a fancy enigmatic moving light:
  2593. @example
  2594. 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
  2595. @end example
  2596. @end itemize
  2597. @section gradfun
  2598. Fix the banding artifacts that are sometimes introduced into nearly flat
  2599. regions by truncation to 8bit color depth.
  2600. Interpolate the gradients that should go where the bands are, and
  2601. dither them.
  2602. This filter is designed for playback only. Do not use it prior to
  2603. lossy compression, because compression tends to lose the dither and
  2604. bring back the bands.
  2605. The filter accepts a list of options in the form of @var{key}=@var{value} pairs
  2606. separated by ":". A description of the accepted options follows.
  2607. @table @option
  2608. @item strength
  2609. The maximum amount by which the filter will change
  2610. any one pixel. Also the threshold for detecting nearly flat
  2611. regions. Acceptable values range from @code{0.51} to @code{64}, default value
  2612. is @code{1.2}.
  2613. @item radius
  2614. The neighborhood to fit the gradient to. A larger
  2615. radius makes for smoother gradients, but also prevents the filter from
  2616. modifying the pixels near detailed regions. Acceptable values are
  2617. @code{8-32}, default value is @code{16}.
  2618. @end table
  2619. Alternatively, the options can be specified as a flat string:
  2620. @var{strength}[:@var{radius}]
  2621. @subsection Examples
  2622. @itemize
  2623. @item
  2624. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  2625. @example
  2626. gradfun=3.5:8
  2627. @end example
  2628. @item
  2629. Specify radius, omitting the strength (which will fall-back to the default
  2630. value):
  2631. @example
  2632. gradfun=radius=8
  2633. @end example
  2634. @end itemize
  2635. @section hflip
  2636. Flip the input video horizontally.
  2637. For example to horizontally flip the input video with @command{ffmpeg}:
  2638. @example
  2639. ffmpeg -i in.avi -vf "hflip" out.avi
  2640. @end example
  2641. @section histeq
  2642. This filter applies a global color histogram equalization on a
  2643. per-frame basis.
  2644. It can be used to correct video that has a compressed range of pixel
  2645. intensities. The filter redistributes the pixel intensities to
  2646. equalize their distribution across the intensity range. It may be
  2647. viewed as an "automatically adjusting contrast filter". This filter is
  2648. useful only for correcting degraded or poorly captured source
  2649. video.
  2650. The filter accepts parameters as a list of @var{key}=@var{value}
  2651. pairs, separated by ":". If the key of the first options is omitted,
  2652. the arguments are interpreted according to syntax
  2653. @var{strength}:@var{intensity}:@var{antibanding}.
  2654. This filter accepts the following named options:
  2655. @table @option
  2656. @item strength
  2657. Determine the amount of equalization to be applied. As the strength
  2658. is reduced, the distribution of pixel intensities more-and-more
  2659. approaches that of the input frame. The value must be a float number
  2660. in the range [0,1] and defaults to 0.200.
  2661. @item intensity
  2662. Set the maximum intensity that can generated and scale the output
  2663. values appropriately. The strength should be set as desired and then
  2664. the intensity can be limited if needed to avoid washing-out. The value
  2665. must be a float number in the range [0,1] and defaults to 0.210.
  2666. @item antibanding
  2667. Set the antibanding level. If enabled the filter will randomly vary
  2668. the luminance of output pixels by a small amount to avoid banding of
  2669. the histogram. Possible values are @code{none}, @code{weak} or
  2670. @code{strong}. It defaults to @code{none}.
  2671. @end table
  2672. @section histogram
  2673. Compute and draw a color distribution histogram for the input video.
  2674. The computed histogram is a representation of distribution of color components
  2675. in an image.
  2676. The filter accepts the following named parameters:
  2677. @table @option
  2678. @item mode
  2679. Set histogram mode.
  2680. It accepts the following values:
  2681. @table @samp
  2682. @item levels
  2683. standard histogram that display color components distribution in an image.
  2684. Displays color graph for each color component. Shows distribution
  2685. of the Y, U, V, A or G, B, R components, depending on input format,
  2686. in current frame. Bellow each graph is color component scale meter.
  2687. @item color
  2688. chroma values in vectorscope, if brighter more such chroma values are
  2689. distributed in an image.
  2690. Displays chroma values (U/V color placement) in two dimensional graph
  2691. (which is called a vectorscope). It can be used to read of the hue and
  2692. saturation of the current frame. At a same time it is a histogram.
  2693. The whiter a pixel in the vectorscope, the more pixels of the input frame
  2694. correspond to that pixel (that is the more pixels have this chroma value).
  2695. The V component is displayed on the horizontal (X) axis, with the leftmost
  2696. side being V = 0 and the rightmost side being V = 255.
  2697. The U component is displayed on the vertical (Y) axis, with the top
  2698. representing U = 0 and the bottom representing U = 255.
  2699. The position of a white pixel in the graph corresponds to the chroma value
  2700. of a pixel of the input clip. So the graph can be used to read of the
  2701. hue (color flavor) and the saturation (the dominance of the hue in the color).
  2702. As the hue of a color changes, it moves around the square. At the center of
  2703. the square, the saturation is zero, which means that the corresponding pixel
  2704. has no color. If you increase the amount of a specific color, while leaving
  2705. the other colors unchanged, the saturation increases, and you move towards
  2706. the edge of the square.
  2707. @item color2
  2708. chroma values in vectorscope, similar as @code{color} but actual chroma values
  2709. are displayed.
  2710. @item waveform
  2711. per row/column color component graph. In row mode graph in the left side represents
  2712. color component value 0 and right side represents value = 255. In column mode top
  2713. side represents color component value = 0 and bottom side represents value = 255.
  2714. @end table
  2715. Default value is @code{levels}.
  2716. @item level_height
  2717. Set height of level in @code{levels}. Default value is @code{200}.
  2718. Allowed range is [50, 2048].
  2719. @item scale_height
  2720. Set height of color scale in @code{levels}. Default value is @code{12}.
  2721. Allowed range is [0, 40].
  2722. @item step
  2723. Set step for @code{waveform} mode. Smaller values are useful to find out how much
  2724. of same luminance values across input rows/columns are distributed.
  2725. Default value is @code{10}. Allowed range is [1, 255].
  2726. @item waveform_mode
  2727. Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
  2728. Default is @code{row}.
  2729. @item display_mode
  2730. Set display mode for @code{waveform} and @code{levels}.
  2731. It accepts the following values:
  2732. @table @samp
  2733. @item parade
  2734. Display separate graph for the color components side by side in
  2735. @code{row} waveform mode or one below other in @code{column} waveform mode
  2736. for @code{waveform} histogram mode. For @code{levels} histogram mode
  2737. per color component graphs are placed one bellow other.
  2738. This display mode in @code{waveform} histogram mode makes it easy to spot
  2739. color casts in the highlights and shadows of an image, by comparing the
  2740. contours of the top and the bottom of each waveform.
  2741. Since whites, grays, and blacks are characterized by
  2742. exactly equal amounts of red, green, and blue, neutral areas of the
  2743. picture should display three waveforms of roughly equal width/height.
  2744. If not, the correction is easy to make by making adjustments to level the
  2745. three waveforms.
  2746. @item overlay
  2747. Presents information that's identical to that in the @code{parade}, except
  2748. that the graphs representing color components are superimposed directly
  2749. over one another.
  2750. This display mode in @code{waveform} histogram mode can make it easier to spot
  2751. the relative differences or similarities in overlapping areas of the color
  2752. components that are supposed to be identical, such as neutral whites, grays,
  2753. or blacks.
  2754. @end table
  2755. Default is @code{parade}.
  2756. @end table
  2757. @subsection Examples
  2758. @itemize
  2759. @item
  2760. Calculate and draw histogram:
  2761. @example
  2762. ffplay -i input -vf histogram
  2763. @end example
  2764. @end itemize
  2765. @section hqdn3d
  2766. High precision/quality 3d denoise filter. This filter aims to reduce
  2767. image noise producing smooth images and making still images really
  2768. still. It should enhance compressibility.
  2769. It accepts the following optional parameters:
  2770. @var{luma_spatial}:@var{chroma_spatial}:@var{luma_tmp}:@var{chroma_tmp}
  2771. @table @option
  2772. @item luma_spatial
  2773. a non-negative float number which specifies spatial luma strength,
  2774. defaults to 4.0
  2775. @item chroma_spatial
  2776. a non-negative float number which specifies spatial chroma strength,
  2777. defaults to 3.0*@var{luma_spatial}/4.0
  2778. @item luma_tmp
  2779. a float number which specifies luma temporal strength, defaults to
  2780. 6.0*@var{luma_spatial}/4.0
  2781. @item chroma_tmp
  2782. a float number which specifies chroma temporal strength, defaults to
  2783. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
  2784. @end table
  2785. @section hue
  2786. Modify the hue and/or the saturation of the input.
  2787. This filter accepts the following optional named options:
  2788. @table @option
  2789. @item h
  2790. Specify the hue angle as a number of degrees. It accepts a float
  2791. number or an expression, and defaults to 0.0.
  2792. @item H
  2793. Specify the hue angle as a number of radians. It accepts a float
  2794. number or an expression, and defaults to 0.0.
  2795. @item s
  2796. Specify the saturation in the [-10,10] range. It accepts a float number and
  2797. defaults to 1.0.
  2798. @end table
  2799. The @var{h}, @var{H} and @var{s} parameters are expressions containing the
  2800. following constants:
  2801. @table @option
  2802. @item n
  2803. frame count of the input frame starting from 0
  2804. @item pts
  2805. presentation timestamp of the input frame expressed in time base units
  2806. @item r
  2807. frame rate of the input video, NAN if the input frame rate is unknown
  2808. @item t
  2809. timestamp expressed in seconds, NAN if the input timestamp is unknown
  2810. @item tb
  2811. time base of the input video
  2812. @end table
  2813. The options can also be set using the syntax: @var{hue}:@var{saturation}
  2814. In this case @var{hue} is expressed in degrees.
  2815. @subsection Examples
  2816. @itemize
  2817. @item
  2818. Set the hue to 90 degrees and the saturation to 1.0:
  2819. @example
  2820. hue=h=90:s=1
  2821. @end example
  2822. @item
  2823. Same command but expressing the hue in radians:
  2824. @example
  2825. hue=H=PI/2:s=1
  2826. @end example
  2827. @item
  2828. Same command without named options, hue must be expressed in degrees:
  2829. @example
  2830. hue=90:1
  2831. @end example
  2832. @item
  2833. Note that "h:s" syntax does not support expressions for the values of
  2834. h and s, so the following example will issue an error:
  2835. @example
  2836. hue=PI/2:1
  2837. @end example
  2838. @item
  2839. Rotate hue and make the saturation swing between 0
  2840. and 2 over a period of 1 second:
  2841. @example
  2842. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  2843. @end example
  2844. @item
  2845. Apply a 3 seconds saturation fade-in effect starting at 0:
  2846. @example
  2847. hue="s=min(t/3\,1)"
  2848. @end example
  2849. The general fade-in expression can be written as:
  2850. @example
  2851. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  2852. @end example
  2853. @item
  2854. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  2855. @example
  2856. hue="s=max(0\, min(1\, (8-t)/3))"
  2857. @end example
  2858. The general fade-out expression can be written as:
  2859. @example
  2860. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  2861. @end example
  2862. @end itemize
  2863. @subsection Commands
  2864. This filter supports the following command:
  2865. @table @option
  2866. @item reinit
  2867. Modify the hue and/or the saturation of the input video.
  2868. The command accepts the same named options and syntax than when calling the
  2869. filter from the command-line.
  2870. If a parameter is omitted, it is kept at its current value.
  2871. @end table
  2872. @section idet
  2873. Detect video interlacing type.
  2874. This filter tries to detect if the input is interlaced or progressive,
  2875. top or bottom field first.
  2876. @section il
  2877. Deinterleave or interleave fields.
  2878. This filter allows to process interlaced images fields without
  2879. deinterlacing them. Deinterleaving splits the input frame into 2
  2880. fields (so called half pictures). Odd lines are moved to the top
  2881. half of the output image, even lines to the bottom half.
  2882. You can process (filter) them independently and then re-interleave them.
  2883. It accepts a list of options in the form of @var{key}=@var{value} pairs
  2884. separated by ":". A description of the accepted options follows.
  2885. @table @option
  2886. @item luma_mode, l
  2887. @item chroma_mode, s
  2888. @item alpha_mode, a
  2889. Available values for @var{luma_mode}, @var{chroma_mode} and
  2890. @var{alpha_mode} are:
  2891. @table @samp
  2892. @item none
  2893. Do nothing.
  2894. @item deinterleave, d
  2895. Deinterleave fields, placing one above the other.
  2896. @item interleave, i
  2897. Interleave fields. Reverse the effect of deinterleaving.
  2898. @end table
  2899. Default value is @code{none}.
  2900. @item luma_swap, ls
  2901. @item chroma_swap, cs
  2902. @item alpha_swap, as
  2903. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  2904. @end table
  2905. @section kerndeint
  2906. Deinterlace input video by applying Donald Graft's adaptive kernel
  2907. deinterling. Work on interlaced parts of a video to produce
  2908. progressive frames.
  2909. This filter accepts parameters as a list of @var{key}=@var{value}
  2910. pairs, separated by ":". If the key of the first options is omitted,
  2911. the arguments are interpreted according to the following syntax:
  2912. @var{thresh}:@var{map}:@var{order}:@var{sharp}:@var{twoway}.
  2913. The description of the accepted parameters follows.
  2914. @table @option
  2915. @item thresh
  2916. Set the threshold which affects the filter's tolerance when
  2917. determining if a pixel line must be processed. It must be an integer
  2918. in the range [0,255] and defaults to 10. A value of 0 will result in
  2919. applying the process on every pixels.
  2920. @item map
  2921. Paint pixels exceeding the threshold value to white if set to 1.
  2922. Default is 0.
  2923. @item order
  2924. Set the fields order. Swap fields if set to 1, leave fields alone if
  2925. 0. Default is 0.
  2926. @item sharp
  2927. Enable additional sharpening if set to 1. Default is 0.
  2928. @item twoway
  2929. Enable twoway sharpening if set to 1. Default is 0.
  2930. @end table
  2931. @subsection Examples
  2932. @itemize
  2933. @item
  2934. Apply default values:
  2935. @example
  2936. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  2937. @end example
  2938. @item
  2939. Enable additional sharpening:
  2940. @example
  2941. kerndeint=sharp=1
  2942. @end example
  2943. @item
  2944. Paint processed pixels in white:
  2945. @example
  2946. kerndeint=map=1
  2947. @end example
  2948. @end itemize
  2949. @section lut, lutrgb, lutyuv
  2950. Compute a look-up table for binding each pixel component input value
  2951. to an output value, and apply it to input video.
  2952. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  2953. to an RGB input video.
  2954. These filters accept in input a ":"-separated list of options, which
  2955. specify the expressions used for computing the lookup table for the
  2956. corresponding pixel component values.
  2957. The @var{lut} filter requires either YUV or RGB pixel formats in
  2958. input, and accepts the options:
  2959. @table @option
  2960. @item c0
  2961. set first pixel component expression
  2962. @item c1
  2963. set second pixel component expression
  2964. @item c2
  2965. set third pixel component expression
  2966. @item c3
  2967. set fourth pixel component expression, corresponds to the alpha component
  2968. @end table
  2969. The exact component associated to each option depends on the format in
  2970. input.
  2971. The @var{lutrgb} filter requires RGB pixel formats in input, and
  2972. accepts the options:
  2973. @table @option
  2974. @item r
  2975. set red component expression
  2976. @item g
  2977. set green component expression
  2978. @item b
  2979. set blue component expression
  2980. @item a
  2981. alpha component expression
  2982. @end table
  2983. The @var{lutyuv} filter requires YUV pixel formats in input, and
  2984. accepts the options:
  2985. @table @option
  2986. @item y
  2987. set Y/luminance component expression
  2988. @item u
  2989. set U/Cb component expression
  2990. @item v
  2991. set V/Cr component expression
  2992. @item a
  2993. set alpha component expression
  2994. @end table
  2995. The expressions can contain the following constants and functions:
  2996. @table @option
  2997. @item w, h
  2998. the input width and height
  2999. @item val
  3000. input value for the pixel component
  3001. @item clipval
  3002. the input value clipped in the @var{minval}-@var{maxval} range
  3003. @item maxval
  3004. maximum value for the pixel component
  3005. @item minval
  3006. minimum value for the pixel component
  3007. @item negval
  3008. the negated value for the pixel component value clipped in the
  3009. @var{minval}-@var{maxval} range , it corresponds to the expression
  3010. "maxval-clipval+minval"
  3011. @item clip(val)
  3012. the computed value in @var{val} clipped in the
  3013. @var{minval}-@var{maxval} range
  3014. @item gammaval(gamma)
  3015. the computed gamma correction value of the pixel component value
  3016. clipped in the @var{minval}-@var{maxval} range, corresponds to the
  3017. expression
  3018. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  3019. @end table
  3020. All expressions default to "val".
  3021. @subsection Examples
  3022. @itemize
  3023. @item
  3024. Negate input video:
  3025. @example
  3026. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  3027. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  3028. @end example
  3029. The above is the same as:
  3030. @example
  3031. lutrgb="r=negval:g=negval:b=negval"
  3032. lutyuv="y=negval:u=negval:v=negval"
  3033. @end example
  3034. @item
  3035. Negate luminance:
  3036. @example
  3037. lutyuv=y=negval
  3038. @end example
  3039. @item
  3040. Remove chroma components, turns the video into a graytone image:
  3041. @example
  3042. lutyuv="u=128:v=128"
  3043. @end example
  3044. @item
  3045. Apply a luma burning effect:
  3046. @example
  3047. lutyuv="y=2*val"
  3048. @end example
  3049. @item
  3050. Remove green and blue components:
  3051. @example
  3052. lutrgb="g=0:b=0"
  3053. @end example
  3054. @item
  3055. Set a constant alpha channel value on input:
  3056. @example
  3057. format=rgba,lutrgb=a="maxval-minval/2"
  3058. @end example
  3059. @item
  3060. Correct luminance gamma by a 0.5 factor:
  3061. @example
  3062. lutyuv=y=gammaval(0.5)
  3063. @end example
  3064. @item
  3065. Discard least significant bits of luma:
  3066. @example
  3067. lutyuv=y='bitand(val, 128+64+32)'
  3068. @end example
  3069. @end itemize
  3070. @section mp
  3071. Apply an MPlayer filter to the input video.
  3072. This filter provides a wrapper around most of the filters of
  3073. MPlayer/MEncoder.
  3074. This wrapper is considered experimental. Some of the wrapped filters
  3075. may not work properly and we may drop support for them, as they will
  3076. be implemented natively into FFmpeg. Thus you should avoid
  3077. depending on them when writing portable scripts.
  3078. The filters accepts the parameters:
  3079. @var{filter_name}[:=]@var{filter_params}
  3080. @var{filter_name} is the name of a supported MPlayer filter,
  3081. @var{filter_params} is a string containing the parameters accepted by
  3082. the named filter.
  3083. The list of the currently supported filters follows:
  3084. @table @var
  3085. @item detc
  3086. @item dint
  3087. @item divtc
  3088. @item down3dright
  3089. @item eq2
  3090. @item eq
  3091. @item fil
  3092. @item fspp
  3093. @item ilpack
  3094. @item ivtc
  3095. @item mcdeint
  3096. @item ow
  3097. @item perspective
  3098. @item phase
  3099. @item pp7
  3100. @item pullup
  3101. @item qp
  3102. @item sab
  3103. @item softpulldown
  3104. @item spp
  3105. @item telecine
  3106. @item tinterlace
  3107. @item uspp
  3108. @end table
  3109. The parameter syntax and behavior for the listed filters are the same
  3110. of the corresponding MPlayer filters. For detailed instructions check
  3111. the "VIDEO FILTERS" section in the MPlayer manual.
  3112. @subsection Examples
  3113. @itemize
  3114. @item
  3115. Adjust gamma, brightness, contrast:
  3116. @example
  3117. mp=eq2=1.0:2:0.5
  3118. @end example
  3119. @end itemize
  3120. See also mplayer(1), @url{http://www.mplayerhq.hu/}.
  3121. @section negate
  3122. Negate input video.
  3123. This filter accepts an integer in input, if non-zero it negates the
  3124. alpha component (if available). The default value in input is 0.
  3125. @section noformat
  3126. Force libavfilter not to use any of the specified pixel formats for the
  3127. input to the next filter.
  3128. This filter accepts the following parameters:
  3129. @table @option
  3130. @item pix_fmts
  3131. A '|'-separated list of pixel format names, for example
  3132. "pix_fmts=yuv420p|monow|rgb24".
  3133. @end table
  3134. @subsection Examples
  3135. @itemize
  3136. @item
  3137. Force libavfilter to use a format different from @var{yuv420p} for the
  3138. input to the vflip filter:
  3139. @example
  3140. noformat=pix_fmts=yuv420p,vflip
  3141. @end example
  3142. @item
  3143. Convert the input video to any of the formats not contained in the list:
  3144. @example
  3145. noformat=yuv420p|yuv444p|yuv410p
  3146. @end example
  3147. @end itemize
  3148. @section noise
  3149. Add noise on video input frame.
  3150. This filter accepts a list of options in the form of @var{key}=@var{value}
  3151. pairs separated by ":". A description of the accepted options follows.
  3152. @table @option
  3153. @item all_seed
  3154. @item c0_seed
  3155. @item c1_seed
  3156. @item c2_seed
  3157. @item c3_seed
  3158. Set noise seed for specific pixel component or all pixel components in case
  3159. of @var{all_seed}. Default value is @code{123457}.
  3160. @item all_strength, alls
  3161. @item c0_strength, c0s
  3162. @item c1_strength, c1s
  3163. @item c2_strength, c2s
  3164. @item c3_strength, c3s
  3165. Set noise strength for specific pixel component or all pixel components in case
  3166. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  3167. @item all_flags, allf
  3168. @item c0_flags, c0f
  3169. @item c1_flags, c1f
  3170. @item c2_flags, c2f
  3171. @item c3_flags, c3f
  3172. Set pixel component flags or set flags for all components if @var{all_flags}.
  3173. Available values for component flags are:
  3174. @table @samp
  3175. @item a
  3176. averaged temporal noise (smoother)
  3177. @item p
  3178. mix random noise with a (semi)regular pattern
  3179. @item q
  3180. higher quality (slightly better looking, slightly slower)
  3181. @item t
  3182. temporal noise (noise pattern changes between frames)
  3183. @item u
  3184. uniform noise (gaussian otherwise)
  3185. @end table
  3186. @end table
  3187. @subsection Examples
  3188. Add temporal and uniform noise to input video:
  3189. @example
  3190. noise=alls=20:allf=t+u
  3191. @end example
  3192. @section null
  3193. Pass the video source unchanged to the output.
  3194. @section ocv
  3195. Apply video transform using libopencv.
  3196. To enable this filter install libopencv library and headers and
  3197. configure FFmpeg with @code{--enable-libopencv}.
  3198. The filter takes the parameters: @var{filter_name}@{:=@}@var{filter_params}.
  3199. @var{filter_name} is the name of the libopencv filter to apply.
  3200. @var{filter_params} specifies the parameters to pass to the libopencv
  3201. filter. If not specified the default values are assumed.
  3202. Refer to the official libopencv documentation for more precise
  3203. information:
  3204. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  3205. Follows the list of supported libopencv filters.
  3206. @anchor{dilate}
  3207. @subsection dilate
  3208. Dilate an image by using a specific structuring element.
  3209. This filter corresponds to the libopencv function @code{cvDilate}.
  3210. It accepts the parameters: @var{struct_el}:@var{nb_iterations}.
  3211. @var{struct_el} represents a structuring element, and has the syntax:
  3212. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  3213. @var{cols} and @var{rows} represent the number of columns and rows of
  3214. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  3215. point, and @var{shape} the shape for the structuring element, and
  3216. can be one of the values "rect", "cross", "ellipse", "custom".
  3217. If the value for @var{shape} is "custom", it must be followed by a
  3218. string of the form "=@var{filename}". The file with name
  3219. @var{filename} is assumed to represent a binary image, with each
  3220. printable character corresponding to a bright pixel. When a custom
  3221. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  3222. or columns and rows of the read file are assumed instead.
  3223. The default value for @var{struct_el} is "3x3+0x0/rect".
  3224. @var{nb_iterations} specifies the number of times the transform is
  3225. applied to the image, and defaults to 1.
  3226. Follow some example:
  3227. @example
  3228. # use the default values
  3229. ocv=dilate
  3230. # dilate using a structuring element with a 5x5 cross, iterate two times
  3231. ocv=dilate=5x5+2x2/cross:2
  3232. # read the shape from the file diamond.shape, iterate two times
  3233. # the file diamond.shape may contain a pattern of characters like this:
  3234. # *
  3235. # ***
  3236. # *****
  3237. # ***
  3238. # *
  3239. # the specified cols and rows are ignored (but not the anchor point coordinates)
  3240. ocv=0x0+2x2/custom=diamond.shape:2
  3241. @end example
  3242. @subsection erode
  3243. Erode an image by using a specific structuring element.
  3244. This filter corresponds to the libopencv function @code{cvErode}.
  3245. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
  3246. with the same syntax and semantics as the @ref{dilate} filter.
  3247. @subsection smooth
  3248. Smooth the input video.
  3249. The filter takes the following parameters:
  3250. @var{type}:@var{param1}:@var{param2}:@var{param3}:@var{param4}.
  3251. @var{type} is the type of smooth filter to apply, and can be one of
  3252. the following values: "blur", "blur_no_scale", "median", "gaussian",
  3253. "bilateral". The default value is "gaussian".
  3254. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  3255. parameters whose meanings depend on smooth type. @var{param1} and
  3256. @var{param2} accept integer positive values or 0, @var{param3} and
  3257. @var{param4} accept float values.
  3258. The default value for @var{param1} is 3, the default value for the
  3259. other parameters is 0.
  3260. These parameters correspond to the parameters assigned to the
  3261. libopencv function @code{cvSmooth}.
  3262. @anchor{overlay}
  3263. @section overlay
  3264. Overlay one video on top of another.
  3265. It takes two inputs and one output, the first input is the "main"
  3266. video on which the second input is overlayed.
  3267. This filter accepts a list of @var{key}=@var{value} pairs as argument,
  3268. separated by ":". If the key of the first options is omitted, the
  3269. arguments are interpreted according to the syntax @var{x}:@var{y}.
  3270. A description of the accepted options follows.
  3271. @table @option
  3272. @item x
  3273. @item y
  3274. Set the expression for the x and y coordinates of the overlayed video
  3275. on the main video. Default value is "0" for both expressions. In case
  3276. the expression is invalid, it is set to a huge value (meaning that the
  3277. overlay will not be displayed within the output visible area).
  3278. @item enable
  3279. Set the expression which enables the overlay. If the evaluation is
  3280. different from 0, the overlay is displayed on top of the input
  3281. frame. By default it is "1".
  3282. @item eval
  3283. Set when the expressions for @option{x}, @option{y}, and
  3284. @option{enable} are evaluated.
  3285. It accepts the following values:
  3286. @table @samp
  3287. @item init
  3288. only evaluate expressions once during the filter initialization or
  3289. when a command is processed
  3290. @item frame
  3291. evaluate expressions for each incoming frame
  3292. @end table
  3293. Default value is @samp{frame}.
  3294. @item shortest
  3295. If set to 1, force the output to terminate when the shortest input
  3296. terminates. Default value is 0.
  3297. @item format
  3298. Set the format for the output video.
  3299. It accepts the following values:
  3300. @table @samp
  3301. @item yuv420
  3302. force YUV420 output
  3303. @item yuv444
  3304. force YUV444 output
  3305. @item rgb
  3306. force RGB output
  3307. @end table
  3308. Default value is @samp{yuv420}.
  3309. @item rgb @emph{(deprecated)}
  3310. If set to 1, force the filter to accept inputs in the RGB
  3311. color space. Default value is 0. This option is deprecated, use
  3312. @option{format} instead.
  3313. @end table
  3314. The @option{x}, @option{y}, and @option{enable} expressions can
  3315. contain the following parameters.
  3316. @table @option
  3317. @item main_w, W
  3318. @item main_h, H
  3319. main input width and height
  3320. @item overlay_w, w
  3321. @item overlay_h, h
  3322. overlay input width and height
  3323. @item x
  3324. @item y
  3325. the computed values for @var{x} and @var{y}. They are evaluated for
  3326. each new frame.
  3327. @item hsub
  3328. @item vsub
  3329. horizontal and vertical chroma subsample values of the output
  3330. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  3331. @var{vsub} is 1.
  3332. @item n
  3333. the number of input frame, starting from 0
  3334. @item pos
  3335. the position in the file of the input frame, NAN if unknown
  3336. @item t
  3337. timestamp expressed in seconds, NAN if the input timestamp is unknown
  3338. @end table
  3339. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  3340. when evaluation is done @emph{per frame}, and will evaluate to NAN
  3341. when @option{eval} is set to @samp{init}.
  3342. Be aware that frames are taken from each input video in timestamp
  3343. order, hence, if their initial timestamps differ, it is a a good idea
  3344. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  3345. have them begin in the same zero timestamp, as it does the example for
  3346. the @var{movie} filter.
  3347. You can chain together more overlays but you should test the
  3348. efficiency of such approach.
  3349. @subsection Commands
  3350. This filter supports the following command:
  3351. @table @option
  3352. @item x
  3353. Set the @option{x} option expression.
  3354. @item y
  3355. Set the @option{y} option expression.
  3356. @item enable
  3357. Set the @option{enable} option expression.
  3358. @end table
  3359. @subsection Examples
  3360. @itemize
  3361. @item
  3362. Draw the overlay at 10 pixels from the bottom right corner of the main
  3363. video:
  3364. @example
  3365. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  3366. @end example
  3367. Using named options the example above becomes:
  3368. @example
  3369. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  3370. @end example
  3371. @item
  3372. Insert a transparent PNG logo in the bottom left corner of the input,
  3373. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  3374. @example
  3375. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  3376. @end example
  3377. @item
  3378. Insert 2 different transparent PNG logos (second logo on bottom
  3379. right corner) using the @command{ffmpeg} tool:
  3380. @example
  3381. ffmpeg -i input -i logo1 -i logo2 -filter_complex 'overlay=10:H-h-10,overlay=W-w-10:H-h-10' output
  3382. @end example
  3383. @item
  3384. Add a transparent color layer on top of the main video, @code{WxH}
  3385. must specify the size of the main input to the overlay filter:
  3386. @example
  3387. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  3388. @end example
  3389. @item
  3390. Play an original video and a filtered version (here with the deshake
  3391. filter) side by side using the @command{ffplay} tool:
  3392. @example
  3393. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  3394. @end example
  3395. The above command is the same as:
  3396. @example
  3397. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  3398. @end example
  3399. @item
  3400. Make a sliding overlay appearing from the left to the right top part of the
  3401. screen starting since time 2:
  3402. @example
  3403. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  3404. @end example
  3405. @item
  3406. Compose output by putting two input videos side to side:
  3407. @example
  3408. ffmpeg -i left.avi -i right.avi -filter_complex "
  3409. nullsrc=size=200x100 [background];
  3410. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  3411. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  3412. [background][left] overlay=shortest=1 [background+left];
  3413. [background+left][right] overlay=shortest=1:x=100 [left+right]
  3414. "
  3415. @end example
  3416. @item
  3417. Chain several overlays in cascade:
  3418. @example
  3419. nullsrc=s=200x200 [bg];
  3420. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  3421. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  3422. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  3423. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  3424. [in3] null, [mid2] overlay=100:100 [out0]
  3425. @end example
  3426. @end itemize
  3427. @section pad
  3428. Add paddings to the input image, and place the original input at the
  3429. given coordinates @var{x}, @var{y}.
  3430. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  3431. separated by ":".
  3432. If the key of the first options is omitted, the arguments are
  3433. interpreted according to the syntax
  3434. @var{width}:@var{height}:@var{x}:@var{y}:@var{color}.
  3435. A description of the accepted options follows.
  3436. @table @option
  3437. @item width, w
  3438. @item height, h
  3439. Specify an expression for the size of the output image with the
  3440. paddings added. If the value for @var{width} or @var{height} is 0, the
  3441. corresponding input size is used for the output.
  3442. The @var{width} expression can reference the value set by the
  3443. @var{height} expression, and vice versa.
  3444. The default value of @var{width} and @var{height} is 0.
  3445. @item x
  3446. @item y
  3447. Specify an expression for the offsets where to place the input image
  3448. in the padded area with respect to the top/left border of the output
  3449. image.
  3450. The @var{x} expression can reference the value set by the @var{y}
  3451. expression, and vice versa.
  3452. The default value of @var{x} and @var{y} is 0.
  3453. @item color
  3454. Specify the color of the padded area, it can be the name of a color
  3455. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  3456. The default value of @var{color} is "black".
  3457. @end table
  3458. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  3459. options are expressions containing the following constants:
  3460. @table @option
  3461. @item in_w, in_h
  3462. the input video width and height
  3463. @item iw, ih
  3464. same as @var{in_w} and @var{in_h}
  3465. @item out_w, out_h
  3466. the output width and height, that is the size of the padded area as
  3467. specified by the @var{width} and @var{height} expressions
  3468. @item ow, oh
  3469. same as @var{out_w} and @var{out_h}
  3470. @item x, y
  3471. x and y offsets as specified by the @var{x} and @var{y}
  3472. expressions, or NAN if not yet specified
  3473. @item a
  3474. same as @var{iw} / @var{ih}
  3475. @item sar
  3476. input sample aspect ratio
  3477. @item dar
  3478. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  3479. @item hsub, vsub
  3480. horizontal and vertical chroma subsample values. For example for the
  3481. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3482. @end table
  3483. @subsection Examples
  3484. @itemize
  3485. @item
  3486. Add paddings with color "violet" to the input video. Output video
  3487. size is 640x480, the top-left corner of the input video is placed at
  3488. column 0, row 40:
  3489. @example
  3490. pad=640:480:0:40:violet
  3491. @end example
  3492. The example above is equivalent to the following command:
  3493. @example
  3494. pad=width=640:height=480:x=0:y=40:color=violet
  3495. @end example
  3496. @item
  3497. Pad the input to get an output with dimensions increased by 3/2,
  3498. and put the input video at the center of the padded area:
  3499. @example
  3500. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  3501. @end example
  3502. @item
  3503. Pad the input to get a squared output with size equal to the maximum
  3504. value between the input width and height, and put the input video at
  3505. the center of the padded area:
  3506. @example
  3507. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  3508. @end example
  3509. @item
  3510. Pad the input to get a final w/h ratio of 16:9:
  3511. @example
  3512. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  3513. @end example
  3514. @item
  3515. In case of anamorphic video, in order to set the output display aspect
  3516. correctly, it is necessary to use @var{sar} in the expression,
  3517. according to the relation:
  3518. @example
  3519. (ih * X / ih) * sar = output_dar
  3520. X = output_dar / sar
  3521. @end example
  3522. Thus the previous example needs to be modified to:
  3523. @example
  3524. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  3525. @end example
  3526. @item
  3527. Double output size and put the input video in the bottom-right
  3528. corner of the output padded area:
  3529. @example
  3530. pad="2*iw:2*ih:ow-iw:oh-ih"
  3531. @end example
  3532. @end itemize
  3533. @section pixdesctest
  3534. Pixel format descriptor test filter, mainly useful for internal
  3535. testing. The output video should be equal to the input video.
  3536. For example:
  3537. @example
  3538. format=monow, pixdesctest
  3539. @end example
  3540. can be used to test the monowhite pixel format descriptor definition.
  3541. @section pp
  3542. Enable the specified chain of postprocessing subfilters using libpostproc. This
  3543. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  3544. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  3545. Each subfilter and some options have a short and a long name that can be used
  3546. interchangeably, i.e. dr/dering are the same.
  3547. All subfilters share common options to determine their scope:
  3548. @table @option
  3549. @item a/autoq
  3550. Honor the quality commands for this subfilter.
  3551. @item c/chrom
  3552. Do chrominance filtering, too (default).
  3553. @item y/nochrom
  3554. Do luminance filtering only (no chrominance).
  3555. @item n/noluma
  3556. Do chrominance filtering only (no luminance).
  3557. @end table
  3558. These options can be appended after the subfilter name, separated by a ':'.
  3559. Available subfilters are:
  3560. @table @option
  3561. @item hb/hdeblock[:difference[:flatness]]
  3562. Horizontal deblocking filter
  3563. @table @option
  3564. @item difference
  3565. Difference factor where higher values mean more deblocking (default: @code{32}).
  3566. @item flatness
  3567. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  3568. @end table
  3569. @item vb/vdeblock[:difference[:flatness]]
  3570. Vertical deblocking filter
  3571. @table @option
  3572. @item difference
  3573. Difference factor where higher values mean more deblocking (default: @code{32}).
  3574. @item flatness
  3575. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  3576. @end table
  3577. @item ha/hadeblock[:difference[:flatness]]
  3578. Accurate horizontal deblocking filter
  3579. @table @option
  3580. @item difference
  3581. Difference factor where higher values mean more deblocking (default: @code{32}).
  3582. @item flatness
  3583. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  3584. @end table
  3585. @item va/vadeblock[:difference[:flatness]]
  3586. Accurate vertical deblocking filter
  3587. @table @option
  3588. @item difference
  3589. Difference factor where higher values mean more deblocking (default: @code{32}).
  3590. @item flatness
  3591. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  3592. @end table
  3593. @end table
  3594. The horizontal and vertical deblocking filters share the difference and
  3595. flatness values so you cannot set different horizontal and vertical
  3596. thresholds.
  3597. @table @option
  3598. @item h1/x1hdeblock
  3599. Experimental horizontal deblocking filter
  3600. @item v1/x1vdeblock
  3601. Experimental vertical deblocking filter
  3602. @item dr/dering
  3603. Deringing filter
  3604. @item tn/tmpnoise[:threshold1[:threshold2[:threshold3]]], temporal noise reducer
  3605. @table @option
  3606. @item threshold1
  3607. larger -> stronger filtering
  3608. @item threshold2
  3609. larger -> stronger filtering
  3610. @item threshold3
  3611. larger -> stronger filtering
  3612. @end table
  3613. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  3614. @table @option
  3615. @item f/fullyrange
  3616. Stretch luminance to @code{0-255}.
  3617. @end table
  3618. @item lb/linblenddeint
  3619. Linear blend deinterlacing filter that deinterlaces the given block by
  3620. filtering all lines with a @code{(1 2 1)} filter.
  3621. @item li/linipoldeint
  3622. Linear interpolating deinterlacing filter that deinterlaces the given block by
  3623. linearly interpolating every second line.
  3624. @item ci/cubicipoldeint
  3625. Cubic interpolating deinterlacing filter deinterlaces the given block by
  3626. cubically interpolating every second line.
  3627. @item md/mediandeint
  3628. Median deinterlacing filter that deinterlaces the given block by applying a
  3629. median filter to every second line.
  3630. @item fd/ffmpegdeint
  3631. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  3632. second line with a @code{(-1 4 2 4 -1)} filter.
  3633. @item l5/lowpass5
  3634. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  3635. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  3636. @item fq/forceQuant[:quantizer]
  3637. Overrides the quantizer table from the input with the constant quantizer you
  3638. specify.
  3639. @table @option
  3640. @item quantizer
  3641. Quantizer to use
  3642. @end table
  3643. @item de/default
  3644. Default pp filter combination (@code{hb:a,vb:a,dr:a})
  3645. @item fa/fast
  3646. Fast pp filter combination (@code{h1:a,v1:a,dr:a})
  3647. @item ac
  3648. High quality pp filter combination (@code{ha:a:128:7,va:a,dr:a})
  3649. @end table
  3650. @subsection Examples
  3651. @itemize
  3652. @item
  3653. Apply horizontal and vertical deblocking, deringing and automatic
  3654. brightness/contrast:
  3655. @example
  3656. pp=hb/vb/dr/al
  3657. @end example
  3658. @item
  3659. Apply default filters without brightness/contrast correction:
  3660. @example
  3661. pp=de/-al
  3662. @end example
  3663. @item
  3664. Apply default filters and temporal denoiser:
  3665. @example
  3666. pp=default/tmpnoise:1:2:3
  3667. @end example
  3668. @item
  3669. Apply deblocking on luminance only, and switch vertical deblocking on or off
  3670. automatically depending on available CPU time:
  3671. @example
  3672. pp=hb:y/vb:a
  3673. @end example
  3674. @end itemize
  3675. @section removelogo
  3676. Suppress a TV station logo, using an image file to determine which
  3677. pixels comprise the logo. It works by filling in the pixels that
  3678. comprise the logo with neighboring pixels.
  3679. This filter requires one argument which specifies the filter bitmap
  3680. file, which can be any image format supported by libavformat. The
  3681. width and height of the image file must match those of the video
  3682. stream being processed.
  3683. Pixels in the provided bitmap image with a value of zero are not
  3684. considered part of the logo, non-zero pixels are considered part of
  3685. the logo. If you use white (255) for the logo and black (0) for the
  3686. rest, you will be safe. For making the filter bitmap, it is
  3687. recommended to take a screen capture of a black frame with the logo
  3688. visible, and then using a threshold filter followed by the erode
  3689. filter once or twice.
  3690. If needed, little splotches can be fixed manually. Remember that if
  3691. logo pixels are not covered, the filter quality will be much
  3692. reduced. Marking too many pixels as part of the logo does not hurt as
  3693. much, but it will increase the amount of blurring needed to cover over
  3694. the image and will destroy more information than necessary, and extra
  3695. pixels will slow things down on a large logo.
  3696. @section scale
  3697. Scale (resize) the input video, using the libswscale library.
  3698. The scale filter forces the output display aspect ratio to be the same
  3699. of the input, by changing the output sample aspect ratio.
  3700. This filter accepts a list of named options in the form of
  3701. @var{key}=@var{value} pairs separated by ":". If the key for the first
  3702. two options is not specified, the assumed keys for the first two
  3703. values are @code{w} and @code{h}. If the first option has no key and
  3704. can be interpreted like a video size specification, it will be used
  3705. to set the video size.
  3706. A description of the accepted options follows.
  3707. @table @option
  3708. @item width, w
  3709. Set the video width expression, default value is @code{iw}. See below
  3710. for the list of accepted constants.
  3711. @item height, h
  3712. Set the video heiht expression, default value is @code{ih}.
  3713. See below for the list of accepted constants.
  3714. @item interl
  3715. Set the interlacing. It accepts the following values:
  3716. @table @option
  3717. @item 1
  3718. force interlaced aware scaling
  3719. @item 0
  3720. do not apply interlaced scaling
  3721. @item -1
  3722. select interlaced aware scaling depending on whether the source frames
  3723. are flagged as interlaced or not
  3724. @end table
  3725. Default value is @code{0}.
  3726. @item flags
  3727. Set libswscale scaling flags. If not explictly specified the filter
  3728. applies a bilinear scaling algorithm.
  3729. @item size, s
  3730. Set the video size, the value must be a valid abbreviation or in the
  3731. form @var{width}x@var{height}.
  3732. @end table
  3733. The values of the @var{w} and @var{h} options are expressions
  3734. containing the following constants:
  3735. @table @option
  3736. @item in_w, in_h
  3737. the input width and height
  3738. @item iw, ih
  3739. same as @var{in_w} and @var{in_h}
  3740. @item out_w, out_h
  3741. the output (cropped) width and height
  3742. @item ow, oh
  3743. same as @var{out_w} and @var{out_h}
  3744. @item a
  3745. same as @var{iw} / @var{ih}
  3746. @item sar
  3747. input sample aspect ratio
  3748. @item dar
  3749. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  3750. @item hsub, vsub
  3751. horizontal and vertical chroma subsample values. For example for the
  3752. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3753. @end table
  3754. If the input image format is different from the format requested by
  3755. the next filter, the scale filter will convert the input to the
  3756. requested format.
  3757. If the value for @var{width} or @var{height} is 0, the respective input
  3758. size is used for the output.
  3759. If the value for @var{width} or @var{height} is -1, the scale filter will
  3760. use, for the respective output size, a value that maintains the aspect
  3761. ratio of the input image.
  3762. @subsection Examples
  3763. @itemize
  3764. @item
  3765. Scale the input video to a size of 200x100:
  3766. @example
  3767. scale=200:100
  3768. @end example
  3769. This is equivalent to:
  3770. @example
  3771. scale=w=200:h=100
  3772. @end example
  3773. or:
  3774. @example
  3775. scale=200x100
  3776. @end example
  3777. @item
  3778. Specify a size abbreviation for the output size:
  3779. @example
  3780. scale=qcif
  3781. @end example
  3782. which can also be written as:
  3783. @example
  3784. scale=size=qcif
  3785. @end example
  3786. @item
  3787. Scale the input to 2x:
  3788. @example
  3789. scale=2*iw:2*ih
  3790. @end example
  3791. @item
  3792. The above is the same as:
  3793. @example
  3794. scale=2*in_w:2*in_h
  3795. @end example
  3796. @item
  3797. Scale the input to 2x with forced interlaced scaling:
  3798. @example
  3799. scale=2*iw:2*ih:interl=1
  3800. @end example
  3801. @item
  3802. Scale the input to half size:
  3803. @example
  3804. scale=iw/2:ih/2
  3805. @end example
  3806. @item
  3807. Increase the width, and set the height to the same size:
  3808. @example
  3809. scale=3/2*iw:ow
  3810. @end example
  3811. @item
  3812. Seek for Greek harmony:
  3813. @example
  3814. scale=iw:1/PHI*iw
  3815. scale=ih*PHI:ih
  3816. @end example
  3817. @item
  3818. Increase the height, and set the width to 3/2 of the height:
  3819. @example
  3820. scale=3/2*oh:3/5*ih
  3821. @end example
  3822. @item
  3823. Increase the size, but make the size a multiple of the chroma
  3824. subsample values:
  3825. @example
  3826. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  3827. @end example
  3828. @item
  3829. Increase the width to a maximum of 500 pixels, keep the same input
  3830. aspect ratio:
  3831. @example
  3832. scale='min(500\, iw*3/2):-1'
  3833. @end example
  3834. @end itemize
  3835. @section separatefields
  3836. The @code{separatefields} takes a frame-based video input and splits
  3837. each frame into its components fields, producing a new half height clip
  3838. with twice the frame rate and twice the frame count.
  3839. This filter use field-dominance information in frame to decide which
  3840. of each pair of fields to place first in the output.
  3841. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  3842. @section setdar, setsar
  3843. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  3844. output video.
  3845. This is done by changing the specified Sample (aka Pixel) Aspect
  3846. Ratio, according to the following equation:
  3847. @example
  3848. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  3849. @end example
  3850. Keep in mind that the @code{setdar} filter does not modify the pixel
  3851. dimensions of the video frame. Also the display aspect ratio set by
  3852. this filter may be changed by later filters in the filterchain,
  3853. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  3854. applied.
  3855. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  3856. the filter output video.
  3857. Note that as a consequence of the application of this filter, the
  3858. output display aspect ratio will change according to the equation
  3859. above.
  3860. Keep in mind that the sample aspect ratio set by the @code{setsar}
  3861. filter may be changed by later filters in the filterchain, e.g. if
  3862. another "setsar" or a "setdar" filter is applied.
  3863. The @code{setdar} and @code{setsar} filters accept a string in the
  3864. form @var{num}:@var{den} expressing an aspect ratio, or the following
  3865. named options, expressed as a sequence of @var{key}=@var{value} pairs,
  3866. separated by ":".
  3867. @table @option
  3868. @item max
  3869. Set the maximum integer value to use for expressing numerator and
  3870. denominator when reducing the expressed aspect ratio to a rational.
  3871. Default value is @code{100}.
  3872. @item r, ratio:
  3873. Set the aspect ratio used by the filter.
  3874. The parameter can be a floating point number string, an expression, or
  3875. a string of the form @var{num}:@var{den}, where @var{num} and
  3876. @var{den} are the numerator and denominator of the aspect ratio. If
  3877. the parameter is not specified, it is assumed the value "0".
  3878. In case the form "@var{num}:@var{den}" the @code{:} character should
  3879. be escaped.
  3880. @end table
  3881. If the keys are omitted in the named options list, the specifed values
  3882. are assumed to be @var{ratio} and @var{max} in that order.
  3883. For example to change the display aspect ratio to 16:9, specify:
  3884. @example
  3885. setdar='16:9'
  3886. @end example
  3887. The example above is equivalent to:
  3888. @example
  3889. setdar=1.77777
  3890. @end example
  3891. To change the sample aspect ratio to 10:11, specify:
  3892. @example
  3893. setsar='10:11'
  3894. @end example
  3895. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  3896. 1000 in the aspect ratio reduction, use the command:
  3897. @example
  3898. setdar=ratio='16:9':max=1000
  3899. @end example
  3900. @anchor{setfield}
  3901. @section setfield
  3902. Force field for the output video frame.
  3903. The @code{setfield} filter marks the interlace type field for the
  3904. output frames. It does not change the input frame, but only sets the
  3905. corresponding property, which affects how the frame is treated by
  3906. following filters (e.g. @code{fieldorder} or @code{yadif}).
  3907. This filter accepts a single option @option{mode}, which can be
  3908. specified either by setting @code{mode=VALUE} or setting the value
  3909. alone. Available values are:
  3910. @table @samp
  3911. @item auto
  3912. Keep the same field property.
  3913. @item bff
  3914. Mark the frame as bottom-field-first.
  3915. @item tff
  3916. Mark the frame as top-field-first.
  3917. @item prog
  3918. Mark the frame as progressive.
  3919. @end table
  3920. @section showinfo
  3921. Show a line containing various information for each input video frame.
  3922. The input video is not modified.
  3923. The shown line contains a sequence of key/value pairs of the form
  3924. @var{key}:@var{value}.
  3925. A description of each shown parameter follows:
  3926. @table @option
  3927. @item n
  3928. sequential number of the input frame, starting from 0
  3929. @item pts
  3930. Presentation TimeStamp of the input frame, expressed as a number of
  3931. time base units. The time base unit depends on the filter input pad.
  3932. @item pts_time
  3933. Presentation TimeStamp of the input frame, expressed as a number of
  3934. seconds
  3935. @item pos
  3936. position of the frame in the input stream, -1 if this information in
  3937. unavailable and/or meaningless (for example in case of synthetic video)
  3938. @item fmt
  3939. pixel format name
  3940. @item sar
  3941. sample aspect ratio of the input frame, expressed in the form
  3942. @var{num}/@var{den}
  3943. @item s
  3944. size of the input frame, expressed in the form
  3945. @var{width}x@var{height}
  3946. @item i
  3947. interlaced mode ("P" for "progressive", "T" for top field first, "B"
  3948. for bottom field first)
  3949. @item iskey
  3950. 1 if the frame is a key frame, 0 otherwise
  3951. @item type
  3952. picture type of the input frame ("I" for an I-frame, "P" for a
  3953. P-frame, "B" for a B-frame, "?" for unknown type).
  3954. Check also the documentation of the @code{AVPictureType} enum and of
  3955. the @code{av_get_picture_type_char} function defined in
  3956. @file{libavutil/avutil.h}.
  3957. @item checksum
  3958. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  3959. @item plane_checksum
  3960. Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  3961. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]"
  3962. @end table
  3963. @section smartblur
  3964. Blur the input video without impacting the outlines.
  3965. This filter accepts parameters as a list of @var{key}=@var{value} pairs,
  3966. separated by ":".
  3967. If the key of the first options is omitted, the arguments are
  3968. interpreted according to the syntax:
  3969. @var{luma_radius}:@var{luma_strength}:@var{luma_threshold}[:@var{chroma_radius}:@var{chroma_strength}:@var{chroma_threshold}]
  3970. A description of the accepted options follows.
  3971. @table @option
  3972. @item luma_radius, lr
  3973. @item chroma_radius, cr
  3974. Set the luma/chroma radius. The option value must be a float number in
  3975. the range [0.1,5.0] that specifies the variance of the gaussian filter
  3976. used to blur the image (slower if larger). Default value is 1.0.
  3977. @item luma_strength, ls
  3978. @item chroma_strength, cs
  3979. Set the luma/chroma strength. The option value must be a float number
  3980. in the range [-1.0,1.0] that configures the blurring. A value included
  3981. in [0.0,1.0] will blur the image whereas a value included in
  3982. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  3983. @item luma_threshold, lt
  3984. @item chroma_threshold, ct
  3985. Set the luma/chroma threshold used as a coefficient to determine
  3986. whether a pixel should be blurred or not. The option value must be an
  3987. integer in the range [-30,30]. A value of 0 will filter all the image,
  3988. a value included in [0,30] will filter flat areas and a value included
  3989. in [-30,0] will filter edges. Default value is 0.
  3990. @end table
  3991. If a chroma option is not explicitly set, the corresponding luma value
  3992. is set.
  3993. @section stereo3d
  3994. Convert between different stereoscopic image formats.
  3995. This filter accepts the following named options, expressed as a
  3996. sequence of @var{key}=@var{value} pairs, separated by ":".
  3997. @table @option
  3998. @item in
  3999. Set stereoscopic image format of input.
  4000. Available values for input image formats are:
  4001. @table @samp
  4002. @item sbsl
  4003. side by side parallel (left eye left, right eye right)
  4004. @item sbsr
  4005. side by side crosseye (right eye left, left eye right)
  4006. @item sbs2l
  4007. side by side parallel with half width resolution
  4008. (left eye left, right eye right)
  4009. @item sbs2r
  4010. side by side crosseye with half width resolution
  4011. (right eye left, left eye right)
  4012. @item abl
  4013. above-below (left eye above, right eye below)
  4014. @item abr
  4015. above-below (right eye above, left eye below)
  4016. @item ab2l
  4017. above-below with half height resolution
  4018. (left eye above, right eye below)
  4019. @item ab2r
  4020. above-below with half height resolution
  4021. (right eye above, left eye below)
  4022. Default value is @samp{sbsl}.
  4023. @end table
  4024. @item out
  4025. Set stereoscopic image format of output.
  4026. Available values for output image formats are all the input formats as well as:
  4027. @table @samp
  4028. @item arbg
  4029. anaglyph red/blue gray
  4030. (red filter on left eye, blue filter on right eye)
  4031. @item argg
  4032. anaglyph red/green gray
  4033. (red filter on left eye, green filter on right eye)
  4034. @item arcg
  4035. anaglyph red/cyan gray
  4036. (red filter on left eye, cyan filter on right eye)
  4037. @item arch
  4038. anaglyph red/cyan half colored
  4039. (red filter on left eye, cyan filter on right eye)
  4040. @item arcc
  4041. anaglyph red/cyan color
  4042. (red filter on left eye, cyan filter on right eye)
  4043. @item arcd
  4044. anaglyph red/cyan color optimized with the least squares projection of dubois
  4045. (red filter on left eye, cyan filter on right eye)
  4046. @item agmg
  4047. anaglyph green/magenta gray
  4048. (green filter on left eye, magenta filter on right eye)
  4049. @item agmh
  4050. anaglyph green/magenta half colored
  4051. (green filter on left eye, magenta filter on right eye)
  4052. @item agmc
  4053. anaglyph green/magenta colored
  4054. (green filter on left eye, magenta filter on right eye)
  4055. @item agmd
  4056. anaglyph green/magenta color optimized with the least squares projection of dubois
  4057. (green filter on left eye, magenta filter on right eye)
  4058. @item aybg
  4059. anaglyph yellow/blue gray
  4060. (yellow filter on left eye, blue filter on right eye)
  4061. @item aybh
  4062. anaglyph yellow/blue half colored
  4063. (yellow filter on left eye, blue filter on right eye)
  4064. @item aybc
  4065. anaglyph yellow/blue colored
  4066. (yellow filter on left eye, blue filter on right eye)
  4067. @item aybd
  4068. anaglyph yellow/blue color optimized with the least squares projection of dubois
  4069. (yellow filter on left eye, blue filter on right eye)
  4070. @item irl
  4071. interleaved rows (left eye has top row, right eye starts on next row)
  4072. @item irr
  4073. interleaved rows (right eye has top row, left eye starts on next row)
  4074. @item ml
  4075. mono output (left eye only)
  4076. @item mr
  4077. mono output (right eye only)
  4078. @end table
  4079. Default value is @samp{arcd}.
  4080. @end table
  4081. @anchor{subtitles}
  4082. @section subtitles
  4083. Draw subtitles on top of input video using the libass library.
  4084. To enable compilation of this filter you need to configure FFmpeg with
  4085. @code{--enable-libass}. This filter also requires a build with libavcodec and
  4086. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  4087. Alpha) subtitles format.
  4088. This filter accepts the following named options, expressed as a
  4089. sequence of @var{key}=@var{value} pairs, separated by ":".
  4090. @table @option
  4091. @item filename, f
  4092. Set the filename of the subtitle file to read. It must be specified.
  4093. @item original_size
  4094. Specify the size of the original video, the video for which the ASS file
  4095. was composed. Due to a misdesign in ASS aspect ratio arithmetic, this is
  4096. necessary to correctly scale the fonts if the aspect ratio has been changed.
  4097. @item charenc
  4098. Set subtitles input character encoding. @code{subtitles} filter only. Only
  4099. useful if not UTF-8.
  4100. @end table
  4101. If the first key is not specified, it is assumed that the first value
  4102. specifies the @option{filename}.
  4103. For example, to render the file @file{sub.srt} on top of the input
  4104. video, use the command:
  4105. @example
  4106. subtitles=sub.srt
  4107. @end example
  4108. which is equivalent to:
  4109. @example
  4110. subtitles=filename=sub.srt
  4111. @end example
  4112. @section split
  4113. Split input video into several identical outputs.
  4114. The filter accepts a single parameter which specifies the number of outputs. If
  4115. unspecified, it defaults to 2.
  4116. For example
  4117. @example
  4118. ffmpeg -i INPUT -filter_complex split=5 OUTPUT
  4119. @end example
  4120. will create 5 copies of the input video.
  4121. For example:
  4122. @example
  4123. [in] split [splitout1][splitout2];
  4124. [splitout1] crop=100:100:0:0 [cropout];
  4125. [splitout2] pad=200:200:100:100 [padout];
  4126. @end example
  4127. will create two separate outputs from the same input, one cropped and
  4128. one padded.
  4129. @section super2xsai
  4130. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  4131. Interpolate) pixel art scaling algorithm.
  4132. Useful for enlarging pixel art images without reducing sharpness.
  4133. @section swapuv
  4134. Swap U & V plane.
  4135. @section thumbnail
  4136. Select the most representative frame in a given sequence of consecutive frames.
  4137. The filter accepts parameters as a list of @var{key}=@var{value}
  4138. pairs, separated by ":". If the key of the first options is omitted,
  4139. the arguments are interpreted according to the syntax
  4140. thumbnail[=@var{n}].
  4141. @table @option
  4142. @item n
  4143. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  4144. will pick one of them, and then handle the next batch of @var{n} frames until
  4145. the end. Default is @code{100}.
  4146. @end table
  4147. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  4148. value will result in a higher memory usage, so a high value is not recommended.
  4149. @subsection Examples
  4150. @itemize
  4151. @item
  4152. Extract one picture each 50 frames:
  4153. @example
  4154. thumbnail=50
  4155. @end example
  4156. @item
  4157. Complete example of a thumbnail creation with @command{ffmpeg}:
  4158. @example
  4159. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  4160. @end example
  4161. @end itemize
  4162. @section tile
  4163. Tile several successive frames together.
  4164. It accepts a list of options in the form of @var{key}=@var{value} pairs
  4165. separated by ":". A description of the accepted options follows.
  4166. @table @option
  4167. @item layout
  4168. Set the grid size (i.e. the number of lines and columns) in the form
  4169. "@var{w}x@var{h}".
  4170. @item margin
  4171. Set the outer border margin in pixels.
  4172. @item padding
  4173. Set the inner border thickness (i.e. the number of pixels between frames). For
  4174. more advanced padding options (such as having different values for the edges),
  4175. refer to the pad video filter.
  4176. @item nb_frames
  4177. Set the maximum number of frames to render in the given area. It must be less
  4178. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  4179. the area will be used.
  4180. @end table
  4181. Alternatively, the options can be specified as a flat string:
  4182. @var{layout}[:@var{nb_frames}[:@var{margin}[:@var{padding}]]]
  4183. For example, produce 8x8 PNG tiles of all keyframes (@option{-skip_frame
  4184. nokey}) in a movie:
  4185. @example
  4186. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  4187. @end example
  4188. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  4189. duplicating each output frame to accomodate the originally detected frame
  4190. rate.
  4191. Another example to display @code{5} pictures in an area of @code{3x2} frames,
  4192. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  4193. mixed flat and named options:
  4194. @example
  4195. tile=3x2:nb_frames=5:padding=7:margin=2
  4196. @end example
  4197. @section tinterlace
  4198. Perform various types of temporal field interlacing.
  4199. Frames are counted starting from 1, so the first input frame is
  4200. considered odd.
  4201. This filter accepts options in the form of @var{key}=@var{value} pairs
  4202. separated by ":".
  4203. Alternatively, the @var{mode} option can be specified as a value alone,
  4204. optionally followed by a ":" and further ":" separated @var{key}=@var{value}
  4205. pairs.
  4206. A description of the accepted options follows.
  4207. @table @option
  4208. @item mode
  4209. Specify the mode of the interlacing. This option can also be specified
  4210. as a value alone. See below for a list of values for this option.
  4211. Available values are:
  4212. @table @samp
  4213. @item merge, 0
  4214. Move odd frames into the upper field, even into the lower field,
  4215. generating a double height frame at half frame rate.
  4216. @item drop_odd, 1
  4217. Only output even frames, odd frames are dropped, generating a frame with
  4218. unchanged height at half frame rate.
  4219. @item drop_even, 2
  4220. Only output odd frames, even frames are dropped, generating a frame with
  4221. unchanged height at half frame rate.
  4222. @item pad, 3
  4223. Expand each frame to full height, but pad alternate lines with black,
  4224. generating a frame with double height at the same input frame rate.
  4225. @item interleave_top, 4
  4226. Interleave the upper field from odd frames with the lower field from
  4227. even frames, generating a frame with unchanged height at half frame rate.
  4228. @item interleave_bottom, 5
  4229. Interleave the lower field from odd frames with the upper field from
  4230. even frames, generating a frame with unchanged height at half frame rate.
  4231. @item interlacex2, 6
  4232. Double frame rate with unchanged height. Frames are inserted each
  4233. containing the second temporal field from the previous input frame and
  4234. the first temporal field from the next input frame. This mode relies on
  4235. the top_field_first flag. Useful for interlaced video displays with no
  4236. field synchronisation.
  4237. @end table
  4238. Numeric values are deprecated but are accepted for backward
  4239. compatibility reasons.
  4240. Default mode is @code{merge}.
  4241. @item flags
  4242. Specify flags influencing the filter process.
  4243. Available value for @var{flags} is:
  4244. @table @option
  4245. @item low_pass_filter, vlfp
  4246. Enable vertical low-pass filtering in the filter.
  4247. Vertical low-pass filtering is required when creating an interlaced
  4248. destination from a progressive source which contains high-frequency
  4249. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  4250. patterning.
  4251. Vertical low-pass filtering can only be enabled for @option{mode}
  4252. @var{interleave_top} and @var{interleave_bottom}.
  4253. @end table
  4254. @end table
  4255. @section transpose
  4256. Transpose rows with columns in the input video and optionally flip it.
  4257. The filter accepts parameters as a list of @var{key}=@var{value}
  4258. pairs, separated by ':'. If the key of the first options is omitted,
  4259. the arguments are interpreted according to the syntax
  4260. @var{dir}:@var{passthrough}.
  4261. @table @option
  4262. @item dir
  4263. Specify the transposition direction. Can assume the following values:
  4264. @table @samp
  4265. @item 0, 4
  4266. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  4267. @example
  4268. L.R L.l
  4269. . . -> . .
  4270. l.r R.r
  4271. @end example
  4272. @item 1, 5
  4273. Rotate by 90 degrees clockwise, that is:
  4274. @example
  4275. L.R l.L
  4276. . . -> . .
  4277. l.r r.R
  4278. @end example
  4279. @item 2, 6
  4280. Rotate by 90 degrees counterclockwise, that is:
  4281. @example
  4282. L.R R.r
  4283. . . -> . .
  4284. l.r L.l
  4285. @end example
  4286. @item 3, 7
  4287. Rotate by 90 degrees clockwise and vertically flip, that is:
  4288. @example
  4289. L.R r.R
  4290. . . -> . .
  4291. l.r l.L
  4292. @end example
  4293. @end table
  4294. For values between 4-7, the transposition is only done if the input
  4295. video geometry is portrait and not landscape. These values are
  4296. deprecated, the @code{passthrough} option should be used instead.
  4297. @item passthrough
  4298. Do not apply the transposition if the input geometry matches the one
  4299. specified by the specified value. It accepts the following values:
  4300. @table @samp
  4301. @item none
  4302. Always apply transposition.
  4303. @item portrait
  4304. Preserve portrait geometry (when @var{height} >= @var{width}).
  4305. @item landscape
  4306. Preserve landscape geometry (when @var{width} >= @var{height}).
  4307. @end table
  4308. Default value is @code{none}.
  4309. @end table
  4310. For example to rotate by 90 degrees clockwise and preserve portrait
  4311. layout:
  4312. @example
  4313. transpose=dir=1:passthrough=portrait
  4314. @end example
  4315. The command above can also be specified as:
  4316. @example
  4317. transpose=1:portrait
  4318. @end example
  4319. @section unsharp
  4320. Sharpen or blur the input video.
  4321. This filter accepts parameters as a list of @var{key}=@var{value} pairs,
  4322. separated by ":".
  4323. If the key of the first options is omitted, the arguments are
  4324. interpreted according to the syntax:
  4325. @var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount}
  4326. A description of the accepted options follows.
  4327. @table @option
  4328. @item luma_msize_x, lx
  4329. @item chroma_msize_x, cx
  4330. Set the luma/chroma matrix horizontal size. It must be an odd integer
  4331. between 3 and 63, default value is 5.
  4332. @item luma_msize_y, ly
  4333. @item chroma_msize_y, cy
  4334. Set the luma/chroma matrix vertical size. It must be an odd integer
  4335. between 3 and 63, default value is 5.
  4336. @item luma_amount, la
  4337. @item chroma_amount, ca
  4338. Set the luma/chroma effect strength. It can be a float number,
  4339. reasonable values lay between -1.5 and 1.5.
  4340. Negative values will blur the input video, while positive values will
  4341. sharpen it, a value of zero will disable the effect.
  4342. Default value is 1.0 for @option{luma_amount}, 0.0 for
  4343. @option{chroma_amount}.
  4344. @end table
  4345. @subsection Examples
  4346. @itemize
  4347. @item
  4348. Apply strong luma sharpen effect:
  4349. @example
  4350. unsharp=7:7:2.5
  4351. @end example
  4352. @item
  4353. Apply strong blur of both luma and chroma parameters:
  4354. @example
  4355. unsharp=7:7:-2:7:7:-2
  4356. @end example
  4357. @end itemize
  4358. @section vflip
  4359. Flip the input video vertically.
  4360. @example
  4361. ffmpeg -i in.avi -vf "vflip" out.avi
  4362. @end example
  4363. @section yadif
  4364. Deinterlace the input video ("yadif" means "yet another deinterlacing
  4365. filter").
  4366. The filter accepts parameters as a list of @var{key}=@var{value}
  4367. pairs, separated by ":". If the key of the first options is omitted,
  4368. the arguments are interpreted according to syntax
  4369. @var{mode}:@var{parity}:@var{deint}.
  4370. The description of the accepted parameters follows.
  4371. @table @option
  4372. @item mode
  4373. Specify the interlacing mode to adopt. Accept one of the following
  4374. values:
  4375. @table @option
  4376. @item 0, send_frame
  4377. output 1 frame for each frame
  4378. @item 1, send_field
  4379. output 1 frame for each field
  4380. @item 2, send_frame_nospatial
  4381. like @code{send_frame} but skip spatial interlacing check
  4382. @item 3, send_field_nospatial
  4383. like @code{send_field} but skip spatial interlacing check
  4384. @end table
  4385. Default value is @code{send_frame}.
  4386. @item parity
  4387. Specify the picture field parity assumed for the input interlaced
  4388. video. Accept one of the following values:
  4389. @table @option
  4390. @item 0, tff
  4391. assume top field first
  4392. @item 1, bff
  4393. assume bottom field first
  4394. @item -1, auto
  4395. enable automatic detection
  4396. @end table
  4397. Default value is @code{auto}.
  4398. If interlacing is unknown or decoder does not export this information,
  4399. top field first will be assumed.
  4400. @item deint
  4401. Specify which frames to deinterlace. Accept one of the following
  4402. values:
  4403. @table @option
  4404. @item 0, all
  4405. deinterlace all frames
  4406. @item 1, interlaced
  4407. only deinterlace frames marked as interlaced
  4408. @end table
  4409. Default value is @code{all}.
  4410. @end table
  4411. @c man end VIDEO FILTERS
  4412. @chapter Video Sources
  4413. @c man begin VIDEO SOURCES
  4414. Below is a description of the currently available video sources.
  4415. @section buffer
  4416. Buffer video frames, and make them available to the filter chain.
  4417. This source is mainly intended for a programmatic use, in particular
  4418. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  4419. It accepts a list of options in the form of @var{key}=@var{value} pairs
  4420. separated by ":". A description of the accepted options follows.
  4421. @table @option
  4422. @item video_size
  4423. Specify the size (width and height) of the buffered video frames.
  4424. @item pix_fmt
  4425. A string representing the pixel format of the buffered video frames.
  4426. It may be a number corresponding to a pixel format, or a pixel format
  4427. name.
  4428. @item time_base
  4429. Specify the timebase assumed by the timestamps of the buffered frames.
  4430. @item time_base
  4431. Specify the frame rate expected for the video stream.
  4432. @item pixel_aspect
  4433. Specify the sample aspect ratio assumed by the video frames.
  4434. @item sws_param
  4435. Specify the optional parameters to be used for the scale filter which
  4436. is automatically inserted when an input change is detected in the
  4437. input size or format.
  4438. @end table
  4439. For example:
  4440. @example
  4441. buffer=size=320x240:pix_fmt=yuv410p:time_base=1/24:pixel_aspect=1/1
  4442. @end example
  4443. will instruct the source to accept video frames with size 320x240 and
  4444. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  4445. square pixels (1:1 sample aspect ratio).
  4446. Since the pixel format with name "yuv410p" corresponds to the number 6
  4447. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  4448. this example corresponds to:
  4449. @example
  4450. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  4451. @end example
  4452. Alternatively, the options can be specified as a flat string, but this
  4453. syntax is deprecated:
  4454. @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}]
  4455. @section cellauto
  4456. Create a pattern generated by an elementary cellular automaton.
  4457. The initial state of the cellular automaton can be defined through the
  4458. @option{filename}, and @option{pattern} options. If such options are
  4459. not specified an initial state is created randomly.
  4460. At each new frame a new row in the video is filled with the result of
  4461. the cellular automaton next generation. The behavior when the whole
  4462. frame is filled is defined by the @option{scroll} option.
  4463. This source accepts a list of options in the form of
  4464. @var{key}=@var{value} pairs separated by ":". A description of the
  4465. accepted options follows.
  4466. @table @option
  4467. @item filename, f
  4468. Read the initial cellular automaton state, i.e. the starting row, from
  4469. the specified file.
  4470. In the file, each non-whitespace character is considered an alive
  4471. cell, a newline will terminate the row, and further characters in the
  4472. file will be ignored.
  4473. @item pattern, p
  4474. Read the initial cellular automaton state, i.e. the starting row, from
  4475. the specified string.
  4476. Each non-whitespace character in the string is considered an alive
  4477. cell, a newline will terminate the row, and further characters in the
  4478. string will be ignored.
  4479. @item rate, r
  4480. Set the video rate, that is the number of frames generated per second.
  4481. Default is 25.
  4482. @item random_fill_ratio, ratio
  4483. Set the random fill ratio for the initial cellular automaton row. It
  4484. is a floating point number value ranging from 0 to 1, defaults to
  4485. 1/PHI.
  4486. This option is ignored when a file or a pattern is specified.
  4487. @item random_seed, seed
  4488. Set the seed for filling randomly the initial row, must be an integer
  4489. included between 0 and UINT32_MAX. If not specified, or if explicitly
  4490. set to -1, the filter will try to use a good random seed on a best
  4491. effort basis.
  4492. @item rule
  4493. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  4494. Default value is 110.
  4495. @item size, s
  4496. Set the size of the output video.
  4497. If @option{filename} or @option{pattern} is specified, the size is set
  4498. by default to the width of the specified initial state row, and the
  4499. height is set to @var{width} * PHI.
  4500. If @option{size} is set, it must contain the width of the specified
  4501. pattern string, and the specified pattern will be centered in the
  4502. larger row.
  4503. If a filename or a pattern string is not specified, the size value
  4504. defaults to "320x518" (used for a randomly generated initial state).
  4505. @item scroll
  4506. If set to 1, scroll the output upward when all the rows in the output
  4507. have been already filled. If set to 0, the new generated row will be
  4508. written over the top row just after the bottom row is filled.
  4509. Defaults to 1.
  4510. @item start_full, full
  4511. If set to 1, completely fill the output with generated rows before
  4512. outputting the first frame.
  4513. This is the default behavior, for disabling set the value to 0.
  4514. @item stitch
  4515. If set to 1, stitch the left and right row edges together.
  4516. This is the default behavior, for disabling set the value to 0.
  4517. @end table
  4518. @subsection Examples
  4519. @itemize
  4520. @item
  4521. Read the initial state from @file{pattern}, and specify an output of
  4522. size 200x400.
  4523. @example
  4524. cellauto=f=pattern:s=200x400
  4525. @end example
  4526. @item
  4527. Generate a random initial row with a width of 200 cells, with a fill
  4528. ratio of 2/3:
  4529. @example
  4530. cellauto=ratio=2/3:s=200x200
  4531. @end example
  4532. @item
  4533. Create a pattern generated by rule 18 starting by a single alive cell
  4534. centered on an initial row with width 100:
  4535. @example
  4536. cellauto=p=@@:s=100x400:full=0:rule=18
  4537. @end example
  4538. @item
  4539. Specify a more elaborated initial pattern:
  4540. @example
  4541. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  4542. @end example
  4543. @end itemize
  4544. @section mandelbrot
  4545. Generate a Mandelbrot set fractal, and progressively zoom towards the
  4546. point specified with @var{start_x} and @var{start_y}.
  4547. This source accepts a list of options in the form of
  4548. @var{key}=@var{value} pairs separated by ":". A description of the
  4549. accepted options follows.
  4550. @table @option
  4551. @item end_pts
  4552. Set the terminal pts value. Default value is 400.
  4553. @item end_scale
  4554. Set the terminal scale value.
  4555. Must be a floating point value. Default value is 0.3.
  4556. @item inner
  4557. Set the inner coloring mode, that is the algorithm used to draw the
  4558. Mandelbrot fractal internal region.
  4559. It shall assume one of the following values:
  4560. @table @option
  4561. @item black
  4562. Set black mode.
  4563. @item convergence
  4564. Show time until convergence.
  4565. @item mincol
  4566. Set color based on point closest to the origin of the iterations.
  4567. @item period
  4568. Set period mode.
  4569. @end table
  4570. Default value is @var{mincol}.
  4571. @item bailout
  4572. Set the bailout value. Default value is 10.0.
  4573. @item maxiter
  4574. Set the maximum of iterations performed by the rendering
  4575. algorithm. Default value is 7189.
  4576. @item outer
  4577. Set outer coloring mode.
  4578. It shall assume one of following values:
  4579. @table @option
  4580. @item iteration_count
  4581. Set iteration cound mode.
  4582. @item normalized_iteration_count
  4583. set normalized iteration count mode.
  4584. @end table
  4585. Default value is @var{normalized_iteration_count}.
  4586. @item rate, r
  4587. Set frame rate, expressed as number of frames per second. Default
  4588. value is "25".
  4589. @item size, s
  4590. Set frame size. Default value is "640x480".
  4591. @item start_scale
  4592. Set the initial scale value. Default value is 3.0.
  4593. @item start_x
  4594. Set the initial x position. Must be a floating point value between
  4595. -100 and 100. Default value is -0.743643887037158704752191506114774.
  4596. @item start_y
  4597. Set the initial y position. Must be a floating point value between
  4598. -100 and 100. Default value is -0.131825904205311970493132056385139.
  4599. @end table
  4600. @section mptestsrc
  4601. Generate various test patterns, as generated by the MPlayer test filter.
  4602. The size of the generated video is fixed, and is 256x256.
  4603. This source is useful in particular for testing encoding features.
  4604. This source accepts an optional sequence of @var{key}=@var{value} pairs,
  4605. separated by ":". The description of the accepted options follows.
  4606. @table @option
  4607. @item rate, r
  4608. Specify the frame rate of the sourced video, as the number of frames
  4609. generated per second. It has to be a string in the format
  4610. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  4611. number or a valid video frame rate abbreviation. The default value is
  4612. "25".
  4613. @item duration, d
  4614. Set the video duration of the sourced video. The accepted syntax is:
  4615. @example
  4616. [-]HH:MM:SS[.m...]
  4617. [-]S+[.m...]
  4618. @end example
  4619. See also the function @code{av_parse_time()}.
  4620. If not specified, or the expressed duration is negative, the video is
  4621. supposed to be generated forever.
  4622. @item test, t
  4623. Set the number or the name of the test to perform. Supported tests are:
  4624. @table @option
  4625. @item dc_luma
  4626. @item dc_chroma
  4627. @item freq_luma
  4628. @item freq_chroma
  4629. @item amp_luma
  4630. @item amp_chroma
  4631. @item cbp
  4632. @item mv
  4633. @item ring1
  4634. @item ring2
  4635. @item all
  4636. @end table
  4637. Default value is "all", which will cycle through the list of all tests.
  4638. @end table
  4639. For example the following:
  4640. @example
  4641. testsrc=t=dc_luma
  4642. @end example
  4643. will generate a "dc_luma" test pattern.
  4644. @section frei0r_src
  4645. Provide a frei0r source.
  4646. To enable compilation of this filter you need to install the frei0r
  4647. header and configure FFmpeg with @code{--enable-frei0r}.
  4648. The source supports the syntax:
  4649. @example
  4650. @var{size}:@var{rate}:@var{src_name}[@{=|:@}@var{param1}:@var{param2}:...:@var{paramN}]
  4651. @end example
  4652. @var{size} is the size of the video to generate, may be a string of the
  4653. form @var{width}x@var{height} or a frame size abbreviation.
  4654. @var{rate} is the rate of the video to generate, may be a string of
  4655. the form @var{num}/@var{den} or a frame rate abbreviation.
  4656. @var{src_name} is the name to the frei0r source to load. For more
  4657. information regarding frei0r and how to set the parameters read the
  4658. section @ref{frei0r} in the description of the video filters.
  4659. For example, to generate a frei0r partik0l source with size 200x200
  4660. and frame rate 10 which is overlayed on the overlay filter main input:
  4661. @example
  4662. frei0r_src=200x200:10:partik0l=1234 [overlay]; [in][overlay] overlay
  4663. @end example
  4664. @section life
  4665. Generate a life pattern.
  4666. This source is based on a generalization of John Conway's life game.
  4667. The sourced input represents a life grid, each pixel represents a cell
  4668. which can be in one of two possible states, alive or dead. Every cell
  4669. interacts with its eight neighbours, which are the cells that are
  4670. horizontally, vertically, or diagonally adjacent.
  4671. At each interaction the grid evolves according to the adopted rule,
  4672. which specifies the number of neighbor alive cells which will make a
  4673. cell stay alive or born. The @option{rule} option allows to specify
  4674. the rule to adopt.
  4675. This source accepts a list of options in the form of
  4676. @var{key}=@var{value} pairs separated by ":". A description of the
  4677. accepted options follows.
  4678. @table @option
  4679. @item filename, f
  4680. Set the file from which to read the initial grid state. In the file,
  4681. each non-whitespace character is considered an alive cell, and newline
  4682. is used to delimit the end of each row.
  4683. If this option is not specified, the initial grid is generated
  4684. randomly.
  4685. @item rate, r
  4686. Set the video rate, that is the number of frames generated per second.
  4687. Default is 25.
  4688. @item random_fill_ratio, ratio
  4689. Set the random fill ratio for the initial random grid. It is a
  4690. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  4691. It is ignored when a file is specified.
  4692. @item random_seed, seed
  4693. Set the seed for filling the initial random grid, must be an integer
  4694. included between 0 and UINT32_MAX. If not specified, or if explicitly
  4695. set to -1, the filter will try to use a good random seed on a best
  4696. effort basis.
  4697. @item rule
  4698. Set the life rule.
  4699. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  4700. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  4701. @var{NS} specifies the number of alive neighbor cells which make a
  4702. live cell stay alive, and @var{NB} the number of alive neighbor cells
  4703. which make a dead cell to become alive (i.e. to "born").
  4704. "s" and "b" can be used in place of "S" and "B", respectively.
  4705. Alternatively a rule can be specified by an 18-bits integer. The 9
  4706. high order bits are used to encode the next cell state if it is alive
  4707. for each number of neighbor alive cells, the low order bits specify
  4708. the rule for "borning" new cells. Higher order bits encode for an
  4709. higher number of neighbor cells.
  4710. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  4711. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  4712. Default value is "S23/B3", which is the original Conway's game of life
  4713. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  4714. cells, and will born a new cell if there are three alive cells around
  4715. a dead cell.
  4716. @item size, s
  4717. Set the size of the output video.
  4718. If @option{filename} is specified, the size is set by default to the
  4719. same size of the input file. If @option{size} is set, it must contain
  4720. the size specified in the input file, and the initial grid defined in
  4721. that file is centered in the larger resulting area.
  4722. If a filename is not specified, the size value defaults to "320x240"
  4723. (used for a randomly generated initial grid).
  4724. @item stitch
  4725. If set to 1, stitch the left and right grid edges together, and the
  4726. top and bottom edges also. Defaults to 1.
  4727. @item mold
  4728. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  4729. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  4730. value from 0 to 255.
  4731. @item life_color
  4732. Set the color of living (or new born) cells.
  4733. @item death_color
  4734. Set the color of dead cells. If @option{mold} is set, this is the first color
  4735. used to represent a dead cell.
  4736. @item mold_color
  4737. Set mold color, for definitely dead and moldy cells.
  4738. @end table
  4739. @subsection Examples
  4740. @itemize
  4741. @item
  4742. Read a grid from @file{pattern}, and center it on a grid of size
  4743. 300x300 pixels:
  4744. @example
  4745. life=f=pattern:s=300x300
  4746. @end example
  4747. @item
  4748. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  4749. @example
  4750. life=ratio=2/3:s=200x200
  4751. @end example
  4752. @item
  4753. Specify a custom rule for evolving a randomly generated grid:
  4754. @example
  4755. life=rule=S14/B34
  4756. @end example
  4757. @item
  4758. Full example with slow death effect (mold) using @command{ffplay}:
  4759. @example
  4760. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  4761. @end example
  4762. @end itemize
  4763. @section color, nullsrc, rgbtestsrc, smptebars, testsrc
  4764. The @code{color} source provides an uniformly colored input.
  4765. The @code{nullsrc} source returns unprocessed video frames. It is
  4766. mainly useful to be employed in analysis / debugging tools, or as the
  4767. source for filters which ignore the input data.
  4768. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  4769. detecting RGB vs BGR issues. You should see a red, green and blue
  4770. stripe from top to bottom.
  4771. The @code{smptebars} source generates a color bars pattern, based on
  4772. the SMPTE Engineering Guideline EG 1-1990.
  4773. The @code{testsrc} source generates a test video pattern, showing a
  4774. color pattern, a scrolling gradient and a timestamp. This is mainly
  4775. intended for testing purposes.
  4776. These sources accept an optional sequence of @var{key}=@var{value} pairs,
  4777. separated by ":". The description of the accepted options follows.
  4778. @table @option
  4779. @item color, c
  4780. Specify the color of the source, only used in the @code{color}
  4781. source. It can be the name of a color (case insensitive match) or a
  4782. 0xRRGGBB[AA] sequence, possibly followed by an alpha specifier. The
  4783. default value is "black".
  4784. @item size, s
  4785. Specify the size of the sourced video, it may be a string of the form
  4786. @var{width}x@var{height}, or the name of a size abbreviation. The
  4787. default value is "320x240".
  4788. @item rate, r
  4789. Specify the frame rate of the sourced video, as the number of frames
  4790. generated per second. It has to be a string in the format
  4791. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  4792. number or a valid video frame rate abbreviation. The default value is
  4793. "25".
  4794. @item sar
  4795. Set the sample aspect ratio of the sourced video.
  4796. @item duration, d
  4797. Set the video duration of the sourced video. The accepted syntax is:
  4798. @example
  4799. [-]HH[:MM[:SS[.m...]]]
  4800. [-]S+[.m...]
  4801. @end example
  4802. See also the function @code{av_parse_time()}.
  4803. If not specified, or the expressed duration is negative, the video is
  4804. supposed to be generated forever.
  4805. @item decimals, n
  4806. Set the number of decimals to show in the timestamp, only used in the
  4807. @code{testsrc} source.
  4808. The displayed timestamp value will correspond to the original
  4809. timestamp value multiplied by the power of 10 of the specified
  4810. value. Default value is 0.
  4811. @end table
  4812. For example the following:
  4813. @example
  4814. testsrc=duration=5.3:size=qcif:rate=10
  4815. @end example
  4816. will generate a video with a duration of 5.3 seconds, with size
  4817. 176x144 and a frame rate of 10 frames per second.
  4818. The following graph description will generate a red source
  4819. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  4820. frames per second.
  4821. @example
  4822. color=c=red@@0.2:s=qcif:r=10
  4823. @end example
  4824. If the input content is to be ignored, @code{nullsrc} can be used. The
  4825. following command generates noise in the luminance plane by employing
  4826. the @code{geq} filter:
  4827. @example
  4828. nullsrc=s=256x256, geq=random(1)*255:128:128
  4829. @end example
  4830. @c man end VIDEO SOURCES
  4831. @chapter Video Sinks
  4832. @c man begin VIDEO SINKS
  4833. Below is a description of the currently available video sinks.
  4834. @section buffersink
  4835. Buffer video frames, and make them available to the end of the filter
  4836. graph.
  4837. This sink is mainly intended for a programmatic use, in particular
  4838. through the interface defined in @file{libavfilter/buffersink.h}.
  4839. It does not require a string parameter in input, but you need to
  4840. specify a pointer to a list of supported pixel formats terminated by
  4841. -1 in the opaque parameter provided to @code{avfilter_init_filter}
  4842. when initializing this sink.
  4843. @section nullsink
  4844. Null video sink, do absolutely nothing with the input video. It is
  4845. mainly useful as a template and to be employed in analysis / debugging
  4846. tools.
  4847. @c man end VIDEO SINKS
  4848. @chapter Multimedia Filters
  4849. @c man begin MULTIMEDIA FILTERS
  4850. Below is a description of the currently available multimedia filters.
  4851. @section aperms, perms
  4852. Set read/write permissions for the output frames.
  4853. These filters are mainly aimed at developers to test direct path in the
  4854. following filter in the filtergraph.
  4855. The filters accept parameters as a list of @var{key}=@var{value} pairs,
  4856. separated by ":". If the key of the first options is omitted, the argument is
  4857. assumed to be the @var{mode}.
  4858. A description of the accepted parameters follows.
  4859. @table @option
  4860. @item mode
  4861. Select the permissions mode.
  4862. It accepts the following values:
  4863. @table @samp
  4864. @item none
  4865. Do nothing. This is the default.
  4866. @item ro
  4867. Set all the output frames read-only.
  4868. @item rw
  4869. Set all the output frames directly writable.
  4870. @item toggle
  4871. Make the frame read-only if writable, and writable if read-only.
  4872. @item random
  4873. Set each output frame read-only or writable randomly.
  4874. @end table
  4875. @item seed
  4876. Set the seed for the @var{random} mode, must be an integer included between
  4877. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  4878. @code{-1}, the filter will try to use a good random seed on a best effort
  4879. basis.
  4880. @end table
  4881. Note: in case of auto-inserted filter between the permission filter and the
  4882. following one, the permission might not be received as expected in that
  4883. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  4884. perms/aperms filter can avoid this problem.
  4885. @section aphaser
  4886. Add a phasing effect to the input audio.
  4887. A phaser filter creates series of peaks and troughs in the frequency spectrum.
  4888. The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
  4889. The filter accepts parameters as a list of @var{key}=@var{value}
  4890. pairs, separated by ":".
  4891. A description of the accepted parameters follows.
  4892. @table @option
  4893. @item in_gain
  4894. Set input gain. Default is 0.4.
  4895. @item out_gain
  4896. Set output gain. Default is 0.74
  4897. @item delay
  4898. Set delay in milliseconds. Default is 3.0.
  4899. @item decay
  4900. Set decay. Default is 0.4.
  4901. @item speed
  4902. Set modulation speed in Hz. Default is 0.5.
  4903. @item type
  4904. Set modulation type. Default is triangular.
  4905. It accepts the following values:
  4906. @table @samp
  4907. @item triangular, t
  4908. @item sinusoidal, s
  4909. @end table
  4910. @end table
  4911. @section aselect, select
  4912. Select frames to pass in output.
  4913. These filters accept a single option @option{expr} or @option{e}
  4914. specifying the select expression, which can be specified either by
  4915. specyfing @code{expr=VALUE} or specifying the expression
  4916. alone.
  4917. The select expression is evaluated for each input frame. If the
  4918. evaluation result is a non-zero value, the frame is selected and
  4919. passed to the output, otherwise it is discarded.
  4920. The expression can contain the following constants:
  4921. @table @option
  4922. @item n
  4923. the sequential number of the filtered frame, starting from 0
  4924. @item selected_n
  4925. the sequential number of the selected frame, starting from 0
  4926. @item prev_selected_n
  4927. the sequential number of the last selected frame, NAN if undefined
  4928. @item TB
  4929. timebase of the input timestamps
  4930. @item pts
  4931. the PTS (Presentation TimeStamp) of the filtered video frame,
  4932. expressed in @var{TB} units, NAN if undefined
  4933. @item t
  4934. the PTS (Presentation TimeStamp) of the filtered video frame,
  4935. expressed in seconds, NAN if undefined
  4936. @item prev_pts
  4937. the PTS of the previously filtered video frame, NAN if undefined
  4938. @item prev_selected_pts
  4939. the PTS of the last previously filtered video frame, NAN if undefined
  4940. @item prev_selected_t
  4941. the PTS of the last previously selected video frame, NAN if undefined
  4942. @item start_pts
  4943. the PTS of the first video frame in the video, NAN if undefined
  4944. @item start_t
  4945. the time of the first video frame in the video, NAN if undefined
  4946. @item pict_type @emph{(video only)}
  4947. the type of the filtered frame, can assume one of the following
  4948. values:
  4949. @table @option
  4950. @item I
  4951. @item P
  4952. @item B
  4953. @item S
  4954. @item SI
  4955. @item SP
  4956. @item BI
  4957. @end table
  4958. @item interlace_type @emph{(video only)}
  4959. the frame interlace type, can assume one of the following values:
  4960. @table @option
  4961. @item PROGRESSIVE
  4962. the frame is progressive (not interlaced)
  4963. @item TOPFIRST
  4964. the frame is top-field-first
  4965. @item BOTTOMFIRST
  4966. the frame is bottom-field-first
  4967. @end table
  4968. @item consumed_sample_n @emph{(audio only)}
  4969. the number of selected samples before the current frame
  4970. @item samples_n @emph{(audio only)}
  4971. the number of samples in the current frame
  4972. @item sample_rate @emph{(audio only)}
  4973. the input sample rate
  4974. @item key
  4975. 1 if the filtered frame is a key-frame, 0 otherwise
  4976. @item pos
  4977. the position in the file of the filtered frame, -1 if the information
  4978. is not available (e.g. for synthetic video)
  4979. @item scene @emph{(video only)}
  4980. value between 0 and 1 to indicate a new scene; a low value reflects a low
  4981. probability for the current frame to introduce a new scene, while a higher
  4982. value means the current frame is more likely to be one (see the example below)
  4983. @end table
  4984. The default value of the select expression is "1".
  4985. @subsection Examples
  4986. @itemize
  4987. @item
  4988. Select all frames in input:
  4989. @example
  4990. select
  4991. @end example
  4992. The example above is the same as:
  4993. @example
  4994. select=1
  4995. @end example
  4996. @item
  4997. Skip all frames:
  4998. @example
  4999. select=0
  5000. @end example
  5001. @item
  5002. Select only I-frames:
  5003. @example
  5004. select='eq(pict_type\,I)'
  5005. @end example
  5006. @item
  5007. Select one frame every 100:
  5008. @example
  5009. select='not(mod(n\,100))'
  5010. @end example
  5011. @item
  5012. Select only frames contained in the 10-20 time interval:
  5013. @example
  5014. select='gte(t\,10)*lte(t\,20)'
  5015. @end example
  5016. @item
  5017. Select only I frames contained in the 10-20 time interval:
  5018. @example
  5019. select='gte(t\,10)*lte(t\,20)*eq(pict_type\,I)'
  5020. @end example
  5021. @item
  5022. Select frames with a minimum distance of 10 seconds:
  5023. @example
  5024. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  5025. @end example
  5026. @item
  5027. Use aselect to select only audio frames with samples number > 100:
  5028. @example
  5029. aselect='gt(samples_n\,100)'
  5030. @end example
  5031. @item
  5032. Create a mosaic of the first scenes:
  5033. @example
  5034. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  5035. @end example
  5036. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  5037. choice.
  5038. @end itemize
  5039. @section asendcmd, sendcmd
  5040. Send commands to filters in the filtergraph.
  5041. These filters read commands to be sent to other filters in the
  5042. filtergraph.
  5043. @code{asendcmd} must be inserted between two audio filters,
  5044. @code{sendcmd} must be inserted between two video filters, but apart
  5045. from that they act the same way.
  5046. The specification of commands can be provided in the filter arguments
  5047. with the @var{commands} option, or in a file specified by the
  5048. @var{filename} option.
  5049. These filters accept the following options:
  5050. @table @option
  5051. @item commands, c
  5052. Set the commands to be read and sent to the other filters.
  5053. @item filename, f
  5054. Set the filename of the commands to be read and sent to the other
  5055. filters.
  5056. @end table
  5057. @subsection Commands syntax
  5058. A commands description consists of a sequence of interval
  5059. specifications, comprising a list of commands to be executed when a
  5060. particular event related to that interval occurs. The occurring event
  5061. is typically the current frame time entering or leaving a given time
  5062. interval.
  5063. An interval is specified by the following syntax:
  5064. @example
  5065. @var{START}[-@var{END}] @var{COMMANDS};
  5066. @end example
  5067. The time interval is specified by the @var{START} and @var{END} times.
  5068. @var{END} is optional and defaults to the maximum time.
  5069. The current frame time is considered within the specified interval if
  5070. it is included in the interval [@var{START}, @var{END}), that is when
  5071. the time is greater or equal to @var{START} and is lesser than
  5072. @var{END}.
  5073. @var{COMMANDS} consists of a sequence of one or more command
  5074. specifications, separated by ",", relating to that interval. The
  5075. syntax of a command specification is given by:
  5076. @example
  5077. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  5078. @end example
  5079. @var{FLAGS} is optional and specifies the type of events relating to
  5080. the time interval which enable sending the specified command, and must
  5081. be a non-null sequence of identifier flags separated by "+" or "|" and
  5082. enclosed between "[" and "]".
  5083. The following flags are recognized:
  5084. @table @option
  5085. @item enter
  5086. The command is sent when the current frame timestamp enters the
  5087. specified interval. In other words, the command is sent when the
  5088. previous frame timestamp was not in the given interval, and the
  5089. current is.
  5090. @item leave
  5091. The command is sent when the current frame timestamp leaves the
  5092. specified interval. In other words, the command is sent when the
  5093. previous frame timestamp was in the given interval, and the
  5094. current is not.
  5095. @end table
  5096. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  5097. assumed.
  5098. @var{TARGET} specifies the target of the command, usually the name of
  5099. the filter class or a specific filter instance name.
  5100. @var{COMMAND} specifies the name of the command for the target filter.
  5101. @var{ARG} is optional and specifies the optional list of argument for
  5102. the given @var{COMMAND}.
  5103. Between one interval specification and another, whitespaces, or
  5104. sequences of characters starting with @code{#} until the end of line,
  5105. are ignored and can be used to annotate comments.
  5106. A simplified BNF description of the commands specification syntax
  5107. follows:
  5108. @example
  5109. @var{COMMAND_FLAG} ::= "enter" | "leave"
  5110. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  5111. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  5112. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  5113. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  5114. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  5115. @end example
  5116. @subsection Examples
  5117. @itemize
  5118. @item
  5119. Specify audio tempo change at second 4:
  5120. @example
  5121. asendcmd=c='4.0 atempo tempo 1.5',atempo
  5122. @end example
  5123. @item
  5124. Specify a list of drawtext and hue commands in a file.
  5125. @example
  5126. # show text in the interval 5-10
  5127. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  5128. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  5129. # desaturate the image in the interval 15-20
  5130. 15.0-20.0 [enter] hue reinit s=0,
  5131. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  5132. [leave] hue reinit s=1,
  5133. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  5134. # apply an exponential saturation fade-out effect, starting from time 25
  5135. 25 [enter] hue s=exp(t-25)
  5136. @end example
  5137. A filtergraph allowing to read and process the above command list
  5138. stored in a file @file{test.cmd}, can be specified with:
  5139. @example
  5140. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  5141. @end example
  5142. @end itemize
  5143. @anchor{setpts}
  5144. @section asetpts, setpts
  5145. Change the PTS (presentation timestamp) of the input frames.
  5146. @code{asetpts} works on audio frames, @code{setpts} on video frames.
  5147. Accept in input an expression evaluated through the eval API, which
  5148. can contain the following constants:
  5149. @table @option
  5150. @item FRAME_RATE
  5151. frame rate, only defined for constant frame-rate video
  5152. @item PTS
  5153. the presentation timestamp in input
  5154. @item N
  5155. the count of the input frame, starting from 0.
  5156. @item NB_CONSUMED_SAMPLES
  5157. the number of consumed samples, not including the current frame (only
  5158. audio)
  5159. @item NB_SAMPLES
  5160. the number of samples in the current frame (only audio)
  5161. @item SAMPLE_RATE
  5162. audio sample rate
  5163. @item STARTPTS
  5164. the PTS of the first frame
  5165. @item STARTT
  5166. the time in seconds of the first frame
  5167. @item INTERLACED
  5168. tell if the current frame is interlaced
  5169. @item T
  5170. the time in seconds of the current frame
  5171. @item TB
  5172. the time base
  5173. @item POS
  5174. original position in the file of the frame, or undefined if undefined
  5175. for the current frame
  5176. @item PREV_INPTS
  5177. previous input PTS
  5178. @item PREV_INT
  5179. previous input time in seconds
  5180. @item PREV_OUTPTS
  5181. previous output PTS
  5182. @item PREV_OUTT
  5183. previous output time in seconds
  5184. @item RTCTIME
  5185. wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  5186. instead.
  5187. @item RTCSTART
  5188. wallclock (RTC) time at the start of the movie in microseconds
  5189. @end table
  5190. @subsection Examples
  5191. @itemize
  5192. @item
  5193. Start counting PTS from zero
  5194. @example
  5195. setpts=PTS-STARTPTS
  5196. @end example
  5197. @item
  5198. Apply fast motion effect:
  5199. @example
  5200. setpts=0.5*PTS
  5201. @end example
  5202. @item
  5203. Apply slow motion effect:
  5204. @example
  5205. setpts=2.0*PTS
  5206. @end example
  5207. @item
  5208. Set fixed rate of 25 frames per second:
  5209. @example
  5210. setpts=N/(25*TB)
  5211. @end example
  5212. @item
  5213. Set fixed rate 25 fps with some jitter:
  5214. @example
  5215. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  5216. @end example
  5217. @item
  5218. Apply an offset of 10 seconds to the input PTS:
  5219. @example
  5220. setpts=PTS+10/TB
  5221. @end example
  5222. @item
  5223. Generate timestamps from a "live source" and rebase onto the current timebase:
  5224. @example
  5225. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  5226. @end example
  5227. @end itemize
  5228. @section ebur128
  5229. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  5230. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  5231. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  5232. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  5233. The filter also has a video output (see the @var{video} option) with a real
  5234. time graph to observe the loudness evolution. The graphic contains the logged
  5235. message mentioned above, so it is not printed anymore when this option is set,
  5236. unless the verbose logging is set. The main graphing area contains the
  5237. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  5238. the momentary loudness (400 milliseconds).
  5239. More information about the Loudness Recommendation EBU R128 on
  5240. @url{http://tech.ebu.ch/loudness}.
  5241. The filter accepts the following named parameters:
  5242. @table @option
  5243. @item video
  5244. Activate the video output. The audio stream is passed unchanged whether this
  5245. option is set or no. The video stream will be the first output stream if
  5246. activated. Default is @code{0}.
  5247. @item size
  5248. Set the video size. This option is for video only. Default and minimum
  5249. resolution is @code{640x480}.
  5250. @item meter
  5251. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  5252. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  5253. other integer value between this range is allowed.
  5254. @item metadata
  5255. Set metadata injection. If set to @code{1}, the audio input will be segmented
  5256. into 100ms output frames, each of them containing various loudness information
  5257. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  5258. Default is @code{0}.
  5259. @item framelog
  5260. Force the frame logging level.
  5261. Available values are:
  5262. @table @samp
  5263. @item info
  5264. information logging level
  5265. @item verbose
  5266. verbose logging level
  5267. @end table
  5268. By default, the logging level is set to @var{info}. If the @option{video} or
  5269. the @option{metadata} options are set, it switches to @var{verbose}.
  5270. @end table
  5271. @subsection Examples
  5272. @itemize
  5273. @item
  5274. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  5275. @example
  5276. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  5277. @end example
  5278. @item
  5279. Run an analysis with @command{ffmpeg}:
  5280. @example
  5281. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  5282. @end example
  5283. @end itemize
  5284. @section settb, asettb
  5285. Set the timebase to use for the output frames timestamps.
  5286. It is mainly useful for testing timebase configuration.
  5287. This filter accepts a single option @option{tb}, which can be
  5288. specified either by setting @option{tb}=@var{VALUE} or setting the
  5289. value alone.
  5290. The value for @option{tb} is an arithmetic expression representing a
  5291. rational. The expression can contain the constants "AVTB" (the default
  5292. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  5293. audio only). Default value is "intb".
  5294. @subsection Examples
  5295. @itemize
  5296. @item
  5297. Set the timebase to 1/25:
  5298. @example
  5299. settb=1/25
  5300. @end example
  5301. @item
  5302. Set the timebase to 1/10:
  5303. @example
  5304. settb=0.1
  5305. @end example
  5306. @item
  5307. Set the timebase to 1001/1000:
  5308. @example
  5309. settb=1+0.001
  5310. @end example
  5311. @item
  5312. Set the timebase to 2*intb:
  5313. @example
  5314. settb=2*intb
  5315. @end example
  5316. @item
  5317. Set the default timebase value:
  5318. @example
  5319. settb=AVTB
  5320. @end example
  5321. @end itemize
  5322. @section concat
  5323. Concatenate audio and video streams, joining them together one after the
  5324. other.
  5325. The filter works on segments of synchronized video and audio streams. All
  5326. segments must have the same number of streams of each type, and that will
  5327. also be the number of streams at output.
  5328. The filter accepts the following named parameters:
  5329. @table @option
  5330. @item n
  5331. Set the number of segments. Default is 2.
  5332. @item v
  5333. Set the number of output video streams, that is also the number of video
  5334. streams in each segment. Default is 1.
  5335. @item a
  5336. Set the number of output audio streams, that is also the number of video
  5337. streams in each segment. Default is 0.
  5338. @item unsafe
  5339. Activate unsafe mode: do not fail if segments have a different format.
  5340. @end table
  5341. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  5342. @var{a} audio outputs.
  5343. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  5344. segment, in the same order as the outputs, then the inputs for the second
  5345. segment, etc.
  5346. Related streams do not always have exactly the same duration, for various
  5347. reasons including codec frame size or sloppy authoring. For that reason,
  5348. related synchronized streams (e.g. a video and its audio track) should be
  5349. concatenated at once. The concat filter will use the duration of the longest
  5350. stream in each segment (except the last one), and if necessary pad shorter
  5351. audio streams with silence.
  5352. For this filter to work correctly, all segments must start at timestamp 0.
  5353. All corresponding streams must have the same parameters in all segments; the
  5354. filtering system will automatically select a common pixel format for video
  5355. streams, and a common sample format, sample rate and channel layout for
  5356. audio streams, but other settings, such as resolution, must be converted
  5357. explicitly by the user.
  5358. Different frame rates are acceptable but will result in variable frame rate
  5359. at output; be sure to configure the output file to handle it.
  5360. @subsection Examples
  5361. @itemize
  5362. @item
  5363. Concatenate an opening, an episode and an ending, all in bilingual version
  5364. (video in stream 0, audio in streams 1 and 2):
  5365. @example
  5366. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  5367. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  5368. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  5369. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  5370. @end example
  5371. @item
  5372. Concatenate two parts, handling audio and video separately, using the
  5373. (a)movie sources, and adjusting the resolution:
  5374. @example
  5375. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  5376. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  5377. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  5378. @end example
  5379. Note that a desync will happen at the stitch if the audio and video streams
  5380. do not have exactly the same duration in the first file.
  5381. @end itemize
  5382. @section showspectrum
  5383. Convert input audio to a video output, representing the audio frequency
  5384. spectrum.
  5385. The filter accepts the following named parameters:
  5386. @table @option
  5387. @item size, s
  5388. Specify the video size for the output. Default value is @code{640x512}.
  5389. @item slide
  5390. Specify if the spectrum should slide along the window. Default value is
  5391. @code{0}.
  5392. @item mode
  5393. Specify display mode.
  5394. It accepts the following values:
  5395. @table @samp
  5396. @item combined
  5397. all channels are displayed in the same row
  5398. @item separate
  5399. all channels are displayed in separate rows
  5400. @end table
  5401. Default value is @samp{combined}.
  5402. @item color
  5403. Specify display color mode.
  5404. It accepts the following values:
  5405. @table @samp
  5406. @item channel
  5407. each channel is displayed in a separate color
  5408. @item intensity
  5409. each channel is is displayed using the same color scheme
  5410. @end table
  5411. Default value is @samp{channel}.
  5412. @item scale
  5413. Specify scale used for calculating intensity color values.
  5414. It accepts the following values:
  5415. @table @samp
  5416. @item lin
  5417. linear
  5418. @item sqrt
  5419. square root, default
  5420. @item cbrt
  5421. cubic root
  5422. @item log
  5423. logarithmic
  5424. @end table
  5425. Default value is @samp{sqrt}.
  5426. @item saturation
  5427. Set saturation modifier for displayed colors. Negative values provide
  5428. alternative color scheme. @code{0} is no saturation at all.
  5429. Saturation must be in [-10.0, 10.0] range.
  5430. Default value is @code{1}.
  5431. @end table
  5432. The usage is very similar to the showwaves filter; see the examples in that
  5433. section.
  5434. @subsection Examples
  5435. @itemize
  5436. @item
  5437. Large window with logarithmic color scaling:
  5438. @example
  5439. showspectrum=s=1280x480:scale=log
  5440. @end example
  5441. @item
  5442. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  5443. @example
  5444. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  5445. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  5446. @end example
  5447. @end itemize
  5448. @section showwaves
  5449. Convert input audio to a video output, representing the samples waves.
  5450. The filter accepts the following named parameters:
  5451. @table @option
  5452. @item mode
  5453. Set display mode.
  5454. Available values are:
  5455. @table @samp
  5456. @item point
  5457. Draw a point for each sample.
  5458. @item line
  5459. Draw a vertical line for each sample.
  5460. @end table
  5461. Default value is @code{point}.
  5462. @item n
  5463. Set the number of samples which are printed on the same column. A
  5464. larger value will decrease the frame rate. Must be a positive
  5465. integer. This option can be set only if the value for @var{rate}
  5466. is not explicitly specified.
  5467. @item rate, r
  5468. Set the (approximate) output frame rate. This is done by setting the
  5469. option @var{n}. Default value is "25".
  5470. @item size, s
  5471. Specify the video size for the output. Default value is "600x240".
  5472. @end table
  5473. @subsection Examples
  5474. @itemize
  5475. @item
  5476. Output the input file audio and the corresponding video representation
  5477. at the same time:
  5478. @example
  5479. amovie=a.mp3,asplit[out0],showwaves[out1]
  5480. @end example
  5481. @item
  5482. Create a synthetic signal and show it with showwaves, forcing a
  5483. frame rate of 30 frames per second:
  5484. @example
  5485. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  5486. @end example
  5487. @end itemize
  5488. @c man end MULTIMEDIA FILTERS
  5489. @chapter Multimedia Sources
  5490. @c man begin MULTIMEDIA SOURCES
  5491. Below is a description of the currently available multimedia sources.
  5492. @section amovie
  5493. This is the same as @ref{movie} source, except it selects an audio
  5494. stream by default.
  5495. @anchor{movie}
  5496. @section movie
  5497. Read audio and/or video stream(s) from a movie container.
  5498. It accepts the syntax: @var{movie_name}[:@var{options}] where
  5499. @var{movie_name} is the name of the resource to read (not necessarily
  5500. a file but also a device or a stream accessed through some protocol),
  5501. and @var{options} is an optional sequence of @var{key}=@var{value}
  5502. pairs, separated by ":".
  5503. The description of the accepted options follows.
  5504. @table @option
  5505. @item format_name, f
  5506. Specifies the format assumed for the movie to read, and can be either
  5507. the name of a container or an input device. If not specified the
  5508. format is guessed from @var{movie_name} or by probing.
  5509. @item seek_point, sp
  5510. Specifies the seek point in seconds, the frames will be output
  5511. starting from this seek point, the parameter is evaluated with
  5512. @code{av_strtod} so the numerical value may be suffixed by an IS
  5513. postfix. Default value is "0".
  5514. @item streams, s
  5515. Specifies the streams to read. Several streams can be specified,
  5516. separated by "+". The source will then have as many outputs, in the
  5517. same order. The syntax is explained in the ``Stream specifiers''
  5518. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  5519. respectively the default (best suited) video and audio stream. Default
  5520. is "dv", or "da" if the filter is called as "amovie".
  5521. @item stream_index, si
  5522. Specifies the index of the video stream to read. If the value is -1,
  5523. the best suited video stream will be automatically selected. Default
  5524. value is "-1". Deprecated. If the filter is called "amovie", it will select
  5525. audio instead of video.
  5526. @item loop
  5527. Specifies how many times to read the stream in sequence.
  5528. If the value is less than 1, the stream will be read again and again.
  5529. Default value is "1".
  5530. Note that when the movie is looped the source timestamps are not
  5531. changed, so it will generate non monotonically increasing timestamps.
  5532. @end table
  5533. This filter allows to overlay a second video on top of main input of
  5534. a filtergraph as shown in this graph:
  5535. @example
  5536. input -----------> deltapts0 --> overlay --> output
  5537. ^
  5538. |
  5539. movie --> scale--> deltapts1 -------+
  5540. @end example
  5541. @subsection Examples
  5542. @itemize
  5543. @item
  5544. Skip 3.2 seconds from the start of the avi file in.avi, and overlay it
  5545. on top of the input labelled as "in":
  5546. @example
  5547. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  5548. [in] setpts=PTS-STARTPTS [main];
  5549. [main][over] overlay=16:16 [out]
  5550. @end example
  5551. @item
  5552. Read from a video4linux2 device, and overlay it on top of the input
  5553. labelled as "in":
  5554. @example
  5555. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  5556. [in] setpts=PTS-STARTPTS [main];
  5557. [main][over] overlay=16:16 [out]
  5558. @end example
  5559. @item
  5560. Read the first video stream and the audio stream with id 0x81 from
  5561. dvd.vob; the video is connected to the pad named "video" and the audio is
  5562. connected to the pad named "audio":
  5563. @example
  5564. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  5565. @end example
  5566. @end itemize
  5567. @c man end MULTIMEDIA SOURCES