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.

7286 lines
193KB

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