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.

7638 lines
206KB

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