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.

7837 lines
211KB

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