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.

10030 lines
270KB

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