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.

10077 lines
272KB

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