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.

7620 lines
205KB

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