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.

9669 lines
259KB

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