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.

7254 lines
195KB

  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. A description of the accepted options follows.
  1878. @table @option
  1879. @item max
  1880. Set the maximum number of consecutive frames which can be dropped (if
  1881. positive), or the minimum interval between dropped frames (if
  1882. negative). If the value is 0, the frame is dropped unregarding the
  1883. number of previous sequentially dropped frames.
  1884. Default value is 0.
  1885. @item hi
  1886. @item lo
  1887. @item frac
  1888. Set the dropping threshold values.
  1889. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  1890. represent actual pixel value differences, so a threshold of 64
  1891. corresponds to 1 unit of difference for each pixel, or the same spread
  1892. out differently over the block.
  1893. A frame is a candidate for dropping if no 8x8 blocks differ by more
  1894. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  1895. meaning the whole image) differ by more than a threshold of @option{lo}.
  1896. Default value for @option{hi} is 64*12, default value for @option{lo} is
  1897. 64*5, and default value for @option{frac} is 0.33.
  1898. @end table
  1899. @section delogo
  1900. Suppress a TV station logo by a simple interpolation of the surrounding
  1901. pixels. Just set a rectangle covering the logo and watch it disappear
  1902. (and sometimes something even uglier appear - your mileage may vary).
  1903. This filter accepts the following options:
  1904. @table @option
  1905. @item x, y
  1906. Specify the top left corner coordinates of the logo. They must be
  1907. specified.
  1908. @item w, h
  1909. Specify the width and height of the logo to clear. They must be
  1910. specified.
  1911. @item band, t
  1912. Specify the thickness of the fuzzy edge of the rectangle (added to
  1913. @var{w} and @var{h}). The default value is 4.
  1914. @item show
  1915. When set to 1, a green rectangle is drawn on the screen to simplify
  1916. finding the right @var{x}, @var{y}, @var{w}, @var{h} parameters, and
  1917. @var{band} is set to 4. The default value is 0.
  1918. @end table
  1919. @subsection Examples
  1920. @itemize
  1921. @item
  1922. Set a rectangle covering the area with top left corner coordinates 0,0
  1923. and size 100x77, setting a band of size 10:
  1924. @example
  1925. delogo=x=0:y=0:w=100:h=77:band=10
  1926. @end example
  1927. @end itemize
  1928. @section deshake
  1929. Attempt to fix small changes in horizontal and/or vertical shift. This
  1930. filter helps remove camera shake from hand-holding a camera, bumping a
  1931. tripod, moving on a vehicle, etc.
  1932. The filter accepts parameters as a list of @var{key}=@var{value}
  1933. pairs, separated by ":". If the key of the first options is omitted,
  1934. the arguments are interpreted according to the syntax
  1935. @var{x}:@var{y}:@var{w}:@var{h}:@var{rx}:@var{ry}:@var{edge}:@var{blocksize}:@var{contrast}:@var{search}:@var{filename}:@var{opencl}.
  1936. A description of the accepted parameters follows.
  1937. @table @option
  1938. @item x, y, w, h
  1939. Specify a rectangular area where to limit the search for motion
  1940. vectors.
  1941. If desired the search for motion vectors can be limited to a
  1942. rectangular area of the frame defined by its top left corner, width
  1943. and height. These parameters have the same meaning as the drawbox
  1944. filter which can be used to visualise the position of the bounding
  1945. box.
  1946. This is useful when simultaneous movement of subjects within the frame
  1947. might be confused for camera motion by the motion vector search.
  1948. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  1949. then the full frame is used. This allows later options to be set
  1950. without specifying the bounding box for the motion vector search.
  1951. Default - search the whole frame.
  1952. @item rx, ry
  1953. Specify the maximum extent of movement in x and y directions in the
  1954. range 0-64 pixels. Default 16.
  1955. @item edge
  1956. Specify how to generate pixels to fill blanks at the edge of the
  1957. frame. Available values are:
  1958. @table @samp
  1959. @item blank, 0
  1960. Fill zeroes at blank locations
  1961. @item original, 1
  1962. Original image at blank locations
  1963. @item clamp, 2
  1964. Extruded edge value at blank locations
  1965. @item mirror, 3
  1966. Mirrored edge at blank locations
  1967. @end table
  1968. Default value is @samp{mirror}.
  1969. @item blocksize
  1970. Specify the blocksize to use for motion search. Range 4-128 pixels,
  1971. default 8.
  1972. @item contrast
  1973. Specify the contrast threshold for blocks. Only blocks with more than
  1974. the specified contrast (difference between darkest and lightest
  1975. pixels) will be considered. Range 1-255, default 125.
  1976. @item search
  1977. Specify the search strategy. Available values are:
  1978. @table @samp
  1979. @item exhaustive, 0
  1980. Set exhaustive search
  1981. @item less, 1
  1982. Set less exhaustive search.
  1983. @end table
  1984. Default value is @samp{exhaustive}.
  1985. @item filename
  1986. If set then a detailed log of the motion search is written to the
  1987. specified file.
  1988. @item opencl
  1989. If set to 1, specify using OpenCL capabilities, only available if
  1990. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  1991. @end table
  1992. @section drawbox
  1993. Draw a colored box on the input image.
  1994. This filter accepts the following options:
  1995. @table @option
  1996. @item x, y
  1997. Specify the top left corner coordinates of the box. Default to 0.
  1998. @item width, w
  1999. @item height, h
  2000. Specify the width and height of the box, if 0 they are interpreted as
  2001. the input width and height. Default to 0.
  2002. @item color, c
  2003. Specify the color of the box to write, it can be the name of a color
  2004. (case insensitive match) or a 0xRRGGBB[AA] sequence. If the special
  2005. value @code{invert} is used, the box edge color is the same as the
  2006. video with inverted luma.
  2007. @item thickness, t
  2008. Set the thickness of the box edge. Default value is @code{4}.
  2009. @end table
  2010. @subsection Examples
  2011. @itemize
  2012. @item
  2013. Draw a black box around the edge of the input image:
  2014. @example
  2015. drawbox
  2016. @end example
  2017. @item
  2018. Draw a box with color red and an opacity of 50%:
  2019. @example
  2020. drawbox=10:20:200:60:red@@0.5
  2021. @end example
  2022. The previous example can be specified as:
  2023. @example
  2024. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  2025. @end example
  2026. @item
  2027. Fill the box with pink color:
  2028. @example
  2029. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  2030. @end example
  2031. @end itemize
  2032. @anchor{drawtext}
  2033. @section drawtext
  2034. Draw text string or text from specified file on top of video using the
  2035. libfreetype library.
  2036. To enable compilation of this filter you need to configure FFmpeg with
  2037. @code{--enable-libfreetype}.
  2038. @subsection Syntax
  2039. The description of the accepted parameters follows.
  2040. @table @option
  2041. @item box
  2042. Used to draw a box around text using background color.
  2043. Value should be either 1 (enable) or 0 (disable).
  2044. The default value of @var{box} is 0.
  2045. @item boxcolor
  2046. The color to be used for drawing box around text.
  2047. Either a string (e.g. "yellow") or in 0xRRGGBB[AA] format
  2048. (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  2049. The default value of @var{boxcolor} is "white".
  2050. @item draw
  2051. Set an expression which specifies if the text should be drawn. If the
  2052. expression evaluates to 0, the text is not drawn. This is useful for
  2053. specifying that the text should be drawn only when specific conditions
  2054. are met.
  2055. Default value is "1".
  2056. See below for the list of accepted constants and functions.
  2057. @item expansion
  2058. Select how the @var{text} is expanded. Can be either @code{none},
  2059. @code{strftime} (deprecated) or
  2060. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  2061. below for details.
  2062. @item fix_bounds
  2063. If true, check and fix text coords to avoid clipping.
  2064. @item fontcolor
  2065. The color to be used for drawing fonts.
  2066. Either a string (e.g. "red") or in 0xRRGGBB[AA] format
  2067. (e.g. "0xff000033"), possibly followed by an alpha specifier.
  2068. The default value of @var{fontcolor} is "black".
  2069. @item fontfile
  2070. The font file to be used for drawing text. Path must be included.
  2071. This parameter is mandatory.
  2072. @item fontsize
  2073. The font size to be used for drawing text.
  2074. The default value of @var{fontsize} is 16.
  2075. @item ft_load_flags
  2076. Flags to be used for loading the fonts.
  2077. The flags map the corresponding flags supported by libfreetype, and are
  2078. a combination of the following values:
  2079. @table @var
  2080. @item default
  2081. @item no_scale
  2082. @item no_hinting
  2083. @item render
  2084. @item no_bitmap
  2085. @item vertical_layout
  2086. @item force_autohint
  2087. @item crop_bitmap
  2088. @item pedantic
  2089. @item ignore_global_advance_width
  2090. @item no_recurse
  2091. @item ignore_transform
  2092. @item monochrome
  2093. @item linear_design
  2094. @item no_autohint
  2095. @item end table
  2096. @end table
  2097. Default value is "render".
  2098. For more information consult the documentation for the FT_LOAD_*
  2099. libfreetype flags.
  2100. @item shadowcolor
  2101. The color to be used for drawing a shadow behind the drawn text. It
  2102. can be a color name (e.g. "yellow") or a string in the 0xRRGGBB[AA]
  2103. form (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  2104. The default value of @var{shadowcolor} is "black".
  2105. @item shadowx, shadowy
  2106. The x and y offsets for the text shadow position with respect to the
  2107. position of the text. They can be either positive or negative
  2108. values. Default value for both is "0".
  2109. @item tabsize
  2110. The size in number of spaces to use for rendering the tab.
  2111. Default value is 4.
  2112. @item timecode
  2113. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  2114. format. It can be used with or without text parameter. @var{timecode_rate}
  2115. option must be specified.
  2116. @item timecode_rate, rate, r
  2117. Set the timecode frame rate (timecode only).
  2118. @item text
  2119. The text string to be drawn. The text must be a sequence of UTF-8
  2120. encoded characters.
  2121. This parameter is mandatory if no file is specified with the parameter
  2122. @var{textfile}.
  2123. @item textfile
  2124. A text file containing text to be drawn. The text must be a sequence
  2125. of UTF-8 encoded characters.
  2126. This parameter is mandatory if no text string is specified with the
  2127. parameter @var{text}.
  2128. If both @var{text} and @var{textfile} are specified, an error is thrown.
  2129. @item reload
  2130. If set to 1, the @var{textfile} will be reloaded before each frame.
  2131. Be sure to update it atomically, or it may be read partially, or even fail.
  2132. @item x, y
  2133. The expressions which specify the offsets where text will be drawn
  2134. within the video frame. They are relative to the top/left border of the
  2135. output image.
  2136. The default value of @var{x} and @var{y} is "0".
  2137. See below for the list of accepted constants and functions.
  2138. @end table
  2139. The parameters for @var{x} and @var{y} are expressions containing the
  2140. following constants and functions:
  2141. @table @option
  2142. @item dar
  2143. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  2144. @item hsub, vsub
  2145. horizontal and vertical chroma subsample values. For example for the
  2146. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2147. @item line_h, lh
  2148. the height of each text line
  2149. @item main_h, h, H
  2150. the input height
  2151. @item main_w, w, W
  2152. the input width
  2153. @item max_glyph_a, ascent
  2154. the maximum distance from the baseline to the highest/upper grid
  2155. coordinate used to place a glyph outline point, for all the rendered
  2156. glyphs.
  2157. It is a positive value, due to the grid's orientation with the Y axis
  2158. upwards.
  2159. @item max_glyph_d, descent
  2160. the maximum distance from the baseline to the lowest grid coordinate
  2161. used to place a glyph outline point, for all the rendered glyphs.
  2162. This is a negative value, due to the grid's orientation, with the Y axis
  2163. upwards.
  2164. @item max_glyph_h
  2165. maximum glyph height, that is the maximum height for all the glyphs
  2166. contained in the rendered text, it is equivalent to @var{ascent} -
  2167. @var{descent}.
  2168. @item max_glyph_w
  2169. maximum glyph width, that is the maximum width for all the glyphs
  2170. contained in the rendered text
  2171. @item n
  2172. the number of input frame, starting from 0
  2173. @item rand(min, max)
  2174. return a random number included between @var{min} and @var{max}
  2175. @item sar
  2176. input sample aspect ratio
  2177. @item t
  2178. timestamp expressed in seconds, NAN if the input timestamp is unknown
  2179. @item text_h, th
  2180. the height of the rendered text
  2181. @item text_w, tw
  2182. the width of the rendered text
  2183. @item x, y
  2184. the x and y offset coordinates where the text is drawn.
  2185. These parameters allow the @var{x} and @var{y} expressions to refer
  2186. each other, so you can for example specify @code{y=x/dar}.
  2187. @end table
  2188. If libavfilter was built with @code{--enable-fontconfig}, then
  2189. @option{fontfile} can be a fontconfig pattern or omitted.
  2190. @anchor{drawtext_expansion}
  2191. @subsection Text expansion
  2192. If @option{expansion} is set to @code{strftime},
  2193. the filter recognizes strftime() sequences in the provided text and
  2194. expands them accordingly. Check the documentation of strftime(). This
  2195. feature is deprecated.
  2196. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  2197. If @option{expansion} is set to @code{normal} (which is the default),
  2198. the following expansion mechanism is used.
  2199. The backslash character '\', followed by any character, always expands to
  2200. the second character.
  2201. Sequence of the form @code{%@{...@}} are expanded. The text between the
  2202. braces is a function name, possibly followed by arguments separated by ':'.
  2203. If the arguments contain special characters or delimiters (':' or '@}'),
  2204. they should be escaped.
  2205. Note that they probably must also be escaped as the value for the
  2206. @option{text} option in the filter argument string and as the filter
  2207. argument in the filtergraph description, and possibly also for the shell,
  2208. that makes up to four levels of escaping; using a text file avoids these
  2209. problems.
  2210. The following functions are available:
  2211. @table @command
  2212. @item expr, e
  2213. The expression evaluation result.
  2214. It must take one argument specifying the expression to be evaluated,
  2215. which accepts the same constants and functions as the @var{x} and
  2216. @var{y} values. Note that not all constants should be used, for
  2217. example the text size is not known when evaluating the expression, so
  2218. the constants @var{text_w} and @var{text_h} will have an undefined
  2219. value.
  2220. @item gmtime
  2221. The time at which the filter is running, expressed in UTC.
  2222. It can accept an argument: a strftime() format string.
  2223. @item localtime
  2224. The time at which the filter is running, expressed in the local time zone.
  2225. It can accept an argument: a strftime() format string.
  2226. @item n, frame_num
  2227. The frame number, starting from 0.
  2228. @item pts
  2229. The timestamp of the current frame, in seconds, with microsecond accuracy.
  2230. @end table
  2231. @subsection Examples
  2232. @itemize
  2233. @item
  2234. Draw "Test Text" with font FreeSerif, using the default values for the
  2235. optional parameters.
  2236. @example
  2237. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  2238. @end example
  2239. @item
  2240. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  2241. and y=50 (counting from the top-left corner of the screen), text is
  2242. yellow with a red box around it. Both the text and the box have an
  2243. opacity of 20%.
  2244. @example
  2245. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  2246. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  2247. @end example
  2248. Note that the double quotes are not necessary if spaces are not used
  2249. within the parameter list.
  2250. @item
  2251. Show the text at the center of the video frame:
  2252. @example
  2253. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  2254. @end example
  2255. @item
  2256. Show a text line sliding from right to left in the last row of the video
  2257. frame. The file @file{LONG_LINE} is assumed to contain a single line
  2258. with no newlines.
  2259. @example
  2260. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  2261. @end example
  2262. @item
  2263. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  2264. @example
  2265. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  2266. @end example
  2267. @item
  2268. Draw a single green letter "g", at the center of the input video.
  2269. The glyph baseline is placed at half screen height.
  2270. @example
  2271. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  2272. @end example
  2273. @item
  2274. Show text for 1 second every 3 seconds:
  2275. @example
  2276. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:draw=lt(mod(t\,3)\,1):text='blink'"
  2277. @end example
  2278. @item
  2279. Use fontconfig to set the font. Note that the colons need to be escaped.
  2280. @example
  2281. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  2282. @end example
  2283. @item
  2284. Print the date of a real-time encoding (see strftime(3)):
  2285. @example
  2286. drawtext='fontfile=FreeSans.ttf:text=%@{localtime:%a %b %d %Y@}'
  2287. @end example
  2288. @end itemize
  2289. For more information about libfreetype, check:
  2290. @url{http://www.freetype.org/}.
  2291. For more information about fontconfig, check:
  2292. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  2293. @section edgedetect
  2294. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  2295. The filter accepts the following options:
  2296. @table @option
  2297. @item low, high
  2298. Set low and high threshold values used by the Canny thresholding
  2299. algorithm.
  2300. The high threshold selects the "strong" edge pixels, which are then
  2301. connected through 8-connectivity with the "weak" edge pixels selected
  2302. by the low threshold.
  2303. @var{low} and @var{high} threshold values must be choosen in the range
  2304. [0,1], and @var{low} should be lesser or equal to @var{high}.
  2305. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  2306. is @code{50/255}.
  2307. @end table
  2308. Example:
  2309. @example
  2310. edgedetect=low=0.1:high=0.4
  2311. @end example
  2312. @section fade
  2313. Apply fade-in/out effect to input video.
  2314. This filter accepts the following options:
  2315. @table @option
  2316. @item type, t
  2317. The effect type -- can be either "in" for fade-in, or "out" for a fade-out
  2318. effect.
  2319. Default is @code{in}.
  2320. @item start_frame, s
  2321. Specify the number of the start frame for starting to apply the fade
  2322. effect. Default is 0.
  2323. @item nb_frames, n
  2324. The number of frames for which the fade effect has to last. At the end of the
  2325. fade-in effect the output video will have the same intensity as the input video,
  2326. at the end of the fade-out transition the output video will be completely black.
  2327. Default is 25.
  2328. @item alpha
  2329. If set to 1, fade only alpha channel, if one exists on the input.
  2330. Default value is 0.
  2331. @end table
  2332. @subsection Examples
  2333. @itemize
  2334. @item
  2335. Fade in first 30 frames of video:
  2336. @example
  2337. fade=in:0:30
  2338. @end example
  2339. The command above is equivalent to:
  2340. @example
  2341. fade=t=in:s=0:n=30
  2342. @end example
  2343. @item
  2344. Fade out last 45 frames of a 200-frame video:
  2345. @example
  2346. fade=out:155:45
  2347. fade=type=out:start_frame=155:nb_frames=45
  2348. @end example
  2349. @item
  2350. Fade in first 25 frames and fade out last 25 frames of a 1000-frame video:
  2351. @example
  2352. fade=in:0:25, fade=out:975:25
  2353. @end example
  2354. @item
  2355. Make first 5 frames black, then fade in from frame 5-24:
  2356. @example
  2357. fade=in:5:20
  2358. @end example
  2359. @item
  2360. Fade in alpha over first 25 frames of video:
  2361. @example
  2362. fade=in:0:25:alpha=1
  2363. @end example
  2364. @end itemize
  2365. @section field
  2366. Extract a single field from an interlaced image using stride
  2367. arithmetic to avoid wasting CPU time. The output frames are marked as
  2368. non-interlaced.
  2369. This filter accepts the following named options:
  2370. @table @option
  2371. @item type
  2372. Specify whether to extract the top (if the value is @code{0} or
  2373. @code{top}) or the bottom field (if the value is @code{1} or
  2374. @code{bottom}).
  2375. @end table
  2376. @section fieldorder
  2377. Transform the field order of the input video.
  2378. This filter accepts the following options:
  2379. @table @option
  2380. @item order
  2381. Output field order. Valid values are @var{tff} for top field first or @var{bff}
  2382. for bottom field first.
  2383. @end table
  2384. Default value is @samp{tff}.
  2385. Transformation is achieved by shifting the picture content up or down
  2386. by one line, and filling the remaining line with appropriate picture content.
  2387. This method is consistent with most broadcast field order converters.
  2388. If the input video is not flagged as being interlaced, or it is already
  2389. flagged as being of the required output field order then this filter does
  2390. not alter the incoming video.
  2391. This filter is very useful when converting to or from PAL DV material,
  2392. which is bottom field first.
  2393. For example:
  2394. @example
  2395. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  2396. @end example
  2397. @section fifo
  2398. Buffer input images and send them when they are requested.
  2399. This filter is mainly useful when auto-inserted by the libavfilter
  2400. framework.
  2401. The filter does not take parameters.
  2402. @anchor{format}
  2403. @section format
  2404. Convert the input video to one of the specified pixel formats.
  2405. Libavfilter will try to pick one that is supported for the input to
  2406. the next filter.
  2407. This filter accepts the following parameters:
  2408. @table @option
  2409. @item pix_fmts
  2410. A '|'-separated list of pixel format names, for example
  2411. "pix_fmts=yuv420p|monow|rgb24".
  2412. @end table
  2413. @subsection Examples
  2414. @itemize
  2415. @item
  2416. Convert the input video to the format @var{yuv420p}
  2417. @example
  2418. format=pix_fmts=yuv420p
  2419. @end example
  2420. Convert the input video to any of the formats in the list
  2421. @example
  2422. format=pix_fmts=yuv420p|yuv444p|yuv410p
  2423. @end example
  2424. @end itemize
  2425. @section fps
  2426. Convert the video to specified constant frame rate by duplicating or dropping
  2427. frames as necessary.
  2428. This filter accepts the following named parameters:
  2429. @table @option
  2430. @item fps
  2431. Desired output frame rate. The default is @code{25}.
  2432. @item round
  2433. Rounding method.
  2434. Possible values are:
  2435. @table @option
  2436. @item zero
  2437. zero round towards 0
  2438. @item inf
  2439. round away from 0
  2440. @item down
  2441. round towards -infinity
  2442. @item up
  2443. round towards +infinity
  2444. @item near
  2445. round to nearest
  2446. @end table
  2447. The default is @code{near}.
  2448. @end table
  2449. Alternatively, the options can be specified as a flat string:
  2450. @var{fps}[:@var{round}].
  2451. See also the @ref{setpts} filter.
  2452. @section framestep
  2453. Select one frame every N.
  2454. This filter accepts in input a string representing a positive
  2455. integer. Default argument is @code{1}.
  2456. @anchor{frei0r}
  2457. @section frei0r
  2458. Apply a frei0r effect to the input video.
  2459. To enable compilation of this filter you need to install the frei0r
  2460. header and configure FFmpeg with @code{--enable-frei0r}.
  2461. This filter accepts the following options:
  2462. @table @option
  2463. @item filter_name
  2464. The name to the frei0r effect to load. If the environment variable
  2465. @env{FREI0R_PATH} is defined, the frei0r effect is searched in each one of the
  2466. directories specified by the colon separated list in @env{FREIOR_PATH},
  2467. otherwise in the standard frei0r paths, which are in this order:
  2468. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  2469. @file{/usr/lib/frei0r-1/}.
  2470. @item filter_params
  2471. A '|'-separated list of parameters to pass to the frei0r effect.
  2472. @end table
  2473. A frei0r effect parameter can be a boolean (whose values are specified
  2474. with "y" and "n"), a double, a color (specified by the syntax
  2475. @var{R}/@var{G}/@var{B}, @var{R}, @var{G}, and @var{B} being float
  2476. numbers from 0.0 to 1.0) or by an @code{av_parse_color()} color
  2477. description), a position (specified by the syntax @var{X}/@var{Y},
  2478. @var{X} and @var{Y} being float numbers) and a string.
  2479. The number and kind of parameters depend on the loaded effect. If an
  2480. effect parameter is not specified the default value is set.
  2481. @subsection Examples
  2482. @itemize
  2483. @item
  2484. Apply the distort0r effect, set the first two double parameters:
  2485. @example
  2486. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  2487. @end example
  2488. @item
  2489. Apply the colordistance effect, take a color as first parameter:
  2490. @example
  2491. frei0r=colordistance:0.2/0.3/0.4
  2492. frei0r=colordistance:violet
  2493. frei0r=colordistance:0x112233
  2494. @end example
  2495. @item
  2496. Apply the perspective effect, specify the top left and top right image
  2497. positions:
  2498. @example
  2499. frei0r=perspective:0.2/0.2|0.8/0.2
  2500. @end example
  2501. @end itemize
  2502. For more information see:
  2503. @url{http://frei0r.dyne.org}
  2504. @section geq
  2505. The filter accepts the following options:
  2506. @table @option
  2507. @item lum_expr
  2508. the luminance expression
  2509. @item cb_expr
  2510. the chrominance blue expression
  2511. @item cr_expr
  2512. the chrominance red expression
  2513. @item alpha_expr
  2514. the alpha expression
  2515. @end table
  2516. If one of the chrominance expression is not defined, it falls back on the other
  2517. one. If no alpha expression is specified it will evaluate to opaque value.
  2518. If none of chrominance expressions are
  2519. specified, they will evaluate the luminance expression.
  2520. The expressions can use the following variables and functions:
  2521. @table @option
  2522. @item N
  2523. The sequential number of the filtered frame, starting from @code{0}.
  2524. @item X
  2525. @item Y
  2526. The coordinates of the current sample.
  2527. @item W
  2528. @item H
  2529. The width and height of the image.
  2530. @item SW
  2531. @item SH
  2532. Width and height scale depending on the currently filtered plane. It is the
  2533. ratio between the corresponding luma plane number of pixels and the current
  2534. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  2535. @code{0.5,0.5} for chroma planes.
  2536. @item T
  2537. Time of the current frame, expressed in seconds.
  2538. @item p(x, y)
  2539. Return the value of the pixel at location (@var{x},@var{y}) of the current
  2540. plane.
  2541. @item lum(x, y)
  2542. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  2543. plane.
  2544. @item cb(x, y)
  2545. Return the value of the pixel at location (@var{x},@var{y}) of the
  2546. blue-difference chroma plane. Returns 0 if there is no such plane.
  2547. @item cr(x, y)
  2548. Return the value of the pixel at location (@var{x},@var{y}) of the
  2549. red-difference chroma plane. Returns 0 if there is no such plane.
  2550. @item alpha(x, y)
  2551. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  2552. plane. Returns 0 if there is no such plane.
  2553. @end table
  2554. For functions, if @var{x} and @var{y} are outside the area, the value will be
  2555. automatically clipped to the closer edge.
  2556. @subsection Examples
  2557. @itemize
  2558. @item
  2559. Flip the image horizontally:
  2560. @example
  2561. geq=p(W-X\,Y)
  2562. @end example
  2563. @item
  2564. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  2565. wavelength of 100 pixels:
  2566. @example
  2567. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  2568. @end example
  2569. @item
  2570. Generate a fancy enigmatic moving light:
  2571. @example
  2572. 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
  2573. @end example
  2574. @end itemize
  2575. @section gradfun
  2576. Fix the banding artifacts that are sometimes introduced into nearly flat
  2577. regions by truncation to 8bit color depth.
  2578. Interpolate the gradients that should go where the bands are, and
  2579. dither them.
  2580. This filter is designed for playback only. Do not use it prior to
  2581. lossy compression, because compression tends to lose the dither and
  2582. bring back the bands.
  2583. This filter accepts the following options:
  2584. @table @option
  2585. @item strength
  2586. The maximum amount by which the filter will change any one pixel. Also the
  2587. threshold for detecting nearly flat regions. Acceptable values range from .51 to
  2588. 64, default value is 1.2, out-of-range values will be clipped to the valid
  2589. range.
  2590. @item radius
  2591. The neighborhood to fit the gradient to. A larger radius makes for smoother
  2592. gradients, but also prevents the filter from modifying the pixels near detailed
  2593. regions. Acceptable values are 8-32, default value is 16, out-of-range values
  2594. will be clipped to the valid range.
  2595. @end table
  2596. Alternatively, the options can be specified as a flat string:
  2597. @var{strength}[:@var{radius}]
  2598. @subsection Examples
  2599. @itemize
  2600. @item
  2601. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  2602. @example
  2603. gradfun=3.5:8
  2604. @end example
  2605. @item
  2606. Specify radius, omitting the strength (which will fall-back to the default
  2607. value):
  2608. @example
  2609. gradfun=radius=8
  2610. @end example
  2611. @end itemize
  2612. @section hflip
  2613. Flip the input video horizontally.
  2614. For example to horizontally flip the input video with @command{ffmpeg}:
  2615. @example
  2616. ffmpeg -i in.avi -vf "hflip" out.avi
  2617. @end example
  2618. @section histeq
  2619. This filter applies a global color histogram equalization on a
  2620. per-frame basis.
  2621. It can be used to correct video that has a compressed range of pixel
  2622. intensities. The filter redistributes the pixel intensities to
  2623. equalize their distribution across the intensity range. It may be
  2624. viewed as an "automatically adjusting contrast filter". This filter is
  2625. useful only for correcting degraded or poorly captured source
  2626. video.
  2627. The filter accepts parameters as a list of @var{key}=@var{value}
  2628. pairs, separated by ":". If the key of the first options is omitted,
  2629. the arguments are interpreted according to syntax
  2630. @var{strength}:@var{intensity}:@var{antibanding}.
  2631. This filter accepts the following named options:
  2632. @table @option
  2633. @item strength
  2634. Determine the amount of equalization to be applied. As the strength
  2635. is reduced, the distribution of pixel intensities more-and-more
  2636. approaches that of the input frame. The value must be a float number
  2637. in the range [0,1] and defaults to 0.200.
  2638. @item intensity
  2639. Set the maximum intensity that can generated and scale the output
  2640. values appropriately. The strength should be set as desired and then
  2641. the intensity can be limited if needed to avoid washing-out. The value
  2642. must be a float number in the range [0,1] and defaults to 0.210.
  2643. @item antibanding
  2644. Set the antibanding level. If enabled the filter will randomly vary
  2645. the luminance of output pixels by a small amount to avoid banding of
  2646. the histogram. Possible values are @code{none}, @code{weak} or
  2647. @code{strong}. It defaults to @code{none}.
  2648. @end table
  2649. @section histogram
  2650. Compute and draw a color distribution histogram for the input video.
  2651. The computed histogram is a representation of distribution of color components
  2652. in an image.
  2653. The filter accepts the following named parameters:
  2654. @table @option
  2655. @item mode
  2656. Set histogram mode.
  2657. It accepts the following values:
  2658. @table @samp
  2659. @item levels
  2660. standard histogram that display color components distribution in an image.
  2661. Displays color graph for each color component. Shows distribution
  2662. of the Y, U, V, A or G, B, R components, depending on input format,
  2663. in current frame. Bellow each graph is color component scale meter.
  2664. @item color
  2665. chroma values in vectorscope, if brighter more such chroma values are
  2666. distributed in an image.
  2667. Displays chroma values (U/V color placement) in two dimensional graph
  2668. (which is called a vectorscope). It can be used to read of the hue and
  2669. saturation of the current frame. At a same time it is a histogram.
  2670. The whiter a pixel in the vectorscope, the more pixels of the input frame
  2671. correspond to that pixel (that is the more pixels have this chroma value).
  2672. The V component is displayed on the horizontal (X) axis, with the leftmost
  2673. side being V = 0 and the rightmost side being V = 255.
  2674. The U component is displayed on the vertical (Y) axis, with the top
  2675. representing U = 0 and the bottom representing U = 255.
  2676. The position of a white pixel in the graph corresponds to the chroma value
  2677. of a pixel of the input clip. So the graph can be used to read of the
  2678. hue (color flavor) and the saturation (the dominance of the hue in the color).
  2679. As the hue of a color changes, it moves around the square. At the center of
  2680. the square, the saturation is zero, which means that the corresponding pixel
  2681. has no color. If you increase the amount of a specific color, while leaving
  2682. the other colors unchanged, the saturation increases, and you move towards
  2683. the edge of the square.
  2684. @item color2
  2685. chroma values in vectorscope, similar as @code{color} but actual chroma values
  2686. are displayed.
  2687. @item waveform
  2688. per row/column color component graph. In row mode graph in the left side represents
  2689. color component value 0 and right side represents value = 255. In column mode top
  2690. side represents color component value = 0 and bottom side represents value = 255.
  2691. @end table
  2692. Default value is @code{levels}.
  2693. @item level_height
  2694. Set height of level in @code{levels}. Default value is @code{200}.
  2695. Allowed range is [50, 2048].
  2696. @item scale_height
  2697. Set height of color scale in @code{levels}. Default value is @code{12}.
  2698. Allowed range is [0, 40].
  2699. @item step
  2700. Set step for @code{waveform} mode. Smaller values are useful to find out how much
  2701. of same luminance values across input rows/columns are distributed.
  2702. Default value is @code{10}. Allowed range is [1, 255].
  2703. @item waveform_mode
  2704. Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
  2705. Default is @code{row}.
  2706. @item display_mode
  2707. Set display mode for @code{waveform} and @code{levels}.
  2708. It accepts the following values:
  2709. @table @samp
  2710. @item parade
  2711. Display separate graph for the color components side by side in
  2712. @code{row} waveform mode or one below other in @code{column} waveform mode
  2713. for @code{waveform} histogram mode. For @code{levels} histogram mode
  2714. per color component graphs are placed one bellow other.
  2715. This display mode in @code{waveform} histogram mode makes it easy to spot
  2716. color casts in the highlights and shadows of an image, by comparing the
  2717. contours of the top and the bottom of each waveform.
  2718. Since whites, grays, and blacks are characterized by
  2719. exactly equal amounts of red, green, and blue, neutral areas of the
  2720. picture should display three waveforms of roughly equal width/height.
  2721. If not, the correction is easy to make by making adjustments to level the
  2722. three waveforms.
  2723. @item overlay
  2724. Presents information that's identical to that in the @code{parade}, except
  2725. that the graphs representing color components are superimposed directly
  2726. over one another.
  2727. This display mode in @code{waveform} histogram mode can make it easier to spot
  2728. the relative differences or similarities in overlapping areas of the color
  2729. components that are supposed to be identical, such as neutral whites, grays,
  2730. or blacks.
  2731. @end table
  2732. Default is @code{parade}.
  2733. @end table
  2734. @subsection Examples
  2735. @itemize
  2736. @item
  2737. Calculate and draw histogram:
  2738. @example
  2739. ffplay -i input -vf histogram
  2740. @end example
  2741. @end itemize
  2742. @section hqdn3d
  2743. High precision/quality 3d denoise filter. This filter aims to reduce
  2744. image noise producing smooth images and making still images really
  2745. still. It should enhance compressibility.
  2746. It accepts the following optional parameters:
  2747. @table @option
  2748. @item luma_spatial
  2749. a non-negative float number which specifies spatial luma strength,
  2750. defaults to 4.0
  2751. @item chroma_spatial
  2752. a non-negative float number which specifies spatial chroma strength,
  2753. defaults to 3.0*@var{luma_spatial}/4.0
  2754. @item luma_tmp
  2755. a float number which specifies luma temporal strength, defaults to
  2756. 6.0*@var{luma_spatial}/4.0
  2757. @item chroma_tmp
  2758. a float number which specifies chroma temporal strength, defaults to
  2759. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
  2760. @end table
  2761. @section hue
  2762. Modify the hue and/or the saturation of the input.
  2763. This filter accepts the following optional named options:
  2764. @table @option
  2765. @item h
  2766. Specify the hue angle as a number of degrees. It accepts a float
  2767. number or an expression, and defaults to 0.0.
  2768. @item H
  2769. Specify the hue angle as a number of radians. It accepts a float
  2770. number or an expression, and defaults to 0.0.
  2771. @item s
  2772. Specify the saturation in the [-10,10] range. It accepts a float number and
  2773. defaults to 1.0.
  2774. @end table
  2775. The @var{h}, @var{H} and @var{s} parameters are expressions containing the
  2776. following constants:
  2777. @table @option
  2778. @item n
  2779. frame count of the input frame starting from 0
  2780. @item pts
  2781. presentation timestamp of the input frame expressed in time base units
  2782. @item r
  2783. frame rate of the input video, NAN if the input frame rate is unknown
  2784. @item t
  2785. timestamp expressed in seconds, NAN if the input timestamp is unknown
  2786. @item tb
  2787. time base of the input video
  2788. @end table
  2789. The options can also be set using the syntax: @var{hue}:@var{saturation}
  2790. In this case @var{hue} is expressed in degrees.
  2791. @subsection Examples
  2792. @itemize
  2793. @item
  2794. Set the hue to 90 degrees and the saturation to 1.0:
  2795. @example
  2796. hue=h=90:s=1
  2797. @end example
  2798. @item
  2799. Same command but expressing the hue in radians:
  2800. @example
  2801. hue=H=PI/2:s=1
  2802. @end example
  2803. @item
  2804. Same command without named options, hue must be expressed in degrees:
  2805. @example
  2806. hue=90:1
  2807. @end example
  2808. @item
  2809. Note that "h:s" syntax does not support expressions for the values of
  2810. h and s, so the following example will issue an error:
  2811. @example
  2812. hue=PI/2:1
  2813. @end example
  2814. @item
  2815. Rotate hue and make the saturation swing between 0
  2816. and 2 over a period of 1 second:
  2817. @example
  2818. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  2819. @end example
  2820. @item
  2821. Apply a 3 seconds saturation fade-in effect starting at 0:
  2822. @example
  2823. hue="s=min(t/3\,1)"
  2824. @end example
  2825. The general fade-in expression can be written as:
  2826. @example
  2827. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  2828. @end example
  2829. @item
  2830. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  2831. @example
  2832. hue="s=max(0\, min(1\, (8-t)/3))"
  2833. @end example
  2834. The general fade-out expression can be written as:
  2835. @example
  2836. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  2837. @end example
  2838. @end itemize
  2839. @subsection Commands
  2840. This filter supports the following command:
  2841. @table @option
  2842. @item reinit
  2843. Modify the hue and/or the saturation of the input video.
  2844. The command accepts the same named options and syntax than when calling the
  2845. filter from the command-line.
  2846. If a parameter is omitted, it is kept at its current value.
  2847. @end table
  2848. @section idet
  2849. Detect video interlacing type.
  2850. This filter tries to detect if the input is interlaced or progressive,
  2851. top or bottom field first.
  2852. @section il
  2853. Deinterleave or interleave fields.
  2854. This filter allows to process interlaced images fields without
  2855. deinterlacing them. Deinterleaving splits the input frame into 2
  2856. fields (so called half pictures). Odd lines are moved to the top
  2857. half of the output image, even lines to the bottom half.
  2858. You can process (filter) them independently and then re-interleave them.
  2859. It accepts a list of options in the form of @var{key}=@var{value} pairs
  2860. separated by ":". A description of the accepted options follows.
  2861. @table @option
  2862. @item luma_mode, l
  2863. @item chroma_mode, s
  2864. @item alpha_mode, a
  2865. Available values for @var{luma_mode}, @var{chroma_mode} and
  2866. @var{alpha_mode} are:
  2867. @table @samp
  2868. @item none
  2869. Do nothing.
  2870. @item deinterleave, d
  2871. Deinterleave fields, placing one above the other.
  2872. @item interleave, i
  2873. Interleave fields. Reverse the effect of deinterleaving.
  2874. @end table
  2875. Default value is @code{none}.
  2876. @item luma_swap, ls
  2877. @item chroma_swap, cs
  2878. @item alpha_swap, as
  2879. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  2880. @end table
  2881. @section kerndeint
  2882. Deinterlace input video by applying Donald Graft's adaptive kernel
  2883. deinterling. Work on interlaced parts of a video to produce
  2884. progressive frames.
  2885. This filter accepts parameters as a list of @var{key}=@var{value}
  2886. pairs, separated by ":". If the key of the first options is omitted,
  2887. the arguments are interpreted according to the following syntax:
  2888. @var{thresh}:@var{map}:@var{order}:@var{sharp}:@var{twoway}.
  2889. The description of the accepted parameters follows.
  2890. @table @option
  2891. @item thresh
  2892. Set the threshold which affects the filter's tolerance when
  2893. determining if a pixel line must be processed. It must be an integer
  2894. in the range [0,255] and defaults to 10. A value of 0 will result in
  2895. applying the process on every pixels.
  2896. @item map
  2897. Paint pixels exceeding the threshold value to white if set to 1.
  2898. Default is 0.
  2899. @item order
  2900. Set the fields order. Swap fields if set to 1, leave fields alone if
  2901. 0. Default is 0.
  2902. @item sharp
  2903. Enable additional sharpening if set to 1. Default is 0.
  2904. @item twoway
  2905. Enable twoway sharpening if set to 1. Default is 0.
  2906. @end table
  2907. @subsection Examples
  2908. @itemize
  2909. @item
  2910. Apply default values:
  2911. @example
  2912. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  2913. @end example
  2914. @item
  2915. Enable additional sharpening:
  2916. @example
  2917. kerndeint=sharp=1
  2918. @end example
  2919. @item
  2920. Paint processed pixels in white:
  2921. @example
  2922. kerndeint=map=1
  2923. @end example
  2924. @end itemize
  2925. @section lut, lutrgb, lutyuv
  2926. Compute a look-up table for binding each pixel component input value
  2927. to an output value, and apply it to input video.
  2928. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  2929. to an RGB input video.
  2930. These filters accept the following options:
  2931. @table @option
  2932. @item c0
  2933. set first pixel component expression
  2934. @item c1
  2935. set second pixel component expression
  2936. @item c2
  2937. set third pixel component expression
  2938. @item c3
  2939. set fourth pixel component expression, corresponds to the alpha component
  2940. @item r
  2941. set red component expression
  2942. @item g
  2943. set green component expression
  2944. @item b
  2945. set blue component expression
  2946. @item a
  2947. alpha component expression
  2948. @item y
  2949. set Y/luminance component expression
  2950. @item u
  2951. set U/Cb component expression
  2952. @item v
  2953. set V/Cr component expression
  2954. @end table
  2955. Each of them specifies the expression to use for computing the lookup table for
  2956. the corresponding pixel component values.
  2957. The exact component associated to each of the @var{c*} options depends on the
  2958. format in input.
  2959. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  2960. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  2961. The expressions can contain the following constants and functions:
  2962. @table @option
  2963. @item w, h
  2964. the input width and height
  2965. @item val
  2966. input value for the pixel component
  2967. @item clipval
  2968. the input value clipped in the @var{minval}-@var{maxval} range
  2969. @item maxval
  2970. maximum value for the pixel component
  2971. @item minval
  2972. minimum value for the pixel component
  2973. @item negval
  2974. the negated value for the pixel component value clipped in the
  2975. @var{minval}-@var{maxval} range , it corresponds to the expression
  2976. "maxval-clipval+minval"
  2977. @item clip(val)
  2978. the computed value in @var{val} clipped in the
  2979. @var{minval}-@var{maxval} range
  2980. @item gammaval(gamma)
  2981. the computed gamma correction value of the pixel component value
  2982. clipped in the @var{minval}-@var{maxval} range, corresponds to the
  2983. expression
  2984. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  2985. @end table
  2986. All expressions default to "val".
  2987. @subsection Examples
  2988. @itemize
  2989. @item
  2990. Negate input video:
  2991. @example
  2992. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  2993. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  2994. @end example
  2995. The above is the same as:
  2996. @example
  2997. lutrgb="r=negval:g=negval:b=negval"
  2998. lutyuv="y=negval:u=negval:v=negval"
  2999. @end example
  3000. @item
  3001. Negate luminance:
  3002. @example
  3003. lutyuv=y=negval
  3004. @end example
  3005. @item
  3006. Remove chroma components, turns the video into a graytone image:
  3007. @example
  3008. lutyuv="u=128:v=128"
  3009. @end example
  3010. @item
  3011. Apply a luma burning effect:
  3012. @example
  3013. lutyuv="y=2*val"
  3014. @end example
  3015. @item
  3016. Remove green and blue components:
  3017. @example
  3018. lutrgb="g=0:b=0"
  3019. @end example
  3020. @item
  3021. Set a constant alpha channel value on input:
  3022. @example
  3023. format=rgba,lutrgb=a="maxval-minval/2"
  3024. @end example
  3025. @item
  3026. Correct luminance gamma by a 0.5 factor:
  3027. @example
  3028. lutyuv=y=gammaval(0.5)
  3029. @end example
  3030. @item
  3031. Discard least significant bits of luma:
  3032. @example
  3033. lutyuv=y='bitand(val, 128+64+32)'
  3034. @end example
  3035. @end itemize
  3036. @section mp
  3037. Apply an MPlayer filter to the input video.
  3038. This filter provides a wrapper around most of the filters of
  3039. MPlayer/MEncoder.
  3040. This wrapper is considered experimental. Some of the wrapped filters
  3041. may not work properly and we may drop support for them, as they will
  3042. be implemented natively into FFmpeg. Thus you should avoid
  3043. depending on them when writing portable scripts.
  3044. The filters accepts the parameters:
  3045. @var{filter_name}[:=]@var{filter_params}
  3046. @var{filter_name} is the name of a supported MPlayer filter,
  3047. @var{filter_params} is a string containing the parameters accepted by
  3048. the named filter.
  3049. The list of the currently supported filters follows:
  3050. @table @var
  3051. @item detc
  3052. @item dint
  3053. @item divtc
  3054. @item down3dright
  3055. @item eq2
  3056. @item eq
  3057. @item fil
  3058. @item fspp
  3059. @item ilpack
  3060. @item ivtc
  3061. @item mcdeint
  3062. @item ow
  3063. @item perspective
  3064. @item phase
  3065. @item pp7
  3066. @item pullup
  3067. @item qp
  3068. @item sab
  3069. @item softpulldown
  3070. @item spp
  3071. @item telecine
  3072. @item tinterlace
  3073. @item uspp
  3074. @end table
  3075. The parameter syntax and behavior for the listed filters are the same
  3076. of the corresponding MPlayer filters. For detailed instructions check
  3077. the "VIDEO FILTERS" section in the MPlayer manual.
  3078. @subsection Examples
  3079. @itemize
  3080. @item
  3081. Adjust gamma, brightness, contrast:
  3082. @example
  3083. mp=eq2=1.0:2:0.5
  3084. @end example
  3085. @end itemize
  3086. See also mplayer(1), @url{http://www.mplayerhq.hu/}.
  3087. @section negate
  3088. Negate input video.
  3089. This filter accepts an integer in input, if non-zero it negates the
  3090. alpha component (if available). The default value in input is 0.
  3091. @section noformat
  3092. Force libavfilter not to use any of the specified pixel formats for the
  3093. input to the next filter.
  3094. This filter accepts the following parameters:
  3095. @table @option
  3096. @item pix_fmts
  3097. A '|'-separated list of pixel format names, for example
  3098. "pix_fmts=yuv420p|monow|rgb24".
  3099. @end table
  3100. @subsection Examples
  3101. @itemize
  3102. @item
  3103. Force libavfilter to use a format different from @var{yuv420p} for the
  3104. input to the vflip filter:
  3105. @example
  3106. noformat=pix_fmts=yuv420p,vflip
  3107. @end example
  3108. @item
  3109. Convert the input video to any of the formats not contained in the list:
  3110. @example
  3111. noformat=yuv420p|yuv444p|yuv410p
  3112. @end example
  3113. @end itemize
  3114. @section noise
  3115. Add noise on video input frame.
  3116. This filter accepts a list of options in the form of @var{key}=@var{value}
  3117. pairs separated by ":". A description of the accepted options follows.
  3118. @table @option
  3119. @item all_seed
  3120. @item c0_seed
  3121. @item c1_seed
  3122. @item c2_seed
  3123. @item c3_seed
  3124. Set noise seed for specific pixel component or all pixel components in case
  3125. of @var{all_seed}. Default value is @code{123457}.
  3126. @item all_strength, alls
  3127. @item c0_strength, c0s
  3128. @item c1_strength, c1s
  3129. @item c2_strength, c2s
  3130. @item c3_strength, c3s
  3131. Set noise strength for specific pixel component or all pixel components in case
  3132. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  3133. @item all_flags, allf
  3134. @item c0_flags, c0f
  3135. @item c1_flags, c1f
  3136. @item c2_flags, c2f
  3137. @item c3_flags, c3f
  3138. Set pixel component flags or set flags for all components if @var{all_flags}.
  3139. Available values for component flags are:
  3140. @table @samp
  3141. @item a
  3142. averaged temporal noise (smoother)
  3143. @item p
  3144. mix random noise with a (semi)regular pattern
  3145. @item q
  3146. higher quality (slightly better looking, slightly slower)
  3147. @item t
  3148. temporal noise (noise pattern changes between frames)
  3149. @item u
  3150. uniform noise (gaussian otherwise)
  3151. @end table
  3152. @end table
  3153. @subsection Examples
  3154. Add temporal and uniform noise to input video:
  3155. @example
  3156. noise=alls=20:allf=t+u
  3157. @end example
  3158. @section null
  3159. Pass the video source unchanged to the output.
  3160. @section ocv
  3161. Apply video transform using libopencv.
  3162. To enable this filter install libopencv library and headers and
  3163. configure FFmpeg with @code{--enable-libopencv}.
  3164. This filter accepts the following parameters:
  3165. @table @option
  3166. @item filter_name
  3167. The name of the libopencv filter to apply.
  3168. @item filter_params
  3169. The parameters to pass to the libopencv filter. If not specified the default
  3170. values are assumed.
  3171. @end table
  3172. Refer to the official libopencv documentation for more precise
  3173. information:
  3174. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  3175. Follows the list of supported libopencv filters.
  3176. @anchor{dilate}
  3177. @subsection dilate
  3178. Dilate an image by using a specific structuring element.
  3179. This filter corresponds to the libopencv function @code{cvDilate}.
  3180. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  3181. @var{struct_el} represents a structuring element, and has the syntax:
  3182. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  3183. @var{cols} and @var{rows} represent the number of columns and rows of
  3184. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  3185. point, and @var{shape} the shape for the structuring element, and
  3186. can be one of the values "rect", "cross", "ellipse", "custom".
  3187. If the value for @var{shape} is "custom", it must be followed by a
  3188. string of the form "=@var{filename}". The file with name
  3189. @var{filename} is assumed to represent a binary image, with each
  3190. printable character corresponding to a bright pixel. When a custom
  3191. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  3192. or columns and rows of the read file are assumed instead.
  3193. The default value for @var{struct_el} is "3x3+0x0/rect".
  3194. @var{nb_iterations} specifies the number of times the transform is
  3195. applied to the image, and defaults to 1.
  3196. Follow some example:
  3197. @example
  3198. # use the default values
  3199. ocv=dilate
  3200. # dilate using a structuring element with a 5x5 cross, iterate two times
  3201. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  3202. # read the shape from the file diamond.shape, iterate two times
  3203. # the file diamond.shape may contain a pattern of characters like this:
  3204. # *
  3205. # ***
  3206. # *****
  3207. # ***
  3208. # *
  3209. # the specified cols and rows are ignored (but not the anchor point coordinates)
  3210. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  3211. @end example
  3212. @subsection erode
  3213. Erode an image by using a specific structuring element.
  3214. This filter corresponds to the libopencv function @code{cvErode}.
  3215. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
  3216. with the same syntax and semantics as the @ref{dilate} filter.
  3217. @subsection smooth
  3218. Smooth the input video.
  3219. The filter takes the following parameters:
  3220. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  3221. @var{type} is the type of smooth filter to apply, and can be one of
  3222. the following values: "blur", "blur_no_scale", "median", "gaussian",
  3223. "bilateral". The default value is "gaussian".
  3224. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  3225. parameters whose meanings depend on smooth type. @var{param1} and
  3226. @var{param2} accept integer positive values or 0, @var{param3} and
  3227. @var{param4} accept float values.
  3228. The default value for @var{param1} is 3, the default value for the
  3229. other parameters is 0.
  3230. These parameters correspond to the parameters assigned to the
  3231. libopencv function @code{cvSmooth}.
  3232. @anchor{overlay}
  3233. @section overlay
  3234. Overlay one video on top of another.
  3235. It takes two inputs and one output, the first input is the "main"
  3236. video on which the second input is overlayed.
  3237. This filter accepts the following parameters:
  3238. A description of the accepted options follows.
  3239. @table @option
  3240. @item x
  3241. @item y
  3242. Set the expression for the x and y coordinates of the overlayed video
  3243. on the main video. Default value is "0" for both expressions. In case
  3244. the expression is invalid, it is set to a huge value (meaning that the
  3245. overlay will not be displayed within the output visible area).
  3246. @item enable
  3247. Set the expression which enables the overlay. If the evaluation is
  3248. different from 0, the overlay is displayed on top of the input
  3249. frame. By default it is "1".
  3250. @item eval
  3251. Set when the expressions for @option{x}, @option{y}, and
  3252. @option{enable} are evaluated.
  3253. It accepts the following values:
  3254. @table @samp
  3255. @item init
  3256. only evaluate expressions once during the filter initialization or
  3257. when a command is processed
  3258. @item frame
  3259. evaluate expressions for each incoming frame
  3260. @end table
  3261. Default value is @samp{frame}.
  3262. @item shortest
  3263. If set to 1, force the output to terminate when the shortest input
  3264. terminates. Default value is 0.
  3265. @item format
  3266. Set the format for the output video.
  3267. It accepts the following values:
  3268. @table @samp
  3269. @item yuv420
  3270. force YUV420 output
  3271. @item yuv444
  3272. force YUV444 output
  3273. @item rgb
  3274. force RGB output
  3275. @end table
  3276. Default value is @samp{yuv420}.
  3277. @item rgb @emph{(deprecated)}
  3278. If set to 1, force the filter to accept inputs in the RGB
  3279. color space. Default value is 0. This option is deprecated, use
  3280. @option{format} instead.
  3281. @end table
  3282. The @option{x}, @option{y}, and @option{enable} expressions can
  3283. contain the following parameters.
  3284. @table @option
  3285. @item main_w, W
  3286. @item main_h, H
  3287. main input width and height
  3288. @item overlay_w, w
  3289. @item overlay_h, h
  3290. overlay input width and height
  3291. @item x
  3292. @item y
  3293. the computed values for @var{x} and @var{y}. They are evaluated for
  3294. each new frame.
  3295. @item hsub
  3296. @item vsub
  3297. horizontal and vertical chroma subsample values of the output
  3298. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  3299. @var{vsub} is 1.
  3300. @item n
  3301. the number of input frame, starting from 0
  3302. @item pos
  3303. the position in the file of the input frame, NAN if unknown
  3304. @item t
  3305. timestamp expressed in seconds, NAN if the input timestamp is unknown
  3306. @end table
  3307. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  3308. when evaluation is done @emph{per frame}, and will evaluate to NAN
  3309. when @option{eval} is set to @samp{init}.
  3310. Be aware that frames are taken from each input video in timestamp
  3311. order, hence, if their initial timestamps differ, it is a a good idea
  3312. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  3313. have them begin in the same zero timestamp, as it does the example for
  3314. the @var{movie} filter.
  3315. You can chain together more overlays but you should test the
  3316. efficiency of such approach.
  3317. @subsection Commands
  3318. This filter supports the following command:
  3319. @table @option
  3320. @item x
  3321. Set the @option{x} option expression.
  3322. @item y
  3323. Set the @option{y} option expression.
  3324. @item enable
  3325. Set the @option{enable} option expression.
  3326. @end table
  3327. @subsection Examples
  3328. @itemize
  3329. @item
  3330. Draw the overlay at 10 pixels from the bottom right corner of the main
  3331. video:
  3332. @example
  3333. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  3334. @end example
  3335. Using named options the example above becomes:
  3336. @example
  3337. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  3338. @end example
  3339. @item
  3340. Insert a transparent PNG logo in the bottom left corner of the input,
  3341. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  3342. @example
  3343. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  3344. @end example
  3345. @item
  3346. Insert 2 different transparent PNG logos (second logo on bottom
  3347. right corner) using the @command{ffmpeg} tool:
  3348. @example
  3349. 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
  3350. @end example
  3351. @item
  3352. Add a transparent color layer on top of the main video, @code{WxH}
  3353. must specify the size of the main input to the overlay filter:
  3354. @example
  3355. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  3356. @end example
  3357. @item
  3358. Play an original video and a filtered version (here with the deshake
  3359. filter) side by side using the @command{ffplay} tool:
  3360. @example
  3361. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  3362. @end example
  3363. The above command is the same as:
  3364. @example
  3365. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  3366. @end example
  3367. @item
  3368. Make a sliding overlay appearing from the left to the right top part of the
  3369. screen starting since time 2:
  3370. @example
  3371. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  3372. @end example
  3373. @item
  3374. Compose output by putting two input videos side to side:
  3375. @example
  3376. ffmpeg -i left.avi -i right.avi -filter_complex "
  3377. nullsrc=size=200x100 [background];
  3378. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  3379. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  3380. [background][left] overlay=shortest=1 [background+left];
  3381. [background+left][right] overlay=shortest=1:x=100 [left+right]
  3382. "
  3383. @end example
  3384. @item
  3385. Chain several overlays in cascade:
  3386. @example
  3387. nullsrc=s=200x200 [bg];
  3388. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  3389. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  3390. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  3391. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  3392. [in3] null, [mid2] overlay=100:100 [out0]
  3393. @end example
  3394. @end itemize
  3395. @section pad
  3396. Add paddings to the input image, and place the original input at the
  3397. given coordinates @var{x}, @var{y}.
  3398. This filter accepts the following parameters:
  3399. @table @option
  3400. @item width, w
  3401. @item height, h
  3402. Specify an expression for the size of the output image with the
  3403. paddings added. If the value for @var{width} or @var{height} is 0, the
  3404. corresponding input size is used for the output.
  3405. The @var{width} expression can reference the value set by the
  3406. @var{height} expression, and vice versa.
  3407. The default value of @var{width} and @var{height} is 0.
  3408. @item x
  3409. @item y
  3410. Specify an expression for the offsets where to place the input image
  3411. in the padded area with respect to the top/left border of the output
  3412. image.
  3413. The @var{x} expression can reference the value set by the @var{y}
  3414. expression, and vice versa.
  3415. The default value of @var{x} and @var{y} is 0.
  3416. @item color
  3417. Specify the color of the padded area, it can be the name of a color
  3418. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  3419. The default value of @var{color} is "black".
  3420. @end table
  3421. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  3422. options are expressions containing the following constants:
  3423. @table @option
  3424. @item in_w, in_h
  3425. the input video width and height
  3426. @item iw, ih
  3427. same as @var{in_w} and @var{in_h}
  3428. @item out_w, out_h
  3429. the output width and height, that is the size of the padded area as
  3430. specified by the @var{width} and @var{height} expressions
  3431. @item ow, oh
  3432. same as @var{out_w} and @var{out_h}
  3433. @item x, y
  3434. x and y offsets as specified by the @var{x} and @var{y}
  3435. expressions, or NAN if not yet specified
  3436. @item a
  3437. same as @var{iw} / @var{ih}
  3438. @item sar
  3439. input sample aspect ratio
  3440. @item dar
  3441. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  3442. @item hsub, vsub
  3443. horizontal and vertical chroma subsample values. For example for the
  3444. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3445. @end table
  3446. @subsection Examples
  3447. @itemize
  3448. @item
  3449. Add paddings with color "violet" to the input video. Output video
  3450. size is 640x480, the top-left corner of the input video is placed at
  3451. column 0, row 40:
  3452. @example
  3453. pad=640:480:0:40:violet
  3454. @end example
  3455. The example above is equivalent to the following command:
  3456. @example
  3457. pad=width=640:height=480:x=0:y=40:color=violet
  3458. @end example
  3459. @item
  3460. Pad the input to get an output with dimensions increased by 3/2,
  3461. and put the input video at the center of the padded area:
  3462. @example
  3463. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  3464. @end example
  3465. @item
  3466. Pad the input to get a squared output with size equal to the maximum
  3467. value between the input width and height, and put the input video at
  3468. the center of the padded area:
  3469. @example
  3470. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  3471. @end example
  3472. @item
  3473. Pad the input to get a final w/h ratio of 16:9:
  3474. @example
  3475. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  3476. @end example
  3477. @item
  3478. In case of anamorphic video, in order to set the output display aspect
  3479. correctly, it is necessary to use @var{sar} in the expression,
  3480. according to the relation:
  3481. @example
  3482. (ih * X / ih) * sar = output_dar
  3483. X = output_dar / sar
  3484. @end example
  3485. Thus the previous example needs to be modified to:
  3486. @example
  3487. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  3488. @end example
  3489. @item
  3490. Double output size and put the input video in the bottom-right
  3491. corner of the output padded area:
  3492. @example
  3493. pad="2*iw:2*ih:ow-iw:oh-ih"
  3494. @end example
  3495. @end itemize
  3496. @section pixdesctest
  3497. Pixel format descriptor test filter, mainly useful for internal
  3498. testing. The output video should be equal to the input video.
  3499. For example:
  3500. @example
  3501. format=monow, pixdesctest
  3502. @end example
  3503. can be used to test the monowhite pixel format descriptor definition.
  3504. @section pp
  3505. Enable the specified chain of postprocessing subfilters using libpostproc. This
  3506. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  3507. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  3508. Each subfilter and some options have a short and a long name that can be used
  3509. interchangeably, i.e. dr/dering are the same.
  3510. The filters accept the following options:
  3511. @table @option
  3512. @item subfilters
  3513. Set postprocessing subfilters string.
  3514. @end table
  3515. All subfilters share common options to determine their scope:
  3516. @table @option
  3517. @item a/autoq
  3518. Honor the quality commands for this subfilter.
  3519. @item c/chrom
  3520. Do chrominance filtering, too (default).
  3521. @item y/nochrom
  3522. Do luminance filtering only (no chrominance).
  3523. @item n/noluma
  3524. Do chrominance filtering only (no luminance).
  3525. @end table
  3526. These options can be appended after the subfilter name, separated by a '|'.
  3527. Available subfilters are:
  3528. @table @option
  3529. @item hb/hdeblock[|difference[|flatness]]
  3530. Horizontal deblocking filter
  3531. @table @option
  3532. @item difference
  3533. Difference factor where higher values mean more deblocking (default: @code{32}).
  3534. @item flatness
  3535. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  3536. @end table
  3537. @item vb/vdeblock[|difference[|flatness]]
  3538. Vertical 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 ha/hadeblock[|difference[|flatness]]
  3546. Accurate horizontal 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 va/vadeblock[|difference[|flatness]]
  3554. Accurate vertical 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. @end table
  3562. The horizontal and vertical deblocking filters share the difference and
  3563. flatness values so you cannot set different horizontal and vertical
  3564. thresholds.
  3565. @table @option
  3566. @item h1/x1hdeblock
  3567. Experimental horizontal deblocking filter
  3568. @item v1/x1vdeblock
  3569. Experimental vertical deblocking filter
  3570. @item dr/dering
  3571. Deringing filter
  3572. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  3573. @table @option
  3574. @item threshold1
  3575. larger -> stronger filtering
  3576. @item threshold2
  3577. larger -> stronger filtering
  3578. @item threshold3
  3579. larger -> stronger filtering
  3580. @end table
  3581. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  3582. @table @option
  3583. @item f/fullyrange
  3584. Stretch luminance to @code{0-255}.
  3585. @end table
  3586. @item lb/linblenddeint
  3587. Linear blend deinterlacing filter that deinterlaces the given block by
  3588. filtering all lines with a @code{(1 2 1)} filter.
  3589. @item li/linipoldeint
  3590. Linear interpolating deinterlacing filter that deinterlaces the given block by
  3591. linearly interpolating every second line.
  3592. @item ci/cubicipoldeint
  3593. Cubic interpolating deinterlacing filter deinterlaces the given block by
  3594. cubically interpolating every second line.
  3595. @item md/mediandeint
  3596. Median deinterlacing filter that deinterlaces the given block by applying a
  3597. median filter to every second line.
  3598. @item fd/ffmpegdeint
  3599. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  3600. second line with a @code{(-1 4 2 4 -1)} filter.
  3601. @item l5/lowpass5
  3602. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  3603. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  3604. @item fq/forceQuant[|quantizer]
  3605. Overrides the quantizer table from the input with the constant quantizer you
  3606. specify.
  3607. @table @option
  3608. @item quantizer
  3609. Quantizer to use
  3610. @end table
  3611. @item de/default
  3612. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  3613. @item fa/fast
  3614. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  3615. @item ac
  3616. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  3617. @end table
  3618. @subsection Examples
  3619. @itemize
  3620. @item
  3621. Apply horizontal and vertical deblocking, deringing and automatic
  3622. brightness/contrast:
  3623. @example
  3624. pp=hb/vb/dr/al
  3625. @end example
  3626. @item
  3627. Apply default filters without brightness/contrast correction:
  3628. @example
  3629. pp=de/-al
  3630. @end example
  3631. @item
  3632. Apply default filters and temporal denoiser:
  3633. @example
  3634. pp=default/tmpnoise|1|2|3
  3635. @end example
  3636. @item
  3637. Apply deblocking on luminance only, and switch vertical deblocking on or off
  3638. automatically depending on available CPU time:
  3639. @example
  3640. pp=hb|y/vb|a
  3641. @end example
  3642. @end itemize
  3643. @section removelogo
  3644. Suppress a TV station logo, using an image file to determine which
  3645. pixels comprise the logo. It works by filling in the pixels that
  3646. comprise the logo with neighboring pixels.
  3647. This filter requires one argument which specifies the filter bitmap
  3648. file, which can be any image format supported by libavformat. The
  3649. width and height of the image file must match those of the video
  3650. stream being processed.
  3651. Pixels in the provided bitmap image with a value of zero are not
  3652. considered part of the logo, non-zero pixels are considered part of
  3653. the logo. If you use white (255) for the logo and black (0) for the
  3654. rest, you will be safe. For making the filter bitmap, it is
  3655. recommended to take a screen capture of a black frame with the logo
  3656. visible, and then using a threshold filter followed by the erode
  3657. filter once or twice.
  3658. If needed, little splotches can be fixed manually. Remember that if
  3659. logo pixels are not covered, the filter quality will be much
  3660. reduced. Marking too many pixels as part of the logo does not hurt as
  3661. much, but it will increase the amount of blurring needed to cover over
  3662. the image and will destroy more information than necessary, and extra
  3663. pixels will slow things down on a large logo.
  3664. @section scale
  3665. Scale (resize) the input video, using the libswscale library.
  3666. The scale filter forces the output display aspect ratio to be the same
  3667. of the input, by changing the output sample aspect ratio.
  3668. This filter accepts a list of named options in the form of
  3669. @var{key}=@var{value} pairs separated by ":". If the key for the first
  3670. two options is not specified, the assumed keys for the first two
  3671. values are @code{w} and @code{h}. If the first option has no key and
  3672. can be interpreted like a video size specification, it will be used
  3673. to set the video size.
  3674. A description of the accepted options follows.
  3675. @table @option
  3676. @item width, w
  3677. Output video width.
  3678. default value is @code{iw}. See below
  3679. for the list of accepted constants.
  3680. @item height, h
  3681. Output video height.
  3682. default value is @code{ih}.
  3683. See below for the list of accepted constants.
  3684. @item interl
  3685. Set the interlacing. It accepts the following values:
  3686. @table @option
  3687. @item 1
  3688. force interlaced aware scaling
  3689. @item 0
  3690. do not apply interlaced scaling
  3691. @item -1
  3692. select interlaced aware scaling depending on whether the source frames
  3693. are flagged as interlaced or not
  3694. @end table
  3695. Default value is @code{0}.
  3696. @item flags
  3697. Set libswscale scaling flags. If not explictly specified the filter
  3698. applies a bilinear scaling algorithm.
  3699. @item size, s
  3700. Set the video size, the value must be a valid abbreviation or in the
  3701. form @var{width}x@var{height}.
  3702. @end table
  3703. The values of the @var{w} and @var{h} options are expressions
  3704. containing the following constants:
  3705. @table @option
  3706. @item in_w, in_h
  3707. the input width and height
  3708. @item iw, ih
  3709. same as @var{in_w} and @var{in_h}
  3710. @item out_w, out_h
  3711. the output (cropped) width and height
  3712. @item ow, oh
  3713. same as @var{out_w} and @var{out_h}
  3714. @item a
  3715. same as @var{iw} / @var{ih}
  3716. @item sar
  3717. input sample aspect ratio
  3718. @item dar
  3719. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  3720. @item hsub, vsub
  3721. horizontal and vertical chroma subsample values. For example for the
  3722. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3723. @end table
  3724. If the input image format is different from the format requested by
  3725. the next filter, the scale filter will convert the input to the
  3726. requested format.
  3727. If the value for @var{w} or @var{h} is 0, the respective input
  3728. size is used for the output.
  3729. If the value for @var{w} or @var{h} is -1, the scale filter will use, for the
  3730. respective output size, a value that maintains the aspect ratio of the input
  3731. image.
  3732. @subsection Examples
  3733. @itemize
  3734. @item
  3735. Scale the input video to a size of 200x100:
  3736. @example
  3737. scale=w=200:h=100
  3738. @end example
  3739. This is equivalent to:
  3740. @example
  3741. scale=w=200:h=100
  3742. @end example
  3743. or:
  3744. @example
  3745. scale=200x100
  3746. @end example
  3747. @item
  3748. Specify a size abbreviation for the output size:
  3749. @example
  3750. scale=qcif
  3751. @end example
  3752. which can also be written as:
  3753. @example
  3754. scale=size=qcif
  3755. @end example
  3756. @item
  3757. Scale the input to 2x:
  3758. @example
  3759. scale=w=2*iw:h=2*ih
  3760. @end example
  3761. @item
  3762. The above is the same as:
  3763. @example
  3764. scale=2*in_w:2*in_h
  3765. @end example
  3766. @item
  3767. Scale the input to 2x with forced interlaced scaling:
  3768. @example
  3769. scale=2*iw:2*ih:interl=1
  3770. @end example
  3771. @item
  3772. Scale the input to half size:
  3773. @example
  3774. scale=w=iw/2:h=ih/2
  3775. @end example
  3776. @item
  3777. Increase the width, and set the height to the same size:
  3778. @example
  3779. scale=3/2*iw:ow
  3780. @end example
  3781. @item
  3782. Seek for Greek harmony:
  3783. @example
  3784. scale=iw:1/PHI*iw
  3785. scale=ih*PHI:ih
  3786. @end example
  3787. @item
  3788. Increase the height, and set the width to 3/2 of the height:
  3789. @example
  3790. scale=w=3/2*oh:h=3/5*ih
  3791. @end example
  3792. @item
  3793. Increase the size, but make the size a multiple of the chroma
  3794. subsample values:
  3795. @example
  3796. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  3797. @end example
  3798. @item
  3799. Increase the width to a maximum of 500 pixels, keep the same input
  3800. aspect ratio:
  3801. @example
  3802. scale=w='min(500\, iw*3/2):h=-1'
  3803. @end example
  3804. @end itemize
  3805. @section separatefields
  3806. The @code{separatefields} takes a frame-based video input and splits
  3807. each frame into its components fields, producing a new half height clip
  3808. with twice the frame rate and twice the frame count.
  3809. This filter use field-dominance information in frame to decide which
  3810. of each pair of fields to place first in the output.
  3811. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  3812. @section setdar, setsar
  3813. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  3814. output video.
  3815. This is done by changing the specified Sample (aka Pixel) Aspect
  3816. Ratio, according to the following equation:
  3817. @example
  3818. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  3819. @end example
  3820. Keep in mind that the @code{setdar} filter does not modify the pixel
  3821. dimensions of the video frame. Also the display aspect ratio set by
  3822. this filter may be changed by later filters in the filterchain,
  3823. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  3824. applied.
  3825. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  3826. the filter output video.
  3827. Note that as a consequence of the application of this filter, the
  3828. output display aspect ratio will change according to the equation
  3829. above.
  3830. Keep in mind that the sample aspect ratio set by the @code{setsar}
  3831. filter may be changed by later filters in the filterchain, e.g. if
  3832. another "setsar" or a "setdar" filter is applied.
  3833. The @code{setdar} and @code{setsar} filters accept a string in the
  3834. form @var{num}:@var{den} expressing an aspect ratio, or the following
  3835. named options, expressed as a sequence of @var{key}=@var{value} pairs,
  3836. separated by ":".
  3837. @table @option
  3838. @item max
  3839. Set the maximum integer value to use for expressing numerator and
  3840. denominator when reducing the expressed aspect ratio to a rational.
  3841. Default value is @code{100}.
  3842. @item r, ratio, dar, sar:
  3843. Set the aspect ratio used by the filter.
  3844. The parameter can be a floating point number string, an expression, or
  3845. a string of the form @var{num}:@var{den}, where @var{num} and
  3846. @var{den} are the numerator and denominator of the aspect ratio. If
  3847. the parameter is not specified, it is assumed the value "0".
  3848. In case the form "@var{num}:@var{den}" the @code{:} character should
  3849. be escaped.
  3850. @end table
  3851. If the keys are omitted in the named options list, the specifed values
  3852. are assumed to be @var{ratio} and @var{max} in that order.
  3853. For example to change the display aspect ratio to 16:9, specify:
  3854. @example
  3855. setdar='16:9'
  3856. # the above is equivalent to
  3857. setdar=1.77777
  3858. setdar=dar=16/9
  3859. setdar=dar=1.77777
  3860. @end example
  3861. To change the sample aspect ratio to 10:11, specify:
  3862. @example
  3863. setsar='10:11'
  3864. # the above is equivalent to
  3865. setsar='sar=10/11'
  3866. @end example
  3867. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  3868. 1000 in the aspect ratio reduction, use the command:
  3869. @example
  3870. setdar=ratio='16:9':max=1000
  3871. @end example
  3872. @anchor{setfield}
  3873. @section setfield
  3874. Force field for the output video frame.
  3875. The @code{setfield} filter marks the interlace type field for the
  3876. output frames. It does not change the input frame, but only sets the
  3877. corresponding property, which affects how the frame is treated by
  3878. following filters (e.g. @code{fieldorder} or @code{yadif}).
  3879. This filter accepts a single option @option{mode}, which can be
  3880. specified either by setting @code{mode=VALUE} or setting the value
  3881. alone. Available values are:
  3882. @table @samp
  3883. @item auto
  3884. Keep the same field property.
  3885. @item bff
  3886. Mark the frame as bottom-field-first.
  3887. @item tff
  3888. Mark the frame as top-field-first.
  3889. @item prog
  3890. Mark the frame as progressive.
  3891. @end table
  3892. @section showinfo
  3893. Show a line containing various information for each input video frame.
  3894. The input video is not modified.
  3895. The shown line contains a sequence of key/value pairs of the form
  3896. @var{key}:@var{value}.
  3897. A description of each shown parameter follows:
  3898. @table @option
  3899. @item n
  3900. sequential number of the input frame, starting from 0
  3901. @item pts
  3902. Presentation TimeStamp of the input frame, expressed as a number of
  3903. time base units. The time base unit depends on the filter input pad.
  3904. @item pts_time
  3905. Presentation TimeStamp of the input frame, expressed as a number of
  3906. seconds
  3907. @item pos
  3908. position of the frame in the input stream, -1 if this information in
  3909. unavailable and/or meaningless (for example in case of synthetic video)
  3910. @item fmt
  3911. pixel format name
  3912. @item sar
  3913. sample aspect ratio of the input frame, expressed in the form
  3914. @var{num}/@var{den}
  3915. @item s
  3916. size of the input frame, expressed in the form
  3917. @var{width}x@var{height}
  3918. @item i
  3919. interlaced mode ("P" for "progressive", "T" for top field first, "B"
  3920. for bottom field first)
  3921. @item iskey
  3922. 1 if the frame is a key frame, 0 otherwise
  3923. @item type
  3924. picture type of the input frame ("I" for an I-frame, "P" for a
  3925. P-frame, "B" for a B-frame, "?" for unknown type).
  3926. Check also the documentation of the @code{AVPictureType} enum and of
  3927. the @code{av_get_picture_type_char} function defined in
  3928. @file{libavutil/avutil.h}.
  3929. @item checksum
  3930. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  3931. @item plane_checksum
  3932. Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  3933. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]"
  3934. @end table
  3935. @section smartblur
  3936. Blur the input video without impacting the outlines.
  3937. A description of the accepted options follows.
  3938. @table @option
  3939. @item luma_radius, lr
  3940. Set the luma radius. The option value must be a float number in
  3941. the range [0.1,5.0] that specifies the variance of the gaussian filter
  3942. used to blur the image (slower if larger). Default value is 1.0.
  3943. @item luma_strength, ls
  3944. Set the luma strength. The option value must be a float number
  3945. in the range [-1.0,1.0] that configures the blurring. A value included
  3946. in [0.0,1.0] will blur the image whereas a value included in
  3947. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  3948. @item luma_threshold, lt
  3949. Set the luma threshold used as a coefficient to determine
  3950. whether a pixel should be blurred or not. The option value must be an
  3951. integer in the range [-30,30]. A value of 0 will filter all the image,
  3952. a value included in [0,30] will filter flat areas and a value included
  3953. in [-30,0] will filter edges. Default value is 0.
  3954. @item chroma_radius, cr
  3955. Set the chroma radius. The option value must be a float number in
  3956. the range [0.1,5.0] that specifies the variance of the gaussian filter
  3957. used to blur the image (slower if larger). Default value is 1.0.
  3958. @item chroma_strength, cs
  3959. Set the 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 chroma_threshold, ct
  3964. Set the chroma threshold used as a coefficient to determine
  3965. whether a pixel should be blurred or not. The option value must be an
  3966. integer in the range [-30,30]. A value of 0 will filter all the image,
  3967. a value included in [0,30] will filter flat areas and a value included
  3968. in [-30,0] will filter edges. Default value is 0.
  3969. @end table
  3970. If a chroma option is not explicitly set, the corresponding luma value
  3971. is set.
  3972. @section stereo3d
  3973. Convert between different stereoscopic image formats.
  3974. This filter accepts the following named options, expressed as a
  3975. sequence of @var{key}=@var{value} pairs, separated by ":".
  3976. @table @option
  3977. @item in
  3978. Set stereoscopic image format of input.
  3979. Available values for input image formats are:
  3980. @table @samp
  3981. @item sbsl
  3982. side by side parallel (left eye left, right eye right)
  3983. @item sbsr
  3984. side by side crosseye (right eye left, left eye right)
  3985. @item sbs2l
  3986. side by side parallel with half width resolution
  3987. (left eye left, right eye right)
  3988. @item sbs2r
  3989. side by side crosseye with half width resolution
  3990. (right eye left, left eye right)
  3991. @item abl
  3992. above-below (left eye above, right eye below)
  3993. @item abr
  3994. above-below (right eye above, left eye below)
  3995. @item ab2l
  3996. above-below with half height resolution
  3997. (left eye above, right eye below)
  3998. @item ab2r
  3999. above-below with half height resolution
  4000. (right eye above, left eye below)
  4001. Default value is @samp{sbsl}.
  4002. @end table
  4003. @item out
  4004. Set stereoscopic image format of output.
  4005. Available values for output image formats are all the input formats as well as:
  4006. @table @samp
  4007. @item arbg
  4008. anaglyph red/blue gray
  4009. (red filter on left eye, blue filter on right eye)
  4010. @item argg
  4011. anaglyph red/green gray
  4012. (red filter on left eye, green filter on right eye)
  4013. @item arcg
  4014. anaglyph red/cyan gray
  4015. (red filter on left eye, cyan filter on right eye)
  4016. @item arch
  4017. anaglyph red/cyan half colored
  4018. (red filter on left eye, cyan filter on right eye)
  4019. @item arcc
  4020. anaglyph red/cyan color
  4021. (red filter on left eye, cyan filter on right eye)
  4022. @item arcd
  4023. anaglyph red/cyan color optimized with the least squares projection of dubois
  4024. (red filter on left eye, cyan filter on right eye)
  4025. @item agmg
  4026. anaglyph green/magenta gray
  4027. (green filter on left eye, magenta filter on right eye)
  4028. @item agmh
  4029. anaglyph green/magenta half colored
  4030. (green filter on left eye, magenta filter on right eye)
  4031. @item agmc
  4032. anaglyph green/magenta colored
  4033. (green filter on left eye, magenta filter on right eye)
  4034. @item agmd
  4035. anaglyph green/magenta color optimized with the least squares projection of dubois
  4036. (green filter on left eye, magenta filter on right eye)
  4037. @item aybg
  4038. anaglyph yellow/blue gray
  4039. (yellow filter on left eye, blue filter on right eye)
  4040. @item aybh
  4041. anaglyph yellow/blue half colored
  4042. (yellow filter on left eye, blue filter on right eye)
  4043. @item aybc
  4044. anaglyph yellow/blue colored
  4045. (yellow filter on left eye, blue filter on right eye)
  4046. @item aybd
  4047. anaglyph yellow/blue color optimized with the least squares projection of dubois
  4048. (yellow filter on left eye, blue filter on right eye)
  4049. @item irl
  4050. interleaved rows (left eye has top row, right eye starts on next row)
  4051. @item irr
  4052. interleaved rows (right eye has top row, left eye starts on next row)
  4053. @item ml
  4054. mono output (left eye only)
  4055. @item mr
  4056. mono output (right eye only)
  4057. @end table
  4058. Default value is @samp{arcd}.
  4059. @end table
  4060. @anchor{subtitles}
  4061. @section subtitles
  4062. Draw subtitles on top of input video using the libass library.
  4063. To enable compilation of this filter you need to configure FFmpeg with
  4064. @code{--enable-libass}. This filter also requires a build with libavcodec and
  4065. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  4066. Alpha) subtitles format.
  4067. The filter accepts the following options:
  4068. @table @option
  4069. @item filename, f
  4070. Set the filename of the subtitle file to read. It must be specified.
  4071. @item original_size
  4072. Specify the size of the original video, the video for which the ASS file
  4073. was composed. Due to a misdesign in ASS aspect ratio arithmetic, this is
  4074. necessary to correctly scale the fonts if the aspect ratio has been changed.
  4075. @item charenc
  4076. Set subtitles input character encoding. @code{subtitles} filter only. Only
  4077. useful if not UTF-8.
  4078. @end table
  4079. If the first key is not specified, it is assumed that the first value
  4080. specifies the @option{filename}.
  4081. For example, to render the file @file{sub.srt} on top of the input
  4082. video, use the command:
  4083. @example
  4084. subtitles=sub.srt
  4085. @end example
  4086. which is equivalent to:
  4087. @example
  4088. subtitles=filename=sub.srt
  4089. @end example
  4090. @section split
  4091. Split input video into several identical outputs.
  4092. The filter accepts a single parameter which specifies the number of outputs. If
  4093. unspecified, it defaults to 2.
  4094. For example
  4095. @example
  4096. ffmpeg -i INPUT -filter_complex split=5 OUTPUT
  4097. @end example
  4098. will create 5 copies of the input video.
  4099. For example:
  4100. @example
  4101. [in] split [splitout1][splitout2];
  4102. [splitout1] crop=100:100:0:0 [cropout];
  4103. [splitout2] pad=200:200:100:100 [padout];
  4104. @end example
  4105. will create two separate outputs from the same input, one cropped and
  4106. one padded.
  4107. @section super2xsai
  4108. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  4109. Interpolate) pixel art scaling algorithm.
  4110. Useful for enlarging pixel art images without reducing sharpness.
  4111. @section swapuv
  4112. Swap U & V plane.
  4113. @section thumbnail
  4114. Select the most representative frame in a given sequence of consecutive frames.
  4115. The filter accepts the following options:
  4116. @table @option
  4117. @item n
  4118. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  4119. will pick one of them, and then handle the next batch of @var{n} frames until
  4120. the end. Default is @code{100}.
  4121. @end table
  4122. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  4123. value will result in a higher memory usage, so a high value is not recommended.
  4124. @subsection Examples
  4125. @itemize
  4126. @item
  4127. Extract one picture each 50 frames:
  4128. @example
  4129. thumbnail=50
  4130. @end example
  4131. @item
  4132. Complete example of a thumbnail creation with @command{ffmpeg}:
  4133. @example
  4134. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  4135. @end example
  4136. @end itemize
  4137. @section tile
  4138. Tile several successive frames together.
  4139. It accepts a list of options in the form of @var{key}=@var{value} pairs
  4140. separated by ":". A description of the accepted options follows.
  4141. @table @option
  4142. @item layout
  4143. Set the grid size (i.e. the number of lines and columns) in the form
  4144. "@var{w}x@var{h}".
  4145. @item margin
  4146. Set the outer border margin in pixels.
  4147. @item padding
  4148. Set the inner border thickness (i.e. the number of pixels between frames). For
  4149. more advanced padding options (such as having different values for the edges),
  4150. refer to the pad video filter.
  4151. @item nb_frames
  4152. Set the maximum number of frames to render in the given area. It must be less
  4153. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  4154. the area will be used.
  4155. @end table
  4156. Alternatively, the options can be specified as a flat string:
  4157. @var{layout}[:@var{nb_frames}[:@var{margin}[:@var{padding}]]]
  4158. For example, produce 8x8 PNG tiles of all keyframes (@option{-skip_frame
  4159. nokey}) in a movie:
  4160. @example
  4161. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  4162. @end example
  4163. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  4164. duplicating each output frame to accomodate the originally detected frame
  4165. rate.
  4166. Another example to display @code{5} pictures in an area of @code{3x2} frames,
  4167. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  4168. mixed flat and named options:
  4169. @example
  4170. tile=3x2:nb_frames=5:padding=7:margin=2
  4171. @end example
  4172. @section tinterlace
  4173. Perform various types of temporal field interlacing.
  4174. Frames are counted starting from 1, so the first input frame is
  4175. considered odd.
  4176. This filter accepts options in the form of @var{key}=@var{value} pairs
  4177. separated by ":".
  4178. Alternatively, the @var{mode} option can be specified as a value alone,
  4179. optionally followed by a ":" and further ":" separated @var{key}=@var{value}
  4180. pairs.
  4181. A description of the accepted options follows.
  4182. @table @option
  4183. @item mode
  4184. Specify the mode of the interlacing. This option can also be specified
  4185. as a value alone. See below for a list of values for this option.
  4186. Available values are:
  4187. @table @samp
  4188. @item merge, 0
  4189. Move odd frames into the upper field, even into the lower field,
  4190. generating a double height frame at half frame rate.
  4191. @item drop_odd, 1
  4192. Only output even frames, odd frames are dropped, generating a frame with
  4193. unchanged height at half frame rate.
  4194. @item drop_even, 2
  4195. Only output odd frames, even frames are dropped, generating a frame with
  4196. unchanged height at half frame rate.
  4197. @item pad, 3
  4198. Expand each frame to full height, but pad alternate lines with black,
  4199. generating a frame with double height at the same input frame rate.
  4200. @item interleave_top, 4
  4201. Interleave the upper field from odd frames with the lower field from
  4202. even frames, generating a frame with unchanged height at half frame rate.
  4203. @item interleave_bottom, 5
  4204. Interleave the lower field from odd frames with the upper field from
  4205. even frames, generating a frame with unchanged height at half frame rate.
  4206. @item interlacex2, 6
  4207. Double frame rate with unchanged height. Frames are inserted each
  4208. containing the second temporal field from the previous input frame and
  4209. the first temporal field from the next input frame. This mode relies on
  4210. the top_field_first flag. Useful for interlaced video displays with no
  4211. field synchronisation.
  4212. @end table
  4213. Numeric values are deprecated but are accepted for backward
  4214. compatibility reasons.
  4215. Default mode is @code{merge}.
  4216. @item flags
  4217. Specify flags influencing the filter process.
  4218. Available value for @var{flags} is:
  4219. @table @option
  4220. @item low_pass_filter, vlfp
  4221. Enable vertical low-pass filtering in the filter.
  4222. Vertical low-pass filtering is required when creating an interlaced
  4223. destination from a progressive source which contains high-frequency
  4224. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  4225. patterning.
  4226. Vertical low-pass filtering can only be enabled for @option{mode}
  4227. @var{interleave_top} and @var{interleave_bottom}.
  4228. @end table
  4229. @end table
  4230. @section transpose
  4231. Transpose rows with columns in the input video and optionally flip it.
  4232. This filter accepts the following options:
  4233. @table @option
  4234. @item dir
  4235. The direction of the transpose.
  4236. @table @samp
  4237. @item 0, 4, cclock_flip
  4238. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  4239. @example
  4240. L.R L.l
  4241. . . -> . .
  4242. l.r R.r
  4243. @end example
  4244. @item 1, 5, clock
  4245. Rotate by 90 degrees clockwise, that is:
  4246. @example
  4247. L.R l.L
  4248. . . -> . .
  4249. l.r r.R
  4250. @end example
  4251. @item 2, 6, cclock
  4252. Rotate by 90 degrees counterclockwise, that is:
  4253. @example
  4254. L.R R.r
  4255. . . -> . .
  4256. l.r L.l
  4257. @end example
  4258. @item 3, 7, clock_flip
  4259. Rotate by 90 degrees clockwise and vertically flip, that is:
  4260. @example
  4261. L.R r.R
  4262. . . -> . .
  4263. l.r l.L
  4264. @end example
  4265. @end table
  4266. For values between 4-7, the transposition is only done if the input
  4267. video geometry is portrait and not landscape. These values are
  4268. deprecated, the @code{passthrough} option should be used instead.
  4269. @item passthrough
  4270. Do not apply the transposition if the input geometry matches the one
  4271. specified by the specified value. It accepts the following values:
  4272. @table @samp
  4273. @item none
  4274. Always apply transposition.
  4275. @item portrait
  4276. Preserve portrait geometry (when @var{height} >= @var{width}).
  4277. @item landscape
  4278. Preserve landscape geometry (when @var{width} >= @var{height}).
  4279. @end table
  4280. Default value is @code{none}.
  4281. @end table
  4282. For example to rotate by 90 degrees clockwise and preserve portrait
  4283. layout:
  4284. @example
  4285. transpose=dir=1:passthrough=portrait
  4286. @end example
  4287. The command above can also be specified as:
  4288. @example
  4289. transpose=1:portrait
  4290. @end example
  4291. @section unsharp
  4292. Sharpen or blur the input video.
  4293. It accepts the following parameters:
  4294. @table @option
  4295. @item luma_msize_x, lx
  4296. @item chroma_msize_x, cx
  4297. Set the luma/chroma matrix horizontal size. It must be an odd integer
  4298. between 3 and 63, default value is 5.
  4299. @item luma_msize_y, ly
  4300. @item chroma_msize_y, cy
  4301. Set the luma/chroma matrix vertical size. It must be an odd integer
  4302. between 3 and 63, default value is 5.
  4303. @item luma_amount, la
  4304. @item chroma_amount, ca
  4305. Set the luma/chroma effect strength. It can be a float number,
  4306. reasonable values lay between -1.5 and 1.5.
  4307. Negative values will blur the input video, while positive values will
  4308. sharpen it, a value of zero will disable the effect.
  4309. Default value is 1.0 for @option{luma_amount}, 0.0 for
  4310. @option{chroma_amount}.
  4311. @end table
  4312. All parameters are optional and default to the
  4313. equivalent of the string '5:5:1.0:5:5:0.0'.
  4314. @subsection Examples
  4315. @itemize
  4316. @item
  4317. Apply strong luma sharpen effect:
  4318. @example
  4319. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  4320. @end example
  4321. @item
  4322. Apply strong blur of both luma and chroma parameters:
  4323. @example
  4324. unsharp=7:7:-2:7:7:-2
  4325. @end example
  4326. @end itemize
  4327. @section vflip
  4328. Flip the input video vertically.
  4329. @example
  4330. ffmpeg -i in.avi -vf "vflip" out.avi
  4331. @end example
  4332. @section yadif
  4333. Deinterlace the input video ("yadif" means "yet another deinterlacing
  4334. filter").
  4335. The filter accepts parameters as a list of @var{key}=@var{value}
  4336. pairs, separated by ":". If the key of the first options is omitted,
  4337. the arguments are interpreted according to syntax
  4338. @var{mode}:@var{parity}:@var{deint}.
  4339. The description of the accepted parameters follows.
  4340. @table @option
  4341. @item mode
  4342. Specify the interlacing mode to adopt. Accept one of the following
  4343. values:
  4344. @table @option
  4345. @item 0, send_frame
  4346. output 1 frame for each frame
  4347. @item 1, send_field
  4348. output 1 frame for each field
  4349. @item 2, send_frame_nospatial
  4350. like @code{send_frame} but skip spatial interlacing check
  4351. @item 3, send_field_nospatial
  4352. like @code{send_field} but skip spatial interlacing check
  4353. @end table
  4354. Default value is @code{send_frame}.
  4355. @item parity
  4356. Specify the picture field parity assumed for the input interlaced
  4357. video. Accept one of the following values:
  4358. @table @option
  4359. @item 0, tff
  4360. assume top field first
  4361. @item 1, bff
  4362. assume bottom field first
  4363. @item -1, auto
  4364. enable automatic detection
  4365. @end table
  4366. Default value is @code{auto}.
  4367. If interlacing is unknown or decoder does not export this information,
  4368. top field first will be assumed.
  4369. @item deint
  4370. Specify which frames to deinterlace. Accept one of the following
  4371. values:
  4372. @table @option
  4373. @item 0, all
  4374. deinterlace all frames
  4375. @item 1, interlaced
  4376. only deinterlace frames marked as interlaced
  4377. @end table
  4378. Default value is @code{all}.
  4379. @end table
  4380. @c man end VIDEO FILTERS
  4381. @chapter Video Sources
  4382. @c man begin VIDEO SOURCES
  4383. Below is a description of the currently available video sources.
  4384. @section buffer
  4385. Buffer video frames, and make them available to the filter chain.
  4386. This source is mainly intended for a programmatic use, in particular
  4387. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  4388. It accepts a list of options in the form of @var{key}=@var{value} pairs
  4389. separated by ":". A description of the accepted options follows.
  4390. @table @option
  4391. @item video_size
  4392. Specify the size (width and height) of the buffered video frames.
  4393. @item pix_fmt
  4394. A string representing the pixel format of the buffered video frames.
  4395. It may be a number corresponding to a pixel format, or a pixel format
  4396. name.
  4397. @item time_base
  4398. Specify the timebase assumed by the timestamps of the buffered frames.
  4399. @item time_base
  4400. Specify the frame rate expected for the video stream.
  4401. @item pixel_aspect
  4402. Specify the sample aspect ratio assumed by the video frames.
  4403. @item sws_param
  4404. Specify the optional parameters to be used for the scale filter which
  4405. is automatically inserted when an input change is detected in the
  4406. input size or format.
  4407. @end table
  4408. For example:
  4409. @example
  4410. buffer=size=320x240:pix_fmt=yuv410p:time_base=1/24:pixel_aspect=1/1
  4411. @end example
  4412. will instruct the source to accept video frames with size 320x240 and
  4413. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  4414. square pixels (1:1 sample aspect ratio).
  4415. Since the pixel format with name "yuv410p" corresponds to the number 6
  4416. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  4417. this example corresponds to:
  4418. @example
  4419. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  4420. @end example
  4421. Alternatively, the options can be specified as a flat string, but this
  4422. syntax is deprecated:
  4423. @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}]
  4424. @section cellauto
  4425. Create a pattern generated by an elementary cellular automaton.
  4426. The initial state of the cellular automaton can be defined through the
  4427. @option{filename}, and @option{pattern} options. If such options are
  4428. not specified an initial state is created randomly.
  4429. At each new frame a new row in the video is filled with the result of
  4430. the cellular automaton next generation. The behavior when the whole
  4431. frame is filled is defined by the @option{scroll} option.
  4432. This source accepts the following options:
  4433. @table @option
  4434. @item filename, f
  4435. Read the initial cellular automaton state, i.e. the starting row, from
  4436. the specified file.
  4437. In the file, each non-whitespace character is considered an alive
  4438. cell, a newline will terminate the row, and further characters in the
  4439. file will be ignored.
  4440. @item pattern, p
  4441. Read the initial cellular automaton state, i.e. the starting row, from
  4442. the specified string.
  4443. Each non-whitespace character in the string is considered an alive
  4444. cell, a newline will terminate the row, and further characters in the
  4445. string will be ignored.
  4446. @item rate, r
  4447. Set the video rate, that is the number of frames generated per second.
  4448. Default is 25.
  4449. @item random_fill_ratio, ratio
  4450. Set the random fill ratio for the initial cellular automaton row. It
  4451. is a floating point number value ranging from 0 to 1, defaults to
  4452. 1/PHI.
  4453. This option is ignored when a file or a pattern is specified.
  4454. @item random_seed, seed
  4455. Set the seed for filling randomly the initial row, must be an integer
  4456. included between 0 and UINT32_MAX. If not specified, or if explicitly
  4457. set to -1, the filter will try to use a good random seed on a best
  4458. effort basis.
  4459. @item rule
  4460. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  4461. Default value is 110.
  4462. @item size, s
  4463. Set the size of the output video.
  4464. If @option{filename} or @option{pattern} is specified, the size is set
  4465. by default to the width of the specified initial state row, and the
  4466. height is set to @var{width} * PHI.
  4467. If @option{size} is set, it must contain the width of the specified
  4468. pattern string, and the specified pattern will be centered in the
  4469. larger row.
  4470. If a filename or a pattern string is not specified, the size value
  4471. defaults to "320x518" (used for a randomly generated initial state).
  4472. @item scroll
  4473. If set to 1, scroll the output upward when all the rows in the output
  4474. have been already filled. If set to 0, the new generated row will be
  4475. written over the top row just after the bottom row is filled.
  4476. Defaults to 1.
  4477. @item start_full, full
  4478. If set to 1, completely fill the output with generated rows before
  4479. outputting the first frame.
  4480. This is the default behavior, for disabling set the value to 0.
  4481. @item stitch
  4482. If set to 1, stitch the left and right row edges together.
  4483. This is the default behavior, for disabling set the value to 0.
  4484. @end table
  4485. @subsection Examples
  4486. @itemize
  4487. @item
  4488. Read the initial state from @file{pattern}, and specify an output of
  4489. size 200x400.
  4490. @example
  4491. cellauto=f=pattern:s=200x400
  4492. @end example
  4493. @item
  4494. Generate a random initial row with a width of 200 cells, with a fill
  4495. ratio of 2/3:
  4496. @example
  4497. cellauto=ratio=2/3:s=200x200
  4498. @end example
  4499. @item
  4500. Create a pattern generated by rule 18 starting by a single alive cell
  4501. centered on an initial row with width 100:
  4502. @example
  4503. cellauto=p=@@:s=100x400:full=0:rule=18
  4504. @end example
  4505. @item
  4506. Specify a more elaborated initial pattern:
  4507. @example
  4508. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  4509. @end example
  4510. @end itemize
  4511. @section mandelbrot
  4512. Generate a Mandelbrot set fractal, and progressively zoom towards the
  4513. point specified with @var{start_x} and @var{start_y}.
  4514. This source accepts the following options:
  4515. @table @option
  4516. @item end_pts
  4517. Set the terminal pts value. Default value is 400.
  4518. @item end_scale
  4519. Set the terminal scale value.
  4520. Must be a floating point value. Default value is 0.3.
  4521. @item inner
  4522. Set the inner coloring mode, that is the algorithm used to draw the
  4523. Mandelbrot fractal internal region.
  4524. It shall assume one of the following values:
  4525. @table @option
  4526. @item black
  4527. Set black mode.
  4528. @item convergence
  4529. Show time until convergence.
  4530. @item mincol
  4531. Set color based on point closest to the origin of the iterations.
  4532. @item period
  4533. Set period mode.
  4534. @end table
  4535. Default value is @var{mincol}.
  4536. @item bailout
  4537. Set the bailout value. Default value is 10.0.
  4538. @item maxiter
  4539. Set the maximum of iterations performed by the rendering
  4540. algorithm. Default value is 7189.
  4541. @item outer
  4542. Set outer coloring mode.
  4543. It shall assume one of following values:
  4544. @table @option
  4545. @item iteration_count
  4546. Set iteration cound mode.
  4547. @item normalized_iteration_count
  4548. set normalized iteration count mode.
  4549. @end table
  4550. Default value is @var{normalized_iteration_count}.
  4551. @item rate, r
  4552. Set frame rate, expressed as number of frames per second. Default
  4553. value is "25".
  4554. @item size, s
  4555. Set frame size. Default value is "640x480".
  4556. @item start_scale
  4557. Set the initial scale value. Default value is 3.0.
  4558. @item start_x
  4559. Set the initial x position. Must be a floating point value between
  4560. -100 and 100. Default value is -0.743643887037158704752191506114774.
  4561. @item start_y
  4562. Set the initial y position. Must be a floating point value between
  4563. -100 and 100. Default value is -0.131825904205311970493132056385139.
  4564. @end table
  4565. @section mptestsrc
  4566. Generate various test patterns, as generated by the MPlayer test filter.
  4567. The size of the generated video is fixed, and is 256x256.
  4568. This source is useful in particular for testing encoding features.
  4569. This source accepts the following options:
  4570. @table @option
  4571. @item rate, r
  4572. Specify the frame rate of the sourced video, as the number of frames
  4573. generated per second. It has to be a string in the format
  4574. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  4575. number or a valid video frame rate abbreviation. The default value is
  4576. "25".
  4577. @item duration, d
  4578. Set the video duration of the sourced video. The accepted syntax is:
  4579. @example
  4580. [-]HH:MM:SS[.m...]
  4581. [-]S+[.m...]
  4582. @end example
  4583. See also the function @code{av_parse_time()}.
  4584. If not specified, or the expressed duration is negative, the video is
  4585. supposed to be generated forever.
  4586. @item test, t
  4587. Set the number or the name of the test to perform. Supported tests are:
  4588. @table @option
  4589. @item dc_luma
  4590. @item dc_chroma
  4591. @item freq_luma
  4592. @item freq_chroma
  4593. @item amp_luma
  4594. @item amp_chroma
  4595. @item cbp
  4596. @item mv
  4597. @item ring1
  4598. @item ring2
  4599. @item all
  4600. @end table
  4601. Default value is "all", which will cycle through the list of all tests.
  4602. @end table
  4603. For example the following:
  4604. @example
  4605. testsrc=t=dc_luma
  4606. @end example
  4607. will generate a "dc_luma" test pattern.
  4608. @section frei0r_src
  4609. Provide a frei0r source.
  4610. To enable compilation of this filter you need to install the frei0r
  4611. header and configure FFmpeg with @code{--enable-frei0r}.
  4612. This source accepts the following options:
  4613. @table @option
  4614. @item size
  4615. The size of the video to generate, may be a string of the form
  4616. @var{width}x@var{height} or a frame size abbreviation.
  4617. @item framerate
  4618. Framerate of the generated video, may be a string of the form
  4619. @var{num}/@var{den} or a frame rate abbreviation.
  4620. @item filter_name
  4621. The name to the frei0r source to load. For more information regarding frei0r and
  4622. how to set the parameters read the section @ref{frei0r} in the description of
  4623. the video filters.
  4624. @item filter_params
  4625. A '|'-separated list of parameters to pass to the frei0r source.
  4626. @end table
  4627. For example, to generate a frei0r partik0l source with size 200x200
  4628. and frame rate 10 which is overlayed on the overlay filter main input:
  4629. @example
  4630. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  4631. @end example
  4632. @section life
  4633. Generate a life pattern.
  4634. This source is based on a generalization of John Conway's life game.
  4635. The sourced input represents a life grid, each pixel represents a cell
  4636. which can be in one of two possible states, alive or dead. Every cell
  4637. interacts with its eight neighbours, which are the cells that are
  4638. horizontally, vertically, or diagonally adjacent.
  4639. At each interaction the grid evolves according to the adopted rule,
  4640. which specifies the number of neighbor alive cells which will make a
  4641. cell stay alive or born. The @option{rule} option allows to specify
  4642. the rule to adopt.
  4643. This source accepts the following options:
  4644. @table @option
  4645. @item filename, f
  4646. Set the file from which to read the initial grid state. In the file,
  4647. each non-whitespace character is considered an alive cell, and newline
  4648. is used to delimit the end of each row.
  4649. If this option is not specified, the initial grid is generated
  4650. randomly.
  4651. @item rate, r
  4652. Set the video rate, that is the number of frames generated per second.
  4653. Default is 25.
  4654. @item random_fill_ratio, ratio
  4655. Set the random fill ratio for the initial random grid. It is a
  4656. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  4657. It is ignored when a file is specified.
  4658. @item random_seed, seed
  4659. Set the seed for filling the initial random grid, must be an integer
  4660. included between 0 and UINT32_MAX. If not specified, or if explicitly
  4661. set to -1, the filter will try to use a good random seed on a best
  4662. effort basis.
  4663. @item rule
  4664. Set the life rule.
  4665. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  4666. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  4667. @var{NS} specifies the number of alive neighbor cells which make a
  4668. live cell stay alive, and @var{NB} the number of alive neighbor cells
  4669. which make a dead cell to become alive (i.e. to "born").
  4670. "s" and "b" can be used in place of "S" and "B", respectively.
  4671. Alternatively a rule can be specified by an 18-bits integer. The 9
  4672. high order bits are used to encode the next cell state if it is alive
  4673. for each number of neighbor alive cells, the low order bits specify
  4674. the rule for "borning" new cells. Higher order bits encode for an
  4675. higher number of neighbor cells.
  4676. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  4677. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  4678. Default value is "S23/B3", which is the original Conway's game of life
  4679. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  4680. cells, and will born a new cell if there are three alive cells around
  4681. a dead cell.
  4682. @item size, s
  4683. Set the size of the output video.
  4684. If @option{filename} is specified, the size is set by default to the
  4685. same size of the input file. If @option{size} is set, it must contain
  4686. the size specified in the input file, and the initial grid defined in
  4687. that file is centered in the larger resulting area.
  4688. If a filename is not specified, the size value defaults to "320x240"
  4689. (used for a randomly generated initial grid).
  4690. @item stitch
  4691. If set to 1, stitch the left and right grid edges together, and the
  4692. top and bottom edges also. Defaults to 1.
  4693. @item mold
  4694. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  4695. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  4696. value from 0 to 255.
  4697. @item life_color
  4698. Set the color of living (or new born) cells.
  4699. @item death_color
  4700. Set the color of dead cells. If @option{mold} is set, this is the first color
  4701. used to represent a dead cell.
  4702. @item mold_color
  4703. Set mold color, for definitely dead and moldy cells.
  4704. @end table
  4705. @subsection Examples
  4706. @itemize
  4707. @item
  4708. Read a grid from @file{pattern}, and center it on a grid of size
  4709. 300x300 pixels:
  4710. @example
  4711. life=f=pattern:s=300x300
  4712. @end example
  4713. @item
  4714. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  4715. @example
  4716. life=ratio=2/3:s=200x200
  4717. @end example
  4718. @item
  4719. Specify a custom rule for evolving a randomly generated grid:
  4720. @example
  4721. life=rule=S14/B34
  4722. @end example
  4723. @item
  4724. Full example with slow death effect (mold) using @command{ffplay}:
  4725. @example
  4726. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  4727. @end example
  4728. @end itemize
  4729. @section color, nullsrc, rgbtestsrc, smptebars, testsrc
  4730. The @code{color} source provides an uniformly colored input.
  4731. The @code{nullsrc} source returns unprocessed video frames. It is
  4732. mainly useful to be employed in analysis / debugging tools, or as the
  4733. source for filters which ignore the input data.
  4734. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  4735. detecting RGB vs BGR issues. You should see a red, green and blue
  4736. stripe from top to bottom.
  4737. The @code{smptebars} source generates a color bars pattern, based on
  4738. the SMPTE Engineering Guideline EG 1-1990.
  4739. The @code{testsrc} source generates a test video pattern, showing a
  4740. color pattern, a scrolling gradient and a timestamp. This is mainly
  4741. intended for testing purposes.
  4742. These sources accept an optional sequence of @var{key}=@var{value} pairs,
  4743. separated by ":". The description of the accepted options follows.
  4744. @table @option
  4745. @item color, c
  4746. Specify the color of the source, only used in the @code{color}
  4747. source. It can be the name of a color (case insensitive match) or a
  4748. 0xRRGGBB[AA] sequence, possibly followed by an alpha specifier. The
  4749. default value is "black".
  4750. @item size, s
  4751. Specify the size of the sourced video, it may be a string of the form
  4752. @var{width}x@var{height}, or the name of a size abbreviation. The
  4753. default value is "320x240".
  4754. @item rate, r
  4755. Specify the frame rate of the sourced video, as the number of frames
  4756. generated per second. It has to be a string in the format
  4757. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  4758. number or a valid video frame rate abbreviation. The default value is
  4759. "25".
  4760. @item sar
  4761. Set the sample aspect ratio of the sourced video.
  4762. @item duration, d
  4763. Set the video duration of the sourced video. The accepted syntax is:
  4764. @example
  4765. [-]HH[:MM[:SS[.m...]]]
  4766. [-]S+[.m...]
  4767. @end example
  4768. See also the function @code{av_parse_time()}.
  4769. If not specified, or the expressed duration is negative, the video is
  4770. supposed to be generated forever.
  4771. @item decimals, n
  4772. Set the number of decimals to show in the timestamp, only used in the
  4773. @code{testsrc} source.
  4774. The displayed timestamp value will correspond to the original
  4775. timestamp value multiplied by the power of 10 of the specified
  4776. value. Default value is 0.
  4777. @end table
  4778. For example the following:
  4779. @example
  4780. testsrc=duration=5.3:size=qcif:rate=10
  4781. @end example
  4782. will generate a video with a duration of 5.3 seconds, with size
  4783. 176x144 and a frame rate of 10 frames per second.
  4784. The following graph description will generate a red source
  4785. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  4786. frames per second.
  4787. @example
  4788. color=c=red@@0.2:s=qcif:r=10
  4789. @end example
  4790. If the input content is to be ignored, @code{nullsrc} can be used. The
  4791. following command generates noise in the luminance plane by employing
  4792. the @code{geq} filter:
  4793. @example
  4794. nullsrc=s=256x256, geq=random(1)*255:128:128
  4795. @end example
  4796. @c man end VIDEO SOURCES
  4797. @chapter Video Sinks
  4798. @c man begin VIDEO SINKS
  4799. Below is a description of the currently available video sinks.
  4800. @section buffersink
  4801. Buffer video frames, and make them available to the end of the filter
  4802. graph.
  4803. This sink is mainly intended for a programmatic use, in particular
  4804. through the interface defined in @file{libavfilter/buffersink.h}.
  4805. It does not require a string parameter in input, but you need to
  4806. specify a pointer to a list of supported pixel formats terminated by
  4807. -1 in the opaque parameter provided to @code{avfilter_init_filter}
  4808. when initializing this sink.
  4809. @section nullsink
  4810. Null video sink, do absolutely nothing with the input video. It is
  4811. mainly useful as a template and to be employed in analysis / debugging
  4812. tools.
  4813. @c man end VIDEO SINKS
  4814. @chapter Multimedia Filters
  4815. @c man begin MULTIMEDIA FILTERS
  4816. Below is a description of the currently available multimedia filters.
  4817. @section aperms, perms
  4818. Set read/write permissions for the output frames.
  4819. These filters are mainly aimed at developers to test direct path in the
  4820. following filter in the filtergraph.
  4821. The filters accept the following options:
  4822. @table @option
  4823. @item mode
  4824. Select the permissions mode.
  4825. It accepts the following values:
  4826. @table @samp
  4827. @item none
  4828. Do nothing. This is the default.
  4829. @item ro
  4830. Set all the output frames read-only.
  4831. @item rw
  4832. Set all the output frames directly writable.
  4833. @item toggle
  4834. Make the frame read-only if writable, and writable if read-only.
  4835. @item random
  4836. Set each output frame read-only or writable randomly.
  4837. @end table
  4838. @item seed
  4839. Set the seed for the @var{random} mode, must be an integer included between
  4840. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  4841. @code{-1}, the filter will try to use a good random seed on a best effort
  4842. basis.
  4843. @end table
  4844. Note: in case of auto-inserted filter between the permission filter and the
  4845. following one, the permission might not be received as expected in that
  4846. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  4847. perms/aperms filter can avoid this problem.
  4848. @section aphaser
  4849. Add a phasing effect to the input audio.
  4850. A phaser filter creates series of peaks and troughs in the frequency spectrum.
  4851. The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
  4852. The filter accepts parameters as a list of @var{key}=@var{value}
  4853. pairs, separated by ":".
  4854. A description of the accepted parameters follows.
  4855. @table @option
  4856. @item in_gain
  4857. Set input gain. Default is 0.4.
  4858. @item out_gain
  4859. Set output gain. Default is 0.74
  4860. @item delay
  4861. Set delay in milliseconds. Default is 3.0.
  4862. @item decay
  4863. Set decay. Default is 0.4.
  4864. @item speed
  4865. Set modulation speed in Hz. Default is 0.5.
  4866. @item type
  4867. Set modulation type. Default is triangular.
  4868. It accepts the following values:
  4869. @table @samp
  4870. @item triangular, t
  4871. @item sinusoidal, s
  4872. @end table
  4873. @end table
  4874. @section aselect, select
  4875. Select frames to pass in output.
  4876. This filter accepts the following options:
  4877. @table @option
  4878. @item expr
  4879. An expression, which is evaluated for each input frame. If the expression is
  4880. evaluated to a non-zero value, the frame is selected and passed to the output,
  4881. otherwise it is discarded.
  4882. @end table
  4883. The expression can contain the following constants:
  4884. @table @option
  4885. @item n
  4886. the sequential number of the filtered frame, starting from 0
  4887. @item selected_n
  4888. the sequential number of the selected frame, starting from 0
  4889. @item prev_selected_n
  4890. the sequential number of the last selected frame, NAN if undefined
  4891. @item TB
  4892. timebase of the input timestamps
  4893. @item pts
  4894. the PTS (Presentation TimeStamp) of the filtered video frame,
  4895. expressed in @var{TB} units, NAN if undefined
  4896. @item t
  4897. the PTS (Presentation TimeStamp) of the filtered video frame,
  4898. expressed in seconds, NAN if undefined
  4899. @item prev_pts
  4900. the PTS of the previously filtered video frame, NAN if undefined
  4901. @item prev_selected_pts
  4902. the PTS of the last previously filtered video frame, NAN if undefined
  4903. @item prev_selected_t
  4904. the PTS of the last previously selected video frame, NAN if undefined
  4905. @item start_pts
  4906. the PTS of the first video frame in the video, NAN if undefined
  4907. @item start_t
  4908. the time of the first video frame in the video, NAN if undefined
  4909. @item pict_type @emph{(video only)}
  4910. the type of the filtered frame, can assume one of the following
  4911. values:
  4912. @table @option
  4913. @item I
  4914. @item P
  4915. @item B
  4916. @item S
  4917. @item SI
  4918. @item SP
  4919. @item BI
  4920. @end table
  4921. @item interlace_type @emph{(video only)}
  4922. the frame interlace type, can assume one of the following values:
  4923. @table @option
  4924. @item PROGRESSIVE
  4925. the frame is progressive (not interlaced)
  4926. @item TOPFIRST
  4927. the frame is top-field-first
  4928. @item BOTTOMFIRST
  4929. the frame is bottom-field-first
  4930. @end table
  4931. @item consumed_sample_n @emph{(audio only)}
  4932. the number of selected samples before the current frame
  4933. @item samples_n @emph{(audio only)}
  4934. the number of samples in the current frame
  4935. @item sample_rate @emph{(audio only)}
  4936. the input sample rate
  4937. @item key
  4938. 1 if the filtered frame is a key-frame, 0 otherwise
  4939. @item pos
  4940. the position in the file of the filtered frame, -1 if the information
  4941. is not available (e.g. for synthetic video)
  4942. @item scene @emph{(video only)}
  4943. value between 0 and 1 to indicate a new scene; a low value reflects a low
  4944. probability for the current frame to introduce a new scene, while a higher
  4945. value means the current frame is more likely to be one (see the example below)
  4946. @end table
  4947. The default value of the select expression is "1".
  4948. @subsection Examples
  4949. @itemize
  4950. @item
  4951. Select all frames in input:
  4952. @example
  4953. select
  4954. @end example
  4955. The example above is the same as:
  4956. @example
  4957. select=1
  4958. @end example
  4959. @item
  4960. Skip all frames:
  4961. @example
  4962. select=0
  4963. @end example
  4964. @item
  4965. Select only I-frames:
  4966. @example
  4967. select='eq(pict_type\,I)'
  4968. @end example
  4969. @item
  4970. Select one frame every 100:
  4971. @example
  4972. select='not(mod(n\,100))'
  4973. @end example
  4974. @item
  4975. Select only frames contained in the 10-20 time interval:
  4976. @example
  4977. select='gte(t\,10)*lte(t\,20)'
  4978. @end example
  4979. @item
  4980. Select only I frames contained in the 10-20 time interval:
  4981. @example
  4982. select='gte(t\,10)*lte(t\,20)*eq(pict_type\,I)'
  4983. @end example
  4984. @item
  4985. Select frames with a minimum distance of 10 seconds:
  4986. @example
  4987. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  4988. @end example
  4989. @item
  4990. Use aselect to select only audio frames with samples number > 100:
  4991. @example
  4992. aselect='gt(samples_n\,100)'
  4993. @end example
  4994. @item
  4995. Create a mosaic of the first scenes:
  4996. @example
  4997. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  4998. @end example
  4999. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  5000. choice.
  5001. @end itemize
  5002. @section asendcmd, sendcmd
  5003. Send commands to filters in the filtergraph.
  5004. These filters read commands to be sent to other filters in the
  5005. filtergraph.
  5006. @code{asendcmd} must be inserted between two audio filters,
  5007. @code{sendcmd} must be inserted between two video filters, but apart
  5008. from that they act the same way.
  5009. The specification of commands can be provided in the filter arguments
  5010. with the @var{commands} option, or in a file specified by the
  5011. @var{filename} option.
  5012. These filters accept the following options:
  5013. @table @option
  5014. @item commands, c
  5015. Set the commands to be read and sent to the other filters.
  5016. @item filename, f
  5017. Set the filename of the commands to be read and sent to the other
  5018. filters.
  5019. @end table
  5020. @subsection Commands syntax
  5021. A commands description consists of a sequence of interval
  5022. specifications, comprising a list of commands to be executed when a
  5023. particular event related to that interval occurs. The occurring event
  5024. is typically the current frame time entering or leaving a given time
  5025. interval.
  5026. An interval is specified by the following syntax:
  5027. @example
  5028. @var{START}[-@var{END}] @var{COMMANDS};
  5029. @end example
  5030. The time interval is specified by the @var{START} and @var{END} times.
  5031. @var{END} is optional and defaults to the maximum time.
  5032. The current frame time is considered within the specified interval if
  5033. it is included in the interval [@var{START}, @var{END}), that is when
  5034. the time is greater or equal to @var{START} and is lesser than
  5035. @var{END}.
  5036. @var{COMMANDS} consists of a sequence of one or more command
  5037. specifications, separated by ",", relating to that interval. The
  5038. syntax of a command specification is given by:
  5039. @example
  5040. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  5041. @end example
  5042. @var{FLAGS} is optional and specifies the type of events relating to
  5043. the time interval which enable sending the specified command, and must
  5044. be a non-null sequence of identifier flags separated by "+" or "|" and
  5045. enclosed between "[" and "]".
  5046. The following flags are recognized:
  5047. @table @option
  5048. @item enter
  5049. The command is sent when the current frame timestamp enters the
  5050. specified interval. In other words, the command is sent when the
  5051. previous frame timestamp was not in the given interval, and the
  5052. current is.
  5053. @item leave
  5054. The command is sent when the current frame timestamp leaves the
  5055. specified interval. In other words, the command is sent when the
  5056. previous frame timestamp was in the given interval, and the
  5057. current is not.
  5058. @end table
  5059. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  5060. assumed.
  5061. @var{TARGET} specifies the target of the command, usually the name of
  5062. the filter class or a specific filter instance name.
  5063. @var{COMMAND} specifies the name of the command for the target filter.
  5064. @var{ARG} is optional and specifies the optional list of argument for
  5065. the given @var{COMMAND}.
  5066. Between one interval specification and another, whitespaces, or
  5067. sequences of characters starting with @code{#} until the end of line,
  5068. are ignored and can be used to annotate comments.
  5069. A simplified BNF description of the commands specification syntax
  5070. follows:
  5071. @example
  5072. @var{COMMAND_FLAG} ::= "enter" | "leave"
  5073. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  5074. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  5075. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  5076. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  5077. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  5078. @end example
  5079. @subsection Examples
  5080. @itemize
  5081. @item
  5082. Specify audio tempo change at second 4:
  5083. @example
  5084. asendcmd=c='4.0 atempo tempo 1.5',atempo
  5085. @end example
  5086. @item
  5087. Specify a list of drawtext and hue commands in a file.
  5088. @example
  5089. # show text in the interval 5-10
  5090. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  5091. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  5092. # desaturate the image in the interval 15-20
  5093. 15.0-20.0 [enter] hue reinit s=0,
  5094. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  5095. [leave] hue reinit s=1,
  5096. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  5097. # apply an exponential saturation fade-out effect, starting from time 25
  5098. 25 [enter] hue s=exp(t-25)
  5099. @end example
  5100. A filtergraph allowing to read and process the above command list
  5101. stored in a file @file{test.cmd}, can be specified with:
  5102. @example
  5103. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  5104. @end example
  5105. @end itemize
  5106. @anchor{setpts}
  5107. @section asetpts, setpts
  5108. Change the PTS (presentation timestamp) of the input frames.
  5109. @code{asetpts} works on audio frames, @code{setpts} on video frames.
  5110. This filter accepts the following options:
  5111. @table @option
  5112. @item expr
  5113. The expression which is evaluated for each frame to construct its timestamp.
  5114. @end table
  5115. The expression is evaluated through the eval API and can contain the following
  5116. constants:
  5117. @table @option
  5118. @item FRAME_RATE
  5119. frame rate, only defined for constant frame-rate video
  5120. @item PTS
  5121. the presentation timestamp in input
  5122. @item N
  5123. the count of the input frame, starting from 0.
  5124. @item NB_CONSUMED_SAMPLES
  5125. the number of consumed samples, not including the current frame (only
  5126. audio)
  5127. @item NB_SAMPLES
  5128. the number of samples in the current frame (only audio)
  5129. @item SAMPLE_RATE
  5130. audio sample rate
  5131. @item STARTPTS
  5132. the PTS of the first frame
  5133. @item STARTT
  5134. the time in seconds of the first frame
  5135. @item INTERLACED
  5136. tell if the current frame is interlaced
  5137. @item T
  5138. the time in seconds of the current frame
  5139. @item TB
  5140. the time base
  5141. @item POS
  5142. original position in the file of the frame, or undefined if undefined
  5143. for the current frame
  5144. @item PREV_INPTS
  5145. previous input PTS
  5146. @item PREV_INT
  5147. previous input time in seconds
  5148. @item PREV_OUTPTS
  5149. previous output PTS
  5150. @item PREV_OUTT
  5151. previous output time in seconds
  5152. @item RTCTIME
  5153. wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  5154. instead.
  5155. @item RTCSTART
  5156. wallclock (RTC) time at the start of the movie in microseconds
  5157. @end table
  5158. @subsection Examples
  5159. @itemize
  5160. @item
  5161. Start counting PTS from zero
  5162. @example
  5163. setpts=PTS-STARTPTS
  5164. @end example
  5165. @item
  5166. Apply fast motion effect:
  5167. @example
  5168. setpts=0.5*PTS
  5169. @end example
  5170. @item
  5171. Apply slow motion effect:
  5172. @example
  5173. setpts=2.0*PTS
  5174. @end example
  5175. @item
  5176. Set fixed rate of 25 frames per second:
  5177. @example
  5178. setpts=N/(25*TB)
  5179. @end example
  5180. @item
  5181. Set fixed rate 25 fps with some jitter:
  5182. @example
  5183. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  5184. @end example
  5185. @item
  5186. Apply an offset of 10 seconds to the input PTS:
  5187. @example
  5188. setpts=PTS+10/TB
  5189. @end example
  5190. @item
  5191. Generate timestamps from a "live source" and rebase onto the current timebase:
  5192. @example
  5193. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  5194. @end example
  5195. @end itemize
  5196. @section ebur128
  5197. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  5198. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  5199. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  5200. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  5201. The filter also has a video output (see the @var{video} option) with a real
  5202. time graph to observe the loudness evolution. The graphic contains the logged
  5203. message mentioned above, so it is not printed anymore when this option is set,
  5204. unless the verbose logging is set. The main graphing area contains the
  5205. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  5206. the momentary loudness (400 milliseconds).
  5207. More information about the Loudness Recommendation EBU R128 on
  5208. @url{http://tech.ebu.ch/loudness}.
  5209. The filter accepts the following options:
  5210. @table @option
  5211. @item video
  5212. Activate the video output. The audio stream is passed unchanged whether this
  5213. option is set or no. The video stream will be the first output stream if
  5214. activated. Default is @code{0}.
  5215. @item size
  5216. Set the video size. This option is for video only. Default and minimum
  5217. resolution is @code{640x480}.
  5218. @item meter
  5219. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  5220. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  5221. other integer value between this range is allowed.
  5222. @item metadata
  5223. Set metadata injection. If set to @code{1}, the audio input will be segmented
  5224. into 100ms output frames, each of them containing various loudness information
  5225. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  5226. Default is @code{0}.
  5227. @item framelog
  5228. Force the frame logging level.
  5229. Available values are:
  5230. @table @samp
  5231. @item info
  5232. information logging level
  5233. @item verbose
  5234. verbose logging level
  5235. @end table
  5236. By default, the logging level is set to @var{info}. If the @option{video} or
  5237. the @option{metadata} options are set, it switches to @var{verbose}.
  5238. @end table
  5239. @subsection Examples
  5240. @itemize
  5241. @item
  5242. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  5243. @example
  5244. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  5245. @end example
  5246. @item
  5247. Run an analysis with @command{ffmpeg}:
  5248. @example
  5249. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  5250. @end example
  5251. @end itemize
  5252. @section settb, asettb
  5253. Set the timebase to use for the output frames timestamps.
  5254. It is mainly useful for testing timebase configuration.
  5255. This filter accepts the following options:
  5256. @table @option
  5257. @item expr
  5258. The expression which is evaluated into the output timebase.
  5259. @end table
  5260. The value for @option{tb} is an arithmetic expression representing a
  5261. rational. The expression can contain the constants "AVTB" (the default
  5262. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  5263. audio only). Default value is "intb".
  5264. @subsection Examples
  5265. @itemize
  5266. @item
  5267. Set the timebase to 1/25:
  5268. @example
  5269. settb=expr=1/25
  5270. @end example
  5271. @item
  5272. Set the timebase to 1/10:
  5273. @example
  5274. settb=expr=0.1
  5275. @end example
  5276. @item
  5277. Set the timebase to 1001/1000:
  5278. @example
  5279. settb=1+0.001
  5280. @end example
  5281. @item
  5282. Set the timebase to 2*intb:
  5283. @example
  5284. settb=2*intb
  5285. @end example
  5286. @item
  5287. Set the default timebase value:
  5288. @example
  5289. settb=AVTB
  5290. @end example
  5291. @end itemize
  5292. @section concat
  5293. Concatenate audio and video streams, joining them together one after the
  5294. other.
  5295. The filter works on segments of synchronized video and audio streams. All
  5296. segments must have the same number of streams of each type, and that will
  5297. also be the number of streams at output.
  5298. The filter accepts the following named parameters:
  5299. @table @option
  5300. @item n
  5301. Set the number of segments. Default is 2.
  5302. @item v
  5303. Set the number of output video streams, that is also the number of video
  5304. streams in each segment. Default is 1.
  5305. @item a
  5306. Set the number of output audio streams, that is also the number of video
  5307. streams in each segment. Default is 0.
  5308. @item unsafe
  5309. Activate unsafe mode: do not fail if segments have a different format.
  5310. @end table
  5311. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  5312. @var{a} audio outputs.
  5313. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  5314. segment, in the same order as the outputs, then the inputs for the second
  5315. segment, etc.
  5316. Related streams do not always have exactly the same duration, for various
  5317. reasons including codec frame size or sloppy authoring. For that reason,
  5318. related synchronized streams (e.g. a video and its audio track) should be
  5319. concatenated at once. The concat filter will use the duration of the longest
  5320. stream in each segment (except the last one), and if necessary pad shorter
  5321. audio streams with silence.
  5322. For this filter to work correctly, all segments must start at timestamp 0.
  5323. All corresponding streams must have the same parameters in all segments; the
  5324. filtering system will automatically select a common pixel format for video
  5325. streams, and a common sample format, sample rate and channel layout for
  5326. audio streams, but other settings, such as resolution, must be converted
  5327. explicitly by the user.
  5328. Different frame rates are acceptable but will result in variable frame rate
  5329. at output; be sure to configure the output file to handle it.
  5330. @subsection Examples
  5331. @itemize
  5332. @item
  5333. Concatenate an opening, an episode and an ending, all in bilingual version
  5334. (video in stream 0, audio in streams 1 and 2):
  5335. @example
  5336. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  5337. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  5338. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  5339. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  5340. @end example
  5341. @item
  5342. Concatenate two parts, handling audio and video separately, using the
  5343. (a)movie sources, and adjusting the resolution:
  5344. @example
  5345. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  5346. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  5347. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  5348. @end example
  5349. Note that a desync will happen at the stitch if the audio and video streams
  5350. do not have exactly the same duration in the first file.
  5351. @end itemize
  5352. @section showspectrum
  5353. Convert input audio to a video output, representing the audio frequency
  5354. spectrum.
  5355. The filter accepts the following options:
  5356. @table @option
  5357. @item size, s
  5358. Specify the video size for the output. Default value is @code{640x512}.
  5359. @item slide
  5360. Specify if the spectrum should slide along the window. Default value is
  5361. @code{0}.
  5362. @item mode
  5363. Specify display mode.
  5364. It accepts the following values:
  5365. @table @samp
  5366. @item combined
  5367. all channels are displayed in the same row
  5368. @item separate
  5369. all channels are displayed in separate rows
  5370. @end table
  5371. Default value is @samp{combined}.
  5372. @item color
  5373. Specify display color mode.
  5374. It accepts the following values:
  5375. @table @samp
  5376. @item channel
  5377. each channel is displayed in a separate color
  5378. @item intensity
  5379. each channel is is displayed using the same color scheme
  5380. @end table
  5381. Default value is @samp{channel}.
  5382. @item scale
  5383. Specify scale used for calculating intensity color values.
  5384. It accepts the following values:
  5385. @table @samp
  5386. @item lin
  5387. linear
  5388. @item sqrt
  5389. square root, default
  5390. @item cbrt
  5391. cubic root
  5392. @item log
  5393. logarithmic
  5394. @end table
  5395. Default value is @samp{sqrt}.
  5396. @item saturation
  5397. Set saturation modifier for displayed colors. Negative values provide
  5398. alternative color scheme. @code{0} is no saturation at all.
  5399. Saturation must be in [-10.0, 10.0] range.
  5400. Default value is @code{1}.
  5401. @end table
  5402. The usage is very similar to the showwaves filter; see the examples in that
  5403. section.
  5404. @subsection Examples
  5405. @itemize
  5406. @item
  5407. Large window with logarithmic color scaling:
  5408. @example
  5409. showspectrum=s=1280x480:scale=log
  5410. @end example
  5411. @item
  5412. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  5413. @example
  5414. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  5415. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  5416. @end example
  5417. @end itemize
  5418. @section showwaves
  5419. Convert input audio to a video output, representing the samples waves.
  5420. The filter accepts the following named parameters:
  5421. @table @option
  5422. @item mode
  5423. Set display mode.
  5424. Available values are:
  5425. @table @samp
  5426. @item point
  5427. Draw a point for each sample.
  5428. @item line
  5429. Draw a vertical line for each sample.
  5430. @end table
  5431. Default value is @code{point}.
  5432. @item n
  5433. Set the number of samples which are printed on the same column. A
  5434. larger value will decrease the frame rate. Must be a positive
  5435. integer. This option can be set only if the value for @var{rate}
  5436. is not explicitly specified.
  5437. @item rate, r
  5438. Set the (approximate) output frame rate. This is done by setting the
  5439. option @var{n}. Default value is "25".
  5440. @item size, s
  5441. Specify the video size for the output. Default value is "600x240".
  5442. @end table
  5443. @subsection Examples
  5444. @itemize
  5445. @item
  5446. Output the input file audio and the corresponding video representation
  5447. at the same time:
  5448. @example
  5449. amovie=a.mp3,asplit[out0],showwaves[out1]
  5450. @end example
  5451. @item
  5452. Create a synthetic signal and show it with showwaves, forcing a
  5453. frame rate of 30 frames per second:
  5454. @example
  5455. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  5456. @end example
  5457. @end itemize
  5458. @c man end MULTIMEDIA FILTERS
  5459. @chapter Multimedia Sources
  5460. @c man begin MULTIMEDIA SOURCES
  5461. Below is a description of the currently available multimedia sources.
  5462. @section amovie
  5463. This is the same as @ref{movie} source, except it selects an audio
  5464. stream by default.
  5465. @anchor{movie}
  5466. @section movie
  5467. Read audio and/or video stream(s) from a movie container.
  5468. It accepts the syntax: @var{movie_name}[:@var{options}] where
  5469. @var{movie_name} is the name of the resource to read (not necessarily
  5470. a file but also a device or a stream accessed through some protocol),
  5471. and @var{options} is an optional sequence of @var{key}=@var{value}
  5472. pairs, separated by ":".
  5473. The description of the accepted options follows.
  5474. @table @option
  5475. @item format_name, f
  5476. Specifies the format assumed for the movie to read, and can be either
  5477. the name of a container or an input device. If not specified the
  5478. format is guessed from @var{movie_name} or by probing.
  5479. @item seek_point, sp
  5480. Specifies the seek point in seconds, the frames will be output
  5481. starting from this seek point, the parameter is evaluated with
  5482. @code{av_strtod} so the numerical value may be suffixed by an IS
  5483. postfix. Default value is "0".
  5484. @item streams, s
  5485. Specifies the streams to read. Several streams can be specified,
  5486. separated by "+". The source will then have as many outputs, in the
  5487. same order. The syntax is explained in the ``Stream specifiers''
  5488. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  5489. respectively the default (best suited) video and audio stream. Default
  5490. is "dv", or "da" if the filter is called as "amovie".
  5491. @item stream_index, si
  5492. Specifies the index of the video stream to read. If the value is -1,
  5493. the best suited video stream will be automatically selected. Default
  5494. value is "-1". Deprecated. If the filter is called "amovie", it will select
  5495. audio instead of video.
  5496. @item loop
  5497. Specifies how many times to read the stream in sequence.
  5498. If the value is less than 1, the stream will be read again and again.
  5499. Default value is "1".
  5500. Note that when the movie is looped the source timestamps are not
  5501. changed, so it will generate non monotonically increasing timestamps.
  5502. @end table
  5503. This filter allows to overlay a second video on top of main input of
  5504. a filtergraph as shown in this graph:
  5505. @example
  5506. input -----------> deltapts0 --> overlay --> output
  5507. ^
  5508. |
  5509. movie --> scale--> deltapts1 -------+
  5510. @end example
  5511. @subsection Examples
  5512. @itemize
  5513. @item
  5514. Skip 3.2 seconds from the start of the avi file in.avi, and overlay it
  5515. on top of the input labelled as "in":
  5516. @example
  5517. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  5518. [in] setpts=PTS-STARTPTS [main];
  5519. [main][over] overlay=16:16 [out]
  5520. @end example
  5521. @item
  5522. Read from a video4linux2 device, and overlay it on top of the input
  5523. labelled as "in":
  5524. @example
  5525. movie=/dev/video0:f=video4linux2, 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 the first video stream and the audio stream with id 0x81 from
  5531. dvd.vob; the video is connected to the pad named "video" and the audio is
  5532. connected to the pad named "audio":
  5533. @example
  5534. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  5535. @end example
  5536. @end itemize
  5537. @c man end MULTIMEDIA SOURCES