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.

9895 lines
266KB

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