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.

8345 lines
224KB

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