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.

9723 lines
261KB

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