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.

9977 lines
269KB

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