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.

6263 lines
171KB

  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 hqdn3d
  2348. High precision/quality 3d denoise filter. This filter aims to reduce
  2349. image noise producing smooth images and making still images really
  2350. still. It should enhance compressibility.
  2351. It accepts the following optional parameters:
  2352. @var{luma_spatial}:@var{chroma_spatial}:@var{luma_tmp}:@var{chroma_tmp}
  2353. @table @option
  2354. @item luma_spatial
  2355. a non-negative float number which specifies spatial luma strength,
  2356. defaults to 4.0
  2357. @item chroma_spatial
  2358. a non-negative float number which specifies spatial chroma strength,
  2359. defaults to 3.0*@var{luma_spatial}/4.0
  2360. @item luma_tmp
  2361. a float number which specifies luma temporal strength, defaults to
  2362. 6.0*@var{luma_spatial}/4.0
  2363. @item chroma_tmp
  2364. a float number which specifies chroma temporal strength, defaults to
  2365. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
  2366. @end table
  2367. @section hue
  2368. Modify the hue and/or the saturation of the input.
  2369. This filter accepts the following optional named options:
  2370. @table @option
  2371. @item h
  2372. Specify the hue angle as a number of degrees. It accepts a float
  2373. number or an expression, and defaults to 0.0.
  2374. @item H
  2375. Specify the hue angle as a number of degrees. It accepts a float
  2376. number or an expression, and defaults to 0.0.
  2377. @item s
  2378. Specify the saturation in the [-10,10] range. It accepts a float number and
  2379. defaults to 1.0.
  2380. @end table
  2381. The @var{h}, @var{H} and @var{s} parameters are expressions containing the
  2382. following constants:
  2383. @table @option
  2384. @item n
  2385. frame count of the input frame starting from 0
  2386. @item pts
  2387. presentation timestamp of the input frame expressed in time base units
  2388. @item r
  2389. frame rate of the input video, NAN if the input frame rate is unknown
  2390. @item t
  2391. timestamp expressed in seconds, NAN if the input timestamp is unknown
  2392. @item tb
  2393. time base of the input video
  2394. @end table
  2395. The options can also be set using the syntax: @var{hue}:@var{saturation}
  2396. In this case @var{hue} is expressed in degrees.
  2397. Some examples follow:
  2398. @itemize
  2399. @item
  2400. Set the hue to 90 degrees and the saturation to 1.0:
  2401. @example
  2402. hue=h=90:s=1
  2403. @end example
  2404. @item
  2405. Same command but expressing the hue in radians:
  2406. @example
  2407. hue=H=PI/2:s=1
  2408. @end example
  2409. @item
  2410. Same command without named options, hue must be expressed in degrees:
  2411. @example
  2412. hue=90:1
  2413. @end example
  2414. @item
  2415. Note that "h:s" syntax does not support expressions for the values of
  2416. h and s, so the following example will issue an error:
  2417. @example
  2418. hue=PI/2:1
  2419. @end example
  2420. @item
  2421. Rotate hue and make the saturation swing between 0
  2422. and 2 over a period of 1 second:
  2423. @example
  2424. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  2425. @end example
  2426. @item
  2427. Apply a 3 seconds saturation fade-in effect starting at 0:
  2428. @example
  2429. hue="s=min(t/3\,1)"
  2430. @end example
  2431. The general fade-in expression can be written as:
  2432. @example
  2433. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  2434. @end example
  2435. @item
  2436. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  2437. @example
  2438. hue="s=max(0\, min(1\, (8-t)/3))"
  2439. @end example
  2440. The general fade-out expression can be written as:
  2441. @example
  2442. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  2443. @end example
  2444. @end itemize
  2445. @subsection Commands
  2446. This filter supports the following command:
  2447. @table @option
  2448. @item reinit
  2449. Modify the hue and/or the saturation of the input video.
  2450. The command accepts the same named options and syntax than when calling the
  2451. filter from the command-line.
  2452. If a parameter is omitted, it is kept at its current value.
  2453. @end table
  2454. @section idet
  2455. Interlaceing detect filter. This filter tries to detect if the input is
  2456. interlaced or progressive. Top or bottom field first.
  2457. @section kerndeint
  2458. Deinterlace input video by applying Donald Graft's adaptive kernel
  2459. deinterling. Work on interlaced parts of a video to produce
  2460. progressive frames.
  2461. This filter accepts parameters as a list of @var{key}=@var{value}
  2462. pairs, separated by ":". If the key of the first options is omitted,
  2463. the arguments are interpreted according to the following syntax:
  2464. @var{thresh}:@var{map}:@var{order}:@var{sharp}:@var{twoway}.
  2465. The description of the accepted parameters follows.
  2466. @table @option
  2467. @item thresh
  2468. Set the threshold which affects the filter's tolerance when
  2469. determining if a pixel line must be processed. It must be an integer
  2470. in the range [0,255] and defaults to 10. A value of 0 will result in
  2471. applying the process on every pixels.
  2472. @item map
  2473. Paint pixels exceeding the threshold value to white if set to 1.
  2474. Default is 0.
  2475. @item order
  2476. Set the fields order. Swap fields if set to 1, leave fields alone if
  2477. 0. Default is 0.
  2478. @item sharp
  2479. Enable additional sharpening if set to 1. Default is 0.
  2480. @item twoway
  2481. Enable twoway sharpening if set to 1. Default is 0.
  2482. @end table
  2483. @subsection Examples
  2484. @itemize
  2485. @item
  2486. Apply default values:
  2487. @example
  2488. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  2489. @end example
  2490. @item
  2491. Enable additional sharpening:
  2492. @example
  2493. kerndeint=sharp=1
  2494. @end example
  2495. @item
  2496. Paint processed pixels in white:
  2497. @example
  2498. kerndeint=map=1
  2499. @end example
  2500. @end itemize
  2501. @section lut, lutrgb, lutyuv
  2502. Compute a look-up table for binding each pixel component input value
  2503. to an output value, and apply it to input video.
  2504. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  2505. to an RGB input video.
  2506. These filters accept in input a ":"-separated list of options, which
  2507. specify the expressions used for computing the lookup table for the
  2508. corresponding pixel component values.
  2509. The @var{lut} filter requires either YUV or RGB pixel formats in
  2510. input, and accepts the options:
  2511. @table @option
  2512. @item c0
  2513. set first pixel component expression
  2514. @item c1
  2515. set second pixel component expression
  2516. @item c2
  2517. set third pixel component expression
  2518. @item c3
  2519. set fourth pixel component expression, corresponds to the alpha component
  2520. @end table
  2521. The exact component associated to each option depends on the format in
  2522. input.
  2523. The @var{lutrgb} filter requires RGB pixel formats in input, and
  2524. accepts the options:
  2525. @table @option
  2526. @item r
  2527. set red component expression
  2528. @item g
  2529. set green component expression
  2530. @item b
  2531. set blue component expression
  2532. @item a
  2533. alpha component expression
  2534. @end table
  2535. The @var{lutyuv} filter requires YUV pixel formats in input, and
  2536. accepts the options:
  2537. @table @option
  2538. @item y
  2539. set Y/luminance component expression
  2540. @item u
  2541. set U/Cb component expression
  2542. @item v
  2543. set V/Cr component expression
  2544. @item a
  2545. set alpha component expression
  2546. @end table
  2547. The expressions can contain the following constants and functions:
  2548. @table @option
  2549. @item w, h
  2550. the input width and height
  2551. @item val
  2552. input value for the pixel component
  2553. @item clipval
  2554. the input value clipped in the @var{minval}-@var{maxval} range
  2555. @item maxval
  2556. maximum value for the pixel component
  2557. @item minval
  2558. minimum value for the pixel component
  2559. @item negval
  2560. the negated value for the pixel component value clipped in the
  2561. @var{minval}-@var{maxval} range , it corresponds to the expression
  2562. "maxval-clipval+minval"
  2563. @item clip(val)
  2564. the computed value in @var{val} clipped in the
  2565. @var{minval}-@var{maxval} range
  2566. @item gammaval(gamma)
  2567. the computed gamma correction value of the pixel component value
  2568. clipped in the @var{minval}-@var{maxval} range, corresponds to the
  2569. expression
  2570. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  2571. @end table
  2572. All expressions default to "val".
  2573. @subsection Examples
  2574. @itemize
  2575. @item
  2576. Negate input video:
  2577. @example
  2578. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  2579. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  2580. @end example
  2581. The above is the same as:
  2582. @example
  2583. lutrgb="r=negval:g=negval:b=negval"
  2584. lutyuv="y=negval:u=negval:v=negval"
  2585. @end example
  2586. @item
  2587. Negate luminance:
  2588. @example
  2589. lutyuv=y=negval
  2590. @end example
  2591. @item
  2592. Remove chroma components, turns the video into a graytone image:
  2593. @example
  2594. lutyuv="u=128:v=128"
  2595. @end example
  2596. @item
  2597. Apply a luma burning effect:
  2598. @example
  2599. lutyuv="y=2*val"
  2600. @end example
  2601. @item
  2602. Remove green and blue components:
  2603. @example
  2604. lutrgb="g=0:b=0"
  2605. @end example
  2606. @item
  2607. Set a constant alpha channel value on input:
  2608. @example
  2609. format=rgba,lutrgb=a="maxval-minval/2"
  2610. @end example
  2611. @item
  2612. Correct luminance gamma by a 0.5 factor:
  2613. @example
  2614. lutyuv=y=gammaval(0.5)
  2615. @end example
  2616. @end itemize
  2617. @section mp
  2618. Apply an MPlayer filter to the input video.
  2619. This filter provides a wrapper around most of the filters of
  2620. MPlayer/MEncoder.
  2621. This wrapper is considered experimental. Some of the wrapped filters
  2622. may not work properly and we may drop support for them, as they will
  2623. be implemented natively into FFmpeg. Thus you should avoid
  2624. depending on them when writing portable scripts.
  2625. The filters accepts the parameters:
  2626. @var{filter_name}[:=]@var{filter_params}
  2627. @var{filter_name} is the name of a supported MPlayer filter,
  2628. @var{filter_params} is a string containing the parameters accepted by
  2629. the named filter.
  2630. The list of the currently supported filters follows:
  2631. @table @var
  2632. @item detc
  2633. @item dint
  2634. @item divtc
  2635. @item down3dright
  2636. @item dsize
  2637. @item eq2
  2638. @item eq
  2639. @item fil
  2640. @item fspp
  2641. @item harddup
  2642. @item il
  2643. @item ilpack
  2644. @item ivtc
  2645. @item kerndeint
  2646. @item mcdeint
  2647. @item noise
  2648. @item ow
  2649. @item perspective
  2650. @item phase
  2651. @item pp7
  2652. @item pullup
  2653. @item qp
  2654. @item sab
  2655. @item softpulldown
  2656. @item softskip
  2657. @item spp
  2658. @item telecine
  2659. @item tinterlace
  2660. @item unsharp
  2661. @item uspp
  2662. @end table
  2663. The parameter syntax and behavior for the listed filters are the same
  2664. of the corresponding MPlayer filters. For detailed instructions check
  2665. the "VIDEO FILTERS" section in the MPlayer manual.
  2666. Some examples follow:
  2667. @itemize
  2668. @item
  2669. Adjust gamma, brightness, contrast:
  2670. @example
  2671. mp=eq2=1.0:2:0.5
  2672. @end example
  2673. @item
  2674. Add temporal noise to input video:
  2675. @example
  2676. mp=noise=20t
  2677. @end example
  2678. @end itemize
  2679. See also mplayer(1), @url{http://www.mplayerhq.hu/}.
  2680. @section negate
  2681. Negate input video.
  2682. This filter accepts an integer in input, if non-zero it negates the
  2683. alpha component (if available). The default value in input is 0.
  2684. @section noformat
  2685. Force libavfilter not to use any of the specified pixel formats for the
  2686. input to the next filter.
  2687. The filter accepts a list of pixel format names, separated by ":",
  2688. for example "yuv420p:monow:rgb24".
  2689. Some examples follow:
  2690. @example
  2691. # force libavfilter to use a format different from "yuv420p" for the
  2692. # input to the vflip filter
  2693. noformat=yuv420p,vflip
  2694. # convert the input video to any of the formats not contained in the list
  2695. noformat=yuv420p:yuv444p:yuv410p
  2696. @end example
  2697. @section null
  2698. Pass the video source unchanged to the output.
  2699. @section ocv
  2700. Apply video transform using libopencv.
  2701. To enable this filter install libopencv library and headers and
  2702. configure FFmpeg with @code{--enable-libopencv}.
  2703. The filter takes the parameters: @var{filter_name}@{:=@}@var{filter_params}.
  2704. @var{filter_name} is the name of the libopencv filter to apply.
  2705. @var{filter_params} specifies the parameters to pass to the libopencv
  2706. filter. If not specified the default values are assumed.
  2707. Refer to the official libopencv documentation for more precise
  2708. information:
  2709. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  2710. Follows the list of supported libopencv filters.
  2711. @anchor{dilate}
  2712. @subsection dilate
  2713. Dilate an image by using a specific structuring element.
  2714. This filter corresponds to the libopencv function @code{cvDilate}.
  2715. It accepts the parameters: @var{struct_el}:@var{nb_iterations}.
  2716. @var{struct_el} represents a structuring element, and has the syntax:
  2717. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  2718. @var{cols} and @var{rows} represent the number of columns and rows of
  2719. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  2720. point, and @var{shape} the shape for the structuring element, and
  2721. can be one of the values "rect", "cross", "ellipse", "custom".
  2722. If the value for @var{shape} is "custom", it must be followed by a
  2723. string of the form "=@var{filename}". The file with name
  2724. @var{filename} is assumed to represent a binary image, with each
  2725. printable character corresponding to a bright pixel. When a custom
  2726. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  2727. or columns and rows of the read file are assumed instead.
  2728. The default value for @var{struct_el} is "3x3+0x0/rect".
  2729. @var{nb_iterations} specifies the number of times the transform is
  2730. applied to the image, and defaults to 1.
  2731. Follow some example:
  2732. @example
  2733. # use the default values
  2734. ocv=dilate
  2735. # dilate using a structuring element with a 5x5 cross, iterate two times
  2736. ocv=dilate=5x5+2x2/cross:2
  2737. # read the shape from the file diamond.shape, iterate two times
  2738. # the file diamond.shape may contain a pattern of characters like this:
  2739. # *
  2740. # ***
  2741. # *****
  2742. # ***
  2743. # *
  2744. # the specified cols and rows are ignored (but not the anchor point coordinates)
  2745. ocv=0x0+2x2/custom=diamond.shape:2
  2746. @end example
  2747. @subsection erode
  2748. Erode an image by using a specific structuring element.
  2749. This filter corresponds to the libopencv function @code{cvErode}.
  2750. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
  2751. with the same syntax and semantics as the @ref{dilate} filter.
  2752. @subsection smooth
  2753. Smooth the input video.
  2754. The filter takes the following parameters:
  2755. @var{type}:@var{param1}:@var{param2}:@var{param3}:@var{param4}.
  2756. @var{type} is the type of smooth filter to apply, and can be one of
  2757. the following values: "blur", "blur_no_scale", "median", "gaussian",
  2758. "bilateral". The default value is "gaussian".
  2759. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  2760. parameters whose meanings depend on smooth type. @var{param1} and
  2761. @var{param2} accept integer positive values or 0, @var{param3} and
  2762. @var{param4} accept float values.
  2763. The default value for @var{param1} is 3, the default value for the
  2764. other parameters is 0.
  2765. These parameters correspond to the parameters assigned to the
  2766. libopencv function @code{cvSmooth}.
  2767. @anchor{overlay}
  2768. @section overlay
  2769. Overlay one video on top of another.
  2770. It takes two inputs and one output, the first input is the "main"
  2771. video on which the second input is overlayed.
  2772. This filter accepts a list of @var{key}=@var{value} pairs as argument,
  2773. separated by ":". If the key of the first options is omitted, the
  2774. arguments are interpreted according to the syntax @var{x}:@var{y}.
  2775. A description of the accepted options follows.
  2776. @table @option
  2777. @item x, y
  2778. Set the expression for the x and y coordinates of the overlayed video
  2779. on the main video. Default value is 0.
  2780. The @var{x} and @var{y} expressions can contain the following
  2781. parameters:
  2782. @table @option
  2783. @item main_w, main_h
  2784. main input width and height
  2785. @item W, H
  2786. same as @var{main_w} and @var{main_h}
  2787. @item overlay_w, overlay_h
  2788. overlay input width and height
  2789. @item w, h
  2790. same as @var{overlay_w} and @var{overlay_h}
  2791. @end table
  2792. @item rgb
  2793. If set to 1, force the filter to accept inputs in the RGB
  2794. color space. Default value is 0.
  2795. @end table
  2796. Be aware that frames are taken from each input video in timestamp
  2797. order, hence, if their initial timestamps differ, it is a a good idea
  2798. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  2799. have them begin in the same zero timestamp, as it does the example for
  2800. the @var{movie} filter.
  2801. You can chain together more overlays but you should test the
  2802. efficiency of such approach.
  2803. @subsection Examples
  2804. @itemize
  2805. @item
  2806. Draw the overlay at 10 pixels from the bottom right corner of the main
  2807. video:
  2808. @example
  2809. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  2810. @end example
  2811. Using named options the example above becomes:
  2812. @example
  2813. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  2814. @end example
  2815. @item
  2816. Insert a transparent PNG logo in the bottom left corner of the input,
  2817. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  2818. @example
  2819. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  2820. @end example
  2821. @item
  2822. Insert 2 different transparent PNG logos (second logo on bottom
  2823. right corner) using the @command{ffmpeg} tool:
  2824. @example
  2825. ffmpeg -i input -i logo1 -i logo2 -filter_complex 'overlay=10:H-h-10,overlay=W-w-10:H-h-10' output
  2826. @end example
  2827. @item
  2828. Add a transparent color layer on top of the main video, WxH specifies
  2829. the size of the main input to the overlay filter:
  2830. @example
  2831. color=red@@.3:WxH [over]; [in][over] overlay [out]
  2832. @end example
  2833. @item
  2834. Play an original video and a filtered version (here with the deshake
  2835. filter) side by side using the @command{ffplay} tool:
  2836. @example
  2837. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  2838. @end example
  2839. The above command is the same as:
  2840. @example
  2841. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  2842. @end example
  2843. @item
  2844. Chain several overlays in cascade:
  2845. @example
  2846. nullsrc=s=200x200 [bg];
  2847. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  2848. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  2849. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  2850. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  2851. [in3] null, [mid2] overlay=100:100 [out0]
  2852. @end example
  2853. @end itemize
  2854. @section pad
  2855. Add paddings to the input image, and place the original input at the
  2856. given coordinates @var{x}, @var{y}.
  2857. The filter accepts parameters as a list of @var{key}=@var{value} pairs,
  2858. separated by ":".
  2859. If the key of the first options is omitted, the arguments are
  2860. interpreted according to the syntax
  2861. @var{width}:@var{height}:@var{x}:@var{y}:@var{color}.
  2862. A description of the accepted options follows.
  2863. @table @option
  2864. @item width, w
  2865. @item height, h
  2866. Specify an expression for the size of the output image with the
  2867. paddings added. If the value for @var{width} or @var{height} is 0, the
  2868. corresponding input size is used for the output.
  2869. The @var{width} expression can reference the value set by the
  2870. @var{height} expression, and vice versa.
  2871. The default value of @var{width} and @var{height} is 0.
  2872. @item x
  2873. @item y
  2874. Specify an expression for the offsets where to place the input image
  2875. in the padded area with respect to the top/left border of the output
  2876. image.
  2877. The @var{x} expression can reference the value set by the @var{y}
  2878. expression, and vice versa.
  2879. The default value of @var{x} and @var{y} is 0.
  2880. @item color
  2881. Specify the color of the padded area, it can be the name of a color
  2882. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  2883. The default value of @var{color} is "black".
  2884. @end table
  2885. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  2886. options are expressions containing the following constants:
  2887. @table @option
  2888. @item in_w, in_h
  2889. the input video width and height
  2890. @item iw, ih
  2891. same as @var{in_w} and @var{in_h}
  2892. @item out_w, out_h
  2893. the output width and height, that is the size of the padded area as
  2894. specified by the @var{width} and @var{height} expressions
  2895. @item ow, oh
  2896. same as @var{out_w} and @var{out_h}
  2897. @item x, y
  2898. x and y offsets as specified by the @var{x} and @var{y}
  2899. expressions, or NAN if not yet specified
  2900. @item a
  2901. same as @var{iw} / @var{ih}
  2902. @item sar
  2903. input sample aspect ratio
  2904. @item dar
  2905. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2906. @item hsub, vsub
  2907. horizontal and vertical chroma subsample values. For example for the
  2908. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2909. @end table
  2910. @subsection Examples
  2911. @itemize
  2912. @item
  2913. Add paddings with color "violet" to the input video. Output video
  2914. size is 640x480, the top-left corner of the input video is placed at
  2915. column 0, row 40:
  2916. @example
  2917. pad=640:480:0:40:violet
  2918. @end example
  2919. The example above is equivalent to the following command:
  2920. @example
  2921. pad=width=640:height=480:x=0:y=40:color=violet
  2922. @end example
  2923. @item
  2924. Pad the input to get an output with dimensions increased by 3/2,
  2925. and put the input video at the center of the padded area:
  2926. @example
  2927. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  2928. @end example
  2929. @item
  2930. Pad the input to get a squared output with size equal to the maximum
  2931. value between the input width and height, and put the input video at
  2932. the center of the padded area:
  2933. @example
  2934. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  2935. @end example
  2936. @item
  2937. Pad the input to get a final w/h ratio of 16:9:
  2938. @example
  2939. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  2940. @end example
  2941. @item
  2942. In case of anamorphic video, in order to set the output display aspect
  2943. correctly, it is necessary to use @var{sar} in the expression,
  2944. according to the relation:
  2945. @example
  2946. (ih * X / ih) * sar = output_dar
  2947. X = output_dar / sar
  2948. @end example
  2949. Thus the previous example needs to be modified to:
  2950. @example
  2951. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  2952. @end example
  2953. @item
  2954. Double output size and put the input video in the bottom-right
  2955. corner of the output padded area:
  2956. @example
  2957. pad="2*iw:2*ih:ow-iw:oh-ih"
  2958. @end example
  2959. @end itemize
  2960. @section pixdesctest
  2961. Pixel format descriptor test filter, mainly useful for internal
  2962. testing. The output video should be equal to the input video.
  2963. For example:
  2964. @example
  2965. format=monow, pixdesctest
  2966. @end example
  2967. can be used to test the monowhite pixel format descriptor definition.
  2968. @section pp
  2969. Enable the specified chain of postprocessing subfilters using libpostproc. This
  2970. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  2971. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  2972. Each subfilter and some options have a short and a long name that can be used
  2973. interchangeably, i.e. dr/dering are the same.
  2974. All subfilters share common options to determine their scope:
  2975. @table @option
  2976. @item a/autoq
  2977. Honor the quality commands for this subfilter.
  2978. @item c/chrom
  2979. Do chrominance filtering, too (default).
  2980. @item y/nochrom
  2981. Do luminance filtering only (no chrominance).
  2982. @item n/noluma
  2983. Do chrominance filtering only (no luminance).
  2984. @end table
  2985. These options can be appended after the subfilter name, separated by a ':'.
  2986. Available subfilters are:
  2987. @table @option
  2988. @item hb/hdeblock[:difference[:flatness]]
  2989. Horizontal deblocking filter
  2990. @table @option
  2991. @item difference
  2992. Difference factor where higher values mean more deblocking (default: @code{32}).
  2993. @item flatness
  2994. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  2995. @end table
  2996. @item vb/vdeblock[:difference[:flatness]]
  2997. Vertical deblocking filter
  2998. @table @option
  2999. @item difference
  3000. Difference factor where higher values mean more deblocking (default: @code{32}).
  3001. @item flatness
  3002. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  3003. @end table
  3004. @item ha/hadeblock[:difference[:flatness]]
  3005. Accurate horizontal deblocking filter
  3006. @table @option
  3007. @item difference
  3008. Difference factor where higher values mean more deblocking (default: @code{32}).
  3009. @item flatness
  3010. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  3011. @end table
  3012. @item va/vadeblock[:difference[:flatness]]
  3013. Accurate vertical deblocking filter
  3014. @table @option
  3015. @item difference
  3016. Difference factor where higher values mean more deblocking (default: @code{32}).
  3017. @item flatness
  3018. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  3019. @end table
  3020. @end table
  3021. The horizontal and vertical deblocking filters share the difference and
  3022. flatness values so you cannot set different horizontal and vertical
  3023. thresholds.
  3024. @table @option
  3025. @item h1/x1hdeblock
  3026. Experimental horizontal deblocking filter
  3027. @item v1/x1vdeblock
  3028. Experimental vertical deblocking filter
  3029. @item dr/dering
  3030. Deringing filter
  3031. @item tn/tmpnoise[:threshold1[:threshold2[:threshold3]]], temporal noise reducer
  3032. @table @option
  3033. @item threshold1
  3034. larger -> stronger filtering
  3035. @item threshold2
  3036. larger -> stronger filtering
  3037. @item threshold3
  3038. larger -> stronger filtering
  3039. @end table
  3040. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  3041. @table @option
  3042. @item f/fullyrange
  3043. Stretch luminance to @code{0-255}.
  3044. @end table
  3045. @item lb/linblenddeint
  3046. Linear blend deinterlacing filter that deinterlaces the given block by
  3047. filtering all lines with a @code{(1 2 1)} filter.
  3048. @item li/linipoldeint
  3049. Linear interpolating deinterlacing filter that deinterlaces the given block by
  3050. linearly interpolating every second line.
  3051. @item ci/cubicipoldeint
  3052. Cubic interpolating deinterlacing filter deinterlaces the given block by
  3053. cubically interpolating every second line.
  3054. @item md/mediandeint
  3055. Median deinterlacing filter that deinterlaces the given block by applying a
  3056. median filter to every second line.
  3057. @item fd/ffmpegdeint
  3058. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  3059. second line with a @code{(-1 4 2 4 -1)} filter.
  3060. @item l5/lowpass5
  3061. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  3062. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  3063. @item fq/forceQuant[:quantizer]
  3064. Overrides the quantizer table from the input with the constant quantizer you
  3065. specify.
  3066. @table @option
  3067. @item quantizer
  3068. Quantizer to use
  3069. @end table
  3070. @item de/default
  3071. Default pp filter combination (@code{hb:a,vb:a,dr:a})
  3072. @item fa/fast
  3073. Fast pp filter combination (@code{h1:a,v1:a,dr:a})
  3074. @item ac
  3075. High quality pp filter combination (@code{ha:a:128:7,va:a,dr:a})
  3076. @end table
  3077. @subsection Examples
  3078. @itemize
  3079. @item
  3080. Apply horizontal and vertical deblocking, deringing and automatic
  3081. brightness/contrast:
  3082. @example
  3083. pp=hb/vb/dr/al
  3084. @end example
  3085. @item
  3086. Apply default filters without brightness/contrast correction:
  3087. @example
  3088. pp=de/-al
  3089. @end example
  3090. @item
  3091. Apply default filters and temporal denoiser:
  3092. @example
  3093. pp=default/tmpnoise:1:2:3
  3094. @end example
  3095. @item
  3096. Apply deblocking on luminance only, and switch vertical deblocking on or off
  3097. automatically depending on available CPU time:
  3098. @example
  3099. pp=hb:y/vb:a
  3100. @end example
  3101. @end itemize
  3102. @section removelogo
  3103. Suppress a TV station logo, using an image file to determine which
  3104. pixels comprise the logo. It works by filling in the pixels that
  3105. comprise the logo with neighboring pixels.
  3106. This filter requires one argument which specifies the filter bitmap
  3107. file, which can be any image format supported by libavformat. The
  3108. width and height of the image file must match those of the video
  3109. stream being processed.
  3110. Pixels in the provided bitmap image with a value of zero are not
  3111. considered part of the logo, non-zero pixels are considered part of
  3112. the logo. If you use white (255) for the logo and black (0) for the
  3113. rest, you will be safe. For making the filter bitmap, it is
  3114. recommended to take a screen capture of a black frame with the logo
  3115. visible, and then using a threshold filter followed by the erode
  3116. filter once or twice.
  3117. If needed, little splotches can be fixed manually. Remember that if
  3118. logo pixels are not covered, the filter quality will be much
  3119. reduced. Marking too many pixels as part of the logo does not hurt as
  3120. much, but it will increase the amount of blurring needed to cover over
  3121. the image and will destroy more information than necessary, and extra
  3122. pixels will slow things down on a large logo.
  3123. @section scale
  3124. Scale (resize) the input video, using the libswscale library.
  3125. The scale filter forces the output display aspect ratio to be the same
  3126. of the input, by changing the output sample aspect ratio.
  3127. This filter accepts a list of named options in the form of
  3128. @var{key}=@var{value} pairs separated by ":". If the key for the first
  3129. two options is not specified, the assumed keys for the first two
  3130. values are @code{w} and @code{h}. If the first option has no key and
  3131. can be interpreted like a video size specification, it will be used
  3132. to set the video size.
  3133. A description of the accepted options follows.
  3134. @table @option
  3135. @item width, w
  3136. Set the video width expression, default value is @code{iw}. See below
  3137. for the list of accepted constants.
  3138. @item height, h
  3139. Set the video heiht expression, default value is @code{ih}.
  3140. See below for the list of accepted constants.
  3141. @item interl
  3142. Set the interlacing. It accepts the following values:
  3143. @table @option
  3144. @item 1
  3145. force interlaced aware scaling
  3146. @item 0
  3147. do not apply interlaced scaling
  3148. @item -1
  3149. select interlaced aware scaling depending on whether the source frames
  3150. are flagged as interlaced or not
  3151. @end table
  3152. Default value is @code{0}.
  3153. @item flags
  3154. Set libswscale scaling flags. If not explictly specified the filter
  3155. applies a bilinear scaling algorithm.
  3156. @item size, s
  3157. Set the video size, the value must be a valid abbreviation or in the
  3158. form @var{width}x@var{height}.
  3159. @end table
  3160. The values of the @var{w} and @var{h} options are expressions
  3161. containing the following constants:
  3162. @table @option
  3163. @item in_w, in_h
  3164. the input width and height
  3165. @item iw, ih
  3166. same as @var{in_w} and @var{in_h}
  3167. @item out_w, out_h
  3168. the output (cropped) width and height
  3169. @item ow, oh
  3170. same as @var{out_w} and @var{out_h}
  3171. @item a
  3172. same as @var{iw} / @var{ih}
  3173. @item sar
  3174. input sample aspect ratio
  3175. @item dar
  3176. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  3177. @item hsub, vsub
  3178. horizontal and vertical chroma subsample values. For example for the
  3179. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3180. @end table
  3181. If the input image format is different from the format requested by
  3182. the next filter, the scale filter will convert the input to the
  3183. requested format.
  3184. If the value for @var{width} or @var{height} is 0, the respective input
  3185. size is used for the output.
  3186. If the value for @var{width} or @var{height} is -1, the scale filter will
  3187. use, for the respective output size, a value that maintains the aspect
  3188. ratio of the input image.
  3189. @subsection Examples
  3190. @itemize
  3191. @item
  3192. Scale the input video to a size of 200x100:
  3193. @example
  3194. scale=200:100
  3195. @end example
  3196. This is equivalent to:
  3197. @example
  3198. scale=w=200:h=100
  3199. @end example
  3200. or:
  3201. @example
  3202. scale=200x100
  3203. @end example
  3204. @item
  3205. Specify a size abbreviation for the output size:
  3206. @example
  3207. scale=qcif
  3208. @end example
  3209. which can also be written as:
  3210. @example
  3211. scale=size=qcif
  3212. @end example
  3213. @item
  3214. Scale the input to 2x:
  3215. @example
  3216. scale=2*iw:2*ih
  3217. @end example
  3218. @item
  3219. The above is the same as:
  3220. @example
  3221. scale=2*in_w:2*in_h
  3222. @end example
  3223. @item
  3224. Scale the input to 2x with forced interlaced scaling:
  3225. @example
  3226. scale=2*iw:2*ih:interl=1
  3227. @end example
  3228. @item
  3229. Scale the input to half size:
  3230. @example
  3231. scale=iw/2:ih/2
  3232. @end example
  3233. @item
  3234. Increase the width, and set the height to the same size:
  3235. @example
  3236. scale=3/2*iw:ow
  3237. @end example
  3238. @item
  3239. Seek for Greek harmony:
  3240. @example
  3241. scale=iw:1/PHI*iw
  3242. scale=ih*PHI:ih
  3243. @end example
  3244. @item
  3245. Increase the height, and set the width to 3/2 of the height:
  3246. @example
  3247. scale=3/2*oh:3/5*ih
  3248. @end example
  3249. @item
  3250. Increase the size, but make the size a multiple of the chroma:
  3251. @example
  3252. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  3253. @end example
  3254. @item
  3255. Increase the width to a maximum of 500 pixels, keep the same input
  3256. aspect ratio:
  3257. @example
  3258. scale='min(500\, iw*3/2):-1'
  3259. @end example
  3260. @end itemize
  3261. @section setdar, setsar
  3262. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  3263. output video.
  3264. This is done by changing the specified Sample (aka Pixel) Aspect
  3265. Ratio, according to the following equation:
  3266. @example
  3267. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  3268. @end example
  3269. Keep in mind that the @code{setdar} filter does not modify the pixel
  3270. dimensions of the video frame. Also the display aspect ratio set by
  3271. this filter may be changed by later filters in the filterchain,
  3272. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  3273. applied.
  3274. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  3275. the filter output video.
  3276. Note that as a consequence of the application of this filter, the
  3277. output display aspect ratio will change according to the equation
  3278. above.
  3279. Keep in mind that the sample aspect ratio set by the @code{setsar}
  3280. filter may be changed by later filters in the filterchain, e.g. if
  3281. another "setsar" or a "setdar" filter is applied.
  3282. The @code{setdar} and @code{setsar} filters accept a string in the
  3283. form @var{num}:@var{den} expressing an aspect ratio, or the following
  3284. named options, expressed as a sequence of @var{key}=@var{value} pairs,
  3285. separated by ":".
  3286. @table @option
  3287. @item max
  3288. Set the maximum integer value to use for expressing numerator and
  3289. denominator when reducing the expressed aspect ratio to a rational.
  3290. Default value is @code{100}.
  3291. @item r, ratio:
  3292. Set the aspect ratio used by the filter.
  3293. The parameter can be a floating point number string, an expression, or
  3294. a string of the form @var{num}:@var{den}, where @var{num} and
  3295. @var{den} are the numerator and denominator of the aspect ratio. If
  3296. the parameter is not specified, it is assumed the value "0".
  3297. In case the form "@var{num}:@var{den}" the @code{:} character should
  3298. be escaped.
  3299. @end table
  3300. If the keys are omitted in the named options list, the specifed values
  3301. are assumed to be @var{ratio} and @var{max} in that order.
  3302. For example to change the display aspect ratio to 16:9, specify:
  3303. @example
  3304. setdar='16:9'
  3305. @end example
  3306. The example above is equivalent to:
  3307. @example
  3308. setdar=1.77777
  3309. @end example
  3310. To change the sample aspect ratio to 10:11, specify:
  3311. @example
  3312. setsar='10:11'
  3313. @end example
  3314. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  3315. 1000 in the aspect ratio reduction, use the command:
  3316. @example
  3317. setdar=ratio='16:9':max=1000
  3318. @end example
  3319. @section setfield
  3320. Force field for the output video frame.
  3321. The @code{setfield} filter marks the interlace type field for the
  3322. output frames. It does not change the input frame, but only sets the
  3323. corresponding property, which affects how the frame is treated by
  3324. following filters (e.g. @code{fieldorder} or @code{yadif}).
  3325. This filter accepts a single option @option{mode}, which can be
  3326. specified either by setting @code{mode=VALUE} or setting the value
  3327. alone. Available values are:
  3328. @table @samp
  3329. @item auto
  3330. Keep the same field property.
  3331. @item bff
  3332. Mark the frame as bottom-field-first.
  3333. @item tff
  3334. Mark the frame as top-field-first.
  3335. @item prog
  3336. Mark the frame as progressive.
  3337. @end table
  3338. @section showinfo
  3339. Show a line containing various information for each input video frame.
  3340. The input video is not modified.
  3341. The shown line contains a sequence of key/value pairs of the form
  3342. @var{key}:@var{value}.
  3343. A description of each shown parameter follows:
  3344. @table @option
  3345. @item n
  3346. sequential number of the input frame, starting from 0
  3347. @item pts
  3348. Presentation TimeStamp of the input frame, expressed as a number of
  3349. time base units. The time base unit depends on the filter input pad.
  3350. @item pts_time
  3351. Presentation TimeStamp of the input frame, expressed as a number of
  3352. seconds
  3353. @item pos
  3354. position of the frame in the input stream, -1 if this information in
  3355. unavailable and/or meaningless (for example in case of synthetic video)
  3356. @item fmt
  3357. pixel format name
  3358. @item sar
  3359. sample aspect ratio of the input frame, expressed in the form
  3360. @var{num}/@var{den}
  3361. @item s
  3362. size of the input frame, expressed in the form
  3363. @var{width}x@var{height}
  3364. @item i
  3365. interlaced mode ("P" for "progressive", "T" for top field first, "B"
  3366. for bottom field first)
  3367. @item iskey
  3368. 1 if the frame is a key frame, 0 otherwise
  3369. @item type
  3370. picture type of the input frame ("I" for an I-frame, "P" for a
  3371. P-frame, "B" for a B-frame, "?" for unknown type).
  3372. Check also the documentation of the @code{AVPictureType} enum and of
  3373. the @code{av_get_picture_type_char} function defined in
  3374. @file{libavutil/avutil.h}.
  3375. @item checksum
  3376. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  3377. @item plane_checksum
  3378. Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  3379. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]"
  3380. @end table
  3381. @section smartblur
  3382. Blur the input video without impacting the outlines.
  3383. The filter accepts the following parameters:
  3384. @var{luma_radius}:@var{luma_strength}:@var{luma_threshold}[:@var{chroma_radius}:@var{chroma_strength}:@var{chroma_threshold}]
  3385. Parameters prefixed by @var{luma} indicate that they work on the
  3386. luminance of the pixels whereas parameters prefixed by @var{chroma}
  3387. refer to the chrominance of the pixels.
  3388. If the chroma parameters are not set, the luma parameters are used for
  3389. either the luminance and the chrominance of the pixels.
  3390. @var{luma_radius} or @var{chroma_radius} must be a float number in the
  3391. range [0.1,5.0] that specifies the variance of the gaussian filter
  3392. used to blur the image (slower if larger).
  3393. @var{luma_strength} or @var{chroma_strength} must be a float number in
  3394. the range [-1.0,1.0] that configures the blurring. A value included in
  3395. [0.0,1.0] will blur the image whereas a value included in [-1.0,0.0]
  3396. will sharpen the image.
  3397. @var{luma_threshold} or @var{chroma_threshold} must be an integer in
  3398. the range [-30,30] that is used as a coefficient to determine whether
  3399. a pixel should be blurred or not. A value of 0 will filter all the
  3400. image, a value included in [0,30] will filter flat areas and a value
  3401. included in [-30,0] will filter edges.
  3402. @anchor{subtitles}
  3403. @section subtitles
  3404. Draw subtitles on top of input video using the libass library.
  3405. To enable compilation of this filter you need to configure FFmpeg with
  3406. @code{--enable-libass}. This filter also requires a build with libavcodec and
  3407. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  3408. Alpha) subtitles format.
  3409. This filter accepts the following named options, expressed as a
  3410. sequence of @var{key}=@var{value} pairs, separated by ":".
  3411. @table @option
  3412. @item filename, f
  3413. Set the filename of the subtitle file to read. It must be specified.
  3414. @item original_size
  3415. Specify the size of the original video, the video for which the ASS file
  3416. was composed. Due to a misdesign in ASS aspect ratio arithmetic, this is
  3417. necessary to correctly scale the fonts if the aspect ratio has been changed.
  3418. @end table
  3419. If the first key is not specified, it is assumed that the first value
  3420. specifies the @option{filename}.
  3421. For example, to render the file @file{sub.srt} on top of the input
  3422. video, use the command:
  3423. @example
  3424. subtitles=sub.srt
  3425. @end example
  3426. which is equivalent to:
  3427. @example
  3428. subtitles=filename=sub.srt
  3429. @end example
  3430. @section split
  3431. Split input video into several identical outputs.
  3432. The filter accepts a single parameter which specifies the number of outputs. If
  3433. unspecified, it defaults to 2.
  3434. For example
  3435. @example
  3436. ffmpeg -i INPUT -filter_complex split=5 OUTPUT
  3437. @end example
  3438. will create 5 copies of the input video.
  3439. For example:
  3440. @example
  3441. [in] split [splitout1][splitout2];
  3442. [splitout1] crop=100:100:0:0 [cropout];
  3443. [splitout2] pad=200:200:100:100 [padout];
  3444. @end example
  3445. will create two separate outputs from the same input, one cropped and
  3446. one padded.
  3447. @section super2xsai
  3448. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  3449. Interpolate) pixel art scaling algorithm.
  3450. Useful for enlarging pixel art images without reducing sharpness.
  3451. @section swapuv
  3452. Swap U & V plane.
  3453. @section thumbnail
  3454. Select the most representative frame in a given sequence of consecutive frames.
  3455. It accepts as argument the frames batch size to analyze (default @var{N}=100);
  3456. in a set of @var{N} frames, the filter will pick one of them, and then handle
  3457. the next batch of @var{N} frames until the end.
  3458. Since the filter keeps track of the whole frames sequence, a bigger @var{N}
  3459. value will result in a higher memory usage, so a high value is not recommended.
  3460. The following example extract one picture each 50 frames:
  3461. @example
  3462. thumbnail=50
  3463. @end example
  3464. Complete example of a thumbnail creation with @command{ffmpeg}:
  3465. @example
  3466. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  3467. @end example
  3468. @section tile
  3469. Tile several successive frames together.
  3470. It accepts a list of options in the form of @var{key}=@var{value} pairs
  3471. separated by ":". A description of the accepted options follows.
  3472. @table @option
  3473. @item layout
  3474. Set the grid size (i.e. the number of lines and columns) in the form
  3475. "@var{w}x@var{h}".
  3476. @item margin
  3477. Set the outer border margin in pixels.
  3478. @item padding
  3479. Set the inner border thickness (i.e. the number of pixels between frames). For
  3480. more advanced padding options (such as having different values for the edges),
  3481. refer to the pad video filter.
  3482. @item nb_frames
  3483. Set the maximum number of frames to render in the given area. It must be less
  3484. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  3485. the area will be used.
  3486. @end table
  3487. Alternatively, the options can be specified as a flat string:
  3488. @var{layout}[:@var{nb_frames}[:@var{margin}[:@var{padding}]]]
  3489. For example, produce 8×8 PNG tiles of all keyframes (@option{-skip_frame
  3490. nokey}) in a movie:
  3491. @example
  3492. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  3493. @end example
  3494. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  3495. duplicating each output frame to accomodate the originally detected frame
  3496. rate.
  3497. Another example to display @code{5} pictures in an area of @code{3x2} frames,
  3498. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  3499. mixed flat and named options:
  3500. @example
  3501. tile=3x2:nb_frames=5:padding=7:margin=2
  3502. @end example
  3503. @section tinterlace
  3504. Perform various types of temporal field interlacing.
  3505. Frames are counted starting from 1, so the first input frame is
  3506. considered odd.
  3507. This filter accepts options in the form of @var{key}=@var{value} pairs
  3508. separated by ":".
  3509. Alternatively, the @var{mode} option can be specified as a value alone,
  3510. optionally followed by a ":" and further ":" separated @var{key}=@var{value}
  3511. pairs.
  3512. A description of the accepted options follows.
  3513. @table @option
  3514. @item mode
  3515. Specify the mode of the interlacing. This option can also be specified
  3516. as a value alone. See below for a list of values for this option.
  3517. Available values are:
  3518. @table @samp
  3519. @item merge, 0
  3520. Move odd frames into the upper field, even into the lower field,
  3521. generating a double height frame at half framerate.
  3522. @item drop_odd, 1
  3523. Only output even frames, odd frames are dropped, generating a frame with
  3524. unchanged height at half framerate.
  3525. @item drop_even, 2
  3526. Only output odd frames, even frames are dropped, generating a frame with
  3527. unchanged height at half framerate.
  3528. @item pad, 3
  3529. Expand each frame to full height, but pad alternate lines with black,
  3530. generating a frame with double height at the same input framerate.
  3531. @item interleave_top, 4
  3532. Interleave the upper field from odd frames with the lower field from
  3533. even frames, generating a frame with unchanged height at half framerate.
  3534. @item interleave_bottom, 5
  3535. Interleave the lower field from odd frames with the upper field from
  3536. even frames, generating a frame with unchanged height at half framerate.
  3537. @item interlacex2, 6
  3538. Double frame rate with unchanged height. Frames are inserted each
  3539. containing the second temporal field from the previous input frame and
  3540. the first temporal field from the next input frame. This mode relies on
  3541. the top_field_first flag. Useful for interlaced video displays with no
  3542. field synchronisation.
  3543. @end table
  3544. Numeric values are deprecated but are accepted for backward
  3545. compatibility reasons.
  3546. Default mode is @code{merge}.
  3547. @item flags
  3548. Specify flags influencing the filter process.
  3549. Available value for @var{flags} is:
  3550. @table @option
  3551. @item low_pass_filter, vlfp
  3552. Enable vertical low-pass filtering in the filter.
  3553. Vertical low-pass filtering is required when creating an interlaced
  3554. destination from a progressive source which contains high-frequency
  3555. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  3556. patterning.
  3557. Vertical low-pass filtering can only be enabled for @option{mode}
  3558. @var{interleave_top} and @var{interleave_bottom}.
  3559. @end table
  3560. @end table
  3561. @section transpose
  3562. Transpose rows with columns in the input video and optionally flip it.
  3563. The filter accepts parameters as a list of @var{key}=@var{value}
  3564. pairs, separated by ':'. If the key of the first options is omitted,
  3565. the arguments are interpreted according to the syntax
  3566. @var{dir}:@var{passthrough}.
  3567. @table @option
  3568. @item dir
  3569. Specify the transposition direction. Can assume the following values:
  3570. @table @samp
  3571. @item 0, 4
  3572. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  3573. @example
  3574. L.R L.l
  3575. . . -> . .
  3576. l.r R.r
  3577. @end example
  3578. @item 1, 5
  3579. Rotate by 90 degrees clockwise, that is:
  3580. @example
  3581. L.R l.L
  3582. . . -> . .
  3583. l.r r.R
  3584. @end example
  3585. @item 2, 6
  3586. Rotate by 90 degrees counterclockwise, that is:
  3587. @example
  3588. L.R R.r
  3589. . . -> . .
  3590. l.r L.l
  3591. @end example
  3592. @item 3, 7
  3593. Rotate by 90 degrees clockwise and vertically flip, that is:
  3594. @example
  3595. L.R r.R
  3596. . . -> . .
  3597. l.r l.L
  3598. @end example
  3599. @end table
  3600. For values between 4-7, the transposition is only done if the input
  3601. video geometry is portrait and not landscape. These values are
  3602. deprecated, the @code{passthrough} option should be used instead.
  3603. @item passthrough
  3604. Do not apply the transposition if the input geometry matches the one
  3605. specified by the specified value. It accepts the following values:
  3606. @table @samp
  3607. @item none
  3608. Always apply transposition.
  3609. @item portrait
  3610. Preserve portrait geometry (when @var{height} >= @var{width}).
  3611. @item landscape
  3612. Preserve landscape geometry (when @var{width} >= @var{height}).
  3613. @end table
  3614. Default value is @code{none}.
  3615. @end table
  3616. For example to rotate by 90 degrees clockwise and preserve portrait
  3617. layout:
  3618. @example
  3619. transpose=dir=1:passthrough=portrait
  3620. @end example
  3621. The command above can also be specified as:
  3622. @example
  3623. transpose=1:portrait
  3624. @end example
  3625. @section unsharp
  3626. Sharpen or blur the input video.
  3627. It accepts the following parameters:
  3628. @var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount}
  3629. Negative values for the amount will blur the input video, while positive
  3630. values will sharpen. All parameters are optional and default to the
  3631. equivalent of the string '5:5:1.0:5:5:0.0'.
  3632. @table @option
  3633. @item luma_msize_x
  3634. Set the luma matrix horizontal size. It can be an integer between 3
  3635. and 13, default value is 5.
  3636. @item luma_msize_y
  3637. Set the luma matrix vertical size. It can be an integer between 3
  3638. and 13, default value is 5.
  3639. @item luma_amount
  3640. Set the luma effect strength. It can be a float number between -2.0
  3641. and 5.0, default value is 1.0.
  3642. @item chroma_msize_x
  3643. Set the chroma matrix horizontal size. It can be an integer between 3
  3644. and 13, default value is 5.
  3645. @item chroma_msize_y
  3646. Set the chroma matrix vertical size. It can be an integer between 3
  3647. and 13, default value is 5.
  3648. @item chroma_amount
  3649. Set the chroma effect strength. It can be a float number between -2.0
  3650. and 5.0, default value is 0.0.
  3651. @end table
  3652. @example
  3653. # Strong luma sharpen effect parameters
  3654. unsharp=7:7:2.5
  3655. # Strong blur of both luma and chroma parameters
  3656. unsharp=7:7:-2:7:7:-2
  3657. # Use the default values with @command{ffmpeg}
  3658. ffmpeg -i in.avi -vf "unsharp" out.mp4
  3659. @end example
  3660. @section vflip
  3661. Flip the input video vertically.
  3662. @example
  3663. ffmpeg -i in.avi -vf "vflip" out.avi
  3664. @end example
  3665. @section yadif
  3666. Deinterlace the input video ("yadif" means "yet another deinterlacing
  3667. filter").
  3668. The filter accepts parameters as a list of @var{key}=@var{value}
  3669. pairs, separated by ":". If the key of the first options is omitted,
  3670. the arguments are interpreted according to syntax
  3671. @var{mode}:@var{parity}:@var{deint}.
  3672. The description of the accepted parameters follows.
  3673. @table @option
  3674. @item mode
  3675. Specify the interlacing mode to adopt. Accept one of the following
  3676. values:
  3677. @table @option
  3678. @item 0, send_frame
  3679. output 1 frame for each frame
  3680. @item 1, send_field
  3681. output 1 frame for each field
  3682. @item 2, send_frame_nospatial
  3683. like @code{send_frame} but skip spatial interlacing check
  3684. @item 3, send_field_nospatial
  3685. like @code{send_field} but skip spatial interlacing check
  3686. @end table
  3687. Default value is @code{send_frame}.
  3688. @item parity
  3689. Specify the picture field parity assumed for the input interlaced
  3690. video. Accept one of the following values:
  3691. @table @option
  3692. @item 0, tff
  3693. assume top field first
  3694. @item 1, bff
  3695. assume bottom field first
  3696. @item -1, auto
  3697. enable automatic detection
  3698. @end table
  3699. Default value is @code{auto}.
  3700. If interlacing is unknown or decoder does not export this information,
  3701. top field first will be assumed.
  3702. @item deint
  3703. Specify which frames to deinterlace. Accept one of the following
  3704. values:
  3705. @table @option
  3706. @item 0, all
  3707. deinterlace all frames
  3708. @item 1, interlaced
  3709. only deinterlace frames marked as interlaced
  3710. @end table
  3711. Default value is @code{all}.
  3712. @end table
  3713. @c man end VIDEO FILTERS
  3714. @chapter Video Sources
  3715. @c man begin VIDEO SOURCES
  3716. Below is a description of the currently available video sources.
  3717. @section buffer
  3718. Buffer video frames, and make them available to the filter chain.
  3719. This source is mainly intended for a programmatic use, in particular
  3720. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  3721. It accepts a list of options in the form of @var{key}=@var{value} pairs
  3722. separated by ":". A description of the accepted options follows.
  3723. @table @option
  3724. @item video_size
  3725. Specify the size (width and height) of the buffered video frames.
  3726. @item pix_fmt
  3727. A string representing the pixel format of the buffered video frames.
  3728. It may be a number corresponding to a pixel format, or a pixel format
  3729. name.
  3730. @item time_base
  3731. Specify the timebase assumed by the timestamps of the buffered frames.
  3732. @item time_base
  3733. Specify the frame rate expected for the video stream.
  3734. @item pixel_aspect
  3735. Specify the sample aspect ratio assumed by the video frames.
  3736. @item sws_param
  3737. Specify the optional parameters to be used for the scale filter which
  3738. is automatically inserted when an input change is detected in the
  3739. input size or format.
  3740. @end table
  3741. For example:
  3742. @example
  3743. buffer=size=320x240:pix_fmt=yuv410p:time_base=1/24:pixel_aspect=1/1
  3744. @end example
  3745. will instruct the source to accept video frames with size 320x240 and
  3746. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  3747. square pixels (1:1 sample aspect ratio).
  3748. Since the pixel format with name "yuv410p" corresponds to the number 6
  3749. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  3750. this example corresponds to:
  3751. @example
  3752. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  3753. @end example
  3754. Alternatively, the options can be specified as a flat string, but this
  3755. syntax is deprecated:
  3756. @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}]
  3757. @section cellauto
  3758. Create a pattern generated by an elementary cellular automaton.
  3759. The initial state of the cellular automaton can be defined through the
  3760. @option{filename}, and @option{pattern} options. If such options are
  3761. not specified an initial state is created randomly.
  3762. At each new frame a new row in the video is filled with the result of
  3763. the cellular automaton next generation. The behavior when the whole
  3764. frame is filled is defined by the @option{scroll} option.
  3765. This source accepts a list of options in the form of
  3766. @var{key}=@var{value} pairs separated by ":". A description of the
  3767. accepted options follows.
  3768. @table @option
  3769. @item filename, f
  3770. Read the initial cellular automaton state, i.e. the starting row, from
  3771. the specified file.
  3772. In the file, each non-whitespace character is considered an alive
  3773. cell, a newline will terminate the row, and further characters in the
  3774. file will be ignored.
  3775. @item pattern, p
  3776. Read the initial cellular automaton state, i.e. the starting row, from
  3777. the specified string.
  3778. Each non-whitespace character in the string is considered an alive
  3779. cell, a newline will terminate the row, and further characters in the
  3780. string will be ignored.
  3781. @item rate, r
  3782. Set the video rate, that is the number of frames generated per second.
  3783. Default is 25.
  3784. @item random_fill_ratio, ratio
  3785. Set the random fill ratio for the initial cellular automaton row. It
  3786. is a floating point number value ranging from 0 to 1, defaults to
  3787. 1/PHI.
  3788. This option is ignored when a file or a pattern is specified.
  3789. @item random_seed, seed
  3790. Set the seed for filling randomly the initial row, must be an integer
  3791. included between 0 and UINT32_MAX. If not specified, or if explicitly
  3792. set to -1, the filter will try to use a good random seed on a best
  3793. effort basis.
  3794. @item rule
  3795. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  3796. Default value is 110.
  3797. @item size, s
  3798. Set the size of the output video.
  3799. If @option{filename} or @option{pattern} is specified, the size is set
  3800. by default to the width of the specified initial state row, and the
  3801. height is set to @var{width} * PHI.
  3802. If @option{size} is set, it must contain the width of the specified
  3803. pattern string, and the specified pattern will be centered in the
  3804. larger row.
  3805. If a filename or a pattern string is not specified, the size value
  3806. defaults to "320x518" (used for a randomly generated initial state).
  3807. @item scroll
  3808. If set to 1, scroll the output upward when all the rows in the output
  3809. have been already filled. If set to 0, the new generated row will be
  3810. written over the top row just after the bottom row is filled.
  3811. Defaults to 1.
  3812. @item start_full, full
  3813. If set to 1, completely fill the output with generated rows before
  3814. outputting the first frame.
  3815. This is the default behavior, for disabling set the value to 0.
  3816. @item stitch
  3817. If set to 1, stitch the left and right row edges together.
  3818. This is the default behavior, for disabling set the value to 0.
  3819. @end table
  3820. @subsection Examples
  3821. @itemize
  3822. @item
  3823. Read the initial state from @file{pattern}, and specify an output of
  3824. size 200x400.
  3825. @example
  3826. cellauto=f=pattern:s=200x400
  3827. @end example
  3828. @item
  3829. Generate a random initial row with a width of 200 cells, with a fill
  3830. ratio of 2/3:
  3831. @example
  3832. cellauto=ratio=2/3:s=200x200
  3833. @end example
  3834. @item
  3835. Create a pattern generated by rule 18 starting by a single alive cell
  3836. centered on an initial row with width 100:
  3837. @example
  3838. cellauto=p=@@:s=100x400:full=0:rule=18
  3839. @end example
  3840. @item
  3841. Specify a more elaborated initial pattern:
  3842. @example
  3843. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  3844. @end example
  3845. @end itemize
  3846. @section mandelbrot
  3847. Generate a Mandelbrot set fractal, and progressively zoom towards the
  3848. point specified with @var{start_x} and @var{start_y}.
  3849. This source accepts a list of options in the form of
  3850. @var{key}=@var{value} pairs separated by ":". A description of the
  3851. accepted options follows.
  3852. @table @option
  3853. @item end_pts
  3854. Set the terminal pts value. Default value is 400.
  3855. @item end_scale
  3856. Set the terminal scale value.
  3857. Must be a floating point value. Default value is 0.3.
  3858. @item inner
  3859. Set the inner coloring mode, that is the algorithm used to draw the
  3860. Mandelbrot fractal internal region.
  3861. It shall assume one of the following values:
  3862. @table @option
  3863. @item black
  3864. Set black mode.
  3865. @item convergence
  3866. Show time until convergence.
  3867. @item mincol
  3868. Set color based on point closest to the origin of the iterations.
  3869. @item period
  3870. Set period mode.
  3871. @end table
  3872. Default value is @var{mincol}.
  3873. @item bailout
  3874. Set the bailout value. Default value is 10.0.
  3875. @item maxiter
  3876. Set the maximum of iterations performed by the rendering
  3877. algorithm. Default value is 7189.
  3878. @item outer
  3879. Set outer coloring mode.
  3880. It shall assume one of following values:
  3881. @table @option
  3882. @item iteration_count
  3883. Set iteration cound mode.
  3884. @item normalized_iteration_count
  3885. set normalized iteration count mode.
  3886. @end table
  3887. Default value is @var{normalized_iteration_count}.
  3888. @item rate, r
  3889. Set frame rate, expressed as number of frames per second. Default
  3890. value is "25".
  3891. @item size, s
  3892. Set frame size. Default value is "640x480".
  3893. @item start_scale
  3894. Set the initial scale value. Default value is 3.0.
  3895. @item start_x
  3896. Set the initial x position. Must be a floating point value between
  3897. -100 and 100. Default value is -0.743643887037158704752191506114774.
  3898. @item start_y
  3899. Set the initial y position. Must be a floating point value between
  3900. -100 and 100. Default value is -0.131825904205311970493132056385139.
  3901. @end table
  3902. @section mptestsrc
  3903. Generate various test patterns, as generated by the MPlayer test filter.
  3904. The size of the generated video is fixed, and is 256x256.
  3905. This source is useful in particular for testing encoding features.
  3906. This source accepts an optional sequence of @var{key}=@var{value} pairs,
  3907. separated by ":". The description of the accepted options follows.
  3908. @table @option
  3909. @item rate, r
  3910. Specify the frame rate of the sourced video, as the number of frames
  3911. generated per second. It has to be a string in the format
  3912. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  3913. number or a valid video frame rate abbreviation. The default value is
  3914. "25".
  3915. @item duration, d
  3916. Set the video duration of the sourced video. The accepted syntax is:
  3917. @example
  3918. [-]HH:MM:SS[.m...]
  3919. [-]S+[.m...]
  3920. @end example
  3921. See also the function @code{av_parse_time()}.
  3922. If not specified, or the expressed duration is negative, the video is
  3923. supposed to be generated forever.
  3924. @item test, t
  3925. Set the number or the name of the test to perform. Supported tests are:
  3926. @table @option
  3927. @item dc_luma
  3928. @item dc_chroma
  3929. @item freq_luma
  3930. @item freq_chroma
  3931. @item amp_luma
  3932. @item amp_chroma
  3933. @item cbp
  3934. @item mv
  3935. @item ring1
  3936. @item ring2
  3937. @item all
  3938. @end table
  3939. Default value is "all", which will cycle through the list of all tests.
  3940. @end table
  3941. For example the following:
  3942. @example
  3943. testsrc=t=dc_luma
  3944. @end example
  3945. will generate a "dc_luma" test pattern.
  3946. @section frei0r_src
  3947. Provide a frei0r source.
  3948. To enable compilation of this filter you need to install the frei0r
  3949. header and configure FFmpeg with @code{--enable-frei0r}.
  3950. The source supports the syntax:
  3951. @example
  3952. @var{size}:@var{rate}:@var{src_name}[@{=|:@}@var{param1}:@var{param2}:...:@var{paramN}]
  3953. @end example
  3954. @var{size} is the size of the video to generate, may be a string of the
  3955. form @var{width}x@var{height} or a frame size abbreviation.
  3956. @var{rate} is the rate of the video to generate, may be a string of
  3957. the form @var{num}/@var{den} or a frame rate abbreviation.
  3958. @var{src_name} is the name to the frei0r source to load. For more
  3959. information regarding frei0r and how to set the parameters read the
  3960. section @ref{frei0r} in the description of the video filters.
  3961. For example, to generate a frei0r partik0l source with size 200x200
  3962. and frame rate 10 which is overlayed on the overlay filter main input:
  3963. @example
  3964. frei0r_src=200x200:10:partik0l=1234 [overlay]; [in][overlay] overlay
  3965. @end example
  3966. @section life
  3967. Generate a life pattern.
  3968. This source is based on a generalization of John Conway's life game.
  3969. The sourced input represents a life grid, each pixel represents a cell
  3970. which can be in one of two possible states, alive or dead. Every cell
  3971. interacts with its eight neighbours, which are the cells that are
  3972. horizontally, vertically, or diagonally adjacent.
  3973. At each interaction the grid evolves according to the adopted rule,
  3974. which specifies the number of neighbor alive cells which will make a
  3975. cell stay alive or born. The @option{rule} option allows to specify
  3976. the rule to adopt.
  3977. This source accepts a list of options in the form of
  3978. @var{key}=@var{value} pairs separated by ":". A description of the
  3979. accepted options follows.
  3980. @table @option
  3981. @item filename, f
  3982. Set the file from which to read the initial grid state. In the file,
  3983. each non-whitespace character is considered an alive cell, and newline
  3984. is used to delimit the end of each row.
  3985. If this option is not specified, the initial grid is generated
  3986. randomly.
  3987. @item rate, r
  3988. Set the video rate, that is the number of frames generated per second.
  3989. Default is 25.
  3990. @item random_fill_ratio, ratio
  3991. Set the random fill ratio for the initial random grid. It is a
  3992. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  3993. It is ignored when a file is specified.
  3994. @item random_seed, seed
  3995. Set the seed for filling the initial random grid, must be an integer
  3996. included between 0 and UINT32_MAX. If not specified, or if explicitly
  3997. set to -1, the filter will try to use a good random seed on a best
  3998. effort basis.
  3999. @item rule
  4000. Set the life rule.
  4001. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  4002. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  4003. @var{NS} specifies the number of alive neighbor cells which make a
  4004. live cell stay alive, and @var{NB} the number of alive neighbor cells
  4005. which make a dead cell to become alive (i.e. to "born").
  4006. "s" and "b" can be used in place of "S" and "B", respectively.
  4007. Alternatively a rule can be specified by an 18-bits integer. The 9
  4008. high order bits are used to encode the next cell state if it is alive
  4009. for each number of neighbor alive cells, the low order bits specify
  4010. the rule for "borning" new cells. Higher order bits encode for an
  4011. higher number of neighbor cells.
  4012. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  4013. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  4014. Default value is "S23/B3", which is the original Conway's game of life
  4015. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  4016. cells, and will born a new cell if there are three alive cells around
  4017. a dead cell.
  4018. @item size, s
  4019. Set the size of the output video.
  4020. If @option{filename} is specified, the size is set by default to the
  4021. same size of the input file. If @option{size} is set, it must contain
  4022. the size specified in the input file, and the initial grid defined in
  4023. that file is centered in the larger resulting area.
  4024. If a filename is not specified, the size value defaults to "320x240"
  4025. (used for a randomly generated initial grid).
  4026. @item stitch
  4027. If set to 1, stitch the left and right grid edges together, and the
  4028. top and bottom edges also. Defaults to 1.
  4029. @item mold
  4030. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  4031. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  4032. value from 0 to 255.
  4033. @item life_color
  4034. Set the color of living (or new born) cells.
  4035. @item death_color
  4036. Set the color of dead cells. If @option{mold} is set, this is the first color
  4037. used to represent a dead cell.
  4038. @item mold_color
  4039. Set mold color, for definitely dead and moldy cells.
  4040. @end table
  4041. @subsection Examples
  4042. @itemize
  4043. @item
  4044. Read a grid from @file{pattern}, and center it on a grid of size
  4045. 300x300 pixels:
  4046. @example
  4047. life=f=pattern:s=300x300
  4048. @end example
  4049. @item
  4050. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  4051. @example
  4052. life=ratio=2/3:s=200x200
  4053. @end example
  4054. @item
  4055. Specify a custom rule for evolving a randomly generated grid:
  4056. @example
  4057. life=rule=S14/B34
  4058. @end example
  4059. @item
  4060. Full example with slow death effect (mold) using @command{ffplay}:
  4061. @example
  4062. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  4063. @end example
  4064. @end itemize
  4065. @section color, nullsrc, rgbtestsrc, smptebars, testsrc
  4066. The @code{color} source provides an uniformly colored input.
  4067. The @code{nullsrc} source returns unprocessed video frames. It is
  4068. mainly useful to be employed in analysis / debugging tools, or as the
  4069. source for filters which ignore the input data.
  4070. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  4071. detecting RGB vs BGR issues. You should see a red, green and blue
  4072. stripe from top to bottom.
  4073. The @code{smptebars} source generates a color bars pattern, based on
  4074. the SMPTE Engineering Guideline EG 1-1990.
  4075. The @code{testsrc} source generates a test video pattern, showing a
  4076. color pattern, a scrolling gradient and a timestamp. This is mainly
  4077. intended for testing purposes.
  4078. These sources accept an optional sequence of @var{key}=@var{value} pairs,
  4079. separated by ":". The description of the accepted options follows.
  4080. @table @option
  4081. @item color, c
  4082. Specify the color of the source, only used in the @code{color}
  4083. source. It can be the name of a color (case insensitive match) or a
  4084. 0xRRGGBB[AA] sequence, possibly followed by an alpha specifier. The
  4085. default value is "black".
  4086. @item size, s
  4087. Specify the size of the sourced video, it may be a string of the form
  4088. @var{width}x@var{height}, or the name of a size abbreviation. The
  4089. default value is "320x240".
  4090. @item rate, r
  4091. Specify the frame rate of the sourced video, as the number of frames
  4092. generated per second. It has to be a string in the format
  4093. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  4094. number or a valid video frame rate abbreviation. The default value is
  4095. "25".
  4096. @item sar
  4097. Set the sample aspect ratio of the sourced video.
  4098. @item duration, d
  4099. Set the video duration of the sourced video. The accepted syntax is:
  4100. @example
  4101. [-]HH[:MM[:SS[.m...]]]
  4102. [-]S+[.m...]
  4103. @end example
  4104. See also the function @code{av_parse_time()}.
  4105. If not specified, or the expressed duration is negative, the video is
  4106. supposed to be generated forever.
  4107. @item decimals, n
  4108. Set the number of decimals to show in the timestamp, only used in the
  4109. @code{testsrc} source.
  4110. The displayed timestamp value will correspond to the original
  4111. timestamp value multiplied by the power of 10 of the specified
  4112. value. Default value is 0.
  4113. @end table
  4114. For example the following:
  4115. @example
  4116. testsrc=duration=5.3:size=qcif:rate=10
  4117. @end example
  4118. will generate a video with a duration of 5.3 seconds, with size
  4119. 176x144 and a frame rate of 10 frames per second.
  4120. The following graph description will generate a red source
  4121. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  4122. frames per second.
  4123. @example
  4124. color=c=red@@0.2:s=qcif:r=10
  4125. @end example
  4126. If the input content is to be ignored, @code{nullsrc} can be used. The
  4127. following command generates noise in the luminance plane by employing
  4128. the @code{geq} filter:
  4129. @example
  4130. nullsrc=s=256x256, geq=random(1)*255:128:128
  4131. @end example
  4132. @c man end VIDEO SOURCES
  4133. @chapter Video Sinks
  4134. @c man begin VIDEO SINKS
  4135. Below is a description of the currently available video sinks.
  4136. @section buffersink
  4137. Buffer video frames, and make them available to the end of the filter
  4138. graph.
  4139. This sink is mainly intended for a programmatic use, in particular
  4140. through the interface defined in @file{libavfilter/buffersink.h}.
  4141. It does not require a string parameter in input, but you need to
  4142. specify a pointer to a list of supported pixel formats terminated by
  4143. -1 in the opaque parameter provided to @code{avfilter_init_filter}
  4144. when initializing this sink.
  4145. @section nullsink
  4146. Null video sink, do absolutely nothing with the input video. It is
  4147. mainly useful as a template and to be employed in analysis / debugging
  4148. tools.
  4149. @c man end VIDEO SINKS
  4150. @chapter Multimedia Filters
  4151. @c man begin MULTIMEDIA FILTERS
  4152. Below is a description of the currently available multimedia filters.
  4153. @section aselect, select
  4154. Select frames to pass in output.
  4155. These filters accept a single option @option{expr} or @option{e}
  4156. specifying the select expression, which can be specified either by
  4157. specyfing @code{expr=VALUE} or specifying the expression
  4158. alone.
  4159. The select expression is evaluated for each input frame. If the
  4160. evaluation result is a non-zero value, the frame is selected and
  4161. passed to the output, otherwise it is discarded.
  4162. The expression can contain the following constants:
  4163. @table @option
  4164. @item n
  4165. the sequential number of the filtered frame, starting from 0
  4166. @item selected_n
  4167. the sequential number of the selected frame, starting from 0
  4168. @item prev_selected_n
  4169. the sequential number of the last selected frame, NAN if undefined
  4170. @item TB
  4171. timebase of the input timestamps
  4172. @item pts
  4173. the PTS (Presentation TimeStamp) of the filtered video frame,
  4174. expressed in @var{TB} units, NAN if undefined
  4175. @item t
  4176. the PTS (Presentation TimeStamp) of the filtered video frame,
  4177. expressed in seconds, NAN if undefined
  4178. @item prev_pts
  4179. the PTS of the previously filtered video frame, NAN if undefined
  4180. @item prev_selected_pts
  4181. the PTS of the last previously filtered video frame, NAN if undefined
  4182. @item prev_selected_t
  4183. the PTS of the last previously selected video frame, NAN if undefined
  4184. @item start_pts
  4185. the PTS of the first video frame in the video, NAN if undefined
  4186. @item start_t
  4187. the time of the first video frame in the video, NAN if undefined
  4188. @item pict_type @emph{(video only)}
  4189. the type of the filtered frame, can assume one of the following
  4190. values:
  4191. @table @option
  4192. @item I
  4193. @item P
  4194. @item B
  4195. @item S
  4196. @item SI
  4197. @item SP
  4198. @item BI
  4199. @end table
  4200. @item interlace_type @emph{(video only)}
  4201. the frame interlace type, can assume one of the following values:
  4202. @table @option
  4203. @item PROGRESSIVE
  4204. the frame is progressive (not interlaced)
  4205. @item TOPFIRST
  4206. the frame is top-field-first
  4207. @item BOTTOMFIRST
  4208. the frame is bottom-field-first
  4209. @end table
  4210. @item consumed_sample_n @emph{(audio only)}
  4211. the number of selected samples before the current frame
  4212. @item samples_n @emph{(audio only)}
  4213. the number of samples in the current frame
  4214. @item sample_rate @emph{(audio only)}
  4215. the input sample rate
  4216. @item key
  4217. 1 if the filtered frame is a key-frame, 0 otherwise
  4218. @item pos
  4219. the position in the file of the filtered frame, -1 if the information
  4220. is not available (e.g. for synthetic video)
  4221. @item scene @emph{(video only)}
  4222. value between 0 and 1 to indicate a new scene; a low value reflects a low
  4223. probability for the current frame to introduce a new scene, while a higher
  4224. value means the current frame is more likely to be one (see the example below)
  4225. @end table
  4226. The default value of the select expression is "1".
  4227. @subsection Examples
  4228. @itemize
  4229. @item
  4230. Select all frames in input:
  4231. @example
  4232. select
  4233. @end example
  4234. The example above is the same as:
  4235. @example
  4236. select=1
  4237. @end example
  4238. @item
  4239. Skip all frames:
  4240. @example
  4241. select=0
  4242. @end example
  4243. @item
  4244. Select only I-frames:
  4245. @example
  4246. select='eq(pict_type\,I)'
  4247. @end example
  4248. @item
  4249. Select one frame every 100:
  4250. @example
  4251. select='not(mod(n\,100))'
  4252. @end example
  4253. @item
  4254. Select only frames contained in the 10-20 time interval:
  4255. @example
  4256. select='gte(t\,10)*lte(t\,20)'
  4257. @end example
  4258. @item
  4259. Select only I frames contained in the 10-20 time interval:
  4260. @example
  4261. select='gte(t\,10)*lte(t\,20)*eq(pict_type\,I)'
  4262. @end example
  4263. @item
  4264. Select frames with a minimum distance of 10 seconds:
  4265. @example
  4266. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  4267. @end example
  4268. @item
  4269. Use aselect to select only audio frames with samples number > 100:
  4270. @example
  4271. aselect='gt(samples_n\,100)'
  4272. @end example
  4273. @item
  4274. Create a mosaic of the first scenes:
  4275. @example
  4276. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  4277. @end example
  4278. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  4279. choice.
  4280. @end itemize
  4281. @section asendcmd, sendcmd
  4282. Send commands to filters in the filtergraph.
  4283. These filters read commands to be sent to other filters in the
  4284. filtergraph.
  4285. @code{asendcmd} must be inserted between two audio filters,
  4286. @code{sendcmd} must be inserted between two video filters, but apart
  4287. from that they act the same way.
  4288. The specification of commands can be provided in the filter arguments
  4289. with the @var{commands} option, or in a file specified by the
  4290. @var{filename} option.
  4291. These filters accept the following options:
  4292. @table @option
  4293. @item commands, c
  4294. Set the commands to be read and sent to the other filters.
  4295. @item filename, f
  4296. Set the filename of the commands to be read and sent to the other
  4297. filters.
  4298. @end table
  4299. @subsection Commands syntax
  4300. A commands description consists of a sequence of interval
  4301. specifications, comprising a list of commands to be executed when a
  4302. particular event related to that interval occurs. The occurring event
  4303. is typically the current frame time entering or leaving a given time
  4304. interval.
  4305. An interval is specified by the following syntax:
  4306. @example
  4307. @var{START}[-@var{END}] @var{COMMANDS};
  4308. @end example
  4309. The time interval is specified by the @var{START} and @var{END} times.
  4310. @var{END} is optional and defaults to the maximum time.
  4311. The current frame time is considered within the specified interval if
  4312. it is included in the interval [@var{START}, @var{END}), that is when
  4313. the time is greater or equal to @var{START} and is lesser than
  4314. @var{END}.
  4315. @var{COMMANDS} consists of a sequence of one or more command
  4316. specifications, separated by ",", relating to that interval. The
  4317. syntax of a command specification is given by:
  4318. @example
  4319. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  4320. @end example
  4321. @var{FLAGS} is optional and specifies the type of events relating to
  4322. the time interval which enable sending the specified command, and must
  4323. be a non-null sequence of identifier flags separated by "+" or "|" and
  4324. enclosed between "[" and "]".
  4325. The following flags are recognized:
  4326. @table @option
  4327. @item enter
  4328. The command is sent when the current frame timestamp enters the
  4329. specified interval. In other words, the command is sent when the
  4330. previous frame timestamp was not in the given interval, and the
  4331. current is.
  4332. @item leave
  4333. The command is sent when the current frame timestamp leaves the
  4334. specified interval. In other words, the command is sent when the
  4335. previous frame timestamp was in the given interval, and the
  4336. current is not.
  4337. @end table
  4338. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  4339. assumed.
  4340. @var{TARGET} specifies the target of the command, usually the name of
  4341. the filter class or a specific filter instance name.
  4342. @var{COMMAND} specifies the name of the command for the target filter.
  4343. @var{ARG} is optional and specifies the optional list of argument for
  4344. the given @var{COMMAND}.
  4345. Between one interval specification and another, whitespaces, or
  4346. sequences of characters starting with @code{#} until the end of line,
  4347. are ignored and can be used to annotate comments.
  4348. A simplified BNF description of the commands specification syntax
  4349. follows:
  4350. @example
  4351. @var{COMMAND_FLAG} ::= "enter" | "leave"
  4352. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  4353. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  4354. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  4355. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  4356. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  4357. @end example
  4358. @subsection Examples
  4359. @itemize
  4360. @item
  4361. Specify audio tempo change at second 4:
  4362. @example
  4363. asendcmd=c='4.0 atempo tempo 1.5',atempo
  4364. @end example
  4365. @item
  4366. Specify a list of drawtext and hue commands in a file.
  4367. @example
  4368. # show text in the interval 5-10
  4369. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  4370. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  4371. # desaturate the image in the interval 15-20
  4372. 15.0-20.0 [enter] hue reinit s=0,
  4373. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  4374. [leave] hue reinit s=1,
  4375. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  4376. # apply an exponential saturation fade-out effect, starting from time 25
  4377. 25 [enter] hue s=exp(t-25)
  4378. @end example
  4379. A filtergraph allowing to read and process the above command list
  4380. stored in a file @file{test.cmd}, can be specified with:
  4381. @example
  4382. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  4383. @end example
  4384. @end itemize
  4385. @anchor{setpts}
  4386. @section asetpts, setpts
  4387. Change the PTS (presentation timestamp) of the input frames.
  4388. @code{asetpts} works on audio frames, @code{setpts} on video frames.
  4389. Accept in input an expression evaluated through the eval API, which
  4390. can contain the following constants:
  4391. @table @option
  4392. @item FRAME_RATE
  4393. frame rate, only defined for constant frame-rate video
  4394. @item PTS
  4395. the presentation timestamp in input
  4396. @item N
  4397. the count of the input frame, starting from 0.
  4398. @item NB_CONSUMED_SAMPLES
  4399. the number of consumed samples, not including the current frame (only
  4400. audio)
  4401. @item NB_SAMPLES
  4402. the number of samples in the current frame (only audio)
  4403. @item SAMPLE_RATE
  4404. audio sample rate
  4405. @item STARTPTS
  4406. the PTS of the first frame
  4407. @item STARTT
  4408. the time in seconds of the first frame
  4409. @item INTERLACED
  4410. tell if the current frame is interlaced
  4411. @item T
  4412. the time in seconds of the current frame
  4413. @item TB
  4414. the time base
  4415. @item POS
  4416. original position in the file of the frame, or undefined if undefined
  4417. for the current frame
  4418. @item PREV_INPTS
  4419. previous input PTS
  4420. @item PREV_INT
  4421. previous input time in seconds
  4422. @item PREV_OUTPTS
  4423. previous output PTS
  4424. @item PREV_OUTT
  4425. previous output time in seconds
  4426. @item RTCTIME
  4427. wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  4428. instead.
  4429. @item RTCSTART
  4430. wallclock (RTC) time at the start of the movie in microseconds
  4431. @end table
  4432. @subsection Examples
  4433. @itemize
  4434. @item
  4435. Start counting PTS from zero
  4436. @example
  4437. setpts=PTS-STARTPTS
  4438. @end example
  4439. @item
  4440. Apply fast motion effect:
  4441. @example
  4442. setpts=0.5*PTS
  4443. @end example
  4444. @item
  4445. Apply slow motion effect:
  4446. @example
  4447. setpts=2.0*PTS
  4448. @end example
  4449. @item
  4450. Set fixed rate of 25 frames per second:
  4451. @example
  4452. setpts=N/(25*TB)
  4453. @end example
  4454. @item
  4455. Set fixed rate 25 fps with some jitter:
  4456. @example
  4457. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  4458. @end example
  4459. @item
  4460. Apply an offset of 10 seconds to the input PTS:
  4461. @example
  4462. setpts=PTS+10/TB
  4463. @end example
  4464. @item
  4465. Generate timestamps from a "live source" and rebase onto the current timebase:
  4466. @example
  4467. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  4468. @end example
  4469. @end itemize
  4470. @section ebur128
  4471. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  4472. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  4473. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  4474. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  4475. The filter also has a video output (see the @var{video} option) with a real
  4476. time graph to observe the loudness evolution. The graphic contains the logged
  4477. message mentioned above, so it is not printed anymore when this option is set,
  4478. unless the verbose logging is set. The main graphing area contains the
  4479. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  4480. the momentary loudness (400 milliseconds).
  4481. More information about the Loudness Recommendation EBU R128 on
  4482. @url{http://tech.ebu.ch/loudness}.
  4483. The filter accepts the following named parameters:
  4484. @table @option
  4485. @item video
  4486. Activate the video output. The audio stream is passed unchanged whether this
  4487. option is set or no. The video stream will be the first output stream if
  4488. activated. Default is @code{0}.
  4489. @item size
  4490. Set the video size. This option is for video only. Default and minimum
  4491. resolution is @code{640x480}.
  4492. @item meter
  4493. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  4494. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  4495. other integer value between this range is allowed.
  4496. @end table
  4497. Example of real-time graph using @command{ffplay}, with a EBU scale meter +18:
  4498. @example
  4499. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  4500. @end example
  4501. Run an analysis with @command{ffmpeg}:
  4502. @example
  4503. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  4504. @end example
  4505. @section settb, asettb
  4506. Set the timebase to use for the output frames timestamps.
  4507. It is mainly useful for testing timebase configuration.
  4508. It accepts in input an arithmetic expression representing a rational.
  4509. The expression can contain the constants "AVTB" (the
  4510. default timebase), "intb" (the input timebase) and "sr" (the sample rate,
  4511. audio only).
  4512. The default value for the input is "intb".
  4513. @subsection Examples
  4514. @itemize
  4515. @item
  4516. Set the timebase to 1/25:
  4517. @example
  4518. settb=1/25
  4519. @end example
  4520. @item
  4521. Set the timebase to 1/10:
  4522. @example
  4523. settb=0.1
  4524. @end example
  4525. @item
  4526. Set the timebase to 1001/1000:
  4527. @example
  4528. settb=1+0.001
  4529. @end example
  4530. @item
  4531. Set the timebase to 2*intb:
  4532. @example
  4533. settb=2*intb
  4534. @end example
  4535. @item
  4536. Set the default timebase value:
  4537. @example
  4538. settb=AVTB
  4539. @end example
  4540. @end itemize
  4541. @section concat
  4542. Concatenate audio and video streams, joining them together one after the
  4543. other.
  4544. The filter works on segments of synchronized video and audio streams. All
  4545. segments must have the same number of streams of each type, and that will
  4546. also be the number of streams at output.
  4547. The filter accepts the following named parameters:
  4548. @table @option
  4549. @item n
  4550. Set the number of segments. Default is 2.
  4551. @item v
  4552. Set the number of output video streams, that is also the number of video
  4553. streams in each segment. Default is 1.
  4554. @item a
  4555. Set the number of output audio streams, that is also the number of video
  4556. streams in each segment. Default is 0.
  4557. @item unsafe
  4558. Activate unsafe mode: do not fail if segments have a different format.
  4559. @end table
  4560. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  4561. @var{a} audio outputs.
  4562. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  4563. segment, in the same order as the outputs, then the inputs for the second
  4564. segment, etc.
  4565. Related streams do not always have exactly the same duration, for various
  4566. reasons including codec frame size or sloppy authoring. For that reason,
  4567. related synchronized streams (e.g. a video and its audio track) should be
  4568. concatenated at once. The concat filter will use the duration of the longest
  4569. stream in each segment (except the last one), and if necessary pad shorter
  4570. audio streams with silence.
  4571. For this filter to work correctly, all segments must start at timestamp 0.
  4572. All corresponding streams must have the same parameters in all segments; the
  4573. filtering system will automatically select a common pixel format for video
  4574. streams, and a common sample format, sample rate and channel layout for
  4575. audio streams, but other settings, such as resolution, must be converted
  4576. explicitly by the user.
  4577. Different frame rates are acceptable but will result in variable frame rate
  4578. at output; be sure to configure the output file to handle it.
  4579. Examples:
  4580. @itemize
  4581. @item
  4582. Concatenate an opening, an episode and an ending, all in bilingual version
  4583. (video in stream 0, audio in streams 1 and 2):
  4584. @example
  4585. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  4586. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  4587. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  4588. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  4589. @end example
  4590. @item
  4591. Concatenate two parts, handling audio and video separately, using the
  4592. (a)movie sources, and adjusting the resolution:
  4593. @example
  4594. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  4595. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  4596. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  4597. @end example
  4598. Note that a desync will happen at the stitch if the audio and video streams
  4599. do not have exactly the same duration in the first file.
  4600. @end itemize
  4601. @section showspectrum
  4602. Convert input audio to a video output, representing the audio frequency
  4603. spectrum.
  4604. The filter accepts the following named parameters:
  4605. @table @option
  4606. @item size, s
  4607. Specify the video size for the output. Default value is @code{640x512}.
  4608. @item slide
  4609. Specify if the spectrum should slide along the window. Default value is
  4610. @code{0}.
  4611. @item mode
  4612. Specify display mode.
  4613. It accepts the following values:
  4614. @table @samp
  4615. @item combined
  4616. all channels are displayed in the same row
  4617. @item separate
  4618. all channels are displayed in separate rows
  4619. @end table
  4620. Default value is @samp{combined}.
  4621. @item color
  4622. Specify display color mode.
  4623. It accepts the following values:
  4624. @table @samp
  4625. @item channel
  4626. each channel is displayed in a separate color
  4627. @item intensity
  4628. each channel is is displayed using the same color scheme
  4629. @end table
  4630. Default value is @samp{channel}.
  4631. @item scale
  4632. Specify scale used for calculating intensity color values.
  4633. It accepts the following values:
  4634. @table @samp
  4635. @item lin
  4636. linear
  4637. @item sqrt
  4638. square root, default
  4639. @item cbrt
  4640. cubic root
  4641. @item log
  4642. logarithmic
  4643. @end table
  4644. Default value is @samp{sqrt}.
  4645. @item saturation
  4646. Set saturation modifier for displayed colors. Negative values provide
  4647. alternative color scheme. @code{0} is no saturation at all.
  4648. Saturation must be in [-10.0, 10.0] range.
  4649. Default value is @code{1}.
  4650. @end table
  4651. The usage is very similar to the showwaves filter; see the examples in that
  4652. section.
  4653. @section showwaves
  4654. Convert input audio to a video output, representing the samples waves.
  4655. The filter accepts the following named parameters:
  4656. @table @option
  4657. @item mode
  4658. Set display mode.
  4659. Available values are:
  4660. @table @samp
  4661. @item point
  4662. Draw a point for each sample.
  4663. @item line
  4664. Draw a vertical line for each sample.
  4665. @end table
  4666. Default value is @code{point}.
  4667. @item n
  4668. Set the number of samples which are printed on the same column. A
  4669. larger value will decrease the frame rate. Must be a positive
  4670. integer. This option can be set only if the value for @var{rate}
  4671. is not explicitly specified.
  4672. @item rate, r
  4673. Set the (approximate) output frame rate. This is done by setting the
  4674. option @var{n}. Default value is "25".
  4675. @item size, s
  4676. Specify the video size for the output. Default value is "600x240".
  4677. @end table
  4678. Some examples follow.
  4679. @itemize
  4680. @item
  4681. Output the input file audio and the corresponding video representation
  4682. at the same time:
  4683. @example
  4684. amovie=a.mp3,asplit[out0],showwaves[out1]
  4685. @end example
  4686. @item
  4687. Create a synthetic signal and show it with showwaves, forcing a
  4688. framerate of 30 frames per second:
  4689. @example
  4690. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  4691. @end example
  4692. @end itemize
  4693. @c man end MULTIMEDIA FILTERS
  4694. @chapter Multimedia Sources
  4695. @c man begin MULTIMEDIA SOURCES
  4696. Below is a description of the currently available multimedia sources.
  4697. @section amovie
  4698. This is the same as @ref{movie} source, except it selects an audio
  4699. stream by default.
  4700. @anchor{movie}
  4701. @section movie
  4702. Read audio and/or video stream(s) from a movie container.
  4703. It accepts the syntax: @var{movie_name}[:@var{options}] where
  4704. @var{movie_name} is the name of the resource to read (not necessarily
  4705. a file but also a device or a stream accessed through some protocol),
  4706. and @var{options} is an optional sequence of @var{key}=@var{value}
  4707. pairs, separated by ":".
  4708. The description of the accepted options follows.
  4709. @table @option
  4710. @item format_name, f
  4711. Specifies the format assumed for the movie to read, and can be either
  4712. the name of a container or an input device. If not specified the
  4713. format is guessed from @var{movie_name} or by probing.
  4714. @item seek_point, sp
  4715. Specifies the seek point in seconds, the frames will be output
  4716. starting from this seek point, the parameter is evaluated with
  4717. @code{av_strtod} so the numerical value may be suffixed by an IS
  4718. postfix. Default value is "0".
  4719. @item streams, s
  4720. Specifies the streams to read. Several streams can be specified,
  4721. separated by "+". The source will then have as many outputs, in the
  4722. same order. The syntax is explained in the ``Stream specifiers''
  4723. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  4724. respectively the default (best suited) video and audio stream. Default
  4725. is "dv", or "da" if the filter is called as "amovie".
  4726. @item stream_index, si
  4727. Specifies the index of the video stream to read. If the value is -1,
  4728. the best suited video stream will be automatically selected. Default
  4729. value is "-1". Deprecated. If the filter is called "amovie", it will select
  4730. audio instead of video.
  4731. @item loop
  4732. Specifies how many times to read the stream in sequence.
  4733. If the value is less than 1, the stream will be read again and again.
  4734. Default value is "1".
  4735. Note that when the movie is looped the source timestamps are not
  4736. changed, so it will generate non monotonically increasing timestamps.
  4737. @end table
  4738. This filter allows to overlay a second video on top of main input of
  4739. a filtergraph as shown in this graph:
  4740. @example
  4741. input -----------> deltapts0 --> overlay --> output
  4742. ^
  4743. |
  4744. movie --> scale--> deltapts1 -------+
  4745. @end example
  4746. Some examples follow.
  4747. @itemize
  4748. @item
  4749. Skip 3.2 seconds from the start of the avi file in.avi, and overlay it
  4750. on top of the input labelled as "in":
  4751. @example
  4752. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  4753. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  4754. @end example
  4755. @item
  4756. Read from a video4linux2 device, and overlay it on top of the input
  4757. labelled as "in":
  4758. @example
  4759. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [movie];
  4760. [in] setpts=PTS-STARTPTS, [movie] overlay=16:16 [out]
  4761. @end example
  4762. @item
  4763. Read the first video stream and the audio stream with id 0x81 from
  4764. dvd.vob; the video is connected to the pad named "video" and the audio is
  4765. connected to the pad named "audio":
  4766. @example
  4767. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  4768. @end example
  4769. @end itemize
  4770. @c man end MULTIMEDIA SOURCES