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.

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