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.

9528 lines
255KB

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