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.

7279 lines
193KB

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