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.

7253 lines
196KB

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