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.

7253 lines
192KB

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