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.

7240 lines
194KB

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