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.

6456 lines
178KB

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