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.

7257 lines
192KB

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