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.

7289 lines
194KB

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