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.

9659 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 expansion
  2482. Select how the @var{text} is expanded. Can be either @code{none},
  2483. @code{strftime} (deprecated) or
  2484. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  2485. below for details.
  2486. @item fix_bounds
  2487. If true, check and fix text coords to avoid clipping.
  2488. @item fontcolor
  2489. The color to be used for drawing fonts.
  2490. Either a string (e.g. "red") or in 0xRRGGBB[AA] format
  2491. (e.g. "0xff000033"), possibly followed by an alpha specifier.
  2492. The default value of @var{fontcolor} is "black".
  2493. @item fontfile
  2494. The font file to be used for drawing text. Path must be included.
  2495. This parameter is mandatory.
  2496. @item fontsize
  2497. The font size to be used for drawing text.
  2498. The default value of @var{fontsize} is 16.
  2499. @item ft_load_flags
  2500. Flags to be used for loading the fonts.
  2501. The flags map the corresponding flags supported by libfreetype, and are
  2502. a combination of the following values:
  2503. @table @var
  2504. @item default
  2505. @item no_scale
  2506. @item no_hinting
  2507. @item render
  2508. @item no_bitmap
  2509. @item vertical_layout
  2510. @item force_autohint
  2511. @item crop_bitmap
  2512. @item pedantic
  2513. @item ignore_global_advance_width
  2514. @item no_recurse
  2515. @item ignore_transform
  2516. @item monochrome
  2517. @item linear_design
  2518. @item no_autohint
  2519. @end table
  2520. Default value is "render".
  2521. For more information consult the documentation for the FT_LOAD_*
  2522. libfreetype flags.
  2523. @item shadowcolor
  2524. The color to be used for drawing a shadow behind the drawn text. It
  2525. can be a color name (e.g. "yellow") or a string in the 0xRRGGBB[AA]
  2526. form (e.g. "0xff00ff"), possibly followed by an alpha specifier.
  2527. The default value of @var{shadowcolor} is "black".
  2528. @item shadowx
  2529. @item shadowy
  2530. The x and y offsets for the text shadow position with respect to the
  2531. position of the text. They can be either positive or negative
  2532. values. Default value for both is "0".
  2533. @item start_number
  2534. The starting frame number for the n/frame_num variable. The default value
  2535. is "0".
  2536. @item tabsize
  2537. The size in number of spaces to use for rendering the tab.
  2538. Default value is 4.
  2539. @item timecode
  2540. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  2541. format. It can be used with or without text parameter. @var{timecode_rate}
  2542. option must be specified.
  2543. @item timecode_rate, rate, r
  2544. Set the timecode frame rate (timecode only).
  2545. @item text
  2546. The text string to be drawn. The text must be a sequence of UTF-8
  2547. encoded characters.
  2548. This parameter is mandatory if no file is specified with the parameter
  2549. @var{textfile}.
  2550. @item textfile
  2551. A text file containing text to be drawn. The text must be a sequence
  2552. of UTF-8 encoded characters.
  2553. This parameter is mandatory if no text string is specified with the
  2554. parameter @var{text}.
  2555. If both @var{text} and @var{textfile} are specified, an error is thrown.
  2556. @item reload
  2557. If set to 1, the @var{textfile} will be reloaded before each frame.
  2558. Be sure to update it atomically, or it may be read partially, or even fail.
  2559. @item x
  2560. @item y
  2561. The expressions which specify the offsets where text will be drawn
  2562. within the video frame. They are relative to the top/left border of the
  2563. output image.
  2564. The default value of @var{x} and @var{y} is "0".
  2565. See below for the list of accepted constants and functions.
  2566. @end table
  2567. The parameters for @var{x} and @var{y} are expressions containing the
  2568. following constants and functions:
  2569. @table @option
  2570. @item dar
  2571. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  2572. @item hsub
  2573. @item vsub
  2574. horizontal and vertical chroma subsample values. For example for the
  2575. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2576. @item line_h, lh
  2577. the height of each text line
  2578. @item main_h, h, H
  2579. the input height
  2580. @item main_w, w, W
  2581. the input width
  2582. @item max_glyph_a, ascent
  2583. the maximum distance from the baseline to the highest/upper grid
  2584. coordinate used to place a glyph outline point, for all the rendered
  2585. glyphs.
  2586. It is a positive value, due to the grid's orientation with the Y axis
  2587. upwards.
  2588. @item max_glyph_d, descent
  2589. the maximum distance from the baseline to the lowest grid coordinate
  2590. used to place a glyph outline point, for all the rendered glyphs.
  2591. This is a negative value, due to the grid's orientation, with the Y axis
  2592. upwards.
  2593. @item max_glyph_h
  2594. maximum glyph height, that is the maximum height for all the glyphs
  2595. contained in the rendered text, it is equivalent to @var{ascent} -
  2596. @var{descent}.
  2597. @item max_glyph_w
  2598. maximum glyph width, that is the maximum width for all the glyphs
  2599. contained in the rendered text
  2600. @item n
  2601. the number of input frame, starting from 0
  2602. @item rand(min, max)
  2603. return a random number included between @var{min} and @var{max}
  2604. @item sar
  2605. input sample aspect ratio
  2606. @item t
  2607. timestamp expressed in seconds, NAN if the input timestamp is unknown
  2608. @item text_h, th
  2609. the height of the rendered text
  2610. @item text_w, tw
  2611. the width of the rendered text
  2612. @item x
  2613. @item y
  2614. the x and y offset coordinates where the text is drawn.
  2615. These parameters allow the @var{x} and @var{y} expressions to refer
  2616. each other, so you can for example specify @code{y=x/dar}.
  2617. @end table
  2618. If libavfilter was built with @code{--enable-fontconfig}, then
  2619. @option{fontfile} can be a fontconfig pattern or omitted.
  2620. @anchor{drawtext_expansion}
  2621. @subsection Text expansion
  2622. If @option{expansion} is set to @code{strftime},
  2623. the filter recognizes strftime() sequences in the provided text and
  2624. expands them accordingly. Check the documentation of strftime(). This
  2625. feature is deprecated.
  2626. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  2627. If @option{expansion} is set to @code{normal} (which is the default),
  2628. the following expansion mechanism is used.
  2629. The backslash character '\', followed by any character, always expands to
  2630. the second character.
  2631. Sequence of the form @code{%@{...@}} are expanded. The text between the
  2632. braces is a function name, possibly followed by arguments separated by ':'.
  2633. If the arguments contain special characters or delimiters (':' or '@}'),
  2634. they should be escaped.
  2635. Note that they probably must also be escaped as the value for the
  2636. @option{text} option in the filter argument string and as the filter
  2637. argument in the filtergraph description, and possibly also for the shell,
  2638. that makes up to four levels of escaping; using a text file avoids these
  2639. problems.
  2640. The following functions are available:
  2641. @table @command
  2642. @item expr, e
  2643. The expression evaluation result.
  2644. It must take one argument specifying the expression to be evaluated,
  2645. which accepts the same constants and functions as the @var{x} and
  2646. @var{y} values. Note that not all constants should be used, for
  2647. example the text size is not known when evaluating the expression, so
  2648. the constants @var{text_w} and @var{text_h} will have an undefined
  2649. value.
  2650. @item gmtime
  2651. The time at which the filter is running, expressed in UTC.
  2652. It can accept an argument: a strftime() format string.
  2653. @item localtime
  2654. The time at which the filter is running, expressed in the local time zone.
  2655. It can accept an argument: a strftime() format string.
  2656. @item metadata
  2657. Frame metadata. It must take one argument specifying metadata key.
  2658. @item n, frame_num
  2659. The frame number, starting from 0.
  2660. @item pict_type
  2661. A 1 character description of the current picture type.
  2662. @item pts
  2663. The timestamp of the current frame, in seconds, with microsecond accuracy.
  2664. @end table
  2665. @subsection Examples
  2666. @itemize
  2667. @item
  2668. Draw "Test Text" with font FreeSerif, using the default values for the
  2669. optional parameters.
  2670. @example
  2671. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  2672. @end example
  2673. @item
  2674. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  2675. and y=50 (counting from the top-left corner of the screen), text is
  2676. yellow with a red box around it. Both the text and the box have an
  2677. opacity of 20%.
  2678. @example
  2679. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  2680. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  2681. @end example
  2682. Note that the double quotes are not necessary if spaces are not used
  2683. within the parameter list.
  2684. @item
  2685. Show the text at the center of the video frame:
  2686. @example
  2687. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  2688. @end example
  2689. @item
  2690. Show a text line sliding from right to left in the last row of the video
  2691. frame. The file @file{LONG_LINE} is assumed to contain a single line
  2692. with no newlines.
  2693. @example
  2694. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  2695. @end example
  2696. @item
  2697. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  2698. @example
  2699. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  2700. @end example
  2701. @item
  2702. Draw a single green letter "g", at the center of the input video.
  2703. The glyph baseline is placed at half screen height.
  2704. @example
  2705. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  2706. @end example
  2707. @item
  2708. Show text for 1 second every 3 seconds:
  2709. @example
  2710. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  2711. @end example
  2712. @item
  2713. Use fontconfig to set the font. Note that the colons need to be escaped.
  2714. @example
  2715. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  2716. @end example
  2717. @item
  2718. Print the date of a real-time encoding (see strftime(3)):
  2719. @example
  2720. drawtext='fontfile=FreeSans.ttf:text=%@{localtime:%a %b %d %Y@}'
  2721. @end example
  2722. @end itemize
  2723. For more information about libfreetype, check:
  2724. @url{http://www.freetype.org/}.
  2725. For more information about fontconfig, check:
  2726. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  2727. @section edgedetect
  2728. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  2729. The filter accepts the following options:
  2730. @table @option
  2731. @item low
  2732. @item high
  2733. Set low and high threshold values used by the Canny thresholding
  2734. algorithm.
  2735. The high threshold selects the "strong" edge pixels, which are then
  2736. connected through 8-connectivity with the "weak" edge pixels selected
  2737. by the low threshold.
  2738. @var{low} and @var{high} threshold values must be choosen in the range
  2739. [0,1], and @var{low} should be lesser or equal to @var{high}.
  2740. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  2741. is @code{50/255}.
  2742. @end table
  2743. Example:
  2744. @example
  2745. edgedetect=low=0.1:high=0.4
  2746. @end example
  2747. @section extractplanes
  2748. Extract color channel components from input video stream into
  2749. separate grayscale video streams.
  2750. The filter accepts the following option:
  2751. @table @option
  2752. @item planes
  2753. Set plane(s) to extract.
  2754. Available values for planes are:
  2755. @table @samp
  2756. @item y
  2757. @item u
  2758. @item v
  2759. @item a
  2760. @item r
  2761. @item g
  2762. @item b
  2763. @end table
  2764. Choosing planes not available in the input will result in an error.
  2765. That means you cannot select @code{r}, @code{g}, @code{b} planes
  2766. with @code{y}, @code{u}, @code{v} planes at same time.
  2767. @end table
  2768. @subsection Examples
  2769. @itemize
  2770. @item
  2771. Extract luma, u and v color channel component from input video frame
  2772. into 3 grayscale outputs:
  2773. @example
  2774. 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
  2775. @end example
  2776. @end itemize
  2777. @section fade
  2778. Apply fade-in/out effect to input video.
  2779. This filter accepts the following options:
  2780. @table @option
  2781. @item type, t
  2782. The effect type -- can be either "in" for fade-in, or "out" for a fade-out
  2783. effect.
  2784. Default is @code{in}.
  2785. @item start_frame, s
  2786. Specify the number of the start frame for starting to apply the fade
  2787. effect. Default is 0.
  2788. @item nb_frames, n
  2789. The number of frames for which the fade effect has to last. At the end of the
  2790. fade-in effect the output video will have the same intensity as the input video,
  2791. at the end of the fade-out transition the output video will be completely black.
  2792. Default is 25.
  2793. @item alpha
  2794. If set to 1, fade only alpha channel, if one exists on the input.
  2795. Default value is 0.
  2796. @item start_time, st
  2797. Specify the timestamp (in seconds) of the frame to start to apply the fade
  2798. effect. If both start_frame and start_time are specified, the fade will start at
  2799. whichever comes last. Default is 0.
  2800. @item duration, d
  2801. The number of seconds for which the fade effect has to last. At the end of the
  2802. fade-in effect the output video will have the same intensity as the input video,
  2803. at the end of the fade-out transition the output video will be completely black.
  2804. If both duration and nb_frames are specified, duration is used. Default is 0.
  2805. @end table
  2806. @subsection Examples
  2807. @itemize
  2808. @item
  2809. Fade in first 30 frames of video:
  2810. @example
  2811. fade=in:0:30
  2812. @end example
  2813. The command above is equivalent to:
  2814. @example
  2815. fade=t=in:s=0:n=30
  2816. @end example
  2817. @item
  2818. Fade out last 45 frames of a 200-frame video:
  2819. @example
  2820. fade=out:155:45
  2821. fade=type=out:start_frame=155:nb_frames=45
  2822. @end example
  2823. @item
  2824. Fade in first 25 frames and fade out last 25 frames of a 1000-frame video:
  2825. @example
  2826. fade=in:0:25, fade=out:975:25
  2827. @end example
  2828. @item
  2829. Make first 5 frames black, then fade in from frame 5-24:
  2830. @example
  2831. fade=in:5:20
  2832. @end example
  2833. @item
  2834. Fade in alpha over first 25 frames of video:
  2835. @example
  2836. fade=in:0:25:alpha=1
  2837. @end example
  2838. @item
  2839. Make first 5.5 seconds black, then fade in for 0.5 seconds:
  2840. @example
  2841. fade=t=in:st=5.5:d=0.5
  2842. @end example
  2843. @end itemize
  2844. @section field
  2845. Extract a single field from an interlaced image using stride
  2846. arithmetic to avoid wasting CPU time. The output frames are marked as
  2847. non-interlaced.
  2848. The filter accepts the following options:
  2849. @table @option
  2850. @item type
  2851. Specify whether to extract the top (if the value is @code{0} or
  2852. @code{top}) or the bottom field (if the value is @code{1} or
  2853. @code{bottom}).
  2854. @end table
  2855. @section fieldmatch
  2856. Field matching filter for inverse telecine. It is meant to reconstruct the
  2857. progressive frames from a telecined stream. The filter does not drop duplicated
  2858. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  2859. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  2860. The separation of the field matching and the decimation is notably motivated by
  2861. the possibility of inserting a de-interlacing filter fallback between the two.
  2862. If the source has mixed telecined and real interlaced content,
  2863. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  2864. But these remaining combed frames will be marked as interlaced, and thus can be
  2865. de-interlaced by a later filter such as @ref{yadif} before decimation.
  2866. In addition to the various configuration options, @code{fieldmatch} can take an
  2867. optional second stream, activated through the @option{ppsrc} option. If
  2868. enabled, the frames reconstruction will be based on the fields and frames from
  2869. this second stream. This allows the first input to be pre-processed in order to
  2870. help the various algorithms of the filter, while keeping the output lossless
  2871. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  2872. or brightness/contrast adjustments can help.
  2873. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  2874. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  2875. which @code{fieldmatch} is based on. While the semantic and usage are very
  2876. close, some behaviour and options names can differ.
  2877. The filter accepts the following options:
  2878. @table @option
  2879. @item order
  2880. Specify the assumed field order of the input stream. Available values are:
  2881. @table @samp
  2882. @item auto
  2883. Auto detect parity (use FFmpeg's internal parity value).
  2884. @item bff
  2885. Assume bottom field first.
  2886. @item tff
  2887. Assume top field first.
  2888. @end table
  2889. Note that it is sometimes recommended not to trust the parity announced by the
  2890. stream.
  2891. Default value is @var{auto}.
  2892. @item mode
  2893. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  2894. sense that it won't risk creating jerkiness due to duplicate frames when
  2895. possible, but if there are bad edits or blended fields it will end up
  2896. outputting combed frames when a good match might actually exist. On the other
  2897. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  2898. but will almost always find a good frame if there is one. The other values are
  2899. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  2900. jerkiness and creating duplicate frames versus finding good matches in sections
  2901. with bad edits, orphaned fields, blended fields, etc.
  2902. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  2903. Available values are:
  2904. @table @samp
  2905. @item pc
  2906. 2-way matching (p/c)
  2907. @item pc_n
  2908. 2-way matching, and trying 3rd match if still combed (p/c + n)
  2909. @item pc_u
  2910. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  2911. @item pc_n_ub
  2912. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  2913. still combed (p/c + n + u/b)
  2914. @item pcn
  2915. 3-way matching (p/c/n)
  2916. @item pcn_ub
  2917. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  2918. detected as combed (p/c/n + u/b)
  2919. @end table
  2920. The parenthesis at the end indicate the matches that would be used for that
  2921. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  2922. @var{top}).
  2923. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  2924. the slowest.
  2925. Default value is @var{pc_n}.
  2926. @item ppsrc
  2927. Mark the main input stream as a pre-processed input, and enable the secondary
  2928. input stream as the clean source to pick the fields from. See the filter
  2929. introduction for more details. It is similar to the @option{clip2} feature from
  2930. VFM/TFM.
  2931. Default value is @code{0} (disabled).
  2932. @item field
  2933. Set the field to match from. It is recommended to set this to the same value as
  2934. @option{order} unless you experience matching failures with that setting. In
  2935. certain circumstances changing the field that is used to match from can have a
  2936. large impact on matching performance. Available values are:
  2937. @table @samp
  2938. @item auto
  2939. Automatic (same value as @option{order}).
  2940. @item bottom
  2941. Match from the bottom field.
  2942. @item top
  2943. Match from the top field.
  2944. @end table
  2945. Default value is @var{auto}.
  2946. @item mchroma
  2947. Set whether or not chroma is included during the match comparisons. In most
  2948. cases it is recommended to leave this enabled. You should set this to @code{0}
  2949. only if your clip has bad chroma problems such as heavy rainbowing or other
  2950. artifacts. Setting this to @code{0} could also be used to speed things up at
  2951. the cost of some accuracy.
  2952. Default value is @code{1}.
  2953. @item y0
  2954. @item y1
  2955. These define an exclusion band which excludes the lines between @option{y0} and
  2956. @option{y1} from being included in the field matching decision. An exclusion
  2957. band can be used to ignore subtitles, a logo, or other things that may
  2958. interfere with the matching. @option{y0} sets the starting scan line and
  2959. @option{y1} sets the ending line; all lines in between @option{y0} and
  2960. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  2961. @option{y0} and @option{y1} to the same value will disable the feature.
  2962. @option{y0} and @option{y1} defaults to @code{0}.
  2963. @item scthresh
  2964. Set the scene change detection threshold as a percentage of maximum change on
  2965. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  2966. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  2967. @option{scthresh} is @code{[0.0, 100.0]}.
  2968. Default value is @code{12.0}.
  2969. @item combmatch
  2970. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  2971. account the combed scores of matches when deciding what match to use as the
  2972. final match. Available values are:
  2973. @table @samp
  2974. @item none
  2975. No final matching based on combed scores.
  2976. @item sc
  2977. Combed scores are only used when a scene change is detected.
  2978. @item full
  2979. Use combed scores all the time.
  2980. @end table
  2981. Default is @var{sc}.
  2982. @item combdbg
  2983. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  2984. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  2985. Available values are:
  2986. @table @samp
  2987. @item none
  2988. No forced calculation.
  2989. @item pcn
  2990. Force p/c/n calculations.
  2991. @item pcnub
  2992. Force p/c/n/u/b calculations.
  2993. @end table
  2994. Default value is @var{none}.
  2995. @item cthresh
  2996. This is the area combing threshold used for combed frame detection. This
  2997. essentially controls how "strong" or "visible" combing must be to be detected.
  2998. Larger values mean combing must be more visible and smaller values mean combing
  2999. can be less visible or strong and still be detected. Valid settings are from
  3000. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  3001. be detected as combed). This is basically a pixel difference value. A good
  3002. range is @code{[8, 12]}.
  3003. Default value is @code{9}.
  3004. @item chroma
  3005. Sets whether or not chroma is considered in the combed frame decision. Only
  3006. disable this if your source has chroma problems (rainbowing, etc.) that are
  3007. causing problems for the combed frame detection with chroma enabled. Actually,
  3008. using @option{chroma}=@var{0} is usually more reliable, except for the case
  3009. where there is chroma only combing in the source.
  3010. Default value is @code{0}.
  3011. @item blockx
  3012. @item blocky
  3013. Respectively set the x-axis and y-axis size of the window used during combed
  3014. frame detection. This has to do with the size of the area in which
  3015. @option{combpel} pixels are required to be detected as combed for a frame to be
  3016. declared combed. See the @option{combpel} parameter description for more info.
  3017. Possible values are any number that is a power of 2 starting at 4 and going up
  3018. to 512.
  3019. Default value is @code{16}.
  3020. @item combpel
  3021. The number of combed pixels inside any of the @option{blocky} by
  3022. @option{blockx} size blocks on the frame for the frame to be detected as
  3023. combed. While @option{cthresh} controls how "visible" the combing must be, this
  3024. setting controls "how much" combing there must be in any localized area (a
  3025. window defined by the @option{blockx} and @option{blocky} settings) on the
  3026. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  3027. which point no frames will ever be detected as combed). This setting is known
  3028. as @option{MI} in TFM/VFM vocabulary.
  3029. Default value is @code{80}.
  3030. @end table
  3031. @anchor{p/c/n/u/b meaning}
  3032. @subsection p/c/n/u/b meaning
  3033. @subsubsection p/c/n
  3034. We assume the following telecined stream:
  3035. @example
  3036. Top fields: 1 2 2 3 4
  3037. Bottom fields: 1 2 3 4 4
  3038. @end example
  3039. The numbers correspond to the progressive frame the fields relate to. Here, the
  3040. first two frames are progressive, the 3rd and 4th are combed, and so on.
  3041. When @code{fieldmatch} is configured to run a matching from bottom
  3042. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  3043. @example
  3044. Input stream:
  3045. T 1 2 2 3 4
  3046. B 1 2 3 4 4 <-- matching reference
  3047. Matches: c c n n c
  3048. Output stream:
  3049. T 1 2 3 4 4
  3050. B 1 2 3 4 4
  3051. @end example
  3052. As a result of the field matching, we can see that some frames get duplicated.
  3053. To perform a complete inverse telecine, you need to rely on a decimation filter
  3054. after this operation. See for instance the @ref{decimate} filter.
  3055. The same operation now matching from top fields (@option{field}=@var{top})
  3056. looks like this:
  3057. @example
  3058. Input stream:
  3059. T 1 2 2 3 4 <-- matching reference
  3060. B 1 2 3 4 4
  3061. Matches: c c p p c
  3062. Output stream:
  3063. T 1 2 2 3 4
  3064. B 1 2 2 3 4
  3065. @end example
  3066. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  3067. basically, they refer to the frame and field of the opposite parity:
  3068. @itemize
  3069. @item @var{p} matches the field of the opposite parity in the previous frame
  3070. @item @var{c} matches the field of the opposite parity in the current frame
  3071. @item @var{n} matches the field of the opposite parity in the next frame
  3072. @end itemize
  3073. @subsubsection u/b
  3074. The @var{u} and @var{b} matching are a bit special in the sense that they match
  3075. from the opposite parity flag. In the following examples, we assume that we are
  3076. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  3077. 'x' is placed above and below each matched fields.
  3078. With bottom matching (@option{field}=@var{bottom}):
  3079. @example
  3080. Match: c p n b u
  3081. x x x x x
  3082. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  3083. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  3084. x x x x x
  3085. Output frames:
  3086. 2 1 2 2 2
  3087. 2 2 2 1 3
  3088. @end example
  3089. With top matching (@option{field}=@var{top}):
  3090. @example
  3091. Match: c p n b u
  3092. x x x x x
  3093. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  3094. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  3095. x x x x x
  3096. Output frames:
  3097. 2 2 2 1 2
  3098. 2 1 3 2 2
  3099. @end example
  3100. @subsection Examples
  3101. Simple IVTC of a top field first telecined stream:
  3102. @example
  3103. fieldmatch=order=tff:combmatch=none, decimate
  3104. @end example
  3105. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  3106. @example
  3107. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  3108. @end example
  3109. @section fieldorder
  3110. Transform the field order of the input video.
  3111. This filter accepts the following options:
  3112. @table @option
  3113. @item order
  3114. Output field order. Valid values are @var{tff} for top field first or @var{bff}
  3115. for bottom field first.
  3116. @end table
  3117. Default value is @samp{tff}.
  3118. Transformation is achieved by shifting the picture content up or down
  3119. by one line, and filling the remaining line with appropriate picture content.
  3120. This method is consistent with most broadcast field order converters.
  3121. If the input video is not flagged as being interlaced, or it is already
  3122. flagged as being of the required output field order then this filter does
  3123. not alter the incoming video.
  3124. This filter is very useful when converting to or from PAL DV material,
  3125. which is bottom field first.
  3126. For example:
  3127. @example
  3128. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  3129. @end example
  3130. @section fifo
  3131. Buffer input images and send them when they are requested.
  3132. This filter is mainly useful when auto-inserted by the libavfilter
  3133. framework.
  3134. The filter does not take parameters.
  3135. @anchor{format}
  3136. @section format
  3137. Convert the input video to one of the specified pixel formats.
  3138. Libavfilter will try to pick one that is supported for the input to
  3139. the next filter.
  3140. This filter accepts the following parameters:
  3141. @table @option
  3142. @item pix_fmts
  3143. A '|'-separated list of pixel format names, for example
  3144. "pix_fmts=yuv420p|monow|rgb24".
  3145. @end table
  3146. @subsection Examples
  3147. @itemize
  3148. @item
  3149. Convert the input video to the format @var{yuv420p}
  3150. @example
  3151. format=pix_fmts=yuv420p
  3152. @end example
  3153. Convert the input video to any of the formats in the list
  3154. @example
  3155. format=pix_fmts=yuv420p|yuv444p|yuv410p
  3156. @end example
  3157. @end itemize
  3158. @section fps
  3159. Convert the video to specified constant frame rate by duplicating or dropping
  3160. frames as necessary.
  3161. This filter accepts the following named parameters:
  3162. @table @option
  3163. @item fps
  3164. Desired output frame rate. The default is @code{25}.
  3165. @item round
  3166. Rounding method.
  3167. Possible values are:
  3168. @table @option
  3169. @item zero
  3170. zero round towards 0
  3171. @item inf
  3172. round away from 0
  3173. @item down
  3174. round towards -infinity
  3175. @item up
  3176. round towards +infinity
  3177. @item near
  3178. round to nearest
  3179. @end table
  3180. The default is @code{near}.
  3181. @item start_time
  3182. Assume the first PTS should be the given value, in seconds. This allows for
  3183. padding/trimming at the start of stream. By default, no assumption is made
  3184. about the first frame's expected PTS, so no padding or trimming is done.
  3185. For example, this could be set to 0 to pad the beginning with duplicates of
  3186. the first frame if a video stream starts after the audio stream or to trim any
  3187. frames with a negative PTS.
  3188. @end table
  3189. Alternatively, the options can be specified as a flat string:
  3190. @var{fps}[:@var{round}].
  3191. See also the @ref{setpts} filter.
  3192. @subsection Examples
  3193. @itemize
  3194. @item
  3195. A typical usage in order to set the fps to 25:
  3196. @example
  3197. fps=fps=25
  3198. @end example
  3199. @item
  3200. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  3201. @example
  3202. fps=fps=film:round=near
  3203. @end example
  3204. @end itemize
  3205. @section framestep
  3206. Select one frame every N-th frame.
  3207. This filter accepts the following option:
  3208. @table @option
  3209. @item step
  3210. Select frame after every @code{step} frames.
  3211. Allowed values are positive integers higher than 0. Default value is @code{1}.
  3212. @end table
  3213. @anchor{frei0r}
  3214. @section frei0r
  3215. Apply a frei0r effect to the input video.
  3216. To enable compilation of this filter you need to install the frei0r
  3217. header and configure FFmpeg with @code{--enable-frei0r}.
  3218. This filter accepts the following options:
  3219. @table @option
  3220. @item filter_name
  3221. The name to the frei0r effect to load. If the environment variable
  3222. @env{FREI0R_PATH} is defined, the frei0r effect is searched in each one of the
  3223. directories specified by the colon separated list in @env{FREIOR_PATH},
  3224. otherwise in the standard frei0r paths, which are in this order:
  3225. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  3226. @file{/usr/lib/frei0r-1/}.
  3227. @item filter_params
  3228. A '|'-separated list of parameters to pass to the frei0r effect.
  3229. @end table
  3230. A frei0r effect parameter can be a boolean (whose values are specified
  3231. with "y" and "n"), a double, a color (specified by the syntax
  3232. @var{R}/@var{G}/@var{B}, @var{R}, @var{G}, and @var{B} being float
  3233. numbers from 0.0 to 1.0) or by an @code{av_parse_color()} color
  3234. description), a position (specified by the syntax @var{X}/@var{Y},
  3235. @var{X} and @var{Y} being float numbers) and a string.
  3236. The number and kind of parameters depend on the loaded effect. If an
  3237. effect parameter is not specified the default value is set.
  3238. @subsection Examples
  3239. @itemize
  3240. @item
  3241. Apply the distort0r effect, set the first two double parameters:
  3242. @example
  3243. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  3244. @end example
  3245. @item
  3246. Apply the colordistance effect, take a color as first parameter:
  3247. @example
  3248. frei0r=colordistance:0.2/0.3/0.4
  3249. frei0r=colordistance:violet
  3250. frei0r=colordistance:0x112233
  3251. @end example
  3252. @item
  3253. Apply the perspective effect, specify the top left and top right image
  3254. positions:
  3255. @example
  3256. frei0r=perspective:0.2/0.2|0.8/0.2
  3257. @end example
  3258. @end itemize
  3259. For more information see:
  3260. @url{http://frei0r.dyne.org}
  3261. @section geq
  3262. The filter accepts the following options:
  3263. @table @option
  3264. @item lum_expr, lum
  3265. Set the luminance expression.
  3266. @item cb_expr, cb
  3267. Set the chrominance blue expression.
  3268. @item cr_expr, cr
  3269. Set the chrominance red expression.
  3270. @item alpha_expr, a
  3271. Set the alpha expression.
  3272. @item red_expr, r
  3273. Set the red expression.
  3274. @item green_expr, g
  3275. Set the green expression.
  3276. @item blue_expr, b
  3277. Set the blue expression.
  3278. @end table
  3279. The colorspace is selected according to the specified options. If one
  3280. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  3281. options is specified, the filter will automatically select a YCbCr
  3282. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  3283. @option{blue_expr} options is specified, it will select an RGB
  3284. colorspace.
  3285. If one of the chrominance expression is not defined, it falls back on the other
  3286. one. If no alpha expression is specified it will evaluate to opaque value.
  3287. If none of chrominance expressions are specified, they will evaluate
  3288. to the luminance expression.
  3289. The expressions can use the following variables and functions:
  3290. @table @option
  3291. @item N
  3292. The sequential number of the filtered frame, starting from @code{0}.
  3293. @item X
  3294. @item Y
  3295. The coordinates of the current sample.
  3296. @item W
  3297. @item H
  3298. The width and height of the image.
  3299. @item SW
  3300. @item SH
  3301. Width and height scale depending on the currently filtered plane. It is the
  3302. ratio between the corresponding luma plane number of pixels and the current
  3303. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  3304. @code{0.5,0.5} for chroma planes.
  3305. @item T
  3306. Time of the current frame, expressed in seconds.
  3307. @item p(x, y)
  3308. Return the value of the pixel at location (@var{x},@var{y}) of the current
  3309. plane.
  3310. @item lum(x, y)
  3311. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  3312. plane.
  3313. @item cb(x, y)
  3314. Return the value of the pixel at location (@var{x},@var{y}) of the
  3315. blue-difference chroma plane. Return 0 if there is no such plane.
  3316. @item cr(x, y)
  3317. Return the value of the pixel at location (@var{x},@var{y}) of the
  3318. red-difference chroma plane. Return 0 if there is no such plane.
  3319. @item r(x, y)
  3320. @item g(x, y)
  3321. @item b(x, y)
  3322. Return the value of the pixel at location (@var{x},@var{y}) of the
  3323. red/green/blue component. Return 0 if there is no such component.
  3324. @item alpha(x, y)
  3325. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  3326. plane. Return 0 if there is no such plane.
  3327. @end table
  3328. For functions, if @var{x} and @var{y} are outside the area, the value will be
  3329. automatically clipped to the closer edge.
  3330. @subsection Examples
  3331. @itemize
  3332. @item
  3333. Flip the image horizontally:
  3334. @example
  3335. geq=p(W-X\,Y)
  3336. @end example
  3337. @item
  3338. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  3339. wavelength of 100 pixels:
  3340. @example
  3341. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  3342. @end example
  3343. @item
  3344. Generate a fancy enigmatic moving light:
  3345. @example
  3346. 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
  3347. @end example
  3348. @item
  3349. Generate a quick emboss effect:
  3350. @example
  3351. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  3352. @end example
  3353. @item
  3354. Modify RGB components depending on pixel position:
  3355. @example
  3356. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  3357. @end example
  3358. @end itemize
  3359. @section gradfun
  3360. Fix the banding artifacts that are sometimes introduced into nearly flat
  3361. regions by truncation to 8bit color depth.
  3362. Interpolate the gradients that should go where the bands are, and
  3363. dither them.
  3364. This filter is designed for playback only. Do not use it prior to
  3365. lossy compression, because compression tends to lose the dither and
  3366. bring back the bands.
  3367. This filter accepts the following options:
  3368. @table @option
  3369. @item strength
  3370. The maximum amount by which the filter will change any one pixel. Also the
  3371. threshold for detecting nearly flat regions. Acceptable values range from .51 to
  3372. 64, default value is 1.2, out-of-range values will be clipped to the valid
  3373. range.
  3374. @item radius
  3375. The neighborhood to fit the gradient to. A larger radius makes for smoother
  3376. gradients, but also prevents the filter from modifying the pixels near detailed
  3377. regions. Acceptable values are 8-32, default value is 16, out-of-range values
  3378. will be clipped to the valid range.
  3379. @end table
  3380. Alternatively, the options can be specified as a flat string:
  3381. @var{strength}[:@var{radius}]
  3382. @subsection Examples
  3383. @itemize
  3384. @item
  3385. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  3386. @example
  3387. gradfun=3.5:8
  3388. @end example
  3389. @item
  3390. Specify radius, omitting the strength (which will fall-back to the default
  3391. value):
  3392. @example
  3393. gradfun=radius=8
  3394. @end example
  3395. @end itemize
  3396. @anchor{haldclut}
  3397. @section haldclut
  3398. Apply a Hald CLUT to a video stream.
  3399. First input is the video stream to process, and second one is the Hald CLUT.
  3400. The Hald CLUT input can be a simple picture or a complete video stream.
  3401. The filter accepts the following options:
  3402. @table @option
  3403. @item shortest
  3404. Force termination when the shortest input terminates. Default is @code{0}.
  3405. @item repeatlast
  3406. Continue applying the last CLUT after the end of the stream. A value of
  3407. @code{0} disable the filter after the last frame of the CLUT is reached.
  3408. Default is @code{1}.
  3409. @end table
  3410. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  3411. filters share the same internals).
  3412. More information about the Hald CLUT can be found on Eskil Steenberg's website
  3413. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  3414. @subsection Workflow examples
  3415. @subsubsection Hald CLUT video stream
  3416. Generate an identity Hald CLUT stream altered with various effects:
  3417. @example
  3418. 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
  3419. @end example
  3420. Note: make sure you use a lossless codec.
  3421. Then use it with @code{haldclut} to apply it on some random stream:
  3422. @example
  3423. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  3424. @end example
  3425. The Hald CLUT will be applied to the 10 first seconds (duration of
  3426. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  3427. to the remaining frames of the @code{mandelbrot} stream.
  3428. @subsubsection Hald CLUT with preview
  3429. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  3430. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  3431. biggest possible square starting at the top left of the picture. The remaining
  3432. padding pixels (bottom or right) will be ignored. This area can be used to add
  3433. a preview of the Hald CLUT.
  3434. Typically, the following generated Hald CLUT will be supported by the
  3435. @code{haldclut} filter:
  3436. @example
  3437. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  3438. pad=iw+320 [padded_clut];
  3439. smptebars=s=320x256, split [a][b];
  3440. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  3441. [main][b] overlay=W-320" -frames:v 1 clut.png
  3442. @end example
  3443. It contains the original and a preview of the effect of the CLUT: SMPTE color
  3444. bars are displayed on the right-top, and below the same color bars processed by
  3445. the color changes.
  3446. Then, the effect of this Hald CLUT can be visualized with:
  3447. @example
  3448. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  3449. @end example
  3450. @section hflip
  3451. Flip the input video horizontally.
  3452. For example to horizontally flip the input video with @command{ffmpeg}:
  3453. @example
  3454. ffmpeg -i in.avi -vf "hflip" out.avi
  3455. @end example
  3456. @section histeq
  3457. This filter applies a global color histogram equalization on a
  3458. per-frame basis.
  3459. It can be used to correct video that has a compressed range of pixel
  3460. intensities. The filter redistributes the pixel intensities to
  3461. equalize their distribution across the intensity range. It may be
  3462. viewed as an "automatically adjusting contrast filter". This filter is
  3463. useful only for correcting degraded or poorly captured source
  3464. video.
  3465. The filter accepts the following options:
  3466. @table @option
  3467. @item strength
  3468. Determine the amount of equalization to be applied. As the strength
  3469. is reduced, the distribution of pixel intensities more-and-more
  3470. approaches that of the input frame. The value must be a float number
  3471. in the range [0,1] and defaults to 0.200.
  3472. @item intensity
  3473. Set the maximum intensity that can generated and scale the output
  3474. values appropriately. The strength should be set as desired and then
  3475. the intensity can be limited if needed to avoid washing-out. The value
  3476. must be a float number in the range [0,1] and defaults to 0.210.
  3477. @item antibanding
  3478. Set the antibanding level. If enabled the filter will randomly vary
  3479. the luminance of output pixels by a small amount to avoid banding of
  3480. the histogram. Possible values are @code{none}, @code{weak} or
  3481. @code{strong}. It defaults to @code{none}.
  3482. @end table
  3483. @section histogram
  3484. Compute and draw a color distribution histogram for the input video.
  3485. The computed histogram is a representation of distribution of color components
  3486. in an image.
  3487. The filter accepts the following options:
  3488. @table @option
  3489. @item mode
  3490. Set histogram mode.
  3491. It accepts the following values:
  3492. @table @samp
  3493. @item levels
  3494. standard histogram that display color components distribution in an image.
  3495. Displays color graph for each color component. Shows distribution
  3496. of the Y, U, V, A or G, B, R components, depending on input format,
  3497. in current frame. Bellow each graph is color component scale meter.
  3498. @item color
  3499. chroma values in vectorscope, if brighter more such chroma values are
  3500. distributed in an image.
  3501. Displays chroma values (U/V color placement) in two dimensional graph
  3502. (which is called a vectorscope). It can be used to read of the hue and
  3503. saturation of the current frame. At a same time it is a histogram.
  3504. The whiter a pixel in the vectorscope, the more pixels of the input frame
  3505. correspond to that pixel (that is the more pixels have this chroma value).
  3506. The V component is displayed on the horizontal (X) axis, with the leftmost
  3507. side being V = 0 and the rightmost side being V = 255.
  3508. The U component is displayed on the vertical (Y) axis, with the top
  3509. representing U = 0 and the bottom representing U = 255.
  3510. The position of a white pixel in the graph corresponds to the chroma value
  3511. of a pixel of the input clip. So the graph can be used to read of the
  3512. hue (color flavor) and the saturation (the dominance of the hue in the color).
  3513. As the hue of a color changes, it moves around the square. At the center of
  3514. the square, the saturation is zero, which means that the corresponding pixel
  3515. has no color. If you increase the amount of a specific color, while leaving
  3516. the other colors unchanged, the saturation increases, and you move towards
  3517. the edge of the square.
  3518. @item color2
  3519. chroma values in vectorscope, similar as @code{color} but actual chroma values
  3520. are displayed.
  3521. @item waveform
  3522. per row/column color component graph. In row mode graph in the left side represents
  3523. color component value 0 and right side represents value = 255. In column mode top
  3524. side represents color component value = 0 and bottom side represents value = 255.
  3525. @end table
  3526. Default value is @code{levels}.
  3527. @item level_height
  3528. Set height of level in @code{levels}. Default value is @code{200}.
  3529. Allowed range is [50, 2048].
  3530. @item scale_height
  3531. Set height of color scale in @code{levels}. Default value is @code{12}.
  3532. Allowed range is [0, 40].
  3533. @item step
  3534. Set step for @code{waveform} mode. Smaller values are useful to find out how much
  3535. of same luminance values across input rows/columns are distributed.
  3536. Default value is @code{10}. Allowed range is [1, 255].
  3537. @item waveform_mode
  3538. Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
  3539. Default is @code{row}.
  3540. @item display_mode
  3541. Set display mode for @code{waveform} and @code{levels}.
  3542. It accepts the following values:
  3543. @table @samp
  3544. @item parade
  3545. Display separate graph for the color components side by side in
  3546. @code{row} waveform mode or one below other in @code{column} waveform mode
  3547. for @code{waveform} histogram mode. For @code{levels} histogram mode
  3548. per color component graphs are placed one bellow other.
  3549. This display mode in @code{waveform} histogram mode makes it easy to spot
  3550. color casts in the highlights and shadows of an image, by comparing the
  3551. contours of the top and the bottom of each waveform.
  3552. Since whites, grays, and blacks are characterized by
  3553. exactly equal amounts of red, green, and blue, neutral areas of the
  3554. picture should display three waveforms of roughly equal width/height.
  3555. If not, the correction is easy to make by making adjustments to level the
  3556. three waveforms.
  3557. @item overlay
  3558. Presents information that's identical to that in the @code{parade}, except
  3559. that the graphs representing color components are superimposed directly
  3560. over one another.
  3561. This display mode in @code{waveform} histogram mode can make it easier to spot
  3562. the relative differences or similarities in overlapping areas of the color
  3563. components that are supposed to be identical, such as neutral whites, grays,
  3564. or blacks.
  3565. @end table
  3566. Default is @code{parade}.
  3567. @item levels_mode
  3568. Set mode for @code{levels}. Can be either @code{linear}, or @code{logarithmic}.
  3569. Default is @code{linear}.
  3570. @end table
  3571. @subsection Examples
  3572. @itemize
  3573. @item
  3574. Calculate and draw histogram:
  3575. @example
  3576. ffplay -i input -vf histogram
  3577. @end example
  3578. @end itemize
  3579. @anchor{hqdn3d}
  3580. @section hqdn3d
  3581. High precision/quality 3d denoise filter. This filter aims to reduce
  3582. image noise producing smooth images and making still images really
  3583. still. It should enhance compressibility.
  3584. It accepts the following optional parameters:
  3585. @table @option
  3586. @item luma_spatial
  3587. a non-negative float number which specifies spatial luma strength,
  3588. defaults to 4.0
  3589. @item chroma_spatial
  3590. a non-negative float number which specifies spatial chroma strength,
  3591. defaults to 3.0*@var{luma_spatial}/4.0
  3592. @item luma_tmp
  3593. a float number which specifies luma temporal strength, defaults to
  3594. 6.0*@var{luma_spatial}/4.0
  3595. @item chroma_tmp
  3596. a float number which specifies chroma temporal strength, defaults to
  3597. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
  3598. @end table
  3599. @section hue
  3600. Modify the hue and/or the saturation of the input.
  3601. This filter accepts the following options:
  3602. @table @option
  3603. @item h
  3604. Specify the hue angle as a number of degrees. It accepts an expression,
  3605. and defaults to "0".
  3606. @item s
  3607. Specify the saturation in the [-10,10] range. It accepts an expression and
  3608. defaults to "1".
  3609. @item H
  3610. Specify the hue angle as a number of radians. It accepts an
  3611. expression, and defaults to "0".
  3612. @item b
  3613. Specify the brightness in the [-10,10] range. It accepts an expression and
  3614. defaults to "0".
  3615. @end table
  3616. @option{h} and @option{H} are mutually exclusive, and can't be
  3617. specified at the same time.
  3618. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  3619. expressions containing the following constants:
  3620. @table @option
  3621. @item n
  3622. frame count of the input frame starting from 0
  3623. @item pts
  3624. presentation timestamp of the input frame expressed in time base units
  3625. @item r
  3626. frame rate of the input video, NAN if the input frame rate is unknown
  3627. @item t
  3628. timestamp expressed in seconds, NAN if the input timestamp is unknown
  3629. @item tb
  3630. time base of the input video
  3631. @end table
  3632. @subsection Examples
  3633. @itemize
  3634. @item
  3635. Set the hue to 90 degrees and the saturation to 1.0:
  3636. @example
  3637. hue=h=90:s=1
  3638. @end example
  3639. @item
  3640. Same command but expressing the hue in radians:
  3641. @example
  3642. hue=H=PI/2:s=1
  3643. @end example
  3644. @item
  3645. Rotate hue and make the saturation swing between 0
  3646. and 2 over a period of 1 second:
  3647. @example
  3648. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  3649. @end example
  3650. @item
  3651. Apply a 3 seconds saturation fade-in effect starting at 0:
  3652. @example
  3653. hue="s=min(t/3\,1)"
  3654. @end example
  3655. The general fade-in expression can be written as:
  3656. @example
  3657. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  3658. @end example
  3659. @item
  3660. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  3661. @example
  3662. hue="s=max(0\, min(1\, (8-t)/3))"
  3663. @end example
  3664. The general fade-out expression can be written as:
  3665. @example
  3666. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  3667. @end example
  3668. @end itemize
  3669. @subsection Commands
  3670. This filter supports the following commands:
  3671. @table @option
  3672. @item b
  3673. @item s
  3674. @item h
  3675. @item H
  3676. Modify the hue and/or the saturation and/or brightness of the input video.
  3677. The command accepts the same syntax of the corresponding option.
  3678. If the specified expression is not valid, it is kept at its current
  3679. value.
  3680. @end table
  3681. @section idet
  3682. Detect video interlacing type.
  3683. This filter tries to detect if the input is interlaced or progressive,
  3684. top or bottom field first.
  3685. The filter accepts the following options:
  3686. @table @option
  3687. @item intl_thres
  3688. Set interlacing threshold.
  3689. @item prog_thres
  3690. Set progressive threshold.
  3691. @end table
  3692. @section il
  3693. Deinterleave or interleave fields.
  3694. This filter allows to process interlaced images fields without
  3695. deinterlacing them. Deinterleaving splits the input frame into 2
  3696. fields (so called half pictures). Odd lines are moved to the top
  3697. half of the output image, even lines to the bottom half.
  3698. You can process (filter) them independently and then re-interleave them.
  3699. The filter accepts the following options:
  3700. @table @option
  3701. @item luma_mode, l
  3702. @item chroma_mode, c
  3703. @item alpha_mode, a
  3704. Available values for @var{luma_mode}, @var{chroma_mode} and
  3705. @var{alpha_mode} are:
  3706. @table @samp
  3707. @item none
  3708. Do nothing.
  3709. @item deinterleave, d
  3710. Deinterleave fields, placing one above the other.
  3711. @item interleave, i
  3712. Interleave fields. Reverse the effect of deinterleaving.
  3713. @end table
  3714. Default value is @code{none}.
  3715. @item luma_swap, ls
  3716. @item chroma_swap, cs
  3717. @item alpha_swap, as
  3718. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  3719. @end table
  3720. @section interlace
  3721. Simple interlacing filter from progressive contents. This interleaves upper (or
  3722. lower) lines from odd frames with lower (or upper) lines from even frames,
  3723. halving the frame rate and preserving image height.
  3724. @example
  3725. Original Original New Frame
  3726. Frame 'j' Frame 'j+1' (tff)
  3727. ========== =========== ==================
  3728. Line 0 --------------------> Frame 'j' Line 0
  3729. Line 1 Line 1 ----> Frame 'j+1' Line 1
  3730. Line 2 ---------------------> Frame 'j' Line 2
  3731. Line 3 Line 3 ----> Frame 'j+1' Line 3
  3732. ... ... ...
  3733. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  3734. @end example
  3735. It accepts the following optional parameters:
  3736. @table @option
  3737. @item scan
  3738. determines whether the interlaced frame is taken from the even (tff - default)
  3739. or odd (bff) lines of the progressive frame.
  3740. @item lowpass
  3741. Enable (default) or disable the vertical lowpass filter to avoid twitter
  3742. interlacing and reduce moire patterns.
  3743. @end table
  3744. @section kerndeint
  3745. Deinterlace input video by applying Donald Graft's adaptive kernel
  3746. deinterling. Work on interlaced parts of a video to produce
  3747. progressive frames.
  3748. The description of the accepted parameters follows.
  3749. @table @option
  3750. @item thresh
  3751. Set the threshold which affects the filter's tolerance when
  3752. determining if a pixel line must be processed. It must be an integer
  3753. in the range [0,255] and defaults to 10. A value of 0 will result in
  3754. applying the process on every pixels.
  3755. @item map
  3756. Paint pixels exceeding the threshold value to white if set to 1.
  3757. Default is 0.
  3758. @item order
  3759. Set the fields order. Swap fields if set to 1, leave fields alone if
  3760. 0. Default is 0.
  3761. @item sharp
  3762. Enable additional sharpening if set to 1. Default is 0.
  3763. @item twoway
  3764. Enable twoway sharpening if set to 1. Default is 0.
  3765. @end table
  3766. @subsection Examples
  3767. @itemize
  3768. @item
  3769. Apply default values:
  3770. @example
  3771. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  3772. @end example
  3773. @item
  3774. Enable additional sharpening:
  3775. @example
  3776. kerndeint=sharp=1
  3777. @end example
  3778. @item
  3779. Paint processed pixels in white:
  3780. @example
  3781. kerndeint=map=1
  3782. @end example
  3783. @end itemize
  3784. @anchor{lut3d}
  3785. @section lut3d
  3786. Apply a 3D LUT to an input video.
  3787. The filter accepts the following options:
  3788. @table @option
  3789. @item file
  3790. Set the 3D LUT file name.
  3791. Currently supported formats:
  3792. @table @samp
  3793. @item 3dl
  3794. AfterEffects
  3795. @item cube
  3796. Iridas
  3797. @item dat
  3798. DaVinci
  3799. @item m3d
  3800. Pandora
  3801. @end table
  3802. @item interp
  3803. Select interpolation mode.
  3804. Available values are:
  3805. @table @samp
  3806. @item nearest
  3807. Use values from the nearest defined point.
  3808. @item trilinear
  3809. Interpolate values using the 8 points defining a cube.
  3810. @item tetrahedral
  3811. Interpolate values using a tetrahedron.
  3812. @end table
  3813. @end table
  3814. @section lut, lutrgb, lutyuv
  3815. Compute a look-up table for binding each pixel component input value
  3816. to an output value, and apply it to input video.
  3817. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  3818. to an RGB input video.
  3819. These filters accept the following options:
  3820. @table @option
  3821. @item c0
  3822. set first pixel component expression
  3823. @item c1
  3824. set second pixel component expression
  3825. @item c2
  3826. set third pixel component expression
  3827. @item c3
  3828. set fourth pixel component expression, corresponds to the alpha component
  3829. @item r
  3830. set red component expression
  3831. @item g
  3832. set green component expression
  3833. @item b
  3834. set blue component expression
  3835. @item a
  3836. alpha component expression
  3837. @item y
  3838. set Y/luminance component expression
  3839. @item u
  3840. set U/Cb component expression
  3841. @item v
  3842. set V/Cr component expression
  3843. @end table
  3844. Each of them specifies the expression to use for computing the lookup table for
  3845. the corresponding pixel component values.
  3846. The exact component associated to each of the @var{c*} options depends on the
  3847. format in input.
  3848. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  3849. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  3850. The expressions can contain the following constants and functions:
  3851. @table @option
  3852. @item w
  3853. @item h
  3854. the input width and height
  3855. @item val
  3856. input value for the pixel component
  3857. @item clipval
  3858. the input value clipped in the @var{minval}-@var{maxval} range
  3859. @item maxval
  3860. maximum value for the pixel component
  3861. @item minval
  3862. minimum value for the pixel component
  3863. @item negval
  3864. the negated value for the pixel component value clipped in the
  3865. @var{minval}-@var{maxval} range , it corresponds to the expression
  3866. "maxval-clipval+minval"
  3867. @item clip(val)
  3868. the computed value in @var{val} clipped in the
  3869. @var{minval}-@var{maxval} range
  3870. @item gammaval(gamma)
  3871. the computed gamma correction value of the pixel component value
  3872. clipped in the @var{minval}-@var{maxval} range, corresponds to the
  3873. expression
  3874. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  3875. @end table
  3876. All expressions default to "val".
  3877. @subsection Examples
  3878. @itemize
  3879. @item
  3880. Negate input video:
  3881. @example
  3882. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  3883. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  3884. @end example
  3885. The above is the same as:
  3886. @example
  3887. lutrgb="r=negval:g=negval:b=negval"
  3888. lutyuv="y=negval:u=negval:v=negval"
  3889. @end example
  3890. @item
  3891. Negate luminance:
  3892. @example
  3893. lutyuv=y=negval
  3894. @end example
  3895. @item
  3896. Remove chroma components, turns the video into a graytone image:
  3897. @example
  3898. lutyuv="u=128:v=128"
  3899. @end example
  3900. @item
  3901. Apply a luma burning effect:
  3902. @example
  3903. lutyuv="y=2*val"
  3904. @end example
  3905. @item
  3906. Remove green and blue components:
  3907. @example
  3908. lutrgb="g=0:b=0"
  3909. @end example
  3910. @item
  3911. Set a constant alpha channel value on input:
  3912. @example
  3913. format=rgba,lutrgb=a="maxval-minval/2"
  3914. @end example
  3915. @item
  3916. Correct luminance gamma by a 0.5 factor:
  3917. @example
  3918. lutyuv=y=gammaval(0.5)
  3919. @end example
  3920. @item
  3921. Discard least significant bits of luma:
  3922. @example
  3923. lutyuv=y='bitand(val, 128+64+32)'
  3924. @end example
  3925. @end itemize
  3926. @section mcdeint
  3927. Apply motion-compensation deinterlacing.
  3928. It needs one field per frame as input and must thus be used together
  3929. with yadif=1/3 or equivalent.
  3930. This filter accepts the following options:
  3931. @table @option
  3932. @item mode
  3933. Set the deinterlacing mode.
  3934. It accepts one of the following values:
  3935. @table @samp
  3936. @item fast
  3937. @item medium
  3938. @item slow
  3939. use iterative motion estimation
  3940. @item extra_slow
  3941. like @samp{slow}, but use multiple reference frames.
  3942. @end table
  3943. Default value is @samp{fast}.
  3944. @item parity
  3945. Set the picture field parity assumed for the input video. It must be
  3946. one of the following values:
  3947. @table @samp
  3948. @item 0, tff
  3949. assume top field first
  3950. @item 1, bff
  3951. assume bottom field first
  3952. @end table
  3953. Default value is @samp{bff}.
  3954. @item qp
  3955. Set per-block quantization parameter (QP) used by the internal
  3956. encoder.
  3957. Higher values should result in a smoother motion vector field but less
  3958. optimal individual vectors. Default value is 1.
  3959. @end table
  3960. @section mp
  3961. Apply an MPlayer filter to the input video.
  3962. This filter provides a wrapper around some of the filters of
  3963. MPlayer/MEncoder.
  3964. This wrapper is considered experimental. Some of the wrapped filters
  3965. may not work properly and we may drop support for them, as they will
  3966. be implemented natively into FFmpeg. Thus you should avoid
  3967. depending on them when writing portable scripts.
  3968. The filter accepts the parameters:
  3969. @var{filter_name}[:=]@var{filter_params}
  3970. @var{filter_name} is the name of a supported MPlayer filter,
  3971. @var{filter_params} is a string containing the parameters accepted by
  3972. the named filter.
  3973. The list of the currently supported filters follows:
  3974. @table @var
  3975. @item dint
  3976. @item eq2
  3977. @item eq
  3978. @item fil
  3979. @item fspp
  3980. @item ilpack
  3981. @item pp7
  3982. @item pullup
  3983. @item qp
  3984. @item softpulldown
  3985. @item uspp
  3986. @end table
  3987. The parameter syntax and behavior for the listed filters are the same
  3988. of the corresponding MPlayer filters. For detailed instructions check
  3989. the "VIDEO FILTERS" section in the MPlayer manual.
  3990. @subsection Examples
  3991. @itemize
  3992. @item
  3993. Adjust gamma, brightness, contrast:
  3994. @example
  3995. mp=eq2=1.0:2:0.5
  3996. @end example
  3997. @end itemize
  3998. See also mplayer(1), @url{http://www.mplayerhq.hu/}.
  3999. @section mpdecimate
  4000. Drop frames that do not differ greatly from the previous frame in
  4001. order to reduce frame rate.
  4002. The main use of this filter is for very-low-bitrate encoding
  4003. (e.g. streaming over dialup modem), but it could in theory be used for
  4004. fixing movies that were inverse-telecined incorrectly.
  4005. A description of the accepted options follows.
  4006. @table @option
  4007. @item max
  4008. Set the maximum number of consecutive frames which can be dropped (if
  4009. positive), or the minimum interval between dropped frames (if
  4010. negative). If the value is 0, the frame is dropped unregarding the
  4011. number of previous sequentially dropped frames.
  4012. Default value is 0.
  4013. @item hi
  4014. @item lo
  4015. @item frac
  4016. Set the dropping threshold values.
  4017. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  4018. represent actual pixel value differences, so a threshold of 64
  4019. corresponds to 1 unit of difference for each pixel, or the same spread
  4020. out differently over the block.
  4021. A frame is a candidate for dropping if no 8x8 blocks differ by more
  4022. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  4023. meaning the whole image) differ by more than a threshold of @option{lo}.
  4024. Default value for @option{hi} is 64*12, default value for @option{lo} is
  4025. 64*5, and default value for @option{frac} is 0.33.
  4026. @end table
  4027. @section negate
  4028. Negate input video.
  4029. This filter accepts an integer in input, if non-zero it negates the
  4030. alpha component (if available). The default value in input is 0.
  4031. @section noformat
  4032. Force libavfilter not to use any of the specified pixel formats for the
  4033. input to the next filter.
  4034. This filter accepts the following parameters:
  4035. @table @option
  4036. @item pix_fmts
  4037. A '|'-separated list of pixel format names, for example
  4038. "pix_fmts=yuv420p|monow|rgb24".
  4039. @end table
  4040. @subsection Examples
  4041. @itemize
  4042. @item
  4043. Force libavfilter to use a format different from @var{yuv420p} for the
  4044. input to the vflip filter:
  4045. @example
  4046. noformat=pix_fmts=yuv420p,vflip
  4047. @end example
  4048. @item
  4049. Convert the input video to any of the formats not contained in the list:
  4050. @example
  4051. noformat=yuv420p|yuv444p|yuv410p
  4052. @end example
  4053. @end itemize
  4054. @section noise
  4055. Add noise on video input frame.
  4056. The filter accepts the following options:
  4057. @table @option
  4058. @item all_seed
  4059. @item c0_seed
  4060. @item c1_seed
  4061. @item c2_seed
  4062. @item c3_seed
  4063. Set noise seed for specific pixel component or all pixel components in case
  4064. of @var{all_seed}. Default value is @code{123457}.
  4065. @item all_strength, alls
  4066. @item c0_strength, c0s
  4067. @item c1_strength, c1s
  4068. @item c2_strength, c2s
  4069. @item c3_strength, c3s
  4070. Set noise strength for specific pixel component or all pixel components in case
  4071. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  4072. @item all_flags, allf
  4073. @item c0_flags, c0f
  4074. @item c1_flags, c1f
  4075. @item c2_flags, c2f
  4076. @item c3_flags, c3f
  4077. Set pixel component flags or set flags for all components if @var{all_flags}.
  4078. Available values for component flags are:
  4079. @table @samp
  4080. @item a
  4081. averaged temporal noise (smoother)
  4082. @item p
  4083. mix random noise with a (semi)regular pattern
  4084. @item t
  4085. temporal noise (noise pattern changes between frames)
  4086. @item u
  4087. uniform noise (gaussian otherwise)
  4088. @end table
  4089. @end table
  4090. @subsection Examples
  4091. Add temporal and uniform noise to input video:
  4092. @example
  4093. noise=alls=20:allf=t+u
  4094. @end example
  4095. @section null
  4096. Pass the video source unchanged to the output.
  4097. @section ocv
  4098. Apply video transform using libopencv.
  4099. To enable this filter install libopencv library and headers and
  4100. configure FFmpeg with @code{--enable-libopencv}.
  4101. This filter accepts the following parameters:
  4102. @table @option
  4103. @item filter_name
  4104. The name of the libopencv filter to apply.
  4105. @item filter_params
  4106. The parameters to pass to the libopencv filter. If not specified the default
  4107. values are assumed.
  4108. @end table
  4109. Refer to the official libopencv documentation for more precise
  4110. information:
  4111. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  4112. Follows the list of supported libopencv filters.
  4113. @anchor{dilate}
  4114. @subsection dilate
  4115. Dilate an image by using a specific structuring element.
  4116. This filter corresponds to the libopencv function @code{cvDilate}.
  4117. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  4118. @var{struct_el} represents a structuring element, and has the syntax:
  4119. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  4120. @var{cols} and @var{rows} represent the number of columns and rows of
  4121. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  4122. point, and @var{shape} the shape for the structuring element, and
  4123. can be one of the values "rect", "cross", "ellipse", "custom".
  4124. If the value for @var{shape} is "custom", it must be followed by a
  4125. string of the form "=@var{filename}". The file with name
  4126. @var{filename} is assumed to represent a binary image, with each
  4127. printable character corresponding to a bright pixel. When a custom
  4128. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  4129. or columns and rows of the read file are assumed instead.
  4130. The default value for @var{struct_el} is "3x3+0x0/rect".
  4131. @var{nb_iterations} specifies the number of times the transform is
  4132. applied to the image, and defaults to 1.
  4133. Follow some example:
  4134. @example
  4135. # use the default values
  4136. ocv=dilate
  4137. # dilate using a structuring element with a 5x5 cross, iterate two times
  4138. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  4139. # read the shape from the file diamond.shape, iterate two times
  4140. # the file diamond.shape may contain a pattern of characters like this:
  4141. # *
  4142. # ***
  4143. # *****
  4144. # ***
  4145. # *
  4146. # the specified cols and rows are ignored (but not the anchor point coordinates)
  4147. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  4148. @end example
  4149. @subsection erode
  4150. Erode an image by using a specific structuring element.
  4151. This filter corresponds to the libopencv function @code{cvErode}.
  4152. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
  4153. with the same syntax and semantics as the @ref{dilate} filter.
  4154. @subsection smooth
  4155. Smooth the input video.
  4156. The filter takes the following parameters:
  4157. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  4158. @var{type} is the type of smooth filter to apply, and can be one of
  4159. the following values: "blur", "blur_no_scale", "median", "gaussian",
  4160. "bilateral". The default value is "gaussian".
  4161. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  4162. parameters whose meanings depend on smooth type. @var{param1} and
  4163. @var{param2} accept integer positive values or 0, @var{param3} and
  4164. @var{param4} accept float values.
  4165. The default value for @var{param1} is 3, the default value for the
  4166. other parameters is 0.
  4167. These parameters correspond to the parameters assigned to the
  4168. libopencv function @code{cvSmooth}.
  4169. @anchor{overlay}
  4170. @section overlay
  4171. Overlay one video on top of another.
  4172. It takes two inputs and one output, the first input is the "main"
  4173. video on which the second input is overlayed.
  4174. This filter accepts the following parameters:
  4175. A description of the accepted options follows.
  4176. @table @option
  4177. @item x
  4178. @item y
  4179. Set the expression for the x and y coordinates of the overlayed video
  4180. on the main video. Default value is "0" for both expressions. In case
  4181. the expression is invalid, it is set to a huge value (meaning that the
  4182. overlay will not be displayed within the output visible area).
  4183. @item eval
  4184. Set when the expressions for @option{x}, and @option{y} are evaluated.
  4185. It accepts the following values:
  4186. @table @samp
  4187. @item init
  4188. only evaluate expressions once during the filter initialization or
  4189. when a command is processed
  4190. @item frame
  4191. evaluate expressions for each incoming frame
  4192. @end table
  4193. Default value is @samp{frame}.
  4194. @item shortest
  4195. If set to 1, force the output to terminate when the shortest input
  4196. terminates. Default value is 0.
  4197. @item format
  4198. Set the format for the output video.
  4199. It accepts the following values:
  4200. @table @samp
  4201. @item yuv420
  4202. force YUV420 output
  4203. @item yuv444
  4204. force YUV444 output
  4205. @item rgb
  4206. force RGB output
  4207. @end table
  4208. Default value is @samp{yuv420}.
  4209. @item rgb @emph{(deprecated)}
  4210. If set to 1, force the filter to accept inputs in the RGB
  4211. color space. Default value is 0. This option is deprecated, use
  4212. @option{format} instead.
  4213. @item repeatlast
  4214. If set to 1, force the filter to draw the last overlay frame over the
  4215. main input until the end of the stream. A value of 0 disables this
  4216. behavior. Default value is 1.
  4217. @end table
  4218. The @option{x}, and @option{y} expressions can contain the following
  4219. parameters.
  4220. @table @option
  4221. @item main_w, W
  4222. @item main_h, H
  4223. main input width and height
  4224. @item overlay_w, w
  4225. @item overlay_h, h
  4226. overlay input width and height
  4227. @item x
  4228. @item y
  4229. the computed values for @var{x} and @var{y}. They are evaluated for
  4230. each new frame.
  4231. @item hsub
  4232. @item vsub
  4233. horizontal and vertical chroma subsample values of the output
  4234. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  4235. @var{vsub} is 1.
  4236. @item n
  4237. the number of input frame, starting from 0
  4238. @item pos
  4239. the position in the file of the input frame, NAN if unknown
  4240. @item t
  4241. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4242. @end table
  4243. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  4244. when evaluation is done @emph{per frame}, and will evaluate to NAN
  4245. when @option{eval} is set to @samp{init}.
  4246. Be aware that frames are taken from each input video in timestamp
  4247. order, hence, if their initial timestamps differ, it is a good idea
  4248. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  4249. have them begin in the same zero timestamp, as it does the example for
  4250. the @var{movie} filter.
  4251. You can chain together more overlays but you should test the
  4252. efficiency of such approach.
  4253. @subsection Commands
  4254. This filter supports the following commands:
  4255. @table @option
  4256. @item x
  4257. @item y
  4258. Modify the x and y of the overlay input.
  4259. The command accepts the same syntax of the corresponding option.
  4260. If the specified expression is not valid, it is kept at its current
  4261. value.
  4262. @end table
  4263. @subsection Examples
  4264. @itemize
  4265. @item
  4266. Draw the overlay at 10 pixels from the bottom right corner of the main
  4267. video:
  4268. @example
  4269. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  4270. @end example
  4271. Using named options the example above becomes:
  4272. @example
  4273. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  4274. @end example
  4275. @item
  4276. Insert a transparent PNG logo in the bottom left corner of the input,
  4277. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  4278. @example
  4279. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  4280. @end example
  4281. @item
  4282. Insert 2 different transparent PNG logos (second logo on bottom
  4283. right corner) using the @command{ffmpeg} tool:
  4284. @example
  4285. 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
  4286. @end example
  4287. @item
  4288. Add a transparent color layer on top of the main video, @code{WxH}
  4289. must specify the size of the main input to the overlay filter:
  4290. @example
  4291. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  4292. @end example
  4293. @item
  4294. Play an original video and a filtered version (here with the deshake
  4295. filter) side by side using the @command{ffplay} tool:
  4296. @example
  4297. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  4298. @end example
  4299. The above command is the same as:
  4300. @example
  4301. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  4302. @end example
  4303. @item
  4304. Make a sliding overlay appearing from the left to the right top part of the
  4305. screen starting since time 2:
  4306. @example
  4307. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  4308. @end example
  4309. @item
  4310. Compose output by putting two input videos side to side:
  4311. @example
  4312. ffmpeg -i left.avi -i right.avi -filter_complex "
  4313. nullsrc=size=200x100 [background];
  4314. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  4315. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  4316. [background][left] overlay=shortest=1 [background+left];
  4317. [background+left][right] overlay=shortest=1:x=100 [left+right]
  4318. "
  4319. @end example
  4320. @item
  4321. Chain several overlays in cascade:
  4322. @example
  4323. nullsrc=s=200x200 [bg];
  4324. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  4325. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  4326. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  4327. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  4328. [in3] null, [mid2] overlay=100:100 [out0]
  4329. @end example
  4330. @end itemize
  4331. @section owdenoise
  4332. Apply Overcomplete Wavelet denoiser.
  4333. The filter accepts the following options:
  4334. @table @option
  4335. @item depth
  4336. Set depth.
  4337. Larger depth values will denoise lower frequency components more, but
  4338. slow down filtering.
  4339. Must be an int in the range 8-16, default is @code{8}.
  4340. @item luma_strength, ls
  4341. Set luma strength.
  4342. Must be a double value in the range 0-1000, default is @code{1.0}.
  4343. @item chroma_strength, cs
  4344. Set chroma strength.
  4345. Must be a double value in the range 0-1000, default is @code{1.0}.
  4346. @end table
  4347. @section pad
  4348. Add paddings to the input image, and place the original input at the
  4349. given coordinates @var{x}, @var{y}.
  4350. This filter accepts the following parameters:
  4351. @table @option
  4352. @item width, w
  4353. @item height, h
  4354. Specify an expression for the size of the output image with the
  4355. paddings added. If the value for @var{width} or @var{height} is 0, the
  4356. corresponding input size is used for the output.
  4357. The @var{width} expression can reference the value set by the
  4358. @var{height} expression, and vice versa.
  4359. The default value of @var{width} and @var{height} is 0.
  4360. @item x
  4361. @item y
  4362. Specify an expression for the offsets where to place the input image
  4363. in the padded area with respect to the top/left border of the output
  4364. image.
  4365. The @var{x} expression can reference the value set by the @var{y}
  4366. expression, and vice versa.
  4367. The default value of @var{x} and @var{y} is 0.
  4368. @item color
  4369. Specify the color of the padded area, it can be the name of a color
  4370. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  4371. The default value of @var{color} is "black".
  4372. @end table
  4373. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  4374. options are expressions containing the following constants:
  4375. @table @option
  4376. @item in_w
  4377. @item in_h
  4378. the input video width and height
  4379. @item iw
  4380. @item ih
  4381. same as @var{in_w} and @var{in_h}
  4382. @item out_w
  4383. @item out_h
  4384. the output width and height, that is the size of the padded area as
  4385. specified by the @var{width} and @var{height} expressions
  4386. @item ow
  4387. @item oh
  4388. same as @var{out_w} and @var{out_h}
  4389. @item x
  4390. @item y
  4391. x and y offsets as specified by the @var{x} and @var{y}
  4392. expressions, or NAN if not yet specified
  4393. @item a
  4394. same as @var{iw} / @var{ih}
  4395. @item sar
  4396. input sample aspect ratio
  4397. @item dar
  4398. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  4399. @item hsub
  4400. @item vsub
  4401. horizontal and vertical chroma subsample values. For example for the
  4402. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4403. @end table
  4404. @subsection Examples
  4405. @itemize
  4406. @item
  4407. Add paddings with color "violet" to the input video. Output video
  4408. size is 640x480, the top-left corner of the input video is placed at
  4409. column 0, row 40:
  4410. @example
  4411. pad=640:480:0:40:violet
  4412. @end example
  4413. The example above is equivalent to the following command:
  4414. @example
  4415. pad=width=640:height=480:x=0:y=40:color=violet
  4416. @end example
  4417. @item
  4418. Pad the input to get an output with dimensions increased by 3/2,
  4419. and put the input video at the center of the padded area:
  4420. @example
  4421. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  4422. @end example
  4423. @item
  4424. Pad the input to get a squared output with size equal to the maximum
  4425. value between the input width and height, and put the input video at
  4426. the center of the padded area:
  4427. @example
  4428. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  4429. @end example
  4430. @item
  4431. Pad the input to get a final w/h ratio of 16:9:
  4432. @example
  4433. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  4434. @end example
  4435. @item
  4436. In case of anamorphic video, in order to set the output display aspect
  4437. correctly, it is necessary to use @var{sar} in the expression,
  4438. according to the relation:
  4439. @example
  4440. (ih * X / ih) * sar = output_dar
  4441. X = output_dar / sar
  4442. @end example
  4443. Thus the previous example needs to be modified to:
  4444. @example
  4445. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  4446. @end example
  4447. @item
  4448. Double output size and put the input video in the bottom-right
  4449. corner of the output padded area:
  4450. @example
  4451. pad="2*iw:2*ih:ow-iw:oh-ih"
  4452. @end example
  4453. @end itemize
  4454. @section perspective
  4455. Correct perspective of video not recorded perpendicular to the screen.
  4456. A description of the accepted parameters follows.
  4457. @table @option
  4458. @item x0
  4459. @item y0
  4460. @item x1
  4461. @item y1
  4462. @item x2
  4463. @item y2
  4464. @item x3
  4465. @item y3
  4466. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  4467. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  4468. The expressions can use the following variables:
  4469. @table @option
  4470. @item W
  4471. @item H
  4472. the width and height of video frame.
  4473. @end table
  4474. @item interpolation
  4475. Set interpolation for perspective correction.
  4476. It accepts the following values:
  4477. @table @samp
  4478. @item linear
  4479. @item cubic
  4480. @end table
  4481. Default value is @samp{linear}.
  4482. @end table
  4483. @section phase
  4484. Delay interlaced video by one field time so that the field order changes.
  4485. The intended use is to fix PAL movies that have been captured with the
  4486. opposite field order to the film-to-video transfer.
  4487. A description of the accepted parameters follows.
  4488. @table @option
  4489. @item mode
  4490. Set phase mode.
  4491. It accepts the following values:
  4492. @table @samp
  4493. @item t
  4494. Capture field order top-first, transfer bottom-first.
  4495. Filter will delay the bottom field.
  4496. @item b
  4497. Capture field order bottom-first, transfer top-first.
  4498. Filter will delay the top field.
  4499. @item p
  4500. Capture and transfer with the same field order. This mode only exists
  4501. for the documentation of the other options to refer to, but if you
  4502. actually select it, the filter will faithfully do nothing.
  4503. @item a
  4504. Capture field order determined automatically by field flags, transfer
  4505. opposite.
  4506. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  4507. basis using field flags. If no field information is available,
  4508. then this works just like @samp{u}.
  4509. @item u
  4510. Capture unknown or varying, transfer opposite.
  4511. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  4512. analyzing the images and selecting the alternative that produces best
  4513. match between the fields.
  4514. @item T
  4515. Capture top-first, transfer unknown or varying.
  4516. Filter selects among @samp{t} and @samp{p} using image analysis.
  4517. @item B
  4518. Capture bottom-first, transfer unknown or varying.
  4519. Filter selects among @samp{b} and @samp{p} using image analysis.
  4520. @item A
  4521. Capture determined by field flags, transfer unknown or varying.
  4522. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  4523. image analysis. If no field information is available, then this works just
  4524. like @samp{U}. This is the default mode.
  4525. @item U
  4526. Both capture and transfer unknown or varying.
  4527. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  4528. @end table
  4529. @end table
  4530. @section pixdesctest
  4531. Pixel format descriptor test filter, mainly useful for internal
  4532. testing. The output video should be equal to the input video.
  4533. For example:
  4534. @example
  4535. format=monow, pixdesctest
  4536. @end example
  4537. can be used to test the monowhite pixel format descriptor definition.
  4538. @section pp
  4539. Enable the specified chain of postprocessing subfilters using libpostproc. This
  4540. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  4541. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  4542. Each subfilter and some options have a short and a long name that can be used
  4543. interchangeably, i.e. dr/dering are the same.
  4544. The filters accept the following options:
  4545. @table @option
  4546. @item subfilters
  4547. Set postprocessing subfilters string.
  4548. @end table
  4549. All subfilters share common options to determine their scope:
  4550. @table @option
  4551. @item a/autoq
  4552. Honor the quality commands for this subfilter.
  4553. @item c/chrom
  4554. Do chrominance filtering, too (default).
  4555. @item y/nochrom
  4556. Do luminance filtering only (no chrominance).
  4557. @item n/noluma
  4558. Do chrominance filtering only (no luminance).
  4559. @end table
  4560. These options can be appended after the subfilter name, separated by a '|'.
  4561. Available subfilters are:
  4562. @table @option
  4563. @item hb/hdeblock[|difference[|flatness]]
  4564. Horizontal deblocking filter
  4565. @table @option
  4566. @item difference
  4567. Difference factor where higher values mean more deblocking (default: @code{32}).
  4568. @item flatness
  4569. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  4570. @end table
  4571. @item vb/vdeblock[|difference[|flatness]]
  4572. Vertical 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 ha/hadeblock[|difference[|flatness]]
  4580. Accurate horizontal 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 va/vadeblock[|difference[|flatness]]
  4588. Accurate vertical 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. @end table
  4596. The horizontal and vertical deblocking filters share the difference and
  4597. flatness values so you cannot set different horizontal and vertical
  4598. thresholds.
  4599. @table @option
  4600. @item h1/x1hdeblock
  4601. Experimental horizontal deblocking filter
  4602. @item v1/x1vdeblock
  4603. Experimental vertical deblocking filter
  4604. @item dr/dering
  4605. Deringing filter
  4606. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  4607. @table @option
  4608. @item threshold1
  4609. larger -> stronger filtering
  4610. @item threshold2
  4611. larger -> stronger filtering
  4612. @item threshold3
  4613. larger -> stronger filtering
  4614. @end table
  4615. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  4616. @table @option
  4617. @item f/fullyrange
  4618. Stretch luminance to @code{0-255}.
  4619. @end table
  4620. @item lb/linblenddeint
  4621. Linear blend deinterlacing filter that deinterlaces the given block by
  4622. filtering all lines with a @code{(1 2 1)} filter.
  4623. @item li/linipoldeint
  4624. Linear interpolating deinterlacing filter that deinterlaces the given block by
  4625. linearly interpolating every second line.
  4626. @item ci/cubicipoldeint
  4627. Cubic interpolating deinterlacing filter deinterlaces the given block by
  4628. cubically interpolating every second line.
  4629. @item md/mediandeint
  4630. Median deinterlacing filter that deinterlaces the given block by applying a
  4631. median filter to every second line.
  4632. @item fd/ffmpegdeint
  4633. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  4634. second line with a @code{(-1 4 2 4 -1)} filter.
  4635. @item l5/lowpass5
  4636. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  4637. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  4638. @item fq/forceQuant[|quantizer]
  4639. Overrides the quantizer table from the input with the constant quantizer you
  4640. specify.
  4641. @table @option
  4642. @item quantizer
  4643. Quantizer to use
  4644. @end table
  4645. @item de/default
  4646. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  4647. @item fa/fast
  4648. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  4649. @item ac
  4650. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  4651. @end table
  4652. @subsection Examples
  4653. @itemize
  4654. @item
  4655. Apply horizontal and vertical deblocking, deringing and automatic
  4656. brightness/contrast:
  4657. @example
  4658. pp=hb/vb/dr/al
  4659. @end example
  4660. @item
  4661. Apply default filters without brightness/contrast correction:
  4662. @example
  4663. pp=de/-al
  4664. @end example
  4665. @item
  4666. Apply default filters and temporal denoiser:
  4667. @example
  4668. pp=default/tmpnoise|1|2|3
  4669. @end example
  4670. @item
  4671. Apply deblocking on luminance only, and switch vertical deblocking on or off
  4672. automatically depending on available CPU time:
  4673. @example
  4674. pp=hb|y/vb|a
  4675. @end example
  4676. @end itemize
  4677. @section psnr
  4678. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  4679. Ratio) between two input videos.
  4680. This filter takes in input two input videos, the first input is
  4681. considered the "main" source and is passed unchanged to the
  4682. output. The second input is used as a "reference" video for computing
  4683. the PSNR.
  4684. Both video inputs must have the same resolution and pixel format for
  4685. this filter to work correctly. Also it assumes that both inputs
  4686. have the same number of frames, which are compared one by one.
  4687. The obtained average PSNR is printed through the logging system.
  4688. The filter stores the accumulated MSE (mean squared error) of each
  4689. frame, and at the end of the processing it is averaged across all frames
  4690. equally, and the following formula is applied to obtain the PSNR:
  4691. @example
  4692. PSNR = 10*log10(MAX^2/MSE)
  4693. @end example
  4694. Where MAX is the average of the maximum values of each component of the
  4695. image.
  4696. The description of the accepted parameters follows.
  4697. @table @option
  4698. @item stats_file, f
  4699. If specified the filter will use the named file to save the PSNR of
  4700. each individual frame.
  4701. @end table
  4702. The file printed if @var{stats_file} is selected, contains a sequence of
  4703. key/value pairs of the form @var{key}:@var{value} for each compared
  4704. couple of frames.
  4705. A description of each shown parameter follows:
  4706. @table @option
  4707. @item n
  4708. sequential number of the input frame, starting from 1
  4709. @item mse_avg
  4710. Mean Square Error pixel-by-pixel average difference of the compared
  4711. frames, averaged over all the image components.
  4712. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  4713. Mean Square Error pixel-by-pixel average difference of the compared
  4714. frames for the component specified by the suffix.
  4715. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  4716. Peak Signal to Noise ratio of the compared frames for the component
  4717. specified by the suffix.
  4718. @end table
  4719. For example:
  4720. @example
  4721. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  4722. [main][ref] psnr="stats_file=stats.log" [out]
  4723. @end example
  4724. On this example the input file being processed is compared with the
  4725. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  4726. is stored in @file{stats.log}.
  4727. @section removelogo
  4728. Suppress a TV station logo, using an image file to determine which
  4729. pixels comprise the logo. It works by filling in the pixels that
  4730. comprise the logo with neighboring pixels.
  4731. The filter accepts the following options:
  4732. @table @option
  4733. @item filename, f
  4734. Set the filter bitmap file, which can be any image format supported by
  4735. libavformat. The width and height of the image file must match those of the
  4736. video stream being processed.
  4737. @end table
  4738. Pixels in the provided bitmap image with a value of zero are not
  4739. considered part of the logo, non-zero pixels are considered part of
  4740. the logo. If you use white (255) for the logo and black (0) for the
  4741. rest, you will be safe. For making the filter bitmap, it is
  4742. recommended to take a screen capture of a black frame with the logo
  4743. visible, and then using a threshold filter followed by the erode
  4744. filter once or twice.
  4745. If needed, little splotches can be fixed manually. Remember that if
  4746. logo pixels are not covered, the filter quality will be much
  4747. reduced. Marking too many pixels as part of the logo does not hurt as
  4748. much, but it will increase the amount of blurring needed to cover over
  4749. the image and will destroy more information than necessary, and extra
  4750. pixels will slow things down on a large logo.
  4751. @section rotate
  4752. Rotate video by an arbitrary angle expressed in radians.
  4753. The filter accepts the following options:
  4754. A description of the optional parameters follows.
  4755. @table @option
  4756. @item angle, a
  4757. Set an expression for the angle by which to rotate the input video
  4758. clockwise, expressed as a number of radians. A negative value will
  4759. result in a counter-clockwise rotation. By default it is set to "0".
  4760. This expression is evaluated for each frame.
  4761. @item out_w, ow
  4762. Set the output width expression, default value is "iw".
  4763. This expression is evaluated just once during configuration.
  4764. @item out_h, oh
  4765. Set the output height expression, default value is "ih".
  4766. This expression is evaluated just once during configuration.
  4767. @item bilinear
  4768. Enable bilinear interpolation if set to 1, a value of 0 disables
  4769. it. Default value is 1.
  4770. @item fillcolor, c
  4771. Set the color used to fill the output area not covered by the rotated
  4772. image. If the special value "none" is selected then no background is
  4773. printed (useful for example if the background is never shown). Default
  4774. value is "black".
  4775. @end table
  4776. The expressions for the angle and the output size can contain the
  4777. following constants and functions:
  4778. @table @option
  4779. @item n
  4780. sequential number of the input frame, starting from 0. It is always NAN
  4781. before the first frame is filtered.
  4782. @item t
  4783. time in seconds of the input frame, it is set to 0 when the filter is
  4784. configured. It is always NAN before the first frame is filtered.
  4785. @item hsub
  4786. @item vsub
  4787. horizontal and vertical chroma subsample values. For example for the
  4788. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4789. @item in_w, iw
  4790. @item in_h, ih
  4791. the input video width and heigth
  4792. @item out_w, ow
  4793. @item out_h, oh
  4794. the output width and heigth, that is the size of the padded area as
  4795. specified by the @var{width} and @var{height} expressions
  4796. @item rotw(a)
  4797. @item roth(a)
  4798. the minimal width/height required for completely containing the input
  4799. video rotated by @var{a} radians.
  4800. These are only available when computing the @option{out_w} and
  4801. @option{out_h} expressions.
  4802. @end table
  4803. @subsection Examples
  4804. @itemize
  4805. @item
  4806. Rotate the input by PI/6 radians clockwise:
  4807. @example
  4808. rotate=PI/6
  4809. @end example
  4810. @item
  4811. Rotate the input by PI/6 radians counter-clockwise:
  4812. @example
  4813. rotate=-PI/6
  4814. @end example
  4815. @item
  4816. Apply a constant rotation with period T, starting from an angle of PI/3:
  4817. @example
  4818. rotate=PI/3+2*PI*t/T
  4819. @end example
  4820. @item
  4821. Make the input video rotation oscillating with a period of T
  4822. seconds and an amplitude of A radians:
  4823. @example
  4824. rotate=A*sin(2*PI/T*t)
  4825. @end example
  4826. @item
  4827. Rotate the video, output size is choosen so that the whole rotating
  4828. input video is always completely contained in the output:
  4829. @example
  4830. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  4831. @end example
  4832. @item
  4833. Rotate the video, reduce the output size so that no background is ever
  4834. shown:
  4835. @example
  4836. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  4837. @end example
  4838. @end itemize
  4839. @subsection Commands
  4840. The filter supports the following commands:
  4841. @table @option
  4842. @item a, angle
  4843. Set the angle expression.
  4844. The command accepts the same syntax of the corresponding option.
  4845. If the specified expression is not valid, it is kept at its current
  4846. value.
  4847. @end table
  4848. @section sab
  4849. Apply Shape Adaptive Blur.
  4850. The filter accepts the following options:
  4851. @table @option
  4852. @item luma_radius, lr
  4853. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  4854. value is 1.0. A greater value will result in a more blurred image, and
  4855. in slower processing.
  4856. @item luma_pre_filter_radius, lpfr
  4857. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  4858. value is 1.0.
  4859. @item luma_strength, ls
  4860. Set luma maximum difference between pixels to still be considered, must
  4861. be a value in the 0.1-100.0 range, default value is 1.0.
  4862. @item chroma_radius, cr
  4863. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  4864. greater value will result in a more blurred image, and in slower
  4865. processing.
  4866. @item chroma_pre_filter_radius, cpfr
  4867. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  4868. @item chroma_strength, cs
  4869. Set chroma maximum difference between pixels to still be considered,
  4870. must be a value in the 0.1-100.0 range.
  4871. @end table
  4872. Each chroma option value, if not explicitly specified, is set to the
  4873. corresponding luma option value.
  4874. @section scale
  4875. Scale (resize) the input video, using the libswscale library.
  4876. The scale filter forces the output display aspect ratio to be the same
  4877. of the input, by changing the output sample aspect ratio.
  4878. If the input image format is different from the format requested by
  4879. the next filter, the scale filter will convert the input to the
  4880. requested format.
  4881. @subsection Options
  4882. The filter accepts the following options:
  4883. @table @option
  4884. @item width, w
  4885. @item height, h
  4886. Set the output video dimension expression. Default value is the input
  4887. dimension.
  4888. If the value is 0, the input width is used for the output.
  4889. If one of the values is -1, the scale filter will use a value that
  4890. maintains the aspect ratio of the input image, calculated from the
  4891. other specified dimension. If both of them are -1, the input size is
  4892. used
  4893. See below for the list of accepted constants for use in the dimension
  4894. expression.
  4895. @item interl
  4896. Set the interlacing mode. It accepts the following values:
  4897. @table @samp
  4898. @item 1
  4899. Force interlaced aware scaling.
  4900. @item 0
  4901. Do not apply interlaced scaling.
  4902. @item -1
  4903. Select interlaced aware scaling depending on whether the source frames
  4904. are flagged as interlaced or not.
  4905. @end table
  4906. Default value is @samp{0}.
  4907. @item flags
  4908. Set libswscale scaling flags. If not explictly specified the filter
  4909. applies a bilinear scaling algorithm.
  4910. @item size, s
  4911. Set the video size, the value must be a valid abbreviation or in the
  4912. form @var{width}x@var{height}.
  4913. @item in_color_matrix
  4914. @item out_color_matrix
  4915. Set in/output YCbCr color space type.
  4916. This allows the autodetected value to be overridden as well as allows forcing
  4917. a specific value used for the output and encoder.
  4918. If not specified, the color space type depends on the pixel format.
  4919. Possible values:
  4920. @table @samp
  4921. @item auto
  4922. Choose automatically.
  4923. @item bt709
  4924. Format conforming to International Telecommunication Union (ITU)
  4925. Recommendation BT.709.
  4926. @item fcc
  4927. Set color space conforming to the United States Federal Communications
  4928. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  4929. @item bt601
  4930. Set color space conforming to:
  4931. @itemize
  4932. @item
  4933. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  4934. @item
  4935. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  4936. @item
  4937. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  4938. @end itemize
  4939. @item smpte240m
  4940. Set color space conforming to SMPTE ST 240:1999.
  4941. @end table
  4942. @item in_range
  4943. @item out_range
  4944. Set in/output YCbCr sample range.
  4945. This allows the autodetected value to be overridden as well as allows forcing
  4946. a specific value used for the output and encoder. If not specified, the
  4947. range depends on the pixel format. Possible values:
  4948. @table @samp
  4949. @item auto
  4950. Choose automatically.
  4951. @item jpeg/full/pc
  4952. Set full range (0-255 in case of 8-bit luma).
  4953. @item mpeg/tv
  4954. Set "MPEG" range (16-235 in case of 8-bit luma).
  4955. @end table
  4956. @item sws_dither
  4957. Set the dithering algorithm
  4958. @table @samp
  4959. @item auto
  4960. Choose automatically.
  4961. @item none
  4962. No dithering
  4963. @item bayer
  4964. bayer dither
  4965. @item ed
  4966. error diffusion dither
  4967. @end table
  4968. @item force_original_aspect_ratio
  4969. Enable decreasing or increasing output video width or height if necessary to
  4970. keep the original aspect ratio. Possible values:
  4971. @table @samp
  4972. @item disable
  4973. Scale the video as specified and disable this feature.
  4974. @item decrease
  4975. The output video dimensions will automatically be decreased if needed.
  4976. @item increase
  4977. The output video dimensions will automatically be increased if needed.
  4978. @end table
  4979. One useful instance of this option is that when you know a specific device's
  4980. maximum allowed resolution, you can use this to limit the output video to
  4981. that, while retaining the aspect ratio. For example, device A allows
  4982. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  4983. decrease) and specifying 1280x720 to the command line makes the output
  4984. 1280x533.
  4985. Please note that this is a different thing than specifying -1 for @option{w}
  4986. or @option{h}, you still need to specify the output resolution for this option
  4987. to work.
  4988. @end table
  4989. The values of the @option{w} and @option{h} options are expressions
  4990. containing the following constants:
  4991. @table @var
  4992. @item in_w
  4993. @item in_h
  4994. the input width and height
  4995. @item iw
  4996. @item ih
  4997. same as @var{in_w} and @var{in_h}
  4998. @item out_w
  4999. @item out_h
  5000. the output (scaled) width and height
  5001. @item ow
  5002. @item oh
  5003. same as @var{out_w} and @var{out_h}
  5004. @item a
  5005. same as @var{iw} / @var{ih}
  5006. @item sar
  5007. input sample aspect ratio
  5008. @item dar
  5009. input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  5010. @item hsub
  5011. @item vsub
  5012. horizontal and vertical chroma subsample values. For example for the
  5013. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  5014. @end table
  5015. @subsection Examples
  5016. @itemize
  5017. @item
  5018. Scale the input video to a size of 200x100:
  5019. @example
  5020. scale=w=200:h=100
  5021. @end example
  5022. This is equivalent to:
  5023. @example
  5024. scale=200:100
  5025. @end example
  5026. or:
  5027. @example
  5028. scale=200x100
  5029. @end example
  5030. @item
  5031. Specify a size abbreviation for the output size:
  5032. @example
  5033. scale=qcif
  5034. @end example
  5035. which can also be written as:
  5036. @example
  5037. scale=size=qcif
  5038. @end example
  5039. @item
  5040. Scale the input to 2x:
  5041. @example
  5042. scale=w=2*iw:h=2*ih
  5043. @end example
  5044. @item
  5045. The above is the same as:
  5046. @example
  5047. scale=2*in_w:2*in_h
  5048. @end example
  5049. @item
  5050. Scale the input to 2x with forced interlaced scaling:
  5051. @example
  5052. scale=2*iw:2*ih:interl=1
  5053. @end example
  5054. @item
  5055. Scale the input to half size:
  5056. @example
  5057. scale=w=iw/2:h=ih/2
  5058. @end example
  5059. @item
  5060. Increase the width, and set the height to the same size:
  5061. @example
  5062. scale=3/2*iw:ow
  5063. @end example
  5064. @item
  5065. Seek for Greek harmony:
  5066. @example
  5067. scale=iw:1/PHI*iw
  5068. scale=ih*PHI:ih
  5069. @end example
  5070. @item
  5071. Increase the height, and set the width to 3/2 of the height:
  5072. @example
  5073. scale=w=3/2*oh:h=3/5*ih
  5074. @end example
  5075. @item
  5076. Increase the size, but make the size a multiple of the chroma
  5077. subsample values:
  5078. @example
  5079. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  5080. @end example
  5081. @item
  5082. Increase the width to a maximum of 500 pixels, keep the same input
  5083. aspect ratio:
  5084. @example
  5085. scale=w='min(500\, iw*3/2):h=-1'
  5086. @end example
  5087. @end itemize
  5088. @section separatefields
  5089. The @code{separatefields} takes a frame-based video input and splits
  5090. each frame into its components fields, producing a new half height clip
  5091. with twice the frame rate and twice the frame count.
  5092. This filter use field-dominance information in frame to decide which
  5093. of each pair of fields to place first in the output.
  5094. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  5095. @section setdar, setsar
  5096. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  5097. output video.
  5098. This is done by changing the specified Sample (aka Pixel) Aspect
  5099. Ratio, according to the following equation:
  5100. @example
  5101. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  5102. @end example
  5103. Keep in mind that the @code{setdar} filter does not modify the pixel
  5104. dimensions of the video frame. Also the display aspect ratio set by
  5105. this filter may be changed by later filters in the filterchain,
  5106. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  5107. applied.
  5108. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  5109. the filter output video.
  5110. Note that as a consequence of the application of this filter, the
  5111. output display aspect ratio will change according to the equation
  5112. above.
  5113. Keep in mind that the sample aspect ratio set by the @code{setsar}
  5114. filter may be changed by later filters in the filterchain, e.g. if
  5115. another "setsar" or a "setdar" filter is applied.
  5116. The filters accept the following options:
  5117. @table @option
  5118. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  5119. Set the aspect ratio used by the filter.
  5120. The parameter can be a floating point number string, an expression, or
  5121. a string of the form @var{num}:@var{den}, where @var{num} and
  5122. @var{den} are the numerator and denominator of the aspect ratio. If
  5123. the parameter is not specified, it is assumed the value "0".
  5124. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  5125. should be escaped.
  5126. @item max
  5127. Set the maximum integer value to use for expressing numerator and
  5128. denominator when reducing the expressed aspect ratio to a rational.
  5129. Default value is @code{100}.
  5130. @end table
  5131. @subsection Examples
  5132. @itemize
  5133. @item
  5134. To change the display aspect ratio to 16:9, specify one of the following:
  5135. @example
  5136. setdar=dar=1.77777
  5137. setdar=dar=16/9
  5138. setdar=dar=1.77777
  5139. @end example
  5140. @item
  5141. To change the sample aspect ratio to 10:11, specify:
  5142. @example
  5143. setsar=sar=10/11
  5144. @end example
  5145. @item
  5146. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  5147. 1000 in the aspect ratio reduction, use the command:
  5148. @example
  5149. setdar=ratio=16/9:max=1000
  5150. @end example
  5151. @end itemize
  5152. @anchor{setfield}
  5153. @section setfield
  5154. Force field for the output video frame.
  5155. The @code{setfield} filter marks the interlace type field for the
  5156. output frames. It does not change the input frame, but only sets the
  5157. corresponding property, which affects how the frame is treated by
  5158. following filters (e.g. @code{fieldorder} or @code{yadif}).
  5159. The filter accepts the following options:
  5160. @table @option
  5161. @item mode
  5162. Available values are:
  5163. @table @samp
  5164. @item auto
  5165. Keep the same field property.
  5166. @item bff
  5167. Mark the frame as bottom-field-first.
  5168. @item tff
  5169. Mark the frame as top-field-first.
  5170. @item prog
  5171. Mark the frame as progressive.
  5172. @end table
  5173. @end table
  5174. @section showinfo
  5175. Show a line containing various information for each input video frame.
  5176. The input video is not modified.
  5177. The shown line contains a sequence of key/value pairs of the form
  5178. @var{key}:@var{value}.
  5179. A description of each shown parameter follows:
  5180. @table @option
  5181. @item n
  5182. sequential number of the input frame, starting from 0
  5183. @item pts
  5184. Presentation TimeStamp of the input frame, expressed as a number of
  5185. time base units. The time base unit depends on the filter input pad.
  5186. @item pts_time
  5187. Presentation TimeStamp of the input frame, expressed as a number of
  5188. seconds
  5189. @item pos
  5190. position of the frame in the input stream, -1 if this information in
  5191. unavailable and/or meaningless (for example in case of synthetic video)
  5192. @item fmt
  5193. pixel format name
  5194. @item sar
  5195. sample aspect ratio of the input frame, expressed in the form
  5196. @var{num}/@var{den}
  5197. @item s
  5198. size of the input frame, expressed in the form
  5199. @var{width}x@var{height}
  5200. @item i
  5201. interlaced mode ("P" for "progressive", "T" for top field first, "B"
  5202. for bottom field first)
  5203. @item iskey
  5204. 1 if the frame is a key frame, 0 otherwise
  5205. @item type
  5206. picture type of the input frame ("I" for an I-frame, "P" for a
  5207. P-frame, "B" for a B-frame, "?" for unknown type).
  5208. Check also the documentation of the @code{AVPictureType} enum and of
  5209. the @code{av_get_picture_type_char} function defined in
  5210. @file{libavutil/avutil.h}.
  5211. @item checksum
  5212. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  5213. @item plane_checksum
  5214. Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  5215. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]"
  5216. @end table
  5217. @anchor{smartblur}
  5218. @section smartblur
  5219. Blur the input video without impacting the outlines.
  5220. The filter accepts the following options:
  5221. @table @option
  5222. @item luma_radius, lr
  5223. Set the luma radius. The option value must be a float number in
  5224. the range [0.1,5.0] that specifies the variance of the gaussian filter
  5225. used to blur the image (slower if larger). Default value is 1.0.
  5226. @item luma_strength, ls
  5227. Set the luma strength. The option value must be a float number
  5228. in the range [-1.0,1.0] that configures the blurring. A value included
  5229. in [0.0,1.0] will blur the image whereas a value included in
  5230. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  5231. @item luma_threshold, lt
  5232. Set the luma threshold used as a coefficient to determine
  5233. whether a pixel should be blurred or not. The option value must be an
  5234. integer in the range [-30,30]. A value of 0 will filter all the image,
  5235. a value included in [0,30] will filter flat areas and a value included
  5236. in [-30,0] will filter edges. Default value is 0.
  5237. @item chroma_radius, cr
  5238. Set the chroma radius. The option value must be a float number in
  5239. the range [0.1,5.0] that specifies the variance of the gaussian filter
  5240. used to blur the image (slower if larger). Default value is 1.0.
  5241. @item chroma_strength, cs
  5242. Set the chroma strength. The option value must be a float number
  5243. in the range [-1.0,1.0] that configures the blurring. A value included
  5244. in [0.0,1.0] will blur the image whereas a value included in
  5245. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  5246. @item chroma_threshold, ct
  5247. Set the chroma threshold used as a coefficient to determine
  5248. whether a pixel should be blurred or not. The option value must be an
  5249. integer in the range [-30,30]. A value of 0 will filter all the image,
  5250. a value included in [0,30] will filter flat areas and a value included
  5251. in [-30,0] will filter edges. Default value is 0.
  5252. @end table
  5253. If a chroma option is not explicitly set, the corresponding luma value
  5254. is set.
  5255. @section stereo3d
  5256. Convert between different stereoscopic image formats.
  5257. The filters accept the following options:
  5258. @table @option
  5259. @item in
  5260. Set stereoscopic image format of input.
  5261. Available values for input image formats are:
  5262. @table @samp
  5263. @item sbsl
  5264. side by side parallel (left eye left, right eye right)
  5265. @item sbsr
  5266. side by side crosseye (right eye left, left eye right)
  5267. @item sbs2l
  5268. side by side parallel with half width resolution
  5269. (left eye left, right eye right)
  5270. @item sbs2r
  5271. side by side crosseye with half width resolution
  5272. (right eye left, left eye right)
  5273. @item abl
  5274. above-below (left eye above, right eye below)
  5275. @item abr
  5276. above-below (right eye above, left eye below)
  5277. @item ab2l
  5278. above-below with half height resolution
  5279. (left eye above, right eye below)
  5280. @item ab2r
  5281. above-below with half height resolution
  5282. (right eye above, left eye below)
  5283. @item al
  5284. alternating frames (left eye first, right eye second)
  5285. @item ar
  5286. alternating frames (right eye first, left eye second)
  5287. Default value is @samp{sbsl}.
  5288. @end table
  5289. @item out
  5290. Set stereoscopic image format of output.
  5291. Available values for output image formats are all the input formats as well as:
  5292. @table @samp
  5293. @item arbg
  5294. anaglyph red/blue gray
  5295. (red filter on left eye, blue filter on right eye)
  5296. @item argg
  5297. anaglyph red/green gray
  5298. (red filter on left eye, green filter on right eye)
  5299. @item arcg
  5300. anaglyph red/cyan gray
  5301. (red filter on left eye, cyan filter on right eye)
  5302. @item arch
  5303. anaglyph red/cyan half colored
  5304. (red filter on left eye, cyan filter on right eye)
  5305. @item arcc
  5306. anaglyph red/cyan color
  5307. (red filter on left eye, cyan filter on right eye)
  5308. @item arcd
  5309. anaglyph red/cyan color optimized with the least squares projection of dubois
  5310. (red filter on left eye, cyan filter on right eye)
  5311. @item agmg
  5312. anaglyph green/magenta gray
  5313. (green filter on left eye, magenta filter on right eye)
  5314. @item agmh
  5315. anaglyph green/magenta half colored
  5316. (green filter on left eye, magenta filter on right eye)
  5317. @item agmc
  5318. anaglyph green/magenta colored
  5319. (green filter on left eye, magenta filter on right eye)
  5320. @item agmd
  5321. anaglyph green/magenta color optimized with the least squares projection of dubois
  5322. (green filter on left eye, magenta filter on right eye)
  5323. @item aybg
  5324. anaglyph yellow/blue gray
  5325. (yellow filter on left eye, blue filter on right eye)
  5326. @item aybh
  5327. anaglyph yellow/blue half colored
  5328. (yellow filter on left eye, blue filter on right eye)
  5329. @item aybc
  5330. anaglyph yellow/blue colored
  5331. (yellow filter on left eye, blue filter on right eye)
  5332. @item aybd
  5333. anaglyph yellow/blue color optimized with the least squares projection of dubois
  5334. (yellow filter on left eye, blue filter on right eye)
  5335. @item irl
  5336. interleaved rows (left eye has top row, right eye starts on next row)
  5337. @item irr
  5338. interleaved rows (right eye has top row, left eye starts on next row)
  5339. @item ml
  5340. mono output (left eye only)
  5341. @item mr
  5342. mono output (right eye only)
  5343. @end table
  5344. Default value is @samp{arcd}.
  5345. @end table
  5346. @subsection Examples
  5347. @itemize
  5348. @item
  5349. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  5350. @example
  5351. stereo3d=sbsl:aybd
  5352. @end example
  5353. @item
  5354. Convert input video from above bellow (left eye above, right eye below) to side by side crosseye.
  5355. @example
  5356. stereo3d=abl:sbsr
  5357. @end example
  5358. @end itemize
  5359. @section spp
  5360. Apply a simple postprocessing filter that compresses and decompresses the image
  5361. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  5362. and average the results.
  5363. The filter accepts the following options:
  5364. @table @option
  5365. @item quality
  5366. Set quality. This option defines the number of levels for averaging. It accepts
  5367. an integer in the range 0-6. If set to @code{0}, the filter will have no
  5368. effect. A value of @code{6} means the higher quality. For each increment of
  5369. that value the speed drops by a factor of approximately 2. Default value is
  5370. @code{3}.
  5371. @item qp
  5372. Force a constant quantization parameter. If not set, the filter will use the QP
  5373. from the video stream (if available).
  5374. @item mode
  5375. Set thresholding mode. Available modes are:
  5376. @table @samp
  5377. @item hard
  5378. Set hard thresholding (default).
  5379. @item soft
  5380. Set soft thresholding (better de-ringing effect, but likely blurrier).
  5381. @end table
  5382. @item use_bframe_qp
  5383. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  5384. option may cause flicker since the B-Frames have often larger QP. Default is
  5385. @code{0} (not enabled).
  5386. @end table
  5387. @anchor{subtitles}
  5388. @section subtitles
  5389. Draw subtitles on top of input video using the libass library.
  5390. To enable compilation of this filter you need to configure FFmpeg with
  5391. @code{--enable-libass}. This filter also requires a build with libavcodec and
  5392. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  5393. Alpha) subtitles format.
  5394. The filter accepts the following options:
  5395. @table @option
  5396. @item filename, f
  5397. Set the filename of the subtitle file to read. It must be specified.
  5398. @item original_size
  5399. Specify the size of the original video, the video for which the ASS file
  5400. was composed. Due to a misdesign in ASS aspect ratio arithmetic, this is
  5401. necessary to correctly scale the fonts if the aspect ratio has been changed.
  5402. @item charenc
  5403. Set subtitles input character encoding. @code{subtitles} filter only. Only
  5404. useful if not UTF-8.
  5405. @end table
  5406. If the first key is not specified, it is assumed that the first value
  5407. specifies the @option{filename}.
  5408. For example, to render the file @file{sub.srt} on top of the input
  5409. video, use the command:
  5410. @example
  5411. subtitles=sub.srt
  5412. @end example
  5413. which is equivalent to:
  5414. @example
  5415. subtitles=filename=sub.srt
  5416. @end example
  5417. @section super2xsai
  5418. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  5419. Interpolate) pixel art scaling algorithm.
  5420. Useful for enlarging pixel art images without reducing sharpness.
  5421. @section swapuv
  5422. Swap U & V plane.
  5423. @section telecine
  5424. Apply telecine process to the video.
  5425. This filter accepts the following options:
  5426. @table @option
  5427. @item first_field
  5428. @table @samp
  5429. @item top, t
  5430. top field first
  5431. @item bottom, b
  5432. bottom field first
  5433. The default value is @code{top}.
  5434. @end table
  5435. @item pattern
  5436. A string of numbers representing the pulldown pattern you wish to apply.
  5437. The default value is @code{23}.
  5438. @end table
  5439. @example
  5440. Some typical patterns:
  5441. NTSC output (30i):
  5442. 27.5p: 32222
  5443. 24p: 23 (classic)
  5444. 24p: 2332 (preferred)
  5445. 20p: 33
  5446. 18p: 334
  5447. 16p: 3444
  5448. PAL output (25i):
  5449. 27.5p: 12222
  5450. 24p: 222222222223 ("Euro pulldown")
  5451. 16.67p: 33
  5452. 16p: 33333334
  5453. @end example
  5454. @section thumbnail
  5455. Select the most representative frame in a given sequence of consecutive frames.
  5456. The filter accepts the following options:
  5457. @table @option
  5458. @item n
  5459. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  5460. will pick one of them, and then handle the next batch of @var{n} frames until
  5461. the end. Default is @code{100}.
  5462. @end table
  5463. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  5464. value will result in a higher memory usage, so a high value is not recommended.
  5465. @subsection Examples
  5466. @itemize
  5467. @item
  5468. Extract one picture each 50 frames:
  5469. @example
  5470. thumbnail=50
  5471. @end example
  5472. @item
  5473. Complete example of a thumbnail creation with @command{ffmpeg}:
  5474. @example
  5475. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  5476. @end example
  5477. @end itemize
  5478. @section tile
  5479. Tile several successive frames together.
  5480. The filter accepts the following options:
  5481. @table @option
  5482. @item layout
  5483. Set the grid size (i.e. the number of lines and columns) in the form
  5484. "@var{w}x@var{h}".
  5485. @item nb_frames
  5486. Set the maximum number of frames to render in the given area. It must be less
  5487. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  5488. the area will be used.
  5489. @item margin
  5490. Set the outer border margin in pixels.
  5491. @item padding
  5492. Set the inner border thickness (i.e. the number of pixels between frames). For
  5493. more advanced padding options (such as having different values for the edges),
  5494. refer to the pad video filter.
  5495. @item color
  5496. Specify the color of the unused area, it can be the name of a color
  5497. (case insensitive match) or a 0xRRGGBB[AA] sequence.
  5498. The default value of @var{color} is "black".
  5499. @end table
  5500. @subsection Examples
  5501. @itemize
  5502. @item
  5503. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  5504. @example
  5505. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  5506. @end example
  5507. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  5508. duplicating each output frame to accomodate the originally detected frame
  5509. rate.
  5510. @item
  5511. Display @code{5} pictures in an area of @code{3x2} frames,
  5512. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  5513. mixed flat and named options:
  5514. @example
  5515. tile=3x2:nb_frames=5:padding=7:margin=2
  5516. @end example
  5517. @end itemize
  5518. @section tinterlace
  5519. Perform various types of temporal field interlacing.
  5520. Frames are counted starting from 1, so the first input frame is
  5521. considered odd.
  5522. The filter accepts the following options:
  5523. @table @option
  5524. @item mode
  5525. Specify the mode of the interlacing. This option can also be specified
  5526. as a value alone. See below for a list of values for this option.
  5527. Available values are:
  5528. @table @samp
  5529. @item merge, 0
  5530. Move odd frames into the upper field, even into the lower field,
  5531. generating a double height frame at half frame rate.
  5532. @item drop_odd, 1
  5533. Only output even frames, odd frames are dropped, generating a frame with
  5534. unchanged height at half frame rate.
  5535. @item drop_even, 2
  5536. Only output odd frames, even frames are dropped, generating a frame with
  5537. unchanged height at half frame rate.
  5538. @item pad, 3
  5539. Expand each frame to full height, but pad alternate lines with black,
  5540. generating a frame with double height at the same input frame rate.
  5541. @item interleave_top, 4
  5542. Interleave the upper field from odd frames with the lower field from
  5543. even frames, generating a frame with unchanged height at half frame rate.
  5544. @item interleave_bottom, 5
  5545. Interleave the lower field from odd frames with the upper field from
  5546. even frames, generating a frame with unchanged height at half frame rate.
  5547. @item interlacex2, 6
  5548. Double frame rate with unchanged height. Frames are inserted each
  5549. containing the second temporal field from the previous input frame and
  5550. the first temporal field from the next input frame. This mode relies on
  5551. the top_field_first flag. Useful for interlaced video displays with no
  5552. field synchronisation.
  5553. @end table
  5554. Numeric values are deprecated but are accepted for backward
  5555. compatibility reasons.
  5556. Default mode is @code{merge}.
  5557. @item flags
  5558. Specify flags influencing the filter process.
  5559. Available value for @var{flags} is:
  5560. @table @option
  5561. @item low_pass_filter, vlfp
  5562. Enable vertical low-pass filtering in the filter.
  5563. Vertical low-pass filtering is required when creating an interlaced
  5564. destination from a progressive source which contains high-frequency
  5565. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  5566. patterning.
  5567. Vertical low-pass filtering can only be enabled for @option{mode}
  5568. @var{interleave_top} and @var{interleave_bottom}.
  5569. @end table
  5570. @end table
  5571. @section transpose
  5572. Transpose rows with columns in the input video and optionally flip it.
  5573. This filter accepts the following options:
  5574. @table @option
  5575. @item dir
  5576. Specify the transposition direction.
  5577. Can assume the following values:
  5578. @table @samp
  5579. @item 0, 4, cclock_flip
  5580. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  5581. @example
  5582. L.R L.l
  5583. . . -> . .
  5584. l.r R.r
  5585. @end example
  5586. @item 1, 5, clock
  5587. Rotate by 90 degrees clockwise, that is:
  5588. @example
  5589. L.R l.L
  5590. . . -> . .
  5591. l.r r.R
  5592. @end example
  5593. @item 2, 6, cclock
  5594. Rotate by 90 degrees counterclockwise, that is:
  5595. @example
  5596. L.R R.r
  5597. . . -> . .
  5598. l.r L.l
  5599. @end example
  5600. @item 3, 7, clock_flip
  5601. Rotate by 90 degrees clockwise and vertically flip, that is:
  5602. @example
  5603. L.R r.R
  5604. . . -> . .
  5605. l.r l.L
  5606. @end example
  5607. @end table
  5608. For values between 4-7, the transposition is only done if the input
  5609. video geometry is portrait and not landscape. These values are
  5610. deprecated, the @code{passthrough} option should be used instead.
  5611. Numerical values are deprecated, and should be dropped in favor of
  5612. symbolic constants.
  5613. @item passthrough
  5614. Do not apply the transposition if the input geometry matches the one
  5615. specified by the specified value. It accepts the following values:
  5616. @table @samp
  5617. @item none
  5618. Always apply transposition.
  5619. @item portrait
  5620. Preserve portrait geometry (when @var{height} >= @var{width}).
  5621. @item landscape
  5622. Preserve landscape geometry (when @var{width} >= @var{height}).
  5623. @end table
  5624. Default value is @code{none}.
  5625. @end table
  5626. For example to rotate by 90 degrees clockwise and preserve portrait
  5627. layout:
  5628. @example
  5629. transpose=dir=1:passthrough=portrait
  5630. @end example
  5631. The command above can also be specified as:
  5632. @example
  5633. transpose=1:portrait
  5634. @end example
  5635. @section trim
  5636. Trim the input so that the output contains one continuous subpart of the input.
  5637. This filter accepts the following options:
  5638. @table @option
  5639. @item start
  5640. Specify time of the start of the kept section, i.e. the frame with the
  5641. timestamp @var{start} will be the first frame in the output.
  5642. @item end
  5643. Specify time of the first frame that will be dropped, i.e. the frame
  5644. immediately preceding the one with the timestamp @var{end} will be the last
  5645. frame in the output.
  5646. @item start_pts
  5647. Same as @var{start}, except this option sets the start timestamp in timebase
  5648. units instead of seconds.
  5649. @item end_pts
  5650. Same as @var{end}, except this option sets the end timestamp in timebase units
  5651. instead of seconds.
  5652. @item duration
  5653. Specify maximum duration of the output.
  5654. @item start_frame
  5655. Number of the first frame that should be passed to output.
  5656. @item end_frame
  5657. Number of the first frame that should be dropped.
  5658. @end table
  5659. @option{start}, @option{end}, @option{duration} are expressed as time
  5660. duration specifications, check the "Time duration" section in the
  5661. ffmpeg-utils manual.
  5662. Note that the first two sets of the start/end options and the @option{duration}
  5663. option look at the frame timestamp, while the _frame variants simply count the
  5664. frames that pass through the filter. Also note that this filter does not modify
  5665. the timestamps. If you wish that the output timestamps start at zero, insert a
  5666. setpts filter after the trim filter.
  5667. If multiple start or end options are set, this filter tries to be greedy and
  5668. keep all the frames that match at least one of the specified constraints. To keep
  5669. only the part that matches all the constraints at once, chain multiple trim
  5670. filters.
  5671. The defaults are such that all the input is kept. So it is possible to set e.g.
  5672. just the end values to keep everything before the specified time.
  5673. Examples:
  5674. @itemize
  5675. @item
  5676. drop everything except the second minute of input
  5677. @example
  5678. ffmpeg -i INPUT -vf trim=60:120
  5679. @end example
  5680. @item
  5681. keep only the first second
  5682. @example
  5683. ffmpeg -i INPUT -vf trim=duration=1
  5684. @end example
  5685. @end itemize
  5686. @section unsharp
  5687. Sharpen or blur the input video.
  5688. It accepts the following parameters:
  5689. @table @option
  5690. @item luma_msize_x, lx
  5691. Set the luma matrix horizontal size. It must be an odd integer between
  5692. 3 and 63, default value is 5.
  5693. @item luma_msize_y, ly
  5694. Set the luma matrix vertical size. It must be an odd integer between 3
  5695. and 63, default value is 5.
  5696. @item luma_amount, la
  5697. Set the luma effect strength. It can be a float number, reasonable
  5698. values lay between -1.5 and 1.5.
  5699. Negative values will blur the input video, while positive values will
  5700. sharpen it, a value of zero will disable the effect.
  5701. Default value is 1.0.
  5702. @item chroma_msize_x, cx
  5703. Set the chroma matrix horizontal size. It must be an odd integer
  5704. between 3 and 63, default value is 5.
  5705. @item chroma_msize_y, cy
  5706. Set the chroma matrix vertical size. It must be an odd integer
  5707. between 3 and 63, default value is 5.
  5708. @item chroma_amount, ca
  5709. Set the chroma effect strength. It can be a float number, reasonable
  5710. values lay between -1.5 and 1.5.
  5711. Negative values will blur the input video, while positive values will
  5712. sharpen it, a value of zero will disable the effect.
  5713. Default value is 0.0.
  5714. @item opencl
  5715. If set to 1, specify using OpenCL capabilities, only available if
  5716. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  5717. @end table
  5718. All parameters are optional and default to the equivalent of the
  5719. string '5:5:1.0:5:5:0.0'.
  5720. @subsection Examples
  5721. @itemize
  5722. @item
  5723. Apply strong luma sharpen effect:
  5724. @example
  5725. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  5726. @end example
  5727. @item
  5728. Apply strong blur of both luma and chroma parameters:
  5729. @example
  5730. unsharp=7:7:-2:7:7:-2
  5731. @end example
  5732. @end itemize
  5733. @anchor{vidstabdetect}
  5734. @section vidstabdetect
  5735. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  5736. @ref{vidstabtransform} for pass 2.
  5737. This filter generates a file with relative translation and rotation
  5738. transform information about subsequent frames, which is then used by
  5739. the @ref{vidstabtransform} filter.
  5740. To enable compilation of this filter you need to configure FFmpeg with
  5741. @code{--enable-libvidstab}.
  5742. This filter accepts the following options:
  5743. @table @option
  5744. @item result
  5745. Set the path to the file used to write the transforms information.
  5746. Default value is @file{transforms.trf}.
  5747. @item shakiness
  5748. Set how shaky the video is and how quick the camera is. It accepts an
  5749. integer in the range 1-10, a value of 1 means little shakiness, a
  5750. value of 10 means strong shakiness. Default value is 5.
  5751. @item accuracy
  5752. Set the accuracy of the detection process. It must be a value in the
  5753. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  5754. accuracy. Default value is 9.
  5755. @item stepsize
  5756. Set stepsize of the search process. The region around minimum is
  5757. scanned with 1 pixel resolution. Default value is 6.
  5758. @item mincontrast
  5759. Set minimum contrast. Below this value a local measurement field is
  5760. discarded. Must be a floating point value in the range 0-1. Default
  5761. value is 0.3.
  5762. @item tripod
  5763. Set reference frame number for tripod mode.
  5764. If enabled, the motion of the frames is compared to a reference frame
  5765. in the filtered stream, identified by the specified number. The idea
  5766. is to compensate all movements in a more-or-less static scene and keep
  5767. the camera view absolutely still.
  5768. If set to 0, it is disabled. The frames are counted starting from 1.
  5769. @item show
  5770. Show fields and transforms in the resulting frames. It accepts an
  5771. integer in the range 0-2. Default value is 0, which disables any
  5772. visualization.
  5773. @end table
  5774. @subsection Examples
  5775. @itemize
  5776. @item
  5777. Use default values:
  5778. @example
  5779. vidstabdetect
  5780. @end example
  5781. @item
  5782. Analyze strongly shaky movie and put the results in file
  5783. @file{mytransforms.trf}:
  5784. @example
  5785. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  5786. @end example
  5787. @item
  5788. Visualize the result of internal transformations in the resulting
  5789. video:
  5790. @example
  5791. vidstabdetect=show=1
  5792. @end example
  5793. @item
  5794. Analyze a video with medium shakiness using @command{ffmpeg}:
  5795. @example
  5796. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  5797. @end example
  5798. @end itemize
  5799. @anchor{vidstabtransform}
  5800. @section vidstabtransform
  5801. Video stabilization/deshaking: pass 2 of 2,
  5802. see @ref{vidstabdetect} for pass 1.
  5803. Read a file with transform information for each frame and
  5804. apply/compensate them. Together with the @ref{vidstabdetect}
  5805. filter this can be used to deshake videos. See also
  5806. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  5807. the unsharp filter, see below.
  5808. To enable compilation of this filter you need to configure FFmpeg with
  5809. @code{--enable-libvidstab}.
  5810. This filter accepts the following options:
  5811. @table @option
  5812. @item input
  5813. path to the file used to read the transforms (default: @file{transforms.trf})
  5814. @item smoothing
  5815. number of frames (value*2 + 1) used for lowpass filtering the camera movements
  5816. (default: 10). For example a number of 10 means that 21 frames are used
  5817. (10 in the past and 10 in the future) to smoothen the motion in the
  5818. video. A larger values leads to a smoother video, but limits the
  5819. acceleration of the camera (pan/tilt movements).
  5820. @item maxshift
  5821. maximal number of pixels to translate frames (default: -1 no limit)
  5822. @item maxangle
  5823. maximal angle in radians (degree*PI/180) to rotate frames (default: -1
  5824. no limit)
  5825. @item crop
  5826. How to deal with borders that may be visible due to movement
  5827. compensation. Available values are:
  5828. @table @samp
  5829. @item keep
  5830. keep image information from previous frame (default)
  5831. @item black
  5832. fill the border black
  5833. @end table
  5834. @item invert
  5835. @table @samp
  5836. @item 0
  5837. keep transforms normal (default)
  5838. @item 1
  5839. invert transforms
  5840. @end table
  5841. @item relative
  5842. consider transforms as
  5843. @table @samp
  5844. @item 0
  5845. absolute
  5846. @item 1
  5847. relative to previous frame (default)
  5848. @end table
  5849. @item zoom
  5850. percentage to zoom (default: 0)
  5851. @table @samp
  5852. @item >0
  5853. zoom in
  5854. @item <0
  5855. zoom out
  5856. @end table
  5857. @item optzoom
  5858. if 1 then optimal zoom value is determined (default).
  5859. Optimal zoom means no (or only little) border should be visible.
  5860. Note that the value given at zoom is added to the one calculated
  5861. here.
  5862. @item interpol
  5863. type of interpolation
  5864. Available values are:
  5865. @table @samp
  5866. @item no
  5867. no interpolation
  5868. @item linear
  5869. linear only horizontal
  5870. @item bilinear
  5871. linear in both directions (default)
  5872. @item bicubic
  5873. cubic in both directions (slow)
  5874. @end table
  5875. @item tripod
  5876. virtual tripod mode means that the video is stabilized such that the
  5877. camera stays stationary. Use also @code{tripod} option of
  5878. @ref{vidstabdetect}.
  5879. @table @samp
  5880. @item 0
  5881. off (default)
  5882. @item 1
  5883. virtual tripod mode: equivalent to @code{relative=0:smoothing=0}
  5884. @end table
  5885. @end table
  5886. @subsection Examples
  5887. @itemize
  5888. @item
  5889. typical call with default default values:
  5890. (note the unsharp filter which is always recommended)
  5891. @example
  5892. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  5893. @end example
  5894. @item
  5895. zoom in a bit more and load transform data from a given file
  5896. @example
  5897. vidstabtransform=zoom=5:input="mytransforms.trf"
  5898. @end example
  5899. @item
  5900. smoothen the video even more
  5901. @example
  5902. vidstabtransform=smoothing=30
  5903. @end example
  5904. @end itemize
  5905. @section vflip
  5906. Flip the input video vertically.
  5907. For example, to vertically flip a video with @command{ffmpeg}:
  5908. @example
  5909. ffmpeg -i in.avi -vf "vflip" out.avi
  5910. @end example
  5911. @section vignette
  5912. Make or reverse a natural vignetting effect.
  5913. The filter accepts the following options:
  5914. @table @option
  5915. @item angle, a
  5916. Set lens angle expression as a number of radians.
  5917. The value is clipped in the @code{[0,PI/2]} range.
  5918. Default value: @code{"PI/5"}
  5919. @item x0
  5920. @item y0
  5921. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  5922. by default.
  5923. @item mode
  5924. Set forward/backward mode.
  5925. Available modes are:
  5926. @table @samp
  5927. @item forward
  5928. The larger the distance from the central point, the darker the image becomes.
  5929. @item backward
  5930. The larger the distance from the central point, the brighter the image becomes.
  5931. This can be used to reverse a vignette effect, though there is no automatic
  5932. detection to extract the lens @option{angle} and other settings (yet). It can
  5933. also be used to create a burning effect.
  5934. @end table
  5935. Default value is @samp{forward}.
  5936. @item eval
  5937. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  5938. It accepts the following values:
  5939. @table @samp
  5940. @item init
  5941. Evaluate expressions only once during the filter initialization.
  5942. @item frame
  5943. Evaluate expressions for each incoming frame. This is way slower than the
  5944. @samp{init} mode since it requires all the scalers to be re-computed, but it
  5945. allows advanced dynamic expressions.
  5946. @end table
  5947. Default value is @samp{init}.
  5948. @item dither
  5949. Set dithering to reduce the circular banding effects. Default is @code{1}
  5950. (enabled).
  5951. @item aspect
  5952. Set vignette aspect. This setting allows to adjust the shape of the vignette.
  5953. Setting this value to the SAR of the input will make a rectangular vignetting
  5954. following the dimensions of the video.
  5955. Default is @code{1/1}.
  5956. @end table
  5957. @subsection Expressions
  5958. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  5959. following parameters.
  5960. @table @option
  5961. @item w
  5962. @item h
  5963. input width and height
  5964. @item n
  5965. the number of input frame, starting from 0
  5966. @item pts
  5967. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  5968. @var{TB} units, NAN if undefined
  5969. @item r
  5970. frame rate of the input video, NAN if the input frame rate is unknown
  5971. @item t
  5972. the PTS (Presentation TimeStamp) of the filtered video frame,
  5973. expressed in seconds, NAN if undefined
  5974. @item tb
  5975. time base of the input video
  5976. @end table
  5977. @subsection Examples
  5978. @itemize
  5979. @item
  5980. Apply simple strong vignetting effect:
  5981. @example
  5982. vignette=PI/4
  5983. @end example
  5984. @item
  5985. Make a flickering vignetting:
  5986. @example
  5987. vignette='PI/4+random(1)*PI/50':eval=frame
  5988. @end example
  5989. @end itemize
  5990. @anchor{yadif}
  5991. @section yadif
  5992. Deinterlace the input video ("yadif" means "yet another deinterlacing
  5993. filter").
  5994. This filter accepts the following options:
  5995. @table @option
  5996. @item mode
  5997. The interlacing mode to adopt, accepts one of the following values:
  5998. @table @option
  5999. @item 0, send_frame
  6000. output 1 frame for each frame
  6001. @item 1, send_field
  6002. output 1 frame for each field
  6003. @item 2, send_frame_nospatial
  6004. like @code{send_frame} but skip spatial interlacing check
  6005. @item 3, send_field_nospatial
  6006. like @code{send_field} but skip spatial interlacing check
  6007. @end table
  6008. Default value is @code{send_frame}.
  6009. @item parity
  6010. The picture field parity assumed for the input interlaced video, accepts one of
  6011. the following values:
  6012. @table @option
  6013. @item 0, tff
  6014. assume top field first
  6015. @item 1, bff
  6016. assume bottom field first
  6017. @item -1, auto
  6018. enable automatic detection
  6019. @end table
  6020. Default value is @code{auto}.
  6021. If interlacing is unknown or decoder does not export this information,
  6022. top field first will be assumed.
  6023. @item deint
  6024. Specify which frames to deinterlace. Accept one of the following
  6025. values:
  6026. @table @option
  6027. @item 0, all
  6028. deinterlace all frames
  6029. @item 1, interlaced
  6030. only deinterlace frames marked as interlaced
  6031. @end table
  6032. Default value is @code{all}.
  6033. @end table
  6034. @c man end VIDEO FILTERS
  6035. @chapter Video Sources
  6036. @c man begin VIDEO SOURCES
  6037. Below is a description of the currently available video sources.
  6038. @section buffer
  6039. Buffer video frames, and make them available to the filter chain.
  6040. This source is mainly intended for a programmatic use, in particular
  6041. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  6042. This source accepts the following options:
  6043. @table @option
  6044. @item video_size
  6045. Specify the size (width and height) of the buffered video frames.
  6046. @item width
  6047. Input video width.
  6048. @item height
  6049. Input video height.
  6050. @item pix_fmt
  6051. A string representing the pixel format of the buffered video frames.
  6052. It may be a number corresponding to a pixel format, or a pixel format
  6053. name.
  6054. @item time_base
  6055. Specify the timebase assumed by the timestamps of the buffered frames.
  6056. @item frame_rate
  6057. Specify the frame rate expected for the video stream.
  6058. @item pixel_aspect, sar
  6059. Specify the sample aspect ratio assumed by the video frames.
  6060. @item sws_param
  6061. Specify the optional parameters to be used for the scale filter which
  6062. is automatically inserted when an input change is detected in the
  6063. input size or format.
  6064. @end table
  6065. For example:
  6066. @example
  6067. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  6068. @end example
  6069. will instruct the source to accept video frames with size 320x240 and
  6070. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  6071. square pixels (1:1 sample aspect ratio).
  6072. Since the pixel format with name "yuv410p" corresponds to the number 6
  6073. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  6074. this example corresponds to:
  6075. @example
  6076. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  6077. @end example
  6078. Alternatively, the options can be specified as a flat string, but this
  6079. syntax is deprecated:
  6080. @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}]
  6081. @section cellauto
  6082. Create a pattern generated by an elementary cellular automaton.
  6083. The initial state of the cellular automaton can be defined through the
  6084. @option{filename}, and @option{pattern} options. If such options are
  6085. not specified an initial state is created randomly.
  6086. At each new frame a new row in the video is filled with the result of
  6087. the cellular automaton next generation. The behavior when the whole
  6088. frame is filled is defined by the @option{scroll} option.
  6089. This source accepts the following options:
  6090. @table @option
  6091. @item filename, f
  6092. Read the initial cellular automaton state, i.e. the starting row, from
  6093. the specified file.
  6094. In the file, each non-whitespace character is considered an alive
  6095. cell, a newline will terminate the row, and further characters in the
  6096. file will be ignored.
  6097. @item pattern, p
  6098. Read the initial cellular automaton state, i.e. the starting row, from
  6099. the specified string.
  6100. Each non-whitespace character in the string is considered an alive
  6101. cell, a newline will terminate the row, and further characters in the
  6102. string will be ignored.
  6103. @item rate, r
  6104. Set the video rate, that is the number of frames generated per second.
  6105. Default is 25.
  6106. @item random_fill_ratio, ratio
  6107. Set the random fill ratio for the initial cellular automaton row. It
  6108. is a floating point number value ranging from 0 to 1, defaults to
  6109. 1/PHI.
  6110. This option is ignored when a file or a pattern is specified.
  6111. @item random_seed, seed
  6112. Set the seed for filling randomly the initial row, must be an integer
  6113. included between 0 and UINT32_MAX. If not specified, or if explicitly
  6114. set to -1, the filter will try to use a good random seed on a best
  6115. effort basis.
  6116. @item rule
  6117. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  6118. Default value is 110.
  6119. @item size, s
  6120. Set the size of the output video.
  6121. If @option{filename} or @option{pattern} is specified, the size is set
  6122. by default to the width of the specified initial state row, and the
  6123. height is set to @var{width} * PHI.
  6124. If @option{size} is set, it must contain the width of the specified
  6125. pattern string, and the specified pattern will be centered in the
  6126. larger row.
  6127. If a filename or a pattern string is not specified, the size value
  6128. defaults to "320x518" (used for a randomly generated initial state).
  6129. @item scroll
  6130. If set to 1, scroll the output upward when all the rows in the output
  6131. have been already filled. If set to 0, the new generated row will be
  6132. written over the top row just after the bottom row is filled.
  6133. Defaults to 1.
  6134. @item start_full, full
  6135. If set to 1, completely fill the output with generated rows before
  6136. outputting the first frame.
  6137. This is the default behavior, for disabling set the value to 0.
  6138. @item stitch
  6139. If set to 1, stitch the left and right row edges together.
  6140. This is the default behavior, for disabling set the value to 0.
  6141. @end table
  6142. @subsection Examples
  6143. @itemize
  6144. @item
  6145. Read the initial state from @file{pattern}, and specify an output of
  6146. size 200x400.
  6147. @example
  6148. cellauto=f=pattern:s=200x400
  6149. @end example
  6150. @item
  6151. Generate a random initial row with a width of 200 cells, with a fill
  6152. ratio of 2/3:
  6153. @example
  6154. cellauto=ratio=2/3:s=200x200
  6155. @end example
  6156. @item
  6157. Create a pattern generated by rule 18 starting by a single alive cell
  6158. centered on an initial row with width 100:
  6159. @example
  6160. cellauto=p=@@:s=100x400:full=0:rule=18
  6161. @end example
  6162. @item
  6163. Specify a more elaborated initial pattern:
  6164. @example
  6165. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  6166. @end example
  6167. @end itemize
  6168. @section mandelbrot
  6169. Generate a Mandelbrot set fractal, and progressively zoom towards the
  6170. point specified with @var{start_x} and @var{start_y}.
  6171. This source accepts the following options:
  6172. @table @option
  6173. @item end_pts
  6174. Set the terminal pts value. Default value is 400.
  6175. @item end_scale
  6176. Set the terminal scale value.
  6177. Must be a floating point value. Default value is 0.3.
  6178. @item inner
  6179. Set the inner coloring mode, that is the algorithm used to draw the
  6180. Mandelbrot fractal internal region.
  6181. It shall assume one of the following values:
  6182. @table @option
  6183. @item black
  6184. Set black mode.
  6185. @item convergence
  6186. Show time until convergence.
  6187. @item mincol
  6188. Set color based on point closest to the origin of the iterations.
  6189. @item period
  6190. Set period mode.
  6191. @end table
  6192. Default value is @var{mincol}.
  6193. @item bailout
  6194. Set the bailout value. Default value is 10.0.
  6195. @item maxiter
  6196. Set the maximum of iterations performed by the rendering
  6197. algorithm. Default value is 7189.
  6198. @item outer
  6199. Set outer coloring mode.
  6200. It shall assume one of following values:
  6201. @table @option
  6202. @item iteration_count
  6203. Set iteration cound mode.
  6204. @item normalized_iteration_count
  6205. set normalized iteration count mode.
  6206. @end table
  6207. Default value is @var{normalized_iteration_count}.
  6208. @item rate, r
  6209. Set frame rate, expressed as number of frames per second. Default
  6210. value is "25".
  6211. @item size, s
  6212. Set frame size. Default value is "640x480".
  6213. @item start_scale
  6214. Set the initial scale value. Default value is 3.0.
  6215. @item start_x
  6216. Set the initial x position. Must be a floating point value between
  6217. -100 and 100. Default value is -0.743643887037158704752191506114774.
  6218. @item start_y
  6219. Set the initial y position. Must be a floating point value between
  6220. -100 and 100. Default value is -0.131825904205311970493132056385139.
  6221. @end table
  6222. @section mptestsrc
  6223. Generate various test patterns, as generated by the MPlayer test filter.
  6224. The size of the generated video is fixed, and is 256x256.
  6225. This source is useful in particular for testing encoding features.
  6226. This source accepts the following options:
  6227. @table @option
  6228. @item rate, r
  6229. Specify the frame rate of the sourced video, as the number of frames
  6230. generated per second. It has to be a string in the format
  6231. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  6232. number or a valid video frame rate abbreviation. The default value is
  6233. "25".
  6234. @item duration, d
  6235. Set the video duration of the sourced video. The accepted syntax is:
  6236. @example
  6237. [-]HH:MM:SS[.m...]
  6238. [-]S+[.m...]
  6239. @end example
  6240. See also the function @code{av_parse_time()}.
  6241. If not specified, or the expressed duration is negative, the video is
  6242. supposed to be generated forever.
  6243. @item test, t
  6244. Set the number or the name of the test to perform. Supported tests are:
  6245. @table @option
  6246. @item dc_luma
  6247. @item dc_chroma
  6248. @item freq_luma
  6249. @item freq_chroma
  6250. @item amp_luma
  6251. @item amp_chroma
  6252. @item cbp
  6253. @item mv
  6254. @item ring1
  6255. @item ring2
  6256. @item all
  6257. @end table
  6258. Default value is "all", which will cycle through the list of all tests.
  6259. @end table
  6260. For example the following:
  6261. @example
  6262. testsrc=t=dc_luma
  6263. @end example
  6264. will generate a "dc_luma" test pattern.
  6265. @section frei0r_src
  6266. Provide a frei0r source.
  6267. To enable compilation of this filter you need to install the frei0r
  6268. header and configure FFmpeg with @code{--enable-frei0r}.
  6269. This source accepts the following options:
  6270. @table @option
  6271. @item size
  6272. The size of the video to generate, may be a string of the form
  6273. @var{width}x@var{height} or a frame size abbreviation.
  6274. @item framerate
  6275. Framerate of the generated video, may be a string of the form
  6276. @var{num}/@var{den} or a frame rate abbreviation.
  6277. @item filter_name
  6278. The name to the frei0r source to load. For more information regarding frei0r and
  6279. how to set the parameters read the section @ref{frei0r} in the description of
  6280. the video filters.
  6281. @item filter_params
  6282. A '|'-separated list of parameters to pass to the frei0r source.
  6283. @end table
  6284. For example, to generate a frei0r partik0l source with size 200x200
  6285. and frame rate 10 which is overlayed on the overlay filter main input:
  6286. @example
  6287. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  6288. @end example
  6289. @section life
  6290. Generate a life pattern.
  6291. This source is based on a generalization of John Conway's life game.
  6292. The sourced input represents a life grid, each pixel represents a cell
  6293. which can be in one of two possible states, alive or dead. Every cell
  6294. interacts with its eight neighbours, which are the cells that are
  6295. horizontally, vertically, or diagonally adjacent.
  6296. At each interaction the grid evolves according to the adopted rule,
  6297. which specifies the number of neighbor alive cells which will make a
  6298. cell stay alive or born. The @option{rule} option allows to specify
  6299. the rule to adopt.
  6300. This source accepts the following options:
  6301. @table @option
  6302. @item filename, f
  6303. Set the file from which to read the initial grid state. In the file,
  6304. each non-whitespace character is considered an alive cell, and newline
  6305. is used to delimit the end of each row.
  6306. If this option is not specified, the initial grid is generated
  6307. randomly.
  6308. @item rate, r
  6309. Set the video rate, that is the number of frames generated per second.
  6310. Default is 25.
  6311. @item random_fill_ratio, ratio
  6312. Set the random fill ratio for the initial random grid. It is a
  6313. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  6314. It is ignored when a file is specified.
  6315. @item random_seed, seed
  6316. Set the seed for filling the initial random grid, must be an integer
  6317. included between 0 and UINT32_MAX. If not specified, or if explicitly
  6318. set to -1, the filter will try to use a good random seed on a best
  6319. effort basis.
  6320. @item rule
  6321. Set the life rule.
  6322. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  6323. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  6324. @var{NS} specifies the number of alive neighbor cells which make a
  6325. live cell stay alive, and @var{NB} the number of alive neighbor cells
  6326. which make a dead cell to become alive (i.e. to "born").
  6327. "s" and "b" can be used in place of "S" and "B", respectively.
  6328. Alternatively a rule can be specified by an 18-bits integer. The 9
  6329. high order bits are used to encode the next cell state if it is alive
  6330. for each number of neighbor alive cells, the low order bits specify
  6331. the rule for "borning" new cells. Higher order bits encode for an
  6332. higher number of neighbor cells.
  6333. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  6334. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  6335. Default value is "S23/B3", which is the original Conway's game of life
  6336. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  6337. cells, and will born a new cell if there are three alive cells around
  6338. a dead cell.
  6339. @item size, s
  6340. Set the size of the output video.
  6341. If @option{filename} is specified, the size is set by default to the
  6342. same size of the input file. If @option{size} is set, it must contain
  6343. the size specified in the input file, and the initial grid defined in
  6344. that file is centered in the larger resulting area.
  6345. If a filename is not specified, the size value defaults to "320x240"
  6346. (used for a randomly generated initial grid).
  6347. @item stitch
  6348. If set to 1, stitch the left and right grid edges together, and the
  6349. top and bottom edges also. Defaults to 1.
  6350. @item mold
  6351. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  6352. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  6353. value from 0 to 255.
  6354. @item life_color
  6355. Set the color of living (or new born) cells.
  6356. @item death_color
  6357. Set the color of dead cells. If @option{mold} is set, this is the first color
  6358. used to represent a dead cell.
  6359. @item mold_color
  6360. Set mold color, for definitely dead and moldy cells.
  6361. @end table
  6362. @subsection Examples
  6363. @itemize
  6364. @item
  6365. Read a grid from @file{pattern}, and center it on a grid of size
  6366. 300x300 pixels:
  6367. @example
  6368. life=f=pattern:s=300x300
  6369. @end example
  6370. @item
  6371. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  6372. @example
  6373. life=ratio=2/3:s=200x200
  6374. @end example
  6375. @item
  6376. Specify a custom rule for evolving a randomly generated grid:
  6377. @example
  6378. life=rule=S14/B34
  6379. @end example
  6380. @item
  6381. Full example with slow death effect (mold) using @command{ffplay}:
  6382. @example
  6383. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  6384. @end example
  6385. @end itemize
  6386. @anchor{color}
  6387. @anchor{haldclutsrc}
  6388. @anchor{nullsrc}
  6389. @anchor{rgbtestsrc}
  6390. @anchor{smptebars}
  6391. @anchor{smptehdbars}
  6392. @anchor{testsrc}
  6393. @section color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  6394. The @code{color} source provides an uniformly colored input.
  6395. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  6396. @ref{haldclut} filter.
  6397. The @code{nullsrc} source returns unprocessed video frames. It is
  6398. mainly useful to be employed in analysis / debugging tools, or as the
  6399. source for filters which ignore the input data.
  6400. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  6401. detecting RGB vs BGR issues. You should see a red, green and blue
  6402. stripe from top to bottom.
  6403. The @code{smptebars} source generates a color bars pattern, based on
  6404. the SMPTE Engineering Guideline EG 1-1990.
  6405. The @code{smptehdbars} source generates a color bars pattern, based on
  6406. the SMPTE RP 219-2002.
  6407. The @code{testsrc} source generates a test video pattern, showing a
  6408. color pattern, a scrolling gradient and a timestamp. This is mainly
  6409. intended for testing purposes.
  6410. The sources accept the following options:
  6411. @table @option
  6412. @item color, c
  6413. Specify the color of the source, only available in the @code{color}
  6414. source. It can be the name of a color (case insensitive match) or a
  6415. 0xRRGGBB[AA] sequence, possibly followed by an alpha specifier. The
  6416. default value is "black".
  6417. @item level
  6418. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  6419. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  6420. pixels to be used as identity matrix for 3D lookup tables. Each component is
  6421. coded on a @code{1/(N*N)} scale.
  6422. @item size, s
  6423. Specify the size of the sourced video, it may be a string of the form
  6424. @var{width}x@var{height}, or the name of a size abbreviation. The
  6425. default value is "320x240".
  6426. This option is not available with the @code{haldclutsrc} filter.
  6427. @item rate, r
  6428. Specify the frame rate of the sourced video, as the number of frames
  6429. generated per second. It has to be a string in the format
  6430. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  6431. number or a valid video frame rate abbreviation. The default value is
  6432. "25".
  6433. @item sar
  6434. Set the sample aspect ratio of the sourced video.
  6435. @item duration, d
  6436. Set the video duration of the sourced video. The accepted syntax is:
  6437. @example
  6438. [-]HH[:MM[:SS[.m...]]]
  6439. [-]S+[.m...]
  6440. @end example
  6441. See also the function @code{av_parse_time()}.
  6442. If not specified, or the expressed duration is negative, the video is
  6443. supposed to be generated forever.
  6444. @item decimals, n
  6445. Set the number of decimals to show in the timestamp, only available in the
  6446. @code{testsrc} source.
  6447. The displayed timestamp value will correspond to the original
  6448. timestamp value multiplied by the power of 10 of the specified
  6449. value. Default value is 0.
  6450. @end table
  6451. For example the following:
  6452. @example
  6453. testsrc=duration=5.3:size=qcif:rate=10
  6454. @end example
  6455. will generate a video with a duration of 5.3 seconds, with size
  6456. 176x144 and a frame rate of 10 frames per second.
  6457. The following graph description will generate a red source
  6458. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  6459. frames per second.
  6460. @example
  6461. color=c=red@@0.2:s=qcif:r=10
  6462. @end example
  6463. If the input content is to be ignored, @code{nullsrc} can be used. The
  6464. following command generates noise in the luminance plane by employing
  6465. the @code{geq} filter:
  6466. @example
  6467. nullsrc=s=256x256, geq=random(1)*255:128:128
  6468. @end example
  6469. @subsection Commands
  6470. The @code{color} source supports the following commands:
  6471. @table @option
  6472. @item c, color
  6473. Set the color of the created image. Accepts the same syntax of the
  6474. corresponding @option{color} option.
  6475. @end table
  6476. @c man end VIDEO SOURCES
  6477. @chapter Video Sinks
  6478. @c man begin VIDEO SINKS
  6479. Below is a description of the currently available video sinks.
  6480. @section buffersink
  6481. Buffer video frames, and make them available to the end of the filter
  6482. graph.
  6483. This sink is mainly intended for a programmatic use, in particular
  6484. through the interface defined in @file{libavfilter/buffersink.h}
  6485. or the options system.
  6486. It accepts a pointer to an AVBufferSinkContext structure, which
  6487. defines the incoming buffers' formats, to be passed as the opaque
  6488. parameter to @code{avfilter_init_filter} for initialization.
  6489. @section nullsink
  6490. Null video sink, do absolutely nothing with the input video. It is
  6491. mainly useful as a template and to be employed in analysis / debugging
  6492. tools.
  6493. @c man end VIDEO SINKS
  6494. @chapter Multimedia Filters
  6495. @c man begin MULTIMEDIA FILTERS
  6496. Below is a description of the currently available multimedia filters.
  6497. @section avectorscope
  6498. Convert input audio to a video output, representing the audio vector
  6499. scope.
  6500. The filter is used to measure the difference between channels of stereo
  6501. audio stream. A monoaural signal, consisting of identical left and right
  6502. signal, results in straight vertical line. Any stereo separation is visible
  6503. as a deviation from this line, creating a Lissajous figure.
  6504. If the straight (or deviation from it) but horizontal line appears this
  6505. indicates that the left and right channels are out of phase.
  6506. The filter accepts the following options:
  6507. @table @option
  6508. @item mode, m
  6509. Set the vectorscope mode.
  6510. Available values are:
  6511. @table @samp
  6512. @item lissajous
  6513. Lissajous rotated by 45 degrees.
  6514. @item lissajous_xy
  6515. Same as above but not rotated.
  6516. @end table
  6517. Default value is @samp{lissajous}.
  6518. @item size, s
  6519. Set the video size for the output. Default value is @code{400x400}.
  6520. @item rate, r
  6521. Set the output frame rate. Default value is @code{25}.
  6522. @item rc
  6523. @item gc
  6524. @item bc
  6525. Specify the red, green and blue contrast. Default values are @code{40}, @code{160} and @code{80}.
  6526. Allowed range is @code{[0, 255]}.
  6527. @item rf
  6528. @item gf
  6529. @item bf
  6530. Specify the red, green and blue fade. Default values are @code{15}, @code{10} and @code{5}.
  6531. Allowed range is @code{[0, 255]}.
  6532. @item zoom
  6533. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  6534. @end table
  6535. @subsection Examples
  6536. @itemize
  6537. @item
  6538. Complete example using @command{ffplay}:
  6539. @example
  6540. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  6541. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  6542. @end example
  6543. @end itemize
  6544. @section concat
  6545. Concatenate audio and video streams, joining them together one after the
  6546. other.
  6547. The filter works on segments of synchronized video and audio streams. All
  6548. segments must have the same number of streams of each type, and that will
  6549. also be the number of streams at output.
  6550. The filter accepts the following options:
  6551. @table @option
  6552. @item n
  6553. Set the number of segments. Default is 2.
  6554. @item v
  6555. Set the number of output video streams, that is also the number of video
  6556. streams in each segment. Default is 1.
  6557. @item a
  6558. Set the number of output audio streams, that is also the number of video
  6559. streams in each segment. Default is 0.
  6560. @item unsafe
  6561. Activate unsafe mode: do not fail if segments have a different format.
  6562. @end table
  6563. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  6564. @var{a} audio outputs.
  6565. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  6566. segment, in the same order as the outputs, then the inputs for the second
  6567. segment, etc.
  6568. Related streams do not always have exactly the same duration, for various
  6569. reasons including codec frame size or sloppy authoring. For that reason,
  6570. related synchronized streams (e.g. a video and its audio track) should be
  6571. concatenated at once. The concat filter will use the duration of the longest
  6572. stream in each segment (except the last one), and if necessary pad shorter
  6573. audio streams with silence.
  6574. For this filter to work correctly, all segments must start at timestamp 0.
  6575. All corresponding streams must have the same parameters in all segments; the
  6576. filtering system will automatically select a common pixel format for video
  6577. streams, and a common sample format, sample rate and channel layout for
  6578. audio streams, but other settings, such as resolution, must be converted
  6579. explicitly by the user.
  6580. Different frame rates are acceptable but will result in variable frame rate
  6581. at output; be sure to configure the output file to handle it.
  6582. @subsection Examples
  6583. @itemize
  6584. @item
  6585. Concatenate an opening, an episode and an ending, all in bilingual version
  6586. (video in stream 0, audio in streams 1 and 2):
  6587. @example
  6588. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  6589. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  6590. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  6591. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  6592. @end example
  6593. @item
  6594. Concatenate two parts, handling audio and video separately, using the
  6595. (a)movie sources, and adjusting the resolution:
  6596. @example
  6597. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  6598. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  6599. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  6600. @end example
  6601. Note that a desync will happen at the stitch if the audio and video streams
  6602. do not have exactly the same duration in the first file.
  6603. @end itemize
  6604. @section ebur128
  6605. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  6606. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  6607. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  6608. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  6609. The filter also has a video output (see the @var{video} option) with a real
  6610. time graph to observe the loudness evolution. The graphic contains the logged
  6611. message mentioned above, so it is not printed anymore when this option is set,
  6612. unless the verbose logging is set. The main graphing area contains the
  6613. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  6614. the momentary loudness (400 milliseconds).
  6615. More information about the Loudness Recommendation EBU R128 on
  6616. @url{http://tech.ebu.ch/loudness}.
  6617. The filter accepts the following options:
  6618. @table @option
  6619. @item video
  6620. Activate the video output. The audio stream is passed unchanged whether this
  6621. option is set or no. The video stream will be the first output stream if
  6622. activated. Default is @code{0}.
  6623. @item size
  6624. Set the video size. This option is for video only. Default and minimum
  6625. resolution is @code{640x480}.
  6626. @item meter
  6627. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  6628. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  6629. other integer value between this range is allowed.
  6630. @item metadata
  6631. Set metadata injection. If set to @code{1}, the audio input will be segmented
  6632. into 100ms output frames, each of them containing various loudness information
  6633. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  6634. Default is @code{0}.
  6635. @item framelog
  6636. Force the frame logging level.
  6637. Available values are:
  6638. @table @samp
  6639. @item info
  6640. information logging level
  6641. @item verbose
  6642. verbose logging level
  6643. @end table
  6644. By default, the logging level is set to @var{info}. If the @option{video} or
  6645. the @option{metadata} options are set, it switches to @var{verbose}.
  6646. @end table
  6647. @subsection Examples
  6648. @itemize
  6649. @item
  6650. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  6651. @example
  6652. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  6653. @end example
  6654. @item
  6655. Run an analysis with @command{ffmpeg}:
  6656. @example
  6657. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  6658. @end example
  6659. @end itemize
  6660. @section interleave, ainterleave
  6661. Temporally interleave frames from several inputs.
  6662. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  6663. These filters read frames from several inputs and send the oldest
  6664. queued frame to the output.
  6665. Input streams must have a well defined, monotonically increasing frame
  6666. timestamp values.
  6667. In order to submit one frame to output, these filters need to enqueue
  6668. at least one frame for each input, so they cannot work in case one
  6669. input is not yet terminated and will not receive incoming frames.
  6670. For example consider the case when one input is a @code{select} filter
  6671. which always drop input frames. The @code{interleave} filter will keep
  6672. reading from that input, but it will never be able to send new frames
  6673. to output until the input will send an end-of-stream signal.
  6674. Also, depending on inputs synchronization, the filters will drop
  6675. frames in case one input receives more frames than the other ones, and
  6676. the queue is already filled.
  6677. These filters accept the following options:
  6678. @table @option
  6679. @item nb_inputs, n
  6680. Set the number of different inputs, it is 2 by default.
  6681. @end table
  6682. @subsection Examples
  6683. @itemize
  6684. @item
  6685. Interleave frames belonging to different streams using @command{ffmpeg}:
  6686. @example
  6687. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  6688. @end example
  6689. @item
  6690. Add flickering blur effect:
  6691. @example
  6692. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  6693. @end example
  6694. @end itemize
  6695. @section perms, aperms
  6696. Set read/write permissions for the output frames.
  6697. These filters are mainly aimed at developers to test direct path in the
  6698. following filter in the filtergraph.
  6699. The filters accept the following options:
  6700. @table @option
  6701. @item mode
  6702. Select the permissions mode.
  6703. It accepts the following values:
  6704. @table @samp
  6705. @item none
  6706. Do nothing. This is the default.
  6707. @item ro
  6708. Set all the output frames read-only.
  6709. @item rw
  6710. Set all the output frames directly writable.
  6711. @item toggle
  6712. Make the frame read-only if writable, and writable if read-only.
  6713. @item random
  6714. Set each output frame read-only or writable randomly.
  6715. @end table
  6716. @item seed
  6717. Set the seed for the @var{random} mode, must be an integer included between
  6718. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  6719. @code{-1}, the filter will try to use a good random seed on a best effort
  6720. basis.
  6721. @end table
  6722. Note: in case of auto-inserted filter between the permission filter and the
  6723. following one, the permission might not be received as expected in that
  6724. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  6725. perms/aperms filter can avoid this problem.
  6726. @section select, aselect
  6727. Select frames to pass in output.
  6728. This filter accepts the following options:
  6729. @table @option
  6730. @item expr, e
  6731. Set expression, which is evaluated for each input frame.
  6732. If the expression is evaluated to zero, the frame is discarded.
  6733. If the evaluation result is negative or NaN, the frame is sent to the
  6734. first output; otherwise it is sent to the output with index
  6735. @code{ceil(val)-1}, assuming that the input index starts from 0.
  6736. For example a value of @code{1.2} corresponds to the output with index
  6737. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  6738. @item outputs, n
  6739. Set the number of outputs. The output to which to send the selected
  6740. frame is based on the result of the evaluation. Default value is 1.
  6741. @end table
  6742. The expression can contain the following constants:
  6743. @table @option
  6744. @item n
  6745. the sequential number of the filtered frame, starting from 0
  6746. @item selected_n
  6747. the sequential number of the selected frame, starting from 0
  6748. @item prev_selected_n
  6749. the sequential number of the last selected frame, NAN if undefined
  6750. @item TB
  6751. timebase of the input timestamps
  6752. @item pts
  6753. the PTS (Presentation TimeStamp) of the filtered video frame,
  6754. expressed in @var{TB} units, NAN if undefined
  6755. @item t
  6756. the PTS (Presentation TimeStamp) of the filtered video frame,
  6757. expressed in seconds, NAN if undefined
  6758. @item prev_pts
  6759. the PTS of the previously filtered video frame, NAN if undefined
  6760. @item prev_selected_pts
  6761. the PTS of the last previously filtered video frame, NAN if undefined
  6762. @item prev_selected_t
  6763. the PTS of the last previously selected video frame, NAN if undefined
  6764. @item start_pts
  6765. the PTS of the first video frame in the video, NAN if undefined
  6766. @item start_t
  6767. the time of the first video frame in the video, NAN if undefined
  6768. @item pict_type @emph{(video only)}
  6769. the type of the filtered frame, can assume one of the following
  6770. values:
  6771. @table @option
  6772. @item I
  6773. @item P
  6774. @item B
  6775. @item S
  6776. @item SI
  6777. @item SP
  6778. @item BI
  6779. @end table
  6780. @item interlace_type @emph{(video only)}
  6781. the frame interlace type, can assume one of the following values:
  6782. @table @option
  6783. @item PROGRESSIVE
  6784. the frame is progressive (not interlaced)
  6785. @item TOPFIRST
  6786. the frame is top-field-first
  6787. @item BOTTOMFIRST
  6788. the frame is bottom-field-first
  6789. @end table
  6790. @item consumed_sample_n @emph{(audio only)}
  6791. the number of selected samples before the current frame
  6792. @item samples_n @emph{(audio only)}
  6793. the number of samples in the current frame
  6794. @item sample_rate @emph{(audio only)}
  6795. the input sample rate
  6796. @item key
  6797. 1 if the filtered frame is a key-frame, 0 otherwise
  6798. @item pos
  6799. the position in the file of the filtered frame, -1 if the information
  6800. is not available (e.g. for synthetic video)
  6801. @item scene @emph{(video only)}
  6802. value between 0 and 1 to indicate a new scene; a low value reflects a low
  6803. probability for the current frame to introduce a new scene, while a higher
  6804. value means the current frame is more likely to be one (see the example below)
  6805. @end table
  6806. The default value of the select expression is "1".
  6807. @subsection Examples
  6808. @itemize
  6809. @item
  6810. Select all frames in input:
  6811. @example
  6812. select
  6813. @end example
  6814. The example above is the same as:
  6815. @example
  6816. select=1
  6817. @end example
  6818. @item
  6819. Skip all frames:
  6820. @example
  6821. select=0
  6822. @end example
  6823. @item
  6824. Select only I-frames:
  6825. @example
  6826. select='eq(pict_type\,I)'
  6827. @end example
  6828. @item
  6829. Select one frame every 100:
  6830. @example
  6831. select='not(mod(n\,100))'
  6832. @end example
  6833. @item
  6834. Select only frames contained in the 10-20 time interval:
  6835. @example
  6836. select='gte(t\,10)*lte(t\,20)'
  6837. @end example
  6838. @item
  6839. Select only I frames contained in the 10-20 time interval:
  6840. @example
  6841. select='gte(t\,10)*lte(t\,20)*eq(pict_type\,I)'
  6842. @end example
  6843. @item
  6844. Select frames with a minimum distance of 10 seconds:
  6845. @example
  6846. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  6847. @end example
  6848. @item
  6849. Use aselect to select only audio frames with samples number > 100:
  6850. @example
  6851. aselect='gt(samples_n\,100)'
  6852. @end example
  6853. @item
  6854. Create a mosaic of the first scenes:
  6855. @example
  6856. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  6857. @end example
  6858. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  6859. choice.
  6860. @item
  6861. Send even and odd frames to separate outputs, and compose them:
  6862. @example
  6863. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  6864. @end example
  6865. @end itemize
  6866. @section sendcmd, asendcmd
  6867. Send commands to filters in the filtergraph.
  6868. These filters read commands to be sent to other filters in the
  6869. filtergraph.
  6870. @code{sendcmd} must be inserted between two video filters,
  6871. @code{asendcmd} must be inserted between two audio filters, but apart
  6872. from that they act the same way.
  6873. The specification of commands can be provided in the filter arguments
  6874. with the @var{commands} option, or in a file specified by the
  6875. @var{filename} option.
  6876. These filters accept the following options:
  6877. @table @option
  6878. @item commands, c
  6879. Set the commands to be read and sent to the other filters.
  6880. @item filename, f
  6881. Set the filename of the commands to be read and sent to the other
  6882. filters.
  6883. @end table
  6884. @subsection Commands syntax
  6885. A commands description consists of a sequence of interval
  6886. specifications, comprising a list of commands to be executed when a
  6887. particular event related to that interval occurs. The occurring event
  6888. is typically the current frame time entering or leaving a given time
  6889. interval.
  6890. An interval is specified by the following syntax:
  6891. @example
  6892. @var{START}[-@var{END}] @var{COMMANDS};
  6893. @end example
  6894. The time interval is specified by the @var{START} and @var{END} times.
  6895. @var{END} is optional and defaults to the maximum time.
  6896. The current frame time is considered within the specified interval if
  6897. it is included in the interval [@var{START}, @var{END}), that is when
  6898. the time is greater or equal to @var{START} and is lesser than
  6899. @var{END}.
  6900. @var{COMMANDS} consists of a sequence of one or more command
  6901. specifications, separated by ",", relating to that interval. The
  6902. syntax of a command specification is given by:
  6903. @example
  6904. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  6905. @end example
  6906. @var{FLAGS} is optional and specifies the type of events relating to
  6907. the time interval which enable sending the specified command, and must
  6908. be a non-null sequence of identifier flags separated by "+" or "|" and
  6909. enclosed between "[" and "]".
  6910. The following flags are recognized:
  6911. @table @option
  6912. @item enter
  6913. The command is sent when the current frame timestamp enters the
  6914. specified interval. In other words, the command is sent when the
  6915. previous frame timestamp was not in the given interval, and the
  6916. current is.
  6917. @item leave
  6918. The command is sent when the current frame timestamp leaves the
  6919. specified interval. In other words, the command is sent when the
  6920. previous frame timestamp was in the given interval, and the
  6921. current is not.
  6922. @end table
  6923. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  6924. assumed.
  6925. @var{TARGET} specifies the target of the command, usually the name of
  6926. the filter class or a specific filter instance name.
  6927. @var{COMMAND} specifies the name of the command for the target filter.
  6928. @var{ARG} is optional and specifies the optional list of argument for
  6929. the given @var{COMMAND}.
  6930. Between one interval specification and another, whitespaces, or
  6931. sequences of characters starting with @code{#} until the end of line,
  6932. are ignored and can be used to annotate comments.
  6933. A simplified BNF description of the commands specification syntax
  6934. follows:
  6935. @example
  6936. @var{COMMAND_FLAG} ::= "enter" | "leave"
  6937. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  6938. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  6939. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  6940. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  6941. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  6942. @end example
  6943. @subsection Examples
  6944. @itemize
  6945. @item
  6946. Specify audio tempo change at second 4:
  6947. @example
  6948. asendcmd=c='4.0 atempo tempo 1.5',atempo
  6949. @end example
  6950. @item
  6951. Specify a list of drawtext and hue commands in a file.
  6952. @example
  6953. # show text in the interval 5-10
  6954. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  6955. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  6956. # desaturate the image in the interval 15-20
  6957. 15.0-20.0 [enter] hue s 0,
  6958. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  6959. [leave] hue s 1,
  6960. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  6961. # apply an exponential saturation fade-out effect, starting from time 25
  6962. 25 [enter] hue s exp(25-t)
  6963. @end example
  6964. A filtergraph allowing to read and process the above command list
  6965. stored in a file @file{test.cmd}, can be specified with:
  6966. @example
  6967. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  6968. @end example
  6969. @end itemize
  6970. @anchor{setpts}
  6971. @section setpts, asetpts
  6972. Change the PTS (presentation timestamp) of the input frames.
  6973. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  6974. This filter accepts the following options:
  6975. @table @option
  6976. @item expr
  6977. The expression which is evaluated for each frame to construct its timestamp.
  6978. @end table
  6979. The expression is evaluated through the eval API and can contain the following
  6980. constants:
  6981. @table @option
  6982. @item FRAME_RATE
  6983. frame rate, only defined for constant frame-rate video
  6984. @item PTS
  6985. the presentation timestamp in input
  6986. @item N
  6987. the count of the input frame for video or the number of consumed samples,
  6988. not including the current frame for audio, starting from 0.
  6989. @item NB_CONSUMED_SAMPLES
  6990. the number of consumed samples, not including the current frame (only
  6991. audio)
  6992. @item NB_SAMPLES, S
  6993. the number of samples in the current frame (only audio)
  6994. @item SAMPLE_RATE, SR
  6995. audio sample rate
  6996. @item STARTPTS
  6997. the PTS of the first frame
  6998. @item STARTT
  6999. the time in seconds of the first frame
  7000. @item INTERLACED
  7001. tell if the current frame is interlaced
  7002. @item T
  7003. the time in seconds of the current frame
  7004. @item POS
  7005. original position in the file of the frame, or undefined if undefined
  7006. for the current frame
  7007. @item PREV_INPTS
  7008. previous input PTS
  7009. @item PREV_INT
  7010. previous input time in seconds
  7011. @item PREV_OUTPTS
  7012. previous output PTS
  7013. @item PREV_OUTT
  7014. previous output time in seconds
  7015. @item RTCTIME
  7016. wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  7017. instead.
  7018. @item RTCSTART
  7019. wallclock (RTC) time at the start of the movie in microseconds
  7020. @item TB
  7021. timebase of the input timestamps
  7022. @end table
  7023. @subsection Examples
  7024. @itemize
  7025. @item
  7026. Start counting PTS from zero
  7027. @example
  7028. setpts=PTS-STARTPTS
  7029. @end example
  7030. @item
  7031. Apply fast motion effect:
  7032. @example
  7033. setpts=0.5*PTS
  7034. @end example
  7035. @item
  7036. Apply slow motion effect:
  7037. @example
  7038. setpts=2.0*PTS
  7039. @end example
  7040. @item
  7041. Set fixed rate of 25 frames per second:
  7042. @example
  7043. setpts=N/(25*TB)
  7044. @end example
  7045. @item
  7046. Set fixed rate 25 fps with some jitter:
  7047. @example
  7048. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  7049. @end example
  7050. @item
  7051. Apply an offset of 10 seconds to the input PTS:
  7052. @example
  7053. setpts=PTS+10/TB
  7054. @end example
  7055. @item
  7056. Generate timestamps from a "live source" and rebase onto the current timebase:
  7057. @example
  7058. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  7059. @end example
  7060. @item
  7061. Generate timestamps by counting samples:
  7062. @example
  7063. asetpts=N/SR/TB
  7064. @end example
  7065. @end itemize
  7066. @section settb, asettb
  7067. Set the timebase to use for the output frames timestamps.
  7068. It is mainly useful for testing timebase configuration.
  7069. This filter accepts the following options:
  7070. @table @option
  7071. @item expr, tb
  7072. The expression which is evaluated into the output timebase.
  7073. @end table
  7074. The value for @option{tb} is an arithmetic expression representing a
  7075. rational. The expression can contain the constants "AVTB" (the default
  7076. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  7077. audio only). Default value is "intb".
  7078. @subsection Examples
  7079. @itemize
  7080. @item
  7081. Set the timebase to 1/25:
  7082. @example
  7083. settb=expr=1/25
  7084. @end example
  7085. @item
  7086. Set the timebase to 1/10:
  7087. @example
  7088. settb=expr=0.1
  7089. @end example
  7090. @item
  7091. Set the timebase to 1001/1000:
  7092. @example
  7093. settb=1+0.001
  7094. @end example
  7095. @item
  7096. Set the timebase to 2*intb:
  7097. @example
  7098. settb=2*intb
  7099. @end example
  7100. @item
  7101. Set the default timebase value:
  7102. @example
  7103. settb=AVTB
  7104. @end example
  7105. @end itemize
  7106. @section showspectrum
  7107. Convert input audio to a video output, representing the audio frequency
  7108. spectrum.
  7109. The filter accepts the following options:
  7110. @table @option
  7111. @item size, s
  7112. Specify the video size for the output. Default value is @code{640x512}.
  7113. @item slide
  7114. Specify if the spectrum should slide along the window. Default value is
  7115. @code{0}.
  7116. @item mode
  7117. Specify display mode.
  7118. It accepts the following values:
  7119. @table @samp
  7120. @item combined
  7121. all channels are displayed in the same row
  7122. @item separate
  7123. all channels are displayed in separate rows
  7124. @end table
  7125. Default value is @samp{combined}.
  7126. @item color
  7127. Specify display color mode.
  7128. It accepts the following values:
  7129. @table @samp
  7130. @item channel
  7131. each channel is displayed in a separate color
  7132. @item intensity
  7133. each channel is is displayed using the same color scheme
  7134. @end table
  7135. Default value is @samp{channel}.
  7136. @item scale
  7137. Specify scale used for calculating intensity color values.
  7138. It accepts the following values:
  7139. @table @samp
  7140. @item lin
  7141. linear
  7142. @item sqrt
  7143. square root, default
  7144. @item cbrt
  7145. cubic root
  7146. @item log
  7147. logarithmic
  7148. @end table
  7149. Default value is @samp{sqrt}.
  7150. @item saturation
  7151. Set saturation modifier for displayed colors. Negative values provide
  7152. alternative color scheme. @code{0} is no saturation at all.
  7153. Saturation must be in [-10.0, 10.0] range.
  7154. Default value is @code{1}.
  7155. @end table
  7156. The usage is very similar to the showwaves filter; see the examples in that
  7157. section.
  7158. @subsection Examples
  7159. @itemize
  7160. @item
  7161. Large window with logarithmic color scaling:
  7162. @example
  7163. showspectrum=s=1280x480:scale=log
  7164. @end example
  7165. @item
  7166. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  7167. @example
  7168. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  7169. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  7170. @end example
  7171. @end itemize
  7172. @section showwaves
  7173. Convert input audio to a video output, representing the samples waves.
  7174. The filter accepts the following options:
  7175. @table @option
  7176. @item size, s
  7177. Specify the video size for the output. Default value is "600x240".
  7178. @item mode
  7179. Set display mode.
  7180. Available values are:
  7181. @table @samp
  7182. @item point
  7183. Draw a point for each sample.
  7184. @item line
  7185. Draw a vertical line for each sample.
  7186. @end table
  7187. Default value is @code{point}.
  7188. @item n
  7189. Set the number of samples which are printed on the same column. A
  7190. larger value will decrease the frame rate. Must be a positive
  7191. integer. This option can be set only if the value for @var{rate}
  7192. is not explicitly specified.
  7193. @item rate, r
  7194. Set the (approximate) output frame rate. This is done by setting the
  7195. option @var{n}. Default value is "25".
  7196. @end table
  7197. @subsection Examples
  7198. @itemize
  7199. @item
  7200. Output the input file audio and the corresponding video representation
  7201. at the same time:
  7202. @example
  7203. amovie=a.mp3,asplit[out0],showwaves[out1]
  7204. @end example
  7205. @item
  7206. Create a synthetic signal and show it with showwaves, forcing a
  7207. frame rate of 30 frames per second:
  7208. @example
  7209. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  7210. @end example
  7211. @end itemize
  7212. @section split, asplit
  7213. Split input into several identical outputs.
  7214. @code{asplit} works with audio input, @code{split} with video.
  7215. The filter accepts a single parameter which specifies the number of outputs. If
  7216. unspecified, it defaults to 2.
  7217. @subsection Examples
  7218. @itemize
  7219. @item
  7220. Create two separate outputs from the same input:
  7221. @example
  7222. [in] split [out0][out1]
  7223. @end example
  7224. @item
  7225. To create 3 or more outputs, you need to specify the number of
  7226. outputs, like in:
  7227. @example
  7228. [in] asplit=3 [out0][out1][out2]
  7229. @end example
  7230. @item
  7231. Create two separate outputs from the same input, one cropped and
  7232. one padded:
  7233. @example
  7234. [in] split [splitout1][splitout2];
  7235. [splitout1] crop=100:100:0:0 [cropout];
  7236. [splitout2] pad=200:200:100:100 [padout];
  7237. @end example
  7238. @item
  7239. Create 5 copies of the input audio with @command{ffmpeg}:
  7240. @example
  7241. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  7242. @end example
  7243. @end itemize
  7244. @section zmq, azmq
  7245. Receive commands sent through a libzmq client, and forward them to
  7246. filters in the filtergraph.
  7247. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  7248. must be inserted between two video filters, @code{azmq} between two
  7249. audio filters.
  7250. To enable these filters you need to install the libzmq library and
  7251. headers and configure FFmpeg with @code{--enable-libzmq}.
  7252. For more information about libzmq see:
  7253. @url{http://www.zeromq.org/}
  7254. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  7255. receives messages sent through a network interface defined by the
  7256. @option{bind_address} option.
  7257. The received message must be in the form:
  7258. @example
  7259. @var{TARGET} @var{COMMAND} [@var{ARG}]
  7260. @end example
  7261. @var{TARGET} specifies the target of the command, usually the name of
  7262. the filter class or a specific filter instance name.
  7263. @var{COMMAND} specifies the name of the command for the target filter.
  7264. @var{ARG} is optional and specifies the optional argument list for the
  7265. given @var{COMMAND}.
  7266. Upon reception, the message is processed and the corresponding command
  7267. is injected into the filtergraph. Depending on the result, the filter
  7268. will send a reply to the client, adopting the format:
  7269. @example
  7270. @var{ERROR_CODE} @var{ERROR_REASON}
  7271. @var{MESSAGE}
  7272. @end example
  7273. @var{MESSAGE} is optional.
  7274. @subsection Examples
  7275. Look at @file{tools/zmqsend} for an example of a zmq client which can
  7276. be used to send commands processed by these filters.
  7277. Consider the following filtergraph generated by @command{ffplay}
  7278. @example
  7279. ffplay -dumpgraph 1 -f lavfi "
  7280. color=s=100x100:c=red [l];
  7281. color=s=100x100:c=blue [r];
  7282. nullsrc=s=200x100, zmq [bg];
  7283. [bg][l] overlay [bg+l];
  7284. [bg+l][r] overlay=x=100 "
  7285. @end example
  7286. To change the color of the left side of the video, the following
  7287. command can be used:
  7288. @example
  7289. echo Parsed_color_0 c yellow | tools/zmqsend
  7290. @end example
  7291. To change the right side:
  7292. @example
  7293. echo Parsed_color_1 c pink | tools/zmqsend
  7294. @end example
  7295. @c man end MULTIMEDIA FILTERS
  7296. @chapter Multimedia Sources
  7297. @c man begin MULTIMEDIA SOURCES
  7298. Below is a description of the currently available multimedia sources.
  7299. @section amovie
  7300. This is the same as @ref{movie} source, except it selects an audio
  7301. stream by default.
  7302. @anchor{movie}
  7303. @section movie
  7304. Read audio and/or video stream(s) from a movie container.
  7305. This filter accepts the following options:
  7306. @table @option
  7307. @item filename
  7308. The name of the resource to read (not necessarily a file but also a device or a
  7309. stream accessed through some protocol).
  7310. @item format_name, f
  7311. Specifies the format assumed for the movie to read, and can be either
  7312. the name of a container or an input device. If not specified the
  7313. format is guessed from @var{movie_name} or by probing.
  7314. @item seek_point, sp
  7315. Specifies the seek point in seconds, the frames will be output
  7316. starting from this seek point, the parameter is evaluated with
  7317. @code{av_strtod} so the numerical value may be suffixed by an IS
  7318. postfix. Default value is "0".
  7319. @item streams, s
  7320. Specifies the streams to read. Several streams can be specified,
  7321. separated by "+". The source will then have as many outputs, in the
  7322. same order. The syntax is explained in the ``Stream specifiers''
  7323. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  7324. respectively the default (best suited) video and audio stream. Default
  7325. is "dv", or "da" if the filter is called as "amovie".
  7326. @item stream_index, si
  7327. Specifies the index of the video stream to read. If the value is -1,
  7328. the best suited video stream will be automatically selected. Default
  7329. value is "-1". Deprecated. If the filter is called "amovie", it will select
  7330. audio instead of video.
  7331. @item loop
  7332. Specifies how many times to read the stream in sequence.
  7333. If the value is less than 1, the stream will be read again and again.
  7334. Default value is "1".
  7335. Note that when the movie is looped the source timestamps are not
  7336. changed, so it will generate non monotonically increasing timestamps.
  7337. @end table
  7338. This filter allows to overlay a second video on top of main input of
  7339. a filtergraph as shown in this graph:
  7340. @example
  7341. input -----------> deltapts0 --> overlay --> output
  7342. ^
  7343. |
  7344. movie --> scale--> deltapts1 -------+
  7345. @end example
  7346. @subsection Examples
  7347. @itemize
  7348. @item
  7349. Skip 3.2 seconds from the start of the avi file in.avi, and overlay it
  7350. on top of the input labelled as "in":
  7351. @example
  7352. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  7353. [in] setpts=PTS-STARTPTS [main];
  7354. [main][over] overlay=16:16 [out]
  7355. @end example
  7356. @item
  7357. Read from a video4linux2 device, and overlay it on top of the input
  7358. labelled as "in":
  7359. @example
  7360. movie=/dev/video0:f=video4linux2, 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 the first video stream and the audio stream with id 0x81 from
  7366. dvd.vob; the video is connected to the pad named "video" and the audio is
  7367. connected to the pad named "audio":
  7368. @example
  7369. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  7370. @end example
  7371. @end itemize
  7372. @c man end MULTIMEDIA SOURCES