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.

9603 lines
257KB

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