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.

7804 lines
210KB

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