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.

7744 lines
208KB

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