You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

7289 lines
194KB

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