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.

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