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.

8104 lines
217KB

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