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.

9995 lines
269KB

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