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.

9885 lines
266KB

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