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.

10058 lines
271KB

  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 elbg
  2905. Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
  2906. For each input image, the filter will compute the optimal mapping from
  2907. the input to the output given the codebook length, that is the number
  2908. of distinct output colors.
  2909. This filter accepts the following options.
  2910. @table @option
  2911. @item codebook_length, l
  2912. Set codebook length. The value must be a positive integer, and
  2913. represents the number of distinct output colors. Default value is 256.
  2914. @item nb_steps, n
  2915. Set the maximum number of iterations to apply for computing the optimal
  2916. mapping. The higher the value the better the result and the higher the
  2917. computation time. Default value is 1.
  2918. @item seed, s
  2919. Set a random seed, must be an integer included between 0 and
  2920. UINT32_MAX. If not specified, or if explicitly set to -1, the filter
  2921. will try to use a good random seed on a best effort basis.
  2922. @end table
  2923. @section fade
  2924. Apply fade-in/out effect to input video.
  2925. This filter accepts the following options:
  2926. @table @option
  2927. @item type, t
  2928. The effect type -- can be either "in" for fade-in, or "out" for a fade-out
  2929. effect.
  2930. Default is @code{in}.
  2931. @item start_frame, s
  2932. Specify the number of the start frame for starting to apply the fade
  2933. effect. Default is 0.
  2934. @item nb_frames, n
  2935. The number of frames for which the fade effect has to last. At the end of the
  2936. fade-in effect the output video will have the same intensity as the input video,
  2937. at the end of the fade-out transition the output video will be filled with the
  2938. selected @option{color}.
  2939. Default is 25.
  2940. @item alpha
  2941. If set to 1, fade only alpha channel, if one exists on the input.
  2942. Default value is 0.
  2943. @item start_time, st
  2944. Specify the timestamp (in seconds) of the frame to start to apply the fade
  2945. effect. If both start_frame and start_time are specified, the fade will start at
  2946. whichever comes last. Default is 0.
  2947. @item duration, d
  2948. The number of seconds for which the fade effect has to last. At the end of the
  2949. fade-in effect the output video will have the same intensity as the input video,
  2950. at the end of the fade-out transition the output video will be filled with the
  2951. selected @option{color}.
  2952. If both duration and nb_frames are specified, duration is used. Default is 0.
  2953. @item color, c
  2954. Specify the color of the fade. Default is "black".
  2955. @end table
  2956. @subsection Examples
  2957. @itemize
  2958. @item
  2959. Fade in first 30 frames of video:
  2960. @example
  2961. fade=in:0:30
  2962. @end example
  2963. The command above is equivalent to:
  2964. @example
  2965. fade=t=in:s=0:n=30
  2966. @end example
  2967. @item
  2968. Fade out last 45 frames of a 200-frame video:
  2969. @example
  2970. fade=out:155:45
  2971. fade=type=out:start_frame=155:nb_frames=45
  2972. @end example
  2973. @item
  2974. Fade in first 25 frames and fade out last 25 frames of a 1000-frame video:
  2975. @example
  2976. fade=in:0:25, fade=out:975:25
  2977. @end example
  2978. @item
  2979. Make first 5 frames yellow, then fade in from frame 5-24:
  2980. @example
  2981. fade=in:5:20:color=yellow
  2982. @end example
  2983. @item
  2984. Fade in alpha over first 25 frames of video:
  2985. @example
  2986. fade=in:0:25:alpha=1
  2987. @end example
  2988. @item
  2989. Make first 5.5 seconds black, then fade in for 0.5 seconds:
  2990. @example
  2991. fade=t=in:st=5.5:d=0.5
  2992. @end example
  2993. @end itemize
  2994. @section field
  2995. Extract a single field from an interlaced image using stride
  2996. arithmetic to avoid wasting CPU time. The output frames are marked as
  2997. non-interlaced.
  2998. The filter accepts the following options:
  2999. @table @option
  3000. @item type
  3001. Specify whether to extract the top (if the value is @code{0} or
  3002. @code{top}) or the bottom field (if the value is @code{1} or
  3003. @code{bottom}).
  3004. @end table
  3005. @section fieldmatch
  3006. Field matching filter for inverse telecine. It is meant to reconstruct the
  3007. progressive frames from a telecined stream. The filter does not drop duplicated
  3008. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  3009. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  3010. The separation of the field matching and the decimation is notably motivated by
  3011. the possibility of inserting a de-interlacing filter fallback between the two.
  3012. If the source has mixed telecined and real interlaced content,
  3013. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  3014. But these remaining combed frames will be marked as interlaced, and thus can be
  3015. de-interlaced by a later filter such as @ref{yadif} before decimation.
  3016. In addition to the various configuration options, @code{fieldmatch} can take an
  3017. optional second stream, activated through the @option{ppsrc} option. If
  3018. enabled, the frames reconstruction will be based on the fields and frames from
  3019. this second stream. This allows the first input to be pre-processed in order to
  3020. help the various algorithms of the filter, while keeping the output lossless
  3021. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  3022. or brightness/contrast adjustments can help.
  3023. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  3024. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  3025. which @code{fieldmatch} is based on. While the semantic and usage are very
  3026. close, some behaviour and options names can differ.
  3027. The filter accepts the following options:
  3028. @table @option
  3029. @item order
  3030. Specify the assumed field order of the input stream. Available values are:
  3031. @table @samp
  3032. @item auto
  3033. Auto detect parity (use FFmpeg's internal parity value).
  3034. @item bff
  3035. Assume bottom field first.
  3036. @item tff
  3037. Assume top field first.
  3038. @end table
  3039. Note that it is sometimes recommended not to trust the parity announced by the
  3040. stream.
  3041. Default value is @var{auto}.
  3042. @item mode
  3043. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  3044. sense that it won't risk creating jerkiness due to duplicate frames when
  3045. possible, but if there are bad edits or blended fields it will end up
  3046. outputting combed frames when a good match might actually exist. On the other
  3047. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  3048. but will almost always find a good frame if there is one. The other values are
  3049. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  3050. jerkiness and creating duplicate frames versus finding good matches in sections
  3051. with bad edits, orphaned fields, blended fields, etc.
  3052. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  3053. Available values are:
  3054. @table @samp
  3055. @item pc
  3056. 2-way matching (p/c)
  3057. @item pc_n
  3058. 2-way matching, and trying 3rd match if still combed (p/c + n)
  3059. @item pc_u
  3060. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  3061. @item pc_n_ub
  3062. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  3063. still combed (p/c + n + u/b)
  3064. @item pcn
  3065. 3-way matching (p/c/n)
  3066. @item pcn_ub
  3067. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  3068. detected as combed (p/c/n + u/b)
  3069. @end table
  3070. The parenthesis at the end indicate the matches that would be used for that
  3071. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  3072. @var{top}).
  3073. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  3074. the slowest.
  3075. Default value is @var{pc_n}.
  3076. @item ppsrc
  3077. Mark the main input stream as a pre-processed input, and enable the secondary
  3078. input stream as the clean source to pick the fields from. See the filter
  3079. introduction for more details. It is similar to the @option{clip2} feature from
  3080. VFM/TFM.
  3081. Default value is @code{0} (disabled).
  3082. @item field
  3083. Set the field to match from. It is recommended to set this to the same value as
  3084. @option{order} unless you experience matching failures with that setting. In
  3085. certain circumstances changing the field that is used to match from can have a
  3086. large impact on matching performance. Available values are:
  3087. @table @samp
  3088. @item auto
  3089. Automatic (same value as @option{order}).
  3090. @item bottom
  3091. Match from the bottom field.
  3092. @item top
  3093. Match from the top field.
  3094. @end table
  3095. Default value is @var{auto}.
  3096. @item mchroma
  3097. Set whether or not chroma is included during the match comparisons. In most
  3098. cases it is recommended to leave this enabled. You should set this to @code{0}
  3099. only if your clip has bad chroma problems such as heavy rainbowing or other
  3100. artifacts. Setting this to @code{0} could also be used to speed things up at
  3101. the cost of some accuracy.
  3102. Default value is @code{1}.
  3103. @item y0
  3104. @item y1
  3105. These define an exclusion band which excludes the lines between @option{y0} and
  3106. @option{y1} from being included in the field matching decision. An exclusion
  3107. band can be used to ignore subtitles, a logo, or other things that may
  3108. interfere with the matching. @option{y0} sets the starting scan line and
  3109. @option{y1} sets the ending line; all lines in between @option{y0} and
  3110. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  3111. @option{y0} and @option{y1} to the same value will disable the feature.
  3112. @option{y0} and @option{y1} defaults to @code{0}.
  3113. @item scthresh
  3114. Set the scene change detection threshold as a percentage of maximum change on
  3115. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  3116. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  3117. @option{scthresh} is @code{[0.0, 100.0]}.
  3118. Default value is @code{12.0}.
  3119. @item combmatch
  3120. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  3121. account the combed scores of matches when deciding what match to use as the
  3122. final match. Available values are:
  3123. @table @samp
  3124. @item none
  3125. No final matching based on combed scores.
  3126. @item sc
  3127. Combed scores are only used when a scene change is detected.
  3128. @item full
  3129. Use combed scores all the time.
  3130. @end table
  3131. Default is @var{sc}.
  3132. @item combdbg
  3133. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  3134. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  3135. Available values are:
  3136. @table @samp
  3137. @item none
  3138. No forced calculation.
  3139. @item pcn
  3140. Force p/c/n calculations.
  3141. @item pcnub
  3142. Force p/c/n/u/b calculations.
  3143. @end table
  3144. Default value is @var{none}.
  3145. @item cthresh
  3146. This is the area combing threshold used for combed frame detection. This
  3147. essentially controls how "strong" or "visible" combing must be to be detected.
  3148. Larger values mean combing must be more visible and smaller values mean combing
  3149. can be less visible or strong and still be detected. Valid settings are from
  3150. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  3151. be detected as combed). This is basically a pixel difference value. A good
  3152. range is @code{[8, 12]}.
  3153. Default value is @code{9}.
  3154. @item chroma
  3155. Sets whether or not chroma is considered in the combed frame decision. Only
  3156. disable this if your source has chroma problems (rainbowing, etc.) that are
  3157. causing problems for the combed frame detection with chroma enabled. Actually,
  3158. using @option{chroma}=@var{0} is usually more reliable, except for the case
  3159. where there is chroma only combing in the source.
  3160. Default value is @code{0}.
  3161. @item blockx
  3162. @item blocky
  3163. Respectively set the x-axis and y-axis size of the window used during combed
  3164. frame detection. This has to do with the size of the area in which
  3165. @option{combpel} pixels are required to be detected as combed for a frame to be
  3166. declared combed. See the @option{combpel} parameter description for more info.
  3167. Possible values are any number that is a power of 2 starting at 4 and going up
  3168. to 512.
  3169. Default value is @code{16}.
  3170. @item combpel
  3171. The number of combed pixels inside any of the @option{blocky} by
  3172. @option{blockx} size blocks on the frame for the frame to be detected as
  3173. combed. While @option{cthresh} controls how "visible" the combing must be, this
  3174. setting controls "how much" combing there must be in any localized area (a
  3175. window defined by the @option{blockx} and @option{blocky} settings) on the
  3176. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  3177. which point no frames will ever be detected as combed). This setting is known
  3178. as @option{MI} in TFM/VFM vocabulary.
  3179. Default value is @code{80}.
  3180. @end table
  3181. @anchor{p/c/n/u/b meaning}
  3182. @subsection p/c/n/u/b meaning
  3183. @subsubsection p/c/n
  3184. We assume the following telecined stream:
  3185. @example
  3186. Top fields: 1 2 2 3 4
  3187. Bottom fields: 1 2 3 4 4
  3188. @end example
  3189. The numbers correspond to the progressive frame the fields relate to. Here, the
  3190. first two frames are progressive, the 3rd and 4th are combed, and so on.
  3191. When @code{fieldmatch} is configured to run a matching from bottom
  3192. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  3193. @example
  3194. Input stream:
  3195. T 1 2 2 3 4
  3196. B 1 2 3 4 4 <-- matching reference
  3197. Matches: c c n n c
  3198. Output stream:
  3199. T 1 2 3 4 4
  3200. B 1 2 3 4 4
  3201. @end example
  3202. As a result of the field matching, we can see that some frames get duplicated.
  3203. To perform a complete inverse telecine, you need to rely on a decimation filter
  3204. after this operation. See for instance the @ref{decimate} filter.
  3205. The same operation now matching from top fields (@option{field}=@var{top})
  3206. looks like this:
  3207. @example
  3208. Input stream:
  3209. T 1 2 2 3 4 <-- matching reference
  3210. B 1 2 3 4 4
  3211. Matches: c c p p c
  3212. Output stream:
  3213. T 1 2 2 3 4
  3214. B 1 2 2 3 4
  3215. @end example
  3216. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  3217. basically, they refer to the frame and field of the opposite parity:
  3218. @itemize
  3219. @item @var{p} matches the field of the opposite parity in the previous frame
  3220. @item @var{c} matches the field of the opposite parity in the current frame
  3221. @item @var{n} matches the field of the opposite parity in the next frame
  3222. @end itemize
  3223. @subsubsection u/b
  3224. The @var{u} and @var{b} matching are a bit special in the sense that they match
  3225. from the opposite parity flag. In the following examples, we assume that we are
  3226. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  3227. 'x' is placed above and below each matched fields.
  3228. With bottom matching (@option{field}=@var{bottom}):
  3229. @example
  3230. Match: c p n b u
  3231. x x x x x
  3232. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  3233. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  3234. x x x x x
  3235. Output frames:
  3236. 2 1 2 2 2
  3237. 2 2 2 1 3
  3238. @end example
  3239. With top matching (@option{field}=@var{top}):
  3240. @example
  3241. Match: c p n b u
  3242. x x x x x
  3243. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  3244. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  3245. x x x x x
  3246. Output frames:
  3247. 2 2 2 1 2
  3248. 2 1 3 2 2
  3249. @end example
  3250. @subsection Examples
  3251. Simple IVTC of a top field first telecined stream:
  3252. @example
  3253. fieldmatch=order=tff:combmatch=none, decimate
  3254. @end example
  3255. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  3256. @example
  3257. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  3258. @end example
  3259. @section fieldorder
  3260. Transform the field order of the input video.
  3261. This filter accepts the following options:
  3262. @table @option
  3263. @item order
  3264. Output field order. Valid values are @var{tff} for top field first or @var{bff}
  3265. for bottom field first.
  3266. @end table
  3267. Default value is @samp{tff}.
  3268. Transformation is achieved by shifting the picture content up or down
  3269. by one line, and filling the remaining line with appropriate picture content.
  3270. This method is consistent with most broadcast field order converters.
  3271. If the input video is not flagged as being interlaced, or it is already
  3272. flagged as being of the required output field order then this filter does
  3273. not alter the incoming video.
  3274. This filter is very useful when converting to or from PAL DV material,
  3275. which is bottom field first.
  3276. For example:
  3277. @example
  3278. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  3279. @end example
  3280. @section fifo
  3281. Buffer input images and send them when they are requested.
  3282. This filter is mainly useful when auto-inserted by the libavfilter
  3283. framework.
  3284. The filter does not take parameters.
  3285. @anchor{format}
  3286. @section format
  3287. Convert the input video to one of the specified pixel formats.
  3288. Libavfilter will try to pick one that is supported for the input to
  3289. the next filter.
  3290. This filter accepts the following parameters:
  3291. @table @option
  3292. @item pix_fmts
  3293. A '|'-separated list of pixel format names, for example
  3294. "pix_fmts=yuv420p|monow|rgb24".
  3295. @end table
  3296. @subsection Examples
  3297. @itemize
  3298. @item
  3299. Convert the input video to the format @var{yuv420p}
  3300. @example
  3301. format=pix_fmts=yuv420p
  3302. @end example
  3303. Convert the input video to any of the formats in the list
  3304. @example
  3305. format=pix_fmts=yuv420p|yuv444p|yuv410p
  3306. @end example
  3307. @end itemize
  3308. @section fps
  3309. Convert the video to specified constant frame rate by duplicating or dropping
  3310. frames as necessary.
  3311. This filter accepts the following named parameters:
  3312. @table @option
  3313. @item fps
  3314. Desired output frame rate. The default is @code{25}.
  3315. @item round
  3316. Rounding method.
  3317. Possible values are:
  3318. @table @option
  3319. @item zero
  3320. zero round towards 0
  3321. @item inf
  3322. round away from 0
  3323. @item down
  3324. round towards -infinity
  3325. @item up
  3326. round towards +infinity
  3327. @item near
  3328. round to nearest
  3329. @end table
  3330. The default is @code{near}.
  3331. @item start_time
  3332. Assume the first PTS should be the given value, in seconds. This allows for
  3333. padding/trimming at the start of stream. By default, no assumption is made
  3334. about the first frame's expected PTS, so no padding or trimming is done.
  3335. For example, this could be set to 0 to pad the beginning with duplicates of
  3336. the first frame if a video stream starts after the audio stream or to trim any
  3337. frames with a negative PTS.
  3338. @end table
  3339. Alternatively, the options can be specified as a flat string:
  3340. @var{fps}[:@var{round}].
  3341. See also the @ref{setpts} filter.
  3342. @subsection Examples
  3343. @itemize
  3344. @item
  3345. A typical usage in order to set the fps to 25:
  3346. @example
  3347. fps=fps=25
  3348. @end example
  3349. @item
  3350. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  3351. @example
  3352. fps=fps=film:round=near
  3353. @end example
  3354. @end itemize
  3355. @section framestep
  3356. Select one frame every N-th frame.
  3357. This filter accepts the following option:
  3358. @table @option
  3359. @item step
  3360. Select frame after every @code{step} frames.
  3361. Allowed values are positive integers higher than 0. Default value is @code{1}.
  3362. @end table
  3363. @anchor{frei0r}
  3364. @section frei0r
  3365. Apply a frei0r effect to the input video.
  3366. To enable compilation of this filter you need to install the frei0r
  3367. header and configure FFmpeg with @code{--enable-frei0r}.
  3368. This filter accepts the following options:
  3369. @table @option
  3370. @item filter_name
  3371. The name to the frei0r effect to load. If the environment variable
  3372. @env{FREI0R_PATH} is defined, the frei0r effect is searched in each one of the
  3373. directories specified by the colon separated list in @env{FREIOR_PATH},
  3374. otherwise in the standard frei0r paths, which are in this order:
  3375. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  3376. @file{/usr/lib/frei0r-1/}.
  3377. @item filter_params
  3378. A '|'-separated list of parameters to pass to the frei0r effect.
  3379. @end table
  3380. A frei0r effect parameter can be a boolean (whose values are specified
  3381. with "y" and "n"), a double, a color (specified by the syntax
  3382. @var{R}/@var{G}/@var{B}, (@var{R}, @var{G}, and @var{B} being float
  3383. numbers from 0.0 to 1.0) or by a color description specified in the "Color"
  3384. section in the ffmpeg-utils manual), a position (specified by the syntax @var{X}/@var{Y},
  3385. @var{X} and @var{Y} being float numbers) and a string.
  3386. The number and kind of parameters depend on the loaded effect. If an
  3387. effect parameter is not specified the default value is set.
  3388. @subsection Examples
  3389. @itemize
  3390. @item
  3391. Apply the distort0r effect, set the first two double parameters:
  3392. @example
  3393. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  3394. @end example
  3395. @item
  3396. Apply the colordistance effect, take a color as first parameter:
  3397. @example
  3398. frei0r=colordistance:0.2/0.3/0.4
  3399. frei0r=colordistance:violet
  3400. frei0r=colordistance:0x112233
  3401. @end example
  3402. @item
  3403. Apply the perspective effect, specify the top left and top right image
  3404. positions:
  3405. @example
  3406. frei0r=perspective:0.2/0.2|0.8/0.2
  3407. @end example
  3408. @end itemize
  3409. For more information see:
  3410. @url{http://frei0r.dyne.org}
  3411. @section geq
  3412. The filter accepts the following options:
  3413. @table @option
  3414. @item lum_expr, lum
  3415. Set the luminance expression.
  3416. @item cb_expr, cb
  3417. Set the chrominance blue expression.
  3418. @item cr_expr, cr
  3419. Set the chrominance red expression.
  3420. @item alpha_expr, a
  3421. Set the alpha expression.
  3422. @item red_expr, r
  3423. Set the red expression.
  3424. @item green_expr, g
  3425. Set the green expression.
  3426. @item blue_expr, b
  3427. Set the blue expression.
  3428. @end table
  3429. The colorspace is selected according to the specified options. If one
  3430. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  3431. options is specified, the filter will automatically select a YCbCr
  3432. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  3433. @option{blue_expr} options is specified, it will select an RGB
  3434. colorspace.
  3435. If one of the chrominance expression is not defined, it falls back on the other
  3436. one. If no alpha expression is specified it will evaluate to opaque value.
  3437. If none of chrominance expressions are specified, they will evaluate
  3438. to the luminance expression.
  3439. The expressions can use the following variables and functions:
  3440. @table @option
  3441. @item N
  3442. The sequential number of the filtered frame, starting from @code{0}.
  3443. @item X
  3444. @item Y
  3445. The coordinates of the current sample.
  3446. @item W
  3447. @item H
  3448. The width and height of the image.
  3449. @item SW
  3450. @item SH
  3451. Width and height scale depending on the currently filtered plane. It is the
  3452. ratio between the corresponding luma plane number of pixels and the current
  3453. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  3454. @code{0.5,0.5} for chroma planes.
  3455. @item T
  3456. Time of the current frame, expressed in seconds.
  3457. @item p(x, y)
  3458. Return the value of the pixel at location (@var{x},@var{y}) of the current
  3459. plane.
  3460. @item lum(x, y)
  3461. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  3462. plane.
  3463. @item cb(x, y)
  3464. Return the value of the pixel at location (@var{x},@var{y}) of the
  3465. blue-difference chroma plane. Return 0 if there is no such plane.
  3466. @item cr(x, y)
  3467. Return the value of the pixel at location (@var{x},@var{y}) of the
  3468. red-difference chroma plane. Return 0 if there is no such plane.
  3469. @item r(x, y)
  3470. @item g(x, y)
  3471. @item b(x, y)
  3472. Return the value of the pixel at location (@var{x},@var{y}) of the
  3473. red/green/blue component. Return 0 if there is no such component.
  3474. @item alpha(x, y)
  3475. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  3476. plane. Return 0 if there is no such plane.
  3477. @end table
  3478. For functions, if @var{x} and @var{y} are outside the area, the value will be
  3479. automatically clipped to the closer edge.
  3480. @subsection Examples
  3481. @itemize
  3482. @item
  3483. Flip the image horizontally:
  3484. @example
  3485. geq=p(W-X\,Y)
  3486. @end example
  3487. @item
  3488. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  3489. wavelength of 100 pixels:
  3490. @example
  3491. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  3492. @end example
  3493. @item
  3494. Generate a fancy enigmatic moving light:
  3495. @example
  3496. 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
  3497. @end example
  3498. @item
  3499. Generate a quick emboss effect:
  3500. @example
  3501. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  3502. @end example
  3503. @item
  3504. Modify RGB components depending on pixel position:
  3505. @example
  3506. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  3507. @end example
  3508. @end itemize
  3509. @section gradfun
  3510. Fix the banding artifacts that are sometimes introduced into nearly flat
  3511. regions by truncation to 8bit color depth.
  3512. Interpolate the gradients that should go where the bands are, and
  3513. dither them.
  3514. This filter is designed for playback only. Do not use it prior to
  3515. lossy compression, because compression tends to lose the dither and
  3516. bring back the bands.
  3517. This filter accepts the following options:
  3518. @table @option
  3519. @item strength
  3520. The maximum amount by which the filter will change any one pixel. Also the
  3521. threshold for detecting nearly flat regions. Acceptable values range from .51 to
  3522. 64, default value is 1.2, out-of-range values will be clipped to the valid
  3523. range.
  3524. @item radius
  3525. The neighborhood to fit the gradient to. A larger radius makes for smoother
  3526. gradients, but also prevents the filter from modifying the pixels near detailed
  3527. regions. Acceptable values are 8-32, default value is 16, out-of-range values
  3528. will be clipped to the valid range.
  3529. @end table
  3530. Alternatively, the options can be specified as a flat string:
  3531. @var{strength}[:@var{radius}]
  3532. @subsection Examples
  3533. @itemize
  3534. @item
  3535. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  3536. @example
  3537. gradfun=3.5:8
  3538. @end example
  3539. @item
  3540. Specify radius, omitting the strength (which will fall-back to the default
  3541. value):
  3542. @example
  3543. gradfun=radius=8
  3544. @end example
  3545. @end itemize
  3546. @anchor{haldclut}
  3547. @section haldclut
  3548. Apply a Hald CLUT to a video stream.
  3549. First input is the video stream to process, and second one is the Hald CLUT.
  3550. The Hald CLUT input can be a simple picture or a complete video stream.
  3551. The filter accepts the following options:
  3552. @table @option
  3553. @item shortest
  3554. Force termination when the shortest input terminates. Default is @code{0}.
  3555. @item repeatlast
  3556. Continue applying the last CLUT after the end of the stream. A value of
  3557. @code{0} disable the filter after the last frame of the CLUT is reached.
  3558. Default is @code{1}.
  3559. @end table
  3560. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  3561. filters share the same internals).
  3562. More information about the Hald CLUT can be found on Eskil Steenberg's website
  3563. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  3564. @subsection Workflow examples
  3565. @subsubsection Hald CLUT video stream
  3566. Generate an identity Hald CLUT stream altered with various effects:
  3567. @example
  3568. 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
  3569. @end example
  3570. Note: make sure you use a lossless codec.
  3571. Then use it with @code{haldclut} to apply it on some random stream:
  3572. @example
  3573. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  3574. @end example
  3575. The Hald CLUT will be applied to the 10 first seconds (duration of
  3576. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  3577. to the remaining frames of the @code{mandelbrot} stream.
  3578. @subsubsection Hald CLUT with preview
  3579. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  3580. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  3581. biggest possible square starting at the top left of the picture. The remaining
  3582. padding pixels (bottom or right) will be ignored. This area can be used to add
  3583. a preview of the Hald CLUT.
  3584. Typically, the following generated Hald CLUT will be supported by the
  3585. @code{haldclut} filter:
  3586. @example
  3587. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  3588. pad=iw+320 [padded_clut];
  3589. smptebars=s=320x256, split [a][b];
  3590. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  3591. [main][b] overlay=W-320" -frames:v 1 clut.png
  3592. @end example
  3593. It contains the original and a preview of the effect of the CLUT: SMPTE color
  3594. bars are displayed on the right-top, and below the same color bars processed by
  3595. the color changes.
  3596. Then, the effect of this Hald CLUT can be visualized with:
  3597. @example
  3598. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  3599. @end example
  3600. @section hflip
  3601. Flip the input video horizontally.
  3602. For example to horizontally flip the input video with @command{ffmpeg}:
  3603. @example
  3604. ffmpeg -i in.avi -vf "hflip" out.avi
  3605. @end example
  3606. @section histeq
  3607. This filter applies a global color histogram equalization on a
  3608. per-frame basis.
  3609. It can be used to correct video that has a compressed range of pixel
  3610. intensities. The filter redistributes the pixel intensities to
  3611. equalize their distribution across the intensity range. It may be
  3612. viewed as an "automatically adjusting contrast filter". This filter is
  3613. useful only for correcting degraded or poorly captured source
  3614. video.
  3615. The filter accepts the following options:
  3616. @table @option
  3617. @item strength
  3618. Determine the amount of equalization to be applied. As the strength
  3619. is reduced, the distribution of pixel intensities more-and-more
  3620. approaches that of the input frame. The value must be a float number
  3621. in the range [0,1] and defaults to 0.200.
  3622. @item intensity
  3623. Set the maximum intensity that can generated and scale the output
  3624. values appropriately. The strength should be set as desired and then
  3625. the intensity can be limited if needed to avoid washing-out. The value
  3626. must be a float number in the range [0,1] and defaults to 0.210.
  3627. @item antibanding
  3628. Set the antibanding level. If enabled the filter will randomly vary
  3629. the luminance of output pixels by a small amount to avoid banding of
  3630. the histogram. Possible values are @code{none}, @code{weak} or
  3631. @code{strong}. It defaults to @code{none}.
  3632. @end table
  3633. @section histogram
  3634. Compute and draw a color distribution histogram for the input video.
  3635. The computed histogram is a representation of distribution of color components
  3636. in an image.
  3637. The filter accepts the following options:
  3638. @table @option
  3639. @item mode
  3640. Set histogram mode.
  3641. It accepts the following values:
  3642. @table @samp
  3643. @item levels
  3644. standard histogram that display color components distribution in an image.
  3645. Displays color graph for each color component. Shows distribution
  3646. of the Y, U, V, A or R, G, B components, depending on input format,
  3647. in current frame. Bellow each graph is color component scale meter.
  3648. @item color
  3649. chroma values in vectorscope, if brighter more such chroma values are
  3650. distributed in an image.
  3651. Displays chroma values (U/V color placement) in two dimensional graph
  3652. (which is called a vectorscope). It can be used to read of the hue and
  3653. saturation of the current frame. At a same time it is a histogram.
  3654. The whiter a pixel in the vectorscope, the more pixels of the input frame
  3655. correspond to that pixel (that is the more pixels have this chroma value).
  3656. The V component is displayed on the horizontal (X) axis, with the leftmost
  3657. side being V = 0 and the rightmost side being V = 255.
  3658. The U component is displayed on the vertical (Y) axis, with the top
  3659. representing U = 0 and the bottom representing U = 255.
  3660. The position of a white pixel in the graph corresponds to the chroma value
  3661. of a pixel of the input clip. So the graph can be used to read of the
  3662. hue (color flavor) and the saturation (the dominance of the hue in the color).
  3663. As the hue of a color changes, it moves around the square. At the center of
  3664. the square, the saturation is zero, which means that the corresponding pixel
  3665. has no color. If you increase the amount of a specific color, while leaving
  3666. the other colors unchanged, the saturation increases, and you move towards
  3667. the edge of the square.
  3668. @item color2
  3669. chroma values in vectorscope, similar as @code{color} but actual chroma values
  3670. are displayed.
  3671. @item waveform
  3672. per row/column color component graph. In row mode graph in the left side represents
  3673. color component value 0 and right side represents value = 255. In column mode top
  3674. side represents color component value = 0 and bottom side represents value = 255.
  3675. @end table
  3676. Default value is @code{levels}.
  3677. @item level_height
  3678. Set height of level in @code{levels}. Default value is @code{200}.
  3679. Allowed range is [50, 2048].
  3680. @item scale_height
  3681. Set height of color scale in @code{levels}. Default value is @code{12}.
  3682. Allowed range is [0, 40].
  3683. @item step
  3684. Set step for @code{waveform} mode. Smaller values are useful to find out how much
  3685. of same luminance values across input rows/columns are distributed.
  3686. Default value is @code{10}. Allowed range is [1, 255].
  3687. @item waveform_mode
  3688. Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
  3689. Default is @code{row}.
  3690. @item waveform_mirror
  3691. Set mirroring mode for @code{waveform}. @code{0} means unmirrored, @code{1}
  3692. means mirrored. In mirrored mode, higher values will be represented on the left
  3693. side for @code{row} mode and at the top for @code{column} mode. Default is
  3694. @code{0} (unmirrored).
  3695. @item display_mode
  3696. Set display mode for @code{waveform} and @code{levels}.
  3697. It accepts the following values:
  3698. @table @samp
  3699. @item parade
  3700. Display separate graph for the color components side by side in
  3701. @code{row} waveform mode or one below other in @code{column} waveform mode
  3702. for @code{waveform} histogram mode. For @code{levels} histogram mode
  3703. per color component graphs are placed one bellow other.
  3704. This display mode in @code{waveform} histogram mode makes it easy to spot
  3705. color casts in the highlights and shadows of an image, by comparing the
  3706. contours of the top and the bottom of each waveform.
  3707. Since whites, grays, and blacks are characterized by
  3708. exactly equal amounts of red, green, and blue, neutral areas of the
  3709. picture should display three waveforms of roughly equal width/height.
  3710. If not, the correction is easy to make by making adjustments to level the
  3711. three waveforms.
  3712. @item overlay
  3713. Presents information that's identical to that in the @code{parade}, except
  3714. that the graphs representing color components are superimposed directly
  3715. over one another.
  3716. This display mode in @code{waveform} histogram mode can make it easier to spot
  3717. the relative differences or similarities in overlapping areas of the color
  3718. components that are supposed to be identical, such as neutral whites, grays,
  3719. or blacks.
  3720. @end table
  3721. Default is @code{parade}.
  3722. @item levels_mode
  3723. Set mode for @code{levels}. Can be either @code{linear}, or @code{logarithmic}.
  3724. Default is @code{linear}.
  3725. @end table
  3726. @subsection Examples
  3727. @itemize
  3728. @item
  3729. Calculate and draw histogram:
  3730. @example
  3731. ffplay -i input -vf histogram
  3732. @end example
  3733. @end itemize
  3734. @anchor{hqdn3d}
  3735. @section hqdn3d
  3736. High precision/quality 3d denoise filter. This filter aims to reduce
  3737. image noise producing smooth images and making still images really
  3738. still. It should enhance compressibility.
  3739. It accepts the following optional parameters:
  3740. @table @option
  3741. @item luma_spatial
  3742. a non-negative float number which specifies spatial luma strength,
  3743. defaults to 4.0
  3744. @item chroma_spatial
  3745. a non-negative float number which specifies spatial chroma strength,
  3746. defaults to 3.0*@var{luma_spatial}/4.0
  3747. @item luma_tmp
  3748. a float number which specifies luma temporal strength, defaults to
  3749. 6.0*@var{luma_spatial}/4.0
  3750. @item chroma_tmp
  3751. a float number which specifies chroma temporal strength, defaults to
  3752. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}
  3753. @end table
  3754. @section hue
  3755. Modify the hue and/or the saturation of the input.
  3756. This filter accepts the following options:
  3757. @table @option
  3758. @item h
  3759. Specify the hue angle as a number of degrees. It accepts an expression,
  3760. and defaults to "0".
  3761. @item s
  3762. Specify the saturation in the [-10,10] range. It accepts an expression and
  3763. defaults to "1".
  3764. @item H
  3765. Specify the hue angle as a number of radians. It accepts an
  3766. expression, and defaults to "0".
  3767. @item b
  3768. Specify the brightness in the [-10,10] range. It accepts an expression and
  3769. defaults to "0".
  3770. @end table
  3771. @option{h} and @option{H} are mutually exclusive, and can't be
  3772. specified at the same time.
  3773. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  3774. expressions containing the following constants:
  3775. @table @option
  3776. @item n
  3777. frame count of the input frame starting from 0
  3778. @item pts
  3779. presentation timestamp of the input frame expressed in time base units
  3780. @item r
  3781. frame rate of the input video, NAN if the input frame rate is unknown
  3782. @item t
  3783. timestamp expressed in seconds, NAN if the input timestamp is unknown
  3784. @item tb
  3785. time base of the input video
  3786. @end table
  3787. @subsection Examples
  3788. @itemize
  3789. @item
  3790. Set the hue to 90 degrees and the saturation to 1.0:
  3791. @example
  3792. hue=h=90:s=1
  3793. @end example
  3794. @item
  3795. Same command but expressing the hue in radians:
  3796. @example
  3797. hue=H=PI/2:s=1
  3798. @end example
  3799. @item
  3800. Rotate hue and make the saturation swing between 0
  3801. and 2 over a period of 1 second:
  3802. @example
  3803. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  3804. @end example
  3805. @item
  3806. Apply a 3 seconds saturation fade-in effect starting at 0:
  3807. @example
  3808. hue="s=min(t/3\,1)"
  3809. @end example
  3810. The general fade-in expression can be written as:
  3811. @example
  3812. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  3813. @end example
  3814. @item
  3815. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  3816. @example
  3817. hue="s=max(0\, min(1\, (8-t)/3))"
  3818. @end example
  3819. The general fade-out expression can be written as:
  3820. @example
  3821. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  3822. @end example
  3823. @end itemize
  3824. @subsection Commands
  3825. This filter supports the following commands:
  3826. @table @option
  3827. @item b
  3828. @item s
  3829. @item h
  3830. @item H
  3831. Modify the hue and/or the saturation and/or brightness of the input video.
  3832. The command accepts the same syntax of the corresponding option.
  3833. If the specified expression is not valid, it is kept at its current
  3834. value.
  3835. @end table
  3836. @section idet
  3837. Detect video interlacing type.
  3838. This filter tries to detect if the input is interlaced or progressive,
  3839. top or bottom field first.
  3840. The filter accepts the following options:
  3841. @table @option
  3842. @item intl_thres
  3843. Set interlacing threshold.
  3844. @item prog_thres
  3845. Set progressive threshold.
  3846. @end table
  3847. @section il
  3848. Deinterleave or interleave fields.
  3849. This filter allows to process interlaced images fields without
  3850. deinterlacing them. Deinterleaving splits the input frame into 2
  3851. fields (so called half pictures). Odd lines are moved to the top
  3852. half of the output image, even lines to the bottom half.
  3853. You can process (filter) them independently and then re-interleave them.
  3854. The filter accepts the following options:
  3855. @table @option
  3856. @item luma_mode, l
  3857. @item chroma_mode, c
  3858. @item alpha_mode, a
  3859. Available values for @var{luma_mode}, @var{chroma_mode} and
  3860. @var{alpha_mode} are:
  3861. @table @samp
  3862. @item none
  3863. Do nothing.
  3864. @item deinterleave, d
  3865. Deinterleave fields, placing one above the other.
  3866. @item interleave, i
  3867. Interleave fields. Reverse the effect of deinterleaving.
  3868. @end table
  3869. Default value is @code{none}.
  3870. @item luma_swap, ls
  3871. @item chroma_swap, cs
  3872. @item alpha_swap, as
  3873. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  3874. @end table
  3875. @section interlace
  3876. Simple interlacing filter from progressive contents. This interleaves upper (or
  3877. lower) lines from odd frames with lower (or upper) lines from even frames,
  3878. halving the frame rate and preserving image height.
  3879. @example
  3880. Original Original New Frame
  3881. Frame 'j' Frame 'j+1' (tff)
  3882. ========== =========== ==================
  3883. Line 0 --------------------> Frame 'j' Line 0
  3884. Line 1 Line 1 ----> Frame 'j+1' Line 1
  3885. Line 2 ---------------------> Frame 'j' Line 2
  3886. Line 3 Line 3 ----> Frame 'j+1' Line 3
  3887. ... ... ...
  3888. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  3889. @end example
  3890. It accepts the following optional parameters:
  3891. @table @option
  3892. @item scan
  3893. determines whether the interlaced frame is taken from the even (tff - default)
  3894. or odd (bff) lines of the progressive frame.
  3895. @item lowpass
  3896. Enable (default) or disable the vertical lowpass filter to avoid twitter
  3897. interlacing and reduce moire patterns.
  3898. @end table
  3899. @section kerndeint
  3900. Deinterlace input video by applying Donald Graft's adaptive kernel
  3901. deinterling. Work on interlaced parts of a video to produce
  3902. progressive frames.
  3903. The description of the accepted parameters follows.
  3904. @table @option
  3905. @item thresh
  3906. Set the threshold which affects the filter's tolerance when
  3907. determining if a pixel line must be processed. It must be an integer
  3908. in the range [0,255] and defaults to 10. A value of 0 will result in
  3909. applying the process on every pixels.
  3910. @item map
  3911. Paint pixels exceeding the threshold value to white if set to 1.
  3912. Default is 0.
  3913. @item order
  3914. Set the fields order. Swap fields if set to 1, leave fields alone if
  3915. 0. Default is 0.
  3916. @item sharp
  3917. Enable additional sharpening if set to 1. Default is 0.
  3918. @item twoway
  3919. Enable twoway sharpening if set to 1. Default is 0.
  3920. @end table
  3921. @subsection Examples
  3922. @itemize
  3923. @item
  3924. Apply default values:
  3925. @example
  3926. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  3927. @end example
  3928. @item
  3929. Enable additional sharpening:
  3930. @example
  3931. kerndeint=sharp=1
  3932. @end example
  3933. @item
  3934. Paint processed pixels in white:
  3935. @example
  3936. kerndeint=map=1
  3937. @end example
  3938. @end itemize
  3939. @anchor{lut3d}
  3940. @section lut3d
  3941. Apply a 3D LUT to an input video.
  3942. The filter accepts the following options:
  3943. @table @option
  3944. @item file
  3945. Set the 3D LUT file name.
  3946. Currently supported formats:
  3947. @table @samp
  3948. @item 3dl
  3949. AfterEffects
  3950. @item cube
  3951. Iridas
  3952. @item dat
  3953. DaVinci
  3954. @item m3d
  3955. Pandora
  3956. @end table
  3957. @item interp
  3958. Select interpolation mode.
  3959. Available values are:
  3960. @table @samp
  3961. @item nearest
  3962. Use values from the nearest defined point.
  3963. @item trilinear
  3964. Interpolate values using the 8 points defining a cube.
  3965. @item tetrahedral
  3966. Interpolate values using a tetrahedron.
  3967. @end table
  3968. @end table
  3969. @section lut, lutrgb, lutyuv
  3970. Compute a look-up table for binding each pixel component input value
  3971. to an output value, and apply it to input video.
  3972. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  3973. to an RGB input video.
  3974. These filters accept the following options:
  3975. @table @option
  3976. @item c0
  3977. set first pixel component expression
  3978. @item c1
  3979. set second pixel component expression
  3980. @item c2
  3981. set third pixel component expression
  3982. @item c3
  3983. set fourth pixel component expression, corresponds to the alpha component
  3984. @item r
  3985. set red component expression
  3986. @item g
  3987. set green component expression
  3988. @item b
  3989. set blue component expression
  3990. @item a
  3991. alpha component expression
  3992. @item y
  3993. set Y/luminance component expression
  3994. @item u
  3995. set U/Cb component expression
  3996. @item v
  3997. set V/Cr component expression
  3998. @end table
  3999. Each of them specifies the expression to use for computing the lookup table for
  4000. the corresponding pixel component values.
  4001. The exact component associated to each of the @var{c*} options depends on the
  4002. format in input.
  4003. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  4004. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  4005. The expressions can contain the following constants and functions:
  4006. @table @option
  4007. @item w
  4008. @item h
  4009. the input width and height
  4010. @item val
  4011. input value for the pixel component
  4012. @item clipval
  4013. the input value clipped in the @var{minval}-@var{maxval} range
  4014. @item maxval
  4015. maximum value for the pixel component
  4016. @item minval
  4017. minimum value for the pixel component
  4018. @item negval
  4019. the negated value for the pixel component value clipped in the
  4020. @var{minval}-@var{maxval} range , it corresponds to the expression
  4021. "maxval-clipval+minval"
  4022. @item clip(val)
  4023. the computed value in @var{val} clipped in the
  4024. @var{minval}-@var{maxval} range
  4025. @item gammaval(gamma)
  4026. the computed gamma correction value of the pixel component value
  4027. clipped in the @var{minval}-@var{maxval} range, corresponds to the
  4028. expression
  4029. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  4030. @end table
  4031. All expressions default to "val".
  4032. @subsection Examples
  4033. @itemize
  4034. @item
  4035. Negate input video:
  4036. @example
  4037. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  4038. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  4039. @end example
  4040. The above is the same as:
  4041. @example
  4042. lutrgb="r=negval:g=negval:b=negval"
  4043. lutyuv="y=negval:u=negval:v=negval"
  4044. @end example
  4045. @item
  4046. Negate luminance:
  4047. @example
  4048. lutyuv=y=negval
  4049. @end example
  4050. @item
  4051. Remove chroma components, turns the video into a graytone image:
  4052. @example
  4053. lutyuv="u=128:v=128"
  4054. @end example
  4055. @item
  4056. Apply a luma burning effect:
  4057. @example
  4058. lutyuv="y=2*val"
  4059. @end example
  4060. @item
  4061. Remove green and blue components:
  4062. @example
  4063. lutrgb="g=0:b=0"
  4064. @end example
  4065. @item
  4066. Set a constant alpha channel value on input:
  4067. @example
  4068. format=rgba,lutrgb=a="maxval-minval/2"
  4069. @end example
  4070. @item
  4071. Correct luminance gamma by a 0.5 factor:
  4072. @example
  4073. lutyuv=y=gammaval(0.5)
  4074. @end example
  4075. @item
  4076. Discard least significant bits of luma:
  4077. @example
  4078. lutyuv=y='bitand(val, 128+64+32)'
  4079. @end example
  4080. @end itemize
  4081. @section mergeplanes
  4082. Merge color channel components from several video streams.
  4083. The filter accepts up to 4 input streams, and merge selected input
  4084. planes to the output video.
  4085. This filter accepts the following options:
  4086. @table @option
  4087. @item mapping
  4088. Set input to output plane mapping. Default is @code{0}.
  4089. The mappings is specified as a bitmap. It should be specified as a
  4090. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  4091. mapping for the first plane of the output stream. 'A' sets the number of
  4092. the input stream to use (from 0 to 3), and 'a' the plane number of the
  4093. corresponding input to use (from 0 to 3). The rest of the mappings is
  4094. similar, 'Bb' describes the mapping for the output stream second
  4095. plane, 'Cc' describes the mapping for the output stream third plane and
  4096. 'Dd' describes the mapping for the output stream fourth plane.
  4097. @item format
  4098. Set output pixel format. Default is @code{yuva444p}.
  4099. @end table
  4100. @subsection Examples
  4101. @itemize
  4102. @item
  4103. Merge three gray video streams of same width and height into single video stream:
  4104. @example
  4105. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  4106. @end example
  4107. @item
  4108. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  4109. @example
  4110. [a0][a1]mergeplanes=0x00010210:yuva444p
  4111. @end example
  4112. @item
  4113. Swap Y and A plane in yuva444p stream:
  4114. @example
  4115. format=yuva444p,mergeplanes=0x03010200:yuva444p
  4116. @end example
  4117. @item
  4118. Swap U and V plane in yuv420p stream:
  4119. @example
  4120. format=yuv420p,mergeplanes=0x000201:yuv420p
  4121. @end example
  4122. @item
  4123. Cast a rgb24 clip to yuv444p:
  4124. @example
  4125. format=rgb24,mergeplanes=0x000102:yuv444p
  4126. @end example
  4127. @end itemize
  4128. @section mcdeint
  4129. Apply motion-compensation deinterlacing.
  4130. It needs one field per frame as input and must thus be used together
  4131. with yadif=1/3 or equivalent.
  4132. This filter accepts the following options:
  4133. @table @option
  4134. @item mode
  4135. Set the deinterlacing mode.
  4136. It accepts one of the following values:
  4137. @table @samp
  4138. @item fast
  4139. @item medium
  4140. @item slow
  4141. use iterative motion estimation
  4142. @item extra_slow
  4143. like @samp{slow}, but use multiple reference frames.
  4144. @end table
  4145. Default value is @samp{fast}.
  4146. @item parity
  4147. Set the picture field parity assumed for the input video. It must be
  4148. one of the following values:
  4149. @table @samp
  4150. @item 0, tff
  4151. assume top field first
  4152. @item 1, bff
  4153. assume bottom field first
  4154. @end table
  4155. Default value is @samp{bff}.
  4156. @item qp
  4157. Set per-block quantization parameter (QP) used by the internal
  4158. encoder.
  4159. Higher values should result in a smoother motion vector field but less
  4160. optimal individual vectors. Default value is 1.
  4161. @end table
  4162. @section mp
  4163. Apply an MPlayer filter to the input video.
  4164. This filter provides a wrapper around some of the filters of
  4165. MPlayer/MEncoder.
  4166. This wrapper is considered experimental. Some of the wrapped filters
  4167. may not work properly and we may drop support for them, as they will
  4168. be implemented natively into FFmpeg. Thus you should avoid
  4169. depending on them when writing portable scripts.
  4170. The filter accepts the parameters:
  4171. @var{filter_name}[:=]@var{filter_params}
  4172. @var{filter_name} is the name of a supported MPlayer filter,
  4173. @var{filter_params} is a string containing the parameters accepted by
  4174. the named filter.
  4175. The list of the currently supported filters follows:
  4176. @table @var
  4177. @item eq2
  4178. @item eq
  4179. @item fspp
  4180. @item ilpack
  4181. @item pp7
  4182. @item softpulldown
  4183. @item uspp
  4184. @end table
  4185. The parameter syntax and behavior for the listed filters are the same
  4186. of the corresponding MPlayer filters. For detailed instructions check
  4187. the "VIDEO FILTERS" section in the MPlayer manual.
  4188. @subsection Examples
  4189. @itemize
  4190. @item
  4191. Adjust gamma, brightness, contrast:
  4192. @example
  4193. mp=eq2=1.0:2:0.5
  4194. @end example
  4195. @end itemize
  4196. See also mplayer(1), @url{http://www.mplayerhq.hu/}.
  4197. @section mpdecimate
  4198. Drop frames that do not differ greatly from the previous frame in
  4199. order to reduce frame rate.
  4200. The main use of this filter is for very-low-bitrate encoding
  4201. (e.g. streaming over dialup modem), but it could in theory be used for
  4202. fixing movies that were inverse-telecined incorrectly.
  4203. A description of the accepted options follows.
  4204. @table @option
  4205. @item max
  4206. Set the maximum number of consecutive frames which can be dropped (if
  4207. positive), or the minimum interval between dropped frames (if
  4208. negative). If the value is 0, the frame is dropped unregarding the
  4209. number of previous sequentially dropped frames.
  4210. Default value is 0.
  4211. @item hi
  4212. @item lo
  4213. @item frac
  4214. Set the dropping threshold values.
  4215. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  4216. represent actual pixel value differences, so a threshold of 64
  4217. corresponds to 1 unit of difference for each pixel, or the same spread
  4218. out differently over the block.
  4219. A frame is a candidate for dropping if no 8x8 blocks differ by more
  4220. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  4221. meaning the whole image) differ by more than a threshold of @option{lo}.
  4222. Default value for @option{hi} is 64*12, default value for @option{lo} is
  4223. 64*5, and default value for @option{frac} is 0.33.
  4224. @end table
  4225. @section negate
  4226. Negate input video.
  4227. This filter accepts an integer in input, if non-zero it negates the
  4228. alpha component (if available). The default value in input is 0.
  4229. @section noformat
  4230. Force libavfilter not to use any of the specified pixel formats for the
  4231. input to the next filter.
  4232. This filter accepts the following parameters:
  4233. @table @option
  4234. @item pix_fmts
  4235. A '|'-separated list of pixel format names, for example
  4236. "pix_fmts=yuv420p|monow|rgb24".
  4237. @end table
  4238. @subsection Examples
  4239. @itemize
  4240. @item
  4241. Force libavfilter to use a format different from @var{yuv420p} for the
  4242. input to the vflip filter:
  4243. @example
  4244. noformat=pix_fmts=yuv420p,vflip
  4245. @end example
  4246. @item
  4247. Convert the input video to any of the formats not contained in the list:
  4248. @example
  4249. noformat=yuv420p|yuv444p|yuv410p
  4250. @end example
  4251. @end itemize
  4252. @section noise
  4253. Add noise on video input frame.
  4254. The filter accepts the following options:
  4255. @table @option
  4256. @item all_seed
  4257. @item c0_seed
  4258. @item c1_seed
  4259. @item c2_seed
  4260. @item c3_seed
  4261. Set noise seed for specific pixel component or all pixel components in case
  4262. of @var{all_seed}. Default value is @code{123457}.
  4263. @item all_strength, alls
  4264. @item c0_strength, c0s
  4265. @item c1_strength, c1s
  4266. @item c2_strength, c2s
  4267. @item c3_strength, c3s
  4268. Set noise strength for specific pixel component or all pixel components in case
  4269. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  4270. @item all_flags, allf
  4271. @item c0_flags, c0f
  4272. @item c1_flags, c1f
  4273. @item c2_flags, c2f
  4274. @item c3_flags, c3f
  4275. Set pixel component flags or set flags for all components if @var{all_flags}.
  4276. Available values for component flags are:
  4277. @table @samp
  4278. @item a
  4279. averaged temporal noise (smoother)
  4280. @item p
  4281. mix random noise with a (semi)regular pattern
  4282. @item t
  4283. temporal noise (noise pattern changes between frames)
  4284. @item u
  4285. uniform noise (gaussian otherwise)
  4286. @end table
  4287. @end table
  4288. @subsection Examples
  4289. Add temporal and uniform noise to input video:
  4290. @example
  4291. noise=alls=20:allf=t+u
  4292. @end example
  4293. @section null
  4294. Pass the video source unchanged to the output.
  4295. @section ocv
  4296. Apply video transform using libopencv.
  4297. To enable this filter install libopencv library and headers and
  4298. configure FFmpeg with @code{--enable-libopencv}.
  4299. This filter accepts the following parameters:
  4300. @table @option
  4301. @item filter_name
  4302. The name of the libopencv filter to apply.
  4303. @item filter_params
  4304. The parameters to pass to the libopencv filter. If not specified the default
  4305. values are assumed.
  4306. @end table
  4307. Refer to the official libopencv documentation for more precise
  4308. information:
  4309. @url{http://opencv.willowgarage.com/documentation/c/image_filtering.html}
  4310. Follows the list of supported libopencv filters.
  4311. @anchor{dilate}
  4312. @subsection dilate
  4313. Dilate an image by using a specific structuring element.
  4314. This filter corresponds to the libopencv function @code{cvDilate}.
  4315. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  4316. @var{struct_el} represents a structuring element, and has the syntax:
  4317. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  4318. @var{cols} and @var{rows} represent the number of columns and rows of
  4319. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  4320. point, and @var{shape} the shape for the structuring element, and
  4321. can be one of the values "rect", "cross", "ellipse", "custom".
  4322. If the value for @var{shape} is "custom", it must be followed by a
  4323. string of the form "=@var{filename}". The file with name
  4324. @var{filename} is assumed to represent a binary image, with each
  4325. printable character corresponding to a bright pixel. When a custom
  4326. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  4327. or columns and rows of the read file are assumed instead.
  4328. The default value for @var{struct_el} is "3x3+0x0/rect".
  4329. @var{nb_iterations} specifies the number of times the transform is
  4330. applied to the image, and defaults to 1.
  4331. Follow some example:
  4332. @example
  4333. # use the default values
  4334. ocv=dilate
  4335. # dilate using a structuring element with a 5x5 cross, iterate two times
  4336. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  4337. # read the shape from the file diamond.shape, iterate two times
  4338. # the file diamond.shape may contain a pattern of characters like this:
  4339. # *
  4340. # ***
  4341. # *****
  4342. # ***
  4343. # *
  4344. # the specified cols and rows are ignored (but not the anchor point coordinates)
  4345. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  4346. @end example
  4347. @subsection erode
  4348. Erode an image by using a specific structuring element.
  4349. This filter corresponds to the libopencv function @code{cvErode}.
  4350. The filter accepts the parameters: @var{struct_el}:@var{nb_iterations},
  4351. with the same syntax and semantics as the @ref{dilate} filter.
  4352. @subsection smooth
  4353. Smooth the input video.
  4354. The filter takes the following parameters:
  4355. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  4356. @var{type} is the type of smooth filter to apply, and can be one of
  4357. the following values: "blur", "blur_no_scale", "median", "gaussian",
  4358. "bilateral". The default value is "gaussian".
  4359. @var{param1}, @var{param2}, @var{param3}, and @var{param4} are
  4360. parameters whose meanings depend on smooth type. @var{param1} and
  4361. @var{param2} accept integer positive values or 0, @var{param3} and
  4362. @var{param4} accept float values.
  4363. The default value for @var{param1} is 3, the default value for the
  4364. other parameters is 0.
  4365. These parameters correspond to the parameters assigned to the
  4366. libopencv function @code{cvSmooth}.
  4367. @anchor{overlay}
  4368. @section overlay
  4369. Overlay one video on top of another.
  4370. It takes two inputs and one output, the first input is the "main"
  4371. video on which the second input is overlayed.
  4372. This filter accepts the following parameters:
  4373. A description of the accepted options follows.
  4374. @table @option
  4375. @item x
  4376. @item y
  4377. Set the expression for the x and y coordinates of the overlayed video
  4378. on the main video. Default value is "0" for both expressions. In case
  4379. the expression is invalid, it is set to a huge value (meaning that the
  4380. overlay will not be displayed within the output visible area).
  4381. @item eval
  4382. Set when the expressions for @option{x}, and @option{y} are evaluated.
  4383. It accepts the following values:
  4384. @table @samp
  4385. @item init
  4386. only evaluate expressions once during the filter initialization or
  4387. when a command is processed
  4388. @item frame
  4389. evaluate expressions for each incoming frame
  4390. @end table
  4391. Default value is @samp{frame}.
  4392. @item shortest
  4393. If set to 1, force the output to terminate when the shortest input
  4394. terminates. Default value is 0.
  4395. @item format
  4396. Set the format for the output video.
  4397. It accepts the following values:
  4398. @table @samp
  4399. @item yuv420
  4400. force YUV420 output
  4401. @item yuv444
  4402. force YUV444 output
  4403. @item rgb
  4404. force RGB output
  4405. @end table
  4406. Default value is @samp{yuv420}.
  4407. @item rgb @emph{(deprecated)}
  4408. If set to 1, force the filter to accept inputs in the RGB
  4409. color space. Default value is 0. This option is deprecated, use
  4410. @option{format} instead.
  4411. @item repeatlast
  4412. If set to 1, force the filter to draw the last overlay frame over the
  4413. main input until the end of the stream. A value of 0 disables this
  4414. behavior. Default value is 1.
  4415. @end table
  4416. The @option{x}, and @option{y} expressions can contain the following
  4417. parameters.
  4418. @table @option
  4419. @item main_w, W
  4420. @item main_h, H
  4421. main input width and height
  4422. @item overlay_w, w
  4423. @item overlay_h, h
  4424. overlay input width and height
  4425. @item x
  4426. @item y
  4427. the computed values for @var{x} and @var{y}. They are evaluated for
  4428. each new frame.
  4429. @item hsub
  4430. @item vsub
  4431. horizontal and vertical chroma subsample values of the output
  4432. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  4433. @var{vsub} is 1.
  4434. @item n
  4435. the number of input frame, starting from 0
  4436. @item pos
  4437. the position in the file of the input frame, NAN if unknown
  4438. @item t
  4439. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4440. @end table
  4441. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  4442. when evaluation is done @emph{per frame}, and will evaluate to NAN
  4443. when @option{eval} is set to @samp{init}.
  4444. Be aware that frames are taken from each input video in timestamp
  4445. order, hence, if their initial timestamps differ, it is a good idea
  4446. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  4447. have them begin in the same zero timestamp, as it does the example for
  4448. the @var{movie} filter.
  4449. You can chain together more overlays but you should test the
  4450. efficiency of such approach.
  4451. @subsection Commands
  4452. This filter supports the following commands:
  4453. @table @option
  4454. @item x
  4455. @item y
  4456. Modify the x and y of the overlay input.
  4457. The command accepts the same syntax of the corresponding option.
  4458. If the specified expression is not valid, it is kept at its current
  4459. value.
  4460. @end table
  4461. @subsection Examples
  4462. @itemize
  4463. @item
  4464. Draw the overlay at 10 pixels from the bottom right corner of the main
  4465. video:
  4466. @example
  4467. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  4468. @end example
  4469. Using named options the example above becomes:
  4470. @example
  4471. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  4472. @end example
  4473. @item
  4474. Insert a transparent PNG logo in the bottom left corner of the input,
  4475. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  4476. @example
  4477. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  4478. @end example
  4479. @item
  4480. Insert 2 different transparent PNG logos (second logo on bottom
  4481. right corner) using the @command{ffmpeg} tool:
  4482. @example
  4483. 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
  4484. @end example
  4485. @item
  4486. Add a transparent color layer on top of the main video, @code{WxH}
  4487. must specify the size of the main input to the overlay filter:
  4488. @example
  4489. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  4490. @end example
  4491. @item
  4492. Play an original video and a filtered version (here with the deshake
  4493. filter) side by side using the @command{ffplay} tool:
  4494. @example
  4495. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  4496. @end example
  4497. The above command is the same as:
  4498. @example
  4499. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  4500. @end example
  4501. @item
  4502. Make a sliding overlay appearing from the left to the right top part of the
  4503. screen starting since time 2:
  4504. @example
  4505. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  4506. @end example
  4507. @item
  4508. Compose output by putting two input videos side to side:
  4509. @example
  4510. ffmpeg -i left.avi -i right.avi -filter_complex "
  4511. nullsrc=size=200x100 [background];
  4512. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  4513. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  4514. [background][left] overlay=shortest=1 [background+left];
  4515. [background+left][right] overlay=shortest=1:x=100 [left+right]
  4516. "
  4517. @end example
  4518. @item
  4519. Chain several overlays in cascade:
  4520. @example
  4521. nullsrc=s=200x200 [bg];
  4522. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  4523. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  4524. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  4525. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  4526. [in3] null, [mid2] overlay=100:100 [out0]
  4527. @end example
  4528. @end itemize
  4529. @section owdenoise
  4530. Apply Overcomplete Wavelet denoiser.
  4531. The filter accepts the following options:
  4532. @table @option
  4533. @item depth
  4534. Set depth.
  4535. Larger depth values will denoise lower frequency components more, but
  4536. slow down filtering.
  4537. Must be an int in the range 8-16, default is @code{8}.
  4538. @item luma_strength, ls
  4539. Set luma strength.
  4540. Must be a double value in the range 0-1000, default is @code{1.0}.
  4541. @item chroma_strength, cs
  4542. Set chroma strength.
  4543. Must be a double value in the range 0-1000, default is @code{1.0}.
  4544. @end table
  4545. @section pad
  4546. Add paddings to the input image, and place the original input at the
  4547. given coordinates @var{x}, @var{y}.
  4548. This filter accepts the following parameters:
  4549. @table @option
  4550. @item width, w
  4551. @item height, h
  4552. Specify an expression for the size of the output image with the
  4553. paddings added. If the value for @var{width} or @var{height} is 0, the
  4554. corresponding input size is used for the output.
  4555. The @var{width} expression can reference the value set by the
  4556. @var{height} expression, and vice versa.
  4557. The default value of @var{width} and @var{height} is 0.
  4558. @item x
  4559. @item y
  4560. Specify an expression for the offsets where to place the input image
  4561. in the padded area with respect to the top/left border of the output
  4562. image.
  4563. The @var{x} expression can reference the value set by the @var{y}
  4564. expression, and vice versa.
  4565. The default value of @var{x} and @var{y} is 0.
  4566. @item color
  4567. Specify the color of the padded area. For the syntax of this option,
  4568. check the "Color" section in the ffmpeg-utils manual.
  4569. The default value of @var{color} is "black".
  4570. @end table
  4571. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  4572. options are expressions containing the following constants:
  4573. @table @option
  4574. @item in_w
  4575. @item in_h
  4576. the input video width and height
  4577. @item iw
  4578. @item ih
  4579. same as @var{in_w} and @var{in_h}
  4580. @item out_w
  4581. @item out_h
  4582. the output width and height, that is the size of the padded area as
  4583. specified by the @var{width} and @var{height} expressions
  4584. @item ow
  4585. @item oh
  4586. same as @var{out_w} and @var{out_h}
  4587. @item x
  4588. @item y
  4589. x and y offsets as specified by the @var{x} and @var{y}
  4590. expressions, or NAN if not yet specified
  4591. @item a
  4592. same as @var{iw} / @var{ih}
  4593. @item sar
  4594. input sample aspect ratio
  4595. @item dar
  4596. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  4597. @item hsub
  4598. @item vsub
  4599. horizontal and vertical chroma subsample values. For example for the
  4600. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4601. @end table
  4602. @subsection Examples
  4603. @itemize
  4604. @item
  4605. Add paddings with color "violet" to the input video. Output video
  4606. size is 640x480, the top-left corner of the input video is placed at
  4607. column 0, row 40:
  4608. @example
  4609. pad=640:480:0:40:violet
  4610. @end example
  4611. The example above is equivalent to the following command:
  4612. @example
  4613. pad=width=640:height=480:x=0:y=40:color=violet
  4614. @end example
  4615. @item
  4616. Pad the input to get an output with dimensions increased by 3/2,
  4617. and put the input video at the center of the padded area:
  4618. @example
  4619. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  4620. @end example
  4621. @item
  4622. Pad the input to get a squared output with size equal to the maximum
  4623. value between the input width and height, and put the input video at
  4624. the center of the padded area:
  4625. @example
  4626. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  4627. @end example
  4628. @item
  4629. Pad the input to get a final w/h ratio of 16:9:
  4630. @example
  4631. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  4632. @end example
  4633. @item
  4634. In case of anamorphic video, in order to set the output display aspect
  4635. correctly, it is necessary to use @var{sar} in the expression,
  4636. according to the relation:
  4637. @example
  4638. (ih * X / ih) * sar = output_dar
  4639. X = output_dar / sar
  4640. @end example
  4641. Thus the previous example needs to be modified to:
  4642. @example
  4643. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  4644. @end example
  4645. @item
  4646. Double output size and put the input video in the bottom-right
  4647. corner of the output padded area:
  4648. @example
  4649. pad="2*iw:2*ih:ow-iw:oh-ih"
  4650. @end example
  4651. @end itemize
  4652. @section perspective
  4653. Correct perspective of video not recorded perpendicular to the screen.
  4654. A description of the accepted parameters follows.
  4655. @table @option
  4656. @item x0
  4657. @item y0
  4658. @item x1
  4659. @item y1
  4660. @item x2
  4661. @item y2
  4662. @item x3
  4663. @item y3
  4664. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  4665. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  4666. The expressions can use the following variables:
  4667. @table @option
  4668. @item W
  4669. @item H
  4670. the width and height of video frame.
  4671. @end table
  4672. @item interpolation
  4673. Set interpolation for perspective correction.
  4674. It accepts the following values:
  4675. @table @samp
  4676. @item linear
  4677. @item cubic
  4678. @end table
  4679. Default value is @samp{linear}.
  4680. @end table
  4681. @section phase
  4682. Delay interlaced video by one field time so that the field order changes.
  4683. The intended use is to fix PAL movies that have been captured with the
  4684. opposite field order to the film-to-video transfer.
  4685. A description of the accepted parameters follows.
  4686. @table @option
  4687. @item mode
  4688. Set phase mode.
  4689. It accepts the following values:
  4690. @table @samp
  4691. @item t
  4692. Capture field order top-first, transfer bottom-first.
  4693. Filter will delay the bottom field.
  4694. @item b
  4695. Capture field order bottom-first, transfer top-first.
  4696. Filter will delay the top field.
  4697. @item p
  4698. Capture and transfer with the same field order. This mode only exists
  4699. for the documentation of the other options to refer to, but if you
  4700. actually select it, the filter will faithfully do nothing.
  4701. @item a
  4702. Capture field order determined automatically by field flags, transfer
  4703. opposite.
  4704. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  4705. basis using field flags. If no field information is available,
  4706. then this works just like @samp{u}.
  4707. @item u
  4708. Capture unknown or varying, transfer opposite.
  4709. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  4710. analyzing the images and selecting the alternative that produces best
  4711. match between the fields.
  4712. @item T
  4713. Capture top-first, transfer unknown or varying.
  4714. Filter selects among @samp{t} and @samp{p} using image analysis.
  4715. @item B
  4716. Capture bottom-first, transfer unknown or varying.
  4717. Filter selects among @samp{b} and @samp{p} using image analysis.
  4718. @item A
  4719. Capture determined by field flags, transfer unknown or varying.
  4720. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  4721. image analysis. If no field information is available, then this works just
  4722. like @samp{U}. This is the default mode.
  4723. @item U
  4724. Both capture and transfer unknown or varying.
  4725. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  4726. @end table
  4727. @end table
  4728. @section pixdesctest
  4729. Pixel format descriptor test filter, mainly useful for internal
  4730. testing. The output video should be equal to the input video.
  4731. For example:
  4732. @example
  4733. format=monow, pixdesctest
  4734. @end example
  4735. can be used to test the monowhite pixel format descriptor definition.
  4736. @section pp
  4737. Enable the specified chain of postprocessing subfilters using libpostproc. This
  4738. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  4739. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  4740. Each subfilter and some options have a short and a long name that can be used
  4741. interchangeably, i.e. dr/dering are the same.
  4742. The filters accept the following options:
  4743. @table @option
  4744. @item subfilters
  4745. Set postprocessing subfilters string.
  4746. @end table
  4747. All subfilters share common options to determine their scope:
  4748. @table @option
  4749. @item a/autoq
  4750. Honor the quality commands for this subfilter.
  4751. @item c/chrom
  4752. Do chrominance filtering, too (default).
  4753. @item y/nochrom
  4754. Do luminance filtering only (no chrominance).
  4755. @item n/noluma
  4756. Do chrominance filtering only (no luminance).
  4757. @end table
  4758. These options can be appended after the subfilter name, separated by a '|'.
  4759. Available subfilters are:
  4760. @table @option
  4761. @item hb/hdeblock[|difference[|flatness]]
  4762. Horizontal deblocking filter
  4763. @table @option
  4764. @item difference
  4765. Difference factor where higher values mean more deblocking (default: @code{32}).
  4766. @item flatness
  4767. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  4768. @end table
  4769. @item vb/vdeblock[|difference[|flatness]]
  4770. Vertical deblocking filter
  4771. @table @option
  4772. @item difference
  4773. Difference factor where higher values mean more deblocking (default: @code{32}).
  4774. @item flatness
  4775. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  4776. @end table
  4777. @item ha/hadeblock[|difference[|flatness]]
  4778. Accurate horizontal deblocking filter
  4779. @table @option
  4780. @item difference
  4781. Difference factor where higher values mean more deblocking (default: @code{32}).
  4782. @item flatness
  4783. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  4784. @end table
  4785. @item va/vadeblock[|difference[|flatness]]
  4786. Accurate vertical deblocking filter
  4787. @table @option
  4788. @item difference
  4789. Difference factor where higher values mean more deblocking (default: @code{32}).
  4790. @item flatness
  4791. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  4792. @end table
  4793. @end table
  4794. The horizontal and vertical deblocking filters share the difference and
  4795. flatness values so you cannot set different horizontal and vertical
  4796. thresholds.
  4797. @table @option
  4798. @item h1/x1hdeblock
  4799. Experimental horizontal deblocking filter
  4800. @item v1/x1vdeblock
  4801. Experimental vertical deblocking filter
  4802. @item dr/dering
  4803. Deringing filter
  4804. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  4805. @table @option
  4806. @item threshold1
  4807. larger -> stronger filtering
  4808. @item threshold2
  4809. larger -> stronger filtering
  4810. @item threshold3
  4811. larger -> stronger filtering
  4812. @end table
  4813. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  4814. @table @option
  4815. @item f/fullyrange
  4816. Stretch luminance to @code{0-255}.
  4817. @end table
  4818. @item lb/linblenddeint
  4819. Linear blend deinterlacing filter that deinterlaces the given block by
  4820. filtering all lines with a @code{(1 2 1)} filter.
  4821. @item li/linipoldeint
  4822. Linear interpolating deinterlacing filter that deinterlaces the given block by
  4823. linearly interpolating every second line.
  4824. @item ci/cubicipoldeint
  4825. Cubic interpolating deinterlacing filter deinterlaces the given block by
  4826. cubically interpolating every second line.
  4827. @item md/mediandeint
  4828. Median deinterlacing filter that deinterlaces the given block by applying a
  4829. median filter to every second line.
  4830. @item fd/ffmpegdeint
  4831. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  4832. second line with a @code{(-1 4 2 4 -1)} filter.
  4833. @item l5/lowpass5
  4834. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  4835. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  4836. @item fq/forceQuant[|quantizer]
  4837. Overrides the quantizer table from the input with the constant quantizer you
  4838. specify.
  4839. @table @option
  4840. @item quantizer
  4841. Quantizer to use
  4842. @end table
  4843. @item de/default
  4844. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  4845. @item fa/fast
  4846. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  4847. @item ac
  4848. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  4849. @end table
  4850. @subsection Examples
  4851. @itemize
  4852. @item
  4853. Apply horizontal and vertical deblocking, deringing and automatic
  4854. brightness/contrast:
  4855. @example
  4856. pp=hb/vb/dr/al
  4857. @end example
  4858. @item
  4859. Apply default filters without brightness/contrast correction:
  4860. @example
  4861. pp=de/-al
  4862. @end example
  4863. @item
  4864. Apply default filters and temporal denoiser:
  4865. @example
  4866. pp=default/tmpnoise|1|2|3
  4867. @end example
  4868. @item
  4869. Apply deblocking on luminance only, and switch vertical deblocking on or off
  4870. automatically depending on available CPU time:
  4871. @example
  4872. pp=hb|y/vb|a
  4873. @end example
  4874. @end itemize
  4875. @section psnr
  4876. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  4877. Ratio) between two input videos.
  4878. This filter takes in input two input videos, the first input is
  4879. considered the "main" source and is passed unchanged to the
  4880. output. The second input is used as a "reference" video for computing
  4881. the PSNR.
  4882. Both video inputs must have the same resolution and pixel format for
  4883. this filter to work correctly. Also it assumes that both inputs
  4884. have the same number of frames, which are compared one by one.
  4885. The obtained average PSNR is printed through the logging system.
  4886. The filter stores the accumulated MSE (mean squared error) of each
  4887. frame, and at the end of the processing it is averaged across all frames
  4888. equally, and the following formula is applied to obtain the PSNR:
  4889. @example
  4890. PSNR = 10*log10(MAX^2/MSE)
  4891. @end example
  4892. Where MAX is the average of the maximum values of each component of the
  4893. image.
  4894. The description of the accepted parameters follows.
  4895. @table @option
  4896. @item stats_file, f
  4897. If specified the filter will use the named file to save the PSNR of
  4898. each individual frame.
  4899. @end table
  4900. The file printed if @var{stats_file} is selected, contains a sequence of
  4901. key/value pairs of the form @var{key}:@var{value} for each compared
  4902. couple of frames.
  4903. A description of each shown parameter follows:
  4904. @table @option
  4905. @item n
  4906. sequential number of the input frame, starting from 1
  4907. @item mse_avg
  4908. Mean Square Error pixel-by-pixel average difference of the compared
  4909. frames, averaged over all the image components.
  4910. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  4911. Mean Square Error pixel-by-pixel average difference of the compared
  4912. frames for the component specified by the suffix.
  4913. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  4914. Peak Signal to Noise ratio of the compared frames for the component
  4915. specified by the suffix.
  4916. @end table
  4917. For example:
  4918. @example
  4919. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  4920. [main][ref] psnr="stats_file=stats.log" [out]
  4921. @end example
  4922. On this example the input file being processed is compared with the
  4923. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  4924. is stored in @file{stats.log}.
  4925. @section pullup
  4926. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  4927. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  4928. content.
  4929. The pullup filter is designed to take advantage of future context in making
  4930. its decisions. This filter is stateless in the sense that it does not lock
  4931. onto a pattern to follow, but it instead looks forward to the following
  4932. fields in order to identify matches and rebuild progressive frames.
  4933. To produce content with an even framerate, insert the fps filter after
  4934. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  4935. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  4936. The filter accepts the following options:
  4937. @table @option
  4938. @item jl
  4939. @item jr
  4940. @item jt
  4941. @item jb
  4942. These options set the amount of "junk" to ignore at the left, right, top, and
  4943. bottom of the image, respectively. Left and right are in units of 8 pixels,
  4944. while top and bottom are in units of 2 lines.
  4945. The default is 8 pixels on each side.
  4946. @item sb
  4947. Set the strict breaks. Setting this option to 1 will reduce the chances of
  4948. filter generating an occasional mismatched frame, but it may also cause an
  4949. excessive number of frames to be dropped during high motion sequences.
  4950. Conversely, setting it to -1 will make filter match fields more easily.
  4951. This may help processing of video where there is slight blurring between
  4952. the fields, but may also cause there to be interlaced frames in the output.
  4953. Default value is @code{0}.
  4954. @item mp
  4955. Set the metric plane to use. It accepts the following values:
  4956. @table @samp
  4957. @item l
  4958. Use luma plane.
  4959. @item u
  4960. Use chroma blue plane.
  4961. @item v
  4962. Use chroma red plane.
  4963. @end table
  4964. This option may be set to use chroma plane instead of the default luma plane
  4965. for doing filter's computations. This may improve accuracy on very clean
  4966. source material, but more likely will decrease accuracy, especially if there
  4967. is chroma noise (rainbow effect) or any grayscale video.
  4968. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  4969. load and make pullup usable in realtime on slow machines.
  4970. @end table
  4971. For best results (without duplicated frames in the output file) it is
  4972. necessary to change the output frame rate. For example, to inverse
  4973. telecine NTSC input:
  4974. @example
  4975. ffmpeg -i input -vf pullup -r 24000/1001 ...
  4976. @end example
  4977. @section removelogo
  4978. Suppress a TV station logo, using an image file to determine which
  4979. pixels comprise the logo. It works by filling in the pixels that
  4980. comprise the logo with neighboring pixels.
  4981. The filter accepts the following options:
  4982. @table @option
  4983. @item filename, f
  4984. Set the filter bitmap file, which can be any image format supported by
  4985. libavformat. The width and height of the image file must match those of the
  4986. video stream being processed.
  4987. @end table
  4988. Pixels in the provided bitmap image with a value of zero are not
  4989. considered part of the logo, non-zero pixels are considered part of
  4990. the logo. If you use white (255) for the logo and black (0) for the
  4991. rest, you will be safe. For making the filter bitmap, it is
  4992. recommended to take a screen capture of a black frame with the logo
  4993. visible, and then using a threshold filter followed by the erode
  4994. filter once or twice.
  4995. If needed, little splotches can be fixed manually. Remember that if
  4996. logo pixels are not covered, the filter quality will be much
  4997. reduced. Marking too many pixels as part of the logo does not hurt as
  4998. much, but it will increase the amount of blurring needed to cover over
  4999. the image and will destroy more information than necessary, and extra
  5000. pixels will slow things down on a large logo.
  5001. @section rotate
  5002. Rotate video by an arbitrary angle expressed in radians.
  5003. The filter accepts the following options:
  5004. A description of the optional parameters follows.
  5005. @table @option
  5006. @item angle, a
  5007. Set an expression for the angle by which to rotate the input video
  5008. clockwise, expressed as a number of radians. A negative value will
  5009. result in a counter-clockwise rotation. By default it is set to "0".
  5010. This expression is evaluated for each frame.
  5011. @item out_w, ow
  5012. Set the output width expression, default value is "iw".
  5013. This expression is evaluated just once during configuration.
  5014. @item out_h, oh
  5015. Set the output height expression, default value is "ih".
  5016. This expression is evaluated just once during configuration.
  5017. @item bilinear
  5018. Enable bilinear interpolation if set to 1, a value of 0 disables
  5019. it. Default value is 1.
  5020. @item fillcolor, c
  5021. Set the color used to fill the output area not covered by the rotated
  5022. image. For the generalsyntax of this option, check the "Color" section in the
  5023. ffmpeg-utils manual. If the special value "none" is selected then no
  5024. background is printed (useful for example if the background is never shown).
  5025. Default value is "black".
  5026. @end table
  5027. The expressions for the angle and the output size can contain the
  5028. following constants and functions:
  5029. @table @option
  5030. @item n
  5031. sequential number of the input frame, starting from 0. It is always NAN
  5032. before the first frame is filtered.
  5033. @item t
  5034. time in seconds of the input frame, it is set to 0 when the filter is
  5035. configured. It is always NAN before the first frame is filtered.
  5036. @item hsub
  5037. @item vsub
  5038. horizontal and vertical chroma subsample values. For example for the
  5039. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  5040. @item in_w, iw
  5041. @item in_h, ih
  5042. the input video width and heigth
  5043. @item out_w, ow
  5044. @item out_h, oh
  5045. the output width and heigth, that is the size of the padded area as
  5046. specified by the @var{width} and @var{height} expressions
  5047. @item rotw(a)
  5048. @item roth(a)
  5049. the minimal width/height required for completely containing the input
  5050. video rotated by @var{a} radians.
  5051. These are only available when computing the @option{out_w} and
  5052. @option{out_h} expressions.
  5053. @end table
  5054. @subsection Examples
  5055. @itemize
  5056. @item
  5057. Rotate the input by PI/6 radians clockwise:
  5058. @example
  5059. rotate=PI/6
  5060. @end example
  5061. @item
  5062. Rotate the input by PI/6 radians counter-clockwise:
  5063. @example
  5064. rotate=-PI/6
  5065. @end example
  5066. @item
  5067. Apply a constant rotation with period T, starting from an angle of PI/3:
  5068. @example
  5069. rotate=PI/3+2*PI*t/T
  5070. @end example
  5071. @item
  5072. Make the input video rotation oscillating with a period of T
  5073. seconds and an amplitude of A radians:
  5074. @example
  5075. rotate=A*sin(2*PI/T*t)
  5076. @end example
  5077. @item
  5078. Rotate the video, output size is choosen so that the whole rotating
  5079. input video is always completely contained in the output:
  5080. @example
  5081. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  5082. @end example
  5083. @item
  5084. Rotate the video, reduce the output size so that no background is ever
  5085. shown:
  5086. @example
  5087. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  5088. @end example
  5089. @end itemize
  5090. @subsection Commands
  5091. The filter supports the following commands:
  5092. @table @option
  5093. @item a, angle
  5094. Set the angle expression.
  5095. The command accepts the same syntax of the corresponding option.
  5096. If the specified expression is not valid, it is kept at its current
  5097. value.
  5098. @end table
  5099. @section sab
  5100. Apply Shape Adaptive Blur.
  5101. The filter accepts the following options:
  5102. @table @option
  5103. @item luma_radius, lr
  5104. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  5105. value is 1.0. A greater value will result in a more blurred image, and
  5106. in slower processing.
  5107. @item luma_pre_filter_radius, lpfr
  5108. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  5109. value is 1.0.
  5110. @item luma_strength, ls
  5111. Set luma maximum difference between pixels to still be considered, must
  5112. be a value in the 0.1-100.0 range, default value is 1.0.
  5113. @item chroma_radius, cr
  5114. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  5115. greater value will result in a more blurred image, and in slower
  5116. processing.
  5117. @item chroma_pre_filter_radius, cpfr
  5118. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  5119. @item chroma_strength, cs
  5120. Set chroma maximum difference between pixels to still be considered,
  5121. must be a value in the 0.1-100.0 range.
  5122. @end table
  5123. Each chroma option value, if not explicitly specified, is set to the
  5124. corresponding luma option value.
  5125. @section scale
  5126. Scale (resize) the input video, using the libswscale library.
  5127. The scale filter forces the output display aspect ratio to be the same
  5128. of the input, by changing the output sample aspect ratio.
  5129. If the input image format is different from the format requested by
  5130. the next filter, the scale filter will convert the input to the
  5131. requested format.
  5132. @subsection Options
  5133. The filter accepts the following options, or any of the options
  5134. supported by the libswscale scaler.
  5135. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  5136. the complete list of scaler options.
  5137. @table @option
  5138. @item width, w
  5139. @item height, h
  5140. Set the output video dimension expression. Default value is the input
  5141. dimension.
  5142. If the value is 0, the input width is used for the output.
  5143. If one of the values is -1, the scale filter will use a value that
  5144. maintains the aspect ratio of the input image, calculated from the
  5145. other specified dimension. If both of them are -1, the input size is
  5146. used
  5147. See below for the list of accepted constants for use in the dimension
  5148. expression.
  5149. @item interl
  5150. Set the interlacing mode. It accepts the following values:
  5151. @table @samp
  5152. @item 1
  5153. Force interlaced aware scaling.
  5154. @item 0
  5155. Do not apply interlaced scaling.
  5156. @item -1
  5157. Select interlaced aware scaling depending on whether the source frames
  5158. are flagged as interlaced or not.
  5159. @end table
  5160. Default value is @samp{0}.
  5161. @item flags
  5162. Set libswscale scaling flags. See
  5163. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  5164. complete list of values. If not explictly specified the filter applies
  5165. the default flags.
  5166. @item size, s
  5167. Set the video size. For the syntax of this option, check the "Video size"
  5168. section in the ffmpeg-utils manual.
  5169. @item in_color_matrix
  5170. @item out_color_matrix
  5171. Set in/output YCbCr color space type.
  5172. This allows the autodetected value to be overridden as well as allows forcing
  5173. a specific value used for the output and encoder.
  5174. If not specified, the color space type depends on the pixel format.
  5175. Possible values:
  5176. @table @samp
  5177. @item auto
  5178. Choose automatically.
  5179. @item bt709
  5180. Format conforming to International Telecommunication Union (ITU)
  5181. Recommendation BT.709.
  5182. @item fcc
  5183. Set color space conforming to the United States Federal Communications
  5184. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  5185. @item bt601
  5186. Set color space conforming to:
  5187. @itemize
  5188. @item
  5189. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  5190. @item
  5191. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  5192. @item
  5193. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  5194. @end itemize
  5195. @item smpte240m
  5196. Set color space conforming to SMPTE ST 240:1999.
  5197. @end table
  5198. @item in_range
  5199. @item out_range
  5200. Set in/output YCbCr sample range.
  5201. This allows the autodetected value to be overridden as well as allows forcing
  5202. a specific value used for the output and encoder. If not specified, the
  5203. range depends on the pixel format. Possible values:
  5204. @table @samp
  5205. @item auto
  5206. Choose automatically.
  5207. @item jpeg/full/pc
  5208. Set full range (0-255 in case of 8-bit luma).
  5209. @item mpeg/tv
  5210. Set "MPEG" range (16-235 in case of 8-bit luma).
  5211. @end table
  5212. @item force_original_aspect_ratio
  5213. Enable decreasing or increasing output video width or height if necessary to
  5214. keep the original aspect ratio. Possible values:
  5215. @table @samp
  5216. @item disable
  5217. Scale the video as specified and disable this feature.
  5218. @item decrease
  5219. The output video dimensions will automatically be decreased if needed.
  5220. @item increase
  5221. The output video dimensions will automatically be increased if needed.
  5222. @end table
  5223. One useful instance of this option is that when you know a specific device's
  5224. maximum allowed resolution, you can use this to limit the output video to
  5225. that, while retaining the aspect ratio. For example, device A allows
  5226. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  5227. decrease) and specifying 1280x720 to the command line makes the output
  5228. 1280x533.
  5229. Please note that this is a different thing than specifying -1 for @option{w}
  5230. or @option{h}, you still need to specify the output resolution for this option
  5231. to work.
  5232. @end table
  5233. The values of the @option{w} and @option{h} options are expressions
  5234. containing the following constants:
  5235. @table @var
  5236. @item in_w
  5237. @item in_h
  5238. the input width and height
  5239. @item iw
  5240. @item ih
  5241. same as @var{in_w} and @var{in_h}
  5242. @item out_w
  5243. @item out_h
  5244. the output (scaled) width and height
  5245. @item ow
  5246. @item oh
  5247. same as @var{out_w} and @var{out_h}
  5248. @item a
  5249. same as @var{iw} / @var{ih}
  5250. @item sar
  5251. input sample aspect ratio
  5252. @item dar
  5253. input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  5254. @item hsub
  5255. @item vsub
  5256. horizontal and vertical input chroma subsample values. For example for the
  5257. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  5258. @item ohsub
  5259. @item ovsub
  5260. horizontal and vertical output chroma subsample values. For example for the
  5261. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  5262. @end table
  5263. @subsection Examples
  5264. @itemize
  5265. @item
  5266. Scale the input video to a size of 200x100:
  5267. @example
  5268. scale=w=200:h=100
  5269. @end example
  5270. This is equivalent to:
  5271. @example
  5272. scale=200:100
  5273. @end example
  5274. or:
  5275. @example
  5276. scale=200x100
  5277. @end example
  5278. @item
  5279. Specify a size abbreviation for the output size:
  5280. @example
  5281. scale=qcif
  5282. @end example
  5283. which can also be written as:
  5284. @example
  5285. scale=size=qcif
  5286. @end example
  5287. @item
  5288. Scale the input to 2x:
  5289. @example
  5290. scale=w=2*iw:h=2*ih
  5291. @end example
  5292. @item
  5293. The above is the same as:
  5294. @example
  5295. scale=2*in_w:2*in_h
  5296. @end example
  5297. @item
  5298. Scale the input to 2x with forced interlaced scaling:
  5299. @example
  5300. scale=2*iw:2*ih:interl=1
  5301. @end example
  5302. @item
  5303. Scale the input to half size:
  5304. @example
  5305. scale=w=iw/2:h=ih/2
  5306. @end example
  5307. @item
  5308. Increase the width, and set the height to the same size:
  5309. @example
  5310. scale=3/2*iw:ow
  5311. @end example
  5312. @item
  5313. Seek for Greek harmony:
  5314. @example
  5315. scale=iw:1/PHI*iw
  5316. scale=ih*PHI:ih
  5317. @end example
  5318. @item
  5319. Increase the height, and set the width to 3/2 of the height:
  5320. @example
  5321. scale=w=3/2*oh:h=3/5*ih
  5322. @end example
  5323. @item
  5324. Increase the size, but make the size a multiple of the chroma
  5325. subsample values:
  5326. @example
  5327. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  5328. @end example
  5329. @item
  5330. Increase the width to a maximum of 500 pixels, keep the same input
  5331. aspect ratio:
  5332. @example
  5333. scale=w='min(500\, iw*3/2):h=-1'
  5334. @end example
  5335. @end itemize
  5336. @section separatefields
  5337. The @code{separatefields} takes a frame-based video input and splits
  5338. each frame into its components fields, producing a new half height clip
  5339. with twice the frame rate and twice the frame count.
  5340. This filter use field-dominance information in frame to decide which
  5341. of each pair of fields to place first in the output.
  5342. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  5343. @section setdar, setsar
  5344. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  5345. output video.
  5346. This is done by changing the specified Sample (aka Pixel) Aspect
  5347. Ratio, according to the following equation:
  5348. @example
  5349. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  5350. @end example
  5351. Keep in mind that the @code{setdar} filter does not modify the pixel
  5352. dimensions of the video frame. Also the display aspect ratio set by
  5353. this filter may be changed by later filters in the filterchain,
  5354. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  5355. applied.
  5356. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  5357. the filter output video.
  5358. Note that as a consequence of the application of this filter, the
  5359. output display aspect ratio will change according to the equation
  5360. above.
  5361. Keep in mind that the sample aspect ratio set by the @code{setsar}
  5362. filter may be changed by later filters in the filterchain, e.g. if
  5363. another "setsar" or a "setdar" filter is applied.
  5364. The filters accept the following options:
  5365. @table @option
  5366. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  5367. Set the aspect ratio used by the filter.
  5368. The parameter can be a floating point number string, an expression, or
  5369. a string of the form @var{num}:@var{den}, where @var{num} and
  5370. @var{den} are the numerator and denominator of the aspect ratio. If
  5371. the parameter is not specified, it is assumed the value "0".
  5372. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  5373. should be escaped.
  5374. @item max
  5375. Set the maximum integer value to use for expressing numerator and
  5376. denominator when reducing the expressed aspect ratio to a rational.
  5377. Default value is @code{100}.
  5378. @end table
  5379. The parameter @var{sar} is an expression containing
  5380. the following constants:
  5381. @table @option
  5382. @item E, PI, PHI
  5383. the corresponding mathematical approximated values for e
  5384. (euler number), pi (greek PI), phi (golden ratio)
  5385. @item w, h
  5386. the input width and height
  5387. @item a
  5388. same as @var{w} / @var{h}
  5389. @item sar
  5390. input sample aspect ratio
  5391. @item dar
  5392. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  5393. @item hsub, vsub
  5394. horizontal and vertical chroma subsample values. For example for the
  5395. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  5396. @end table
  5397. @subsection Examples
  5398. @itemize
  5399. @item
  5400. To change the display aspect ratio to 16:9, specify one of the following:
  5401. @example
  5402. setdar=dar=1.77777
  5403. setdar=dar=16/9
  5404. setdar=dar=1.77777
  5405. @end example
  5406. @item
  5407. To change the sample aspect ratio to 10:11, specify:
  5408. @example
  5409. setsar=sar=10/11
  5410. @end example
  5411. @item
  5412. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  5413. 1000 in the aspect ratio reduction, use the command:
  5414. @example
  5415. setdar=ratio=16/9:max=1000
  5416. @end example
  5417. @end itemize
  5418. @anchor{setfield}
  5419. @section setfield
  5420. Force field for the output video frame.
  5421. The @code{setfield} filter marks the interlace type field for the
  5422. output frames. It does not change the input frame, but only sets the
  5423. corresponding property, which affects how the frame is treated by
  5424. following filters (e.g. @code{fieldorder} or @code{yadif}).
  5425. The filter accepts the following options:
  5426. @table @option
  5427. @item mode
  5428. Available values are:
  5429. @table @samp
  5430. @item auto
  5431. Keep the same field property.
  5432. @item bff
  5433. Mark the frame as bottom-field-first.
  5434. @item tff
  5435. Mark the frame as top-field-first.
  5436. @item prog
  5437. Mark the frame as progressive.
  5438. @end table
  5439. @end table
  5440. @section showinfo
  5441. Show a line containing various information for each input video frame.
  5442. The input video is not modified.
  5443. The shown line contains a sequence of key/value pairs of the form
  5444. @var{key}:@var{value}.
  5445. A description of each shown parameter follows:
  5446. @table @option
  5447. @item n
  5448. sequential number of the input frame, starting from 0
  5449. @item pts
  5450. Presentation TimeStamp of the input frame, expressed as a number of
  5451. time base units. The time base unit depends on the filter input pad.
  5452. @item pts_time
  5453. Presentation TimeStamp of the input frame, expressed as a number of
  5454. seconds
  5455. @item pos
  5456. position of the frame in the input stream, -1 if this information in
  5457. unavailable and/or meaningless (for example in case of synthetic video)
  5458. @item fmt
  5459. pixel format name
  5460. @item sar
  5461. sample aspect ratio of the input frame, expressed in the form
  5462. @var{num}/@var{den}
  5463. @item s
  5464. size of the input frame. For the syntax of this option, check the "Video size"
  5465. section in the ffmpeg-utils manual.
  5466. @item i
  5467. interlaced mode ("P" for "progressive", "T" for top field first, "B"
  5468. for bottom field first)
  5469. @item iskey
  5470. 1 if the frame is a key frame, 0 otherwise
  5471. @item type
  5472. picture type of the input frame ("I" for an I-frame, "P" for a
  5473. P-frame, "B" for a B-frame, "?" for unknown type).
  5474. Check also the documentation of the @code{AVPictureType} enum and of
  5475. the @code{av_get_picture_type_char} function defined in
  5476. @file{libavutil/avutil.h}.
  5477. @item checksum
  5478. Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame
  5479. @item plane_checksum
  5480. Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  5481. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]"
  5482. @end table
  5483. @anchor{smartblur}
  5484. @section smartblur
  5485. Blur the input video without impacting the outlines.
  5486. The filter accepts the following options:
  5487. @table @option
  5488. @item luma_radius, lr
  5489. Set the luma radius. The option value must be a float number in
  5490. the range [0.1,5.0] that specifies the variance of the gaussian filter
  5491. used to blur the image (slower if larger). Default value is 1.0.
  5492. @item luma_strength, ls
  5493. Set the luma strength. The option value must be a float number
  5494. in the range [-1.0,1.0] that configures the blurring. A value included
  5495. in [0.0,1.0] will blur the image whereas a value included in
  5496. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  5497. @item luma_threshold, lt
  5498. Set the luma threshold used as a coefficient to determine
  5499. whether a pixel should be blurred or not. The option value must be an
  5500. integer in the range [-30,30]. A value of 0 will filter all the image,
  5501. a value included in [0,30] will filter flat areas and a value included
  5502. in [-30,0] will filter edges. Default value is 0.
  5503. @item chroma_radius, cr
  5504. Set the chroma radius. The option value must be a float number in
  5505. the range [0.1,5.0] that specifies the variance of the gaussian filter
  5506. used to blur the image (slower if larger). Default value is 1.0.
  5507. @item chroma_strength, cs
  5508. Set the chroma strength. The option value must be a float number
  5509. in the range [-1.0,1.0] that configures the blurring. A value included
  5510. in [0.0,1.0] will blur the image whereas a value included in
  5511. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  5512. @item chroma_threshold, ct
  5513. Set the chroma threshold used as a coefficient to determine
  5514. whether a pixel should be blurred or not. The option value must be an
  5515. integer in the range [-30,30]. A value of 0 will filter all the image,
  5516. a value included in [0,30] will filter flat areas and a value included
  5517. in [-30,0] will filter edges. Default value is 0.
  5518. @end table
  5519. If a chroma option is not explicitly set, the corresponding luma value
  5520. is set.
  5521. @section stereo3d
  5522. Convert between different stereoscopic image formats.
  5523. The filters accept the following options:
  5524. @table @option
  5525. @item in
  5526. Set stereoscopic image format of input.
  5527. Available values for input image formats are:
  5528. @table @samp
  5529. @item sbsl
  5530. side by side parallel (left eye left, right eye right)
  5531. @item sbsr
  5532. side by side crosseye (right eye left, left eye right)
  5533. @item sbs2l
  5534. side by side parallel with half width resolution
  5535. (left eye left, right eye right)
  5536. @item sbs2r
  5537. side by side crosseye with half width resolution
  5538. (right eye left, left eye right)
  5539. @item abl
  5540. above-below (left eye above, right eye below)
  5541. @item abr
  5542. above-below (right eye above, left eye below)
  5543. @item ab2l
  5544. above-below with half height resolution
  5545. (left eye above, right eye below)
  5546. @item ab2r
  5547. above-below with half height resolution
  5548. (right eye above, left eye below)
  5549. @item al
  5550. alternating frames (left eye first, right eye second)
  5551. @item ar
  5552. alternating frames (right eye first, left eye second)
  5553. Default value is @samp{sbsl}.
  5554. @end table
  5555. @item out
  5556. Set stereoscopic image format of output.
  5557. Available values for output image formats are all the input formats as well as:
  5558. @table @samp
  5559. @item arbg
  5560. anaglyph red/blue gray
  5561. (red filter on left eye, blue filter on right eye)
  5562. @item argg
  5563. anaglyph red/green gray
  5564. (red filter on left eye, green filter on right eye)
  5565. @item arcg
  5566. anaglyph red/cyan gray
  5567. (red filter on left eye, cyan filter on right eye)
  5568. @item arch
  5569. anaglyph red/cyan half colored
  5570. (red filter on left eye, cyan filter on right eye)
  5571. @item arcc
  5572. anaglyph red/cyan color
  5573. (red filter on left eye, cyan filter on right eye)
  5574. @item arcd
  5575. anaglyph red/cyan color optimized with the least squares projection of dubois
  5576. (red filter on left eye, cyan filter on right eye)
  5577. @item agmg
  5578. anaglyph green/magenta gray
  5579. (green filter on left eye, magenta filter on right eye)
  5580. @item agmh
  5581. anaglyph green/magenta half colored
  5582. (green filter on left eye, magenta filter on right eye)
  5583. @item agmc
  5584. anaglyph green/magenta colored
  5585. (green filter on left eye, magenta filter on right eye)
  5586. @item agmd
  5587. anaglyph green/magenta color optimized with the least squares projection of dubois
  5588. (green filter on left eye, magenta filter on right eye)
  5589. @item aybg
  5590. anaglyph yellow/blue gray
  5591. (yellow filter on left eye, blue filter on right eye)
  5592. @item aybh
  5593. anaglyph yellow/blue half colored
  5594. (yellow filter on left eye, blue filter on right eye)
  5595. @item aybc
  5596. anaglyph yellow/blue colored
  5597. (yellow filter on left eye, blue filter on right eye)
  5598. @item aybd
  5599. anaglyph yellow/blue color optimized with the least squares projection of dubois
  5600. (yellow filter on left eye, blue filter on right eye)
  5601. @item irl
  5602. interleaved rows (left eye has top row, right eye starts on next row)
  5603. @item irr
  5604. interleaved rows (right eye has top row, left eye starts on next row)
  5605. @item ml
  5606. mono output (left eye only)
  5607. @item mr
  5608. mono output (right eye only)
  5609. @end table
  5610. Default value is @samp{arcd}.
  5611. @end table
  5612. @subsection Examples
  5613. @itemize
  5614. @item
  5615. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  5616. @example
  5617. stereo3d=sbsl:aybd
  5618. @end example
  5619. @item
  5620. Convert input video from above bellow (left eye above, right eye below) to side by side crosseye.
  5621. @example
  5622. stereo3d=abl:sbsr
  5623. @end example
  5624. @end itemize
  5625. @section spp
  5626. Apply a simple postprocessing filter that compresses and decompresses the image
  5627. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  5628. and average the results.
  5629. The filter accepts the following options:
  5630. @table @option
  5631. @item quality
  5632. Set quality. This option defines the number of levels for averaging. It accepts
  5633. an integer in the range 0-6. If set to @code{0}, the filter will have no
  5634. effect. A value of @code{6} means the higher quality. For each increment of
  5635. that value the speed drops by a factor of approximately 2. Default value is
  5636. @code{3}.
  5637. @item qp
  5638. Force a constant quantization parameter. If not set, the filter will use the QP
  5639. from the video stream (if available).
  5640. @item mode
  5641. Set thresholding mode. Available modes are:
  5642. @table @samp
  5643. @item hard
  5644. Set hard thresholding (default).
  5645. @item soft
  5646. Set soft thresholding (better de-ringing effect, but likely blurrier).
  5647. @end table
  5648. @item use_bframe_qp
  5649. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  5650. option may cause flicker since the B-Frames have often larger QP. Default is
  5651. @code{0} (not enabled).
  5652. @end table
  5653. @anchor{subtitles}
  5654. @section subtitles
  5655. Draw subtitles on top of input video using the libass library.
  5656. To enable compilation of this filter you need to configure FFmpeg with
  5657. @code{--enable-libass}. This filter also requires a build with libavcodec and
  5658. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  5659. Alpha) subtitles format.
  5660. The filter accepts the following options:
  5661. @table @option
  5662. @item filename, f
  5663. Set the filename of the subtitle file to read. It must be specified.
  5664. @item original_size
  5665. Specify the size of the original video, the video for which the ASS file
  5666. was composed. For the syntax of this option, check the "Video size" section in
  5667. the ffmpeg-utils manual. Due to a misdesign in ASS aspect ratio arithmetic,
  5668. this is necessary to correctly scale the fonts if the aspect ratio has been
  5669. changed.
  5670. @item charenc
  5671. Set subtitles input character encoding. @code{subtitles} filter only. Only
  5672. useful if not UTF-8.
  5673. @end table
  5674. If the first key is not specified, it is assumed that the first value
  5675. specifies the @option{filename}.
  5676. For example, to render the file @file{sub.srt} on top of the input
  5677. video, use the command:
  5678. @example
  5679. subtitles=sub.srt
  5680. @end example
  5681. which is equivalent to:
  5682. @example
  5683. subtitles=filename=sub.srt
  5684. @end example
  5685. @section super2xsai
  5686. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  5687. Interpolate) pixel art scaling algorithm.
  5688. Useful for enlarging pixel art images without reducing sharpness.
  5689. @section swapuv
  5690. Swap U & V plane.
  5691. @section telecine
  5692. Apply telecine process to the video.
  5693. This filter accepts the following options:
  5694. @table @option
  5695. @item first_field
  5696. @table @samp
  5697. @item top, t
  5698. top field first
  5699. @item bottom, b
  5700. bottom field first
  5701. The default value is @code{top}.
  5702. @end table
  5703. @item pattern
  5704. A string of numbers representing the pulldown pattern you wish to apply.
  5705. The default value is @code{23}.
  5706. @end table
  5707. @example
  5708. Some typical patterns:
  5709. NTSC output (30i):
  5710. 27.5p: 32222
  5711. 24p: 23 (classic)
  5712. 24p: 2332 (preferred)
  5713. 20p: 33
  5714. 18p: 334
  5715. 16p: 3444
  5716. PAL output (25i):
  5717. 27.5p: 12222
  5718. 24p: 222222222223 ("Euro pulldown")
  5719. 16.67p: 33
  5720. 16p: 33333334
  5721. @end example
  5722. @section thumbnail
  5723. Select the most representative frame in a given sequence of consecutive frames.
  5724. The filter accepts the following options:
  5725. @table @option
  5726. @item n
  5727. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  5728. will pick one of them, and then handle the next batch of @var{n} frames until
  5729. the end. Default is @code{100}.
  5730. @end table
  5731. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  5732. value will result in a higher memory usage, so a high value is not recommended.
  5733. @subsection Examples
  5734. @itemize
  5735. @item
  5736. Extract one picture each 50 frames:
  5737. @example
  5738. thumbnail=50
  5739. @end example
  5740. @item
  5741. Complete example of a thumbnail creation with @command{ffmpeg}:
  5742. @example
  5743. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  5744. @end example
  5745. @end itemize
  5746. @section tile
  5747. Tile several successive frames together.
  5748. The filter accepts the following options:
  5749. @table @option
  5750. @item layout
  5751. Set the grid size (i.e. the number of lines and columns). For the syntax of
  5752. this option, check the "Video size" section in the ffmpeg-utils manual.
  5753. @item nb_frames
  5754. Set the maximum number of frames to render in the given area. It must be less
  5755. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  5756. the area will be used.
  5757. @item margin
  5758. Set the outer border margin in pixels.
  5759. @item padding
  5760. Set the inner border thickness (i.e. the number of pixels between frames). For
  5761. more advanced padding options (such as having different values for the edges),
  5762. refer to the pad video filter.
  5763. @item color
  5764. Specify the color of the unused areaFor the syntax of this option, check the
  5765. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  5766. is "black".
  5767. @end table
  5768. @subsection Examples
  5769. @itemize
  5770. @item
  5771. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  5772. @example
  5773. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  5774. @end example
  5775. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  5776. duplicating each output frame to accomodate the originally detected frame
  5777. rate.
  5778. @item
  5779. Display @code{5} pictures in an area of @code{3x2} frames,
  5780. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  5781. mixed flat and named options:
  5782. @example
  5783. tile=3x2:nb_frames=5:padding=7:margin=2
  5784. @end example
  5785. @end itemize
  5786. @section tinterlace
  5787. Perform various types of temporal field interlacing.
  5788. Frames are counted starting from 1, so the first input frame is
  5789. considered odd.
  5790. The filter accepts the following options:
  5791. @table @option
  5792. @item mode
  5793. Specify the mode of the interlacing. This option can also be specified
  5794. as a value alone. See below for a list of values for this option.
  5795. Available values are:
  5796. @table @samp
  5797. @item merge, 0
  5798. Move odd frames into the upper field, even into the lower field,
  5799. generating a double height frame at half frame rate.
  5800. @item drop_odd, 1
  5801. Only output even frames, odd frames are dropped, generating a frame with
  5802. unchanged height at half frame rate.
  5803. @item drop_even, 2
  5804. Only output odd frames, even frames are dropped, generating a frame with
  5805. unchanged height at half frame rate.
  5806. @item pad, 3
  5807. Expand each frame to full height, but pad alternate lines with black,
  5808. generating a frame with double height at the same input frame rate.
  5809. @item interleave_top, 4
  5810. Interleave the upper field from odd frames with the lower field from
  5811. even frames, generating a frame with unchanged height at half frame rate.
  5812. @item interleave_bottom, 5
  5813. Interleave the lower field from odd frames with the upper field from
  5814. even frames, generating a frame with unchanged height at half frame rate.
  5815. @item interlacex2, 6
  5816. Double frame rate with unchanged height. Frames are inserted each
  5817. containing the second temporal field from the previous input frame and
  5818. the first temporal field from the next input frame. This mode relies on
  5819. the top_field_first flag. Useful for interlaced video displays with no
  5820. field synchronisation.
  5821. @end table
  5822. Numeric values are deprecated but are accepted for backward
  5823. compatibility reasons.
  5824. Default mode is @code{merge}.
  5825. @item flags
  5826. Specify flags influencing the filter process.
  5827. Available value for @var{flags} is:
  5828. @table @option
  5829. @item low_pass_filter, vlfp
  5830. Enable vertical low-pass filtering in the filter.
  5831. Vertical low-pass filtering is required when creating an interlaced
  5832. destination from a progressive source which contains high-frequency
  5833. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  5834. patterning.
  5835. Vertical low-pass filtering can only be enabled for @option{mode}
  5836. @var{interleave_top} and @var{interleave_bottom}.
  5837. @end table
  5838. @end table
  5839. @section transpose
  5840. Transpose rows with columns in the input video and optionally flip it.
  5841. This filter accepts the following options:
  5842. @table @option
  5843. @item dir
  5844. Specify the transposition direction.
  5845. Can assume the following values:
  5846. @table @samp
  5847. @item 0, 4, cclock_flip
  5848. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  5849. @example
  5850. L.R L.l
  5851. . . -> . .
  5852. l.r R.r
  5853. @end example
  5854. @item 1, 5, clock
  5855. Rotate by 90 degrees clockwise, that is:
  5856. @example
  5857. L.R l.L
  5858. . . -> . .
  5859. l.r r.R
  5860. @end example
  5861. @item 2, 6, cclock
  5862. Rotate by 90 degrees counterclockwise, that is:
  5863. @example
  5864. L.R R.r
  5865. . . -> . .
  5866. l.r L.l
  5867. @end example
  5868. @item 3, 7, clock_flip
  5869. Rotate by 90 degrees clockwise and vertically flip, that is:
  5870. @example
  5871. L.R r.R
  5872. . . -> . .
  5873. l.r l.L
  5874. @end example
  5875. @end table
  5876. For values between 4-7, the transposition is only done if the input
  5877. video geometry is portrait and not landscape. These values are
  5878. deprecated, the @code{passthrough} option should be used instead.
  5879. Numerical values are deprecated, and should be dropped in favor of
  5880. symbolic constants.
  5881. @item passthrough
  5882. Do not apply the transposition if the input geometry matches the one
  5883. specified by the specified value. It accepts the following values:
  5884. @table @samp
  5885. @item none
  5886. Always apply transposition.
  5887. @item portrait
  5888. Preserve portrait geometry (when @var{height} >= @var{width}).
  5889. @item landscape
  5890. Preserve landscape geometry (when @var{width} >= @var{height}).
  5891. @end table
  5892. Default value is @code{none}.
  5893. @end table
  5894. For example to rotate by 90 degrees clockwise and preserve portrait
  5895. layout:
  5896. @example
  5897. transpose=dir=1:passthrough=portrait
  5898. @end example
  5899. The command above can also be specified as:
  5900. @example
  5901. transpose=1:portrait
  5902. @end example
  5903. @section trim
  5904. Trim the input so that the output contains one continuous subpart of the input.
  5905. This filter accepts the following options:
  5906. @table @option
  5907. @item start
  5908. Specify time of the start of the kept section, i.e. the frame with the
  5909. timestamp @var{start} will be the first frame in the output.
  5910. @item end
  5911. Specify time of the first frame that will be dropped, i.e. the frame
  5912. immediately preceding the one with the timestamp @var{end} will be the last
  5913. frame in the output.
  5914. @item start_pts
  5915. Same as @var{start}, except this option sets the start timestamp in timebase
  5916. units instead of seconds.
  5917. @item end_pts
  5918. Same as @var{end}, except this option sets the end timestamp in timebase units
  5919. instead of seconds.
  5920. @item duration
  5921. Specify maximum duration of the output.
  5922. @item start_frame
  5923. Number of the first frame that should be passed to output.
  5924. @item end_frame
  5925. Number of the first frame that should be dropped.
  5926. @end table
  5927. @option{start}, @option{end}, @option{duration} are expressed as time
  5928. duration specifications, check the "Time duration" section in the
  5929. ffmpeg-utils manual.
  5930. Note that the first two sets of the start/end options and the @option{duration}
  5931. option look at the frame timestamp, while the _frame variants simply count the
  5932. frames that pass through the filter. Also note that this filter does not modify
  5933. the timestamps. If you wish that the output timestamps start at zero, insert a
  5934. setpts filter after the trim filter.
  5935. If multiple start or end options are set, this filter tries to be greedy and
  5936. keep all the frames that match at least one of the specified constraints. To keep
  5937. only the part that matches all the constraints at once, chain multiple trim
  5938. filters.
  5939. The defaults are such that all the input is kept. So it is possible to set e.g.
  5940. just the end values to keep everything before the specified time.
  5941. Examples:
  5942. @itemize
  5943. @item
  5944. drop everything except the second minute of input
  5945. @example
  5946. ffmpeg -i INPUT -vf trim=60:120
  5947. @end example
  5948. @item
  5949. keep only the first second
  5950. @example
  5951. ffmpeg -i INPUT -vf trim=duration=1
  5952. @end example
  5953. @end itemize
  5954. @section unsharp
  5955. Sharpen or blur the input video.
  5956. It accepts the following parameters:
  5957. @table @option
  5958. @item luma_msize_x, lx
  5959. Set the luma matrix horizontal size. It must be an odd integer between
  5960. 3 and 63, default value is 5.
  5961. @item luma_msize_y, ly
  5962. Set the luma matrix vertical size. It must be an odd integer between 3
  5963. and 63, default value is 5.
  5964. @item luma_amount, la
  5965. Set the luma effect strength. It can be a float number, reasonable
  5966. values lay between -1.5 and 1.5.
  5967. Negative values will blur the input video, while positive values will
  5968. sharpen it, a value of zero will disable the effect.
  5969. Default value is 1.0.
  5970. @item chroma_msize_x, cx
  5971. Set the chroma matrix horizontal size. It must be an odd integer
  5972. between 3 and 63, default value is 5.
  5973. @item chroma_msize_y, cy
  5974. Set the chroma matrix vertical size. It must be an odd integer
  5975. between 3 and 63, default value is 5.
  5976. @item chroma_amount, ca
  5977. Set the chroma effect strength. It can be a float number, reasonable
  5978. values lay between -1.5 and 1.5.
  5979. Negative values will blur the input video, while positive values will
  5980. sharpen it, a value of zero will disable the effect.
  5981. Default value is 0.0.
  5982. @item opencl
  5983. If set to 1, specify using OpenCL capabilities, only available if
  5984. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  5985. @end table
  5986. All parameters are optional and default to the equivalent of the
  5987. string '5:5:1.0:5:5:0.0'.
  5988. @subsection Examples
  5989. @itemize
  5990. @item
  5991. Apply strong luma sharpen effect:
  5992. @example
  5993. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  5994. @end example
  5995. @item
  5996. Apply strong blur of both luma and chroma parameters:
  5997. @example
  5998. unsharp=7:7:-2:7:7:-2
  5999. @end example
  6000. @end itemize
  6001. @anchor{vidstabdetect}
  6002. @section vidstabdetect
  6003. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  6004. @ref{vidstabtransform} for pass 2.
  6005. This filter generates a file with relative translation and rotation
  6006. transform information about subsequent frames, which is then used by
  6007. the @ref{vidstabtransform} filter.
  6008. To enable compilation of this filter you need to configure FFmpeg with
  6009. @code{--enable-libvidstab}.
  6010. This filter accepts the following options:
  6011. @table @option
  6012. @item result
  6013. Set the path to the file used to write the transforms information.
  6014. Default value is @file{transforms.trf}.
  6015. @item shakiness
  6016. Set how shaky the video is and how quick the camera is. It accepts an
  6017. integer in the range 1-10, a value of 1 means little shakiness, a
  6018. value of 10 means strong shakiness. Default value is 5.
  6019. @item accuracy
  6020. Set the accuracy of the detection process. It must be a value in the
  6021. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  6022. accuracy. Default value is 9.
  6023. @item stepsize
  6024. Set stepsize of the search process. The region around minimum is
  6025. scanned with 1 pixel resolution. Default value is 6.
  6026. @item mincontrast
  6027. Set minimum contrast. Below this value a local measurement field is
  6028. discarded. Must be a floating point value in the range 0-1. Default
  6029. value is 0.3.
  6030. @item tripod
  6031. Set reference frame number for tripod mode.
  6032. If enabled, the motion of the frames is compared to a reference frame
  6033. in the filtered stream, identified by the specified number. The idea
  6034. is to compensate all movements in a more-or-less static scene and keep
  6035. the camera view absolutely still.
  6036. If set to 0, it is disabled. The frames are counted starting from 1.
  6037. @item show
  6038. Show fields and transforms in the resulting frames. It accepts an
  6039. integer in the range 0-2. Default value is 0, which disables any
  6040. visualization.
  6041. @end table
  6042. @subsection Examples
  6043. @itemize
  6044. @item
  6045. Use default values:
  6046. @example
  6047. vidstabdetect
  6048. @end example
  6049. @item
  6050. Analyze strongly shaky movie and put the results in file
  6051. @file{mytransforms.trf}:
  6052. @example
  6053. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  6054. @end example
  6055. @item
  6056. Visualize the result of internal transformations in the resulting
  6057. video:
  6058. @example
  6059. vidstabdetect=show=1
  6060. @end example
  6061. @item
  6062. Analyze a video with medium shakiness using @command{ffmpeg}:
  6063. @example
  6064. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  6065. @end example
  6066. @end itemize
  6067. @anchor{vidstabtransform}
  6068. @section vidstabtransform
  6069. Video stabilization/deshaking: pass 2 of 2,
  6070. see @ref{vidstabdetect} for pass 1.
  6071. Read a file with transform information for each frame and
  6072. apply/compensate them. Together with the @ref{vidstabdetect}
  6073. filter this can be used to deshake videos. See also
  6074. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  6075. the unsharp filter, see below.
  6076. To enable compilation of this filter you need to configure FFmpeg with
  6077. @code{--enable-libvidstab}.
  6078. This filter accepts the following options:
  6079. @table @option
  6080. @item input
  6081. path to the file used to read the transforms (default: @file{transforms.trf})
  6082. @item smoothing
  6083. number of frames (value*2 + 1) used for lowpass filtering the camera movements
  6084. (default: 10). For example a number of 10 means that 21 frames are used
  6085. (10 in the past and 10 in the future) to smoothen the motion in the
  6086. video. A larger values leads to a smoother video, but limits the
  6087. acceleration of the camera (pan/tilt movements).
  6088. @item maxshift
  6089. maximal number of pixels to translate frames (default: -1 no limit)
  6090. @item maxangle
  6091. maximal angle in radians (degree*PI/180) to rotate frames (default: -1
  6092. no limit)
  6093. @item crop
  6094. How to deal with borders that may be visible due to movement
  6095. compensation. Available values are:
  6096. @table @samp
  6097. @item keep
  6098. keep image information from previous frame (default)
  6099. @item black
  6100. fill the border black
  6101. @end table
  6102. @item invert
  6103. @table @samp
  6104. @item 0
  6105. keep transforms normal (default)
  6106. @item 1
  6107. invert transforms
  6108. @end table
  6109. @item relative
  6110. consider transforms as
  6111. @table @samp
  6112. @item 0
  6113. absolute
  6114. @item 1
  6115. relative to previous frame (default)
  6116. @end table
  6117. @item zoom
  6118. percentage to zoom (default: 0)
  6119. @table @samp
  6120. @item >0
  6121. zoom in
  6122. @item <0
  6123. zoom out
  6124. @end table
  6125. @item optzoom
  6126. set optimal zooming to avoid borders
  6127. @table @samp
  6128. @item 0
  6129. disabled
  6130. @item 1
  6131. optimal static zoom value is determined (only very strong movements will lead to visible borders) (default)
  6132. @item 2
  6133. optimal adaptive zoom value is determined (no borders will be visible)
  6134. @end table
  6135. Note that the value given at zoom is added to the one calculated
  6136. here.
  6137. @item interpol
  6138. type of interpolation
  6139. Available values are:
  6140. @table @samp
  6141. @item no
  6142. no interpolation
  6143. @item linear
  6144. linear only horizontal
  6145. @item bilinear
  6146. linear in both directions (default)
  6147. @item bicubic
  6148. cubic in both directions (slow)
  6149. @end table
  6150. @item tripod
  6151. virtual tripod mode means that the video is stabilized such that the
  6152. camera stays stationary. Use also @code{tripod} option of
  6153. @ref{vidstabdetect}.
  6154. @table @samp
  6155. @item 0
  6156. off (default)
  6157. @item 1
  6158. virtual tripod mode: equivalent to @code{relative=0:smoothing=0}
  6159. @end table
  6160. @end table
  6161. @subsection Examples
  6162. @itemize
  6163. @item
  6164. typical call with default default values:
  6165. (note the unsharp filter which is always recommended)
  6166. @example
  6167. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  6168. @end example
  6169. @item
  6170. zoom in a bit more and load transform data from a given file
  6171. @example
  6172. vidstabtransform=zoom=5:input="mytransforms.trf"
  6173. @end example
  6174. @item
  6175. smoothen the video even more
  6176. @example
  6177. vidstabtransform=smoothing=30
  6178. @end example
  6179. @end itemize
  6180. @section vflip
  6181. Flip the input video vertically.
  6182. For example, to vertically flip a video with @command{ffmpeg}:
  6183. @example
  6184. ffmpeg -i in.avi -vf "vflip" out.avi
  6185. @end example
  6186. @section vignette
  6187. Make or reverse a natural vignetting effect.
  6188. The filter accepts the following options:
  6189. @table @option
  6190. @item angle, a
  6191. Set lens angle expression as a number of radians.
  6192. The value is clipped in the @code{[0,PI/2]} range.
  6193. Default value: @code{"PI/5"}
  6194. @item x0
  6195. @item y0
  6196. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  6197. by default.
  6198. @item mode
  6199. Set forward/backward mode.
  6200. Available modes are:
  6201. @table @samp
  6202. @item forward
  6203. The larger the distance from the central point, the darker the image becomes.
  6204. @item backward
  6205. The larger the distance from the central point, the brighter the image becomes.
  6206. This can be used to reverse a vignette effect, though there is no automatic
  6207. detection to extract the lens @option{angle} and other settings (yet). It can
  6208. also be used to create a burning effect.
  6209. @end table
  6210. Default value is @samp{forward}.
  6211. @item eval
  6212. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  6213. It accepts the following values:
  6214. @table @samp
  6215. @item init
  6216. Evaluate expressions only once during the filter initialization.
  6217. @item frame
  6218. Evaluate expressions for each incoming frame. This is way slower than the
  6219. @samp{init} mode since it requires all the scalers to be re-computed, but it
  6220. allows advanced dynamic expressions.
  6221. @end table
  6222. Default value is @samp{init}.
  6223. @item dither
  6224. Set dithering to reduce the circular banding effects. Default is @code{1}
  6225. (enabled).
  6226. @item aspect
  6227. Set vignette aspect. This setting allows to adjust the shape of the vignette.
  6228. Setting this value to the SAR of the input will make a rectangular vignetting
  6229. following the dimensions of the video.
  6230. Default is @code{1/1}.
  6231. @end table
  6232. @subsection Expressions
  6233. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  6234. following parameters.
  6235. @table @option
  6236. @item w
  6237. @item h
  6238. input width and height
  6239. @item n
  6240. the number of input frame, starting from 0
  6241. @item pts
  6242. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  6243. @var{TB} units, NAN if undefined
  6244. @item r
  6245. frame rate of the input video, NAN if the input frame rate is unknown
  6246. @item t
  6247. the PTS (Presentation TimeStamp) of the filtered video frame,
  6248. expressed in seconds, NAN if undefined
  6249. @item tb
  6250. time base of the input video
  6251. @end table
  6252. @subsection Examples
  6253. @itemize
  6254. @item
  6255. Apply simple strong vignetting effect:
  6256. @example
  6257. vignette=PI/4
  6258. @end example
  6259. @item
  6260. Make a flickering vignetting:
  6261. @example
  6262. vignette='PI/4+random(1)*PI/50':eval=frame
  6263. @end example
  6264. @end itemize
  6265. @section w3fdif
  6266. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  6267. Deinterlacing Filter").
  6268. Based on the process described by Martin Weston for BBC R&D, and
  6269. implemented based on the de-interlace algorithm written by Jim
  6270. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  6271. uses filter coefficients calculated by BBC R&D.
  6272. There are two sets of filter coefficients, so called "simple":
  6273. and "complex". Which set of filter coefficients is used can
  6274. be set by passing an optional parameter:
  6275. @table @option
  6276. @item filter
  6277. Set the interlacing filter coefficients. Accepts one of the following values:
  6278. @table @samp
  6279. @item simple
  6280. Simple filter coefficient set.
  6281. @item complex
  6282. More-complex filter coefficient set.
  6283. @end table
  6284. Default value is @samp{complex}.
  6285. @item deint
  6286. Specify which frames to deinterlace. Accept one of the following values:
  6287. @table @samp
  6288. @item all
  6289. Deinterlace all frames,
  6290. @item interlaced
  6291. Only deinterlace frames marked as interlaced.
  6292. @end table
  6293. Default value is @samp{all}.
  6294. @end table
  6295. @anchor{yadif}
  6296. @section yadif
  6297. Deinterlace the input video ("yadif" means "yet another deinterlacing
  6298. filter").
  6299. This filter accepts the following options:
  6300. @table @option
  6301. @item mode
  6302. The interlacing mode to adopt, accepts one of the following values:
  6303. @table @option
  6304. @item 0, send_frame
  6305. output 1 frame for each frame
  6306. @item 1, send_field
  6307. output 1 frame for each field
  6308. @item 2, send_frame_nospatial
  6309. like @code{send_frame} but skip spatial interlacing check
  6310. @item 3, send_field_nospatial
  6311. like @code{send_field} but skip spatial interlacing check
  6312. @end table
  6313. Default value is @code{send_frame}.
  6314. @item parity
  6315. The picture field parity assumed for the input interlaced video, accepts one of
  6316. the following values:
  6317. @table @option
  6318. @item 0, tff
  6319. assume top field first
  6320. @item 1, bff
  6321. assume bottom field first
  6322. @item -1, auto
  6323. enable automatic detection
  6324. @end table
  6325. Default value is @code{auto}.
  6326. If interlacing is unknown or decoder does not export this information,
  6327. top field first will be assumed.
  6328. @item deint
  6329. Specify which frames to deinterlace. Accept one of the following
  6330. values:
  6331. @table @option
  6332. @item 0, all
  6333. deinterlace all frames
  6334. @item 1, interlaced
  6335. only deinterlace frames marked as interlaced
  6336. @end table
  6337. Default value is @code{all}.
  6338. @end table
  6339. @c man end VIDEO FILTERS
  6340. @chapter Video Sources
  6341. @c man begin VIDEO SOURCES
  6342. Below is a description of the currently available video sources.
  6343. @section buffer
  6344. Buffer video frames, and make them available to the filter chain.
  6345. This source is mainly intended for a programmatic use, in particular
  6346. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  6347. This source accepts the following options:
  6348. @table @option
  6349. @item video_size
  6350. Specify the size (width and height) of the buffered video frames. For the
  6351. syntax of this option, check the "Video size" section in the ffmpeg-utils
  6352. manual.
  6353. @item width
  6354. Input video width.
  6355. @item height
  6356. Input video height.
  6357. @item pix_fmt
  6358. A string representing the pixel format of the buffered video frames.
  6359. It may be a number corresponding to a pixel format, or a pixel format
  6360. name.
  6361. @item time_base
  6362. Specify the timebase assumed by the timestamps of the buffered frames.
  6363. @item frame_rate
  6364. Specify the frame rate expected for the video stream.
  6365. @item pixel_aspect, sar
  6366. Specify the sample aspect ratio assumed by the video frames.
  6367. @item sws_param
  6368. Specify the optional parameters to be used for the scale filter which
  6369. is automatically inserted when an input change is detected in the
  6370. input size or format.
  6371. @end table
  6372. For example:
  6373. @example
  6374. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  6375. @end example
  6376. will instruct the source to accept video frames with size 320x240 and
  6377. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  6378. square pixels (1:1 sample aspect ratio).
  6379. Since the pixel format with name "yuv410p" corresponds to the number 6
  6380. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  6381. this example corresponds to:
  6382. @example
  6383. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  6384. @end example
  6385. Alternatively, the options can be specified as a flat string, but this
  6386. syntax is deprecated:
  6387. @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}]
  6388. @section cellauto
  6389. Create a pattern generated by an elementary cellular automaton.
  6390. The initial state of the cellular automaton can be defined through the
  6391. @option{filename}, and @option{pattern} options. If such options are
  6392. not specified an initial state is created randomly.
  6393. At each new frame a new row in the video is filled with the result of
  6394. the cellular automaton next generation. The behavior when the whole
  6395. frame is filled is defined by the @option{scroll} option.
  6396. This source accepts the following options:
  6397. @table @option
  6398. @item filename, f
  6399. Read the initial cellular automaton state, i.e. the starting row, from
  6400. the specified file.
  6401. In the file, each non-whitespace character is considered an alive
  6402. cell, a newline will terminate the row, and further characters in the
  6403. file will be ignored.
  6404. @item pattern, p
  6405. Read the initial cellular automaton state, i.e. the starting row, from
  6406. the specified string.
  6407. Each non-whitespace character in the string is considered an alive
  6408. cell, a newline will terminate the row, and further characters in the
  6409. string will be ignored.
  6410. @item rate, r
  6411. Set the video rate, that is the number of frames generated per second.
  6412. Default is 25.
  6413. @item random_fill_ratio, ratio
  6414. Set the random fill ratio for the initial cellular automaton row. It
  6415. is a floating point number value ranging from 0 to 1, defaults to
  6416. 1/PHI.
  6417. This option is ignored when a file or a pattern is specified.
  6418. @item random_seed, seed
  6419. Set the seed for filling randomly the initial row, must be an integer
  6420. included between 0 and UINT32_MAX. If not specified, or if explicitly
  6421. set to -1, the filter will try to use a good random seed on a best
  6422. effort basis.
  6423. @item rule
  6424. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  6425. Default value is 110.
  6426. @item size, s
  6427. Set the size of the output video. For the syntax of this option, check
  6428. the "Video size" section in the ffmpeg-utils manual.
  6429. If @option{filename} or @option{pattern} is specified, the size is set
  6430. by default to the width of the specified initial state row, and the
  6431. height is set to @var{width} * PHI.
  6432. If @option{size} is set, it must contain the width of the specified
  6433. pattern string, and the specified pattern will be centered in the
  6434. larger row.
  6435. If a filename or a pattern string is not specified, the size value
  6436. defaults to "320x518" (used for a randomly generated initial state).
  6437. @item scroll
  6438. If set to 1, scroll the output upward when all the rows in the output
  6439. have been already filled. If set to 0, the new generated row will be
  6440. written over the top row just after the bottom row is filled.
  6441. Defaults to 1.
  6442. @item start_full, full
  6443. If set to 1, completely fill the output with generated rows before
  6444. outputting the first frame.
  6445. This is the default behavior, for disabling set the value to 0.
  6446. @item stitch
  6447. If set to 1, stitch the left and right row edges together.
  6448. This is the default behavior, for disabling set the value to 0.
  6449. @end table
  6450. @subsection Examples
  6451. @itemize
  6452. @item
  6453. Read the initial state from @file{pattern}, and specify an output of
  6454. size 200x400.
  6455. @example
  6456. cellauto=f=pattern:s=200x400
  6457. @end example
  6458. @item
  6459. Generate a random initial row with a width of 200 cells, with a fill
  6460. ratio of 2/3:
  6461. @example
  6462. cellauto=ratio=2/3:s=200x200
  6463. @end example
  6464. @item
  6465. Create a pattern generated by rule 18 starting by a single alive cell
  6466. centered on an initial row with width 100:
  6467. @example
  6468. cellauto=p=@@:s=100x400:full=0:rule=18
  6469. @end example
  6470. @item
  6471. Specify a more elaborated initial pattern:
  6472. @example
  6473. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  6474. @end example
  6475. @end itemize
  6476. @section mandelbrot
  6477. Generate a Mandelbrot set fractal, and progressively zoom towards the
  6478. point specified with @var{start_x} and @var{start_y}.
  6479. This source accepts the following options:
  6480. @table @option
  6481. @item end_pts
  6482. Set the terminal pts value. Default value is 400.
  6483. @item end_scale
  6484. Set the terminal scale value.
  6485. Must be a floating point value. Default value is 0.3.
  6486. @item inner
  6487. Set the inner coloring mode, that is the algorithm used to draw the
  6488. Mandelbrot fractal internal region.
  6489. It shall assume one of the following values:
  6490. @table @option
  6491. @item black
  6492. Set black mode.
  6493. @item convergence
  6494. Show time until convergence.
  6495. @item mincol
  6496. Set color based on point closest to the origin of the iterations.
  6497. @item period
  6498. Set period mode.
  6499. @end table
  6500. Default value is @var{mincol}.
  6501. @item bailout
  6502. Set the bailout value. Default value is 10.0.
  6503. @item maxiter
  6504. Set the maximum of iterations performed by the rendering
  6505. algorithm. Default value is 7189.
  6506. @item outer
  6507. Set outer coloring mode.
  6508. It shall assume one of following values:
  6509. @table @option
  6510. @item iteration_count
  6511. Set iteration cound mode.
  6512. @item normalized_iteration_count
  6513. set normalized iteration count mode.
  6514. @end table
  6515. Default value is @var{normalized_iteration_count}.
  6516. @item rate, r
  6517. Set frame rate, expressed as number of frames per second. Default
  6518. value is "25".
  6519. @item size, s
  6520. Set frame size. For the syntax of this option, check the "Video
  6521. size" section in the ffmpeg-utils manual. Default value is "640x480".
  6522. @item start_scale
  6523. Set the initial scale value. Default value is 3.0.
  6524. @item start_x
  6525. Set the initial x position. Must be a floating point value between
  6526. -100 and 100. Default value is -0.743643887037158704752191506114774.
  6527. @item start_y
  6528. Set the initial y position. Must be a floating point value between
  6529. -100 and 100. Default value is -0.131825904205311970493132056385139.
  6530. @end table
  6531. @section mptestsrc
  6532. Generate various test patterns, as generated by the MPlayer test filter.
  6533. The size of the generated video is fixed, and is 256x256.
  6534. This source is useful in particular for testing encoding features.
  6535. This source accepts the following options:
  6536. @table @option
  6537. @item rate, r
  6538. Specify the frame rate of the sourced video, as the number of frames
  6539. generated per second. It has to be a string in the format
  6540. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  6541. number or a valid video frame rate abbreviation. The default value is
  6542. "25".
  6543. @item duration, d
  6544. Set the video duration of the sourced video. The accepted syntax is:
  6545. @example
  6546. [-]HH:MM:SS[.m...]
  6547. [-]S+[.m...]
  6548. @end example
  6549. See also the function @code{av_parse_time()}.
  6550. If not specified, or the expressed duration is negative, the video is
  6551. supposed to be generated forever.
  6552. @item test, t
  6553. Set the number or the name of the test to perform. Supported tests are:
  6554. @table @option
  6555. @item dc_luma
  6556. @item dc_chroma
  6557. @item freq_luma
  6558. @item freq_chroma
  6559. @item amp_luma
  6560. @item amp_chroma
  6561. @item cbp
  6562. @item mv
  6563. @item ring1
  6564. @item ring2
  6565. @item all
  6566. @end table
  6567. Default value is "all", which will cycle through the list of all tests.
  6568. @end table
  6569. For example the following:
  6570. @example
  6571. testsrc=t=dc_luma
  6572. @end example
  6573. will generate a "dc_luma" test pattern.
  6574. @section frei0r_src
  6575. Provide a frei0r source.
  6576. To enable compilation of this filter you need to install the frei0r
  6577. header and configure FFmpeg with @code{--enable-frei0r}.
  6578. This source accepts the following options:
  6579. @table @option
  6580. @item size
  6581. The size of the video to generate. For the syntax of this option, check the
  6582. "Video size" section in the ffmpeg-utils manual.
  6583. @item framerate
  6584. Framerate of the generated video, may be a string of the form
  6585. @var{num}/@var{den} or a frame rate abbreviation.
  6586. @item filter_name
  6587. The name to the frei0r source to load. For more information regarding frei0r and
  6588. how to set the parameters read the section @ref{frei0r} in the description of
  6589. the video filters.
  6590. @item filter_params
  6591. A '|'-separated list of parameters to pass to the frei0r source.
  6592. @end table
  6593. For example, to generate a frei0r partik0l source with size 200x200
  6594. and frame rate 10 which is overlayed on the overlay filter main input:
  6595. @example
  6596. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  6597. @end example
  6598. @section life
  6599. Generate a life pattern.
  6600. This source is based on a generalization of John Conway's life game.
  6601. The sourced input represents a life grid, each pixel represents a cell
  6602. which can be in one of two possible states, alive or dead. Every cell
  6603. interacts with its eight neighbours, which are the cells that are
  6604. horizontally, vertically, or diagonally adjacent.
  6605. At each interaction the grid evolves according to the adopted rule,
  6606. which specifies the number of neighbor alive cells which will make a
  6607. cell stay alive or born. The @option{rule} option allows to specify
  6608. the rule to adopt.
  6609. This source accepts the following options:
  6610. @table @option
  6611. @item filename, f
  6612. Set the file from which to read the initial grid state. In the file,
  6613. each non-whitespace character is considered an alive cell, and newline
  6614. is used to delimit the end of each row.
  6615. If this option is not specified, the initial grid is generated
  6616. randomly.
  6617. @item rate, r
  6618. Set the video rate, that is the number of frames generated per second.
  6619. Default is 25.
  6620. @item random_fill_ratio, ratio
  6621. Set the random fill ratio for the initial random grid. It is a
  6622. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  6623. It is ignored when a file is specified.
  6624. @item random_seed, seed
  6625. Set the seed for filling the initial random grid, must be an integer
  6626. included between 0 and UINT32_MAX. If not specified, or if explicitly
  6627. set to -1, the filter will try to use a good random seed on a best
  6628. effort basis.
  6629. @item rule
  6630. Set the life rule.
  6631. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  6632. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  6633. @var{NS} specifies the number of alive neighbor cells which make a
  6634. live cell stay alive, and @var{NB} the number of alive neighbor cells
  6635. which make a dead cell to become alive (i.e. to "born").
  6636. "s" and "b" can be used in place of "S" and "B", respectively.
  6637. Alternatively a rule can be specified by an 18-bits integer. The 9
  6638. high order bits are used to encode the next cell state if it is alive
  6639. for each number of neighbor alive cells, the low order bits specify
  6640. the rule for "borning" new cells. Higher order bits encode for an
  6641. higher number of neighbor cells.
  6642. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  6643. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  6644. Default value is "S23/B3", which is the original Conway's game of life
  6645. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  6646. cells, and will born a new cell if there are three alive cells around
  6647. a dead cell.
  6648. @item size, s
  6649. Set the size of the output video. For the syntax of this option, check the
  6650. "Video size" section in the ffmpeg-utils manual.
  6651. If @option{filename} is specified, the size is set by default to the
  6652. same size of the input file. If @option{size} is set, it must contain
  6653. the size specified in the input file, and the initial grid defined in
  6654. that file is centered in the larger resulting area.
  6655. If a filename is not specified, the size value defaults to "320x240"
  6656. (used for a randomly generated initial grid).
  6657. @item stitch
  6658. If set to 1, stitch the left and right grid edges together, and the
  6659. top and bottom edges also. Defaults to 1.
  6660. @item mold
  6661. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  6662. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  6663. value from 0 to 255.
  6664. @item life_color
  6665. Set the color of living (or new born) cells.
  6666. @item death_color
  6667. Set the color of dead cells. If @option{mold} is set, this is the first color
  6668. used to represent a dead cell.
  6669. @item mold_color
  6670. Set mold color, for definitely dead and moldy cells.
  6671. For the syntax of these 3 color options, check the "Color" section in the
  6672. ffmpeg-utils manual.
  6673. @end table
  6674. @subsection Examples
  6675. @itemize
  6676. @item
  6677. Read a grid from @file{pattern}, and center it on a grid of size
  6678. 300x300 pixels:
  6679. @example
  6680. life=f=pattern:s=300x300
  6681. @end example
  6682. @item
  6683. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  6684. @example
  6685. life=ratio=2/3:s=200x200
  6686. @end example
  6687. @item
  6688. Specify a custom rule for evolving a randomly generated grid:
  6689. @example
  6690. life=rule=S14/B34
  6691. @end example
  6692. @item
  6693. Full example with slow death effect (mold) using @command{ffplay}:
  6694. @example
  6695. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  6696. @end example
  6697. @end itemize
  6698. @anchor{color}
  6699. @anchor{haldclutsrc}
  6700. @anchor{nullsrc}
  6701. @anchor{rgbtestsrc}
  6702. @anchor{smptebars}
  6703. @anchor{smptehdbars}
  6704. @anchor{testsrc}
  6705. @section color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  6706. The @code{color} source provides an uniformly colored input.
  6707. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  6708. @ref{haldclut} filter.
  6709. The @code{nullsrc} source returns unprocessed video frames. It is
  6710. mainly useful to be employed in analysis / debugging tools, or as the
  6711. source for filters which ignore the input data.
  6712. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  6713. detecting RGB vs BGR issues. You should see a red, green and blue
  6714. stripe from top to bottom.
  6715. The @code{smptebars} source generates a color bars pattern, based on
  6716. the SMPTE Engineering Guideline EG 1-1990.
  6717. The @code{smptehdbars} source generates a color bars pattern, based on
  6718. the SMPTE RP 219-2002.
  6719. The @code{testsrc} source generates a test video pattern, showing a
  6720. color pattern, a scrolling gradient and a timestamp. This is mainly
  6721. intended for testing purposes.
  6722. The sources accept the following options:
  6723. @table @option
  6724. @item color, c
  6725. Specify the color of the source, only available in the @code{color}
  6726. source. For the syntax of this option, check the "Color" section in the
  6727. ffmpeg-utils manual.
  6728. @item level
  6729. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  6730. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  6731. pixels to be used as identity matrix for 3D lookup tables. Each component is
  6732. coded on a @code{1/(N*N)} scale.
  6733. @item size, s
  6734. Specify the size of the sourced video. For the syntax of this option, check the
  6735. "Video size" section in the ffmpeg-utils manual. The default value is
  6736. "320x240".
  6737. This option is not available with the @code{haldclutsrc} filter.
  6738. @item rate, r
  6739. Specify the frame rate of the sourced video, as the number of frames
  6740. generated per second. It has to be a string in the format
  6741. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float
  6742. number or a valid video frame rate abbreviation. The default value is
  6743. "25".
  6744. @item sar
  6745. Set the sample aspect ratio of the sourced video.
  6746. @item duration, d
  6747. Set the video duration of the sourced video. The accepted syntax is:
  6748. @example
  6749. [-]HH[:MM[:SS[.m...]]]
  6750. [-]S+[.m...]
  6751. @end example
  6752. See also the function @code{av_parse_time()}.
  6753. If not specified, or the expressed duration is negative, the video is
  6754. supposed to be generated forever.
  6755. @item decimals, n
  6756. Set the number of decimals to show in the timestamp, only available in the
  6757. @code{testsrc} source.
  6758. The displayed timestamp value will correspond to the original
  6759. timestamp value multiplied by the power of 10 of the specified
  6760. value. Default value is 0.
  6761. @end table
  6762. For example the following:
  6763. @example
  6764. testsrc=duration=5.3:size=qcif:rate=10
  6765. @end example
  6766. will generate a video with a duration of 5.3 seconds, with size
  6767. 176x144 and a frame rate of 10 frames per second.
  6768. The following graph description will generate a red source
  6769. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  6770. frames per second.
  6771. @example
  6772. color=c=red@@0.2:s=qcif:r=10
  6773. @end example
  6774. If the input content is to be ignored, @code{nullsrc} can be used. The
  6775. following command generates noise in the luminance plane by employing
  6776. the @code{geq} filter:
  6777. @example
  6778. nullsrc=s=256x256, geq=random(1)*255:128:128
  6779. @end example
  6780. @subsection Commands
  6781. The @code{color} source supports the following commands:
  6782. @table @option
  6783. @item c, color
  6784. Set the color of the created image. Accepts the same syntax of the
  6785. corresponding @option{color} option.
  6786. @end table
  6787. @c man end VIDEO SOURCES
  6788. @chapter Video Sinks
  6789. @c man begin VIDEO SINKS
  6790. Below is a description of the currently available video sinks.
  6791. @section buffersink
  6792. Buffer video frames, and make them available to the end of the filter
  6793. graph.
  6794. This sink is mainly intended for a programmatic use, in particular
  6795. through the interface defined in @file{libavfilter/buffersink.h}
  6796. or the options system.
  6797. It accepts a pointer to an AVBufferSinkContext structure, which
  6798. defines the incoming buffers' formats, to be passed as the opaque
  6799. parameter to @code{avfilter_init_filter} for initialization.
  6800. @section nullsink
  6801. Null video sink, do absolutely nothing with the input video. It is
  6802. mainly useful as a template and to be employed in analysis / debugging
  6803. tools.
  6804. @c man end VIDEO SINKS
  6805. @chapter Multimedia Filters
  6806. @c man begin MULTIMEDIA FILTERS
  6807. Below is a description of the currently available multimedia filters.
  6808. @section avectorscope
  6809. Convert input audio to a video output, representing the audio vector
  6810. scope.
  6811. The filter is used to measure the difference between channels of stereo
  6812. audio stream. A monoaural signal, consisting of identical left and right
  6813. signal, results in straight vertical line. Any stereo separation is visible
  6814. as a deviation from this line, creating a Lissajous figure.
  6815. If the straight (or deviation from it) but horizontal line appears this
  6816. indicates that the left and right channels are out of phase.
  6817. The filter accepts the following options:
  6818. @table @option
  6819. @item mode, m
  6820. Set the vectorscope mode.
  6821. Available values are:
  6822. @table @samp
  6823. @item lissajous
  6824. Lissajous rotated by 45 degrees.
  6825. @item lissajous_xy
  6826. Same as above but not rotated.
  6827. @end table
  6828. Default value is @samp{lissajous}.
  6829. @item size, s
  6830. Set the video size for the output. For the syntax of this option, check the "Video size"
  6831. section in the ffmpeg-utils manual. Default value is @code{400x400}.
  6832. @item rate, r
  6833. Set the output frame rate. Default value is @code{25}.
  6834. @item rc
  6835. @item gc
  6836. @item bc
  6837. Specify the red, green and blue contrast. Default values are @code{40}, @code{160} and @code{80}.
  6838. Allowed range is @code{[0, 255]}.
  6839. @item rf
  6840. @item gf
  6841. @item bf
  6842. Specify the red, green and blue fade. Default values are @code{15}, @code{10} and @code{5}.
  6843. Allowed range is @code{[0, 255]}.
  6844. @item zoom
  6845. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  6846. @end table
  6847. @subsection Examples
  6848. @itemize
  6849. @item
  6850. Complete example using @command{ffplay}:
  6851. @example
  6852. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  6853. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  6854. @end example
  6855. @end itemize
  6856. @section concat
  6857. Concatenate audio and video streams, joining them together one after the
  6858. other.
  6859. The filter works on segments of synchronized video and audio streams. All
  6860. segments must have the same number of streams of each type, and that will
  6861. also be the number of streams at output.
  6862. The filter accepts the following options:
  6863. @table @option
  6864. @item n
  6865. Set the number of segments. Default is 2.
  6866. @item v
  6867. Set the number of output video streams, that is also the number of video
  6868. streams in each segment. Default is 1.
  6869. @item a
  6870. Set the number of output audio streams, that is also the number of video
  6871. streams in each segment. Default is 0.
  6872. @item unsafe
  6873. Activate unsafe mode: do not fail if segments have a different format.
  6874. @end table
  6875. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  6876. @var{a} audio outputs.
  6877. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  6878. segment, in the same order as the outputs, then the inputs for the second
  6879. segment, etc.
  6880. Related streams do not always have exactly the same duration, for various
  6881. reasons including codec frame size or sloppy authoring. For that reason,
  6882. related synchronized streams (e.g. a video and its audio track) should be
  6883. concatenated at once. The concat filter will use the duration of the longest
  6884. stream in each segment (except the last one), and if necessary pad shorter
  6885. audio streams with silence.
  6886. For this filter to work correctly, all segments must start at timestamp 0.
  6887. All corresponding streams must have the same parameters in all segments; the
  6888. filtering system will automatically select a common pixel format for video
  6889. streams, and a common sample format, sample rate and channel layout for
  6890. audio streams, but other settings, such as resolution, must be converted
  6891. explicitly by the user.
  6892. Different frame rates are acceptable but will result in variable frame rate
  6893. at output; be sure to configure the output file to handle it.
  6894. @subsection Examples
  6895. @itemize
  6896. @item
  6897. Concatenate an opening, an episode and an ending, all in bilingual version
  6898. (video in stream 0, audio in streams 1 and 2):
  6899. @example
  6900. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  6901. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  6902. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  6903. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  6904. @end example
  6905. @item
  6906. Concatenate two parts, handling audio and video separately, using the
  6907. (a)movie sources, and adjusting the resolution:
  6908. @example
  6909. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  6910. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  6911. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  6912. @end example
  6913. Note that a desync will happen at the stitch if the audio and video streams
  6914. do not have exactly the same duration in the first file.
  6915. @end itemize
  6916. @section ebur128
  6917. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  6918. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  6919. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  6920. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  6921. The filter also has a video output (see the @var{video} option) with a real
  6922. time graph to observe the loudness evolution. The graphic contains the logged
  6923. message mentioned above, so it is not printed anymore when this option is set,
  6924. unless the verbose logging is set. The main graphing area contains the
  6925. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  6926. the momentary loudness (400 milliseconds).
  6927. More information about the Loudness Recommendation EBU R128 on
  6928. @url{http://tech.ebu.ch/loudness}.
  6929. The filter accepts the following options:
  6930. @table @option
  6931. @item video
  6932. Activate the video output. The audio stream is passed unchanged whether this
  6933. option is set or no. The video stream will be the first output stream if
  6934. activated. Default is @code{0}.
  6935. @item size
  6936. Set the video size. This option is for video only. For the syntax of this
  6937. option, check the "Video size" section in the ffmpeg-utils manual. Default
  6938. and minimum resolution is @code{640x480}.
  6939. @item meter
  6940. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  6941. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  6942. other integer value between this range is allowed.
  6943. @item metadata
  6944. Set metadata injection. If set to @code{1}, the audio input will be segmented
  6945. into 100ms output frames, each of them containing various loudness information
  6946. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  6947. Default is @code{0}.
  6948. @item framelog
  6949. Force the frame logging level.
  6950. Available values are:
  6951. @table @samp
  6952. @item info
  6953. information logging level
  6954. @item verbose
  6955. verbose logging level
  6956. @end table
  6957. By default, the logging level is set to @var{info}. If the @option{video} or
  6958. the @option{metadata} options are set, it switches to @var{verbose}.
  6959. @end table
  6960. @subsection Examples
  6961. @itemize
  6962. @item
  6963. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  6964. @example
  6965. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  6966. @end example
  6967. @item
  6968. Run an analysis with @command{ffmpeg}:
  6969. @example
  6970. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  6971. @end example
  6972. @end itemize
  6973. @section interleave, ainterleave
  6974. Temporally interleave frames from several inputs.
  6975. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  6976. These filters read frames from several inputs and send the oldest
  6977. queued frame to the output.
  6978. Input streams must have a well defined, monotonically increasing frame
  6979. timestamp values.
  6980. In order to submit one frame to output, these filters need to enqueue
  6981. at least one frame for each input, so they cannot work in case one
  6982. input is not yet terminated and will not receive incoming frames.
  6983. For example consider the case when one input is a @code{select} filter
  6984. which always drop input frames. The @code{interleave} filter will keep
  6985. reading from that input, but it will never be able to send new frames
  6986. to output until the input will send an end-of-stream signal.
  6987. Also, depending on inputs synchronization, the filters will drop
  6988. frames in case one input receives more frames than the other ones, and
  6989. the queue is already filled.
  6990. These filters accept the following options:
  6991. @table @option
  6992. @item nb_inputs, n
  6993. Set the number of different inputs, it is 2 by default.
  6994. @end table
  6995. @subsection Examples
  6996. @itemize
  6997. @item
  6998. Interleave frames belonging to different streams using @command{ffmpeg}:
  6999. @example
  7000. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  7001. @end example
  7002. @item
  7003. Add flickering blur effect:
  7004. @example
  7005. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  7006. @end example
  7007. @end itemize
  7008. @section perms, aperms
  7009. Set read/write permissions for the output frames.
  7010. These filters are mainly aimed at developers to test direct path in the
  7011. following filter in the filtergraph.
  7012. The filters accept the following options:
  7013. @table @option
  7014. @item mode
  7015. Select the permissions mode.
  7016. It accepts the following values:
  7017. @table @samp
  7018. @item none
  7019. Do nothing. This is the default.
  7020. @item ro
  7021. Set all the output frames read-only.
  7022. @item rw
  7023. Set all the output frames directly writable.
  7024. @item toggle
  7025. Make the frame read-only if writable, and writable if read-only.
  7026. @item random
  7027. Set each output frame read-only or writable randomly.
  7028. @end table
  7029. @item seed
  7030. Set the seed for the @var{random} mode, must be an integer included between
  7031. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  7032. @code{-1}, the filter will try to use a good random seed on a best effort
  7033. basis.
  7034. @end table
  7035. Note: in case of auto-inserted filter between the permission filter and the
  7036. following one, the permission might not be received as expected in that
  7037. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  7038. perms/aperms filter can avoid this problem.
  7039. @section select, aselect
  7040. Select frames to pass in output.
  7041. This filter accepts the following options:
  7042. @table @option
  7043. @item expr, e
  7044. Set expression, which is evaluated for each input frame.
  7045. If the expression is evaluated to zero, the frame is discarded.
  7046. If the evaluation result is negative or NaN, the frame is sent to the
  7047. first output; otherwise it is sent to the output with index
  7048. @code{ceil(val)-1}, assuming that the input index starts from 0.
  7049. For example a value of @code{1.2} corresponds to the output with index
  7050. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  7051. @item outputs, n
  7052. Set the number of outputs. The output to which to send the selected
  7053. frame is based on the result of the evaluation. Default value is 1.
  7054. @end table
  7055. The expression can contain the following constants:
  7056. @table @option
  7057. @item n
  7058. the sequential number of the filtered frame, starting from 0
  7059. @item selected_n
  7060. the sequential number of the selected frame, starting from 0
  7061. @item prev_selected_n
  7062. the sequential number of the last selected frame, NAN if undefined
  7063. @item TB
  7064. timebase of the input timestamps
  7065. @item pts
  7066. the PTS (Presentation TimeStamp) of the filtered video frame,
  7067. expressed in @var{TB} units, NAN if undefined
  7068. @item t
  7069. the PTS (Presentation TimeStamp) of the filtered video frame,
  7070. expressed in seconds, NAN if undefined
  7071. @item prev_pts
  7072. the PTS of the previously filtered video frame, NAN if undefined
  7073. @item prev_selected_pts
  7074. the PTS of the last previously filtered video frame, NAN if undefined
  7075. @item prev_selected_t
  7076. the PTS of the last previously selected video frame, NAN if undefined
  7077. @item start_pts
  7078. the PTS of the first video frame in the video, NAN if undefined
  7079. @item start_t
  7080. the time of the first video frame in the video, NAN if undefined
  7081. @item pict_type @emph{(video only)}
  7082. the type of the filtered frame, can assume one of the following
  7083. values:
  7084. @table @option
  7085. @item I
  7086. @item P
  7087. @item B
  7088. @item S
  7089. @item SI
  7090. @item SP
  7091. @item BI
  7092. @end table
  7093. @item interlace_type @emph{(video only)}
  7094. the frame interlace type, can assume one of the following values:
  7095. @table @option
  7096. @item PROGRESSIVE
  7097. the frame is progressive (not interlaced)
  7098. @item TOPFIRST
  7099. the frame is top-field-first
  7100. @item BOTTOMFIRST
  7101. the frame is bottom-field-first
  7102. @end table
  7103. @item consumed_sample_n @emph{(audio only)}
  7104. the number of selected samples before the current frame
  7105. @item samples_n @emph{(audio only)}
  7106. the number of samples in the current frame
  7107. @item sample_rate @emph{(audio only)}
  7108. the input sample rate
  7109. @item key
  7110. 1 if the filtered frame is a key-frame, 0 otherwise
  7111. @item pos
  7112. the position in the file of the filtered frame, -1 if the information
  7113. is not available (e.g. for synthetic video)
  7114. @item scene @emph{(video only)}
  7115. value between 0 and 1 to indicate a new scene; a low value reflects a low
  7116. probability for the current frame to introduce a new scene, while a higher
  7117. value means the current frame is more likely to be one (see the example below)
  7118. @end table
  7119. The default value of the select expression is "1".
  7120. @subsection Examples
  7121. @itemize
  7122. @item
  7123. Select all frames in input:
  7124. @example
  7125. select
  7126. @end example
  7127. The example above is the same as:
  7128. @example
  7129. select=1
  7130. @end example
  7131. @item
  7132. Skip all frames:
  7133. @example
  7134. select=0
  7135. @end example
  7136. @item
  7137. Select only I-frames:
  7138. @example
  7139. select='eq(pict_type\,I)'
  7140. @end example
  7141. @item
  7142. Select one frame every 100:
  7143. @example
  7144. select='not(mod(n\,100))'
  7145. @end example
  7146. @item
  7147. Select only frames contained in the 10-20 time interval:
  7148. @example
  7149. select=between(t\,10\,20)
  7150. @end example
  7151. @item
  7152. Select only I frames contained in the 10-20 time interval:
  7153. @example
  7154. select=between(t\,10\,20)*eq(pict_type\,I)
  7155. @end example
  7156. @item
  7157. Select frames with a minimum distance of 10 seconds:
  7158. @example
  7159. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  7160. @end example
  7161. @item
  7162. Use aselect to select only audio frames with samples number > 100:
  7163. @example
  7164. aselect='gt(samples_n\,100)'
  7165. @end example
  7166. @item
  7167. Create a mosaic of the first scenes:
  7168. @example
  7169. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  7170. @end example
  7171. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  7172. choice.
  7173. @item
  7174. Send even and odd frames to separate outputs, and compose them:
  7175. @example
  7176. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  7177. @end example
  7178. @end itemize
  7179. @section sendcmd, asendcmd
  7180. Send commands to filters in the filtergraph.
  7181. These filters read commands to be sent to other filters in the
  7182. filtergraph.
  7183. @code{sendcmd} must be inserted between two video filters,
  7184. @code{asendcmd} must be inserted between two audio filters, but apart
  7185. from that they act the same way.
  7186. The specification of commands can be provided in the filter arguments
  7187. with the @var{commands} option, or in a file specified by the
  7188. @var{filename} option.
  7189. These filters accept the following options:
  7190. @table @option
  7191. @item commands, c
  7192. Set the commands to be read and sent to the other filters.
  7193. @item filename, f
  7194. Set the filename of the commands to be read and sent to the other
  7195. filters.
  7196. @end table
  7197. @subsection Commands syntax
  7198. A commands description consists of a sequence of interval
  7199. specifications, comprising a list of commands to be executed when a
  7200. particular event related to that interval occurs. The occurring event
  7201. is typically the current frame time entering or leaving a given time
  7202. interval.
  7203. An interval is specified by the following syntax:
  7204. @example
  7205. @var{START}[-@var{END}] @var{COMMANDS};
  7206. @end example
  7207. The time interval is specified by the @var{START} and @var{END} times.
  7208. @var{END} is optional and defaults to the maximum time.
  7209. The current frame time is considered within the specified interval if
  7210. it is included in the interval [@var{START}, @var{END}), that is when
  7211. the time is greater or equal to @var{START} and is lesser than
  7212. @var{END}.
  7213. @var{COMMANDS} consists of a sequence of one or more command
  7214. specifications, separated by ",", relating to that interval. The
  7215. syntax of a command specification is given by:
  7216. @example
  7217. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  7218. @end example
  7219. @var{FLAGS} is optional and specifies the type of events relating to
  7220. the time interval which enable sending the specified command, and must
  7221. be a non-null sequence of identifier flags separated by "+" or "|" and
  7222. enclosed between "[" and "]".
  7223. The following flags are recognized:
  7224. @table @option
  7225. @item enter
  7226. The command is sent when the current frame timestamp enters the
  7227. specified interval. In other words, the command is sent when the
  7228. previous frame timestamp was not in the given interval, and the
  7229. current is.
  7230. @item leave
  7231. The command is sent when the current frame timestamp leaves the
  7232. specified interval. In other words, the command is sent when the
  7233. previous frame timestamp was in the given interval, and the
  7234. current is not.
  7235. @end table
  7236. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  7237. assumed.
  7238. @var{TARGET} specifies the target of the command, usually the name of
  7239. the filter class or a specific filter instance name.
  7240. @var{COMMAND} specifies the name of the command for the target filter.
  7241. @var{ARG} is optional and specifies the optional list of argument for
  7242. the given @var{COMMAND}.
  7243. Between one interval specification and another, whitespaces, or
  7244. sequences of characters starting with @code{#} until the end of line,
  7245. are ignored and can be used to annotate comments.
  7246. A simplified BNF description of the commands specification syntax
  7247. follows:
  7248. @example
  7249. @var{COMMAND_FLAG} ::= "enter" | "leave"
  7250. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  7251. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  7252. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  7253. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  7254. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  7255. @end example
  7256. @subsection Examples
  7257. @itemize
  7258. @item
  7259. Specify audio tempo change at second 4:
  7260. @example
  7261. asendcmd=c='4.0 atempo tempo 1.5',atempo
  7262. @end example
  7263. @item
  7264. Specify a list of drawtext and hue commands in a file.
  7265. @example
  7266. # show text in the interval 5-10
  7267. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  7268. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  7269. # desaturate the image in the interval 15-20
  7270. 15.0-20.0 [enter] hue s 0,
  7271. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  7272. [leave] hue s 1,
  7273. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  7274. # apply an exponential saturation fade-out effect, starting from time 25
  7275. 25 [enter] hue s exp(25-t)
  7276. @end example
  7277. A filtergraph allowing to read and process the above command list
  7278. stored in a file @file{test.cmd}, can be specified with:
  7279. @example
  7280. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  7281. @end example
  7282. @end itemize
  7283. @anchor{setpts}
  7284. @section setpts, asetpts
  7285. Change the PTS (presentation timestamp) of the input frames.
  7286. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  7287. This filter accepts the following options:
  7288. @table @option
  7289. @item expr
  7290. The expression which is evaluated for each frame to construct its timestamp.
  7291. @end table
  7292. The expression is evaluated through the eval API and can contain the following
  7293. constants:
  7294. @table @option
  7295. @item FRAME_RATE
  7296. frame rate, only defined for constant frame-rate video
  7297. @item PTS
  7298. the presentation timestamp in input
  7299. @item N
  7300. the count of the input frame for video or the number of consumed samples,
  7301. not including the current frame for audio, starting from 0.
  7302. @item NB_CONSUMED_SAMPLES
  7303. the number of consumed samples, not including the current frame (only
  7304. audio)
  7305. @item NB_SAMPLES, S
  7306. the number of samples in the current frame (only audio)
  7307. @item SAMPLE_RATE, SR
  7308. audio sample rate
  7309. @item STARTPTS
  7310. the PTS of the first frame
  7311. @item STARTT
  7312. the time in seconds of the first frame
  7313. @item INTERLACED
  7314. tell if the current frame is interlaced
  7315. @item T
  7316. the time in seconds of the current frame
  7317. @item POS
  7318. original position in the file of the frame, or undefined if undefined
  7319. for the current frame
  7320. @item PREV_INPTS
  7321. previous input PTS
  7322. @item PREV_INT
  7323. previous input time in seconds
  7324. @item PREV_OUTPTS
  7325. previous output PTS
  7326. @item PREV_OUTT
  7327. previous output time in seconds
  7328. @item RTCTIME
  7329. wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  7330. instead.
  7331. @item RTCSTART
  7332. wallclock (RTC) time at the start of the movie in microseconds
  7333. @item TB
  7334. timebase of the input timestamps
  7335. @end table
  7336. @subsection Examples
  7337. @itemize
  7338. @item
  7339. Start counting PTS from zero
  7340. @example
  7341. setpts=PTS-STARTPTS
  7342. @end example
  7343. @item
  7344. Apply fast motion effect:
  7345. @example
  7346. setpts=0.5*PTS
  7347. @end example
  7348. @item
  7349. Apply slow motion effect:
  7350. @example
  7351. setpts=2.0*PTS
  7352. @end example
  7353. @item
  7354. Set fixed rate of 25 frames per second:
  7355. @example
  7356. setpts=N/(25*TB)
  7357. @end example
  7358. @item
  7359. Set fixed rate 25 fps with some jitter:
  7360. @example
  7361. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  7362. @end example
  7363. @item
  7364. Apply an offset of 10 seconds to the input PTS:
  7365. @example
  7366. setpts=PTS+10/TB
  7367. @end example
  7368. @item
  7369. Generate timestamps from a "live source" and rebase onto the current timebase:
  7370. @example
  7371. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  7372. @end example
  7373. @item
  7374. Generate timestamps by counting samples:
  7375. @example
  7376. asetpts=N/SR/TB
  7377. @end example
  7378. @end itemize
  7379. @section settb, asettb
  7380. Set the timebase to use for the output frames timestamps.
  7381. It is mainly useful for testing timebase configuration.
  7382. This filter accepts the following options:
  7383. @table @option
  7384. @item expr, tb
  7385. The expression which is evaluated into the output timebase.
  7386. @end table
  7387. The value for @option{tb} is an arithmetic expression representing a
  7388. rational. The expression can contain the constants "AVTB" (the default
  7389. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  7390. audio only). Default value is "intb".
  7391. @subsection Examples
  7392. @itemize
  7393. @item
  7394. Set the timebase to 1/25:
  7395. @example
  7396. settb=expr=1/25
  7397. @end example
  7398. @item
  7399. Set the timebase to 1/10:
  7400. @example
  7401. settb=expr=0.1
  7402. @end example
  7403. @item
  7404. Set the timebase to 1001/1000:
  7405. @example
  7406. settb=1+0.001
  7407. @end example
  7408. @item
  7409. Set the timebase to 2*intb:
  7410. @example
  7411. settb=2*intb
  7412. @end example
  7413. @item
  7414. Set the default timebase value:
  7415. @example
  7416. settb=AVTB
  7417. @end example
  7418. @end itemize
  7419. @section showspectrum
  7420. Convert input audio to a video output, representing the audio frequency
  7421. spectrum.
  7422. The filter accepts the following options:
  7423. @table @option
  7424. @item size, s
  7425. Specify the video size for the output. For the syntax of this option, check
  7426. the "Video size" section in the ffmpeg-utils manual. Default value is
  7427. @code{640x512}.
  7428. @item slide
  7429. Specify if the spectrum should slide along the window. Default value is
  7430. @code{0}.
  7431. @item mode
  7432. Specify display mode.
  7433. It accepts the following values:
  7434. @table @samp
  7435. @item combined
  7436. all channels are displayed in the same row
  7437. @item separate
  7438. all channels are displayed in separate rows
  7439. @end table
  7440. Default value is @samp{combined}.
  7441. @item color
  7442. Specify display color mode.
  7443. It accepts the following values:
  7444. @table @samp
  7445. @item channel
  7446. each channel is displayed in a separate color
  7447. @item intensity
  7448. each channel is is displayed using the same color scheme
  7449. @end table
  7450. Default value is @samp{channel}.
  7451. @item scale
  7452. Specify scale used for calculating intensity color values.
  7453. It accepts the following values:
  7454. @table @samp
  7455. @item lin
  7456. linear
  7457. @item sqrt
  7458. square root, default
  7459. @item cbrt
  7460. cubic root
  7461. @item log
  7462. logarithmic
  7463. @end table
  7464. Default value is @samp{sqrt}.
  7465. @item saturation
  7466. Set saturation modifier for displayed colors. Negative values provide
  7467. alternative color scheme. @code{0} is no saturation at all.
  7468. Saturation must be in [-10.0, 10.0] range.
  7469. Default value is @code{1}.
  7470. @end table
  7471. The usage is very similar to the showwaves filter; see the examples in that
  7472. section.
  7473. @subsection Examples
  7474. @itemize
  7475. @item
  7476. Large window with logarithmic color scaling:
  7477. @example
  7478. showspectrum=s=1280x480:scale=log
  7479. @end example
  7480. @item
  7481. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  7482. @example
  7483. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  7484. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  7485. @end example
  7486. @end itemize
  7487. @section showwaves
  7488. Convert input audio to a video output, representing the samples waves.
  7489. The filter accepts the following options:
  7490. @table @option
  7491. @item size, s
  7492. Specify the video size for the output. For the syntax of this option, check
  7493. the "Video size" section in the ffmpeg-utils manual. Default value
  7494. is "600x240".
  7495. @item mode
  7496. Set display mode.
  7497. Available values are:
  7498. @table @samp
  7499. @item point
  7500. Draw a point for each sample.
  7501. @item line
  7502. Draw a vertical line for each sample.
  7503. @end table
  7504. Default value is @code{point}.
  7505. @item n
  7506. Set the number of samples which are printed on the same column. A
  7507. larger value will decrease the frame rate. Must be a positive
  7508. integer. This option can be set only if the value for @var{rate}
  7509. is not explicitly specified.
  7510. @item rate, r
  7511. Set the (approximate) output frame rate. This is done by setting the
  7512. option @var{n}. Default value is "25".
  7513. @end table
  7514. @subsection Examples
  7515. @itemize
  7516. @item
  7517. Output the input file audio and the corresponding video representation
  7518. at the same time:
  7519. @example
  7520. amovie=a.mp3,asplit[out0],showwaves[out1]
  7521. @end example
  7522. @item
  7523. Create a synthetic signal and show it with showwaves, forcing a
  7524. frame rate of 30 frames per second:
  7525. @example
  7526. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  7527. @end example
  7528. @end itemize
  7529. @section split, asplit
  7530. Split input into several identical outputs.
  7531. @code{asplit} works with audio input, @code{split} with video.
  7532. The filter accepts a single parameter which specifies the number of outputs. If
  7533. unspecified, it defaults to 2.
  7534. @subsection Examples
  7535. @itemize
  7536. @item
  7537. Create two separate outputs from the same input:
  7538. @example
  7539. [in] split [out0][out1]
  7540. @end example
  7541. @item
  7542. To create 3 or more outputs, you need to specify the number of
  7543. outputs, like in:
  7544. @example
  7545. [in] asplit=3 [out0][out1][out2]
  7546. @end example
  7547. @item
  7548. Create two separate outputs from the same input, one cropped and
  7549. one padded:
  7550. @example
  7551. [in] split [splitout1][splitout2];
  7552. [splitout1] crop=100:100:0:0 [cropout];
  7553. [splitout2] pad=200:200:100:100 [padout];
  7554. @end example
  7555. @item
  7556. Create 5 copies of the input audio with @command{ffmpeg}:
  7557. @example
  7558. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  7559. @end example
  7560. @end itemize
  7561. @section zmq, azmq
  7562. Receive commands sent through a libzmq client, and forward them to
  7563. filters in the filtergraph.
  7564. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  7565. must be inserted between two video filters, @code{azmq} between two
  7566. audio filters.
  7567. To enable these filters you need to install the libzmq library and
  7568. headers and configure FFmpeg with @code{--enable-libzmq}.
  7569. For more information about libzmq see:
  7570. @url{http://www.zeromq.org/}
  7571. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  7572. receives messages sent through a network interface defined by the
  7573. @option{bind_address} option.
  7574. The received message must be in the form:
  7575. @example
  7576. @var{TARGET} @var{COMMAND} [@var{ARG}]
  7577. @end example
  7578. @var{TARGET} specifies the target of the command, usually the name of
  7579. the filter class or a specific filter instance name.
  7580. @var{COMMAND} specifies the name of the command for the target filter.
  7581. @var{ARG} is optional and specifies the optional argument list for the
  7582. given @var{COMMAND}.
  7583. Upon reception, the message is processed and the corresponding command
  7584. is injected into the filtergraph. Depending on the result, the filter
  7585. will send a reply to the client, adopting the format:
  7586. @example
  7587. @var{ERROR_CODE} @var{ERROR_REASON}
  7588. @var{MESSAGE}
  7589. @end example
  7590. @var{MESSAGE} is optional.
  7591. @subsection Examples
  7592. Look at @file{tools/zmqsend} for an example of a zmq client which can
  7593. be used to send commands processed by these filters.
  7594. Consider the following filtergraph generated by @command{ffplay}
  7595. @example
  7596. ffplay -dumpgraph 1 -f lavfi "
  7597. color=s=100x100:c=red [l];
  7598. color=s=100x100:c=blue [r];
  7599. nullsrc=s=200x100, zmq [bg];
  7600. [bg][l] overlay [bg+l];
  7601. [bg+l][r] overlay=x=100 "
  7602. @end example
  7603. To change the color of the left side of the video, the following
  7604. command can be used:
  7605. @example
  7606. echo Parsed_color_0 c yellow | tools/zmqsend
  7607. @end example
  7608. To change the right side:
  7609. @example
  7610. echo Parsed_color_1 c pink | tools/zmqsend
  7611. @end example
  7612. @c man end MULTIMEDIA FILTERS
  7613. @chapter Multimedia Sources
  7614. @c man begin MULTIMEDIA SOURCES
  7615. Below is a description of the currently available multimedia sources.
  7616. @section amovie
  7617. This is the same as @ref{movie} source, except it selects an audio
  7618. stream by default.
  7619. @anchor{movie}
  7620. @section movie
  7621. Read audio and/or video stream(s) from a movie container.
  7622. This filter accepts the following options:
  7623. @table @option
  7624. @item filename
  7625. The name of the resource to read (not necessarily a file but also a device or a
  7626. stream accessed through some protocol).
  7627. @item format_name, f
  7628. Specifies the format assumed for the movie to read, and can be either
  7629. the name of a container or an input device. If not specified the
  7630. format is guessed from @var{movie_name} or by probing.
  7631. @item seek_point, sp
  7632. Specifies the seek point in seconds, the frames will be output
  7633. starting from this seek point, the parameter is evaluated with
  7634. @code{av_strtod} so the numerical value may be suffixed by an IS
  7635. postfix. Default value is "0".
  7636. @item streams, s
  7637. Specifies the streams to read. Several streams can be specified,
  7638. separated by "+". The source will then have as many outputs, in the
  7639. same order. The syntax is explained in the ``Stream specifiers''
  7640. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  7641. respectively the default (best suited) video and audio stream. Default
  7642. is "dv", or "da" if the filter is called as "amovie".
  7643. @item stream_index, si
  7644. Specifies the index of the video stream to read. If the value is -1,
  7645. the best suited video stream will be automatically selected. Default
  7646. value is "-1". Deprecated. If the filter is called "amovie", it will select
  7647. audio instead of video.
  7648. @item loop
  7649. Specifies how many times to read the stream in sequence.
  7650. If the value is less than 1, the stream will be read again and again.
  7651. Default value is "1".
  7652. Note that when the movie is looped the source timestamps are not
  7653. changed, so it will generate non monotonically increasing timestamps.
  7654. @end table
  7655. This filter allows to overlay a second video on top of main input of
  7656. a filtergraph as shown in this graph:
  7657. @example
  7658. input -----------> deltapts0 --> overlay --> output
  7659. ^
  7660. |
  7661. movie --> scale--> deltapts1 -------+
  7662. @end example
  7663. @subsection Examples
  7664. @itemize
  7665. @item
  7666. Skip 3.2 seconds from the start of the avi file in.avi, and overlay it
  7667. on top of the input labelled as "in":
  7668. @example
  7669. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  7670. [in] setpts=PTS-STARTPTS [main];
  7671. [main][over] overlay=16:16 [out]
  7672. @end example
  7673. @item
  7674. Read from a video4linux2 device, and overlay it on top of the input
  7675. labelled as "in":
  7676. @example
  7677. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  7678. [in] setpts=PTS-STARTPTS [main];
  7679. [main][over] overlay=16:16 [out]
  7680. @end example
  7681. @item
  7682. Read the first video stream and the audio stream with id 0x81 from
  7683. dvd.vob; the video is connected to the pad named "video" and the audio is
  7684. connected to the pad named "audio":
  7685. @example
  7686. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  7687. @end example
  7688. @end itemize
  7689. @c man end MULTIMEDIA SOURCES