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.

13579 lines
371KB

  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. @verbatim
  9. [main]
  10. input --> split ---------------------> overlay --> output
  11. | ^
  12. |[tmp] [flip]|
  13. +-----> crop --> vflip -------+
  14. @end verbatim
  15. This filtergraph splits the input stream in two streams, then 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 the top half of the video is mirrored
  23. onto the bottom half of the output video.
  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 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", and a filter with no
  89. output pads is called a "sink".
  90. @anchor{Filtergraph syntax}
  91. @section Filtergraph syntax
  92. A filtergraph has a textual representation, which is recognized by the
  93. @option{-filter}/@option{-vf}/@option{-af} and
  94. @option{-filter_complex} options in @command{ffmpeg} and
  95. @option{-vf}/@option{-af} in @command{ffplay}, and by the
  96. @code{avfilter_graph_parse_ptr()} function defined in
  97. @file{libavfilter/avfilter.h}.
  98. A filterchain consists of a sequence of connected filters, each one
  99. connected to the previous one in the sequence. A filterchain is
  100. represented by a list of ","-separated filter descriptions.
  101. A filtergraph consists of a sequence of filterchains. A sequence of
  102. filterchains is represented by a list of ";"-separated filterchain
  103. descriptions.
  104. A filter is represented by a string of the form:
  105. [@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
  106. @var{filter_name} is the name of the filter class of which the
  107. described filter is an instance of, and has to be the name of one of
  108. the filter classes registered in the program.
  109. The name of the filter class is optionally followed by a string
  110. "=@var{arguments}".
  111. @var{arguments} is a string which contains the parameters used to
  112. initialize the filter instance. It may have one of two forms:
  113. @itemize
  114. @item
  115. A ':'-separated list of @var{key=value} pairs.
  116. @item
  117. A ':'-separated list of @var{value}. In this case, the keys are assumed to be
  118. the option names in the order they are declared. E.g. the @code{fade} filter
  119. declares three options in this order -- @option{type}, @option{start_frame} and
  120. @option{nb_frames}. Then the parameter list @var{in:0:30} means that the value
  121. @var{in} is assigned to the option @option{type}, @var{0} to
  122. @option{start_frame} and @var{30} to @option{nb_frames}.
  123. @item
  124. A ':'-separated list of mixed direct @var{value} and long @var{key=value}
  125. pairs. The direct @var{value} must precede the @var{key=value} pairs, and
  126. follow the same constraints order of the previous point. The following
  127. @var{key=value} pairs can be set in any preferred order.
  128. @end itemize
  129. If the option value itself is a list of items (e.g. the @code{format} filter
  130. takes a list of pixel formats), the items in the list are usually separated by
  131. @samp{|}.
  132. The list of arguments can be quoted using the character @samp{'} as initial
  133. and ending mark, and the character @samp{\} for escaping the characters
  134. within the quoted text; otherwise the argument string is considered
  135. terminated when the next special character (belonging to the set
  136. @samp{[]=;,}) is encountered.
  137. The name and arguments of the filter are optionally preceded and
  138. followed by a list of link labels.
  139. A link label allows one to name a link and associate it to a filter output
  140. or input pad. The preceding labels @var{in_link_1}
  141. ... @var{in_link_N}, are associated to the filter input pads,
  142. the following labels @var{out_link_1} ... @var{out_link_M}, are
  143. associated to the output pads.
  144. When two link labels with the same name are found in the
  145. filtergraph, a link between the corresponding input and output pad is
  146. created.
  147. If an output pad is not labelled, it is linked by default to the first
  148. unlabelled input pad of the next filter in the filterchain.
  149. For example in the filterchain
  150. @example
  151. nullsrc, split[L1], [L2]overlay, nullsink
  152. @end example
  153. the split filter instance has two output pads, and the overlay filter
  154. instance two input pads. The first output pad of split is labelled
  155. "L1", the first input pad of overlay is labelled "L2", and the second
  156. output pad of split is linked to the second input pad of overlay,
  157. which are both unlabelled.
  158. In a filter description, if the input label of the first filter is not
  159. specified, "in" is assumed; if the output label of the last filter is not
  160. specified, "out" is assumed.
  161. In a complete filterchain all the unlabelled filter input and output
  162. pads must be connected. A filtergraph is considered valid if all the
  163. filter input and output pads of all the filterchains are connected.
  164. Libavfilter will automatically insert @ref{scale} filters where format
  165. conversion is required. It is possible to specify swscale flags
  166. for those automatically inserted scalers by prepending
  167. @code{sws_flags=@var{flags};}
  168. to the filtergraph description.
  169. Here is a BNF description of the filtergraph syntax:
  170. @example
  171. @var{NAME} ::= sequence of alphanumeric characters and '_'
  172. @var{LINKLABEL} ::= "[" @var{NAME} "]"
  173. @var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
  174. @var{FILTER_ARGUMENTS} ::= sequence of chars (possibly quoted)
  175. @var{FILTER} ::= [@var{LINKLABELS}] @var{NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}]
  176. @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
  177. @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
  178. @end example
  179. @section Notes on filtergraph escaping
  180. Filtergraph description composition entails several levels of
  181. escaping. See @ref{quoting_and_escaping,,the "Quoting and escaping"
  182. section in the ffmpeg-utils(1) manual,ffmpeg-utils} for more
  183. information about the employed escaping procedure.
  184. A first level escaping affects the content of each filter option
  185. value, which may contain the special character @code{:} used to
  186. separate values, or one of the escaping characters @code{\'}.
  187. A second level escaping affects the whole filter description, which
  188. may contain the escaping characters @code{\'} or the special
  189. characters @code{[],;} used by the filtergraph description.
  190. Finally, when you specify a filtergraph on a shell commandline, you
  191. need to perform a third level escaping for the shell special
  192. characters contained within it.
  193. For example, consider the following string to be embedded in
  194. the @ref{drawtext} filter description @option{text} value:
  195. @example
  196. this is a 'string': may contain one, or more, special characters
  197. @end example
  198. This string contains the @code{'} special escaping character, and the
  199. @code{:} special character, so it needs to be escaped in this way:
  200. @example
  201. text=this is a \'string\'\: may contain one, or more, special characters
  202. @end example
  203. A second level of escaping is required when embedding the filter
  204. description in a filtergraph description, in order to escape all the
  205. filtergraph special characters. Thus the example above becomes:
  206. @example
  207. drawtext=text=this is a \\\'string\\\'\\: may contain one\, or more\, special characters
  208. @end example
  209. (note that in addition to the @code{\'} escaping special characters,
  210. also @code{,} needs to be escaped).
  211. Finally an additional level of escaping is needed when writing the
  212. filtergraph description in a shell command, which depends on the
  213. escaping rules of the adopted shell. For example, assuming that
  214. @code{\} is special and needs to be escaped with another @code{\}, the
  215. previous string will finally result in:
  216. @example
  217. -vf "drawtext=text=this is a \\\\\\'string\\\\\\'\\\\: may contain one\\, or more\\, special characters"
  218. @end example
  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. @item w
  234. @item h
  235. width and height of the input frame if video
  236. @end table
  237. Additionally, these filters support an @option{enable} command that can be used
  238. to re-define the expression.
  239. Like any other filtering option, the @option{enable} option follows the same
  240. rules.
  241. For example, to enable a blur filter (@ref{smartblur}) from 10 seconds to 3
  242. minutes, and a @ref{curves} filter starting at 3 seconds:
  243. @example
  244. smartblur = enable='between(t,10,3*60)',
  245. curves = enable='gte(t,3)' : preset=cross_process
  246. @end example
  247. @c man end FILTERGRAPH DESCRIPTION
  248. @chapter Audio Filters
  249. @c man begin AUDIO FILTERS
  250. When you configure your FFmpeg build, you can disable any of the
  251. existing filters using @code{--disable-filters}.
  252. The configure output will show the audio filters included in your
  253. build.
  254. Below is a description of the currently available audio filters.
  255. @section acrossfade
  256. Apply cross fade from one input audio stream to another input audio stream.
  257. The cross fade is applied for specified duration near the end of first stream.
  258. The filter accepts the following options:
  259. @table @option
  260. @item nb_samples, ns
  261. Specify the number of samples for which the cross fade effect has to last.
  262. At the end of the cross fade effect the first input audio will be completely
  263. silent. Default is 44100.
  264. @item duration, d
  265. Specify the duration of the cross fade effect. See
  266. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  267. for the accepted syntax.
  268. By default the duration is determined by @var{nb_samples}.
  269. If set this option is used instead of @var{nb_samples}.
  270. @item overlap, o
  271. Should first stream end overlap with second stream start. Default is enabled.
  272. @item curve1
  273. Set curve for cross fade transition for first stream.
  274. @item curve2
  275. Set curve for cross fade transition for second stream.
  276. For description of available curve types see @ref{afade} filter description.
  277. @end table
  278. @subsection Examples
  279. @itemize
  280. @item
  281. Cross fade from one input to another:
  282. @example
  283. ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:c1=exp:c2=exp output.flac
  284. @end example
  285. @item
  286. Cross fade from one input to another but without overlapping:
  287. @example
  288. ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:o=0:c1=exp:c2=exp output.flac
  289. @end example
  290. @end itemize
  291. @section adelay
  292. Delay one or more audio channels.
  293. Samples in delayed channel are filled with silence.
  294. The filter accepts the following option:
  295. @table @option
  296. @item delays
  297. Set list of delays in milliseconds for each channel separated by '|'.
  298. At least one delay greater than 0 should be provided.
  299. Unused delays will be silently ignored. If number of given delays is
  300. smaller than number of channels all remaining channels will not be delayed.
  301. @end table
  302. @subsection Examples
  303. @itemize
  304. @item
  305. Delay first channel by 1.5 seconds, the third channel by 0.5 seconds and leave
  306. the second channel (and any other channels that may be present) unchanged.
  307. @example
  308. adelay=1500|0|500
  309. @end example
  310. @end itemize
  311. @section aecho
  312. Apply echoing to the input audio.
  313. Echoes are reflected sound and can occur naturally amongst mountains
  314. (and sometimes large buildings) when talking or shouting; digital echo
  315. effects emulate this behaviour and are often used to help fill out the
  316. sound of a single instrument or vocal. The time difference between the
  317. original signal and the reflection is the @code{delay}, and the
  318. loudness of the reflected signal is the @code{decay}.
  319. Multiple echoes can have different delays and decays.
  320. A description of the accepted parameters follows.
  321. @table @option
  322. @item in_gain
  323. Set input gain of reflected signal. Default is @code{0.6}.
  324. @item out_gain
  325. Set output gain of reflected signal. Default is @code{0.3}.
  326. @item delays
  327. Set list of time intervals in milliseconds between original signal and reflections
  328. separated by '|'. Allowed range for each @code{delay} is @code{(0 - 90000.0]}.
  329. Default is @code{1000}.
  330. @item decays
  331. Set list of loudnesses of reflected signals separated by '|'.
  332. Allowed range for each @code{decay} is @code{(0 - 1.0]}.
  333. Default is @code{0.5}.
  334. @end table
  335. @subsection Examples
  336. @itemize
  337. @item
  338. Make it sound as if there are twice as many instruments as are actually playing:
  339. @example
  340. aecho=0.8:0.88:60:0.4
  341. @end example
  342. @item
  343. If delay is very short, then it sound like a (metallic) robot playing music:
  344. @example
  345. aecho=0.8:0.88:6:0.4
  346. @end example
  347. @item
  348. A longer delay will sound like an open air concert in the mountains:
  349. @example
  350. aecho=0.8:0.9:1000:0.3
  351. @end example
  352. @item
  353. Same as above but with one more mountain:
  354. @example
  355. aecho=0.8:0.9:1000|1800:0.3|0.25
  356. @end example
  357. @end itemize
  358. @section aeval
  359. Modify an audio signal according to the specified expressions.
  360. This filter accepts one or more expressions (one for each channel),
  361. which are evaluated and used to modify a corresponding audio signal.
  362. It accepts the following parameters:
  363. @table @option
  364. @item exprs
  365. Set the '|'-separated expressions list for each separate channel. If
  366. the number of input channels is greater than the number of
  367. expressions, the last specified expression is used for the remaining
  368. output channels.
  369. @item channel_layout, c
  370. Set output channel layout. If not specified, the channel layout is
  371. specified by the number of expressions. If set to @samp{same}, it will
  372. use by default the same input channel layout.
  373. @end table
  374. Each expression in @var{exprs} can contain the following constants and functions:
  375. @table @option
  376. @item ch
  377. channel number of the current expression
  378. @item n
  379. number of the evaluated sample, starting from 0
  380. @item s
  381. sample rate
  382. @item t
  383. time of the evaluated sample expressed in seconds
  384. @item nb_in_channels
  385. @item nb_out_channels
  386. input and output number of channels
  387. @item val(CH)
  388. the value of input channel with number @var{CH}
  389. @end table
  390. Note: this filter is slow. For faster processing you should use a
  391. dedicated filter.
  392. @subsection Examples
  393. @itemize
  394. @item
  395. Half volume:
  396. @example
  397. aeval=val(ch)/2:c=same
  398. @end example
  399. @item
  400. Invert phase of the second channel:
  401. @example
  402. aeval=val(0)|-val(1)
  403. @end example
  404. @end itemize
  405. @anchor{afade}
  406. @section afade
  407. Apply fade-in/out effect to input audio.
  408. A description of the accepted parameters follows.
  409. @table @option
  410. @item type, t
  411. Specify the effect type, can be either @code{in} for fade-in, or
  412. @code{out} for a fade-out effect. Default is @code{in}.
  413. @item start_sample, ss
  414. Specify the number of the start sample for starting to apply the fade
  415. effect. Default is 0.
  416. @item nb_samples, ns
  417. Specify the number of samples for which the fade effect has to last. At
  418. the end of the fade-in effect the output audio will have the same
  419. volume as the input audio, at the end of the fade-out transition
  420. the output audio will be silence. Default is 44100.
  421. @item start_time, st
  422. Specify the start time of the fade effect. Default is 0.
  423. The value must be specified as a time duration; see
  424. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  425. for the accepted syntax.
  426. If set this option is used instead of @var{start_sample}.
  427. @item duration, d
  428. Specify the duration of the fade effect. See
  429. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  430. for the accepted syntax.
  431. At the end of the fade-in effect the output audio will have the same
  432. volume as the input audio, at the end of the fade-out transition
  433. the output audio will be silence.
  434. By default the duration is determined by @var{nb_samples}.
  435. If set this option is used instead of @var{nb_samples}.
  436. @item curve
  437. Set curve for fade transition.
  438. It accepts the following values:
  439. @table @option
  440. @item tri
  441. select triangular, linear slope (default)
  442. @item qsin
  443. select quarter of sine wave
  444. @item hsin
  445. select half of sine wave
  446. @item esin
  447. select exponential sine wave
  448. @item log
  449. select logarithmic
  450. @item ipar
  451. select inverted parabola
  452. @item qua
  453. select quadratic
  454. @item cub
  455. select cubic
  456. @item squ
  457. select square root
  458. @item cbr
  459. select cubic root
  460. @item par
  461. select parabola
  462. @item exp
  463. select exponential
  464. @item iqsin
  465. select inverted quarter of sine wave
  466. @item ihsin
  467. select inverted half of sine wave
  468. @item dese
  469. select double-exponential seat
  470. @item desi
  471. select double-exponential sigmoid
  472. @end table
  473. @end table
  474. @subsection Examples
  475. @itemize
  476. @item
  477. Fade in first 15 seconds of audio:
  478. @example
  479. afade=t=in:ss=0:d=15
  480. @end example
  481. @item
  482. Fade out last 25 seconds of a 900 seconds audio:
  483. @example
  484. afade=t=out:st=875:d=25
  485. @end example
  486. @end itemize
  487. @anchor{aformat}
  488. @section aformat
  489. Set output format constraints for the input audio. The framework will
  490. negotiate the most appropriate format to minimize conversions.
  491. It accepts the following parameters:
  492. @table @option
  493. @item sample_fmts
  494. A '|'-separated list of requested sample formats.
  495. @item sample_rates
  496. A '|'-separated list of requested sample rates.
  497. @item channel_layouts
  498. A '|'-separated list of requested channel layouts.
  499. See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  500. for the required syntax.
  501. @end table
  502. If a parameter is omitted, all values are allowed.
  503. Force the output to either unsigned 8-bit or signed 16-bit stereo
  504. @example
  505. aformat=sample_fmts=u8|s16:channel_layouts=stereo
  506. @end example
  507. @section allpass
  508. Apply a two-pole all-pass filter with central frequency (in Hz)
  509. @var{frequency}, and filter-width @var{width}.
  510. An all-pass filter changes the audio's frequency to phase relationship
  511. without changing its frequency to amplitude relationship.
  512. The filter accepts the following options:
  513. @table @option
  514. @item frequency, f
  515. Set frequency in Hz.
  516. @item width_type
  517. Set method to specify band-width of filter.
  518. @table @option
  519. @item h
  520. Hz
  521. @item q
  522. Q-Factor
  523. @item o
  524. octave
  525. @item s
  526. slope
  527. @end table
  528. @item width, w
  529. Specify the band-width of a filter in width_type units.
  530. @end table
  531. @anchor{amerge}
  532. @section amerge
  533. Merge two or more audio streams into a single multi-channel stream.
  534. The filter accepts the following options:
  535. @table @option
  536. @item inputs
  537. Set the number of inputs. Default is 2.
  538. @end table
  539. If the channel layouts of the inputs are disjoint, and therefore compatible,
  540. the channel layout of the output will be set accordingly and the channels
  541. will be reordered as necessary. If the channel layouts of the inputs are not
  542. disjoint, the output will have all the channels of the first input then all
  543. the channels of the second input, in that order, and the channel layout of
  544. the output will be the default value corresponding to the total number of
  545. channels.
  546. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  547. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  548. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  549. first input, b1 is the first channel of the second input).
  550. On the other hand, if both input are in stereo, the output channels will be
  551. in the default order: a1, a2, b1, b2, and the channel layout will be
  552. arbitrarily set to 4.0, which may or may not be the expected value.
  553. All inputs must have the same sample rate, and format.
  554. If inputs do not have the same duration, the output will stop with the
  555. shortest.
  556. @subsection Examples
  557. @itemize
  558. @item
  559. Merge two mono files into a stereo stream:
  560. @example
  561. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  562. @end example
  563. @item
  564. Multiple merges assuming 1 video stream and 6 audio streams in @file{input.mkv}:
  565. @example
  566. 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
  567. @end example
  568. @end itemize
  569. @section amix
  570. Mixes multiple audio inputs into a single output.
  571. Note that this filter only supports float samples (the @var{amerge}
  572. and @var{pan} audio filters support many formats). If the @var{amix}
  573. input has integer samples then @ref{aresample} will be automatically
  574. inserted to perform the conversion to float samples.
  575. For example
  576. @example
  577. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  578. @end example
  579. will mix 3 input audio streams to a single output with the same duration as the
  580. first input and a dropout transition time of 3 seconds.
  581. It accepts the following parameters:
  582. @table @option
  583. @item inputs
  584. The number of inputs. If unspecified, it defaults to 2.
  585. @item duration
  586. How to determine the end-of-stream.
  587. @table @option
  588. @item longest
  589. The duration of the longest input. (default)
  590. @item shortest
  591. The duration of the shortest input.
  592. @item first
  593. The duration of the first input.
  594. @end table
  595. @item dropout_transition
  596. The transition time, in seconds, for volume renormalization when an input
  597. stream ends. The default value is 2 seconds.
  598. @end table
  599. @section anull
  600. Pass the audio source unchanged to the output.
  601. @section apad
  602. Pad the end of an audio stream with silence.
  603. This can be used together with @command{ffmpeg} @option{-shortest} to
  604. extend audio streams to the same length as the video stream.
  605. A description of the accepted options follows.
  606. @table @option
  607. @item packet_size
  608. Set silence packet size. Default value is 4096.
  609. @item pad_len
  610. Set the number of samples of silence to add to the end. After the
  611. value is reached, the stream is terminated. This option is mutually
  612. exclusive with @option{whole_len}.
  613. @item whole_len
  614. Set the minimum total number of samples in the output audio stream. If
  615. the value is longer than the input audio length, silence is added to
  616. the end, until the value is reached. This option is mutually exclusive
  617. with @option{pad_len}.
  618. @end table
  619. If neither the @option{pad_len} nor the @option{whole_len} option is
  620. set, the filter will add silence to the end of the input stream
  621. indefinitely.
  622. @subsection Examples
  623. @itemize
  624. @item
  625. Add 1024 samples of silence to the end of the input:
  626. @example
  627. apad=pad_len=1024
  628. @end example
  629. @item
  630. Make sure the audio output will contain at least 10000 samples, pad
  631. the input with silence if required:
  632. @example
  633. apad=whole_len=10000
  634. @end example
  635. @item
  636. Use @command{ffmpeg} to pad the audio input with silence, so that the
  637. video stream will always result the shortest and will be converted
  638. until the end in the output file when using the @option{shortest}
  639. option:
  640. @example
  641. ffmpeg -i VIDEO -i AUDIO -filter_complex "[1:0]apad" -shortest OUTPUT
  642. @end example
  643. @end itemize
  644. @section aphaser
  645. Add a phasing effect to the input audio.
  646. A phaser filter creates series of peaks and troughs in the frequency spectrum.
  647. The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
  648. A description of the accepted parameters follows.
  649. @table @option
  650. @item in_gain
  651. Set input gain. Default is 0.4.
  652. @item out_gain
  653. Set output gain. Default is 0.74
  654. @item delay
  655. Set delay in milliseconds. Default is 3.0.
  656. @item decay
  657. Set decay. Default is 0.4.
  658. @item speed
  659. Set modulation speed in Hz. Default is 0.5.
  660. @item type
  661. Set modulation type. Default is triangular.
  662. It accepts the following values:
  663. @table @samp
  664. @item triangular, t
  665. @item sinusoidal, s
  666. @end table
  667. @end table
  668. @anchor{aresample}
  669. @section aresample
  670. Resample the input audio to the specified parameters, using the
  671. libswresample library. If none are specified then the filter will
  672. automatically convert between its input and output.
  673. This filter is also able to stretch/squeeze the audio data to make it match
  674. the timestamps or to inject silence / cut out audio to make it match the
  675. timestamps, do a combination of both or do neither.
  676. The filter accepts the syntax
  677. [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
  678. expresses a sample rate and @var{resampler_options} is a list of
  679. @var{key}=@var{value} pairs, separated by ":". See the
  680. ffmpeg-resampler manual for the complete list of supported options.
  681. @subsection Examples
  682. @itemize
  683. @item
  684. Resample the input audio to 44100Hz:
  685. @example
  686. aresample=44100
  687. @end example
  688. @item
  689. Stretch/squeeze samples to the given timestamps, with a maximum of 1000
  690. samples per second compensation:
  691. @example
  692. aresample=async=1000
  693. @end example
  694. @end itemize
  695. @section asetnsamples
  696. Set the number of samples per each output audio frame.
  697. The last output packet may contain a different number of samples, as
  698. the filter will flush all the remaining samples when the input audio
  699. signal its end.
  700. The filter accepts the following options:
  701. @table @option
  702. @item nb_out_samples, n
  703. Set the number of frames per each output audio frame. The number is
  704. intended as the number of samples @emph{per each channel}.
  705. Default value is 1024.
  706. @item pad, p
  707. If set to 1, the filter will pad the last audio frame with zeroes, so
  708. that the last frame will contain the same number of samples as the
  709. previous ones. Default value is 1.
  710. @end table
  711. For example, to set the number of per-frame samples to 1234 and
  712. disable padding for the last frame, use:
  713. @example
  714. asetnsamples=n=1234:p=0
  715. @end example
  716. @section asetrate
  717. Set the sample rate without altering the PCM data.
  718. This will result in a change of speed and pitch.
  719. The filter accepts the following options:
  720. @table @option
  721. @item sample_rate, r
  722. Set the output sample rate. Default is 44100 Hz.
  723. @end table
  724. @section ashowinfo
  725. Show a line containing various information for each input audio frame.
  726. The input audio is not modified.
  727. The shown line contains a sequence of key/value pairs of the form
  728. @var{key}:@var{value}.
  729. The following values are shown in the output:
  730. @table @option
  731. @item n
  732. The (sequential) number of the input frame, starting from 0.
  733. @item pts
  734. The presentation timestamp of the input frame, in time base units; the time base
  735. depends on the filter input pad, and is usually 1/@var{sample_rate}.
  736. @item pts_time
  737. The presentation timestamp of the input frame in seconds.
  738. @item pos
  739. position of the frame in the input stream, -1 if this information in
  740. unavailable and/or meaningless (for example in case of synthetic audio)
  741. @item fmt
  742. The sample format.
  743. @item chlayout
  744. The channel layout.
  745. @item rate
  746. The sample rate for the audio frame.
  747. @item nb_samples
  748. The number of samples (per channel) in the frame.
  749. @item checksum
  750. The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
  751. audio, the data is treated as if all the planes were concatenated.
  752. @item plane_checksums
  753. A list of Adler-32 checksums for each data plane.
  754. @end table
  755. @anchor{astats}
  756. @section astats
  757. Display time domain statistical information about the audio channels.
  758. Statistics are calculated and displayed for each audio channel and,
  759. where applicable, an overall figure is also given.
  760. It accepts the following option:
  761. @table @option
  762. @item length
  763. Short window length in seconds, used for peak and trough RMS measurement.
  764. Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.1 - 10]}.
  765. @item metadata
  766. Set metadata injection. All the metadata keys are prefixed with @code{lavfi.astats.X},
  767. where @code{X} is channel number starting from 1 or string @code{Overall}. Default is
  768. disabled.
  769. Available keys for each channel are:
  770. DC_offset
  771. Min_level
  772. Max_level
  773. Min_difference
  774. Max_difference
  775. Mean_difference
  776. Peak_level
  777. RMS_peak
  778. RMS_trough
  779. Crest_factor
  780. Flat_factor
  781. Peak_count
  782. Bit_depth
  783. and for Overall:
  784. DC_offset
  785. Min_level
  786. Max_level
  787. Min_difference
  788. Max_difference
  789. Mean_difference
  790. Peak_level
  791. RMS_level
  792. RMS_peak
  793. RMS_trough
  794. Flat_factor
  795. Peak_count
  796. Bit_depth
  797. Number_of_samples
  798. For example full key look like this @code{lavfi.astats.1.DC_offset} or
  799. this @code{lavfi.astats.Overall.Peak_count}.
  800. For description what each key means read bellow.
  801. @item reset
  802. Set number of frame after which stats are going to be recalculated.
  803. Default is disabled.
  804. @end table
  805. A description of each shown parameter follows:
  806. @table @option
  807. @item DC offset
  808. Mean amplitude displacement from zero.
  809. @item Min level
  810. Minimal sample level.
  811. @item Max level
  812. Maximal sample level.
  813. @item Min difference
  814. Minimal difference between two consecutive samples.
  815. @item Max difference
  816. Maximal difference between two consecutive samples.
  817. @item Mean difference
  818. Mean difference between two consecutive samples.
  819. The average of each difference between two consecutive samples.
  820. @item Peak level dB
  821. @item RMS level dB
  822. Standard peak and RMS level measured in dBFS.
  823. @item RMS peak dB
  824. @item RMS trough dB
  825. Peak and trough values for RMS level measured over a short window.
  826. @item Crest factor
  827. Standard ratio of peak to RMS level (note: not in dB).
  828. @item Flat factor
  829. Flatness (i.e. consecutive samples with the same value) of the signal at its peak levels
  830. (i.e. either @var{Min level} or @var{Max level}).
  831. @item Peak count
  832. Number of occasions (not the number of samples) that the signal attained either
  833. @var{Min level} or @var{Max level}.
  834. @item Bit depth
  835. Overall bit depth of audio. Number of bits used for each sample.
  836. @end table
  837. @section astreamsync
  838. Forward two audio streams and control the order the buffers are forwarded.
  839. The filter accepts the following options:
  840. @table @option
  841. @item expr, e
  842. Set the expression deciding which stream should be
  843. forwarded next: if the result is negative, the first stream is forwarded; if
  844. the result is positive or zero, the second stream is forwarded. It can use
  845. the following variables:
  846. @table @var
  847. @item b1 b2
  848. number of buffers forwarded so far on each stream
  849. @item s1 s2
  850. number of samples forwarded so far on each stream
  851. @item t1 t2
  852. current timestamp of each stream
  853. @end table
  854. The default value is @code{t1-t2}, which means to always forward the stream
  855. that has a smaller timestamp.
  856. @end table
  857. @subsection Examples
  858. Stress-test @code{amerge} by randomly sending buffers on the wrong
  859. input, while avoiding too much of a desynchronization:
  860. @example
  861. amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
  862. [a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
  863. [a2] [b2] amerge
  864. @end example
  865. @section asyncts
  866. Synchronize audio data with timestamps by squeezing/stretching it and/or
  867. dropping samples/adding silence when needed.
  868. This filter is not built by default, please use @ref{aresample} to do squeezing/stretching.
  869. It accepts the following parameters:
  870. @table @option
  871. @item compensate
  872. Enable stretching/squeezing the data to make it match the timestamps. Disabled
  873. by default. When disabled, time gaps are covered with silence.
  874. @item min_delta
  875. The minimum difference between timestamps and audio data (in seconds) to trigger
  876. adding/dropping samples. The default value is 0.1. If you get an imperfect
  877. sync with this filter, try setting this parameter to 0.
  878. @item max_comp
  879. The maximum compensation in samples per second. Only relevant with compensate=1.
  880. The default value is 500.
  881. @item first_pts
  882. Assume that the first PTS should be this value. The time base is 1 / sample
  883. rate. This allows for padding/trimming at the start of the stream. By default,
  884. no assumption is made about the first frame's expected PTS, so no padding or
  885. trimming is done. For example, this could be set to 0 to pad the beginning with
  886. silence if an audio stream starts after the video stream or to trim any samples
  887. with a negative PTS due to encoder delay.
  888. @end table
  889. @section atempo
  890. Adjust audio tempo.
  891. The filter accepts exactly one parameter, the audio tempo. If not
  892. specified then the filter will assume nominal 1.0 tempo. Tempo must
  893. be in the [0.5, 2.0] range.
  894. @subsection Examples
  895. @itemize
  896. @item
  897. Slow down audio to 80% tempo:
  898. @example
  899. atempo=0.8
  900. @end example
  901. @item
  902. To speed up audio to 125% tempo:
  903. @example
  904. atempo=1.25
  905. @end example
  906. @end itemize
  907. @section atrim
  908. Trim the input so that the output contains one continuous subpart of the input.
  909. It accepts the following parameters:
  910. @table @option
  911. @item start
  912. Timestamp (in seconds) of the start of the section to keep. I.e. the audio
  913. sample with the timestamp @var{start} will be the first sample in the output.
  914. @item end
  915. Specify time of the first audio sample that will be dropped, i.e. the
  916. audio sample immediately preceding the one with the timestamp @var{end} will be
  917. the last sample in the output.
  918. @item start_pts
  919. Same as @var{start}, except this option sets the start timestamp in samples
  920. instead of seconds.
  921. @item end_pts
  922. Same as @var{end}, except this option sets the end timestamp in samples instead
  923. of seconds.
  924. @item duration
  925. The maximum duration of the output in seconds.
  926. @item start_sample
  927. The number of the first sample that should be output.
  928. @item end_sample
  929. The number of the first sample that should be dropped.
  930. @end table
  931. @option{start}, @option{end}, and @option{duration} are expressed as time
  932. duration specifications; see
  933. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  934. Note that the first two sets of the start/end options and the @option{duration}
  935. option look at the frame timestamp, while the _sample options simply count the
  936. samples that pass through the filter. So start/end_pts and start/end_sample will
  937. give different results when the timestamps are wrong, inexact or do not start at
  938. zero. Also note that this filter does not modify the timestamps. If you wish
  939. to have the output timestamps start at zero, insert the asetpts filter after the
  940. atrim filter.
  941. If multiple start or end options are set, this filter tries to be greedy and
  942. keep all samples that match at least one of the specified constraints. To keep
  943. only the part that matches all the constraints at once, chain multiple atrim
  944. filters.
  945. The defaults are such that all the input is kept. So it is possible to set e.g.
  946. just the end values to keep everything before the specified time.
  947. Examples:
  948. @itemize
  949. @item
  950. Drop everything except the second minute of input:
  951. @example
  952. ffmpeg -i INPUT -af atrim=60:120
  953. @end example
  954. @item
  955. Keep only the first 1000 samples:
  956. @example
  957. ffmpeg -i INPUT -af atrim=end_sample=1000
  958. @end example
  959. @end itemize
  960. @section bandpass
  961. Apply a two-pole Butterworth band-pass filter with central
  962. frequency @var{frequency}, and (3dB-point) band-width width.
  963. The @var{csg} option selects a constant skirt gain (peak gain = Q)
  964. instead of the default: constant 0dB peak gain.
  965. The filter roll off at 6dB per octave (20dB per decade).
  966. The filter accepts the following options:
  967. @table @option
  968. @item frequency, f
  969. Set the filter's central frequency. Default is @code{3000}.
  970. @item csg
  971. Constant skirt gain if set to 1. Defaults to 0.
  972. @item width_type
  973. Set method to specify band-width of filter.
  974. @table @option
  975. @item h
  976. Hz
  977. @item q
  978. Q-Factor
  979. @item o
  980. octave
  981. @item s
  982. slope
  983. @end table
  984. @item width, w
  985. Specify the band-width of a filter in width_type units.
  986. @end table
  987. @section bandreject
  988. Apply a two-pole Butterworth band-reject filter with central
  989. frequency @var{frequency}, and (3dB-point) band-width @var{width}.
  990. The filter roll off at 6dB per octave (20dB per decade).
  991. The filter accepts the following options:
  992. @table @option
  993. @item frequency, f
  994. Set the filter's central frequency. Default is @code{3000}.
  995. @item width_type
  996. Set method to specify band-width of filter.
  997. @table @option
  998. @item h
  999. Hz
  1000. @item q
  1001. Q-Factor
  1002. @item o
  1003. octave
  1004. @item s
  1005. slope
  1006. @end table
  1007. @item width, w
  1008. Specify the band-width of a filter in width_type units.
  1009. @end table
  1010. @section bass
  1011. Boost or cut the bass (lower) frequencies of the audio using a two-pole
  1012. shelving filter with a response similar to that of a standard
  1013. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  1014. The filter accepts the following options:
  1015. @table @option
  1016. @item gain, g
  1017. Give the gain at 0 Hz. Its useful range is about -20
  1018. (for a large cut) to +20 (for a large boost).
  1019. Beware of clipping when using a positive gain.
  1020. @item frequency, f
  1021. Set the filter's central frequency and so can be used
  1022. to extend or reduce the frequency range to be boosted or cut.
  1023. The default value is @code{100} Hz.
  1024. @item width_type
  1025. Set method to specify band-width of filter.
  1026. @table @option
  1027. @item h
  1028. Hz
  1029. @item q
  1030. Q-Factor
  1031. @item o
  1032. octave
  1033. @item s
  1034. slope
  1035. @end table
  1036. @item width, w
  1037. Determine how steep is the filter's shelf transition.
  1038. @end table
  1039. @section biquad
  1040. Apply a biquad IIR filter with the given coefficients.
  1041. Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
  1042. are the numerator and denominator coefficients respectively.
  1043. @section bs2b
  1044. Bauer stereo to binaural transformation, which improves headphone listening of
  1045. stereo audio records.
  1046. It accepts the following parameters:
  1047. @table @option
  1048. @item profile
  1049. Pre-defined crossfeed level.
  1050. @table @option
  1051. @item default
  1052. Default level (fcut=700, feed=50).
  1053. @item cmoy
  1054. Chu Moy circuit (fcut=700, feed=60).
  1055. @item jmeier
  1056. Jan Meier circuit (fcut=650, feed=95).
  1057. @end table
  1058. @item fcut
  1059. Cut frequency (in Hz).
  1060. @item feed
  1061. Feed level (in Hz).
  1062. @end table
  1063. @section channelmap
  1064. Remap input channels to new locations.
  1065. It accepts the following parameters:
  1066. @table @option
  1067. @item channel_layout
  1068. The channel layout of the output stream.
  1069. @item map
  1070. Map channels from input to output. The argument is a '|'-separated list of
  1071. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  1072. @var{in_channel} form. @var{in_channel} can be either the name of the input
  1073. channel (e.g. FL for front left) or its index in the input channel layout.
  1074. @var{out_channel} is the name of the output channel or its index in the output
  1075. channel layout. If @var{out_channel} is not given then it is implicitly an
  1076. index, starting with zero and increasing by one for each mapping.
  1077. @end table
  1078. If no mapping is present, the filter will implicitly map input channels to
  1079. output channels, preserving indices.
  1080. For example, assuming a 5.1+downmix input MOV file,
  1081. @example
  1082. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
  1083. @end example
  1084. will create an output WAV file tagged as stereo from the downmix channels of
  1085. the input.
  1086. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  1087. @example
  1088. ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:5.1' out.wav
  1089. @end example
  1090. @section channelsplit
  1091. Split each channel from an input audio stream into a separate output stream.
  1092. It accepts the following parameters:
  1093. @table @option
  1094. @item channel_layout
  1095. The channel layout of the input stream. The default is "stereo".
  1096. @end table
  1097. For example, assuming a stereo input MP3 file,
  1098. @example
  1099. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  1100. @end example
  1101. will create an output Matroska file with two audio streams, one containing only
  1102. the left channel and the other the right channel.
  1103. Split a 5.1 WAV file into per-channel files:
  1104. @example
  1105. ffmpeg -i in.wav -filter_complex
  1106. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  1107. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  1108. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  1109. side_right.wav
  1110. @end example
  1111. @section chorus
  1112. Add a chorus effect to the audio.
  1113. Can make a single vocal sound like a chorus, but can also be applied to instrumentation.
  1114. Chorus resembles an echo effect with a short delay, but whereas with echo the delay is
  1115. constant, with chorus, it is varied using using sinusoidal or triangular modulation.
  1116. The modulation depth defines the range the modulated delay is played before or after
  1117. the delay. Hence the delayed sound will sound slower or faster, that is the delayed
  1118. sound tuned around the original one, like in a chorus where some vocals are slightly
  1119. off key.
  1120. It accepts the following parameters:
  1121. @table @option
  1122. @item in_gain
  1123. Set input gain. Default is 0.4.
  1124. @item out_gain
  1125. Set output gain. Default is 0.4.
  1126. @item delays
  1127. Set delays. A typical delay is around 40ms to 60ms.
  1128. @item decays
  1129. Set decays.
  1130. @item speeds
  1131. Set speeds.
  1132. @item depths
  1133. Set depths.
  1134. @end table
  1135. @subsection Examples
  1136. @itemize
  1137. @item
  1138. A single delay:
  1139. @example
  1140. chorus=0.7:0.9:55:0.4:0.25:2
  1141. @end example
  1142. @item
  1143. Two delays:
  1144. @example
  1145. chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3
  1146. @end example
  1147. @item
  1148. Fuller sounding chorus with three delays:
  1149. @example
  1150. chorus=0.5:0.9:50|60|40:0.4|0.32|0.3:0.25|0.4|0.3:2|2.3|1.3
  1151. @end example
  1152. @end itemize
  1153. @section compand
  1154. Compress or expand the audio's dynamic range.
  1155. It accepts the following parameters:
  1156. @table @option
  1157. @item attacks
  1158. @item decays
  1159. A list of times in seconds for each channel over which the instantaneous level
  1160. of the input signal is averaged to determine its volume. @var{attacks} refers to
  1161. increase of volume and @var{decays} refers to decrease of volume. For most
  1162. situations, the attack time (response to the audio getting louder) should be
  1163. shorter than the decay time, because the human ear is more sensitive to sudden
  1164. loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
  1165. a typical value for decay is 0.8 seconds.
  1166. If specified number of attacks & decays is lower than number of channels, the last
  1167. set attack/decay will be used for all remaining channels.
  1168. @item points
  1169. A list of points for the transfer function, specified in dB relative to the
  1170. maximum possible signal amplitude. Each key points list must be defined using
  1171. the following syntax: @code{x0/y0|x1/y1|x2/y2|....} or
  1172. @code{x0/y0 x1/y1 x2/y2 ....}
  1173. The input values must be in strictly increasing order but the transfer function
  1174. does not have to be monotonically rising. The point @code{0/0} is assumed but
  1175. may be overridden (by @code{0/out-dBn}). Typical values for the transfer
  1176. function are @code{-70/-70|-60/-20}.
  1177. @item soft-knee
  1178. Set the curve radius in dB for all joints. It defaults to 0.01.
  1179. @item gain
  1180. Set the additional gain in dB to be applied at all points on the transfer
  1181. function. This allows for easy adjustment of the overall gain.
  1182. It defaults to 0.
  1183. @item volume
  1184. Set an initial volume, in dB, to be assumed for each channel when filtering
  1185. starts. This permits the user to supply a nominal level initially, so that, for
  1186. example, a very large gain is not applied to initial signal levels before the
  1187. companding has begun to operate. A typical value for audio which is initially
  1188. quiet is -90 dB. It defaults to 0.
  1189. @item delay
  1190. Set a delay, in seconds. The input audio is analyzed immediately, but audio is
  1191. delayed before being fed to the volume adjuster. Specifying a delay
  1192. approximately equal to the attack/decay times allows the filter to effectively
  1193. operate in predictive rather than reactive mode. It defaults to 0.
  1194. @end table
  1195. @subsection Examples
  1196. @itemize
  1197. @item
  1198. Make music with both quiet and loud passages suitable for listening to in a
  1199. noisy environment:
  1200. @example
  1201. compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
  1202. @end example
  1203. Another example for audio with whisper and explosion parts:
  1204. @example
  1205. compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0
  1206. @end example
  1207. @item
  1208. A noise gate for when the noise is at a lower level than the signal:
  1209. @example
  1210. compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
  1211. @end example
  1212. @item
  1213. Here is another noise gate, this time for when the noise is at a higher level
  1214. than the signal (making it, in some ways, similar to squelch):
  1215. @example
  1216. compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
  1217. @end example
  1218. @end itemize
  1219. @section dcshift
  1220. Apply a DC shift to the audio.
  1221. This can be useful to remove a DC offset (caused perhaps by a hardware problem
  1222. in the recording chain) from the audio. The effect of a DC offset is reduced
  1223. headroom and hence volume. The @ref{astats} filter can be used to determine if
  1224. a signal has a DC offset.
  1225. @table @option
  1226. @item shift
  1227. Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift
  1228. the audio.
  1229. @item limitergain
  1230. Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
  1231. used to prevent clipping.
  1232. @end table
  1233. @section dynaudnorm
  1234. Dynamic Audio Normalizer.
  1235. This filter applies a certain amount of gain to the input audio in order
  1236. to bring its peak magnitude to a target level (e.g. 0 dBFS). However, in
  1237. contrast to more "simple" normalization algorithms, the Dynamic Audio
  1238. Normalizer *dynamically* re-adjusts the gain factor to the input audio.
  1239. This allows for applying extra gain to the "quiet" sections of the audio
  1240. while avoiding distortions or clipping the "loud" sections. In other words:
  1241. The Dynamic Audio Normalizer will "even out" the volume of quiet and loud
  1242. sections, in the sense that the volume of each section is brought to the
  1243. same target level. Note, however, that the Dynamic Audio Normalizer achieves
  1244. this goal *without* applying "dynamic range compressing". It will retain 100%
  1245. of the dynamic range *within* each section of the audio file.
  1246. @table @option
  1247. @item f
  1248. Set the frame length in milliseconds. In range from 10 to 8000 milliseconds.
  1249. Default is 500 milliseconds.
  1250. The Dynamic Audio Normalizer processes the input audio in small chunks,
  1251. referred to as frames. This is required, because a peak magnitude has no
  1252. meaning for just a single sample value. Instead, we need to determine the
  1253. peak magnitude for a contiguous sequence of sample values. While a "standard"
  1254. normalizer would simply use the peak magnitude of the complete file, the
  1255. Dynamic Audio Normalizer determines the peak magnitude individually for each
  1256. frame. The length of a frame is specified in milliseconds. By default, the
  1257. Dynamic Audio Normalizer uses a frame length of 500 milliseconds, which has
  1258. been found to give good results with most files.
  1259. Note that the exact frame length, in number of samples, will be determined
  1260. automatically, based on the sampling rate of the individual input audio file.
  1261. @item g
  1262. Set the Gaussian filter window size. In range from 3 to 301, must be odd
  1263. number. Default is 31.
  1264. Probably the most important parameter of the Dynamic Audio Normalizer is the
  1265. @code{window size} of the Gaussian smoothing filter. The filter's window size
  1266. is specified in frames, centered around the current frame. For the sake of
  1267. simplicity, this must be an odd number. Consequently, the default value of 31
  1268. takes into account the current frame, as well as the 15 preceding frames and
  1269. the 15 subsequent frames. Using a larger window results in a stronger
  1270. smoothing effect and thus in less gain variation, i.e. slower gain
  1271. adaptation. Conversely, using a smaller window results in a weaker smoothing
  1272. effect and thus in more gain variation, i.e. faster gain adaptation.
  1273. In other words, the more you increase this value, the more the Dynamic Audio
  1274. Normalizer will behave like a "traditional" normalization filter. On the
  1275. contrary, the more you decrease this value, the more the Dynamic Audio
  1276. Normalizer will behave like a dynamic range compressor.
  1277. @item p
  1278. Set the target peak value. This specifies the highest permissible magnitude
  1279. level for the normalized audio input. This filter will try to approach the
  1280. target peak magnitude as closely as possible, but at the same time it also
  1281. makes sure that the normalized signal will never exceed the peak magnitude.
  1282. A frame's maximum local gain factor is imposed directly by the target peak
  1283. magnitude. The default value is 0.95 and thus leaves a headroom of 5%*.
  1284. It is not recommended to go above this value.
  1285. @item m
  1286. Set the maximum gain factor. In range from 1.0 to 100.0. Default is 10.0.
  1287. The Dynamic Audio Normalizer determines the maximum possible (local) gain
  1288. factor for each input frame, i.e. the maximum gain factor that does not
  1289. result in clipping or distortion. The maximum gain factor is determined by
  1290. the frame's highest magnitude sample. However, the Dynamic Audio Normalizer
  1291. additionally bounds the frame's maximum gain factor by a predetermined
  1292. (global) maximum gain factor. This is done in order to avoid excessive gain
  1293. factors in "silent" or almost silent frames. By default, the maximum gain
  1294. factor is 10.0, For most inputs the default value should be sufficient and
  1295. it usually is not recommended to increase this value. Though, for input
  1296. with an extremely low overall volume level, it may be necessary to allow even
  1297. higher gain factors. Note, however, that the Dynamic Audio Normalizer does
  1298. not simply apply a "hard" threshold (i.e. cut off values above the threshold).
  1299. Instead, a "sigmoid" threshold function will be applied. This way, the
  1300. gain factors will smoothly approach the threshold value, but never exceed that
  1301. value.
  1302. @item r
  1303. Set the target RMS. In range from 0.0 to 1.0. Default is 0.0 - disabled.
  1304. By default, the Dynamic Audio Normalizer performs "peak" normalization.
  1305. This means that the maximum local gain factor for each frame is defined
  1306. (only) by the frame's highest magnitude sample. This way, the samples can
  1307. be amplified as much as possible without exceeding the maximum signal
  1308. level, i.e. without clipping. Optionally, however, the Dynamic Audio
  1309. Normalizer can also take into account the frame's root mean square,
  1310. abbreviated RMS. In electrical engineering, the RMS is commonly used to
  1311. determine the power of a time-varying signal. It is therefore considered
  1312. that the RMS is a better approximation of the "perceived loudness" than
  1313. just looking at the signal's peak magnitude. Consequently, by adjusting all
  1314. frames to a constant RMS value, a uniform "perceived loudness" can be
  1315. established. If a target RMS value has been specified, a frame's local gain
  1316. factor is defined as the factor that would result in exactly that RMS value.
  1317. Note, however, that the maximum local gain factor is still restricted by the
  1318. frame's highest magnitude sample, in order to prevent clipping.
  1319. @item n
  1320. Enable channels coupling. By default is enabled.
  1321. By default, the Dynamic Audio Normalizer will amplify all channels by the same
  1322. amount. This means the same gain factor will be applied to all channels, i.e.
  1323. the maximum possible gain factor is determined by the "loudest" channel.
  1324. However, in some recordings, it may happen that the volume of the different
  1325. channels is uneven, e.g. one channel may be "quieter" than the other one(s).
  1326. In this case, this option can be used to disable the channel coupling. This way,
  1327. the gain factor will be determined independently for each channel, depending
  1328. only on the individual channel's highest magnitude sample. This allows for
  1329. harmonizing the volume of the different channels.
  1330. @item c
  1331. Enable DC bias correction. By default is disabled.
  1332. An audio signal (in the time domain) is a sequence of sample values.
  1333. In the Dynamic Audio Normalizer these sample values are represented in the
  1334. -1.0 to 1.0 range, regardless of the original input format. Normally, the
  1335. audio signal, or "waveform", should be centered around the zero point.
  1336. That means if we calculate the mean value of all samples in a file, or in a
  1337. single frame, then the result should be 0.0 or at least very close to that
  1338. value. If, however, there is a significant deviation of the mean value from
  1339. 0.0, in either positive or negative direction, this is referred to as a
  1340. DC bias or DC offset. Since a DC bias is clearly undesirable, the Dynamic
  1341. Audio Normalizer provides optional DC bias correction.
  1342. With DC bias correction enabled, the Dynamic Audio Normalizer will determine
  1343. the mean value, or "DC correction" offset, of each input frame and subtract
  1344. that value from all of the frame's sample values which ensures those samples
  1345. are centered around 0.0 again. Also, in order to avoid "gaps" at the frame
  1346. boundaries, the DC correction offset values will be interpolated smoothly
  1347. between neighbouring frames.
  1348. @item b
  1349. Enable alternative boundary mode. By default is disabled.
  1350. The Dynamic Audio Normalizer takes into account a certain neighbourhood
  1351. around each frame. This includes the preceding frames as well as the
  1352. subsequent frames. However, for the "boundary" frames, located at the very
  1353. beginning and at the very end of the audio file, not all neighbouring
  1354. frames are available. In particular, for the first few frames in the audio
  1355. file, the preceding frames are not known. And, similarly, for the last few
  1356. frames in the audio file, the subsequent frames are not known. Thus, the
  1357. question arises which gain factors should be assumed for the missing frames
  1358. in the "boundary" region. The Dynamic Audio Normalizer implements two modes
  1359. to deal with this situation. The default boundary mode assumes a gain factor
  1360. of exactly 1.0 for the missing frames, resulting in a smooth "fade in" and
  1361. "fade out" at the beginning and at the end of the input, respectively.
  1362. @item s
  1363. Set the compress factor. In range from 0.0 to 30.0. Default is 0.0.
  1364. By default, the Dynamic Audio Normalizer does not apply "traditional"
  1365. compression. This means that signal peaks will not be pruned and thus the
  1366. full dynamic range will be retained within each local neighbourhood. However,
  1367. in some cases it may be desirable to combine the Dynamic Audio Normalizer's
  1368. normalization algorithm with a more "traditional" compression.
  1369. For this purpose, the Dynamic Audio Normalizer provides an optional compression
  1370. (thresholding) function. If (and only if) the compression feature is enabled,
  1371. all input frames will be processed by a soft knee thresholding function prior
  1372. to the actual normalization process. Put simply, the thresholding function is
  1373. going to prune all samples whose magnitude exceeds a certain threshold value.
  1374. However, the Dynamic Audio Normalizer does not simply apply a fixed threshold
  1375. value. Instead, the threshold value will be adjusted for each individual
  1376. frame.
  1377. In general, smaller parameters result in stronger compression, and vice versa.
  1378. Values below 3.0 are not recommended, because audible distortion may appear.
  1379. @end table
  1380. @section earwax
  1381. Make audio easier to listen to on headphones.
  1382. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  1383. so that when listened to on headphones the stereo image is moved from
  1384. inside your head (standard for headphones) to outside and in front of
  1385. the listener (standard for speakers).
  1386. Ported from SoX.
  1387. @section equalizer
  1388. Apply a two-pole peaking equalisation (EQ) filter. With this
  1389. filter, the signal-level at and around a selected frequency can
  1390. be increased or decreased, whilst (unlike bandpass and bandreject
  1391. filters) that at all other frequencies is unchanged.
  1392. In order to produce complex equalisation curves, this filter can
  1393. be given several times, each with a different central frequency.
  1394. The filter accepts the following options:
  1395. @table @option
  1396. @item frequency, f
  1397. Set the filter's central frequency in Hz.
  1398. @item width_type
  1399. Set method to specify band-width of filter.
  1400. @table @option
  1401. @item h
  1402. Hz
  1403. @item q
  1404. Q-Factor
  1405. @item o
  1406. octave
  1407. @item s
  1408. slope
  1409. @end table
  1410. @item width, w
  1411. Specify the band-width of a filter in width_type units.
  1412. @item gain, g
  1413. Set the required gain or attenuation in dB.
  1414. Beware of clipping when using a positive gain.
  1415. @end table
  1416. @subsection Examples
  1417. @itemize
  1418. @item
  1419. Attenuate 10 dB at 1000 Hz, with a bandwidth of 200 Hz:
  1420. @example
  1421. equalizer=f=1000:width_type=h:width=200:g=-10
  1422. @end example
  1423. @item
  1424. Apply 2 dB gain at 1000 Hz with Q 1 and attenuate 5 dB at 100 Hz with Q 2:
  1425. @example
  1426. equalizer=f=1000:width_type=q:width=1:g=2,equalizer=f=100:width_type=q:width=2:g=-5
  1427. @end example
  1428. @end itemize
  1429. @section extrastereo
  1430. Linearly increases the difference between left and right channels which
  1431. adds some sort of "live" effect to playback.
  1432. The filter accepts the following option:
  1433. @table @option
  1434. @item m
  1435. Sets the difference coefficient (default: 2.5). 0.0 means mono sound
  1436. (average of both channels), with 1.0 sound will be unchanged, with
  1437. -1.0 left and right channels will be swapped.
  1438. @item c
  1439. Enable clipping. By default is enabled.
  1440. @end table
  1441. @section flanger
  1442. Apply a flanging effect to the audio.
  1443. The filter accepts the following options:
  1444. @table @option
  1445. @item delay
  1446. Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
  1447. @item depth
  1448. Set added swep delay in milliseconds. Range from 0 to 10. Default value is 2.
  1449. @item regen
  1450. Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
  1451. Default value is 0.
  1452. @item width
  1453. Set percentage of delayed signal mixed with original. Range from 0 to 100.
  1454. Default value is 71.
  1455. @item speed
  1456. Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
  1457. @item shape
  1458. Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
  1459. Default value is @var{sinusoidal}.
  1460. @item phase
  1461. Set swept wave percentage-shift for multi channel. Range from 0 to 100.
  1462. Default value is 25.
  1463. @item interp
  1464. Set delay-line interpolation, @var{linear} or @var{quadratic}.
  1465. Default is @var{linear}.
  1466. @end table
  1467. @section highpass
  1468. Apply a high-pass filter with 3dB point frequency.
  1469. The filter can be either single-pole, or double-pole (the default).
  1470. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1471. The filter accepts the following options:
  1472. @table @option
  1473. @item frequency, f
  1474. Set frequency in Hz. Default is 3000.
  1475. @item poles, p
  1476. Set number of poles. Default is 2.
  1477. @item width_type
  1478. Set method to specify band-width of filter.
  1479. @table @option
  1480. @item h
  1481. Hz
  1482. @item q
  1483. Q-Factor
  1484. @item o
  1485. octave
  1486. @item s
  1487. slope
  1488. @end table
  1489. @item width, w
  1490. Specify the band-width of a filter in width_type units.
  1491. Applies only to double-pole filter.
  1492. The default is 0.707q and gives a Butterworth response.
  1493. @end table
  1494. @section join
  1495. Join multiple input streams into one multi-channel stream.
  1496. It accepts the following parameters:
  1497. @table @option
  1498. @item inputs
  1499. The number of input streams. It defaults to 2.
  1500. @item channel_layout
  1501. The desired output channel layout. It defaults to stereo.
  1502. @item map
  1503. Map channels from inputs to output. The argument is a '|'-separated list of
  1504. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  1505. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  1506. can be either the name of the input channel (e.g. FL for front left) or its
  1507. index in the specified input stream. @var{out_channel} is the name of the output
  1508. channel.
  1509. @end table
  1510. The filter will attempt to guess the mappings when they are not specified
  1511. explicitly. It does so by first trying to find an unused matching input channel
  1512. and if that fails it picks the first unused input channel.
  1513. Join 3 inputs (with properly set channel layouts):
  1514. @example
  1515. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  1516. @end example
  1517. Build a 5.1 output from 6 single-channel streams:
  1518. @example
  1519. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  1520. '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'
  1521. out
  1522. @end example
  1523. @section ladspa
  1524. Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
  1525. To enable compilation of this filter you need to configure FFmpeg with
  1526. @code{--enable-ladspa}.
  1527. @table @option
  1528. @item file, f
  1529. Specifies the name of LADSPA plugin library to load. If the environment
  1530. variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
  1531. each one of the directories specified by the colon separated list in
  1532. @env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
  1533. this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
  1534. @file{/usr/lib/ladspa/}.
  1535. @item plugin, p
  1536. Specifies the plugin within the library. Some libraries contain only
  1537. one plugin, but others contain many of them. If this is not set filter
  1538. will list all available plugins within the specified library.
  1539. @item controls, c
  1540. Set the '|' separated list of controls which are zero or more floating point
  1541. values that determine the behavior of the loaded plugin (for example delay,
  1542. threshold or gain).
  1543. Controls need to be defined using the following syntax:
  1544. c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
  1545. @var{valuei} is the value set on the @var{i}-th control.
  1546. If @option{controls} is set to @code{help}, all available controls and
  1547. their valid ranges are printed.
  1548. @item sample_rate, s
  1549. Specify the sample rate, default to 44100. Only used if plugin have
  1550. zero inputs.
  1551. @item nb_samples, n
  1552. Set the number of samples per channel per each output frame, default
  1553. is 1024. Only used if plugin have zero inputs.
  1554. @item duration, d
  1555. Set the minimum duration of the sourced audio. See
  1556. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  1557. for the accepted syntax.
  1558. Note that the resulting duration may be greater than the specified duration,
  1559. as the generated audio is always cut at the end of a complete frame.
  1560. If not specified, or the expressed duration is negative, the audio is
  1561. supposed to be generated forever.
  1562. Only used if plugin have zero inputs.
  1563. @end table
  1564. @subsection Examples
  1565. @itemize
  1566. @item
  1567. List all available plugins within amp (LADSPA example plugin) library:
  1568. @example
  1569. ladspa=file=amp
  1570. @end example
  1571. @item
  1572. List all available controls and their valid ranges for @code{vcf_notch}
  1573. plugin from @code{VCF} library:
  1574. @example
  1575. ladspa=f=vcf:p=vcf_notch:c=help
  1576. @end example
  1577. @item
  1578. Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
  1579. plugin library:
  1580. @example
  1581. ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
  1582. @end example
  1583. @item
  1584. Add reverberation to the audio using TAP-plugins
  1585. (Tom's Audio Processing plugins):
  1586. @example
  1587. ladspa=file=tap_reverb:tap_reverb
  1588. @end example
  1589. @item
  1590. Generate white noise, with 0.2 amplitude:
  1591. @example
  1592. ladspa=file=cmt:noise_source_white:c=c0=.2
  1593. @end example
  1594. @item
  1595. Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
  1596. @code{C* Audio Plugin Suite} (CAPS) library:
  1597. @example
  1598. ladspa=file=caps:Click:c=c1=20'
  1599. @end example
  1600. @item
  1601. Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
  1602. @example
  1603. ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
  1604. @end example
  1605. @end itemize
  1606. @subsection Commands
  1607. This filter supports the following commands:
  1608. @table @option
  1609. @item cN
  1610. Modify the @var{N}-th control value.
  1611. If the specified value is not valid, it is ignored and prior one is kept.
  1612. @end table
  1613. @section lowpass
  1614. Apply a low-pass filter with 3dB point frequency.
  1615. The filter can be either single-pole or double-pole (the default).
  1616. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1617. The filter accepts the following options:
  1618. @table @option
  1619. @item frequency, f
  1620. Set frequency in Hz. Default is 500.
  1621. @item poles, p
  1622. Set number of poles. Default is 2.
  1623. @item width_type
  1624. Set method to specify band-width of filter.
  1625. @table @option
  1626. @item h
  1627. Hz
  1628. @item q
  1629. Q-Factor
  1630. @item o
  1631. octave
  1632. @item s
  1633. slope
  1634. @end table
  1635. @item width, w
  1636. Specify the band-width of a filter in width_type units.
  1637. Applies only to double-pole filter.
  1638. The default is 0.707q and gives a Butterworth response.
  1639. @end table
  1640. @anchor{pan}
  1641. @section pan
  1642. Mix channels with specific gain levels. The filter accepts the output
  1643. channel layout followed by a set of channels definitions.
  1644. This filter is also designed to efficiently remap the channels of an audio
  1645. stream.
  1646. The filter accepts parameters of the form:
  1647. "@var{l}|@var{outdef}|@var{outdef}|..."
  1648. @table @option
  1649. @item l
  1650. output channel layout or number of channels
  1651. @item outdef
  1652. output channel specification, of the form:
  1653. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  1654. @item out_name
  1655. output channel to define, either a channel name (FL, FR, etc.) or a channel
  1656. number (c0, c1, etc.)
  1657. @item gain
  1658. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  1659. @item in_name
  1660. input channel to use, see out_name for details; it is not possible to mix
  1661. named and numbered input channels
  1662. @end table
  1663. If the `=' in a channel specification is replaced by `<', then the gains for
  1664. that specification will be renormalized so that the total is 1, thus
  1665. avoiding clipping noise.
  1666. @subsection Mixing examples
  1667. For example, if you want to down-mix from stereo to mono, but with a bigger
  1668. factor for the left channel:
  1669. @example
  1670. pan=1c|c0=0.9*c0+0.1*c1
  1671. @end example
  1672. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  1673. 7-channels surround:
  1674. @example
  1675. pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  1676. @end example
  1677. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  1678. that should be preferred (see "-ac" option) unless you have very specific
  1679. needs.
  1680. @subsection Remapping examples
  1681. The channel remapping will be effective if, and only if:
  1682. @itemize
  1683. @item gain coefficients are zeroes or ones,
  1684. @item only one input per channel output,
  1685. @end itemize
  1686. If all these conditions are satisfied, the filter will notify the user ("Pure
  1687. channel mapping detected"), and use an optimized and lossless method to do the
  1688. remapping.
  1689. For example, if you have a 5.1 source and want a stereo audio stream by
  1690. dropping the extra channels:
  1691. @example
  1692. pan="stereo| c0=FL | c1=FR"
  1693. @end example
  1694. Given the same source, you can also switch front left and front right channels
  1695. and keep the input channel layout:
  1696. @example
  1697. pan="5.1| c0=c1 | c1=c0 | c2=c2 | c3=c3 | c4=c4 | c5=c5"
  1698. @end example
  1699. If the input is a stereo audio stream, you can mute the front left channel (and
  1700. still keep the stereo channel layout) with:
  1701. @example
  1702. pan="stereo|c1=c1"
  1703. @end example
  1704. Still with a stereo audio stream input, you can copy the right channel in both
  1705. front left and right:
  1706. @example
  1707. pan="stereo| c0=FR | c1=FR"
  1708. @end example
  1709. @section replaygain
  1710. ReplayGain scanner filter. This filter takes an audio stream as an input and
  1711. outputs it unchanged.
  1712. At end of filtering it displays @code{track_gain} and @code{track_peak}.
  1713. @section resample
  1714. Convert the audio sample format, sample rate and channel layout. It is
  1715. not meant to be used directly.
  1716. @section sidechaincompress
  1717. This filter acts like normal compressor but has the ability to compress
  1718. detected signal using second input signal.
  1719. It needs two input streams and returns one output stream.
  1720. First input stream will be processed depending on second stream signal.
  1721. The filtered signal then can be filtered with other filters in later stages of
  1722. processing. See @ref{pan} and @ref{amerge} filter.
  1723. The filter accepts the following options:
  1724. @table @option
  1725. @item threshold
  1726. If a signal of second stream raises above this level it will affect the gain
  1727. reduction of first stream.
  1728. By default is 0.125. Range is between 0.00097563 and 1.
  1729. @item ratio
  1730. Set a ratio about which the signal is reduced. 1:2 means that if the level
  1731. raised 4dB above the threshold, it will be only 2dB above after the reduction.
  1732. Default is 2. Range is between 1 and 20.
  1733. @item attack
  1734. Amount of milliseconds the signal has to rise above the threshold before gain
  1735. reduction starts. Default is 20. Range is between 0.01 and 2000.
  1736. @item release
  1737. Amount of milliseconds the signal has to fall bellow the threshold before
  1738. reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
  1739. @item makeup
  1740. Set the amount by how much signal will be amplified after processing.
  1741. Default is 2. Range is from 1 and 64.
  1742. @item knee
  1743. Curve the sharp knee around the threshold to enter gain reduction more softly.
  1744. Default is 2.82843. Range is between 1 and 8.
  1745. @item link
  1746. Choose if the @code{average} level between all channels of side-chain stream
  1747. or the louder(@code{maximum}) channel of side-chain stream affects the
  1748. reduction. Default is @code{average}.
  1749. @item detection
  1750. Should the exact signal be taken in case of @code{peak} or an RMS one in case
  1751. of @code{rms}. Default is @code{rms} which is mainly smoother.
  1752. @end table
  1753. @subsection Examples
  1754. @itemize
  1755. @item
  1756. Full ffmpeg example taking 2 audio inputs, 1st input to be compressed
  1757. depending on the signal of 2nd input and later compressed signal to be
  1758. merged with 2nd input:
  1759. @example
  1760. ffmpeg -i main.flac -i sidechain.flac -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge"
  1761. @end example
  1762. @end itemize
  1763. @section silencedetect
  1764. Detect silence in an audio stream.
  1765. This filter logs a message when it detects that the input audio volume is less
  1766. or equal to a noise tolerance value for a duration greater or equal to the
  1767. minimum detected noise duration.
  1768. The printed times and duration are expressed in seconds.
  1769. The filter accepts the following options:
  1770. @table @option
  1771. @item duration, d
  1772. Set silence duration until notification (default is 2 seconds).
  1773. @item noise, n
  1774. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  1775. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  1776. @end table
  1777. @subsection Examples
  1778. @itemize
  1779. @item
  1780. Detect 5 seconds of silence with -50dB noise tolerance:
  1781. @example
  1782. silencedetect=n=-50dB:d=5
  1783. @end example
  1784. @item
  1785. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  1786. tolerance in @file{silence.mp3}:
  1787. @example
  1788. ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
  1789. @end example
  1790. @end itemize
  1791. @section silenceremove
  1792. Remove silence from the beginning, middle or end of the audio.
  1793. The filter accepts the following options:
  1794. @table @option
  1795. @item start_periods
  1796. This value is used to indicate if audio should be trimmed at beginning of
  1797. the audio. A value of zero indicates no silence should be trimmed from the
  1798. beginning. When specifying a non-zero value, it trims audio up until it
  1799. finds non-silence. Normally, when trimming silence from beginning of audio
  1800. the @var{start_periods} will be @code{1} but it can be increased to higher
  1801. values to trim all audio up to specific count of non-silence periods.
  1802. Default value is @code{0}.
  1803. @item start_duration
  1804. Specify the amount of time that non-silence must be detected before it stops
  1805. trimming audio. By increasing the duration, bursts of noises can be treated
  1806. as silence and trimmed off. Default value is @code{0}.
  1807. @item start_threshold
  1808. This indicates what sample value should be treated as silence. For digital
  1809. audio, a value of @code{0} may be fine but for audio recorded from analog,
  1810. you may wish to increase the value to account for background noise.
  1811. Can be specified in dB (in case "dB" is appended to the specified value)
  1812. or amplitude ratio. Default value is @code{0}.
  1813. @item stop_periods
  1814. Set the count for trimming silence from the end of audio.
  1815. To remove silence from the middle of a file, specify a @var{stop_periods}
  1816. that is negative. This value is then treated as a positive value and is
  1817. used to indicate the effect should restart processing as specified by
  1818. @var{start_periods}, making it suitable for removing periods of silence
  1819. in the middle of the audio.
  1820. Default value is @code{0}.
  1821. @item stop_duration
  1822. Specify a duration of silence that must exist before audio is not copied any
  1823. more. By specifying a higher duration, silence that is wanted can be left in
  1824. the audio.
  1825. Default value is @code{0}.
  1826. @item stop_threshold
  1827. This is the same as @option{start_threshold} but for trimming silence from
  1828. the end of audio.
  1829. Can be specified in dB (in case "dB" is appended to the specified value)
  1830. or amplitude ratio. Default value is @code{0}.
  1831. @item leave_silence
  1832. This indicate that @var{stop_duration} length of audio should be left intact
  1833. at the beginning of each period of silence.
  1834. For example, if you want to remove long pauses between words but do not want
  1835. to remove the pauses completely. Default value is @code{0}.
  1836. @end table
  1837. @subsection Examples
  1838. @itemize
  1839. @item
  1840. The following example shows how this filter can be used to start a recording
  1841. that does not contain the delay at the start which usually occurs between
  1842. pressing the record button and the start of the performance:
  1843. @example
  1844. silenceremove=1:5:0.02
  1845. @end example
  1846. @end itemize
  1847. @section treble
  1848. Boost or cut treble (upper) frequencies of the audio using a two-pole
  1849. shelving filter with a response similar to that of a standard
  1850. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  1851. The filter accepts the following options:
  1852. @table @option
  1853. @item gain, g
  1854. Give the gain at whichever is the lower of ~22 kHz and the
  1855. Nyquist frequency. Its useful range is about -20 (for a large cut)
  1856. to +20 (for a large boost). Beware of clipping when using a positive gain.
  1857. @item frequency, f
  1858. Set the filter's central frequency and so can be used
  1859. to extend or reduce the frequency range to be boosted or cut.
  1860. The default value is @code{3000} Hz.
  1861. @item width_type
  1862. Set method to specify band-width of filter.
  1863. @table @option
  1864. @item h
  1865. Hz
  1866. @item q
  1867. Q-Factor
  1868. @item o
  1869. octave
  1870. @item s
  1871. slope
  1872. @end table
  1873. @item width, w
  1874. Determine how steep is the filter's shelf transition.
  1875. @end table
  1876. @section volume
  1877. Adjust the input audio volume.
  1878. It accepts the following parameters:
  1879. @table @option
  1880. @item volume
  1881. Set audio volume expression.
  1882. Output values are clipped to the maximum value.
  1883. The output audio volume is given by the relation:
  1884. @example
  1885. @var{output_volume} = @var{volume} * @var{input_volume}
  1886. @end example
  1887. The default value for @var{volume} is "1.0".
  1888. @item precision
  1889. This parameter represents the mathematical precision.
  1890. It determines which input sample formats will be allowed, which affects the
  1891. precision of the volume scaling.
  1892. @table @option
  1893. @item fixed
  1894. 8-bit fixed-point; this limits input sample format to U8, S16, and S32.
  1895. @item float
  1896. 32-bit floating-point; this limits input sample format to FLT. (default)
  1897. @item double
  1898. 64-bit floating-point; this limits input sample format to DBL.
  1899. @end table
  1900. @item replaygain
  1901. Choose the behaviour on encountering ReplayGain side data in input frames.
  1902. @table @option
  1903. @item drop
  1904. Remove ReplayGain side data, ignoring its contents (the default).
  1905. @item ignore
  1906. Ignore ReplayGain side data, but leave it in the frame.
  1907. @item track
  1908. Prefer the track gain, if present.
  1909. @item album
  1910. Prefer the album gain, if present.
  1911. @end table
  1912. @item replaygain_preamp
  1913. Pre-amplification gain in dB to apply to the selected replaygain gain.
  1914. Default value for @var{replaygain_preamp} is 0.0.
  1915. @item eval
  1916. Set when the volume expression is evaluated.
  1917. It accepts the following values:
  1918. @table @samp
  1919. @item once
  1920. only evaluate expression once during the filter initialization, or
  1921. when the @samp{volume} command is sent
  1922. @item frame
  1923. evaluate expression for each incoming frame
  1924. @end table
  1925. Default value is @samp{once}.
  1926. @end table
  1927. The volume expression can contain the following parameters.
  1928. @table @option
  1929. @item n
  1930. frame number (starting at zero)
  1931. @item nb_channels
  1932. number of channels
  1933. @item nb_consumed_samples
  1934. number of samples consumed by the filter
  1935. @item nb_samples
  1936. number of samples in the current frame
  1937. @item pos
  1938. original frame position in the file
  1939. @item pts
  1940. frame PTS
  1941. @item sample_rate
  1942. sample rate
  1943. @item startpts
  1944. PTS at start of stream
  1945. @item startt
  1946. time at start of stream
  1947. @item t
  1948. frame time
  1949. @item tb
  1950. timestamp timebase
  1951. @item volume
  1952. last set volume value
  1953. @end table
  1954. Note that when @option{eval} is set to @samp{once} only the
  1955. @var{sample_rate} and @var{tb} variables are available, all other
  1956. variables will evaluate to NAN.
  1957. @subsection Commands
  1958. This filter supports the following commands:
  1959. @table @option
  1960. @item volume
  1961. Modify the volume expression.
  1962. The command accepts the same syntax of the corresponding option.
  1963. If the specified expression is not valid, it is kept at its current
  1964. value.
  1965. @item replaygain_noclip
  1966. Prevent clipping by limiting the gain applied.
  1967. Default value for @var{replaygain_noclip} is 1.
  1968. @end table
  1969. @subsection Examples
  1970. @itemize
  1971. @item
  1972. Halve the input audio volume:
  1973. @example
  1974. volume=volume=0.5
  1975. volume=volume=1/2
  1976. volume=volume=-6.0206dB
  1977. @end example
  1978. In all the above example the named key for @option{volume} can be
  1979. omitted, for example like in:
  1980. @example
  1981. volume=0.5
  1982. @end example
  1983. @item
  1984. Increase input audio power by 6 decibels using fixed-point precision:
  1985. @example
  1986. volume=volume=6dB:precision=fixed
  1987. @end example
  1988. @item
  1989. Fade volume after time 10 with an annihilation period of 5 seconds:
  1990. @example
  1991. volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
  1992. @end example
  1993. @end itemize
  1994. @section volumedetect
  1995. Detect the volume of the input video.
  1996. The filter has no parameters. The input is not modified. Statistics about
  1997. the volume will be printed in the log when the input stream end is reached.
  1998. In particular it will show the mean volume (root mean square), maximum
  1999. volume (on a per-sample basis), and the beginning of a histogram of the
  2000. registered volume values (from the maximum value to a cumulated 1/1000 of
  2001. the samples).
  2002. All volumes are in decibels relative to the maximum PCM value.
  2003. @subsection Examples
  2004. Here is an excerpt of the output:
  2005. @example
  2006. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  2007. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  2008. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  2009. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  2010. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  2011. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  2012. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  2013. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  2014. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  2015. @end example
  2016. It means that:
  2017. @itemize
  2018. @item
  2019. The mean square energy is approximately -27 dB, or 10^-2.7.
  2020. @item
  2021. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  2022. @item
  2023. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  2024. @end itemize
  2025. In other words, raising the volume by +4 dB does not cause any clipping,
  2026. raising it by +5 dB causes clipping for 6 samples, etc.
  2027. @c man end AUDIO FILTERS
  2028. @chapter Audio Sources
  2029. @c man begin AUDIO SOURCES
  2030. Below is a description of the currently available audio sources.
  2031. @section abuffer
  2032. Buffer audio frames, and make them available to the filter chain.
  2033. This source is mainly intended for a programmatic use, in particular
  2034. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  2035. It accepts the following parameters:
  2036. @table @option
  2037. @item time_base
  2038. The timebase which will be used for timestamps of submitted frames. It must be
  2039. either a floating-point number or in @var{numerator}/@var{denominator} form.
  2040. @item sample_rate
  2041. The sample rate of the incoming audio buffers.
  2042. @item sample_fmt
  2043. The sample format of the incoming audio buffers.
  2044. Either a sample format name or its corresponding integer representation from
  2045. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  2046. @item channel_layout
  2047. The channel layout of the incoming audio buffers.
  2048. Either a channel layout name from channel_layout_map in
  2049. @file{libavutil/channel_layout.c} or its corresponding integer representation
  2050. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  2051. @item channels
  2052. The number of channels of the incoming audio buffers.
  2053. If both @var{channels} and @var{channel_layout} are specified, then they
  2054. must be consistent.
  2055. @end table
  2056. @subsection Examples
  2057. @example
  2058. abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
  2059. @end example
  2060. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  2061. Since the sample format with name "s16p" corresponds to the number
  2062. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  2063. equivalent to:
  2064. @example
  2065. abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
  2066. @end example
  2067. @section aevalsrc
  2068. Generate an audio signal specified by an expression.
  2069. This source accepts in input one or more expressions (one for each
  2070. channel), which are evaluated and used to generate a corresponding
  2071. audio signal.
  2072. This source accepts the following options:
  2073. @table @option
  2074. @item exprs
  2075. Set the '|'-separated expressions list for each separate channel. In case the
  2076. @option{channel_layout} option is not specified, the selected channel layout
  2077. depends on the number of provided expressions. Otherwise the last
  2078. specified expression is applied to the remaining output channels.
  2079. @item channel_layout, c
  2080. Set the channel layout. The number of channels in the specified layout
  2081. must be equal to the number of specified expressions.
  2082. @item duration, d
  2083. Set the minimum duration of the sourced audio. See
  2084. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  2085. for the accepted syntax.
  2086. Note that the resulting duration may be greater than the specified
  2087. duration, as the generated audio is always cut at the end of a
  2088. complete frame.
  2089. If not specified, or the expressed duration is negative, the audio is
  2090. supposed to be generated forever.
  2091. @item nb_samples, n
  2092. Set the number of samples per channel per each output frame,
  2093. default to 1024.
  2094. @item sample_rate, s
  2095. Specify the sample rate, default to 44100.
  2096. @end table
  2097. Each expression in @var{exprs} can contain the following constants:
  2098. @table @option
  2099. @item n
  2100. number of the evaluated sample, starting from 0
  2101. @item t
  2102. time of the evaluated sample expressed in seconds, starting from 0
  2103. @item s
  2104. sample rate
  2105. @end table
  2106. @subsection Examples
  2107. @itemize
  2108. @item
  2109. Generate silence:
  2110. @example
  2111. aevalsrc=0
  2112. @end example
  2113. @item
  2114. Generate a sin signal with frequency of 440 Hz, set sample rate to
  2115. 8000 Hz:
  2116. @example
  2117. aevalsrc="sin(440*2*PI*t):s=8000"
  2118. @end example
  2119. @item
  2120. Generate a two channels signal, specify the channel layout (Front
  2121. Center + Back Center) explicitly:
  2122. @example
  2123. aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
  2124. @end example
  2125. @item
  2126. Generate white noise:
  2127. @example
  2128. aevalsrc="-2+random(0)"
  2129. @end example
  2130. @item
  2131. Generate an amplitude modulated signal:
  2132. @example
  2133. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  2134. @end example
  2135. @item
  2136. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  2137. @example
  2138. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
  2139. @end example
  2140. @end itemize
  2141. @section anullsrc
  2142. The null audio source, return unprocessed audio frames. It is mainly useful
  2143. as a template and to be employed in analysis / debugging tools, or as
  2144. the source for filters which ignore the input data (for example the sox
  2145. synth filter).
  2146. This source accepts the following options:
  2147. @table @option
  2148. @item channel_layout, cl
  2149. Specifies the channel layout, and can be either an integer or a string
  2150. representing a channel layout. The default value of @var{channel_layout}
  2151. is "stereo".
  2152. Check the channel_layout_map definition in
  2153. @file{libavutil/channel_layout.c} for the mapping between strings and
  2154. channel layout values.
  2155. @item sample_rate, r
  2156. Specifies the sample rate, and defaults to 44100.
  2157. @item nb_samples, n
  2158. Set the number of samples per requested frames.
  2159. @end table
  2160. @subsection Examples
  2161. @itemize
  2162. @item
  2163. Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  2164. @example
  2165. anullsrc=r=48000:cl=4
  2166. @end example
  2167. @item
  2168. Do the same operation with a more obvious syntax:
  2169. @example
  2170. anullsrc=r=48000:cl=mono
  2171. @end example
  2172. @end itemize
  2173. All the parameters need to be explicitly defined.
  2174. @section flite
  2175. Synthesize a voice utterance using the libflite library.
  2176. To enable compilation of this filter you need to configure FFmpeg with
  2177. @code{--enable-libflite}.
  2178. Note that the flite library is not thread-safe.
  2179. The filter accepts the following options:
  2180. @table @option
  2181. @item list_voices
  2182. If set to 1, list the names of the available voices and exit
  2183. immediately. Default value is 0.
  2184. @item nb_samples, n
  2185. Set the maximum number of samples per frame. Default value is 512.
  2186. @item textfile
  2187. Set the filename containing the text to speak.
  2188. @item text
  2189. Set the text to speak.
  2190. @item voice, v
  2191. Set the voice to use for the speech synthesis. Default value is
  2192. @code{kal}. See also the @var{list_voices} option.
  2193. @end table
  2194. @subsection Examples
  2195. @itemize
  2196. @item
  2197. Read from file @file{speech.txt}, and synthesize the text using the
  2198. standard flite voice:
  2199. @example
  2200. flite=textfile=speech.txt
  2201. @end example
  2202. @item
  2203. Read the specified text selecting the @code{slt} voice:
  2204. @example
  2205. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2206. @end example
  2207. @item
  2208. Input text to ffmpeg:
  2209. @example
  2210. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2211. @end example
  2212. @item
  2213. Make @file{ffplay} speak the specified text, using @code{flite} and
  2214. the @code{lavfi} device:
  2215. @example
  2216. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  2217. @end example
  2218. @end itemize
  2219. For more information about libflite, check:
  2220. @url{http://www.speech.cs.cmu.edu/flite/}
  2221. @section sine
  2222. Generate an audio signal made of a sine wave with amplitude 1/8.
  2223. The audio signal is bit-exact.
  2224. The filter accepts the following options:
  2225. @table @option
  2226. @item frequency, f
  2227. Set the carrier frequency. Default is 440 Hz.
  2228. @item beep_factor, b
  2229. Enable a periodic beep every second with frequency @var{beep_factor} times
  2230. the carrier frequency. Default is 0, meaning the beep is disabled.
  2231. @item sample_rate, r
  2232. Specify the sample rate, default is 44100.
  2233. @item duration, d
  2234. Specify the duration of the generated audio stream.
  2235. @item samples_per_frame
  2236. Set the number of samples per output frame.
  2237. The expression can contain the following constants:
  2238. @table @option
  2239. @item n
  2240. The (sequential) number of the output audio frame, starting from 0.
  2241. @item pts
  2242. The PTS (Presentation TimeStamp) of the output audio frame,
  2243. expressed in @var{TB} units.
  2244. @item t
  2245. The PTS of the output audio frame, expressed in seconds.
  2246. @item TB
  2247. The timebase of the output audio frames.
  2248. @end table
  2249. Default is @code{1024}.
  2250. @end table
  2251. @subsection Examples
  2252. @itemize
  2253. @item
  2254. Generate a simple 440 Hz sine wave:
  2255. @example
  2256. sine
  2257. @end example
  2258. @item
  2259. Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
  2260. @example
  2261. sine=220:4:d=5
  2262. sine=f=220:b=4:d=5
  2263. sine=frequency=220:beep_factor=4:duration=5
  2264. @end example
  2265. @item
  2266. Generate a 1 kHz sine wave following @code{1602,1601,1602,1601,1602} NTSC
  2267. pattern:
  2268. @example
  2269. sine=1000:samples_per_frame='st(0,mod(n,5)); 1602-not(not(eq(ld(0),1)+eq(ld(0),3)))'
  2270. @end example
  2271. @end itemize
  2272. @c man end AUDIO SOURCES
  2273. @chapter Audio Sinks
  2274. @c man begin AUDIO SINKS
  2275. Below is a description of the currently available audio sinks.
  2276. @section abuffersink
  2277. Buffer audio frames, and make them available to the end of filter chain.
  2278. This sink is mainly intended for programmatic use, in particular
  2279. through the interface defined in @file{libavfilter/buffersink.h}
  2280. or the options system.
  2281. It accepts a pointer to an AVABufferSinkContext structure, which
  2282. defines the incoming buffers' formats, to be passed as the opaque
  2283. parameter to @code{avfilter_init_filter} for initialization.
  2284. @section anullsink
  2285. Null audio sink; do absolutely nothing with the input audio. It is
  2286. mainly useful as a template and for use in analysis / debugging
  2287. tools.
  2288. @c man end AUDIO SINKS
  2289. @chapter Video Filters
  2290. @c man begin VIDEO FILTERS
  2291. When you configure your FFmpeg build, you can disable any of the
  2292. existing filters using @code{--disable-filters}.
  2293. The configure output will show the video filters included in your
  2294. build.
  2295. Below is a description of the currently available video filters.
  2296. @section alphaextract
  2297. Extract the alpha component from the input as a grayscale video. This
  2298. is especially useful with the @var{alphamerge} filter.
  2299. @section alphamerge
  2300. Add or replace the alpha component of the primary input with the
  2301. grayscale value of a second input. This is intended for use with
  2302. @var{alphaextract} to allow the transmission or storage of frame
  2303. sequences that have alpha in a format that doesn't support an alpha
  2304. channel.
  2305. For example, to reconstruct full frames from a normal YUV-encoded video
  2306. and a separate video created with @var{alphaextract}, you might use:
  2307. @example
  2308. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  2309. @end example
  2310. Since this filter is designed for reconstruction, it operates on frame
  2311. sequences without considering timestamps, and terminates when either
  2312. input reaches end of stream. This will cause problems if your encoding
  2313. pipeline drops frames. If you're trying to apply an image as an
  2314. overlay to a video stream, consider the @var{overlay} filter instead.
  2315. @section ass
  2316. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  2317. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  2318. Substation Alpha) subtitles files.
  2319. This filter accepts the following option in addition to the common options from
  2320. the @ref{subtitles} filter:
  2321. @table @option
  2322. @item shaping
  2323. Set the shaping engine
  2324. Available values are:
  2325. @table @samp
  2326. @item auto
  2327. The default libass shaping engine, which is the best available.
  2328. @item simple
  2329. Fast, font-agnostic shaper that can do only substitutions
  2330. @item complex
  2331. Slower shaper using OpenType for substitutions and positioning
  2332. @end table
  2333. The default is @code{auto}.
  2334. @end table
  2335. @section atadenoise
  2336. Apply an Adaptive Temporal Averaging Denoiser to the video input.
  2337. The filter accepts the following options:
  2338. @table @option
  2339. @item 0a
  2340. Set threshold A for 1st plane. Default is 0.02.
  2341. Valid range is 0 to 0.3.
  2342. @item 0b
  2343. Set threshold B for 1st plane. Default is 0.04.
  2344. Valid range is 0 to 5.
  2345. @item 1a
  2346. Set threshold A for 2nd plane. Default is 0.02.
  2347. Valid range is 0 to 0.3.
  2348. @item 1b
  2349. Set threshold B for 2nd plane. Default is 0.04.
  2350. Valid range is 0 to 5.
  2351. @item 2a
  2352. Set threshold A for 3rd plane. Default is 0.02.
  2353. Valid range is 0 to 0.3.
  2354. @item 2b
  2355. Set threshold B for 3rd plane. Default is 0.04.
  2356. Valid range is 0 to 5.
  2357. Threshold A is designed to react on abrupt changes in the input signal and
  2358. threshold B is designed to react on continuous changes in the input signal.
  2359. @item s
  2360. Set number of frames filter will use for averaging. Default is 33. Must be odd
  2361. number in range [5, 129].
  2362. @end table
  2363. @section bbox
  2364. Compute the bounding box for the non-black pixels in the input frame
  2365. luminance plane.
  2366. This filter computes the bounding box containing all the pixels with a
  2367. luminance value greater than the minimum allowed value.
  2368. The parameters describing the bounding box are printed on the filter
  2369. log.
  2370. The filter accepts the following option:
  2371. @table @option
  2372. @item min_val
  2373. Set the minimal luminance value. Default is @code{16}.
  2374. @end table
  2375. @section blackdetect
  2376. Detect video intervals that are (almost) completely black. Can be
  2377. useful to detect chapter transitions, commercials, or invalid
  2378. recordings. Output lines contains the time for the start, end and
  2379. duration of the detected black interval expressed in seconds.
  2380. In order to display the output lines, you need to set the loglevel at
  2381. least to the AV_LOG_INFO value.
  2382. The filter accepts the following options:
  2383. @table @option
  2384. @item black_min_duration, d
  2385. Set the minimum detected black duration expressed in seconds. It must
  2386. be a non-negative floating point number.
  2387. Default value is 2.0.
  2388. @item picture_black_ratio_th, pic_th
  2389. Set the threshold for considering a picture "black".
  2390. Express the minimum value for the ratio:
  2391. @example
  2392. @var{nb_black_pixels} / @var{nb_pixels}
  2393. @end example
  2394. for which a picture is considered black.
  2395. Default value is 0.98.
  2396. @item pixel_black_th, pix_th
  2397. Set the threshold for considering a pixel "black".
  2398. The threshold expresses the maximum pixel luminance value for which a
  2399. pixel is considered "black". The provided value is scaled according to
  2400. the following equation:
  2401. @example
  2402. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  2403. @end example
  2404. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  2405. the input video format, the range is [0-255] for YUV full-range
  2406. formats and [16-235] for YUV non full-range formats.
  2407. Default value is 0.10.
  2408. @end table
  2409. The following example sets the maximum pixel threshold to the minimum
  2410. value, and detects only black intervals of 2 or more seconds:
  2411. @example
  2412. blackdetect=d=2:pix_th=0.00
  2413. @end example
  2414. @section blackframe
  2415. Detect frames that are (almost) completely black. Can be useful to
  2416. detect chapter transitions or commercials. Output lines consist of
  2417. the frame number of the detected frame, the percentage of blackness,
  2418. the position in the file if known or -1 and the timestamp in seconds.
  2419. In order to display the output lines, you need to set the loglevel at
  2420. least to the AV_LOG_INFO value.
  2421. It accepts the following parameters:
  2422. @table @option
  2423. @item amount
  2424. The percentage of the pixels that have to be below the threshold; it defaults to
  2425. @code{98}.
  2426. @item threshold, thresh
  2427. The threshold below which a pixel value is considered black; it defaults to
  2428. @code{32}.
  2429. @end table
  2430. @section blend, tblend
  2431. Blend two video frames into each other.
  2432. The @code{blend} filter takes two input streams and outputs one
  2433. stream, the first input is the "top" layer and second input is
  2434. "bottom" layer. Output terminates when shortest input terminates.
  2435. The @code{tblend} (time blend) filter takes two consecutive frames
  2436. from one single stream, and outputs the result obtained by blending
  2437. the new frame on top of the old frame.
  2438. A description of the accepted options follows.
  2439. @table @option
  2440. @item c0_mode
  2441. @item c1_mode
  2442. @item c2_mode
  2443. @item c3_mode
  2444. @item all_mode
  2445. Set blend mode for specific pixel component or all pixel components in case
  2446. of @var{all_mode}. Default value is @code{normal}.
  2447. Available values for component modes are:
  2448. @table @samp
  2449. @item addition
  2450. @item and
  2451. @item average
  2452. @item burn
  2453. @item darken
  2454. @item difference
  2455. @item difference128
  2456. @item divide
  2457. @item dodge
  2458. @item exclusion
  2459. @item glow
  2460. @item hardlight
  2461. @item hardmix
  2462. @item lighten
  2463. @item linearlight
  2464. @item multiply
  2465. @item negation
  2466. @item normal
  2467. @item or
  2468. @item overlay
  2469. @item phoenix
  2470. @item pinlight
  2471. @item reflect
  2472. @item screen
  2473. @item softlight
  2474. @item subtract
  2475. @item vividlight
  2476. @item xor
  2477. @end table
  2478. @item c0_opacity
  2479. @item c1_opacity
  2480. @item c2_opacity
  2481. @item c3_opacity
  2482. @item all_opacity
  2483. Set blend opacity for specific pixel component or all pixel components in case
  2484. of @var{all_opacity}. Only used in combination with pixel component blend modes.
  2485. @item c0_expr
  2486. @item c1_expr
  2487. @item c2_expr
  2488. @item c3_expr
  2489. @item all_expr
  2490. Set blend expression for specific pixel component or all pixel components in case
  2491. of @var{all_expr}. Note that related mode options will be ignored if those are set.
  2492. The expressions can use the following variables:
  2493. @table @option
  2494. @item N
  2495. The sequential number of the filtered frame, starting from @code{0}.
  2496. @item X
  2497. @item Y
  2498. the coordinates of the current sample
  2499. @item W
  2500. @item H
  2501. the width and height of currently filtered plane
  2502. @item SW
  2503. @item SH
  2504. Width and height scale depending on the currently filtered plane. It is the
  2505. ratio between the corresponding luma plane number of pixels and the current
  2506. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  2507. @code{0.5,0.5} for chroma planes.
  2508. @item T
  2509. Time of the current frame, expressed in seconds.
  2510. @item TOP, A
  2511. Value of pixel component at current location for first video frame (top layer).
  2512. @item BOTTOM, B
  2513. Value of pixel component at current location for second video frame (bottom layer).
  2514. @end table
  2515. @item shortest
  2516. Force termination when the shortest input terminates. Default is
  2517. @code{0}. This option is only defined for the @code{blend} filter.
  2518. @item repeatlast
  2519. Continue applying the last bottom frame after the end of the stream. A value of
  2520. @code{0} disable the filter after the last frame of the bottom layer is reached.
  2521. Default is @code{1}. This option is only defined for the @code{blend} filter.
  2522. @end table
  2523. @subsection Examples
  2524. @itemize
  2525. @item
  2526. Apply transition from bottom layer to top layer in first 10 seconds:
  2527. @example
  2528. blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
  2529. @end example
  2530. @item
  2531. Apply 1x1 checkerboard effect:
  2532. @example
  2533. blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
  2534. @end example
  2535. @item
  2536. Apply uncover left effect:
  2537. @example
  2538. blend=all_expr='if(gte(N*SW+X,W),A,B)'
  2539. @end example
  2540. @item
  2541. Apply uncover down effect:
  2542. @example
  2543. blend=all_expr='if(gte(Y-N*SH,0),A,B)'
  2544. @end example
  2545. @item
  2546. Apply uncover up-left effect:
  2547. @example
  2548. blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
  2549. @end example
  2550. @item
  2551. Display differences between the current and the previous frame:
  2552. @example
  2553. tblend=all_mode=difference128
  2554. @end example
  2555. @end itemize
  2556. @section boxblur
  2557. Apply a boxblur algorithm to the input video.
  2558. It accepts the following parameters:
  2559. @table @option
  2560. @item luma_radius, lr
  2561. @item luma_power, lp
  2562. @item chroma_radius, cr
  2563. @item chroma_power, cp
  2564. @item alpha_radius, ar
  2565. @item alpha_power, ap
  2566. @end table
  2567. A description of the accepted options follows.
  2568. @table @option
  2569. @item luma_radius, lr
  2570. @item chroma_radius, cr
  2571. @item alpha_radius, ar
  2572. Set an expression for the box radius in pixels used for blurring the
  2573. corresponding input plane.
  2574. The radius value must be a non-negative number, and must not be
  2575. greater than the value of the expression @code{min(w,h)/2} for the
  2576. luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
  2577. planes.
  2578. Default value for @option{luma_radius} is "2". If not specified,
  2579. @option{chroma_radius} and @option{alpha_radius} default to the
  2580. corresponding value set for @option{luma_radius}.
  2581. The expressions can contain the following constants:
  2582. @table @option
  2583. @item w
  2584. @item h
  2585. The input width and height in pixels.
  2586. @item cw
  2587. @item ch
  2588. The input chroma image width and height in pixels.
  2589. @item hsub
  2590. @item vsub
  2591. The horizontal and vertical chroma subsample values. For example, for the
  2592. pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
  2593. @end table
  2594. @item luma_power, lp
  2595. @item chroma_power, cp
  2596. @item alpha_power, ap
  2597. Specify how many times the boxblur filter is applied to the
  2598. corresponding plane.
  2599. Default value for @option{luma_power} is 2. If not specified,
  2600. @option{chroma_power} and @option{alpha_power} default to the
  2601. corresponding value set for @option{luma_power}.
  2602. A value of 0 will disable the effect.
  2603. @end table
  2604. @subsection Examples
  2605. @itemize
  2606. @item
  2607. Apply a boxblur filter with the luma, chroma, and alpha radii
  2608. set to 2:
  2609. @example
  2610. boxblur=luma_radius=2:luma_power=1
  2611. boxblur=2:1
  2612. @end example
  2613. @item
  2614. Set the luma radius to 2, and alpha and chroma radius to 0:
  2615. @example
  2616. boxblur=2:1:cr=0:ar=0
  2617. @end example
  2618. @item
  2619. Set the luma and chroma radii to a fraction of the video dimension:
  2620. @example
  2621. boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
  2622. @end example
  2623. @end itemize
  2624. @section codecview
  2625. Visualize information exported by some codecs.
  2626. Some codecs can export information through frames using side-data or other
  2627. means. For example, some MPEG based codecs export motion vectors through the
  2628. @var{export_mvs} flag in the codec @option{flags2} option.
  2629. The filter accepts the following option:
  2630. @table @option
  2631. @item mv
  2632. Set motion vectors to visualize.
  2633. Available flags for @var{mv} are:
  2634. @table @samp
  2635. @item pf
  2636. forward predicted MVs of P-frames
  2637. @item bf
  2638. forward predicted MVs of B-frames
  2639. @item bb
  2640. backward predicted MVs of B-frames
  2641. @end table
  2642. @end table
  2643. @subsection Examples
  2644. @itemize
  2645. @item
  2646. Visualizes multi-directionals MVs from P and B-Frames using @command{ffplay}:
  2647. @example
  2648. ffplay -flags2 +export_mvs input.mpg -vf codecview=mv=pf+bf+bb
  2649. @end example
  2650. @end itemize
  2651. @section colorbalance
  2652. Modify intensity of primary colors (red, green and blue) of input frames.
  2653. The filter allows an input frame to be adjusted in the shadows, midtones or highlights
  2654. regions for the red-cyan, green-magenta or blue-yellow balance.
  2655. A positive adjustment value shifts the balance towards the primary color, a negative
  2656. value towards the complementary color.
  2657. The filter accepts the following options:
  2658. @table @option
  2659. @item rs
  2660. @item gs
  2661. @item bs
  2662. Adjust red, green and blue shadows (darkest pixels).
  2663. @item rm
  2664. @item gm
  2665. @item bm
  2666. Adjust red, green and blue midtones (medium pixels).
  2667. @item rh
  2668. @item gh
  2669. @item bh
  2670. Adjust red, green and blue highlights (brightest pixels).
  2671. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  2672. @end table
  2673. @subsection Examples
  2674. @itemize
  2675. @item
  2676. Add red color cast to shadows:
  2677. @example
  2678. colorbalance=rs=.3
  2679. @end example
  2680. @end itemize
  2681. @section colorkey
  2682. RGB colorspace color keying.
  2683. The filter accepts the following options:
  2684. @table @option
  2685. @item color
  2686. The color which will be replaced with transparency.
  2687. @item similarity
  2688. Similarity percentage with the key color.
  2689. 0.01 matches only the exact key color, while 1.0 matches everything.
  2690. @item blend
  2691. Blend percentage.
  2692. 0.0 makes pixels either fully transparent, or not transparent at all.
  2693. Higher values result in semi-transparent pixels, with a higher transparency
  2694. the more similar the pixels color is to the key color.
  2695. @end table
  2696. @subsection Examples
  2697. @itemize
  2698. @item
  2699. Make every green pixel in the input image transparent:
  2700. @example
  2701. ffmpeg -i input.png -vf colorkey=green out.png
  2702. @end example
  2703. @item
  2704. Overlay a greenscreen-video on top of a static background image.
  2705. @example
  2706. ffmpeg -i background.png -i video.mp4 -filter_complex "[1:v]colorkey=0x3BBD1E:0.3:0.2[ckout];[0:v][ckout]overlay[out]" -map "[out]" output.flv
  2707. @end example
  2708. @end itemize
  2709. @section colorlevels
  2710. Adjust video input frames using levels.
  2711. The filter accepts the following options:
  2712. @table @option
  2713. @item rimin
  2714. @item gimin
  2715. @item bimin
  2716. @item aimin
  2717. Adjust red, green, blue and alpha input black point.
  2718. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  2719. @item rimax
  2720. @item gimax
  2721. @item bimax
  2722. @item aimax
  2723. Adjust red, green, blue and alpha input white point.
  2724. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
  2725. Input levels are used to lighten highlights (bright tones), darken shadows
  2726. (dark tones), change the balance of bright and dark tones.
  2727. @item romin
  2728. @item gomin
  2729. @item bomin
  2730. @item aomin
  2731. Adjust red, green, blue and alpha output black point.
  2732. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
  2733. @item romax
  2734. @item gomax
  2735. @item bomax
  2736. @item aomax
  2737. Adjust red, green, blue and alpha output white point.
  2738. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
  2739. Output levels allows manual selection of a constrained output level range.
  2740. @end table
  2741. @subsection Examples
  2742. @itemize
  2743. @item
  2744. Make video output darker:
  2745. @example
  2746. colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
  2747. @end example
  2748. @item
  2749. Increase contrast:
  2750. @example
  2751. colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
  2752. @end example
  2753. @item
  2754. Make video output lighter:
  2755. @example
  2756. colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
  2757. @end example
  2758. @item
  2759. Increase brightness:
  2760. @example
  2761. colorlevels=romin=0.5:gomin=0.5:bomin=0.5
  2762. @end example
  2763. @end itemize
  2764. @section colorchannelmixer
  2765. Adjust video input frames by re-mixing color channels.
  2766. This filter modifies a color channel by adding the values associated to
  2767. the other channels of the same pixels. For example if the value to
  2768. modify is red, the output value will be:
  2769. @example
  2770. @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
  2771. @end example
  2772. The filter accepts the following options:
  2773. @table @option
  2774. @item rr
  2775. @item rg
  2776. @item rb
  2777. @item ra
  2778. Adjust contribution of input red, green, blue and alpha channels for output red channel.
  2779. Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
  2780. @item gr
  2781. @item gg
  2782. @item gb
  2783. @item ga
  2784. Adjust contribution of input red, green, blue and alpha channels for output green channel.
  2785. Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
  2786. @item br
  2787. @item bg
  2788. @item bb
  2789. @item ba
  2790. Adjust contribution of input red, green, blue and alpha channels for output blue channel.
  2791. Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
  2792. @item ar
  2793. @item ag
  2794. @item ab
  2795. @item aa
  2796. Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
  2797. Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
  2798. Allowed ranges for options are @code{[-2.0, 2.0]}.
  2799. @end table
  2800. @subsection Examples
  2801. @itemize
  2802. @item
  2803. Convert source to grayscale:
  2804. @example
  2805. colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
  2806. @end example
  2807. @item
  2808. Simulate sepia tones:
  2809. @example
  2810. colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
  2811. @end example
  2812. @end itemize
  2813. @section colormatrix
  2814. Convert color matrix.
  2815. The filter accepts the following options:
  2816. @table @option
  2817. @item src
  2818. @item dst
  2819. Specify the source and destination color matrix. Both values must be
  2820. specified.
  2821. The accepted values are:
  2822. @table @samp
  2823. @item bt709
  2824. BT.709
  2825. @item bt601
  2826. BT.601
  2827. @item smpte240m
  2828. SMPTE-240M
  2829. @item fcc
  2830. FCC
  2831. @end table
  2832. @end table
  2833. For example to convert from BT.601 to SMPTE-240M, use the command:
  2834. @example
  2835. colormatrix=bt601:smpte240m
  2836. @end example
  2837. @section copy
  2838. Copy the input source unchanged to the output. This is mainly useful for
  2839. testing purposes.
  2840. @section crop
  2841. Crop the input video to given dimensions.
  2842. It accepts the following parameters:
  2843. @table @option
  2844. @item w, out_w
  2845. The width of the output video. It defaults to @code{iw}.
  2846. This expression is evaluated only once during the filter
  2847. configuration, or when the @samp{w} or @samp{out_w} command is sent.
  2848. @item h, out_h
  2849. The height of the output video. It defaults to @code{ih}.
  2850. This expression is evaluated only once during the filter
  2851. configuration, or when the @samp{h} or @samp{out_h} command is sent.
  2852. @item x
  2853. The horizontal position, in the input video, of the left edge of the output
  2854. video. It defaults to @code{(in_w-out_w)/2}.
  2855. This expression is evaluated per-frame.
  2856. @item y
  2857. The vertical position, in the input video, of the top edge of the output video.
  2858. It defaults to @code{(in_h-out_h)/2}.
  2859. This expression is evaluated per-frame.
  2860. @item keep_aspect
  2861. If set to 1 will force the output display aspect ratio
  2862. to be the same of the input, by changing the output sample aspect
  2863. ratio. It defaults to 0.
  2864. @end table
  2865. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  2866. expressions containing the following constants:
  2867. @table @option
  2868. @item x
  2869. @item y
  2870. The computed values for @var{x} and @var{y}. They are evaluated for
  2871. each new frame.
  2872. @item in_w
  2873. @item in_h
  2874. The input width and height.
  2875. @item iw
  2876. @item ih
  2877. These are the same as @var{in_w} and @var{in_h}.
  2878. @item out_w
  2879. @item out_h
  2880. The output (cropped) width and height.
  2881. @item ow
  2882. @item oh
  2883. These are the same as @var{out_w} and @var{out_h}.
  2884. @item a
  2885. same as @var{iw} / @var{ih}
  2886. @item sar
  2887. input sample aspect ratio
  2888. @item dar
  2889. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2890. @item hsub
  2891. @item vsub
  2892. horizontal and vertical chroma subsample values. For example for the
  2893. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2894. @item n
  2895. The number of the input frame, starting from 0.
  2896. @item pos
  2897. the position in the file of the input frame, NAN if unknown
  2898. @item t
  2899. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  2900. @end table
  2901. The expression for @var{out_w} may depend on the value of @var{out_h},
  2902. and the expression for @var{out_h} may depend on @var{out_w}, but they
  2903. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  2904. evaluated after @var{out_w} and @var{out_h}.
  2905. The @var{x} and @var{y} parameters specify the expressions for the
  2906. position of the top-left corner of the output (non-cropped) area. They
  2907. are evaluated for each frame. If the evaluated value is not valid, it
  2908. is approximated to the nearest valid value.
  2909. The expression for @var{x} may depend on @var{y}, and the expression
  2910. for @var{y} may depend on @var{x}.
  2911. @subsection Examples
  2912. @itemize
  2913. @item
  2914. Crop area with size 100x100 at position (12,34).
  2915. @example
  2916. crop=100:100:12:34
  2917. @end example
  2918. Using named options, the example above becomes:
  2919. @example
  2920. crop=w=100:h=100:x=12:y=34
  2921. @end example
  2922. @item
  2923. Crop the central input area with size 100x100:
  2924. @example
  2925. crop=100:100
  2926. @end example
  2927. @item
  2928. Crop the central input area with size 2/3 of the input video:
  2929. @example
  2930. crop=2/3*in_w:2/3*in_h
  2931. @end example
  2932. @item
  2933. Crop the input video central square:
  2934. @example
  2935. crop=out_w=in_h
  2936. crop=in_h
  2937. @end example
  2938. @item
  2939. Delimit the rectangle with the top-left corner placed at position
  2940. 100:100 and the right-bottom corner corresponding to the right-bottom
  2941. corner of the input image.
  2942. @example
  2943. crop=in_w-100:in_h-100:100:100
  2944. @end example
  2945. @item
  2946. Crop 10 pixels from the left and right borders, and 20 pixels from
  2947. the top and bottom borders
  2948. @example
  2949. crop=in_w-2*10:in_h-2*20
  2950. @end example
  2951. @item
  2952. Keep only the bottom right quarter of the input image:
  2953. @example
  2954. crop=in_w/2:in_h/2:in_w/2:in_h/2
  2955. @end example
  2956. @item
  2957. Crop height for getting Greek harmony:
  2958. @example
  2959. crop=in_w:1/PHI*in_w
  2960. @end example
  2961. @item
  2962. Apply trembling effect:
  2963. @example
  2964. 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)
  2965. @end example
  2966. @item
  2967. Apply erratic camera effect depending on timestamp:
  2968. @example
  2969. 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)"
  2970. @end example
  2971. @item
  2972. Set x depending on the value of y:
  2973. @example
  2974. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  2975. @end example
  2976. @end itemize
  2977. @subsection Commands
  2978. This filter supports the following commands:
  2979. @table @option
  2980. @item w, out_w
  2981. @item h, out_h
  2982. @item x
  2983. @item y
  2984. Set width/height of the output video and the horizontal/vertical position
  2985. in the input video.
  2986. The command accepts the same syntax of the corresponding option.
  2987. If the specified expression is not valid, it is kept at its current
  2988. value.
  2989. @end table
  2990. @section cropdetect
  2991. Auto-detect the crop size.
  2992. It calculates the necessary cropping parameters and prints the
  2993. recommended parameters via the logging system. The detected dimensions
  2994. correspond to the non-black area of the input video.
  2995. It accepts the following parameters:
  2996. @table @option
  2997. @item limit
  2998. Set higher black value threshold, which can be optionally specified
  2999. from nothing (0) to everything (255 for 8bit based formats). An intensity
  3000. value greater to the set value is considered non-black. It defaults to 24.
  3001. You can also specify a value between 0.0 and 1.0 which will be scaled depending
  3002. on the bitdepth of the pixel format.
  3003. @item round
  3004. The value which the width/height should be divisible by. It defaults to
  3005. 16. The offset is automatically adjusted to center the video. Use 2 to
  3006. get only even dimensions (needed for 4:2:2 video). 16 is best when
  3007. encoding to most video codecs.
  3008. @item reset_count, reset
  3009. Set the counter that determines after how many frames cropdetect will
  3010. reset the previously detected largest video area and start over to
  3011. detect the current optimal crop area. Default value is 0.
  3012. This can be useful when channel logos distort the video area. 0
  3013. indicates 'never reset', and returns the largest area encountered during
  3014. playback.
  3015. @end table
  3016. @anchor{curves}
  3017. @section curves
  3018. Apply color adjustments using curves.
  3019. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  3020. component (red, green and blue) has its values defined by @var{N} key points
  3021. tied from each other using a smooth curve. The x-axis represents the pixel
  3022. values from the input frame, and the y-axis the new pixel values to be set for
  3023. the output frame.
  3024. By default, a component curve is defined by the two points @var{(0;0)} and
  3025. @var{(1;1)}. This creates a straight line where each original pixel value is
  3026. "adjusted" to its own value, which means no change to the image.
  3027. The filter allows you to redefine these two points and add some more. A new
  3028. curve (using a natural cubic spline interpolation) will be define to pass
  3029. smoothly through all these new coordinates. The new defined points needs to be
  3030. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  3031. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  3032. the vector spaces, the values will be clipped accordingly.
  3033. If there is no key point defined in @code{x=0}, the filter will automatically
  3034. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  3035. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  3036. The filter accepts the following options:
  3037. @table @option
  3038. @item preset
  3039. Select one of the available color presets. This option can be used in addition
  3040. to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
  3041. options takes priority on the preset values.
  3042. Available presets are:
  3043. @table @samp
  3044. @item none
  3045. @item color_negative
  3046. @item cross_process
  3047. @item darker
  3048. @item increase_contrast
  3049. @item lighter
  3050. @item linear_contrast
  3051. @item medium_contrast
  3052. @item negative
  3053. @item strong_contrast
  3054. @item vintage
  3055. @end table
  3056. Default is @code{none}.
  3057. @item master, m
  3058. Set the master key points. These points will define a second pass mapping. It
  3059. is sometimes called a "luminance" or "value" mapping. It can be used with
  3060. @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
  3061. post-processing LUT.
  3062. @item red, r
  3063. Set the key points for the red component.
  3064. @item green, g
  3065. Set the key points for the green component.
  3066. @item blue, b
  3067. Set the key points for the blue component.
  3068. @item all
  3069. Set the key points for all components (not including master).
  3070. Can be used in addition to the other key points component
  3071. options. In this case, the unset component(s) will fallback on this
  3072. @option{all} setting.
  3073. @item psfile
  3074. Specify a Photoshop curves file (@code{.asv}) to import the settings from.
  3075. @end table
  3076. To avoid some filtergraph syntax conflicts, each key points list need to be
  3077. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  3078. @subsection Examples
  3079. @itemize
  3080. @item
  3081. Increase slightly the middle level of blue:
  3082. @example
  3083. curves=blue='0.5/0.58'
  3084. @end example
  3085. @item
  3086. Vintage effect:
  3087. @example
  3088. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  3089. @end example
  3090. Here we obtain the following coordinates for each components:
  3091. @table @var
  3092. @item red
  3093. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  3094. @item green
  3095. @code{(0;0) (0.50;0.48) (1;1)}
  3096. @item blue
  3097. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  3098. @end table
  3099. @item
  3100. The previous example can also be achieved with the associated built-in preset:
  3101. @example
  3102. curves=preset=vintage
  3103. @end example
  3104. @item
  3105. Or simply:
  3106. @example
  3107. curves=vintage
  3108. @end example
  3109. @item
  3110. Use a Photoshop preset and redefine the points of the green component:
  3111. @example
  3112. curves=psfile='MyCurvesPresets/purple.asv':green='0.45/0.53'
  3113. @end example
  3114. @end itemize
  3115. @section dctdnoiz
  3116. Denoise frames using 2D DCT (frequency domain filtering).
  3117. This filter is not designed for real time.
  3118. The filter accepts the following options:
  3119. @table @option
  3120. @item sigma, s
  3121. Set the noise sigma constant.
  3122. This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
  3123. coefficient (absolute value) below this threshold with be dropped.
  3124. If you need a more advanced filtering, see @option{expr}.
  3125. Default is @code{0}.
  3126. @item overlap
  3127. Set number overlapping pixels for each block. Since the filter can be slow, you
  3128. may want to reduce this value, at the cost of a less effective filter and the
  3129. risk of various artefacts.
  3130. If the overlapping value doesn't permit processing the whole input width or
  3131. height, a warning will be displayed and according borders won't be denoised.
  3132. Default value is @var{blocksize}-1, which is the best possible setting.
  3133. @item expr, e
  3134. Set the coefficient factor expression.
  3135. For each coefficient of a DCT block, this expression will be evaluated as a
  3136. multiplier value for the coefficient.
  3137. If this is option is set, the @option{sigma} option will be ignored.
  3138. The absolute value of the coefficient can be accessed through the @var{c}
  3139. variable.
  3140. @item n
  3141. Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
  3142. @var{blocksize}, which is the width and height of the processed blocks.
  3143. The default value is @var{3} (8x8) and can be raised to @var{4} for a
  3144. @var{blocksize} of 16x16. Note that changing this setting has huge consequences
  3145. on the speed processing. Also, a larger block size does not necessarily means a
  3146. better de-noising.
  3147. @end table
  3148. @subsection Examples
  3149. Apply a denoise with a @option{sigma} of @code{4.5}:
  3150. @example
  3151. dctdnoiz=4.5
  3152. @end example
  3153. The same operation can be achieved using the expression system:
  3154. @example
  3155. dctdnoiz=e='gte(c, 4.5*3)'
  3156. @end example
  3157. Violent denoise using a block size of @code{16x16}:
  3158. @example
  3159. dctdnoiz=15:n=4
  3160. @end example
  3161. @section deband
  3162. Remove banding artifacts from input video.
  3163. It works by replacing banded pixels with average value of referenced pixels.
  3164. The filter accepts the following options:
  3165. @table @option
  3166. @item 1thr
  3167. @item 2thr
  3168. @item 3thr
  3169. @item 4thr
  3170. Set banding detection threshold for each plane. Default is 0.02.
  3171. Valid range is 0.00003 to 0.5.
  3172. If difference between current pixel and reference pixel is less than threshold,
  3173. it will be considered as banded.
  3174. @item range, r
  3175. Banding detection range in pixels. Default is 16. If positive, random number
  3176. in range 0 to set value will be used. If negative, exact absolute value
  3177. will be used.
  3178. The range defines square of four pixels around current pixel.
  3179. @item direction, d
  3180. Set direction in radians from which four pixel will be compared. If positive,
  3181. random direction from 0 to set direction will be picked. If negative, exact of
  3182. absolute value will be picked. For example direction 0, -PI or -2*PI radians
  3183. will pick only pixels on same row and -PI/2 will pick only pixels on same
  3184. column.
  3185. @item blur
  3186. If enabled, current pixel is compared with average value of all four
  3187. surrounding pixels. The default is enabled. If disabled current pixel is
  3188. compared with all four surrounding pixels. The pixel is considered banded
  3189. if only all four differences with surrounding pixels are less than threshold.
  3190. @end table
  3191. @anchor{decimate}
  3192. @section decimate
  3193. Drop duplicated frames at regular intervals.
  3194. The filter accepts the following options:
  3195. @table @option
  3196. @item cycle
  3197. Set the number of frames from which one will be dropped. Setting this to
  3198. @var{N} means one frame in every batch of @var{N} frames will be dropped.
  3199. Default is @code{5}.
  3200. @item dupthresh
  3201. Set the threshold for duplicate detection. If the difference metric for a frame
  3202. is less than or equal to this value, then it is declared as duplicate. Default
  3203. is @code{1.1}
  3204. @item scthresh
  3205. Set scene change threshold. Default is @code{15}.
  3206. @item blockx
  3207. @item blocky
  3208. Set the size of the x and y-axis blocks used during metric calculations.
  3209. Larger blocks give better noise suppression, but also give worse detection of
  3210. small movements. Must be a power of two. Default is @code{32}.
  3211. @item ppsrc
  3212. Mark main input as a pre-processed input and activate clean source input
  3213. stream. This allows the input to be pre-processed with various filters to help
  3214. the metrics calculation while keeping the frame selection lossless. When set to
  3215. @code{1}, the first stream is for the pre-processed input, and the second
  3216. stream is the clean source from where the kept frames are chosen. Default is
  3217. @code{0}.
  3218. @item chroma
  3219. Set whether or not chroma is considered in the metric calculations. Default is
  3220. @code{1}.
  3221. @end table
  3222. @section deflate
  3223. Apply deflate effect to the video.
  3224. This filter replaces the pixel by the local(3x3) average by taking into account
  3225. only values lower than the pixel.
  3226. It accepts the following options:
  3227. @table @option
  3228. @item threshold0
  3229. @item threshold1
  3230. @item threshold2
  3231. @item threshold3
  3232. Allows to limit the maximum change for each plane, default is 65535.
  3233. If 0, plane will remain unchanged.
  3234. @end table
  3235. @section dejudder
  3236. Remove judder produced by partially interlaced telecined content.
  3237. Judder can be introduced, for instance, by @ref{pullup} filter. If the original
  3238. source was partially telecined content then the output of @code{pullup,dejudder}
  3239. will have a variable frame rate. May change the recorded frame rate of the
  3240. container. Aside from that change, this filter will not affect constant frame
  3241. rate video.
  3242. The option available in this filter is:
  3243. @table @option
  3244. @item cycle
  3245. Specify the length of the window over which the judder repeats.
  3246. Accepts any integer greater than 1. Useful values are:
  3247. @table @samp
  3248. @item 4
  3249. If the original was telecined from 24 to 30 fps (Film to NTSC).
  3250. @item 5
  3251. If the original was telecined from 25 to 30 fps (PAL to NTSC).
  3252. @item 20
  3253. If a mixture of the two.
  3254. @end table
  3255. The default is @samp{4}.
  3256. @end table
  3257. @section delogo
  3258. Suppress a TV station logo by a simple interpolation of the surrounding
  3259. pixels. Just set a rectangle covering the logo and watch it disappear
  3260. (and sometimes something even uglier appear - your mileage may vary).
  3261. It accepts the following parameters:
  3262. @table @option
  3263. @item x
  3264. @item y
  3265. Specify the top left corner coordinates of the logo. They must be
  3266. specified.
  3267. @item w
  3268. @item h
  3269. Specify the width and height of the logo to clear. They must be
  3270. specified.
  3271. @item band, t
  3272. Specify the thickness of the fuzzy edge of the rectangle (added to
  3273. @var{w} and @var{h}). The default value is 4.
  3274. @item show
  3275. When set to 1, a green rectangle is drawn on the screen to simplify
  3276. finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
  3277. The default value is 0.
  3278. The rectangle is drawn on the outermost pixels which will be (partly)
  3279. replaced with interpolated values. The values of the next pixels
  3280. immediately outside this rectangle in each direction will be used to
  3281. compute the interpolated pixel values inside the rectangle.
  3282. @end table
  3283. @subsection Examples
  3284. @itemize
  3285. @item
  3286. Set a rectangle covering the area with top left corner coordinates 0,0
  3287. and size 100x77, and a band of size 10:
  3288. @example
  3289. delogo=x=0:y=0:w=100:h=77:band=10
  3290. @end example
  3291. @end itemize
  3292. @section deshake
  3293. Attempt to fix small changes in horizontal and/or vertical shift. This
  3294. filter helps remove camera shake from hand-holding a camera, bumping a
  3295. tripod, moving on a vehicle, etc.
  3296. The filter accepts the following options:
  3297. @table @option
  3298. @item x
  3299. @item y
  3300. @item w
  3301. @item h
  3302. Specify a rectangular area where to limit the search for motion
  3303. vectors.
  3304. If desired the search for motion vectors can be limited to a
  3305. rectangular area of the frame defined by its top left corner, width
  3306. and height. These parameters have the same meaning as the drawbox
  3307. filter which can be used to visualise the position of the bounding
  3308. box.
  3309. This is useful when simultaneous movement of subjects within the frame
  3310. might be confused for camera motion by the motion vector search.
  3311. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  3312. then the full frame is used. This allows later options to be set
  3313. without specifying the bounding box for the motion vector search.
  3314. Default - search the whole frame.
  3315. @item rx
  3316. @item ry
  3317. Specify the maximum extent of movement in x and y directions in the
  3318. range 0-64 pixels. Default 16.
  3319. @item edge
  3320. Specify how to generate pixels to fill blanks at the edge of the
  3321. frame. Available values are:
  3322. @table @samp
  3323. @item blank, 0
  3324. Fill zeroes at blank locations
  3325. @item original, 1
  3326. Original image at blank locations
  3327. @item clamp, 2
  3328. Extruded edge value at blank locations
  3329. @item mirror, 3
  3330. Mirrored edge at blank locations
  3331. @end table
  3332. Default value is @samp{mirror}.
  3333. @item blocksize
  3334. Specify the blocksize to use for motion search. Range 4-128 pixels,
  3335. default 8.
  3336. @item contrast
  3337. Specify the contrast threshold for blocks. Only blocks with more than
  3338. the specified contrast (difference between darkest and lightest
  3339. pixels) will be considered. Range 1-255, default 125.
  3340. @item search
  3341. Specify the search strategy. Available values are:
  3342. @table @samp
  3343. @item exhaustive, 0
  3344. Set exhaustive search
  3345. @item less, 1
  3346. Set less exhaustive search.
  3347. @end table
  3348. Default value is @samp{exhaustive}.
  3349. @item filename
  3350. If set then a detailed log of the motion search is written to the
  3351. specified file.
  3352. @item opencl
  3353. If set to 1, specify using OpenCL capabilities, only available if
  3354. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  3355. @end table
  3356. @section detelecine
  3357. Apply an exact inverse of the telecine operation. It requires a predefined
  3358. pattern specified using the pattern option which must be the same as that passed
  3359. to the telecine filter.
  3360. This filter accepts the following options:
  3361. @table @option
  3362. @item first_field
  3363. @table @samp
  3364. @item top, t
  3365. top field first
  3366. @item bottom, b
  3367. bottom field first
  3368. The default value is @code{top}.
  3369. @end table
  3370. @item pattern
  3371. A string of numbers representing the pulldown pattern you wish to apply.
  3372. The default value is @code{23}.
  3373. @item start_frame
  3374. A number representing position of the first frame with respect to the telecine
  3375. pattern. This is to be used if the stream is cut. The default value is @code{0}.
  3376. @end table
  3377. @section dilation
  3378. Apply dilation effect to the video.
  3379. This filter replaces the pixel by the local(3x3) maximum.
  3380. It accepts the following options:
  3381. @table @option
  3382. @item threshold0
  3383. @item threshold1
  3384. @item threshold2
  3385. @item threshold3
  3386. Allows to limit the maximum change for each plane, default is 65535.
  3387. If 0, plane will remain unchanged.
  3388. @item coordinates
  3389. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  3390. pixels are used.
  3391. Flags to local 3x3 coordinates maps like this:
  3392. 1 2 3
  3393. 4 5
  3394. 6 7 8
  3395. @end table
  3396. @section drawbox
  3397. Draw a colored box on the input image.
  3398. It accepts the following parameters:
  3399. @table @option
  3400. @item x
  3401. @item y
  3402. The expressions which specify the top left corner coordinates of the box. It defaults to 0.
  3403. @item width, w
  3404. @item height, h
  3405. The expressions which specify the width and height of the box; if 0 they are interpreted as
  3406. the input width and height. It defaults to 0.
  3407. @item color, c
  3408. Specify the color of the box to write. For the general syntax of this option,
  3409. check the "Color" section in the ffmpeg-utils manual. If the special
  3410. value @code{invert} is used, the box edge color is the same as the
  3411. video with inverted luma.
  3412. @item thickness, t
  3413. The expression which sets the thickness of the box edge. Default value is @code{3}.
  3414. See below for the list of accepted constants.
  3415. @end table
  3416. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  3417. following constants:
  3418. @table @option
  3419. @item dar
  3420. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  3421. @item hsub
  3422. @item vsub
  3423. horizontal and vertical chroma subsample values. For example for the
  3424. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3425. @item in_h, ih
  3426. @item in_w, iw
  3427. The input width and height.
  3428. @item sar
  3429. The input sample aspect ratio.
  3430. @item x
  3431. @item y
  3432. The x and y offset coordinates where the box is drawn.
  3433. @item w
  3434. @item h
  3435. The width and height of the drawn box.
  3436. @item t
  3437. The thickness of the drawn box.
  3438. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  3439. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  3440. @end table
  3441. @subsection Examples
  3442. @itemize
  3443. @item
  3444. Draw a black box around the edge of the input image:
  3445. @example
  3446. drawbox
  3447. @end example
  3448. @item
  3449. Draw a box with color red and an opacity of 50%:
  3450. @example
  3451. drawbox=10:20:200:60:red@@0.5
  3452. @end example
  3453. The previous example can be specified as:
  3454. @example
  3455. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  3456. @end example
  3457. @item
  3458. Fill the box with pink color:
  3459. @example
  3460. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  3461. @end example
  3462. @item
  3463. Draw a 2-pixel red 2.40:1 mask:
  3464. @example
  3465. 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
  3466. @end example
  3467. @end itemize
  3468. @section drawgraph, adrawgraph
  3469. Draw a graph using input video or audio metadata.
  3470. It accepts the following parameters:
  3471. @table @option
  3472. @item m1
  3473. Set 1st frame metadata key from which metadata values will be used to draw a graph.
  3474. @item fg1
  3475. Set 1st foreground color expression.
  3476. @item m2
  3477. Set 2nd frame metadata key from which metadata values will be used to draw a graph.
  3478. @item fg2
  3479. Set 2nd foreground color expression.
  3480. @item m3
  3481. Set 3rd frame metadata key from which metadata values will be used to draw a graph.
  3482. @item fg3
  3483. Set 3rd foreground color expression.
  3484. @item m4
  3485. Set 4th frame metadata key from which metadata values will be used to draw a graph.
  3486. @item fg4
  3487. Set 4th foreground color expression.
  3488. @item min
  3489. Set minimal value of metadata value.
  3490. @item max
  3491. Set maximal value of metadata value.
  3492. @item bg
  3493. Set graph background color. Default is white.
  3494. @item mode
  3495. Set graph mode.
  3496. Available values for mode is:
  3497. @table @samp
  3498. @item bar
  3499. @item dot
  3500. @item line
  3501. @end table
  3502. Default is @code{line}.
  3503. @item slide
  3504. Set slide mode.
  3505. Available values for slide is:
  3506. @table @samp
  3507. @item frame
  3508. Draw new frame when right border is reached.
  3509. @item replace
  3510. Replace old columns with new ones.
  3511. @item scroll
  3512. Scroll from right to left.
  3513. @item rscroll
  3514. Scroll from left to right.
  3515. @end table
  3516. Default is @code{frame}.
  3517. @item size
  3518. Set size of graph video. For the syntax of this option, check the
  3519. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  3520. The default value is @code{900x256}.
  3521. The foreground color expressions can use the following variables:
  3522. @table @option
  3523. @item MIN
  3524. Minimal value of metadata value.
  3525. @item MAX
  3526. Maximal value of metadata value.
  3527. @item VAL
  3528. Current metadata key value.
  3529. @end table
  3530. The color is defined as 0xAABBGGRR.
  3531. @end table
  3532. Example using metadata from @ref{signalstats} filter:
  3533. @example
  3534. signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255
  3535. @end example
  3536. Example using metadata from @ref{ebur128} filter:
  3537. @example
  3538. ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5
  3539. @end example
  3540. @section drawgrid
  3541. Draw a grid on the input image.
  3542. It accepts the following parameters:
  3543. @table @option
  3544. @item x
  3545. @item y
  3546. The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
  3547. @item width, w
  3548. @item height, h
  3549. The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
  3550. input width and height, respectively, minus @code{thickness}, so image gets
  3551. framed. Default to 0.
  3552. @item color, c
  3553. Specify the color of the grid. For the general syntax of this option,
  3554. check the "Color" section in the ffmpeg-utils manual. If the special
  3555. value @code{invert} is used, the grid color is the same as the
  3556. video with inverted luma.
  3557. @item thickness, t
  3558. The expression which sets the thickness of the grid line. Default value is @code{1}.
  3559. See below for the list of accepted constants.
  3560. @end table
  3561. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  3562. following constants:
  3563. @table @option
  3564. @item dar
  3565. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  3566. @item hsub
  3567. @item vsub
  3568. horizontal and vertical chroma subsample values. For example for the
  3569. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3570. @item in_h, ih
  3571. @item in_w, iw
  3572. The input grid cell width and height.
  3573. @item sar
  3574. The input sample aspect ratio.
  3575. @item x
  3576. @item y
  3577. The x and y coordinates of some point of grid intersection (meant to configure offset).
  3578. @item w
  3579. @item h
  3580. The width and height of the drawn cell.
  3581. @item t
  3582. The thickness of the drawn cell.
  3583. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  3584. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  3585. @end table
  3586. @subsection Examples
  3587. @itemize
  3588. @item
  3589. Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
  3590. @example
  3591. drawgrid=width=100:height=100:thickness=2:color=red@@0.5
  3592. @end example
  3593. @item
  3594. Draw a white 3x3 grid with an opacity of 50%:
  3595. @example
  3596. drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
  3597. @end example
  3598. @end itemize
  3599. @anchor{drawtext}
  3600. @section drawtext
  3601. Draw a text string or text from a specified file on top of a video, using the
  3602. libfreetype library.
  3603. To enable compilation of this filter, you need to configure FFmpeg with
  3604. @code{--enable-libfreetype}.
  3605. To enable default font fallback and the @var{font} option you need to
  3606. configure FFmpeg with @code{--enable-libfontconfig}.
  3607. To enable the @var{text_shaping} option, you need to configure FFmpeg with
  3608. @code{--enable-libfribidi}.
  3609. @subsection Syntax
  3610. It accepts the following parameters:
  3611. @table @option
  3612. @item box
  3613. Used to draw a box around text using the background color.
  3614. The value must be either 1 (enable) or 0 (disable).
  3615. The default value of @var{box} is 0.
  3616. @item boxborderw
  3617. Set the width of the border to be drawn around the box using @var{boxcolor}.
  3618. The default value of @var{boxborderw} is 0.
  3619. @item boxcolor
  3620. The color to be used for drawing box around text. For the syntax of this
  3621. option, check the "Color" section in the ffmpeg-utils manual.
  3622. The default value of @var{boxcolor} is "white".
  3623. @item borderw
  3624. Set the width of the border to be drawn around the text using @var{bordercolor}.
  3625. The default value of @var{borderw} is 0.
  3626. @item bordercolor
  3627. Set the color to be used for drawing border around text. For the syntax of this
  3628. option, check the "Color" section in the ffmpeg-utils manual.
  3629. The default value of @var{bordercolor} is "black".
  3630. @item expansion
  3631. Select how the @var{text} is expanded. Can be either @code{none},
  3632. @code{strftime} (deprecated) or
  3633. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  3634. below for details.
  3635. @item fix_bounds
  3636. If true, check and fix text coords to avoid clipping.
  3637. @item fontcolor
  3638. The color to be used for drawing fonts. For the syntax of this option, check
  3639. the "Color" section in the ffmpeg-utils manual.
  3640. The default value of @var{fontcolor} is "black".
  3641. @item fontcolor_expr
  3642. String which is expanded the same way as @var{text} to obtain dynamic
  3643. @var{fontcolor} value. By default this option has empty value and is not
  3644. processed. When this option is set, it overrides @var{fontcolor} option.
  3645. @item font
  3646. The font family to be used for drawing text. By default Sans.
  3647. @item fontfile
  3648. The font file to be used for drawing text. The path must be included.
  3649. This parameter is mandatory if the fontconfig support is disabled.
  3650. @item draw
  3651. This option does not exist, please see the timeline system
  3652. @item alpha
  3653. Draw the text applying alpha blending. The value can
  3654. be either a number between 0.0 and 1.0
  3655. The expression accepts the same variables @var{x, y} do.
  3656. The default value is 1.
  3657. Please see fontcolor_expr
  3658. @item fontsize
  3659. The font size to be used for drawing text.
  3660. The default value of @var{fontsize} is 16.
  3661. @item text_shaping
  3662. If set to 1, attempt to shape the text (for example, reverse the order of
  3663. right-to-left text and join Arabic characters) before drawing it.
  3664. Otherwise, just draw the text exactly as given.
  3665. By default 1 (if supported).
  3666. @item ft_load_flags
  3667. The flags to be used for loading the fonts.
  3668. The flags map the corresponding flags supported by libfreetype, and are
  3669. a combination of the following values:
  3670. @table @var
  3671. @item default
  3672. @item no_scale
  3673. @item no_hinting
  3674. @item render
  3675. @item no_bitmap
  3676. @item vertical_layout
  3677. @item force_autohint
  3678. @item crop_bitmap
  3679. @item pedantic
  3680. @item ignore_global_advance_width
  3681. @item no_recurse
  3682. @item ignore_transform
  3683. @item monochrome
  3684. @item linear_design
  3685. @item no_autohint
  3686. @end table
  3687. Default value is "default".
  3688. For more information consult the documentation for the FT_LOAD_*
  3689. libfreetype flags.
  3690. @item shadowcolor
  3691. The color to be used for drawing a shadow behind the drawn text. For the
  3692. syntax of this option, check the "Color" section in the ffmpeg-utils manual.
  3693. The default value of @var{shadowcolor} is "black".
  3694. @item shadowx
  3695. @item shadowy
  3696. The x and y offsets for the text shadow position with respect to the
  3697. position of the text. They can be either positive or negative
  3698. values. The default value for both is "0".
  3699. @item start_number
  3700. The starting frame number for the n/frame_num variable. The default value
  3701. is "0".
  3702. @item tabsize
  3703. The size in number of spaces to use for rendering the tab.
  3704. Default value is 4.
  3705. @item timecode
  3706. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  3707. format. It can be used with or without text parameter. @var{timecode_rate}
  3708. option must be specified.
  3709. @item timecode_rate, rate, r
  3710. Set the timecode frame rate (timecode only).
  3711. @item text
  3712. The text string to be drawn. The text must be a sequence of UTF-8
  3713. encoded characters.
  3714. This parameter is mandatory if no file is specified with the parameter
  3715. @var{textfile}.
  3716. @item textfile
  3717. A text file containing text to be drawn. The text must be a sequence
  3718. of UTF-8 encoded characters.
  3719. This parameter is mandatory if no text string is specified with the
  3720. parameter @var{text}.
  3721. If both @var{text} and @var{textfile} are specified, an error is thrown.
  3722. @item reload
  3723. If set to 1, the @var{textfile} will be reloaded before each frame.
  3724. Be sure to update it atomically, or it may be read partially, or even fail.
  3725. @item x
  3726. @item y
  3727. The expressions which specify the offsets where text will be drawn
  3728. within the video frame. They are relative to the top/left border of the
  3729. output image.
  3730. The default value of @var{x} and @var{y} is "0".
  3731. See below for the list of accepted constants and functions.
  3732. @end table
  3733. The parameters for @var{x} and @var{y} are expressions containing the
  3734. following constants and functions:
  3735. @table @option
  3736. @item dar
  3737. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  3738. @item hsub
  3739. @item vsub
  3740. horizontal and vertical chroma subsample values. For example for the
  3741. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3742. @item line_h, lh
  3743. the height of each text line
  3744. @item main_h, h, H
  3745. the input height
  3746. @item main_w, w, W
  3747. the input width
  3748. @item max_glyph_a, ascent
  3749. the maximum distance from the baseline to the highest/upper grid
  3750. coordinate used to place a glyph outline point, for all the rendered
  3751. glyphs.
  3752. It is a positive value, due to the grid's orientation with the Y axis
  3753. upwards.
  3754. @item max_glyph_d, descent
  3755. the maximum distance from the baseline to the lowest grid coordinate
  3756. used to place a glyph outline point, for all the rendered glyphs.
  3757. This is a negative value, due to the grid's orientation, with the Y axis
  3758. upwards.
  3759. @item max_glyph_h
  3760. maximum glyph height, that is the maximum height for all the glyphs
  3761. contained in the rendered text, it is equivalent to @var{ascent} -
  3762. @var{descent}.
  3763. @item max_glyph_w
  3764. maximum glyph width, that is the maximum width for all the glyphs
  3765. contained in the rendered text
  3766. @item n
  3767. the number of input frame, starting from 0
  3768. @item rand(min, max)
  3769. return a random number included between @var{min} and @var{max}
  3770. @item sar
  3771. The input sample aspect ratio.
  3772. @item t
  3773. timestamp expressed in seconds, NAN if the input timestamp is unknown
  3774. @item text_h, th
  3775. the height of the rendered text
  3776. @item text_w, tw
  3777. the width of the rendered text
  3778. @item x
  3779. @item y
  3780. the x and y offset coordinates where the text is drawn.
  3781. These parameters allow the @var{x} and @var{y} expressions to refer
  3782. each other, so you can for example specify @code{y=x/dar}.
  3783. @end table
  3784. @anchor{drawtext_expansion}
  3785. @subsection Text expansion
  3786. If @option{expansion} is set to @code{strftime},
  3787. the filter recognizes strftime() sequences in the provided text and
  3788. expands them accordingly. Check the documentation of strftime(). This
  3789. feature is deprecated.
  3790. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  3791. If @option{expansion} is set to @code{normal} (which is the default),
  3792. the following expansion mechanism is used.
  3793. The backslash character @samp{\}, followed by any character, always expands to
  3794. the second character.
  3795. Sequence of the form @code{%@{...@}} are expanded. The text between the
  3796. braces is a function name, possibly followed by arguments separated by ':'.
  3797. If the arguments contain special characters or delimiters (':' or '@}'),
  3798. they should be escaped.
  3799. Note that they probably must also be escaped as the value for the
  3800. @option{text} option in the filter argument string and as the filter
  3801. argument in the filtergraph description, and possibly also for the shell,
  3802. that makes up to four levels of escaping; using a text file avoids these
  3803. problems.
  3804. The following functions are available:
  3805. @table @command
  3806. @item expr, e
  3807. The expression evaluation result.
  3808. It must take one argument specifying the expression to be evaluated,
  3809. which accepts the same constants and functions as the @var{x} and
  3810. @var{y} values. Note that not all constants should be used, for
  3811. example the text size is not known when evaluating the expression, so
  3812. the constants @var{text_w} and @var{text_h} will have an undefined
  3813. value.
  3814. @item expr_int_format, eif
  3815. Evaluate the expression's value and output as formatted integer.
  3816. The first argument is the expression to be evaluated, just as for the @var{expr} function.
  3817. The second argument specifies the output format. Allowed values are @samp{x},
  3818. @samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
  3819. @code{printf} function.
  3820. The third parameter is optional and sets the number of positions taken by the output.
  3821. It can be used to add padding with zeros from the left.
  3822. @item gmtime
  3823. The time at which the filter is running, expressed in UTC.
  3824. It can accept an argument: a strftime() format string.
  3825. @item localtime
  3826. The time at which the filter is running, expressed in the local time zone.
  3827. It can accept an argument: a strftime() format string.
  3828. @item metadata
  3829. Frame metadata. It must take one argument specifying metadata key.
  3830. @item n, frame_num
  3831. The frame number, starting from 0.
  3832. @item pict_type
  3833. A 1 character description of the current picture type.
  3834. @item pts
  3835. The timestamp of the current frame.
  3836. It can take up to two arguments.
  3837. The first argument is the format of the timestamp; it defaults to @code{flt}
  3838. for seconds as a decimal number with microsecond accuracy; @code{hms} stands
  3839. for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
  3840. The second argument is an offset added to the timestamp.
  3841. @end table
  3842. @subsection Examples
  3843. @itemize
  3844. @item
  3845. Draw "Test Text" with font FreeSerif, using the default values for the
  3846. optional parameters.
  3847. @example
  3848. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  3849. @end example
  3850. @item
  3851. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  3852. and y=50 (counting from the top-left corner of the screen), text is
  3853. yellow with a red box around it. Both the text and the box have an
  3854. opacity of 20%.
  3855. @example
  3856. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  3857. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  3858. @end example
  3859. Note that the double quotes are not necessary if spaces are not used
  3860. within the parameter list.
  3861. @item
  3862. Show the text at the center of the video frame:
  3863. @example
  3864. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  3865. @end example
  3866. @item
  3867. Show a text line sliding from right to left in the last row of the video
  3868. frame. The file @file{LONG_LINE} is assumed to contain a single line
  3869. with no newlines.
  3870. @example
  3871. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  3872. @end example
  3873. @item
  3874. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  3875. @example
  3876. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  3877. @end example
  3878. @item
  3879. Draw a single green letter "g", at the center of the input video.
  3880. The glyph baseline is placed at half screen height.
  3881. @example
  3882. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  3883. @end example
  3884. @item
  3885. Show text for 1 second every 3 seconds:
  3886. @example
  3887. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  3888. @end example
  3889. @item
  3890. Use fontconfig to set the font. Note that the colons need to be escaped.
  3891. @example
  3892. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  3893. @end example
  3894. @item
  3895. Print the date of a real-time encoding (see strftime(3)):
  3896. @example
  3897. drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
  3898. @end example
  3899. @item
  3900. Show text fading in and out (appearing/disappearing):
  3901. @example
  3902. #!/bin/sh
  3903. DS=1.0 # display start
  3904. DE=10.0 # display end
  3905. FID=1.5 # fade in duration
  3906. FOD=5 # fade out duration
  3907. ffplay -f lavfi "color,drawtext=text=TEST:fontsize=50:fontfile=FreeSerif.ttf:fontcolor_expr=ff0000%@{eif\\\\: clip(255*(1*between(t\\, $DS + $FID\\, $DE - $FOD) + ((t - $DS)/$FID)*between(t\\, $DS\\, $DS + $FID) + (-(t - $DE)/$FOD)*between(t\\, $DE - $FOD\\, $DE) )\\, 0\\, 255) \\\\: x\\\\: 2 @}"
  3908. @end example
  3909. @end itemize
  3910. For more information about libfreetype, check:
  3911. @url{http://www.freetype.org/}.
  3912. For more information about fontconfig, check:
  3913. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  3914. For more information about libfribidi, check:
  3915. @url{http://fribidi.org/}.
  3916. @section edgedetect
  3917. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  3918. The filter accepts the following options:
  3919. @table @option
  3920. @item low
  3921. @item high
  3922. Set low and high threshold values used by the Canny thresholding
  3923. algorithm.
  3924. The high threshold selects the "strong" edge pixels, which are then
  3925. connected through 8-connectivity with the "weak" edge pixels selected
  3926. by the low threshold.
  3927. @var{low} and @var{high} threshold values must be chosen in the range
  3928. [0,1], and @var{low} should be lesser or equal to @var{high}.
  3929. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  3930. is @code{50/255}.
  3931. @item mode
  3932. Define the drawing mode.
  3933. @table @samp
  3934. @item wires
  3935. Draw white/gray wires on black background.
  3936. @item colormix
  3937. Mix the colors to create a paint/cartoon effect.
  3938. @end table
  3939. Default value is @var{wires}.
  3940. @end table
  3941. @subsection Examples
  3942. @itemize
  3943. @item
  3944. Standard edge detection with custom values for the hysteresis thresholding:
  3945. @example
  3946. edgedetect=low=0.1:high=0.4
  3947. @end example
  3948. @item
  3949. Painting effect without thresholding:
  3950. @example
  3951. edgedetect=mode=colormix:high=0
  3952. @end example
  3953. @end itemize
  3954. @section eq
  3955. Set brightness, contrast, saturation and approximate gamma adjustment.
  3956. The filter accepts the following options:
  3957. @table @option
  3958. @item contrast
  3959. Set the contrast expression. The value must be a float value in range
  3960. @code{-2.0} to @code{2.0}. The default value is "0".
  3961. @item brightness
  3962. Set the brightness expression. The value must be a float value in
  3963. range @code{-1.0} to @code{1.0}. The default value is "0".
  3964. @item saturation
  3965. Set the saturation expression. The value must be a float in
  3966. range @code{0.0} to @code{3.0}. The default value is "1".
  3967. @item gamma
  3968. Set the gamma expression. The value must be a float in range
  3969. @code{0.1} to @code{10.0}. The default value is "1".
  3970. @item gamma_r
  3971. Set the gamma expression for red. The value must be a float in
  3972. range @code{0.1} to @code{10.0}. The default value is "1".
  3973. @item gamma_g
  3974. Set the gamma expression for green. The value must be a float in range
  3975. @code{0.1} to @code{10.0}. The default value is "1".
  3976. @item gamma_b
  3977. Set the gamma expression for blue. The value must be a float in range
  3978. @code{0.1} to @code{10.0}. The default value is "1".
  3979. @item gamma_weight
  3980. Set the gamma weight expression. It can be used to reduce the effect
  3981. of a high gamma value on bright image areas, e.g. keep them from
  3982. getting overamplified and just plain white. The value must be a float
  3983. in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
  3984. gamma correction all the way down while @code{1.0} leaves it at its
  3985. full strength. Default is "1".
  3986. @item eval
  3987. Set when the expressions for brightness, contrast, saturation and
  3988. gamma expressions are evaluated.
  3989. It accepts the following values:
  3990. @table @samp
  3991. @item init
  3992. only evaluate expressions once during the filter initialization or
  3993. when a command is processed
  3994. @item frame
  3995. evaluate expressions for each incoming frame
  3996. @end table
  3997. Default value is @samp{init}.
  3998. @end table
  3999. The expressions accept the following parameters:
  4000. @table @option
  4001. @item n
  4002. frame count of the input frame starting from 0
  4003. @item pos
  4004. byte position of the corresponding packet in the input file, NAN if
  4005. unspecified
  4006. @item r
  4007. frame rate of the input video, NAN if the input frame rate is unknown
  4008. @item t
  4009. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4010. @end table
  4011. @subsection Commands
  4012. The filter supports the following commands:
  4013. @table @option
  4014. @item contrast
  4015. Set the contrast expression.
  4016. @item brightness
  4017. Set the brightness expression.
  4018. @item saturation
  4019. Set the saturation expression.
  4020. @item gamma
  4021. Set the gamma expression.
  4022. @item gamma_r
  4023. Set the gamma_r expression.
  4024. @item gamma_g
  4025. Set gamma_g expression.
  4026. @item gamma_b
  4027. Set gamma_b expression.
  4028. @item gamma_weight
  4029. Set gamma_weight expression.
  4030. The command accepts the same syntax of the corresponding option.
  4031. If the specified expression is not valid, it is kept at its current
  4032. value.
  4033. @end table
  4034. @section erosion
  4035. Apply erosion effect to the video.
  4036. This filter replaces the pixel by the local(3x3) minimum.
  4037. It accepts the following options:
  4038. @table @option
  4039. @item threshold0
  4040. @item threshold1
  4041. @item threshold2
  4042. @item threshold3
  4043. Allows to limit the maximum change for each plane, default is 65535.
  4044. If 0, plane will remain unchanged.
  4045. @item coordinates
  4046. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  4047. pixels are used.
  4048. Flags to local 3x3 coordinates maps like this:
  4049. 1 2 3
  4050. 4 5
  4051. 6 7 8
  4052. @end table
  4053. @section extractplanes
  4054. Extract color channel components from input video stream into
  4055. separate grayscale video streams.
  4056. The filter accepts the following option:
  4057. @table @option
  4058. @item planes
  4059. Set plane(s) to extract.
  4060. Available values for planes are:
  4061. @table @samp
  4062. @item y
  4063. @item u
  4064. @item v
  4065. @item a
  4066. @item r
  4067. @item g
  4068. @item b
  4069. @end table
  4070. Choosing planes not available in the input will result in an error.
  4071. That means you cannot select @code{r}, @code{g}, @code{b} planes
  4072. with @code{y}, @code{u}, @code{v} planes at same time.
  4073. @end table
  4074. @subsection Examples
  4075. @itemize
  4076. @item
  4077. Extract luma, u and v color channel component from input video frame
  4078. into 3 grayscale outputs:
  4079. @example
  4080. 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
  4081. @end example
  4082. @end itemize
  4083. @section elbg
  4084. Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
  4085. For each input image, the filter will compute the optimal mapping from
  4086. the input to the output given the codebook length, that is the number
  4087. of distinct output colors.
  4088. This filter accepts the following options.
  4089. @table @option
  4090. @item codebook_length, l
  4091. Set codebook length. The value must be a positive integer, and
  4092. represents the number of distinct output colors. Default value is 256.
  4093. @item nb_steps, n
  4094. Set the maximum number of iterations to apply for computing the optimal
  4095. mapping. The higher the value the better the result and the higher the
  4096. computation time. Default value is 1.
  4097. @item seed, s
  4098. Set a random seed, must be an integer included between 0 and
  4099. UINT32_MAX. If not specified, or if explicitly set to -1, the filter
  4100. will try to use a good random seed on a best effort basis.
  4101. @item pal8
  4102. Set pal8 output pixel format. This option does not work with codebook
  4103. length greater than 256.
  4104. @end table
  4105. @section fade
  4106. Apply a fade-in/out effect to the input video.
  4107. It accepts the following parameters:
  4108. @table @option
  4109. @item type, t
  4110. The effect type can be either "in" for a fade-in, or "out" for a fade-out
  4111. effect.
  4112. Default is @code{in}.
  4113. @item start_frame, s
  4114. Specify the number of the frame to start applying the fade
  4115. effect at. Default is 0.
  4116. @item nb_frames, n
  4117. The number of frames that the fade effect lasts. At the end of the
  4118. fade-in effect, the output video will have the same intensity as the input video.
  4119. At the end of the fade-out transition, the output video will be filled with the
  4120. selected @option{color}.
  4121. Default is 25.
  4122. @item alpha
  4123. If set to 1, fade only alpha channel, if one exists on the input.
  4124. Default value is 0.
  4125. @item start_time, st
  4126. Specify the timestamp (in seconds) of the frame to start to apply the fade
  4127. effect. If both start_frame and start_time are specified, the fade will start at
  4128. whichever comes last. Default is 0.
  4129. @item duration, d
  4130. The number of seconds for which the fade effect has to last. At the end of the
  4131. fade-in effect the output video will have the same intensity as the input video,
  4132. at the end of the fade-out transition the output video will be filled with the
  4133. selected @option{color}.
  4134. If both duration and nb_frames are specified, duration is used. Default is 0
  4135. (nb_frames is used by default).
  4136. @item color, c
  4137. Specify the color of the fade. Default is "black".
  4138. @end table
  4139. @subsection Examples
  4140. @itemize
  4141. @item
  4142. Fade in the first 30 frames of video:
  4143. @example
  4144. fade=in:0:30
  4145. @end example
  4146. The command above is equivalent to:
  4147. @example
  4148. fade=t=in:s=0:n=30
  4149. @end example
  4150. @item
  4151. Fade out the last 45 frames of a 200-frame video:
  4152. @example
  4153. fade=out:155:45
  4154. fade=type=out:start_frame=155:nb_frames=45
  4155. @end example
  4156. @item
  4157. Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
  4158. @example
  4159. fade=in:0:25, fade=out:975:25
  4160. @end example
  4161. @item
  4162. Make the first 5 frames yellow, then fade in from frame 5-24:
  4163. @example
  4164. fade=in:5:20:color=yellow
  4165. @end example
  4166. @item
  4167. Fade in alpha over first 25 frames of video:
  4168. @example
  4169. fade=in:0:25:alpha=1
  4170. @end example
  4171. @item
  4172. Make the first 5.5 seconds black, then fade in for 0.5 seconds:
  4173. @example
  4174. fade=t=in:st=5.5:d=0.5
  4175. @end example
  4176. @end itemize
  4177. @section fftfilt
  4178. Apply arbitrary expressions to samples in frequency domain
  4179. @table @option
  4180. @item dc_Y
  4181. Adjust the dc value (gain) of the luma plane of the image. The filter
  4182. accepts an integer value in range @code{0} to @code{1000}. The default
  4183. value is set to @code{0}.
  4184. @item dc_U
  4185. Adjust the dc value (gain) of the 1st chroma plane of the image. The
  4186. filter accepts an integer value in range @code{0} to @code{1000}. The
  4187. default value is set to @code{0}.
  4188. @item dc_V
  4189. Adjust the dc value (gain) of the 2nd chroma plane of the image. The
  4190. filter accepts an integer value in range @code{0} to @code{1000}. The
  4191. default value is set to @code{0}.
  4192. @item weight_Y
  4193. Set the frequency domain weight expression for the luma plane.
  4194. @item weight_U
  4195. Set the frequency domain weight expression for the 1st chroma plane.
  4196. @item weight_V
  4197. Set the frequency domain weight expression for the 2nd chroma plane.
  4198. The filter accepts the following variables:
  4199. @item X
  4200. @item Y
  4201. The coordinates of the current sample.
  4202. @item W
  4203. @item H
  4204. The width and height of the image.
  4205. @end table
  4206. @subsection Examples
  4207. @itemize
  4208. @item
  4209. High-pass:
  4210. @example
  4211. fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
  4212. @end example
  4213. @item
  4214. Low-pass:
  4215. @example
  4216. fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
  4217. @end example
  4218. @item
  4219. Sharpen:
  4220. @example
  4221. fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
  4222. @end example
  4223. @end itemize
  4224. @section field
  4225. Extract a single field from an interlaced image using stride
  4226. arithmetic to avoid wasting CPU time. The output frames are marked as
  4227. non-interlaced.
  4228. The filter accepts the following options:
  4229. @table @option
  4230. @item type
  4231. Specify whether to extract the top (if the value is @code{0} or
  4232. @code{top}) or the bottom field (if the value is @code{1} or
  4233. @code{bottom}).
  4234. @end table
  4235. @section fieldmatch
  4236. Field matching filter for inverse telecine. It is meant to reconstruct the
  4237. progressive frames from a telecined stream. The filter does not drop duplicated
  4238. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  4239. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  4240. The separation of the field matching and the decimation is notably motivated by
  4241. the possibility of inserting a de-interlacing filter fallback between the two.
  4242. If the source has mixed telecined and real interlaced content,
  4243. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  4244. But these remaining combed frames will be marked as interlaced, and thus can be
  4245. de-interlaced by a later filter such as @ref{yadif} before decimation.
  4246. In addition to the various configuration options, @code{fieldmatch} can take an
  4247. optional second stream, activated through the @option{ppsrc} option. If
  4248. enabled, the frames reconstruction will be based on the fields and frames from
  4249. this second stream. This allows the first input to be pre-processed in order to
  4250. help the various algorithms of the filter, while keeping the output lossless
  4251. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  4252. or brightness/contrast adjustments can help.
  4253. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  4254. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  4255. which @code{fieldmatch} is based on. While the semantic and usage are very
  4256. close, some behaviour and options names can differ.
  4257. The @ref{decimate} filter currently only works for constant frame rate input.
  4258. If your input has mixed telecined (30fps) and progressive content with a lower
  4259. framerate like 24fps use the following filterchain to produce the necessary cfr
  4260. stream: @code{dejudder,fps=30000/1001,fieldmatch,decimate}.
  4261. The filter accepts the following options:
  4262. @table @option
  4263. @item order
  4264. Specify the assumed field order of the input stream. Available values are:
  4265. @table @samp
  4266. @item auto
  4267. Auto detect parity (use FFmpeg's internal parity value).
  4268. @item bff
  4269. Assume bottom field first.
  4270. @item tff
  4271. Assume top field first.
  4272. @end table
  4273. Note that it is sometimes recommended not to trust the parity announced by the
  4274. stream.
  4275. Default value is @var{auto}.
  4276. @item mode
  4277. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  4278. sense that it won't risk creating jerkiness due to duplicate frames when
  4279. possible, but if there are bad edits or blended fields it will end up
  4280. outputting combed frames when a good match might actually exist. On the other
  4281. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  4282. but will almost always find a good frame if there is one. The other values are
  4283. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  4284. jerkiness and creating duplicate frames versus finding good matches in sections
  4285. with bad edits, orphaned fields, blended fields, etc.
  4286. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  4287. Available values are:
  4288. @table @samp
  4289. @item pc
  4290. 2-way matching (p/c)
  4291. @item pc_n
  4292. 2-way matching, and trying 3rd match if still combed (p/c + n)
  4293. @item pc_u
  4294. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  4295. @item pc_n_ub
  4296. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  4297. still combed (p/c + n + u/b)
  4298. @item pcn
  4299. 3-way matching (p/c/n)
  4300. @item pcn_ub
  4301. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  4302. detected as combed (p/c/n + u/b)
  4303. @end table
  4304. The parenthesis at the end indicate the matches that would be used for that
  4305. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  4306. @var{top}).
  4307. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  4308. the slowest.
  4309. Default value is @var{pc_n}.
  4310. @item ppsrc
  4311. Mark the main input stream as a pre-processed input, and enable the secondary
  4312. input stream as the clean source to pick the fields from. See the filter
  4313. introduction for more details. It is similar to the @option{clip2} feature from
  4314. VFM/TFM.
  4315. Default value is @code{0} (disabled).
  4316. @item field
  4317. Set the field to match from. It is recommended to set this to the same value as
  4318. @option{order} unless you experience matching failures with that setting. In
  4319. certain circumstances changing the field that is used to match from can have a
  4320. large impact on matching performance. Available values are:
  4321. @table @samp
  4322. @item auto
  4323. Automatic (same value as @option{order}).
  4324. @item bottom
  4325. Match from the bottom field.
  4326. @item top
  4327. Match from the top field.
  4328. @end table
  4329. Default value is @var{auto}.
  4330. @item mchroma
  4331. Set whether or not chroma is included during the match comparisons. In most
  4332. cases it is recommended to leave this enabled. You should set this to @code{0}
  4333. only if your clip has bad chroma problems such as heavy rainbowing or other
  4334. artifacts. Setting this to @code{0} could also be used to speed things up at
  4335. the cost of some accuracy.
  4336. Default value is @code{1}.
  4337. @item y0
  4338. @item y1
  4339. These define an exclusion band which excludes the lines between @option{y0} and
  4340. @option{y1} from being included in the field matching decision. An exclusion
  4341. band can be used to ignore subtitles, a logo, or other things that may
  4342. interfere with the matching. @option{y0} sets the starting scan line and
  4343. @option{y1} sets the ending line; all lines in between @option{y0} and
  4344. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  4345. @option{y0} and @option{y1} to the same value will disable the feature.
  4346. @option{y0} and @option{y1} defaults to @code{0}.
  4347. @item scthresh
  4348. Set the scene change detection threshold as a percentage of maximum change on
  4349. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  4350. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  4351. @option{scthresh} is @code{[0.0, 100.0]}.
  4352. Default value is @code{12.0}.
  4353. @item combmatch
  4354. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  4355. account the combed scores of matches when deciding what match to use as the
  4356. final match. Available values are:
  4357. @table @samp
  4358. @item none
  4359. No final matching based on combed scores.
  4360. @item sc
  4361. Combed scores are only used when a scene change is detected.
  4362. @item full
  4363. Use combed scores all the time.
  4364. @end table
  4365. Default is @var{sc}.
  4366. @item combdbg
  4367. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  4368. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  4369. Available values are:
  4370. @table @samp
  4371. @item none
  4372. No forced calculation.
  4373. @item pcn
  4374. Force p/c/n calculations.
  4375. @item pcnub
  4376. Force p/c/n/u/b calculations.
  4377. @end table
  4378. Default value is @var{none}.
  4379. @item cthresh
  4380. This is the area combing threshold used for combed frame detection. This
  4381. essentially controls how "strong" or "visible" combing must be to be detected.
  4382. Larger values mean combing must be more visible and smaller values mean combing
  4383. can be less visible or strong and still be detected. Valid settings are from
  4384. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  4385. be detected as combed). This is basically a pixel difference value. A good
  4386. range is @code{[8, 12]}.
  4387. Default value is @code{9}.
  4388. @item chroma
  4389. Sets whether or not chroma is considered in the combed frame decision. Only
  4390. disable this if your source has chroma problems (rainbowing, etc.) that are
  4391. causing problems for the combed frame detection with chroma enabled. Actually,
  4392. using @option{chroma}=@var{0} is usually more reliable, except for the case
  4393. where there is chroma only combing in the source.
  4394. Default value is @code{0}.
  4395. @item blockx
  4396. @item blocky
  4397. Respectively set the x-axis and y-axis size of the window used during combed
  4398. frame detection. This has to do with the size of the area in which
  4399. @option{combpel} pixels are required to be detected as combed for a frame to be
  4400. declared combed. See the @option{combpel} parameter description for more info.
  4401. Possible values are any number that is a power of 2 starting at 4 and going up
  4402. to 512.
  4403. Default value is @code{16}.
  4404. @item combpel
  4405. The number of combed pixels inside any of the @option{blocky} by
  4406. @option{blockx} size blocks on the frame for the frame to be detected as
  4407. combed. While @option{cthresh} controls how "visible" the combing must be, this
  4408. setting controls "how much" combing there must be in any localized area (a
  4409. window defined by the @option{blockx} and @option{blocky} settings) on the
  4410. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  4411. which point no frames will ever be detected as combed). This setting is known
  4412. as @option{MI} in TFM/VFM vocabulary.
  4413. Default value is @code{80}.
  4414. @end table
  4415. @anchor{p/c/n/u/b meaning}
  4416. @subsection p/c/n/u/b meaning
  4417. @subsubsection p/c/n
  4418. We assume the following telecined stream:
  4419. @example
  4420. Top fields: 1 2 2 3 4
  4421. Bottom fields: 1 2 3 4 4
  4422. @end example
  4423. The numbers correspond to the progressive frame the fields relate to. Here, the
  4424. first two frames are progressive, the 3rd and 4th are combed, and so on.
  4425. When @code{fieldmatch} is configured to run a matching from bottom
  4426. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  4427. @example
  4428. Input stream:
  4429. T 1 2 2 3 4
  4430. B 1 2 3 4 4 <-- matching reference
  4431. Matches: c c n n c
  4432. Output stream:
  4433. T 1 2 3 4 4
  4434. B 1 2 3 4 4
  4435. @end example
  4436. As a result of the field matching, we can see that some frames get duplicated.
  4437. To perform a complete inverse telecine, you need to rely on a decimation filter
  4438. after this operation. See for instance the @ref{decimate} filter.
  4439. The same operation now matching from top fields (@option{field}=@var{top})
  4440. looks like this:
  4441. @example
  4442. Input stream:
  4443. T 1 2 2 3 4 <-- matching reference
  4444. B 1 2 3 4 4
  4445. Matches: c c p p c
  4446. Output stream:
  4447. T 1 2 2 3 4
  4448. B 1 2 2 3 4
  4449. @end example
  4450. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  4451. basically, they refer to the frame and field of the opposite parity:
  4452. @itemize
  4453. @item @var{p} matches the field of the opposite parity in the previous frame
  4454. @item @var{c} matches the field of the opposite parity in the current frame
  4455. @item @var{n} matches the field of the opposite parity in the next frame
  4456. @end itemize
  4457. @subsubsection u/b
  4458. The @var{u} and @var{b} matching are a bit special in the sense that they match
  4459. from the opposite parity flag. In the following examples, we assume that we are
  4460. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  4461. 'x' is placed above and below each matched fields.
  4462. With bottom matching (@option{field}=@var{bottom}):
  4463. @example
  4464. Match: c p n b u
  4465. x x x x x
  4466. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  4467. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  4468. x x x x x
  4469. Output frames:
  4470. 2 1 2 2 2
  4471. 2 2 2 1 3
  4472. @end example
  4473. With top matching (@option{field}=@var{top}):
  4474. @example
  4475. Match: c p n b u
  4476. x x x x x
  4477. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  4478. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  4479. x x x x x
  4480. Output frames:
  4481. 2 2 2 1 2
  4482. 2 1 3 2 2
  4483. @end example
  4484. @subsection Examples
  4485. Simple IVTC of a top field first telecined stream:
  4486. @example
  4487. fieldmatch=order=tff:combmatch=none, decimate
  4488. @end example
  4489. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  4490. @example
  4491. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  4492. @end example
  4493. @section fieldorder
  4494. Transform the field order of the input video.
  4495. It accepts the following parameters:
  4496. @table @option
  4497. @item order
  4498. The output field order. Valid values are @var{tff} for top field first or @var{bff}
  4499. for bottom field first.
  4500. @end table
  4501. The default value is @samp{tff}.
  4502. The transformation is done by shifting the picture content up or down
  4503. by one line, and filling the remaining line with appropriate picture content.
  4504. This method is consistent with most broadcast field order converters.
  4505. If the input video is not flagged as being interlaced, or it is already
  4506. flagged as being of the required output field order, then this filter does
  4507. not alter the incoming video.
  4508. It is very useful when converting to or from PAL DV material,
  4509. which is bottom field first.
  4510. For example:
  4511. @example
  4512. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  4513. @end example
  4514. @section fifo
  4515. Buffer input images and send them when they are requested.
  4516. It is mainly useful when auto-inserted by the libavfilter
  4517. framework.
  4518. It does not take parameters.
  4519. @section find_rect
  4520. Find a rectangular object
  4521. It accepts the following options:
  4522. @table @option
  4523. @item object
  4524. Filepath of the object image, needs to be in gray8.
  4525. @item threshold
  4526. Detection threshold, default is 0.5.
  4527. @item mipmaps
  4528. Number of mipmaps, default is 3.
  4529. @item xmin, ymin, xmax, ymax
  4530. Specifies the rectangle in which to search.
  4531. @end table
  4532. @subsection Examples
  4533. @itemize
  4534. @item
  4535. Generate a representative palette of a given video using @command{ffmpeg}:
  4536. @example
  4537. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  4538. @end example
  4539. @end itemize
  4540. @section cover_rect
  4541. Cover a rectangular object
  4542. It accepts the following options:
  4543. @table @option
  4544. @item cover
  4545. Filepath of the optional cover image, needs to be in yuv420.
  4546. @item mode
  4547. Set covering mode.
  4548. It accepts the following values:
  4549. @table @samp
  4550. @item cover
  4551. cover it by the supplied image
  4552. @item blur
  4553. cover it by interpolating the surrounding pixels
  4554. @end table
  4555. Default value is @var{blur}.
  4556. @end table
  4557. @subsection Examples
  4558. @itemize
  4559. @item
  4560. Generate a representative palette of a given video using @command{ffmpeg}:
  4561. @example
  4562. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  4563. @end example
  4564. @end itemize
  4565. @anchor{format}
  4566. @section format
  4567. Convert the input video to one of the specified pixel formats.
  4568. Libavfilter will try to pick one that is suitable as input to
  4569. the next filter.
  4570. It accepts the following parameters:
  4571. @table @option
  4572. @item pix_fmts
  4573. A '|'-separated list of pixel format names, such as
  4574. "pix_fmts=yuv420p|monow|rgb24".
  4575. @end table
  4576. @subsection Examples
  4577. @itemize
  4578. @item
  4579. Convert the input video to the @var{yuv420p} format
  4580. @example
  4581. format=pix_fmts=yuv420p
  4582. @end example
  4583. Convert the input video to any of the formats in the list
  4584. @example
  4585. format=pix_fmts=yuv420p|yuv444p|yuv410p
  4586. @end example
  4587. @end itemize
  4588. @anchor{fps}
  4589. @section fps
  4590. Convert the video to specified constant frame rate by duplicating or dropping
  4591. frames as necessary.
  4592. It accepts the following parameters:
  4593. @table @option
  4594. @item fps
  4595. The desired output frame rate. The default is @code{25}.
  4596. @item round
  4597. Rounding method.
  4598. Possible values are:
  4599. @table @option
  4600. @item zero
  4601. zero round towards 0
  4602. @item inf
  4603. round away from 0
  4604. @item down
  4605. round towards -infinity
  4606. @item up
  4607. round towards +infinity
  4608. @item near
  4609. round to nearest
  4610. @end table
  4611. The default is @code{near}.
  4612. @item start_time
  4613. Assume the first PTS should be the given value, in seconds. This allows for
  4614. padding/trimming at the start of stream. By default, no assumption is made
  4615. about the first frame's expected PTS, so no padding or trimming is done.
  4616. For example, this could be set to 0 to pad the beginning with duplicates of
  4617. the first frame if a video stream starts after the audio stream or to trim any
  4618. frames with a negative PTS.
  4619. @end table
  4620. Alternatively, the options can be specified as a flat string:
  4621. @var{fps}[:@var{round}].
  4622. See also the @ref{setpts} filter.
  4623. @subsection Examples
  4624. @itemize
  4625. @item
  4626. A typical usage in order to set the fps to 25:
  4627. @example
  4628. fps=fps=25
  4629. @end example
  4630. @item
  4631. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  4632. @example
  4633. fps=fps=film:round=near
  4634. @end example
  4635. @end itemize
  4636. @section framepack
  4637. Pack two different video streams into a stereoscopic video, setting proper
  4638. metadata on supported codecs. The two views should have the same size and
  4639. framerate and processing will stop when the shorter video ends. Please note
  4640. that you may conveniently adjust view properties with the @ref{scale} and
  4641. @ref{fps} filters.
  4642. It accepts the following parameters:
  4643. @table @option
  4644. @item format
  4645. The desired packing format. Supported values are:
  4646. @table @option
  4647. @item sbs
  4648. The views are next to each other (default).
  4649. @item tab
  4650. The views are on top of each other.
  4651. @item lines
  4652. The views are packed by line.
  4653. @item columns
  4654. The views are packed by column.
  4655. @item frameseq
  4656. The views are temporally interleaved.
  4657. @end table
  4658. @end table
  4659. Some examples:
  4660. @example
  4661. # Convert left and right views into a frame-sequential video
  4662. ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
  4663. # Convert views into a side-by-side video with the same output resolution as the input
  4664. ffmpeg -i LEFT -i RIGHT -filter_complex [0:v]scale=w=iw/2[left],[1:v]scale=w=iw/2[right],[left][right]framepack=sbs OUTPUT
  4665. @end example
  4666. @section framerate
  4667. Change the frame rate by interpolating new video output frames from the source
  4668. frames.
  4669. This filter is not designed to function correctly with interlaced media. If
  4670. you wish to change the frame rate of interlaced media then you are required
  4671. to deinterlace before this filter and re-interlace after this filter.
  4672. A description of the accepted options follows.
  4673. @table @option
  4674. @item fps
  4675. Specify the output frames per second. This option can also be specified
  4676. as a value alone. The default is @code{50}.
  4677. @item interp_start
  4678. Specify the start of a range where the output frame will be created as a
  4679. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  4680. the default is @code{15}.
  4681. @item interp_end
  4682. Specify the end of a range where the output frame will be created as a
  4683. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  4684. the default is @code{240}.
  4685. @item scene
  4686. Specify the level at which a scene change is detected as a value between
  4687. 0 and 100 to indicate a new scene; a low value reflects a low
  4688. probability for the current frame to introduce a new scene, while a higher
  4689. value means the current frame is more likely to be one.
  4690. The default is @code{7}.
  4691. @item flags
  4692. Specify flags influencing the filter process.
  4693. Available value for @var{flags} is:
  4694. @table @option
  4695. @item scene_change_detect, scd
  4696. Enable scene change detection using the value of the option @var{scene}.
  4697. This flag is enabled by default.
  4698. @end table
  4699. @end table
  4700. @section framestep
  4701. Select one frame every N-th frame.
  4702. This filter accepts the following option:
  4703. @table @option
  4704. @item step
  4705. Select frame after every @code{step} frames.
  4706. Allowed values are positive integers higher than 0. Default value is @code{1}.
  4707. @end table
  4708. @anchor{frei0r}
  4709. @section frei0r
  4710. Apply a frei0r effect to the input video.
  4711. To enable the compilation of this filter, you need to install the frei0r
  4712. header and configure FFmpeg with @code{--enable-frei0r}.
  4713. It accepts the following parameters:
  4714. @table @option
  4715. @item filter_name
  4716. The name of the frei0r effect to load. If the environment variable
  4717. @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
  4718. directories specified by the colon-separated list in @env{FREIOR_PATH}.
  4719. Otherwise, the standard frei0r paths are searched, in this order:
  4720. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  4721. @file{/usr/lib/frei0r-1/}.
  4722. @item filter_params
  4723. A '|'-separated list of parameters to pass to the frei0r effect.
  4724. @end table
  4725. A frei0r effect parameter can be a boolean (its value is either
  4726. "y" or "n"), a double, a color (specified as
  4727. @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
  4728. numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
  4729. section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
  4730. @var{X} and @var{Y} are floating point numbers) and/or a string.
  4731. The number and types of parameters depend on the loaded effect. If an
  4732. effect parameter is not specified, the default value is set.
  4733. @subsection Examples
  4734. @itemize
  4735. @item
  4736. Apply the distort0r effect, setting the first two double parameters:
  4737. @example
  4738. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  4739. @end example
  4740. @item
  4741. Apply the colordistance effect, taking a color as the first parameter:
  4742. @example
  4743. frei0r=colordistance:0.2/0.3/0.4
  4744. frei0r=colordistance:violet
  4745. frei0r=colordistance:0x112233
  4746. @end example
  4747. @item
  4748. Apply the perspective effect, specifying the top left and top right image
  4749. positions:
  4750. @example
  4751. frei0r=perspective:0.2/0.2|0.8/0.2
  4752. @end example
  4753. @end itemize
  4754. For more information, see
  4755. @url{http://frei0r.dyne.org}
  4756. @section fspp
  4757. Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
  4758. It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
  4759. processing filter, one of them is performed once per block, not per pixel.
  4760. This allows for much higher speed.
  4761. The filter accepts the following options:
  4762. @table @option
  4763. @item quality
  4764. Set quality. This option defines the number of levels for averaging. It accepts
  4765. an integer in the range 4-5. Default value is @code{4}.
  4766. @item qp
  4767. Force a constant quantization parameter. It accepts an integer in range 0-63.
  4768. If not set, the filter will use the QP from the video stream (if available).
  4769. @item strength
  4770. Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
  4771. more details but also more artifacts, while higher values make the image smoother
  4772. but also blurrier. Default value is @code{0} − PSNR optimal.
  4773. @item use_bframe_qp
  4774. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  4775. option may cause flicker since the B-Frames have often larger QP. Default is
  4776. @code{0} (not enabled).
  4777. @end table
  4778. @section geq
  4779. The filter accepts the following options:
  4780. @table @option
  4781. @item lum_expr, lum
  4782. Set the luminance expression.
  4783. @item cb_expr, cb
  4784. Set the chrominance blue expression.
  4785. @item cr_expr, cr
  4786. Set the chrominance red expression.
  4787. @item alpha_expr, a
  4788. Set the alpha expression.
  4789. @item red_expr, r
  4790. Set the red expression.
  4791. @item green_expr, g
  4792. Set the green expression.
  4793. @item blue_expr, b
  4794. Set the blue expression.
  4795. @end table
  4796. The colorspace is selected according to the specified options. If one
  4797. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  4798. options is specified, the filter will automatically select a YCbCr
  4799. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  4800. @option{blue_expr} options is specified, it will select an RGB
  4801. colorspace.
  4802. If one of the chrominance expression is not defined, it falls back on the other
  4803. one. If no alpha expression is specified it will evaluate to opaque value.
  4804. If none of chrominance expressions are specified, they will evaluate
  4805. to the luminance expression.
  4806. The expressions can use the following variables and functions:
  4807. @table @option
  4808. @item N
  4809. The sequential number of the filtered frame, starting from @code{0}.
  4810. @item X
  4811. @item Y
  4812. The coordinates of the current sample.
  4813. @item W
  4814. @item H
  4815. The width and height of the image.
  4816. @item SW
  4817. @item SH
  4818. Width and height scale depending on the currently filtered plane. It is the
  4819. ratio between the corresponding luma plane number of pixels and the current
  4820. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  4821. @code{0.5,0.5} for chroma planes.
  4822. @item T
  4823. Time of the current frame, expressed in seconds.
  4824. @item p(x, y)
  4825. Return the value of the pixel at location (@var{x},@var{y}) of the current
  4826. plane.
  4827. @item lum(x, y)
  4828. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  4829. plane.
  4830. @item cb(x, y)
  4831. Return the value of the pixel at location (@var{x},@var{y}) of the
  4832. blue-difference chroma plane. Return 0 if there is no such plane.
  4833. @item cr(x, y)
  4834. Return the value of the pixel at location (@var{x},@var{y}) of the
  4835. red-difference chroma plane. Return 0 if there is no such plane.
  4836. @item r(x, y)
  4837. @item g(x, y)
  4838. @item b(x, y)
  4839. Return the value of the pixel at location (@var{x},@var{y}) of the
  4840. red/green/blue component. Return 0 if there is no such component.
  4841. @item alpha(x, y)
  4842. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  4843. plane. Return 0 if there is no such plane.
  4844. @end table
  4845. For functions, if @var{x} and @var{y} are outside the area, the value will be
  4846. automatically clipped to the closer edge.
  4847. @subsection Examples
  4848. @itemize
  4849. @item
  4850. Flip the image horizontally:
  4851. @example
  4852. geq=p(W-X\,Y)
  4853. @end example
  4854. @item
  4855. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  4856. wavelength of 100 pixels:
  4857. @example
  4858. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  4859. @end example
  4860. @item
  4861. Generate a fancy enigmatic moving light:
  4862. @example
  4863. 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
  4864. @end example
  4865. @item
  4866. Generate a quick emboss effect:
  4867. @example
  4868. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  4869. @end example
  4870. @item
  4871. Modify RGB components depending on pixel position:
  4872. @example
  4873. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  4874. @end example
  4875. @item
  4876. Create a radial gradient that is the same size as the input (also see
  4877. the @ref{vignette} filter):
  4878. @example
  4879. geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
  4880. @end example
  4881. @item
  4882. Create a linear gradient to use as a mask for another filter, then
  4883. compose with @ref{overlay}. In this example the video will gradually
  4884. become more blurry from the top to the bottom of the y-axis as defined
  4885. by the linear gradient:
  4886. @example
  4887. ffmpeg -i input.mp4 -filter_complex "geq=lum=255*(Y/H),format=gray[grad];[0:v]boxblur=4[blur];[blur][grad]alphamerge[alpha];[0:v][alpha]overlay" output.mp4
  4888. @end example
  4889. @end itemize
  4890. @section gradfun
  4891. Fix the banding artifacts that are sometimes introduced into nearly flat
  4892. regions by truncation to 8bit color depth.
  4893. Interpolate the gradients that should go where the bands are, and
  4894. dither them.
  4895. It is designed for playback only. Do not use it prior to
  4896. lossy compression, because compression tends to lose the dither and
  4897. bring back the bands.
  4898. It accepts the following parameters:
  4899. @table @option
  4900. @item strength
  4901. The maximum amount by which the filter will change any one pixel. This is also
  4902. the threshold for detecting nearly flat regions. Acceptable values range from
  4903. .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
  4904. valid range.
  4905. @item radius
  4906. The neighborhood to fit the gradient to. A larger radius makes for smoother
  4907. gradients, but also prevents the filter from modifying the pixels near detailed
  4908. regions. Acceptable values are 8-32; the default value is 16. Out-of-range
  4909. values will be clipped to the valid range.
  4910. @end table
  4911. Alternatively, the options can be specified as a flat string:
  4912. @var{strength}[:@var{radius}]
  4913. @subsection Examples
  4914. @itemize
  4915. @item
  4916. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  4917. @example
  4918. gradfun=3.5:8
  4919. @end example
  4920. @item
  4921. Specify radius, omitting the strength (which will fall-back to the default
  4922. value):
  4923. @example
  4924. gradfun=radius=8
  4925. @end example
  4926. @end itemize
  4927. @anchor{haldclut}
  4928. @section haldclut
  4929. Apply a Hald CLUT to a video stream.
  4930. First input is the video stream to process, and second one is the Hald CLUT.
  4931. The Hald CLUT input can be a simple picture or a complete video stream.
  4932. The filter accepts the following options:
  4933. @table @option
  4934. @item shortest
  4935. Force termination when the shortest input terminates. Default is @code{0}.
  4936. @item repeatlast
  4937. Continue applying the last CLUT after the end of the stream. A value of
  4938. @code{0} disable the filter after the last frame of the CLUT is reached.
  4939. Default is @code{1}.
  4940. @end table
  4941. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  4942. filters share the same internals).
  4943. More information about the Hald CLUT can be found on Eskil Steenberg's website
  4944. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  4945. @subsection Workflow examples
  4946. @subsubsection Hald CLUT video stream
  4947. Generate an identity Hald CLUT stream altered with various effects:
  4948. @example
  4949. 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
  4950. @end example
  4951. Note: make sure you use a lossless codec.
  4952. Then use it with @code{haldclut} to apply it on some random stream:
  4953. @example
  4954. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  4955. @end example
  4956. The Hald CLUT will be applied to the 10 first seconds (duration of
  4957. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  4958. to the remaining frames of the @code{mandelbrot} stream.
  4959. @subsubsection Hald CLUT with preview
  4960. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  4961. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  4962. biggest possible square starting at the top left of the picture. The remaining
  4963. padding pixels (bottom or right) will be ignored. This area can be used to add
  4964. a preview of the Hald CLUT.
  4965. Typically, the following generated Hald CLUT will be supported by the
  4966. @code{haldclut} filter:
  4967. @example
  4968. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  4969. pad=iw+320 [padded_clut];
  4970. smptebars=s=320x256, split [a][b];
  4971. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  4972. [main][b] overlay=W-320" -frames:v 1 clut.png
  4973. @end example
  4974. It contains the original and a preview of the effect of the CLUT: SMPTE color
  4975. bars are displayed on the right-top, and below the same color bars processed by
  4976. the color changes.
  4977. Then, the effect of this Hald CLUT can be visualized with:
  4978. @example
  4979. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  4980. @end example
  4981. @section hflip
  4982. Flip the input video horizontally.
  4983. For example, to horizontally flip the input video with @command{ffmpeg}:
  4984. @example
  4985. ffmpeg -i in.avi -vf "hflip" out.avi
  4986. @end example
  4987. @section histeq
  4988. This filter applies a global color histogram equalization on a
  4989. per-frame basis.
  4990. It can be used to correct video that has a compressed range of pixel
  4991. intensities. The filter redistributes the pixel intensities to
  4992. equalize their distribution across the intensity range. It may be
  4993. viewed as an "automatically adjusting contrast filter". This filter is
  4994. useful only for correcting degraded or poorly captured source
  4995. video.
  4996. The filter accepts the following options:
  4997. @table @option
  4998. @item strength
  4999. Determine the amount of equalization to be applied. As the strength
  5000. is reduced, the distribution of pixel intensities more-and-more
  5001. approaches that of the input frame. The value must be a float number
  5002. in the range [0,1] and defaults to 0.200.
  5003. @item intensity
  5004. Set the maximum intensity that can generated and scale the output
  5005. values appropriately. The strength should be set as desired and then
  5006. the intensity can be limited if needed to avoid washing-out. The value
  5007. must be a float number in the range [0,1] and defaults to 0.210.
  5008. @item antibanding
  5009. Set the antibanding level. If enabled the filter will randomly vary
  5010. the luminance of output pixels by a small amount to avoid banding of
  5011. the histogram. Possible values are @code{none}, @code{weak} or
  5012. @code{strong}. It defaults to @code{none}.
  5013. @end table
  5014. @section histogram
  5015. Compute and draw a color distribution histogram for the input video.
  5016. The computed histogram is a representation of the color component
  5017. distribution in an image.
  5018. The filter accepts the following options:
  5019. @table @option
  5020. @item mode
  5021. Set histogram mode.
  5022. It accepts the following values:
  5023. @table @samp
  5024. @item levels
  5025. Standard histogram that displays the color components distribution in an
  5026. image. Displays color graph for each color component. Shows distribution of
  5027. the Y, U, V, A or R, G, B components, depending on input format, in the
  5028. current frame. Below each graph a color component scale meter is shown.
  5029. @item color
  5030. Displays chroma values (U/V color placement) in a two dimensional
  5031. graph (which is called a vectorscope). The brighter a pixel in the
  5032. vectorscope, the more pixels of the input frame correspond to that pixel
  5033. (i.e., more pixels have this chroma value). The V component is displayed on
  5034. the horizontal (X) axis, with the leftmost side being V = 0 and the rightmost
  5035. side being V = 255. The U component is displayed on the vertical (Y) axis,
  5036. with the top representing U = 0 and the bottom representing U = 255.
  5037. The position of a white pixel in the graph corresponds to the chroma value of
  5038. a pixel of the input clip. The graph can therefore be used to read the hue
  5039. (color flavor) and the saturation (the dominance of the hue in the color). As
  5040. the hue of a color changes, it moves around the square. At the center of the
  5041. square the saturation is zero, which means that the corresponding pixel has no
  5042. color. If the amount of a specific color is increased (while leaving the other
  5043. colors unchanged) the saturation increases, and the indicator moves towards
  5044. the edge of the square.
  5045. @item color2
  5046. Chroma values in vectorscope, similar as @code{color} but actual chroma values
  5047. are displayed.
  5048. @item waveform
  5049. Per row/column color component graph. In row mode, the graph on the left side
  5050. represents color component value 0 and the right side represents value = 255.
  5051. In column mode, the top side represents color component value = 0 and bottom
  5052. side represents value = 255.
  5053. @end table
  5054. Default value is @code{levels}.
  5055. @item level_height
  5056. Set height of level in @code{levels}. Default value is @code{200}.
  5057. Allowed range is [50, 2048].
  5058. @item scale_height
  5059. Set height of color scale in @code{levels}. Default value is @code{12}.
  5060. Allowed range is [0, 40].
  5061. @item step
  5062. Set step for @code{waveform} mode. Smaller values are useful to find out how
  5063. many values of the same luminance are distributed across input rows/columns.
  5064. Default value is @code{10}. Allowed range is [1, 255].
  5065. @item waveform_mode
  5066. Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
  5067. Default is @code{row}.
  5068. @item waveform_mirror
  5069. Set mirroring mode for @code{waveform}. @code{0} means unmirrored, @code{1}
  5070. means mirrored. In mirrored mode, higher values will be represented on the left
  5071. side for @code{row} mode and at the top for @code{column} mode. Default is
  5072. @code{0} (unmirrored).
  5073. @item display_mode
  5074. Set display mode for @code{waveform} and @code{levels}.
  5075. It accepts the following values:
  5076. @table @samp
  5077. @item parade
  5078. Display separate graph for the color components side by side in
  5079. @code{row} waveform mode or one below the other in @code{column} waveform mode
  5080. for @code{waveform} histogram mode. For @code{levels} histogram mode,
  5081. per color component graphs are placed below each other.
  5082. Using this display mode in @code{waveform} histogram mode makes it easy to
  5083. spot color casts in the highlights and shadows of an image, by comparing the
  5084. contours of the top and the bottom graphs of each waveform. Since whites,
  5085. grays, and blacks are characterized by exactly equal amounts of red, green,
  5086. and blue, neutral areas of the picture should display three waveforms of
  5087. roughly equal width/height. If not, the correction is easy to perform by
  5088. making level adjustments the three waveforms.
  5089. @item overlay
  5090. Presents information identical to that in the @code{parade}, except
  5091. that the graphs representing color components are superimposed directly
  5092. over one another.
  5093. This display mode in @code{waveform} histogram mode makes it easier to spot
  5094. relative differences or similarities in overlapping areas of the color
  5095. components that are supposed to be identical, such as neutral whites, grays,
  5096. or blacks.
  5097. @end table
  5098. Default is @code{parade}.
  5099. @item levels_mode
  5100. Set mode for @code{levels}. Can be either @code{linear}, or @code{logarithmic}.
  5101. Default is @code{linear}.
  5102. @item components
  5103. Set what color components to display for mode @code{levels}.
  5104. Default is @code{7}.
  5105. @end table
  5106. @subsection Examples
  5107. @itemize
  5108. @item
  5109. Calculate and draw histogram:
  5110. @example
  5111. ffplay -i input -vf histogram
  5112. @end example
  5113. @end itemize
  5114. @anchor{hqdn3d}
  5115. @section hqdn3d
  5116. This is a high precision/quality 3d denoise filter. It aims to reduce
  5117. image noise, producing smooth images and making still images really
  5118. still. It should enhance compressibility.
  5119. It accepts the following optional parameters:
  5120. @table @option
  5121. @item luma_spatial
  5122. A non-negative floating point number which specifies spatial luma strength.
  5123. It defaults to 4.0.
  5124. @item chroma_spatial
  5125. A non-negative floating point number which specifies spatial chroma strength.
  5126. It defaults to 3.0*@var{luma_spatial}/4.0.
  5127. @item luma_tmp
  5128. A floating point number which specifies luma temporal strength. It defaults to
  5129. 6.0*@var{luma_spatial}/4.0.
  5130. @item chroma_tmp
  5131. A floating point number which specifies chroma temporal strength. It defaults to
  5132. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
  5133. @end table
  5134. @section hqx
  5135. Apply a high-quality magnification filter designed for pixel art. This filter
  5136. was originally created by Maxim Stepin.
  5137. It accepts the following option:
  5138. @table @option
  5139. @item n
  5140. Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
  5141. @code{hq3x} and @code{4} for @code{hq4x}.
  5142. Default is @code{3}.
  5143. @end table
  5144. @section hstack
  5145. Stack input videos horizontally.
  5146. All streams must be of same pixel format and of same height.
  5147. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  5148. to create same output.
  5149. The filter accept the following option:
  5150. @table @option
  5151. @item nb_inputs
  5152. Set number of input streams. Default is 2.
  5153. @end table
  5154. @section hue
  5155. Modify the hue and/or the saturation of the input.
  5156. It accepts the following parameters:
  5157. @table @option
  5158. @item h
  5159. Specify the hue angle as a number of degrees. It accepts an expression,
  5160. and defaults to "0".
  5161. @item s
  5162. Specify the saturation in the [-10,10] range. It accepts an expression and
  5163. defaults to "1".
  5164. @item H
  5165. Specify the hue angle as a number of radians. It accepts an
  5166. expression, and defaults to "0".
  5167. @item b
  5168. Specify the brightness in the [-10,10] range. It accepts an expression and
  5169. defaults to "0".
  5170. @end table
  5171. @option{h} and @option{H} are mutually exclusive, and can't be
  5172. specified at the same time.
  5173. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  5174. expressions containing the following constants:
  5175. @table @option
  5176. @item n
  5177. frame count of the input frame starting from 0
  5178. @item pts
  5179. presentation timestamp of the input frame expressed in time base units
  5180. @item r
  5181. frame rate of the input video, NAN if the input frame rate is unknown
  5182. @item t
  5183. timestamp expressed in seconds, NAN if the input timestamp is unknown
  5184. @item tb
  5185. time base of the input video
  5186. @end table
  5187. @subsection Examples
  5188. @itemize
  5189. @item
  5190. Set the hue to 90 degrees and the saturation to 1.0:
  5191. @example
  5192. hue=h=90:s=1
  5193. @end example
  5194. @item
  5195. Same command but expressing the hue in radians:
  5196. @example
  5197. hue=H=PI/2:s=1
  5198. @end example
  5199. @item
  5200. Rotate hue and make the saturation swing between 0
  5201. and 2 over a period of 1 second:
  5202. @example
  5203. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  5204. @end example
  5205. @item
  5206. Apply a 3 seconds saturation fade-in effect starting at 0:
  5207. @example
  5208. hue="s=min(t/3\,1)"
  5209. @end example
  5210. The general fade-in expression can be written as:
  5211. @example
  5212. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  5213. @end example
  5214. @item
  5215. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  5216. @example
  5217. hue="s=max(0\, min(1\, (8-t)/3))"
  5218. @end example
  5219. The general fade-out expression can be written as:
  5220. @example
  5221. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  5222. @end example
  5223. @end itemize
  5224. @subsection Commands
  5225. This filter supports the following commands:
  5226. @table @option
  5227. @item b
  5228. @item s
  5229. @item h
  5230. @item H
  5231. Modify the hue and/or the saturation and/or brightness of the input video.
  5232. The command accepts the same syntax of the corresponding option.
  5233. If the specified expression is not valid, it is kept at its current
  5234. value.
  5235. @end table
  5236. @section idet
  5237. Detect video interlacing type.
  5238. This filter tries to detect if the input frames as interlaced, progressive,
  5239. top or bottom field first. It will also try and detect fields that are
  5240. repeated between adjacent frames (a sign of telecine).
  5241. Single frame detection considers only immediately adjacent frames when classifying each frame.
  5242. Multiple frame detection incorporates the classification history of previous frames.
  5243. The filter will log these metadata values:
  5244. @table @option
  5245. @item single.current_frame
  5246. Detected type of current frame using single-frame detection. One of:
  5247. ``tff'' (top field first), ``bff'' (bottom field first),
  5248. ``progressive'', or ``undetermined''
  5249. @item single.tff
  5250. Cumulative number of frames detected as top field first using single-frame detection.
  5251. @item multiple.tff
  5252. Cumulative number of frames detected as top field first using multiple-frame detection.
  5253. @item single.bff
  5254. Cumulative number of frames detected as bottom field first using single-frame detection.
  5255. @item multiple.current_frame
  5256. Detected type of current frame using multiple-frame detection. One of:
  5257. ``tff'' (top field first), ``bff'' (bottom field first),
  5258. ``progressive'', or ``undetermined''
  5259. @item multiple.bff
  5260. Cumulative number of frames detected as bottom field first using multiple-frame detection.
  5261. @item single.progressive
  5262. Cumulative number of frames detected as progressive using single-frame detection.
  5263. @item multiple.progressive
  5264. Cumulative number of frames detected as progressive using multiple-frame detection.
  5265. @item single.undetermined
  5266. Cumulative number of frames that could not be classified using single-frame detection.
  5267. @item multiple.undetermined
  5268. Cumulative number of frames that could not be classified using multiple-frame detection.
  5269. @item repeated.current_frame
  5270. Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
  5271. @item repeated.neither
  5272. Cumulative number of frames with no repeated field.
  5273. @item repeated.top
  5274. Cumulative number of frames with the top field repeated from the previous frame's top field.
  5275. @item repeated.bottom
  5276. Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
  5277. @end table
  5278. The filter accepts the following options:
  5279. @table @option
  5280. @item intl_thres
  5281. Set interlacing threshold.
  5282. @item prog_thres
  5283. Set progressive threshold.
  5284. @item repeat_thres
  5285. Threshold for repeated field detection.
  5286. @item half_life
  5287. Number of frames after which a given frame's contribution to the
  5288. statistics is halved (i.e., it contributes only 0.5 to it's
  5289. classification). The default of 0 means that all frames seen are given
  5290. full weight of 1.0 forever.
  5291. @item analyze_interlaced_flag
  5292. When this is not 0 then idet will use the specified number of frames to determine
  5293. if the interlaced flag is accurate, it will not count undetermined frames.
  5294. If the flag is found to be accurate it will be used without any further
  5295. computations, if it is found to be inaccurate it will be cleared without any
  5296. further computations. This allows inserting the idet filter as a low computational
  5297. method to clean up the interlaced flag
  5298. @end table
  5299. @section il
  5300. Deinterleave or interleave fields.
  5301. This filter allows one to process interlaced images fields without
  5302. deinterlacing them. Deinterleaving splits the input frame into 2
  5303. fields (so called half pictures). Odd lines are moved to the top
  5304. half of the output image, even lines to the bottom half.
  5305. You can process (filter) them independently and then re-interleave them.
  5306. The filter accepts the following options:
  5307. @table @option
  5308. @item luma_mode, l
  5309. @item chroma_mode, c
  5310. @item alpha_mode, a
  5311. Available values for @var{luma_mode}, @var{chroma_mode} and
  5312. @var{alpha_mode} are:
  5313. @table @samp
  5314. @item none
  5315. Do nothing.
  5316. @item deinterleave, d
  5317. Deinterleave fields, placing one above the other.
  5318. @item interleave, i
  5319. Interleave fields. Reverse the effect of deinterleaving.
  5320. @end table
  5321. Default value is @code{none}.
  5322. @item luma_swap, ls
  5323. @item chroma_swap, cs
  5324. @item alpha_swap, as
  5325. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  5326. @end table
  5327. @section inflate
  5328. Apply inflate effect to the video.
  5329. This filter replaces the pixel by the local(3x3) average by taking into account
  5330. only values higher than the pixel.
  5331. It accepts the following options:
  5332. @table @option
  5333. @item threshold0
  5334. @item threshold1
  5335. @item threshold2
  5336. @item threshold3
  5337. Allows to limit the maximum change for each plane, default is 65535.
  5338. If 0, plane will remain unchanged.
  5339. @end table
  5340. @section interlace
  5341. Simple interlacing filter from progressive contents. This interleaves upper (or
  5342. lower) lines from odd frames with lower (or upper) lines from even frames,
  5343. halving the frame rate and preserving image height.
  5344. @example
  5345. Original Original New Frame
  5346. Frame 'j' Frame 'j+1' (tff)
  5347. ========== =========== ==================
  5348. Line 0 --------------------> Frame 'j' Line 0
  5349. Line 1 Line 1 ----> Frame 'j+1' Line 1
  5350. Line 2 ---------------------> Frame 'j' Line 2
  5351. Line 3 Line 3 ----> Frame 'j+1' Line 3
  5352. ... ... ...
  5353. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  5354. @end example
  5355. It accepts the following optional parameters:
  5356. @table @option
  5357. @item scan
  5358. This determines whether the interlaced frame is taken from the even
  5359. (tff - default) or odd (bff) lines of the progressive frame.
  5360. @item lowpass
  5361. Enable (default) or disable the vertical lowpass filter to avoid twitter
  5362. interlacing and reduce moire patterns.
  5363. @end table
  5364. @section kerndeint
  5365. Deinterlace input video by applying Donald Graft's adaptive kernel
  5366. deinterling. Work on interlaced parts of a video to produce
  5367. progressive frames.
  5368. The description of the accepted parameters follows.
  5369. @table @option
  5370. @item thresh
  5371. Set the threshold which affects the filter's tolerance when
  5372. determining if a pixel line must be processed. It must be an integer
  5373. in the range [0,255] and defaults to 10. A value of 0 will result in
  5374. applying the process on every pixels.
  5375. @item map
  5376. Paint pixels exceeding the threshold value to white if set to 1.
  5377. Default is 0.
  5378. @item order
  5379. Set the fields order. Swap fields if set to 1, leave fields alone if
  5380. 0. Default is 0.
  5381. @item sharp
  5382. Enable additional sharpening if set to 1. Default is 0.
  5383. @item twoway
  5384. Enable twoway sharpening if set to 1. Default is 0.
  5385. @end table
  5386. @subsection Examples
  5387. @itemize
  5388. @item
  5389. Apply default values:
  5390. @example
  5391. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  5392. @end example
  5393. @item
  5394. Enable additional sharpening:
  5395. @example
  5396. kerndeint=sharp=1
  5397. @end example
  5398. @item
  5399. Paint processed pixels in white:
  5400. @example
  5401. kerndeint=map=1
  5402. @end example
  5403. @end itemize
  5404. @section lenscorrection
  5405. Correct radial lens distortion
  5406. This filter can be used to correct for radial distortion as can result from the use
  5407. of wide angle lenses, and thereby re-rectify the image. To find the right parameters
  5408. one can use tools available for example as part of opencv or simply trial-and-error.
  5409. To use opencv use the calibration sample (under samples/cpp) from the opencv sources
  5410. and extract the k1 and k2 coefficients from the resulting matrix.
  5411. Note that effectively the same filter is available in the open-source tools Krita and
  5412. Digikam from the KDE project.
  5413. In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
  5414. this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
  5415. brightness distribution, so you may want to use both filters together in certain
  5416. cases, though you will have to take care of ordering, i.e. whether vignetting should
  5417. be applied before or after lens correction.
  5418. @subsection Options
  5419. The filter accepts the following options:
  5420. @table @option
  5421. @item cx
  5422. Relative x-coordinate of the focal point of the image, and thereby the center of the
  5423. distortion. This value has a range [0,1] and is expressed as fractions of the image
  5424. width.
  5425. @item cy
  5426. Relative y-coordinate of the focal point of the image, and thereby the center of the
  5427. distortion. This value has a range [0,1] and is expressed as fractions of the image
  5428. height.
  5429. @item k1
  5430. Coefficient of the quadratic correction term. 0.5 means no correction.
  5431. @item k2
  5432. Coefficient of the double quadratic correction term. 0.5 means no correction.
  5433. @end table
  5434. The formula that generates the correction is:
  5435. @var{r_src} = @var{r_tgt} * (1 + @var{k1} * (@var{r_tgt} / @var{r_0})^2 + @var{k2} * (@var{r_tgt} / @var{r_0})^4)
  5436. where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
  5437. distances from the focal point in the source and target images, respectively.
  5438. @anchor{lut3d}
  5439. @section lut3d
  5440. Apply a 3D LUT to an input video.
  5441. The filter accepts the following options:
  5442. @table @option
  5443. @item file
  5444. Set the 3D LUT file name.
  5445. Currently supported formats:
  5446. @table @samp
  5447. @item 3dl
  5448. AfterEffects
  5449. @item cube
  5450. Iridas
  5451. @item dat
  5452. DaVinci
  5453. @item m3d
  5454. Pandora
  5455. @end table
  5456. @item interp
  5457. Select interpolation mode.
  5458. Available values are:
  5459. @table @samp
  5460. @item nearest
  5461. Use values from the nearest defined point.
  5462. @item trilinear
  5463. Interpolate values using the 8 points defining a cube.
  5464. @item tetrahedral
  5465. Interpolate values using a tetrahedron.
  5466. @end table
  5467. @end table
  5468. @section lut, lutrgb, lutyuv
  5469. Compute a look-up table for binding each pixel component input value
  5470. to an output value, and apply it to the input video.
  5471. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  5472. to an RGB input video.
  5473. These filters accept the following parameters:
  5474. @table @option
  5475. @item c0
  5476. set first pixel component expression
  5477. @item c1
  5478. set second pixel component expression
  5479. @item c2
  5480. set third pixel component expression
  5481. @item c3
  5482. set fourth pixel component expression, corresponds to the alpha component
  5483. @item r
  5484. set red component expression
  5485. @item g
  5486. set green component expression
  5487. @item b
  5488. set blue component expression
  5489. @item a
  5490. alpha component expression
  5491. @item y
  5492. set Y/luminance component expression
  5493. @item u
  5494. set U/Cb component expression
  5495. @item v
  5496. set V/Cr component expression
  5497. @end table
  5498. Each of them specifies the expression to use for computing the lookup table for
  5499. the corresponding pixel component values.
  5500. The exact component associated to each of the @var{c*} options depends on the
  5501. format in input.
  5502. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  5503. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  5504. The expressions can contain the following constants and functions:
  5505. @table @option
  5506. @item w
  5507. @item h
  5508. The input width and height.
  5509. @item val
  5510. The input value for the pixel component.
  5511. @item clipval
  5512. The input value, clipped to the @var{minval}-@var{maxval} range.
  5513. @item maxval
  5514. The maximum value for the pixel component.
  5515. @item minval
  5516. The minimum value for the pixel component.
  5517. @item negval
  5518. The negated value for the pixel component value, clipped to the
  5519. @var{minval}-@var{maxval} range; it corresponds to the expression
  5520. "maxval-clipval+minval".
  5521. @item clip(val)
  5522. The computed value in @var{val}, clipped to the
  5523. @var{minval}-@var{maxval} range.
  5524. @item gammaval(gamma)
  5525. The computed gamma correction value of the pixel component value,
  5526. clipped to the @var{minval}-@var{maxval} range. It corresponds to the
  5527. expression
  5528. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  5529. @end table
  5530. All expressions default to "val".
  5531. @subsection Examples
  5532. @itemize
  5533. @item
  5534. Negate input video:
  5535. @example
  5536. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  5537. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  5538. @end example
  5539. The above is the same as:
  5540. @example
  5541. lutrgb="r=negval:g=negval:b=negval"
  5542. lutyuv="y=negval:u=negval:v=negval"
  5543. @end example
  5544. @item
  5545. Negate luminance:
  5546. @example
  5547. lutyuv=y=negval
  5548. @end example
  5549. @item
  5550. Remove chroma components, turning the video into a graytone image:
  5551. @example
  5552. lutyuv="u=128:v=128"
  5553. @end example
  5554. @item
  5555. Apply a luma burning effect:
  5556. @example
  5557. lutyuv="y=2*val"
  5558. @end example
  5559. @item
  5560. Remove green and blue components:
  5561. @example
  5562. lutrgb="g=0:b=0"
  5563. @end example
  5564. @item
  5565. Set a constant alpha channel value on input:
  5566. @example
  5567. format=rgba,lutrgb=a="maxval-minval/2"
  5568. @end example
  5569. @item
  5570. Correct luminance gamma by a factor of 0.5:
  5571. @example
  5572. lutyuv=y=gammaval(0.5)
  5573. @end example
  5574. @item
  5575. Discard least significant bits of luma:
  5576. @example
  5577. lutyuv=y='bitand(val, 128+64+32)'
  5578. @end example
  5579. @end itemize
  5580. @section mergeplanes
  5581. Merge color channel components from several video streams.
  5582. The filter accepts up to 4 input streams, and merge selected input
  5583. planes to the output video.
  5584. This filter accepts the following options:
  5585. @table @option
  5586. @item mapping
  5587. Set input to output plane mapping. Default is @code{0}.
  5588. The mappings is specified as a bitmap. It should be specified as a
  5589. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  5590. mapping for the first plane of the output stream. 'A' sets the number of
  5591. the input stream to use (from 0 to 3), and 'a' the plane number of the
  5592. corresponding input to use (from 0 to 3). The rest of the mappings is
  5593. similar, 'Bb' describes the mapping for the output stream second
  5594. plane, 'Cc' describes the mapping for the output stream third plane and
  5595. 'Dd' describes the mapping for the output stream fourth plane.
  5596. @item format
  5597. Set output pixel format. Default is @code{yuva444p}.
  5598. @end table
  5599. @subsection Examples
  5600. @itemize
  5601. @item
  5602. Merge three gray video streams of same width and height into single video stream:
  5603. @example
  5604. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  5605. @end example
  5606. @item
  5607. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  5608. @example
  5609. [a0][a1]mergeplanes=0x00010210:yuva444p
  5610. @end example
  5611. @item
  5612. Swap Y and A plane in yuva444p stream:
  5613. @example
  5614. format=yuva444p,mergeplanes=0x03010200:yuva444p
  5615. @end example
  5616. @item
  5617. Swap U and V plane in yuv420p stream:
  5618. @example
  5619. format=yuv420p,mergeplanes=0x000201:yuv420p
  5620. @end example
  5621. @item
  5622. Cast a rgb24 clip to yuv444p:
  5623. @example
  5624. format=rgb24,mergeplanes=0x000102:yuv444p
  5625. @end example
  5626. @end itemize
  5627. @section mcdeint
  5628. Apply motion-compensation deinterlacing.
  5629. It needs one field per frame as input and must thus be used together
  5630. with yadif=1/3 or equivalent.
  5631. This filter accepts the following options:
  5632. @table @option
  5633. @item mode
  5634. Set the deinterlacing mode.
  5635. It accepts one of the following values:
  5636. @table @samp
  5637. @item fast
  5638. @item medium
  5639. @item slow
  5640. use iterative motion estimation
  5641. @item extra_slow
  5642. like @samp{slow}, but use multiple reference frames.
  5643. @end table
  5644. Default value is @samp{fast}.
  5645. @item parity
  5646. Set the picture field parity assumed for the input video. It must be
  5647. one of the following values:
  5648. @table @samp
  5649. @item 0, tff
  5650. assume top field first
  5651. @item 1, bff
  5652. assume bottom field first
  5653. @end table
  5654. Default value is @samp{bff}.
  5655. @item qp
  5656. Set per-block quantization parameter (QP) used by the internal
  5657. encoder.
  5658. Higher values should result in a smoother motion vector field but less
  5659. optimal individual vectors. Default value is 1.
  5660. @end table
  5661. @section mpdecimate
  5662. Drop frames that do not differ greatly from the previous frame in
  5663. order to reduce frame rate.
  5664. The main use of this filter is for very-low-bitrate encoding
  5665. (e.g. streaming over dialup modem), but it could in theory be used for
  5666. fixing movies that were inverse-telecined incorrectly.
  5667. A description of the accepted options follows.
  5668. @table @option
  5669. @item max
  5670. Set the maximum number of consecutive frames which can be dropped (if
  5671. positive), or the minimum interval between dropped frames (if
  5672. negative). If the value is 0, the frame is dropped unregarding the
  5673. number of previous sequentially dropped frames.
  5674. Default value is 0.
  5675. @item hi
  5676. @item lo
  5677. @item frac
  5678. Set the dropping threshold values.
  5679. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  5680. represent actual pixel value differences, so a threshold of 64
  5681. corresponds to 1 unit of difference for each pixel, or the same spread
  5682. out differently over the block.
  5683. A frame is a candidate for dropping if no 8x8 blocks differ by more
  5684. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  5685. meaning the whole image) differ by more than a threshold of @option{lo}.
  5686. Default value for @option{hi} is 64*12, default value for @option{lo} is
  5687. 64*5, and default value for @option{frac} is 0.33.
  5688. @end table
  5689. @section negate
  5690. Negate input video.
  5691. It accepts an integer in input; if non-zero it negates the
  5692. alpha component (if available). The default value in input is 0.
  5693. @section noformat
  5694. Force libavfilter not to use any of the specified pixel formats for the
  5695. input to the next filter.
  5696. It accepts the following parameters:
  5697. @table @option
  5698. @item pix_fmts
  5699. A '|'-separated list of pixel format names, such as
  5700. apix_fmts=yuv420p|monow|rgb24".
  5701. @end table
  5702. @subsection Examples
  5703. @itemize
  5704. @item
  5705. Force libavfilter to use a format different from @var{yuv420p} for the
  5706. input to the vflip filter:
  5707. @example
  5708. noformat=pix_fmts=yuv420p,vflip
  5709. @end example
  5710. @item
  5711. Convert the input video to any of the formats not contained in the list:
  5712. @example
  5713. noformat=yuv420p|yuv444p|yuv410p
  5714. @end example
  5715. @end itemize
  5716. @section noise
  5717. Add noise on video input frame.
  5718. The filter accepts the following options:
  5719. @table @option
  5720. @item all_seed
  5721. @item c0_seed
  5722. @item c1_seed
  5723. @item c2_seed
  5724. @item c3_seed
  5725. Set noise seed for specific pixel component or all pixel components in case
  5726. of @var{all_seed}. Default value is @code{123457}.
  5727. @item all_strength, alls
  5728. @item c0_strength, c0s
  5729. @item c1_strength, c1s
  5730. @item c2_strength, c2s
  5731. @item c3_strength, c3s
  5732. Set noise strength for specific pixel component or all pixel components in case
  5733. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  5734. @item all_flags, allf
  5735. @item c0_flags, c0f
  5736. @item c1_flags, c1f
  5737. @item c2_flags, c2f
  5738. @item c3_flags, c3f
  5739. Set pixel component flags or set flags for all components if @var{all_flags}.
  5740. Available values for component flags are:
  5741. @table @samp
  5742. @item a
  5743. averaged temporal noise (smoother)
  5744. @item p
  5745. mix random noise with a (semi)regular pattern
  5746. @item t
  5747. temporal noise (noise pattern changes between frames)
  5748. @item u
  5749. uniform noise (gaussian otherwise)
  5750. @end table
  5751. @end table
  5752. @subsection Examples
  5753. Add temporal and uniform noise to input video:
  5754. @example
  5755. noise=alls=20:allf=t+u
  5756. @end example
  5757. @section null
  5758. Pass the video source unchanged to the output.
  5759. @section ocv
  5760. Apply a video transform using libopencv.
  5761. To enable this filter, install the libopencv library and headers and
  5762. configure FFmpeg with @code{--enable-libopencv}.
  5763. It accepts the following parameters:
  5764. @table @option
  5765. @item filter_name
  5766. The name of the libopencv filter to apply.
  5767. @item filter_params
  5768. The parameters to pass to the libopencv filter. If not specified, the default
  5769. values are assumed.
  5770. @end table
  5771. Refer to the official libopencv documentation for more precise
  5772. information:
  5773. @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
  5774. Several libopencv filters are supported; see the following subsections.
  5775. @anchor{dilate}
  5776. @subsection dilate
  5777. Dilate an image by using a specific structuring element.
  5778. It corresponds to the libopencv function @code{cvDilate}.
  5779. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  5780. @var{struct_el} represents a structuring element, and has the syntax:
  5781. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  5782. @var{cols} and @var{rows} represent the number of columns and rows of
  5783. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  5784. point, and @var{shape} the shape for the structuring element. @var{shape}
  5785. must be "rect", "cross", "ellipse", or "custom".
  5786. If the value for @var{shape} is "custom", it must be followed by a
  5787. string of the form "=@var{filename}". The file with name
  5788. @var{filename} is assumed to represent a binary image, with each
  5789. printable character corresponding to a bright pixel. When a custom
  5790. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  5791. or columns and rows of the read file are assumed instead.
  5792. The default value for @var{struct_el} is "3x3+0x0/rect".
  5793. @var{nb_iterations} specifies the number of times the transform is
  5794. applied to the image, and defaults to 1.
  5795. Some examples:
  5796. @example
  5797. # Use the default values
  5798. ocv=dilate
  5799. # Dilate using a structuring element with a 5x5 cross, iterating two times
  5800. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  5801. # Read the shape from the file diamond.shape, iterating two times.
  5802. # The file diamond.shape may contain a pattern of characters like this
  5803. # *
  5804. # ***
  5805. # *****
  5806. # ***
  5807. # *
  5808. # The specified columns and rows are ignored
  5809. # but the anchor point coordinates are not
  5810. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  5811. @end example
  5812. @subsection erode
  5813. Erode an image by using a specific structuring element.
  5814. It corresponds to the libopencv function @code{cvErode}.
  5815. It accepts the parameters: @var{struct_el}:@var{nb_iterations},
  5816. with the same syntax and semantics as the @ref{dilate} filter.
  5817. @subsection smooth
  5818. Smooth the input video.
  5819. The filter takes the following parameters:
  5820. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  5821. @var{type} is the type of smooth filter to apply, and must be one of
  5822. the following values: "blur", "blur_no_scale", "median", "gaussian",
  5823. or "bilateral". The default value is "gaussian".
  5824. The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
  5825. depend on the smooth type. @var{param1} and
  5826. @var{param2} accept integer positive values or 0. @var{param3} and
  5827. @var{param4} accept floating point values.
  5828. The default value for @var{param1} is 3. The default value for the
  5829. other parameters is 0.
  5830. These parameters correspond to the parameters assigned to the
  5831. libopencv function @code{cvSmooth}.
  5832. @anchor{overlay}
  5833. @section overlay
  5834. Overlay one video on top of another.
  5835. It takes two inputs and has one output. The first input is the "main"
  5836. video on which the second input is overlaid.
  5837. It accepts the following parameters:
  5838. A description of the accepted options follows.
  5839. @table @option
  5840. @item x
  5841. @item y
  5842. Set the expression for the x and y coordinates of the overlaid video
  5843. on the main video. Default value is "0" for both expressions. In case
  5844. the expression is invalid, it is set to a huge value (meaning that the
  5845. overlay will not be displayed within the output visible area).
  5846. @item eof_action
  5847. The action to take when EOF is encountered on the secondary input; it accepts
  5848. one of the following values:
  5849. @table @option
  5850. @item repeat
  5851. Repeat the last frame (the default).
  5852. @item endall
  5853. End both streams.
  5854. @item pass
  5855. Pass the main input through.
  5856. @end table
  5857. @item eval
  5858. Set when the expressions for @option{x}, and @option{y} are evaluated.
  5859. It accepts the following values:
  5860. @table @samp
  5861. @item init
  5862. only evaluate expressions once during the filter initialization or
  5863. when a command is processed
  5864. @item frame
  5865. evaluate expressions for each incoming frame
  5866. @end table
  5867. Default value is @samp{frame}.
  5868. @item shortest
  5869. If set to 1, force the output to terminate when the shortest input
  5870. terminates. Default value is 0.
  5871. @item format
  5872. Set the format for the output video.
  5873. It accepts the following values:
  5874. @table @samp
  5875. @item yuv420
  5876. force YUV420 output
  5877. @item yuv422
  5878. force YUV422 output
  5879. @item yuv444
  5880. force YUV444 output
  5881. @item rgb
  5882. force RGB output
  5883. @end table
  5884. Default value is @samp{yuv420}.
  5885. @item rgb @emph{(deprecated)}
  5886. If set to 1, force the filter to accept inputs in the RGB
  5887. color space. Default value is 0. This option is deprecated, use
  5888. @option{format} instead.
  5889. @item repeatlast
  5890. If set to 1, force the filter to draw the last overlay frame over the
  5891. main input until the end of the stream. A value of 0 disables this
  5892. behavior. Default value is 1.
  5893. @end table
  5894. The @option{x}, and @option{y} expressions can contain the following
  5895. parameters.
  5896. @table @option
  5897. @item main_w, W
  5898. @item main_h, H
  5899. The main input width and height.
  5900. @item overlay_w, w
  5901. @item overlay_h, h
  5902. The overlay input width and height.
  5903. @item x
  5904. @item y
  5905. The computed values for @var{x} and @var{y}. They are evaluated for
  5906. each new frame.
  5907. @item hsub
  5908. @item vsub
  5909. horizontal and vertical chroma subsample values of the output
  5910. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  5911. @var{vsub} is 1.
  5912. @item n
  5913. the number of input frame, starting from 0
  5914. @item pos
  5915. the position in the file of the input frame, NAN if unknown
  5916. @item t
  5917. The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
  5918. @end table
  5919. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  5920. when evaluation is done @emph{per frame}, and will evaluate to NAN
  5921. when @option{eval} is set to @samp{init}.
  5922. Be aware that frames are taken from each input video in timestamp
  5923. order, hence, if their initial timestamps differ, it is a good idea
  5924. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  5925. have them begin in the same zero timestamp, as the example for
  5926. the @var{movie} filter does.
  5927. You can chain together more overlays but you should test the
  5928. efficiency of such approach.
  5929. @subsection Commands
  5930. This filter supports the following commands:
  5931. @table @option
  5932. @item x
  5933. @item y
  5934. Modify the x and y of the overlay input.
  5935. The command accepts the same syntax of the corresponding option.
  5936. If the specified expression is not valid, it is kept at its current
  5937. value.
  5938. @end table
  5939. @subsection Examples
  5940. @itemize
  5941. @item
  5942. Draw the overlay at 10 pixels from the bottom right corner of the main
  5943. video:
  5944. @example
  5945. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  5946. @end example
  5947. Using named options the example above becomes:
  5948. @example
  5949. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  5950. @end example
  5951. @item
  5952. Insert a transparent PNG logo in the bottom left corner of the input,
  5953. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  5954. @example
  5955. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  5956. @end example
  5957. @item
  5958. Insert 2 different transparent PNG logos (second logo on bottom
  5959. right corner) using the @command{ffmpeg} tool:
  5960. @example
  5961. 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
  5962. @end example
  5963. @item
  5964. Add a transparent color layer on top of the main video; @code{WxH}
  5965. must specify the size of the main input to the overlay filter:
  5966. @example
  5967. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  5968. @end example
  5969. @item
  5970. Play an original video and a filtered version (here with the deshake
  5971. filter) side by side using the @command{ffplay} tool:
  5972. @example
  5973. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  5974. @end example
  5975. The above command is the same as:
  5976. @example
  5977. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  5978. @end example
  5979. @item
  5980. Make a sliding overlay appearing from the left to the right top part of the
  5981. screen starting since time 2:
  5982. @example
  5983. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  5984. @end example
  5985. @item
  5986. Compose output by putting two input videos side to side:
  5987. @example
  5988. ffmpeg -i left.avi -i right.avi -filter_complex "
  5989. nullsrc=size=200x100 [background];
  5990. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  5991. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  5992. [background][left] overlay=shortest=1 [background+left];
  5993. [background+left][right] overlay=shortest=1:x=100 [left+right]
  5994. "
  5995. @end example
  5996. @item
  5997. Mask 10-20 seconds of a video by applying the delogo filter to a section
  5998. @example
  5999. ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
  6000. -vf '[in]split[split_main][split_delogo];[split_delogo]trim=start=360:end=371,delogo=0:0:640:480[delogoed];[split_main][delogoed]overlay=eof_action=pass[out]'
  6001. masked.avi
  6002. @end example
  6003. @item
  6004. Chain several overlays in cascade:
  6005. @example
  6006. nullsrc=s=200x200 [bg];
  6007. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  6008. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  6009. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  6010. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  6011. [in3] null, [mid2] overlay=100:100 [out0]
  6012. @end example
  6013. @end itemize
  6014. @section owdenoise
  6015. Apply Overcomplete Wavelet denoiser.
  6016. The filter accepts the following options:
  6017. @table @option
  6018. @item depth
  6019. Set depth.
  6020. Larger depth values will denoise lower frequency components more, but
  6021. slow down filtering.
  6022. Must be an int in the range 8-16, default is @code{8}.
  6023. @item luma_strength, ls
  6024. Set luma strength.
  6025. Must be a double value in the range 0-1000, default is @code{1.0}.
  6026. @item chroma_strength, cs
  6027. Set chroma strength.
  6028. Must be a double value in the range 0-1000, default is @code{1.0}.
  6029. @end table
  6030. @anchor{pad}
  6031. @section pad
  6032. Add paddings to the input image, and place the original input at the
  6033. provided @var{x}, @var{y} coordinates.
  6034. It accepts the following parameters:
  6035. @table @option
  6036. @item width, w
  6037. @item height, h
  6038. Specify an expression for the size of the output image with the
  6039. paddings added. If the value for @var{width} or @var{height} is 0, the
  6040. corresponding input size is used for the output.
  6041. The @var{width} expression can reference the value set by the
  6042. @var{height} expression, and vice versa.
  6043. The default value of @var{width} and @var{height} is 0.
  6044. @item x
  6045. @item y
  6046. Specify the offsets to place the input image at within the padded area,
  6047. with respect to the top/left border of the output image.
  6048. The @var{x} expression can reference the value set by the @var{y}
  6049. expression, and vice versa.
  6050. The default value of @var{x} and @var{y} is 0.
  6051. @item color
  6052. Specify the color of the padded area. For the syntax of this option,
  6053. check the "Color" section in the ffmpeg-utils manual.
  6054. The default value of @var{color} is "black".
  6055. @end table
  6056. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  6057. options are expressions containing the following constants:
  6058. @table @option
  6059. @item in_w
  6060. @item in_h
  6061. The input video width and height.
  6062. @item iw
  6063. @item ih
  6064. These are the same as @var{in_w} and @var{in_h}.
  6065. @item out_w
  6066. @item out_h
  6067. The output width and height (the size of the padded area), as
  6068. specified by the @var{width} and @var{height} expressions.
  6069. @item ow
  6070. @item oh
  6071. These are the same as @var{out_w} and @var{out_h}.
  6072. @item x
  6073. @item y
  6074. The x and y offsets as specified by the @var{x} and @var{y}
  6075. expressions, or NAN if not yet specified.
  6076. @item a
  6077. same as @var{iw} / @var{ih}
  6078. @item sar
  6079. input sample aspect ratio
  6080. @item dar
  6081. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  6082. @item hsub
  6083. @item vsub
  6084. The horizontal and vertical chroma subsample values. For example for the
  6085. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6086. @end table
  6087. @subsection Examples
  6088. @itemize
  6089. @item
  6090. Add paddings with the color "violet" to the input video. The output video
  6091. size is 640x480, and the top-left corner of the input video is placed at
  6092. column 0, row 40
  6093. @example
  6094. pad=640:480:0:40:violet
  6095. @end example
  6096. The example above is equivalent to the following command:
  6097. @example
  6098. pad=width=640:height=480:x=0:y=40:color=violet
  6099. @end example
  6100. @item
  6101. Pad the input to get an output with dimensions increased by 3/2,
  6102. and put the input video at the center of the padded area:
  6103. @example
  6104. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  6105. @end example
  6106. @item
  6107. Pad the input to get a squared output with size equal to the maximum
  6108. value between the input width and height, and put the input video at
  6109. the center of the padded area:
  6110. @example
  6111. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  6112. @end example
  6113. @item
  6114. Pad the input to get a final w/h ratio of 16:9:
  6115. @example
  6116. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  6117. @end example
  6118. @item
  6119. In case of anamorphic video, in order to set the output display aspect
  6120. correctly, it is necessary to use @var{sar} in the expression,
  6121. according to the relation:
  6122. @example
  6123. (ih * X / ih) * sar = output_dar
  6124. X = output_dar / sar
  6125. @end example
  6126. Thus the previous example needs to be modified to:
  6127. @example
  6128. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  6129. @end example
  6130. @item
  6131. Double the output size and put the input video in the bottom-right
  6132. corner of the output padded area:
  6133. @example
  6134. pad="2*iw:2*ih:ow-iw:oh-ih"
  6135. @end example
  6136. @end itemize
  6137. @anchor{palettegen}
  6138. @section palettegen
  6139. Generate one palette for a whole video stream.
  6140. It accepts the following options:
  6141. @table @option
  6142. @item max_colors
  6143. Set the maximum number of colors to quantize in the palette.
  6144. Note: the palette will still contain 256 colors; the unused palette entries
  6145. will be black.
  6146. @item reserve_transparent
  6147. Create a palette of 255 colors maximum and reserve the last one for
  6148. transparency. Reserving the transparency color is useful for GIF optimization.
  6149. If not set, the maximum of colors in the palette will be 256. You probably want
  6150. to disable this option for a standalone image.
  6151. Set by default.
  6152. @item stats_mode
  6153. Set statistics mode.
  6154. It accepts the following values:
  6155. @table @samp
  6156. @item full
  6157. Compute full frame histograms.
  6158. @item diff
  6159. Compute histograms only for the part that differs from previous frame. This
  6160. might be relevant to give more importance to the moving part of your input if
  6161. the background is static.
  6162. @end table
  6163. Default value is @var{full}.
  6164. @end table
  6165. The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
  6166. (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
  6167. color quantization of the palette. This information is also visible at
  6168. @var{info} logging level.
  6169. @subsection Examples
  6170. @itemize
  6171. @item
  6172. Generate a representative palette of a given video using @command{ffmpeg}:
  6173. @example
  6174. ffmpeg -i input.mkv -vf palettegen palette.png
  6175. @end example
  6176. @end itemize
  6177. @section paletteuse
  6178. Use a palette to downsample an input video stream.
  6179. The filter takes two inputs: one video stream and a palette. The palette must
  6180. be a 256 pixels image.
  6181. It accepts the following options:
  6182. @table @option
  6183. @item dither
  6184. Select dithering mode. Available algorithms are:
  6185. @table @samp
  6186. @item bayer
  6187. Ordered 8x8 bayer dithering (deterministic)
  6188. @item heckbert
  6189. Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
  6190. Note: this dithering is sometimes considered "wrong" and is included as a
  6191. reference.
  6192. @item floyd_steinberg
  6193. Floyd and Steingberg dithering (error diffusion)
  6194. @item sierra2
  6195. Frankie Sierra dithering v2 (error diffusion)
  6196. @item sierra2_4a
  6197. Frankie Sierra dithering v2 "Lite" (error diffusion)
  6198. @end table
  6199. Default is @var{sierra2_4a}.
  6200. @item bayer_scale
  6201. When @var{bayer} dithering is selected, this option defines the scale of the
  6202. pattern (how much the crosshatch pattern is visible). A low value means more
  6203. visible pattern for less banding, and higher value means less visible pattern
  6204. at the cost of more banding.
  6205. The option must be an integer value in the range [0,5]. Default is @var{2}.
  6206. @item diff_mode
  6207. If set, define the zone to process
  6208. @table @samp
  6209. @item rectangle
  6210. Only the changing rectangle will be reprocessed. This is similar to GIF
  6211. cropping/offsetting compression mechanism. This option can be useful for speed
  6212. if only a part of the image is changing, and has use cases such as limiting the
  6213. scope of the error diffusal @option{dither} to the rectangle that bounds the
  6214. moving scene (it leads to more deterministic output if the scene doesn't change
  6215. much, and as a result less moving noise and better GIF compression).
  6216. @end table
  6217. Default is @var{none}.
  6218. @end table
  6219. @subsection Examples
  6220. @itemize
  6221. @item
  6222. Use a palette (generated for example with @ref{palettegen}) to encode a GIF
  6223. using @command{ffmpeg}:
  6224. @example
  6225. ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
  6226. @end example
  6227. @end itemize
  6228. @section perspective
  6229. Correct perspective of video not recorded perpendicular to the screen.
  6230. A description of the accepted parameters follows.
  6231. @table @option
  6232. @item x0
  6233. @item y0
  6234. @item x1
  6235. @item y1
  6236. @item x2
  6237. @item y2
  6238. @item x3
  6239. @item y3
  6240. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  6241. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  6242. If the @code{sense} option is set to @code{source}, then the specified points will be sent
  6243. to the corners of the destination. If the @code{sense} option is set to @code{destination},
  6244. then the corners of the source will be sent to the specified coordinates.
  6245. The expressions can use the following variables:
  6246. @table @option
  6247. @item W
  6248. @item H
  6249. the width and height of video frame.
  6250. @end table
  6251. @item interpolation
  6252. Set interpolation for perspective correction.
  6253. It accepts the following values:
  6254. @table @samp
  6255. @item linear
  6256. @item cubic
  6257. @end table
  6258. Default value is @samp{linear}.
  6259. @item sense
  6260. Set interpretation of coordinate options.
  6261. It accepts the following values:
  6262. @table @samp
  6263. @item 0, source
  6264. Send point in the source specified by the given coordinates to
  6265. the corners of the destination.
  6266. @item 1, destination
  6267. Send the corners of the source to the point in the destination specified
  6268. by the given coordinates.
  6269. Default value is @samp{source}.
  6270. @end table
  6271. @end table
  6272. @section phase
  6273. Delay interlaced video by one field time so that the field order changes.
  6274. The intended use is to fix PAL movies that have been captured with the
  6275. opposite field order to the film-to-video transfer.
  6276. A description of the accepted parameters follows.
  6277. @table @option
  6278. @item mode
  6279. Set phase mode.
  6280. It accepts the following values:
  6281. @table @samp
  6282. @item t
  6283. Capture field order top-first, transfer bottom-first.
  6284. Filter will delay the bottom field.
  6285. @item b
  6286. Capture field order bottom-first, transfer top-first.
  6287. Filter will delay the top field.
  6288. @item p
  6289. Capture and transfer with the same field order. This mode only exists
  6290. for the documentation of the other options to refer to, but if you
  6291. actually select it, the filter will faithfully do nothing.
  6292. @item a
  6293. Capture field order determined automatically by field flags, transfer
  6294. opposite.
  6295. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  6296. basis using field flags. If no field information is available,
  6297. then this works just like @samp{u}.
  6298. @item u
  6299. Capture unknown or varying, transfer opposite.
  6300. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  6301. analyzing the images and selecting the alternative that produces best
  6302. match between the fields.
  6303. @item T
  6304. Capture top-first, transfer unknown or varying.
  6305. Filter selects among @samp{t} and @samp{p} using image analysis.
  6306. @item B
  6307. Capture bottom-first, transfer unknown or varying.
  6308. Filter selects among @samp{b} and @samp{p} using image analysis.
  6309. @item A
  6310. Capture determined by field flags, transfer unknown or varying.
  6311. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  6312. image analysis. If no field information is available, then this works just
  6313. like @samp{U}. This is the default mode.
  6314. @item U
  6315. Both capture and transfer unknown or varying.
  6316. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  6317. @end table
  6318. @end table
  6319. @section pixdesctest
  6320. Pixel format descriptor test filter, mainly useful for internal
  6321. testing. The output video should be equal to the input video.
  6322. For example:
  6323. @example
  6324. format=monow, pixdesctest
  6325. @end example
  6326. can be used to test the monowhite pixel format descriptor definition.
  6327. @section pp
  6328. Enable the specified chain of postprocessing subfilters using libpostproc. This
  6329. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  6330. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  6331. Each subfilter and some options have a short and a long name that can be used
  6332. interchangeably, i.e. dr/dering are the same.
  6333. The filters accept the following options:
  6334. @table @option
  6335. @item subfilters
  6336. Set postprocessing subfilters string.
  6337. @end table
  6338. All subfilters share common options to determine their scope:
  6339. @table @option
  6340. @item a/autoq
  6341. Honor the quality commands for this subfilter.
  6342. @item c/chrom
  6343. Do chrominance filtering, too (default).
  6344. @item y/nochrom
  6345. Do luminance filtering only (no chrominance).
  6346. @item n/noluma
  6347. Do chrominance filtering only (no luminance).
  6348. @end table
  6349. These options can be appended after the subfilter name, separated by a '|'.
  6350. Available subfilters are:
  6351. @table @option
  6352. @item hb/hdeblock[|difference[|flatness]]
  6353. Horizontal deblocking filter
  6354. @table @option
  6355. @item difference
  6356. Difference factor where higher values mean more deblocking (default: @code{32}).
  6357. @item flatness
  6358. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6359. @end table
  6360. @item vb/vdeblock[|difference[|flatness]]
  6361. Vertical deblocking filter
  6362. @table @option
  6363. @item difference
  6364. Difference factor where higher values mean more deblocking (default: @code{32}).
  6365. @item flatness
  6366. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6367. @end table
  6368. @item ha/hadeblock[|difference[|flatness]]
  6369. Accurate horizontal deblocking filter
  6370. @table @option
  6371. @item difference
  6372. Difference factor where higher values mean more deblocking (default: @code{32}).
  6373. @item flatness
  6374. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6375. @end table
  6376. @item va/vadeblock[|difference[|flatness]]
  6377. Accurate vertical deblocking filter
  6378. @table @option
  6379. @item difference
  6380. Difference factor where higher values mean more deblocking (default: @code{32}).
  6381. @item flatness
  6382. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6383. @end table
  6384. @end table
  6385. The horizontal and vertical deblocking filters share the difference and
  6386. flatness values so you cannot set different horizontal and vertical
  6387. thresholds.
  6388. @table @option
  6389. @item h1/x1hdeblock
  6390. Experimental horizontal deblocking filter
  6391. @item v1/x1vdeblock
  6392. Experimental vertical deblocking filter
  6393. @item dr/dering
  6394. Deringing filter
  6395. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  6396. @table @option
  6397. @item threshold1
  6398. larger -> stronger filtering
  6399. @item threshold2
  6400. larger -> stronger filtering
  6401. @item threshold3
  6402. larger -> stronger filtering
  6403. @end table
  6404. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  6405. @table @option
  6406. @item f/fullyrange
  6407. Stretch luminance to @code{0-255}.
  6408. @end table
  6409. @item lb/linblenddeint
  6410. Linear blend deinterlacing filter that deinterlaces the given block by
  6411. filtering all lines with a @code{(1 2 1)} filter.
  6412. @item li/linipoldeint
  6413. Linear interpolating deinterlacing filter that deinterlaces the given block by
  6414. linearly interpolating every second line.
  6415. @item ci/cubicipoldeint
  6416. Cubic interpolating deinterlacing filter deinterlaces the given block by
  6417. cubically interpolating every second line.
  6418. @item md/mediandeint
  6419. Median deinterlacing filter that deinterlaces the given block by applying a
  6420. median filter to every second line.
  6421. @item fd/ffmpegdeint
  6422. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  6423. second line with a @code{(-1 4 2 4 -1)} filter.
  6424. @item l5/lowpass5
  6425. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  6426. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  6427. @item fq/forceQuant[|quantizer]
  6428. Overrides the quantizer table from the input with the constant quantizer you
  6429. specify.
  6430. @table @option
  6431. @item quantizer
  6432. Quantizer to use
  6433. @end table
  6434. @item de/default
  6435. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  6436. @item fa/fast
  6437. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  6438. @item ac
  6439. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  6440. @end table
  6441. @subsection Examples
  6442. @itemize
  6443. @item
  6444. Apply horizontal and vertical deblocking, deringing and automatic
  6445. brightness/contrast:
  6446. @example
  6447. pp=hb/vb/dr/al
  6448. @end example
  6449. @item
  6450. Apply default filters without brightness/contrast correction:
  6451. @example
  6452. pp=de/-al
  6453. @end example
  6454. @item
  6455. Apply default filters and temporal denoiser:
  6456. @example
  6457. pp=default/tmpnoise|1|2|3
  6458. @end example
  6459. @item
  6460. Apply deblocking on luminance only, and switch vertical deblocking on or off
  6461. automatically depending on available CPU time:
  6462. @example
  6463. pp=hb|y/vb|a
  6464. @end example
  6465. @end itemize
  6466. @section pp7
  6467. Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
  6468. similar to spp = 6 with 7 point DCT, where only the center sample is
  6469. used after IDCT.
  6470. The filter accepts the following options:
  6471. @table @option
  6472. @item qp
  6473. Force a constant quantization parameter. It accepts an integer in range
  6474. 0 to 63. If not set, the filter will use the QP from the video stream
  6475. (if available).
  6476. @item mode
  6477. Set thresholding mode. Available modes are:
  6478. @table @samp
  6479. @item hard
  6480. Set hard thresholding.
  6481. @item soft
  6482. Set soft thresholding (better de-ringing effect, but likely blurrier).
  6483. @item medium
  6484. Set medium thresholding (good results, default).
  6485. @end table
  6486. @end table
  6487. @section psnr
  6488. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  6489. Ratio) between two input videos.
  6490. This filter takes in input two input videos, the first input is
  6491. considered the "main" source and is passed unchanged to the
  6492. output. The second input is used as a "reference" video for computing
  6493. the PSNR.
  6494. Both video inputs must have the same resolution and pixel format for
  6495. this filter to work correctly. Also it assumes that both inputs
  6496. have the same number of frames, which are compared one by one.
  6497. The obtained average PSNR is printed through the logging system.
  6498. The filter stores the accumulated MSE (mean squared error) of each
  6499. frame, and at the end of the processing it is averaged across all frames
  6500. equally, and the following formula is applied to obtain the PSNR:
  6501. @example
  6502. PSNR = 10*log10(MAX^2/MSE)
  6503. @end example
  6504. Where MAX is the average of the maximum values of each component of the
  6505. image.
  6506. The description of the accepted parameters follows.
  6507. @table @option
  6508. @item stats_file, f
  6509. If specified the filter will use the named file to save the PSNR of
  6510. each individual frame.
  6511. @end table
  6512. The file printed if @var{stats_file} is selected, contains a sequence of
  6513. key/value pairs of the form @var{key}:@var{value} for each compared
  6514. couple of frames.
  6515. A description of each shown parameter follows:
  6516. @table @option
  6517. @item n
  6518. sequential number of the input frame, starting from 1
  6519. @item mse_avg
  6520. Mean Square Error pixel-by-pixel average difference of the compared
  6521. frames, averaged over all the image components.
  6522. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  6523. Mean Square Error pixel-by-pixel average difference of the compared
  6524. frames for the component specified by the suffix.
  6525. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  6526. Peak Signal to Noise ratio of the compared frames for the component
  6527. specified by the suffix.
  6528. @end table
  6529. For example:
  6530. @example
  6531. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  6532. [main][ref] psnr="stats_file=stats.log" [out]
  6533. @end example
  6534. On this example the input file being processed is compared with the
  6535. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  6536. is stored in @file{stats.log}.
  6537. @anchor{pullup}
  6538. @section pullup
  6539. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  6540. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  6541. content.
  6542. The pullup filter is designed to take advantage of future context in making
  6543. its decisions. This filter is stateless in the sense that it does not lock
  6544. onto a pattern to follow, but it instead looks forward to the following
  6545. fields in order to identify matches and rebuild progressive frames.
  6546. To produce content with an even framerate, insert the fps filter after
  6547. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  6548. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  6549. The filter accepts the following options:
  6550. @table @option
  6551. @item jl
  6552. @item jr
  6553. @item jt
  6554. @item jb
  6555. These options set the amount of "junk" to ignore at the left, right, top, and
  6556. bottom of the image, respectively. Left and right are in units of 8 pixels,
  6557. while top and bottom are in units of 2 lines.
  6558. The default is 8 pixels on each side.
  6559. @item sb
  6560. Set the strict breaks. Setting this option to 1 will reduce the chances of
  6561. filter generating an occasional mismatched frame, but it may also cause an
  6562. excessive number of frames to be dropped during high motion sequences.
  6563. Conversely, setting it to -1 will make filter match fields more easily.
  6564. This may help processing of video where there is slight blurring between
  6565. the fields, but may also cause there to be interlaced frames in the output.
  6566. Default value is @code{0}.
  6567. @item mp
  6568. Set the metric plane to use. It accepts the following values:
  6569. @table @samp
  6570. @item l
  6571. Use luma plane.
  6572. @item u
  6573. Use chroma blue plane.
  6574. @item v
  6575. Use chroma red plane.
  6576. @end table
  6577. This option may be set to use chroma plane instead of the default luma plane
  6578. for doing filter's computations. This may improve accuracy on very clean
  6579. source material, but more likely will decrease accuracy, especially if there
  6580. is chroma noise (rainbow effect) or any grayscale video.
  6581. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  6582. load and make pullup usable in realtime on slow machines.
  6583. @end table
  6584. For best results (without duplicated frames in the output file) it is
  6585. necessary to change the output frame rate. For example, to inverse
  6586. telecine NTSC input:
  6587. @example
  6588. ffmpeg -i input -vf pullup -r 24000/1001 ...
  6589. @end example
  6590. @section qp
  6591. Change video quantization parameters (QP).
  6592. The filter accepts the following option:
  6593. @table @option
  6594. @item qp
  6595. Set expression for quantization parameter.
  6596. @end table
  6597. The expression is evaluated through the eval API and can contain, among others,
  6598. the following constants:
  6599. @table @var
  6600. @item known
  6601. 1 if index is not 129, 0 otherwise.
  6602. @item qp
  6603. Sequentional index starting from -129 to 128.
  6604. @end table
  6605. @subsection Examples
  6606. @itemize
  6607. @item
  6608. Some equation like:
  6609. @example
  6610. qp=2+2*sin(PI*qp)
  6611. @end example
  6612. @end itemize
  6613. @section random
  6614. Flush video frames from internal cache of frames into a random order.
  6615. No frame is discarded.
  6616. Inspired by @ref{frei0r} nervous filter.
  6617. @table @option
  6618. @item frames
  6619. Set size in number of frames of internal cache, in range from @code{2} to
  6620. @code{512}. Default is @code{30}.
  6621. @item seed
  6622. Set seed for random number generator, must be an integer included between
  6623. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  6624. less than @code{0}, the filter will try to use a good random seed on a
  6625. best effort basis.
  6626. @end table
  6627. @section removegrain
  6628. The removegrain filter is a spatial denoiser for progressive video.
  6629. @table @option
  6630. @item m0
  6631. Set mode for the first plane.
  6632. @item m1
  6633. Set mode for the second plane.
  6634. @item m2
  6635. Set mode for the third plane.
  6636. @item m3
  6637. Set mode for the fourth plane.
  6638. @end table
  6639. Range of mode is from 0 to 24. Description of each mode follows:
  6640. @table @var
  6641. @item 0
  6642. Leave input plane unchanged. Default.
  6643. @item 1
  6644. Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
  6645. @item 2
  6646. Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
  6647. @item 3
  6648. Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
  6649. @item 4
  6650. Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
  6651. This is equivalent to a median filter.
  6652. @item 5
  6653. Line-sensitive clipping giving the minimal change.
  6654. @item 6
  6655. Line-sensitive clipping, intermediate.
  6656. @item 7
  6657. Line-sensitive clipping, intermediate.
  6658. @item 8
  6659. Line-sensitive clipping, intermediate.
  6660. @item 9
  6661. Line-sensitive clipping on a line where the neighbours pixels are the closest.
  6662. @item 10
  6663. Replaces the target pixel with the closest neighbour.
  6664. @item 11
  6665. [1 2 1] horizontal and vertical kernel blur.
  6666. @item 12
  6667. Same as mode 11.
  6668. @item 13
  6669. Bob mode, interpolates top field from the line where the neighbours
  6670. pixels are the closest.
  6671. @item 14
  6672. Bob mode, interpolates bottom field from the line where the neighbours
  6673. pixels are the closest.
  6674. @item 15
  6675. Bob mode, interpolates top field. Same as 13 but with a more complicated
  6676. interpolation formula.
  6677. @item 16
  6678. Bob mode, interpolates bottom field. Same as 14 but with a more complicated
  6679. interpolation formula.
  6680. @item 17
  6681. Clips the pixel with the minimum and maximum of respectively the maximum and
  6682. minimum of each pair of opposite neighbour pixels.
  6683. @item 18
  6684. Line-sensitive clipping using opposite neighbours whose greatest distance from
  6685. the current pixel is minimal.
  6686. @item 19
  6687. Replaces the pixel with the average of its 8 neighbours.
  6688. @item 20
  6689. Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
  6690. @item 21
  6691. Clips pixels using the averages of opposite neighbour.
  6692. @item 22
  6693. Same as mode 21 but simpler and faster.
  6694. @item 23
  6695. Small edge and halo removal, but reputed useless.
  6696. @item 24
  6697. Similar as 23.
  6698. @end table
  6699. @section removelogo
  6700. Suppress a TV station logo, using an image file to determine which
  6701. pixels comprise the logo. It works by filling in the pixels that
  6702. comprise the logo with neighboring pixels.
  6703. The filter accepts the following options:
  6704. @table @option
  6705. @item filename, f
  6706. Set the filter bitmap file, which can be any image format supported by
  6707. libavformat. The width and height of the image file must match those of the
  6708. video stream being processed.
  6709. @end table
  6710. Pixels in the provided bitmap image with a value of zero are not
  6711. considered part of the logo, non-zero pixels are considered part of
  6712. the logo. If you use white (255) for the logo and black (0) for the
  6713. rest, you will be safe. For making the filter bitmap, it is
  6714. recommended to take a screen capture of a black frame with the logo
  6715. visible, and then using a threshold filter followed by the erode
  6716. filter once or twice.
  6717. If needed, little splotches can be fixed manually. Remember that if
  6718. logo pixels are not covered, the filter quality will be much
  6719. reduced. Marking too many pixels as part of the logo does not hurt as
  6720. much, but it will increase the amount of blurring needed to cover over
  6721. the image and will destroy more information than necessary, and extra
  6722. pixels will slow things down on a large logo.
  6723. @section repeatfields
  6724. This filter uses the repeat_field flag from the Video ES headers and hard repeats
  6725. fields based on its value.
  6726. @section reverse, areverse
  6727. Reverse a clip.
  6728. Warning: This filter requires memory to buffer the entire clip, so trimming
  6729. is suggested.
  6730. @subsection Examples
  6731. @itemize
  6732. @item
  6733. Take the first 5 seconds of a clip, and reverse it.
  6734. @example
  6735. trim=end=5,reverse
  6736. @end example
  6737. @end itemize
  6738. @section rotate
  6739. Rotate video by an arbitrary angle expressed in radians.
  6740. The filter accepts the following options:
  6741. A description of the optional parameters follows.
  6742. @table @option
  6743. @item angle, a
  6744. Set an expression for the angle by which to rotate the input video
  6745. clockwise, expressed as a number of radians. A negative value will
  6746. result in a counter-clockwise rotation. By default it is set to "0".
  6747. This expression is evaluated for each frame.
  6748. @item out_w, ow
  6749. Set the output width expression, default value is "iw".
  6750. This expression is evaluated just once during configuration.
  6751. @item out_h, oh
  6752. Set the output height expression, default value is "ih".
  6753. This expression is evaluated just once during configuration.
  6754. @item bilinear
  6755. Enable bilinear interpolation if set to 1, a value of 0 disables
  6756. it. Default value is 1.
  6757. @item fillcolor, c
  6758. Set the color used to fill the output area not covered by the rotated
  6759. image. For the general syntax of this option, check the "Color" section in the
  6760. ffmpeg-utils manual. If the special value "none" is selected then no
  6761. background is printed (useful for example if the background is never shown).
  6762. Default value is "black".
  6763. @end table
  6764. The expressions for the angle and the output size can contain the
  6765. following constants and functions:
  6766. @table @option
  6767. @item n
  6768. sequential number of the input frame, starting from 0. It is always NAN
  6769. before the first frame is filtered.
  6770. @item t
  6771. time in seconds of the input frame, it is set to 0 when the filter is
  6772. configured. It is always NAN before the first frame is filtered.
  6773. @item hsub
  6774. @item vsub
  6775. horizontal and vertical chroma subsample values. For example for the
  6776. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6777. @item in_w, iw
  6778. @item in_h, ih
  6779. the input video width and height
  6780. @item out_w, ow
  6781. @item out_h, oh
  6782. the output width and height, that is the size of the padded area as
  6783. specified by the @var{width} and @var{height} expressions
  6784. @item rotw(a)
  6785. @item roth(a)
  6786. the minimal width/height required for completely containing the input
  6787. video rotated by @var{a} radians.
  6788. These are only available when computing the @option{out_w} and
  6789. @option{out_h} expressions.
  6790. @end table
  6791. @subsection Examples
  6792. @itemize
  6793. @item
  6794. Rotate the input by PI/6 radians clockwise:
  6795. @example
  6796. rotate=PI/6
  6797. @end example
  6798. @item
  6799. Rotate the input by PI/6 radians counter-clockwise:
  6800. @example
  6801. rotate=-PI/6
  6802. @end example
  6803. @item
  6804. Rotate the input by 45 degrees clockwise:
  6805. @example
  6806. rotate=45*PI/180
  6807. @end example
  6808. @item
  6809. Apply a constant rotation with period T, starting from an angle of PI/3:
  6810. @example
  6811. rotate=PI/3+2*PI*t/T
  6812. @end example
  6813. @item
  6814. Make the input video rotation oscillating with a period of T
  6815. seconds and an amplitude of A radians:
  6816. @example
  6817. rotate=A*sin(2*PI/T*t)
  6818. @end example
  6819. @item
  6820. Rotate the video, output size is chosen so that the whole rotating
  6821. input video is always completely contained in the output:
  6822. @example
  6823. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  6824. @end example
  6825. @item
  6826. Rotate the video, reduce the output size so that no background is ever
  6827. shown:
  6828. @example
  6829. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  6830. @end example
  6831. @end itemize
  6832. @subsection Commands
  6833. The filter supports the following commands:
  6834. @table @option
  6835. @item a, angle
  6836. Set the angle expression.
  6837. The command accepts the same syntax of the corresponding option.
  6838. If the specified expression is not valid, it is kept at its current
  6839. value.
  6840. @end table
  6841. @section sab
  6842. Apply Shape Adaptive Blur.
  6843. The filter accepts the following options:
  6844. @table @option
  6845. @item luma_radius, lr
  6846. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  6847. value is 1.0. A greater value will result in a more blurred image, and
  6848. in slower processing.
  6849. @item luma_pre_filter_radius, lpfr
  6850. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  6851. value is 1.0.
  6852. @item luma_strength, ls
  6853. Set luma maximum difference between pixels to still be considered, must
  6854. be a value in the 0.1-100.0 range, default value is 1.0.
  6855. @item chroma_radius, cr
  6856. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  6857. greater value will result in a more blurred image, and in slower
  6858. processing.
  6859. @item chroma_pre_filter_radius, cpfr
  6860. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  6861. @item chroma_strength, cs
  6862. Set chroma maximum difference between pixels to still be considered,
  6863. must be a value in the 0.1-100.0 range.
  6864. @end table
  6865. Each chroma option value, if not explicitly specified, is set to the
  6866. corresponding luma option value.
  6867. @anchor{scale}
  6868. @section scale
  6869. Scale (resize) the input video, using the libswscale library.
  6870. The scale filter forces the output display aspect ratio to be the same
  6871. of the input, by changing the output sample aspect ratio.
  6872. If the input image format is different from the format requested by
  6873. the next filter, the scale filter will convert the input to the
  6874. requested format.
  6875. @subsection Options
  6876. The filter accepts the following options, or any of the options
  6877. supported by the libswscale scaler.
  6878. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  6879. the complete list of scaler options.
  6880. @table @option
  6881. @item width, w
  6882. @item height, h
  6883. Set the output video dimension expression. Default value is the input
  6884. dimension.
  6885. If the value is 0, the input width is used for the output.
  6886. If one of the values is -1, the scale filter will use a value that
  6887. maintains the aspect ratio of the input image, calculated from the
  6888. other specified dimension. If both of them are -1, the input size is
  6889. used
  6890. If one of the values is -n with n > 1, the scale filter will also use a value
  6891. that maintains the aspect ratio of the input image, calculated from the other
  6892. specified dimension. After that it will, however, make sure that the calculated
  6893. dimension is divisible by n and adjust the value if necessary.
  6894. See below for the list of accepted constants for use in the dimension
  6895. expression.
  6896. @item interl
  6897. Set the interlacing mode. It accepts the following values:
  6898. @table @samp
  6899. @item 1
  6900. Force interlaced aware scaling.
  6901. @item 0
  6902. Do not apply interlaced scaling.
  6903. @item -1
  6904. Select interlaced aware scaling depending on whether the source frames
  6905. are flagged as interlaced or not.
  6906. @end table
  6907. Default value is @samp{0}.
  6908. @item flags
  6909. Set libswscale scaling flags. See
  6910. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  6911. complete list of values. If not explicitly specified the filter applies
  6912. the default flags.
  6913. @item size, s
  6914. Set the video size. For the syntax of this option, check the
  6915. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  6916. @item in_color_matrix
  6917. @item out_color_matrix
  6918. Set in/output YCbCr color space type.
  6919. This allows the autodetected value to be overridden as well as allows forcing
  6920. a specific value used for the output and encoder.
  6921. If not specified, the color space type depends on the pixel format.
  6922. Possible values:
  6923. @table @samp
  6924. @item auto
  6925. Choose automatically.
  6926. @item bt709
  6927. Format conforming to International Telecommunication Union (ITU)
  6928. Recommendation BT.709.
  6929. @item fcc
  6930. Set color space conforming to the United States Federal Communications
  6931. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  6932. @item bt601
  6933. Set color space conforming to:
  6934. @itemize
  6935. @item
  6936. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  6937. @item
  6938. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  6939. @item
  6940. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  6941. @end itemize
  6942. @item smpte240m
  6943. Set color space conforming to SMPTE ST 240:1999.
  6944. @end table
  6945. @item in_range
  6946. @item out_range
  6947. Set in/output YCbCr sample range.
  6948. This allows the autodetected value to be overridden as well as allows forcing
  6949. a specific value used for the output and encoder. If not specified, the
  6950. range depends on the pixel format. Possible values:
  6951. @table @samp
  6952. @item auto
  6953. Choose automatically.
  6954. @item jpeg/full/pc
  6955. Set full range (0-255 in case of 8-bit luma).
  6956. @item mpeg/tv
  6957. Set "MPEG" range (16-235 in case of 8-bit luma).
  6958. @end table
  6959. @item force_original_aspect_ratio
  6960. Enable decreasing or increasing output video width or height if necessary to
  6961. keep the original aspect ratio. Possible values:
  6962. @table @samp
  6963. @item disable
  6964. Scale the video as specified and disable this feature.
  6965. @item decrease
  6966. The output video dimensions will automatically be decreased if needed.
  6967. @item increase
  6968. The output video dimensions will automatically be increased if needed.
  6969. @end table
  6970. One useful instance of this option is that when you know a specific device's
  6971. maximum allowed resolution, you can use this to limit the output video to
  6972. that, while retaining the aspect ratio. For example, device A allows
  6973. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  6974. decrease) and specifying 1280x720 to the command line makes the output
  6975. 1280x533.
  6976. Please note that this is a different thing than specifying -1 for @option{w}
  6977. or @option{h}, you still need to specify the output resolution for this option
  6978. to work.
  6979. @end table
  6980. The values of the @option{w} and @option{h} options are expressions
  6981. containing the following constants:
  6982. @table @var
  6983. @item in_w
  6984. @item in_h
  6985. The input width and height
  6986. @item iw
  6987. @item ih
  6988. These are the same as @var{in_w} and @var{in_h}.
  6989. @item out_w
  6990. @item out_h
  6991. The output (scaled) width and height
  6992. @item ow
  6993. @item oh
  6994. These are the same as @var{out_w} and @var{out_h}
  6995. @item a
  6996. The same as @var{iw} / @var{ih}
  6997. @item sar
  6998. input sample aspect ratio
  6999. @item dar
  7000. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  7001. @item hsub
  7002. @item vsub
  7003. horizontal and vertical input chroma subsample values. For example for the
  7004. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7005. @item ohsub
  7006. @item ovsub
  7007. horizontal and vertical output chroma subsample values. For example for the
  7008. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7009. @end table
  7010. @subsection Examples
  7011. @itemize
  7012. @item
  7013. Scale the input video to a size of 200x100
  7014. @example
  7015. scale=w=200:h=100
  7016. @end example
  7017. This is equivalent to:
  7018. @example
  7019. scale=200:100
  7020. @end example
  7021. or:
  7022. @example
  7023. scale=200x100
  7024. @end example
  7025. @item
  7026. Specify a size abbreviation for the output size:
  7027. @example
  7028. scale=qcif
  7029. @end example
  7030. which can also be written as:
  7031. @example
  7032. scale=size=qcif
  7033. @end example
  7034. @item
  7035. Scale the input to 2x:
  7036. @example
  7037. scale=w=2*iw:h=2*ih
  7038. @end example
  7039. @item
  7040. The above is the same as:
  7041. @example
  7042. scale=2*in_w:2*in_h
  7043. @end example
  7044. @item
  7045. Scale the input to 2x with forced interlaced scaling:
  7046. @example
  7047. scale=2*iw:2*ih:interl=1
  7048. @end example
  7049. @item
  7050. Scale the input to half size:
  7051. @example
  7052. scale=w=iw/2:h=ih/2
  7053. @end example
  7054. @item
  7055. Increase the width, and set the height to the same size:
  7056. @example
  7057. scale=3/2*iw:ow
  7058. @end example
  7059. @item
  7060. Seek Greek harmony:
  7061. @example
  7062. scale=iw:1/PHI*iw
  7063. scale=ih*PHI:ih
  7064. @end example
  7065. @item
  7066. Increase the height, and set the width to 3/2 of the height:
  7067. @example
  7068. scale=w=3/2*oh:h=3/5*ih
  7069. @end example
  7070. @item
  7071. Increase the size, making the size a multiple of the chroma
  7072. subsample values:
  7073. @example
  7074. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  7075. @end example
  7076. @item
  7077. Increase the width to a maximum of 500 pixels,
  7078. keeping the same aspect ratio as the input:
  7079. @example
  7080. scale=w='min(500\, iw*3/2):h=-1'
  7081. @end example
  7082. @end itemize
  7083. @subsection Commands
  7084. This filter supports the following commands:
  7085. @table @option
  7086. @item width, w
  7087. @item height, h
  7088. Set the output video dimension expression.
  7089. The command accepts the same syntax of the corresponding option.
  7090. If the specified expression is not valid, it is kept at its current
  7091. value.
  7092. @end table
  7093. @section scale2ref
  7094. Scale (resize) the input video, based on a reference video.
  7095. See the scale filter for available options, scale2ref supports the same but
  7096. uses the reference video instead of the main input as basis.
  7097. @subsection Examples
  7098. @itemize
  7099. @item
  7100. Scale a subtitle stream to match the main video in size before overlaying
  7101. @example
  7102. 'scale2ref[b][a];[a][b]overlay'
  7103. @end example
  7104. @end itemize
  7105. @section separatefields
  7106. The @code{separatefields} takes a frame-based video input and splits
  7107. each frame into its components fields, producing a new half height clip
  7108. with twice the frame rate and twice the frame count.
  7109. This filter use field-dominance information in frame to decide which
  7110. of each pair of fields to place first in the output.
  7111. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  7112. @section setdar, setsar
  7113. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  7114. output video.
  7115. This is done by changing the specified Sample (aka Pixel) Aspect
  7116. Ratio, according to the following equation:
  7117. @example
  7118. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  7119. @end example
  7120. Keep in mind that the @code{setdar} filter does not modify the pixel
  7121. dimensions of the video frame. Also, the display aspect ratio set by
  7122. this filter may be changed by later filters in the filterchain,
  7123. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  7124. applied.
  7125. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  7126. the filter output video.
  7127. Note that as a consequence of the application of this filter, the
  7128. output display aspect ratio will change according to the equation
  7129. above.
  7130. Keep in mind that the sample aspect ratio set by the @code{setsar}
  7131. filter may be changed by later filters in the filterchain, e.g. if
  7132. another "setsar" or a "setdar" filter is applied.
  7133. It accepts the following parameters:
  7134. @table @option
  7135. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  7136. Set the aspect ratio used by the filter.
  7137. The parameter can be a floating point number string, an expression, or
  7138. a string of the form @var{num}:@var{den}, where @var{num} and
  7139. @var{den} are the numerator and denominator of the aspect ratio. If
  7140. the parameter is not specified, it is assumed the value "0".
  7141. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  7142. should be escaped.
  7143. @item max
  7144. Set the maximum integer value to use for expressing numerator and
  7145. denominator when reducing the expressed aspect ratio to a rational.
  7146. Default value is @code{100}.
  7147. @end table
  7148. The parameter @var{sar} is an expression containing
  7149. the following constants:
  7150. @table @option
  7151. @item E, PI, PHI
  7152. These are approximated values for the mathematical constants e
  7153. (Euler's number), pi (Greek pi), and phi (the golden ratio).
  7154. @item w, h
  7155. The input width and height.
  7156. @item a
  7157. These are the same as @var{w} / @var{h}.
  7158. @item sar
  7159. The input sample aspect ratio.
  7160. @item dar
  7161. The input display aspect ratio. It is the same as
  7162. (@var{w} / @var{h}) * @var{sar}.
  7163. @item hsub, vsub
  7164. Horizontal and vertical chroma subsample values. For example, for the
  7165. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7166. @end table
  7167. @subsection Examples
  7168. @itemize
  7169. @item
  7170. To change the display aspect ratio to 16:9, specify one of the following:
  7171. @example
  7172. setdar=dar=1.77777
  7173. setdar=dar=16/9
  7174. setdar=dar=1.77777
  7175. @end example
  7176. @item
  7177. To change the sample aspect ratio to 10:11, specify:
  7178. @example
  7179. setsar=sar=10/11
  7180. @end example
  7181. @item
  7182. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  7183. 1000 in the aspect ratio reduction, use the command:
  7184. @example
  7185. setdar=ratio=16/9:max=1000
  7186. @end example
  7187. @end itemize
  7188. @anchor{setfield}
  7189. @section setfield
  7190. Force field for the output video frame.
  7191. The @code{setfield} filter marks the interlace type field for the
  7192. output frames. It does not change the input frame, but only sets the
  7193. corresponding property, which affects how the frame is treated by
  7194. following filters (e.g. @code{fieldorder} or @code{yadif}).
  7195. The filter accepts the following options:
  7196. @table @option
  7197. @item mode
  7198. Available values are:
  7199. @table @samp
  7200. @item auto
  7201. Keep the same field property.
  7202. @item bff
  7203. Mark the frame as bottom-field-first.
  7204. @item tff
  7205. Mark the frame as top-field-first.
  7206. @item prog
  7207. Mark the frame as progressive.
  7208. @end table
  7209. @end table
  7210. @section showinfo
  7211. Show a line containing various information for each input video frame.
  7212. The input video is not modified.
  7213. The shown line contains a sequence of key/value pairs of the form
  7214. @var{key}:@var{value}.
  7215. The following values are shown in the output:
  7216. @table @option
  7217. @item n
  7218. The (sequential) number of the input frame, starting from 0.
  7219. @item pts
  7220. The Presentation TimeStamp of the input frame, expressed as a number of
  7221. time base units. The time base unit depends on the filter input pad.
  7222. @item pts_time
  7223. The Presentation TimeStamp of the input frame, expressed as a number of
  7224. seconds.
  7225. @item pos
  7226. The position of the frame in the input stream, or -1 if this information is
  7227. unavailable and/or meaningless (for example in case of synthetic video).
  7228. @item fmt
  7229. The pixel format name.
  7230. @item sar
  7231. The sample aspect ratio of the input frame, expressed in the form
  7232. @var{num}/@var{den}.
  7233. @item s
  7234. The size of the input frame. For the syntax of this option, check the
  7235. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7236. @item i
  7237. The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
  7238. for bottom field first).
  7239. @item iskey
  7240. This is 1 if the frame is a key frame, 0 otherwise.
  7241. @item type
  7242. The picture type of the input frame ("I" for an I-frame, "P" for a
  7243. P-frame, "B" for a B-frame, or "?" for an unknown type).
  7244. Also refer to the documentation of the @code{AVPictureType} enum and of
  7245. the @code{av_get_picture_type_char} function defined in
  7246. @file{libavutil/avutil.h}.
  7247. @item checksum
  7248. The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
  7249. @item plane_checksum
  7250. The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  7251. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
  7252. @end table
  7253. @section showpalette
  7254. Displays the 256 colors palette of each frame. This filter is only relevant for
  7255. @var{pal8} pixel format frames.
  7256. It accepts the following option:
  7257. @table @option
  7258. @item s
  7259. Set the size of the box used to represent one palette color entry. Default is
  7260. @code{30} (for a @code{30x30} pixel box).
  7261. @end table
  7262. @section shuffleplanes
  7263. Reorder and/or duplicate video planes.
  7264. It accepts the following parameters:
  7265. @table @option
  7266. @item map0
  7267. The index of the input plane to be used as the first output plane.
  7268. @item map1
  7269. The index of the input plane to be used as the second output plane.
  7270. @item map2
  7271. The index of the input plane to be used as the third output plane.
  7272. @item map3
  7273. The index of the input plane to be used as the fourth output plane.
  7274. @end table
  7275. The first plane has the index 0. The default is to keep the input unchanged.
  7276. Swap the second and third planes of the input:
  7277. @example
  7278. ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
  7279. @end example
  7280. @anchor{signalstats}
  7281. @section signalstats
  7282. Evaluate various visual metrics that assist in determining issues associated
  7283. with the digitization of analog video media.
  7284. By default the filter will log these metadata values:
  7285. @table @option
  7286. @item YMIN
  7287. Display the minimal Y value contained within the input frame. Expressed in
  7288. range of [0-255].
  7289. @item YLOW
  7290. Display the Y value at the 10% percentile within the input frame. Expressed in
  7291. range of [0-255].
  7292. @item YAVG
  7293. Display the average Y value within the input frame. Expressed in range of
  7294. [0-255].
  7295. @item YHIGH
  7296. Display the Y value at the 90% percentile within the input frame. Expressed in
  7297. range of [0-255].
  7298. @item YMAX
  7299. Display the maximum Y value contained within the input frame. Expressed in
  7300. range of [0-255].
  7301. @item UMIN
  7302. Display the minimal U value contained within the input frame. Expressed in
  7303. range of [0-255].
  7304. @item ULOW
  7305. Display the U value at the 10% percentile within the input frame. Expressed in
  7306. range of [0-255].
  7307. @item UAVG
  7308. Display the average U value within the input frame. Expressed in range of
  7309. [0-255].
  7310. @item UHIGH
  7311. Display the U value at the 90% percentile within the input frame. Expressed in
  7312. range of [0-255].
  7313. @item UMAX
  7314. Display the maximum U value contained within the input frame. Expressed in
  7315. range of [0-255].
  7316. @item VMIN
  7317. Display the minimal V value contained within the input frame. Expressed in
  7318. range of [0-255].
  7319. @item VLOW
  7320. Display the V value at the 10% percentile within the input frame. Expressed in
  7321. range of [0-255].
  7322. @item VAVG
  7323. Display the average V value within the input frame. Expressed in range of
  7324. [0-255].
  7325. @item VHIGH
  7326. Display the V value at the 90% percentile within the input frame. Expressed in
  7327. range of [0-255].
  7328. @item VMAX
  7329. Display the maximum V value contained within the input frame. Expressed in
  7330. range of [0-255].
  7331. @item SATMIN
  7332. Display the minimal saturation value contained within the input frame.
  7333. Expressed in range of [0-~181.02].
  7334. @item SATLOW
  7335. Display the saturation value at the 10% percentile within the input frame.
  7336. Expressed in range of [0-~181.02].
  7337. @item SATAVG
  7338. Display the average saturation value within the input frame. Expressed in range
  7339. of [0-~181.02].
  7340. @item SATHIGH
  7341. Display the saturation value at the 90% percentile within the input frame.
  7342. Expressed in range of [0-~181.02].
  7343. @item SATMAX
  7344. Display the maximum saturation value contained within the input frame.
  7345. Expressed in range of [0-~181.02].
  7346. @item HUEMED
  7347. Display the median value for hue within the input frame. Expressed in range of
  7348. [0-360].
  7349. @item HUEAVG
  7350. Display the average value for hue within the input frame. Expressed in range of
  7351. [0-360].
  7352. @item YDIF
  7353. Display the average of sample value difference between all values of the Y
  7354. plane in the current frame and corresponding values of the previous input frame.
  7355. Expressed in range of [0-255].
  7356. @item UDIF
  7357. Display the average of sample value difference between all values of the U
  7358. plane in the current frame and corresponding values of the previous input frame.
  7359. Expressed in range of [0-255].
  7360. @item VDIF
  7361. Display the average of sample value difference between all values of the V
  7362. plane in the current frame and corresponding values of the previous input frame.
  7363. Expressed in range of [0-255].
  7364. @end table
  7365. The filter accepts the following options:
  7366. @table @option
  7367. @item stat
  7368. @item out
  7369. @option{stat} specify an additional form of image analysis.
  7370. @option{out} output video with the specified type of pixel highlighted.
  7371. Both options accept the following values:
  7372. @table @samp
  7373. @item tout
  7374. Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
  7375. unlike the neighboring pixels of the same field. Examples of temporal outliers
  7376. include the results of video dropouts, head clogs, or tape tracking issues.
  7377. @item vrep
  7378. Identify @var{vertical line repetition}. Vertical line repetition includes
  7379. similar rows of pixels within a frame. In born-digital video vertical line
  7380. repetition is common, but this pattern is uncommon in video digitized from an
  7381. analog source. When it occurs in video that results from the digitization of an
  7382. analog source it can indicate concealment from a dropout compensator.
  7383. @item brng
  7384. Identify pixels that fall outside of legal broadcast range.
  7385. @end table
  7386. @item color, c
  7387. Set the highlight color for the @option{out} option. The default color is
  7388. yellow.
  7389. @end table
  7390. @subsection Examples
  7391. @itemize
  7392. @item
  7393. Output data of various video metrics:
  7394. @example
  7395. ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
  7396. @end example
  7397. @item
  7398. Output specific data about the minimum and maximum values of the Y plane per frame:
  7399. @example
  7400. ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
  7401. @end example
  7402. @item
  7403. Playback video while highlighting pixels that are outside of broadcast range in red.
  7404. @example
  7405. ffplay example.mov -vf signalstats="out=brng:color=red"
  7406. @end example
  7407. @item
  7408. Playback video with signalstats metadata drawn over the frame.
  7409. @example
  7410. ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
  7411. @end example
  7412. The contents of signalstat_drawtext.txt used in the command are:
  7413. @example
  7414. time %@{pts:hms@}
  7415. Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
  7416. U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
  7417. V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
  7418. saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
  7419. @end example
  7420. @end itemize
  7421. @anchor{smartblur}
  7422. @section smartblur
  7423. Blur the input video without impacting the outlines.
  7424. It accepts the following options:
  7425. @table @option
  7426. @item luma_radius, lr
  7427. Set the luma radius. The option value must be a float number in
  7428. the range [0.1,5.0] that specifies the variance of the gaussian filter
  7429. used to blur the image (slower if larger). Default value is 1.0.
  7430. @item luma_strength, ls
  7431. Set the luma strength. The option value must be a float number
  7432. in the range [-1.0,1.0] that configures the blurring. A value included
  7433. in [0.0,1.0] will blur the image whereas a value included in
  7434. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  7435. @item luma_threshold, lt
  7436. Set the luma threshold used as a coefficient to determine
  7437. whether a pixel should be blurred or not. The option value must be an
  7438. integer in the range [-30,30]. A value of 0 will filter all the image,
  7439. a value included in [0,30] will filter flat areas and a value included
  7440. in [-30,0] will filter edges. Default value is 0.
  7441. @item chroma_radius, cr
  7442. Set the chroma radius. The option value must be a float number in
  7443. the range [0.1,5.0] that specifies the variance of the gaussian filter
  7444. used to blur the image (slower if larger). Default value is 1.0.
  7445. @item chroma_strength, cs
  7446. Set the chroma strength. The option value must be a float number
  7447. in the range [-1.0,1.0] that configures the blurring. A value included
  7448. in [0.0,1.0] will blur the image whereas a value included in
  7449. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  7450. @item chroma_threshold, ct
  7451. Set the chroma threshold used as a coefficient to determine
  7452. whether a pixel should be blurred or not. The option value must be an
  7453. integer in the range [-30,30]. A value of 0 will filter all the image,
  7454. a value included in [0,30] will filter flat areas and a value included
  7455. in [-30,0] will filter edges. Default value is 0.
  7456. @end table
  7457. If a chroma option is not explicitly set, the corresponding luma value
  7458. is set.
  7459. @section ssim
  7460. Obtain the SSIM (Structural SImilarity Metric) between two input videos.
  7461. This filter takes in input two input videos, the first input is
  7462. considered the "main" source and is passed unchanged to the
  7463. output. The second input is used as a "reference" video for computing
  7464. the SSIM.
  7465. Both video inputs must have the same resolution and pixel format for
  7466. this filter to work correctly. Also it assumes that both inputs
  7467. have the same number of frames, which are compared one by one.
  7468. The filter stores the calculated SSIM of each frame.
  7469. The description of the accepted parameters follows.
  7470. @table @option
  7471. @item stats_file, f
  7472. If specified the filter will use the named file to save the SSIM of
  7473. each individual frame.
  7474. @end table
  7475. The file printed if @var{stats_file} is selected, contains a sequence of
  7476. key/value pairs of the form @var{key}:@var{value} for each compared
  7477. couple of frames.
  7478. A description of each shown parameter follows:
  7479. @table @option
  7480. @item n
  7481. sequential number of the input frame, starting from 1
  7482. @item Y, U, V, R, G, B
  7483. SSIM of the compared frames for the component specified by the suffix.
  7484. @item All
  7485. SSIM of the compared frames for the whole frame.
  7486. @item dB
  7487. Same as above but in dB representation.
  7488. @end table
  7489. For example:
  7490. @example
  7491. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  7492. [main][ref] ssim="stats_file=stats.log" [out]
  7493. @end example
  7494. On this example the input file being processed is compared with the
  7495. reference file @file{ref_movie.mpg}. The SSIM of each individual frame
  7496. is stored in @file{stats.log}.
  7497. Another example with both psnr and ssim at same time:
  7498. @example
  7499. ffmpeg -i main.mpg -i ref.mpg -lavfi "ssim;[0:v][1:v]psnr" -f null -
  7500. @end example
  7501. @section stereo3d
  7502. Convert between different stereoscopic image formats.
  7503. The filters accept the following options:
  7504. @table @option
  7505. @item in
  7506. Set stereoscopic image format of input.
  7507. Available values for input image formats are:
  7508. @table @samp
  7509. @item sbsl
  7510. side by side parallel (left eye left, right eye right)
  7511. @item sbsr
  7512. side by side crosseye (right eye left, left eye right)
  7513. @item sbs2l
  7514. side by side parallel with half width resolution
  7515. (left eye left, right eye right)
  7516. @item sbs2r
  7517. side by side crosseye with half width resolution
  7518. (right eye left, left eye right)
  7519. @item abl
  7520. above-below (left eye above, right eye below)
  7521. @item abr
  7522. above-below (right eye above, left eye below)
  7523. @item ab2l
  7524. above-below with half height resolution
  7525. (left eye above, right eye below)
  7526. @item ab2r
  7527. above-below with half height resolution
  7528. (right eye above, left eye below)
  7529. @item al
  7530. alternating frames (left eye first, right eye second)
  7531. @item ar
  7532. alternating frames (right eye first, left eye second)
  7533. @item irl
  7534. interleaved rows (left eye has top row, right eye starts on next row)
  7535. @item irr
  7536. interleaved rows (right eye has top row, left eye starts on next row)
  7537. Default value is @samp{sbsl}.
  7538. @end table
  7539. @item out
  7540. Set stereoscopic image format of output.
  7541. Available values for output image formats are all the input formats as well as:
  7542. @table @samp
  7543. @item arbg
  7544. anaglyph red/blue gray
  7545. (red filter on left eye, blue filter on right eye)
  7546. @item argg
  7547. anaglyph red/green gray
  7548. (red filter on left eye, green filter on right eye)
  7549. @item arcg
  7550. anaglyph red/cyan gray
  7551. (red filter on left eye, cyan filter on right eye)
  7552. @item arch
  7553. anaglyph red/cyan half colored
  7554. (red filter on left eye, cyan filter on right eye)
  7555. @item arcc
  7556. anaglyph red/cyan color
  7557. (red filter on left eye, cyan filter on right eye)
  7558. @item arcd
  7559. anaglyph red/cyan color optimized with the least squares projection of dubois
  7560. (red filter on left eye, cyan filter on right eye)
  7561. @item agmg
  7562. anaglyph green/magenta gray
  7563. (green filter on left eye, magenta filter on right eye)
  7564. @item agmh
  7565. anaglyph green/magenta half colored
  7566. (green filter on left eye, magenta filter on right eye)
  7567. @item agmc
  7568. anaglyph green/magenta colored
  7569. (green filter on left eye, magenta filter on right eye)
  7570. @item agmd
  7571. anaglyph green/magenta color optimized with the least squares projection of dubois
  7572. (green filter on left eye, magenta filter on right eye)
  7573. @item aybg
  7574. anaglyph yellow/blue gray
  7575. (yellow filter on left eye, blue filter on right eye)
  7576. @item aybh
  7577. anaglyph yellow/blue half colored
  7578. (yellow filter on left eye, blue filter on right eye)
  7579. @item aybc
  7580. anaglyph yellow/blue colored
  7581. (yellow filter on left eye, blue filter on right eye)
  7582. @item aybd
  7583. anaglyph yellow/blue color optimized with the least squares projection of dubois
  7584. (yellow filter on left eye, blue filter on right eye)
  7585. @item ml
  7586. mono output (left eye only)
  7587. @item mr
  7588. mono output (right eye only)
  7589. @item chl
  7590. checkerboard, left eye first
  7591. @item chr
  7592. checkerboard, right eye first
  7593. @item icl
  7594. interleaved columns, left eye first
  7595. @item icr
  7596. interleaved columns, right eye first
  7597. @end table
  7598. Default value is @samp{arcd}.
  7599. @end table
  7600. @subsection Examples
  7601. @itemize
  7602. @item
  7603. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  7604. @example
  7605. stereo3d=sbsl:aybd
  7606. @end example
  7607. @item
  7608. Convert input video from above bellow (left eye above, right eye below) to side by side crosseye.
  7609. @example
  7610. stereo3d=abl:sbsr
  7611. @end example
  7612. @end itemize
  7613. @anchor{spp}
  7614. @section spp
  7615. Apply a simple postprocessing filter that compresses and decompresses the image
  7616. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  7617. and average the results.
  7618. The filter accepts the following options:
  7619. @table @option
  7620. @item quality
  7621. Set quality. This option defines the number of levels for averaging. It accepts
  7622. an integer in the range 0-6. If set to @code{0}, the filter will have no
  7623. effect. A value of @code{6} means the higher quality. For each increment of
  7624. that value the speed drops by a factor of approximately 2. Default value is
  7625. @code{3}.
  7626. @item qp
  7627. Force a constant quantization parameter. If not set, the filter will use the QP
  7628. from the video stream (if available).
  7629. @item mode
  7630. Set thresholding mode. Available modes are:
  7631. @table @samp
  7632. @item hard
  7633. Set hard thresholding (default).
  7634. @item soft
  7635. Set soft thresholding (better de-ringing effect, but likely blurrier).
  7636. @end table
  7637. @item use_bframe_qp
  7638. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  7639. option may cause flicker since the B-Frames have often larger QP. Default is
  7640. @code{0} (not enabled).
  7641. @end table
  7642. @anchor{subtitles}
  7643. @section subtitles
  7644. Draw subtitles on top of input video using the libass library.
  7645. To enable compilation of this filter you need to configure FFmpeg with
  7646. @code{--enable-libass}. This filter also requires a build with libavcodec and
  7647. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  7648. Alpha) subtitles format.
  7649. The filter accepts the following options:
  7650. @table @option
  7651. @item filename, f
  7652. Set the filename of the subtitle file to read. It must be specified.
  7653. @item original_size
  7654. Specify the size of the original video, the video for which the ASS file
  7655. was composed. For the syntax of this option, check the
  7656. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7657. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
  7658. correctly scale the fonts if the aspect ratio has been changed.
  7659. @item fontsdir
  7660. Set a directory path containing fonts that can be used by the filter.
  7661. These fonts will be used in addition to whatever the font provider uses.
  7662. @item charenc
  7663. Set subtitles input character encoding. @code{subtitles} filter only. Only
  7664. useful if not UTF-8.
  7665. @item stream_index, si
  7666. Set subtitles stream index. @code{subtitles} filter only.
  7667. @item force_style
  7668. Override default style or script info parameters of the subtitles. It accepts a
  7669. string containing ASS style format @code{KEY=VALUE} couples separated by ",".
  7670. @end table
  7671. If the first key is not specified, it is assumed that the first value
  7672. specifies the @option{filename}.
  7673. For example, to render the file @file{sub.srt} on top of the input
  7674. video, use the command:
  7675. @example
  7676. subtitles=sub.srt
  7677. @end example
  7678. which is equivalent to:
  7679. @example
  7680. subtitles=filename=sub.srt
  7681. @end example
  7682. To render the default subtitles stream from file @file{video.mkv}, use:
  7683. @example
  7684. subtitles=video.mkv
  7685. @end example
  7686. To render the second subtitles stream from that file, use:
  7687. @example
  7688. subtitles=video.mkv:si=1
  7689. @end example
  7690. To make the subtitles stream from @file{sub.srt} appear in transparent green
  7691. @code{DejaVu Serif}, use:
  7692. @example
  7693. subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
  7694. @end example
  7695. @section super2xsai
  7696. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  7697. Interpolate) pixel art scaling algorithm.
  7698. Useful for enlarging pixel art images without reducing sharpness.
  7699. @section swapuv
  7700. Swap U & V plane.
  7701. @section telecine
  7702. Apply telecine process to the video.
  7703. This filter accepts the following options:
  7704. @table @option
  7705. @item first_field
  7706. @table @samp
  7707. @item top, t
  7708. top field first
  7709. @item bottom, b
  7710. bottom field first
  7711. The default value is @code{top}.
  7712. @end table
  7713. @item pattern
  7714. A string of numbers representing the pulldown pattern you wish to apply.
  7715. The default value is @code{23}.
  7716. @end table
  7717. @example
  7718. Some typical patterns:
  7719. NTSC output (30i):
  7720. 27.5p: 32222
  7721. 24p: 23 (classic)
  7722. 24p: 2332 (preferred)
  7723. 20p: 33
  7724. 18p: 334
  7725. 16p: 3444
  7726. PAL output (25i):
  7727. 27.5p: 12222
  7728. 24p: 222222222223 ("Euro pulldown")
  7729. 16.67p: 33
  7730. 16p: 33333334
  7731. @end example
  7732. @section thumbnail
  7733. Select the most representative frame in a given sequence of consecutive frames.
  7734. The filter accepts the following options:
  7735. @table @option
  7736. @item n
  7737. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  7738. will pick one of them, and then handle the next batch of @var{n} frames until
  7739. the end. Default is @code{100}.
  7740. @end table
  7741. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  7742. value will result in a higher memory usage, so a high value is not recommended.
  7743. @subsection Examples
  7744. @itemize
  7745. @item
  7746. Extract one picture each 50 frames:
  7747. @example
  7748. thumbnail=50
  7749. @end example
  7750. @item
  7751. Complete example of a thumbnail creation with @command{ffmpeg}:
  7752. @example
  7753. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  7754. @end example
  7755. @end itemize
  7756. @section tile
  7757. Tile several successive frames together.
  7758. The filter accepts the following options:
  7759. @table @option
  7760. @item layout
  7761. Set the grid size (i.e. the number of lines and columns). For the syntax of
  7762. this option, check the
  7763. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7764. @item nb_frames
  7765. Set the maximum number of frames to render in the given area. It must be less
  7766. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  7767. the area will be used.
  7768. @item margin
  7769. Set the outer border margin in pixels.
  7770. @item padding
  7771. Set the inner border thickness (i.e. the number of pixels between frames). For
  7772. more advanced padding options (such as having different values for the edges),
  7773. refer to the pad video filter.
  7774. @item color
  7775. Specify the color of the unused area. For the syntax of this option, check the
  7776. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  7777. is "black".
  7778. @end table
  7779. @subsection Examples
  7780. @itemize
  7781. @item
  7782. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  7783. @example
  7784. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  7785. @end example
  7786. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  7787. duplicating each output frame to accommodate the originally detected frame
  7788. rate.
  7789. @item
  7790. Display @code{5} pictures in an area of @code{3x2} frames,
  7791. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  7792. mixed flat and named options:
  7793. @example
  7794. tile=3x2:nb_frames=5:padding=7:margin=2
  7795. @end example
  7796. @end itemize
  7797. @section tinterlace
  7798. Perform various types of temporal field interlacing.
  7799. Frames are counted starting from 1, so the first input frame is
  7800. considered odd.
  7801. The filter accepts the following options:
  7802. @table @option
  7803. @item mode
  7804. Specify the mode of the interlacing. This option can also be specified
  7805. as a value alone. See below for a list of values for this option.
  7806. Available values are:
  7807. @table @samp
  7808. @item merge, 0
  7809. Move odd frames into the upper field, even into the lower field,
  7810. generating a double height frame at half frame rate.
  7811. @example
  7812. ------> time
  7813. Input:
  7814. Frame 1 Frame 2 Frame 3 Frame 4
  7815. 11111 22222 33333 44444
  7816. 11111 22222 33333 44444
  7817. 11111 22222 33333 44444
  7818. 11111 22222 33333 44444
  7819. Output:
  7820. 11111 33333
  7821. 22222 44444
  7822. 11111 33333
  7823. 22222 44444
  7824. 11111 33333
  7825. 22222 44444
  7826. 11111 33333
  7827. 22222 44444
  7828. @end example
  7829. @item drop_odd, 1
  7830. Only output even frames, odd frames are dropped, generating a frame with
  7831. unchanged height at half frame rate.
  7832. @example
  7833. ------> time
  7834. Input:
  7835. Frame 1 Frame 2 Frame 3 Frame 4
  7836. 11111 22222 33333 44444
  7837. 11111 22222 33333 44444
  7838. 11111 22222 33333 44444
  7839. 11111 22222 33333 44444
  7840. Output:
  7841. 22222 44444
  7842. 22222 44444
  7843. 22222 44444
  7844. 22222 44444
  7845. @end example
  7846. @item drop_even, 2
  7847. Only output odd frames, even frames are dropped, generating a frame with
  7848. unchanged height at half frame rate.
  7849. @example
  7850. ------> time
  7851. Input:
  7852. Frame 1 Frame 2 Frame 3 Frame 4
  7853. 11111 22222 33333 44444
  7854. 11111 22222 33333 44444
  7855. 11111 22222 33333 44444
  7856. 11111 22222 33333 44444
  7857. Output:
  7858. 11111 33333
  7859. 11111 33333
  7860. 11111 33333
  7861. 11111 33333
  7862. @end example
  7863. @item pad, 3
  7864. Expand each frame to full height, but pad alternate lines with black,
  7865. generating a frame with double height at the same input frame rate.
  7866. @example
  7867. ------> time
  7868. Input:
  7869. Frame 1 Frame 2 Frame 3 Frame 4
  7870. 11111 22222 33333 44444
  7871. 11111 22222 33333 44444
  7872. 11111 22222 33333 44444
  7873. 11111 22222 33333 44444
  7874. Output:
  7875. 11111 ..... 33333 .....
  7876. ..... 22222 ..... 44444
  7877. 11111 ..... 33333 .....
  7878. ..... 22222 ..... 44444
  7879. 11111 ..... 33333 .....
  7880. ..... 22222 ..... 44444
  7881. 11111 ..... 33333 .....
  7882. ..... 22222 ..... 44444
  7883. @end example
  7884. @item interleave_top, 4
  7885. Interleave the upper field from odd frames with the lower field from
  7886. even frames, generating a frame with unchanged height at half frame rate.
  7887. @example
  7888. ------> time
  7889. Input:
  7890. Frame 1 Frame 2 Frame 3 Frame 4
  7891. 11111<- 22222 33333<- 44444
  7892. 11111 22222<- 33333 44444<-
  7893. 11111<- 22222 33333<- 44444
  7894. 11111 22222<- 33333 44444<-
  7895. Output:
  7896. 11111 33333
  7897. 22222 44444
  7898. 11111 33333
  7899. 22222 44444
  7900. @end example
  7901. @item interleave_bottom, 5
  7902. Interleave the lower field from odd frames with the upper field from
  7903. even frames, generating a frame with unchanged height at half frame rate.
  7904. @example
  7905. ------> time
  7906. Input:
  7907. Frame 1 Frame 2 Frame 3 Frame 4
  7908. 11111 22222<- 33333 44444<-
  7909. 11111<- 22222 33333<- 44444
  7910. 11111 22222<- 33333 44444<-
  7911. 11111<- 22222 33333<- 44444
  7912. Output:
  7913. 22222 44444
  7914. 11111 33333
  7915. 22222 44444
  7916. 11111 33333
  7917. @end example
  7918. @item interlacex2, 6
  7919. Double frame rate with unchanged height. Frames are inserted each
  7920. containing the second temporal field from the previous input frame and
  7921. the first temporal field from the next input frame. This mode relies on
  7922. the top_field_first flag. Useful for interlaced video displays with no
  7923. field synchronisation.
  7924. @example
  7925. ------> time
  7926. Input:
  7927. Frame 1 Frame 2 Frame 3 Frame 4
  7928. 11111 22222 33333 44444
  7929. 11111 22222 33333 44444
  7930. 11111 22222 33333 44444
  7931. 11111 22222 33333 44444
  7932. Output:
  7933. 11111 22222 22222 33333 33333 44444 44444
  7934. 11111 11111 22222 22222 33333 33333 44444
  7935. 11111 22222 22222 33333 33333 44444 44444
  7936. 11111 11111 22222 22222 33333 33333 44444
  7937. @end example
  7938. @end table
  7939. Numeric values are deprecated but are accepted for backward
  7940. compatibility reasons.
  7941. Default mode is @code{merge}.
  7942. @item flags
  7943. Specify flags influencing the filter process.
  7944. Available value for @var{flags} is:
  7945. @table @option
  7946. @item low_pass_filter, vlfp
  7947. Enable vertical low-pass filtering in the filter.
  7948. Vertical low-pass filtering is required when creating an interlaced
  7949. destination from a progressive source which contains high-frequency
  7950. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  7951. patterning.
  7952. Vertical low-pass filtering can only be enabled for @option{mode}
  7953. @var{interleave_top} and @var{interleave_bottom}.
  7954. @end table
  7955. @end table
  7956. @section transpose
  7957. Transpose rows with columns in the input video and optionally flip it.
  7958. It accepts the following parameters:
  7959. @table @option
  7960. @item dir
  7961. Specify the transposition direction.
  7962. Can assume the following values:
  7963. @table @samp
  7964. @item 0, 4, cclock_flip
  7965. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  7966. @example
  7967. L.R L.l
  7968. . . -> . .
  7969. l.r R.r
  7970. @end example
  7971. @item 1, 5, clock
  7972. Rotate by 90 degrees clockwise, that is:
  7973. @example
  7974. L.R l.L
  7975. . . -> . .
  7976. l.r r.R
  7977. @end example
  7978. @item 2, 6, cclock
  7979. Rotate by 90 degrees counterclockwise, that is:
  7980. @example
  7981. L.R R.r
  7982. . . -> . .
  7983. l.r L.l
  7984. @end example
  7985. @item 3, 7, clock_flip
  7986. Rotate by 90 degrees clockwise and vertically flip, that is:
  7987. @example
  7988. L.R r.R
  7989. . . -> . .
  7990. l.r l.L
  7991. @end example
  7992. @end table
  7993. For values between 4-7, the transposition is only done if the input
  7994. video geometry is portrait and not landscape. These values are
  7995. deprecated, the @code{passthrough} option should be used instead.
  7996. Numerical values are deprecated, and should be dropped in favor of
  7997. symbolic constants.
  7998. @item passthrough
  7999. Do not apply the transposition if the input geometry matches the one
  8000. specified by the specified value. It accepts the following values:
  8001. @table @samp
  8002. @item none
  8003. Always apply transposition.
  8004. @item portrait
  8005. Preserve portrait geometry (when @var{height} >= @var{width}).
  8006. @item landscape
  8007. Preserve landscape geometry (when @var{width} >= @var{height}).
  8008. @end table
  8009. Default value is @code{none}.
  8010. @end table
  8011. For example to rotate by 90 degrees clockwise and preserve portrait
  8012. layout:
  8013. @example
  8014. transpose=dir=1:passthrough=portrait
  8015. @end example
  8016. The command above can also be specified as:
  8017. @example
  8018. transpose=1:portrait
  8019. @end example
  8020. @section trim
  8021. Trim the input so that the output contains one continuous subpart of the input.
  8022. It accepts the following parameters:
  8023. @table @option
  8024. @item start
  8025. Specify the time of the start of the kept section, i.e. the frame with the
  8026. timestamp @var{start} will be the first frame in the output.
  8027. @item end
  8028. Specify the time of the first frame that will be dropped, i.e. the frame
  8029. immediately preceding the one with the timestamp @var{end} will be the last
  8030. frame in the output.
  8031. @item start_pts
  8032. This is the same as @var{start}, except this option sets the start timestamp
  8033. in timebase units instead of seconds.
  8034. @item end_pts
  8035. This is the same as @var{end}, except this option sets the end timestamp
  8036. in timebase units instead of seconds.
  8037. @item duration
  8038. The maximum duration of the output in seconds.
  8039. @item start_frame
  8040. The number of the first frame that should be passed to the output.
  8041. @item end_frame
  8042. The number of the first frame that should be dropped.
  8043. @end table
  8044. @option{start}, @option{end}, and @option{duration} are expressed as time
  8045. duration specifications; see
  8046. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  8047. for the accepted syntax.
  8048. Note that the first two sets of the start/end options and the @option{duration}
  8049. option look at the frame timestamp, while the _frame variants simply count the
  8050. frames that pass through the filter. Also note that this filter does not modify
  8051. the timestamps. If you wish for the output timestamps to start at zero, insert a
  8052. setpts filter after the trim filter.
  8053. If multiple start or end options are set, this filter tries to be greedy and
  8054. keep all the frames that match at least one of the specified constraints. To keep
  8055. only the part that matches all the constraints at once, chain multiple trim
  8056. filters.
  8057. The defaults are such that all the input is kept. So it is possible to set e.g.
  8058. just the end values to keep everything before the specified time.
  8059. Examples:
  8060. @itemize
  8061. @item
  8062. Drop everything except the second minute of input:
  8063. @example
  8064. ffmpeg -i INPUT -vf trim=60:120
  8065. @end example
  8066. @item
  8067. Keep only the first second:
  8068. @example
  8069. ffmpeg -i INPUT -vf trim=duration=1
  8070. @end example
  8071. @end itemize
  8072. @anchor{unsharp}
  8073. @section unsharp
  8074. Sharpen or blur the input video.
  8075. It accepts the following parameters:
  8076. @table @option
  8077. @item luma_msize_x, lx
  8078. Set the luma matrix horizontal size. It must be an odd integer between
  8079. 3 and 63. The default value is 5.
  8080. @item luma_msize_y, ly
  8081. Set the luma matrix vertical size. It must be an odd integer between 3
  8082. and 63. The default value is 5.
  8083. @item luma_amount, la
  8084. Set the luma effect strength. It must be a floating point number, reasonable
  8085. values lay between -1.5 and 1.5.
  8086. Negative values will blur the input video, while positive values will
  8087. sharpen it, a value of zero will disable the effect.
  8088. Default value is 1.0.
  8089. @item chroma_msize_x, cx
  8090. Set the chroma matrix horizontal size. It must be an odd integer
  8091. between 3 and 63. The default value is 5.
  8092. @item chroma_msize_y, cy
  8093. Set the chroma matrix vertical size. It must be an odd integer
  8094. between 3 and 63. The default value is 5.
  8095. @item chroma_amount, ca
  8096. Set the chroma effect strength. It must be a floating point number, reasonable
  8097. values lay between -1.5 and 1.5.
  8098. Negative values will blur the input video, while positive values will
  8099. sharpen it, a value of zero will disable the effect.
  8100. Default value is 0.0.
  8101. @item opencl
  8102. If set to 1, specify using OpenCL capabilities, only available if
  8103. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  8104. @end table
  8105. All parameters are optional and default to the equivalent of the
  8106. string '5:5:1.0:5:5:0.0'.
  8107. @subsection Examples
  8108. @itemize
  8109. @item
  8110. Apply strong luma sharpen effect:
  8111. @example
  8112. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  8113. @end example
  8114. @item
  8115. Apply a strong blur of both luma and chroma parameters:
  8116. @example
  8117. unsharp=7:7:-2:7:7:-2
  8118. @end example
  8119. @end itemize
  8120. @section uspp
  8121. Apply ultra slow/simple postprocessing filter that compresses and decompresses
  8122. the image at several (or - in the case of @option{quality} level @code{8} - all)
  8123. shifts and average the results.
  8124. The way this differs from the behavior of spp is that uspp actually encodes &
  8125. decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
  8126. DCT similar to MJPEG.
  8127. The filter accepts the following options:
  8128. @table @option
  8129. @item quality
  8130. Set quality. This option defines the number of levels for averaging. It accepts
  8131. an integer in the range 0-8. If set to @code{0}, the filter will have no
  8132. effect. A value of @code{8} means the higher quality. For each increment of
  8133. that value the speed drops by a factor of approximately 2. Default value is
  8134. @code{3}.
  8135. @item qp
  8136. Force a constant quantization parameter. If not set, the filter will use the QP
  8137. from the video stream (if available).
  8138. @end table
  8139. @section vectorscope
  8140. Display 2 color component values in the two dimensional graph (which is called
  8141. a vectorscope).
  8142. This filter accepts the following options:
  8143. @table @option
  8144. @item mode, m
  8145. Set vectorscope mode.
  8146. It accepts the following values:
  8147. @table @samp
  8148. @item gray
  8149. Gray values are displayed on graph, higher brightness means more pixels have
  8150. same component color value on location in graph. This is the default mode.
  8151. @item color
  8152. Gray values are displayed on graph. Surrounding pixels values which are not
  8153. present in video frame are drawn in gradient of 2 color components which are
  8154. set by option @code{x} and @code{y}.
  8155. @item color2
  8156. Actual color components values present in video frame are displayed on graph.
  8157. @item color3
  8158. Similar as color2 but higher frequency of same values @code{x} and @code{y}
  8159. on graph increases value of another color component, which is luminance by
  8160. default values of @code{x} and @code{y}.
  8161. @item color4
  8162. Actual colors present in video frame are displayed on graph. If two different
  8163. colors map to same position on graph then color with higher value of component
  8164. not present in graph is picked.
  8165. @end table
  8166. @item x
  8167. Set which color component will be represented on X-axis. Default is @code{1}.
  8168. @item y
  8169. Set which color component will be represented on Y-axis. Default is @code{2}.
  8170. @item intensity, i
  8171. Set intensity, used by modes: gray, color and color3 for increasing brightness
  8172. of color component which represents frequency of (X, Y) location in graph.
  8173. @item envelope, e
  8174. @table @samp
  8175. @item none
  8176. No envelope, this is default.
  8177. @item instant
  8178. Instant envelope, even darkest single pixel will be clearly highlighted.
  8179. @item peak
  8180. Hold maximum and minimum values presented in graph over time. This way you
  8181. can still spot out of range values without constantly looking at vectorscope.
  8182. @item peak+instant
  8183. Peak and instant envelope combined together.
  8184. @end table
  8185. @end table
  8186. @anchor{vidstabdetect}
  8187. @section vidstabdetect
  8188. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  8189. @ref{vidstabtransform} for pass 2.
  8190. This filter generates a file with relative translation and rotation
  8191. transform information about subsequent frames, which is then used by
  8192. the @ref{vidstabtransform} filter.
  8193. To enable compilation of this filter you need to configure FFmpeg with
  8194. @code{--enable-libvidstab}.
  8195. This filter accepts the following options:
  8196. @table @option
  8197. @item result
  8198. Set the path to the file used to write the transforms information.
  8199. Default value is @file{transforms.trf}.
  8200. @item shakiness
  8201. Set how shaky the video is and how quick the camera is. It accepts an
  8202. integer in the range 1-10, a value of 1 means little shakiness, a
  8203. value of 10 means strong shakiness. Default value is 5.
  8204. @item accuracy
  8205. Set the accuracy of the detection process. It must be a value in the
  8206. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  8207. accuracy. Default value is 15.
  8208. @item stepsize
  8209. Set stepsize of the search process. The region around minimum is
  8210. scanned with 1 pixel resolution. Default value is 6.
  8211. @item mincontrast
  8212. Set minimum contrast. Below this value a local measurement field is
  8213. discarded. Must be a floating point value in the range 0-1. Default
  8214. value is 0.3.
  8215. @item tripod
  8216. Set reference frame number for tripod mode.
  8217. If enabled, the motion of the frames is compared to a reference frame
  8218. in the filtered stream, identified by the specified number. The idea
  8219. is to compensate all movements in a more-or-less static scene and keep
  8220. the camera view absolutely still.
  8221. If set to 0, it is disabled. The frames are counted starting from 1.
  8222. @item show
  8223. Show fields and transforms in the resulting frames. It accepts an
  8224. integer in the range 0-2. Default value is 0, which disables any
  8225. visualization.
  8226. @end table
  8227. @subsection Examples
  8228. @itemize
  8229. @item
  8230. Use default values:
  8231. @example
  8232. vidstabdetect
  8233. @end example
  8234. @item
  8235. Analyze strongly shaky movie and put the results in file
  8236. @file{mytransforms.trf}:
  8237. @example
  8238. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  8239. @end example
  8240. @item
  8241. Visualize the result of internal transformations in the resulting
  8242. video:
  8243. @example
  8244. vidstabdetect=show=1
  8245. @end example
  8246. @item
  8247. Analyze a video with medium shakiness using @command{ffmpeg}:
  8248. @example
  8249. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  8250. @end example
  8251. @end itemize
  8252. @anchor{vidstabtransform}
  8253. @section vidstabtransform
  8254. Video stabilization/deshaking: pass 2 of 2,
  8255. see @ref{vidstabdetect} for pass 1.
  8256. Read a file with transform information for each frame and
  8257. apply/compensate them. Together with the @ref{vidstabdetect}
  8258. filter this can be used to deshake videos. See also
  8259. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  8260. the @ref{unsharp} filter, see below.
  8261. To enable compilation of this filter you need to configure FFmpeg with
  8262. @code{--enable-libvidstab}.
  8263. @subsection Options
  8264. @table @option
  8265. @item input
  8266. Set path to the file used to read the transforms. Default value is
  8267. @file{transforms.trf}.
  8268. @item smoothing
  8269. Set the number of frames (value*2 + 1) used for lowpass filtering the
  8270. camera movements. Default value is 10.
  8271. For example a number of 10 means that 21 frames are used (10 in the
  8272. past and 10 in the future) to smoothen the motion in the video. A
  8273. larger value leads to a smoother video, but limits the acceleration of
  8274. the camera (pan/tilt movements). 0 is a special case where a static
  8275. camera is simulated.
  8276. @item optalgo
  8277. Set the camera path optimization algorithm.
  8278. Accepted values are:
  8279. @table @samp
  8280. @item gauss
  8281. gaussian kernel low-pass filter on camera motion (default)
  8282. @item avg
  8283. averaging on transformations
  8284. @end table
  8285. @item maxshift
  8286. Set maximal number of pixels to translate frames. Default value is -1,
  8287. meaning no limit.
  8288. @item maxangle
  8289. Set maximal angle in radians (degree*PI/180) to rotate frames. Default
  8290. value is -1, meaning no limit.
  8291. @item crop
  8292. Specify how to deal with borders that may be visible due to movement
  8293. compensation.
  8294. Available values are:
  8295. @table @samp
  8296. @item keep
  8297. keep image information from previous frame (default)
  8298. @item black
  8299. fill the border black
  8300. @end table
  8301. @item invert
  8302. Invert transforms if set to 1. Default value is 0.
  8303. @item relative
  8304. Consider transforms as relative to previous frame if set to 1,
  8305. absolute if set to 0. Default value is 0.
  8306. @item zoom
  8307. Set percentage to zoom. A positive value will result in a zoom-in
  8308. effect, a negative value in a zoom-out effect. Default value is 0 (no
  8309. zoom).
  8310. @item optzoom
  8311. Set optimal zooming to avoid borders.
  8312. Accepted values are:
  8313. @table @samp
  8314. @item 0
  8315. disabled
  8316. @item 1
  8317. optimal static zoom value is determined (only very strong movements
  8318. will lead to visible borders) (default)
  8319. @item 2
  8320. optimal adaptive zoom value is determined (no borders will be
  8321. visible), see @option{zoomspeed}
  8322. @end table
  8323. Note that the value given at zoom is added to the one calculated here.
  8324. @item zoomspeed
  8325. Set percent to zoom maximally each frame (enabled when
  8326. @option{optzoom} is set to 2). Range is from 0 to 5, default value is
  8327. 0.25.
  8328. @item interpol
  8329. Specify type of interpolation.
  8330. Available values are:
  8331. @table @samp
  8332. @item no
  8333. no interpolation
  8334. @item linear
  8335. linear only horizontal
  8336. @item bilinear
  8337. linear in both directions (default)
  8338. @item bicubic
  8339. cubic in both directions (slow)
  8340. @end table
  8341. @item tripod
  8342. Enable virtual tripod mode if set to 1, which is equivalent to
  8343. @code{relative=0:smoothing=0}. Default value is 0.
  8344. Use also @code{tripod} option of @ref{vidstabdetect}.
  8345. @item debug
  8346. Increase log verbosity if set to 1. Also the detected global motions
  8347. are written to the temporary file @file{global_motions.trf}. Default
  8348. value is 0.
  8349. @end table
  8350. @subsection Examples
  8351. @itemize
  8352. @item
  8353. Use @command{ffmpeg} for a typical stabilization with default values:
  8354. @example
  8355. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  8356. @end example
  8357. Note the use of the @ref{unsharp} filter which is always recommended.
  8358. @item
  8359. Zoom in a bit more and load transform data from a given file:
  8360. @example
  8361. vidstabtransform=zoom=5:input="mytransforms.trf"
  8362. @end example
  8363. @item
  8364. Smoothen the video even more:
  8365. @example
  8366. vidstabtransform=smoothing=30
  8367. @end example
  8368. @end itemize
  8369. @section vflip
  8370. Flip the input video vertically.
  8371. For example, to vertically flip a video with @command{ffmpeg}:
  8372. @example
  8373. ffmpeg -i in.avi -vf "vflip" out.avi
  8374. @end example
  8375. @anchor{vignette}
  8376. @section vignette
  8377. Make or reverse a natural vignetting effect.
  8378. The filter accepts the following options:
  8379. @table @option
  8380. @item angle, a
  8381. Set lens angle expression as a number of radians.
  8382. The value is clipped in the @code{[0,PI/2]} range.
  8383. Default value: @code{"PI/5"}
  8384. @item x0
  8385. @item y0
  8386. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  8387. by default.
  8388. @item mode
  8389. Set forward/backward mode.
  8390. Available modes are:
  8391. @table @samp
  8392. @item forward
  8393. The larger the distance from the central point, the darker the image becomes.
  8394. @item backward
  8395. The larger the distance from the central point, the brighter the image becomes.
  8396. This can be used to reverse a vignette effect, though there is no automatic
  8397. detection to extract the lens @option{angle} and other settings (yet). It can
  8398. also be used to create a burning effect.
  8399. @end table
  8400. Default value is @samp{forward}.
  8401. @item eval
  8402. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  8403. It accepts the following values:
  8404. @table @samp
  8405. @item init
  8406. Evaluate expressions only once during the filter initialization.
  8407. @item frame
  8408. Evaluate expressions for each incoming frame. This is way slower than the
  8409. @samp{init} mode since it requires all the scalers to be re-computed, but it
  8410. allows advanced dynamic expressions.
  8411. @end table
  8412. Default value is @samp{init}.
  8413. @item dither
  8414. Set dithering to reduce the circular banding effects. Default is @code{1}
  8415. (enabled).
  8416. @item aspect
  8417. Set vignette aspect. This setting allows one to adjust the shape of the vignette.
  8418. Setting this value to the SAR of the input will make a rectangular vignetting
  8419. following the dimensions of the video.
  8420. Default is @code{1/1}.
  8421. @end table
  8422. @subsection Expressions
  8423. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  8424. following parameters.
  8425. @table @option
  8426. @item w
  8427. @item h
  8428. input width and height
  8429. @item n
  8430. the number of input frame, starting from 0
  8431. @item pts
  8432. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  8433. @var{TB} units, NAN if undefined
  8434. @item r
  8435. frame rate of the input video, NAN if the input frame rate is unknown
  8436. @item t
  8437. the PTS (Presentation TimeStamp) of the filtered video frame,
  8438. expressed in seconds, NAN if undefined
  8439. @item tb
  8440. time base of the input video
  8441. @end table
  8442. @subsection Examples
  8443. @itemize
  8444. @item
  8445. Apply simple strong vignetting effect:
  8446. @example
  8447. vignette=PI/4
  8448. @end example
  8449. @item
  8450. Make a flickering vignetting:
  8451. @example
  8452. vignette='PI/4+random(1)*PI/50':eval=frame
  8453. @end example
  8454. @end itemize
  8455. @section vstack
  8456. Stack input videos vertically.
  8457. All streams must be of same pixel format and of same width.
  8458. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  8459. to create same output.
  8460. The filter accept the following option:
  8461. @table @option
  8462. @item nb_inputs
  8463. Set number of input streams. Default is 2.
  8464. @end table
  8465. @section w3fdif
  8466. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  8467. Deinterlacing Filter").
  8468. Based on the process described by Martin Weston for BBC R&D, and
  8469. implemented based on the de-interlace algorithm written by Jim
  8470. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  8471. uses filter coefficients calculated by BBC R&D.
  8472. There are two sets of filter coefficients, so called "simple":
  8473. and "complex". Which set of filter coefficients is used can
  8474. be set by passing an optional parameter:
  8475. @table @option
  8476. @item filter
  8477. Set the interlacing filter coefficients. Accepts one of the following values:
  8478. @table @samp
  8479. @item simple
  8480. Simple filter coefficient set.
  8481. @item complex
  8482. More-complex filter coefficient set.
  8483. @end table
  8484. Default value is @samp{complex}.
  8485. @item deint
  8486. Specify which frames to deinterlace. Accept one of the following values:
  8487. @table @samp
  8488. @item all
  8489. Deinterlace all frames,
  8490. @item interlaced
  8491. Only deinterlace frames marked as interlaced.
  8492. @end table
  8493. Default value is @samp{all}.
  8494. @end table
  8495. @section waveform
  8496. Video waveform monitor.
  8497. The waveform monitor plots color component intensity. By default luminance
  8498. only. Each column of the waveform corresponds to a column of pixels in the
  8499. source video.
  8500. It accepts the following options:
  8501. @table @option
  8502. @item mode, m
  8503. Can be either @code{row}, or @code{column}. Default is @code{column}.
  8504. In row mode, the graph on the left side represents color component value 0 and
  8505. the right side represents value = 255. In column mode, the top side represents
  8506. color component value = 0 and bottom side represents value = 255.
  8507. @item intensity, i
  8508. Set intensity. Smaller values are useful to find out how many values of the same
  8509. luminance are distributed across input rows/columns.
  8510. Default value is @code{0.04}. Allowed range is [0, 1].
  8511. @item mirror, r
  8512. Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored.
  8513. In mirrored mode, higher values will be represented on the left
  8514. side for @code{row} mode and at the top for @code{column} mode. Default is
  8515. @code{1} (mirrored).
  8516. @item display, d
  8517. Set display mode.
  8518. It accepts the following values:
  8519. @table @samp
  8520. @item overlay
  8521. Presents information identical to that in the @code{parade}, except
  8522. that the graphs representing color components are superimposed directly
  8523. over one another.
  8524. This display mode makes it easier to spot relative differences or similarities
  8525. in overlapping areas of the color components that are supposed to be identical,
  8526. such as neutral whites, grays, or blacks.
  8527. @item parade
  8528. Display separate graph for the color components side by side in
  8529. @code{row} mode or one below the other in @code{column} mode.
  8530. Using this display mode makes it easy to spot color casts in the highlights
  8531. and shadows of an image, by comparing the contours of the top and the bottom
  8532. graphs of each waveform. Since whites, grays, and blacks are characterized
  8533. by exactly equal amounts of red, green, and blue, neutral areas of the picture
  8534. should display three waveforms of roughly equal width/height. If not, the
  8535. correction is easy to perform by making level adjustments the three waveforms.
  8536. @end table
  8537. Default is @code{parade}.
  8538. @item components, c
  8539. Set which color components to display. Default is 1, which means only luminance
  8540. or red color component if input is in RGB colorspace. If is set for example to
  8541. 7 it will display all 3 (if) available color components.
  8542. @item envelope, e
  8543. @table @samp
  8544. @item none
  8545. No envelope, this is default.
  8546. @item instant
  8547. Instant envelope, minimum and maximum values presented in graph will be easily
  8548. visible even with small @code{step} value.
  8549. @item peak
  8550. Hold minimum and maximum values presented in graph across time. This way you
  8551. can still spot out of range values without constantly looking at waveforms.
  8552. @item peak+instant
  8553. Peak and instant envelope combined together.
  8554. @end table
  8555. @item filter, f
  8556. @table @samp
  8557. @item lowpass
  8558. No filtering, this is default.
  8559. @item flat
  8560. Luma and chroma combined together.
  8561. @item aflat
  8562. Similar as above, but shows difference between blue and red chroma.
  8563. @item chroma
  8564. Displays only chroma.
  8565. @item achroma
  8566. Similar as above, but shows difference between blue and red chroma.
  8567. @item color
  8568. Displays actual color value on waveform.
  8569. @end table
  8570. @end table
  8571. @section xbr
  8572. Apply the xBR high-quality magnification filter which is designed for pixel
  8573. art. It follows a set of edge-detection rules, see
  8574. @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
  8575. It accepts the following option:
  8576. @table @option
  8577. @item n
  8578. Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
  8579. @code{3xBR} and @code{4} for @code{4xBR}.
  8580. Default is @code{3}.
  8581. @end table
  8582. @anchor{yadif}
  8583. @section yadif
  8584. Deinterlace the input video ("yadif" means "yet another deinterlacing
  8585. filter").
  8586. It accepts the following parameters:
  8587. @table @option
  8588. @item mode
  8589. The interlacing mode to adopt. It accepts one of the following values:
  8590. @table @option
  8591. @item 0, send_frame
  8592. Output one frame for each frame.
  8593. @item 1, send_field
  8594. Output one frame for each field.
  8595. @item 2, send_frame_nospatial
  8596. Like @code{send_frame}, but it skips the spatial interlacing check.
  8597. @item 3, send_field_nospatial
  8598. Like @code{send_field}, but it skips the spatial interlacing check.
  8599. @end table
  8600. The default value is @code{send_frame}.
  8601. @item parity
  8602. The picture field parity assumed for the input interlaced video. It accepts one
  8603. of the following values:
  8604. @table @option
  8605. @item 0, tff
  8606. Assume the top field is first.
  8607. @item 1, bff
  8608. Assume the bottom field is first.
  8609. @item -1, auto
  8610. Enable automatic detection of field parity.
  8611. @end table
  8612. The default value is @code{auto}.
  8613. If the interlacing is unknown or the decoder does not export this information,
  8614. top field first will be assumed.
  8615. @item deint
  8616. Specify which frames to deinterlace. Accept one of the following
  8617. values:
  8618. @table @option
  8619. @item 0, all
  8620. Deinterlace all frames.
  8621. @item 1, interlaced
  8622. Only deinterlace frames marked as interlaced.
  8623. @end table
  8624. The default value is @code{all}.
  8625. @end table
  8626. @section zoompan
  8627. Apply Zoom & Pan effect.
  8628. This filter accepts the following options:
  8629. @table @option
  8630. @item zoom, z
  8631. Set the zoom expression. Default is 1.
  8632. @item x
  8633. @item y
  8634. Set the x and y expression. Default is 0.
  8635. @item d
  8636. Set the duration expression in number of frames.
  8637. This sets for how many number of frames effect will last for
  8638. single input image.
  8639. @item s
  8640. Set the output image size, default is 'hd720'.
  8641. @end table
  8642. Each expression can contain the following constants:
  8643. @table @option
  8644. @item in_w, iw
  8645. Input width.
  8646. @item in_h, ih
  8647. Input height.
  8648. @item out_w, ow
  8649. Output width.
  8650. @item out_h, oh
  8651. Output height.
  8652. @item in
  8653. Input frame count.
  8654. @item on
  8655. Output frame count.
  8656. @item x
  8657. @item y
  8658. Last calculated 'x' and 'y' position from 'x' and 'y' expression
  8659. for current input frame.
  8660. @item px
  8661. @item py
  8662. 'x' and 'y' of last output frame of previous input frame or 0 when there was
  8663. not yet such frame (first input frame).
  8664. @item zoom
  8665. Last calculated zoom from 'z' expression for current input frame.
  8666. @item pzoom
  8667. Last calculated zoom of last output frame of previous input frame.
  8668. @item duration
  8669. Number of output frames for current input frame. Calculated from 'd' expression
  8670. for each input frame.
  8671. @item pduration
  8672. number of output frames created for previous input frame
  8673. @item a
  8674. Rational number: input width / input height
  8675. @item sar
  8676. sample aspect ratio
  8677. @item dar
  8678. display aspect ratio
  8679. @end table
  8680. @subsection Examples
  8681. @itemize
  8682. @item
  8683. Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
  8684. @example
  8685. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='if(gte(zoom,1.5),x,x+1/a)':y='if(gte(zoom,1.5),y,y+1)':s=640x360
  8686. @end example
  8687. @item
  8688. Zoom-in up to 1.5 and pan always at center of picture:
  8689. @example
  8690. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
  8691. @end example
  8692. @end itemize
  8693. @c man end VIDEO FILTERS
  8694. @chapter Video Sources
  8695. @c man begin VIDEO SOURCES
  8696. Below is a description of the currently available video sources.
  8697. @section buffer
  8698. Buffer video frames, and make them available to the filter chain.
  8699. This source is mainly intended for a programmatic use, in particular
  8700. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  8701. It accepts the following parameters:
  8702. @table @option
  8703. @item video_size
  8704. Specify the size (width and height) of the buffered video frames. For the
  8705. syntax of this option, check the
  8706. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8707. @item width
  8708. The input video width.
  8709. @item height
  8710. The input video height.
  8711. @item pix_fmt
  8712. A string representing the pixel format of the buffered video frames.
  8713. It may be a number corresponding to a pixel format, or a pixel format
  8714. name.
  8715. @item time_base
  8716. Specify the timebase assumed by the timestamps of the buffered frames.
  8717. @item frame_rate
  8718. Specify the frame rate expected for the video stream.
  8719. @item pixel_aspect, sar
  8720. The sample (pixel) aspect ratio of the input video.
  8721. @item sws_param
  8722. Specify the optional parameters to be used for the scale filter which
  8723. is automatically inserted when an input change is detected in the
  8724. input size or format.
  8725. @end table
  8726. For example:
  8727. @example
  8728. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  8729. @end example
  8730. will instruct the source to accept video frames with size 320x240 and
  8731. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  8732. square pixels (1:1 sample aspect ratio).
  8733. Since the pixel format with name "yuv410p" corresponds to the number 6
  8734. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  8735. this example corresponds to:
  8736. @example
  8737. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  8738. @end example
  8739. Alternatively, the options can be specified as a flat string, but this
  8740. syntax is deprecated:
  8741. @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}]
  8742. @section cellauto
  8743. Create a pattern generated by an elementary cellular automaton.
  8744. The initial state of the cellular automaton can be defined through the
  8745. @option{filename}, and @option{pattern} options. If such options are
  8746. not specified an initial state is created randomly.
  8747. At each new frame a new row in the video is filled with the result of
  8748. the cellular automaton next generation. The behavior when the whole
  8749. frame is filled is defined by the @option{scroll} option.
  8750. This source accepts the following options:
  8751. @table @option
  8752. @item filename, f
  8753. Read the initial cellular automaton state, i.e. the starting row, from
  8754. the specified file.
  8755. In the file, each non-whitespace character is considered an alive
  8756. cell, a newline will terminate the row, and further characters in the
  8757. file will be ignored.
  8758. @item pattern, p
  8759. Read the initial cellular automaton state, i.e. the starting row, from
  8760. the specified string.
  8761. Each non-whitespace character in the string is considered an alive
  8762. cell, a newline will terminate the row, and further characters in the
  8763. string will be ignored.
  8764. @item rate, r
  8765. Set the video rate, that is the number of frames generated per second.
  8766. Default is 25.
  8767. @item random_fill_ratio, ratio
  8768. Set the random fill ratio for the initial cellular automaton row. It
  8769. is a floating point number value ranging from 0 to 1, defaults to
  8770. 1/PHI.
  8771. This option is ignored when a file or a pattern is specified.
  8772. @item random_seed, seed
  8773. Set the seed for filling randomly the initial row, must be an integer
  8774. included between 0 and UINT32_MAX. If not specified, or if explicitly
  8775. set to -1, the filter will try to use a good random seed on a best
  8776. effort basis.
  8777. @item rule
  8778. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  8779. Default value is 110.
  8780. @item size, s
  8781. Set the size of the output video. For the syntax of this option, check the
  8782. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8783. If @option{filename} or @option{pattern} is specified, the size is set
  8784. by default to the width of the specified initial state row, and the
  8785. height is set to @var{width} * PHI.
  8786. If @option{size} is set, it must contain the width of the specified
  8787. pattern string, and the specified pattern will be centered in the
  8788. larger row.
  8789. If a filename or a pattern string is not specified, the size value
  8790. defaults to "320x518" (used for a randomly generated initial state).
  8791. @item scroll
  8792. If set to 1, scroll the output upward when all the rows in the output
  8793. have been already filled. If set to 0, the new generated row will be
  8794. written over the top row just after the bottom row is filled.
  8795. Defaults to 1.
  8796. @item start_full, full
  8797. If set to 1, completely fill the output with generated rows before
  8798. outputting the first frame.
  8799. This is the default behavior, for disabling set the value to 0.
  8800. @item stitch
  8801. If set to 1, stitch the left and right row edges together.
  8802. This is the default behavior, for disabling set the value to 0.
  8803. @end table
  8804. @subsection Examples
  8805. @itemize
  8806. @item
  8807. Read the initial state from @file{pattern}, and specify an output of
  8808. size 200x400.
  8809. @example
  8810. cellauto=f=pattern:s=200x400
  8811. @end example
  8812. @item
  8813. Generate a random initial row with a width of 200 cells, with a fill
  8814. ratio of 2/3:
  8815. @example
  8816. cellauto=ratio=2/3:s=200x200
  8817. @end example
  8818. @item
  8819. Create a pattern generated by rule 18 starting by a single alive cell
  8820. centered on an initial row with width 100:
  8821. @example
  8822. cellauto=p=@@:s=100x400:full=0:rule=18
  8823. @end example
  8824. @item
  8825. Specify a more elaborated initial pattern:
  8826. @example
  8827. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  8828. @end example
  8829. @end itemize
  8830. @section mandelbrot
  8831. Generate a Mandelbrot set fractal, and progressively zoom towards the
  8832. point specified with @var{start_x} and @var{start_y}.
  8833. This source accepts the following options:
  8834. @table @option
  8835. @item end_pts
  8836. Set the terminal pts value. Default value is 400.
  8837. @item end_scale
  8838. Set the terminal scale value.
  8839. Must be a floating point value. Default value is 0.3.
  8840. @item inner
  8841. Set the inner coloring mode, that is the algorithm used to draw the
  8842. Mandelbrot fractal internal region.
  8843. It shall assume one of the following values:
  8844. @table @option
  8845. @item black
  8846. Set black mode.
  8847. @item convergence
  8848. Show time until convergence.
  8849. @item mincol
  8850. Set color based on point closest to the origin of the iterations.
  8851. @item period
  8852. Set period mode.
  8853. @end table
  8854. Default value is @var{mincol}.
  8855. @item bailout
  8856. Set the bailout value. Default value is 10.0.
  8857. @item maxiter
  8858. Set the maximum of iterations performed by the rendering
  8859. algorithm. Default value is 7189.
  8860. @item outer
  8861. Set outer coloring mode.
  8862. It shall assume one of following values:
  8863. @table @option
  8864. @item iteration_count
  8865. Set iteration cound mode.
  8866. @item normalized_iteration_count
  8867. set normalized iteration count mode.
  8868. @end table
  8869. Default value is @var{normalized_iteration_count}.
  8870. @item rate, r
  8871. Set frame rate, expressed as number of frames per second. Default
  8872. value is "25".
  8873. @item size, s
  8874. Set frame size. For the syntax of this option, check the "Video
  8875. size" section in the ffmpeg-utils manual. Default value is "640x480".
  8876. @item start_scale
  8877. Set the initial scale value. Default value is 3.0.
  8878. @item start_x
  8879. Set the initial x position. Must be a floating point value between
  8880. -100 and 100. Default value is -0.743643887037158704752191506114774.
  8881. @item start_y
  8882. Set the initial y position. Must be a floating point value between
  8883. -100 and 100. Default value is -0.131825904205311970493132056385139.
  8884. @end table
  8885. @section mptestsrc
  8886. Generate various test patterns, as generated by the MPlayer test filter.
  8887. The size of the generated video is fixed, and is 256x256.
  8888. This source is useful in particular for testing encoding features.
  8889. This source accepts the following options:
  8890. @table @option
  8891. @item rate, r
  8892. Specify the frame rate of the sourced video, as the number of frames
  8893. generated per second. It has to be a string in the format
  8894. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  8895. number or a valid video frame rate abbreviation. The default value is
  8896. "25".
  8897. @item duration, d
  8898. Set the duration of the sourced video. See
  8899. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  8900. for the accepted syntax.
  8901. If not specified, or the expressed duration is negative, the video is
  8902. supposed to be generated forever.
  8903. @item test, t
  8904. Set the number or the name of the test to perform. Supported tests are:
  8905. @table @option
  8906. @item dc_luma
  8907. @item dc_chroma
  8908. @item freq_luma
  8909. @item freq_chroma
  8910. @item amp_luma
  8911. @item amp_chroma
  8912. @item cbp
  8913. @item mv
  8914. @item ring1
  8915. @item ring2
  8916. @item all
  8917. @end table
  8918. Default value is "all", which will cycle through the list of all tests.
  8919. @end table
  8920. Some examples:
  8921. @example
  8922. mptestsrc=t=dc_luma
  8923. @end example
  8924. will generate a "dc_luma" test pattern.
  8925. @section frei0r_src
  8926. Provide a frei0r source.
  8927. To enable compilation of this filter you need to install the frei0r
  8928. header and configure FFmpeg with @code{--enable-frei0r}.
  8929. This source accepts the following parameters:
  8930. @table @option
  8931. @item size
  8932. The size of the video to generate. For the syntax of this option, check the
  8933. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8934. @item framerate
  8935. The framerate of the generated video. It may be a string of the form
  8936. @var{num}/@var{den} or a frame rate abbreviation.
  8937. @item filter_name
  8938. The name to the frei0r source to load. For more information regarding frei0r and
  8939. how to set the parameters, read the @ref{frei0r} section in the video filters
  8940. documentation.
  8941. @item filter_params
  8942. A '|'-separated list of parameters to pass to the frei0r source.
  8943. @end table
  8944. For example, to generate a frei0r partik0l source with size 200x200
  8945. and frame rate 10 which is overlaid on the overlay filter main input:
  8946. @example
  8947. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  8948. @end example
  8949. @section life
  8950. Generate a life pattern.
  8951. This source is based on a generalization of John Conway's life game.
  8952. The sourced input represents a life grid, each pixel represents a cell
  8953. which can be in one of two possible states, alive or dead. Every cell
  8954. interacts with its eight neighbours, which are the cells that are
  8955. horizontally, vertically, or diagonally adjacent.
  8956. At each interaction the grid evolves according to the adopted rule,
  8957. which specifies the number of neighbor alive cells which will make a
  8958. cell stay alive or born. The @option{rule} option allows one to specify
  8959. the rule to adopt.
  8960. This source accepts the following options:
  8961. @table @option
  8962. @item filename, f
  8963. Set the file from which to read the initial grid state. In the file,
  8964. each non-whitespace character is considered an alive cell, and newline
  8965. is used to delimit the end of each row.
  8966. If this option is not specified, the initial grid is generated
  8967. randomly.
  8968. @item rate, r
  8969. Set the video rate, that is the number of frames generated per second.
  8970. Default is 25.
  8971. @item random_fill_ratio, ratio
  8972. Set the random fill ratio for the initial random grid. It is a
  8973. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  8974. It is ignored when a file is specified.
  8975. @item random_seed, seed
  8976. Set the seed for filling the initial random grid, must be an integer
  8977. included between 0 and UINT32_MAX. If not specified, or if explicitly
  8978. set to -1, the filter will try to use a good random seed on a best
  8979. effort basis.
  8980. @item rule
  8981. Set the life rule.
  8982. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  8983. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  8984. @var{NS} specifies the number of alive neighbor cells which make a
  8985. live cell stay alive, and @var{NB} the number of alive neighbor cells
  8986. which make a dead cell to become alive (i.e. to "born").
  8987. "s" and "b" can be used in place of "S" and "B", respectively.
  8988. Alternatively a rule can be specified by an 18-bits integer. The 9
  8989. high order bits are used to encode the next cell state if it is alive
  8990. for each number of neighbor alive cells, the low order bits specify
  8991. the rule for "borning" new cells. Higher order bits encode for an
  8992. higher number of neighbor cells.
  8993. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  8994. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  8995. Default value is "S23/B3", which is the original Conway's game of life
  8996. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  8997. cells, and will born a new cell if there are three alive cells around
  8998. a dead cell.
  8999. @item size, s
  9000. Set the size of the output video. For the syntax of this option, check the
  9001. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9002. If @option{filename} is specified, the size is set by default to the
  9003. same size of the input file. If @option{size} is set, it must contain
  9004. the size specified in the input file, and the initial grid defined in
  9005. that file is centered in the larger resulting area.
  9006. If a filename is not specified, the size value defaults to "320x240"
  9007. (used for a randomly generated initial grid).
  9008. @item stitch
  9009. If set to 1, stitch the left and right grid edges together, and the
  9010. top and bottom edges also. Defaults to 1.
  9011. @item mold
  9012. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  9013. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  9014. value from 0 to 255.
  9015. @item life_color
  9016. Set the color of living (or new born) cells.
  9017. @item death_color
  9018. Set the color of dead cells. If @option{mold} is set, this is the first color
  9019. used to represent a dead cell.
  9020. @item mold_color
  9021. Set mold color, for definitely dead and moldy cells.
  9022. For the syntax of these 3 color options, check the "Color" section in the
  9023. ffmpeg-utils manual.
  9024. @end table
  9025. @subsection Examples
  9026. @itemize
  9027. @item
  9028. Read a grid from @file{pattern}, and center it on a grid of size
  9029. 300x300 pixels:
  9030. @example
  9031. life=f=pattern:s=300x300
  9032. @end example
  9033. @item
  9034. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  9035. @example
  9036. life=ratio=2/3:s=200x200
  9037. @end example
  9038. @item
  9039. Specify a custom rule for evolving a randomly generated grid:
  9040. @example
  9041. life=rule=S14/B34
  9042. @end example
  9043. @item
  9044. Full example with slow death effect (mold) using @command{ffplay}:
  9045. @example
  9046. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  9047. @end example
  9048. @end itemize
  9049. @anchor{allrgb}
  9050. @anchor{allyuv}
  9051. @anchor{color}
  9052. @anchor{haldclutsrc}
  9053. @anchor{nullsrc}
  9054. @anchor{rgbtestsrc}
  9055. @anchor{smptebars}
  9056. @anchor{smptehdbars}
  9057. @anchor{testsrc}
  9058. @section allrgb, allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  9059. The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
  9060. The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
  9061. The @code{color} source provides an uniformly colored input.
  9062. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  9063. @ref{haldclut} filter.
  9064. The @code{nullsrc} source returns unprocessed video frames. It is
  9065. mainly useful to be employed in analysis / debugging tools, or as the
  9066. source for filters which ignore the input data.
  9067. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  9068. detecting RGB vs BGR issues. You should see a red, green and blue
  9069. stripe from top to bottom.
  9070. The @code{smptebars} source generates a color bars pattern, based on
  9071. the SMPTE Engineering Guideline EG 1-1990.
  9072. The @code{smptehdbars} source generates a color bars pattern, based on
  9073. the SMPTE RP 219-2002.
  9074. The @code{testsrc} source generates a test video pattern, showing a
  9075. color pattern, a scrolling gradient and a timestamp. This is mainly
  9076. intended for testing purposes.
  9077. The sources accept the following parameters:
  9078. @table @option
  9079. @item color, c
  9080. Specify the color of the source, only available in the @code{color}
  9081. source. For the syntax of this option, check the "Color" section in the
  9082. ffmpeg-utils manual.
  9083. @item level
  9084. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  9085. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  9086. pixels to be used as identity matrix for 3D lookup tables. Each component is
  9087. coded on a @code{1/(N*N)} scale.
  9088. @item size, s
  9089. Specify the size of the sourced video. For the syntax of this option, check the
  9090. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9091. The default value is @code{320x240}.
  9092. This option is not available with the @code{haldclutsrc} filter.
  9093. @item rate, r
  9094. Specify the frame rate of the sourced video, as the number of frames
  9095. generated per second. It has to be a string in the format
  9096. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  9097. number or a valid video frame rate abbreviation. The default value is
  9098. "25".
  9099. @item sar
  9100. Set the sample aspect ratio of the sourced video.
  9101. @item duration, d
  9102. Set the duration of the sourced video. See
  9103. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  9104. for the accepted syntax.
  9105. If not specified, or the expressed duration is negative, the video is
  9106. supposed to be generated forever.
  9107. @item decimals, n
  9108. Set the number of decimals to show in the timestamp, only available in the
  9109. @code{testsrc} source.
  9110. The displayed timestamp value will correspond to the original
  9111. timestamp value multiplied by the power of 10 of the specified
  9112. value. Default value is 0.
  9113. @end table
  9114. For example the following:
  9115. @example
  9116. testsrc=duration=5.3:size=qcif:rate=10
  9117. @end example
  9118. will generate a video with a duration of 5.3 seconds, with size
  9119. 176x144 and a frame rate of 10 frames per second.
  9120. The following graph description will generate a red source
  9121. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  9122. frames per second.
  9123. @example
  9124. color=c=red@@0.2:s=qcif:r=10
  9125. @end example
  9126. If the input content is to be ignored, @code{nullsrc} can be used. The
  9127. following command generates noise in the luminance plane by employing
  9128. the @code{geq} filter:
  9129. @example
  9130. nullsrc=s=256x256, geq=random(1)*255:128:128
  9131. @end example
  9132. @subsection Commands
  9133. The @code{color} source supports the following commands:
  9134. @table @option
  9135. @item c, color
  9136. Set the color of the created image. Accepts the same syntax of the
  9137. corresponding @option{color} option.
  9138. @end table
  9139. @c man end VIDEO SOURCES
  9140. @chapter Video Sinks
  9141. @c man begin VIDEO SINKS
  9142. Below is a description of the currently available video sinks.
  9143. @section buffersink
  9144. Buffer video frames, and make them available to the end of the filter
  9145. graph.
  9146. This sink is mainly intended for programmatic use, in particular
  9147. through the interface defined in @file{libavfilter/buffersink.h}
  9148. or the options system.
  9149. It accepts a pointer to an AVBufferSinkContext structure, which
  9150. defines the incoming buffers' formats, to be passed as the opaque
  9151. parameter to @code{avfilter_init_filter} for initialization.
  9152. @section nullsink
  9153. Null video sink: do absolutely nothing with the input video. It is
  9154. mainly useful as a template and for use in analysis / debugging
  9155. tools.
  9156. @c man end VIDEO SINKS
  9157. @chapter Multimedia Filters
  9158. @c man begin MULTIMEDIA FILTERS
  9159. Below is a description of the currently available multimedia filters.
  9160. @section aphasemeter
  9161. Convert input audio to a video output, displaying the audio phase.
  9162. The filter accepts the following options:
  9163. @table @option
  9164. @item rate, r
  9165. Set the output frame rate. Default value is @code{25}.
  9166. @item size, s
  9167. Set the video size for the output. For the syntax of this option, check the
  9168. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9169. Default value is @code{800x400}.
  9170. @item rc
  9171. @item gc
  9172. @item bc
  9173. Specify the red, green, blue contrast. Default values are @code{2},
  9174. @code{7} and @code{1}.
  9175. Allowed range is @code{[0, 255]}.
  9176. @item mpc
  9177. Set color which will be used for drawing median phase. If color is
  9178. @code{none} which is default, no median phase value will be drawn.
  9179. @end table
  9180. The filter also exports the frame metadata @code{lavfi.aphasemeter.phase} which
  9181. represents mean phase of current audio frame. Value is in range @code{[-1, 1]}.
  9182. The @code{-1} means left and right channels are completely out of phase and
  9183. @code{1} means channels are in phase.
  9184. @section avectorscope
  9185. Convert input audio to a video output, representing the audio vector
  9186. scope.
  9187. The filter is used to measure the difference between channels of stereo
  9188. audio stream. A monoaural signal, consisting of identical left and right
  9189. signal, results in straight vertical line. Any stereo separation is visible
  9190. as a deviation from this line, creating a Lissajous figure.
  9191. If the straight (or deviation from it) but horizontal line appears this
  9192. indicates that the left and right channels are out of phase.
  9193. The filter accepts the following options:
  9194. @table @option
  9195. @item mode, m
  9196. Set the vectorscope mode.
  9197. Available values are:
  9198. @table @samp
  9199. @item lissajous
  9200. Lissajous rotated by 45 degrees.
  9201. @item lissajous_xy
  9202. Same as above but not rotated.
  9203. @item polar
  9204. Shape resembling half of circle.
  9205. @end table
  9206. Default value is @samp{lissajous}.
  9207. @item size, s
  9208. Set the video size for the output. For the syntax of this option, check the
  9209. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9210. Default value is @code{400x400}.
  9211. @item rate, r
  9212. Set the output frame rate. Default value is @code{25}.
  9213. @item rc
  9214. @item gc
  9215. @item bc
  9216. @item ac
  9217. Specify the red, green, blue and alpha contrast. Default values are @code{40},
  9218. @code{160}, @code{80} and @code{255}.
  9219. Allowed range is @code{[0, 255]}.
  9220. @item rf
  9221. @item gf
  9222. @item bf
  9223. @item af
  9224. Specify the red, green, blue and alpha fade. Default values are @code{15},
  9225. @code{10}, @code{5} and @code{5}.
  9226. Allowed range is @code{[0, 255]}.
  9227. @item zoom
  9228. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  9229. @end table
  9230. @subsection Examples
  9231. @itemize
  9232. @item
  9233. Complete example using @command{ffplay}:
  9234. @example
  9235. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  9236. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  9237. @end example
  9238. @end itemize
  9239. @section concat
  9240. Concatenate audio and video streams, joining them together one after the
  9241. other.
  9242. The filter works on segments of synchronized video and audio streams. All
  9243. segments must have the same number of streams of each type, and that will
  9244. also be the number of streams at output.
  9245. The filter accepts the following options:
  9246. @table @option
  9247. @item n
  9248. Set the number of segments. Default is 2.
  9249. @item v
  9250. Set the number of output video streams, that is also the number of video
  9251. streams in each segment. Default is 1.
  9252. @item a
  9253. Set the number of output audio streams, that is also the number of audio
  9254. streams in each segment. Default is 0.
  9255. @item unsafe
  9256. Activate unsafe mode: do not fail if segments have a different format.
  9257. @end table
  9258. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  9259. @var{a} audio outputs.
  9260. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  9261. segment, in the same order as the outputs, then the inputs for the second
  9262. segment, etc.
  9263. Related streams do not always have exactly the same duration, for various
  9264. reasons including codec frame size or sloppy authoring. For that reason,
  9265. related synchronized streams (e.g. a video and its audio track) should be
  9266. concatenated at once. The concat filter will use the duration of the longest
  9267. stream in each segment (except the last one), and if necessary pad shorter
  9268. audio streams with silence.
  9269. For this filter to work correctly, all segments must start at timestamp 0.
  9270. All corresponding streams must have the same parameters in all segments; the
  9271. filtering system will automatically select a common pixel format for video
  9272. streams, and a common sample format, sample rate and channel layout for
  9273. audio streams, but other settings, such as resolution, must be converted
  9274. explicitly by the user.
  9275. Different frame rates are acceptable but will result in variable frame rate
  9276. at output; be sure to configure the output file to handle it.
  9277. @subsection Examples
  9278. @itemize
  9279. @item
  9280. Concatenate an opening, an episode and an ending, all in bilingual version
  9281. (video in stream 0, audio in streams 1 and 2):
  9282. @example
  9283. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  9284. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  9285. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  9286. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  9287. @end example
  9288. @item
  9289. Concatenate two parts, handling audio and video separately, using the
  9290. (a)movie sources, and adjusting the resolution:
  9291. @example
  9292. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  9293. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  9294. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  9295. @end example
  9296. Note that a desync will happen at the stitch if the audio and video streams
  9297. do not have exactly the same duration in the first file.
  9298. @end itemize
  9299. @anchor{ebur128}
  9300. @section ebur128
  9301. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  9302. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  9303. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  9304. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  9305. The filter also has a video output (see the @var{video} option) with a real
  9306. time graph to observe the loudness evolution. The graphic contains the logged
  9307. message mentioned above, so it is not printed anymore when this option is set,
  9308. unless the verbose logging is set. The main graphing area contains the
  9309. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  9310. the momentary loudness (400 milliseconds).
  9311. More information about the Loudness Recommendation EBU R128 on
  9312. @url{http://tech.ebu.ch/loudness}.
  9313. The filter accepts the following options:
  9314. @table @option
  9315. @item video
  9316. Activate the video output. The audio stream is passed unchanged whether this
  9317. option is set or no. The video stream will be the first output stream if
  9318. activated. Default is @code{0}.
  9319. @item size
  9320. Set the video size. This option is for video only. For the syntax of this
  9321. option, check the
  9322. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9323. Default and minimum resolution is @code{640x480}.
  9324. @item meter
  9325. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  9326. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  9327. other integer value between this range is allowed.
  9328. @item metadata
  9329. Set metadata injection. If set to @code{1}, the audio input will be segmented
  9330. into 100ms output frames, each of them containing various loudness information
  9331. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  9332. Default is @code{0}.
  9333. @item framelog
  9334. Force the frame logging level.
  9335. Available values are:
  9336. @table @samp
  9337. @item info
  9338. information logging level
  9339. @item verbose
  9340. verbose logging level
  9341. @end table
  9342. By default, the logging level is set to @var{info}. If the @option{video} or
  9343. the @option{metadata} options are set, it switches to @var{verbose}.
  9344. @item peak
  9345. Set peak mode(s).
  9346. Available modes can be cumulated (the option is a @code{flag} type). Possible
  9347. values are:
  9348. @table @samp
  9349. @item none
  9350. Disable any peak mode (default).
  9351. @item sample
  9352. Enable sample-peak mode.
  9353. Simple peak mode looking for the higher sample value. It logs a message
  9354. for sample-peak (identified by @code{SPK}).
  9355. @item true
  9356. Enable true-peak mode.
  9357. If enabled, the peak lookup is done on an over-sampled version of the input
  9358. stream for better peak accuracy. It logs a message for true-peak.
  9359. (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
  9360. This mode requires a build with @code{libswresample}.
  9361. @end table
  9362. @end table
  9363. @subsection Examples
  9364. @itemize
  9365. @item
  9366. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  9367. @example
  9368. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  9369. @end example
  9370. @item
  9371. Run an analysis with @command{ffmpeg}:
  9372. @example
  9373. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  9374. @end example
  9375. @end itemize
  9376. @section interleave, ainterleave
  9377. Temporally interleave frames from several inputs.
  9378. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  9379. These filters read frames from several inputs and send the oldest
  9380. queued frame to the output.
  9381. Input streams must have a well defined, monotonically increasing frame
  9382. timestamp values.
  9383. In order to submit one frame to output, these filters need to enqueue
  9384. at least one frame for each input, so they cannot work in case one
  9385. input is not yet terminated and will not receive incoming frames.
  9386. For example consider the case when one input is a @code{select} filter
  9387. which always drop input frames. The @code{interleave} filter will keep
  9388. reading from that input, but it will never be able to send new frames
  9389. to output until the input will send an end-of-stream signal.
  9390. Also, depending on inputs synchronization, the filters will drop
  9391. frames in case one input receives more frames than the other ones, and
  9392. the queue is already filled.
  9393. These filters accept the following options:
  9394. @table @option
  9395. @item nb_inputs, n
  9396. Set the number of different inputs, it is 2 by default.
  9397. @end table
  9398. @subsection Examples
  9399. @itemize
  9400. @item
  9401. Interleave frames belonging to different streams using @command{ffmpeg}:
  9402. @example
  9403. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  9404. @end example
  9405. @item
  9406. Add flickering blur effect:
  9407. @example
  9408. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  9409. @end example
  9410. @end itemize
  9411. @section perms, aperms
  9412. Set read/write permissions for the output frames.
  9413. These filters are mainly aimed at developers to test direct path in the
  9414. following filter in the filtergraph.
  9415. The filters accept the following options:
  9416. @table @option
  9417. @item mode
  9418. Select the permissions mode.
  9419. It accepts the following values:
  9420. @table @samp
  9421. @item none
  9422. Do nothing. This is the default.
  9423. @item ro
  9424. Set all the output frames read-only.
  9425. @item rw
  9426. Set all the output frames directly writable.
  9427. @item toggle
  9428. Make the frame read-only if writable, and writable if read-only.
  9429. @item random
  9430. Set each output frame read-only or writable randomly.
  9431. @end table
  9432. @item seed
  9433. Set the seed for the @var{random} mode, must be an integer included between
  9434. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  9435. @code{-1}, the filter will try to use a good random seed on a best effort
  9436. basis.
  9437. @end table
  9438. Note: in case of auto-inserted filter between the permission filter and the
  9439. following one, the permission might not be received as expected in that
  9440. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  9441. perms/aperms filter can avoid this problem.
  9442. @section select, aselect
  9443. Select frames to pass in output.
  9444. This filter accepts the following options:
  9445. @table @option
  9446. @item expr, e
  9447. Set expression, which is evaluated for each input frame.
  9448. If the expression is evaluated to zero, the frame is discarded.
  9449. If the evaluation result is negative or NaN, the frame is sent to the
  9450. first output; otherwise it is sent to the output with index
  9451. @code{ceil(val)-1}, assuming that the input index starts from 0.
  9452. For example a value of @code{1.2} corresponds to the output with index
  9453. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  9454. @item outputs, n
  9455. Set the number of outputs. The output to which to send the selected
  9456. frame is based on the result of the evaluation. Default value is 1.
  9457. @end table
  9458. The expression can contain the following constants:
  9459. @table @option
  9460. @item n
  9461. The (sequential) number of the filtered frame, starting from 0.
  9462. @item selected_n
  9463. The (sequential) number of the selected frame, starting from 0.
  9464. @item prev_selected_n
  9465. The sequential number of the last selected frame. It's NAN if undefined.
  9466. @item TB
  9467. The timebase of the input timestamps.
  9468. @item pts
  9469. The PTS (Presentation TimeStamp) of the filtered video frame,
  9470. expressed in @var{TB} units. It's NAN if undefined.
  9471. @item t
  9472. The PTS of the filtered video frame,
  9473. expressed in seconds. It's NAN if undefined.
  9474. @item prev_pts
  9475. The PTS of the previously filtered video frame. It's NAN if undefined.
  9476. @item prev_selected_pts
  9477. The PTS of the last previously filtered video frame. It's NAN if undefined.
  9478. @item prev_selected_t
  9479. The PTS of the last previously selected video frame. It's NAN if undefined.
  9480. @item start_pts
  9481. The PTS of the first video frame in the video. It's NAN if undefined.
  9482. @item start_t
  9483. The time of the first video frame in the video. It's NAN if undefined.
  9484. @item pict_type @emph{(video only)}
  9485. The type of the filtered frame. It can assume one of the following
  9486. values:
  9487. @table @option
  9488. @item I
  9489. @item P
  9490. @item B
  9491. @item S
  9492. @item SI
  9493. @item SP
  9494. @item BI
  9495. @end table
  9496. @item interlace_type @emph{(video only)}
  9497. The frame interlace type. It can assume one of the following values:
  9498. @table @option
  9499. @item PROGRESSIVE
  9500. The frame is progressive (not interlaced).
  9501. @item TOPFIRST
  9502. The frame is top-field-first.
  9503. @item BOTTOMFIRST
  9504. The frame is bottom-field-first.
  9505. @end table
  9506. @item consumed_sample_n @emph{(audio only)}
  9507. the number of selected samples before the current frame
  9508. @item samples_n @emph{(audio only)}
  9509. the number of samples in the current frame
  9510. @item sample_rate @emph{(audio only)}
  9511. the input sample rate
  9512. @item key
  9513. This is 1 if the filtered frame is a key-frame, 0 otherwise.
  9514. @item pos
  9515. the position in the file of the filtered frame, -1 if the information
  9516. is not available (e.g. for synthetic video)
  9517. @item scene @emph{(video only)}
  9518. value between 0 and 1 to indicate a new scene; a low value reflects a low
  9519. probability for the current frame to introduce a new scene, while a higher
  9520. value means the current frame is more likely to be one (see the example below)
  9521. @end table
  9522. The default value of the select expression is "1".
  9523. @subsection Examples
  9524. @itemize
  9525. @item
  9526. Select all frames in input:
  9527. @example
  9528. select
  9529. @end example
  9530. The example above is the same as:
  9531. @example
  9532. select=1
  9533. @end example
  9534. @item
  9535. Skip all frames:
  9536. @example
  9537. select=0
  9538. @end example
  9539. @item
  9540. Select only I-frames:
  9541. @example
  9542. select='eq(pict_type\,I)'
  9543. @end example
  9544. @item
  9545. Select one frame every 100:
  9546. @example
  9547. select='not(mod(n\,100))'
  9548. @end example
  9549. @item
  9550. Select only frames contained in the 10-20 time interval:
  9551. @example
  9552. select=between(t\,10\,20)
  9553. @end example
  9554. @item
  9555. Select only I frames contained in the 10-20 time interval:
  9556. @example
  9557. select=between(t\,10\,20)*eq(pict_type\,I)
  9558. @end example
  9559. @item
  9560. Select frames with a minimum distance of 10 seconds:
  9561. @example
  9562. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  9563. @end example
  9564. @item
  9565. Use aselect to select only audio frames with samples number > 100:
  9566. @example
  9567. aselect='gt(samples_n\,100)'
  9568. @end example
  9569. @item
  9570. Create a mosaic of the first scenes:
  9571. @example
  9572. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  9573. @end example
  9574. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  9575. choice.
  9576. @item
  9577. Send even and odd frames to separate outputs, and compose them:
  9578. @example
  9579. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  9580. @end example
  9581. @end itemize
  9582. @section sendcmd, asendcmd
  9583. Send commands to filters in the filtergraph.
  9584. These filters read commands to be sent to other filters in the
  9585. filtergraph.
  9586. @code{sendcmd} must be inserted between two video filters,
  9587. @code{asendcmd} must be inserted between two audio filters, but apart
  9588. from that they act the same way.
  9589. The specification of commands can be provided in the filter arguments
  9590. with the @var{commands} option, or in a file specified by the
  9591. @var{filename} option.
  9592. These filters accept the following options:
  9593. @table @option
  9594. @item commands, c
  9595. Set the commands to be read and sent to the other filters.
  9596. @item filename, f
  9597. Set the filename of the commands to be read and sent to the other
  9598. filters.
  9599. @end table
  9600. @subsection Commands syntax
  9601. A commands description consists of a sequence of interval
  9602. specifications, comprising a list of commands to be executed when a
  9603. particular event related to that interval occurs. The occurring event
  9604. is typically the current frame time entering or leaving a given time
  9605. interval.
  9606. An interval is specified by the following syntax:
  9607. @example
  9608. @var{START}[-@var{END}] @var{COMMANDS};
  9609. @end example
  9610. The time interval is specified by the @var{START} and @var{END} times.
  9611. @var{END} is optional and defaults to the maximum time.
  9612. The current frame time is considered within the specified interval if
  9613. it is included in the interval [@var{START}, @var{END}), that is when
  9614. the time is greater or equal to @var{START} and is lesser than
  9615. @var{END}.
  9616. @var{COMMANDS} consists of a sequence of one or more command
  9617. specifications, separated by ",", relating to that interval. The
  9618. syntax of a command specification is given by:
  9619. @example
  9620. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  9621. @end example
  9622. @var{FLAGS} is optional and specifies the type of events relating to
  9623. the time interval which enable sending the specified command, and must
  9624. be a non-null sequence of identifier flags separated by "+" or "|" and
  9625. enclosed between "[" and "]".
  9626. The following flags are recognized:
  9627. @table @option
  9628. @item enter
  9629. The command is sent when the current frame timestamp enters the
  9630. specified interval. In other words, the command is sent when the
  9631. previous frame timestamp was not in the given interval, and the
  9632. current is.
  9633. @item leave
  9634. The command is sent when the current frame timestamp leaves the
  9635. specified interval. In other words, the command is sent when the
  9636. previous frame timestamp was in the given interval, and the
  9637. current is not.
  9638. @end table
  9639. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  9640. assumed.
  9641. @var{TARGET} specifies the target of the command, usually the name of
  9642. the filter class or a specific filter instance name.
  9643. @var{COMMAND} specifies the name of the command for the target filter.
  9644. @var{ARG} is optional and specifies the optional list of argument for
  9645. the given @var{COMMAND}.
  9646. Between one interval specification and another, whitespaces, or
  9647. sequences of characters starting with @code{#} until the end of line,
  9648. are ignored and can be used to annotate comments.
  9649. A simplified BNF description of the commands specification syntax
  9650. follows:
  9651. @example
  9652. @var{COMMAND_FLAG} ::= "enter" | "leave"
  9653. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  9654. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  9655. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  9656. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  9657. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  9658. @end example
  9659. @subsection Examples
  9660. @itemize
  9661. @item
  9662. Specify audio tempo change at second 4:
  9663. @example
  9664. asendcmd=c='4.0 atempo tempo 1.5',atempo
  9665. @end example
  9666. @item
  9667. Specify a list of drawtext and hue commands in a file.
  9668. @example
  9669. # show text in the interval 5-10
  9670. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  9671. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  9672. # desaturate the image in the interval 15-20
  9673. 15.0-20.0 [enter] hue s 0,
  9674. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  9675. [leave] hue s 1,
  9676. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  9677. # apply an exponential saturation fade-out effect, starting from time 25
  9678. 25 [enter] hue s exp(25-t)
  9679. @end example
  9680. A filtergraph allowing to read and process the above command list
  9681. stored in a file @file{test.cmd}, can be specified with:
  9682. @example
  9683. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  9684. @end example
  9685. @end itemize
  9686. @anchor{setpts}
  9687. @section setpts, asetpts
  9688. Change the PTS (presentation timestamp) of the input frames.
  9689. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  9690. This filter accepts the following options:
  9691. @table @option
  9692. @item expr
  9693. The expression which is evaluated for each frame to construct its timestamp.
  9694. @end table
  9695. The expression is evaluated through the eval API and can contain the following
  9696. constants:
  9697. @table @option
  9698. @item FRAME_RATE
  9699. frame rate, only defined for constant frame-rate video
  9700. @item PTS
  9701. The presentation timestamp in input
  9702. @item N
  9703. The count of the input frame for video or the number of consumed samples,
  9704. not including the current frame for audio, starting from 0.
  9705. @item NB_CONSUMED_SAMPLES
  9706. The number of consumed samples, not including the current frame (only
  9707. audio)
  9708. @item NB_SAMPLES, S
  9709. The number of samples in the current frame (only audio)
  9710. @item SAMPLE_RATE, SR
  9711. The audio sample rate.
  9712. @item STARTPTS
  9713. The PTS of the first frame.
  9714. @item STARTT
  9715. the time in seconds of the first frame
  9716. @item INTERLACED
  9717. State whether the current frame is interlaced.
  9718. @item T
  9719. the time in seconds of the current frame
  9720. @item POS
  9721. original position in the file of the frame, or undefined if undefined
  9722. for the current frame
  9723. @item PREV_INPTS
  9724. The previous input PTS.
  9725. @item PREV_INT
  9726. previous input time in seconds
  9727. @item PREV_OUTPTS
  9728. The previous output PTS.
  9729. @item PREV_OUTT
  9730. previous output time in seconds
  9731. @item RTCTIME
  9732. The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  9733. instead.
  9734. @item RTCSTART
  9735. The wallclock (RTC) time at the start of the movie in microseconds.
  9736. @item TB
  9737. The timebase of the input timestamps.
  9738. @end table
  9739. @subsection Examples
  9740. @itemize
  9741. @item
  9742. Start counting PTS from zero
  9743. @example
  9744. setpts=PTS-STARTPTS
  9745. @end example
  9746. @item
  9747. Apply fast motion effect:
  9748. @example
  9749. setpts=0.5*PTS
  9750. @end example
  9751. @item
  9752. Apply slow motion effect:
  9753. @example
  9754. setpts=2.0*PTS
  9755. @end example
  9756. @item
  9757. Set fixed rate of 25 frames per second:
  9758. @example
  9759. setpts=N/(25*TB)
  9760. @end example
  9761. @item
  9762. Set fixed rate 25 fps with some jitter:
  9763. @example
  9764. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  9765. @end example
  9766. @item
  9767. Apply an offset of 10 seconds to the input PTS:
  9768. @example
  9769. setpts=PTS+10/TB
  9770. @end example
  9771. @item
  9772. Generate timestamps from a "live source" and rebase onto the current timebase:
  9773. @example
  9774. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  9775. @end example
  9776. @item
  9777. Generate timestamps by counting samples:
  9778. @example
  9779. asetpts=N/SR/TB
  9780. @end example
  9781. @end itemize
  9782. @section settb, asettb
  9783. Set the timebase to use for the output frames timestamps.
  9784. It is mainly useful for testing timebase configuration.
  9785. It accepts the following parameters:
  9786. @table @option
  9787. @item expr, tb
  9788. The expression which is evaluated into the output timebase.
  9789. @end table
  9790. The value for @option{tb} is an arithmetic expression representing a
  9791. rational. The expression can contain the constants "AVTB" (the default
  9792. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  9793. audio only). Default value is "intb".
  9794. @subsection Examples
  9795. @itemize
  9796. @item
  9797. Set the timebase to 1/25:
  9798. @example
  9799. settb=expr=1/25
  9800. @end example
  9801. @item
  9802. Set the timebase to 1/10:
  9803. @example
  9804. settb=expr=0.1
  9805. @end example
  9806. @item
  9807. Set the timebase to 1001/1000:
  9808. @example
  9809. settb=1+0.001
  9810. @end example
  9811. @item
  9812. Set the timebase to 2*intb:
  9813. @example
  9814. settb=2*intb
  9815. @end example
  9816. @item
  9817. Set the default timebase value:
  9818. @example
  9819. settb=AVTB
  9820. @end example
  9821. @end itemize
  9822. @section showcqt
  9823. Convert input audio to a video output representing
  9824. frequency spectrum logarithmically (using constant Q transform with
  9825. Brown-Puckette algorithm), with musical tone scale, from E0 to D#10 (10 octaves).
  9826. The filter accepts the following options:
  9827. @table @option
  9828. @item volume
  9829. Specify transform volume (multiplier) expression. The expression can contain
  9830. variables:
  9831. @table @option
  9832. @item frequency, freq, f
  9833. the frequency where transform is evaluated
  9834. @item timeclamp, tc
  9835. value of timeclamp option
  9836. @end table
  9837. and functions:
  9838. @table @option
  9839. @item a_weighting(f)
  9840. A-weighting of equal loudness
  9841. @item b_weighting(f)
  9842. B-weighting of equal loudness
  9843. @item c_weighting(f)
  9844. C-weighting of equal loudness
  9845. @end table
  9846. Default value is @code{16}.
  9847. @item tlength
  9848. Specify transform length expression. The expression can contain variables:
  9849. @table @option
  9850. @item frequency, freq, f
  9851. the frequency where transform is evaluated
  9852. @item timeclamp, tc
  9853. value of timeclamp option
  9854. @end table
  9855. Default value is @code{384/f*tc/(384/f+tc)}.
  9856. @item timeclamp
  9857. Specify the transform timeclamp. At low frequency, there is trade-off between
  9858. accuracy in time domain and frequency domain. If timeclamp is lower,
  9859. event in time domain is represented more accurately (such as fast bass drum),
  9860. otherwise event in frequency domain is represented more accurately
  9861. (such as bass guitar). Acceptable value is [0.1, 1.0]. Default value is @code{0.17}.
  9862. @item coeffclamp
  9863. Specify the transform coeffclamp. If coeffclamp is lower, transform is
  9864. more accurate, otherwise transform is faster. Acceptable value is [0.1, 10.0].
  9865. Default value is @code{1.0}.
  9866. @item gamma
  9867. Specify gamma. Lower gamma makes the spectrum more contrast, higher gamma
  9868. makes the spectrum having more range. Acceptable value is [1.0, 7.0].
  9869. Default value is @code{3.0}.
  9870. @item gamma2
  9871. Specify gamma of bargraph. Acceptable value is [1.0, 7.0].
  9872. Default value is @code{1.0}.
  9873. @item fontfile
  9874. Specify font file for use with freetype. If not specified, use embedded font.
  9875. @item fontcolor
  9876. Specify font color expression. This is arithmetic expression that should return
  9877. integer value 0xRRGGBB. The expression can contain variables:
  9878. @table @option
  9879. @item frequency, freq, f
  9880. the frequency where transform is evaluated
  9881. @item timeclamp, tc
  9882. value of timeclamp option
  9883. @end table
  9884. and functions:
  9885. @table @option
  9886. @item midi(f)
  9887. midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
  9888. @item r(x), g(x), b(x)
  9889. red, green, and blue value of intensity x
  9890. @end table
  9891. Default value is @code{st(0, (midi(f)-59.5)/12);
  9892. st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
  9893. r(1-ld(1)) + b(ld(1))}
  9894. @item fullhd
  9895. If set to 1 (the default), the video size is 1920x1080 (full HD),
  9896. if set to 0, the video size is 960x540. Use this option to make CPU usage lower.
  9897. @item fps
  9898. Specify video fps. Default value is @code{25}.
  9899. @item count
  9900. Specify number of transform per frame, so there are fps*count transforms
  9901. per second. Note that audio data rate must be divisible by fps*count.
  9902. Default value is @code{6}.
  9903. @end table
  9904. @subsection Examples
  9905. @itemize
  9906. @item
  9907. Playing audio while showing the spectrum:
  9908. @example
  9909. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
  9910. @end example
  9911. @item
  9912. Same as above, but with frame rate 30 fps:
  9913. @example
  9914. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
  9915. @end example
  9916. @item
  9917. Playing at 960x540 and lower CPU usage:
  9918. @example
  9919. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fullhd=0:count=3 [out0]'
  9920. @end example
  9921. @item
  9922. A1 and its harmonics: A1, A2, (near)E3, A3:
  9923. @example
  9924. ffplay -f lavfi 'aevalsrc=0.1*sin(2*PI*55*t)+0.1*sin(4*PI*55*t)+0.1*sin(6*PI*55*t)+0.1*sin(8*PI*55*t),
  9925. asplit[a][out1]; [a] showcqt [out0]'
  9926. @end example
  9927. @item
  9928. Same as above, but with more accuracy in frequency domain (and slower):
  9929. @example
  9930. ffplay -f lavfi 'aevalsrc=0.1*sin(2*PI*55*t)+0.1*sin(4*PI*55*t)+0.1*sin(6*PI*55*t)+0.1*sin(8*PI*55*t),
  9931. asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
  9932. @end example
  9933. @item
  9934. B-weighting of equal loudness
  9935. @example
  9936. volume=16*b_weighting(f)
  9937. @end example
  9938. @item
  9939. Lower Q factor
  9940. @example
  9941. tlength=100/f*tc/(100/f+tc)
  9942. @end example
  9943. @item
  9944. Custom fontcolor, C-note is colored green, others are colored blue
  9945. @example
  9946. fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))'
  9947. @end example
  9948. @item
  9949. Custom gamma, now spectrum is linear to the amplitude.
  9950. @example
  9951. gamma=2:gamma2=2
  9952. @end example
  9953. @end itemize
  9954. @section showfreqs
  9955. Convert input audio to video output representing the audio power spectrum.
  9956. Audio amplitude is on Y-axis while frequency is on X-axis.
  9957. The filter accepts the following options:
  9958. @table @option
  9959. @item size, s
  9960. Specify size of video. For the syntax of this option, check the
  9961. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9962. Default is @code{1024x512}.
  9963. @item mode
  9964. Set display mode.
  9965. This set how each frequency bin will be represented.
  9966. It accepts the following values:
  9967. @table @samp
  9968. @item line
  9969. @item bar
  9970. @item dot
  9971. @end table
  9972. Default is @code{bar}.
  9973. @item ascale
  9974. Set amplitude scale.
  9975. It accepts the following values:
  9976. @table @samp
  9977. @item lin
  9978. Linear scale.
  9979. @item sqrt
  9980. Square root scale.
  9981. @item cbrt
  9982. Cubic root scale.
  9983. @item log
  9984. Logarithmic scale.
  9985. @end table
  9986. Default is @code{log}.
  9987. @item fscale
  9988. Set frequency scale.
  9989. It accepts the following values:
  9990. @table @samp
  9991. @item lin
  9992. Linear scale.
  9993. @item log
  9994. Logarithmic scale.
  9995. @item rlog
  9996. Reverse logarithmic scale.
  9997. @end table
  9998. Default is @code{lin}.
  9999. @item win_size
  10000. Set window size.
  10001. It accepts the following values:
  10002. @table @samp
  10003. @item w16
  10004. @item w32
  10005. @item w64
  10006. @item w128
  10007. @item w256
  10008. @item w512
  10009. @item w1024
  10010. @item w2048
  10011. @item w4096
  10012. @item w8192
  10013. @item w16384
  10014. @item w32768
  10015. @item w65536
  10016. @end table
  10017. Default is @code{w2048}
  10018. @item win_func
  10019. Set windowing function.
  10020. It accepts the following values:
  10021. @table @samp
  10022. @item rect
  10023. @item bartlett
  10024. @item hanning
  10025. @item hamming
  10026. @item blackman
  10027. @item welch
  10028. @item flattop
  10029. @item bharris
  10030. @item bnuttall
  10031. @item bhann
  10032. @item sine
  10033. @item nuttall
  10034. @end table
  10035. Default is @code{hanning}.
  10036. @item overlap
  10037. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  10038. which means optimal overlap for selected window function will be picked.
  10039. @item averaging
  10040. Set time averaging. Setting this to 0 will display current maximal peaks.
  10041. Default is @code{1}, which means time averaging is disabled.
  10042. @item color
  10043. Specify list of colors separated by space or by '|' which will be used to
  10044. draw channel frequencies. Unrecognized or missing colors will be replaced
  10045. by white color.
  10046. @end table
  10047. @section showspectrum
  10048. Convert input audio to a video output, representing the audio frequency
  10049. spectrum.
  10050. The filter accepts the following options:
  10051. @table @option
  10052. @item size, s
  10053. Specify the video size for the output. For the syntax of this option, check the
  10054. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10055. Default value is @code{640x512}.
  10056. @item slide
  10057. Specify how the spectrum should slide along the window.
  10058. It accepts the following values:
  10059. @table @samp
  10060. @item replace
  10061. the samples start again on the left when they reach the right
  10062. @item scroll
  10063. the samples scroll from right to left
  10064. @item fullframe
  10065. frames are only produced when the samples reach the right
  10066. @end table
  10067. Default value is @code{replace}.
  10068. @item mode
  10069. Specify display mode.
  10070. It accepts the following values:
  10071. @table @samp
  10072. @item combined
  10073. all channels are displayed in the same row
  10074. @item separate
  10075. all channels are displayed in separate rows
  10076. @end table
  10077. Default value is @samp{combined}.
  10078. @item color
  10079. Specify display color mode.
  10080. It accepts the following values:
  10081. @table @samp
  10082. @item channel
  10083. each channel is displayed in a separate color
  10084. @item intensity
  10085. each channel is is displayed using the same color scheme
  10086. @end table
  10087. Default value is @samp{channel}.
  10088. @item scale
  10089. Specify scale used for calculating intensity color values.
  10090. It accepts the following values:
  10091. @table @samp
  10092. @item lin
  10093. linear
  10094. @item sqrt
  10095. square root, default
  10096. @item cbrt
  10097. cubic root
  10098. @item log
  10099. logarithmic
  10100. @end table
  10101. Default value is @samp{sqrt}.
  10102. @item saturation
  10103. Set saturation modifier for displayed colors. Negative values provide
  10104. alternative color scheme. @code{0} is no saturation at all.
  10105. Saturation must be in [-10.0, 10.0] range.
  10106. Default value is @code{1}.
  10107. @item win_func
  10108. Set window function.
  10109. It accepts the following values:
  10110. @table @samp
  10111. @item none
  10112. No samples pre-processing (do not expect this to be faster)
  10113. @item hann
  10114. Hann window
  10115. @item hamming
  10116. Hamming window
  10117. @item blackman
  10118. Blackman window
  10119. @end table
  10120. Default value is @code{hann}.
  10121. @end table
  10122. The usage is very similar to the showwaves filter; see the examples in that
  10123. section.
  10124. @subsection Examples
  10125. @itemize
  10126. @item
  10127. Large window with logarithmic color scaling:
  10128. @example
  10129. showspectrum=s=1280x480:scale=log
  10130. @end example
  10131. @item
  10132. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  10133. @example
  10134. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  10135. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  10136. @end example
  10137. @end itemize
  10138. @section showvolume
  10139. Convert input audio volume to a video output.
  10140. The filter accepts the following options:
  10141. @table @option
  10142. @item rate, r
  10143. Set video rate.
  10144. @item b
  10145. Set border width, allowed range is [0, 5]. Default is 1.
  10146. @item w
  10147. Set channel width, allowed range is [40, 1080]. Default is 400.
  10148. @item h
  10149. Set channel height, allowed range is [1, 100]. Default is 20.
  10150. @item f
  10151. Set fade, allowed range is [1, 255]. Default is 20.
  10152. @item c
  10153. Set volume color expression.
  10154. The expression can use the following variables:
  10155. @table @option
  10156. @item VOLUME
  10157. Current max volume of channel in dB.
  10158. @item CHANNEL
  10159. Current channel number, starting from 0.
  10160. @end table
  10161. @item t
  10162. If set, displays channel names. Default is enabled.
  10163. @end table
  10164. @section showwaves
  10165. Convert input audio to a video output, representing the samples waves.
  10166. The filter accepts the following options:
  10167. @table @option
  10168. @item size, s
  10169. Specify the video size for the output. For the syntax of this option, check the
  10170. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10171. Default value is @code{600x240}.
  10172. @item mode
  10173. Set display mode.
  10174. Available values are:
  10175. @table @samp
  10176. @item point
  10177. Draw a point for each sample.
  10178. @item line
  10179. Draw a vertical line for each sample.
  10180. @item p2p
  10181. Draw a point for each sample and a line between them.
  10182. @item cline
  10183. Draw a centered vertical line for each sample.
  10184. @end table
  10185. Default value is @code{point}.
  10186. @item n
  10187. Set the number of samples which are printed on the same column. A
  10188. larger value will decrease the frame rate. Must be a positive
  10189. integer. This option can be set only if the value for @var{rate}
  10190. is not explicitly specified.
  10191. @item rate, r
  10192. Set the (approximate) output frame rate. This is done by setting the
  10193. option @var{n}. Default value is "25".
  10194. @item split_channels
  10195. Set if channels should be drawn separately or overlap. Default value is 0.
  10196. @end table
  10197. @subsection Examples
  10198. @itemize
  10199. @item
  10200. Output the input file audio and the corresponding video representation
  10201. at the same time:
  10202. @example
  10203. amovie=a.mp3,asplit[out0],showwaves[out1]
  10204. @end example
  10205. @item
  10206. Create a synthetic signal and show it with showwaves, forcing a
  10207. frame rate of 30 frames per second:
  10208. @example
  10209. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  10210. @end example
  10211. @end itemize
  10212. @section showwavespic
  10213. Convert input audio to a single video frame, representing the samples waves.
  10214. The filter accepts the following options:
  10215. @table @option
  10216. @item size, s
  10217. Specify the video size for the output. For the syntax of this option, check the
  10218. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10219. Default value is @code{600x240}.
  10220. @item split_channels
  10221. Set if channels should be drawn separately or overlap. Default value is 0.
  10222. @end table
  10223. @subsection Examples
  10224. @itemize
  10225. @item
  10226. Extract a channel split representation of the wave form of a whole audio track
  10227. in a 1024x800 picture using @command{ffmpeg}:
  10228. @example
  10229. ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
  10230. @end example
  10231. @end itemize
  10232. @section split, asplit
  10233. Split input into several identical outputs.
  10234. @code{asplit} works with audio input, @code{split} with video.
  10235. The filter accepts a single parameter which specifies the number of outputs. If
  10236. unspecified, it defaults to 2.
  10237. @subsection Examples
  10238. @itemize
  10239. @item
  10240. Create two separate outputs from the same input:
  10241. @example
  10242. [in] split [out0][out1]
  10243. @end example
  10244. @item
  10245. To create 3 or more outputs, you need to specify the number of
  10246. outputs, like in:
  10247. @example
  10248. [in] asplit=3 [out0][out1][out2]
  10249. @end example
  10250. @item
  10251. Create two separate outputs from the same input, one cropped and
  10252. one padded:
  10253. @example
  10254. [in] split [splitout1][splitout2];
  10255. [splitout1] crop=100:100:0:0 [cropout];
  10256. [splitout2] pad=200:200:100:100 [padout];
  10257. @end example
  10258. @item
  10259. Create 5 copies of the input audio with @command{ffmpeg}:
  10260. @example
  10261. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  10262. @end example
  10263. @end itemize
  10264. @section zmq, azmq
  10265. Receive commands sent through a libzmq client, and forward them to
  10266. filters in the filtergraph.
  10267. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  10268. must be inserted between two video filters, @code{azmq} between two
  10269. audio filters.
  10270. To enable these filters you need to install the libzmq library and
  10271. headers and configure FFmpeg with @code{--enable-libzmq}.
  10272. For more information about libzmq see:
  10273. @url{http://www.zeromq.org/}
  10274. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  10275. receives messages sent through a network interface defined by the
  10276. @option{bind_address} option.
  10277. The received message must be in the form:
  10278. @example
  10279. @var{TARGET} @var{COMMAND} [@var{ARG}]
  10280. @end example
  10281. @var{TARGET} specifies the target of the command, usually the name of
  10282. the filter class or a specific filter instance name.
  10283. @var{COMMAND} specifies the name of the command for the target filter.
  10284. @var{ARG} is optional and specifies the optional argument list for the
  10285. given @var{COMMAND}.
  10286. Upon reception, the message is processed and the corresponding command
  10287. is injected into the filtergraph. Depending on the result, the filter
  10288. will send a reply to the client, adopting the format:
  10289. @example
  10290. @var{ERROR_CODE} @var{ERROR_REASON}
  10291. @var{MESSAGE}
  10292. @end example
  10293. @var{MESSAGE} is optional.
  10294. @subsection Examples
  10295. Look at @file{tools/zmqsend} for an example of a zmq client which can
  10296. be used to send commands processed by these filters.
  10297. Consider the following filtergraph generated by @command{ffplay}
  10298. @example
  10299. ffplay -dumpgraph 1 -f lavfi "
  10300. color=s=100x100:c=red [l];
  10301. color=s=100x100:c=blue [r];
  10302. nullsrc=s=200x100, zmq [bg];
  10303. [bg][l] overlay [bg+l];
  10304. [bg+l][r] overlay=x=100 "
  10305. @end example
  10306. To change the color of the left side of the video, the following
  10307. command can be used:
  10308. @example
  10309. echo Parsed_color_0 c yellow | tools/zmqsend
  10310. @end example
  10311. To change the right side:
  10312. @example
  10313. echo Parsed_color_1 c pink | tools/zmqsend
  10314. @end example
  10315. @c man end MULTIMEDIA FILTERS
  10316. @chapter Multimedia Sources
  10317. @c man begin MULTIMEDIA SOURCES
  10318. Below is a description of the currently available multimedia sources.
  10319. @section amovie
  10320. This is the same as @ref{movie} source, except it selects an audio
  10321. stream by default.
  10322. @anchor{movie}
  10323. @section movie
  10324. Read audio and/or video stream(s) from a movie container.
  10325. It accepts the following parameters:
  10326. @table @option
  10327. @item filename
  10328. The name of the resource to read (not necessarily a file; it can also be a
  10329. device or a stream accessed through some protocol).
  10330. @item format_name, f
  10331. Specifies the format assumed for the movie to read, and can be either
  10332. the name of a container or an input device. If not specified, the
  10333. format is guessed from @var{movie_name} or by probing.
  10334. @item seek_point, sp
  10335. Specifies the seek point in seconds. The frames will be output
  10336. starting from this seek point. The parameter is evaluated with
  10337. @code{av_strtod}, so the numerical value may be suffixed by an IS
  10338. postfix. The default value is "0".
  10339. @item streams, s
  10340. Specifies the streams to read. Several streams can be specified,
  10341. separated by "+". The source will then have as many outputs, in the
  10342. same order. The syntax is explained in the ``Stream specifiers''
  10343. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  10344. respectively the default (best suited) video and audio stream. Default
  10345. is "dv", or "da" if the filter is called as "amovie".
  10346. @item stream_index, si
  10347. Specifies the index of the video stream to read. If the value is -1,
  10348. the most suitable video stream will be automatically selected. The default
  10349. value is "-1". Deprecated. If the filter is called "amovie", it will select
  10350. audio instead of video.
  10351. @item loop
  10352. Specifies how many times to read the stream in sequence.
  10353. If the value is less than 1, the stream will be read again and again.
  10354. Default value is "1".
  10355. Note that when the movie is looped the source timestamps are not
  10356. changed, so it will generate non monotonically increasing timestamps.
  10357. @end table
  10358. It allows overlaying a second video on top of the main input of
  10359. a filtergraph, as shown in this graph:
  10360. @example
  10361. input -----------> deltapts0 --> overlay --> output
  10362. ^
  10363. |
  10364. movie --> scale--> deltapts1 -------+
  10365. @end example
  10366. @subsection Examples
  10367. @itemize
  10368. @item
  10369. Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
  10370. on top of the input labelled "in":
  10371. @example
  10372. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  10373. [in] setpts=PTS-STARTPTS [main];
  10374. [main][over] overlay=16:16 [out]
  10375. @end example
  10376. @item
  10377. Read from a video4linux2 device, and overlay it on top of the input
  10378. labelled "in":
  10379. @example
  10380. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  10381. [in] setpts=PTS-STARTPTS [main];
  10382. [main][over] overlay=16:16 [out]
  10383. @end example
  10384. @item
  10385. Read the first video stream and the audio stream with id 0x81 from
  10386. dvd.vob; the video is connected to the pad named "video" and the audio is
  10387. connected to the pad named "audio":
  10388. @example
  10389. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  10390. @end example
  10391. @end itemize
  10392. @c man end MULTIMEDIA SOURCES