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.

8162 lines
219KB

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