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.

9916 lines
267KB

  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 replaygain
  1269. ReplayGain scanner filter. This filter takes an audio stream as an input and
  1270. outputs it unchanged.
  1271. At end of filtering it displays @code{track_gain} and @code{track_peak}.
  1272. @section resample
  1273. Convert the audio sample format, sample rate and channel layout. This filter is
  1274. not meant to be used directly.
  1275. @section silencedetect
  1276. Detect silence in an audio stream.
  1277. This filter logs a message when it detects that the input audio volume is less
  1278. or equal to a noise tolerance value for a duration greater or equal to the
  1279. minimum detected noise duration.
  1280. The printed times and duration are expressed in seconds.
  1281. The filter accepts the following options:
  1282. @table @option
  1283. @item duration, d
  1284. Set silence duration until notification (default is 2 seconds).
  1285. @item noise, n
  1286. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  1287. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  1288. @end table
  1289. @subsection Examples
  1290. @itemize
  1291. @item
  1292. Detect 5 seconds of silence with -50dB noise tolerance:
  1293. @example
  1294. silencedetect=n=-50dB:d=5
  1295. @end example
  1296. @item
  1297. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  1298. tolerance in @file{silence.mp3}:
  1299. @example
  1300. ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
  1301. @end example
  1302. @end itemize
  1303. @section treble
  1304. Boost or cut treble (upper) frequencies of the audio using a two-pole
  1305. shelving filter with a response similar to that of a standard
  1306. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  1307. The filter accepts the following options:
  1308. @table @option
  1309. @item gain, g
  1310. Give the gain at whichever is the lower of ~22 kHz and the
  1311. Nyquist frequency. Its useful range is about -20 (for a large cut)
  1312. to +20 (for a large boost). Beware of clipping when using a positive gain.
  1313. @item frequency, f
  1314. Set the filter's central frequency and so can be used
  1315. to extend or reduce the frequency range to be boosted or cut.
  1316. The default value is @code{3000} Hz.
  1317. @item width_type
  1318. Set method to specify band-width of filter.
  1319. @table @option
  1320. @item h
  1321. Hz
  1322. @item q
  1323. Q-Factor
  1324. @item o
  1325. octave
  1326. @item s
  1327. slope
  1328. @end table
  1329. @item width, w
  1330. Determine how steep is the filter's shelf transition.
  1331. @end table
  1332. @section volume
  1333. Adjust the input audio volume.
  1334. The filter accepts the following options:
  1335. @table @option
  1336. @item volume
  1337. Expresses how the audio volume will be increased or decreased.
  1338. Output values are clipped to the maximum value.
  1339. The output audio volume is given by the relation:
  1340. @example
  1341. @var{output_volume} = @var{volume} * @var{input_volume}
  1342. @end example
  1343. Default value for @var{volume} is 1.0.
  1344. @item precision
  1345. Set the mathematical precision.
  1346. This determines which input sample formats will be allowed, which affects the
  1347. precision of the volume scaling.
  1348. @table @option
  1349. @item fixed
  1350. 8-bit fixed-point; limits input sample format to U8, S16, and S32.
  1351. @item float
  1352. 32-bit floating-point; limits input sample format to FLT. (default)
  1353. @item double
  1354. 64-bit floating-point; limits input sample format to DBL.
  1355. @end table
  1356. @end table
  1357. @subsection Examples
  1358. @itemize
  1359. @item
  1360. Halve the input audio volume:
  1361. @example
  1362. volume=volume=0.5
  1363. volume=volume=1/2
  1364. volume=volume=-6.0206dB
  1365. @end example
  1366. In all the above example the named key for @option{volume} can be
  1367. omitted, for example like in:
  1368. @example
  1369. volume=0.5
  1370. @end example
  1371. @item
  1372. Increase input audio power by 6 decibels using fixed-point precision:
  1373. @example
  1374. volume=volume=6dB:precision=fixed
  1375. @end example
  1376. @end itemize
  1377. @section volumedetect
  1378. Detect the volume of the input video.
  1379. The filter has no parameters. The input is not modified. Statistics about
  1380. the volume will be printed in the log when the input stream end is reached.
  1381. In particular it will show the mean volume (root mean square), maximum
  1382. volume (on a per-sample basis), and the beginning of a histogram of the
  1383. registered volume values (from the maximum value to a cumulated 1/1000 of
  1384. the samples).
  1385. All volumes are in decibels relative to the maximum PCM value.
  1386. @subsection Examples
  1387. Here is an excerpt of the output:
  1388. @example
  1389. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  1390. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  1391. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  1392. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  1393. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  1394. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  1395. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  1396. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  1397. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  1398. @end example
  1399. It means that:
  1400. @itemize
  1401. @item
  1402. The mean square energy is approximately -27 dB, or 10^-2.7.
  1403. @item
  1404. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  1405. @item
  1406. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  1407. @end itemize
  1408. In other words, raising the volume by +4 dB does not cause any clipping,
  1409. raising it by +5 dB causes clipping for 6 samples, etc.
  1410. @c man end AUDIO FILTERS
  1411. @chapter Audio Sources
  1412. @c man begin AUDIO SOURCES
  1413. Below is a description of the currently available audio sources.
  1414. @section abuffer
  1415. Buffer audio frames, and make them available to the filter chain.
  1416. This source is mainly intended for a programmatic use, in particular
  1417. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  1418. It accepts the following named parameters:
  1419. @table @option
  1420. @item time_base
  1421. Timebase which will be used for timestamps of submitted frames. It must be
  1422. either a floating-point number or in @var{numerator}/@var{denominator} form.
  1423. @item sample_rate
  1424. The sample rate of the incoming audio buffers.
  1425. @item sample_fmt
  1426. The sample format of the incoming audio buffers.
  1427. Either a sample format name or its corresponging integer representation from
  1428. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  1429. @item channel_layout
  1430. The channel layout of the incoming audio buffers.
  1431. Either a channel layout name from channel_layout_map in
  1432. @file{libavutil/channel_layout.c} or its corresponding integer representation
  1433. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  1434. @item channels
  1435. The number of channels of the incoming audio buffers.
  1436. If both @var{channels} and @var{channel_layout} are specified, then they
  1437. must be consistent.
  1438. @end table
  1439. @subsection Examples
  1440. @example
  1441. abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
  1442. @end example
  1443. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  1444. Since the sample format with name "s16p" corresponds to the number
  1445. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  1446. equivalent to:
  1447. @example
  1448. abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
  1449. @end example
  1450. @section aevalsrc
  1451. Generate an audio signal specified by an expression.
  1452. This source accepts in input one or more expressions (one for each
  1453. channel), which are evaluated and used to generate a corresponding
  1454. audio signal.
  1455. This source accepts the following options:
  1456. @table @option
  1457. @item exprs
  1458. Set the '|'-separated expressions list for each separate channel. In case the
  1459. @option{channel_layout} option is not specified, the selected channel layout
  1460. depends on the number of provided expressions.
  1461. @item channel_layout, c
  1462. Set the channel layout. The number of channels in the specified layout
  1463. must be equal to the number of specified expressions.
  1464. @item duration, d
  1465. Set the minimum duration of the sourced audio. See the function
  1466. @code{av_parse_time()} for the accepted format.
  1467. Note that the resulting duration may be greater than the specified
  1468. duration, as the generated audio is always cut at the end of a
  1469. complete frame.
  1470. If not specified, or the expressed duration is negative, the audio is
  1471. supposed to be generated forever.
  1472. @item nb_samples, n
  1473. Set the number of samples per channel per each output frame,
  1474. default to 1024.
  1475. @item sample_rate, s
  1476. Specify the sample rate, default to 44100.
  1477. @end table
  1478. Each expression in @var{exprs} can contain the following constants:
  1479. @table @option
  1480. @item n
  1481. number of the evaluated sample, starting from 0
  1482. @item t
  1483. time of the evaluated sample expressed in seconds, starting from 0
  1484. @item s
  1485. sample rate
  1486. @end table
  1487. @subsection Examples
  1488. @itemize
  1489. @item
  1490. Generate silence:
  1491. @example
  1492. aevalsrc=0
  1493. @end example
  1494. @item
  1495. Generate a sin signal with frequency of 440 Hz, set sample rate to
  1496. 8000 Hz:
  1497. @example
  1498. aevalsrc="sin(440*2*PI*t):s=8000"
  1499. @end example
  1500. @item
  1501. Generate a two channels signal, specify the channel layout (Front
  1502. Center + Back Center) explicitly:
  1503. @example
  1504. aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
  1505. @end example
  1506. @item
  1507. Generate white noise:
  1508. @example
  1509. aevalsrc="-2+random(0)"
  1510. @end example
  1511. @item
  1512. Generate an amplitude modulated signal:
  1513. @example
  1514. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  1515. @end example
  1516. @item
  1517. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  1518. @example
  1519. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
  1520. @end example
  1521. @end itemize
  1522. @section anullsrc
  1523. Null audio source, return unprocessed audio frames. It is mainly useful
  1524. as a template and to be employed in analysis / debugging tools, or as
  1525. the source for filters which ignore the input data (for example the sox
  1526. synth filter).
  1527. This source accepts the following options:
  1528. @table @option
  1529. @item channel_layout, cl
  1530. Specify the channel layout, and can be either an integer or a string
  1531. representing a channel layout. The default value of @var{channel_layout}
  1532. is "stereo".
  1533. Check the channel_layout_map definition in
  1534. @file{libavutil/channel_layout.c} for the mapping between strings and
  1535. channel layout values.
  1536. @item sample_rate, r
  1537. Specify the sample rate, and defaults to 44100.
  1538. @item nb_samples, n
  1539. Set the number of samples per requested frames.
  1540. @end table
  1541. @subsection Examples
  1542. @itemize
  1543. @item
  1544. Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  1545. @example
  1546. anullsrc=r=48000:cl=4
  1547. @end example
  1548. @item
  1549. Do the same operation with a more obvious syntax:
  1550. @example
  1551. anullsrc=r=48000:cl=mono
  1552. @end example
  1553. @end itemize
  1554. All the parameters need to be explicitly defined.
  1555. @section flite
  1556. Synthesize a voice utterance using the libflite library.
  1557. To enable compilation of this filter you need to configure FFmpeg with
  1558. @code{--enable-libflite}.
  1559. Note that the flite library is not thread-safe.
  1560. The filter accepts the following options:
  1561. @table @option
  1562. @item list_voices
  1563. If set to 1, list the names of the available voices and exit
  1564. immediately. Default value is 0.
  1565. @item nb_samples, n
  1566. Set the maximum number of samples per frame. Default value is 512.
  1567. @item textfile
  1568. Set the filename containing the text to speak.
  1569. @item text
  1570. Set the text to speak.
  1571. @item voice, v
  1572. Set the voice to use for the speech synthesis. Default value is
  1573. @code{kal}. See also the @var{list_voices} option.
  1574. @end table
  1575. @subsection Examples
  1576. @itemize
  1577. @item
  1578. Read from file @file{speech.txt}, and synthetize the text using the
  1579. standard flite voice:
  1580. @example
  1581. flite=textfile=speech.txt
  1582. @end example
  1583. @item
  1584. Read the specified text selecting the @code{slt} voice:
  1585. @example
  1586. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  1587. @end example
  1588. @item
  1589. Input text to ffmpeg:
  1590. @example
  1591. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  1592. @end example
  1593. @item
  1594. Make @file{ffplay} speak the specified text, using @code{flite} and
  1595. the @code{lavfi} device:
  1596. @example
  1597. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  1598. @end example
  1599. @end itemize
  1600. For more information about libflite, check:
  1601. @url{http://www.speech.cs.cmu.edu/flite/}
  1602. @section sine
  1603. Generate an audio signal made of a sine wave with amplitude 1/8.
  1604. The audio signal is bit-exact.
  1605. The filter accepts the following options:
  1606. @table @option
  1607. @item frequency, f
  1608. Set the carrier frequency. Default is 440 Hz.
  1609. @item beep_factor, b
  1610. Enable a periodic beep every second with frequency @var{beep_factor} times
  1611. the carrier frequency. Default is 0, meaning the beep is disabled.
  1612. @item sample_rate, r
  1613. Specify the sample rate, default is 44100.
  1614. @item duration, d
  1615. Specify the duration of the generated audio stream.
  1616. @item samples_per_frame
  1617. Set the number of samples per output frame, default is 1024.
  1618. @end table
  1619. @subsection Examples
  1620. @itemize
  1621. @item
  1622. Generate a simple 440 Hz sine wave:
  1623. @example
  1624. sine
  1625. @end example
  1626. @item
  1627. Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
  1628. @example
  1629. sine=220:4:d=5
  1630. sine=f=220:b=4:d=5
  1631. sine=frequency=220:beep_factor=4:duration=5
  1632. @end example
  1633. @end itemize
  1634. @c man end AUDIO SOURCES
  1635. @chapter Audio Sinks
  1636. @c man begin AUDIO SINKS
  1637. Below is a description of the currently available audio sinks.
  1638. @section abuffersink
  1639. Buffer audio frames, and make them available to the end of filter chain.
  1640. This sink is mainly intended for programmatic use, in particular
  1641. through the interface defined in @file{libavfilter/buffersink.h}
  1642. or the options system.
  1643. It accepts a pointer to an AVABufferSinkContext structure, which
  1644. defines the incoming buffers' formats, to be passed as the opaque
  1645. parameter to @code{avfilter_init_filter} for initialization.
  1646. @section anullsink
  1647. Null audio sink, do absolutely nothing with the input audio. It is
  1648. mainly useful as a template and to be employed in analysis / debugging
  1649. tools.
  1650. @c man end AUDIO SINKS
  1651. @chapter Video Filters
  1652. @c man begin VIDEO FILTERS
  1653. When you configure your FFmpeg build, you can disable any of the
  1654. existing filters using @code{--disable-filters}.
  1655. The configure output will show the video filters included in your
  1656. build.
  1657. Below is a description of the currently available video filters.
  1658. @section alphaextract
  1659. Extract the alpha component from the input as a grayscale video. This
  1660. is especially useful with the @var{alphamerge} filter.
  1661. @section alphamerge
  1662. Add or replace the alpha component of the primary input with the
  1663. grayscale value of a second input. This is intended for use with
  1664. @var{alphaextract} to allow the transmission or storage of frame
  1665. sequences that have alpha in a format that doesn't support an alpha
  1666. channel.
  1667. For example, to reconstruct full frames from a normal YUV-encoded video
  1668. and a separate video created with @var{alphaextract}, you might use:
  1669. @example
  1670. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  1671. @end example
  1672. Since this filter is designed for reconstruction, it operates on frame
  1673. sequences without considering timestamps, and terminates when either
  1674. input reaches end of stream. This will cause problems if your encoding
  1675. pipeline drops frames. If you're trying to apply an image as an
  1676. overlay to a video stream, consider the @var{overlay} filter instead.
  1677. @section ass
  1678. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  1679. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  1680. Substation Alpha) subtitles files.
  1681. @section bbox
  1682. Compute the bounding box for the non-black pixels in the input frame
  1683. luminance plane.
  1684. This filter computes the bounding box containing all the pixels with a
  1685. luminance value greater than the minimum allowed value.
  1686. The parameters describing the bounding box are printed on the filter
  1687. log.
  1688. The filter accepts the following option:
  1689. @table @option
  1690. @item min_val
  1691. Set the minimal luminance value. Default is @code{16}.
  1692. @end table
  1693. @section blackdetect
  1694. Detect video intervals that are (almost) completely black. Can be
  1695. useful to detect chapter transitions, commercials, or invalid
  1696. recordings. Output lines contains the time for the start, end and
  1697. duration of the detected black interval expressed in seconds.
  1698. In order to display the output lines, you need to set the loglevel at
  1699. least to the AV_LOG_INFO value.
  1700. The filter accepts the following options:
  1701. @table @option
  1702. @item black_min_duration, d
  1703. Set the minimum detected black duration expressed in seconds. It must
  1704. be a non-negative floating point number.
  1705. Default value is 2.0.
  1706. @item picture_black_ratio_th, pic_th
  1707. Set the threshold for considering a picture "black".
  1708. Express the minimum value for the ratio:
  1709. @example
  1710. @var{nb_black_pixels} / @var{nb_pixels}
  1711. @end example
  1712. for which a picture is considered black.
  1713. Default value is 0.98.
  1714. @item pixel_black_th, pix_th
  1715. Set the threshold for considering a pixel "black".
  1716. The threshold expresses the maximum pixel luminance value for which a
  1717. pixel is considered "black". The provided value is scaled according to
  1718. the following equation:
  1719. @example
  1720. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  1721. @end example
  1722. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  1723. the input video format, the range is [0-255] for YUV full-range
  1724. formats and [16-235] for YUV non full-range formats.
  1725. Default value is 0.10.
  1726. @end table
  1727. The following example sets the maximum pixel threshold to the minimum
  1728. value, and detects only black intervals of 2 or more seconds:
  1729. @example
  1730. blackdetect=d=2:pix_th=0.00
  1731. @end example
  1732. @section blackframe
  1733. Detect frames that are (almost) completely black. Can be useful to
  1734. detect chapter transitions or commercials. Output lines consist of
  1735. the frame number of the detected frame, the percentage of blackness,
  1736. the position in the file if known or -1 and the timestamp in seconds.
  1737. In order to display the output lines, you need to set the loglevel at
  1738. least to the AV_LOG_INFO value.
  1739. The filter accepts the following options:
  1740. @table @option
  1741. @item amount
  1742. Set the percentage of the pixels that have to be below the threshold, defaults
  1743. to @code{98}.
  1744. @item threshold, thresh
  1745. Set the threshold below which a pixel value is considered black, defaults to
  1746. @code{32}.
  1747. @end table
  1748. @section blend
  1749. Blend two video frames into each other.
  1750. It takes two input streams and outputs one stream, the first input is the
  1751. "top" layer and second input is "bottom" layer.
  1752. Output terminates when shortest input terminates.
  1753. A description of the accepted options follows.
  1754. @table @option
  1755. @item c0_mode
  1756. @item c1_mode
  1757. @item c2_mode
  1758. @item c3_mode
  1759. @item all_mode
  1760. Set blend mode for specific pixel component or all pixel components in case
  1761. of @var{all_mode}. Default value is @code{normal}.
  1762. Available values for component modes are:
  1763. @table @samp
  1764. @item addition
  1765. @item and
  1766. @item average
  1767. @item burn
  1768. @item darken
  1769. @item difference
  1770. @item divide
  1771. @item dodge
  1772. @item exclusion
  1773. @item hardlight
  1774. @item lighten
  1775. @item multiply
  1776. @item negation
  1777. @item normal
  1778. @item or
  1779. @item overlay
  1780. @item phoenix
  1781. @item pinlight
  1782. @item reflect
  1783. @item screen
  1784. @item softlight
  1785. @item subtract
  1786. @item vividlight
  1787. @item xor
  1788. @end table
  1789. @item c0_opacity
  1790. @item c1_opacity
  1791. @item c2_opacity
  1792. @item c3_opacity
  1793. @item all_opacity
  1794. Set blend opacity for specific pixel component or all pixel components in case
  1795. of @var{all_opacity}. Only used in combination with pixel component blend modes.
  1796. @item c0_expr
  1797. @item c1_expr
  1798. @item c2_expr
  1799. @item c3_expr
  1800. @item all_expr
  1801. Set blend expression for specific pixel component or all pixel components in case
  1802. of @var{all_expr}. Note that related mode options will be ignored if those are set.
  1803. The expressions can use the following variables:
  1804. @table @option
  1805. @item N
  1806. The sequential number of the filtered frame, starting from @code{0}.
  1807. @item X
  1808. @item Y
  1809. the coordinates of the current sample
  1810. @item W
  1811. @item H
  1812. the width and height of currently filtered plane
  1813. @item SW
  1814. @item SH
  1815. Width and height scale depending on the currently filtered plane. It is the
  1816. ratio between the corresponding luma plane number of pixels and the current
  1817. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  1818. @code{0.5,0.5} for chroma planes.
  1819. @item T
  1820. Time of the current frame, expressed in seconds.
  1821. @item TOP, A
  1822. Value of pixel component at current location for first video frame (top layer).
  1823. @item BOTTOM, B
  1824. Value of pixel component at current location for second video frame (bottom layer).
  1825. @end table
  1826. @item shortest
  1827. Force termination when the shortest input terminates. Default is @code{0}.
  1828. @item repeatlast
  1829. Continue applying the last bottom frame after the end of the stream. A value of
  1830. @code{0} disable the filter after the last frame of the bottom layer is reached.
  1831. Default is @code{1}.
  1832. @end table
  1833. @subsection Examples
  1834. @itemize
  1835. @item
  1836. Apply transition from bottom layer to top layer in first 10 seconds:
  1837. @example
  1838. blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
  1839. @end example
  1840. @item
  1841. Apply 1x1 checkerboard effect:
  1842. @example
  1843. blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
  1844. @end example
  1845. @end itemize
  1846. @section boxblur
  1847. Apply boxblur algorithm to the input video.
  1848. The filter accepts the following options:
  1849. @table @option
  1850. @item luma_radius, lr
  1851. @item luma_power, lp
  1852. @item chroma_radius, cr
  1853. @item chroma_power, cp
  1854. @item alpha_radius, ar
  1855. @item alpha_power, ap
  1856. @end table
  1857. A description of the accepted options follows.
  1858. @table @option
  1859. @item luma_radius, lr
  1860. @item chroma_radius, cr
  1861. @item alpha_radius, ar
  1862. Set an expression for the box radius in pixels used for blurring the
  1863. corresponding input plane.
  1864. The radius value must be a non-negative number, and must not be
  1865. greater than the value of the expression @code{min(w,h)/2} for the
  1866. luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
  1867. planes.
  1868. Default value for @option{luma_radius} is "2". If not specified,
  1869. @option{chroma_radius} and @option{alpha_radius} default to the
  1870. corresponding value set for @option{luma_radius}.
  1871. The expressions can contain the following constants:
  1872. @table @option
  1873. @item w
  1874. @item h
  1875. the input width and height in pixels
  1876. @item cw
  1877. @item ch
  1878. the input chroma image width and height in pixels
  1879. @item hsub
  1880. @item vsub
  1881. horizontal and vertical chroma subsample values. For example for the
  1882. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  1883. @end table
  1884. @item luma_power, lp
  1885. @item chroma_power, cp
  1886. @item alpha_power, ap
  1887. Specify how many times the boxblur filter is applied to the
  1888. corresponding plane.
  1889. Default value for @option{luma_power} is 2. If not specified,
  1890. @option{chroma_power} and @option{alpha_power} default to the
  1891. corresponding value set for @option{luma_power}.
  1892. A value of 0 will disable the effect.
  1893. @end table
  1894. @subsection Examples
  1895. @itemize
  1896. @item
  1897. Apply a boxblur filter with luma, chroma, and alpha radius
  1898. set to 2:
  1899. @example
  1900. boxblur=luma_radius=2:luma_power=1
  1901. boxblur=2:1
  1902. @end example
  1903. @item
  1904. Set luma radius to 2, alpha and chroma radius to 0:
  1905. @example
  1906. boxblur=2:1:cr=0:ar=0
  1907. @end example
  1908. @item
  1909. Set luma and chroma radius to a fraction of the video dimension:
  1910. @example
  1911. boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
  1912. @end example
  1913. @end itemize
  1914. @section colorbalance
  1915. Modify intensity of primary colors (red, green and blue) of input frames.
  1916. The filter allows an input frame to be adjusted in the shadows, midtones or highlights
  1917. regions for the red-cyan, green-magenta or blue-yellow balance.
  1918. A positive adjustment value shifts the balance towards the primary color, a negative
  1919. value towards the complementary color.
  1920. The filter accepts the following options:
  1921. @table @option
  1922. @item rs
  1923. @item gs
  1924. @item bs
  1925. Adjust red, green and blue shadows (darkest pixels).
  1926. @item rm
  1927. @item gm
  1928. @item bm
  1929. Adjust red, green and blue midtones (medium pixels).
  1930. @item rh
  1931. @item gh
  1932. @item bh
  1933. Adjust red, green and blue highlights (brightest pixels).
  1934. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  1935. @end table
  1936. @subsection Examples
  1937. @itemize
  1938. @item
  1939. Add red color cast to shadows:
  1940. @example
  1941. colorbalance=rs=.3
  1942. @end example
  1943. @end itemize
  1944. @section colorchannelmixer
  1945. Adjust video input frames by re-mixing color channels.
  1946. This filter modifies a color channel by adding the values associated to
  1947. the other channels of the same pixels. For example if the value to
  1948. modify is red, the output value will be:
  1949. @example
  1950. @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
  1951. @end example
  1952. The filter accepts the following options:
  1953. @table @option
  1954. @item rr
  1955. @item rg
  1956. @item rb
  1957. @item ra
  1958. Adjust contribution of input red, green, blue and alpha channels for output red channel.
  1959. Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
  1960. @item gr
  1961. @item gg
  1962. @item gb
  1963. @item ga
  1964. Adjust contribution of input red, green, blue and alpha channels for output green channel.
  1965. Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
  1966. @item br
  1967. @item bg
  1968. @item bb
  1969. @item ba
  1970. Adjust contribution of input red, green, blue and alpha channels for output blue channel.
  1971. Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
  1972. @item ar
  1973. @item ag
  1974. @item ab
  1975. @item aa
  1976. Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
  1977. Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
  1978. Allowed ranges for options are @code{[-2.0, 2.0]}.
  1979. @end table
  1980. @subsection Examples
  1981. @itemize
  1982. @item
  1983. Convert source to grayscale:
  1984. @example
  1985. colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
  1986. @end example
  1987. @item
  1988. Simulate sepia tones:
  1989. @example
  1990. colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
  1991. @end example
  1992. @end itemize
  1993. @section colormatrix
  1994. Convert color matrix.
  1995. The filter accepts the following options:
  1996. @table @option
  1997. @item src
  1998. @item dst
  1999. Specify the source and destination color matrix. Both values must be
  2000. specified.
  2001. The accepted values are:
  2002. @table @samp
  2003. @item bt709
  2004. BT.709
  2005. @item bt601
  2006. BT.601
  2007. @item smpte240m
  2008. SMPTE-240M
  2009. @item fcc
  2010. FCC
  2011. @end table
  2012. @end table
  2013. For example to convert from BT.601 to SMPTE-240M, use the command:
  2014. @example
  2015. colormatrix=bt601:smpte240m
  2016. @end example
  2017. @section copy
  2018. Copy the input source unchanged to the output. Mainly useful for
  2019. testing purposes.
  2020. @section crop
  2021. Crop the input video to given dimensions.
  2022. The filter accepts the following options:
  2023. @table @option
  2024. @item w, out_w
  2025. Width of the output video. It defaults to @code{iw}.
  2026. This expression is evaluated only once during the filter
  2027. configuration.
  2028. @item h, out_h
  2029. Height of the output video. It defaults to @code{ih}.
  2030. This expression is evaluated only once during the filter
  2031. configuration.
  2032. @item x
  2033. Horizontal position, in the input video, of the left edge of the output video.
  2034. It defaults to @code{(in_w-out_w)/2}.
  2035. This expression is evaluated per-frame.
  2036. @item y
  2037. Vertical position, in the input video, of the top edge of the output video.
  2038. It defaults to @code{(in_h-out_h)/2}.
  2039. This expression is evaluated per-frame.
  2040. @item keep_aspect
  2041. If set to 1 will force the output display aspect ratio
  2042. to be the same of the input, by changing the output sample aspect
  2043. ratio. It defaults to 0.
  2044. @end table
  2045. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  2046. expressions containing the following constants:
  2047. @table @option
  2048. @item x
  2049. @item y
  2050. the computed values for @var{x} and @var{y}. They are evaluated for
  2051. each new frame.
  2052. @item in_w
  2053. @item in_h
  2054. the input width and height
  2055. @item iw
  2056. @item ih
  2057. same as @var{in_w} and @var{in_h}
  2058. @item out_w
  2059. @item out_h
  2060. the output (cropped) width and height
  2061. @item ow
  2062. @item oh
  2063. same as @var{out_w} and @var{out_h}
  2064. @item a
  2065. same as @var{iw} / @var{ih}
  2066. @item sar
  2067. input sample aspect ratio
  2068. @item dar
  2069. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2070. @item hsub
  2071. @item vsub
  2072. horizontal and vertical chroma subsample values. For example for the
  2073. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2074. @item n
  2075. the number of input frame, starting from 0
  2076. @item pos
  2077. the position in the file of the input frame, NAN if unknown
  2078. @item t
  2079. timestamp expressed in seconds, NAN if the input timestamp is unknown
  2080. @end table
  2081. The expression for @var{out_w} may depend on the value of @var{out_h},
  2082. and the expression for @var{out_h} may depend on @var{out_w}, but they
  2083. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  2084. evaluated after @var{out_w} and @var{out_h}.
  2085. The @var{x} and @var{y} parameters specify the expressions for the
  2086. position of the top-left corner of the output (non-cropped) area. They
  2087. are evaluated for each frame. If the evaluated value is not valid, it
  2088. is approximated to the nearest valid value.
  2089. The expression for @var{x} may depend on @var{y}, and the expression
  2090. for @var{y} may depend on @var{x}.
  2091. @subsection Examples
  2092. @itemize
  2093. @item
  2094. Crop area with size 100x100 at position (12,34).
  2095. @example
  2096. crop=100:100:12:34
  2097. @end example
  2098. Using named options, the example above becomes:
  2099. @example
  2100. crop=w=100:h=100:x=12:y=34
  2101. @end example
  2102. @item
  2103. Crop the central input area with size 100x100:
  2104. @example
  2105. crop=100:100
  2106. @end example
  2107. @item
  2108. Crop the central input area with size 2/3 of the input video:
  2109. @example
  2110. crop=2/3*in_w:2/3*in_h
  2111. @end example
  2112. @item
  2113. Crop the input video central square:
  2114. @example
  2115. crop=out_w=in_h
  2116. crop=in_h
  2117. @end example
  2118. @item
  2119. Delimit the rectangle with the top-left corner placed at position
  2120. 100:100 and the right-bottom corner corresponding to the right-bottom
  2121. corner of the input image:
  2122. @example
  2123. crop=in_w-100:in_h-100:100:100
  2124. @end example
  2125. @item
  2126. Crop 10 pixels from the left and right borders, and 20 pixels from
  2127. the top and bottom borders
  2128. @example
  2129. crop=in_w-2*10:in_h-2*20
  2130. @end example
  2131. @item
  2132. Keep only the bottom right quarter of the input image:
  2133. @example
  2134. crop=in_w/2:in_h/2:in_w/2:in_h/2
  2135. @end example
  2136. @item
  2137. Crop height for getting Greek harmony:
  2138. @example
  2139. crop=in_w:1/PHI*in_w
  2140. @end example
  2141. @item
  2142. Appply trembling effect:
  2143. @example
  2144. 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)
  2145. @end example
  2146. @item
  2147. Apply erratic camera effect depending on timestamp:
  2148. @example
  2149. 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)"
  2150. @end example
  2151. @item
  2152. Set x depending on the value of y:
  2153. @example
  2154. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  2155. @end example
  2156. @end itemize
  2157. @section cropdetect
  2158. Auto-detect crop size.
  2159. Calculate necessary cropping parameters and prints the recommended
  2160. parameters through the logging system. The detected dimensions
  2161. correspond to the non-black area of the input video.
  2162. The filter accepts the following options:
  2163. @table @option
  2164. @item limit
  2165. Set higher black value threshold, which can be optionally specified
  2166. from nothing (0) to everything (255). An intensity value greater
  2167. to the set value is considered non-black. Default value is 24.
  2168. @item round
  2169. Set the value for which the width/height should be divisible by. The
  2170. offset is automatically adjusted to center the video. Use 2 to get
  2171. only even dimensions (needed for 4:2:2 video). 16 is best when
  2172. encoding to most video codecs. Default value is 16.
  2173. @item reset_count, reset
  2174. Set the counter that determines after how many frames cropdetect will
  2175. reset the previously detected largest video area and start over to
  2176. detect the current optimal crop area. Default value is 0.
  2177. This can be useful when channel logos distort the video area. 0
  2178. indicates never reset and return the largest area encountered during
  2179. playback.
  2180. @end table
  2181. @anchor{curves}
  2182. @section curves
  2183. Apply color adjustments using curves.
  2184. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  2185. component (red, green and blue) has its values defined by @var{N} key points
  2186. tied from each other using a smooth curve. The x-axis represents the pixel
  2187. values from the input frame, and the y-axis the new pixel values to be set for
  2188. the output frame.
  2189. By default, a component curve is defined by the two points @var{(0;0)} and
  2190. @var{(1;1)}. This creates a straight line where each original pixel value is
  2191. "adjusted" to its own value, which means no change to the image.
  2192. The filter allows you to redefine these two points and add some more. A new
  2193. curve (using a natural cubic spline interpolation) will be define to pass
  2194. smoothly through all these new coordinates. The new defined points needs to be
  2195. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  2196. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  2197. the vector spaces, the values will be clipped accordingly.
  2198. If there is no key point defined in @code{x=0}, the filter will automatically
  2199. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  2200. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  2201. The filter accepts the following options:
  2202. @table @option
  2203. @item preset
  2204. Select one of the available color presets. This option can be used in addition
  2205. to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
  2206. options takes priority on the preset values.
  2207. Available presets are:
  2208. @table @samp
  2209. @item none
  2210. @item color_negative
  2211. @item cross_process
  2212. @item darker
  2213. @item increase_contrast
  2214. @item lighter
  2215. @item linear_contrast
  2216. @item medium_contrast
  2217. @item negative
  2218. @item strong_contrast
  2219. @item vintage
  2220. @end table
  2221. Default is @code{none}.
  2222. @item master, m
  2223. Set the master key points. These points will define a second pass mapping. It
  2224. is sometimes called a "luminance" or "value" mapping. It can be used with
  2225. @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
  2226. post-processing LUT.
  2227. @item red, r
  2228. Set the key points for the red component.
  2229. @item green, g
  2230. Set the key points for the green component.
  2231. @item blue, b
  2232. Set the key points for the blue component.
  2233. @item all
  2234. Set the key points for all components (not including master).
  2235. Can be used in addition to the other key points component
  2236. options. In this case, the unset component(s) will fallback on this
  2237. @option{all} setting.
  2238. @item psfile
  2239. Specify a Photoshop curves file (@code{.asv}) to import the settings from.
  2240. @end table
  2241. To avoid some filtergraph syntax conflicts, each key points list need to be
  2242. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  2243. @subsection Examples
  2244. @itemize
  2245. @item
  2246. Increase slightly the middle level of blue:
  2247. @example
  2248. curves=blue='0.5/0.58'
  2249. @end example
  2250. @item
  2251. Vintage effect:
  2252. @example
  2253. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  2254. @end example
  2255. Here we obtain the following coordinates for each components:
  2256. @table @var
  2257. @item red
  2258. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  2259. @item green
  2260. @code{(0;0) (0.50;0.48) (1;1)}
  2261. @item blue
  2262. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  2263. @end table
  2264. @item
  2265. The previous example can also be achieved with the associated built-in preset:
  2266. @example
  2267. curves=preset=vintage
  2268. @end example
  2269. @item
  2270. Or simply:
  2271. @example
  2272. curves=vintage
  2273. @end example
  2274. @item
  2275. Use a Photoshop preset and redefine the points of the green component:
  2276. @example
  2277. curves=psfile='MyCurvesPresets/purple.asv':green='0.45/0.53'
  2278. @end example
  2279. @end itemize
  2280. @section dctdnoiz
  2281. Denoise frames using 2D DCT (frequency domain filtering).
  2282. This filter is not designed for real time and can be extremely slow.
  2283. The filter accepts the following options:
  2284. @table @option
  2285. @item sigma, s
  2286. Set the noise sigma constant.
  2287. This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
  2288. coefficient (absolute value) below this threshold with be dropped.
  2289. If you need a more advanced filtering, see @option{expr}.
  2290. Default is @code{0}.
  2291. @item overlap
  2292. Set number overlapping pixels for each block. Each block is of size
  2293. @code{16x16}. Since the filter can be slow, you may want to reduce this value,
  2294. at the cost of a less effective filter and the risk of various artefacts.
  2295. If the overlapping value doesn't allow to process the whole input width or
  2296. height, a warning will be displayed and according borders won't be denoised.
  2297. Default value is @code{15}.
  2298. @item expr, e
  2299. Set the coefficient factor expression.
  2300. For each coefficient of a DCT block, this expression will be evaluated as a
  2301. multiplier value for the coefficient.
  2302. If this is option is set, the @option{sigma} option will be ignored.
  2303. The absolute value of the coefficient can be accessed through the @var{c}
  2304. variable.
  2305. @end table
  2306. @subsection Examples
  2307. Apply a denoise with a @option{sigma} of @code{4.5}:
  2308. @example
  2309. dctdnoiz=4.5
  2310. @end example
  2311. The same operation can be achieved using the expression system:
  2312. @example
  2313. dctdnoiz=e='gte(c, 4.5*3)'
  2314. @end example
  2315. @anchor{decimate}
  2316. @section decimate
  2317. Drop duplicated frames at regular intervals.
  2318. The filter accepts the following options:
  2319. @table @option
  2320. @item cycle
  2321. Set the number of frames from which one will be dropped. Setting this to
  2322. @var{N} means one frame in every batch of @var{N} frames will be dropped.
  2323. Default is @code{5}.
  2324. @item dupthresh
  2325. Set the threshold for duplicate detection. If the difference metric for a frame
  2326. is less than or equal to this value, then it is declared as duplicate. Default
  2327. is @code{1.1}
  2328. @item scthresh
  2329. Set scene change threshold. Default is @code{15}.
  2330. @item blockx
  2331. @item blocky
  2332. Set the size of the x and y-axis blocks used during metric calculations.
  2333. Larger blocks give better noise suppression, but also give worse detection of
  2334. small movements. Must be a power of two. Default is @code{32}.
  2335. @item ppsrc
  2336. Mark main input as a pre-processed input and activate clean source input
  2337. stream. This allows the input to be pre-processed with various filters to help
  2338. the metrics calculation while keeping the frame selection lossless. When set to
  2339. @code{1}, the first stream is for the pre-processed input, and the second
  2340. stream is the clean source from where the kept frames are chosen. Default is
  2341. @code{0}.
  2342. @item chroma
  2343. Set whether or not chroma is considered in the metric calculations. Default is
  2344. @code{1}.
  2345. @end table
  2346. @section delogo
  2347. Suppress a TV station logo by a simple interpolation of the surrounding
  2348. pixels. Just set a rectangle covering the logo and watch it disappear
  2349. (and sometimes something even uglier appear - your mileage may vary).
  2350. This filter accepts the following options:
  2351. @table @option
  2352. @item x
  2353. @item y
  2354. Specify the top left corner coordinates of the logo. They must be
  2355. specified.
  2356. @item w
  2357. @item h
  2358. Specify the width and height of the logo to clear. They must be
  2359. specified.
  2360. @item band, t
  2361. Specify the thickness of the fuzzy edge of the rectangle (added to
  2362. @var{w} and @var{h}). The default value is 4.
  2363. @item show
  2364. When set to 1, a green rectangle is drawn on the screen to simplify
  2365. finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
  2366. The default value is 0.
  2367. The rectangle is drawn on the outermost pixels which will be (partly)
  2368. replaced with interpolated values. The values of the next pixels
  2369. immediately outside this rectangle in each direction will be used to
  2370. compute the interpolated pixel values inside the rectangle.
  2371. @end table
  2372. @subsection Examples
  2373. @itemize
  2374. @item
  2375. Set a rectangle covering the area with top left corner coordinates 0,0
  2376. and size 100x77, setting a band of size 10:
  2377. @example
  2378. delogo=x=0:y=0:w=100:h=77:band=10
  2379. @end example
  2380. @end itemize
  2381. @section deshake
  2382. Attempt to fix small changes in horizontal and/or vertical shift. This
  2383. filter helps remove camera shake from hand-holding a camera, bumping a
  2384. tripod, moving on a vehicle, etc.
  2385. The filter accepts the following options:
  2386. @table @option
  2387. @item x
  2388. @item y
  2389. @item w
  2390. @item h
  2391. Specify a rectangular area where to limit the search for motion
  2392. vectors.
  2393. If desired the search for motion vectors can be limited to a
  2394. rectangular area of the frame defined by its top left corner, width
  2395. and height. These parameters have the same meaning as the drawbox
  2396. filter which can be used to visualise the position of the bounding
  2397. box.
  2398. This is useful when simultaneous movement of subjects within the frame
  2399. might be confused for camera motion by the motion vector search.
  2400. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  2401. then the full frame is used. This allows later options to be set
  2402. without specifying the bounding box for the motion vector search.
  2403. Default - search the whole frame.
  2404. @item rx
  2405. @item ry
  2406. Specify the maximum extent of movement in x and y directions in the
  2407. range 0-64 pixels. Default 16.
  2408. @item edge
  2409. Specify how to generate pixels to fill blanks at the edge of the
  2410. frame. Available values are:
  2411. @table @samp
  2412. @item blank, 0
  2413. Fill zeroes at blank locations
  2414. @item original, 1
  2415. Original image at blank locations
  2416. @item clamp, 2
  2417. Extruded edge value at blank locations
  2418. @item mirror, 3
  2419. Mirrored edge at blank locations
  2420. @end table
  2421. Default value is @samp{mirror}.
  2422. @item blocksize
  2423. Specify the blocksize to use for motion search. Range 4-128 pixels,
  2424. default 8.
  2425. @item contrast
  2426. Specify the contrast threshold for blocks. Only blocks with more than
  2427. the specified contrast (difference between darkest and lightest
  2428. pixels) will be considered. Range 1-255, default 125.
  2429. @item search
  2430. Specify the search strategy. Available values are:
  2431. @table @samp
  2432. @item exhaustive, 0
  2433. Set exhaustive search
  2434. @item less, 1
  2435. Set less exhaustive search.
  2436. @end table
  2437. Default value is @samp{exhaustive}.
  2438. @item filename
  2439. If set then a detailed log of the motion search is written to the
  2440. specified file.
  2441. @item opencl
  2442. If set to 1, specify using OpenCL capabilities, only available if
  2443. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  2444. @end table
  2445. @section drawbox
  2446. Draw a colored box on the input image.
  2447. This filter accepts the following options:
  2448. @table @option
  2449. @item x
  2450. @item y
  2451. The expressions which specify the top left corner coordinates of the box. Default to 0.
  2452. @item width, w
  2453. @item height, h
  2454. The expressions which specify the width and height of the box, if 0 they are interpreted as
  2455. the input width and height. Default to 0.
  2456. @item color, c
  2457. Specify the color of the box to write. For the general syntax of this option,
  2458. check the "Color" section in the ffmpeg-utils manual. If the special
  2459. value @code{invert} is used, the box edge color is the same as the
  2460. video with inverted luma.
  2461. @item thickness, t
  2462. The expression which sets the thickness of the box edge. Default value is @code{3}.
  2463. See below for the list of accepted constants.
  2464. @end table
  2465. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  2466. following constants:
  2467. @table @option
  2468. @item dar
  2469. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  2470. @item hsub
  2471. @item vsub
  2472. horizontal and vertical chroma subsample values. For example for the
  2473. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2474. @item in_h, ih
  2475. @item in_w, iw
  2476. The input width and height.
  2477. @item sar
  2478. The input sample aspect ratio.
  2479. @item x
  2480. @item y
  2481. The x and y offset coordinates where the box is drawn.
  2482. @item w
  2483. @item h
  2484. The width and height of the drawn box.
  2485. @item t
  2486. The thickness of the drawn box.
  2487. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  2488. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  2489. @end table
  2490. @subsection Examples
  2491. @itemize
  2492. @item
  2493. Draw a black box around the edge of the input image:
  2494. @example
  2495. drawbox
  2496. @end example
  2497. @item
  2498. Draw a box with color red and an opacity of 50%:
  2499. @example
  2500. drawbox=10:20:200:60:red@@0.5
  2501. @end example
  2502. The previous example can be specified as:
  2503. @example
  2504. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  2505. @end example
  2506. @item
  2507. Fill the box with pink color:
  2508. @example
  2509. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  2510. @end example
  2511. @item
  2512. Draw a 2-pixel red 2.40:1 mask:
  2513. @example
  2514. 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
  2515. @end example
  2516. @end itemize
  2517. @section drawgrid
  2518. Draw a grid on the input image.
  2519. This filter accepts the following options:
  2520. @table @option
  2521. @item x
  2522. @item y
  2523. The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
  2524. @item width, w
  2525. @item height, h
  2526. The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
  2527. input width and height, respectively, minus @code{thickness}, so image gets
  2528. framed. Default to 0.
  2529. @item color, c
  2530. Specify the color of the grid. For the general syntax of this option,
  2531. check the "Color" section in the ffmpeg-utils manual. If the special
  2532. value @code{invert} is used, the grid color is the same as the
  2533. video with inverted luma.
  2534. @item thickness, t
  2535. The expression which sets the thickness of the grid line. Default value is @code{1}.
  2536. See below for the list of accepted constants.
  2537. @end table
  2538. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  2539. following constants:
  2540. @table @option
  2541. @item dar
  2542. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  2543. @item hsub
  2544. @item vsub
  2545. horizontal and vertical chroma subsample values. For example for the
  2546. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2547. @item in_h, ih
  2548. @item in_w, iw
  2549. The input grid cell width and height.
  2550. @item sar
  2551. The input sample aspect ratio.
  2552. @item x
  2553. @item y
  2554. The x and y coordinates of some point of grid intersection (meant to configure offset).
  2555. @item w
  2556. @item h
  2557. The width and height of the drawn cell.
  2558. @item t
  2559. The thickness of the drawn cell.
  2560. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  2561. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  2562. @end table
  2563. @subsection Examples
  2564. @itemize
  2565. @item
  2566. Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
  2567. @example
  2568. drawgrid=width=100:height=100:thickness=2:color=red@@0.5
  2569. @end example
  2570. @item
  2571. Draw a white 3x3 grid with an opacity of 50%:
  2572. @example
  2573. drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
  2574. @end example
  2575. @end itemize
  2576. @anchor{drawtext}
  2577. @section drawtext
  2578. Draw text string or text from specified file on top of video using the
  2579. libfreetype library.
  2580. To enable compilation of this filter you need to configure FFmpeg with
  2581. @code{--enable-libfreetype}.
  2582. @subsection Syntax
  2583. The description of the accepted parameters follows.
  2584. @table @option
  2585. @item box
  2586. Used to draw a box around text using background color.
  2587. Value should be either 1 (enable) or 0 (disable).
  2588. The default value of @var{box} is 0.
  2589. @item boxcolor
  2590. The color to be used for drawing box around text. For the syntax of this
  2591. option, check the "Color" section in the ffmpeg-utils manual.
  2592. The default value of @var{boxcolor} is "white".
  2593. @item expansion
  2594. Select how the @var{text} is expanded. Can be either @code{none},
  2595. @code{strftime} (deprecated) or
  2596. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  2597. below for details.
  2598. @item fix_bounds
  2599. If true, check and fix text coords to avoid clipping.
  2600. @item fontcolor
  2601. The color to be used for drawing fonts. For the syntax of this option, check
  2602. the "Color" section in the ffmpeg-utils manual.
  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. For the
  2636. syntax of this option, check the "Color" section in the ffmpeg-utils manual.
  2637. The default value of @var{shadowcolor} is "black".
  2638. @item shadowx
  2639. @item shadowy
  2640. The x and y offsets for the text shadow position with respect to the
  2641. position of the text. They can be either positive or negative
  2642. values. Default value for both is "0".
  2643. @item start_number
  2644. The starting frame number for the n/frame_num variable. The default value
  2645. is "0".
  2646. @item tabsize
  2647. The size in number of spaces to use for rendering the tab.
  2648. Default value is 4.
  2649. @item timecode
  2650. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  2651. format. It can be used with or without text parameter. @var{timecode_rate}
  2652. option must be specified.
  2653. @item timecode_rate, rate, r
  2654. Set the timecode frame rate (timecode only).
  2655. @item text
  2656. The text string to be drawn. The text must be a sequence of UTF-8
  2657. encoded characters.
  2658. This parameter is mandatory if no file is specified with the parameter
  2659. @var{textfile}.
  2660. @item textfile
  2661. A text file containing text to be drawn. The text must be a sequence
  2662. of UTF-8 encoded characters.
  2663. This parameter is mandatory if no text string is specified with the
  2664. parameter @var{text}.
  2665. If both @var{text} and @var{textfile} are specified, an error is thrown.
  2666. @item reload
  2667. If set to 1, the @var{textfile} will be reloaded before each frame.
  2668. Be sure to update it atomically, or it may be read partially, or even fail.
  2669. @item x
  2670. @item y
  2671. The expressions which specify the offsets where text will be drawn
  2672. within the video frame. They are relative to the top/left border of the
  2673. output image.
  2674. The default value of @var{x} and @var{y} is "0".
  2675. See below for the list of accepted constants and functions.
  2676. @end table
  2677. The parameters for @var{x} and @var{y} are expressions containing the
  2678. following constants and functions:
  2679. @table @option
  2680. @item dar
  2681. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  2682. @item hsub
  2683. @item vsub
  2684. horizontal and vertical chroma subsample values. For example for the
  2685. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2686. @item line_h, lh
  2687. the height of each text line
  2688. @item main_h, h, H
  2689. the input height
  2690. @item main_w, w, W
  2691. the input width
  2692. @item max_glyph_a, ascent
  2693. the maximum distance from the baseline to the highest/upper grid
  2694. coordinate used to place a glyph outline point, for all the rendered
  2695. glyphs.
  2696. It is a positive value, due to the grid's orientation with the Y axis
  2697. upwards.
  2698. @item max_glyph_d, descent
  2699. the maximum distance from the baseline to the lowest grid coordinate
  2700. used to place a glyph outline point, for all the rendered glyphs.
  2701. This is a negative value, due to the grid's orientation, with the Y axis
  2702. upwards.
  2703. @item max_glyph_h
  2704. maximum glyph height, that is the maximum height for all the glyphs
  2705. contained in the rendered text, it is equivalent to @var{ascent} -
  2706. @var{descent}.
  2707. @item max_glyph_w
  2708. maximum glyph width, that is the maximum width for all the glyphs
  2709. contained in the rendered text
  2710. @item n
  2711. the number of input frame, starting from 0
  2712. @item rand(min, max)
  2713. return a random number included between @var{min} and @var{max}
  2714. @item sar
  2715. input sample aspect ratio
  2716. @item t
  2717. timestamp expressed in seconds, NAN if the input timestamp is unknown
  2718. @item text_h, th
  2719. the height of the rendered text
  2720. @item text_w, tw
  2721. the width of the rendered text
  2722. @item x
  2723. @item y
  2724. the x and y offset coordinates where the text is drawn.
  2725. These parameters allow the @var{x} and @var{y} expressions to refer
  2726. each other, so you can for example specify @code{y=x/dar}.
  2727. @end table
  2728. If libavfilter was built with @code{--enable-fontconfig}, then
  2729. @option{fontfile} can be a fontconfig pattern or omitted.
  2730. @anchor{drawtext_expansion}
  2731. @subsection Text expansion
  2732. If @option{expansion} is set to @code{strftime},
  2733. the filter recognizes strftime() sequences in the provided text and
  2734. expands them accordingly. Check the documentation of strftime(). This
  2735. feature is deprecated.
  2736. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  2737. If @option{expansion} is set to @code{normal} (which is the default),
  2738. the following expansion mechanism is used.
  2739. The backslash character '\', followed by any character, always expands to
  2740. the second character.
  2741. Sequence of the form @code{%@{...@}} are expanded. The text between the
  2742. braces is a function name, possibly followed by arguments separated by ':'.
  2743. If the arguments contain special characters or delimiters (':' or '@}'),
  2744. they should be escaped.
  2745. Note that they probably must also be escaped as the value for the
  2746. @option{text} option in the filter argument string and as the filter
  2747. argument in the filtergraph description, and possibly also for the shell,
  2748. that makes up to four levels of escaping; using a text file avoids these
  2749. problems.
  2750. The following functions are available:
  2751. @table @command
  2752. @item expr, e
  2753. The expression evaluation result.
  2754. It must take one argument specifying the expression to be evaluated,
  2755. which accepts the same constants and functions as the @var{x} and
  2756. @var{y} values. Note that not all constants should be used, for
  2757. example the text size is not known when evaluating the expression, so
  2758. the constants @var{text_w} and @var{text_h} will have an undefined
  2759. value.
  2760. @item gmtime
  2761. The time at which the filter is running, expressed in UTC.
  2762. It can accept an argument: a strftime() format string.
  2763. @item localtime
  2764. The time at which the filter is running, expressed in the local time zone.
  2765. It can accept an argument: a strftime() format string.
  2766. @item metadata
  2767. Frame metadata. It must take one argument specifying metadata key.
  2768. @item n, frame_num
  2769. The frame number, starting from 0.
  2770. @item pict_type
  2771. A 1 character description of the current picture type.
  2772. @item pts
  2773. The timestamp of the current frame, in seconds, with microsecond accuracy.
  2774. @end table
  2775. @subsection Examples
  2776. @itemize
  2777. @item
  2778. Draw "Test Text" with font FreeSerif, using the default values for the
  2779. optional parameters.
  2780. @example
  2781. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  2782. @end example
  2783. @item
  2784. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  2785. and y=50 (counting from the top-left corner of the screen), text is
  2786. yellow with a red box around it. Both the text and the box have an
  2787. opacity of 20%.
  2788. @example
  2789. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  2790. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  2791. @end example
  2792. Note that the double quotes are not necessary if spaces are not used
  2793. within the parameter list.
  2794. @item
  2795. Show the text at the center of the video frame:
  2796. @example
  2797. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  2798. @end example
  2799. @item
  2800. Show a text line sliding from right to left in the last row of the video
  2801. frame. The file @file{LONG_LINE} is assumed to contain a single line
  2802. with no newlines.
  2803. @example
  2804. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  2805. @end example
  2806. @item
  2807. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  2808. @example
  2809. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  2810. @end example
  2811. @item
  2812. Draw a single green letter "g", at the center of the input video.
  2813. The glyph baseline is placed at half screen height.
  2814. @example
  2815. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  2816. @end example
  2817. @item
  2818. Show text for 1 second every 3 seconds:
  2819. @example
  2820. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  2821. @end example
  2822. @item
  2823. Use fontconfig to set the font. Note that the colons need to be escaped.
  2824. @example
  2825. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  2826. @end example
  2827. @item
  2828. Print the date of a real-time encoding (see strftime(3)):
  2829. @example
  2830. drawtext='fontfile=FreeSans.ttf:text=%@{localtime:%a %b %d %Y@}'
  2831. @end example
  2832. @end itemize
  2833. For more information about libfreetype, check:
  2834. @url{http://www.freetype.org/}.
  2835. For more information about fontconfig, check:
  2836. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  2837. @section edgedetect
  2838. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  2839. The filter accepts the following options:
  2840. @table @option
  2841. @item low
  2842. @item high
  2843. Set low and high threshold values used by the Canny thresholding
  2844. algorithm.
  2845. The high threshold selects the "strong" edge pixels, which are then
  2846. connected through 8-connectivity with the "weak" edge pixels selected
  2847. by the low threshold.
  2848. @var{low} and @var{high} threshold values must be choosen in the range
  2849. [0,1], and @var{low} should be lesser or equal to @var{high}.
  2850. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  2851. is @code{50/255}.
  2852. @end table
  2853. Example:
  2854. @example
  2855. edgedetect=low=0.1:high=0.4
  2856. @end example
  2857. @section extractplanes
  2858. Extract color channel components from input video stream into
  2859. separate grayscale video streams.
  2860. The filter accepts the following option:
  2861. @table @option
  2862. @item planes
  2863. Set plane(s) to extract.
  2864. Available values for planes are:
  2865. @table @samp
  2866. @item y
  2867. @item u
  2868. @item v
  2869. @item a
  2870. @item r
  2871. @item g
  2872. @item b
  2873. @end table
  2874. Choosing planes not available in the input will result in an error.
  2875. That means you cannot select @code{r}, @code{g}, @code{b} planes
  2876. with @code{y}, @code{u}, @code{v} planes at same time.
  2877. @end table
  2878. @subsection Examples
  2879. @itemize
  2880. @item
  2881. Extract luma, u and v color channel component from input video frame
  2882. into 3 grayscale outputs:
  2883. @example
  2884. 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
  2885. @end example
  2886. @end itemize
  2887. @section fade
  2888. Apply fade-in/out effect to input video.
  2889. This filter accepts the following options:
  2890. @table @option
  2891. @item type, t
  2892. The effect type -- can be either "in" for fade-in, or "out" for a fade-out
  2893. effect.
  2894. Default is @code{in}.
  2895. @item start_frame, s
  2896. Specify the number of the start frame for starting to apply the fade
  2897. effect. Default is 0.
  2898. @item nb_frames, n
  2899. The number of frames for which the fade effect has to last. At the end of the
  2900. fade-in effect the output video will have the same intensity as the input video,
  2901. at the end of the fade-out transition the output video will be completely black.
  2902. Default is 25.
  2903. @item alpha
  2904. If set to 1, fade only alpha channel, if one exists on the input.
  2905. Default value is 0.
  2906. @item start_time, st
  2907. Specify the timestamp (in seconds) of the frame to start to apply the fade
  2908. effect. If both start_frame and start_time are specified, the fade will start at
  2909. whichever comes last. Default is 0.
  2910. @item duration, d
  2911. The number of seconds for which the fade effect has to last. At the end of the
  2912. fade-in effect the output video will have the same intensity as the input video,
  2913. at the end of the fade-out transition the output video will be completely black.
  2914. If both duration and nb_frames are specified, duration is used. Default is 0.
  2915. @end table
  2916. @subsection Examples
  2917. @itemize
  2918. @item
  2919. Fade in first 30 frames of video:
  2920. @example
  2921. fade=in:0:30
  2922. @end example
  2923. The command above is equivalent to:
  2924. @example
  2925. fade=t=in:s=0:n=30
  2926. @end example
  2927. @item
  2928. Fade out last 45 frames of a 200-frame video:
  2929. @example
  2930. fade=out:155:45
  2931. fade=type=out:start_frame=155:nb_frames=45
  2932. @end example
  2933. @item
  2934. Fade in first 25 frames and fade out last 25 frames of a 1000-frame video:
  2935. @example
  2936. fade=in:0:25, fade=out:975:25
  2937. @end example
  2938. @item
  2939. Make first 5 frames black, then fade in from frame 5-24:
  2940. @example
  2941. fade=in:5:20
  2942. @end example
  2943. @item
  2944. Fade in alpha over first 25 frames of video:
  2945. @example
  2946. fade=in:0:25:alpha=1
  2947. @end example
  2948. @item
  2949. Make first 5.5 seconds black, then fade in for 0.5 seconds:
  2950. @example
  2951. fade=t=in:st=5.5:d=0.5
  2952. @end example
  2953. @end itemize
  2954. @section field
  2955. Extract a single field from an interlaced image using stride
  2956. arithmetic to avoid wasting CPU time. The output frames are marked as
  2957. non-interlaced.
  2958. The filter accepts the following options:
  2959. @table @option
  2960. @item type
  2961. Specify whether to extract the top (if the value is @code{0} or
  2962. @code{top}) or the bottom field (if the value is @code{1} or
  2963. @code{bottom}).
  2964. @end table
  2965. @section fieldmatch
  2966. Field matching filter for inverse telecine. It is meant to reconstruct the
  2967. progressive frames from a telecined stream. The filter does not drop duplicated
  2968. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  2969. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  2970. The separation of the field matching and the decimation is notably motivated by
  2971. the possibility of inserting a de-interlacing filter fallback between the two.
  2972. If the source has mixed telecined and real interlaced content,
  2973. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  2974. But these remaining combed frames will be marked as interlaced, and thus can be
  2975. de-interlaced by a later filter such as @ref{yadif} before decimation.
  2976. In addition to the various configuration options, @code{fieldmatch} can take an
  2977. optional second stream, activated through the @option{ppsrc} option. If
  2978. enabled, the frames reconstruction will be based on the fields and frames from
  2979. this second stream. This allows the first input to be pre-processed in order to
  2980. help the various algorithms of the filter, while keeping the output lossless
  2981. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  2982. or brightness/contrast adjustments can help.
  2983. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  2984. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  2985. which @code{fieldmatch} is based on. While the semantic and usage are very
  2986. close, some behaviour and options names can differ.
  2987. The filter accepts the following options:
  2988. @table @option
  2989. @item order
  2990. Specify the assumed field order of the input stream. Available values are:
  2991. @table @samp
  2992. @item auto
  2993. Auto detect parity (use FFmpeg's internal parity value).
  2994. @item bff
  2995. Assume bottom field first.
  2996. @item tff
  2997. Assume top field first.
  2998. @end table
  2999. Note that it is sometimes recommended not to trust the parity announced by the
  3000. stream.
  3001. Default value is @var{auto}.
  3002. @item mode
  3003. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  3004. sense that it won't risk creating jerkiness due to duplicate frames when
  3005. possible, but if there are bad edits or blended fields it will end up
  3006. outputting combed frames when a good match might actually exist. On the other
  3007. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  3008. but will almost always find a good frame if there is one. The other values are
  3009. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  3010. jerkiness and creating duplicate frames versus finding good matches in sections
  3011. with bad edits, orphaned fields, blended fields, etc.
  3012. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  3013. Available values are:
  3014. @table @samp
  3015. @item pc
  3016. 2-way matching (p/c)
  3017. @item pc_n
  3018. 2-way matching, and trying 3rd match if still combed (p/c + n)
  3019. @item pc_u
  3020. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  3021. @item pc_n_ub
  3022. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  3023. still combed (p/c + n + u/b)
  3024. @item pcn
  3025. 3-way matching (p/c/n)
  3026. @item pcn_ub
  3027. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  3028. detected as combed (p/c/n + u/b)
  3029. @end table
  3030. The parenthesis at the end indicate the matches that would be used for that
  3031. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  3032. @var{top}).
  3033. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  3034. the slowest.
  3035. Default value is @var{pc_n}.
  3036. @item ppsrc
  3037. Mark the main input stream as a pre-processed input, and enable the secondary
  3038. input stream as the clean source to pick the fields from. See the filter
  3039. introduction for more details. It is similar to the @option{clip2} feature from
  3040. VFM/TFM.
  3041. Default value is @code{0} (disabled).
  3042. @item field
  3043. Set the field to match from. It is recommended to set this to the same value as
  3044. @option{order} unless you experience matching failures with that setting. In
  3045. certain circumstances changing the field that is used to match from can have a
  3046. large impact on matching performance. Available values are:
  3047. @table @samp
  3048. @item auto
  3049. Automatic (same value as @option{order}).
  3050. @item bottom
  3051. Match from the bottom field.
  3052. @item top
  3053. Match from the top field.
  3054. @end table
  3055. Default value is @var{auto}.
  3056. @item mchroma
  3057. Set whether or not chroma is included during the match comparisons. In most
  3058. cases it is recommended to leave this enabled. You should set this to @code{0}
  3059. only if your clip has bad chroma problems such as heavy rainbowing or other
  3060. artifacts. Setting this to @code{0} could also be used to speed things up at
  3061. the cost of some accuracy.
  3062. Default value is @code{1}.
  3063. @item y0
  3064. @item y1
  3065. These define an exclusion band which excludes the lines between @option{y0} and
  3066. @option{y1} from being included in the field matching decision. An exclusion
  3067. band can be used to ignore subtitles, a logo, or other things that may
  3068. interfere with the matching. @option{y0} sets the starting scan line and
  3069. @option{y1} sets the ending line; all lines in between @option{y0} and
  3070. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  3071. @option{y0} and @option{y1} to the same value will disable the feature.
  3072. @option{y0} and @option{y1} defaults to @code{0}.
  3073. @item scthresh
  3074. Set the scene change detection threshold as a percentage of maximum change on
  3075. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  3076. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  3077. @option{scthresh} is @code{[0.0, 100.0]}.
  3078. Default value is @code{12.0}.
  3079. @item combmatch
  3080. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  3081. account the combed scores of matches when deciding what match to use as the
  3082. final match. Available values are:
  3083. @table @samp
  3084. @item none
  3085. No final matching based on combed scores.
  3086. @item sc
  3087. Combed scores are only used when a scene change is detected.
  3088. @item full
  3089. Use combed scores all the time.
  3090. @end table
  3091. Default is @var{sc}.
  3092. @item combdbg
  3093. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  3094. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  3095. Available values are:
  3096. @table @samp
  3097. @item none
  3098. No forced calculation.
  3099. @item pcn
  3100. Force p/c/n calculations.
  3101. @item pcnub
  3102. Force p/c/n/u/b calculations.
  3103. @end table
  3104. Default value is @var{none}.
  3105. @item cthresh
  3106. This is the area combing threshold used for combed frame detection. This
  3107. essentially controls how "strong" or "visible" combing must be to be detected.
  3108. Larger values mean combing must be more visible and smaller values mean combing
  3109. can be less visible or strong and still be detected. Valid settings are from
  3110. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  3111. be detected as combed). This is basically a pixel difference value. A good
  3112. range is @code{[8, 12]}.
  3113. Default value is @code{9}.
  3114. @item chroma
  3115. Sets whether or not chroma is considered in the combed frame decision. Only
  3116. disable this if your source has chroma problems (rainbowing, etc.) that are
  3117. causing problems for the combed frame detection with chroma enabled. Actually,
  3118. using @option{chroma}=@var{0} is usually more reliable, except for the case
  3119. where there is chroma only combing in the source.
  3120. Default value is @code{0}.
  3121. @item blockx
  3122. @item blocky
  3123. Respectively set the x-axis and y-axis size of the window used during combed
  3124. frame detection. This has to do with the size of the area in which
  3125. @option{combpel} pixels are required to be detected as combed for a frame to be
  3126. declared combed. See the @option{combpel} parameter description for more info.
  3127. Possible values are any number that is a power of 2 starting at 4 and going up
  3128. to 512.
  3129. Default value is @code{16}.
  3130. @item combpel
  3131. The number of combed pixels inside any of the @option{blocky} by
  3132. @option{blockx} size blocks on the frame for the frame to be detected as
  3133. combed. While @option{cthresh} controls how "visible" the combing must be, this
  3134. setting controls "how much" combing there must be in any localized area (a
  3135. window defined by the @option{blockx} and @option{blocky} settings) on the
  3136. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  3137. which point no frames will ever be detected as combed). This setting is known
  3138. as @option{MI} in TFM/VFM vocabulary.
  3139. Default value is @code{80}.
  3140. @end table
  3141. @anchor{p/c/n/u/b meaning}
  3142. @subsection p/c/n/u/b meaning
  3143. @subsubsection p/c/n
  3144. We assume the following telecined stream:
  3145. @example
  3146. Top fields: 1 2 2 3 4
  3147. Bottom fields: 1 2 3 4 4
  3148. @end example
  3149. The numbers correspond to the progressive frame the fields relate to. Here, the
  3150. first two frames are progressive, the 3rd and 4th are combed, and so on.
  3151. When @code{fieldmatch} is configured to run a matching from bottom
  3152. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  3153. @example
  3154. Input stream:
  3155. T 1 2 2 3 4
  3156. B 1 2 3 4 4 <-- matching reference
  3157. Matches: c c n n c
  3158. Output stream:
  3159. T 1 2 3 4 4
  3160. B 1 2 3 4 4
  3161. @end example
  3162. As a result of the field matching, we can see that some frames get duplicated.
  3163. To perform a complete inverse telecine, you need to rely on a decimation filter
  3164. after this operation. See for instance the @ref{decimate} filter.
  3165. The same operation now matching from top fields (@option{field}=@var{top})
  3166. looks like this:
  3167. @example
  3168. Input stream:
  3169. T 1 2 2 3 4 <-- matching reference
  3170. B 1 2 3 4 4
  3171. Matches: c c p p c
  3172. Output stream:
  3173. T 1 2 2 3 4
  3174. B 1 2 2 3 4
  3175. @end example
  3176. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  3177. basically, they refer to the frame and field of the opposite parity:
  3178. @itemize
  3179. @item @var{p} matches the field of the opposite parity in the previous frame
  3180. @item @var{c} matches the field of the opposite parity in the current frame
  3181. @item @var{n} matches the field of the opposite parity in the next frame
  3182. @end itemize
  3183. @subsubsection u/b
  3184. The @var{u} and @var{b} matching are a bit special in the sense that they match
  3185. from the opposite parity flag. In the following examples, we assume that we are
  3186. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  3187. 'x' is placed above and below each matched fields.
  3188. With bottom matching (@option{field}=@var{bottom}):
  3189. @example
  3190. Match: c p n b u
  3191. x x x x x
  3192. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  3193. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  3194. x x x x x
  3195. Output frames:
  3196. 2 1 2 2 2
  3197. 2 2 2 1 3
  3198. @end example
  3199. With top matching (@option{field}=@var{top}):
  3200. @example
  3201. Match: c p n b u
  3202. x x x x x
  3203. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  3204. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  3205. x x x x x
  3206. Output frames:
  3207. 2 2 2 1 2
  3208. 2 1 3 2 2
  3209. @end example
  3210. @subsection Examples
  3211. Simple IVTC of a top field first telecined stream:
  3212. @example
  3213. fieldmatch=order=tff:combmatch=none, decimate
  3214. @end example
  3215. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  3216. @example
  3217. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  3218. @end example
  3219. @section fieldorder
  3220. Transform the field order of the input video.
  3221. This filter accepts the following options:
  3222. @table @option
  3223. @item order
  3224. Output field order. Valid values are @var{tff} for top field first or @var{bff}
  3225. for bottom field first.
  3226. @end table
  3227. Default value is @samp{tff}.
  3228. Transformation is achieved by shifting the picture content up or down
  3229. by one line, and filling the remaining line with appropriate picture content.
  3230. This method is consistent with most broadcast field order converters.
  3231. If the input video is not flagged as being interlaced, or it is already
  3232. flagged as being of the required output field order then this filter does
  3233. not alter the incoming video.
  3234. This filter is very useful when converting to or from PAL DV material,
  3235. which is bottom field first.
  3236. For example:
  3237. @example
  3238. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  3239. @end example
  3240. @section fifo
  3241. Buffer input images and send them when they are requested.
  3242. This filter is mainly useful when auto-inserted by the libavfilter
  3243. framework.
  3244. The filter does not take parameters.
  3245. @anchor{format}
  3246. @section format
  3247. Convert the input video to one of the specified pixel formats.
  3248. Libavfilter will try to pick one that is supported for the input to
  3249. the next filter.
  3250. This filter accepts the following parameters:
  3251. @table @option
  3252. @item pix_fmts
  3253. A '|'-separated list of pixel format names, for example
  3254. "pix_fmts=yuv420p|monow|rgb24".
  3255. @end table
  3256. @subsection Examples
  3257. @itemize
  3258. @item
  3259. Convert the input video to the format @var{yuv420p}
  3260. @example
  3261. format=pix_fmts=yuv420p
  3262. @end example
  3263. Convert the input video to any of the formats in the list
  3264. @example
  3265. format=pix_fmts=yuv420p|yuv444p|yuv410p
  3266. @end example
  3267. @end itemize
  3268. @section fps
  3269. Convert the video to specified constant frame rate by duplicating or dropping
  3270. frames as necessary.
  3271. This filter accepts the following named parameters:
  3272. @table @option
  3273. @item fps
  3274. Desired output frame rate. The default is @code{25}.
  3275. @item round
  3276. Rounding method.
  3277. Possible values are:
  3278. @table @option
  3279. @item zero
  3280. zero round towards 0
  3281. @item inf
  3282. round away from 0
  3283. @item down
  3284. round towards -infinity
  3285. @item up
  3286. round towards +infinity
  3287. @item near
  3288. round to nearest
  3289. @end table
  3290. The default is @code{near}.
  3291. @item start_time
  3292. Assume the first PTS should be the given value, in seconds. This allows for
  3293. padding/trimming at the start of stream. By default, no assumption is made
  3294. about the first frame's expected PTS, so no padding or trimming is done.
  3295. For example, this could be set to 0 to pad the beginning with duplicates of
  3296. the first frame if a video stream starts after the audio stream or to trim any
  3297. frames with a negative PTS.
  3298. @end table
  3299. Alternatively, the options can be specified as a flat string:
  3300. @var{fps}[:@var{round}].
  3301. See also the @ref{setpts} filter.
  3302. @subsection Examples
  3303. @itemize
  3304. @item
  3305. A typical usage in order to set the fps to 25:
  3306. @example
  3307. fps=fps=25
  3308. @end example
  3309. @item
  3310. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  3311. @example
  3312. fps=fps=film:round=near
  3313. @end example
  3314. @end itemize
  3315. @section framestep
  3316. Select one frame every N-th frame.
  3317. This filter accepts the following option:
  3318. @table @option
  3319. @item step
  3320. Select frame after every @code{step} frames.
  3321. Allowed values are positive integers higher than 0. Default value is @code{1}.
  3322. @end table
  3323. @anchor{frei0r}
  3324. @section frei0r
  3325. Apply a frei0r effect to the input video.
  3326. To enable compilation of this filter you need to install the frei0r
  3327. header and configure FFmpeg with @code{--enable-frei0r}.
  3328. This filter accepts the following options:
  3329. @table @option
  3330. @item filter_name
  3331. The name to the frei0r effect to load. If the environment variable
  3332. @env{FREI0R_PATH} is defined, the frei0r effect is searched in each one of the
  3333. directories specified by the colon separated list in @env{FREIOR_PATH},
  3334. otherwise in the standard frei0r paths, which are in this order:
  3335. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  3336. @file{/usr/lib/frei0r-1/}.
  3337. @item filter_params
  3338. A '|'-separated list of parameters to pass to the frei0r effect.
  3339. @end table
  3340. A frei0r effect parameter can be a boolean (whose values are specified
  3341. with "y" and "n"), a double, a color (specified by the syntax
  3342. @var{R}/@var{G}/@var{B}, (@var{R}, @var{G}, and @var{B} being float
  3343. numbers from 0.0 to 1.0) or by a color description specified in the "Color"
  3344. section in the ffmpeg-utils manual), a position (specified by the syntax @var{X}/@var{Y},
  3345. @var{X} and @var{Y} being float numbers) and a string.
  3346. The number and kind of parameters depend on the loaded effect. If an
  3347. effect parameter is not specified the default value is set.
  3348. @subsection Examples
  3349. @itemize
  3350. @item
  3351. Apply the distort0r effect, set the first two double parameters:
  3352. @example
  3353. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  3354. @end example
  3355. @item
  3356. Apply the colordistance effect, take a color as first parameter:
  3357. @example
  3358. frei0r=colordistance:0.2/0.3/0.4
  3359. frei0r=colordistance:violet
  3360. frei0r=colordistance:0x112233
  3361. @end example
  3362. @item
  3363. Apply the perspective effect, specify the top left and top right image
  3364. positions:
  3365. @example
  3366. frei0r=perspective:0.2/0.2|0.8/0.2
  3367. @end example
  3368. @end itemize
  3369. For more information see:
  3370. @url{http://frei0r.dyne.org}
  3371. @section geq
  3372. The filter accepts the following options:
  3373. @table @option
  3374. @item lum_expr, lum
  3375. Set the luminance expression.
  3376. @item cb_expr, cb
  3377. Set the chrominance blue expression.
  3378. @item cr_expr, cr
  3379. Set the chrominance red expression.
  3380. @item alpha_expr, a
  3381. Set the alpha expression.
  3382. @item red_expr, r
  3383. Set the red expression.
  3384. @item green_expr, g
  3385. Set the green expression.
  3386. @item blue_expr, b
  3387. Set the blue expression.
  3388. @end table
  3389. The colorspace is selected according to the specified options. If one
  3390. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  3391. options is specified, the filter will automatically select a YCbCr
  3392. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  3393. @option{blue_expr} options is specified, it will select an RGB
  3394. colorspace.
  3395. If one of the chrominance expression is not defined, it falls back on the other
  3396. one. If no alpha expression is specified it will evaluate to opaque value.
  3397. If none of chrominance expressions are specified, they will evaluate
  3398. to the luminance expression.
  3399. The expressions can use the following variables and functions:
  3400. @table @option
  3401. @item N
  3402. The sequential number of the filtered frame, starting from @code{0}.
  3403. @item X
  3404. @item Y
  3405. The coordinates of the current sample.
  3406. @item W
  3407. @item H
  3408. The width and height of the image.
  3409. @item SW
  3410. @item SH
  3411. Width and height scale depending on the currently filtered plane. It is the
  3412. ratio between the corresponding luma plane number of pixels and the current
  3413. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  3414. @code{0.5,0.5} for chroma planes.
  3415. @item T
  3416. Time of the current frame, expressed in seconds.
  3417. @item p(x, y)
  3418. Return the value of the pixel at location (@var{x},@var{y}) of the current
  3419. plane.
  3420. @item lum(x, y)
  3421. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  3422. plane.
  3423. @item cb(x, y)
  3424. Return the value of the pixel at location (@var{x},@var{y}) of the
  3425. blue-difference chroma plane. Return 0 if there is no such plane.
  3426. @item cr(x, y)
  3427. Return the value of the pixel at location (@var{x},@var{y}) of the
  3428. red-difference chroma plane. Return 0 if there is no such plane.
  3429. @item r(x, y)
  3430. @item g(x, y)
  3431. @item b(x, y)
  3432. Return the value of the pixel at location (@var{x},@var{y}) of the
  3433. red/green/blue component. Return 0 if there is no such component.
  3434. @item alpha(x, y)
  3435. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  3436. plane. Return 0 if there is no such plane.
  3437. @end table
  3438. For functions, if @var{x} and @var{y} are outside the area, the value will be
  3439. automatically clipped to the closer edge.
  3440. @subsection Examples
  3441. @itemize
  3442. @item
  3443. Flip the image horizontally:
  3444. @example
  3445. geq=p(W-X\,Y)
  3446. @end example
  3447. @item
  3448. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  3449. wavelength of 100 pixels:
  3450. @example
  3451. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  3452. @end example
  3453. @item
  3454. Generate a fancy enigmatic moving light:
  3455. @example
  3456. 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
  3457. @end example
  3458. @item
  3459. Generate a quick emboss effect:
  3460. @example
  3461. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  3462. @end example
  3463. @item
  3464. Modify RGB components depending on pixel position:
  3465. @example
  3466. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  3467. @end example
  3468. @end itemize
  3469. @section gradfun
  3470. Fix the banding artifacts that are sometimes introduced into nearly flat
  3471. regions by truncation to 8bit color depth.
  3472. Interpolate the gradients that should go where the bands are, and
  3473. dither them.
  3474. This filter is designed for playback only. Do not use it prior to
  3475. lossy compression, because compression tends to lose the dither and
  3476. bring back the bands.
  3477. This filter accepts the following options:
  3478. @table @option
  3479. @item strength
  3480. The maximum amount by which the filter will change any one pixel. Also the
  3481. threshold for detecting nearly flat regions. Acceptable values range from .51 to
  3482. 64, default value is 1.2, out-of-range values will be clipped to the valid
  3483. range.
  3484. @item radius
  3485. The neighborhood to fit the gradient to. A larger radius makes for smoother
  3486. gradients, but also prevents the filter from modifying the pixels near detailed
  3487. regions. Acceptable values are 8-32, default value is 16, out-of-range values
  3488. will be clipped to the valid range.
  3489. @end table
  3490. Alternatively, the options can be specified as a flat string:
  3491. @var{strength}[:@var{radius}]
  3492. @subsection Examples
  3493. @itemize
  3494. @item
  3495. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  3496. @example
  3497. gradfun=3.5:8
  3498. @end example
  3499. @item
  3500. Specify radius, omitting the strength (which will fall-back to the default
  3501. value):
  3502. @example
  3503. gradfun=radius=8
  3504. @end example
  3505. @end itemize
  3506. @anchor{haldclut}
  3507. @section haldclut
  3508. Apply a Hald CLUT to a video stream.
  3509. First input is the video stream to process, and second one is the Hald CLUT.
  3510. The Hald CLUT input can be a simple picture or a complete video stream.
  3511. The filter accepts the following options:
  3512. @table @option
  3513. @item shortest
  3514. Force termination when the shortest input terminates. Default is @code{0}.
  3515. @item repeatlast
  3516. Continue applying the last CLUT after the end of the stream. A value of
  3517. @code{0} disable the filter after the last frame of the CLUT is reached.
  3518. Default is @code{1}.
  3519. @end table
  3520. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  3521. filters share the same internals).
  3522. More information about the Hald CLUT can be found on Eskil Steenberg's website
  3523. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  3524. @subsection Workflow examples
  3525. @subsubsection Hald CLUT video stream
  3526. Generate an identity Hald CLUT stream altered with various effects:
  3527. @example
  3528. 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
  3529. @end example
  3530. Note: make sure you use a lossless codec.
  3531. Then use it with @code{haldclut} to apply it on some random stream:
  3532. @example
  3533. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  3534. @end example
  3535. The Hald CLUT will be applied to the 10 first seconds (duration of
  3536. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  3537. to the remaining frames of the @code{mandelbrot} stream.
  3538. @subsubsection Hald CLUT with preview
  3539. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  3540. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  3541. biggest possible square starting at the top left of the picture. The remaining
  3542. padding pixels (bottom or right) will be ignored. This area can be used to add
  3543. a preview of the Hald CLUT.
  3544. Typically, the following generated Hald CLUT will be supported by the
  3545. @code{haldclut} filter:
  3546. @example
  3547. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  3548. pad=iw+320 [padded_clut];
  3549. smptebars=s=320x256, split [a][b];
  3550. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  3551. [main][b] overlay=W-320" -frames:v 1 clut.png
  3552. @end example
  3553. It contains the original and a preview of the effect of the CLUT: SMPTE color
  3554. bars are displayed on the right-top, and below the same color bars processed by
  3555. the color changes.
  3556. Then, the effect of this Hald CLUT can be visualized with:
  3557. @example
  3558. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  3559. @end example
  3560. @section hflip
  3561. Flip the input video horizontally.
  3562. For example to horizontally flip the input video with @command{ffmpeg}:
  3563. @example
  3564. ffmpeg -i in.avi -vf "hflip" out.avi
  3565. @end example
  3566. @section histeq
  3567. This filter applies a global color histogram equalization on a
  3568. per-frame basis.
  3569. It can be used to correct video that has a compressed range of pixel
  3570. intensities. The filter redistributes the pixel intensities to
  3571. equalize their distribution across the intensity range. It may be
  3572. viewed as an "automatically adjusting contrast filter". This filter is
  3573. useful only for correcting degraded or poorly captured source
  3574. video.
  3575. The filter accepts the following options:
  3576. @table @option
  3577. @item strength
  3578. Determine the amount of equalization to be applied. As the strength
  3579. is reduced, the distribution of pixel intensities more-and-more
  3580. approaches that of the input frame. The value must be a float number
  3581. in the range [0,1] and defaults to 0.200.
  3582. @item intensity
  3583. Set the maximum intensity that can generated and scale the output
  3584. values appropriately. The strength should be set as desired and then
  3585. the intensity can be limited if needed to avoid washing-out. The value
  3586. must be a float number in the range [0,1] and defaults to 0.210.
  3587. @item antibanding
  3588. Set the antibanding level. If enabled the filter will randomly vary
  3589. the luminance of output pixels by a small amount to avoid banding of
  3590. the histogram. Possible values are @code{none}, @code{weak} or
  3591. @code{strong}. It defaults to @code{none}.
  3592. @end table
  3593. @section histogram
  3594. Compute and draw a color distribution histogram for the input video.
  3595. The computed histogram is a representation of distribution of color components
  3596. in an image.
  3597. The filter accepts the following options:
  3598. @table @option
  3599. @item mode
  3600. Set histogram mode.
  3601. It accepts the following values:
  3602. @table @samp
  3603. @item levels
  3604. standard histogram that display color components distribution in an image.
  3605. Displays color graph for each color component. Shows distribution
  3606. of the Y, U, V, A or R, G, B components, depending on input format,
  3607. in current frame. Bellow each graph is color component scale meter.
  3608. @item color
  3609. chroma values in vectorscope, if brighter more such chroma values are
  3610. distributed in an image.
  3611. Displays chroma values (U/V color placement) in two dimensional graph
  3612. (which is called a vectorscope). It can be used to read of the hue and
  3613. saturation of the current frame. At a same time it is a histogram.
  3614. The whiter a pixel in the vectorscope, the more pixels of the input frame
  3615. correspond to that pixel (that is the more pixels have this chroma value).
  3616. The V component is displayed on the horizontal (X) axis, with the leftmost
  3617. side being V = 0 and the rightmost side being V = 255.
  3618. The U component is displayed on the vertical (Y) axis, with the top
  3619. representing U = 0 and the bottom representing U = 255.
  3620. The position of a white pixel in the graph corresponds to the chroma value
  3621. of a pixel of the input clip. So the graph can be used to read of the
  3622. hue (color flavor) and the saturation (the dominance of the hue in the color).
  3623. As the hue of a color changes, it moves around the square. At the center of
  3624. the square, the saturation is zero, which means that the corresponding pixel
  3625. has no color. If you increase the amount of a specific color, while leaving
  3626. the other colors unchanged, the saturation increases, and you move towards
  3627. the edge of the square.
  3628. @item color2
  3629. chroma values in vectorscope, similar as @code{color} but actual chroma values
  3630. are displayed.
  3631. @item waveform
  3632. per row/column color component graph. In row mode graph in the left side represents
  3633. color component value 0 and right side represents value = 255. In column mode top
  3634. side represents color component value = 0 and bottom side represents value = 255.
  3635. @end table
  3636. Default value is @code{levels}.
  3637. @item level_height
  3638. Set height of level in @code{levels}. Default value is @code{200}.
  3639. Allowed range is [50, 2048].
  3640. @item scale_height
  3641. Set height of color scale in @code{levels}. Default value is @code{12}.
  3642. Allowed range is [0, 40].
  3643. @item step
  3644. Set step for @code{waveform} mode. Smaller values are useful to find out how much
  3645. of same luminance values across input rows/columns are distributed.
  3646. Default value is @code{10}. Allowed range is [1, 255].
  3647. @item waveform_mode
  3648. Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
  3649. Default is @code{row}.
  3650. @item waveform_mirror
  3651. Set mirroring mode for @code{waveform}. @code{0} means unmirrored, @code{1}
  3652. means mirrored. In mirrored mode, higher values will be represented on the left
  3653. side for @code{row} mode and at the top for @code{column} mode. Default is
  3654. @code{0} (unmirrored).
  3655. @item display_mode
  3656. Set display mode for @code{waveform} and @code{levels}.
  3657. It accepts the following values:
  3658. @table @samp
  3659. @item parade
  3660. Display separate graph for the color components side by side in
  3661. @code{row} waveform mode or one below other in @code{column} waveform mode
  3662. for @code{waveform} histogram mode. For @code{levels} histogram mode
  3663. per color component graphs are placed one bellow other.
  3664. This display mode in @code{waveform} histogram mode makes it easy to spot
  3665. color casts in the highlights and shadows of an image, by comparing the
  3666. contours of the top and the bottom of each waveform.
  3667. Since whites, grays, and blacks are characterized by
  3668. exactly equal amounts of red, green, and blue, neutral areas of the
  3669. picture should display three waveforms of roughly equal width/height.
  3670. If not, the correction is easy to make by making adjustments to level the
  3671. three waveforms.
  3672. @item overlay
  3673. Presents information that's identical to that in the @code{parade}, except
  3674. that the graphs representing color components are superimposed directly
  3675. over one another.
  3676. This display mode in @code{waveform} histogram mode can make it easier to spot
  3677. the relative differences or similarities in overlapping areas of the color
  3678. components that are supposed to be identical, such as neutral whites, grays,
  3679. or blacks.
  3680. @end table
  3681. Default is @code{parade}.
  3682. @item levels_mode
  3683. Set mode for @code{levels}. Can be either @code{linear}, or @code{logarithmic}.
  3684. Default is @code{linear}.
  3685. @end table
  3686. @subsection Examples
  3687. @itemize
  3688. @item
  3689. Calculate and draw histogram:
  3690. @example
  3691. ffplay -i input -vf histogram
  3692. @end example
  3693. @end itemize
  3694. @anchor{hqdn3d}
  3695. @section hqdn3d
  3696. High precision/quality 3d denoise filter. This filter aims to reduce
  3697. image noise producing smooth images and making still images really
  3698. still. It should enhance compressibility.
  3699. It accepts the following optional parameters:
  3700. @table @option
  3701. @item luma_spatial
  3702. a non-negative float number which specifies spatial luma strength,
  3703. defaults to 4.0
  3704. @item chroma_spatial
  3705. a non-negative float number which specifies spatial chroma strength,
  3706. defaults to 3.0*@var{luma_spatial}/4.0
  3707. @item luma_tmp
  3708. a float number which specifies luma temporal strength, defaults to
  3709. 6.0*@var{luma_spatial}/4.0
  3710. @item chroma_tmp
  3711. a float number which specifies chroma temporal strength, defaults to
  3712. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
  3713. @end table
  3714. @section hue
  3715. Modify the hue and/or the saturation of the input.
  3716. This filter accepts the following options:
  3717. @table @option
  3718. @item h
  3719. Specify the hue angle as a number of degrees. It accepts an expression,
  3720. and defaults to "0".
  3721. @item s
  3722. Specify the saturation in the [-10,10] range. It accepts an expression and
  3723. defaults to "1".
  3724. @item H
  3725. Specify the hue angle as a number of radians. It accepts an
  3726. expression, and defaults to "0".
  3727. @item b
  3728. Specify the brightness in the [-10,10] range. It accepts an expression and
  3729. defaults to "0".
  3730. @end table
  3731. @option{h} and @option{H} are mutually exclusive, and can't be
  3732. specified at the same time.
  3733. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  3734. expressions containing the following constants:
  3735. @table @option
  3736. @item n
  3737. frame count of the input frame starting from 0
  3738. @item pts
  3739. presentation timestamp of the input frame expressed in time base units
  3740. @item r
  3741. frame rate of the input video, NAN if the input frame rate is unknown
  3742. @item t
  3743. timestamp expressed in seconds, NAN if the input timestamp is unknown
  3744. @item tb
  3745. time base of the input video
  3746. @end table
  3747. @subsection Examples
  3748. @itemize
  3749. @item
  3750. Set the hue to 90 degrees and the saturation to 1.0:
  3751. @example
  3752. hue=h=90:s=1
  3753. @end example
  3754. @item
  3755. Same command but expressing the hue in radians:
  3756. @example
  3757. hue=H=PI/2:s=1
  3758. @end example
  3759. @item
  3760. Rotate hue and make the saturation swing between 0
  3761. and 2 over a period of 1 second:
  3762. @example
  3763. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  3764. @end example
  3765. @item
  3766. Apply a 3 seconds saturation fade-in effect starting at 0:
  3767. @example
  3768. hue="s=min(t/3\,1)"
  3769. @end example
  3770. The general fade-in expression can be written as:
  3771. @example
  3772. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  3773. @end example
  3774. @item
  3775. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  3776. @example
  3777. hue="s=max(0\, min(1\, (8-t)/3))"
  3778. @end example
  3779. The general fade-out expression can be written as:
  3780. @example
  3781. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  3782. @end example
  3783. @end itemize
  3784. @subsection Commands
  3785. This filter supports the following commands:
  3786. @table @option
  3787. @item b
  3788. @item s
  3789. @item h
  3790. @item H
  3791. Modify the hue and/or the saturation and/or brightness of the input video.
  3792. The command accepts the same syntax of the corresponding option.
  3793. If the specified expression is not valid, it is kept at its current
  3794. value.
  3795. @end table
  3796. @section idet
  3797. Detect video interlacing type.
  3798. This filter tries to detect if the input is interlaced or progressive,
  3799. top or bottom field first.
  3800. The filter accepts the following options:
  3801. @table @option
  3802. @item intl_thres
  3803. Set interlacing threshold.
  3804. @item prog_thres
  3805. Set progressive threshold.
  3806. @end table
  3807. @section il
  3808. Deinterleave or interleave fields.
  3809. This filter allows to process interlaced images fields without
  3810. deinterlacing them. Deinterleaving splits the input frame into 2
  3811. fields (so called half pictures). Odd lines are moved to the top
  3812. half of the output image, even lines to the bottom half.
  3813. You can process (filter) them independently and then re-interleave them.
  3814. The filter accepts the following options:
  3815. @table @option
  3816. @item luma_mode, l
  3817. @item chroma_mode, c
  3818. @item alpha_mode, a
  3819. Available values for @var{luma_mode}, @var{chroma_mode} and
  3820. @var{alpha_mode} are:
  3821. @table @samp
  3822. @item none
  3823. Do nothing.
  3824. @item deinterleave, d
  3825. Deinterleave fields, placing one above the other.
  3826. @item interleave, i
  3827. Interleave fields. Reverse the effect of deinterleaving.
  3828. @end table
  3829. Default value is @code{none}.
  3830. @item luma_swap, ls
  3831. @item chroma_swap, cs
  3832. @item alpha_swap, as
  3833. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  3834. @end table
  3835. @section interlace
  3836. Simple interlacing filter from progressive contents. This interleaves upper (or
  3837. lower) lines from odd frames with lower (or upper) lines from even frames,
  3838. halving the frame rate and preserving image height.
  3839. @example
  3840. Original Original New Frame
  3841. Frame 'j' Frame 'j+1' (tff)
  3842. ========== =========== ==================
  3843. Line 0 --------------------> Frame 'j' Line 0
  3844. Line 1 Line 1 ----> Frame 'j+1' Line 1
  3845. Line 2 ---------------------> Frame 'j' Line 2
  3846. Line 3 Line 3 ----> Frame 'j+1' Line 3
  3847. ... ... ...
  3848. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  3849. @end example
  3850. It accepts the following optional parameters:
  3851. @table @option
  3852. @item scan
  3853. determines whether the interlaced frame is taken from the even (tff - default)
  3854. or odd (bff) lines of the progressive frame.
  3855. @item lowpass
  3856. Enable (default) or disable the vertical lowpass filter to avoid twitter
  3857. interlacing and reduce moire patterns.
  3858. @end table
  3859. @section kerndeint
  3860. Deinterlace input video by applying Donald Graft's adaptive kernel
  3861. deinterling. Work on interlaced parts of a video to produce
  3862. progressive frames.
  3863. The description of the accepted parameters follows.
  3864. @table @option
  3865. @item thresh
  3866. Set the threshold which affects the filter's tolerance when
  3867. determining if a pixel line must be processed. It must be an integer
  3868. in the range [0,255] and defaults to 10. A value of 0 will result in
  3869. applying the process on every pixels.
  3870. @item map
  3871. Paint pixels exceeding the threshold value to white if set to 1.
  3872. Default is 0.
  3873. @item order
  3874. Set the fields order. Swap fields if set to 1, leave fields alone if
  3875. 0. Default is 0.
  3876. @item sharp
  3877. Enable additional sharpening if set to 1. Default is 0.
  3878. @item twoway
  3879. Enable twoway sharpening if set to 1. Default is 0.
  3880. @end table
  3881. @subsection Examples
  3882. @itemize
  3883. @item
  3884. Apply default values:
  3885. @example
  3886. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  3887. @end example
  3888. @item
  3889. Enable additional sharpening:
  3890. @example
  3891. kerndeint=sharp=1
  3892. @end example
  3893. @item
  3894. Paint processed pixels in white:
  3895. @example
  3896. kerndeint=map=1
  3897. @end example
  3898. @end itemize
  3899. @anchor{lut3d}
  3900. @section lut3d
  3901. Apply a 3D LUT to an input video.
  3902. The filter accepts the following options:
  3903. @table @option
  3904. @item file
  3905. Set the 3D LUT file name.
  3906. Currently supported formats:
  3907. @table @samp
  3908. @item 3dl
  3909. AfterEffects
  3910. @item cube
  3911. Iridas
  3912. @item dat
  3913. DaVinci
  3914. @item m3d
  3915. Pandora
  3916. @end table
  3917. @item interp
  3918. Select interpolation mode.
  3919. Available values are:
  3920. @table @samp
  3921. @item nearest
  3922. Use values from the nearest defined point.
  3923. @item trilinear
  3924. Interpolate values using the 8 points defining a cube.
  3925. @item tetrahedral
  3926. Interpolate values using a tetrahedron.
  3927. @end table
  3928. @end table
  3929. @section lut, lutrgb, lutyuv
  3930. Compute a look-up table for binding each pixel component input value
  3931. to an output value, and apply it to input video.
  3932. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  3933. to an RGB input video.
  3934. These filters accept the following options:
  3935. @table @option
  3936. @item c0
  3937. set first pixel component expression
  3938. @item c1
  3939. set second pixel component expression
  3940. @item c2
  3941. set third pixel component expression
  3942. @item c3
  3943. set fourth pixel component expression, corresponds to the alpha component
  3944. @item r
  3945. set red component expression
  3946. @item g
  3947. set green component expression
  3948. @item b
  3949. set blue component expression
  3950. @item a
  3951. alpha component expression
  3952. @item y
  3953. set Y/luminance component expression
  3954. @item u
  3955. set U/Cb component expression
  3956. @item v
  3957. set V/Cr component expression
  3958. @end table
  3959. Each of them specifies the expression to use for computing the lookup table for
  3960. the corresponding pixel component values.
  3961. The exact component associated to each of the @var{c*} options depends on the
  3962. format in input.
  3963. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  3964. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  3965. The expressions can contain the following constants and functions:
  3966. @table @option
  3967. @item w
  3968. @item h
  3969. the input width and height
  3970. @item val
  3971. input value for the pixel component
  3972. @item clipval
  3973. the input value clipped in the @var{minval}-@var{maxval} range
  3974. @item maxval
  3975. maximum value for the pixel component
  3976. @item minval
  3977. minimum value for the pixel component
  3978. @item negval
  3979. the negated value for the pixel component value clipped in the
  3980. @var{minval}-@var{maxval} range , it corresponds to the expression
  3981. "maxval-clipval+minval"
  3982. @item clip(val)
  3983. the computed value in @var{val} clipped in the
  3984. @var{minval}-@var{maxval} range
  3985. @item gammaval(gamma)
  3986. the computed gamma correction value of the pixel component value
  3987. clipped in the @var{minval}-@var{maxval} range, corresponds to the
  3988. expression
  3989. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  3990. @end table
  3991. All expressions default to "val".
  3992. @subsection Examples
  3993. @itemize
  3994. @item
  3995. Negate input video:
  3996. @example
  3997. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  3998. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  3999. @end example
  4000. The above is the same as:
  4001. @example
  4002. lutrgb="r=negval:g=negval:b=negval"
  4003. lutyuv="y=negval:u=negval:v=negval"
  4004. @end example
  4005. @item
  4006. Negate luminance:
  4007. @example
  4008. lutyuv=y=negval
  4009. @end example
  4010. @item
  4011. Remove chroma components, turns the video into a graytone image:
  4012. @example
  4013. lutyuv="u=128:v=128"
  4014. @end example
  4015. @item
  4016. Apply a luma burning effect:
  4017. @example
  4018. lutyuv="y=2*val"
  4019. @end example
  4020. @item
  4021. Remove green and blue components:
  4022. @example
  4023. lutrgb="g=0:b=0"
  4024. @end example
  4025. @item
  4026. Set a constant alpha channel value on input:
  4027. @example
  4028. format=rgba,lutrgb=a="maxval-minval/2"
  4029. @end example
  4030. @item
  4031. Correct luminance gamma by a 0.5 factor:
  4032. @example
  4033. lutyuv=y=gammaval(0.5)
  4034. @end example
  4035. @item
  4036. Discard least significant bits of luma:
  4037. @example
  4038. lutyuv=y='bitand(val, 128+64+32)'
  4039. @end example
  4040. @end itemize
  4041. @section mcdeint
  4042. Apply motion-compensation deinterlacing.
  4043. It needs one field per frame as input and must thus be used together
  4044. with yadif=1/3 or equivalent.
  4045. This filter accepts the following options:
  4046. @table @option
  4047. @item mode
  4048. Set the deinterlacing mode.
  4049. It accepts one of the following values:
  4050. @table @samp
  4051. @item fast
  4052. @item medium
  4053. @item slow
  4054. use iterative motion estimation
  4055. @item extra_slow
  4056. like @samp{slow}, but use multiple reference frames.
  4057. @end table
  4058. Default value is @samp{fast}.
  4059. @item parity
  4060. Set the picture field parity assumed for the input video. It must be
  4061. one of the following values:
  4062. @table @samp
  4063. @item 0, tff
  4064. assume top field first
  4065. @item 1, bff
  4066. assume bottom field first
  4067. @end table
  4068. Default value is @samp{bff}.
  4069. @item qp
  4070. Set per-block quantization parameter (QP) used by the internal
  4071. encoder.
  4072. Higher values should result in a smoother motion vector field but less
  4073. optimal individual vectors. Default value is 1.
  4074. @end table
  4075. @section mp
  4076. Apply an MPlayer filter to the input video.
  4077. This filter provides a wrapper around some of the filters of
  4078. MPlayer/MEncoder.
  4079. This wrapper is considered experimental. Some of the wrapped filters
  4080. may not work properly and we may drop support for them, as they will
  4081. be implemented natively into FFmpeg. Thus you should avoid
  4082. depending on them when writing portable scripts.
  4083. The filter accepts the parameters:
  4084. @var{filter_name}[:=]@var{filter_params}
  4085. @var{filter_name} is the name of a supported MPlayer filter,
  4086. @var{filter_params} is a string containing the parameters accepted by
  4087. the named filter.
  4088. The list of the currently supported filters follows:
  4089. @table @var
  4090. @item eq2
  4091. @item eq
  4092. @item fspp
  4093. @item ilpack
  4094. @item pp7
  4095. @item softpulldown
  4096. @item uspp
  4097. @end table
  4098. The parameter syntax and behavior for the listed filters are the same
  4099. of the corresponding MPlayer filters. For detailed instructions check
  4100. the "VIDEO FILTERS" section in the MPlayer manual.
  4101. @subsection Examples
  4102. @itemize
  4103. @item
  4104. Adjust gamma, brightness, contrast:
  4105. @example
  4106. mp=eq2=1.0:2:0.5
  4107. @end example
  4108. @end itemize
  4109. See also mplayer(1), @url{http://www.mplayerhq.hu/}.
  4110. @section mpdecimate
  4111. Drop frames that do not differ greatly from the previous frame in
  4112. order to reduce frame rate.
  4113. The main use of this filter is for very-low-bitrate encoding
  4114. (e.g. streaming over dialup modem), but it could in theory be used for
  4115. fixing movies that were inverse-telecined incorrectly.
  4116. A description of the accepted options follows.
  4117. @table @option
  4118. @item max
  4119. Set the maximum number of consecutive frames which can be dropped (if
  4120. positive), or the minimum interval between dropped frames (if
  4121. negative). If the value is 0, the frame is dropped unregarding the
  4122. number of previous sequentially dropped frames.
  4123. Default value is 0.
  4124. @item hi
  4125. @item lo
  4126. @item frac
  4127. Set the dropping threshold values.
  4128. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  4129. represent actual pixel value differences, so a threshold of 64
  4130. corresponds to 1 unit of difference for each pixel, or the same spread
  4131. out differently over the block.
  4132. A frame is a candidate for dropping if no 8x8 blocks differ by more
  4133. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  4134. meaning the whole image) differ by more than a threshold of @option{lo}.
  4135. Default value for @option{hi} is 64*12, default value for @option{lo} is
  4136. 64*5, and default value for @option{frac} is 0.33.
  4137. @end table
  4138. @section negate
  4139. Negate input video.
  4140. This filter accepts an integer in input, if non-zero it negates the
  4141. alpha component (if available). The default value in input is 0.
  4142. @section noformat
  4143. Force libavfilter not to use any of the specified pixel formats for the
  4144. input to the next filter.
  4145. This filter accepts the following parameters:
  4146. @table @option
  4147. @item pix_fmts
  4148. A '|'-separated list of pixel format names, for example
  4149. "pix_fmts=yuv420p|monow|rgb24".
  4150. @end table
  4151. @subsection Examples
  4152. @itemize
  4153. @item
  4154. Force libavfilter to use a format different from @var{yuv420p} for the
  4155. input to the vflip filter:
  4156. @example
  4157. noformat=pix_fmts=yuv420p,vflip
  4158. @end example
  4159. @item
  4160. Convert the input video to any of the formats not contained in the list:
  4161. @example
  4162. noformat=yuv420p|yuv444p|yuv410p
  4163. @end example
  4164. @end itemize
  4165. @section noise
  4166. Add noise on video input frame.
  4167. The filter accepts the following options:
  4168. @table @option
  4169. @item all_seed
  4170. @item c0_seed
  4171. @item c1_seed
  4172. @item c2_seed
  4173. @item c3_seed
  4174. Set noise seed for specific pixel component or all pixel components in case
  4175. of @var{all_seed}. Default value is @code{123457}.
  4176. @item all_strength, alls
  4177. @item c0_strength, c0s
  4178. @item c1_strength, c1s
  4179. @item c2_strength, c2s
  4180. @item c3_strength, c3s
  4181. Set noise strength for specific pixel component or all pixel components in case
  4182. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  4183. @item all_flags, allf
  4184. @item c0_flags, c0f
  4185. @item c1_flags, c1f
  4186. @item c2_flags, c2f
  4187. @item c3_flags, c3f
  4188. Set pixel component flags or set flags for all components if @var{all_flags}.
  4189. Available values for component flags are:
  4190. @table @samp
  4191. @item a
  4192. averaged temporal noise (smoother)
  4193. @item p
  4194. mix random noise with a (semi)regular pattern
  4195. @item t
  4196. temporal noise (noise pattern changes between frames)
  4197. @item u
  4198. uniform noise (gaussian otherwise)
  4199. @end table
  4200. @end table
  4201. @subsection Examples
  4202. Add temporal and uniform noise to input video:
  4203. @example
  4204. noise=alls=20:allf=t+u
  4205. @end example
  4206. @section null
  4207. Pass the video source unchanged to the output.
  4208. @section ocv
  4209. Apply video transform using libopencv.
  4210. To enable this filter install libopencv library and headers and
  4211. configure FFmpeg with @code{--enable-libopencv}.
  4212. This filter accepts the following parameters:
  4213. @table @option
  4214. @item filter_name
  4215. The name of the libopencv filter to apply.
  4216. @item filter_params
  4217. The parameters to pass to the libopencv filter. If not specified the default
  4218. values are assumed.
  4219. @end table
  4220. Refer to the official libopencv documentation for more precise
  4221. information:
  4222. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  4223. Follows the list of supported libopencv filters.
  4224. @anchor{dilate}
  4225. @subsection dilate
  4226. Dilate an image by using a specific structuring element.
  4227. This filter corresponds to the libopencv function @code{cvDilate}.
  4228. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  4229. @var{struct_el} represents a structuring element, and has the syntax:
  4230. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  4231. @var{cols} and @var{rows} represent the number of columns and rows of
  4232. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  4233. point, and @var{shape} the shape for the structuring element, and
  4234. can be one of the values "rect", "cross", "ellipse", "custom".
  4235. If the value for @var{shape} is "custom", it must be followed by a
  4236. string of the form "=@var{filename}". The file with name
  4237. @var{filename} is assumed to represent a binary image, with each
  4238. printable character corresponding to a bright pixel. When a custom
  4239. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  4240. or columns and rows of the read file are assumed instead.
  4241. The default value for @var{struct_el} is "3x3+0x0/rect".
  4242. @var{nb_iterations} specifies the number of times the transform is
  4243. applied to the image, and defaults to 1.
  4244. Follow some example:
  4245. @example
  4246. # use the default values
  4247. ocv=dilate
  4248. # dilate using a structuring element with a 5x5 cross, iterate two times
  4249. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  4250. # read the shape from the file diamond.shape, iterate two times
  4251. # the file diamond.shape may contain a pattern of characters like this:
  4252. # *
  4253. # ***
  4254. # *****
  4255. # ***
  4256. # *
  4257. # the specified cols and rows are ignored (but not the anchor point coordinates)
  4258. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  4259. @end example
  4260. @subsection erode
  4261. Erode an image by using a specific structuring element.
  4262. This filter corresponds to the libopencv function @code{cvErode}.
  4263. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
  4264. with the same syntax and semantics as the @ref{dilate} filter.
  4265. @subsection smooth
  4266. Smooth the input video.
  4267. The filter takes the following parameters:
  4268. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  4269. @var{type} is the type of smooth filter to apply, and can be one of
  4270. the following values: "blur", "blur_no_scale", "median", "gaussian",
  4271. "bilateral". The default value is "gaussian".
  4272. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  4273. parameters whose meanings depend on smooth type. @var{param1} and
  4274. @var{param2} accept integer positive values or 0, @var{param3} and
  4275. @var{param4} accept float values.
  4276. The default value for @var{param1} is 3, the default value for the
  4277. other parameters is 0.
  4278. These parameters correspond to the parameters assigned to the
  4279. libopencv function @code{cvSmooth}.
  4280. @anchor{overlay}
  4281. @section overlay
  4282. Overlay one video on top of another.
  4283. It takes two inputs and one output, the first input is the "main"
  4284. video on which the second input is overlayed.
  4285. This filter accepts the following parameters:
  4286. A description of the accepted options follows.
  4287. @table @option
  4288. @item x
  4289. @item y
  4290. Set the expression for the x and y coordinates of the overlayed video
  4291. on the main video. Default value is "0" for both expressions. In case
  4292. the expression is invalid, it is set to a huge value (meaning that the
  4293. overlay will not be displayed within the output visible area).
  4294. @item eval
  4295. Set when the expressions for @option{x}, and @option{y} are evaluated.
  4296. It accepts the following values:
  4297. @table @samp
  4298. @item init
  4299. only evaluate expressions once during the filter initialization or
  4300. when a command is processed
  4301. @item frame
  4302. evaluate expressions for each incoming frame
  4303. @end table
  4304. Default value is @samp{frame}.
  4305. @item shortest
  4306. If set to 1, force the output to terminate when the shortest input
  4307. terminates. Default value is 0.
  4308. @item format
  4309. Set the format for the output video.
  4310. It accepts the following values:
  4311. @table @samp
  4312. @item yuv420
  4313. force YUV420 output
  4314. @item yuv444
  4315. force YUV444 output
  4316. @item rgb
  4317. force RGB output
  4318. @end table
  4319. Default value is @samp{yuv420}.
  4320. @item rgb @emph{(deprecated)}
  4321. If set to 1, force the filter to accept inputs in the RGB
  4322. color space. Default value is 0. This option is deprecated, use
  4323. @option{format} instead.
  4324. @item repeatlast
  4325. If set to 1, force the filter to draw the last overlay frame over the
  4326. main input until the end of the stream. A value of 0 disables this
  4327. behavior. Default value is 1.
  4328. @end table
  4329. The @option{x}, and @option{y} expressions can contain the following
  4330. parameters.
  4331. @table @option
  4332. @item main_w, W
  4333. @item main_h, H
  4334. main input width and height
  4335. @item overlay_w, w
  4336. @item overlay_h, h
  4337. overlay input width and height
  4338. @item x
  4339. @item y
  4340. the computed values for @var{x} and @var{y}. They are evaluated for
  4341. each new frame.
  4342. @item hsub
  4343. @item vsub
  4344. horizontal and vertical chroma subsample values of the output
  4345. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  4346. @var{vsub} is 1.
  4347. @item n
  4348. the number of input frame, starting from 0
  4349. @item pos
  4350. the position in the file of the input frame, NAN if unknown
  4351. @item t
  4352. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4353. @end table
  4354. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  4355. when evaluation is done @emph{per frame}, and will evaluate to NAN
  4356. when @option{eval} is set to @samp{init}.
  4357. Be aware that frames are taken from each input video in timestamp
  4358. order, hence, if their initial timestamps differ, it is a good idea
  4359. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  4360. have them begin in the same zero timestamp, as it does the example for
  4361. the @var{movie} filter.
  4362. You can chain together more overlays but you should test the
  4363. efficiency of such approach.
  4364. @subsection Commands
  4365. This filter supports the following commands:
  4366. @table @option
  4367. @item x
  4368. @item y
  4369. Modify the x and y of the overlay input.
  4370. The command accepts the same syntax of the corresponding option.
  4371. If the specified expression is not valid, it is kept at its current
  4372. value.
  4373. @end table
  4374. @subsection Examples
  4375. @itemize
  4376. @item
  4377. Draw the overlay at 10 pixels from the bottom right corner of the main
  4378. video:
  4379. @example
  4380. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  4381. @end example
  4382. Using named options the example above becomes:
  4383. @example
  4384. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  4385. @end example
  4386. @item
  4387. Insert a transparent PNG logo in the bottom left corner of the input,
  4388. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  4389. @example
  4390. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  4391. @end example
  4392. @item
  4393. Insert 2 different transparent PNG logos (second logo on bottom
  4394. right corner) using the @command{ffmpeg} tool:
  4395. @example
  4396. 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
  4397. @end example
  4398. @item
  4399. Add a transparent color layer on top of the main video, @code{WxH}
  4400. must specify the size of the main input to the overlay filter:
  4401. @example
  4402. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  4403. @end example
  4404. @item
  4405. Play an original video and a filtered version (here with the deshake
  4406. filter) side by side using the @command{ffplay} tool:
  4407. @example
  4408. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  4409. @end example
  4410. The above command is the same as:
  4411. @example
  4412. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  4413. @end example
  4414. @item
  4415. Make a sliding overlay appearing from the left to the right top part of the
  4416. screen starting since time 2:
  4417. @example
  4418. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  4419. @end example
  4420. @item
  4421. Compose output by putting two input videos side to side:
  4422. @example
  4423. ffmpeg -i left.avi -i right.avi -filter_complex "
  4424. nullsrc=size=200x100 [background];
  4425. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  4426. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  4427. [background][left] overlay=shortest=1 [background+left];
  4428. [background+left][right] overlay=shortest=1:x=100 [left+right]
  4429. "
  4430. @end example
  4431. @item
  4432. Chain several overlays in cascade:
  4433. @example
  4434. nullsrc=s=200x200 [bg];
  4435. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  4436. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  4437. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  4438. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  4439. [in3] null, [mid2] overlay=100:100 [out0]
  4440. @end example
  4441. @end itemize
  4442. @section owdenoise
  4443. Apply Overcomplete Wavelet denoiser.
  4444. The filter accepts the following options:
  4445. @table @option
  4446. @item depth
  4447. Set depth.
  4448. Larger depth values will denoise lower frequency components more, but
  4449. slow down filtering.
  4450. Must be an int in the range 8-16, default is @code{8}.
  4451. @item luma_strength, ls
  4452. Set luma strength.
  4453. Must be a double value in the range 0-1000, default is @code{1.0}.
  4454. @item chroma_strength, cs
  4455. Set chroma strength.
  4456. Must be a double value in the range 0-1000, default is @code{1.0}.
  4457. @end table
  4458. @section pad
  4459. Add paddings to the input image, and place the original input at the
  4460. given coordinates @var{x}, @var{y}.
  4461. This filter accepts the following parameters:
  4462. @table @option
  4463. @item width, w
  4464. @item height, h
  4465. Specify an expression for the size of the output image with the
  4466. paddings added. If the value for @var{width} or @var{height} is 0, the
  4467. corresponding input size is used for the output.
  4468. The @var{width} expression can reference the value set by the
  4469. @var{height} expression, and vice versa.
  4470. The default value of @var{width} and @var{height} is 0.
  4471. @item x
  4472. @item y
  4473. Specify an expression for the offsets where to place the input image
  4474. in the padded area with respect to the top/left border of the output
  4475. image.
  4476. The @var{x} expression can reference the value set by the @var{y}
  4477. expression, and vice versa.
  4478. The default value of @var{x} and @var{y} is 0.
  4479. @item color
  4480. Specify the color of the padded area. For the syntax of this option,
  4481. check the "Color" section in the ffmpeg-utils manual.
  4482. The default value of @var{color} is "black".
  4483. @end table
  4484. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  4485. options are expressions containing the following constants:
  4486. @table @option
  4487. @item in_w
  4488. @item in_h
  4489. the input video width and height
  4490. @item iw
  4491. @item ih
  4492. same as @var{in_w} and @var{in_h}
  4493. @item out_w
  4494. @item out_h
  4495. the output width and height, that is the size of the padded area as
  4496. specified by the @var{width} and @var{height} expressions
  4497. @item ow
  4498. @item oh
  4499. same as @var{out_w} and @var{out_h}
  4500. @item x
  4501. @item y
  4502. x and y offsets as specified by the @var{x} and @var{y}
  4503. expressions, or NAN if not yet specified
  4504. @item a
  4505. same as @var{iw} / @var{ih}
  4506. @item sar
  4507. input sample aspect ratio
  4508. @item dar
  4509. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  4510. @item hsub
  4511. @item vsub
  4512. horizontal and vertical chroma subsample values. For example for the
  4513. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4514. @end table
  4515. @subsection Examples
  4516. @itemize
  4517. @item
  4518. Add paddings with color "violet" to the input video. Output video
  4519. size is 640x480, the top-left corner of the input video is placed at
  4520. column 0, row 40:
  4521. @example
  4522. pad=640:480:0:40:violet
  4523. @end example
  4524. The example above is equivalent to the following command:
  4525. @example
  4526. pad=width=640:height=480:x=0:y=40:color=violet
  4527. @end example
  4528. @item
  4529. Pad the input to get an output with dimensions increased by 3/2,
  4530. and put the input video at the center of the padded area:
  4531. @example
  4532. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  4533. @end example
  4534. @item
  4535. Pad the input to get a squared output with size equal to the maximum
  4536. value between the input width and height, and put the input video at
  4537. the center of the padded area:
  4538. @example
  4539. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  4540. @end example
  4541. @item
  4542. Pad the input to get a final w/h ratio of 16:9:
  4543. @example
  4544. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  4545. @end example
  4546. @item
  4547. In case of anamorphic video, in order to set the output display aspect
  4548. correctly, it is necessary to use @var{sar} in the expression,
  4549. according to the relation:
  4550. @example
  4551. (ih * X / ih) * sar = output_dar
  4552. X = output_dar / sar
  4553. @end example
  4554. Thus the previous example needs to be modified to:
  4555. @example
  4556. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  4557. @end example
  4558. @item
  4559. Double output size and put the input video in the bottom-right
  4560. corner of the output padded area:
  4561. @example
  4562. pad="2*iw:2*ih:ow-iw:oh-ih"
  4563. @end example
  4564. @end itemize
  4565. @section perspective
  4566. Correct perspective of video not recorded perpendicular to the screen.
  4567. A description of the accepted parameters follows.
  4568. @table @option
  4569. @item x0
  4570. @item y0
  4571. @item x1
  4572. @item y1
  4573. @item x2
  4574. @item y2
  4575. @item x3
  4576. @item y3
  4577. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  4578. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  4579. The expressions can use the following variables:
  4580. @table @option
  4581. @item W
  4582. @item H
  4583. the width and height of video frame.
  4584. @end table
  4585. @item interpolation
  4586. Set interpolation for perspective correction.
  4587. It accepts the following values:
  4588. @table @samp
  4589. @item linear
  4590. @item cubic
  4591. @end table
  4592. Default value is @samp{linear}.
  4593. @end table
  4594. @section phase
  4595. Delay interlaced video by one field time so that the field order changes.
  4596. The intended use is to fix PAL movies that have been captured with the
  4597. opposite field order to the film-to-video transfer.
  4598. A description of the accepted parameters follows.
  4599. @table @option
  4600. @item mode
  4601. Set phase mode.
  4602. It accepts the following values:
  4603. @table @samp
  4604. @item t
  4605. Capture field order top-first, transfer bottom-first.
  4606. Filter will delay the bottom field.
  4607. @item b
  4608. Capture field order bottom-first, transfer top-first.
  4609. Filter will delay the top field.
  4610. @item p
  4611. Capture and transfer with the same field order. This mode only exists
  4612. for the documentation of the other options to refer to, but if you
  4613. actually select it, the filter will faithfully do nothing.
  4614. @item a
  4615. Capture field order determined automatically by field flags, transfer
  4616. opposite.
  4617. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  4618. basis using field flags. If no field information is available,
  4619. then this works just like @samp{u}.
  4620. @item u
  4621. Capture unknown or varying, transfer opposite.
  4622. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  4623. analyzing the images and selecting the alternative that produces best
  4624. match between the fields.
  4625. @item T
  4626. Capture top-first, transfer unknown or varying.
  4627. Filter selects among @samp{t} and @samp{p} using image analysis.
  4628. @item B
  4629. Capture bottom-first, transfer unknown or varying.
  4630. Filter selects among @samp{b} and @samp{p} using image analysis.
  4631. @item A
  4632. Capture determined by field flags, transfer unknown or varying.
  4633. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  4634. image analysis. If no field information is available, then this works just
  4635. like @samp{U}. This is the default mode.
  4636. @item U
  4637. Both capture and transfer unknown or varying.
  4638. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  4639. @end table
  4640. @end table
  4641. @section pixdesctest
  4642. Pixel format descriptor test filter, mainly useful for internal
  4643. testing. The output video should be equal to the input video.
  4644. For example:
  4645. @example
  4646. format=monow, pixdesctest
  4647. @end example
  4648. can be used to test the monowhite pixel format descriptor definition.
  4649. @section pp
  4650. Enable the specified chain of postprocessing subfilters using libpostproc. This
  4651. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  4652. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  4653. Each subfilter and some options have a short and a long name that can be used
  4654. interchangeably, i.e. dr/dering are the same.
  4655. The filters accept the following options:
  4656. @table @option
  4657. @item subfilters
  4658. Set postprocessing subfilters string.
  4659. @end table
  4660. All subfilters share common options to determine their scope:
  4661. @table @option
  4662. @item a/autoq
  4663. Honor the quality commands for this subfilter.
  4664. @item c/chrom
  4665. Do chrominance filtering, too (default).
  4666. @item y/nochrom
  4667. Do luminance filtering only (no chrominance).
  4668. @item n/noluma
  4669. Do chrominance filtering only (no luminance).
  4670. @end table
  4671. These options can be appended after the subfilter name, separated by a '|'.
  4672. Available subfilters are:
  4673. @table @option
  4674. @item hb/hdeblock[|difference[|flatness]]
  4675. Horizontal deblocking filter
  4676. @table @option
  4677. @item difference
  4678. Difference factor where higher values mean more deblocking (default: @code{32}).
  4679. @item flatness
  4680. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  4681. @end table
  4682. @item vb/vdeblock[|difference[|flatness]]
  4683. Vertical deblocking filter
  4684. @table @option
  4685. @item difference
  4686. Difference factor where higher values mean more deblocking (default: @code{32}).
  4687. @item flatness
  4688. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  4689. @end table
  4690. @item ha/hadeblock[|difference[|flatness]]
  4691. Accurate horizontal deblocking filter
  4692. @table @option
  4693. @item difference
  4694. Difference factor where higher values mean more deblocking (default: @code{32}).
  4695. @item flatness
  4696. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  4697. @end table
  4698. @item va/vadeblock[|difference[|flatness]]
  4699. Accurate vertical deblocking filter
  4700. @table @option
  4701. @item difference
  4702. Difference factor where higher values mean more deblocking (default: @code{32}).
  4703. @item flatness
  4704. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  4705. @end table
  4706. @end table
  4707. The horizontal and vertical deblocking filters share the difference and
  4708. flatness values so you cannot set different horizontal and vertical
  4709. thresholds.
  4710. @table @option
  4711. @item h1/x1hdeblock
  4712. Experimental horizontal deblocking filter
  4713. @item v1/x1vdeblock
  4714. Experimental vertical deblocking filter
  4715. @item dr/dering
  4716. Deringing filter
  4717. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  4718. @table @option
  4719. @item threshold1
  4720. larger -> stronger filtering
  4721. @item threshold2
  4722. larger -> stronger filtering
  4723. @item threshold3
  4724. larger -> stronger filtering
  4725. @end table
  4726. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  4727. @table @option
  4728. @item f/fullyrange
  4729. Stretch luminance to @code{0-255}.
  4730. @end table
  4731. @item lb/linblenddeint
  4732. Linear blend deinterlacing filter that deinterlaces the given block by
  4733. filtering all lines with a @code{(1 2 1)} filter.
  4734. @item li/linipoldeint
  4735. Linear interpolating deinterlacing filter that deinterlaces the given block by
  4736. linearly interpolating every second line.
  4737. @item ci/cubicipoldeint
  4738. Cubic interpolating deinterlacing filter deinterlaces the given block by
  4739. cubically interpolating every second line.
  4740. @item md/mediandeint
  4741. Median deinterlacing filter that deinterlaces the given block by applying a
  4742. median filter to every second line.
  4743. @item fd/ffmpegdeint
  4744. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  4745. second line with a @code{(-1 4 2 4 -1)} filter.
  4746. @item l5/lowpass5
  4747. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  4748. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  4749. @item fq/forceQuant[|quantizer]
  4750. Overrides the quantizer table from the input with the constant quantizer you
  4751. specify.
  4752. @table @option
  4753. @item quantizer
  4754. Quantizer to use
  4755. @end table
  4756. @item de/default
  4757. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  4758. @item fa/fast
  4759. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  4760. @item ac
  4761. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  4762. @end table
  4763. @subsection Examples
  4764. @itemize
  4765. @item
  4766. Apply horizontal and vertical deblocking, deringing and automatic
  4767. brightness/contrast:
  4768. @example
  4769. pp=hb/vb/dr/al
  4770. @end example
  4771. @item
  4772. Apply default filters without brightness/contrast correction:
  4773. @example
  4774. pp=de/-al
  4775. @end example
  4776. @item
  4777. Apply default filters and temporal denoiser:
  4778. @example
  4779. pp=default/tmpnoise|1|2|3
  4780. @end example
  4781. @item
  4782. Apply deblocking on luminance only, and switch vertical deblocking on or off
  4783. automatically depending on available CPU time:
  4784. @example
  4785. pp=hb|y/vb|a
  4786. @end example
  4787. @end itemize
  4788. @section psnr
  4789. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  4790. Ratio) between two input videos.
  4791. This filter takes in input two input videos, the first input is
  4792. considered the "main" source and is passed unchanged to the
  4793. output. The second input is used as a "reference" video for computing
  4794. the PSNR.
  4795. Both video inputs must have the same resolution and pixel format for
  4796. this filter to work correctly. Also it assumes that both inputs
  4797. have the same number of frames, which are compared one by one.
  4798. The obtained average PSNR is printed through the logging system.
  4799. The filter stores the accumulated MSE (mean squared error) of each
  4800. frame, and at the end of the processing it is averaged across all frames
  4801. equally, and the following formula is applied to obtain the PSNR:
  4802. @example
  4803. PSNR = 10*log10(MAX^2/MSE)
  4804. @end example
  4805. Where MAX is the average of the maximum values of each component of the
  4806. image.
  4807. The description of the accepted parameters follows.
  4808. @table @option
  4809. @item stats_file, f
  4810. If specified the filter will use the named file to save the PSNR of
  4811. each individual frame.
  4812. @end table
  4813. The file printed if @var{stats_file} is selected, contains a sequence of
  4814. key/value pairs of the form @var{key}:@var{value} for each compared
  4815. couple of frames.
  4816. A description of each shown parameter follows:
  4817. @table @option
  4818. @item n
  4819. sequential number of the input frame, starting from 1
  4820. @item mse_avg
  4821. Mean Square Error pixel-by-pixel average difference of the compared
  4822. frames, averaged over all the image components.
  4823. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  4824. Mean Square Error pixel-by-pixel average difference of the compared
  4825. frames for the component specified by the suffix.
  4826. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  4827. Peak Signal to Noise ratio of the compared frames for the component
  4828. specified by the suffix.
  4829. @end table
  4830. For example:
  4831. @example
  4832. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  4833. [main][ref] psnr="stats_file=stats.log" [out]
  4834. @end example
  4835. On this example the input file being processed is compared with the
  4836. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  4837. is stored in @file{stats.log}.
  4838. @section pullup
  4839. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  4840. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  4841. content.
  4842. The pullup filter is designed to take advantage of future context in making
  4843. its decisions. This filter is stateless in the sense that it does not lock
  4844. onto a pattern to follow, but it instead looks forward to the following
  4845. fields in order to identify matches and rebuild progressive frames.
  4846. To produce content with an even framerate, insert the fps filter after
  4847. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  4848. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  4849. The filter accepts the following options:
  4850. @table @option
  4851. @item jl
  4852. @item jr
  4853. @item jt
  4854. @item jb
  4855. These options set the amount of "junk" to ignore at the left, right, top, and
  4856. bottom of the image, respectively. Left and right are in units of 8 pixels,
  4857. while top and bottom are in units of 2 lines.
  4858. The default is 8 pixels on each side.
  4859. @item sb
  4860. Set the strict breaks. Setting this option to 1 will reduce the chances of
  4861. filter generating an occasional mismatched frame, but it may also cause an
  4862. excessive number of frames to be dropped during high motion sequences.
  4863. Conversely, setting it to -1 will make filter match fields more easily.
  4864. This may help processing of video where there is slight blurring between
  4865. the fields, but may also cause there to be interlaced frames in the output.
  4866. Default value is @code{0}.
  4867. @item mp
  4868. Set the metric plane to use. It accepts the following values:
  4869. @table @samp
  4870. @item l
  4871. Use luma plane.
  4872. @item u
  4873. Use chroma blue plane.
  4874. @item v
  4875. Use chroma red plane.
  4876. @end table
  4877. This option may be set to use chroma plane instead of the default luma plane
  4878. for doing filter's computations. This may improve accuracy on very clean
  4879. source material, but more likely will decrease accuracy, especially if there
  4880. is chroma noise (rainbow effect) or any grayscale video.
  4881. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  4882. load and make pullup usable in realtime on slow machines.
  4883. @end table
  4884. For example to inverse telecined NTSC input:
  4885. @example
  4886. pullup,fps=24000/1001
  4887. @end example
  4888. @section removelogo
  4889. Suppress a TV station logo, using an image file to determine which
  4890. pixels comprise the logo. It works by filling in the pixels that
  4891. comprise the logo with neighboring pixels.
  4892. The filter accepts the following options:
  4893. @table @option
  4894. @item filename, f
  4895. Set the filter bitmap file, which can be any image format supported by
  4896. libavformat. The width and height of the image file must match those of the
  4897. video stream being processed.
  4898. @end table
  4899. Pixels in the provided bitmap image with a value of zero are not
  4900. considered part of the logo, non-zero pixels are considered part of
  4901. the logo. If you use white (255) for the logo and black (0) for the
  4902. rest, you will be safe. For making the filter bitmap, it is
  4903. recommended to take a screen capture of a black frame with the logo
  4904. visible, and then using a threshold filter followed by the erode
  4905. filter once or twice.
  4906. If needed, little splotches can be fixed manually. Remember that if
  4907. logo pixels are not covered, the filter quality will be much
  4908. reduced. Marking too many pixels as part of the logo does not hurt as
  4909. much, but it will increase the amount of blurring needed to cover over
  4910. the image and will destroy more information than necessary, and extra
  4911. pixels will slow things down on a large logo.
  4912. @section rotate
  4913. Rotate video by an arbitrary angle expressed in radians.
  4914. The filter accepts the following options:
  4915. A description of the optional parameters follows.
  4916. @table @option
  4917. @item angle, a
  4918. Set an expression for the angle by which to rotate the input video
  4919. clockwise, expressed as a number of radians. A negative value will
  4920. result in a counter-clockwise rotation. By default it is set to "0".
  4921. This expression is evaluated for each frame.
  4922. @item out_w, ow
  4923. Set the output width expression, default value is "iw".
  4924. This expression is evaluated just once during configuration.
  4925. @item out_h, oh
  4926. Set the output height expression, default value is "ih".
  4927. This expression is evaluated just once during configuration.
  4928. @item bilinear
  4929. Enable bilinear interpolation if set to 1, a value of 0 disables
  4930. it. Default value is 1.
  4931. @item fillcolor, c
  4932. Set the color used to fill the output area not covered by the rotated
  4933. image. For the generalsyntax of this option, check the "Color" section in the
  4934. ffmpeg-utils manual. If the special value "none" is selected then no
  4935. background is printed (useful for example if the background is never shown).
  4936. Default 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. For the syntax of this option, check the "Video size"
  5079. section in the ffmpeg-utils manual.
  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. For the syntax of this option, check the "Video size"
  5354. section in the ffmpeg-utils manual.
  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. For the syntax of this option, check the "Video size" section in
  5556. the ffmpeg-utils manual. Due to a misdesign in ASS aspect ratio arithmetic,
  5557. this is necessary to correctly scale the fonts if the aspect ratio has been
  5558. changed.
  5559. @item charenc
  5560. Set subtitles input character encoding. @code{subtitles} filter only. Only
  5561. useful if not UTF-8.
  5562. @end table
  5563. If the first key is not specified, it is assumed that the first value
  5564. specifies the @option{filename}.
  5565. For example, to render the file @file{sub.srt} on top of the input
  5566. video, use the command:
  5567. @example
  5568. subtitles=sub.srt
  5569. @end example
  5570. which is equivalent to:
  5571. @example
  5572. subtitles=filename=sub.srt
  5573. @end example
  5574. @section super2xsai
  5575. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  5576. Interpolate) pixel art scaling algorithm.
  5577. Useful for enlarging pixel art images without reducing sharpness.
  5578. @section swapuv
  5579. Swap U & V plane.
  5580. @section telecine
  5581. Apply telecine process to the video.
  5582. This filter accepts the following options:
  5583. @table @option
  5584. @item first_field
  5585. @table @samp
  5586. @item top, t
  5587. top field first
  5588. @item bottom, b
  5589. bottom field first
  5590. The default value is @code{top}.
  5591. @end table
  5592. @item pattern
  5593. A string of numbers representing the pulldown pattern you wish to apply.
  5594. The default value is @code{23}.
  5595. @end table
  5596. @example
  5597. Some typical patterns:
  5598. NTSC output (30i):
  5599. 27.5p: 32222
  5600. 24p: 23 (classic)
  5601. 24p: 2332 (preferred)
  5602. 20p: 33
  5603. 18p: 334
  5604. 16p: 3444
  5605. PAL output (25i):
  5606. 27.5p: 12222
  5607. 24p: 222222222223 ("Euro pulldown")
  5608. 16.67p: 33
  5609. 16p: 33333334
  5610. @end example
  5611. @section thumbnail
  5612. Select the most representative frame in a given sequence of consecutive frames.
  5613. The filter accepts the following options:
  5614. @table @option
  5615. @item n
  5616. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  5617. will pick one of them, and then handle the next batch of @var{n} frames until
  5618. the end. Default is @code{100}.
  5619. @end table
  5620. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  5621. value will result in a higher memory usage, so a high value is not recommended.
  5622. @subsection Examples
  5623. @itemize
  5624. @item
  5625. Extract one picture each 50 frames:
  5626. @example
  5627. thumbnail=50
  5628. @end example
  5629. @item
  5630. Complete example of a thumbnail creation with @command{ffmpeg}:
  5631. @example
  5632. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  5633. @end example
  5634. @end itemize
  5635. @section tile
  5636. Tile several successive frames together.
  5637. The filter accepts the following options:
  5638. @table @option
  5639. @item layout
  5640. Set the grid size (i.e. the number of lines and columns). For the syntax of
  5641. this option, check the "Video size" section in the ffmpeg-utils manual.
  5642. @item nb_frames
  5643. Set the maximum number of frames to render in the given area. It must be less
  5644. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  5645. the area will be used.
  5646. @item margin
  5647. Set the outer border margin in pixels.
  5648. @item padding
  5649. Set the inner border thickness (i.e. the number of pixels between frames). For
  5650. more advanced padding options (such as having different values for the edges),
  5651. refer to the pad video filter.
  5652. @item color
  5653. Specify the color of the unused areaFor the syntax of this option, check the
  5654. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  5655. is "black".
  5656. @end table
  5657. @subsection Examples
  5658. @itemize
  5659. @item
  5660. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  5661. @example
  5662. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  5663. @end example
  5664. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  5665. duplicating each output frame to accomodate the originally detected frame
  5666. rate.
  5667. @item
  5668. Display @code{5} pictures in an area of @code{3x2} frames,
  5669. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  5670. mixed flat and named options:
  5671. @example
  5672. tile=3x2:nb_frames=5:padding=7:margin=2
  5673. @end example
  5674. @end itemize
  5675. @section tinterlace
  5676. Perform various types of temporal field interlacing.
  5677. Frames are counted starting from 1, so the first input frame is
  5678. considered odd.
  5679. The filter accepts the following options:
  5680. @table @option
  5681. @item mode
  5682. Specify the mode of the interlacing. This option can also be specified
  5683. as a value alone. See below for a list of values for this option.
  5684. Available values are:
  5685. @table @samp
  5686. @item merge, 0
  5687. Move odd frames into the upper field, even into the lower field,
  5688. generating a double height frame at half frame rate.
  5689. @item drop_odd, 1
  5690. Only output even frames, odd frames are dropped, generating a frame with
  5691. unchanged height at half frame rate.
  5692. @item drop_even, 2
  5693. Only output odd frames, even frames are dropped, generating a frame with
  5694. unchanged height at half frame rate.
  5695. @item pad, 3
  5696. Expand each frame to full height, but pad alternate lines with black,
  5697. generating a frame with double height at the same input frame rate.
  5698. @item interleave_top, 4
  5699. Interleave the upper field from odd frames with the lower field from
  5700. even frames, generating a frame with unchanged height at half frame rate.
  5701. @item interleave_bottom, 5
  5702. Interleave the lower field from odd frames with the upper field from
  5703. even frames, generating a frame with unchanged height at half frame rate.
  5704. @item interlacex2, 6
  5705. Double frame rate with unchanged height. Frames are inserted each
  5706. containing the second temporal field from the previous input frame and
  5707. the first temporal field from the next input frame. This mode relies on
  5708. the top_field_first flag. Useful for interlaced video displays with no
  5709. field synchronisation.
  5710. @end table
  5711. Numeric values are deprecated but are accepted for backward
  5712. compatibility reasons.
  5713. Default mode is @code{merge}.
  5714. @item flags
  5715. Specify flags influencing the filter process.
  5716. Available value for @var{flags} is:
  5717. @table @option
  5718. @item low_pass_filter, vlfp
  5719. Enable vertical low-pass filtering in the filter.
  5720. Vertical low-pass filtering is required when creating an interlaced
  5721. destination from a progressive source which contains high-frequency
  5722. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  5723. patterning.
  5724. Vertical low-pass filtering can only be enabled for @option{mode}
  5725. @var{interleave_top} and @var{interleave_bottom}.
  5726. @end table
  5727. @end table
  5728. @section transpose
  5729. Transpose rows with columns in the input video and optionally flip it.
  5730. This filter accepts the following options:
  5731. @table @option
  5732. @item dir
  5733. Specify the transposition direction.
  5734. Can assume the following values:
  5735. @table @samp
  5736. @item 0, 4, cclock_flip
  5737. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  5738. @example
  5739. L.R L.l
  5740. . . -> . .
  5741. l.r R.r
  5742. @end example
  5743. @item 1, 5, clock
  5744. Rotate by 90 degrees clockwise, that is:
  5745. @example
  5746. L.R l.L
  5747. . . -> . .
  5748. l.r r.R
  5749. @end example
  5750. @item 2, 6, cclock
  5751. Rotate by 90 degrees counterclockwise, that is:
  5752. @example
  5753. L.R R.r
  5754. . . -> . .
  5755. l.r L.l
  5756. @end example
  5757. @item 3, 7, clock_flip
  5758. Rotate by 90 degrees clockwise and vertically flip, that is:
  5759. @example
  5760. L.R r.R
  5761. . . -> . .
  5762. l.r l.L
  5763. @end example
  5764. @end table
  5765. For values between 4-7, the transposition is only done if the input
  5766. video geometry is portrait and not landscape. These values are
  5767. deprecated, the @code{passthrough} option should be used instead.
  5768. Numerical values are deprecated, and should be dropped in favor of
  5769. symbolic constants.
  5770. @item passthrough
  5771. Do not apply the transposition if the input geometry matches the one
  5772. specified by the specified value. It accepts the following values:
  5773. @table @samp
  5774. @item none
  5775. Always apply transposition.
  5776. @item portrait
  5777. Preserve portrait geometry (when @var{height} >= @var{width}).
  5778. @item landscape
  5779. Preserve landscape geometry (when @var{width} >= @var{height}).
  5780. @end table
  5781. Default value is @code{none}.
  5782. @end table
  5783. For example to rotate by 90 degrees clockwise and preserve portrait
  5784. layout:
  5785. @example
  5786. transpose=dir=1:passthrough=portrait
  5787. @end example
  5788. The command above can also be specified as:
  5789. @example
  5790. transpose=1:portrait
  5791. @end example
  5792. @section trim
  5793. Trim the input so that the output contains one continuous subpart of the input.
  5794. This filter accepts the following options:
  5795. @table @option
  5796. @item start
  5797. Specify time of the start of the kept section, i.e. the frame with the
  5798. timestamp @var{start} will be the first frame in the output.
  5799. @item end
  5800. Specify time of the first frame that will be dropped, i.e. the frame
  5801. immediately preceding the one with the timestamp @var{end} will be the last
  5802. frame in the output.
  5803. @item start_pts
  5804. Same as @var{start}, except this option sets the start timestamp in timebase
  5805. units instead of seconds.
  5806. @item end_pts
  5807. Same as @var{end}, except this option sets the end timestamp in timebase units
  5808. instead of seconds.
  5809. @item duration
  5810. Specify maximum duration of the output.
  5811. @item start_frame
  5812. Number of the first frame that should be passed to output.
  5813. @item end_frame
  5814. Number of the first frame that should be dropped.
  5815. @end table
  5816. @option{start}, @option{end}, @option{duration} are expressed as time
  5817. duration specifications, check the "Time duration" section in the
  5818. ffmpeg-utils manual.
  5819. Note that the first two sets of the start/end options and the @option{duration}
  5820. option look at the frame timestamp, while the _frame variants simply count the
  5821. frames that pass through the filter. Also note that this filter does not modify
  5822. the timestamps. If you wish that the output timestamps start at zero, insert a
  5823. setpts filter after the trim filter.
  5824. If multiple start or end options are set, this filter tries to be greedy and
  5825. keep all the frames that match at least one of the specified constraints. To keep
  5826. only the part that matches all the constraints at once, chain multiple trim
  5827. filters.
  5828. The defaults are such that all the input is kept. So it is possible to set e.g.
  5829. just the end values to keep everything before the specified time.
  5830. Examples:
  5831. @itemize
  5832. @item
  5833. drop everything except the second minute of input
  5834. @example
  5835. ffmpeg -i INPUT -vf trim=60:120
  5836. @end example
  5837. @item
  5838. keep only the first second
  5839. @example
  5840. ffmpeg -i INPUT -vf trim=duration=1
  5841. @end example
  5842. @end itemize
  5843. @section unsharp
  5844. Sharpen or blur the input video.
  5845. It accepts the following parameters:
  5846. @table @option
  5847. @item luma_msize_x, lx
  5848. Set the luma matrix horizontal size. It must be an odd integer between
  5849. 3 and 63, default value is 5.
  5850. @item luma_msize_y, ly
  5851. Set the luma matrix vertical size. It must be an odd integer between 3
  5852. and 63, default value is 5.
  5853. @item luma_amount, la
  5854. Set the luma effect strength. It can be a float number, reasonable
  5855. values lay between -1.5 and 1.5.
  5856. Negative values will blur the input video, while positive values will
  5857. sharpen it, a value of zero will disable the effect.
  5858. Default value is 1.0.
  5859. @item chroma_msize_x, cx
  5860. Set the chroma matrix horizontal size. It must be an odd integer
  5861. between 3 and 63, default value is 5.
  5862. @item chroma_msize_y, cy
  5863. Set the chroma matrix vertical size. It must be an odd integer
  5864. between 3 and 63, default value is 5.
  5865. @item chroma_amount, ca
  5866. Set the chroma effect strength. It can be a float number, reasonable
  5867. values lay between -1.5 and 1.5.
  5868. Negative values will blur the input video, while positive values will
  5869. sharpen it, a value of zero will disable the effect.
  5870. Default value is 0.0.
  5871. @item opencl
  5872. If set to 1, specify using OpenCL capabilities, only available if
  5873. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  5874. @end table
  5875. All parameters are optional and default to the equivalent of the
  5876. string '5:5:1.0:5:5:0.0'.
  5877. @subsection Examples
  5878. @itemize
  5879. @item
  5880. Apply strong luma sharpen effect:
  5881. @example
  5882. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  5883. @end example
  5884. @item
  5885. Apply strong blur of both luma and chroma parameters:
  5886. @example
  5887. unsharp=7:7:-2:7:7:-2
  5888. @end example
  5889. @end itemize
  5890. @anchor{vidstabdetect}
  5891. @section vidstabdetect
  5892. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  5893. @ref{vidstabtransform} for pass 2.
  5894. This filter generates a file with relative translation and rotation
  5895. transform information about subsequent frames, which is then used by
  5896. the @ref{vidstabtransform} filter.
  5897. To enable compilation of this filter you need to configure FFmpeg with
  5898. @code{--enable-libvidstab}.
  5899. This filter accepts the following options:
  5900. @table @option
  5901. @item result
  5902. Set the path to the file used to write the transforms information.
  5903. Default value is @file{transforms.trf}.
  5904. @item shakiness
  5905. Set how shaky the video is and how quick the camera is. It accepts an
  5906. integer in the range 1-10, a value of 1 means little shakiness, a
  5907. value of 10 means strong shakiness. Default value is 5.
  5908. @item accuracy
  5909. Set the accuracy of the detection process. It must be a value in the
  5910. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  5911. accuracy. Default value is 9.
  5912. @item stepsize
  5913. Set stepsize of the search process. The region around minimum is
  5914. scanned with 1 pixel resolution. Default value is 6.
  5915. @item mincontrast
  5916. Set minimum contrast. Below this value a local measurement field is
  5917. discarded. Must be a floating point value in the range 0-1. Default
  5918. value is 0.3.
  5919. @item tripod
  5920. Set reference frame number for tripod mode.
  5921. If enabled, the motion of the frames is compared to a reference frame
  5922. in the filtered stream, identified by the specified number. The idea
  5923. is to compensate all movements in a more-or-less static scene and keep
  5924. the camera view absolutely still.
  5925. If set to 0, it is disabled. The frames are counted starting from 1.
  5926. @item show
  5927. Show fields and transforms in the resulting frames. It accepts an
  5928. integer in the range 0-2. Default value is 0, which disables any
  5929. visualization.
  5930. @end table
  5931. @subsection Examples
  5932. @itemize
  5933. @item
  5934. Use default values:
  5935. @example
  5936. vidstabdetect
  5937. @end example
  5938. @item
  5939. Analyze strongly shaky movie and put the results in file
  5940. @file{mytransforms.trf}:
  5941. @example
  5942. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  5943. @end example
  5944. @item
  5945. Visualize the result of internal transformations in the resulting
  5946. video:
  5947. @example
  5948. vidstabdetect=show=1
  5949. @end example
  5950. @item
  5951. Analyze a video with medium shakiness using @command{ffmpeg}:
  5952. @example
  5953. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  5954. @end example
  5955. @end itemize
  5956. @anchor{vidstabtransform}
  5957. @section vidstabtransform
  5958. Video stabilization/deshaking: pass 2 of 2,
  5959. see @ref{vidstabdetect} for pass 1.
  5960. Read a file with transform information for each frame and
  5961. apply/compensate them. Together with the @ref{vidstabdetect}
  5962. filter this can be used to deshake videos. See also
  5963. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  5964. the unsharp filter, see below.
  5965. To enable compilation of this filter you need to configure FFmpeg with
  5966. @code{--enable-libvidstab}.
  5967. This filter accepts the following options:
  5968. @table @option
  5969. @item input
  5970. path to the file used to read the transforms (default: @file{transforms.trf})
  5971. @item smoothing
  5972. number of frames (value*2 + 1) used for lowpass filtering the camera movements
  5973. (default: 10). For example a number of 10 means that 21 frames are used
  5974. (10 in the past and 10 in the future) to smoothen the motion in the
  5975. video. A larger values leads to a smoother video, but limits the
  5976. acceleration of the camera (pan/tilt movements).
  5977. @item maxshift
  5978. maximal number of pixels to translate frames (default: -1 no limit)
  5979. @item maxangle
  5980. maximal angle in radians (degree*PI/180) to rotate frames (default: -1
  5981. no limit)
  5982. @item crop
  5983. How to deal with borders that may be visible due to movement
  5984. compensation. Available values are:
  5985. @table @samp
  5986. @item keep
  5987. keep image information from previous frame (default)
  5988. @item black
  5989. fill the border black
  5990. @end table
  5991. @item invert
  5992. @table @samp
  5993. @item 0
  5994. keep transforms normal (default)
  5995. @item 1
  5996. invert transforms
  5997. @end table
  5998. @item relative
  5999. consider transforms as
  6000. @table @samp
  6001. @item 0
  6002. absolute
  6003. @item 1
  6004. relative to previous frame (default)
  6005. @end table
  6006. @item zoom
  6007. percentage to zoom (default: 0)
  6008. @table @samp
  6009. @item >0
  6010. zoom in
  6011. @item <0
  6012. zoom out
  6013. @end table
  6014. @item optzoom
  6015. set optimal zooming to avoid borders
  6016. @table @samp
  6017. @item 0
  6018. disabled
  6019. @item 1
  6020. optimal static zoom value is determined (only very strong movements will lead to visible borders) (default)
  6021. @item 2
  6022. optimal adaptive zoom value is determined (no borders will be visible)
  6023. @end table
  6024. Note that the value given at zoom is added to the one calculated
  6025. here.
  6026. @item interpol
  6027. type of interpolation
  6028. Available values are:
  6029. @table @samp
  6030. @item no
  6031. no interpolation
  6032. @item linear
  6033. linear only horizontal
  6034. @item bilinear
  6035. linear in both directions (default)
  6036. @item bicubic
  6037. cubic in both directions (slow)
  6038. @end table
  6039. @item tripod
  6040. virtual tripod mode means that the video is stabilized such that the
  6041. camera stays stationary. Use also @code{tripod} option of
  6042. @ref{vidstabdetect}.
  6043. @table @samp
  6044. @item 0
  6045. off (default)
  6046. @item 1
  6047. virtual tripod mode: equivalent to @code{relative=0:smoothing=0}
  6048. @end table
  6049. @end table
  6050. @subsection Examples
  6051. @itemize
  6052. @item
  6053. typical call with default default values:
  6054. (note the unsharp filter which is always recommended)
  6055. @example
  6056. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  6057. @end example
  6058. @item
  6059. zoom in a bit more and load transform data from a given file
  6060. @example
  6061. vidstabtransform=zoom=5:input="mytransforms.trf"
  6062. @end example
  6063. @item
  6064. smoothen the video even more
  6065. @example
  6066. vidstabtransform=smoothing=30
  6067. @end example
  6068. @end itemize
  6069. @section vflip
  6070. Flip the input video vertically.
  6071. For example, to vertically flip a video with @command{ffmpeg}:
  6072. @example
  6073. ffmpeg -i in.avi -vf "vflip" out.avi
  6074. @end example
  6075. @section vignette
  6076. Make or reverse a natural vignetting effect.
  6077. The filter accepts the following options:
  6078. @table @option
  6079. @item angle, a
  6080. Set lens angle expression as a number of radians.
  6081. The value is clipped in the @code{[0,PI/2]} range.
  6082. Default value: @code{"PI/5"}
  6083. @item x0
  6084. @item y0
  6085. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  6086. by default.
  6087. @item mode
  6088. Set forward/backward mode.
  6089. Available modes are:
  6090. @table @samp
  6091. @item forward
  6092. The larger the distance from the central point, the darker the image becomes.
  6093. @item backward
  6094. The larger the distance from the central point, the brighter the image becomes.
  6095. This can be used to reverse a vignette effect, though there is no automatic
  6096. detection to extract the lens @option{angle} and other settings (yet). It can
  6097. also be used to create a burning effect.
  6098. @end table
  6099. Default value is @samp{forward}.
  6100. @item eval
  6101. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  6102. It accepts the following values:
  6103. @table @samp
  6104. @item init
  6105. Evaluate expressions only once during the filter initialization.
  6106. @item frame
  6107. Evaluate expressions for each incoming frame. This is way slower than the
  6108. @samp{init} mode since it requires all the scalers to be re-computed, but it
  6109. allows advanced dynamic expressions.
  6110. @end table
  6111. Default value is @samp{init}.
  6112. @item dither
  6113. Set dithering to reduce the circular banding effects. Default is @code{1}
  6114. (enabled).
  6115. @item aspect
  6116. Set vignette aspect. This setting allows to adjust the shape of the vignette.
  6117. Setting this value to the SAR of the input will make a rectangular vignetting
  6118. following the dimensions of the video.
  6119. Default is @code{1/1}.
  6120. @end table
  6121. @subsection Expressions
  6122. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  6123. following parameters.
  6124. @table @option
  6125. @item w
  6126. @item h
  6127. input width and height
  6128. @item n
  6129. the number of input frame, starting from 0
  6130. @item pts
  6131. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  6132. @var{TB} units, NAN if undefined
  6133. @item r
  6134. frame rate of the input video, NAN if the input frame rate is unknown
  6135. @item t
  6136. the PTS (Presentation TimeStamp) of the filtered video frame,
  6137. expressed in seconds, NAN if undefined
  6138. @item tb
  6139. time base of the input video
  6140. @end table
  6141. @subsection Examples
  6142. @itemize
  6143. @item
  6144. Apply simple strong vignetting effect:
  6145. @example
  6146. vignette=PI/4
  6147. @end example
  6148. @item
  6149. Make a flickering vignetting:
  6150. @example
  6151. vignette='PI/4+random(1)*PI/50':eval=frame
  6152. @end example
  6153. @end itemize
  6154. @section w3fdif
  6155. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  6156. Deinterlacing Filter").
  6157. Based on the process described by Martin Weston for BBC R&D, and
  6158. implemented based on the de-interlace algorithm written by Jim
  6159. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  6160. uses filter coefficients calculated by BBC R&D.
  6161. There are two sets of filter coefficients, so called "simple":
  6162. and "complex". Which set of filter coefficients is used can
  6163. be set by passing an optional parameter:
  6164. @table @option
  6165. @item filter
  6166. Set the interlacing filter coefficients. Accepts one of the following values:
  6167. @table @samp
  6168. @item simple
  6169. Simple filter coefficient set.
  6170. @item complex
  6171. More-complex filter coefficient set.
  6172. @end table
  6173. Default value is @samp{complex}.
  6174. @item deint
  6175. Specify which frames to deinterlace. Accept one of the following values:
  6176. @table @samp
  6177. @item all
  6178. Deinterlace all frames,
  6179. @item interlaced
  6180. Only deinterlace frames marked as interlaced.
  6181. @end table
  6182. Default value is @samp{all}.
  6183. @end table
  6184. @anchor{yadif}
  6185. @section yadif
  6186. Deinterlace the input video ("yadif" means "yet another deinterlacing
  6187. filter").
  6188. This filter accepts the following options:
  6189. @table @option
  6190. @item mode
  6191. The interlacing mode to adopt, accepts one of the following values:
  6192. @table @option
  6193. @item 0, send_frame
  6194. output 1 frame for each frame
  6195. @item 1, send_field
  6196. output 1 frame for each field
  6197. @item 2, send_frame_nospatial
  6198. like @code{send_frame} but skip spatial interlacing check
  6199. @item 3, send_field_nospatial
  6200. like @code{send_field} but skip spatial interlacing check
  6201. @end table
  6202. Default value is @code{send_frame}.
  6203. @item parity
  6204. The picture field parity assumed for the input interlaced video, accepts one of
  6205. the following values:
  6206. @table @option
  6207. @item 0, tff
  6208. assume top field first
  6209. @item 1, bff
  6210. assume bottom field first
  6211. @item -1, auto
  6212. enable automatic detection
  6213. @end table
  6214. Default value is @code{auto}.
  6215. If interlacing is unknown or decoder does not export this information,
  6216. top field first will be assumed.
  6217. @item deint
  6218. Specify which frames to deinterlace. Accept one of the following
  6219. values:
  6220. @table @option
  6221. @item 0, all
  6222. deinterlace all frames
  6223. @item 1, interlaced
  6224. only deinterlace frames marked as interlaced
  6225. @end table
  6226. Default value is @code{all}.
  6227. @end table
  6228. @c man end VIDEO FILTERS
  6229. @chapter Video Sources
  6230. @c man begin VIDEO SOURCES
  6231. Below is a description of the currently available video sources.
  6232. @section buffer
  6233. Buffer video frames, and make them available to the filter chain.
  6234. This source is mainly intended for a programmatic use, in particular
  6235. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  6236. This source accepts the following options:
  6237. @table @option
  6238. @item video_size
  6239. Specify the size (width and height) of the buffered video frames. For the
  6240. syntax of this option, check the "Video size" section in the ffmpeg-utils
  6241. manual.
  6242. @item width
  6243. Input video width.
  6244. @item height
  6245. Input video height.
  6246. @item pix_fmt
  6247. A string representing the pixel format of the buffered video frames.
  6248. It may be a number corresponding to a pixel format, or a pixel format
  6249. name.
  6250. @item time_base
  6251. Specify the timebase assumed by the timestamps of the buffered frames.
  6252. @item frame_rate
  6253. Specify the frame rate expected for the video stream.
  6254. @item pixel_aspect, sar
  6255. Specify the sample aspect ratio assumed by the video frames.
  6256. @item sws_param
  6257. Specify the optional parameters to be used for the scale filter which
  6258. is automatically inserted when an input change is detected in the
  6259. input size or format.
  6260. @end table
  6261. For example:
  6262. @example
  6263. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  6264. @end example
  6265. will instruct the source to accept video frames with size 320x240 and
  6266. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  6267. square pixels (1:1 sample aspect ratio).
  6268. Since the pixel format with name "yuv410p" corresponds to the number 6
  6269. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  6270. this example corresponds to:
  6271. @example
  6272. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  6273. @end example
  6274. Alternatively, the options can be specified as a flat string, but this
  6275. syntax is deprecated:
  6276. @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}]
  6277. @section cellauto
  6278. Create a pattern generated by an elementary cellular automaton.
  6279. The initial state of the cellular automaton can be defined through the
  6280. @option{filename}, and @option{pattern} options. If such options are
  6281. not specified an initial state is created randomly.
  6282. At each new frame a new row in the video is filled with the result of
  6283. the cellular automaton next generation. The behavior when the whole
  6284. frame is filled is defined by the @option{scroll} option.
  6285. This source accepts the following options:
  6286. @table @option
  6287. @item filename, f
  6288. Read the initial cellular automaton state, i.e. the starting row, from
  6289. the specified file.
  6290. In the file, each non-whitespace character is considered an alive
  6291. cell, a newline will terminate the row, and further characters in the
  6292. file will be ignored.
  6293. @item pattern, p
  6294. Read the initial cellular automaton state, i.e. the starting row, from
  6295. the specified string.
  6296. Each non-whitespace character in the string is considered an alive
  6297. cell, a newline will terminate the row, and further characters in the
  6298. string will be ignored.
  6299. @item rate, r
  6300. Set the video rate, that is the number of frames generated per second.
  6301. Default is 25.
  6302. @item random_fill_ratio, ratio
  6303. Set the random fill ratio for the initial cellular automaton row. It
  6304. is a floating point number value ranging from 0 to 1, defaults to
  6305. 1/PHI.
  6306. This option is ignored when a file or a pattern is specified.
  6307. @item random_seed, seed
  6308. Set the seed for filling randomly the initial row, must be an integer
  6309. included between 0 and UINT32_MAX. If not specified, or if explicitly
  6310. set to -1, the filter will try to use a good random seed on a best
  6311. effort basis.
  6312. @item rule
  6313. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  6314. Default value is 110.
  6315. @item size, s
  6316. Set the size of the output video. For the syntax of this option, check
  6317. the "Video size" section in the ffmpeg-utils manual.
  6318. If @option{filename} or @option{pattern} is specified, the size is set
  6319. by default to the width of the specified initial state row, and the
  6320. height is set to @var{width} * PHI.
  6321. If @option{size} is set, it must contain the width of the specified
  6322. pattern string, and the specified pattern will be centered in the
  6323. larger row.
  6324. If a filename or a pattern string is not specified, the size value
  6325. defaults to "320x518" (used for a randomly generated initial state).
  6326. @item scroll
  6327. If set to 1, scroll the output upward when all the rows in the output
  6328. have been already filled. If set to 0, the new generated row will be
  6329. written over the top row just after the bottom row is filled.
  6330. Defaults to 1.
  6331. @item start_full, full
  6332. If set to 1, completely fill the output with generated rows before
  6333. outputting the first frame.
  6334. This is the default behavior, for disabling set the value to 0.
  6335. @item stitch
  6336. If set to 1, stitch the left and right row edges together.
  6337. This is the default behavior, for disabling set the value to 0.
  6338. @end table
  6339. @subsection Examples
  6340. @itemize
  6341. @item
  6342. Read the initial state from @file{pattern}, and specify an output of
  6343. size 200x400.
  6344. @example
  6345. cellauto=f=pattern:s=200x400
  6346. @end example
  6347. @item
  6348. Generate a random initial row with a width of 200 cells, with a fill
  6349. ratio of 2/3:
  6350. @example
  6351. cellauto=ratio=2/3:s=200x200
  6352. @end example
  6353. @item
  6354. Create a pattern generated by rule 18 starting by a single alive cell
  6355. centered on an initial row with width 100:
  6356. @example
  6357. cellauto=p=@@:s=100x400:full=0:rule=18
  6358. @end example
  6359. @item
  6360. Specify a more elaborated initial pattern:
  6361. @example
  6362. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  6363. @end example
  6364. @end itemize
  6365. @section mandelbrot
  6366. Generate a Mandelbrot set fractal, and progressively zoom towards the
  6367. point specified with @var{start_x} and @var{start_y}.
  6368. This source accepts the following options:
  6369. @table @option
  6370. @item end_pts
  6371. Set the terminal pts value. Default value is 400.
  6372. @item end_scale
  6373. Set the terminal scale value.
  6374. Must be a floating point value. Default value is 0.3.
  6375. @item inner
  6376. Set the inner coloring mode, that is the algorithm used to draw the
  6377. Mandelbrot fractal internal region.
  6378. It shall assume one of the following values:
  6379. @table @option
  6380. @item black
  6381. Set black mode.
  6382. @item convergence
  6383. Show time until convergence.
  6384. @item mincol
  6385. Set color based on point closest to the origin of the iterations.
  6386. @item period
  6387. Set period mode.
  6388. @end table
  6389. Default value is @var{mincol}.
  6390. @item bailout
  6391. Set the bailout value. Default value is 10.0.
  6392. @item maxiter
  6393. Set the maximum of iterations performed by the rendering
  6394. algorithm. Default value is 7189.
  6395. @item outer
  6396. Set outer coloring mode.
  6397. It shall assume one of following values:
  6398. @table @option
  6399. @item iteration_count
  6400. Set iteration cound mode.
  6401. @item normalized_iteration_count
  6402. set normalized iteration count mode.
  6403. @end table
  6404. Default value is @var{normalized_iteration_count}.
  6405. @item rate, r
  6406. Set frame rate, expressed as number of frames per second. Default
  6407. value is "25".
  6408. @item size, s
  6409. Set frame size. For the syntax of this option, check the "Video
  6410. size" section in the ffmpeg-utils manual. Default value is "640x480".
  6411. @item start_scale
  6412. Set the initial scale value. Default value is 3.0.
  6413. @item start_x
  6414. Set the initial x position. Must be a floating point value between
  6415. -100 and 100. Default value is -0.743643887037158704752191506114774.
  6416. @item start_y
  6417. Set the initial y position. Must be a floating point value between
  6418. -100 and 100. Default value is -0.131825904205311970493132056385139.
  6419. @end table
  6420. @section mptestsrc
  6421. Generate various test patterns, as generated by the MPlayer test filter.
  6422. The size of the generated video is fixed, and is 256x256.
  6423. This source is useful in particular for testing encoding features.
  6424. This source accepts the following options:
  6425. @table @option
  6426. @item rate, r
  6427. Specify the frame rate of the sourced video, as the number of frames
  6428. generated per second. It has to be a string in the format
  6429. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  6430. number or a valid video frame rate abbreviation. The default value is
  6431. "25".
  6432. @item duration, d
  6433. Set the video duration of the sourced video. The accepted syntax is:
  6434. @example
  6435. [-]HH:MM:SS[.m...]
  6436. [-]S+[.m...]
  6437. @end example
  6438. See also the function @code{av_parse_time()}.
  6439. If not specified, or the expressed duration is negative, the video is
  6440. supposed to be generated forever.
  6441. @item test, t
  6442. Set the number or the name of the test to perform. Supported tests are:
  6443. @table @option
  6444. @item dc_luma
  6445. @item dc_chroma
  6446. @item freq_luma
  6447. @item freq_chroma
  6448. @item amp_luma
  6449. @item amp_chroma
  6450. @item cbp
  6451. @item mv
  6452. @item ring1
  6453. @item ring2
  6454. @item all
  6455. @end table
  6456. Default value is "all", which will cycle through the list of all tests.
  6457. @end table
  6458. For example the following:
  6459. @example
  6460. testsrc=t=dc_luma
  6461. @end example
  6462. will generate a "dc_luma" test pattern.
  6463. @section frei0r_src
  6464. Provide a frei0r source.
  6465. To enable compilation of this filter you need to install the frei0r
  6466. header and configure FFmpeg with @code{--enable-frei0r}.
  6467. This source accepts the following options:
  6468. @table @option
  6469. @item size
  6470. The size of the video to generate. For the syntax of this option, check the
  6471. "Video size" section in the ffmpeg-utils manual.
  6472. @item framerate
  6473. Framerate of the generated video, may be a string of the form
  6474. @var{num}/@var{den} or a frame rate abbreviation.
  6475. @item filter_name
  6476. The name to the frei0r source to load. For more information regarding frei0r and
  6477. how to set the parameters read the section @ref{frei0r} in the description of
  6478. the video filters.
  6479. @item filter_params
  6480. A '|'-separated list of parameters to pass to the frei0r source.
  6481. @end table
  6482. For example, to generate a frei0r partik0l source with size 200x200
  6483. and frame rate 10 which is overlayed on the overlay filter main input:
  6484. @example
  6485. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  6486. @end example
  6487. @section life
  6488. Generate a life pattern.
  6489. This source is based on a generalization of John Conway's life game.
  6490. The sourced input represents a life grid, each pixel represents a cell
  6491. which can be in one of two possible states, alive or dead. Every cell
  6492. interacts with its eight neighbours, which are the cells that are
  6493. horizontally, vertically, or diagonally adjacent.
  6494. At each interaction the grid evolves according to the adopted rule,
  6495. which specifies the number of neighbor alive cells which will make a
  6496. cell stay alive or born. The @option{rule} option allows to specify
  6497. the rule to adopt.
  6498. This source accepts the following options:
  6499. @table @option
  6500. @item filename, f
  6501. Set the file from which to read the initial grid state. In the file,
  6502. each non-whitespace character is considered an alive cell, and newline
  6503. is used to delimit the end of each row.
  6504. If this option is not specified, the initial grid is generated
  6505. randomly.
  6506. @item rate, r
  6507. Set the video rate, that is the number of frames generated per second.
  6508. Default is 25.
  6509. @item random_fill_ratio, ratio
  6510. Set the random fill ratio for the initial random grid. It is a
  6511. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  6512. It is ignored when a file is specified.
  6513. @item random_seed, seed
  6514. Set the seed for filling the initial random grid, must be an integer
  6515. included between 0 and UINT32_MAX. If not specified, or if explicitly
  6516. set to -1, the filter will try to use a good random seed on a best
  6517. effort basis.
  6518. @item rule
  6519. Set the life rule.
  6520. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  6521. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  6522. @var{NS} specifies the number of alive neighbor cells which make a
  6523. live cell stay alive, and @var{NB} the number of alive neighbor cells
  6524. which make a dead cell to become alive (i.e. to "born").
  6525. "s" and "b" can be used in place of "S" and "B", respectively.
  6526. Alternatively a rule can be specified by an 18-bits integer. The 9
  6527. high order bits are used to encode the next cell state if it is alive
  6528. for each number of neighbor alive cells, the low order bits specify
  6529. the rule for "borning" new cells. Higher order bits encode for an
  6530. higher number of neighbor cells.
  6531. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  6532. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  6533. Default value is "S23/B3", which is the original Conway's game of life
  6534. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  6535. cells, and will born a new cell if there are three alive cells around
  6536. a dead cell.
  6537. @item size, s
  6538. Set the size of the output video. For the syntax of this option, check the
  6539. "Video size" section in the ffmpeg-utils manual.
  6540. If @option{filename} is specified, the size is set by default to the
  6541. same size of the input file. If @option{size} is set, it must contain
  6542. the size specified in the input file, and the initial grid defined in
  6543. that file is centered in the larger resulting area.
  6544. If a filename is not specified, the size value defaults to "320x240"
  6545. (used for a randomly generated initial grid).
  6546. @item stitch
  6547. If set to 1, stitch the left and right grid edges together, and the
  6548. top and bottom edges also. Defaults to 1.
  6549. @item mold
  6550. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  6551. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  6552. value from 0 to 255.
  6553. @item life_color
  6554. Set the color of living (or new born) cells.
  6555. @item death_color
  6556. Set the color of dead cells. If @option{mold} is set, this is the first color
  6557. used to represent a dead cell.
  6558. @item mold_color
  6559. Set mold color, for definitely dead and moldy cells.
  6560. For the syntax of these 3 color options, check the "Color" section in the
  6561. ffmpeg-utils manual.
  6562. @end table
  6563. @subsection Examples
  6564. @itemize
  6565. @item
  6566. Read a grid from @file{pattern}, and center it on a grid of size
  6567. 300x300 pixels:
  6568. @example
  6569. life=f=pattern:s=300x300
  6570. @end example
  6571. @item
  6572. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  6573. @example
  6574. life=ratio=2/3:s=200x200
  6575. @end example
  6576. @item
  6577. Specify a custom rule for evolving a randomly generated grid:
  6578. @example
  6579. life=rule=S14/B34
  6580. @end example
  6581. @item
  6582. Full example with slow death effect (mold) using @command{ffplay}:
  6583. @example
  6584. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  6585. @end example
  6586. @end itemize
  6587. @anchor{color}
  6588. @anchor{haldclutsrc}
  6589. @anchor{nullsrc}
  6590. @anchor{rgbtestsrc}
  6591. @anchor{smptebars}
  6592. @anchor{smptehdbars}
  6593. @anchor{testsrc}
  6594. @section color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  6595. The @code{color} source provides an uniformly colored input.
  6596. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  6597. @ref{haldclut} filter.
  6598. The @code{nullsrc} source returns unprocessed video frames. It is
  6599. mainly useful to be employed in analysis / debugging tools, or as the
  6600. source for filters which ignore the input data.
  6601. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  6602. detecting RGB vs BGR issues. You should see a red, green and blue
  6603. stripe from top to bottom.
  6604. The @code{smptebars} source generates a color bars pattern, based on
  6605. the SMPTE Engineering Guideline EG 1-1990.
  6606. The @code{smptehdbars} source generates a color bars pattern, based on
  6607. the SMPTE RP 219-2002.
  6608. The @code{testsrc} source generates a test video pattern, showing a
  6609. color pattern, a scrolling gradient and a timestamp. This is mainly
  6610. intended for testing purposes.
  6611. The sources accept the following options:
  6612. @table @option
  6613. @item color, c
  6614. Specify the color of the source, only available in the @code{color}
  6615. source. For the syntax of this option, check the "Color" section in the
  6616. ffmpeg-utils manual.
  6617. @item level
  6618. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  6619. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  6620. pixels to be used as identity matrix for 3D lookup tables. Each component is
  6621. coded on a @code{1/(N*N)} scale.
  6622. @item size, s
  6623. Specify the size of the sourced video. For the syntax of this option, check the
  6624. "Video size" section in the ffmpeg-utils manual. The default value is
  6625. "320x240".
  6626. This option is not available with the @code{haldclutsrc} filter.
  6627. @item rate, r
  6628. Specify the frame rate of the sourced video, as the number of frames
  6629. generated per second. It has to be a string in the format
  6630. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  6631. number or a valid video frame rate abbreviation. The default value is
  6632. "25".
  6633. @item sar
  6634. Set the sample aspect ratio of the sourced video.
  6635. @item duration, d
  6636. Set the video duration of the sourced video. The accepted syntax is:
  6637. @example
  6638. [-]HH[:MM[:SS[.m...]]]
  6639. [-]S+[.m...]
  6640. @end example
  6641. See also the function @code{av_parse_time()}.
  6642. If not specified, or the expressed duration is negative, the video is
  6643. supposed to be generated forever.
  6644. @item decimals, n
  6645. Set the number of decimals to show in the timestamp, only available in the
  6646. @code{testsrc} source.
  6647. The displayed timestamp value will correspond to the original
  6648. timestamp value multiplied by the power of 10 of the specified
  6649. value. Default value is 0.
  6650. @end table
  6651. For example the following:
  6652. @example
  6653. testsrc=duration=5.3:size=qcif:rate=10
  6654. @end example
  6655. will generate a video with a duration of 5.3 seconds, with size
  6656. 176x144 and a frame rate of 10 frames per second.
  6657. The following graph description will generate a red source
  6658. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  6659. frames per second.
  6660. @example
  6661. color=c=red@@0.2:s=qcif:r=10
  6662. @end example
  6663. If the input content is to be ignored, @code{nullsrc} can be used. The
  6664. following command generates noise in the luminance plane by employing
  6665. the @code{geq} filter:
  6666. @example
  6667. nullsrc=s=256x256, geq=random(1)*255:128:128
  6668. @end example
  6669. @subsection Commands
  6670. The @code{color} source supports the following commands:
  6671. @table @option
  6672. @item c, color
  6673. Set the color of the created image. Accepts the same syntax of the
  6674. corresponding @option{color} option.
  6675. @end table
  6676. @c man end VIDEO SOURCES
  6677. @chapter Video Sinks
  6678. @c man begin VIDEO SINKS
  6679. Below is a description of the currently available video sinks.
  6680. @section buffersink
  6681. Buffer video frames, and make them available to the end of the filter
  6682. graph.
  6683. This sink is mainly intended for a programmatic use, in particular
  6684. through the interface defined in @file{libavfilter/buffersink.h}
  6685. or the options system.
  6686. It accepts a pointer to an AVBufferSinkContext structure, which
  6687. defines the incoming buffers' formats, to be passed as the opaque
  6688. parameter to @code{avfilter_init_filter} for initialization.
  6689. @section nullsink
  6690. Null video sink, do absolutely nothing with the input video. It is
  6691. mainly useful as a template and to be employed in analysis / debugging
  6692. tools.
  6693. @c man end VIDEO SINKS
  6694. @chapter Multimedia Filters
  6695. @c man begin MULTIMEDIA FILTERS
  6696. Below is a description of the currently available multimedia filters.
  6697. @section avectorscope
  6698. Convert input audio to a video output, representing the audio vector
  6699. scope.
  6700. The filter is used to measure the difference between channels of stereo
  6701. audio stream. A monoaural signal, consisting of identical left and right
  6702. signal, results in straight vertical line. Any stereo separation is visible
  6703. as a deviation from this line, creating a Lissajous figure.
  6704. If the straight (or deviation from it) but horizontal line appears this
  6705. indicates that the left and right channels are out of phase.
  6706. The filter accepts the following options:
  6707. @table @option
  6708. @item mode, m
  6709. Set the vectorscope mode.
  6710. Available values are:
  6711. @table @samp
  6712. @item lissajous
  6713. Lissajous rotated by 45 degrees.
  6714. @item lissajous_xy
  6715. Same as above but not rotated.
  6716. @end table
  6717. Default value is @samp{lissajous}.
  6718. @item size, s
  6719. Set the video size for the output. For the syntax of this option, check the "Video size"
  6720. section in the ffmpeg-utils manual. Default value is @code{400x400}.
  6721. @item rate, r
  6722. Set the output frame rate. Default value is @code{25}.
  6723. @item rc
  6724. @item gc
  6725. @item bc
  6726. Specify the red, green and blue contrast. Default values are @code{40}, @code{160} and @code{80}.
  6727. Allowed range is @code{[0, 255]}.
  6728. @item rf
  6729. @item gf
  6730. @item bf
  6731. Specify the red, green and blue fade. Default values are @code{15}, @code{10} and @code{5}.
  6732. Allowed range is @code{[0, 255]}.
  6733. @item zoom
  6734. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  6735. @end table
  6736. @subsection Examples
  6737. @itemize
  6738. @item
  6739. Complete example using @command{ffplay}:
  6740. @example
  6741. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  6742. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  6743. @end example
  6744. @end itemize
  6745. @section concat
  6746. Concatenate audio and video streams, joining them together one after the
  6747. other.
  6748. The filter works on segments of synchronized video and audio streams. All
  6749. segments must have the same number of streams of each type, and that will
  6750. also be the number of streams at output.
  6751. The filter accepts the following options:
  6752. @table @option
  6753. @item n
  6754. Set the number of segments. Default is 2.
  6755. @item v
  6756. Set the number of output video streams, that is also the number of video
  6757. streams in each segment. Default is 1.
  6758. @item a
  6759. Set the number of output audio streams, that is also the number of video
  6760. streams in each segment. Default is 0.
  6761. @item unsafe
  6762. Activate unsafe mode: do not fail if segments have a different format.
  6763. @end table
  6764. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  6765. @var{a} audio outputs.
  6766. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  6767. segment, in the same order as the outputs, then the inputs for the second
  6768. segment, etc.
  6769. Related streams do not always have exactly the same duration, for various
  6770. reasons including codec frame size or sloppy authoring. For that reason,
  6771. related synchronized streams (e.g. a video and its audio track) should be
  6772. concatenated at once. The concat filter will use the duration of the longest
  6773. stream in each segment (except the last one), and if necessary pad shorter
  6774. audio streams with silence.
  6775. For this filter to work correctly, all segments must start at timestamp 0.
  6776. All corresponding streams must have the same parameters in all segments; the
  6777. filtering system will automatically select a common pixel format for video
  6778. streams, and a common sample format, sample rate and channel layout for
  6779. audio streams, but other settings, such as resolution, must be converted
  6780. explicitly by the user.
  6781. Different frame rates are acceptable but will result in variable frame rate
  6782. at output; be sure to configure the output file to handle it.
  6783. @subsection Examples
  6784. @itemize
  6785. @item
  6786. Concatenate an opening, an episode and an ending, all in bilingual version
  6787. (video in stream 0, audio in streams 1 and 2):
  6788. @example
  6789. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  6790. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  6791. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  6792. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  6793. @end example
  6794. @item
  6795. Concatenate two parts, handling audio and video separately, using the
  6796. (a)movie sources, and adjusting the resolution:
  6797. @example
  6798. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  6799. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  6800. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  6801. @end example
  6802. Note that a desync will happen at the stitch if the audio and video streams
  6803. do not have exactly the same duration in the first file.
  6804. @end itemize
  6805. @section ebur128
  6806. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  6807. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  6808. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  6809. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  6810. The filter also has a video output (see the @var{video} option) with a real
  6811. time graph to observe the loudness evolution. The graphic contains the logged
  6812. message mentioned above, so it is not printed anymore when this option is set,
  6813. unless the verbose logging is set. The main graphing area contains the
  6814. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  6815. the momentary loudness (400 milliseconds).
  6816. More information about the Loudness Recommendation EBU R128 on
  6817. @url{http://tech.ebu.ch/loudness}.
  6818. The filter accepts the following options:
  6819. @table @option
  6820. @item video
  6821. Activate the video output. The audio stream is passed unchanged whether this
  6822. option is set or no. The video stream will be the first output stream if
  6823. activated. Default is @code{0}.
  6824. @item size
  6825. Set the video size. This option is for video only. For the syntax of this
  6826. option, check the "Video size" section in the ffmpeg-utils manual. Default
  6827. and minimum resolution is @code{640x480}.
  6828. @item meter
  6829. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  6830. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  6831. other integer value between this range is allowed.
  6832. @item metadata
  6833. Set metadata injection. If set to @code{1}, the audio input will be segmented
  6834. into 100ms output frames, each of them containing various loudness information
  6835. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  6836. Default is @code{0}.
  6837. @item framelog
  6838. Force the frame logging level.
  6839. Available values are:
  6840. @table @samp
  6841. @item info
  6842. information logging level
  6843. @item verbose
  6844. verbose logging level
  6845. @end table
  6846. By default, the logging level is set to @var{info}. If the @option{video} or
  6847. the @option{metadata} options are set, it switches to @var{verbose}.
  6848. @end table
  6849. @subsection Examples
  6850. @itemize
  6851. @item
  6852. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  6853. @example
  6854. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  6855. @end example
  6856. @item
  6857. Run an analysis with @command{ffmpeg}:
  6858. @example
  6859. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  6860. @end example
  6861. @end itemize
  6862. @section interleave, ainterleave
  6863. Temporally interleave frames from several inputs.
  6864. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  6865. These filters read frames from several inputs and send the oldest
  6866. queued frame to the output.
  6867. Input streams must have a well defined, monotonically increasing frame
  6868. timestamp values.
  6869. In order to submit one frame to output, these filters need to enqueue
  6870. at least one frame for each input, so they cannot work in case one
  6871. input is not yet terminated and will not receive incoming frames.
  6872. For example consider the case when one input is a @code{select} filter
  6873. which always drop input frames. The @code{interleave} filter will keep
  6874. reading from that input, but it will never be able to send new frames
  6875. to output until the input will send an end-of-stream signal.
  6876. Also, depending on inputs synchronization, the filters will drop
  6877. frames in case one input receives more frames than the other ones, and
  6878. the queue is already filled.
  6879. These filters accept the following options:
  6880. @table @option
  6881. @item nb_inputs, n
  6882. Set the number of different inputs, it is 2 by default.
  6883. @end table
  6884. @subsection Examples
  6885. @itemize
  6886. @item
  6887. Interleave frames belonging to different streams using @command{ffmpeg}:
  6888. @example
  6889. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  6890. @end example
  6891. @item
  6892. Add flickering blur effect:
  6893. @example
  6894. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  6895. @end example
  6896. @end itemize
  6897. @section perms, aperms
  6898. Set read/write permissions for the output frames.
  6899. These filters are mainly aimed at developers to test direct path in the
  6900. following filter in the filtergraph.
  6901. The filters accept the following options:
  6902. @table @option
  6903. @item mode
  6904. Select the permissions mode.
  6905. It accepts the following values:
  6906. @table @samp
  6907. @item none
  6908. Do nothing. This is the default.
  6909. @item ro
  6910. Set all the output frames read-only.
  6911. @item rw
  6912. Set all the output frames directly writable.
  6913. @item toggle
  6914. Make the frame read-only if writable, and writable if read-only.
  6915. @item random
  6916. Set each output frame read-only or writable randomly.
  6917. @end table
  6918. @item seed
  6919. Set the seed for the @var{random} mode, must be an integer included between
  6920. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  6921. @code{-1}, the filter will try to use a good random seed on a best effort
  6922. basis.
  6923. @end table
  6924. Note: in case of auto-inserted filter between the permission filter and the
  6925. following one, the permission might not be received as expected in that
  6926. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  6927. perms/aperms filter can avoid this problem.
  6928. @section select, aselect
  6929. Select frames to pass in output.
  6930. This filter accepts the following options:
  6931. @table @option
  6932. @item expr, e
  6933. Set expression, which is evaluated for each input frame.
  6934. If the expression is evaluated to zero, the frame is discarded.
  6935. If the evaluation result is negative or NaN, the frame is sent to the
  6936. first output; otherwise it is sent to the output with index
  6937. @code{ceil(val)-1}, assuming that the input index starts from 0.
  6938. For example a value of @code{1.2} corresponds to the output with index
  6939. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  6940. @item outputs, n
  6941. Set the number of outputs. The output to which to send the selected
  6942. frame is based on the result of the evaluation. Default value is 1.
  6943. @end table
  6944. The expression can contain the following constants:
  6945. @table @option
  6946. @item n
  6947. the sequential number of the filtered frame, starting from 0
  6948. @item selected_n
  6949. the sequential number of the selected frame, starting from 0
  6950. @item prev_selected_n
  6951. the sequential number of the last selected frame, NAN if undefined
  6952. @item TB
  6953. timebase of the input timestamps
  6954. @item pts
  6955. the PTS (Presentation TimeStamp) of the filtered video frame,
  6956. expressed in @var{TB} units, NAN if undefined
  6957. @item t
  6958. the PTS (Presentation TimeStamp) of the filtered video frame,
  6959. expressed in seconds, NAN if undefined
  6960. @item prev_pts
  6961. the PTS of the previously filtered video frame, NAN if undefined
  6962. @item prev_selected_pts
  6963. the PTS of the last previously filtered video frame, NAN if undefined
  6964. @item prev_selected_t
  6965. the PTS of the last previously selected video frame, NAN if undefined
  6966. @item start_pts
  6967. the PTS of the first video frame in the video, NAN if undefined
  6968. @item start_t
  6969. the time of the first video frame in the video, NAN if undefined
  6970. @item pict_type @emph{(video only)}
  6971. the type of the filtered frame, can assume one of the following
  6972. values:
  6973. @table @option
  6974. @item I
  6975. @item P
  6976. @item B
  6977. @item S
  6978. @item SI
  6979. @item SP
  6980. @item BI
  6981. @end table
  6982. @item interlace_type @emph{(video only)}
  6983. the frame interlace type, can assume one of the following values:
  6984. @table @option
  6985. @item PROGRESSIVE
  6986. the frame is progressive (not interlaced)
  6987. @item TOPFIRST
  6988. the frame is top-field-first
  6989. @item BOTTOMFIRST
  6990. the frame is bottom-field-first
  6991. @end table
  6992. @item consumed_sample_n @emph{(audio only)}
  6993. the number of selected samples before the current frame
  6994. @item samples_n @emph{(audio only)}
  6995. the number of samples in the current frame
  6996. @item sample_rate @emph{(audio only)}
  6997. the input sample rate
  6998. @item key
  6999. 1 if the filtered frame is a key-frame, 0 otherwise
  7000. @item pos
  7001. the position in the file of the filtered frame, -1 if the information
  7002. is not available (e.g. for synthetic video)
  7003. @item scene @emph{(video only)}
  7004. value between 0 and 1 to indicate a new scene; a low value reflects a low
  7005. probability for the current frame to introduce a new scene, while a higher
  7006. value means the current frame is more likely to be one (see the example below)
  7007. @end table
  7008. The default value of the select expression is "1".
  7009. @subsection Examples
  7010. @itemize
  7011. @item
  7012. Select all frames in input:
  7013. @example
  7014. select
  7015. @end example
  7016. The example above is the same as:
  7017. @example
  7018. select=1
  7019. @end example
  7020. @item
  7021. Skip all frames:
  7022. @example
  7023. select=0
  7024. @end example
  7025. @item
  7026. Select only I-frames:
  7027. @example
  7028. select='eq(pict_type\,I)'
  7029. @end example
  7030. @item
  7031. Select one frame every 100:
  7032. @example
  7033. select='not(mod(n\,100))'
  7034. @end example
  7035. @item
  7036. Select only frames contained in the 10-20 time interval:
  7037. @example
  7038. select=between(t\,10\,20)
  7039. @end example
  7040. @item
  7041. Select only I frames contained in the 10-20 time interval:
  7042. @example
  7043. select=between(t\,10\,20)*eq(pict_type\,I)
  7044. @end example
  7045. @item
  7046. Select frames with a minimum distance of 10 seconds:
  7047. @example
  7048. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  7049. @end example
  7050. @item
  7051. Use aselect to select only audio frames with samples number > 100:
  7052. @example
  7053. aselect='gt(samples_n\,100)'
  7054. @end example
  7055. @item
  7056. Create a mosaic of the first scenes:
  7057. @example
  7058. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  7059. @end example
  7060. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  7061. choice.
  7062. @item
  7063. Send even and odd frames to separate outputs, and compose them:
  7064. @example
  7065. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  7066. @end example
  7067. @end itemize
  7068. @section sendcmd, asendcmd
  7069. Send commands to filters in the filtergraph.
  7070. These filters read commands to be sent to other filters in the
  7071. filtergraph.
  7072. @code{sendcmd} must be inserted between two video filters,
  7073. @code{asendcmd} must be inserted between two audio filters, but apart
  7074. from that they act the same way.
  7075. The specification of commands can be provided in the filter arguments
  7076. with the @var{commands} option, or in a file specified by the
  7077. @var{filename} option.
  7078. These filters accept the following options:
  7079. @table @option
  7080. @item commands, c
  7081. Set the commands to be read and sent to the other filters.
  7082. @item filename, f
  7083. Set the filename of the commands to be read and sent to the other
  7084. filters.
  7085. @end table
  7086. @subsection Commands syntax
  7087. A commands description consists of a sequence of interval
  7088. specifications, comprising a list of commands to be executed when a
  7089. particular event related to that interval occurs. The occurring event
  7090. is typically the current frame time entering or leaving a given time
  7091. interval.
  7092. An interval is specified by the following syntax:
  7093. @example
  7094. @var{START}[-@var{END}] @var{COMMANDS};
  7095. @end example
  7096. The time interval is specified by the @var{START} and @var{END} times.
  7097. @var{END} is optional and defaults to the maximum time.
  7098. The current frame time is considered within the specified interval if
  7099. it is included in the interval [@var{START}, @var{END}), that is when
  7100. the time is greater or equal to @var{START} and is lesser than
  7101. @var{END}.
  7102. @var{COMMANDS} consists of a sequence of one or more command
  7103. specifications, separated by ",", relating to that interval. The
  7104. syntax of a command specification is given by:
  7105. @example
  7106. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  7107. @end example
  7108. @var{FLAGS} is optional and specifies the type of events relating to
  7109. the time interval which enable sending the specified command, and must
  7110. be a non-null sequence of identifier flags separated by "+" or "|" and
  7111. enclosed between "[" and "]".
  7112. The following flags are recognized:
  7113. @table @option
  7114. @item enter
  7115. The command is sent when the current frame timestamp enters the
  7116. specified interval. In other words, the command is sent when the
  7117. previous frame timestamp was not in the given interval, and the
  7118. current is.
  7119. @item leave
  7120. The command is sent when the current frame timestamp leaves the
  7121. specified interval. In other words, the command is sent when the
  7122. previous frame timestamp was in the given interval, and the
  7123. current is not.
  7124. @end table
  7125. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  7126. assumed.
  7127. @var{TARGET} specifies the target of the command, usually the name of
  7128. the filter class or a specific filter instance name.
  7129. @var{COMMAND} specifies the name of the command for the target filter.
  7130. @var{ARG} is optional and specifies the optional list of argument for
  7131. the given @var{COMMAND}.
  7132. Between one interval specification and another, whitespaces, or
  7133. sequences of characters starting with @code{#} until the end of line,
  7134. are ignored and can be used to annotate comments.
  7135. A simplified BNF description of the commands specification syntax
  7136. follows:
  7137. @example
  7138. @var{COMMAND_FLAG} ::= "enter" | "leave"
  7139. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  7140. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  7141. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  7142. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  7143. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  7144. @end example
  7145. @subsection Examples
  7146. @itemize
  7147. @item
  7148. Specify audio tempo change at second 4:
  7149. @example
  7150. asendcmd=c='4.0 atempo tempo 1.5',atempo
  7151. @end example
  7152. @item
  7153. Specify a list of drawtext and hue commands in a file.
  7154. @example
  7155. # show text in the interval 5-10
  7156. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  7157. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  7158. # desaturate the image in the interval 15-20
  7159. 15.0-20.0 [enter] hue s 0,
  7160. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  7161. [leave] hue s 1,
  7162. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  7163. # apply an exponential saturation fade-out effect, starting from time 25
  7164. 25 [enter] hue s exp(25-t)
  7165. @end example
  7166. A filtergraph allowing to read and process the above command list
  7167. stored in a file @file{test.cmd}, can be specified with:
  7168. @example
  7169. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  7170. @end example
  7171. @end itemize
  7172. @anchor{setpts}
  7173. @section setpts, asetpts
  7174. Change the PTS (presentation timestamp) of the input frames.
  7175. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  7176. This filter accepts the following options:
  7177. @table @option
  7178. @item expr
  7179. The expression which is evaluated for each frame to construct its timestamp.
  7180. @end table
  7181. The expression is evaluated through the eval API and can contain the following
  7182. constants:
  7183. @table @option
  7184. @item FRAME_RATE
  7185. frame rate, only defined for constant frame-rate video
  7186. @item PTS
  7187. the presentation timestamp in input
  7188. @item N
  7189. the count of the input frame for video or the number of consumed samples,
  7190. not including the current frame for audio, starting from 0.
  7191. @item NB_CONSUMED_SAMPLES
  7192. the number of consumed samples, not including the current frame (only
  7193. audio)
  7194. @item NB_SAMPLES, S
  7195. the number of samples in the current frame (only audio)
  7196. @item SAMPLE_RATE, SR
  7197. audio sample rate
  7198. @item STARTPTS
  7199. the PTS of the first frame
  7200. @item STARTT
  7201. the time in seconds of the first frame
  7202. @item INTERLACED
  7203. tell if the current frame is interlaced
  7204. @item T
  7205. the time in seconds of the current frame
  7206. @item POS
  7207. original position in the file of the frame, or undefined if undefined
  7208. for the current frame
  7209. @item PREV_INPTS
  7210. previous input PTS
  7211. @item PREV_INT
  7212. previous input time in seconds
  7213. @item PREV_OUTPTS
  7214. previous output PTS
  7215. @item PREV_OUTT
  7216. previous output time in seconds
  7217. @item RTCTIME
  7218. wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  7219. instead.
  7220. @item RTCSTART
  7221. wallclock (RTC) time at the start of the movie in microseconds
  7222. @item TB
  7223. timebase of the input timestamps
  7224. @end table
  7225. @subsection Examples
  7226. @itemize
  7227. @item
  7228. Start counting PTS from zero
  7229. @example
  7230. setpts=PTS-STARTPTS
  7231. @end example
  7232. @item
  7233. Apply fast motion effect:
  7234. @example
  7235. setpts=0.5*PTS
  7236. @end example
  7237. @item
  7238. Apply slow motion effect:
  7239. @example
  7240. setpts=2.0*PTS
  7241. @end example
  7242. @item
  7243. Set fixed rate of 25 frames per second:
  7244. @example
  7245. setpts=N/(25*TB)
  7246. @end example
  7247. @item
  7248. Set fixed rate 25 fps with some jitter:
  7249. @example
  7250. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  7251. @end example
  7252. @item
  7253. Apply an offset of 10 seconds to the input PTS:
  7254. @example
  7255. setpts=PTS+10/TB
  7256. @end example
  7257. @item
  7258. Generate timestamps from a "live source" and rebase onto the current timebase:
  7259. @example
  7260. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  7261. @end example
  7262. @item
  7263. Generate timestamps by counting samples:
  7264. @example
  7265. asetpts=N/SR/TB
  7266. @end example
  7267. @end itemize
  7268. @section settb, asettb
  7269. Set the timebase to use for the output frames timestamps.
  7270. It is mainly useful for testing timebase configuration.
  7271. This filter accepts the following options:
  7272. @table @option
  7273. @item expr, tb
  7274. The expression which is evaluated into the output timebase.
  7275. @end table
  7276. The value for @option{tb} is an arithmetic expression representing a
  7277. rational. The expression can contain the constants "AVTB" (the default
  7278. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  7279. audio only). Default value is "intb".
  7280. @subsection Examples
  7281. @itemize
  7282. @item
  7283. Set the timebase to 1/25:
  7284. @example
  7285. settb=expr=1/25
  7286. @end example
  7287. @item
  7288. Set the timebase to 1/10:
  7289. @example
  7290. settb=expr=0.1
  7291. @end example
  7292. @item
  7293. Set the timebase to 1001/1000:
  7294. @example
  7295. settb=1+0.001
  7296. @end example
  7297. @item
  7298. Set the timebase to 2*intb:
  7299. @example
  7300. settb=2*intb
  7301. @end example
  7302. @item
  7303. Set the default timebase value:
  7304. @example
  7305. settb=AVTB
  7306. @end example
  7307. @end itemize
  7308. @section showspectrum
  7309. Convert input audio to a video output, representing the audio frequency
  7310. spectrum.
  7311. The filter accepts the following options:
  7312. @table @option
  7313. @item size, s
  7314. Specify the video size for the output. For the syntax of this option, check
  7315. the "Video size" section in the ffmpeg-utils manual. Default value is
  7316. @code{640x512}.
  7317. @item slide
  7318. Specify if the spectrum should slide along the window. Default value is
  7319. @code{0}.
  7320. @item mode
  7321. Specify display mode.
  7322. It accepts the following values:
  7323. @table @samp
  7324. @item combined
  7325. all channels are displayed in the same row
  7326. @item separate
  7327. all channels are displayed in separate rows
  7328. @end table
  7329. Default value is @samp{combined}.
  7330. @item color
  7331. Specify display color mode.
  7332. It accepts the following values:
  7333. @table @samp
  7334. @item channel
  7335. each channel is displayed in a separate color
  7336. @item intensity
  7337. each channel is is displayed using the same color scheme
  7338. @end table
  7339. Default value is @samp{channel}.
  7340. @item scale
  7341. Specify scale used for calculating intensity color values.
  7342. It accepts the following values:
  7343. @table @samp
  7344. @item lin
  7345. linear
  7346. @item sqrt
  7347. square root, default
  7348. @item cbrt
  7349. cubic root
  7350. @item log
  7351. logarithmic
  7352. @end table
  7353. Default value is @samp{sqrt}.
  7354. @item saturation
  7355. Set saturation modifier for displayed colors. Negative values provide
  7356. alternative color scheme. @code{0} is no saturation at all.
  7357. Saturation must be in [-10.0, 10.0] range.
  7358. Default value is @code{1}.
  7359. @end table
  7360. The usage is very similar to the showwaves filter; see the examples in that
  7361. section.
  7362. @subsection Examples
  7363. @itemize
  7364. @item
  7365. Large window with logarithmic color scaling:
  7366. @example
  7367. showspectrum=s=1280x480:scale=log
  7368. @end example
  7369. @item
  7370. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  7371. @example
  7372. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  7373. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  7374. @end example
  7375. @end itemize
  7376. @section showwaves
  7377. Convert input audio to a video output, representing the samples waves.
  7378. The filter accepts the following options:
  7379. @table @option
  7380. @item size, s
  7381. Specify the video size for the output. For the syntax of this option, check
  7382. the "Video size" section in the ffmpeg-utils manual. Default value
  7383. is "600x240".
  7384. @item mode
  7385. Set display mode.
  7386. Available values are:
  7387. @table @samp
  7388. @item point
  7389. Draw a point for each sample.
  7390. @item line
  7391. Draw a vertical line for each sample.
  7392. @end table
  7393. Default value is @code{point}.
  7394. @item n
  7395. Set the number of samples which are printed on the same column. A
  7396. larger value will decrease the frame rate. Must be a positive
  7397. integer. This option can be set only if the value for @var{rate}
  7398. is not explicitly specified.
  7399. @item rate, r
  7400. Set the (approximate) output frame rate. This is done by setting the
  7401. option @var{n}. Default value is "25".
  7402. @end table
  7403. @subsection Examples
  7404. @itemize
  7405. @item
  7406. Output the input file audio and the corresponding video representation
  7407. at the same time:
  7408. @example
  7409. amovie=a.mp3,asplit[out0],showwaves[out1]
  7410. @end example
  7411. @item
  7412. Create a synthetic signal and show it with showwaves, forcing a
  7413. frame rate of 30 frames per second:
  7414. @example
  7415. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  7416. @end example
  7417. @end itemize
  7418. @section split, asplit
  7419. Split input into several identical outputs.
  7420. @code{asplit} works with audio input, @code{split} with video.
  7421. The filter accepts a single parameter which specifies the number of outputs. If
  7422. unspecified, it defaults to 2.
  7423. @subsection Examples
  7424. @itemize
  7425. @item
  7426. Create two separate outputs from the same input:
  7427. @example
  7428. [in] split [out0][out1]
  7429. @end example
  7430. @item
  7431. To create 3 or more outputs, you need to specify the number of
  7432. outputs, like in:
  7433. @example
  7434. [in] asplit=3 [out0][out1][out2]
  7435. @end example
  7436. @item
  7437. Create two separate outputs from the same input, one cropped and
  7438. one padded:
  7439. @example
  7440. [in] split [splitout1][splitout2];
  7441. [splitout1] crop=100:100:0:0 [cropout];
  7442. [splitout2] pad=200:200:100:100 [padout];
  7443. @end example
  7444. @item
  7445. Create 5 copies of the input audio with @command{ffmpeg}:
  7446. @example
  7447. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  7448. @end example
  7449. @end itemize
  7450. @section zmq, azmq
  7451. Receive commands sent through a libzmq client, and forward them to
  7452. filters in the filtergraph.
  7453. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  7454. must be inserted between two video filters, @code{azmq} between two
  7455. audio filters.
  7456. To enable these filters you need to install the libzmq library and
  7457. headers and configure FFmpeg with @code{--enable-libzmq}.
  7458. For more information about libzmq see:
  7459. @url{http://www.zeromq.org/}
  7460. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  7461. receives messages sent through a network interface defined by the
  7462. @option{bind_address} option.
  7463. The received message must be in the form:
  7464. @example
  7465. @var{TARGET} @var{COMMAND} [@var{ARG}]
  7466. @end example
  7467. @var{TARGET} specifies the target of the command, usually the name of
  7468. the filter class or a specific filter instance name.
  7469. @var{COMMAND} specifies the name of the command for the target filter.
  7470. @var{ARG} is optional and specifies the optional argument list for the
  7471. given @var{COMMAND}.
  7472. Upon reception, the message is processed and the corresponding command
  7473. is injected into the filtergraph. Depending on the result, the filter
  7474. will send a reply to the client, adopting the format:
  7475. @example
  7476. @var{ERROR_CODE} @var{ERROR_REASON}
  7477. @var{MESSAGE}
  7478. @end example
  7479. @var{MESSAGE} is optional.
  7480. @subsection Examples
  7481. Look at @file{tools/zmqsend} for an example of a zmq client which can
  7482. be used to send commands processed by these filters.
  7483. Consider the following filtergraph generated by @command{ffplay}
  7484. @example
  7485. ffplay -dumpgraph 1 -f lavfi "
  7486. color=s=100x100:c=red [l];
  7487. color=s=100x100:c=blue [r];
  7488. nullsrc=s=200x100, zmq [bg];
  7489. [bg][l] overlay [bg+l];
  7490. [bg+l][r] overlay=x=100 "
  7491. @end example
  7492. To change the color of the left side of the video, the following
  7493. command can be used:
  7494. @example
  7495. echo Parsed_color_0 c yellow | tools/zmqsend
  7496. @end example
  7497. To change the right side:
  7498. @example
  7499. echo Parsed_color_1 c pink | tools/zmqsend
  7500. @end example
  7501. @c man end MULTIMEDIA FILTERS
  7502. @chapter Multimedia Sources
  7503. @c man begin MULTIMEDIA SOURCES
  7504. Below is a description of the currently available multimedia sources.
  7505. @section amovie
  7506. This is the same as @ref{movie} source, except it selects an audio
  7507. stream by default.
  7508. @anchor{movie}
  7509. @section movie
  7510. Read audio and/or video stream(s) from a movie container.
  7511. This filter accepts the following options:
  7512. @table @option
  7513. @item filename
  7514. The name of the resource to read (not necessarily a file but also a device or a
  7515. stream accessed through some protocol).
  7516. @item format_name, f
  7517. Specifies the format assumed for the movie to read, and can be either
  7518. the name of a container or an input device. If not specified the
  7519. format is guessed from @var{movie_name} or by probing.
  7520. @item seek_point, sp
  7521. Specifies the seek point in seconds, the frames will be output
  7522. starting from this seek point, the parameter is evaluated with
  7523. @code{av_strtod} so the numerical value may be suffixed by an IS
  7524. postfix. Default value is "0".
  7525. @item streams, s
  7526. Specifies the streams to read. Several streams can be specified,
  7527. separated by "+". The source will then have as many outputs, in the
  7528. same order. The syntax is explained in the ``Stream specifiers''
  7529. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  7530. respectively the default (best suited) video and audio stream. Default
  7531. is "dv", or "da" if the filter is called as "amovie".
  7532. @item stream_index, si
  7533. Specifies the index of the video stream to read. If the value is -1,
  7534. the best suited video stream will be automatically selected. Default
  7535. value is "-1". Deprecated. If the filter is called "amovie", it will select
  7536. audio instead of video.
  7537. @item loop
  7538. Specifies how many times to read the stream in sequence.
  7539. If the value is less than 1, the stream will be read again and again.
  7540. Default value is "1".
  7541. Note that when the movie is looped the source timestamps are not
  7542. changed, so it will generate non monotonically increasing timestamps.
  7543. @end table
  7544. This filter allows to overlay a second video on top of main input of
  7545. a filtergraph as shown in this graph:
  7546. @example
  7547. input -----------> deltapts0 --> overlay --> output
  7548. ^
  7549. |
  7550. movie --> scale--> deltapts1 -------+
  7551. @end example
  7552. @subsection Examples
  7553. @itemize
  7554. @item
  7555. Skip 3.2 seconds from the start of the avi file in.avi, and overlay it
  7556. on top of the input labelled as "in":
  7557. @example
  7558. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  7559. [in] setpts=PTS-STARTPTS [main];
  7560. [main][over] overlay=16:16 [out]
  7561. @end example
  7562. @item
  7563. Read from a video4linux2 device, and overlay it on top of the input
  7564. labelled as "in":
  7565. @example
  7566. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  7567. [in] setpts=PTS-STARTPTS [main];
  7568. [main][over] overlay=16:16 [out]
  7569. @end example
  7570. @item
  7571. Read the first video stream and the audio stream with id 0x81 from
  7572. dvd.vob; the video is connected to the pad named "video" and the audio is
  7573. connected to the pad named "audio":
  7574. @example
  7575. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  7576. @end example
  7577. @end itemize
  7578. @c man end MULTIMEDIA SOURCES