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.

16011 lines
432KB

  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 acompressor
  256. A compressor is mainly used to reduce the dynamic range of a signal.
  257. Especially modern music is mostly compressed at a high ratio to
  258. improve the overall loudness. It's done to get the highest attention
  259. of a listener, "fatten" the sound and bring more "power" to the track.
  260. If a signal is compressed too much it may sound dull or "dead"
  261. afterwards or it may start to "pump" (which could be a powerful effect
  262. but can also destroy a track completely).
  263. The right compression is the key to reach a professional sound and is
  264. the high art of mixing and mastering. Because of its complex settings
  265. it may take a long time to get the right feeling for this kind of effect.
  266. Compression is done by detecting the volume above a chosen level
  267. @code{threshold} and dividing it by the factor set with @code{ratio}.
  268. So if you set the threshold to -12dB and your signal reaches -6dB a ratio
  269. of 2:1 will result in a signal at -9dB. Because an exact manipulation of
  270. the signal would cause distortion of the waveform the reduction can be
  271. levelled over the time. This is done by setting "Attack" and "Release".
  272. @code{attack} determines how long the signal has to rise above the threshold
  273. before any reduction will occur and @code{release} sets the time the signal
  274. has to fall below the threshold to reduce the reduction again. Shorter signals
  275. than the chosen attack time will be left untouched.
  276. The overall reduction of the signal can be made up afterwards with the
  277. @code{makeup} setting. So compressing the peaks of a signal about 6dB and
  278. raising the makeup to this level results in a signal twice as loud than the
  279. source. To gain a softer entry in the compression the @code{knee} flattens the
  280. hard edge at the threshold in the range of the chosen decibels.
  281. The filter accepts the following options:
  282. @table @option
  283. @item level_in
  284. Set input gain. Default is 1. Range is between 0.015625 and 64.
  285. @item threshold
  286. If a signal of second stream rises above this level it will affect the gain
  287. reduction of the first stream.
  288. By default it is 0.125. Range is between 0.00097563 and 1.
  289. @item ratio
  290. Set a ratio by which the signal is reduced. 1:2 means that if the level
  291. rose 4dB above the threshold, it will be only 2dB above after the reduction.
  292. Default is 2. Range is between 1 and 20.
  293. @item attack
  294. Amount of milliseconds the signal has to rise above the threshold before gain
  295. reduction starts. Default is 20. Range is between 0.01 and 2000.
  296. @item release
  297. Amount of milliseconds the signal has to fall below the threshold before
  298. reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
  299. @item makeup
  300. Set the amount by how much signal will be amplified after processing.
  301. Default is 2. Range is from 1 and 64.
  302. @item knee
  303. Curve the sharp knee around the threshold to enter gain reduction more softly.
  304. Default is 2.82843. Range is between 1 and 8.
  305. @item link
  306. Choose if the @code{average} level between all channels of input stream
  307. or the louder(@code{maximum}) channel of input stream affects the
  308. reduction. Default is @code{average}.
  309. @item detection
  310. Should the exact signal be taken in case of @code{peak} or an RMS one in case
  311. of @code{rms}. Default is @code{rms} which is mostly smoother.
  312. @item mix
  313. How much to use compressed signal in output. Default is 1.
  314. Range is between 0 and 1.
  315. @end table
  316. @section acrossfade
  317. Apply cross fade from one input audio stream to another input audio stream.
  318. The cross fade is applied for specified duration near the end of first stream.
  319. The filter accepts the following options:
  320. @table @option
  321. @item nb_samples, ns
  322. Specify the number of samples for which the cross fade effect has to last.
  323. At the end of the cross fade effect the first input audio will be completely
  324. silent. Default is 44100.
  325. @item duration, d
  326. Specify the duration of the cross fade effect. See
  327. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  328. for the accepted syntax.
  329. By default the duration is determined by @var{nb_samples}.
  330. If set this option is used instead of @var{nb_samples}.
  331. @item overlap, o
  332. Should first stream end overlap with second stream start. Default is enabled.
  333. @item curve1
  334. Set curve for cross fade transition for first stream.
  335. @item curve2
  336. Set curve for cross fade transition for second stream.
  337. For description of available curve types see @ref{afade} filter description.
  338. @end table
  339. @subsection Examples
  340. @itemize
  341. @item
  342. Cross fade from one input to another:
  343. @example
  344. ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:c1=exp:c2=exp output.flac
  345. @end example
  346. @item
  347. Cross fade from one input to another but without overlapping:
  348. @example
  349. ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:o=0:c1=exp:c2=exp output.flac
  350. @end example
  351. @end itemize
  352. @section adelay
  353. Delay one or more audio channels.
  354. Samples in delayed channel are filled with silence.
  355. The filter accepts the following option:
  356. @table @option
  357. @item delays
  358. Set list of delays in milliseconds for each channel separated by '|'.
  359. At least one delay greater than 0 should be provided.
  360. Unused delays will be silently ignored. If number of given delays is
  361. smaller than number of channels all remaining channels will not be delayed.
  362. @end table
  363. @subsection Examples
  364. @itemize
  365. @item
  366. Delay first channel by 1.5 seconds, the third channel by 0.5 seconds and leave
  367. the second channel (and any other channels that may be present) unchanged.
  368. @example
  369. adelay=1500|0|500
  370. @end example
  371. @end itemize
  372. @section aecho
  373. Apply echoing to the input audio.
  374. Echoes are reflected sound and can occur naturally amongst mountains
  375. (and sometimes large buildings) when talking or shouting; digital echo
  376. effects emulate this behaviour and are often used to help fill out the
  377. sound of a single instrument or vocal. The time difference between the
  378. original signal and the reflection is the @code{delay}, and the
  379. loudness of the reflected signal is the @code{decay}.
  380. Multiple echoes can have different delays and decays.
  381. A description of the accepted parameters follows.
  382. @table @option
  383. @item in_gain
  384. Set input gain of reflected signal. Default is @code{0.6}.
  385. @item out_gain
  386. Set output gain of reflected signal. Default is @code{0.3}.
  387. @item delays
  388. Set list of time intervals in milliseconds between original signal and reflections
  389. separated by '|'. Allowed range for each @code{delay} is @code{(0 - 90000.0]}.
  390. Default is @code{1000}.
  391. @item decays
  392. Set list of loudnesses of reflected signals separated by '|'.
  393. Allowed range for each @code{decay} is @code{(0 - 1.0]}.
  394. Default is @code{0.5}.
  395. @end table
  396. @subsection Examples
  397. @itemize
  398. @item
  399. Make it sound as if there are twice as many instruments as are actually playing:
  400. @example
  401. aecho=0.8:0.88:60:0.4
  402. @end example
  403. @item
  404. If delay is very short, then it sound like a (metallic) robot playing music:
  405. @example
  406. aecho=0.8:0.88:6:0.4
  407. @end example
  408. @item
  409. A longer delay will sound like an open air concert in the mountains:
  410. @example
  411. aecho=0.8:0.9:1000:0.3
  412. @end example
  413. @item
  414. Same as above but with one more mountain:
  415. @example
  416. aecho=0.8:0.9:1000|1800:0.3|0.25
  417. @end example
  418. @end itemize
  419. @section aemphasis
  420. Audio emphasis filter creates or restores material directly taken from LPs or
  421. emphased CDs with different filter curves. E.g. to store music on vinyl the
  422. signal has to be altered by a filter first to even out the disadvantages of
  423. this recording medium.
  424. Once the material is played back the inverse filter has to be applied to
  425. restore the distortion of the frequency response.
  426. The filter accepts the following options:
  427. @table @option
  428. @item level_in
  429. Set input gain.
  430. @item level_out
  431. Set output gain.
  432. @item mode
  433. Set filter mode. For restoring material use @code{reproduction} mode, otherwise
  434. use @code{production} mode. Default is @code{reproduction} mode.
  435. @item type
  436. Set filter type. Selects medium. Can be one of the following:
  437. @table @option
  438. @item col
  439. select Columbia.
  440. @item emi
  441. select EMI.
  442. @item bsi
  443. select BSI (78RPM).
  444. @item riaa
  445. select RIAA.
  446. @item cd
  447. select Compact Disc (CD).
  448. @item 50fm
  449. select 50µs (FM).
  450. @item 75fm
  451. select 75µs (FM).
  452. @item 50kf
  453. select 50µs (FM-KF).
  454. @item 75kf
  455. select 75µs (FM-KF).
  456. @end table
  457. @end table
  458. @section aeval
  459. Modify an audio signal according to the specified expressions.
  460. This filter accepts one or more expressions (one for each channel),
  461. which are evaluated and used to modify a corresponding audio signal.
  462. It accepts the following parameters:
  463. @table @option
  464. @item exprs
  465. Set the '|'-separated expressions list for each separate channel. If
  466. the number of input channels is greater than the number of
  467. expressions, the last specified expression is used for the remaining
  468. output channels.
  469. @item channel_layout, c
  470. Set output channel layout. If not specified, the channel layout is
  471. specified by the number of expressions. If set to @samp{same}, it will
  472. use by default the same input channel layout.
  473. @end table
  474. Each expression in @var{exprs} can contain the following constants and functions:
  475. @table @option
  476. @item ch
  477. channel number of the current expression
  478. @item n
  479. number of the evaluated sample, starting from 0
  480. @item s
  481. sample rate
  482. @item t
  483. time of the evaluated sample expressed in seconds
  484. @item nb_in_channels
  485. @item nb_out_channels
  486. input and output number of channels
  487. @item val(CH)
  488. the value of input channel with number @var{CH}
  489. @end table
  490. Note: this filter is slow. For faster processing you should use a
  491. dedicated filter.
  492. @subsection Examples
  493. @itemize
  494. @item
  495. Half volume:
  496. @example
  497. aeval=val(ch)/2:c=same
  498. @end example
  499. @item
  500. Invert phase of the second channel:
  501. @example
  502. aeval=val(0)|-val(1)
  503. @end example
  504. @end itemize
  505. @anchor{afade}
  506. @section afade
  507. Apply fade-in/out effect to input audio.
  508. A description of the accepted parameters follows.
  509. @table @option
  510. @item type, t
  511. Specify the effect type, can be either @code{in} for fade-in, or
  512. @code{out} for a fade-out effect. Default is @code{in}.
  513. @item start_sample, ss
  514. Specify the number of the start sample for starting to apply the fade
  515. effect. Default is 0.
  516. @item nb_samples, ns
  517. Specify the number of samples for which the fade effect has to last. At
  518. the end of the fade-in effect the output audio will have the same
  519. volume as the input audio, at the end of the fade-out transition
  520. the output audio will be silence. Default is 44100.
  521. @item start_time, st
  522. Specify the start time of the fade effect. Default is 0.
  523. The value must be specified as a time duration; see
  524. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  525. for the accepted syntax.
  526. If set this option is used instead of @var{start_sample}.
  527. @item duration, d
  528. Specify the duration of the fade effect. See
  529. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  530. for the accepted syntax.
  531. At the end of the fade-in effect the output audio will have the same
  532. volume as the input audio, at the end of the fade-out transition
  533. the output audio will be silence.
  534. By default the duration is determined by @var{nb_samples}.
  535. If set this option is used instead of @var{nb_samples}.
  536. @item curve
  537. Set curve for fade transition.
  538. It accepts the following values:
  539. @table @option
  540. @item tri
  541. select triangular, linear slope (default)
  542. @item qsin
  543. select quarter of sine wave
  544. @item hsin
  545. select half of sine wave
  546. @item esin
  547. select exponential sine wave
  548. @item log
  549. select logarithmic
  550. @item ipar
  551. select inverted parabola
  552. @item qua
  553. select quadratic
  554. @item cub
  555. select cubic
  556. @item squ
  557. select square root
  558. @item cbr
  559. select cubic root
  560. @item par
  561. select parabola
  562. @item exp
  563. select exponential
  564. @item iqsin
  565. select inverted quarter of sine wave
  566. @item ihsin
  567. select inverted half of sine wave
  568. @item dese
  569. select double-exponential seat
  570. @item desi
  571. select double-exponential sigmoid
  572. @end table
  573. @end table
  574. @subsection Examples
  575. @itemize
  576. @item
  577. Fade in first 15 seconds of audio:
  578. @example
  579. afade=t=in:ss=0:d=15
  580. @end example
  581. @item
  582. Fade out last 25 seconds of a 900 seconds audio:
  583. @example
  584. afade=t=out:st=875:d=25
  585. @end example
  586. @end itemize
  587. @section afftfilt
  588. Apply arbitrary expressions to samples in frequency domain.
  589. @table @option
  590. @item real
  591. Set frequency domain real expression for each separate channel separated
  592. by '|'. Default is "1".
  593. If the number of input channels is greater than the number of
  594. expressions, the last specified expression is used for the remaining
  595. output channels.
  596. @item imag
  597. Set frequency domain imaginary expression for each separate channel
  598. separated by '|'. If not set, @var{real} option is used.
  599. Each expression in @var{real} and @var{imag} can contain the following
  600. constants:
  601. @table @option
  602. @item sr
  603. sample rate
  604. @item b
  605. current frequency bin number
  606. @item nb
  607. number of available bins
  608. @item ch
  609. channel number of the current expression
  610. @item chs
  611. number of channels
  612. @item pts
  613. current frame pts
  614. @end table
  615. @item win_size
  616. Set window size.
  617. It accepts the following values:
  618. @table @samp
  619. @item w16
  620. @item w32
  621. @item w64
  622. @item w128
  623. @item w256
  624. @item w512
  625. @item w1024
  626. @item w2048
  627. @item w4096
  628. @item w8192
  629. @item w16384
  630. @item w32768
  631. @item w65536
  632. @end table
  633. Default is @code{w4096}
  634. @item win_func
  635. Set window function. Default is @code{hann}.
  636. @item overlap
  637. Set window overlap. If set to 1, the recommended overlap for selected
  638. window function will be picked. Default is @code{0.75}.
  639. @end table
  640. @subsection Examples
  641. @itemize
  642. @item
  643. Leave almost only low frequencies in audio:
  644. @example
  645. afftfilt="1-clip((b/nb)*b,0,1)"
  646. @end example
  647. @end itemize
  648. @anchor{aformat}
  649. @section aformat
  650. Set output format constraints for the input audio. The framework will
  651. negotiate the most appropriate format to minimize conversions.
  652. It accepts the following parameters:
  653. @table @option
  654. @item sample_fmts
  655. A '|'-separated list of requested sample formats.
  656. @item sample_rates
  657. A '|'-separated list of requested sample rates.
  658. @item channel_layouts
  659. A '|'-separated list of requested channel layouts.
  660. See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  661. for the required syntax.
  662. @end table
  663. If a parameter is omitted, all values are allowed.
  664. Force the output to either unsigned 8-bit or signed 16-bit stereo
  665. @example
  666. aformat=sample_fmts=u8|s16:channel_layouts=stereo
  667. @end example
  668. @section agate
  669. A gate is mainly used to reduce lower parts of a signal. This kind of signal
  670. processing reduces disturbing noise between useful signals.
  671. Gating is done by detecting the volume below a chosen level @var{threshold}
  672. and divide it by the factor set with @var{ratio}. The bottom of the noise
  673. floor is set via @var{range}. Because an exact manipulation of the signal
  674. would cause distortion of the waveform the reduction can be levelled over
  675. time. This is done by setting @var{attack} and @var{release}.
  676. @var{attack} determines how long the signal has to fall below the threshold
  677. before any reduction will occur and @var{release} sets the time the signal
  678. has to raise above the threshold to reduce the reduction again.
  679. Shorter signals than the chosen attack time will be left untouched.
  680. @table @option
  681. @item level_in
  682. Set input level before filtering.
  683. Default is 1. Allowed range is from 0.015625 to 64.
  684. @item range
  685. Set the level of gain reduction when the signal is below the threshold.
  686. Default is 0.06125. Allowed range is from 0 to 1.
  687. @item threshold
  688. If a signal rises above this level the gain reduction is released.
  689. Default is 0.125. Allowed range is from 0 to 1.
  690. @item ratio
  691. Set a ratio about which the signal is reduced.
  692. Default is 2. Allowed range is from 1 to 9000.
  693. @item attack
  694. Amount of milliseconds the signal has to rise above the threshold before gain
  695. reduction stops.
  696. Default is 20 milliseconds. Allowed range is from 0.01 to 9000.
  697. @item release
  698. Amount of milliseconds the signal has to fall below the threshold before the
  699. reduction is increased again. Default is 250 milliseconds.
  700. Allowed range is from 0.01 to 9000.
  701. @item makeup
  702. Set amount of amplification of signal after processing.
  703. Default is 1. Allowed range is from 1 to 64.
  704. @item knee
  705. Curve the sharp knee around the threshold to enter gain reduction more softly.
  706. Default is 2.828427125. Allowed range is from 1 to 8.
  707. @item detection
  708. Choose if exact signal should be taken for detection or an RMS like one.
  709. Default is rms. Can be peak or rms.
  710. @item link
  711. Choose if the average level between all channels or the louder channel affects
  712. the reduction.
  713. Default is average. Can be average or maximum.
  714. @end table
  715. @section alimiter
  716. The limiter prevents input signal from raising over a desired threshold.
  717. This limiter uses lookahead technology to prevent your signal from distorting.
  718. It means that there is a small delay after signal is processed. Keep in mind
  719. that the delay it produces is the attack time you set.
  720. The filter accepts the following options:
  721. @table @option
  722. @item level_in
  723. Set input gain. Default is 1.
  724. @item level_out
  725. Set output gain. Default is 1.
  726. @item limit
  727. Don't let signals above this level pass the limiter. Default is 1.
  728. @item attack
  729. The limiter will reach its attenuation level in this amount of time in
  730. milliseconds. Default is 5 milliseconds.
  731. @item release
  732. Come back from limiting to attenuation 1.0 in this amount of milliseconds.
  733. Default is 50 milliseconds.
  734. @item asc
  735. When gain reduction is always needed ASC takes care of releasing to an
  736. average reduction level rather than reaching a reduction of 0 in the release
  737. time.
  738. @item asc_level
  739. Select how much the release time is affected by ASC, 0 means nearly no changes
  740. in release time while 1 produces higher release times.
  741. @item level
  742. Auto level output signal. Default is enabled.
  743. This normalizes audio back to 0dB if enabled.
  744. @end table
  745. Depending on picked setting it is recommended to upsample input 2x or 4x times
  746. with @ref{aresample} before applying this filter.
  747. @section allpass
  748. Apply a two-pole all-pass filter with central frequency (in Hz)
  749. @var{frequency}, and filter-width @var{width}.
  750. An all-pass filter changes the audio's frequency to phase relationship
  751. without changing its frequency to amplitude relationship.
  752. The filter accepts the following options:
  753. @table @option
  754. @item frequency, f
  755. Set frequency in Hz.
  756. @item width_type
  757. Set method to specify band-width of filter.
  758. @table @option
  759. @item h
  760. Hz
  761. @item q
  762. Q-Factor
  763. @item o
  764. octave
  765. @item s
  766. slope
  767. @end table
  768. @item width, w
  769. Specify the band-width of a filter in width_type units.
  770. @end table
  771. @anchor{amerge}
  772. @section amerge
  773. Merge two or more audio streams into a single multi-channel stream.
  774. The filter accepts the following options:
  775. @table @option
  776. @item inputs
  777. Set the number of inputs. Default is 2.
  778. @end table
  779. If the channel layouts of the inputs are disjoint, and therefore compatible,
  780. the channel layout of the output will be set accordingly and the channels
  781. will be reordered as necessary. If the channel layouts of the inputs are not
  782. disjoint, the output will have all the channels of the first input then all
  783. the channels of the second input, in that order, and the channel layout of
  784. the output will be the default value corresponding to the total number of
  785. channels.
  786. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  787. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  788. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  789. first input, b1 is the first channel of the second input).
  790. On the other hand, if both input are in stereo, the output channels will be
  791. in the default order: a1, a2, b1, b2, and the channel layout will be
  792. arbitrarily set to 4.0, which may or may not be the expected value.
  793. All inputs must have the same sample rate, and format.
  794. If inputs do not have the same duration, the output will stop with the
  795. shortest.
  796. @subsection Examples
  797. @itemize
  798. @item
  799. Merge two mono files into a stereo stream:
  800. @example
  801. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  802. @end example
  803. @item
  804. Multiple merges assuming 1 video stream and 6 audio streams in @file{input.mkv}:
  805. @example
  806. 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
  807. @end example
  808. @end itemize
  809. @section amix
  810. Mixes multiple audio inputs into a single output.
  811. Note that this filter only supports float samples (the @var{amerge}
  812. and @var{pan} audio filters support many formats). If the @var{amix}
  813. input has integer samples then @ref{aresample} will be automatically
  814. inserted to perform the conversion to float samples.
  815. For example
  816. @example
  817. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  818. @end example
  819. will mix 3 input audio streams to a single output with the same duration as the
  820. first input and a dropout transition time of 3 seconds.
  821. It accepts the following parameters:
  822. @table @option
  823. @item inputs
  824. The number of inputs. If unspecified, it defaults to 2.
  825. @item duration
  826. How to determine the end-of-stream.
  827. @table @option
  828. @item longest
  829. The duration of the longest input. (default)
  830. @item shortest
  831. The duration of the shortest input.
  832. @item first
  833. The duration of the first input.
  834. @end table
  835. @item dropout_transition
  836. The transition time, in seconds, for volume renormalization when an input
  837. stream ends. The default value is 2 seconds.
  838. @end table
  839. @section anequalizer
  840. High-order parametric multiband equalizer for each channel.
  841. It accepts the following parameters:
  842. @table @option
  843. @item params
  844. This option string is in format:
  845. "c@var{chn} f=@var{cf} w=@var{w} g=@var{g} t=@var{f} | ..."
  846. Each equalizer band is separated by '|'.
  847. @table @option
  848. @item chn
  849. Set channel number to which equalization will be applied.
  850. If input doesn't have that channel the entry is ignored.
  851. @item cf
  852. Set central frequency for band.
  853. If input doesn't have that frequency the entry is ignored.
  854. @item w
  855. Set band width in hertz.
  856. @item g
  857. Set band gain in dB.
  858. @item f
  859. Set filter type for band, optional, can be:
  860. @table @samp
  861. @item 0
  862. Butterworth, this is default.
  863. @item 1
  864. Chebyshev type 1.
  865. @item 2
  866. Chebyshev type 2.
  867. @end table
  868. @end table
  869. @item curves
  870. With this option activated frequency response of anequalizer is displayed
  871. in video stream.
  872. @item size
  873. Set video stream size. Only useful if curves option is activated.
  874. @item mgain
  875. Set max gain that will be displayed. Only useful if curves option is activated.
  876. Setting this to reasonable value allows to display gain which is derived from
  877. neighbour bands which are too close to each other and thus produce higher gain
  878. when both are activated.
  879. @item fscale
  880. Set frequency scale used to draw frequency response in video output.
  881. Can be linear or logarithmic. Default is logarithmic.
  882. @item colors
  883. Set color for each channel curve which is going to be displayed in video stream.
  884. This is list of color names separated by space or by '|'.
  885. Unrecognised or missing colors will be replaced by white color.
  886. @end table
  887. @subsection Examples
  888. @itemize
  889. @item
  890. Lower gain by 10 of central frequency 200Hz and width 100 Hz
  891. for first 2 channels using Chebyshev type 1 filter:
  892. @example
  893. anequalizer=c0 f=200 w=100 g=-10 t=1|c1 f=200 w=100 g=-10 t=1
  894. @end example
  895. @end itemize
  896. @subsection Commands
  897. This filter supports the following commands:
  898. @table @option
  899. @item change
  900. Alter existing filter parameters.
  901. Syntax for the commands is : "@var{fN}|f=@var{freq}|w=@var{width}|g=@var{gain}"
  902. @var{fN} is existing filter number, starting from 0, if no such filter is available
  903. error is returned.
  904. @var{freq} set new frequency parameter.
  905. @var{width} set new width parameter in herz.
  906. @var{gain} set new gain parameter in dB.
  907. Full filter invocation with asendcmd may look like this:
  908. asendcmd=c='4.0 anequalizer change 0|f=200|w=50|g=1',anequalizer=...
  909. @end table
  910. @section anull
  911. Pass the audio source unchanged to the output.
  912. @section apad
  913. Pad the end of an audio stream with silence.
  914. This can be used together with @command{ffmpeg} @option{-shortest} to
  915. extend audio streams to the same length as the video stream.
  916. A description of the accepted options follows.
  917. @table @option
  918. @item packet_size
  919. Set silence packet size. Default value is 4096.
  920. @item pad_len
  921. Set the number of samples of silence to add to the end. After the
  922. value is reached, the stream is terminated. This option is mutually
  923. exclusive with @option{whole_len}.
  924. @item whole_len
  925. Set the minimum total number of samples in the output audio stream. If
  926. the value is longer than the input audio length, silence is added to
  927. the end, until the value is reached. This option is mutually exclusive
  928. with @option{pad_len}.
  929. @end table
  930. If neither the @option{pad_len} nor the @option{whole_len} option is
  931. set, the filter will add silence to the end of the input stream
  932. indefinitely.
  933. @subsection Examples
  934. @itemize
  935. @item
  936. Add 1024 samples of silence to the end of the input:
  937. @example
  938. apad=pad_len=1024
  939. @end example
  940. @item
  941. Make sure the audio output will contain at least 10000 samples, pad
  942. the input with silence if required:
  943. @example
  944. apad=whole_len=10000
  945. @end example
  946. @item
  947. Use @command{ffmpeg} to pad the audio input with silence, so that the
  948. video stream will always result the shortest and will be converted
  949. until the end in the output file when using the @option{shortest}
  950. option:
  951. @example
  952. ffmpeg -i VIDEO -i AUDIO -filter_complex "[1:0]apad" -shortest OUTPUT
  953. @end example
  954. @end itemize
  955. @section aphaser
  956. Add a phasing effect to the input audio.
  957. A phaser filter creates series of peaks and troughs in the frequency spectrum.
  958. The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
  959. A description of the accepted parameters follows.
  960. @table @option
  961. @item in_gain
  962. Set input gain. Default is 0.4.
  963. @item out_gain
  964. Set output gain. Default is 0.74
  965. @item delay
  966. Set delay in milliseconds. Default is 3.0.
  967. @item decay
  968. Set decay. Default is 0.4.
  969. @item speed
  970. Set modulation speed in Hz. Default is 0.5.
  971. @item type
  972. Set modulation type. Default is triangular.
  973. It accepts the following values:
  974. @table @samp
  975. @item triangular, t
  976. @item sinusoidal, s
  977. @end table
  978. @end table
  979. @section apulsator
  980. Audio pulsator is something between an autopanner and a tremolo.
  981. But it can produce funny stereo effects as well. Pulsator changes the volume
  982. of the left and right channel based on a LFO (low frequency oscillator) with
  983. different waveforms and shifted phases.
  984. This filter have the ability to define an offset between left and right
  985. channel. An offset of 0 means that both LFO shapes match each other.
  986. The left and right channel are altered equally - a conventional tremolo.
  987. An offset of 50% means that the shape of the right channel is exactly shifted
  988. in phase (or moved backwards about half of the frequency) - pulsator acts as
  989. an autopanner. At 1 both curves match again. Every setting in between moves the
  990. phase shift gapless between all stages and produces some "bypassing" sounds with
  991. sine and triangle waveforms. The more you set the offset near 1 (starting from
  992. the 0.5) the faster the signal passes from the left to the right speaker.
  993. The filter accepts the following options:
  994. @table @option
  995. @item level_in
  996. Set input gain. By default it is 1. Range is [0.015625 - 64].
  997. @item level_out
  998. Set output gain. By default it is 1. Range is [0.015625 - 64].
  999. @item mode
  1000. Set waveform shape the LFO will use. Can be one of: sine, triangle, square,
  1001. sawup or sawdown. Default is sine.
  1002. @item amount
  1003. Set modulation. Define how much of original signal is affected by the LFO.
  1004. @item offset_l
  1005. Set left channel offset. Default is 0. Allowed range is [0 - 1].
  1006. @item offset_r
  1007. Set right channel offset. Default is 0.5. Allowed range is [0 - 1].
  1008. @item width
  1009. Set pulse width. Default is 1. Allowed range is [0 - 2].
  1010. @item timing
  1011. Set possible timing mode. Can be one of: bpm, ms or hz. Default is hz.
  1012. @item bpm
  1013. Set bpm. Default is 120. Allowed range is [30 - 300]. Only used if timing
  1014. is set to bpm.
  1015. @item ms
  1016. Set ms. Default is 500. Allowed range is [10 - 2000]. Only used if timing
  1017. is set to ms.
  1018. @item hz
  1019. Set frequency in Hz. Default is 2. Allowed range is [0.01 - 100]. Only used
  1020. if timing is set to hz.
  1021. @end table
  1022. @anchor{aresample}
  1023. @section aresample
  1024. Resample the input audio to the specified parameters, using the
  1025. libswresample library. If none are specified then the filter will
  1026. automatically convert between its input and output.
  1027. This filter is also able to stretch/squeeze the audio data to make it match
  1028. the timestamps or to inject silence / cut out audio to make it match the
  1029. timestamps, do a combination of both or do neither.
  1030. The filter accepts the syntax
  1031. [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
  1032. expresses a sample rate and @var{resampler_options} is a list of
  1033. @var{key}=@var{value} pairs, separated by ":". See the
  1034. ffmpeg-resampler manual for the complete list of supported options.
  1035. @subsection Examples
  1036. @itemize
  1037. @item
  1038. Resample the input audio to 44100Hz:
  1039. @example
  1040. aresample=44100
  1041. @end example
  1042. @item
  1043. Stretch/squeeze samples to the given timestamps, with a maximum of 1000
  1044. samples per second compensation:
  1045. @example
  1046. aresample=async=1000
  1047. @end example
  1048. @end itemize
  1049. @section asetnsamples
  1050. Set the number of samples per each output audio frame.
  1051. The last output packet may contain a different number of samples, as
  1052. the filter will flush all the remaining samples when the input audio
  1053. signal its end.
  1054. The filter accepts the following options:
  1055. @table @option
  1056. @item nb_out_samples, n
  1057. Set the number of frames per each output audio frame. The number is
  1058. intended as the number of samples @emph{per each channel}.
  1059. Default value is 1024.
  1060. @item pad, p
  1061. If set to 1, the filter will pad the last audio frame with zeroes, so
  1062. that the last frame will contain the same number of samples as the
  1063. previous ones. Default value is 1.
  1064. @end table
  1065. For example, to set the number of per-frame samples to 1234 and
  1066. disable padding for the last frame, use:
  1067. @example
  1068. asetnsamples=n=1234:p=0
  1069. @end example
  1070. @section asetrate
  1071. Set the sample rate without altering the PCM data.
  1072. This will result in a change of speed and pitch.
  1073. The filter accepts the following options:
  1074. @table @option
  1075. @item sample_rate, r
  1076. Set the output sample rate. Default is 44100 Hz.
  1077. @end table
  1078. @section ashowinfo
  1079. Show a line containing various information for each input audio frame.
  1080. The input audio is not modified.
  1081. The shown line contains a sequence of key/value pairs of the form
  1082. @var{key}:@var{value}.
  1083. The following values are shown in the output:
  1084. @table @option
  1085. @item n
  1086. The (sequential) number of the input frame, starting from 0.
  1087. @item pts
  1088. The presentation timestamp of the input frame, in time base units; the time base
  1089. depends on the filter input pad, and is usually 1/@var{sample_rate}.
  1090. @item pts_time
  1091. The presentation timestamp of the input frame in seconds.
  1092. @item pos
  1093. position of the frame in the input stream, -1 if this information in
  1094. unavailable and/or meaningless (for example in case of synthetic audio)
  1095. @item fmt
  1096. The sample format.
  1097. @item chlayout
  1098. The channel layout.
  1099. @item rate
  1100. The sample rate for the audio frame.
  1101. @item nb_samples
  1102. The number of samples (per channel) in the frame.
  1103. @item checksum
  1104. The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
  1105. audio, the data is treated as if all the planes were concatenated.
  1106. @item plane_checksums
  1107. A list of Adler-32 checksums for each data plane.
  1108. @end table
  1109. @anchor{astats}
  1110. @section astats
  1111. Display time domain statistical information about the audio channels.
  1112. Statistics are calculated and displayed for each audio channel and,
  1113. where applicable, an overall figure is also given.
  1114. It accepts the following option:
  1115. @table @option
  1116. @item length
  1117. Short window length in seconds, used for peak and trough RMS measurement.
  1118. Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.1 - 10]}.
  1119. @item metadata
  1120. Set metadata injection. All the metadata keys are prefixed with @code{lavfi.astats.X},
  1121. where @code{X} is channel number starting from 1 or string @code{Overall}. Default is
  1122. disabled.
  1123. Available keys for each channel are:
  1124. DC_offset
  1125. Min_level
  1126. Max_level
  1127. Min_difference
  1128. Max_difference
  1129. Mean_difference
  1130. Peak_level
  1131. RMS_peak
  1132. RMS_trough
  1133. Crest_factor
  1134. Flat_factor
  1135. Peak_count
  1136. Bit_depth
  1137. and for Overall:
  1138. DC_offset
  1139. Min_level
  1140. Max_level
  1141. Min_difference
  1142. Max_difference
  1143. Mean_difference
  1144. Peak_level
  1145. RMS_level
  1146. RMS_peak
  1147. RMS_trough
  1148. Flat_factor
  1149. Peak_count
  1150. Bit_depth
  1151. Number_of_samples
  1152. For example full key look like this @code{lavfi.astats.1.DC_offset} or
  1153. this @code{lavfi.astats.Overall.Peak_count}.
  1154. For description what each key means read below.
  1155. @item reset
  1156. Set number of frame after which stats are going to be recalculated.
  1157. Default is disabled.
  1158. @end table
  1159. A description of each shown parameter follows:
  1160. @table @option
  1161. @item DC offset
  1162. Mean amplitude displacement from zero.
  1163. @item Min level
  1164. Minimal sample level.
  1165. @item Max level
  1166. Maximal sample level.
  1167. @item Min difference
  1168. Minimal difference between two consecutive samples.
  1169. @item Max difference
  1170. Maximal difference between two consecutive samples.
  1171. @item Mean difference
  1172. Mean difference between two consecutive samples.
  1173. The average of each difference between two consecutive samples.
  1174. @item Peak level dB
  1175. @item RMS level dB
  1176. Standard peak and RMS level measured in dBFS.
  1177. @item RMS peak dB
  1178. @item RMS trough dB
  1179. Peak and trough values for RMS level measured over a short window.
  1180. @item Crest factor
  1181. Standard ratio of peak to RMS level (note: not in dB).
  1182. @item Flat factor
  1183. Flatness (i.e. consecutive samples with the same value) of the signal at its peak levels
  1184. (i.e. either @var{Min level} or @var{Max level}).
  1185. @item Peak count
  1186. Number of occasions (not the number of samples) that the signal attained either
  1187. @var{Min level} or @var{Max level}.
  1188. @item Bit depth
  1189. Overall bit depth of audio. Number of bits used for each sample.
  1190. @end table
  1191. @section asyncts
  1192. Synchronize audio data with timestamps by squeezing/stretching it and/or
  1193. dropping samples/adding silence when needed.
  1194. This filter is not built by default, please use @ref{aresample} to do squeezing/stretching.
  1195. It accepts the following parameters:
  1196. @table @option
  1197. @item compensate
  1198. Enable stretching/squeezing the data to make it match the timestamps. Disabled
  1199. by default. When disabled, time gaps are covered with silence.
  1200. @item min_delta
  1201. The minimum difference between timestamps and audio data (in seconds) to trigger
  1202. adding/dropping samples. The default value is 0.1. If you get an imperfect
  1203. sync with this filter, try setting this parameter to 0.
  1204. @item max_comp
  1205. The maximum compensation in samples per second. Only relevant with compensate=1.
  1206. The default value is 500.
  1207. @item first_pts
  1208. Assume that the first PTS should be this value. The time base is 1 / sample
  1209. rate. This allows for padding/trimming at the start of the stream. By default,
  1210. no assumption is made about the first frame's expected PTS, so no padding or
  1211. trimming is done. For example, this could be set to 0 to pad the beginning with
  1212. silence if an audio stream starts after the video stream or to trim any samples
  1213. with a negative PTS due to encoder delay.
  1214. @end table
  1215. @section atempo
  1216. Adjust audio tempo.
  1217. The filter accepts exactly one parameter, the audio tempo. If not
  1218. specified then the filter will assume nominal 1.0 tempo. Tempo must
  1219. be in the [0.5, 2.0] range.
  1220. @subsection Examples
  1221. @itemize
  1222. @item
  1223. Slow down audio to 80% tempo:
  1224. @example
  1225. atempo=0.8
  1226. @end example
  1227. @item
  1228. To speed up audio to 125% tempo:
  1229. @example
  1230. atempo=1.25
  1231. @end example
  1232. @end itemize
  1233. @section atrim
  1234. Trim the input so that the output contains one continuous subpart of the input.
  1235. It accepts the following parameters:
  1236. @table @option
  1237. @item start
  1238. Timestamp (in seconds) of the start of the section to keep. I.e. the audio
  1239. sample with the timestamp @var{start} will be the first sample in the output.
  1240. @item end
  1241. Specify time of the first audio sample that will be dropped, i.e. the
  1242. audio sample immediately preceding the one with the timestamp @var{end} will be
  1243. the last sample in the output.
  1244. @item start_pts
  1245. Same as @var{start}, except this option sets the start timestamp in samples
  1246. instead of seconds.
  1247. @item end_pts
  1248. Same as @var{end}, except this option sets the end timestamp in samples instead
  1249. of seconds.
  1250. @item duration
  1251. The maximum duration of the output in seconds.
  1252. @item start_sample
  1253. The number of the first sample that should be output.
  1254. @item end_sample
  1255. The number of the first sample that should be dropped.
  1256. @end table
  1257. @option{start}, @option{end}, and @option{duration} are expressed as time
  1258. duration specifications; see
  1259. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  1260. Note that the first two sets of the start/end options and the @option{duration}
  1261. option look at the frame timestamp, while the _sample options simply count the
  1262. samples that pass through the filter. So start/end_pts and start/end_sample will
  1263. give different results when the timestamps are wrong, inexact or do not start at
  1264. zero. Also note that this filter does not modify the timestamps. If you wish
  1265. to have the output timestamps start at zero, insert the asetpts filter after the
  1266. atrim filter.
  1267. If multiple start or end options are set, this filter tries to be greedy and
  1268. keep all samples that match at least one of the specified constraints. To keep
  1269. only the part that matches all the constraints at once, chain multiple atrim
  1270. filters.
  1271. The defaults are such that all the input is kept. So it is possible to set e.g.
  1272. just the end values to keep everything before the specified time.
  1273. Examples:
  1274. @itemize
  1275. @item
  1276. Drop everything except the second minute of input:
  1277. @example
  1278. ffmpeg -i INPUT -af atrim=60:120
  1279. @end example
  1280. @item
  1281. Keep only the first 1000 samples:
  1282. @example
  1283. ffmpeg -i INPUT -af atrim=end_sample=1000
  1284. @end example
  1285. @end itemize
  1286. @section bandpass
  1287. Apply a two-pole Butterworth band-pass filter with central
  1288. frequency @var{frequency}, and (3dB-point) band-width width.
  1289. The @var{csg} option selects a constant skirt gain (peak gain = Q)
  1290. instead of the default: constant 0dB peak gain.
  1291. The filter roll off at 6dB per octave (20dB per decade).
  1292. The filter accepts the following options:
  1293. @table @option
  1294. @item frequency, f
  1295. Set the filter's central frequency. Default is @code{3000}.
  1296. @item csg
  1297. Constant skirt gain if set to 1. Defaults to 0.
  1298. @item width_type
  1299. Set method to specify band-width of filter.
  1300. @table @option
  1301. @item h
  1302. Hz
  1303. @item q
  1304. Q-Factor
  1305. @item o
  1306. octave
  1307. @item s
  1308. slope
  1309. @end table
  1310. @item width, w
  1311. Specify the band-width of a filter in width_type units.
  1312. @end table
  1313. @section bandreject
  1314. Apply a two-pole Butterworth band-reject filter with central
  1315. frequency @var{frequency}, and (3dB-point) band-width @var{width}.
  1316. The filter roll off at 6dB per octave (20dB per decade).
  1317. The filter accepts the following options:
  1318. @table @option
  1319. @item frequency, f
  1320. Set the filter's central frequency. Default is @code{3000}.
  1321. @item width_type
  1322. Set method to specify band-width of filter.
  1323. @table @option
  1324. @item h
  1325. Hz
  1326. @item q
  1327. Q-Factor
  1328. @item o
  1329. octave
  1330. @item s
  1331. slope
  1332. @end table
  1333. @item width, w
  1334. Specify the band-width of a filter in width_type units.
  1335. @end table
  1336. @section bass
  1337. Boost or cut the bass (lower) frequencies of the audio using a two-pole
  1338. shelving filter with a response similar to that of a standard
  1339. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  1340. The filter accepts the following options:
  1341. @table @option
  1342. @item gain, g
  1343. Give the gain at 0 Hz. Its useful range is about -20
  1344. (for a large cut) to +20 (for a large boost).
  1345. Beware of clipping when using a positive gain.
  1346. @item frequency, f
  1347. Set the filter's central frequency and so can be used
  1348. to extend or reduce the frequency range to be boosted or cut.
  1349. The default value is @code{100} Hz.
  1350. @item width_type
  1351. Set method to specify band-width of filter.
  1352. @table @option
  1353. @item h
  1354. Hz
  1355. @item q
  1356. Q-Factor
  1357. @item o
  1358. octave
  1359. @item s
  1360. slope
  1361. @end table
  1362. @item width, w
  1363. Determine how steep is the filter's shelf transition.
  1364. @end table
  1365. @section biquad
  1366. Apply a biquad IIR filter with the given coefficients.
  1367. Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
  1368. are the numerator and denominator coefficients respectively.
  1369. @section bs2b
  1370. Bauer stereo to binaural transformation, which improves headphone listening of
  1371. stereo audio records.
  1372. It accepts the following parameters:
  1373. @table @option
  1374. @item profile
  1375. Pre-defined crossfeed level.
  1376. @table @option
  1377. @item default
  1378. Default level (fcut=700, feed=50).
  1379. @item cmoy
  1380. Chu Moy circuit (fcut=700, feed=60).
  1381. @item jmeier
  1382. Jan Meier circuit (fcut=650, feed=95).
  1383. @end table
  1384. @item fcut
  1385. Cut frequency (in Hz).
  1386. @item feed
  1387. Feed level (in Hz).
  1388. @end table
  1389. @section channelmap
  1390. Remap input channels to new locations.
  1391. It accepts the following parameters:
  1392. @table @option
  1393. @item channel_layout
  1394. The channel layout of the output stream.
  1395. @item map
  1396. Map channels from input to output. The argument is a '|'-separated list of
  1397. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  1398. @var{in_channel} form. @var{in_channel} can be either the name of the input
  1399. channel (e.g. FL for front left) or its index in the input channel layout.
  1400. @var{out_channel} is the name of the output channel or its index in the output
  1401. channel layout. If @var{out_channel} is not given then it is implicitly an
  1402. index, starting with zero and increasing by one for each mapping.
  1403. @end table
  1404. If no mapping is present, the filter will implicitly map input channels to
  1405. output channels, preserving indices.
  1406. For example, assuming a 5.1+downmix input MOV file,
  1407. @example
  1408. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
  1409. @end example
  1410. will create an output WAV file tagged as stereo from the downmix channels of
  1411. the input.
  1412. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  1413. @example
  1414. ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:5.1' out.wav
  1415. @end example
  1416. @section channelsplit
  1417. Split each channel from an input audio stream into a separate output stream.
  1418. It accepts the following parameters:
  1419. @table @option
  1420. @item channel_layout
  1421. The channel layout of the input stream. The default is "stereo".
  1422. @end table
  1423. For example, assuming a stereo input MP3 file,
  1424. @example
  1425. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  1426. @end example
  1427. will create an output Matroska file with two audio streams, one containing only
  1428. the left channel and the other the right channel.
  1429. Split a 5.1 WAV file into per-channel files:
  1430. @example
  1431. ffmpeg -i in.wav -filter_complex
  1432. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  1433. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  1434. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  1435. side_right.wav
  1436. @end example
  1437. @section chorus
  1438. Add a chorus effect to the audio.
  1439. Can make a single vocal sound like a chorus, but can also be applied to instrumentation.
  1440. Chorus resembles an echo effect with a short delay, but whereas with echo the delay is
  1441. constant, with chorus, it is varied using using sinusoidal or triangular modulation.
  1442. The modulation depth defines the range the modulated delay is played before or after
  1443. the delay. Hence the delayed sound will sound slower or faster, that is the delayed
  1444. sound tuned around the original one, like in a chorus where some vocals are slightly
  1445. off key.
  1446. It accepts the following parameters:
  1447. @table @option
  1448. @item in_gain
  1449. Set input gain. Default is 0.4.
  1450. @item out_gain
  1451. Set output gain. Default is 0.4.
  1452. @item delays
  1453. Set delays. A typical delay is around 40ms to 60ms.
  1454. @item decays
  1455. Set decays.
  1456. @item speeds
  1457. Set speeds.
  1458. @item depths
  1459. Set depths.
  1460. @end table
  1461. @subsection Examples
  1462. @itemize
  1463. @item
  1464. A single delay:
  1465. @example
  1466. chorus=0.7:0.9:55:0.4:0.25:2
  1467. @end example
  1468. @item
  1469. Two delays:
  1470. @example
  1471. chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3
  1472. @end example
  1473. @item
  1474. Fuller sounding chorus with three delays:
  1475. @example
  1476. 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
  1477. @end example
  1478. @end itemize
  1479. @section compand
  1480. Compress or expand the audio's dynamic range.
  1481. It accepts the following parameters:
  1482. @table @option
  1483. @item attacks
  1484. @item decays
  1485. A list of times in seconds for each channel over which the instantaneous level
  1486. of the input signal is averaged to determine its volume. @var{attacks} refers to
  1487. increase of volume and @var{decays} refers to decrease of volume. For most
  1488. situations, the attack time (response to the audio getting louder) should be
  1489. shorter than the decay time, because the human ear is more sensitive to sudden
  1490. loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
  1491. a typical value for decay is 0.8 seconds.
  1492. If specified number of attacks & decays is lower than number of channels, the last
  1493. set attack/decay will be used for all remaining channels.
  1494. @item points
  1495. A list of points for the transfer function, specified in dB relative to the
  1496. maximum possible signal amplitude. Each key points list must be defined using
  1497. the following syntax: @code{x0/y0|x1/y1|x2/y2|....} or
  1498. @code{x0/y0 x1/y1 x2/y2 ....}
  1499. The input values must be in strictly increasing order but the transfer function
  1500. does not have to be monotonically rising. The point @code{0/0} is assumed but
  1501. may be overridden (by @code{0/out-dBn}). Typical values for the transfer
  1502. function are @code{-70/-70|-60/-20}.
  1503. @item soft-knee
  1504. Set the curve radius in dB for all joints. It defaults to 0.01.
  1505. @item gain
  1506. Set the additional gain in dB to be applied at all points on the transfer
  1507. function. This allows for easy adjustment of the overall gain.
  1508. It defaults to 0.
  1509. @item volume
  1510. Set an initial volume, in dB, to be assumed for each channel when filtering
  1511. starts. This permits the user to supply a nominal level initially, so that, for
  1512. example, a very large gain is not applied to initial signal levels before the
  1513. companding has begun to operate. A typical value for audio which is initially
  1514. quiet is -90 dB. It defaults to 0.
  1515. @item delay
  1516. Set a delay, in seconds. The input audio is analyzed immediately, but audio is
  1517. delayed before being fed to the volume adjuster. Specifying a delay
  1518. approximately equal to the attack/decay times allows the filter to effectively
  1519. operate in predictive rather than reactive mode. It defaults to 0.
  1520. @end table
  1521. @subsection Examples
  1522. @itemize
  1523. @item
  1524. Make music with both quiet and loud passages suitable for listening to in a
  1525. noisy environment:
  1526. @example
  1527. compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
  1528. @end example
  1529. Another example for audio with whisper and explosion parts:
  1530. @example
  1531. compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0
  1532. @end example
  1533. @item
  1534. A noise gate for when the noise is at a lower level than the signal:
  1535. @example
  1536. compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
  1537. @end example
  1538. @item
  1539. Here is another noise gate, this time for when the noise is at a higher level
  1540. than the signal (making it, in some ways, similar to squelch):
  1541. @example
  1542. compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
  1543. @end example
  1544. @item
  1545. 2:1 compression starting at -6dB:
  1546. @example
  1547. compand=points=-80/-80|-6/-6|0/-3.8|20/3.5
  1548. @end example
  1549. @item
  1550. 2:1 compression starting at -9dB:
  1551. @example
  1552. compand=points=-80/-80|-9/-9|0/-5.3|20/2.9
  1553. @end example
  1554. @item
  1555. 2:1 compression starting at -12dB:
  1556. @example
  1557. compand=points=-80/-80|-12/-12|0/-6.8|20/1.9
  1558. @end example
  1559. @item
  1560. 2:1 compression starting at -18dB:
  1561. @example
  1562. compand=points=-80/-80|-18/-18|0/-9.8|20/0.7
  1563. @end example
  1564. @item
  1565. 3:1 compression starting at -15dB:
  1566. @example
  1567. compand=points=-80/-80|-15/-15|0/-10.8|20/-5.2
  1568. @end example
  1569. @item
  1570. Compressor/Gate:
  1571. @example
  1572. compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6
  1573. @end example
  1574. @item
  1575. Expander:
  1576. @example
  1577. compand=attacks=0:points=-80/-169|-54/-80|-49.5/-64.6|-41.1/-41.1|-25.8/-15|-10.8/-4.5|0/0|20/8.3
  1578. @end example
  1579. @item
  1580. Hard limiter at -6dB:
  1581. @example
  1582. compand=attacks=0:points=-80/-80|-6/-6|20/-6
  1583. @end example
  1584. @item
  1585. Hard limiter at -12dB:
  1586. @example
  1587. compand=attacks=0:points=-80/-80|-12/-12|20/-12
  1588. @end example
  1589. @item
  1590. Hard noise gate at -35 dB:
  1591. @example
  1592. compand=attacks=0:points=-80/-115|-35.1/-80|-35/-35|20/20
  1593. @end example
  1594. @item
  1595. Soft limiter:
  1596. @example
  1597. compand=attacks=0:points=-80/-80|-12.4/-12.4|-6/-8|0/-6.8|20/-2.8
  1598. @end example
  1599. @end itemize
  1600. @section compensationdelay
  1601. Compensation Delay Line is a metric based delay to compensate differing
  1602. positions of microphones or speakers.
  1603. For example, you have recorded guitar with two microphones placed in
  1604. different location. Because the front of sound wave has fixed speed in
  1605. normal conditions, the phasing of microphones can vary and depends on
  1606. their location and interposition. The best sound mix can be achieved when
  1607. these microphones are in phase (synchronized). Note that distance of
  1608. ~30 cm between microphones makes one microphone to capture signal in
  1609. antiphase to another microphone. That makes the final mix sounding moody.
  1610. This filter helps to solve phasing problems by adding different delays
  1611. to each microphone track and make them synchronized.
  1612. The best result can be reached when you take one track as base and
  1613. synchronize other tracks one by one with it.
  1614. Remember that synchronization/delay tolerance depends on sample rate, too.
  1615. Higher sample rates will give more tolerance.
  1616. It accepts the following parameters:
  1617. @table @option
  1618. @item mm
  1619. Set millimeters distance. This is compensation distance for fine tuning.
  1620. Default is 0.
  1621. @item cm
  1622. Set cm distance. This is compensation distance for tightening distance setup.
  1623. Default is 0.
  1624. @item m
  1625. Set meters distance. This is compensation distance for hard distance setup.
  1626. Default is 0.
  1627. @item dry
  1628. Set dry amount. Amount of unprocessed (dry) signal.
  1629. Default is 0.
  1630. @item wet
  1631. Set wet amount. Amount of processed (wet) signal.
  1632. Default is 1.
  1633. @item temp
  1634. Set temperature degree in Celsius. This is the temperature of the environment.
  1635. Default is 20.
  1636. @end table
  1637. @section dcshift
  1638. Apply a DC shift to the audio.
  1639. This can be useful to remove a DC offset (caused perhaps by a hardware problem
  1640. in the recording chain) from the audio. The effect of a DC offset is reduced
  1641. headroom and hence volume. The @ref{astats} filter can be used to determine if
  1642. a signal has a DC offset.
  1643. @table @option
  1644. @item shift
  1645. Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift
  1646. the audio.
  1647. @item limitergain
  1648. Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
  1649. used to prevent clipping.
  1650. @end table
  1651. @section dynaudnorm
  1652. Dynamic Audio Normalizer.
  1653. This filter applies a certain amount of gain to the input audio in order
  1654. to bring its peak magnitude to a target level (e.g. 0 dBFS). However, in
  1655. contrast to more "simple" normalization algorithms, the Dynamic Audio
  1656. Normalizer *dynamically* re-adjusts the gain factor to the input audio.
  1657. This allows for applying extra gain to the "quiet" sections of the audio
  1658. while avoiding distortions or clipping the "loud" sections. In other words:
  1659. The Dynamic Audio Normalizer will "even out" the volume of quiet and loud
  1660. sections, in the sense that the volume of each section is brought to the
  1661. same target level. Note, however, that the Dynamic Audio Normalizer achieves
  1662. this goal *without* applying "dynamic range compressing". It will retain 100%
  1663. of the dynamic range *within* each section of the audio file.
  1664. @table @option
  1665. @item f
  1666. Set the frame length in milliseconds. In range from 10 to 8000 milliseconds.
  1667. Default is 500 milliseconds.
  1668. The Dynamic Audio Normalizer processes the input audio in small chunks,
  1669. referred to as frames. This is required, because a peak magnitude has no
  1670. meaning for just a single sample value. Instead, we need to determine the
  1671. peak magnitude for a contiguous sequence of sample values. While a "standard"
  1672. normalizer would simply use the peak magnitude of the complete file, the
  1673. Dynamic Audio Normalizer determines the peak magnitude individually for each
  1674. frame. The length of a frame is specified in milliseconds. By default, the
  1675. Dynamic Audio Normalizer uses a frame length of 500 milliseconds, which has
  1676. been found to give good results with most files.
  1677. Note that the exact frame length, in number of samples, will be determined
  1678. automatically, based on the sampling rate of the individual input audio file.
  1679. @item g
  1680. Set the Gaussian filter window size. In range from 3 to 301, must be odd
  1681. number. Default is 31.
  1682. Probably the most important parameter of the Dynamic Audio Normalizer is the
  1683. @code{window size} of the Gaussian smoothing filter. The filter's window size
  1684. is specified in frames, centered around the current frame. For the sake of
  1685. simplicity, this must be an odd number. Consequently, the default value of 31
  1686. takes into account the current frame, as well as the 15 preceding frames and
  1687. the 15 subsequent frames. Using a larger window results in a stronger
  1688. smoothing effect and thus in less gain variation, i.e. slower gain
  1689. adaptation. Conversely, using a smaller window results in a weaker smoothing
  1690. effect and thus in more gain variation, i.e. faster gain adaptation.
  1691. In other words, the more you increase this value, the more the Dynamic Audio
  1692. Normalizer will behave like a "traditional" normalization filter. On the
  1693. contrary, the more you decrease this value, the more the Dynamic Audio
  1694. Normalizer will behave like a dynamic range compressor.
  1695. @item p
  1696. Set the target peak value. This specifies the highest permissible magnitude
  1697. level for the normalized audio input. This filter will try to approach the
  1698. target peak magnitude as closely as possible, but at the same time it also
  1699. makes sure that the normalized signal will never exceed the peak magnitude.
  1700. A frame's maximum local gain factor is imposed directly by the target peak
  1701. magnitude. The default value is 0.95 and thus leaves a headroom of 5%*.
  1702. It is not recommended to go above this value.
  1703. @item m
  1704. Set the maximum gain factor. In range from 1.0 to 100.0. Default is 10.0.
  1705. The Dynamic Audio Normalizer determines the maximum possible (local) gain
  1706. factor for each input frame, i.e. the maximum gain factor that does not
  1707. result in clipping or distortion. The maximum gain factor is determined by
  1708. the frame's highest magnitude sample. However, the Dynamic Audio Normalizer
  1709. additionally bounds the frame's maximum gain factor by a predetermined
  1710. (global) maximum gain factor. This is done in order to avoid excessive gain
  1711. factors in "silent" or almost silent frames. By default, the maximum gain
  1712. factor is 10.0, For most inputs the default value should be sufficient and
  1713. it usually is not recommended to increase this value. Though, for input
  1714. with an extremely low overall volume level, it may be necessary to allow even
  1715. higher gain factors. Note, however, that the Dynamic Audio Normalizer does
  1716. not simply apply a "hard" threshold (i.e. cut off values above the threshold).
  1717. Instead, a "sigmoid" threshold function will be applied. This way, the
  1718. gain factors will smoothly approach the threshold value, but never exceed that
  1719. value.
  1720. @item r
  1721. Set the target RMS. In range from 0.0 to 1.0. Default is 0.0 - disabled.
  1722. By default, the Dynamic Audio Normalizer performs "peak" normalization.
  1723. This means that the maximum local gain factor for each frame is defined
  1724. (only) by the frame's highest magnitude sample. This way, the samples can
  1725. be amplified as much as possible without exceeding the maximum signal
  1726. level, i.e. without clipping. Optionally, however, the Dynamic Audio
  1727. Normalizer can also take into account the frame's root mean square,
  1728. abbreviated RMS. In electrical engineering, the RMS is commonly used to
  1729. determine the power of a time-varying signal. It is therefore considered
  1730. that the RMS is a better approximation of the "perceived loudness" than
  1731. just looking at the signal's peak magnitude. Consequently, by adjusting all
  1732. frames to a constant RMS value, a uniform "perceived loudness" can be
  1733. established. If a target RMS value has been specified, a frame's local gain
  1734. factor is defined as the factor that would result in exactly that RMS value.
  1735. Note, however, that the maximum local gain factor is still restricted by the
  1736. frame's highest magnitude sample, in order to prevent clipping.
  1737. @item n
  1738. Enable channels coupling. By default is enabled.
  1739. By default, the Dynamic Audio Normalizer will amplify all channels by the same
  1740. amount. This means the same gain factor will be applied to all channels, i.e.
  1741. the maximum possible gain factor is determined by the "loudest" channel.
  1742. However, in some recordings, it may happen that the volume of the different
  1743. channels is uneven, e.g. one channel may be "quieter" than the other one(s).
  1744. In this case, this option can be used to disable the channel coupling. This way,
  1745. the gain factor will be determined independently for each channel, depending
  1746. only on the individual channel's highest magnitude sample. This allows for
  1747. harmonizing the volume of the different channels.
  1748. @item c
  1749. Enable DC bias correction. By default is disabled.
  1750. An audio signal (in the time domain) is a sequence of sample values.
  1751. In the Dynamic Audio Normalizer these sample values are represented in the
  1752. -1.0 to 1.0 range, regardless of the original input format. Normally, the
  1753. audio signal, or "waveform", should be centered around the zero point.
  1754. That means if we calculate the mean value of all samples in a file, or in a
  1755. single frame, then the result should be 0.0 or at least very close to that
  1756. value. If, however, there is a significant deviation of the mean value from
  1757. 0.0, in either positive or negative direction, this is referred to as a
  1758. DC bias or DC offset. Since a DC bias is clearly undesirable, the Dynamic
  1759. Audio Normalizer provides optional DC bias correction.
  1760. With DC bias correction enabled, the Dynamic Audio Normalizer will determine
  1761. the mean value, or "DC correction" offset, of each input frame and subtract
  1762. that value from all of the frame's sample values which ensures those samples
  1763. are centered around 0.0 again. Also, in order to avoid "gaps" at the frame
  1764. boundaries, the DC correction offset values will be interpolated smoothly
  1765. between neighbouring frames.
  1766. @item b
  1767. Enable alternative boundary mode. By default is disabled.
  1768. The Dynamic Audio Normalizer takes into account a certain neighbourhood
  1769. around each frame. This includes the preceding frames as well as the
  1770. subsequent frames. However, for the "boundary" frames, located at the very
  1771. beginning and at the very end of the audio file, not all neighbouring
  1772. frames are available. In particular, for the first few frames in the audio
  1773. file, the preceding frames are not known. And, similarly, for the last few
  1774. frames in the audio file, the subsequent frames are not known. Thus, the
  1775. question arises which gain factors should be assumed for the missing frames
  1776. in the "boundary" region. The Dynamic Audio Normalizer implements two modes
  1777. to deal with this situation. The default boundary mode assumes a gain factor
  1778. of exactly 1.0 for the missing frames, resulting in a smooth "fade in" and
  1779. "fade out" at the beginning and at the end of the input, respectively.
  1780. @item s
  1781. Set the compress factor. In range from 0.0 to 30.0. Default is 0.0.
  1782. By default, the Dynamic Audio Normalizer does not apply "traditional"
  1783. compression. This means that signal peaks will not be pruned and thus the
  1784. full dynamic range will be retained within each local neighbourhood. However,
  1785. in some cases it may be desirable to combine the Dynamic Audio Normalizer's
  1786. normalization algorithm with a more "traditional" compression.
  1787. For this purpose, the Dynamic Audio Normalizer provides an optional compression
  1788. (thresholding) function. If (and only if) the compression feature is enabled,
  1789. all input frames will be processed by a soft knee thresholding function prior
  1790. to the actual normalization process. Put simply, the thresholding function is
  1791. going to prune all samples whose magnitude exceeds a certain threshold value.
  1792. However, the Dynamic Audio Normalizer does not simply apply a fixed threshold
  1793. value. Instead, the threshold value will be adjusted for each individual
  1794. frame.
  1795. In general, smaller parameters result in stronger compression, and vice versa.
  1796. Values below 3.0 are not recommended, because audible distortion may appear.
  1797. @end table
  1798. @section earwax
  1799. Make audio easier to listen to on headphones.
  1800. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  1801. so that when listened to on headphones the stereo image is moved from
  1802. inside your head (standard for headphones) to outside and in front of
  1803. the listener (standard for speakers).
  1804. Ported from SoX.
  1805. @section equalizer
  1806. Apply a two-pole peaking equalisation (EQ) filter. With this
  1807. filter, the signal-level at and around a selected frequency can
  1808. be increased or decreased, whilst (unlike bandpass and bandreject
  1809. filters) that at all other frequencies is unchanged.
  1810. In order to produce complex equalisation curves, this filter can
  1811. be given several times, each with a different central frequency.
  1812. The filter accepts the following options:
  1813. @table @option
  1814. @item frequency, f
  1815. Set the filter's central frequency in Hz.
  1816. @item width_type
  1817. Set method to specify band-width of filter.
  1818. @table @option
  1819. @item h
  1820. Hz
  1821. @item q
  1822. Q-Factor
  1823. @item o
  1824. octave
  1825. @item s
  1826. slope
  1827. @end table
  1828. @item width, w
  1829. Specify the band-width of a filter in width_type units.
  1830. @item gain, g
  1831. Set the required gain or attenuation in dB.
  1832. Beware of clipping when using a positive gain.
  1833. @end table
  1834. @subsection Examples
  1835. @itemize
  1836. @item
  1837. Attenuate 10 dB at 1000 Hz, with a bandwidth of 200 Hz:
  1838. @example
  1839. equalizer=f=1000:width_type=h:width=200:g=-10
  1840. @end example
  1841. @item
  1842. Apply 2 dB gain at 1000 Hz with Q 1 and attenuate 5 dB at 100 Hz with Q 2:
  1843. @example
  1844. equalizer=f=1000:width_type=q:width=1:g=2,equalizer=f=100:width_type=q:width=2:g=-5
  1845. @end example
  1846. @end itemize
  1847. @section extrastereo
  1848. Linearly increases the difference between left and right channels which
  1849. adds some sort of "live" effect to playback.
  1850. The filter accepts the following option:
  1851. @table @option
  1852. @item m
  1853. Sets the difference coefficient (default: 2.5). 0.0 means mono sound
  1854. (average of both channels), with 1.0 sound will be unchanged, with
  1855. -1.0 left and right channels will be swapped.
  1856. @item c
  1857. Enable clipping. By default is enabled.
  1858. @end table
  1859. @section flanger
  1860. Apply a flanging effect to the audio.
  1861. The filter accepts the following options:
  1862. @table @option
  1863. @item delay
  1864. Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
  1865. @item depth
  1866. Set added swep delay in milliseconds. Range from 0 to 10. Default value is 2.
  1867. @item regen
  1868. Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
  1869. Default value is 0.
  1870. @item width
  1871. Set percentage of delayed signal mixed with original. Range from 0 to 100.
  1872. Default value is 71.
  1873. @item speed
  1874. Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
  1875. @item shape
  1876. Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
  1877. Default value is @var{sinusoidal}.
  1878. @item phase
  1879. Set swept wave percentage-shift for multi channel. Range from 0 to 100.
  1880. Default value is 25.
  1881. @item interp
  1882. Set delay-line interpolation, @var{linear} or @var{quadratic}.
  1883. Default is @var{linear}.
  1884. @end table
  1885. @section highpass
  1886. Apply a high-pass filter with 3dB point frequency.
  1887. The filter can be either single-pole, or double-pole (the default).
  1888. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1889. The filter accepts the following options:
  1890. @table @option
  1891. @item frequency, f
  1892. Set frequency in Hz. Default is 3000.
  1893. @item poles, p
  1894. Set number of poles. Default is 2.
  1895. @item width_type
  1896. Set method to specify band-width of filter.
  1897. @table @option
  1898. @item h
  1899. Hz
  1900. @item q
  1901. Q-Factor
  1902. @item o
  1903. octave
  1904. @item s
  1905. slope
  1906. @end table
  1907. @item width, w
  1908. Specify the band-width of a filter in width_type units.
  1909. Applies only to double-pole filter.
  1910. The default is 0.707q and gives a Butterworth response.
  1911. @end table
  1912. @section join
  1913. Join multiple input streams into one multi-channel stream.
  1914. It accepts the following parameters:
  1915. @table @option
  1916. @item inputs
  1917. The number of input streams. It defaults to 2.
  1918. @item channel_layout
  1919. The desired output channel layout. It defaults to stereo.
  1920. @item map
  1921. Map channels from inputs to output. The argument is a '|'-separated list of
  1922. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  1923. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  1924. can be either the name of the input channel (e.g. FL for front left) or its
  1925. index in the specified input stream. @var{out_channel} is the name of the output
  1926. channel.
  1927. @end table
  1928. The filter will attempt to guess the mappings when they are not specified
  1929. explicitly. It does so by first trying to find an unused matching input channel
  1930. and if that fails it picks the first unused input channel.
  1931. Join 3 inputs (with properly set channel layouts):
  1932. @example
  1933. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  1934. @end example
  1935. Build a 5.1 output from 6 single-channel streams:
  1936. @example
  1937. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  1938. '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'
  1939. out
  1940. @end example
  1941. @section ladspa
  1942. Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
  1943. To enable compilation of this filter you need to configure FFmpeg with
  1944. @code{--enable-ladspa}.
  1945. @table @option
  1946. @item file, f
  1947. Specifies the name of LADSPA plugin library to load. If the environment
  1948. variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
  1949. each one of the directories specified by the colon separated list in
  1950. @env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
  1951. this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
  1952. @file{/usr/lib/ladspa/}.
  1953. @item plugin, p
  1954. Specifies the plugin within the library. Some libraries contain only
  1955. one plugin, but others contain many of them. If this is not set filter
  1956. will list all available plugins within the specified library.
  1957. @item controls, c
  1958. Set the '|' separated list of controls which are zero or more floating point
  1959. values that determine the behavior of the loaded plugin (for example delay,
  1960. threshold or gain).
  1961. Controls need to be defined using the following syntax:
  1962. c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
  1963. @var{valuei} is the value set on the @var{i}-th control.
  1964. Alternatively they can be also defined using the following syntax:
  1965. @var{value0}|@var{value1}|@var{value2}|..., where
  1966. @var{valuei} is the value set on the @var{i}-th control.
  1967. If @option{controls} is set to @code{help}, all available controls and
  1968. their valid ranges are printed.
  1969. @item sample_rate, s
  1970. Specify the sample rate, default to 44100. Only used if plugin have
  1971. zero inputs.
  1972. @item nb_samples, n
  1973. Set the number of samples per channel per each output frame, default
  1974. is 1024. Only used if plugin have zero inputs.
  1975. @item duration, d
  1976. Set the minimum duration of the sourced audio. See
  1977. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  1978. for the accepted syntax.
  1979. Note that the resulting duration may be greater than the specified duration,
  1980. as the generated audio is always cut at the end of a complete frame.
  1981. If not specified, or the expressed duration is negative, the audio is
  1982. supposed to be generated forever.
  1983. Only used if plugin have zero inputs.
  1984. @end table
  1985. @subsection Examples
  1986. @itemize
  1987. @item
  1988. List all available plugins within amp (LADSPA example plugin) library:
  1989. @example
  1990. ladspa=file=amp
  1991. @end example
  1992. @item
  1993. List all available controls and their valid ranges for @code{vcf_notch}
  1994. plugin from @code{VCF} library:
  1995. @example
  1996. ladspa=f=vcf:p=vcf_notch:c=help
  1997. @end example
  1998. @item
  1999. Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
  2000. plugin library:
  2001. @example
  2002. ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
  2003. @end example
  2004. @item
  2005. Add reverberation to the audio using TAP-plugins
  2006. (Tom's Audio Processing plugins):
  2007. @example
  2008. ladspa=file=tap_reverb:tap_reverb
  2009. @end example
  2010. @item
  2011. Generate white noise, with 0.2 amplitude:
  2012. @example
  2013. ladspa=file=cmt:noise_source_white:c=c0=.2
  2014. @end example
  2015. @item
  2016. Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
  2017. @code{C* Audio Plugin Suite} (CAPS) library:
  2018. @example
  2019. ladspa=file=caps:Click:c=c1=20'
  2020. @end example
  2021. @item
  2022. Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
  2023. @example
  2024. ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
  2025. @end example
  2026. @item
  2027. Increase volume by 20dB using fast lookahead limiter from Steve Harris
  2028. @code{SWH Plugins} collection:
  2029. @example
  2030. ladspa=fast_lookahead_limiter_1913:fastLookaheadLimiter:20|0|2
  2031. @end example
  2032. @item
  2033. Attenuate low frequencies using Multiband EQ from Steve Harris
  2034. @code{SWH Plugins} collection:
  2035. @example
  2036. ladspa=mbeq_1197:mbeq:-24|-24|-24|0|0|0|0|0|0|0|0|0|0|0|0
  2037. @end example
  2038. @end itemize
  2039. @subsection Commands
  2040. This filter supports the following commands:
  2041. @table @option
  2042. @item cN
  2043. Modify the @var{N}-th control value.
  2044. If the specified value is not valid, it is ignored and prior one is kept.
  2045. @end table
  2046. @section lowpass
  2047. Apply a low-pass filter with 3dB point frequency.
  2048. The filter can be either single-pole or double-pole (the default).
  2049. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  2050. The filter accepts the following options:
  2051. @table @option
  2052. @item frequency, f
  2053. Set frequency in Hz. Default is 500.
  2054. @item poles, p
  2055. Set number of poles. Default is 2.
  2056. @item width_type
  2057. Set method to specify band-width of filter.
  2058. @table @option
  2059. @item h
  2060. Hz
  2061. @item q
  2062. Q-Factor
  2063. @item o
  2064. octave
  2065. @item s
  2066. slope
  2067. @end table
  2068. @item width, w
  2069. Specify the band-width of a filter in width_type units.
  2070. Applies only to double-pole filter.
  2071. The default is 0.707q and gives a Butterworth response.
  2072. @end table
  2073. @anchor{pan}
  2074. @section pan
  2075. Mix channels with specific gain levels. The filter accepts the output
  2076. channel layout followed by a set of channels definitions.
  2077. This filter is also designed to efficiently remap the channels of an audio
  2078. stream.
  2079. The filter accepts parameters of the form:
  2080. "@var{l}|@var{outdef}|@var{outdef}|..."
  2081. @table @option
  2082. @item l
  2083. output channel layout or number of channels
  2084. @item outdef
  2085. output channel specification, of the form:
  2086. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  2087. @item out_name
  2088. output channel to define, either a channel name (FL, FR, etc.) or a channel
  2089. number (c0, c1, etc.)
  2090. @item gain
  2091. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  2092. @item in_name
  2093. input channel to use, see out_name for details; it is not possible to mix
  2094. named and numbered input channels
  2095. @end table
  2096. If the `=' in a channel specification is replaced by `<', then the gains for
  2097. that specification will be renormalized so that the total is 1, thus
  2098. avoiding clipping noise.
  2099. @subsection Mixing examples
  2100. For example, if you want to down-mix from stereo to mono, but with a bigger
  2101. factor for the left channel:
  2102. @example
  2103. pan=1c|c0=0.9*c0+0.1*c1
  2104. @end example
  2105. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  2106. 7-channels surround:
  2107. @example
  2108. pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  2109. @end example
  2110. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  2111. that should be preferred (see "-ac" option) unless you have very specific
  2112. needs.
  2113. @subsection Remapping examples
  2114. The channel remapping will be effective if, and only if:
  2115. @itemize
  2116. @item gain coefficients are zeroes or ones,
  2117. @item only one input per channel output,
  2118. @end itemize
  2119. If all these conditions are satisfied, the filter will notify the user ("Pure
  2120. channel mapping detected"), and use an optimized and lossless method to do the
  2121. remapping.
  2122. For example, if you have a 5.1 source and want a stereo audio stream by
  2123. dropping the extra channels:
  2124. @example
  2125. pan="stereo| c0=FL | c1=FR"
  2126. @end example
  2127. Given the same source, you can also switch front left and front right channels
  2128. and keep the input channel layout:
  2129. @example
  2130. pan="5.1| c0=c1 | c1=c0 | c2=c2 | c3=c3 | c4=c4 | c5=c5"
  2131. @end example
  2132. If the input is a stereo audio stream, you can mute the front left channel (and
  2133. still keep the stereo channel layout) with:
  2134. @example
  2135. pan="stereo|c1=c1"
  2136. @end example
  2137. Still with a stereo audio stream input, you can copy the right channel in both
  2138. front left and right:
  2139. @example
  2140. pan="stereo| c0=FR | c1=FR"
  2141. @end example
  2142. @section replaygain
  2143. ReplayGain scanner filter. This filter takes an audio stream as an input and
  2144. outputs it unchanged.
  2145. At end of filtering it displays @code{track_gain} and @code{track_peak}.
  2146. @section resample
  2147. Convert the audio sample format, sample rate and channel layout. It is
  2148. not meant to be used directly.
  2149. @section rubberband
  2150. Apply time-stretching and pitch-shifting with librubberband.
  2151. The filter accepts the following options:
  2152. @table @option
  2153. @item tempo
  2154. Set tempo scale factor.
  2155. @item pitch
  2156. Set pitch scale factor.
  2157. @item transients
  2158. Set transients detector.
  2159. Possible values are:
  2160. @table @var
  2161. @item crisp
  2162. @item mixed
  2163. @item smooth
  2164. @end table
  2165. @item detector
  2166. Set detector.
  2167. Possible values are:
  2168. @table @var
  2169. @item compound
  2170. @item percussive
  2171. @item soft
  2172. @end table
  2173. @item phase
  2174. Set phase.
  2175. Possible values are:
  2176. @table @var
  2177. @item laminar
  2178. @item independent
  2179. @end table
  2180. @item window
  2181. Set processing window size.
  2182. Possible values are:
  2183. @table @var
  2184. @item standard
  2185. @item short
  2186. @item long
  2187. @end table
  2188. @item smoothing
  2189. Set smoothing.
  2190. Possible values are:
  2191. @table @var
  2192. @item off
  2193. @item on
  2194. @end table
  2195. @item formant
  2196. Enable formant preservation when shift pitching.
  2197. Possible values are:
  2198. @table @var
  2199. @item shifted
  2200. @item preserved
  2201. @end table
  2202. @item pitchq
  2203. Set pitch quality.
  2204. Possible values are:
  2205. @table @var
  2206. @item quality
  2207. @item speed
  2208. @item consistency
  2209. @end table
  2210. @item channels
  2211. Set channels.
  2212. Possible values are:
  2213. @table @var
  2214. @item apart
  2215. @item together
  2216. @end table
  2217. @end table
  2218. @section sidechaincompress
  2219. This filter acts like normal compressor but has the ability to compress
  2220. detected signal using second input signal.
  2221. It needs two input streams and returns one output stream.
  2222. First input stream will be processed depending on second stream signal.
  2223. The filtered signal then can be filtered with other filters in later stages of
  2224. processing. See @ref{pan} and @ref{amerge} filter.
  2225. The filter accepts the following options:
  2226. @table @option
  2227. @item level_in
  2228. Set input gain. Default is 1. Range is between 0.015625 and 64.
  2229. @item threshold
  2230. If a signal of second stream raises above this level it will affect the gain
  2231. reduction of first stream.
  2232. By default is 0.125. Range is between 0.00097563 and 1.
  2233. @item ratio
  2234. Set a ratio about which the signal is reduced. 1:2 means that if the level
  2235. raised 4dB above the threshold, it will be only 2dB above after the reduction.
  2236. Default is 2. Range is between 1 and 20.
  2237. @item attack
  2238. Amount of milliseconds the signal has to rise above the threshold before gain
  2239. reduction starts. Default is 20. Range is between 0.01 and 2000.
  2240. @item release
  2241. Amount of milliseconds the signal has to fall below the threshold before
  2242. reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
  2243. @item makeup
  2244. Set the amount by how much signal will be amplified after processing.
  2245. Default is 2. Range is from 1 and 64.
  2246. @item knee
  2247. Curve the sharp knee around the threshold to enter gain reduction more softly.
  2248. Default is 2.82843. Range is between 1 and 8.
  2249. @item link
  2250. Choose if the @code{average} level between all channels of side-chain stream
  2251. or the louder(@code{maximum}) channel of side-chain stream affects the
  2252. reduction. Default is @code{average}.
  2253. @item detection
  2254. Should the exact signal be taken in case of @code{peak} or an RMS one in case
  2255. of @code{rms}. Default is @code{rms} which is mainly smoother.
  2256. @item level_sc
  2257. Set sidechain gain. Default is 1. Range is between 0.015625 and 64.
  2258. @item mix
  2259. How much to use compressed signal in output. Default is 1.
  2260. Range is between 0 and 1.
  2261. @end table
  2262. @subsection Examples
  2263. @itemize
  2264. @item
  2265. Full ffmpeg example taking 2 audio inputs, 1st input to be compressed
  2266. depending on the signal of 2nd input and later compressed signal to be
  2267. merged with 2nd input:
  2268. @example
  2269. ffmpeg -i main.flac -i sidechain.flac -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge"
  2270. @end example
  2271. @end itemize
  2272. @section sidechaingate
  2273. A sidechain gate acts like a normal (wideband) gate but has the ability to
  2274. filter the detected signal before sending it to the gain reduction stage.
  2275. Normally a gate uses the full range signal to detect a level above the
  2276. threshold.
  2277. For example: If you cut all lower frequencies from your sidechain signal
  2278. the gate will decrease the volume of your track only if not enough highs
  2279. appear. With this technique you are able to reduce the resonation of a
  2280. natural drum or remove "rumbling" of muted strokes from a heavily distorted
  2281. guitar.
  2282. It needs two input streams and returns one output stream.
  2283. First input stream will be processed depending on second stream signal.
  2284. The filter accepts the following options:
  2285. @table @option
  2286. @item level_in
  2287. Set input level before filtering.
  2288. Default is 1. Allowed range is from 0.015625 to 64.
  2289. @item range
  2290. Set the level of gain reduction when the signal is below the threshold.
  2291. Default is 0.06125. Allowed range is from 0 to 1.
  2292. @item threshold
  2293. If a signal rises above this level the gain reduction is released.
  2294. Default is 0.125. Allowed range is from 0 to 1.
  2295. @item ratio
  2296. Set a ratio about which the signal is reduced.
  2297. Default is 2. Allowed range is from 1 to 9000.
  2298. @item attack
  2299. Amount of milliseconds the signal has to rise above the threshold before gain
  2300. reduction stops.
  2301. Default is 20 milliseconds. Allowed range is from 0.01 to 9000.
  2302. @item release
  2303. Amount of milliseconds the signal has to fall below the threshold before the
  2304. reduction is increased again. Default is 250 milliseconds.
  2305. Allowed range is from 0.01 to 9000.
  2306. @item makeup
  2307. Set amount of amplification of signal after processing.
  2308. Default is 1. Allowed range is from 1 to 64.
  2309. @item knee
  2310. Curve the sharp knee around the threshold to enter gain reduction more softly.
  2311. Default is 2.828427125. Allowed range is from 1 to 8.
  2312. @item detection
  2313. Choose if exact signal should be taken for detection or an RMS like one.
  2314. Default is rms. Can be peak or rms.
  2315. @item link
  2316. Choose if the average level between all channels or the louder channel affects
  2317. the reduction.
  2318. Default is average. Can be average or maximum.
  2319. @item level_sc
  2320. Set sidechain gain. Default is 1. Range is from 0.015625 to 64.
  2321. @end table
  2322. @section silencedetect
  2323. Detect silence in an audio stream.
  2324. This filter logs a message when it detects that the input audio volume is less
  2325. or equal to a noise tolerance value for a duration greater or equal to the
  2326. minimum detected noise duration.
  2327. The printed times and duration are expressed in seconds.
  2328. The filter accepts the following options:
  2329. @table @option
  2330. @item duration, d
  2331. Set silence duration until notification (default is 2 seconds).
  2332. @item noise, n
  2333. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  2334. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  2335. @end table
  2336. @subsection Examples
  2337. @itemize
  2338. @item
  2339. Detect 5 seconds of silence with -50dB noise tolerance:
  2340. @example
  2341. silencedetect=n=-50dB:d=5
  2342. @end example
  2343. @item
  2344. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  2345. tolerance in @file{silence.mp3}:
  2346. @example
  2347. ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
  2348. @end example
  2349. @end itemize
  2350. @section silenceremove
  2351. Remove silence from the beginning, middle or end of the audio.
  2352. The filter accepts the following options:
  2353. @table @option
  2354. @item start_periods
  2355. This value is used to indicate if audio should be trimmed at beginning of
  2356. the audio. A value of zero indicates no silence should be trimmed from the
  2357. beginning. When specifying a non-zero value, it trims audio up until it
  2358. finds non-silence. Normally, when trimming silence from beginning of audio
  2359. the @var{start_periods} will be @code{1} but it can be increased to higher
  2360. values to trim all audio up to specific count of non-silence periods.
  2361. Default value is @code{0}.
  2362. @item start_duration
  2363. Specify the amount of time that non-silence must be detected before it stops
  2364. trimming audio. By increasing the duration, bursts of noises can be treated
  2365. as silence and trimmed off. Default value is @code{0}.
  2366. @item start_threshold
  2367. This indicates what sample value should be treated as silence. For digital
  2368. audio, a value of @code{0} may be fine but for audio recorded from analog,
  2369. you may wish to increase the value to account for background noise.
  2370. Can be specified in dB (in case "dB" is appended to the specified value)
  2371. or amplitude ratio. Default value is @code{0}.
  2372. @item stop_periods
  2373. Set the count for trimming silence from the end of audio.
  2374. To remove silence from the middle of a file, specify a @var{stop_periods}
  2375. that is negative. This value is then treated as a positive value and is
  2376. used to indicate the effect should restart processing as specified by
  2377. @var{start_periods}, making it suitable for removing periods of silence
  2378. in the middle of the audio.
  2379. Default value is @code{0}.
  2380. @item stop_duration
  2381. Specify a duration of silence that must exist before audio is not copied any
  2382. more. By specifying a higher duration, silence that is wanted can be left in
  2383. the audio.
  2384. Default value is @code{0}.
  2385. @item stop_threshold
  2386. This is the same as @option{start_threshold} but for trimming silence from
  2387. the end of audio.
  2388. Can be specified in dB (in case "dB" is appended to the specified value)
  2389. or amplitude ratio. Default value is @code{0}.
  2390. @item leave_silence
  2391. This indicate that @var{stop_duration} length of audio should be left intact
  2392. at the beginning of each period of silence.
  2393. For example, if you want to remove long pauses between words but do not want
  2394. to remove the pauses completely. Default value is @code{0}.
  2395. @item detection
  2396. Set how is silence detected. Can be @code{rms} or @code{peak}. Second is faster
  2397. and works better with digital silence which is exactly 0.
  2398. Default value is @code{rms}.
  2399. @item window
  2400. Set ratio used to calculate size of window for detecting silence.
  2401. Default value is @code{0.02}. Allowed range is from @code{0} to @code{10}.
  2402. @end table
  2403. @subsection Examples
  2404. @itemize
  2405. @item
  2406. The following example shows how this filter can be used to start a recording
  2407. that does not contain the delay at the start which usually occurs between
  2408. pressing the record button and the start of the performance:
  2409. @example
  2410. silenceremove=1:5:0.02
  2411. @end example
  2412. @item
  2413. Trim all silence encountered from begining to end where there is more than 1
  2414. second of silence in audio:
  2415. @example
  2416. silenceremove=0:0:0:-1:1:-90dB
  2417. @end example
  2418. @end itemize
  2419. @section sofalizer
  2420. SOFAlizer uses head-related transfer functions (HRTFs) to create virtual
  2421. loudspeakers around the user for binaural listening via headphones (audio
  2422. formats up to 9 channels supported).
  2423. The HRTFs are stored in SOFA files (see @url{http://www.sofacoustics.org/} for a database).
  2424. SOFAlizer is developed at the Acoustics Research Institute (ARI) of the
  2425. Austrian Academy of Sciences.
  2426. To enable compilation of this filter you need to configure FFmpeg with
  2427. @code{--enable-netcdf}.
  2428. The filter accepts the following options:
  2429. @table @option
  2430. @item sofa
  2431. Set the SOFA file used for rendering.
  2432. @item gain
  2433. Set gain applied to audio. Value is in dB. Default is 0.
  2434. @item rotation
  2435. Set rotation of virtual loudspeakers in deg. Default is 0.
  2436. @item elevation
  2437. Set elevation of virtual speakers in deg. Default is 0.
  2438. @item radius
  2439. Set distance in meters between loudspeakers and the listener with near-field
  2440. HRTFs. Default is 1.
  2441. @item type
  2442. Set processing type. Can be @var{time} or @var{freq}. @var{time} is
  2443. processing audio in time domain which is slow but gives high quality output.
  2444. @var{freq} is processing audio in frequency domain which is fast but gives
  2445. mediocre output. Default is @var{freq}.
  2446. @end table
  2447. @section stereotools
  2448. This filter has some handy utilities to manage stereo signals, for converting
  2449. M/S stereo recordings to L/R signal while having control over the parameters
  2450. or spreading the stereo image of master track.
  2451. The filter accepts the following options:
  2452. @table @option
  2453. @item level_in
  2454. Set input level before filtering for both channels. Defaults is 1.
  2455. Allowed range is from 0.015625 to 64.
  2456. @item level_out
  2457. Set output level after filtering for both channels. Defaults is 1.
  2458. Allowed range is from 0.015625 to 64.
  2459. @item balance_in
  2460. Set input balance between both channels. Default is 0.
  2461. Allowed range is from -1 to 1.
  2462. @item balance_out
  2463. Set output balance between both channels. Default is 0.
  2464. Allowed range is from -1 to 1.
  2465. @item softclip
  2466. Enable softclipping. Results in analog distortion instead of harsh digital 0dB
  2467. clipping. Disabled by default.
  2468. @item mutel
  2469. Mute the left channel. Disabled by default.
  2470. @item muter
  2471. Mute the right channel. Disabled by default.
  2472. @item phasel
  2473. Change the phase of the left channel. Disabled by default.
  2474. @item phaser
  2475. Change the phase of the right channel. Disabled by default.
  2476. @item mode
  2477. Set stereo mode. Available values are:
  2478. @table @samp
  2479. @item lr>lr
  2480. Left/Right to Left/Right, this is default.
  2481. @item lr>ms
  2482. Left/Right to Mid/Side.
  2483. @item ms>lr
  2484. Mid/Side to Left/Right.
  2485. @item lr>ll
  2486. Left/Right to Left/Left.
  2487. @item lr>rr
  2488. Left/Right to Right/Right.
  2489. @item lr>l+r
  2490. Left/Right to Left + Right.
  2491. @item lr>rl
  2492. Left/Right to Right/Left.
  2493. @end table
  2494. @item slev
  2495. Set level of side signal. Default is 1.
  2496. Allowed range is from 0.015625 to 64.
  2497. @item sbal
  2498. Set balance of side signal. Default is 0.
  2499. Allowed range is from -1 to 1.
  2500. @item mlev
  2501. Set level of the middle signal. Default is 1.
  2502. Allowed range is from 0.015625 to 64.
  2503. @item mpan
  2504. Set middle signal pan. Default is 0. Allowed range is from -1 to 1.
  2505. @item base
  2506. Set stereo base between mono and inversed channels. Default is 0.
  2507. Allowed range is from -1 to 1.
  2508. @item delay
  2509. Set delay in milliseconds how much to delay left from right channel and
  2510. vice versa. Default is 0. Allowed range is from -20 to 20.
  2511. @item sclevel
  2512. Set S/C level. Default is 1. Allowed range is from 1 to 100.
  2513. @item phase
  2514. Set the stereo phase in degrees. Default is 0. Allowed range is from 0 to 360.
  2515. @end table
  2516. @section stereowiden
  2517. This filter enhance the stereo effect by suppressing signal common to both
  2518. channels and by delaying the signal of left into right and vice versa,
  2519. thereby widening the stereo effect.
  2520. The filter accepts the following options:
  2521. @table @option
  2522. @item delay
  2523. Time in milliseconds of the delay of left signal into right and vice versa.
  2524. Default is 20 milliseconds.
  2525. @item feedback
  2526. Amount of gain in delayed signal into right and vice versa. Gives a delay
  2527. effect of left signal in right output and vice versa which gives widening
  2528. effect. Default is 0.3.
  2529. @item crossfeed
  2530. Cross feed of left into right with inverted phase. This helps in suppressing
  2531. the mono. If the value is 1 it will cancel all the signal common to both
  2532. channels. Default is 0.3.
  2533. @item drymix
  2534. Set level of input signal of original channel. Default is 0.8.
  2535. @end table
  2536. @section treble
  2537. Boost or cut treble (upper) frequencies of the audio using a two-pole
  2538. shelving filter with a response similar to that of a standard
  2539. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  2540. The filter accepts the following options:
  2541. @table @option
  2542. @item gain, g
  2543. Give the gain at whichever is the lower of ~22 kHz and the
  2544. Nyquist frequency. Its useful range is about -20 (for a large cut)
  2545. to +20 (for a large boost). Beware of clipping when using a positive gain.
  2546. @item frequency, f
  2547. Set the filter's central frequency and so can be used
  2548. to extend or reduce the frequency range to be boosted or cut.
  2549. The default value is @code{3000} Hz.
  2550. @item width_type
  2551. Set method to specify band-width of filter.
  2552. @table @option
  2553. @item h
  2554. Hz
  2555. @item q
  2556. Q-Factor
  2557. @item o
  2558. octave
  2559. @item s
  2560. slope
  2561. @end table
  2562. @item width, w
  2563. Determine how steep is the filter's shelf transition.
  2564. @end table
  2565. @section tremolo
  2566. Sinusoidal amplitude modulation.
  2567. The filter accepts the following options:
  2568. @table @option
  2569. @item f
  2570. Modulation frequency in Hertz. Modulation frequencies in the subharmonic range
  2571. (20 Hz or lower) will result in a tremolo effect.
  2572. This filter may also be used as a ring modulator by specifying
  2573. a modulation frequency higher than 20 Hz.
  2574. Range is 0.1 - 20000.0. Default value is 5.0 Hz.
  2575. @item d
  2576. Depth of modulation as a percentage. Range is 0.0 - 1.0.
  2577. Default value is 0.5.
  2578. @end table
  2579. @section vibrato
  2580. Sinusoidal phase modulation.
  2581. The filter accepts the following options:
  2582. @table @option
  2583. @item f
  2584. Modulation frequency in Hertz.
  2585. Range is 0.1 - 20000.0. Default value is 5.0 Hz.
  2586. @item d
  2587. Depth of modulation as a percentage. Range is 0.0 - 1.0.
  2588. Default value is 0.5.
  2589. @end table
  2590. @section volume
  2591. Adjust the input audio volume.
  2592. It accepts the following parameters:
  2593. @table @option
  2594. @item volume
  2595. Set audio volume expression.
  2596. Output values are clipped to the maximum value.
  2597. The output audio volume is given by the relation:
  2598. @example
  2599. @var{output_volume} = @var{volume} * @var{input_volume}
  2600. @end example
  2601. The default value for @var{volume} is "1.0".
  2602. @item precision
  2603. This parameter represents the mathematical precision.
  2604. It determines which input sample formats will be allowed, which affects the
  2605. precision of the volume scaling.
  2606. @table @option
  2607. @item fixed
  2608. 8-bit fixed-point; this limits input sample format to U8, S16, and S32.
  2609. @item float
  2610. 32-bit floating-point; this limits input sample format to FLT. (default)
  2611. @item double
  2612. 64-bit floating-point; this limits input sample format to DBL.
  2613. @end table
  2614. @item replaygain
  2615. Choose the behaviour on encountering ReplayGain side data in input frames.
  2616. @table @option
  2617. @item drop
  2618. Remove ReplayGain side data, ignoring its contents (the default).
  2619. @item ignore
  2620. Ignore ReplayGain side data, but leave it in the frame.
  2621. @item track
  2622. Prefer the track gain, if present.
  2623. @item album
  2624. Prefer the album gain, if present.
  2625. @end table
  2626. @item replaygain_preamp
  2627. Pre-amplification gain in dB to apply to the selected replaygain gain.
  2628. Default value for @var{replaygain_preamp} is 0.0.
  2629. @item eval
  2630. Set when the volume expression is evaluated.
  2631. It accepts the following values:
  2632. @table @samp
  2633. @item once
  2634. only evaluate expression once during the filter initialization, or
  2635. when the @samp{volume} command is sent
  2636. @item frame
  2637. evaluate expression for each incoming frame
  2638. @end table
  2639. Default value is @samp{once}.
  2640. @end table
  2641. The volume expression can contain the following parameters.
  2642. @table @option
  2643. @item n
  2644. frame number (starting at zero)
  2645. @item nb_channels
  2646. number of channels
  2647. @item nb_consumed_samples
  2648. number of samples consumed by the filter
  2649. @item nb_samples
  2650. number of samples in the current frame
  2651. @item pos
  2652. original frame position in the file
  2653. @item pts
  2654. frame PTS
  2655. @item sample_rate
  2656. sample rate
  2657. @item startpts
  2658. PTS at start of stream
  2659. @item startt
  2660. time at start of stream
  2661. @item t
  2662. frame time
  2663. @item tb
  2664. timestamp timebase
  2665. @item volume
  2666. last set volume value
  2667. @end table
  2668. Note that when @option{eval} is set to @samp{once} only the
  2669. @var{sample_rate} and @var{tb} variables are available, all other
  2670. variables will evaluate to NAN.
  2671. @subsection Commands
  2672. This filter supports the following commands:
  2673. @table @option
  2674. @item volume
  2675. Modify the volume expression.
  2676. The command accepts the same syntax of the corresponding option.
  2677. If the specified expression is not valid, it is kept at its current
  2678. value.
  2679. @item replaygain_noclip
  2680. Prevent clipping by limiting the gain applied.
  2681. Default value for @var{replaygain_noclip} is 1.
  2682. @end table
  2683. @subsection Examples
  2684. @itemize
  2685. @item
  2686. Halve the input audio volume:
  2687. @example
  2688. volume=volume=0.5
  2689. volume=volume=1/2
  2690. volume=volume=-6.0206dB
  2691. @end example
  2692. In all the above example the named key for @option{volume} can be
  2693. omitted, for example like in:
  2694. @example
  2695. volume=0.5
  2696. @end example
  2697. @item
  2698. Increase input audio power by 6 decibels using fixed-point precision:
  2699. @example
  2700. volume=volume=6dB:precision=fixed
  2701. @end example
  2702. @item
  2703. Fade volume after time 10 with an annihilation period of 5 seconds:
  2704. @example
  2705. volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
  2706. @end example
  2707. @end itemize
  2708. @section volumedetect
  2709. Detect the volume of the input video.
  2710. The filter has no parameters. The input is not modified. Statistics about
  2711. the volume will be printed in the log when the input stream end is reached.
  2712. In particular it will show the mean volume (root mean square), maximum
  2713. volume (on a per-sample basis), and the beginning of a histogram of the
  2714. registered volume values (from the maximum value to a cumulated 1/1000 of
  2715. the samples).
  2716. All volumes are in decibels relative to the maximum PCM value.
  2717. @subsection Examples
  2718. Here is an excerpt of the output:
  2719. @example
  2720. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  2721. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  2722. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  2723. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  2724. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  2725. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  2726. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  2727. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  2728. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  2729. @end example
  2730. It means that:
  2731. @itemize
  2732. @item
  2733. The mean square energy is approximately -27 dB, or 10^-2.7.
  2734. @item
  2735. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  2736. @item
  2737. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  2738. @end itemize
  2739. In other words, raising the volume by +4 dB does not cause any clipping,
  2740. raising it by +5 dB causes clipping for 6 samples, etc.
  2741. @c man end AUDIO FILTERS
  2742. @chapter Audio Sources
  2743. @c man begin AUDIO SOURCES
  2744. Below is a description of the currently available audio sources.
  2745. @section abuffer
  2746. Buffer audio frames, and make them available to the filter chain.
  2747. This source is mainly intended for a programmatic use, in particular
  2748. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  2749. It accepts the following parameters:
  2750. @table @option
  2751. @item time_base
  2752. The timebase which will be used for timestamps of submitted frames. It must be
  2753. either a floating-point number or in @var{numerator}/@var{denominator} form.
  2754. @item sample_rate
  2755. The sample rate of the incoming audio buffers.
  2756. @item sample_fmt
  2757. The sample format of the incoming audio buffers.
  2758. Either a sample format name or its corresponding integer representation from
  2759. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  2760. @item channel_layout
  2761. The channel layout of the incoming audio buffers.
  2762. Either a channel layout name from channel_layout_map in
  2763. @file{libavutil/channel_layout.c} or its corresponding integer representation
  2764. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  2765. @item channels
  2766. The number of channels of the incoming audio buffers.
  2767. If both @var{channels} and @var{channel_layout} are specified, then they
  2768. must be consistent.
  2769. @end table
  2770. @subsection Examples
  2771. @example
  2772. abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
  2773. @end example
  2774. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  2775. Since the sample format with name "s16p" corresponds to the number
  2776. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  2777. equivalent to:
  2778. @example
  2779. abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
  2780. @end example
  2781. @section aevalsrc
  2782. Generate an audio signal specified by an expression.
  2783. This source accepts in input one or more expressions (one for each
  2784. channel), which are evaluated and used to generate a corresponding
  2785. audio signal.
  2786. This source accepts the following options:
  2787. @table @option
  2788. @item exprs
  2789. Set the '|'-separated expressions list for each separate channel. In case the
  2790. @option{channel_layout} option is not specified, the selected channel layout
  2791. depends on the number of provided expressions. Otherwise the last
  2792. specified expression is applied to the remaining output channels.
  2793. @item channel_layout, c
  2794. Set the channel layout. The number of channels in the specified layout
  2795. must be equal to the number of specified expressions.
  2796. @item duration, d
  2797. Set the minimum duration of the sourced audio. See
  2798. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  2799. for the accepted syntax.
  2800. Note that the resulting duration may be greater than the specified
  2801. duration, as the generated audio is always cut at the end of a
  2802. complete frame.
  2803. If not specified, or the expressed duration is negative, the audio is
  2804. supposed to be generated forever.
  2805. @item nb_samples, n
  2806. Set the number of samples per channel per each output frame,
  2807. default to 1024.
  2808. @item sample_rate, s
  2809. Specify the sample rate, default to 44100.
  2810. @end table
  2811. Each expression in @var{exprs} can contain the following constants:
  2812. @table @option
  2813. @item n
  2814. number of the evaluated sample, starting from 0
  2815. @item t
  2816. time of the evaluated sample expressed in seconds, starting from 0
  2817. @item s
  2818. sample rate
  2819. @end table
  2820. @subsection Examples
  2821. @itemize
  2822. @item
  2823. Generate silence:
  2824. @example
  2825. aevalsrc=0
  2826. @end example
  2827. @item
  2828. Generate a sin signal with frequency of 440 Hz, set sample rate to
  2829. 8000 Hz:
  2830. @example
  2831. aevalsrc="sin(440*2*PI*t):s=8000"
  2832. @end example
  2833. @item
  2834. Generate a two channels signal, specify the channel layout (Front
  2835. Center + Back Center) explicitly:
  2836. @example
  2837. aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
  2838. @end example
  2839. @item
  2840. Generate white noise:
  2841. @example
  2842. aevalsrc="-2+random(0)"
  2843. @end example
  2844. @item
  2845. Generate an amplitude modulated signal:
  2846. @example
  2847. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  2848. @end example
  2849. @item
  2850. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  2851. @example
  2852. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
  2853. @end example
  2854. @end itemize
  2855. @section anullsrc
  2856. The null audio source, return unprocessed audio frames. It is mainly useful
  2857. as a template and to be employed in analysis / debugging tools, or as
  2858. the source for filters which ignore the input data (for example the sox
  2859. synth filter).
  2860. This source accepts the following options:
  2861. @table @option
  2862. @item channel_layout, cl
  2863. Specifies the channel layout, and can be either an integer or a string
  2864. representing a channel layout. The default value of @var{channel_layout}
  2865. is "stereo".
  2866. Check the channel_layout_map definition in
  2867. @file{libavutil/channel_layout.c} for the mapping between strings and
  2868. channel layout values.
  2869. @item sample_rate, r
  2870. Specifies the sample rate, and defaults to 44100.
  2871. @item nb_samples, n
  2872. Set the number of samples per requested frames.
  2873. @end table
  2874. @subsection Examples
  2875. @itemize
  2876. @item
  2877. Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  2878. @example
  2879. anullsrc=r=48000:cl=4
  2880. @end example
  2881. @item
  2882. Do the same operation with a more obvious syntax:
  2883. @example
  2884. anullsrc=r=48000:cl=mono
  2885. @end example
  2886. @end itemize
  2887. All the parameters need to be explicitly defined.
  2888. @section flite
  2889. Synthesize a voice utterance using the libflite library.
  2890. To enable compilation of this filter you need to configure FFmpeg with
  2891. @code{--enable-libflite}.
  2892. Note that the flite library is not thread-safe.
  2893. The filter accepts the following options:
  2894. @table @option
  2895. @item list_voices
  2896. If set to 1, list the names of the available voices and exit
  2897. immediately. Default value is 0.
  2898. @item nb_samples, n
  2899. Set the maximum number of samples per frame. Default value is 512.
  2900. @item textfile
  2901. Set the filename containing the text to speak.
  2902. @item text
  2903. Set the text to speak.
  2904. @item voice, v
  2905. Set the voice to use for the speech synthesis. Default value is
  2906. @code{kal}. See also the @var{list_voices} option.
  2907. @end table
  2908. @subsection Examples
  2909. @itemize
  2910. @item
  2911. Read from file @file{speech.txt}, and synthesize the text using the
  2912. standard flite voice:
  2913. @example
  2914. flite=textfile=speech.txt
  2915. @end example
  2916. @item
  2917. Read the specified text selecting the @code{slt} voice:
  2918. @example
  2919. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2920. @end example
  2921. @item
  2922. Input text to ffmpeg:
  2923. @example
  2924. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2925. @end example
  2926. @item
  2927. Make @file{ffplay} speak the specified text, using @code{flite} and
  2928. the @code{lavfi} device:
  2929. @example
  2930. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  2931. @end example
  2932. @end itemize
  2933. For more information about libflite, check:
  2934. @url{http://www.speech.cs.cmu.edu/flite/}
  2935. @section anoisesrc
  2936. Generate a noise audio signal.
  2937. The filter accepts the following options:
  2938. @table @option
  2939. @item sample_rate, r
  2940. Specify the sample rate. Default value is 48000 Hz.
  2941. @item amplitude, a
  2942. Specify the amplitude (0.0 - 1.0) of the generated audio stream. Default value
  2943. is 1.0.
  2944. @item duration, d
  2945. Specify the duration of the generated audio stream. Not specifying this option
  2946. results in noise with an infinite length.
  2947. @item color, colour, c
  2948. Specify the color of noise. Available noise colors are white, pink, and brown.
  2949. Default color is white.
  2950. @item seed, s
  2951. Specify a value used to seed the PRNG.
  2952. @item nb_samples, n
  2953. Set the number of samples per each output frame, default is 1024.
  2954. @end table
  2955. @subsection Examples
  2956. @itemize
  2957. @item
  2958. Generate 60 seconds of pink noise, with a 44.1 kHz sampling rate and an amplitude of 0.5:
  2959. @example
  2960. anoisesrc=d=60:c=pink:r=44100:a=0.5
  2961. @end example
  2962. @end itemize
  2963. @section sine
  2964. Generate an audio signal made of a sine wave with amplitude 1/8.
  2965. The audio signal is bit-exact.
  2966. The filter accepts the following options:
  2967. @table @option
  2968. @item frequency, f
  2969. Set the carrier frequency. Default is 440 Hz.
  2970. @item beep_factor, b
  2971. Enable a periodic beep every second with frequency @var{beep_factor} times
  2972. the carrier frequency. Default is 0, meaning the beep is disabled.
  2973. @item sample_rate, r
  2974. Specify the sample rate, default is 44100.
  2975. @item duration, d
  2976. Specify the duration of the generated audio stream.
  2977. @item samples_per_frame
  2978. Set the number of samples per output frame.
  2979. The expression can contain the following constants:
  2980. @table @option
  2981. @item n
  2982. The (sequential) number of the output audio frame, starting from 0.
  2983. @item pts
  2984. The PTS (Presentation TimeStamp) of the output audio frame,
  2985. expressed in @var{TB} units.
  2986. @item t
  2987. The PTS of the output audio frame, expressed in seconds.
  2988. @item TB
  2989. The timebase of the output audio frames.
  2990. @end table
  2991. Default is @code{1024}.
  2992. @end table
  2993. @subsection Examples
  2994. @itemize
  2995. @item
  2996. Generate a simple 440 Hz sine wave:
  2997. @example
  2998. sine
  2999. @end example
  3000. @item
  3001. Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
  3002. @example
  3003. sine=220:4:d=5
  3004. sine=f=220:b=4:d=5
  3005. sine=frequency=220:beep_factor=4:duration=5
  3006. @end example
  3007. @item
  3008. Generate a 1 kHz sine wave following @code{1602,1601,1602,1601,1602} NTSC
  3009. pattern:
  3010. @example
  3011. sine=1000:samples_per_frame='st(0,mod(n,5)); 1602-not(not(eq(ld(0),1)+eq(ld(0),3)))'
  3012. @end example
  3013. @end itemize
  3014. @c man end AUDIO SOURCES
  3015. @chapter Audio Sinks
  3016. @c man begin AUDIO SINKS
  3017. Below is a description of the currently available audio sinks.
  3018. @section abuffersink
  3019. Buffer audio frames, and make them available to the end of filter chain.
  3020. This sink is mainly intended for programmatic use, in particular
  3021. through the interface defined in @file{libavfilter/buffersink.h}
  3022. or the options system.
  3023. It accepts a pointer to an AVABufferSinkContext structure, which
  3024. defines the incoming buffers' formats, to be passed as the opaque
  3025. parameter to @code{avfilter_init_filter} for initialization.
  3026. @section anullsink
  3027. Null audio sink; do absolutely nothing with the input audio. It is
  3028. mainly useful as a template and for use in analysis / debugging
  3029. tools.
  3030. @c man end AUDIO SINKS
  3031. @chapter Video Filters
  3032. @c man begin VIDEO FILTERS
  3033. When you configure your FFmpeg build, you can disable any of the
  3034. existing filters using @code{--disable-filters}.
  3035. The configure output will show the video filters included in your
  3036. build.
  3037. Below is a description of the currently available video filters.
  3038. @section alphaextract
  3039. Extract the alpha component from the input as a grayscale video. This
  3040. is especially useful with the @var{alphamerge} filter.
  3041. @section alphamerge
  3042. Add or replace the alpha component of the primary input with the
  3043. grayscale value of a second input. This is intended for use with
  3044. @var{alphaextract} to allow the transmission or storage of frame
  3045. sequences that have alpha in a format that doesn't support an alpha
  3046. channel.
  3047. For example, to reconstruct full frames from a normal YUV-encoded video
  3048. and a separate video created with @var{alphaextract}, you might use:
  3049. @example
  3050. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  3051. @end example
  3052. Since this filter is designed for reconstruction, it operates on frame
  3053. sequences without considering timestamps, and terminates when either
  3054. input reaches end of stream. This will cause problems if your encoding
  3055. pipeline drops frames. If you're trying to apply an image as an
  3056. overlay to a video stream, consider the @var{overlay} filter instead.
  3057. @section ass
  3058. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  3059. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  3060. Substation Alpha) subtitles files.
  3061. This filter accepts the following option in addition to the common options from
  3062. the @ref{subtitles} filter:
  3063. @table @option
  3064. @item shaping
  3065. Set the shaping engine
  3066. Available values are:
  3067. @table @samp
  3068. @item auto
  3069. The default libass shaping engine, which is the best available.
  3070. @item simple
  3071. Fast, font-agnostic shaper that can do only substitutions
  3072. @item complex
  3073. Slower shaper using OpenType for substitutions and positioning
  3074. @end table
  3075. The default is @code{auto}.
  3076. @end table
  3077. @section atadenoise
  3078. Apply an Adaptive Temporal Averaging Denoiser to the video input.
  3079. The filter accepts the following options:
  3080. @table @option
  3081. @item 0a
  3082. Set threshold A for 1st plane. Default is 0.02.
  3083. Valid range is 0 to 0.3.
  3084. @item 0b
  3085. Set threshold B for 1st plane. Default is 0.04.
  3086. Valid range is 0 to 5.
  3087. @item 1a
  3088. Set threshold A for 2nd plane. Default is 0.02.
  3089. Valid range is 0 to 0.3.
  3090. @item 1b
  3091. Set threshold B for 2nd plane. Default is 0.04.
  3092. Valid range is 0 to 5.
  3093. @item 2a
  3094. Set threshold A for 3rd plane. Default is 0.02.
  3095. Valid range is 0 to 0.3.
  3096. @item 2b
  3097. Set threshold B for 3rd plane. Default is 0.04.
  3098. Valid range is 0 to 5.
  3099. Threshold A is designed to react on abrupt changes in the input signal and
  3100. threshold B is designed to react on continuous changes in the input signal.
  3101. @item s
  3102. Set number of frames filter will use for averaging. Default is 33. Must be odd
  3103. number in range [5, 129].
  3104. @end table
  3105. @section bbox
  3106. Compute the bounding box for the non-black pixels in the input frame
  3107. luminance plane.
  3108. This filter computes the bounding box containing all the pixels with a
  3109. luminance value greater than the minimum allowed value.
  3110. The parameters describing the bounding box are printed on the filter
  3111. log.
  3112. The filter accepts the following option:
  3113. @table @option
  3114. @item min_val
  3115. Set the minimal luminance value. Default is @code{16}.
  3116. @end table
  3117. @section blackdetect
  3118. Detect video intervals that are (almost) completely black. Can be
  3119. useful to detect chapter transitions, commercials, or invalid
  3120. recordings. Output lines contains the time for the start, end and
  3121. duration of the detected black interval expressed in seconds.
  3122. In order to display the output lines, you need to set the loglevel at
  3123. least to the AV_LOG_INFO value.
  3124. The filter accepts the following options:
  3125. @table @option
  3126. @item black_min_duration, d
  3127. Set the minimum detected black duration expressed in seconds. It must
  3128. be a non-negative floating point number.
  3129. Default value is 2.0.
  3130. @item picture_black_ratio_th, pic_th
  3131. Set the threshold for considering a picture "black".
  3132. Express the minimum value for the ratio:
  3133. @example
  3134. @var{nb_black_pixels} / @var{nb_pixels}
  3135. @end example
  3136. for which a picture is considered black.
  3137. Default value is 0.98.
  3138. @item pixel_black_th, pix_th
  3139. Set the threshold for considering a pixel "black".
  3140. The threshold expresses the maximum pixel luminance value for which a
  3141. pixel is considered "black". The provided value is scaled according to
  3142. the following equation:
  3143. @example
  3144. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  3145. @end example
  3146. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  3147. the input video format, the range is [0-255] for YUV full-range
  3148. formats and [16-235] for YUV non full-range formats.
  3149. Default value is 0.10.
  3150. @end table
  3151. The following example sets the maximum pixel threshold to the minimum
  3152. value, and detects only black intervals of 2 or more seconds:
  3153. @example
  3154. blackdetect=d=2:pix_th=0.00
  3155. @end example
  3156. @section blackframe
  3157. Detect frames that are (almost) completely black. Can be useful to
  3158. detect chapter transitions or commercials. Output lines consist of
  3159. the frame number of the detected frame, the percentage of blackness,
  3160. the position in the file if known or -1 and the timestamp in seconds.
  3161. In order to display the output lines, you need to set the loglevel at
  3162. least to the AV_LOG_INFO value.
  3163. It accepts the following parameters:
  3164. @table @option
  3165. @item amount
  3166. The percentage of the pixels that have to be below the threshold; it defaults to
  3167. @code{98}.
  3168. @item threshold, thresh
  3169. The threshold below which a pixel value is considered black; it defaults to
  3170. @code{32}.
  3171. @end table
  3172. @section blend, tblend
  3173. Blend two video frames into each other.
  3174. The @code{blend} filter takes two input streams and outputs one
  3175. stream, the first input is the "top" layer and second input is
  3176. "bottom" layer. Output terminates when shortest input terminates.
  3177. The @code{tblend} (time blend) filter takes two consecutive frames
  3178. from one single stream, and outputs the result obtained by blending
  3179. the new frame on top of the old frame.
  3180. A description of the accepted options follows.
  3181. @table @option
  3182. @item c0_mode
  3183. @item c1_mode
  3184. @item c2_mode
  3185. @item c3_mode
  3186. @item all_mode
  3187. Set blend mode for specific pixel component or all pixel components in case
  3188. of @var{all_mode}. Default value is @code{normal}.
  3189. Available values for component modes are:
  3190. @table @samp
  3191. @item addition
  3192. @item addition128
  3193. @item and
  3194. @item average
  3195. @item burn
  3196. @item darken
  3197. @item difference
  3198. @item difference128
  3199. @item divide
  3200. @item dodge
  3201. @item exclusion
  3202. @item glow
  3203. @item hardlight
  3204. @item hardmix
  3205. @item lighten
  3206. @item linearlight
  3207. @item multiply
  3208. @item multiply128
  3209. @item negation
  3210. @item normal
  3211. @item or
  3212. @item overlay
  3213. @item phoenix
  3214. @item pinlight
  3215. @item reflect
  3216. @item screen
  3217. @item softlight
  3218. @item subtract
  3219. @item vividlight
  3220. @item xor
  3221. @end table
  3222. @item c0_opacity
  3223. @item c1_opacity
  3224. @item c2_opacity
  3225. @item c3_opacity
  3226. @item all_opacity
  3227. Set blend opacity for specific pixel component or all pixel components in case
  3228. of @var{all_opacity}. Only used in combination with pixel component blend modes.
  3229. @item c0_expr
  3230. @item c1_expr
  3231. @item c2_expr
  3232. @item c3_expr
  3233. @item all_expr
  3234. Set blend expression for specific pixel component or all pixel components in case
  3235. of @var{all_expr}. Note that related mode options will be ignored if those are set.
  3236. The expressions can use the following variables:
  3237. @table @option
  3238. @item N
  3239. The sequential number of the filtered frame, starting from @code{0}.
  3240. @item X
  3241. @item Y
  3242. the coordinates of the current sample
  3243. @item W
  3244. @item H
  3245. the width and height of currently filtered plane
  3246. @item SW
  3247. @item SH
  3248. Width and height scale depending on the currently filtered plane. It is the
  3249. ratio between the corresponding luma plane number of pixels and the current
  3250. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  3251. @code{0.5,0.5} for chroma planes.
  3252. @item T
  3253. Time of the current frame, expressed in seconds.
  3254. @item TOP, A
  3255. Value of pixel component at current location for first video frame (top layer).
  3256. @item BOTTOM, B
  3257. Value of pixel component at current location for second video frame (bottom layer).
  3258. @end table
  3259. @item shortest
  3260. Force termination when the shortest input terminates. Default is
  3261. @code{0}. This option is only defined for the @code{blend} filter.
  3262. @item repeatlast
  3263. Continue applying the last bottom frame after the end of the stream. A value of
  3264. @code{0} disable the filter after the last frame of the bottom layer is reached.
  3265. Default is @code{1}. This option is only defined for the @code{blend} filter.
  3266. @end table
  3267. @subsection Examples
  3268. @itemize
  3269. @item
  3270. Apply transition from bottom layer to top layer in first 10 seconds:
  3271. @example
  3272. blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
  3273. @end example
  3274. @item
  3275. Apply 1x1 checkerboard effect:
  3276. @example
  3277. blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
  3278. @end example
  3279. @item
  3280. Apply uncover left effect:
  3281. @example
  3282. blend=all_expr='if(gte(N*SW+X,W),A,B)'
  3283. @end example
  3284. @item
  3285. Apply uncover down effect:
  3286. @example
  3287. blend=all_expr='if(gte(Y-N*SH,0),A,B)'
  3288. @end example
  3289. @item
  3290. Apply uncover up-left effect:
  3291. @example
  3292. blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
  3293. @end example
  3294. @item
  3295. Split diagonally video and shows top and bottom layer on each side:
  3296. @example
  3297. blend=all_expr=if(gt(X,Y*(W/H)),A,B)
  3298. @end example
  3299. @item
  3300. Display differences between the current and the previous frame:
  3301. @example
  3302. tblend=all_mode=difference128
  3303. @end example
  3304. @end itemize
  3305. @section bwdif
  3306. Deinterlace the input video ("bwdif" stands for "Bob Weaver
  3307. Deinterlacing Filter").
  3308. Motion adaptive deinterlacing based on yadif with the use of w3fdif and cubic
  3309. interpolation algorithms.
  3310. It accepts the following parameters:
  3311. @table @option
  3312. @item mode
  3313. The interlacing mode to adopt. It accepts one of the following values:
  3314. @table @option
  3315. @item 0, send_frame
  3316. Output one frame for each frame.
  3317. @item 1, send_field
  3318. Output one frame for each field.
  3319. @end table
  3320. The default value is @code{send_field}.
  3321. @item parity
  3322. The picture field parity assumed for the input interlaced video. It accepts one
  3323. of the following values:
  3324. @table @option
  3325. @item 0, tff
  3326. Assume the top field is first.
  3327. @item 1, bff
  3328. Assume the bottom field is first.
  3329. @item -1, auto
  3330. Enable automatic detection of field parity.
  3331. @end table
  3332. The default value is @code{auto}.
  3333. If the interlacing is unknown or the decoder does not export this information,
  3334. top field first will be assumed.
  3335. @item deint
  3336. Specify which frames to deinterlace. Accept one of the following
  3337. values:
  3338. @table @option
  3339. @item 0, all
  3340. Deinterlace all frames.
  3341. @item 1, interlaced
  3342. Only deinterlace frames marked as interlaced.
  3343. @end table
  3344. The default value is @code{all}.
  3345. @end table
  3346. @section boxblur
  3347. Apply a boxblur algorithm to the input video.
  3348. It accepts the following parameters:
  3349. @table @option
  3350. @item luma_radius, lr
  3351. @item luma_power, lp
  3352. @item chroma_radius, cr
  3353. @item chroma_power, cp
  3354. @item alpha_radius, ar
  3355. @item alpha_power, ap
  3356. @end table
  3357. A description of the accepted options follows.
  3358. @table @option
  3359. @item luma_radius, lr
  3360. @item chroma_radius, cr
  3361. @item alpha_radius, ar
  3362. Set an expression for the box radius in pixels used for blurring the
  3363. corresponding input plane.
  3364. The radius value must be a non-negative number, and must not be
  3365. greater than the value of the expression @code{min(w,h)/2} for the
  3366. luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
  3367. planes.
  3368. Default value for @option{luma_radius} is "2". If not specified,
  3369. @option{chroma_radius} and @option{alpha_radius} default to the
  3370. corresponding value set for @option{luma_radius}.
  3371. The expressions can contain the following constants:
  3372. @table @option
  3373. @item w
  3374. @item h
  3375. The input width and height in pixels.
  3376. @item cw
  3377. @item ch
  3378. The input chroma image width and height in pixels.
  3379. @item hsub
  3380. @item vsub
  3381. The horizontal and vertical chroma subsample values. For example, for the
  3382. pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
  3383. @end table
  3384. @item luma_power, lp
  3385. @item chroma_power, cp
  3386. @item alpha_power, ap
  3387. Specify how many times the boxblur filter is applied to the
  3388. corresponding plane.
  3389. Default value for @option{luma_power} is 2. If not specified,
  3390. @option{chroma_power} and @option{alpha_power} default to the
  3391. corresponding value set for @option{luma_power}.
  3392. A value of 0 will disable the effect.
  3393. @end table
  3394. @subsection Examples
  3395. @itemize
  3396. @item
  3397. Apply a boxblur filter with the luma, chroma, and alpha radii
  3398. set to 2:
  3399. @example
  3400. boxblur=luma_radius=2:luma_power=1
  3401. boxblur=2:1
  3402. @end example
  3403. @item
  3404. Set the luma radius to 2, and alpha and chroma radius to 0:
  3405. @example
  3406. boxblur=2:1:cr=0:ar=0
  3407. @end example
  3408. @item
  3409. Set the luma and chroma radii to a fraction of the video dimension:
  3410. @example
  3411. boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
  3412. @end example
  3413. @end itemize
  3414. @section chromakey
  3415. YUV colorspace color/chroma keying.
  3416. The filter accepts the following options:
  3417. @table @option
  3418. @item color
  3419. The color which will be replaced with transparency.
  3420. @item similarity
  3421. Similarity percentage with the key color.
  3422. 0.01 matches only the exact key color, while 1.0 matches everything.
  3423. @item blend
  3424. Blend percentage.
  3425. 0.0 makes pixels either fully transparent, or not transparent at all.
  3426. Higher values result in semi-transparent pixels, with a higher transparency
  3427. the more similar the pixels color is to the key color.
  3428. @item yuv
  3429. Signals that the color passed is already in YUV instead of RGB.
  3430. Litteral colors like "green" or "red" don't make sense with this enabled anymore.
  3431. This can be used to pass exact YUV values as hexadecimal numbers.
  3432. @end table
  3433. @subsection Examples
  3434. @itemize
  3435. @item
  3436. Make every green pixel in the input image transparent:
  3437. @example
  3438. ffmpeg -i input.png -vf chromakey=green out.png
  3439. @end example
  3440. @item
  3441. Overlay a greenscreen-video on top of a static black background.
  3442. @example
  3443. ffmpeg -f lavfi -i color=c=black:s=1280x720 -i video.mp4 -shortest -filter_complex "[1:v]chromakey=0x70de77:0.1:0.2[ckout];[0:v][ckout]overlay[out]" -map "[out]" output.mkv
  3444. @end example
  3445. @end itemize
  3446. @section codecview
  3447. Visualize information exported by some codecs.
  3448. Some codecs can export information through frames using side-data or other
  3449. means. For example, some MPEG based codecs export motion vectors through the
  3450. @var{export_mvs} flag in the codec @option{flags2} option.
  3451. The filter accepts the following option:
  3452. @table @option
  3453. @item mv
  3454. Set motion vectors to visualize.
  3455. Available flags for @var{mv} are:
  3456. @table @samp
  3457. @item pf
  3458. forward predicted MVs of P-frames
  3459. @item bf
  3460. forward predicted MVs of B-frames
  3461. @item bb
  3462. backward predicted MVs of B-frames
  3463. @end table
  3464. @item qp
  3465. Display quantization parameters using the chroma planes
  3466. @end table
  3467. @subsection Examples
  3468. @itemize
  3469. @item
  3470. Visualizes multi-directionals MVs from P and B-Frames using @command{ffplay}:
  3471. @example
  3472. ffplay -flags2 +export_mvs input.mpg -vf codecview=mv=pf+bf+bb
  3473. @end example
  3474. @end itemize
  3475. @section colorbalance
  3476. Modify intensity of primary colors (red, green and blue) of input frames.
  3477. The filter allows an input frame to be adjusted in the shadows, midtones or highlights
  3478. regions for the red-cyan, green-magenta or blue-yellow balance.
  3479. A positive adjustment value shifts the balance towards the primary color, a negative
  3480. value towards the complementary color.
  3481. The filter accepts the following options:
  3482. @table @option
  3483. @item rs
  3484. @item gs
  3485. @item bs
  3486. Adjust red, green and blue shadows (darkest pixels).
  3487. @item rm
  3488. @item gm
  3489. @item bm
  3490. Adjust red, green and blue midtones (medium pixels).
  3491. @item rh
  3492. @item gh
  3493. @item bh
  3494. Adjust red, green and blue highlights (brightest pixels).
  3495. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  3496. @end table
  3497. @subsection Examples
  3498. @itemize
  3499. @item
  3500. Add red color cast to shadows:
  3501. @example
  3502. colorbalance=rs=.3
  3503. @end example
  3504. @end itemize
  3505. @section colorkey
  3506. RGB colorspace color keying.
  3507. The filter accepts the following options:
  3508. @table @option
  3509. @item color
  3510. The color which will be replaced with transparency.
  3511. @item similarity
  3512. Similarity percentage with the key color.
  3513. 0.01 matches only the exact key color, while 1.0 matches everything.
  3514. @item blend
  3515. Blend percentage.
  3516. 0.0 makes pixels either fully transparent, or not transparent at all.
  3517. Higher values result in semi-transparent pixels, with a higher transparency
  3518. the more similar the pixels color is to the key color.
  3519. @end table
  3520. @subsection Examples
  3521. @itemize
  3522. @item
  3523. Make every green pixel in the input image transparent:
  3524. @example
  3525. ffmpeg -i input.png -vf colorkey=green out.png
  3526. @end example
  3527. @item
  3528. Overlay a greenscreen-video on top of a static background image.
  3529. @example
  3530. 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
  3531. @end example
  3532. @end itemize
  3533. @section colorlevels
  3534. Adjust video input frames using levels.
  3535. The filter accepts the following options:
  3536. @table @option
  3537. @item rimin
  3538. @item gimin
  3539. @item bimin
  3540. @item aimin
  3541. Adjust red, green, blue and alpha input black point.
  3542. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  3543. @item rimax
  3544. @item gimax
  3545. @item bimax
  3546. @item aimax
  3547. Adjust red, green, blue and alpha input white point.
  3548. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
  3549. Input levels are used to lighten highlights (bright tones), darken shadows
  3550. (dark tones), change the balance of bright and dark tones.
  3551. @item romin
  3552. @item gomin
  3553. @item bomin
  3554. @item aomin
  3555. Adjust red, green, blue and alpha output black point.
  3556. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
  3557. @item romax
  3558. @item gomax
  3559. @item bomax
  3560. @item aomax
  3561. Adjust red, green, blue and alpha output white point.
  3562. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
  3563. Output levels allows manual selection of a constrained output level range.
  3564. @end table
  3565. @subsection Examples
  3566. @itemize
  3567. @item
  3568. Make video output darker:
  3569. @example
  3570. colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
  3571. @end example
  3572. @item
  3573. Increase contrast:
  3574. @example
  3575. colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
  3576. @end example
  3577. @item
  3578. Make video output lighter:
  3579. @example
  3580. colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
  3581. @end example
  3582. @item
  3583. Increase brightness:
  3584. @example
  3585. colorlevels=romin=0.5:gomin=0.5:bomin=0.5
  3586. @end example
  3587. @end itemize
  3588. @section colorchannelmixer
  3589. Adjust video input frames by re-mixing color channels.
  3590. This filter modifies a color channel by adding the values associated to
  3591. the other channels of the same pixels. For example if the value to
  3592. modify is red, the output value will be:
  3593. @example
  3594. @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
  3595. @end example
  3596. The filter accepts the following options:
  3597. @table @option
  3598. @item rr
  3599. @item rg
  3600. @item rb
  3601. @item ra
  3602. Adjust contribution of input red, green, blue and alpha channels for output red channel.
  3603. Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
  3604. @item gr
  3605. @item gg
  3606. @item gb
  3607. @item ga
  3608. Adjust contribution of input red, green, blue and alpha channels for output green channel.
  3609. Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
  3610. @item br
  3611. @item bg
  3612. @item bb
  3613. @item ba
  3614. Adjust contribution of input red, green, blue and alpha channels for output blue channel.
  3615. Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
  3616. @item ar
  3617. @item ag
  3618. @item ab
  3619. @item aa
  3620. Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
  3621. Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
  3622. Allowed ranges for options are @code{[-2.0, 2.0]}.
  3623. @end table
  3624. @subsection Examples
  3625. @itemize
  3626. @item
  3627. Convert source to grayscale:
  3628. @example
  3629. colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
  3630. @end example
  3631. @item
  3632. Simulate sepia tones:
  3633. @example
  3634. colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
  3635. @end example
  3636. @end itemize
  3637. @section colormatrix
  3638. Convert color matrix.
  3639. The filter accepts the following options:
  3640. @table @option
  3641. @item src
  3642. @item dst
  3643. Specify the source and destination color matrix. Both values must be
  3644. specified.
  3645. The accepted values are:
  3646. @table @samp
  3647. @item bt709
  3648. BT.709
  3649. @item bt601
  3650. BT.601
  3651. @item smpte240m
  3652. SMPTE-240M
  3653. @item fcc
  3654. FCC
  3655. @end table
  3656. @end table
  3657. For example to convert from BT.601 to SMPTE-240M, use the command:
  3658. @example
  3659. colormatrix=bt601:smpte240m
  3660. @end example
  3661. @section convolution
  3662. Apply convolution 3x3 or 5x5 filter.
  3663. The filter accepts the following options:
  3664. @table @option
  3665. @item 0m
  3666. @item 1m
  3667. @item 2m
  3668. @item 3m
  3669. Set matrix for each plane.
  3670. Matrix is sequence of 9 or 25 signed integers.
  3671. @item 0rdiv
  3672. @item 1rdiv
  3673. @item 2rdiv
  3674. @item 3rdiv
  3675. Set multiplier for calculated value for each plane.
  3676. @item 0bias
  3677. @item 1bias
  3678. @item 2bias
  3679. @item 3bias
  3680. Set bias for each plane. This value is added to the result of the multiplication.
  3681. Useful for making the overall image brighter or darker. Default is 0.0.
  3682. @end table
  3683. @subsection Examples
  3684. @itemize
  3685. @item
  3686. Apply sharpen:
  3687. @example
  3688. convolution="0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0"
  3689. @end example
  3690. @item
  3691. Apply blur:
  3692. @example
  3693. convolution="1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1/9:1/9:1/9:1/9"
  3694. @end example
  3695. @item
  3696. Apply edge enhance:
  3697. @example
  3698. convolution="0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:5:1:1:1:0:128:128:128"
  3699. @end example
  3700. @item
  3701. Apply edge detect:
  3702. @example
  3703. convolution="0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:5:5:5:1:0:128:128:128"
  3704. @end example
  3705. @item
  3706. Apply emboss:
  3707. @example
  3708. convolution="-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2"
  3709. @end example
  3710. @end itemize
  3711. @section copy
  3712. Copy the input source unchanged to the output. This is mainly useful for
  3713. testing purposes.
  3714. @section crop
  3715. Crop the input video to given dimensions.
  3716. It accepts the following parameters:
  3717. @table @option
  3718. @item w, out_w
  3719. The width of the output video. It defaults to @code{iw}.
  3720. This expression is evaluated only once during the filter
  3721. configuration, or when the @samp{w} or @samp{out_w} command is sent.
  3722. @item h, out_h
  3723. The height of the output video. It defaults to @code{ih}.
  3724. This expression is evaluated only once during the filter
  3725. configuration, or when the @samp{h} or @samp{out_h} command is sent.
  3726. @item x
  3727. The horizontal position, in the input video, of the left edge of the output
  3728. video. It defaults to @code{(in_w-out_w)/2}.
  3729. This expression is evaluated per-frame.
  3730. @item y
  3731. The vertical position, in the input video, of the top edge of the output video.
  3732. It defaults to @code{(in_h-out_h)/2}.
  3733. This expression is evaluated per-frame.
  3734. @item keep_aspect
  3735. If set to 1 will force the output display aspect ratio
  3736. to be the same of the input, by changing the output sample aspect
  3737. ratio. It defaults to 0.
  3738. @end table
  3739. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  3740. expressions containing the following constants:
  3741. @table @option
  3742. @item x
  3743. @item y
  3744. The computed values for @var{x} and @var{y}. They are evaluated for
  3745. each new frame.
  3746. @item in_w
  3747. @item in_h
  3748. The input width and height.
  3749. @item iw
  3750. @item ih
  3751. These are the same as @var{in_w} and @var{in_h}.
  3752. @item out_w
  3753. @item out_h
  3754. The output (cropped) width and height.
  3755. @item ow
  3756. @item oh
  3757. These are the same as @var{out_w} and @var{out_h}.
  3758. @item a
  3759. same as @var{iw} / @var{ih}
  3760. @item sar
  3761. input sample aspect ratio
  3762. @item dar
  3763. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  3764. @item hsub
  3765. @item vsub
  3766. horizontal and vertical chroma subsample values. For example for the
  3767. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3768. @item n
  3769. The number of the input frame, starting from 0.
  3770. @item pos
  3771. the position in the file of the input frame, NAN if unknown
  3772. @item t
  3773. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  3774. @end table
  3775. The expression for @var{out_w} may depend on the value of @var{out_h},
  3776. and the expression for @var{out_h} may depend on @var{out_w}, but they
  3777. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  3778. evaluated after @var{out_w} and @var{out_h}.
  3779. The @var{x} and @var{y} parameters specify the expressions for the
  3780. position of the top-left corner of the output (non-cropped) area. They
  3781. are evaluated for each frame. If the evaluated value is not valid, it
  3782. is approximated to the nearest valid value.
  3783. The expression for @var{x} may depend on @var{y}, and the expression
  3784. for @var{y} may depend on @var{x}.
  3785. @subsection Examples
  3786. @itemize
  3787. @item
  3788. Crop area with size 100x100 at position (12,34).
  3789. @example
  3790. crop=100:100:12:34
  3791. @end example
  3792. Using named options, the example above becomes:
  3793. @example
  3794. crop=w=100:h=100:x=12:y=34
  3795. @end example
  3796. @item
  3797. Crop the central input area with size 100x100:
  3798. @example
  3799. crop=100:100
  3800. @end example
  3801. @item
  3802. Crop the central input area with size 2/3 of the input video:
  3803. @example
  3804. crop=2/3*in_w:2/3*in_h
  3805. @end example
  3806. @item
  3807. Crop the input video central square:
  3808. @example
  3809. crop=out_w=in_h
  3810. crop=in_h
  3811. @end example
  3812. @item
  3813. Delimit the rectangle with the top-left corner placed at position
  3814. 100:100 and the right-bottom corner corresponding to the right-bottom
  3815. corner of the input image.
  3816. @example
  3817. crop=in_w-100:in_h-100:100:100
  3818. @end example
  3819. @item
  3820. Crop 10 pixels from the left and right borders, and 20 pixels from
  3821. the top and bottom borders
  3822. @example
  3823. crop=in_w-2*10:in_h-2*20
  3824. @end example
  3825. @item
  3826. Keep only the bottom right quarter of the input image:
  3827. @example
  3828. crop=in_w/2:in_h/2:in_w/2:in_h/2
  3829. @end example
  3830. @item
  3831. Crop height for getting Greek harmony:
  3832. @example
  3833. crop=in_w:1/PHI*in_w
  3834. @end example
  3835. @item
  3836. Apply trembling effect:
  3837. @example
  3838. 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)
  3839. @end example
  3840. @item
  3841. Apply erratic camera effect depending on timestamp:
  3842. @example
  3843. 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)"
  3844. @end example
  3845. @item
  3846. Set x depending on the value of y:
  3847. @example
  3848. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  3849. @end example
  3850. @end itemize
  3851. @subsection Commands
  3852. This filter supports the following commands:
  3853. @table @option
  3854. @item w, out_w
  3855. @item h, out_h
  3856. @item x
  3857. @item y
  3858. Set width/height of the output video and the horizontal/vertical position
  3859. in the input video.
  3860. The command accepts the same syntax of the corresponding option.
  3861. If the specified expression is not valid, it is kept at its current
  3862. value.
  3863. @end table
  3864. @section cropdetect
  3865. Auto-detect the crop size.
  3866. It calculates the necessary cropping parameters and prints the
  3867. recommended parameters via the logging system. The detected dimensions
  3868. correspond to the non-black area of the input video.
  3869. It accepts the following parameters:
  3870. @table @option
  3871. @item limit
  3872. Set higher black value threshold, which can be optionally specified
  3873. from nothing (0) to everything (255 for 8bit based formats). An intensity
  3874. value greater to the set value is considered non-black. It defaults to 24.
  3875. You can also specify a value between 0.0 and 1.0 which will be scaled depending
  3876. on the bitdepth of the pixel format.
  3877. @item round
  3878. The value which the width/height should be divisible by. It defaults to
  3879. 16. The offset is automatically adjusted to center the video. Use 2 to
  3880. get only even dimensions (needed for 4:2:2 video). 16 is best when
  3881. encoding to most video codecs.
  3882. @item reset_count, reset
  3883. Set the counter that determines after how many frames cropdetect will
  3884. reset the previously detected largest video area and start over to
  3885. detect the current optimal crop area. Default value is 0.
  3886. This can be useful when channel logos distort the video area. 0
  3887. indicates 'never reset', and returns the largest area encountered during
  3888. playback.
  3889. @end table
  3890. @anchor{curves}
  3891. @section curves
  3892. Apply color adjustments using curves.
  3893. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  3894. component (red, green and blue) has its values defined by @var{N} key points
  3895. tied from each other using a smooth curve. The x-axis represents the pixel
  3896. values from the input frame, and the y-axis the new pixel values to be set for
  3897. the output frame.
  3898. By default, a component curve is defined by the two points @var{(0;0)} and
  3899. @var{(1;1)}. This creates a straight line where each original pixel value is
  3900. "adjusted" to its own value, which means no change to the image.
  3901. The filter allows you to redefine these two points and add some more. A new
  3902. curve (using a natural cubic spline interpolation) will be define to pass
  3903. smoothly through all these new coordinates. The new defined points needs to be
  3904. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  3905. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  3906. the vector spaces, the values will be clipped accordingly.
  3907. If there is no key point defined in @code{x=0}, the filter will automatically
  3908. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  3909. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  3910. The filter accepts the following options:
  3911. @table @option
  3912. @item preset
  3913. Select one of the available color presets. This option can be used in addition
  3914. to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
  3915. options takes priority on the preset values.
  3916. Available presets are:
  3917. @table @samp
  3918. @item none
  3919. @item color_negative
  3920. @item cross_process
  3921. @item darker
  3922. @item increase_contrast
  3923. @item lighter
  3924. @item linear_contrast
  3925. @item medium_contrast
  3926. @item negative
  3927. @item strong_contrast
  3928. @item vintage
  3929. @end table
  3930. Default is @code{none}.
  3931. @item master, m
  3932. Set the master key points. These points will define a second pass mapping. It
  3933. is sometimes called a "luminance" or "value" mapping. It can be used with
  3934. @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
  3935. post-processing LUT.
  3936. @item red, r
  3937. Set the key points for the red component.
  3938. @item green, g
  3939. Set the key points for the green component.
  3940. @item blue, b
  3941. Set the key points for the blue component.
  3942. @item all
  3943. Set the key points for all components (not including master).
  3944. Can be used in addition to the other key points component
  3945. options. In this case, the unset component(s) will fallback on this
  3946. @option{all} setting.
  3947. @item psfile
  3948. Specify a Photoshop curves file (@code{.acv}) to import the settings from.
  3949. @end table
  3950. To avoid some filtergraph syntax conflicts, each key points list need to be
  3951. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  3952. @subsection Examples
  3953. @itemize
  3954. @item
  3955. Increase slightly the middle level of blue:
  3956. @example
  3957. curves=blue='0.5/0.58'
  3958. @end example
  3959. @item
  3960. Vintage effect:
  3961. @example
  3962. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  3963. @end example
  3964. Here we obtain the following coordinates for each components:
  3965. @table @var
  3966. @item red
  3967. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  3968. @item green
  3969. @code{(0;0) (0.50;0.48) (1;1)}
  3970. @item blue
  3971. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  3972. @end table
  3973. @item
  3974. The previous example can also be achieved with the associated built-in preset:
  3975. @example
  3976. curves=preset=vintage
  3977. @end example
  3978. @item
  3979. Or simply:
  3980. @example
  3981. curves=vintage
  3982. @end example
  3983. @item
  3984. Use a Photoshop preset and redefine the points of the green component:
  3985. @example
  3986. curves=psfile='MyCurvesPresets/purple.acv':green='0.45/0.53'
  3987. @end example
  3988. @end itemize
  3989. @section dctdnoiz
  3990. Denoise frames using 2D DCT (frequency domain filtering).
  3991. This filter is not designed for real time.
  3992. The filter accepts the following options:
  3993. @table @option
  3994. @item sigma, s
  3995. Set the noise sigma constant.
  3996. This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
  3997. coefficient (absolute value) below this threshold with be dropped.
  3998. If you need a more advanced filtering, see @option{expr}.
  3999. Default is @code{0}.
  4000. @item overlap
  4001. Set number overlapping pixels for each block. Since the filter can be slow, you
  4002. may want to reduce this value, at the cost of a less effective filter and the
  4003. risk of various artefacts.
  4004. If the overlapping value doesn't permit processing the whole input width or
  4005. height, a warning will be displayed and according borders won't be denoised.
  4006. Default value is @var{blocksize}-1, which is the best possible setting.
  4007. @item expr, e
  4008. Set the coefficient factor expression.
  4009. For each coefficient of a DCT block, this expression will be evaluated as a
  4010. multiplier value for the coefficient.
  4011. If this is option is set, the @option{sigma} option will be ignored.
  4012. The absolute value of the coefficient can be accessed through the @var{c}
  4013. variable.
  4014. @item n
  4015. Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
  4016. @var{blocksize}, which is the width and height of the processed blocks.
  4017. The default value is @var{3} (8x8) and can be raised to @var{4} for a
  4018. @var{blocksize} of 16x16. Note that changing this setting has huge consequences
  4019. on the speed processing. Also, a larger block size does not necessarily means a
  4020. better de-noising.
  4021. @end table
  4022. @subsection Examples
  4023. Apply a denoise with a @option{sigma} of @code{4.5}:
  4024. @example
  4025. dctdnoiz=4.5
  4026. @end example
  4027. The same operation can be achieved using the expression system:
  4028. @example
  4029. dctdnoiz=e='gte(c, 4.5*3)'
  4030. @end example
  4031. Violent denoise using a block size of @code{16x16}:
  4032. @example
  4033. dctdnoiz=15:n=4
  4034. @end example
  4035. @section deband
  4036. Remove banding artifacts from input video.
  4037. It works by replacing banded pixels with average value of referenced pixels.
  4038. The filter accepts the following options:
  4039. @table @option
  4040. @item 1thr
  4041. @item 2thr
  4042. @item 3thr
  4043. @item 4thr
  4044. Set banding detection threshold for each plane. Default is 0.02.
  4045. Valid range is 0.00003 to 0.5.
  4046. If difference between current pixel and reference pixel is less than threshold,
  4047. it will be considered as banded.
  4048. @item range, r
  4049. Banding detection range in pixels. Default is 16. If positive, random number
  4050. in range 0 to set value will be used. If negative, exact absolute value
  4051. will be used.
  4052. The range defines square of four pixels around current pixel.
  4053. @item direction, d
  4054. Set direction in radians from which four pixel will be compared. If positive,
  4055. random direction from 0 to set direction will be picked. If negative, exact of
  4056. absolute value will be picked. For example direction 0, -PI or -2*PI radians
  4057. will pick only pixels on same row and -PI/2 will pick only pixels on same
  4058. column.
  4059. @item blur
  4060. If enabled, current pixel is compared with average value of all four
  4061. surrounding pixels. The default is enabled. If disabled current pixel is
  4062. compared with all four surrounding pixels. The pixel is considered banded
  4063. if only all four differences with surrounding pixels are less than threshold.
  4064. @end table
  4065. @anchor{decimate}
  4066. @section decimate
  4067. Drop duplicated frames at regular intervals.
  4068. The filter accepts the following options:
  4069. @table @option
  4070. @item cycle
  4071. Set the number of frames from which one will be dropped. Setting this to
  4072. @var{N} means one frame in every batch of @var{N} frames will be dropped.
  4073. Default is @code{5}.
  4074. @item dupthresh
  4075. Set the threshold for duplicate detection. If the difference metric for a frame
  4076. is less than or equal to this value, then it is declared as duplicate. Default
  4077. is @code{1.1}
  4078. @item scthresh
  4079. Set scene change threshold. Default is @code{15}.
  4080. @item blockx
  4081. @item blocky
  4082. Set the size of the x and y-axis blocks used during metric calculations.
  4083. Larger blocks give better noise suppression, but also give worse detection of
  4084. small movements. Must be a power of two. Default is @code{32}.
  4085. @item ppsrc
  4086. Mark main input as a pre-processed input and activate clean source input
  4087. stream. This allows the input to be pre-processed with various filters to help
  4088. the metrics calculation while keeping the frame selection lossless. When set to
  4089. @code{1}, the first stream is for the pre-processed input, and the second
  4090. stream is the clean source from where the kept frames are chosen. Default is
  4091. @code{0}.
  4092. @item chroma
  4093. Set whether or not chroma is considered in the metric calculations. Default is
  4094. @code{1}.
  4095. @end table
  4096. @section deflate
  4097. Apply deflate effect to the video.
  4098. This filter replaces the pixel by the local(3x3) average by taking into account
  4099. only values lower than the pixel.
  4100. It accepts the following options:
  4101. @table @option
  4102. @item threshold0
  4103. @item threshold1
  4104. @item threshold2
  4105. @item threshold3
  4106. Limit the maximum change for each plane, default is 65535.
  4107. If 0, plane will remain unchanged.
  4108. @end table
  4109. @section dejudder
  4110. Remove judder produced by partially interlaced telecined content.
  4111. Judder can be introduced, for instance, by @ref{pullup} filter. If the original
  4112. source was partially telecined content then the output of @code{pullup,dejudder}
  4113. will have a variable frame rate. May change the recorded frame rate of the
  4114. container. Aside from that change, this filter will not affect constant frame
  4115. rate video.
  4116. The option available in this filter is:
  4117. @table @option
  4118. @item cycle
  4119. Specify the length of the window over which the judder repeats.
  4120. Accepts any integer greater than 1. Useful values are:
  4121. @table @samp
  4122. @item 4
  4123. If the original was telecined from 24 to 30 fps (Film to NTSC).
  4124. @item 5
  4125. If the original was telecined from 25 to 30 fps (PAL to NTSC).
  4126. @item 20
  4127. If a mixture of the two.
  4128. @end table
  4129. The default is @samp{4}.
  4130. @end table
  4131. @section delogo
  4132. Suppress a TV station logo by a simple interpolation of the surrounding
  4133. pixels. Just set a rectangle covering the logo and watch it disappear
  4134. (and sometimes something even uglier appear - your mileage may vary).
  4135. It accepts the following parameters:
  4136. @table @option
  4137. @item x
  4138. @item y
  4139. Specify the top left corner coordinates of the logo. They must be
  4140. specified.
  4141. @item w
  4142. @item h
  4143. Specify the width and height of the logo to clear. They must be
  4144. specified.
  4145. @item band, t
  4146. Specify the thickness of the fuzzy edge of the rectangle (added to
  4147. @var{w} and @var{h}). The default value is 1. This option is
  4148. deprecated, setting higher values should no longer be necessary and
  4149. is not recommended.
  4150. @item show
  4151. When set to 1, a green rectangle is drawn on the screen to simplify
  4152. finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
  4153. The default value is 0.
  4154. The rectangle is drawn on the outermost pixels which will be (partly)
  4155. replaced with interpolated values. The values of the next pixels
  4156. immediately outside this rectangle in each direction will be used to
  4157. compute the interpolated pixel values inside the rectangle.
  4158. @end table
  4159. @subsection Examples
  4160. @itemize
  4161. @item
  4162. Set a rectangle covering the area with top left corner coordinates 0,0
  4163. and size 100x77, and a band of size 10:
  4164. @example
  4165. delogo=x=0:y=0:w=100:h=77:band=10
  4166. @end example
  4167. @end itemize
  4168. @section deshake
  4169. Attempt to fix small changes in horizontal and/or vertical shift. This
  4170. filter helps remove camera shake from hand-holding a camera, bumping a
  4171. tripod, moving on a vehicle, etc.
  4172. The filter accepts the following options:
  4173. @table @option
  4174. @item x
  4175. @item y
  4176. @item w
  4177. @item h
  4178. Specify a rectangular area where to limit the search for motion
  4179. vectors.
  4180. If desired the search for motion vectors can be limited to a
  4181. rectangular area of the frame defined by its top left corner, width
  4182. and height. These parameters have the same meaning as the drawbox
  4183. filter which can be used to visualise the position of the bounding
  4184. box.
  4185. This is useful when simultaneous movement of subjects within the frame
  4186. might be confused for camera motion by the motion vector search.
  4187. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  4188. then the full frame is used. This allows later options to be set
  4189. without specifying the bounding box for the motion vector search.
  4190. Default - search the whole frame.
  4191. @item rx
  4192. @item ry
  4193. Specify the maximum extent of movement in x and y directions in the
  4194. range 0-64 pixels. Default 16.
  4195. @item edge
  4196. Specify how to generate pixels to fill blanks at the edge of the
  4197. frame. Available values are:
  4198. @table @samp
  4199. @item blank, 0
  4200. Fill zeroes at blank locations
  4201. @item original, 1
  4202. Original image at blank locations
  4203. @item clamp, 2
  4204. Extruded edge value at blank locations
  4205. @item mirror, 3
  4206. Mirrored edge at blank locations
  4207. @end table
  4208. Default value is @samp{mirror}.
  4209. @item blocksize
  4210. Specify the blocksize to use for motion search. Range 4-128 pixels,
  4211. default 8.
  4212. @item contrast
  4213. Specify the contrast threshold for blocks. Only blocks with more than
  4214. the specified contrast (difference between darkest and lightest
  4215. pixels) will be considered. Range 1-255, default 125.
  4216. @item search
  4217. Specify the search strategy. Available values are:
  4218. @table @samp
  4219. @item exhaustive, 0
  4220. Set exhaustive search
  4221. @item less, 1
  4222. Set less exhaustive search.
  4223. @end table
  4224. Default value is @samp{exhaustive}.
  4225. @item filename
  4226. If set then a detailed log of the motion search is written to the
  4227. specified file.
  4228. @item opencl
  4229. If set to 1, specify using OpenCL capabilities, only available if
  4230. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  4231. @end table
  4232. @section detelecine
  4233. Apply an exact inverse of the telecine operation. It requires a predefined
  4234. pattern specified using the pattern option which must be the same as that passed
  4235. to the telecine filter.
  4236. This filter accepts the following options:
  4237. @table @option
  4238. @item first_field
  4239. @table @samp
  4240. @item top, t
  4241. top field first
  4242. @item bottom, b
  4243. bottom field first
  4244. The default value is @code{top}.
  4245. @end table
  4246. @item pattern
  4247. A string of numbers representing the pulldown pattern you wish to apply.
  4248. The default value is @code{23}.
  4249. @item start_frame
  4250. A number representing position of the first frame with respect to the telecine
  4251. pattern. This is to be used if the stream is cut. The default value is @code{0}.
  4252. @end table
  4253. @section dilation
  4254. Apply dilation effect to the video.
  4255. This filter replaces the pixel by the local(3x3) maximum.
  4256. It accepts the following options:
  4257. @table @option
  4258. @item threshold0
  4259. @item threshold1
  4260. @item threshold2
  4261. @item threshold3
  4262. Limit the maximum change for each plane, default is 65535.
  4263. If 0, plane will remain unchanged.
  4264. @item coordinates
  4265. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  4266. pixels are used.
  4267. Flags to local 3x3 coordinates maps like this:
  4268. 1 2 3
  4269. 4 5
  4270. 6 7 8
  4271. @end table
  4272. @section displace
  4273. Displace pixels as indicated by second and third input stream.
  4274. It takes three input streams and outputs one stream, the first input is the
  4275. source, and second and third input are displacement maps.
  4276. The second input specifies how much to displace pixels along the
  4277. x-axis, while the third input specifies how much to displace pixels
  4278. along the y-axis.
  4279. If one of displacement map streams terminates, last frame from that
  4280. displacement map will be used.
  4281. Note that once generated, displacements maps can be reused over and over again.
  4282. A description of the accepted options follows.
  4283. @table @option
  4284. @item edge
  4285. Set displace behavior for pixels that are out of range.
  4286. Available values are:
  4287. @table @samp
  4288. @item blank
  4289. Missing pixels are replaced by black pixels.
  4290. @item smear
  4291. Adjacent pixels will spread out to replace missing pixels.
  4292. @item wrap
  4293. Out of range pixels are wrapped so they point to pixels of other side.
  4294. @end table
  4295. Default is @samp{smear}.
  4296. @end table
  4297. @subsection Examples
  4298. @itemize
  4299. @item
  4300. Add ripple effect to rgb input of video size hd720:
  4301. @example
  4302. ffmpeg -i INPUT -f lavfi -i nullsrc=s=hd720,lutrgb=128:128:128 -f lavfi -i nullsrc=s=hd720,geq='r=128+30*sin(2*PI*X/400+T):g=128+30*sin(2*PI*X/400+T):b=128+30*sin(2*PI*X/400+T)' -lavfi '[0][1][2]displace' OUTPUT
  4303. @end example
  4304. @item
  4305. Add wave effect to rgb input of video size hd720:
  4306. @example
  4307. ffmpeg -i INPUT -f lavfi -i nullsrc=hd720,geq='r=128+80*(sin(sqrt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2))/220*2*PI+T)):g=128+80*(sin(sqrt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2))/220*2*PI+T)):b=128+80*(sin(sqrt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2))/220*2*PI+T))' -lavfi '[1]split[x][y],[0][x][y]displace' OUTPUT
  4308. @end example
  4309. @end itemize
  4310. @section drawbox
  4311. Draw a colored box on the input image.
  4312. It accepts the following parameters:
  4313. @table @option
  4314. @item x
  4315. @item y
  4316. The expressions which specify the top left corner coordinates of the box. It defaults to 0.
  4317. @item width, w
  4318. @item height, h
  4319. The expressions which specify the width and height of the box; if 0 they are interpreted as
  4320. the input width and height. It defaults to 0.
  4321. @item color, c
  4322. Specify the color of the box to write. For the general syntax of this option,
  4323. check the "Color" section in the ffmpeg-utils manual. If the special
  4324. value @code{invert} is used, the box edge color is the same as the
  4325. video with inverted luma.
  4326. @item thickness, t
  4327. The expression which sets the thickness of the box edge. Default value is @code{3}.
  4328. See below for the list of accepted constants.
  4329. @end table
  4330. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  4331. following constants:
  4332. @table @option
  4333. @item dar
  4334. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  4335. @item hsub
  4336. @item vsub
  4337. horizontal and vertical chroma subsample values. For example for the
  4338. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4339. @item in_h, ih
  4340. @item in_w, iw
  4341. The input width and height.
  4342. @item sar
  4343. The input sample aspect ratio.
  4344. @item x
  4345. @item y
  4346. The x and y offset coordinates where the box is drawn.
  4347. @item w
  4348. @item h
  4349. The width and height of the drawn box.
  4350. @item t
  4351. The thickness of the drawn box.
  4352. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  4353. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  4354. @end table
  4355. @subsection Examples
  4356. @itemize
  4357. @item
  4358. Draw a black box around the edge of the input image:
  4359. @example
  4360. drawbox
  4361. @end example
  4362. @item
  4363. Draw a box with color red and an opacity of 50%:
  4364. @example
  4365. drawbox=10:20:200:60:red@@0.5
  4366. @end example
  4367. The previous example can be specified as:
  4368. @example
  4369. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  4370. @end example
  4371. @item
  4372. Fill the box with pink color:
  4373. @example
  4374. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  4375. @end example
  4376. @item
  4377. Draw a 2-pixel red 2.40:1 mask:
  4378. @example
  4379. 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
  4380. @end example
  4381. @end itemize
  4382. @section drawgraph, adrawgraph
  4383. Draw a graph using input video or audio metadata.
  4384. It accepts the following parameters:
  4385. @table @option
  4386. @item m1
  4387. Set 1st frame metadata key from which metadata values will be used to draw a graph.
  4388. @item fg1
  4389. Set 1st foreground color expression.
  4390. @item m2
  4391. Set 2nd frame metadata key from which metadata values will be used to draw a graph.
  4392. @item fg2
  4393. Set 2nd foreground color expression.
  4394. @item m3
  4395. Set 3rd frame metadata key from which metadata values will be used to draw a graph.
  4396. @item fg3
  4397. Set 3rd foreground color expression.
  4398. @item m4
  4399. Set 4th frame metadata key from which metadata values will be used to draw a graph.
  4400. @item fg4
  4401. Set 4th foreground color expression.
  4402. @item min
  4403. Set minimal value of metadata value.
  4404. @item max
  4405. Set maximal value of metadata value.
  4406. @item bg
  4407. Set graph background color. Default is white.
  4408. @item mode
  4409. Set graph mode.
  4410. Available values for mode is:
  4411. @table @samp
  4412. @item bar
  4413. @item dot
  4414. @item line
  4415. @end table
  4416. Default is @code{line}.
  4417. @item slide
  4418. Set slide mode.
  4419. Available values for slide is:
  4420. @table @samp
  4421. @item frame
  4422. Draw new frame when right border is reached.
  4423. @item replace
  4424. Replace old columns with new ones.
  4425. @item scroll
  4426. Scroll from right to left.
  4427. @item rscroll
  4428. Scroll from left to right.
  4429. @end table
  4430. Default is @code{frame}.
  4431. @item size
  4432. Set size of graph video. For the syntax of this option, check the
  4433. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  4434. The default value is @code{900x256}.
  4435. The foreground color expressions can use the following variables:
  4436. @table @option
  4437. @item MIN
  4438. Minimal value of metadata value.
  4439. @item MAX
  4440. Maximal value of metadata value.
  4441. @item VAL
  4442. Current metadata key value.
  4443. @end table
  4444. The color is defined as 0xAABBGGRR.
  4445. @end table
  4446. Example using metadata from @ref{signalstats} filter:
  4447. @example
  4448. signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255
  4449. @end example
  4450. Example using metadata from @ref{ebur128} filter:
  4451. @example
  4452. ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5
  4453. @end example
  4454. @section drawgrid
  4455. Draw a grid on the input image.
  4456. It accepts the following parameters:
  4457. @table @option
  4458. @item x
  4459. @item y
  4460. The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
  4461. @item width, w
  4462. @item height, h
  4463. The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
  4464. input width and height, respectively, minus @code{thickness}, so image gets
  4465. framed. Default to 0.
  4466. @item color, c
  4467. Specify the color of the grid. For the general syntax of this option,
  4468. check the "Color" section in the ffmpeg-utils manual. If the special
  4469. value @code{invert} is used, the grid color is the same as the
  4470. video with inverted luma.
  4471. @item thickness, t
  4472. The expression which sets the thickness of the grid line. Default value is @code{1}.
  4473. See below for the list of accepted constants.
  4474. @end table
  4475. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  4476. following constants:
  4477. @table @option
  4478. @item dar
  4479. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  4480. @item hsub
  4481. @item vsub
  4482. horizontal and vertical chroma subsample values. For example for the
  4483. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4484. @item in_h, ih
  4485. @item in_w, iw
  4486. The input grid cell width and height.
  4487. @item sar
  4488. The input sample aspect ratio.
  4489. @item x
  4490. @item y
  4491. The x and y coordinates of some point of grid intersection (meant to configure offset).
  4492. @item w
  4493. @item h
  4494. The width and height of the drawn cell.
  4495. @item t
  4496. The thickness of the drawn cell.
  4497. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  4498. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  4499. @end table
  4500. @subsection Examples
  4501. @itemize
  4502. @item
  4503. Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
  4504. @example
  4505. drawgrid=width=100:height=100:thickness=2:color=red@@0.5
  4506. @end example
  4507. @item
  4508. Draw a white 3x3 grid with an opacity of 50%:
  4509. @example
  4510. drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
  4511. @end example
  4512. @end itemize
  4513. @anchor{drawtext}
  4514. @section drawtext
  4515. Draw a text string or text from a specified file on top of a video, using the
  4516. libfreetype library.
  4517. To enable compilation of this filter, you need to configure FFmpeg with
  4518. @code{--enable-libfreetype}.
  4519. To enable default font fallback and the @var{font} option you need to
  4520. configure FFmpeg with @code{--enable-libfontconfig}.
  4521. To enable the @var{text_shaping} option, you need to configure FFmpeg with
  4522. @code{--enable-libfribidi}.
  4523. @subsection Syntax
  4524. It accepts the following parameters:
  4525. @table @option
  4526. @item box
  4527. Used to draw a box around text using the background color.
  4528. The value must be either 1 (enable) or 0 (disable).
  4529. The default value of @var{box} is 0.
  4530. @item boxborderw
  4531. Set the width of the border to be drawn around the box using @var{boxcolor}.
  4532. The default value of @var{boxborderw} is 0.
  4533. @item boxcolor
  4534. The color to be used for drawing box around text. For the syntax of this
  4535. option, check the "Color" section in the ffmpeg-utils manual.
  4536. The default value of @var{boxcolor} is "white".
  4537. @item borderw
  4538. Set the width of the border to be drawn around the text using @var{bordercolor}.
  4539. The default value of @var{borderw} is 0.
  4540. @item bordercolor
  4541. Set the color to be used for drawing border around text. For the syntax of this
  4542. option, check the "Color" section in the ffmpeg-utils manual.
  4543. The default value of @var{bordercolor} is "black".
  4544. @item expansion
  4545. Select how the @var{text} is expanded. Can be either @code{none},
  4546. @code{strftime} (deprecated) or
  4547. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  4548. below for details.
  4549. @item fix_bounds
  4550. If true, check and fix text coords to avoid clipping.
  4551. @item fontcolor
  4552. The color to be used for drawing fonts. For the syntax of this option, check
  4553. the "Color" section in the ffmpeg-utils manual.
  4554. The default value of @var{fontcolor} is "black".
  4555. @item fontcolor_expr
  4556. String which is expanded the same way as @var{text} to obtain dynamic
  4557. @var{fontcolor} value. By default this option has empty value and is not
  4558. processed. When this option is set, it overrides @var{fontcolor} option.
  4559. @item font
  4560. The font family to be used for drawing text. By default Sans.
  4561. @item fontfile
  4562. The font file to be used for drawing text. The path must be included.
  4563. This parameter is mandatory if the fontconfig support is disabled.
  4564. @item draw
  4565. This option does not exist, please see the timeline system
  4566. @item alpha
  4567. Draw the text applying alpha blending. The value can
  4568. be either a number between 0.0 and 1.0
  4569. The expression accepts the same variables @var{x, y} do.
  4570. The default value is 1.
  4571. Please see fontcolor_expr
  4572. @item fontsize
  4573. The font size to be used for drawing text.
  4574. The default value of @var{fontsize} is 16.
  4575. @item text_shaping
  4576. If set to 1, attempt to shape the text (for example, reverse the order of
  4577. right-to-left text and join Arabic characters) before drawing it.
  4578. Otherwise, just draw the text exactly as given.
  4579. By default 1 (if supported).
  4580. @item ft_load_flags
  4581. The flags to be used for loading the fonts.
  4582. The flags map the corresponding flags supported by libfreetype, and are
  4583. a combination of the following values:
  4584. @table @var
  4585. @item default
  4586. @item no_scale
  4587. @item no_hinting
  4588. @item render
  4589. @item no_bitmap
  4590. @item vertical_layout
  4591. @item force_autohint
  4592. @item crop_bitmap
  4593. @item pedantic
  4594. @item ignore_global_advance_width
  4595. @item no_recurse
  4596. @item ignore_transform
  4597. @item monochrome
  4598. @item linear_design
  4599. @item no_autohint
  4600. @end table
  4601. Default value is "default".
  4602. For more information consult the documentation for the FT_LOAD_*
  4603. libfreetype flags.
  4604. @item shadowcolor
  4605. The color to be used for drawing a shadow behind the drawn text. For the
  4606. syntax of this option, check the "Color" section in the ffmpeg-utils manual.
  4607. The default value of @var{shadowcolor} is "black".
  4608. @item shadowx
  4609. @item shadowy
  4610. The x and y offsets for the text shadow position with respect to the
  4611. position of the text. They can be either positive or negative
  4612. values. The default value for both is "0".
  4613. @item start_number
  4614. The starting frame number for the n/frame_num variable. The default value
  4615. is "0".
  4616. @item tabsize
  4617. The size in number of spaces to use for rendering the tab.
  4618. Default value is 4.
  4619. @item timecode
  4620. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  4621. format. It can be used with or without text parameter. @var{timecode_rate}
  4622. option must be specified.
  4623. @item timecode_rate, rate, r
  4624. Set the timecode frame rate (timecode only).
  4625. @item text
  4626. The text string to be drawn. The text must be a sequence of UTF-8
  4627. encoded characters.
  4628. This parameter is mandatory if no file is specified with the parameter
  4629. @var{textfile}.
  4630. @item textfile
  4631. A text file containing text to be drawn. The text must be a sequence
  4632. of UTF-8 encoded characters.
  4633. This parameter is mandatory if no text string is specified with the
  4634. parameter @var{text}.
  4635. If both @var{text} and @var{textfile} are specified, an error is thrown.
  4636. @item reload
  4637. If set to 1, the @var{textfile} will be reloaded before each frame.
  4638. Be sure to update it atomically, or it may be read partially, or even fail.
  4639. @item x
  4640. @item y
  4641. The expressions which specify the offsets where text will be drawn
  4642. within the video frame. They are relative to the top/left border of the
  4643. output image.
  4644. The default value of @var{x} and @var{y} is "0".
  4645. See below for the list of accepted constants and functions.
  4646. @end table
  4647. The parameters for @var{x} and @var{y} are expressions containing the
  4648. following constants and functions:
  4649. @table @option
  4650. @item dar
  4651. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  4652. @item hsub
  4653. @item vsub
  4654. horizontal and vertical chroma subsample values. For example for the
  4655. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4656. @item line_h, lh
  4657. the height of each text line
  4658. @item main_h, h, H
  4659. the input height
  4660. @item main_w, w, W
  4661. the input width
  4662. @item max_glyph_a, ascent
  4663. the maximum distance from the baseline to the highest/upper grid
  4664. coordinate used to place a glyph outline point, for all the rendered
  4665. glyphs.
  4666. It is a positive value, due to the grid's orientation with the Y axis
  4667. upwards.
  4668. @item max_glyph_d, descent
  4669. the maximum distance from the baseline to the lowest grid coordinate
  4670. used to place a glyph outline point, for all the rendered glyphs.
  4671. This is a negative value, due to the grid's orientation, with the Y axis
  4672. upwards.
  4673. @item max_glyph_h
  4674. maximum glyph height, that is the maximum height for all the glyphs
  4675. contained in the rendered text, it is equivalent to @var{ascent} -
  4676. @var{descent}.
  4677. @item max_glyph_w
  4678. maximum glyph width, that is the maximum width for all the glyphs
  4679. contained in the rendered text
  4680. @item n
  4681. the number of input frame, starting from 0
  4682. @item rand(min, max)
  4683. return a random number included between @var{min} and @var{max}
  4684. @item sar
  4685. The input sample aspect ratio.
  4686. @item t
  4687. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4688. @item text_h, th
  4689. the height of the rendered text
  4690. @item text_w, tw
  4691. the width of the rendered text
  4692. @item x
  4693. @item y
  4694. the x and y offset coordinates where the text is drawn.
  4695. These parameters allow the @var{x} and @var{y} expressions to refer
  4696. each other, so you can for example specify @code{y=x/dar}.
  4697. @end table
  4698. @anchor{drawtext_expansion}
  4699. @subsection Text expansion
  4700. If @option{expansion} is set to @code{strftime},
  4701. the filter recognizes strftime() sequences in the provided text and
  4702. expands them accordingly. Check the documentation of strftime(). This
  4703. feature is deprecated.
  4704. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  4705. If @option{expansion} is set to @code{normal} (which is the default),
  4706. the following expansion mechanism is used.
  4707. The backslash character @samp{\}, followed by any character, always expands to
  4708. the second character.
  4709. Sequence of the form @code{%@{...@}} are expanded. The text between the
  4710. braces is a function name, possibly followed by arguments separated by ':'.
  4711. If the arguments contain special characters or delimiters (':' or '@}'),
  4712. they should be escaped.
  4713. Note that they probably must also be escaped as the value for the
  4714. @option{text} option in the filter argument string and as the filter
  4715. argument in the filtergraph description, and possibly also for the shell,
  4716. that makes up to four levels of escaping; using a text file avoids these
  4717. problems.
  4718. The following functions are available:
  4719. @table @command
  4720. @item expr, e
  4721. The expression evaluation result.
  4722. It must take one argument specifying the expression to be evaluated,
  4723. which accepts the same constants and functions as the @var{x} and
  4724. @var{y} values. Note that not all constants should be used, for
  4725. example the text size is not known when evaluating the expression, so
  4726. the constants @var{text_w} and @var{text_h} will have an undefined
  4727. value.
  4728. @item expr_int_format, eif
  4729. Evaluate the expression's value and output as formatted integer.
  4730. The first argument is the expression to be evaluated, just as for the @var{expr} function.
  4731. The second argument specifies the output format. Allowed values are @samp{x},
  4732. @samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
  4733. @code{printf} function.
  4734. The third parameter is optional and sets the number of positions taken by the output.
  4735. It can be used to add padding with zeros from the left.
  4736. @item gmtime
  4737. The time at which the filter is running, expressed in UTC.
  4738. It can accept an argument: a strftime() format string.
  4739. @item localtime
  4740. The time at which the filter is running, expressed in the local time zone.
  4741. It can accept an argument: a strftime() format string.
  4742. @item metadata
  4743. Frame metadata. It must take one argument specifying metadata key.
  4744. @item n, frame_num
  4745. The frame number, starting from 0.
  4746. @item pict_type
  4747. A 1 character description of the current picture type.
  4748. @item pts
  4749. The timestamp of the current frame.
  4750. It can take up to three arguments.
  4751. The first argument is the format of the timestamp; it defaults to @code{flt}
  4752. for seconds as a decimal number with microsecond accuracy; @code{hms} stands
  4753. for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
  4754. @code{gmtime} stands for the timestamp of the frame formatted as UTC time;
  4755. @code{localtime} stands for the timestamp of the frame formatted as
  4756. local time zone time.
  4757. The second argument is an offset added to the timestamp.
  4758. If the format is set to @code{localtime} or @code{gmtime},
  4759. a third argument may be supplied: a strftime() format string.
  4760. By default, @var{YYYY-MM-DD HH:MM:SS} format will be used.
  4761. @end table
  4762. @subsection Examples
  4763. @itemize
  4764. @item
  4765. Draw "Test Text" with font FreeSerif, using the default values for the
  4766. optional parameters.
  4767. @example
  4768. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  4769. @end example
  4770. @item
  4771. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  4772. and y=50 (counting from the top-left corner of the screen), text is
  4773. yellow with a red box around it. Both the text and the box have an
  4774. opacity of 20%.
  4775. @example
  4776. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  4777. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  4778. @end example
  4779. Note that the double quotes are not necessary if spaces are not used
  4780. within the parameter list.
  4781. @item
  4782. Show the text at the center of the video frame:
  4783. @example
  4784. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2"
  4785. @end example
  4786. @item
  4787. Show a text line sliding from right to left in the last row of the video
  4788. frame. The file @file{LONG_LINE} is assumed to contain a single line
  4789. with no newlines.
  4790. @example
  4791. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  4792. @end example
  4793. @item
  4794. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  4795. @example
  4796. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  4797. @end example
  4798. @item
  4799. Draw a single green letter "g", at the center of the input video.
  4800. The glyph baseline is placed at half screen height.
  4801. @example
  4802. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  4803. @end example
  4804. @item
  4805. Show text for 1 second every 3 seconds:
  4806. @example
  4807. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  4808. @end example
  4809. @item
  4810. Use fontconfig to set the font. Note that the colons need to be escaped.
  4811. @example
  4812. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  4813. @end example
  4814. @item
  4815. Print the date of a real-time encoding (see strftime(3)):
  4816. @example
  4817. drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
  4818. @end example
  4819. @item
  4820. Show text fading in and out (appearing/disappearing):
  4821. @example
  4822. #!/bin/sh
  4823. DS=1.0 # display start
  4824. DE=10.0 # display end
  4825. FID=1.5 # fade in duration
  4826. FOD=5 # fade out duration
  4827. 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 @}"
  4828. @end example
  4829. @end itemize
  4830. For more information about libfreetype, check:
  4831. @url{http://www.freetype.org/}.
  4832. For more information about fontconfig, check:
  4833. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  4834. For more information about libfribidi, check:
  4835. @url{http://fribidi.org/}.
  4836. @section edgedetect
  4837. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  4838. The filter accepts the following options:
  4839. @table @option
  4840. @item low
  4841. @item high
  4842. Set low and high threshold values used by the Canny thresholding
  4843. algorithm.
  4844. The high threshold selects the "strong" edge pixels, which are then
  4845. connected through 8-connectivity with the "weak" edge pixels selected
  4846. by the low threshold.
  4847. @var{low} and @var{high} threshold values must be chosen in the range
  4848. [0,1], and @var{low} should be lesser or equal to @var{high}.
  4849. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  4850. is @code{50/255}.
  4851. @item mode
  4852. Define the drawing mode.
  4853. @table @samp
  4854. @item wires
  4855. Draw white/gray wires on black background.
  4856. @item colormix
  4857. Mix the colors to create a paint/cartoon effect.
  4858. @end table
  4859. Default value is @var{wires}.
  4860. @end table
  4861. @subsection Examples
  4862. @itemize
  4863. @item
  4864. Standard edge detection with custom values for the hysteresis thresholding:
  4865. @example
  4866. edgedetect=low=0.1:high=0.4
  4867. @end example
  4868. @item
  4869. Painting effect without thresholding:
  4870. @example
  4871. edgedetect=mode=colormix:high=0
  4872. @end example
  4873. @end itemize
  4874. @section eq
  4875. Set brightness, contrast, saturation and approximate gamma adjustment.
  4876. The filter accepts the following options:
  4877. @table @option
  4878. @item contrast
  4879. Set the contrast expression. The value must be a float value in range
  4880. @code{-2.0} to @code{2.0}. The default value is "1".
  4881. @item brightness
  4882. Set the brightness expression. The value must be a float value in
  4883. range @code{-1.0} to @code{1.0}. The default value is "0".
  4884. @item saturation
  4885. Set the saturation expression. The value must be a float in
  4886. range @code{0.0} to @code{3.0}. The default value is "1".
  4887. @item gamma
  4888. Set the gamma expression. The value must be a float in range
  4889. @code{0.1} to @code{10.0}. The default value is "1".
  4890. @item gamma_r
  4891. Set the gamma expression for red. The value must be a float in
  4892. range @code{0.1} to @code{10.0}. The default value is "1".
  4893. @item gamma_g
  4894. Set the gamma expression for green. The value must be a float in range
  4895. @code{0.1} to @code{10.0}. The default value is "1".
  4896. @item gamma_b
  4897. Set the gamma expression for blue. The value must be a float in range
  4898. @code{0.1} to @code{10.0}. The default value is "1".
  4899. @item gamma_weight
  4900. Set the gamma weight expression. It can be used to reduce the effect
  4901. of a high gamma value on bright image areas, e.g. keep them from
  4902. getting overamplified and just plain white. The value must be a float
  4903. in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
  4904. gamma correction all the way down while @code{1.0} leaves it at its
  4905. full strength. Default is "1".
  4906. @item eval
  4907. Set when the expressions for brightness, contrast, saturation and
  4908. gamma expressions are evaluated.
  4909. It accepts the following values:
  4910. @table @samp
  4911. @item init
  4912. only evaluate expressions once during the filter initialization or
  4913. when a command is processed
  4914. @item frame
  4915. evaluate expressions for each incoming frame
  4916. @end table
  4917. Default value is @samp{init}.
  4918. @end table
  4919. The expressions accept the following parameters:
  4920. @table @option
  4921. @item n
  4922. frame count of the input frame starting from 0
  4923. @item pos
  4924. byte position of the corresponding packet in the input file, NAN if
  4925. unspecified
  4926. @item r
  4927. frame rate of the input video, NAN if the input frame rate is unknown
  4928. @item t
  4929. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4930. @end table
  4931. @subsection Commands
  4932. The filter supports the following commands:
  4933. @table @option
  4934. @item contrast
  4935. Set the contrast expression.
  4936. @item brightness
  4937. Set the brightness expression.
  4938. @item saturation
  4939. Set the saturation expression.
  4940. @item gamma
  4941. Set the gamma expression.
  4942. @item gamma_r
  4943. Set the gamma_r expression.
  4944. @item gamma_g
  4945. Set gamma_g expression.
  4946. @item gamma_b
  4947. Set gamma_b expression.
  4948. @item gamma_weight
  4949. Set gamma_weight expression.
  4950. The command accepts the same syntax of the corresponding option.
  4951. If the specified expression is not valid, it is kept at its current
  4952. value.
  4953. @end table
  4954. @section erosion
  4955. Apply erosion effect to the video.
  4956. This filter replaces the pixel by the local(3x3) minimum.
  4957. It accepts the following options:
  4958. @table @option
  4959. @item threshold0
  4960. @item threshold1
  4961. @item threshold2
  4962. @item threshold3
  4963. Limit the maximum change for each plane, default is 65535.
  4964. If 0, plane will remain unchanged.
  4965. @item coordinates
  4966. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  4967. pixels are used.
  4968. Flags to local 3x3 coordinates maps like this:
  4969. 1 2 3
  4970. 4 5
  4971. 6 7 8
  4972. @end table
  4973. @section extractplanes
  4974. Extract color channel components from input video stream into
  4975. separate grayscale video streams.
  4976. The filter accepts the following option:
  4977. @table @option
  4978. @item planes
  4979. Set plane(s) to extract.
  4980. Available values for planes are:
  4981. @table @samp
  4982. @item y
  4983. @item u
  4984. @item v
  4985. @item a
  4986. @item r
  4987. @item g
  4988. @item b
  4989. @end table
  4990. Choosing planes not available in the input will result in an error.
  4991. That means you cannot select @code{r}, @code{g}, @code{b} planes
  4992. with @code{y}, @code{u}, @code{v} planes at same time.
  4993. @end table
  4994. @subsection Examples
  4995. @itemize
  4996. @item
  4997. Extract luma, u and v color channel component from input video frame
  4998. into 3 grayscale outputs:
  4999. @example
  5000. 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
  5001. @end example
  5002. @end itemize
  5003. @section elbg
  5004. Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
  5005. For each input image, the filter will compute the optimal mapping from
  5006. the input to the output given the codebook length, that is the number
  5007. of distinct output colors.
  5008. This filter accepts the following options.
  5009. @table @option
  5010. @item codebook_length, l
  5011. Set codebook length. The value must be a positive integer, and
  5012. represents the number of distinct output colors. Default value is 256.
  5013. @item nb_steps, n
  5014. Set the maximum number of iterations to apply for computing the optimal
  5015. mapping. The higher the value the better the result and the higher the
  5016. computation time. Default value is 1.
  5017. @item seed, s
  5018. Set a random seed, must be an integer included between 0 and
  5019. UINT32_MAX. If not specified, or if explicitly set to -1, the filter
  5020. will try to use a good random seed on a best effort basis.
  5021. @item pal8
  5022. Set pal8 output pixel format. This option does not work with codebook
  5023. length greater than 256.
  5024. @end table
  5025. @section fade
  5026. Apply a fade-in/out effect to the input video.
  5027. It accepts the following parameters:
  5028. @table @option
  5029. @item type, t
  5030. The effect type can be either "in" for a fade-in, or "out" for a fade-out
  5031. effect.
  5032. Default is @code{in}.
  5033. @item start_frame, s
  5034. Specify the number of the frame to start applying the fade
  5035. effect at. Default is 0.
  5036. @item nb_frames, n
  5037. The number of frames that the fade effect lasts. At the end of the
  5038. fade-in effect, the output video will have the same intensity as the input video.
  5039. At the end of the fade-out transition, the output video will be filled with the
  5040. selected @option{color}.
  5041. Default is 25.
  5042. @item alpha
  5043. If set to 1, fade only alpha channel, if one exists on the input.
  5044. Default value is 0.
  5045. @item start_time, st
  5046. Specify the timestamp (in seconds) of the frame to start to apply the fade
  5047. effect. If both start_frame and start_time are specified, the fade will start at
  5048. whichever comes last. Default is 0.
  5049. @item duration, d
  5050. The number of seconds for which the fade effect has to last. At the end of the
  5051. fade-in effect the output video will have the same intensity as the input video,
  5052. at the end of the fade-out transition the output video will be filled with the
  5053. selected @option{color}.
  5054. If both duration and nb_frames are specified, duration is used. Default is 0
  5055. (nb_frames is used by default).
  5056. @item color, c
  5057. Specify the color of the fade. Default is "black".
  5058. @end table
  5059. @subsection Examples
  5060. @itemize
  5061. @item
  5062. Fade in the first 30 frames of video:
  5063. @example
  5064. fade=in:0:30
  5065. @end example
  5066. The command above is equivalent to:
  5067. @example
  5068. fade=t=in:s=0:n=30
  5069. @end example
  5070. @item
  5071. Fade out the last 45 frames of a 200-frame video:
  5072. @example
  5073. fade=out:155:45
  5074. fade=type=out:start_frame=155:nb_frames=45
  5075. @end example
  5076. @item
  5077. Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
  5078. @example
  5079. fade=in:0:25, fade=out:975:25
  5080. @end example
  5081. @item
  5082. Make the first 5 frames yellow, then fade in from frame 5-24:
  5083. @example
  5084. fade=in:5:20:color=yellow
  5085. @end example
  5086. @item
  5087. Fade in alpha over first 25 frames of video:
  5088. @example
  5089. fade=in:0:25:alpha=1
  5090. @end example
  5091. @item
  5092. Make the first 5.5 seconds black, then fade in for 0.5 seconds:
  5093. @example
  5094. fade=t=in:st=5.5:d=0.5
  5095. @end example
  5096. @end itemize
  5097. @section fftfilt
  5098. Apply arbitrary expressions to samples in frequency domain
  5099. @table @option
  5100. @item dc_Y
  5101. Adjust the dc value (gain) of the luma plane of the image. The filter
  5102. accepts an integer value in range @code{0} to @code{1000}. The default
  5103. value is set to @code{0}.
  5104. @item dc_U
  5105. Adjust the dc value (gain) of the 1st chroma plane of the image. The
  5106. filter accepts an integer value in range @code{0} to @code{1000}. The
  5107. default value is set to @code{0}.
  5108. @item dc_V
  5109. Adjust the dc value (gain) of the 2nd chroma plane of the image. The
  5110. filter accepts an integer value in range @code{0} to @code{1000}. The
  5111. default value is set to @code{0}.
  5112. @item weight_Y
  5113. Set the frequency domain weight expression for the luma plane.
  5114. @item weight_U
  5115. Set the frequency domain weight expression for the 1st chroma plane.
  5116. @item weight_V
  5117. Set the frequency domain weight expression for the 2nd chroma plane.
  5118. The filter accepts the following variables:
  5119. @item X
  5120. @item Y
  5121. The coordinates of the current sample.
  5122. @item W
  5123. @item H
  5124. The width and height of the image.
  5125. @end table
  5126. @subsection Examples
  5127. @itemize
  5128. @item
  5129. High-pass:
  5130. @example
  5131. fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
  5132. @end example
  5133. @item
  5134. Low-pass:
  5135. @example
  5136. fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
  5137. @end example
  5138. @item
  5139. Sharpen:
  5140. @example
  5141. fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
  5142. @end example
  5143. @item
  5144. Blur:
  5145. @example
  5146. fftfilt=dc_Y=0:weight_Y='exp(-4 * ((Y+X)/(W+H)))'
  5147. @end example
  5148. @end itemize
  5149. @section field
  5150. Extract a single field from an interlaced image using stride
  5151. arithmetic to avoid wasting CPU time. The output frames are marked as
  5152. non-interlaced.
  5153. The filter accepts the following options:
  5154. @table @option
  5155. @item type
  5156. Specify whether to extract the top (if the value is @code{0} or
  5157. @code{top}) or the bottom field (if the value is @code{1} or
  5158. @code{bottom}).
  5159. @end table
  5160. @section fieldhint
  5161. Create new frames by copying the top and bottom fields from surrounding frames
  5162. supplied as numbers by the hint file.
  5163. @table @option
  5164. @item hint
  5165. Set file containing hints: absolute/relative frame numbers.
  5166. There must be one line for each frame in a clip. Each line must contain two
  5167. numbers separated by the comma, optionally followed by @code{-} or @code{+}.
  5168. Numbers supplied on each line of file can not be out of [N-1,N+1] where N
  5169. is current frame number for @code{absolute} mode or out of [-1, 1] range
  5170. for @code{relative} mode. First number tells from which frame to pick up top
  5171. field and second number tells from which frame to pick up bottom field.
  5172. If optionally followed by @code{+} output frame will be marked as interlaced,
  5173. else if followed by @code{-} output frame will be marked as progressive, else
  5174. it will be marked same as input frame.
  5175. If line starts with @code{#} or @code{;} that line is skipped.
  5176. @item mode
  5177. Can be item @code{absolute} or @code{relative}. Default is @code{absolute}.
  5178. @end table
  5179. Example of first several lines of @code{hint} file for @code{relative} mode:
  5180. @example
  5181. 0,0 - # first frame
  5182. 1,0 - # second frame, use third's frame top field and second's frame bottom field
  5183. 1,0 - # third frame, use fourth's frame top field and third's frame bottom field
  5184. 1,0 -
  5185. 0,0 -
  5186. 0,0 -
  5187. 1,0 -
  5188. 1,0 -
  5189. 1,0 -
  5190. 0,0 -
  5191. 0,0 -
  5192. 1,0 -
  5193. 1,0 -
  5194. 1,0 -
  5195. 0,0 -
  5196. @end example
  5197. @section fieldmatch
  5198. Field matching filter for inverse telecine. It is meant to reconstruct the
  5199. progressive frames from a telecined stream. The filter does not drop duplicated
  5200. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  5201. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  5202. The separation of the field matching and the decimation is notably motivated by
  5203. the possibility of inserting a de-interlacing filter fallback between the two.
  5204. If the source has mixed telecined and real interlaced content,
  5205. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  5206. But these remaining combed frames will be marked as interlaced, and thus can be
  5207. de-interlaced by a later filter such as @ref{yadif} before decimation.
  5208. In addition to the various configuration options, @code{fieldmatch} can take an
  5209. optional second stream, activated through the @option{ppsrc} option. If
  5210. enabled, the frames reconstruction will be based on the fields and frames from
  5211. this second stream. This allows the first input to be pre-processed in order to
  5212. help the various algorithms of the filter, while keeping the output lossless
  5213. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  5214. or brightness/contrast adjustments can help.
  5215. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  5216. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  5217. which @code{fieldmatch} is based on. While the semantic and usage are very
  5218. close, some behaviour and options names can differ.
  5219. The @ref{decimate} filter currently only works for constant frame rate input.
  5220. If your input has mixed telecined (30fps) and progressive content with a lower
  5221. framerate like 24fps use the following filterchain to produce the necessary cfr
  5222. stream: @code{dejudder,fps=30000/1001,fieldmatch,decimate}.
  5223. The filter accepts the following options:
  5224. @table @option
  5225. @item order
  5226. Specify the assumed field order of the input stream. Available values are:
  5227. @table @samp
  5228. @item auto
  5229. Auto detect parity (use FFmpeg's internal parity value).
  5230. @item bff
  5231. Assume bottom field first.
  5232. @item tff
  5233. Assume top field first.
  5234. @end table
  5235. Note that it is sometimes recommended not to trust the parity announced by the
  5236. stream.
  5237. Default value is @var{auto}.
  5238. @item mode
  5239. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  5240. sense that it won't risk creating jerkiness due to duplicate frames when
  5241. possible, but if there are bad edits or blended fields it will end up
  5242. outputting combed frames when a good match might actually exist. On the other
  5243. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  5244. but will almost always find a good frame if there is one. The other values are
  5245. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  5246. jerkiness and creating duplicate frames versus finding good matches in sections
  5247. with bad edits, orphaned fields, blended fields, etc.
  5248. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  5249. Available values are:
  5250. @table @samp
  5251. @item pc
  5252. 2-way matching (p/c)
  5253. @item pc_n
  5254. 2-way matching, and trying 3rd match if still combed (p/c + n)
  5255. @item pc_u
  5256. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  5257. @item pc_n_ub
  5258. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  5259. still combed (p/c + n + u/b)
  5260. @item pcn
  5261. 3-way matching (p/c/n)
  5262. @item pcn_ub
  5263. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  5264. detected as combed (p/c/n + u/b)
  5265. @end table
  5266. The parenthesis at the end indicate the matches that would be used for that
  5267. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  5268. @var{top}).
  5269. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  5270. the slowest.
  5271. Default value is @var{pc_n}.
  5272. @item ppsrc
  5273. Mark the main input stream as a pre-processed input, and enable the secondary
  5274. input stream as the clean source to pick the fields from. See the filter
  5275. introduction for more details. It is similar to the @option{clip2} feature from
  5276. VFM/TFM.
  5277. Default value is @code{0} (disabled).
  5278. @item field
  5279. Set the field to match from. It is recommended to set this to the same value as
  5280. @option{order} unless you experience matching failures with that setting. In
  5281. certain circumstances changing the field that is used to match from can have a
  5282. large impact on matching performance. Available values are:
  5283. @table @samp
  5284. @item auto
  5285. Automatic (same value as @option{order}).
  5286. @item bottom
  5287. Match from the bottom field.
  5288. @item top
  5289. Match from the top field.
  5290. @end table
  5291. Default value is @var{auto}.
  5292. @item mchroma
  5293. Set whether or not chroma is included during the match comparisons. In most
  5294. cases it is recommended to leave this enabled. You should set this to @code{0}
  5295. only if your clip has bad chroma problems such as heavy rainbowing or other
  5296. artifacts. Setting this to @code{0} could also be used to speed things up at
  5297. the cost of some accuracy.
  5298. Default value is @code{1}.
  5299. @item y0
  5300. @item y1
  5301. These define an exclusion band which excludes the lines between @option{y0} and
  5302. @option{y1} from being included in the field matching decision. An exclusion
  5303. band can be used to ignore subtitles, a logo, or other things that may
  5304. interfere with the matching. @option{y0} sets the starting scan line and
  5305. @option{y1} sets the ending line; all lines in between @option{y0} and
  5306. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  5307. @option{y0} and @option{y1} to the same value will disable the feature.
  5308. @option{y0} and @option{y1} defaults to @code{0}.
  5309. @item scthresh
  5310. Set the scene change detection threshold as a percentage of maximum change on
  5311. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  5312. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  5313. @option{scthresh} is @code{[0.0, 100.0]}.
  5314. Default value is @code{12.0}.
  5315. @item combmatch
  5316. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  5317. account the combed scores of matches when deciding what match to use as the
  5318. final match. Available values are:
  5319. @table @samp
  5320. @item none
  5321. No final matching based on combed scores.
  5322. @item sc
  5323. Combed scores are only used when a scene change is detected.
  5324. @item full
  5325. Use combed scores all the time.
  5326. @end table
  5327. Default is @var{sc}.
  5328. @item combdbg
  5329. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  5330. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  5331. Available values are:
  5332. @table @samp
  5333. @item none
  5334. No forced calculation.
  5335. @item pcn
  5336. Force p/c/n calculations.
  5337. @item pcnub
  5338. Force p/c/n/u/b calculations.
  5339. @end table
  5340. Default value is @var{none}.
  5341. @item cthresh
  5342. This is the area combing threshold used for combed frame detection. This
  5343. essentially controls how "strong" or "visible" combing must be to be detected.
  5344. Larger values mean combing must be more visible and smaller values mean combing
  5345. can be less visible or strong and still be detected. Valid settings are from
  5346. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  5347. be detected as combed). This is basically a pixel difference value. A good
  5348. range is @code{[8, 12]}.
  5349. Default value is @code{9}.
  5350. @item chroma
  5351. Sets whether or not chroma is considered in the combed frame decision. Only
  5352. disable this if your source has chroma problems (rainbowing, etc.) that are
  5353. causing problems for the combed frame detection with chroma enabled. Actually,
  5354. using @option{chroma}=@var{0} is usually more reliable, except for the case
  5355. where there is chroma only combing in the source.
  5356. Default value is @code{0}.
  5357. @item blockx
  5358. @item blocky
  5359. Respectively set the x-axis and y-axis size of the window used during combed
  5360. frame detection. This has to do with the size of the area in which
  5361. @option{combpel} pixels are required to be detected as combed for a frame to be
  5362. declared combed. See the @option{combpel} parameter description for more info.
  5363. Possible values are any number that is a power of 2 starting at 4 and going up
  5364. to 512.
  5365. Default value is @code{16}.
  5366. @item combpel
  5367. The number of combed pixels inside any of the @option{blocky} by
  5368. @option{blockx} size blocks on the frame for the frame to be detected as
  5369. combed. While @option{cthresh} controls how "visible" the combing must be, this
  5370. setting controls "how much" combing there must be in any localized area (a
  5371. window defined by the @option{blockx} and @option{blocky} settings) on the
  5372. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  5373. which point no frames will ever be detected as combed). This setting is known
  5374. as @option{MI} in TFM/VFM vocabulary.
  5375. Default value is @code{80}.
  5376. @end table
  5377. @anchor{p/c/n/u/b meaning}
  5378. @subsection p/c/n/u/b meaning
  5379. @subsubsection p/c/n
  5380. We assume the following telecined stream:
  5381. @example
  5382. Top fields: 1 2 2 3 4
  5383. Bottom fields: 1 2 3 4 4
  5384. @end example
  5385. The numbers correspond to the progressive frame the fields relate to. Here, the
  5386. first two frames are progressive, the 3rd and 4th are combed, and so on.
  5387. When @code{fieldmatch} is configured to run a matching from bottom
  5388. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  5389. @example
  5390. Input stream:
  5391. T 1 2 2 3 4
  5392. B 1 2 3 4 4 <-- matching reference
  5393. Matches: c c n n c
  5394. Output stream:
  5395. T 1 2 3 4 4
  5396. B 1 2 3 4 4
  5397. @end example
  5398. As a result of the field matching, we can see that some frames get duplicated.
  5399. To perform a complete inverse telecine, you need to rely on a decimation filter
  5400. after this operation. See for instance the @ref{decimate} filter.
  5401. The same operation now matching from top fields (@option{field}=@var{top})
  5402. looks like this:
  5403. @example
  5404. Input stream:
  5405. T 1 2 2 3 4 <-- matching reference
  5406. B 1 2 3 4 4
  5407. Matches: c c p p c
  5408. Output stream:
  5409. T 1 2 2 3 4
  5410. B 1 2 2 3 4
  5411. @end example
  5412. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  5413. basically, they refer to the frame and field of the opposite parity:
  5414. @itemize
  5415. @item @var{p} matches the field of the opposite parity in the previous frame
  5416. @item @var{c} matches the field of the opposite parity in the current frame
  5417. @item @var{n} matches the field of the opposite parity in the next frame
  5418. @end itemize
  5419. @subsubsection u/b
  5420. The @var{u} and @var{b} matching are a bit special in the sense that they match
  5421. from the opposite parity flag. In the following examples, we assume that we are
  5422. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  5423. 'x' is placed above and below each matched fields.
  5424. With bottom matching (@option{field}=@var{bottom}):
  5425. @example
  5426. Match: c p n b u
  5427. x x x x x
  5428. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  5429. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  5430. x x x x x
  5431. Output frames:
  5432. 2 1 2 2 2
  5433. 2 2 2 1 3
  5434. @end example
  5435. With top matching (@option{field}=@var{top}):
  5436. @example
  5437. Match: c p n b u
  5438. x x x x x
  5439. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  5440. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  5441. x x x x x
  5442. Output frames:
  5443. 2 2 2 1 2
  5444. 2 1 3 2 2
  5445. @end example
  5446. @subsection Examples
  5447. Simple IVTC of a top field first telecined stream:
  5448. @example
  5449. fieldmatch=order=tff:combmatch=none, decimate
  5450. @end example
  5451. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  5452. @example
  5453. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  5454. @end example
  5455. @section fieldorder
  5456. Transform the field order of the input video.
  5457. It accepts the following parameters:
  5458. @table @option
  5459. @item order
  5460. The output field order. Valid values are @var{tff} for top field first or @var{bff}
  5461. for bottom field first.
  5462. @end table
  5463. The default value is @samp{tff}.
  5464. The transformation is done by shifting the picture content up or down
  5465. by one line, and filling the remaining line with appropriate picture content.
  5466. This method is consistent with most broadcast field order converters.
  5467. If the input video is not flagged as being interlaced, or it is already
  5468. flagged as being of the required output field order, then this filter does
  5469. not alter the incoming video.
  5470. It is very useful when converting to or from PAL DV material,
  5471. which is bottom field first.
  5472. For example:
  5473. @example
  5474. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  5475. @end example
  5476. @section fifo, afifo
  5477. Buffer input images and send them when they are requested.
  5478. It is mainly useful when auto-inserted by the libavfilter
  5479. framework.
  5480. It does not take parameters.
  5481. @section find_rect
  5482. Find a rectangular object
  5483. It accepts the following options:
  5484. @table @option
  5485. @item object
  5486. Filepath of the object image, needs to be in gray8.
  5487. @item threshold
  5488. Detection threshold, default is 0.5.
  5489. @item mipmaps
  5490. Number of mipmaps, default is 3.
  5491. @item xmin, ymin, xmax, ymax
  5492. Specifies the rectangle in which to search.
  5493. @end table
  5494. @subsection Examples
  5495. @itemize
  5496. @item
  5497. Generate a representative palette of a given video using @command{ffmpeg}:
  5498. @example
  5499. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  5500. @end example
  5501. @end itemize
  5502. @section cover_rect
  5503. Cover a rectangular object
  5504. It accepts the following options:
  5505. @table @option
  5506. @item cover
  5507. Filepath of the optional cover image, needs to be in yuv420.
  5508. @item mode
  5509. Set covering mode.
  5510. It accepts the following values:
  5511. @table @samp
  5512. @item cover
  5513. cover it by the supplied image
  5514. @item blur
  5515. cover it by interpolating the surrounding pixels
  5516. @end table
  5517. Default value is @var{blur}.
  5518. @end table
  5519. @subsection Examples
  5520. @itemize
  5521. @item
  5522. Generate a representative palette of a given video using @command{ffmpeg}:
  5523. @example
  5524. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  5525. @end example
  5526. @end itemize
  5527. @anchor{format}
  5528. @section format
  5529. Convert the input video to one of the specified pixel formats.
  5530. Libavfilter will try to pick one that is suitable as input to
  5531. the next filter.
  5532. It accepts the following parameters:
  5533. @table @option
  5534. @item pix_fmts
  5535. A '|'-separated list of pixel format names, such as
  5536. "pix_fmts=yuv420p|monow|rgb24".
  5537. @end table
  5538. @subsection Examples
  5539. @itemize
  5540. @item
  5541. Convert the input video to the @var{yuv420p} format
  5542. @example
  5543. format=pix_fmts=yuv420p
  5544. @end example
  5545. Convert the input video to any of the formats in the list
  5546. @example
  5547. format=pix_fmts=yuv420p|yuv444p|yuv410p
  5548. @end example
  5549. @end itemize
  5550. @anchor{fps}
  5551. @section fps
  5552. Convert the video to specified constant frame rate by duplicating or dropping
  5553. frames as necessary.
  5554. It accepts the following parameters:
  5555. @table @option
  5556. @item fps
  5557. The desired output frame rate. The default is @code{25}.
  5558. @item round
  5559. Rounding method.
  5560. Possible values are:
  5561. @table @option
  5562. @item zero
  5563. zero round towards 0
  5564. @item inf
  5565. round away from 0
  5566. @item down
  5567. round towards -infinity
  5568. @item up
  5569. round towards +infinity
  5570. @item near
  5571. round to nearest
  5572. @end table
  5573. The default is @code{near}.
  5574. @item start_time
  5575. Assume the first PTS should be the given value, in seconds. This allows for
  5576. padding/trimming at the start of stream. By default, no assumption is made
  5577. about the first frame's expected PTS, so no padding or trimming is done.
  5578. For example, this could be set to 0 to pad the beginning with duplicates of
  5579. the first frame if a video stream starts after the audio stream or to trim any
  5580. frames with a negative PTS.
  5581. @end table
  5582. Alternatively, the options can be specified as a flat string:
  5583. @var{fps}[:@var{round}].
  5584. See also the @ref{setpts} filter.
  5585. @subsection Examples
  5586. @itemize
  5587. @item
  5588. A typical usage in order to set the fps to 25:
  5589. @example
  5590. fps=fps=25
  5591. @end example
  5592. @item
  5593. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  5594. @example
  5595. fps=fps=film:round=near
  5596. @end example
  5597. @end itemize
  5598. @section framepack
  5599. Pack two different video streams into a stereoscopic video, setting proper
  5600. metadata on supported codecs. The two views should have the same size and
  5601. framerate and processing will stop when the shorter video ends. Please note
  5602. that you may conveniently adjust view properties with the @ref{scale} and
  5603. @ref{fps} filters.
  5604. It accepts the following parameters:
  5605. @table @option
  5606. @item format
  5607. The desired packing format. Supported values are:
  5608. @table @option
  5609. @item sbs
  5610. The views are next to each other (default).
  5611. @item tab
  5612. The views are on top of each other.
  5613. @item lines
  5614. The views are packed by line.
  5615. @item columns
  5616. The views are packed by column.
  5617. @item frameseq
  5618. The views are temporally interleaved.
  5619. @end table
  5620. @end table
  5621. Some examples:
  5622. @example
  5623. # Convert left and right views into a frame-sequential video
  5624. ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
  5625. # Convert views into a side-by-side video with the same output resolution as the input
  5626. 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
  5627. @end example
  5628. @section framerate
  5629. Change the frame rate by interpolating new video output frames from the source
  5630. frames.
  5631. This filter is not designed to function correctly with interlaced media. If
  5632. you wish to change the frame rate of interlaced media then you are required
  5633. to deinterlace before this filter and re-interlace after this filter.
  5634. A description of the accepted options follows.
  5635. @table @option
  5636. @item fps
  5637. Specify the output frames per second. This option can also be specified
  5638. as a value alone. The default is @code{50}.
  5639. @item interp_start
  5640. Specify the start of a range where the output frame will be created as a
  5641. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  5642. the default is @code{15}.
  5643. @item interp_end
  5644. Specify the end of a range where the output frame will be created as a
  5645. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  5646. the default is @code{240}.
  5647. @item scene
  5648. Specify the level at which a scene change is detected as a value between
  5649. 0 and 100 to indicate a new scene; a low value reflects a low
  5650. probability for the current frame to introduce a new scene, while a higher
  5651. value means the current frame is more likely to be one.
  5652. The default is @code{7}.
  5653. @item flags
  5654. Specify flags influencing the filter process.
  5655. Available value for @var{flags} is:
  5656. @table @option
  5657. @item scene_change_detect, scd
  5658. Enable scene change detection using the value of the option @var{scene}.
  5659. This flag is enabled by default.
  5660. @end table
  5661. @end table
  5662. @section framestep
  5663. Select one frame every N-th frame.
  5664. This filter accepts the following option:
  5665. @table @option
  5666. @item step
  5667. Select frame after every @code{step} frames.
  5668. Allowed values are positive integers higher than 0. Default value is @code{1}.
  5669. @end table
  5670. @anchor{frei0r}
  5671. @section frei0r
  5672. Apply a frei0r effect to the input video.
  5673. To enable the compilation of this filter, you need to install the frei0r
  5674. header and configure FFmpeg with @code{--enable-frei0r}.
  5675. It accepts the following parameters:
  5676. @table @option
  5677. @item filter_name
  5678. The name of the frei0r effect to load. If the environment variable
  5679. @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
  5680. directories specified by the colon-separated list in @env{FREIOR_PATH}.
  5681. Otherwise, the standard frei0r paths are searched, in this order:
  5682. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  5683. @file{/usr/lib/frei0r-1/}.
  5684. @item filter_params
  5685. A '|'-separated list of parameters to pass to the frei0r effect.
  5686. @end table
  5687. A frei0r effect parameter can be a boolean (its value is either
  5688. "y" or "n"), a double, a color (specified as
  5689. @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
  5690. numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
  5691. section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
  5692. @var{X} and @var{Y} are floating point numbers) and/or a string.
  5693. The number and types of parameters depend on the loaded effect. If an
  5694. effect parameter is not specified, the default value is set.
  5695. @subsection Examples
  5696. @itemize
  5697. @item
  5698. Apply the distort0r effect, setting the first two double parameters:
  5699. @example
  5700. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  5701. @end example
  5702. @item
  5703. Apply the colordistance effect, taking a color as the first parameter:
  5704. @example
  5705. frei0r=colordistance:0.2/0.3/0.4
  5706. frei0r=colordistance:violet
  5707. frei0r=colordistance:0x112233
  5708. @end example
  5709. @item
  5710. Apply the perspective effect, specifying the top left and top right image
  5711. positions:
  5712. @example
  5713. frei0r=perspective:0.2/0.2|0.8/0.2
  5714. @end example
  5715. @end itemize
  5716. For more information, see
  5717. @url{http://frei0r.dyne.org}
  5718. @section fspp
  5719. Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
  5720. It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
  5721. processing filter, one of them is performed once per block, not per pixel.
  5722. This allows for much higher speed.
  5723. The filter accepts the following options:
  5724. @table @option
  5725. @item quality
  5726. Set quality. This option defines the number of levels for averaging. It accepts
  5727. an integer in the range 4-5. Default value is @code{4}.
  5728. @item qp
  5729. Force a constant quantization parameter. It accepts an integer in range 0-63.
  5730. If not set, the filter will use the QP from the video stream (if available).
  5731. @item strength
  5732. Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
  5733. more details but also more artifacts, while higher values make the image smoother
  5734. but also blurrier. Default value is @code{0} − PSNR optimal.
  5735. @item use_bframe_qp
  5736. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  5737. option may cause flicker since the B-Frames have often larger QP. Default is
  5738. @code{0} (not enabled).
  5739. @end table
  5740. @section geq
  5741. The filter accepts the following options:
  5742. @table @option
  5743. @item lum_expr, lum
  5744. Set the luminance expression.
  5745. @item cb_expr, cb
  5746. Set the chrominance blue expression.
  5747. @item cr_expr, cr
  5748. Set the chrominance red expression.
  5749. @item alpha_expr, a
  5750. Set the alpha expression.
  5751. @item red_expr, r
  5752. Set the red expression.
  5753. @item green_expr, g
  5754. Set the green expression.
  5755. @item blue_expr, b
  5756. Set the blue expression.
  5757. @end table
  5758. The colorspace is selected according to the specified options. If one
  5759. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  5760. options is specified, the filter will automatically select a YCbCr
  5761. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  5762. @option{blue_expr} options is specified, it will select an RGB
  5763. colorspace.
  5764. If one of the chrominance expression is not defined, it falls back on the other
  5765. one. If no alpha expression is specified it will evaluate to opaque value.
  5766. If none of chrominance expressions are specified, they will evaluate
  5767. to the luminance expression.
  5768. The expressions can use the following variables and functions:
  5769. @table @option
  5770. @item N
  5771. The sequential number of the filtered frame, starting from @code{0}.
  5772. @item X
  5773. @item Y
  5774. The coordinates of the current sample.
  5775. @item W
  5776. @item H
  5777. The width and height of the image.
  5778. @item SW
  5779. @item SH
  5780. Width and height scale depending on the currently filtered plane. It is the
  5781. ratio between the corresponding luma plane number of pixels and the current
  5782. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  5783. @code{0.5,0.5} for chroma planes.
  5784. @item T
  5785. Time of the current frame, expressed in seconds.
  5786. @item p(x, y)
  5787. Return the value of the pixel at location (@var{x},@var{y}) of the current
  5788. plane.
  5789. @item lum(x, y)
  5790. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  5791. plane.
  5792. @item cb(x, y)
  5793. Return the value of the pixel at location (@var{x},@var{y}) of the
  5794. blue-difference chroma plane. Return 0 if there is no such plane.
  5795. @item cr(x, y)
  5796. Return the value of the pixel at location (@var{x},@var{y}) of the
  5797. red-difference chroma plane. Return 0 if there is no such plane.
  5798. @item r(x, y)
  5799. @item g(x, y)
  5800. @item b(x, y)
  5801. Return the value of the pixel at location (@var{x},@var{y}) of the
  5802. red/green/blue component. Return 0 if there is no such component.
  5803. @item alpha(x, y)
  5804. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  5805. plane. Return 0 if there is no such plane.
  5806. @end table
  5807. For functions, if @var{x} and @var{y} are outside the area, the value will be
  5808. automatically clipped to the closer edge.
  5809. @subsection Examples
  5810. @itemize
  5811. @item
  5812. Flip the image horizontally:
  5813. @example
  5814. geq=p(W-X\,Y)
  5815. @end example
  5816. @item
  5817. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  5818. wavelength of 100 pixels:
  5819. @example
  5820. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  5821. @end example
  5822. @item
  5823. Generate a fancy enigmatic moving light:
  5824. @example
  5825. 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
  5826. @end example
  5827. @item
  5828. Generate a quick emboss effect:
  5829. @example
  5830. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  5831. @end example
  5832. @item
  5833. Modify RGB components depending on pixel position:
  5834. @example
  5835. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  5836. @end example
  5837. @item
  5838. Create a radial gradient that is the same size as the input (also see
  5839. the @ref{vignette} filter):
  5840. @example
  5841. geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
  5842. @end example
  5843. @end itemize
  5844. @section gradfun
  5845. Fix the banding artifacts that are sometimes introduced into nearly flat
  5846. regions by truncation to 8bit color depth.
  5847. Interpolate the gradients that should go where the bands are, and
  5848. dither them.
  5849. It is designed for playback only. Do not use it prior to
  5850. lossy compression, because compression tends to lose the dither and
  5851. bring back the bands.
  5852. It accepts the following parameters:
  5853. @table @option
  5854. @item strength
  5855. The maximum amount by which the filter will change any one pixel. This is also
  5856. the threshold for detecting nearly flat regions. Acceptable values range from
  5857. .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
  5858. valid range.
  5859. @item radius
  5860. The neighborhood to fit the gradient to. A larger radius makes for smoother
  5861. gradients, but also prevents the filter from modifying the pixels near detailed
  5862. regions. Acceptable values are 8-32; the default value is 16. Out-of-range
  5863. values will be clipped to the valid range.
  5864. @end table
  5865. Alternatively, the options can be specified as a flat string:
  5866. @var{strength}[:@var{radius}]
  5867. @subsection Examples
  5868. @itemize
  5869. @item
  5870. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  5871. @example
  5872. gradfun=3.5:8
  5873. @end example
  5874. @item
  5875. Specify radius, omitting the strength (which will fall-back to the default
  5876. value):
  5877. @example
  5878. gradfun=radius=8
  5879. @end example
  5880. @end itemize
  5881. @anchor{haldclut}
  5882. @section haldclut
  5883. Apply a Hald CLUT to a video stream.
  5884. First input is the video stream to process, and second one is the Hald CLUT.
  5885. The Hald CLUT input can be a simple picture or a complete video stream.
  5886. The filter accepts the following options:
  5887. @table @option
  5888. @item shortest
  5889. Force termination when the shortest input terminates. Default is @code{0}.
  5890. @item repeatlast
  5891. Continue applying the last CLUT after the end of the stream. A value of
  5892. @code{0} disable the filter after the last frame of the CLUT is reached.
  5893. Default is @code{1}.
  5894. @end table
  5895. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  5896. filters share the same internals).
  5897. More information about the Hald CLUT can be found on Eskil Steenberg's website
  5898. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  5899. @subsection Workflow examples
  5900. @subsubsection Hald CLUT video stream
  5901. Generate an identity Hald CLUT stream altered with various effects:
  5902. @example
  5903. 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
  5904. @end example
  5905. Note: make sure you use a lossless codec.
  5906. Then use it with @code{haldclut} to apply it on some random stream:
  5907. @example
  5908. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  5909. @end example
  5910. The Hald CLUT will be applied to the 10 first seconds (duration of
  5911. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  5912. to the remaining frames of the @code{mandelbrot} stream.
  5913. @subsubsection Hald CLUT with preview
  5914. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  5915. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  5916. biggest possible square starting at the top left of the picture. The remaining
  5917. padding pixels (bottom or right) will be ignored. This area can be used to add
  5918. a preview of the Hald CLUT.
  5919. Typically, the following generated Hald CLUT will be supported by the
  5920. @code{haldclut} filter:
  5921. @example
  5922. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  5923. pad=iw+320 [padded_clut];
  5924. smptebars=s=320x256, split [a][b];
  5925. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  5926. [main][b] overlay=W-320" -frames:v 1 clut.png
  5927. @end example
  5928. It contains the original and a preview of the effect of the CLUT: SMPTE color
  5929. bars are displayed on the right-top, and below the same color bars processed by
  5930. the color changes.
  5931. Then, the effect of this Hald CLUT can be visualized with:
  5932. @example
  5933. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  5934. @end example
  5935. @section hflip
  5936. Flip the input video horizontally.
  5937. For example, to horizontally flip the input video with @command{ffmpeg}:
  5938. @example
  5939. ffmpeg -i in.avi -vf "hflip" out.avi
  5940. @end example
  5941. @section histeq
  5942. This filter applies a global color histogram equalization on a
  5943. per-frame basis.
  5944. It can be used to correct video that has a compressed range of pixel
  5945. intensities. The filter redistributes the pixel intensities to
  5946. equalize their distribution across the intensity range. It may be
  5947. viewed as an "automatically adjusting contrast filter". This filter is
  5948. useful only for correcting degraded or poorly captured source
  5949. video.
  5950. The filter accepts the following options:
  5951. @table @option
  5952. @item strength
  5953. Determine the amount of equalization to be applied. As the strength
  5954. is reduced, the distribution of pixel intensities more-and-more
  5955. approaches that of the input frame. The value must be a float number
  5956. in the range [0,1] and defaults to 0.200.
  5957. @item intensity
  5958. Set the maximum intensity that can generated and scale the output
  5959. values appropriately. The strength should be set as desired and then
  5960. the intensity can be limited if needed to avoid washing-out. The value
  5961. must be a float number in the range [0,1] and defaults to 0.210.
  5962. @item antibanding
  5963. Set the antibanding level. If enabled the filter will randomly vary
  5964. the luminance of output pixels by a small amount to avoid banding of
  5965. the histogram. Possible values are @code{none}, @code{weak} or
  5966. @code{strong}. It defaults to @code{none}.
  5967. @end table
  5968. @section histogram
  5969. Compute and draw a color distribution histogram for the input video.
  5970. The computed histogram is a representation of the color component
  5971. distribution in an image.
  5972. Standard histogram displays the color components distribution in an image.
  5973. Displays color graph for each color component. Shows distribution of
  5974. the Y, U, V, A or R, G, B components, depending on input format, in the
  5975. current frame. Below each graph a color component scale meter is shown.
  5976. The filter accepts the following options:
  5977. @table @option
  5978. @item level_height
  5979. Set height of level. Default value is @code{200}.
  5980. Allowed range is [50, 2048].
  5981. @item scale_height
  5982. Set height of color scale. Default value is @code{12}.
  5983. Allowed range is [0, 40].
  5984. @item display_mode
  5985. Set display mode.
  5986. It accepts the following values:
  5987. @table @samp
  5988. @item parade
  5989. Per color component graphs are placed below each other.
  5990. @item overlay
  5991. Presents information identical to that in the @code{parade}, except
  5992. that the graphs representing color components are superimposed directly
  5993. over one another.
  5994. @end table
  5995. Default is @code{parade}.
  5996. @item levels_mode
  5997. Set mode. Can be either @code{linear}, or @code{logarithmic}.
  5998. Default is @code{linear}.
  5999. @item components
  6000. Set what color components to display.
  6001. Default is @code{7}.
  6002. @end table
  6003. @subsection Examples
  6004. @itemize
  6005. @item
  6006. Calculate and draw histogram:
  6007. @example
  6008. ffplay -i input -vf histogram
  6009. @end example
  6010. @end itemize
  6011. @anchor{hqdn3d}
  6012. @section hqdn3d
  6013. This is a high precision/quality 3d denoise filter. It aims to reduce
  6014. image noise, producing smooth images and making still images really
  6015. still. It should enhance compressibility.
  6016. It accepts the following optional parameters:
  6017. @table @option
  6018. @item luma_spatial
  6019. A non-negative floating point number which specifies spatial luma strength.
  6020. It defaults to 4.0.
  6021. @item chroma_spatial
  6022. A non-negative floating point number which specifies spatial chroma strength.
  6023. It defaults to 3.0*@var{luma_spatial}/4.0.
  6024. @item luma_tmp
  6025. A floating point number which specifies luma temporal strength. It defaults to
  6026. 6.0*@var{luma_spatial}/4.0.
  6027. @item chroma_tmp
  6028. A floating point number which specifies chroma temporal strength. It defaults to
  6029. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
  6030. @end table
  6031. @section hqx
  6032. Apply a high-quality magnification filter designed for pixel art. This filter
  6033. was originally created by Maxim Stepin.
  6034. It accepts the following option:
  6035. @table @option
  6036. @item n
  6037. Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
  6038. @code{hq3x} and @code{4} for @code{hq4x}.
  6039. Default is @code{3}.
  6040. @end table
  6041. @section hstack
  6042. Stack input videos horizontally.
  6043. All streams must be of same pixel format and of same height.
  6044. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  6045. to create same output.
  6046. The filter accept the following option:
  6047. @table @option
  6048. @item inputs
  6049. Set number of input streams. Default is 2.
  6050. @item shortest
  6051. If set to 1, force the output to terminate when the shortest input
  6052. terminates. Default value is 0.
  6053. @end table
  6054. @section hue
  6055. Modify the hue and/or the saturation of the input.
  6056. It accepts the following parameters:
  6057. @table @option
  6058. @item h
  6059. Specify the hue angle as a number of degrees. It accepts an expression,
  6060. and defaults to "0".
  6061. @item s
  6062. Specify the saturation in the [-10,10] range. It accepts an expression and
  6063. defaults to "1".
  6064. @item H
  6065. Specify the hue angle as a number of radians. It accepts an
  6066. expression, and defaults to "0".
  6067. @item b
  6068. Specify the brightness in the [-10,10] range. It accepts an expression and
  6069. defaults to "0".
  6070. @end table
  6071. @option{h} and @option{H} are mutually exclusive, and can't be
  6072. specified at the same time.
  6073. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  6074. expressions containing the following constants:
  6075. @table @option
  6076. @item n
  6077. frame count of the input frame starting from 0
  6078. @item pts
  6079. presentation timestamp of the input frame expressed in time base units
  6080. @item r
  6081. frame rate of the input video, NAN if the input frame rate is unknown
  6082. @item t
  6083. timestamp expressed in seconds, NAN if the input timestamp is unknown
  6084. @item tb
  6085. time base of the input video
  6086. @end table
  6087. @subsection Examples
  6088. @itemize
  6089. @item
  6090. Set the hue to 90 degrees and the saturation to 1.0:
  6091. @example
  6092. hue=h=90:s=1
  6093. @end example
  6094. @item
  6095. Same command but expressing the hue in radians:
  6096. @example
  6097. hue=H=PI/2:s=1
  6098. @end example
  6099. @item
  6100. Rotate hue and make the saturation swing between 0
  6101. and 2 over a period of 1 second:
  6102. @example
  6103. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  6104. @end example
  6105. @item
  6106. Apply a 3 seconds saturation fade-in effect starting at 0:
  6107. @example
  6108. hue="s=min(t/3\,1)"
  6109. @end example
  6110. The general fade-in expression can be written as:
  6111. @example
  6112. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  6113. @end example
  6114. @item
  6115. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  6116. @example
  6117. hue="s=max(0\, min(1\, (8-t)/3))"
  6118. @end example
  6119. The general fade-out expression can be written as:
  6120. @example
  6121. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  6122. @end example
  6123. @end itemize
  6124. @subsection Commands
  6125. This filter supports the following commands:
  6126. @table @option
  6127. @item b
  6128. @item s
  6129. @item h
  6130. @item H
  6131. Modify the hue and/or the saturation and/or brightness of the input video.
  6132. The command accepts the same syntax of the corresponding option.
  6133. If the specified expression is not valid, it is kept at its current
  6134. value.
  6135. @end table
  6136. @section idet
  6137. Detect video interlacing type.
  6138. This filter tries to detect if the input frames as interlaced, progressive,
  6139. top or bottom field first. It will also try and detect fields that are
  6140. repeated between adjacent frames (a sign of telecine).
  6141. Single frame detection considers only immediately adjacent frames when classifying each frame.
  6142. Multiple frame detection incorporates the classification history of previous frames.
  6143. The filter will log these metadata values:
  6144. @table @option
  6145. @item single.current_frame
  6146. Detected type of current frame using single-frame detection. One of:
  6147. ``tff'' (top field first), ``bff'' (bottom field first),
  6148. ``progressive'', or ``undetermined''
  6149. @item single.tff
  6150. Cumulative number of frames detected as top field first using single-frame detection.
  6151. @item multiple.tff
  6152. Cumulative number of frames detected as top field first using multiple-frame detection.
  6153. @item single.bff
  6154. Cumulative number of frames detected as bottom field first using single-frame detection.
  6155. @item multiple.current_frame
  6156. Detected type of current frame using multiple-frame detection. One of:
  6157. ``tff'' (top field first), ``bff'' (bottom field first),
  6158. ``progressive'', or ``undetermined''
  6159. @item multiple.bff
  6160. Cumulative number of frames detected as bottom field first using multiple-frame detection.
  6161. @item single.progressive
  6162. Cumulative number of frames detected as progressive using single-frame detection.
  6163. @item multiple.progressive
  6164. Cumulative number of frames detected as progressive using multiple-frame detection.
  6165. @item single.undetermined
  6166. Cumulative number of frames that could not be classified using single-frame detection.
  6167. @item multiple.undetermined
  6168. Cumulative number of frames that could not be classified using multiple-frame detection.
  6169. @item repeated.current_frame
  6170. Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
  6171. @item repeated.neither
  6172. Cumulative number of frames with no repeated field.
  6173. @item repeated.top
  6174. Cumulative number of frames with the top field repeated from the previous frame's top field.
  6175. @item repeated.bottom
  6176. Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
  6177. @end table
  6178. The filter accepts the following options:
  6179. @table @option
  6180. @item intl_thres
  6181. Set interlacing threshold.
  6182. @item prog_thres
  6183. Set progressive threshold.
  6184. @item repeat_thres
  6185. Threshold for repeated field detection.
  6186. @item half_life
  6187. Number of frames after which a given frame's contribution to the
  6188. statistics is halved (i.e., it contributes only 0.5 to it's
  6189. classification). The default of 0 means that all frames seen are given
  6190. full weight of 1.0 forever.
  6191. @item analyze_interlaced_flag
  6192. When this is not 0 then idet will use the specified number of frames to determine
  6193. if the interlaced flag is accurate, it will not count undetermined frames.
  6194. If the flag is found to be accurate it will be used without any further
  6195. computations, if it is found to be inaccurate it will be cleared without any
  6196. further computations. This allows inserting the idet filter as a low computational
  6197. method to clean up the interlaced flag
  6198. @end table
  6199. @section il
  6200. Deinterleave or interleave fields.
  6201. This filter allows one to process interlaced images fields without
  6202. deinterlacing them. Deinterleaving splits the input frame into 2
  6203. fields (so called half pictures). Odd lines are moved to the top
  6204. half of the output image, even lines to the bottom half.
  6205. You can process (filter) them independently and then re-interleave them.
  6206. The filter accepts the following options:
  6207. @table @option
  6208. @item luma_mode, l
  6209. @item chroma_mode, c
  6210. @item alpha_mode, a
  6211. Available values for @var{luma_mode}, @var{chroma_mode} and
  6212. @var{alpha_mode} are:
  6213. @table @samp
  6214. @item none
  6215. Do nothing.
  6216. @item deinterleave, d
  6217. Deinterleave fields, placing one above the other.
  6218. @item interleave, i
  6219. Interleave fields. Reverse the effect of deinterleaving.
  6220. @end table
  6221. Default value is @code{none}.
  6222. @item luma_swap, ls
  6223. @item chroma_swap, cs
  6224. @item alpha_swap, as
  6225. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  6226. @end table
  6227. @section inflate
  6228. Apply inflate effect to the video.
  6229. This filter replaces the pixel by the local(3x3) average by taking into account
  6230. only values higher than the pixel.
  6231. It accepts the following options:
  6232. @table @option
  6233. @item threshold0
  6234. @item threshold1
  6235. @item threshold2
  6236. @item threshold3
  6237. Limit the maximum change for each plane, default is 65535.
  6238. If 0, plane will remain unchanged.
  6239. @end table
  6240. @section interlace
  6241. Simple interlacing filter from progressive contents. This interleaves upper (or
  6242. lower) lines from odd frames with lower (or upper) lines from even frames,
  6243. halving the frame rate and preserving image height.
  6244. @example
  6245. Original Original New Frame
  6246. Frame 'j' Frame 'j+1' (tff)
  6247. ========== =========== ==================
  6248. Line 0 --------------------> Frame 'j' Line 0
  6249. Line 1 Line 1 ----> Frame 'j+1' Line 1
  6250. Line 2 ---------------------> Frame 'j' Line 2
  6251. Line 3 Line 3 ----> Frame 'j+1' Line 3
  6252. ... ... ...
  6253. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  6254. @end example
  6255. It accepts the following optional parameters:
  6256. @table @option
  6257. @item scan
  6258. This determines whether the interlaced frame is taken from the even
  6259. (tff - default) or odd (bff) lines of the progressive frame.
  6260. @item lowpass
  6261. Enable (default) or disable the vertical lowpass filter to avoid twitter
  6262. interlacing and reduce moire patterns.
  6263. @end table
  6264. @section kerndeint
  6265. Deinterlace input video by applying Donald Graft's adaptive kernel
  6266. deinterling. Work on interlaced parts of a video to produce
  6267. progressive frames.
  6268. The description of the accepted parameters follows.
  6269. @table @option
  6270. @item thresh
  6271. Set the threshold which affects the filter's tolerance when
  6272. determining if a pixel line must be processed. It must be an integer
  6273. in the range [0,255] and defaults to 10. A value of 0 will result in
  6274. applying the process on every pixels.
  6275. @item map
  6276. Paint pixels exceeding the threshold value to white if set to 1.
  6277. Default is 0.
  6278. @item order
  6279. Set the fields order. Swap fields if set to 1, leave fields alone if
  6280. 0. Default is 0.
  6281. @item sharp
  6282. Enable additional sharpening if set to 1. Default is 0.
  6283. @item twoway
  6284. Enable twoway sharpening if set to 1. Default is 0.
  6285. @end table
  6286. @subsection Examples
  6287. @itemize
  6288. @item
  6289. Apply default values:
  6290. @example
  6291. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  6292. @end example
  6293. @item
  6294. Enable additional sharpening:
  6295. @example
  6296. kerndeint=sharp=1
  6297. @end example
  6298. @item
  6299. Paint processed pixels in white:
  6300. @example
  6301. kerndeint=map=1
  6302. @end example
  6303. @end itemize
  6304. @section lenscorrection
  6305. Correct radial lens distortion
  6306. This filter can be used to correct for radial distortion as can result from the use
  6307. of wide angle lenses, and thereby re-rectify the image. To find the right parameters
  6308. one can use tools available for example as part of opencv or simply trial-and-error.
  6309. To use opencv use the calibration sample (under samples/cpp) from the opencv sources
  6310. and extract the k1 and k2 coefficients from the resulting matrix.
  6311. Note that effectively the same filter is available in the open-source tools Krita and
  6312. Digikam from the KDE project.
  6313. In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
  6314. this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
  6315. brightness distribution, so you may want to use both filters together in certain
  6316. cases, though you will have to take care of ordering, i.e. whether vignetting should
  6317. be applied before or after lens correction.
  6318. @subsection Options
  6319. The filter accepts the following options:
  6320. @table @option
  6321. @item cx
  6322. Relative x-coordinate of the focal point of the image, and thereby the center of the
  6323. distortion. This value has a range [0,1] and is expressed as fractions of the image
  6324. width.
  6325. @item cy
  6326. Relative y-coordinate of the focal point of the image, and thereby the center of the
  6327. distortion. This value has a range [0,1] and is expressed as fractions of the image
  6328. height.
  6329. @item k1
  6330. Coefficient of the quadratic correction term. 0.5 means no correction.
  6331. @item k2
  6332. Coefficient of the double quadratic correction term. 0.5 means no correction.
  6333. @end table
  6334. The formula that generates the correction is:
  6335. @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)
  6336. where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
  6337. distances from the focal point in the source and target images, respectively.
  6338. @section loop, aloop
  6339. Loop video frames or audio samples.
  6340. Those filters accepts the following options:
  6341. @table @option
  6342. @item loop
  6343. Set the number of loops.
  6344. @item size
  6345. Set maximal size in number of frames for @code{loop} filter or maximal number
  6346. of samples in case of @code{aloop} filter.
  6347. @item start
  6348. Set first frame of loop for @code{loop} filter or first sample of loop in case
  6349. of @code{aloop} filter.
  6350. @end table
  6351. @anchor{lut3d}
  6352. @section lut3d
  6353. Apply a 3D LUT to an input video.
  6354. The filter accepts the following options:
  6355. @table @option
  6356. @item file
  6357. Set the 3D LUT file name.
  6358. Currently supported formats:
  6359. @table @samp
  6360. @item 3dl
  6361. AfterEffects
  6362. @item cube
  6363. Iridas
  6364. @item dat
  6365. DaVinci
  6366. @item m3d
  6367. Pandora
  6368. @end table
  6369. @item interp
  6370. Select interpolation mode.
  6371. Available values are:
  6372. @table @samp
  6373. @item nearest
  6374. Use values from the nearest defined point.
  6375. @item trilinear
  6376. Interpolate values using the 8 points defining a cube.
  6377. @item tetrahedral
  6378. Interpolate values using a tetrahedron.
  6379. @end table
  6380. @end table
  6381. @section lut, lutrgb, lutyuv
  6382. Compute a look-up table for binding each pixel component input value
  6383. to an output value, and apply it to the input video.
  6384. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  6385. to an RGB input video.
  6386. These filters accept the following parameters:
  6387. @table @option
  6388. @item c0
  6389. set first pixel component expression
  6390. @item c1
  6391. set second pixel component expression
  6392. @item c2
  6393. set third pixel component expression
  6394. @item c3
  6395. set fourth pixel component expression, corresponds to the alpha component
  6396. @item r
  6397. set red component expression
  6398. @item g
  6399. set green component expression
  6400. @item b
  6401. set blue component expression
  6402. @item a
  6403. alpha component expression
  6404. @item y
  6405. set Y/luminance component expression
  6406. @item u
  6407. set U/Cb component expression
  6408. @item v
  6409. set V/Cr component expression
  6410. @end table
  6411. Each of them specifies the expression to use for computing the lookup table for
  6412. the corresponding pixel component values.
  6413. The exact component associated to each of the @var{c*} options depends on the
  6414. format in input.
  6415. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  6416. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  6417. The expressions can contain the following constants and functions:
  6418. @table @option
  6419. @item w
  6420. @item h
  6421. The input width and height.
  6422. @item val
  6423. The input value for the pixel component.
  6424. @item clipval
  6425. The input value, clipped to the @var{minval}-@var{maxval} range.
  6426. @item maxval
  6427. The maximum value for the pixel component.
  6428. @item minval
  6429. The minimum value for the pixel component.
  6430. @item negval
  6431. The negated value for the pixel component value, clipped to the
  6432. @var{minval}-@var{maxval} range; it corresponds to the expression
  6433. "maxval-clipval+minval".
  6434. @item clip(val)
  6435. The computed value in @var{val}, clipped to the
  6436. @var{minval}-@var{maxval} range.
  6437. @item gammaval(gamma)
  6438. The computed gamma correction value of the pixel component value,
  6439. clipped to the @var{minval}-@var{maxval} range. It corresponds to the
  6440. expression
  6441. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  6442. @end table
  6443. All expressions default to "val".
  6444. @subsection Examples
  6445. @itemize
  6446. @item
  6447. Negate input video:
  6448. @example
  6449. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  6450. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  6451. @end example
  6452. The above is the same as:
  6453. @example
  6454. lutrgb="r=negval:g=negval:b=negval"
  6455. lutyuv="y=negval:u=negval:v=negval"
  6456. @end example
  6457. @item
  6458. Negate luminance:
  6459. @example
  6460. lutyuv=y=negval
  6461. @end example
  6462. @item
  6463. Remove chroma components, turning the video into a graytone image:
  6464. @example
  6465. lutyuv="u=128:v=128"
  6466. @end example
  6467. @item
  6468. Apply a luma burning effect:
  6469. @example
  6470. lutyuv="y=2*val"
  6471. @end example
  6472. @item
  6473. Remove green and blue components:
  6474. @example
  6475. lutrgb="g=0:b=0"
  6476. @end example
  6477. @item
  6478. Set a constant alpha channel value on input:
  6479. @example
  6480. format=rgba,lutrgb=a="maxval-minval/2"
  6481. @end example
  6482. @item
  6483. Correct luminance gamma by a factor of 0.5:
  6484. @example
  6485. lutyuv=y=gammaval(0.5)
  6486. @end example
  6487. @item
  6488. Discard least significant bits of luma:
  6489. @example
  6490. lutyuv=y='bitand(val, 128+64+32)'
  6491. @end example
  6492. @end itemize
  6493. @section maskedmerge
  6494. Merge the first input stream with the second input stream using per pixel
  6495. weights in the third input stream.
  6496. A value of 0 in the third stream pixel component means that pixel component
  6497. from first stream is returned unchanged, while maximum value (eg. 255 for
  6498. 8-bit videos) means that pixel component from second stream is returned
  6499. unchanged. Intermediate values define the amount of merging between both
  6500. input stream's pixel components.
  6501. This filter accepts the following options:
  6502. @table @option
  6503. @item planes
  6504. Set which planes will be processed as bitmap, unprocessed planes will be
  6505. copied from first stream.
  6506. By default value 0xf, all planes will be processed.
  6507. @end table
  6508. @section mcdeint
  6509. Apply motion-compensation deinterlacing.
  6510. It needs one field per frame as input and must thus be used together
  6511. with yadif=1/3 or equivalent.
  6512. This filter accepts the following options:
  6513. @table @option
  6514. @item mode
  6515. Set the deinterlacing mode.
  6516. It accepts one of the following values:
  6517. @table @samp
  6518. @item fast
  6519. @item medium
  6520. @item slow
  6521. use iterative motion estimation
  6522. @item extra_slow
  6523. like @samp{slow}, but use multiple reference frames.
  6524. @end table
  6525. Default value is @samp{fast}.
  6526. @item parity
  6527. Set the picture field parity assumed for the input video. It must be
  6528. one of the following values:
  6529. @table @samp
  6530. @item 0, tff
  6531. assume top field first
  6532. @item 1, bff
  6533. assume bottom field first
  6534. @end table
  6535. Default value is @samp{bff}.
  6536. @item qp
  6537. Set per-block quantization parameter (QP) used by the internal
  6538. encoder.
  6539. Higher values should result in a smoother motion vector field but less
  6540. optimal individual vectors. Default value is 1.
  6541. @end table
  6542. @section mergeplanes
  6543. Merge color channel components from several video streams.
  6544. The filter accepts up to 4 input streams, and merge selected input
  6545. planes to the output video.
  6546. This filter accepts the following options:
  6547. @table @option
  6548. @item mapping
  6549. Set input to output plane mapping. Default is @code{0}.
  6550. The mappings is specified as a bitmap. It should be specified as a
  6551. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  6552. mapping for the first plane of the output stream. 'A' sets the number of
  6553. the input stream to use (from 0 to 3), and 'a' the plane number of the
  6554. corresponding input to use (from 0 to 3). The rest of the mappings is
  6555. similar, 'Bb' describes the mapping for the output stream second
  6556. plane, 'Cc' describes the mapping for the output stream third plane and
  6557. 'Dd' describes the mapping for the output stream fourth plane.
  6558. @item format
  6559. Set output pixel format. Default is @code{yuva444p}.
  6560. @end table
  6561. @subsection Examples
  6562. @itemize
  6563. @item
  6564. Merge three gray video streams of same width and height into single video stream:
  6565. @example
  6566. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  6567. @end example
  6568. @item
  6569. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  6570. @example
  6571. [a0][a1]mergeplanes=0x00010210:yuva444p
  6572. @end example
  6573. @item
  6574. Swap Y and A plane in yuva444p stream:
  6575. @example
  6576. format=yuva444p,mergeplanes=0x03010200:yuva444p
  6577. @end example
  6578. @item
  6579. Swap U and V plane in yuv420p stream:
  6580. @example
  6581. format=yuv420p,mergeplanes=0x000201:yuv420p
  6582. @end example
  6583. @item
  6584. Cast a rgb24 clip to yuv444p:
  6585. @example
  6586. format=rgb24,mergeplanes=0x000102:yuv444p
  6587. @end example
  6588. @end itemize
  6589. @section metadata, ametadata
  6590. Manipulate frame metadata.
  6591. This filter accepts the following options:
  6592. @table @option
  6593. @item mode
  6594. Set mode of operation of the filter.
  6595. Can be one of the following:
  6596. @table @samp
  6597. @item select
  6598. If both @code{value} and @code{key} is set, select frames
  6599. which have such metadata. If only @code{key} is set, select
  6600. every frame that has such key in metadata.
  6601. @item add
  6602. Add new metadata @code{key} and @code{value}. If key is already available
  6603. do nothing.
  6604. @item modify
  6605. Modify value of already present key.
  6606. @item delete
  6607. If @code{value} is set, delete only keys that have such value.
  6608. Otherwise, delete key.
  6609. @item print
  6610. Print key and its value if metadata was found. If @code{key} is not set print all
  6611. metadata values available in frame.
  6612. @end table
  6613. @item key
  6614. Set key used with all modes. Must be set for all modes except @code{print}.
  6615. @item value
  6616. Set metadata value which will be used. This option is mandatory for
  6617. @code{modify} and @code{add} mode.
  6618. @item function
  6619. Which function to use when comparing metadata value and @code{value}.
  6620. Can be one of following:
  6621. @table @samp
  6622. @item same_str
  6623. Values are interpreted as strings, returns true if metadata value is same as @code{value}.
  6624. @item starts_with
  6625. Values are interpreted as strings, returns true if metadata value starts with
  6626. the @code{value} option string.
  6627. @item less
  6628. Values are interpreted as floats, returns true if metadata value is less than @code{value}.
  6629. @item equal
  6630. Values are interpreted as floats, returns true if @code{value} is equal with metadata value.
  6631. @item greater
  6632. Values are interpreted as floats, returns true if metadata value is greater than @code{value}.
  6633. @item expr
  6634. Values are interpreted as floats, returns true if expression from option @code{expr}
  6635. evaluates to true.
  6636. @end table
  6637. @item expr
  6638. Set expression which is used when @code{function} is set to @code{expr}.
  6639. The expression is evaluated through the eval API and can contain the following
  6640. constants:
  6641. @table @option
  6642. @item VALUE1
  6643. Float representation of @code{value} from metadata key.
  6644. @item VALUE2
  6645. Float representation of @code{value} as supplied by user in @code{value} option.
  6646. @end table
  6647. @item file
  6648. If specified in @code{print} mode, output is written to the named file. When
  6649. filename equals "-" data is written to standard output.
  6650. If @code{file} option is not set, output is written to the log with AV_LOG_INFO
  6651. loglevel.
  6652. @end table
  6653. @subsection Examples
  6654. @itemize
  6655. @item
  6656. Print all metadata values for frames with key @code{lavfi.singnalstats.YDIF} with values
  6657. between 0 and 1.
  6658. @example
  6659. @end example
  6660. signalstats,metadata=print:key=lavfi.signalstats.YDIF:value=0:function=expr:expr='between(VALUE1,0,1)'
  6661. @end itemize
  6662. @section mpdecimate
  6663. Drop frames that do not differ greatly from the previous frame in
  6664. order to reduce frame rate.
  6665. The main use of this filter is for very-low-bitrate encoding
  6666. (e.g. streaming over dialup modem), but it could in theory be used for
  6667. fixing movies that were inverse-telecined incorrectly.
  6668. A description of the accepted options follows.
  6669. @table @option
  6670. @item max
  6671. Set the maximum number of consecutive frames which can be dropped (if
  6672. positive), or the minimum interval between dropped frames (if
  6673. negative). If the value is 0, the frame is dropped unregarding the
  6674. number of previous sequentially dropped frames.
  6675. Default value is 0.
  6676. @item hi
  6677. @item lo
  6678. @item frac
  6679. Set the dropping threshold values.
  6680. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  6681. represent actual pixel value differences, so a threshold of 64
  6682. corresponds to 1 unit of difference for each pixel, or the same spread
  6683. out differently over the block.
  6684. A frame is a candidate for dropping if no 8x8 blocks differ by more
  6685. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  6686. meaning the whole image) differ by more than a threshold of @option{lo}.
  6687. Default value for @option{hi} is 64*12, default value for @option{lo} is
  6688. 64*5, and default value for @option{frac} is 0.33.
  6689. @end table
  6690. @section negate
  6691. Negate input video.
  6692. It accepts an integer in input; if non-zero it negates the
  6693. alpha component (if available). The default value in input is 0.
  6694. @section nnedi
  6695. Deinterlace video using neural network edge directed interpolation.
  6696. This filter accepts the following options:
  6697. @table @option
  6698. @item weights
  6699. Mandatory option, without binary file filter can not work.
  6700. Currently file can be found here:
  6701. https://github.com/dubhater/vapoursynth-nnedi3/blob/master/src/nnedi3_weights.bin
  6702. @item deint
  6703. Set which frames to deinterlace, by default it is @code{all}.
  6704. Can be @code{all} or @code{interlaced}.
  6705. @item field
  6706. Set mode of operation.
  6707. Can be one of the following:
  6708. @table @samp
  6709. @item af
  6710. Use frame flags, both fields.
  6711. @item a
  6712. Use frame flags, single field.
  6713. @item t
  6714. Use top field only.
  6715. @item b
  6716. Use bottom field only.
  6717. @item ft
  6718. Use both fields, top first.
  6719. @item fb
  6720. Use both fields, bottom first.
  6721. @end table
  6722. @item planes
  6723. Set which planes to process, by default filter process all frames.
  6724. @item nsize
  6725. Set size of local neighborhood around each pixel, used by the predictor neural
  6726. network.
  6727. Can be one of the following:
  6728. @table @samp
  6729. @item s8x6
  6730. @item s16x6
  6731. @item s32x6
  6732. @item s48x6
  6733. @item s8x4
  6734. @item s16x4
  6735. @item s32x4
  6736. @end table
  6737. @item nns
  6738. Set the number of neurons in predicctor neural network.
  6739. Can be one of the following:
  6740. @table @samp
  6741. @item n16
  6742. @item n32
  6743. @item n64
  6744. @item n128
  6745. @item n256
  6746. @end table
  6747. @item qual
  6748. Controls the number of different neural network predictions that are blended
  6749. together to compute the final output value. Can be @code{fast}, default or
  6750. @code{slow}.
  6751. @item etype
  6752. Set which set of weights to use in the predictor.
  6753. Can be one of the following:
  6754. @table @samp
  6755. @item a
  6756. weights trained to minimize absolute error
  6757. @item s
  6758. weights trained to minimize squared error
  6759. @end table
  6760. @item pscrn
  6761. Controls whether or not the prescreener neural network is used to decide
  6762. which pixels should be processed by the predictor neural network and which
  6763. can be handled by simple cubic interpolation.
  6764. The prescreener is trained to know whether cubic interpolation will be
  6765. sufficient for a pixel or whether it should be predicted by the predictor nn.
  6766. The computational complexity of the prescreener nn is much less than that of
  6767. the predictor nn. Since most pixels can be handled by cubic interpolation,
  6768. using the prescreener generally results in much faster processing.
  6769. The prescreener is pretty accurate, so the difference between using it and not
  6770. using it is almost always unnoticeable.
  6771. Can be one of the following:
  6772. @table @samp
  6773. @item none
  6774. @item original
  6775. @item new
  6776. @end table
  6777. Default is @code{new}.
  6778. @item fapprox
  6779. Set various debugging flags.
  6780. @end table
  6781. @section noformat
  6782. Force libavfilter not to use any of the specified pixel formats for the
  6783. input to the next filter.
  6784. It accepts the following parameters:
  6785. @table @option
  6786. @item pix_fmts
  6787. A '|'-separated list of pixel format names, such as
  6788. apix_fmts=yuv420p|monow|rgb24".
  6789. @end table
  6790. @subsection Examples
  6791. @itemize
  6792. @item
  6793. Force libavfilter to use a format different from @var{yuv420p} for the
  6794. input to the vflip filter:
  6795. @example
  6796. noformat=pix_fmts=yuv420p,vflip
  6797. @end example
  6798. @item
  6799. Convert the input video to any of the formats not contained in the list:
  6800. @example
  6801. noformat=yuv420p|yuv444p|yuv410p
  6802. @end example
  6803. @end itemize
  6804. @section noise
  6805. Add noise on video input frame.
  6806. The filter accepts the following options:
  6807. @table @option
  6808. @item all_seed
  6809. @item c0_seed
  6810. @item c1_seed
  6811. @item c2_seed
  6812. @item c3_seed
  6813. Set noise seed for specific pixel component or all pixel components in case
  6814. of @var{all_seed}. Default value is @code{123457}.
  6815. @item all_strength, alls
  6816. @item c0_strength, c0s
  6817. @item c1_strength, c1s
  6818. @item c2_strength, c2s
  6819. @item c3_strength, c3s
  6820. Set noise strength for specific pixel component or all pixel components in case
  6821. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  6822. @item all_flags, allf
  6823. @item c0_flags, c0f
  6824. @item c1_flags, c1f
  6825. @item c2_flags, c2f
  6826. @item c3_flags, c3f
  6827. Set pixel component flags or set flags for all components if @var{all_flags}.
  6828. Available values for component flags are:
  6829. @table @samp
  6830. @item a
  6831. averaged temporal noise (smoother)
  6832. @item p
  6833. mix random noise with a (semi)regular pattern
  6834. @item t
  6835. temporal noise (noise pattern changes between frames)
  6836. @item u
  6837. uniform noise (gaussian otherwise)
  6838. @end table
  6839. @end table
  6840. @subsection Examples
  6841. Add temporal and uniform noise to input video:
  6842. @example
  6843. noise=alls=20:allf=t+u
  6844. @end example
  6845. @section null
  6846. Pass the video source unchanged to the output.
  6847. @section ocr
  6848. Optical Character Recognition
  6849. This filter uses Tesseract for optical character recognition.
  6850. It accepts the following options:
  6851. @table @option
  6852. @item datapath
  6853. Set datapath to tesseract data. Default is to use whatever was
  6854. set at installation.
  6855. @item language
  6856. Set language, default is "eng".
  6857. @item whitelist
  6858. Set character whitelist.
  6859. @item blacklist
  6860. Set character blacklist.
  6861. @end table
  6862. The filter exports recognized text as the frame metadata @code{lavfi.ocr.text}.
  6863. @section ocv
  6864. Apply a video transform using libopencv.
  6865. To enable this filter, install the libopencv library and headers and
  6866. configure FFmpeg with @code{--enable-libopencv}.
  6867. It accepts the following parameters:
  6868. @table @option
  6869. @item filter_name
  6870. The name of the libopencv filter to apply.
  6871. @item filter_params
  6872. The parameters to pass to the libopencv filter. If not specified, the default
  6873. values are assumed.
  6874. @end table
  6875. Refer to the official libopencv documentation for more precise
  6876. information:
  6877. @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
  6878. Several libopencv filters are supported; see the following subsections.
  6879. @anchor{dilate}
  6880. @subsection dilate
  6881. Dilate an image by using a specific structuring element.
  6882. It corresponds to the libopencv function @code{cvDilate}.
  6883. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  6884. @var{struct_el} represents a structuring element, and has the syntax:
  6885. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  6886. @var{cols} and @var{rows} represent the number of columns and rows of
  6887. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  6888. point, and @var{shape} the shape for the structuring element. @var{shape}
  6889. must be "rect", "cross", "ellipse", or "custom".
  6890. If the value for @var{shape} is "custom", it must be followed by a
  6891. string of the form "=@var{filename}". The file with name
  6892. @var{filename} is assumed to represent a binary image, with each
  6893. printable character corresponding to a bright pixel. When a custom
  6894. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  6895. or columns and rows of the read file are assumed instead.
  6896. The default value for @var{struct_el} is "3x3+0x0/rect".
  6897. @var{nb_iterations} specifies the number of times the transform is
  6898. applied to the image, and defaults to 1.
  6899. Some examples:
  6900. @example
  6901. # Use the default values
  6902. ocv=dilate
  6903. # Dilate using a structuring element with a 5x5 cross, iterating two times
  6904. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  6905. # Read the shape from the file diamond.shape, iterating two times.
  6906. # The file diamond.shape may contain a pattern of characters like this
  6907. # *
  6908. # ***
  6909. # *****
  6910. # ***
  6911. # *
  6912. # The specified columns and rows are ignored
  6913. # but the anchor point coordinates are not
  6914. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  6915. @end example
  6916. @subsection erode
  6917. Erode an image by using a specific structuring element.
  6918. It corresponds to the libopencv function @code{cvErode}.
  6919. It accepts the parameters: @var{struct_el}:@var{nb_iterations},
  6920. with the same syntax and semantics as the @ref{dilate} filter.
  6921. @subsection smooth
  6922. Smooth the input video.
  6923. The filter takes the following parameters:
  6924. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  6925. @var{type} is the type of smooth filter to apply, and must be one of
  6926. the following values: "blur", "blur_no_scale", "median", "gaussian",
  6927. or "bilateral". The default value is "gaussian".
  6928. The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
  6929. depend on the smooth type. @var{param1} and
  6930. @var{param2} accept integer positive values or 0. @var{param3} and
  6931. @var{param4} accept floating point values.
  6932. The default value for @var{param1} is 3. The default value for the
  6933. other parameters is 0.
  6934. These parameters correspond to the parameters assigned to the
  6935. libopencv function @code{cvSmooth}.
  6936. @anchor{overlay}
  6937. @section overlay
  6938. Overlay one video on top of another.
  6939. It takes two inputs and has one output. The first input is the "main"
  6940. video on which the second input is overlaid.
  6941. It accepts the following parameters:
  6942. A description of the accepted options follows.
  6943. @table @option
  6944. @item x
  6945. @item y
  6946. Set the expression for the x and y coordinates of the overlaid video
  6947. on the main video. Default value is "0" for both expressions. In case
  6948. the expression is invalid, it is set to a huge value (meaning that the
  6949. overlay will not be displayed within the output visible area).
  6950. @item eof_action
  6951. The action to take when EOF is encountered on the secondary input; it accepts
  6952. one of the following values:
  6953. @table @option
  6954. @item repeat
  6955. Repeat the last frame (the default).
  6956. @item endall
  6957. End both streams.
  6958. @item pass
  6959. Pass the main input through.
  6960. @end table
  6961. @item eval
  6962. Set when the expressions for @option{x}, and @option{y} are evaluated.
  6963. It accepts the following values:
  6964. @table @samp
  6965. @item init
  6966. only evaluate expressions once during the filter initialization or
  6967. when a command is processed
  6968. @item frame
  6969. evaluate expressions for each incoming frame
  6970. @end table
  6971. Default value is @samp{frame}.
  6972. @item shortest
  6973. If set to 1, force the output to terminate when the shortest input
  6974. terminates. Default value is 0.
  6975. @item format
  6976. Set the format for the output video.
  6977. It accepts the following values:
  6978. @table @samp
  6979. @item yuv420
  6980. force YUV420 output
  6981. @item yuv422
  6982. force YUV422 output
  6983. @item yuv444
  6984. force YUV444 output
  6985. @item rgb
  6986. force RGB output
  6987. @end table
  6988. Default value is @samp{yuv420}.
  6989. @item rgb @emph{(deprecated)}
  6990. If set to 1, force the filter to accept inputs in the RGB
  6991. color space. Default value is 0. This option is deprecated, use
  6992. @option{format} instead.
  6993. @item repeatlast
  6994. If set to 1, force the filter to draw the last overlay frame over the
  6995. main input until the end of the stream. A value of 0 disables this
  6996. behavior. Default value is 1.
  6997. @end table
  6998. The @option{x}, and @option{y} expressions can contain the following
  6999. parameters.
  7000. @table @option
  7001. @item main_w, W
  7002. @item main_h, H
  7003. The main input width and height.
  7004. @item overlay_w, w
  7005. @item overlay_h, h
  7006. The overlay input width and height.
  7007. @item x
  7008. @item y
  7009. The computed values for @var{x} and @var{y}. They are evaluated for
  7010. each new frame.
  7011. @item hsub
  7012. @item vsub
  7013. horizontal and vertical chroma subsample values of the output
  7014. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  7015. @var{vsub} is 1.
  7016. @item n
  7017. the number of input frame, starting from 0
  7018. @item pos
  7019. the position in the file of the input frame, NAN if unknown
  7020. @item t
  7021. The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
  7022. @end table
  7023. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  7024. when evaluation is done @emph{per frame}, and will evaluate to NAN
  7025. when @option{eval} is set to @samp{init}.
  7026. Be aware that frames are taken from each input video in timestamp
  7027. order, hence, if their initial timestamps differ, it is a good idea
  7028. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  7029. have them begin in the same zero timestamp, as the example for
  7030. the @var{movie} filter does.
  7031. You can chain together more overlays but you should test the
  7032. efficiency of such approach.
  7033. @subsection Commands
  7034. This filter supports the following commands:
  7035. @table @option
  7036. @item x
  7037. @item y
  7038. Modify the x and y of the overlay input.
  7039. The command accepts the same syntax of the corresponding option.
  7040. If the specified expression is not valid, it is kept at its current
  7041. value.
  7042. @end table
  7043. @subsection Examples
  7044. @itemize
  7045. @item
  7046. Draw the overlay at 10 pixels from the bottom right corner of the main
  7047. video:
  7048. @example
  7049. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  7050. @end example
  7051. Using named options the example above becomes:
  7052. @example
  7053. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  7054. @end example
  7055. @item
  7056. Insert a transparent PNG logo in the bottom left corner of the input,
  7057. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  7058. @example
  7059. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  7060. @end example
  7061. @item
  7062. Insert 2 different transparent PNG logos (second logo on bottom
  7063. right corner) using the @command{ffmpeg} tool:
  7064. @example
  7065. 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
  7066. @end example
  7067. @item
  7068. Add a transparent color layer on top of the main video; @code{WxH}
  7069. must specify the size of the main input to the overlay filter:
  7070. @example
  7071. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  7072. @end example
  7073. @item
  7074. Play an original video and a filtered version (here with the deshake
  7075. filter) side by side using the @command{ffplay} tool:
  7076. @example
  7077. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  7078. @end example
  7079. The above command is the same as:
  7080. @example
  7081. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  7082. @end example
  7083. @item
  7084. Make a sliding overlay appearing from the left to the right top part of the
  7085. screen starting since time 2:
  7086. @example
  7087. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  7088. @end example
  7089. @item
  7090. Compose output by putting two input videos side to side:
  7091. @example
  7092. ffmpeg -i left.avi -i right.avi -filter_complex "
  7093. nullsrc=size=200x100 [background];
  7094. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  7095. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  7096. [background][left] overlay=shortest=1 [background+left];
  7097. [background+left][right] overlay=shortest=1:x=100 [left+right]
  7098. "
  7099. @end example
  7100. @item
  7101. Mask 10-20 seconds of a video by applying the delogo filter to a section
  7102. @example
  7103. ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
  7104. -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]'
  7105. masked.avi
  7106. @end example
  7107. @item
  7108. Chain several overlays in cascade:
  7109. @example
  7110. nullsrc=s=200x200 [bg];
  7111. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  7112. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  7113. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  7114. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  7115. [in3] null, [mid2] overlay=100:100 [out0]
  7116. @end example
  7117. @end itemize
  7118. @section owdenoise
  7119. Apply Overcomplete Wavelet denoiser.
  7120. The filter accepts the following options:
  7121. @table @option
  7122. @item depth
  7123. Set depth.
  7124. Larger depth values will denoise lower frequency components more, but
  7125. slow down filtering.
  7126. Must be an int in the range 8-16, default is @code{8}.
  7127. @item luma_strength, ls
  7128. Set luma strength.
  7129. Must be a double value in the range 0-1000, default is @code{1.0}.
  7130. @item chroma_strength, cs
  7131. Set chroma strength.
  7132. Must be a double value in the range 0-1000, default is @code{1.0}.
  7133. @end table
  7134. @anchor{pad}
  7135. @section pad
  7136. Add paddings to the input image, and place the original input at the
  7137. provided @var{x}, @var{y} coordinates.
  7138. It accepts the following parameters:
  7139. @table @option
  7140. @item width, w
  7141. @item height, h
  7142. Specify an expression for the size of the output image with the
  7143. paddings added. If the value for @var{width} or @var{height} is 0, the
  7144. corresponding input size is used for the output.
  7145. The @var{width} expression can reference the value set by the
  7146. @var{height} expression, and vice versa.
  7147. The default value of @var{width} and @var{height} is 0.
  7148. @item x
  7149. @item y
  7150. Specify the offsets to place the input image at within the padded area,
  7151. with respect to the top/left border of the output image.
  7152. The @var{x} expression can reference the value set by the @var{y}
  7153. expression, and vice versa.
  7154. The default value of @var{x} and @var{y} is 0.
  7155. @item color
  7156. Specify the color of the padded area. For the syntax of this option,
  7157. check the "Color" section in the ffmpeg-utils manual.
  7158. The default value of @var{color} is "black".
  7159. @end table
  7160. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  7161. options are expressions containing the following constants:
  7162. @table @option
  7163. @item in_w
  7164. @item in_h
  7165. The input video width and height.
  7166. @item iw
  7167. @item ih
  7168. These are the same as @var{in_w} and @var{in_h}.
  7169. @item out_w
  7170. @item out_h
  7171. The output width and height (the size of the padded area), as
  7172. specified by the @var{width} and @var{height} expressions.
  7173. @item ow
  7174. @item oh
  7175. These are the same as @var{out_w} and @var{out_h}.
  7176. @item x
  7177. @item y
  7178. The x and y offsets as specified by the @var{x} and @var{y}
  7179. expressions, or NAN if not yet specified.
  7180. @item a
  7181. same as @var{iw} / @var{ih}
  7182. @item sar
  7183. input sample aspect ratio
  7184. @item dar
  7185. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  7186. @item hsub
  7187. @item vsub
  7188. The horizontal and vertical chroma subsample values. For example for the
  7189. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7190. @end table
  7191. @subsection Examples
  7192. @itemize
  7193. @item
  7194. Add paddings with the color "violet" to the input video. The output video
  7195. size is 640x480, and the top-left corner of the input video is placed at
  7196. column 0, row 40
  7197. @example
  7198. pad=640:480:0:40:violet
  7199. @end example
  7200. The example above is equivalent to the following command:
  7201. @example
  7202. pad=width=640:height=480:x=0:y=40:color=violet
  7203. @end example
  7204. @item
  7205. Pad the input to get an output with dimensions increased by 3/2,
  7206. and put the input video at the center of the padded area:
  7207. @example
  7208. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  7209. @end example
  7210. @item
  7211. Pad the input to get a squared output with size equal to the maximum
  7212. value between the input width and height, and put the input video at
  7213. the center of the padded area:
  7214. @example
  7215. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  7216. @end example
  7217. @item
  7218. Pad the input to get a final w/h ratio of 16:9:
  7219. @example
  7220. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  7221. @end example
  7222. @item
  7223. In case of anamorphic video, in order to set the output display aspect
  7224. correctly, it is necessary to use @var{sar} in the expression,
  7225. according to the relation:
  7226. @example
  7227. (ih * X / ih) * sar = output_dar
  7228. X = output_dar / sar
  7229. @end example
  7230. Thus the previous example needs to be modified to:
  7231. @example
  7232. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  7233. @end example
  7234. @item
  7235. Double the output size and put the input video in the bottom-right
  7236. corner of the output padded area:
  7237. @example
  7238. pad="2*iw:2*ih:ow-iw:oh-ih"
  7239. @end example
  7240. @end itemize
  7241. @anchor{palettegen}
  7242. @section palettegen
  7243. Generate one palette for a whole video stream.
  7244. It accepts the following options:
  7245. @table @option
  7246. @item max_colors
  7247. Set the maximum number of colors to quantize in the palette.
  7248. Note: the palette will still contain 256 colors; the unused palette entries
  7249. will be black.
  7250. @item reserve_transparent
  7251. Create a palette of 255 colors maximum and reserve the last one for
  7252. transparency. Reserving the transparency color is useful for GIF optimization.
  7253. If not set, the maximum of colors in the palette will be 256. You probably want
  7254. to disable this option for a standalone image.
  7255. Set by default.
  7256. @item stats_mode
  7257. Set statistics mode.
  7258. It accepts the following values:
  7259. @table @samp
  7260. @item full
  7261. Compute full frame histograms.
  7262. @item diff
  7263. Compute histograms only for the part that differs from previous frame. This
  7264. might be relevant to give more importance to the moving part of your input if
  7265. the background is static.
  7266. @end table
  7267. Default value is @var{full}.
  7268. @end table
  7269. The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
  7270. (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
  7271. color quantization of the palette. This information is also visible at
  7272. @var{info} logging level.
  7273. @subsection Examples
  7274. @itemize
  7275. @item
  7276. Generate a representative palette of a given video using @command{ffmpeg}:
  7277. @example
  7278. ffmpeg -i input.mkv -vf palettegen palette.png
  7279. @end example
  7280. @end itemize
  7281. @section paletteuse
  7282. Use a palette to downsample an input video stream.
  7283. The filter takes two inputs: one video stream and a palette. The palette must
  7284. be a 256 pixels image.
  7285. It accepts the following options:
  7286. @table @option
  7287. @item dither
  7288. Select dithering mode. Available algorithms are:
  7289. @table @samp
  7290. @item bayer
  7291. Ordered 8x8 bayer dithering (deterministic)
  7292. @item heckbert
  7293. Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
  7294. Note: this dithering is sometimes considered "wrong" and is included as a
  7295. reference.
  7296. @item floyd_steinberg
  7297. Floyd and Steingberg dithering (error diffusion)
  7298. @item sierra2
  7299. Frankie Sierra dithering v2 (error diffusion)
  7300. @item sierra2_4a
  7301. Frankie Sierra dithering v2 "Lite" (error diffusion)
  7302. @end table
  7303. Default is @var{sierra2_4a}.
  7304. @item bayer_scale
  7305. When @var{bayer} dithering is selected, this option defines the scale of the
  7306. pattern (how much the crosshatch pattern is visible). A low value means more
  7307. visible pattern for less banding, and higher value means less visible pattern
  7308. at the cost of more banding.
  7309. The option must be an integer value in the range [0,5]. Default is @var{2}.
  7310. @item diff_mode
  7311. If set, define the zone to process
  7312. @table @samp
  7313. @item rectangle
  7314. Only the changing rectangle will be reprocessed. This is similar to GIF
  7315. cropping/offsetting compression mechanism. This option can be useful for speed
  7316. if only a part of the image is changing, and has use cases such as limiting the
  7317. scope of the error diffusal @option{dither} to the rectangle that bounds the
  7318. moving scene (it leads to more deterministic output if the scene doesn't change
  7319. much, and as a result less moving noise and better GIF compression).
  7320. @end table
  7321. Default is @var{none}.
  7322. @end table
  7323. @subsection Examples
  7324. @itemize
  7325. @item
  7326. Use a palette (generated for example with @ref{palettegen}) to encode a GIF
  7327. using @command{ffmpeg}:
  7328. @example
  7329. ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
  7330. @end example
  7331. @end itemize
  7332. @section perspective
  7333. Correct perspective of video not recorded perpendicular to the screen.
  7334. A description of the accepted parameters follows.
  7335. @table @option
  7336. @item x0
  7337. @item y0
  7338. @item x1
  7339. @item y1
  7340. @item x2
  7341. @item y2
  7342. @item x3
  7343. @item y3
  7344. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  7345. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  7346. If the @code{sense} option is set to @code{source}, then the specified points will be sent
  7347. to the corners of the destination. If the @code{sense} option is set to @code{destination},
  7348. then the corners of the source will be sent to the specified coordinates.
  7349. The expressions can use the following variables:
  7350. @table @option
  7351. @item W
  7352. @item H
  7353. the width and height of video frame.
  7354. @end table
  7355. @item interpolation
  7356. Set interpolation for perspective correction.
  7357. It accepts the following values:
  7358. @table @samp
  7359. @item linear
  7360. @item cubic
  7361. @end table
  7362. Default value is @samp{linear}.
  7363. @item sense
  7364. Set interpretation of coordinate options.
  7365. It accepts the following values:
  7366. @table @samp
  7367. @item 0, source
  7368. Send point in the source specified by the given coordinates to
  7369. the corners of the destination.
  7370. @item 1, destination
  7371. Send the corners of the source to the point in the destination specified
  7372. by the given coordinates.
  7373. Default value is @samp{source}.
  7374. @end table
  7375. @end table
  7376. @section phase
  7377. Delay interlaced video by one field time so that the field order changes.
  7378. The intended use is to fix PAL movies that have been captured with the
  7379. opposite field order to the film-to-video transfer.
  7380. A description of the accepted parameters follows.
  7381. @table @option
  7382. @item mode
  7383. Set phase mode.
  7384. It accepts the following values:
  7385. @table @samp
  7386. @item t
  7387. Capture field order top-first, transfer bottom-first.
  7388. Filter will delay the bottom field.
  7389. @item b
  7390. Capture field order bottom-first, transfer top-first.
  7391. Filter will delay the top field.
  7392. @item p
  7393. Capture and transfer with the same field order. This mode only exists
  7394. for the documentation of the other options to refer to, but if you
  7395. actually select it, the filter will faithfully do nothing.
  7396. @item a
  7397. Capture field order determined automatically by field flags, transfer
  7398. opposite.
  7399. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  7400. basis using field flags. If no field information is available,
  7401. then this works just like @samp{u}.
  7402. @item u
  7403. Capture unknown or varying, transfer opposite.
  7404. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  7405. analyzing the images and selecting the alternative that produces best
  7406. match between the fields.
  7407. @item T
  7408. Capture top-first, transfer unknown or varying.
  7409. Filter selects among @samp{t} and @samp{p} using image analysis.
  7410. @item B
  7411. Capture bottom-first, transfer unknown or varying.
  7412. Filter selects among @samp{b} and @samp{p} using image analysis.
  7413. @item A
  7414. Capture determined by field flags, transfer unknown or varying.
  7415. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  7416. image analysis. If no field information is available, then this works just
  7417. like @samp{U}. This is the default mode.
  7418. @item U
  7419. Both capture and transfer unknown or varying.
  7420. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  7421. @end table
  7422. @end table
  7423. @section pixdesctest
  7424. Pixel format descriptor test filter, mainly useful for internal
  7425. testing. The output video should be equal to the input video.
  7426. For example:
  7427. @example
  7428. format=monow, pixdesctest
  7429. @end example
  7430. can be used to test the monowhite pixel format descriptor definition.
  7431. @section pp
  7432. Enable the specified chain of postprocessing subfilters using libpostproc. This
  7433. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  7434. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  7435. Each subfilter and some options have a short and a long name that can be used
  7436. interchangeably, i.e. dr/dering are the same.
  7437. The filters accept the following options:
  7438. @table @option
  7439. @item subfilters
  7440. Set postprocessing subfilters string.
  7441. @end table
  7442. All subfilters share common options to determine their scope:
  7443. @table @option
  7444. @item a/autoq
  7445. Honor the quality commands for this subfilter.
  7446. @item c/chrom
  7447. Do chrominance filtering, too (default).
  7448. @item y/nochrom
  7449. Do luminance filtering only (no chrominance).
  7450. @item n/noluma
  7451. Do chrominance filtering only (no luminance).
  7452. @end table
  7453. These options can be appended after the subfilter name, separated by a '|'.
  7454. Available subfilters are:
  7455. @table @option
  7456. @item hb/hdeblock[|difference[|flatness]]
  7457. Horizontal deblocking filter
  7458. @table @option
  7459. @item difference
  7460. Difference factor where higher values mean more deblocking (default: @code{32}).
  7461. @item flatness
  7462. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7463. @end table
  7464. @item vb/vdeblock[|difference[|flatness]]
  7465. Vertical deblocking filter
  7466. @table @option
  7467. @item difference
  7468. Difference factor where higher values mean more deblocking (default: @code{32}).
  7469. @item flatness
  7470. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7471. @end table
  7472. @item ha/hadeblock[|difference[|flatness]]
  7473. Accurate horizontal deblocking filter
  7474. @table @option
  7475. @item difference
  7476. Difference factor where higher values mean more deblocking (default: @code{32}).
  7477. @item flatness
  7478. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7479. @end table
  7480. @item va/vadeblock[|difference[|flatness]]
  7481. Accurate vertical deblocking filter
  7482. @table @option
  7483. @item difference
  7484. Difference factor where higher values mean more deblocking (default: @code{32}).
  7485. @item flatness
  7486. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7487. @end table
  7488. @end table
  7489. The horizontal and vertical deblocking filters share the difference and
  7490. flatness values so you cannot set different horizontal and vertical
  7491. thresholds.
  7492. @table @option
  7493. @item h1/x1hdeblock
  7494. Experimental horizontal deblocking filter
  7495. @item v1/x1vdeblock
  7496. Experimental vertical deblocking filter
  7497. @item dr/dering
  7498. Deringing filter
  7499. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  7500. @table @option
  7501. @item threshold1
  7502. larger -> stronger filtering
  7503. @item threshold2
  7504. larger -> stronger filtering
  7505. @item threshold3
  7506. larger -> stronger filtering
  7507. @end table
  7508. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  7509. @table @option
  7510. @item f/fullyrange
  7511. Stretch luminance to @code{0-255}.
  7512. @end table
  7513. @item lb/linblenddeint
  7514. Linear blend deinterlacing filter that deinterlaces the given block by
  7515. filtering all lines with a @code{(1 2 1)} filter.
  7516. @item li/linipoldeint
  7517. Linear interpolating deinterlacing filter that deinterlaces the given block by
  7518. linearly interpolating every second line.
  7519. @item ci/cubicipoldeint
  7520. Cubic interpolating deinterlacing filter deinterlaces the given block by
  7521. cubically interpolating every second line.
  7522. @item md/mediandeint
  7523. Median deinterlacing filter that deinterlaces the given block by applying a
  7524. median filter to every second line.
  7525. @item fd/ffmpegdeint
  7526. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  7527. second line with a @code{(-1 4 2 4 -1)} filter.
  7528. @item l5/lowpass5
  7529. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  7530. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  7531. @item fq/forceQuant[|quantizer]
  7532. Overrides the quantizer table from the input with the constant quantizer you
  7533. specify.
  7534. @table @option
  7535. @item quantizer
  7536. Quantizer to use
  7537. @end table
  7538. @item de/default
  7539. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  7540. @item fa/fast
  7541. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  7542. @item ac
  7543. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  7544. @end table
  7545. @subsection Examples
  7546. @itemize
  7547. @item
  7548. Apply horizontal and vertical deblocking, deringing and automatic
  7549. brightness/contrast:
  7550. @example
  7551. pp=hb/vb/dr/al
  7552. @end example
  7553. @item
  7554. Apply default filters without brightness/contrast correction:
  7555. @example
  7556. pp=de/-al
  7557. @end example
  7558. @item
  7559. Apply default filters and temporal denoiser:
  7560. @example
  7561. pp=default/tmpnoise|1|2|3
  7562. @end example
  7563. @item
  7564. Apply deblocking on luminance only, and switch vertical deblocking on or off
  7565. automatically depending on available CPU time:
  7566. @example
  7567. pp=hb|y/vb|a
  7568. @end example
  7569. @end itemize
  7570. @section pp7
  7571. Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
  7572. similar to spp = 6 with 7 point DCT, where only the center sample is
  7573. used after IDCT.
  7574. The filter accepts the following options:
  7575. @table @option
  7576. @item qp
  7577. Force a constant quantization parameter. It accepts an integer in range
  7578. 0 to 63. If not set, the filter will use the QP from the video stream
  7579. (if available).
  7580. @item mode
  7581. Set thresholding mode. Available modes are:
  7582. @table @samp
  7583. @item hard
  7584. Set hard thresholding.
  7585. @item soft
  7586. Set soft thresholding (better de-ringing effect, but likely blurrier).
  7587. @item medium
  7588. Set medium thresholding (good results, default).
  7589. @end table
  7590. @end table
  7591. @section psnr
  7592. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  7593. Ratio) between two input videos.
  7594. This filter takes in input two input videos, the first input is
  7595. considered the "main" source and is passed unchanged to the
  7596. output. The second input is used as a "reference" video for computing
  7597. the PSNR.
  7598. Both video inputs must have the same resolution and pixel format for
  7599. this filter to work correctly. Also it assumes that both inputs
  7600. have the same number of frames, which are compared one by one.
  7601. The obtained average PSNR is printed through the logging system.
  7602. The filter stores the accumulated MSE (mean squared error) of each
  7603. frame, and at the end of the processing it is averaged across all frames
  7604. equally, and the following formula is applied to obtain the PSNR:
  7605. @example
  7606. PSNR = 10*log10(MAX^2/MSE)
  7607. @end example
  7608. Where MAX is the average of the maximum values of each component of the
  7609. image.
  7610. The description of the accepted parameters follows.
  7611. @table @option
  7612. @item stats_file, f
  7613. If specified the filter will use the named file to save the PSNR of
  7614. each individual frame. When filename equals "-" the data is sent to
  7615. standard output.
  7616. @end table
  7617. The file printed if @var{stats_file} is selected, contains a sequence of
  7618. key/value pairs of the form @var{key}:@var{value} for each compared
  7619. couple of frames.
  7620. A description of each shown parameter follows:
  7621. @table @option
  7622. @item n
  7623. sequential number of the input frame, starting from 1
  7624. @item mse_avg
  7625. Mean Square Error pixel-by-pixel average difference of the compared
  7626. frames, averaged over all the image components.
  7627. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  7628. Mean Square Error pixel-by-pixel average difference of the compared
  7629. frames for the component specified by the suffix.
  7630. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  7631. Peak Signal to Noise ratio of the compared frames for the component
  7632. specified by the suffix.
  7633. @end table
  7634. For example:
  7635. @example
  7636. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  7637. [main][ref] psnr="stats_file=stats.log" [out]
  7638. @end example
  7639. On this example the input file being processed is compared with the
  7640. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  7641. is stored in @file{stats.log}.
  7642. @anchor{pullup}
  7643. @section pullup
  7644. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  7645. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  7646. content.
  7647. The pullup filter is designed to take advantage of future context in making
  7648. its decisions. This filter is stateless in the sense that it does not lock
  7649. onto a pattern to follow, but it instead looks forward to the following
  7650. fields in order to identify matches and rebuild progressive frames.
  7651. To produce content with an even framerate, insert the fps filter after
  7652. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  7653. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  7654. The filter accepts the following options:
  7655. @table @option
  7656. @item jl
  7657. @item jr
  7658. @item jt
  7659. @item jb
  7660. These options set the amount of "junk" to ignore at the left, right, top, and
  7661. bottom of the image, respectively. Left and right are in units of 8 pixels,
  7662. while top and bottom are in units of 2 lines.
  7663. The default is 8 pixels on each side.
  7664. @item sb
  7665. Set the strict breaks. Setting this option to 1 will reduce the chances of
  7666. filter generating an occasional mismatched frame, but it may also cause an
  7667. excessive number of frames to be dropped during high motion sequences.
  7668. Conversely, setting it to -1 will make filter match fields more easily.
  7669. This may help processing of video where there is slight blurring between
  7670. the fields, but may also cause there to be interlaced frames in the output.
  7671. Default value is @code{0}.
  7672. @item mp
  7673. Set the metric plane to use. It accepts the following values:
  7674. @table @samp
  7675. @item l
  7676. Use luma plane.
  7677. @item u
  7678. Use chroma blue plane.
  7679. @item v
  7680. Use chroma red plane.
  7681. @end table
  7682. This option may be set to use chroma plane instead of the default luma plane
  7683. for doing filter's computations. This may improve accuracy on very clean
  7684. source material, but more likely will decrease accuracy, especially if there
  7685. is chroma noise (rainbow effect) or any grayscale video.
  7686. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  7687. load and make pullup usable in realtime on slow machines.
  7688. @end table
  7689. For best results (without duplicated frames in the output file) it is
  7690. necessary to change the output frame rate. For example, to inverse
  7691. telecine NTSC input:
  7692. @example
  7693. ffmpeg -i input -vf pullup -r 24000/1001 ...
  7694. @end example
  7695. @section qp
  7696. Change video quantization parameters (QP).
  7697. The filter accepts the following option:
  7698. @table @option
  7699. @item qp
  7700. Set expression for quantization parameter.
  7701. @end table
  7702. The expression is evaluated through the eval API and can contain, among others,
  7703. the following constants:
  7704. @table @var
  7705. @item known
  7706. 1 if index is not 129, 0 otherwise.
  7707. @item qp
  7708. Sequentional index starting from -129 to 128.
  7709. @end table
  7710. @subsection Examples
  7711. @itemize
  7712. @item
  7713. Some equation like:
  7714. @example
  7715. qp=2+2*sin(PI*qp)
  7716. @end example
  7717. @end itemize
  7718. @section random
  7719. Flush video frames from internal cache of frames into a random order.
  7720. No frame is discarded.
  7721. Inspired by @ref{frei0r} nervous filter.
  7722. @table @option
  7723. @item frames
  7724. Set size in number of frames of internal cache, in range from @code{2} to
  7725. @code{512}. Default is @code{30}.
  7726. @item seed
  7727. Set seed for random number generator, must be an integer included between
  7728. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  7729. less than @code{0}, the filter will try to use a good random seed on a
  7730. best effort basis.
  7731. @end table
  7732. @section removegrain
  7733. The removegrain filter is a spatial denoiser for progressive video.
  7734. @table @option
  7735. @item m0
  7736. Set mode for the first plane.
  7737. @item m1
  7738. Set mode for the second plane.
  7739. @item m2
  7740. Set mode for the third plane.
  7741. @item m3
  7742. Set mode for the fourth plane.
  7743. @end table
  7744. Range of mode is from 0 to 24. Description of each mode follows:
  7745. @table @var
  7746. @item 0
  7747. Leave input plane unchanged. Default.
  7748. @item 1
  7749. Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
  7750. @item 2
  7751. Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
  7752. @item 3
  7753. Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
  7754. @item 4
  7755. Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
  7756. This is equivalent to a median filter.
  7757. @item 5
  7758. Line-sensitive clipping giving the minimal change.
  7759. @item 6
  7760. Line-sensitive clipping, intermediate.
  7761. @item 7
  7762. Line-sensitive clipping, intermediate.
  7763. @item 8
  7764. Line-sensitive clipping, intermediate.
  7765. @item 9
  7766. Line-sensitive clipping on a line where the neighbours pixels are the closest.
  7767. @item 10
  7768. Replaces the target pixel with the closest neighbour.
  7769. @item 11
  7770. [1 2 1] horizontal and vertical kernel blur.
  7771. @item 12
  7772. Same as mode 11.
  7773. @item 13
  7774. Bob mode, interpolates top field from the line where the neighbours
  7775. pixels are the closest.
  7776. @item 14
  7777. Bob mode, interpolates bottom field from the line where the neighbours
  7778. pixels are the closest.
  7779. @item 15
  7780. Bob mode, interpolates top field. Same as 13 but with a more complicated
  7781. interpolation formula.
  7782. @item 16
  7783. Bob mode, interpolates bottom field. Same as 14 but with a more complicated
  7784. interpolation formula.
  7785. @item 17
  7786. Clips the pixel with the minimum and maximum of respectively the maximum and
  7787. minimum of each pair of opposite neighbour pixels.
  7788. @item 18
  7789. Line-sensitive clipping using opposite neighbours whose greatest distance from
  7790. the current pixel is minimal.
  7791. @item 19
  7792. Replaces the pixel with the average of its 8 neighbours.
  7793. @item 20
  7794. Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
  7795. @item 21
  7796. Clips pixels using the averages of opposite neighbour.
  7797. @item 22
  7798. Same as mode 21 but simpler and faster.
  7799. @item 23
  7800. Small edge and halo removal, but reputed useless.
  7801. @item 24
  7802. Similar as 23.
  7803. @end table
  7804. @section removelogo
  7805. Suppress a TV station logo, using an image file to determine which
  7806. pixels comprise the logo. It works by filling in the pixels that
  7807. comprise the logo with neighboring pixels.
  7808. The filter accepts the following options:
  7809. @table @option
  7810. @item filename, f
  7811. Set the filter bitmap file, which can be any image format supported by
  7812. libavformat. The width and height of the image file must match those of the
  7813. video stream being processed.
  7814. @end table
  7815. Pixels in the provided bitmap image with a value of zero are not
  7816. considered part of the logo, non-zero pixels are considered part of
  7817. the logo. If you use white (255) for the logo and black (0) for the
  7818. rest, you will be safe. For making the filter bitmap, it is
  7819. recommended to take a screen capture of a black frame with the logo
  7820. visible, and then using a threshold filter followed by the erode
  7821. filter once or twice.
  7822. If needed, little splotches can be fixed manually. Remember that if
  7823. logo pixels are not covered, the filter quality will be much
  7824. reduced. Marking too many pixels as part of the logo does not hurt as
  7825. much, but it will increase the amount of blurring needed to cover over
  7826. the image and will destroy more information than necessary, and extra
  7827. pixels will slow things down on a large logo.
  7828. @section repeatfields
  7829. This filter uses the repeat_field flag from the Video ES headers and hard repeats
  7830. fields based on its value.
  7831. @section reverse, areverse
  7832. Reverse a clip.
  7833. Warning: This filter requires memory to buffer the entire clip, so trimming
  7834. is suggested.
  7835. @subsection Examples
  7836. @itemize
  7837. @item
  7838. Take the first 5 seconds of a clip, and reverse it.
  7839. @example
  7840. trim=end=5,reverse
  7841. @end example
  7842. @end itemize
  7843. @section rotate
  7844. Rotate video by an arbitrary angle expressed in radians.
  7845. The filter accepts the following options:
  7846. A description of the optional parameters follows.
  7847. @table @option
  7848. @item angle, a
  7849. Set an expression for the angle by which to rotate the input video
  7850. clockwise, expressed as a number of radians. A negative value will
  7851. result in a counter-clockwise rotation. By default it is set to "0".
  7852. This expression is evaluated for each frame.
  7853. @item out_w, ow
  7854. Set the output width expression, default value is "iw".
  7855. This expression is evaluated just once during configuration.
  7856. @item out_h, oh
  7857. Set the output height expression, default value is "ih".
  7858. This expression is evaluated just once during configuration.
  7859. @item bilinear
  7860. Enable bilinear interpolation if set to 1, a value of 0 disables
  7861. it. Default value is 1.
  7862. @item fillcolor, c
  7863. Set the color used to fill the output area not covered by the rotated
  7864. image. For the general syntax of this option, check the "Color" section in the
  7865. ffmpeg-utils manual. If the special value "none" is selected then no
  7866. background is printed (useful for example if the background is never shown).
  7867. Default value is "black".
  7868. @end table
  7869. The expressions for the angle and the output size can contain the
  7870. following constants and functions:
  7871. @table @option
  7872. @item n
  7873. sequential number of the input frame, starting from 0. It is always NAN
  7874. before the first frame is filtered.
  7875. @item t
  7876. time in seconds of the input frame, it is set to 0 when the filter is
  7877. configured. It is always NAN before the first frame is filtered.
  7878. @item hsub
  7879. @item vsub
  7880. horizontal and vertical chroma subsample values. For example for the
  7881. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7882. @item in_w, iw
  7883. @item in_h, ih
  7884. the input video width and height
  7885. @item out_w, ow
  7886. @item out_h, oh
  7887. the output width and height, that is the size of the padded area as
  7888. specified by the @var{width} and @var{height} expressions
  7889. @item rotw(a)
  7890. @item roth(a)
  7891. the minimal width/height required for completely containing the input
  7892. video rotated by @var{a} radians.
  7893. These are only available when computing the @option{out_w} and
  7894. @option{out_h} expressions.
  7895. @end table
  7896. @subsection Examples
  7897. @itemize
  7898. @item
  7899. Rotate the input by PI/6 radians clockwise:
  7900. @example
  7901. rotate=PI/6
  7902. @end example
  7903. @item
  7904. Rotate the input by PI/6 radians counter-clockwise:
  7905. @example
  7906. rotate=-PI/6
  7907. @end example
  7908. @item
  7909. Rotate the input by 45 degrees clockwise:
  7910. @example
  7911. rotate=45*PI/180
  7912. @end example
  7913. @item
  7914. Apply a constant rotation with period T, starting from an angle of PI/3:
  7915. @example
  7916. rotate=PI/3+2*PI*t/T
  7917. @end example
  7918. @item
  7919. Make the input video rotation oscillating with a period of T
  7920. seconds and an amplitude of A radians:
  7921. @example
  7922. rotate=A*sin(2*PI/T*t)
  7923. @end example
  7924. @item
  7925. Rotate the video, output size is chosen so that the whole rotating
  7926. input video is always completely contained in the output:
  7927. @example
  7928. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  7929. @end example
  7930. @item
  7931. Rotate the video, reduce the output size so that no background is ever
  7932. shown:
  7933. @example
  7934. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  7935. @end example
  7936. @end itemize
  7937. @subsection Commands
  7938. The filter supports the following commands:
  7939. @table @option
  7940. @item a, angle
  7941. Set the angle expression.
  7942. The command accepts the same syntax of the corresponding option.
  7943. If the specified expression is not valid, it is kept at its current
  7944. value.
  7945. @end table
  7946. @section sab
  7947. Apply Shape Adaptive Blur.
  7948. The filter accepts the following options:
  7949. @table @option
  7950. @item luma_radius, lr
  7951. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  7952. value is 1.0. A greater value will result in a more blurred image, and
  7953. in slower processing.
  7954. @item luma_pre_filter_radius, lpfr
  7955. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  7956. value is 1.0.
  7957. @item luma_strength, ls
  7958. Set luma maximum difference between pixels to still be considered, must
  7959. be a value in the 0.1-100.0 range, default value is 1.0.
  7960. @item chroma_radius, cr
  7961. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  7962. greater value will result in a more blurred image, and in slower
  7963. processing.
  7964. @item chroma_pre_filter_radius, cpfr
  7965. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  7966. @item chroma_strength, cs
  7967. Set chroma maximum difference between pixels to still be considered,
  7968. must be a value in the 0.1-100.0 range.
  7969. @end table
  7970. Each chroma option value, if not explicitly specified, is set to the
  7971. corresponding luma option value.
  7972. @anchor{scale}
  7973. @section scale
  7974. Scale (resize) the input video, using the libswscale library.
  7975. The scale filter forces the output display aspect ratio to be the same
  7976. of the input, by changing the output sample aspect ratio.
  7977. If the input image format is different from the format requested by
  7978. the next filter, the scale filter will convert the input to the
  7979. requested format.
  7980. @subsection Options
  7981. The filter accepts the following options, or any of the options
  7982. supported by the libswscale scaler.
  7983. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  7984. the complete list of scaler options.
  7985. @table @option
  7986. @item width, w
  7987. @item height, h
  7988. Set the output video dimension expression. Default value is the input
  7989. dimension.
  7990. If the value is 0, the input width is used for the output.
  7991. If one of the values is -1, the scale filter will use a value that
  7992. maintains the aspect ratio of the input image, calculated from the
  7993. other specified dimension. If both of them are -1, the input size is
  7994. used
  7995. If one of the values is -n with n > 1, the scale filter will also use a value
  7996. that maintains the aspect ratio of the input image, calculated from the other
  7997. specified dimension. After that it will, however, make sure that the calculated
  7998. dimension is divisible by n and adjust the value if necessary.
  7999. See below for the list of accepted constants for use in the dimension
  8000. expression.
  8001. @item eval
  8002. Specify when to evaluate @var{width} and @var{height} expression. It accepts the following values:
  8003. @table @samp
  8004. @item init
  8005. Only evaluate expressions once during the filter initialization or when a command is processed.
  8006. @item frame
  8007. Evaluate expressions for each incoming frame.
  8008. @end table
  8009. Default value is @samp{init}.
  8010. @item interl
  8011. Set the interlacing mode. It accepts the following values:
  8012. @table @samp
  8013. @item 1
  8014. Force interlaced aware scaling.
  8015. @item 0
  8016. Do not apply interlaced scaling.
  8017. @item -1
  8018. Select interlaced aware scaling depending on whether the source frames
  8019. are flagged as interlaced or not.
  8020. @end table
  8021. Default value is @samp{0}.
  8022. @item flags
  8023. Set libswscale scaling flags. See
  8024. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  8025. complete list of values. If not explicitly specified the filter applies
  8026. the default flags.
  8027. @item param0, param1
  8028. Set libswscale input parameters for scaling algorithms that need them. See
  8029. @ref{sws_params,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  8030. complete documentation. If not explicitly specified the filter applies
  8031. empty parameters.
  8032. @item size, s
  8033. Set the video size. For the syntax of this option, check the
  8034. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8035. @item in_color_matrix
  8036. @item out_color_matrix
  8037. Set in/output YCbCr color space type.
  8038. This allows the autodetected value to be overridden as well as allows forcing
  8039. a specific value used for the output and encoder.
  8040. If not specified, the color space type depends on the pixel format.
  8041. Possible values:
  8042. @table @samp
  8043. @item auto
  8044. Choose automatically.
  8045. @item bt709
  8046. Format conforming to International Telecommunication Union (ITU)
  8047. Recommendation BT.709.
  8048. @item fcc
  8049. Set color space conforming to the United States Federal Communications
  8050. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  8051. @item bt601
  8052. Set color space conforming to:
  8053. @itemize
  8054. @item
  8055. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  8056. @item
  8057. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  8058. @item
  8059. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  8060. @end itemize
  8061. @item smpte240m
  8062. Set color space conforming to SMPTE ST 240:1999.
  8063. @end table
  8064. @item in_range
  8065. @item out_range
  8066. Set in/output YCbCr sample range.
  8067. This allows the autodetected value to be overridden as well as allows forcing
  8068. a specific value used for the output and encoder. If not specified, the
  8069. range depends on the pixel format. Possible values:
  8070. @table @samp
  8071. @item auto
  8072. Choose automatically.
  8073. @item jpeg/full/pc
  8074. Set full range (0-255 in case of 8-bit luma).
  8075. @item mpeg/tv
  8076. Set "MPEG" range (16-235 in case of 8-bit luma).
  8077. @end table
  8078. @item force_original_aspect_ratio
  8079. Enable decreasing or increasing output video width or height if necessary to
  8080. keep the original aspect ratio. Possible values:
  8081. @table @samp
  8082. @item disable
  8083. Scale the video as specified and disable this feature.
  8084. @item decrease
  8085. The output video dimensions will automatically be decreased if needed.
  8086. @item increase
  8087. The output video dimensions will automatically be increased if needed.
  8088. @end table
  8089. One useful instance of this option is that when you know a specific device's
  8090. maximum allowed resolution, you can use this to limit the output video to
  8091. that, while retaining the aspect ratio. For example, device A allows
  8092. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  8093. decrease) and specifying 1280x720 to the command line makes the output
  8094. 1280x533.
  8095. Please note that this is a different thing than specifying -1 for @option{w}
  8096. or @option{h}, you still need to specify the output resolution for this option
  8097. to work.
  8098. @end table
  8099. The values of the @option{w} and @option{h} options are expressions
  8100. containing the following constants:
  8101. @table @var
  8102. @item in_w
  8103. @item in_h
  8104. The input width and height
  8105. @item iw
  8106. @item ih
  8107. These are the same as @var{in_w} and @var{in_h}.
  8108. @item out_w
  8109. @item out_h
  8110. The output (scaled) width and height
  8111. @item ow
  8112. @item oh
  8113. These are the same as @var{out_w} and @var{out_h}
  8114. @item a
  8115. The same as @var{iw} / @var{ih}
  8116. @item sar
  8117. input sample aspect ratio
  8118. @item dar
  8119. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  8120. @item hsub
  8121. @item vsub
  8122. horizontal and vertical input chroma subsample values. For example for the
  8123. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  8124. @item ohsub
  8125. @item ovsub
  8126. horizontal and vertical output chroma subsample values. For example for the
  8127. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  8128. @end table
  8129. @subsection Examples
  8130. @itemize
  8131. @item
  8132. Scale the input video to a size of 200x100
  8133. @example
  8134. scale=w=200:h=100
  8135. @end example
  8136. This is equivalent to:
  8137. @example
  8138. scale=200:100
  8139. @end example
  8140. or:
  8141. @example
  8142. scale=200x100
  8143. @end example
  8144. @item
  8145. Specify a size abbreviation for the output size:
  8146. @example
  8147. scale=qcif
  8148. @end example
  8149. which can also be written as:
  8150. @example
  8151. scale=size=qcif
  8152. @end example
  8153. @item
  8154. Scale the input to 2x:
  8155. @example
  8156. scale=w=2*iw:h=2*ih
  8157. @end example
  8158. @item
  8159. The above is the same as:
  8160. @example
  8161. scale=2*in_w:2*in_h
  8162. @end example
  8163. @item
  8164. Scale the input to 2x with forced interlaced scaling:
  8165. @example
  8166. scale=2*iw:2*ih:interl=1
  8167. @end example
  8168. @item
  8169. Scale the input to half size:
  8170. @example
  8171. scale=w=iw/2:h=ih/2
  8172. @end example
  8173. @item
  8174. Increase the width, and set the height to the same size:
  8175. @example
  8176. scale=3/2*iw:ow
  8177. @end example
  8178. @item
  8179. Seek Greek harmony:
  8180. @example
  8181. scale=iw:1/PHI*iw
  8182. scale=ih*PHI:ih
  8183. @end example
  8184. @item
  8185. Increase the height, and set the width to 3/2 of the height:
  8186. @example
  8187. scale=w=3/2*oh:h=3/5*ih
  8188. @end example
  8189. @item
  8190. Increase the size, making the size a multiple of the chroma
  8191. subsample values:
  8192. @example
  8193. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  8194. @end example
  8195. @item
  8196. Increase the width to a maximum of 500 pixels,
  8197. keeping the same aspect ratio as the input:
  8198. @example
  8199. scale=w='min(500\, iw*3/2):h=-1'
  8200. @end example
  8201. @end itemize
  8202. @subsection Commands
  8203. This filter supports the following commands:
  8204. @table @option
  8205. @item width, w
  8206. @item height, h
  8207. Set the output video dimension expression.
  8208. The command accepts the same syntax of the corresponding option.
  8209. If the specified expression is not valid, it is kept at its current
  8210. value.
  8211. @end table
  8212. @section scale2ref
  8213. Scale (resize) the input video, based on a reference video.
  8214. See the scale filter for available options, scale2ref supports the same but
  8215. uses the reference video instead of the main input as basis.
  8216. @subsection Examples
  8217. @itemize
  8218. @item
  8219. Scale a subtitle stream to match the main video in size before overlaying
  8220. @example
  8221. 'scale2ref[b][a];[a][b]overlay'
  8222. @end example
  8223. @end itemize
  8224. @section selectivecolor
  8225. Adjust cyan, magenta, yellow and black (CMYK) to certain ranges of colors (such
  8226. as "reds", "yellows", "greens", "cyans", ...). The adjustment range is defined
  8227. by the "purity" of the color (that is, how saturated it already is).
  8228. This filter is similar to the Adobe Photoshop Selective Color tool.
  8229. The filter accepts the following options:
  8230. @table @option
  8231. @item correction_method
  8232. Select color correction method.
  8233. Available values are:
  8234. @table @samp
  8235. @item absolute
  8236. Specified adjustments are applied "as-is" (added/subtracted to original pixel
  8237. component value).
  8238. @item relative
  8239. Specified adjustments are relative to the original component value.
  8240. @end table
  8241. Default is @code{absolute}.
  8242. @item reds
  8243. Adjustments for red pixels (pixels where the red component is the maximum)
  8244. @item yellows
  8245. Adjustments for yellow pixels (pixels where the blue component is the minimum)
  8246. @item greens
  8247. Adjustments for green pixels (pixels where the green component is the maximum)
  8248. @item cyans
  8249. Adjustments for cyan pixels (pixels where the red component is the minimum)
  8250. @item blues
  8251. Adjustments for blue pixels (pixels where the blue component is the maximum)
  8252. @item magentas
  8253. Adjustments for magenta pixels (pixels where the green component is the minimum)
  8254. @item whites
  8255. Adjustments for white pixels (pixels where all components are greater than 128)
  8256. @item neutrals
  8257. Adjustments for all pixels except pure black and pure white
  8258. @item blacks
  8259. Adjustments for black pixels (pixels where all components are lesser than 128)
  8260. @item psfile
  8261. Specify a Photoshop selective color file (@code{.asv}) to import the settings from.
  8262. @end table
  8263. All the adjustment settings (@option{reds}, @option{yellows}, ...) accept up to
  8264. 4 space separated floating point adjustment values in the [-1,1] range,
  8265. respectively to adjust the amount of cyan, magenta, yellow and black for the
  8266. pixels of its range.
  8267. @subsection Examples
  8268. @itemize
  8269. @item
  8270. Increase cyan by 50% and reduce yellow by 33% in every green areas, and
  8271. increase magenta by 27% in blue areas:
  8272. @example
  8273. selectivecolor=greens=.5 0 -.33 0:blues=0 .27
  8274. @end example
  8275. @item
  8276. Use a Photoshop selective color preset:
  8277. @example
  8278. selectivecolor=psfile=MySelectiveColorPresets/Misty.asv
  8279. @end example
  8280. @end itemize
  8281. @section separatefields
  8282. The @code{separatefields} takes a frame-based video input and splits
  8283. each frame into its components fields, producing a new half height clip
  8284. with twice the frame rate and twice the frame count.
  8285. This filter use field-dominance information in frame to decide which
  8286. of each pair of fields to place first in the output.
  8287. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  8288. @section setdar, setsar
  8289. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  8290. output video.
  8291. This is done by changing the specified Sample (aka Pixel) Aspect
  8292. Ratio, according to the following equation:
  8293. @example
  8294. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  8295. @end example
  8296. Keep in mind that the @code{setdar} filter does not modify the pixel
  8297. dimensions of the video frame. Also, the display aspect ratio set by
  8298. this filter may be changed by later filters in the filterchain,
  8299. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  8300. applied.
  8301. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  8302. the filter output video.
  8303. Note that as a consequence of the application of this filter, the
  8304. output display aspect ratio will change according to the equation
  8305. above.
  8306. Keep in mind that the sample aspect ratio set by the @code{setsar}
  8307. filter may be changed by later filters in the filterchain, e.g. if
  8308. another "setsar" or a "setdar" filter is applied.
  8309. It accepts the following parameters:
  8310. @table @option
  8311. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  8312. Set the aspect ratio used by the filter.
  8313. The parameter can be a floating point number string, an expression, or
  8314. a string of the form @var{num}:@var{den}, where @var{num} and
  8315. @var{den} are the numerator and denominator of the aspect ratio. If
  8316. the parameter is not specified, it is assumed the value "0".
  8317. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  8318. should be escaped.
  8319. @item max
  8320. Set the maximum integer value to use for expressing numerator and
  8321. denominator when reducing the expressed aspect ratio to a rational.
  8322. Default value is @code{100}.
  8323. @end table
  8324. The parameter @var{sar} is an expression containing
  8325. the following constants:
  8326. @table @option
  8327. @item E, PI, PHI
  8328. These are approximated values for the mathematical constants e
  8329. (Euler's number), pi (Greek pi), and phi (the golden ratio).
  8330. @item w, h
  8331. The input width and height.
  8332. @item a
  8333. These are the same as @var{w} / @var{h}.
  8334. @item sar
  8335. The input sample aspect ratio.
  8336. @item dar
  8337. The input display aspect ratio. It is the same as
  8338. (@var{w} / @var{h}) * @var{sar}.
  8339. @item hsub, vsub
  8340. Horizontal and vertical chroma subsample values. For example, for the
  8341. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  8342. @end table
  8343. @subsection Examples
  8344. @itemize
  8345. @item
  8346. To change the display aspect ratio to 16:9, specify one of the following:
  8347. @example
  8348. setdar=dar=1.77777
  8349. setdar=dar=16/9
  8350. setdar=dar=1.77777
  8351. @end example
  8352. @item
  8353. To change the sample aspect ratio to 10:11, specify:
  8354. @example
  8355. setsar=sar=10/11
  8356. @end example
  8357. @item
  8358. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  8359. 1000 in the aspect ratio reduction, use the command:
  8360. @example
  8361. setdar=ratio=16/9:max=1000
  8362. @end example
  8363. @end itemize
  8364. @anchor{setfield}
  8365. @section setfield
  8366. Force field for the output video frame.
  8367. The @code{setfield} filter marks the interlace type field for the
  8368. output frames. It does not change the input frame, but only sets the
  8369. corresponding property, which affects how the frame is treated by
  8370. following filters (e.g. @code{fieldorder} or @code{yadif}).
  8371. The filter accepts the following options:
  8372. @table @option
  8373. @item mode
  8374. Available values are:
  8375. @table @samp
  8376. @item auto
  8377. Keep the same field property.
  8378. @item bff
  8379. Mark the frame as bottom-field-first.
  8380. @item tff
  8381. Mark the frame as top-field-first.
  8382. @item prog
  8383. Mark the frame as progressive.
  8384. @end table
  8385. @end table
  8386. @section showinfo
  8387. Show a line containing various information for each input video frame.
  8388. The input video is not modified.
  8389. The shown line contains a sequence of key/value pairs of the form
  8390. @var{key}:@var{value}.
  8391. The following values are shown in the output:
  8392. @table @option
  8393. @item n
  8394. The (sequential) number of the input frame, starting from 0.
  8395. @item pts
  8396. The Presentation TimeStamp of the input frame, expressed as a number of
  8397. time base units. The time base unit depends on the filter input pad.
  8398. @item pts_time
  8399. The Presentation TimeStamp of the input frame, expressed as a number of
  8400. seconds.
  8401. @item pos
  8402. The position of the frame in the input stream, or -1 if this information is
  8403. unavailable and/or meaningless (for example in case of synthetic video).
  8404. @item fmt
  8405. The pixel format name.
  8406. @item sar
  8407. The sample aspect ratio of the input frame, expressed in the form
  8408. @var{num}/@var{den}.
  8409. @item s
  8410. The size of the input frame. For the syntax of this option, check the
  8411. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8412. @item i
  8413. The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
  8414. for bottom field first).
  8415. @item iskey
  8416. This is 1 if the frame is a key frame, 0 otherwise.
  8417. @item type
  8418. The picture type of the input frame ("I" for an I-frame, "P" for a
  8419. P-frame, "B" for a B-frame, or "?" for an unknown type).
  8420. Also refer to the documentation of the @code{AVPictureType} enum and of
  8421. the @code{av_get_picture_type_char} function defined in
  8422. @file{libavutil/avutil.h}.
  8423. @item checksum
  8424. The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
  8425. @item plane_checksum
  8426. The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  8427. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
  8428. @end table
  8429. @section showpalette
  8430. Displays the 256 colors palette of each frame. This filter is only relevant for
  8431. @var{pal8} pixel format frames.
  8432. It accepts the following option:
  8433. @table @option
  8434. @item s
  8435. Set the size of the box used to represent one palette color entry. Default is
  8436. @code{30} (for a @code{30x30} pixel box).
  8437. @end table
  8438. @section shuffleframes
  8439. Reorder and/or duplicate video frames.
  8440. It accepts the following parameters:
  8441. @table @option
  8442. @item mapping
  8443. Set the destination indexes of input frames.
  8444. This is space or '|' separated list of indexes that maps input frames to output
  8445. frames. Number of indexes also sets maximal value that each index may have.
  8446. @end table
  8447. The first frame has the index 0. The default is to keep the input unchanged.
  8448. Swap second and third frame of every three frames of the input:
  8449. @example
  8450. ffmpeg -i INPUT -vf "shuffleframes=0 2 1" OUTPUT
  8451. @end example
  8452. @section shuffleplanes
  8453. Reorder and/or duplicate video planes.
  8454. It accepts the following parameters:
  8455. @table @option
  8456. @item map0
  8457. The index of the input plane to be used as the first output plane.
  8458. @item map1
  8459. The index of the input plane to be used as the second output plane.
  8460. @item map2
  8461. The index of the input plane to be used as the third output plane.
  8462. @item map3
  8463. The index of the input plane to be used as the fourth output plane.
  8464. @end table
  8465. The first plane has the index 0. The default is to keep the input unchanged.
  8466. Swap the second and third planes of the input:
  8467. @example
  8468. ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
  8469. @end example
  8470. @anchor{signalstats}
  8471. @section signalstats
  8472. Evaluate various visual metrics that assist in determining issues associated
  8473. with the digitization of analog video media.
  8474. By default the filter will log these metadata values:
  8475. @table @option
  8476. @item YMIN
  8477. Display the minimal Y value contained within the input frame. Expressed in
  8478. range of [0-255].
  8479. @item YLOW
  8480. Display the Y value at the 10% percentile within the input frame. Expressed in
  8481. range of [0-255].
  8482. @item YAVG
  8483. Display the average Y value within the input frame. Expressed in range of
  8484. [0-255].
  8485. @item YHIGH
  8486. Display the Y value at the 90% percentile within the input frame. Expressed in
  8487. range of [0-255].
  8488. @item YMAX
  8489. Display the maximum Y value contained within the input frame. Expressed in
  8490. range of [0-255].
  8491. @item UMIN
  8492. Display the minimal U value contained within the input frame. Expressed in
  8493. range of [0-255].
  8494. @item ULOW
  8495. Display the U value at the 10% percentile within the input frame. Expressed in
  8496. range of [0-255].
  8497. @item UAVG
  8498. Display the average U value within the input frame. Expressed in range of
  8499. [0-255].
  8500. @item UHIGH
  8501. Display the U value at the 90% percentile within the input frame. Expressed in
  8502. range of [0-255].
  8503. @item UMAX
  8504. Display the maximum U value contained within the input frame. Expressed in
  8505. range of [0-255].
  8506. @item VMIN
  8507. Display the minimal V value contained within the input frame. Expressed in
  8508. range of [0-255].
  8509. @item VLOW
  8510. Display the V value at the 10% percentile within the input frame. Expressed in
  8511. range of [0-255].
  8512. @item VAVG
  8513. Display the average V value within the input frame. Expressed in range of
  8514. [0-255].
  8515. @item VHIGH
  8516. Display the V value at the 90% percentile within the input frame. Expressed in
  8517. range of [0-255].
  8518. @item VMAX
  8519. Display the maximum V value contained within the input frame. Expressed in
  8520. range of [0-255].
  8521. @item SATMIN
  8522. Display the minimal saturation value contained within the input frame.
  8523. Expressed in range of [0-~181.02].
  8524. @item SATLOW
  8525. Display the saturation value at the 10% percentile within the input frame.
  8526. Expressed in range of [0-~181.02].
  8527. @item SATAVG
  8528. Display the average saturation value within the input frame. Expressed in range
  8529. of [0-~181.02].
  8530. @item SATHIGH
  8531. Display the saturation value at the 90% percentile within the input frame.
  8532. Expressed in range of [0-~181.02].
  8533. @item SATMAX
  8534. Display the maximum saturation value contained within the input frame.
  8535. Expressed in range of [0-~181.02].
  8536. @item HUEMED
  8537. Display the median value for hue within the input frame. Expressed in range of
  8538. [0-360].
  8539. @item HUEAVG
  8540. Display the average value for hue within the input frame. Expressed in range of
  8541. [0-360].
  8542. @item YDIF
  8543. Display the average of sample value difference between all values of the Y
  8544. plane in the current frame and corresponding values of the previous input frame.
  8545. Expressed in range of [0-255].
  8546. @item UDIF
  8547. Display the average of sample value difference between all values of the U
  8548. plane in the current frame and corresponding values of the previous input frame.
  8549. Expressed in range of [0-255].
  8550. @item VDIF
  8551. Display the average of sample value difference between all values of the V
  8552. plane in the current frame and corresponding values of the previous input frame.
  8553. Expressed in range of [0-255].
  8554. @end table
  8555. The filter accepts the following options:
  8556. @table @option
  8557. @item stat
  8558. @item out
  8559. @option{stat} specify an additional form of image analysis.
  8560. @option{out} output video with the specified type of pixel highlighted.
  8561. Both options accept the following values:
  8562. @table @samp
  8563. @item tout
  8564. Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
  8565. unlike the neighboring pixels of the same field. Examples of temporal outliers
  8566. include the results of video dropouts, head clogs, or tape tracking issues.
  8567. @item vrep
  8568. Identify @var{vertical line repetition}. Vertical line repetition includes
  8569. similar rows of pixels within a frame. In born-digital video vertical line
  8570. repetition is common, but this pattern is uncommon in video digitized from an
  8571. analog source. When it occurs in video that results from the digitization of an
  8572. analog source it can indicate concealment from a dropout compensator.
  8573. @item brng
  8574. Identify pixels that fall outside of legal broadcast range.
  8575. @end table
  8576. @item color, c
  8577. Set the highlight color for the @option{out} option. The default color is
  8578. yellow.
  8579. @end table
  8580. @subsection Examples
  8581. @itemize
  8582. @item
  8583. Output data of various video metrics:
  8584. @example
  8585. ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
  8586. @end example
  8587. @item
  8588. Output specific data about the minimum and maximum values of the Y plane per frame:
  8589. @example
  8590. ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
  8591. @end example
  8592. @item
  8593. Playback video while highlighting pixels that are outside of broadcast range in red.
  8594. @example
  8595. ffplay example.mov -vf signalstats="out=brng:color=red"
  8596. @end example
  8597. @item
  8598. Playback video with signalstats metadata drawn over the frame.
  8599. @example
  8600. ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
  8601. @end example
  8602. The contents of signalstat_drawtext.txt used in the command are:
  8603. @example
  8604. time %@{pts:hms@}
  8605. Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
  8606. U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
  8607. V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
  8608. saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
  8609. @end example
  8610. @end itemize
  8611. @anchor{smartblur}
  8612. @section smartblur
  8613. Blur the input video without impacting the outlines.
  8614. It accepts the following options:
  8615. @table @option
  8616. @item luma_radius, lr
  8617. Set the luma radius. The option value must be a float number in
  8618. the range [0.1,5.0] that specifies the variance of the gaussian filter
  8619. used to blur the image (slower if larger). Default value is 1.0.
  8620. @item luma_strength, ls
  8621. Set the luma strength. The option value must be a float number
  8622. in the range [-1.0,1.0] that configures the blurring. A value included
  8623. in [0.0,1.0] will blur the image whereas a value included in
  8624. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  8625. @item luma_threshold, lt
  8626. Set the luma threshold used as a coefficient to determine
  8627. whether a pixel should be blurred or not. The option value must be an
  8628. integer in the range [-30,30]. A value of 0 will filter all the image,
  8629. a value included in [0,30] will filter flat areas and a value included
  8630. in [-30,0] will filter edges. Default value is 0.
  8631. @item chroma_radius, cr
  8632. Set the chroma radius. The option value must be a float number in
  8633. the range [0.1,5.0] that specifies the variance of the gaussian filter
  8634. used to blur the image (slower if larger). Default value is 1.0.
  8635. @item chroma_strength, cs
  8636. Set the chroma strength. The option value must be a float number
  8637. in the range [-1.0,1.0] that configures the blurring. A value included
  8638. in [0.0,1.0] will blur the image whereas a value included in
  8639. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  8640. @item chroma_threshold, ct
  8641. Set the chroma threshold used as a coefficient to determine
  8642. whether a pixel should be blurred or not. The option value must be an
  8643. integer in the range [-30,30]. A value of 0 will filter all the image,
  8644. a value included in [0,30] will filter flat areas and a value included
  8645. in [-30,0] will filter edges. Default value is 0.
  8646. @end table
  8647. If a chroma option is not explicitly set, the corresponding luma value
  8648. is set.
  8649. @section ssim
  8650. Obtain the SSIM (Structural SImilarity Metric) between two input videos.
  8651. This filter takes in input two input videos, the first input is
  8652. considered the "main" source and is passed unchanged to the
  8653. output. The second input is used as a "reference" video for computing
  8654. the SSIM.
  8655. Both video inputs must have the same resolution and pixel format for
  8656. this filter to work correctly. Also it assumes that both inputs
  8657. have the same number of frames, which are compared one by one.
  8658. The filter stores the calculated SSIM of each frame.
  8659. The description of the accepted parameters follows.
  8660. @table @option
  8661. @item stats_file, f
  8662. If specified the filter will use the named file to save the SSIM of
  8663. each individual frame. When filename equals "-" the data is sent to
  8664. standard output.
  8665. @end table
  8666. The file printed if @var{stats_file} is selected, contains a sequence of
  8667. key/value pairs of the form @var{key}:@var{value} for each compared
  8668. couple of frames.
  8669. A description of each shown parameter follows:
  8670. @table @option
  8671. @item n
  8672. sequential number of the input frame, starting from 1
  8673. @item Y, U, V, R, G, B
  8674. SSIM of the compared frames for the component specified by the suffix.
  8675. @item All
  8676. SSIM of the compared frames for the whole frame.
  8677. @item dB
  8678. Same as above but in dB representation.
  8679. @end table
  8680. For example:
  8681. @example
  8682. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  8683. [main][ref] ssim="stats_file=stats.log" [out]
  8684. @end example
  8685. On this example the input file being processed is compared with the
  8686. reference file @file{ref_movie.mpg}. The SSIM of each individual frame
  8687. is stored in @file{stats.log}.
  8688. Another example with both psnr and ssim at same time:
  8689. @example
  8690. ffmpeg -i main.mpg -i ref.mpg -lavfi "ssim;[0:v][1:v]psnr" -f null -
  8691. @end example
  8692. @section stereo3d
  8693. Convert between different stereoscopic image formats.
  8694. The filters accept the following options:
  8695. @table @option
  8696. @item in
  8697. Set stereoscopic image format of input.
  8698. Available values for input image formats are:
  8699. @table @samp
  8700. @item sbsl
  8701. side by side parallel (left eye left, right eye right)
  8702. @item sbsr
  8703. side by side crosseye (right eye left, left eye right)
  8704. @item sbs2l
  8705. side by side parallel with half width resolution
  8706. (left eye left, right eye right)
  8707. @item sbs2r
  8708. side by side crosseye with half width resolution
  8709. (right eye left, left eye right)
  8710. @item abl
  8711. above-below (left eye above, right eye below)
  8712. @item abr
  8713. above-below (right eye above, left eye below)
  8714. @item ab2l
  8715. above-below with half height resolution
  8716. (left eye above, right eye below)
  8717. @item ab2r
  8718. above-below with half height resolution
  8719. (right eye above, left eye below)
  8720. @item al
  8721. alternating frames (left eye first, right eye second)
  8722. @item ar
  8723. alternating frames (right eye first, left eye second)
  8724. @item irl
  8725. interleaved rows (left eye has top row, right eye starts on next row)
  8726. @item irr
  8727. interleaved rows (right eye has top row, left eye starts on next row)
  8728. @item icl
  8729. interleaved columns, left eye first
  8730. @item icr
  8731. interleaved columns, right eye first
  8732. Default value is @samp{sbsl}.
  8733. @end table
  8734. @item out
  8735. Set stereoscopic image format of output.
  8736. @table @samp
  8737. @item sbsl
  8738. side by side parallel (left eye left, right eye right)
  8739. @item sbsr
  8740. side by side crosseye (right eye left, left eye right)
  8741. @item sbs2l
  8742. side by side parallel with half width resolution
  8743. (left eye left, right eye right)
  8744. @item sbs2r
  8745. side by side crosseye with half width resolution
  8746. (right eye left, left eye right)
  8747. @item abl
  8748. above-below (left eye above, right eye below)
  8749. @item abr
  8750. above-below (right eye above, left eye below)
  8751. @item ab2l
  8752. above-below with half height resolution
  8753. (left eye above, right eye below)
  8754. @item ab2r
  8755. above-below with half height resolution
  8756. (right eye above, left eye below)
  8757. @item al
  8758. alternating frames (left eye first, right eye second)
  8759. @item ar
  8760. alternating frames (right eye first, left eye second)
  8761. @item irl
  8762. interleaved rows (left eye has top row, right eye starts on next row)
  8763. @item irr
  8764. interleaved rows (right eye has top row, left eye starts on next row)
  8765. @item arbg
  8766. anaglyph red/blue gray
  8767. (red filter on left eye, blue filter on right eye)
  8768. @item argg
  8769. anaglyph red/green gray
  8770. (red filter on left eye, green filter on right eye)
  8771. @item arcg
  8772. anaglyph red/cyan gray
  8773. (red filter on left eye, cyan filter on right eye)
  8774. @item arch
  8775. anaglyph red/cyan half colored
  8776. (red filter on left eye, cyan filter on right eye)
  8777. @item arcc
  8778. anaglyph red/cyan color
  8779. (red filter on left eye, cyan filter on right eye)
  8780. @item arcd
  8781. anaglyph red/cyan color optimized with the least squares projection of dubois
  8782. (red filter on left eye, cyan filter on right eye)
  8783. @item agmg
  8784. anaglyph green/magenta gray
  8785. (green filter on left eye, magenta filter on right eye)
  8786. @item agmh
  8787. anaglyph green/magenta half colored
  8788. (green filter on left eye, magenta filter on right eye)
  8789. @item agmc
  8790. anaglyph green/magenta colored
  8791. (green filter on left eye, magenta filter on right eye)
  8792. @item agmd
  8793. anaglyph green/magenta color optimized with the least squares projection of dubois
  8794. (green filter on left eye, magenta filter on right eye)
  8795. @item aybg
  8796. anaglyph yellow/blue gray
  8797. (yellow filter on left eye, blue filter on right eye)
  8798. @item aybh
  8799. anaglyph yellow/blue half colored
  8800. (yellow filter on left eye, blue filter on right eye)
  8801. @item aybc
  8802. anaglyph yellow/blue colored
  8803. (yellow filter on left eye, blue filter on right eye)
  8804. @item aybd
  8805. anaglyph yellow/blue color optimized with the least squares projection of dubois
  8806. (yellow filter on left eye, blue filter on right eye)
  8807. @item ml
  8808. mono output (left eye only)
  8809. @item mr
  8810. mono output (right eye only)
  8811. @item chl
  8812. checkerboard, left eye first
  8813. @item chr
  8814. checkerboard, right eye first
  8815. @item icl
  8816. interleaved columns, left eye first
  8817. @item icr
  8818. interleaved columns, right eye first
  8819. @end table
  8820. Default value is @samp{arcd}.
  8821. @end table
  8822. @subsection Examples
  8823. @itemize
  8824. @item
  8825. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  8826. @example
  8827. stereo3d=sbsl:aybd
  8828. @end example
  8829. @item
  8830. Convert input video from above below (left eye above, right eye below) to side by side crosseye.
  8831. @example
  8832. stereo3d=abl:sbsr
  8833. @end example
  8834. @end itemize
  8835. @section streamselect, astreamselect
  8836. Select video or audio streams.
  8837. The filter accepts the following options:
  8838. @table @option
  8839. @item inputs
  8840. Set number of inputs. Default is 2.
  8841. @item map
  8842. Set input indexes to remap to outputs.
  8843. @end table
  8844. @subsection Commands
  8845. The @code{streamselect} and @code{astreamselect} filter supports the following
  8846. commands:
  8847. @table @option
  8848. @item map
  8849. Set input indexes to remap to outputs.
  8850. @end table
  8851. @subsection Examples
  8852. @itemize
  8853. @item
  8854. Select first 5 seconds 1st stream and rest of time 2nd stream:
  8855. @example
  8856. sendcmd='5.0 streamselect map 1',streamselect=inputs=2:map=0
  8857. @end example
  8858. @item
  8859. Same as above, but for audio:
  8860. @example
  8861. asendcmd='5.0 astreamselect map 1',astreamselect=inputs=2:map=0
  8862. @end example
  8863. @end itemize
  8864. @anchor{spp}
  8865. @section spp
  8866. Apply a simple postprocessing filter that compresses and decompresses the image
  8867. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  8868. and average the results.
  8869. The filter accepts the following options:
  8870. @table @option
  8871. @item quality
  8872. Set quality. This option defines the number of levels for averaging. It accepts
  8873. an integer in the range 0-6. If set to @code{0}, the filter will have no
  8874. effect. A value of @code{6} means the higher quality. For each increment of
  8875. that value the speed drops by a factor of approximately 2. Default value is
  8876. @code{3}.
  8877. @item qp
  8878. Force a constant quantization parameter. If not set, the filter will use the QP
  8879. from the video stream (if available).
  8880. @item mode
  8881. Set thresholding mode. Available modes are:
  8882. @table @samp
  8883. @item hard
  8884. Set hard thresholding (default).
  8885. @item soft
  8886. Set soft thresholding (better de-ringing effect, but likely blurrier).
  8887. @end table
  8888. @item use_bframe_qp
  8889. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  8890. option may cause flicker since the B-Frames have often larger QP. Default is
  8891. @code{0} (not enabled).
  8892. @end table
  8893. @anchor{subtitles}
  8894. @section subtitles
  8895. Draw subtitles on top of input video using the libass library.
  8896. To enable compilation of this filter you need to configure FFmpeg with
  8897. @code{--enable-libass}. This filter also requires a build with libavcodec and
  8898. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  8899. Alpha) subtitles format.
  8900. The filter accepts the following options:
  8901. @table @option
  8902. @item filename, f
  8903. Set the filename of the subtitle file to read. It must be specified.
  8904. @item original_size
  8905. Specify the size of the original video, the video for which the ASS file
  8906. was composed. For the syntax of this option, check the
  8907. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8908. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
  8909. correctly scale the fonts if the aspect ratio has been changed.
  8910. @item fontsdir
  8911. Set a directory path containing fonts that can be used by the filter.
  8912. These fonts will be used in addition to whatever the font provider uses.
  8913. @item charenc
  8914. Set subtitles input character encoding. @code{subtitles} filter only. Only
  8915. useful if not UTF-8.
  8916. @item stream_index, si
  8917. Set subtitles stream index. @code{subtitles} filter only.
  8918. @item force_style
  8919. Override default style or script info parameters of the subtitles. It accepts a
  8920. string containing ASS style format @code{KEY=VALUE} couples separated by ",".
  8921. @end table
  8922. If the first key is not specified, it is assumed that the first value
  8923. specifies the @option{filename}.
  8924. For example, to render the file @file{sub.srt} on top of the input
  8925. video, use the command:
  8926. @example
  8927. subtitles=sub.srt
  8928. @end example
  8929. which is equivalent to:
  8930. @example
  8931. subtitles=filename=sub.srt
  8932. @end example
  8933. To render the default subtitles stream from file @file{video.mkv}, use:
  8934. @example
  8935. subtitles=video.mkv
  8936. @end example
  8937. To render the second subtitles stream from that file, use:
  8938. @example
  8939. subtitles=video.mkv:si=1
  8940. @end example
  8941. To make the subtitles stream from @file{sub.srt} appear in transparent green
  8942. @code{DejaVu Serif}, use:
  8943. @example
  8944. subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
  8945. @end example
  8946. @section super2xsai
  8947. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  8948. Interpolate) pixel art scaling algorithm.
  8949. Useful for enlarging pixel art images without reducing sharpness.
  8950. @section swaprect
  8951. Swap two rectangular objects in video.
  8952. This filter accepts the following options:
  8953. @table @option
  8954. @item w
  8955. Set object width.
  8956. @item h
  8957. Set object height.
  8958. @item x1
  8959. Set 1st rect x coordinate.
  8960. @item y1
  8961. Set 1st rect y coordinate.
  8962. @item x2
  8963. Set 2nd rect x coordinate.
  8964. @item y2
  8965. Set 2nd rect y coordinate.
  8966. All expressions are evaluated once for each frame.
  8967. @end table
  8968. The all options are expressions containing the following constants:
  8969. @table @option
  8970. @item w
  8971. @item h
  8972. The input width and height.
  8973. @item a
  8974. same as @var{w} / @var{h}
  8975. @item sar
  8976. input sample aspect ratio
  8977. @item dar
  8978. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  8979. @item n
  8980. The number of the input frame, starting from 0.
  8981. @item t
  8982. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  8983. @item pos
  8984. the position in the file of the input frame, NAN if unknown
  8985. @end table
  8986. @section swapuv
  8987. Swap U & V plane.
  8988. @section telecine
  8989. Apply telecine process to the video.
  8990. This filter accepts the following options:
  8991. @table @option
  8992. @item first_field
  8993. @table @samp
  8994. @item top, t
  8995. top field first
  8996. @item bottom, b
  8997. bottom field first
  8998. The default value is @code{top}.
  8999. @end table
  9000. @item pattern
  9001. A string of numbers representing the pulldown pattern you wish to apply.
  9002. The default value is @code{23}.
  9003. @end table
  9004. @example
  9005. Some typical patterns:
  9006. NTSC output (30i):
  9007. 27.5p: 32222
  9008. 24p: 23 (classic)
  9009. 24p: 2332 (preferred)
  9010. 20p: 33
  9011. 18p: 334
  9012. 16p: 3444
  9013. PAL output (25i):
  9014. 27.5p: 12222
  9015. 24p: 222222222223 ("Euro pulldown")
  9016. 16.67p: 33
  9017. 16p: 33333334
  9018. @end example
  9019. @section thumbnail
  9020. Select the most representative frame in a given sequence of consecutive frames.
  9021. The filter accepts the following options:
  9022. @table @option
  9023. @item n
  9024. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  9025. will pick one of them, and then handle the next batch of @var{n} frames until
  9026. the end. Default is @code{100}.
  9027. @end table
  9028. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  9029. value will result in a higher memory usage, so a high value is not recommended.
  9030. @subsection Examples
  9031. @itemize
  9032. @item
  9033. Extract one picture each 50 frames:
  9034. @example
  9035. thumbnail=50
  9036. @end example
  9037. @item
  9038. Complete example of a thumbnail creation with @command{ffmpeg}:
  9039. @example
  9040. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  9041. @end example
  9042. @end itemize
  9043. @section tile
  9044. Tile several successive frames together.
  9045. The filter accepts the following options:
  9046. @table @option
  9047. @item layout
  9048. Set the grid size (i.e. the number of lines and columns). For the syntax of
  9049. this option, check the
  9050. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9051. @item nb_frames
  9052. Set the maximum number of frames to render in the given area. It must be less
  9053. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  9054. the area will be used.
  9055. @item margin
  9056. Set the outer border margin in pixels.
  9057. @item padding
  9058. Set the inner border thickness (i.e. the number of pixels between frames). For
  9059. more advanced padding options (such as having different values for the edges),
  9060. refer to the pad video filter.
  9061. @item color
  9062. Specify the color of the unused area. For the syntax of this option, check the
  9063. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  9064. is "black".
  9065. @end table
  9066. @subsection Examples
  9067. @itemize
  9068. @item
  9069. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  9070. @example
  9071. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  9072. @end example
  9073. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  9074. duplicating each output frame to accommodate the originally detected frame
  9075. rate.
  9076. @item
  9077. Display @code{5} pictures in an area of @code{3x2} frames,
  9078. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  9079. mixed flat and named options:
  9080. @example
  9081. tile=3x2:nb_frames=5:padding=7:margin=2
  9082. @end example
  9083. @end itemize
  9084. @section tinterlace
  9085. Perform various types of temporal field interlacing.
  9086. Frames are counted starting from 1, so the first input frame is
  9087. considered odd.
  9088. The filter accepts the following options:
  9089. @table @option
  9090. @item mode
  9091. Specify the mode of the interlacing. This option can also be specified
  9092. as a value alone. See below for a list of values for this option.
  9093. Available values are:
  9094. @table @samp
  9095. @item merge, 0
  9096. Move odd frames into the upper field, even into the lower field,
  9097. generating a double height frame at half frame rate.
  9098. @example
  9099. ------> time
  9100. Input:
  9101. Frame 1 Frame 2 Frame 3 Frame 4
  9102. 11111 22222 33333 44444
  9103. 11111 22222 33333 44444
  9104. 11111 22222 33333 44444
  9105. 11111 22222 33333 44444
  9106. Output:
  9107. 11111 33333
  9108. 22222 44444
  9109. 11111 33333
  9110. 22222 44444
  9111. 11111 33333
  9112. 22222 44444
  9113. 11111 33333
  9114. 22222 44444
  9115. @end example
  9116. @item drop_odd, 1
  9117. Only output even frames, odd frames are dropped, generating a frame with
  9118. unchanged height at half frame rate.
  9119. @example
  9120. ------> time
  9121. Input:
  9122. Frame 1 Frame 2 Frame 3 Frame 4
  9123. 11111 22222 33333 44444
  9124. 11111 22222 33333 44444
  9125. 11111 22222 33333 44444
  9126. 11111 22222 33333 44444
  9127. Output:
  9128. 22222 44444
  9129. 22222 44444
  9130. 22222 44444
  9131. 22222 44444
  9132. @end example
  9133. @item drop_even, 2
  9134. Only output odd frames, even frames are dropped, generating a frame with
  9135. unchanged height at half frame rate.
  9136. @example
  9137. ------> time
  9138. Input:
  9139. Frame 1 Frame 2 Frame 3 Frame 4
  9140. 11111 22222 33333 44444
  9141. 11111 22222 33333 44444
  9142. 11111 22222 33333 44444
  9143. 11111 22222 33333 44444
  9144. Output:
  9145. 11111 33333
  9146. 11111 33333
  9147. 11111 33333
  9148. 11111 33333
  9149. @end example
  9150. @item pad, 3
  9151. Expand each frame to full height, but pad alternate lines with black,
  9152. generating a frame with double height at the same input frame rate.
  9153. @example
  9154. ------> time
  9155. Input:
  9156. Frame 1 Frame 2 Frame 3 Frame 4
  9157. 11111 22222 33333 44444
  9158. 11111 22222 33333 44444
  9159. 11111 22222 33333 44444
  9160. 11111 22222 33333 44444
  9161. Output:
  9162. 11111 ..... 33333 .....
  9163. ..... 22222 ..... 44444
  9164. 11111 ..... 33333 .....
  9165. ..... 22222 ..... 44444
  9166. 11111 ..... 33333 .....
  9167. ..... 22222 ..... 44444
  9168. 11111 ..... 33333 .....
  9169. ..... 22222 ..... 44444
  9170. @end example
  9171. @item interleave_top, 4
  9172. Interleave the upper field from odd frames with the lower field from
  9173. even frames, generating a frame with unchanged height at half frame rate.
  9174. @example
  9175. ------> time
  9176. Input:
  9177. Frame 1 Frame 2 Frame 3 Frame 4
  9178. 11111<- 22222 33333<- 44444
  9179. 11111 22222<- 33333 44444<-
  9180. 11111<- 22222 33333<- 44444
  9181. 11111 22222<- 33333 44444<-
  9182. Output:
  9183. 11111 33333
  9184. 22222 44444
  9185. 11111 33333
  9186. 22222 44444
  9187. @end example
  9188. @item interleave_bottom, 5
  9189. Interleave the lower field from odd frames with the upper field from
  9190. even frames, generating a frame with unchanged height at half frame rate.
  9191. @example
  9192. ------> time
  9193. Input:
  9194. Frame 1 Frame 2 Frame 3 Frame 4
  9195. 11111 22222<- 33333 44444<-
  9196. 11111<- 22222 33333<- 44444
  9197. 11111 22222<- 33333 44444<-
  9198. 11111<- 22222 33333<- 44444
  9199. Output:
  9200. 22222 44444
  9201. 11111 33333
  9202. 22222 44444
  9203. 11111 33333
  9204. @end example
  9205. @item interlacex2, 6
  9206. Double frame rate with unchanged height. Frames are inserted each
  9207. containing the second temporal field from the previous input frame and
  9208. the first temporal field from the next input frame. This mode relies on
  9209. the top_field_first flag. Useful for interlaced video displays with no
  9210. field synchronisation.
  9211. @example
  9212. ------> time
  9213. Input:
  9214. Frame 1 Frame 2 Frame 3 Frame 4
  9215. 11111 22222 33333 44444
  9216. 11111 22222 33333 44444
  9217. 11111 22222 33333 44444
  9218. 11111 22222 33333 44444
  9219. Output:
  9220. 11111 22222 22222 33333 33333 44444 44444
  9221. 11111 11111 22222 22222 33333 33333 44444
  9222. 11111 22222 22222 33333 33333 44444 44444
  9223. 11111 11111 22222 22222 33333 33333 44444
  9224. @end example
  9225. @item mergex2, 7
  9226. Move odd frames into the upper field, even into the lower field,
  9227. generating a double height frame at same frame rate.
  9228. @example
  9229. ------> time
  9230. Input:
  9231. Frame 1 Frame 2 Frame 3 Frame 4
  9232. 11111 22222 33333 44444
  9233. 11111 22222 33333 44444
  9234. 11111 22222 33333 44444
  9235. 11111 22222 33333 44444
  9236. Output:
  9237. 11111 33333 33333 55555
  9238. 22222 22222 44444 44444
  9239. 11111 33333 33333 55555
  9240. 22222 22222 44444 44444
  9241. 11111 33333 33333 55555
  9242. 22222 22222 44444 44444
  9243. 11111 33333 33333 55555
  9244. 22222 22222 44444 44444
  9245. @end example
  9246. @end table
  9247. Numeric values are deprecated but are accepted for backward
  9248. compatibility reasons.
  9249. Default mode is @code{merge}.
  9250. @item flags
  9251. Specify flags influencing the filter process.
  9252. Available value for @var{flags} is:
  9253. @table @option
  9254. @item low_pass_filter, vlfp
  9255. Enable vertical low-pass filtering in the filter.
  9256. Vertical low-pass filtering is required when creating an interlaced
  9257. destination from a progressive source which contains high-frequency
  9258. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  9259. patterning.
  9260. Vertical low-pass filtering can only be enabled for @option{mode}
  9261. @var{interleave_top} and @var{interleave_bottom}.
  9262. @end table
  9263. @end table
  9264. @section transpose
  9265. Transpose rows with columns in the input video and optionally flip it.
  9266. It accepts the following parameters:
  9267. @table @option
  9268. @item dir
  9269. Specify the transposition direction.
  9270. Can assume the following values:
  9271. @table @samp
  9272. @item 0, 4, cclock_flip
  9273. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  9274. @example
  9275. L.R L.l
  9276. . . -> . .
  9277. l.r R.r
  9278. @end example
  9279. @item 1, 5, clock
  9280. Rotate by 90 degrees clockwise, that is:
  9281. @example
  9282. L.R l.L
  9283. . . -> . .
  9284. l.r r.R
  9285. @end example
  9286. @item 2, 6, cclock
  9287. Rotate by 90 degrees counterclockwise, that is:
  9288. @example
  9289. L.R R.r
  9290. . . -> . .
  9291. l.r L.l
  9292. @end example
  9293. @item 3, 7, clock_flip
  9294. Rotate by 90 degrees clockwise and vertically flip, that is:
  9295. @example
  9296. L.R r.R
  9297. . . -> . .
  9298. l.r l.L
  9299. @end example
  9300. @end table
  9301. For values between 4-7, the transposition is only done if the input
  9302. video geometry is portrait and not landscape. These values are
  9303. deprecated, the @code{passthrough} option should be used instead.
  9304. Numerical values are deprecated, and should be dropped in favor of
  9305. symbolic constants.
  9306. @item passthrough
  9307. Do not apply the transposition if the input geometry matches the one
  9308. specified by the specified value. It accepts the following values:
  9309. @table @samp
  9310. @item none
  9311. Always apply transposition.
  9312. @item portrait
  9313. Preserve portrait geometry (when @var{height} >= @var{width}).
  9314. @item landscape
  9315. Preserve landscape geometry (when @var{width} >= @var{height}).
  9316. @end table
  9317. Default value is @code{none}.
  9318. @end table
  9319. For example to rotate by 90 degrees clockwise and preserve portrait
  9320. layout:
  9321. @example
  9322. transpose=dir=1:passthrough=portrait
  9323. @end example
  9324. The command above can also be specified as:
  9325. @example
  9326. transpose=1:portrait
  9327. @end example
  9328. @section trim
  9329. Trim the input so that the output contains one continuous subpart of the input.
  9330. It accepts the following parameters:
  9331. @table @option
  9332. @item start
  9333. Specify the time of the start of the kept section, i.e. the frame with the
  9334. timestamp @var{start} will be the first frame in the output.
  9335. @item end
  9336. Specify the time of the first frame that will be dropped, i.e. the frame
  9337. immediately preceding the one with the timestamp @var{end} will be the last
  9338. frame in the output.
  9339. @item start_pts
  9340. This is the same as @var{start}, except this option sets the start timestamp
  9341. in timebase units instead of seconds.
  9342. @item end_pts
  9343. This is the same as @var{end}, except this option sets the end timestamp
  9344. in timebase units instead of seconds.
  9345. @item duration
  9346. The maximum duration of the output in seconds.
  9347. @item start_frame
  9348. The number of the first frame that should be passed to the output.
  9349. @item end_frame
  9350. The number of the first frame that should be dropped.
  9351. @end table
  9352. @option{start}, @option{end}, and @option{duration} are expressed as time
  9353. duration specifications; see
  9354. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  9355. for the accepted syntax.
  9356. Note that the first two sets of the start/end options and the @option{duration}
  9357. option look at the frame timestamp, while the _frame variants simply count the
  9358. frames that pass through the filter. Also note that this filter does not modify
  9359. the timestamps. If you wish for the output timestamps to start at zero, insert a
  9360. setpts filter after the trim filter.
  9361. If multiple start or end options are set, this filter tries to be greedy and
  9362. keep all the frames that match at least one of the specified constraints. To keep
  9363. only the part that matches all the constraints at once, chain multiple trim
  9364. filters.
  9365. The defaults are such that all the input is kept. So it is possible to set e.g.
  9366. just the end values to keep everything before the specified time.
  9367. Examples:
  9368. @itemize
  9369. @item
  9370. Drop everything except the second minute of input:
  9371. @example
  9372. ffmpeg -i INPUT -vf trim=60:120
  9373. @end example
  9374. @item
  9375. Keep only the first second:
  9376. @example
  9377. ffmpeg -i INPUT -vf trim=duration=1
  9378. @end example
  9379. @end itemize
  9380. @anchor{unsharp}
  9381. @section unsharp
  9382. Sharpen or blur the input video.
  9383. It accepts the following parameters:
  9384. @table @option
  9385. @item luma_msize_x, lx
  9386. Set the luma matrix horizontal size. It must be an odd integer between
  9387. 3 and 63. The default value is 5.
  9388. @item luma_msize_y, ly
  9389. Set the luma matrix vertical size. It must be an odd integer between 3
  9390. and 63. The default value is 5.
  9391. @item luma_amount, la
  9392. Set the luma effect strength. It must be a floating point number, reasonable
  9393. values lay between -1.5 and 1.5.
  9394. Negative values will blur the input video, while positive values will
  9395. sharpen it, a value of zero will disable the effect.
  9396. Default value is 1.0.
  9397. @item chroma_msize_x, cx
  9398. Set the chroma matrix horizontal size. It must be an odd integer
  9399. between 3 and 63. The default value is 5.
  9400. @item chroma_msize_y, cy
  9401. Set the chroma matrix vertical size. It must be an odd integer
  9402. between 3 and 63. The default value is 5.
  9403. @item chroma_amount, ca
  9404. Set the chroma effect strength. It must be a floating point number, reasonable
  9405. values lay between -1.5 and 1.5.
  9406. Negative values will blur the input video, while positive values will
  9407. sharpen it, a value of zero will disable the effect.
  9408. Default value is 0.0.
  9409. @item opencl
  9410. If set to 1, specify using OpenCL capabilities, only available if
  9411. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  9412. @end table
  9413. All parameters are optional and default to the equivalent of the
  9414. string '5:5:1.0:5:5:0.0'.
  9415. @subsection Examples
  9416. @itemize
  9417. @item
  9418. Apply strong luma sharpen effect:
  9419. @example
  9420. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  9421. @end example
  9422. @item
  9423. Apply a strong blur of both luma and chroma parameters:
  9424. @example
  9425. unsharp=7:7:-2:7:7:-2
  9426. @end example
  9427. @end itemize
  9428. @section uspp
  9429. Apply ultra slow/simple postprocessing filter that compresses and decompresses
  9430. the image at several (or - in the case of @option{quality} level @code{8} - all)
  9431. shifts and average the results.
  9432. The way this differs from the behavior of spp is that uspp actually encodes &
  9433. decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
  9434. DCT similar to MJPEG.
  9435. The filter accepts the following options:
  9436. @table @option
  9437. @item quality
  9438. Set quality. This option defines the number of levels for averaging. It accepts
  9439. an integer in the range 0-8. If set to @code{0}, the filter will have no
  9440. effect. A value of @code{8} means the higher quality. For each increment of
  9441. that value the speed drops by a factor of approximately 2. Default value is
  9442. @code{3}.
  9443. @item qp
  9444. Force a constant quantization parameter. If not set, the filter will use the QP
  9445. from the video stream (if available).
  9446. @end table
  9447. @section vectorscope
  9448. Display 2 color component values in the two dimensional graph (which is called
  9449. a vectorscope).
  9450. This filter accepts the following options:
  9451. @table @option
  9452. @item mode, m
  9453. Set vectorscope mode.
  9454. It accepts the following values:
  9455. @table @samp
  9456. @item gray
  9457. Gray values are displayed on graph, higher brightness means more pixels have
  9458. same component color value on location in graph. This is the default mode.
  9459. @item color
  9460. Gray values are displayed on graph. Surrounding pixels values which are not
  9461. present in video frame are drawn in gradient of 2 color components which are
  9462. set by option @code{x} and @code{y}.
  9463. @item color2
  9464. Actual color components values present in video frame are displayed on graph.
  9465. @item color3
  9466. Similar as color2 but higher frequency of same values @code{x} and @code{y}
  9467. on graph increases value of another color component, which is luminance by
  9468. default values of @code{x} and @code{y}.
  9469. @item color4
  9470. Actual colors present in video frame are displayed on graph. If two different
  9471. colors map to same position on graph then color with higher value of component
  9472. not present in graph is picked.
  9473. @end table
  9474. @item x
  9475. Set which color component will be represented on X-axis. Default is @code{1}.
  9476. @item y
  9477. Set which color component will be represented on Y-axis. Default is @code{2}.
  9478. @item intensity, i
  9479. Set intensity, used by modes: gray, color and color3 for increasing brightness
  9480. of color component which represents frequency of (X, Y) location in graph.
  9481. @item envelope, e
  9482. @table @samp
  9483. @item none
  9484. No envelope, this is default.
  9485. @item instant
  9486. Instant envelope, even darkest single pixel will be clearly highlighted.
  9487. @item peak
  9488. Hold maximum and minimum values presented in graph over time. This way you
  9489. can still spot out of range values without constantly looking at vectorscope.
  9490. @item peak+instant
  9491. Peak and instant envelope combined together.
  9492. @end table
  9493. @end table
  9494. @anchor{vidstabdetect}
  9495. @section vidstabdetect
  9496. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  9497. @ref{vidstabtransform} for pass 2.
  9498. This filter generates a file with relative translation and rotation
  9499. transform information about subsequent frames, which is then used by
  9500. the @ref{vidstabtransform} filter.
  9501. To enable compilation of this filter you need to configure FFmpeg with
  9502. @code{--enable-libvidstab}.
  9503. This filter accepts the following options:
  9504. @table @option
  9505. @item result
  9506. Set the path to the file used to write the transforms information.
  9507. Default value is @file{transforms.trf}.
  9508. @item shakiness
  9509. Set how shaky the video is and how quick the camera is. It accepts an
  9510. integer in the range 1-10, a value of 1 means little shakiness, a
  9511. value of 10 means strong shakiness. Default value is 5.
  9512. @item accuracy
  9513. Set the accuracy of the detection process. It must be a value in the
  9514. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  9515. accuracy. Default value is 15.
  9516. @item stepsize
  9517. Set stepsize of the search process. The region around minimum is
  9518. scanned with 1 pixel resolution. Default value is 6.
  9519. @item mincontrast
  9520. Set minimum contrast. Below this value a local measurement field is
  9521. discarded. Must be a floating point value in the range 0-1. Default
  9522. value is 0.3.
  9523. @item tripod
  9524. Set reference frame number for tripod mode.
  9525. If enabled, the motion of the frames is compared to a reference frame
  9526. in the filtered stream, identified by the specified number. The idea
  9527. is to compensate all movements in a more-or-less static scene and keep
  9528. the camera view absolutely still.
  9529. If set to 0, it is disabled. The frames are counted starting from 1.
  9530. @item show
  9531. Show fields and transforms in the resulting frames. It accepts an
  9532. integer in the range 0-2. Default value is 0, which disables any
  9533. visualization.
  9534. @end table
  9535. @subsection Examples
  9536. @itemize
  9537. @item
  9538. Use default values:
  9539. @example
  9540. vidstabdetect
  9541. @end example
  9542. @item
  9543. Analyze strongly shaky movie and put the results in file
  9544. @file{mytransforms.trf}:
  9545. @example
  9546. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  9547. @end example
  9548. @item
  9549. Visualize the result of internal transformations in the resulting
  9550. video:
  9551. @example
  9552. vidstabdetect=show=1
  9553. @end example
  9554. @item
  9555. Analyze a video with medium shakiness using @command{ffmpeg}:
  9556. @example
  9557. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  9558. @end example
  9559. @end itemize
  9560. @anchor{vidstabtransform}
  9561. @section vidstabtransform
  9562. Video stabilization/deshaking: pass 2 of 2,
  9563. see @ref{vidstabdetect} for pass 1.
  9564. Read a file with transform information for each frame and
  9565. apply/compensate them. Together with the @ref{vidstabdetect}
  9566. filter this can be used to deshake videos. See also
  9567. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  9568. the @ref{unsharp} filter, see below.
  9569. To enable compilation of this filter you need to configure FFmpeg with
  9570. @code{--enable-libvidstab}.
  9571. @subsection Options
  9572. @table @option
  9573. @item input
  9574. Set path to the file used to read the transforms. Default value is
  9575. @file{transforms.trf}.
  9576. @item smoothing
  9577. Set the number of frames (value*2 + 1) used for lowpass filtering the
  9578. camera movements. Default value is 10.
  9579. For example a number of 10 means that 21 frames are used (10 in the
  9580. past and 10 in the future) to smoothen the motion in the video. A
  9581. larger value leads to a smoother video, but limits the acceleration of
  9582. the camera (pan/tilt movements). 0 is a special case where a static
  9583. camera is simulated.
  9584. @item optalgo
  9585. Set the camera path optimization algorithm.
  9586. Accepted values are:
  9587. @table @samp
  9588. @item gauss
  9589. gaussian kernel low-pass filter on camera motion (default)
  9590. @item avg
  9591. averaging on transformations
  9592. @end table
  9593. @item maxshift
  9594. Set maximal number of pixels to translate frames. Default value is -1,
  9595. meaning no limit.
  9596. @item maxangle
  9597. Set maximal angle in radians (degree*PI/180) to rotate frames. Default
  9598. value is -1, meaning no limit.
  9599. @item crop
  9600. Specify how to deal with borders that may be visible due to movement
  9601. compensation.
  9602. Available values are:
  9603. @table @samp
  9604. @item keep
  9605. keep image information from previous frame (default)
  9606. @item black
  9607. fill the border black
  9608. @end table
  9609. @item invert
  9610. Invert transforms if set to 1. Default value is 0.
  9611. @item relative
  9612. Consider transforms as relative to previous frame if set to 1,
  9613. absolute if set to 0. Default value is 0.
  9614. @item zoom
  9615. Set percentage to zoom. A positive value will result in a zoom-in
  9616. effect, a negative value in a zoom-out effect. Default value is 0 (no
  9617. zoom).
  9618. @item optzoom
  9619. Set optimal zooming to avoid borders.
  9620. Accepted values are:
  9621. @table @samp
  9622. @item 0
  9623. disabled
  9624. @item 1
  9625. optimal static zoom value is determined (only very strong movements
  9626. will lead to visible borders) (default)
  9627. @item 2
  9628. optimal adaptive zoom value is determined (no borders will be
  9629. visible), see @option{zoomspeed}
  9630. @end table
  9631. Note that the value given at zoom is added to the one calculated here.
  9632. @item zoomspeed
  9633. Set percent to zoom maximally each frame (enabled when
  9634. @option{optzoom} is set to 2). Range is from 0 to 5, default value is
  9635. 0.25.
  9636. @item interpol
  9637. Specify type of interpolation.
  9638. Available values are:
  9639. @table @samp
  9640. @item no
  9641. no interpolation
  9642. @item linear
  9643. linear only horizontal
  9644. @item bilinear
  9645. linear in both directions (default)
  9646. @item bicubic
  9647. cubic in both directions (slow)
  9648. @end table
  9649. @item tripod
  9650. Enable virtual tripod mode if set to 1, which is equivalent to
  9651. @code{relative=0:smoothing=0}. Default value is 0.
  9652. Use also @code{tripod} option of @ref{vidstabdetect}.
  9653. @item debug
  9654. Increase log verbosity if set to 1. Also the detected global motions
  9655. are written to the temporary file @file{global_motions.trf}. Default
  9656. value is 0.
  9657. @end table
  9658. @subsection Examples
  9659. @itemize
  9660. @item
  9661. Use @command{ffmpeg} for a typical stabilization with default values:
  9662. @example
  9663. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  9664. @end example
  9665. Note the use of the @ref{unsharp} filter which is always recommended.
  9666. @item
  9667. Zoom in a bit more and load transform data from a given file:
  9668. @example
  9669. vidstabtransform=zoom=5:input="mytransforms.trf"
  9670. @end example
  9671. @item
  9672. Smoothen the video even more:
  9673. @example
  9674. vidstabtransform=smoothing=30
  9675. @end example
  9676. @end itemize
  9677. @section vflip
  9678. Flip the input video vertically.
  9679. For example, to vertically flip a video with @command{ffmpeg}:
  9680. @example
  9681. ffmpeg -i in.avi -vf "vflip" out.avi
  9682. @end example
  9683. @anchor{vignette}
  9684. @section vignette
  9685. Make or reverse a natural vignetting effect.
  9686. The filter accepts the following options:
  9687. @table @option
  9688. @item angle, a
  9689. Set lens angle expression as a number of radians.
  9690. The value is clipped in the @code{[0,PI/2]} range.
  9691. Default value: @code{"PI/5"}
  9692. @item x0
  9693. @item y0
  9694. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  9695. by default.
  9696. @item mode
  9697. Set forward/backward mode.
  9698. Available modes are:
  9699. @table @samp
  9700. @item forward
  9701. The larger the distance from the central point, the darker the image becomes.
  9702. @item backward
  9703. The larger the distance from the central point, the brighter the image becomes.
  9704. This can be used to reverse a vignette effect, though there is no automatic
  9705. detection to extract the lens @option{angle} and other settings (yet). It can
  9706. also be used to create a burning effect.
  9707. @end table
  9708. Default value is @samp{forward}.
  9709. @item eval
  9710. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  9711. It accepts the following values:
  9712. @table @samp
  9713. @item init
  9714. Evaluate expressions only once during the filter initialization.
  9715. @item frame
  9716. Evaluate expressions for each incoming frame. This is way slower than the
  9717. @samp{init} mode since it requires all the scalers to be re-computed, but it
  9718. allows advanced dynamic expressions.
  9719. @end table
  9720. Default value is @samp{init}.
  9721. @item dither
  9722. Set dithering to reduce the circular banding effects. Default is @code{1}
  9723. (enabled).
  9724. @item aspect
  9725. Set vignette aspect. This setting allows one to adjust the shape of the vignette.
  9726. Setting this value to the SAR of the input will make a rectangular vignetting
  9727. following the dimensions of the video.
  9728. Default is @code{1/1}.
  9729. @end table
  9730. @subsection Expressions
  9731. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  9732. following parameters.
  9733. @table @option
  9734. @item w
  9735. @item h
  9736. input width and height
  9737. @item n
  9738. the number of input frame, starting from 0
  9739. @item pts
  9740. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  9741. @var{TB} units, NAN if undefined
  9742. @item r
  9743. frame rate of the input video, NAN if the input frame rate is unknown
  9744. @item t
  9745. the PTS (Presentation TimeStamp) of the filtered video frame,
  9746. expressed in seconds, NAN if undefined
  9747. @item tb
  9748. time base of the input video
  9749. @end table
  9750. @subsection Examples
  9751. @itemize
  9752. @item
  9753. Apply simple strong vignetting effect:
  9754. @example
  9755. vignette=PI/4
  9756. @end example
  9757. @item
  9758. Make a flickering vignetting:
  9759. @example
  9760. vignette='PI/4+random(1)*PI/50':eval=frame
  9761. @end example
  9762. @end itemize
  9763. @section vstack
  9764. Stack input videos vertically.
  9765. All streams must be of same pixel format and of same width.
  9766. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  9767. to create same output.
  9768. The filter accept the following option:
  9769. @table @option
  9770. @item inputs
  9771. Set number of input streams. Default is 2.
  9772. @item shortest
  9773. If set to 1, force the output to terminate when the shortest input
  9774. terminates. Default value is 0.
  9775. @end table
  9776. @section w3fdif
  9777. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  9778. Deinterlacing Filter").
  9779. Based on the process described by Martin Weston for BBC R&D, and
  9780. implemented based on the de-interlace algorithm written by Jim
  9781. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  9782. uses filter coefficients calculated by BBC R&D.
  9783. There are two sets of filter coefficients, so called "simple":
  9784. and "complex". Which set of filter coefficients is used can
  9785. be set by passing an optional parameter:
  9786. @table @option
  9787. @item filter
  9788. Set the interlacing filter coefficients. Accepts one of the following values:
  9789. @table @samp
  9790. @item simple
  9791. Simple filter coefficient set.
  9792. @item complex
  9793. More-complex filter coefficient set.
  9794. @end table
  9795. Default value is @samp{complex}.
  9796. @item deint
  9797. Specify which frames to deinterlace. Accept one of the following values:
  9798. @table @samp
  9799. @item all
  9800. Deinterlace all frames,
  9801. @item interlaced
  9802. Only deinterlace frames marked as interlaced.
  9803. @end table
  9804. Default value is @samp{all}.
  9805. @end table
  9806. @section waveform
  9807. Video waveform monitor.
  9808. The waveform monitor plots color component intensity. By default luminance
  9809. only. Each column of the waveform corresponds to a column of pixels in the
  9810. source video.
  9811. It accepts the following options:
  9812. @table @option
  9813. @item mode, m
  9814. Can be either @code{row}, or @code{column}. Default is @code{column}.
  9815. In row mode, the graph on the left side represents color component value 0 and
  9816. the right side represents value = 255. In column mode, the top side represents
  9817. color component value = 0 and bottom side represents value = 255.
  9818. @item intensity, i
  9819. Set intensity. Smaller values are useful to find out how many values of the same
  9820. luminance are distributed across input rows/columns.
  9821. Default value is @code{0.04}. Allowed range is [0, 1].
  9822. @item mirror, r
  9823. Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored.
  9824. In mirrored mode, higher values will be represented on the left
  9825. side for @code{row} mode and at the top for @code{column} mode. Default is
  9826. @code{1} (mirrored).
  9827. @item display, d
  9828. Set display mode.
  9829. It accepts the following values:
  9830. @table @samp
  9831. @item overlay
  9832. Presents information identical to that in the @code{parade}, except
  9833. that the graphs representing color components are superimposed directly
  9834. over one another.
  9835. This display mode makes it easier to spot relative differences or similarities
  9836. in overlapping areas of the color components that are supposed to be identical,
  9837. such as neutral whites, grays, or blacks.
  9838. @item parade
  9839. Display separate graph for the color components side by side in
  9840. @code{row} mode or one below the other in @code{column} mode.
  9841. Using this display mode makes it easy to spot color casts in the highlights
  9842. and shadows of an image, by comparing the contours of the top and the bottom
  9843. graphs of each waveform. Since whites, grays, and blacks are characterized
  9844. by exactly equal amounts of red, green, and blue, neutral areas of the picture
  9845. should display three waveforms of roughly equal width/height. If not, the
  9846. correction is easy to perform by making level adjustments the three waveforms.
  9847. @end table
  9848. Default is @code{parade}.
  9849. @item components, c
  9850. Set which color components to display. Default is 1, which means only luminance
  9851. or red color component if input is in RGB colorspace. If is set for example to
  9852. 7 it will display all 3 (if) available color components.
  9853. @item envelope, e
  9854. @table @samp
  9855. @item none
  9856. No envelope, this is default.
  9857. @item instant
  9858. Instant envelope, minimum and maximum values presented in graph will be easily
  9859. visible even with small @code{step} value.
  9860. @item peak
  9861. Hold minimum and maximum values presented in graph across time. This way you
  9862. can still spot out of range values without constantly looking at waveforms.
  9863. @item peak+instant
  9864. Peak and instant envelope combined together.
  9865. @end table
  9866. @item filter, f
  9867. @table @samp
  9868. @item lowpass
  9869. No filtering, this is default.
  9870. @item flat
  9871. Luma and chroma combined together.
  9872. @item aflat
  9873. Similar as above, but shows difference between blue and red chroma.
  9874. @item chroma
  9875. Displays only chroma.
  9876. @item achroma
  9877. Similar as above, but shows difference between blue and red chroma.
  9878. @item color
  9879. Displays actual color value on waveform.
  9880. @end table
  9881. @end table
  9882. @section xbr
  9883. Apply the xBR high-quality magnification filter which is designed for pixel
  9884. art. It follows a set of edge-detection rules, see
  9885. @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
  9886. It accepts the following option:
  9887. @table @option
  9888. @item n
  9889. Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
  9890. @code{3xBR} and @code{4} for @code{4xBR}.
  9891. Default is @code{3}.
  9892. @end table
  9893. @anchor{yadif}
  9894. @section yadif
  9895. Deinterlace the input video ("yadif" means "yet another deinterlacing
  9896. filter").
  9897. It accepts the following parameters:
  9898. @table @option
  9899. @item mode
  9900. The interlacing mode to adopt. It accepts one of the following values:
  9901. @table @option
  9902. @item 0, send_frame
  9903. Output one frame for each frame.
  9904. @item 1, send_field
  9905. Output one frame for each field.
  9906. @item 2, send_frame_nospatial
  9907. Like @code{send_frame}, but it skips the spatial interlacing check.
  9908. @item 3, send_field_nospatial
  9909. Like @code{send_field}, but it skips the spatial interlacing check.
  9910. @end table
  9911. The default value is @code{send_frame}.
  9912. @item parity
  9913. The picture field parity assumed for the input interlaced video. It accepts one
  9914. of the following values:
  9915. @table @option
  9916. @item 0, tff
  9917. Assume the top field is first.
  9918. @item 1, bff
  9919. Assume the bottom field is first.
  9920. @item -1, auto
  9921. Enable automatic detection of field parity.
  9922. @end table
  9923. The default value is @code{auto}.
  9924. If the interlacing is unknown or the decoder does not export this information,
  9925. top field first will be assumed.
  9926. @item deint
  9927. Specify which frames to deinterlace. Accept one of the following
  9928. values:
  9929. @table @option
  9930. @item 0, all
  9931. Deinterlace all frames.
  9932. @item 1, interlaced
  9933. Only deinterlace frames marked as interlaced.
  9934. @end table
  9935. The default value is @code{all}.
  9936. @end table
  9937. @section zoompan
  9938. Apply Zoom & Pan effect.
  9939. This filter accepts the following options:
  9940. @table @option
  9941. @item zoom, z
  9942. Set the zoom expression. Default is 1.
  9943. @item x
  9944. @item y
  9945. Set the x and y expression. Default is 0.
  9946. @item d
  9947. Set the duration expression in number of frames.
  9948. This sets for how many number of frames effect will last for
  9949. single input image.
  9950. @item s
  9951. Set the output image size, default is 'hd720'.
  9952. @item fps
  9953. Set the output frame rate, default is '25'.
  9954. @end table
  9955. Each expression can contain the following constants:
  9956. @table @option
  9957. @item in_w, iw
  9958. Input width.
  9959. @item in_h, ih
  9960. Input height.
  9961. @item out_w, ow
  9962. Output width.
  9963. @item out_h, oh
  9964. Output height.
  9965. @item in
  9966. Input frame count.
  9967. @item on
  9968. Output frame count.
  9969. @item x
  9970. @item y
  9971. Last calculated 'x' and 'y' position from 'x' and 'y' expression
  9972. for current input frame.
  9973. @item px
  9974. @item py
  9975. 'x' and 'y' of last output frame of previous input frame or 0 when there was
  9976. not yet such frame (first input frame).
  9977. @item zoom
  9978. Last calculated zoom from 'z' expression for current input frame.
  9979. @item pzoom
  9980. Last calculated zoom of last output frame of previous input frame.
  9981. @item duration
  9982. Number of output frames for current input frame. Calculated from 'd' expression
  9983. for each input frame.
  9984. @item pduration
  9985. number of output frames created for previous input frame
  9986. @item a
  9987. Rational number: input width / input height
  9988. @item sar
  9989. sample aspect ratio
  9990. @item dar
  9991. display aspect ratio
  9992. @end table
  9993. @subsection Examples
  9994. @itemize
  9995. @item
  9996. Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
  9997. @example
  9998. 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
  9999. @end example
  10000. @item
  10001. Zoom-in up to 1.5 and pan always at center of picture:
  10002. @example
  10003. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
  10004. @end example
  10005. @end itemize
  10006. @section zscale
  10007. Scale (resize) the input video, using the z.lib library:
  10008. https://github.com/sekrit-twc/zimg.
  10009. The zscale filter forces the output display aspect ratio to be the same
  10010. as the input, by changing the output sample aspect ratio.
  10011. If the input image format is different from the format requested by
  10012. the next filter, the zscale filter will convert the input to the
  10013. requested format.
  10014. @subsection Options
  10015. The filter accepts the following options.
  10016. @table @option
  10017. @item width, w
  10018. @item height, h
  10019. Set the output video dimension expression. Default value is the input
  10020. dimension.
  10021. If the @var{width} or @var{w} is 0, the input width is used for the output.
  10022. If the @var{height} or @var{h} is 0, the input height is used for the output.
  10023. If one of the values is -1, the zscale filter will use a value that
  10024. maintains the aspect ratio of the input image, calculated from the
  10025. other specified dimension. If both of them are -1, the input size is
  10026. used
  10027. If one of the values is -n with n > 1, the zscale filter will also use a value
  10028. that maintains the aspect ratio of the input image, calculated from the other
  10029. specified dimension. After that it will, however, make sure that the calculated
  10030. dimension is divisible by n and adjust the value if necessary.
  10031. See below for the list of accepted constants for use in the dimension
  10032. expression.
  10033. @item size, s
  10034. Set the video size. For the syntax of this option, check the
  10035. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10036. @item dither, d
  10037. Set the dither type.
  10038. Possible values are:
  10039. @table @var
  10040. @item none
  10041. @item ordered
  10042. @item random
  10043. @item error_diffusion
  10044. @end table
  10045. Default is none.
  10046. @item filter, f
  10047. Set the resize filter type.
  10048. Possible values are:
  10049. @table @var
  10050. @item point
  10051. @item bilinear
  10052. @item bicubic
  10053. @item spline16
  10054. @item spline36
  10055. @item lanczos
  10056. @end table
  10057. Default is bilinear.
  10058. @item range, r
  10059. Set the color range.
  10060. Possible values are:
  10061. @table @var
  10062. @item input
  10063. @item limited
  10064. @item full
  10065. @end table
  10066. Default is same as input.
  10067. @item primaries, p
  10068. Set the color primaries.
  10069. Possible values are:
  10070. @table @var
  10071. @item input
  10072. @item 709
  10073. @item unspecified
  10074. @item 170m
  10075. @item 240m
  10076. @item 2020
  10077. @end table
  10078. Default is same as input.
  10079. @item transfer, t
  10080. Set the transfer characteristics.
  10081. Possible values are:
  10082. @table @var
  10083. @item input
  10084. @item 709
  10085. @item unspecified
  10086. @item 601
  10087. @item linear
  10088. @item 2020_10
  10089. @item 2020_12
  10090. @end table
  10091. Default is same as input.
  10092. @item matrix, m
  10093. Set the colorspace matrix.
  10094. Possible value are:
  10095. @table @var
  10096. @item input
  10097. @item 709
  10098. @item unspecified
  10099. @item 470bg
  10100. @item 170m
  10101. @item 2020_ncl
  10102. @item 2020_cl
  10103. @end table
  10104. Default is same as input.
  10105. @item rangein, rin
  10106. Set the input color range.
  10107. Possible values are:
  10108. @table @var
  10109. @item input
  10110. @item limited
  10111. @item full
  10112. @end table
  10113. Default is same as input.
  10114. @item primariesin, pin
  10115. Set the input color primaries.
  10116. Possible values are:
  10117. @table @var
  10118. @item input
  10119. @item 709
  10120. @item unspecified
  10121. @item 170m
  10122. @item 240m
  10123. @item 2020
  10124. @end table
  10125. Default is same as input.
  10126. @item transferin, tin
  10127. Set the input transfer characteristics.
  10128. Possible values are:
  10129. @table @var
  10130. @item input
  10131. @item 709
  10132. @item unspecified
  10133. @item 601
  10134. @item linear
  10135. @item 2020_10
  10136. @item 2020_12
  10137. @end table
  10138. Default is same as input.
  10139. @item matrixin, min
  10140. Set the input colorspace matrix.
  10141. Possible value are:
  10142. @table @var
  10143. @item input
  10144. @item 709
  10145. @item unspecified
  10146. @item 470bg
  10147. @item 170m
  10148. @item 2020_ncl
  10149. @item 2020_cl
  10150. @end table
  10151. @end table
  10152. The values of the @option{w} and @option{h} options are expressions
  10153. containing the following constants:
  10154. @table @var
  10155. @item in_w
  10156. @item in_h
  10157. The input width and height
  10158. @item iw
  10159. @item ih
  10160. These are the same as @var{in_w} and @var{in_h}.
  10161. @item out_w
  10162. @item out_h
  10163. The output (scaled) width and height
  10164. @item ow
  10165. @item oh
  10166. These are the same as @var{out_w} and @var{out_h}
  10167. @item a
  10168. The same as @var{iw} / @var{ih}
  10169. @item sar
  10170. input sample aspect ratio
  10171. @item dar
  10172. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  10173. @item hsub
  10174. @item vsub
  10175. horizontal and vertical input chroma subsample values. For example for the
  10176. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  10177. @item ohsub
  10178. @item ovsub
  10179. horizontal and vertical output chroma subsample values. For example for the
  10180. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  10181. @end table
  10182. @table @option
  10183. @end table
  10184. @c man end VIDEO FILTERS
  10185. @chapter Video Sources
  10186. @c man begin VIDEO SOURCES
  10187. Below is a description of the currently available video sources.
  10188. @section buffer
  10189. Buffer video frames, and make them available to the filter chain.
  10190. This source is mainly intended for a programmatic use, in particular
  10191. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  10192. It accepts the following parameters:
  10193. @table @option
  10194. @item video_size
  10195. Specify the size (width and height) of the buffered video frames. For the
  10196. syntax of this option, check the
  10197. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10198. @item width
  10199. The input video width.
  10200. @item height
  10201. The input video height.
  10202. @item pix_fmt
  10203. A string representing the pixel format of the buffered video frames.
  10204. It may be a number corresponding to a pixel format, or a pixel format
  10205. name.
  10206. @item time_base
  10207. Specify the timebase assumed by the timestamps of the buffered frames.
  10208. @item frame_rate
  10209. Specify the frame rate expected for the video stream.
  10210. @item pixel_aspect, sar
  10211. The sample (pixel) aspect ratio of the input video.
  10212. @item sws_param
  10213. Specify the optional parameters to be used for the scale filter which
  10214. is automatically inserted when an input change is detected in the
  10215. input size or format.
  10216. @end table
  10217. For example:
  10218. @example
  10219. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  10220. @end example
  10221. will instruct the source to accept video frames with size 320x240 and
  10222. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  10223. square pixels (1:1 sample aspect ratio).
  10224. Since the pixel format with name "yuv410p" corresponds to the number 6
  10225. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  10226. this example corresponds to:
  10227. @example
  10228. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  10229. @end example
  10230. Alternatively, the options can be specified as a flat string, but this
  10231. syntax is deprecated:
  10232. @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}]
  10233. @section cellauto
  10234. Create a pattern generated by an elementary cellular automaton.
  10235. The initial state of the cellular automaton can be defined through the
  10236. @option{filename}, and @option{pattern} options. If such options are
  10237. not specified an initial state is created randomly.
  10238. At each new frame a new row in the video is filled with the result of
  10239. the cellular automaton next generation. The behavior when the whole
  10240. frame is filled is defined by the @option{scroll} option.
  10241. This source accepts the following options:
  10242. @table @option
  10243. @item filename, f
  10244. Read the initial cellular automaton state, i.e. the starting row, from
  10245. the specified file.
  10246. In the file, each non-whitespace character is considered an alive
  10247. cell, a newline will terminate the row, and further characters in the
  10248. file will be ignored.
  10249. @item pattern, p
  10250. Read the initial cellular automaton state, i.e. the starting row, from
  10251. the specified string.
  10252. Each non-whitespace character in the string is considered an alive
  10253. cell, a newline will terminate the row, and further characters in the
  10254. string will be ignored.
  10255. @item rate, r
  10256. Set the video rate, that is the number of frames generated per second.
  10257. Default is 25.
  10258. @item random_fill_ratio, ratio
  10259. Set the random fill ratio for the initial cellular automaton row. It
  10260. is a floating point number value ranging from 0 to 1, defaults to
  10261. 1/PHI.
  10262. This option is ignored when a file or a pattern is specified.
  10263. @item random_seed, seed
  10264. Set the seed for filling randomly the initial row, must be an integer
  10265. included between 0 and UINT32_MAX. If not specified, or if explicitly
  10266. set to -1, the filter will try to use a good random seed on a best
  10267. effort basis.
  10268. @item rule
  10269. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  10270. Default value is 110.
  10271. @item size, s
  10272. Set the size of the output video. For the syntax of this option, check the
  10273. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10274. If @option{filename} or @option{pattern} is specified, the size is set
  10275. by default to the width of the specified initial state row, and the
  10276. height is set to @var{width} * PHI.
  10277. If @option{size} is set, it must contain the width of the specified
  10278. pattern string, and the specified pattern will be centered in the
  10279. larger row.
  10280. If a filename or a pattern string is not specified, the size value
  10281. defaults to "320x518" (used for a randomly generated initial state).
  10282. @item scroll
  10283. If set to 1, scroll the output upward when all the rows in the output
  10284. have been already filled. If set to 0, the new generated row will be
  10285. written over the top row just after the bottom row is filled.
  10286. Defaults to 1.
  10287. @item start_full, full
  10288. If set to 1, completely fill the output with generated rows before
  10289. outputting the first frame.
  10290. This is the default behavior, for disabling set the value to 0.
  10291. @item stitch
  10292. If set to 1, stitch the left and right row edges together.
  10293. This is the default behavior, for disabling set the value to 0.
  10294. @end table
  10295. @subsection Examples
  10296. @itemize
  10297. @item
  10298. Read the initial state from @file{pattern}, and specify an output of
  10299. size 200x400.
  10300. @example
  10301. cellauto=f=pattern:s=200x400
  10302. @end example
  10303. @item
  10304. Generate a random initial row with a width of 200 cells, with a fill
  10305. ratio of 2/3:
  10306. @example
  10307. cellauto=ratio=2/3:s=200x200
  10308. @end example
  10309. @item
  10310. Create a pattern generated by rule 18 starting by a single alive cell
  10311. centered on an initial row with width 100:
  10312. @example
  10313. cellauto=p=@@:s=100x400:full=0:rule=18
  10314. @end example
  10315. @item
  10316. Specify a more elaborated initial pattern:
  10317. @example
  10318. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  10319. @end example
  10320. @end itemize
  10321. @section mandelbrot
  10322. Generate a Mandelbrot set fractal, and progressively zoom towards the
  10323. point specified with @var{start_x} and @var{start_y}.
  10324. This source accepts the following options:
  10325. @table @option
  10326. @item end_pts
  10327. Set the terminal pts value. Default value is 400.
  10328. @item end_scale
  10329. Set the terminal scale value.
  10330. Must be a floating point value. Default value is 0.3.
  10331. @item inner
  10332. Set the inner coloring mode, that is the algorithm used to draw the
  10333. Mandelbrot fractal internal region.
  10334. It shall assume one of the following values:
  10335. @table @option
  10336. @item black
  10337. Set black mode.
  10338. @item convergence
  10339. Show time until convergence.
  10340. @item mincol
  10341. Set color based on point closest to the origin of the iterations.
  10342. @item period
  10343. Set period mode.
  10344. @end table
  10345. Default value is @var{mincol}.
  10346. @item bailout
  10347. Set the bailout value. Default value is 10.0.
  10348. @item maxiter
  10349. Set the maximum of iterations performed by the rendering
  10350. algorithm. Default value is 7189.
  10351. @item outer
  10352. Set outer coloring mode.
  10353. It shall assume one of following values:
  10354. @table @option
  10355. @item iteration_count
  10356. Set iteration cound mode.
  10357. @item normalized_iteration_count
  10358. set normalized iteration count mode.
  10359. @end table
  10360. Default value is @var{normalized_iteration_count}.
  10361. @item rate, r
  10362. Set frame rate, expressed as number of frames per second. Default
  10363. value is "25".
  10364. @item size, s
  10365. Set frame size. For the syntax of this option, check the "Video
  10366. size" section in the ffmpeg-utils manual. Default value is "640x480".
  10367. @item start_scale
  10368. Set the initial scale value. Default value is 3.0.
  10369. @item start_x
  10370. Set the initial x position. Must be a floating point value between
  10371. -100 and 100. Default value is -0.743643887037158704752191506114774.
  10372. @item start_y
  10373. Set the initial y position. Must be a floating point value between
  10374. -100 and 100. Default value is -0.131825904205311970493132056385139.
  10375. @end table
  10376. @section mptestsrc
  10377. Generate various test patterns, as generated by the MPlayer test filter.
  10378. The size of the generated video is fixed, and is 256x256.
  10379. This source is useful in particular for testing encoding features.
  10380. This source accepts the following options:
  10381. @table @option
  10382. @item rate, r
  10383. Specify the frame rate of the sourced video, as the number of frames
  10384. generated per second. It has to be a string in the format
  10385. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  10386. number or a valid video frame rate abbreviation. The default value is
  10387. "25".
  10388. @item duration, d
  10389. Set the duration of the sourced video. See
  10390. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  10391. for the accepted syntax.
  10392. If not specified, or the expressed duration is negative, the video is
  10393. supposed to be generated forever.
  10394. @item test, t
  10395. Set the number or the name of the test to perform. Supported tests are:
  10396. @table @option
  10397. @item dc_luma
  10398. @item dc_chroma
  10399. @item freq_luma
  10400. @item freq_chroma
  10401. @item amp_luma
  10402. @item amp_chroma
  10403. @item cbp
  10404. @item mv
  10405. @item ring1
  10406. @item ring2
  10407. @item all
  10408. @end table
  10409. Default value is "all", which will cycle through the list of all tests.
  10410. @end table
  10411. Some examples:
  10412. @example
  10413. mptestsrc=t=dc_luma
  10414. @end example
  10415. will generate a "dc_luma" test pattern.
  10416. @section frei0r_src
  10417. Provide a frei0r source.
  10418. To enable compilation of this filter you need to install the frei0r
  10419. header and configure FFmpeg with @code{--enable-frei0r}.
  10420. This source accepts the following parameters:
  10421. @table @option
  10422. @item size
  10423. The size of the video to generate. For the syntax of this option, check the
  10424. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10425. @item framerate
  10426. The framerate of the generated video. It may be a string of the form
  10427. @var{num}/@var{den} or a frame rate abbreviation.
  10428. @item filter_name
  10429. The name to the frei0r source to load. For more information regarding frei0r and
  10430. how to set the parameters, read the @ref{frei0r} section in the video filters
  10431. documentation.
  10432. @item filter_params
  10433. A '|'-separated list of parameters to pass to the frei0r source.
  10434. @end table
  10435. For example, to generate a frei0r partik0l source with size 200x200
  10436. and frame rate 10 which is overlaid on the overlay filter main input:
  10437. @example
  10438. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  10439. @end example
  10440. @section life
  10441. Generate a life pattern.
  10442. This source is based on a generalization of John Conway's life game.
  10443. The sourced input represents a life grid, each pixel represents a cell
  10444. which can be in one of two possible states, alive or dead. Every cell
  10445. interacts with its eight neighbours, which are the cells that are
  10446. horizontally, vertically, or diagonally adjacent.
  10447. At each interaction the grid evolves according to the adopted rule,
  10448. which specifies the number of neighbor alive cells which will make a
  10449. cell stay alive or born. The @option{rule} option allows one to specify
  10450. the rule to adopt.
  10451. This source accepts the following options:
  10452. @table @option
  10453. @item filename, f
  10454. Set the file from which to read the initial grid state. In the file,
  10455. each non-whitespace character is considered an alive cell, and newline
  10456. is used to delimit the end of each row.
  10457. If this option is not specified, the initial grid is generated
  10458. randomly.
  10459. @item rate, r
  10460. Set the video rate, that is the number of frames generated per second.
  10461. Default is 25.
  10462. @item random_fill_ratio, ratio
  10463. Set the random fill ratio for the initial random grid. It is a
  10464. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  10465. It is ignored when a file is specified.
  10466. @item random_seed, seed
  10467. Set the seed for filling the initial random grid, must be an integer
  10468. included between 0 and UINT32_MAX. If not specified, or if explicitly
  10469. set to -1, the filter will try to use a good random seed on a best
  10470. effort basis.
  10471. @item rule
  10472. Set the life rule.
  10473. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  10474. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  10475. @var{NS} specifies the number of alive neighbor cells which make a
  10476. live cell stay alive, and @var{NB} the number of alive neighbor cells
  10477. which make a dead cell to become alive (i.e. to "born").
  10478. "s" and "b" can be used in place of "S" and "B", respectively.
  10479. Alternatively a rule can be specified by an 18-bits integer. The 9
  10480. high order bits are used to encode the next cell state if it is alive
  10481. for each number of neighbor alive cells, the low order bits specify
  10482. the rule for "borning" new cells. Higher order bits encode for an
  10483. higher number of neighbor cells.
  10484. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  10485. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  10486. Default value is "S23/B3", which is the original Conway's game of life
  10487. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  10488. cells, and will born a new cell if there are three alive cells around
  10489. a dead cell.
  10490. @item size, s
  10491. Set the size of the output video. For the syntax of this option, check the
  10492. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10493. If @option{filename} is specified, the size is set by default to the
  10494. same size of the input file. If @option{size} is set, it must contain
  10495. the size specified in the input file, and the initial grid defined in
  10496. that file is centered in the larger resulting area.
  10497. If a filename is not specified, the size value defaults to "320x240"
  10498. (used for a randomly generated initial grid).
  10499. @item stitch
  10500. If set to 1, stitch the left and right grid edges together, and the
  10501. top and bottom edges also. Defaults to 1.
  10502. @item mold
  10503. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  10504. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  10505. value from 0 to 255.
  10506. @item life_color
  10507. Set the color of living (or new born) cells.
  10508. @item death_color
  10509. Set the color of dead cells. If @option{mold} is set, this is the first color
  10510. used to represent a dead cell.
  10511. @item mold_color
  10512. Set mold color, for definitely dead and moldy cells.
  10513. For the syntax of these 3 color options, check the "Color" section in the
  10514. ffmpeg-utils manual.
  10515. @end table
  10516. @subsection Examples
  10517. @itemize
  10518. @item
  10519. Read a grid from @file{pattern}, and center it on a grid of size
  10520. 300x300 pixels:
  10521. @example
  10522. life=f=pattern:s=300x300
  10523. @end example
  10524. @item
  10525. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  10526. @example
  10527. life=ratio=2/3:s=200x200
  10528. @end example
  10529. @item
  10530. Specify a custom rule for evolving a randomly generated grid:
  10531. @example
  10532. life=rule=S14/B34
  10533. @end example
  10534. @item
  10535. Full example with slow death effect (mold) using @command{ffplay}:
  10536. @example
  10537. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  10538. @end example
  10539. @end itemize
  10540. @anchor{allrgb}
  10541. @anchor{allyuv}
  10542. @anchor{color}
  10543. @anchor{haldclutsrc}
  10544. @anchor{nullsrc}
  10545. @anchor{rgbtestsrc}
  10546. @anchor{smptebars}
  10547. @anchor{smptehdbars}
  10548. @anchor{testsrc}
  10549. @section allrgb, allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  10550. The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
  10551. The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
  10552. The @code{color} source provides an uniformly colored input.
  10553. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  10554. @ref{haldclut} filter.
  10555. The @code{nullsrc} source returns unprocessed video frames. It is
  10556. mainly useful to be employed in analysis / debugging tools, or as the
  10557. source for filters which ignore the input data.
  10558. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  10559. detecting RGB vs BGR issues. You should see a red, green and blue
  10560. stripe from top to bottom.
  10561. The @code{smptebars} source generates a color bars pattern, based on
  10562. the SMPTE Engineering Guideline EG 1-1990.
  10563. The @code{smptehdbars} source generates a color bars pattern, based on
  10564. the SMPTE RP 219-2002.
  10565. The @code{testsrc} source generates a test video pattern, showing a
  10566. color pattern, a scrolling gradient and a timestamp. This is mainly
  10567. intended for testing purposes.
  10568. The sources accept the following parameters:
  10569. @table @option
  10570. @item color, c
  10571. Specify the color of the source, only available in the @code{color}
  10572. source. For the syntax of this option, check the "Color" section in the
  10573. ffmpeg-utils manual.
  10574. @item level
  10575. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  10576. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  10577. pixels to be used as identity matrix for 3D lookup tables. Each component is
  10578. coded on a @code{1/(N*N)} scale.
  10579. @item size, s
  10580. Specify the size of the sourced video. For the syntax of this option, check the
  10581. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10582. The default value is @code{320x240}.
  10583. This option is not available with the @code{haldclutsrc} filter.
  10584. @item rate, r
  10585. Specify the frame rate of the sourced video, as the number of frames
  10586. generated per second. It has to be a string in the format
  10587. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  10588. number or a valid video frame rate abbreviation. The default value is
  10589. "25".
  10590. @item sar
  10591. Set the sample aspect ratio of the sourced video.
  10592. @item duration, d
  10593. Set the duration of the sourced video. See
  10594. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  10595. for the accepted syntax.
  10596. If not specified, or the expressed duration is negative, the video is
  10597. supposed to be generated forever.
  10598. @item decimals, n
  10599. Set the number of decimals to show in the timestamp, only available in the
  10600. @code{testsrc} source.
  10601. The displayed timestamp value will correspond to the original
  10602. timestamp value multiplied by the power of 10 of the specified
  10603. value. Default value is 0.
  10604. @end table
  10605. For example the following:
  10606. @example
  10607. testsrc=duration=5.3:size=qcif:rate=10
  10608. @end example
  10609. will generate a video with a duration of 5.3 seconds, with size
  10610. 176x144 and a frame rate of 10 frames per second.
  10611. The following graph description will generate a red source
  10612. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  10613. frames per second.
  10614. @example
  10615. color=c=red@@0.2:s=qcif:r=10
  10616. @end example
  10617. If the input content is to be ignored, @code{nullsrc} can be used. The
  10618. following command generates noise in the luminance plane by employing
  10619. the @code{geq} filter:
  10620. @example
  10621. nullsrc=s=256x256, geq=random(1)*255:128:128
  10622. @end example
  10623. @subsection Commands
  10624. The @code{color} source supports the following commands:
  10625. @table @option
  10626. @item c, color
  10627. Set the color of the created image. Accepts the same syntax of the
  10628. corresponding @option{color} option.
  10629. @end table
  10630. @c man end VIDEO SOURCES
  10631. @chapter Video Sinks
  10632. @c man begin VIDEO SINKS
  10633. Below is a description of the currently available video sinks.
  10634. @section buffersink
  10635. Buffer video frames, and make them available to the end of the filter
  10636. graph.
  10637. This sink is mainly intended for programmatic use, in particular
  10638. through the interface defined in @file{libavfilter/buffersink.h}
  10639. or the options system.
  10640. It accepts a pointer to an AVBufferSinkContext structure, which
  10641. defines the incoming buffers' formats, to be passed as the opaque
  10642. parameter to @code{avfilter_init_filter} for initialization.
  10643. @section nullsink
  10644. Null video sink: do absolutely nothing with the input video. It is
  10645. mainly useful as a template and for use in analysis / debugging
  10646. tools.
  10647. @c man end VIDEO SINKS
  10648. @chapter Multimedia Filters
  10649. @c man begin MULTIMEDIA FILTERS
  10650. Below is a description of the currently available multimedia filters.
  10651. @section ahistogram
  10652. Convert input audio to a video output, displaying the volume histogram.
  10653. The filter accepts the following options:
  10654. @table @option
  10655. @item dmode
  10656. Specify how histogram is calculated.
  10657. It accepts the following values:
  10658. @table @samp
  10659. @item single
  10660. Use single histogram for all channels.
  10661. @item separate
  10662. Use separate histogram for each channel.
  10663. @end table
  10664. Default is @code{single}.
  10665. @item rate, r
  10666. Set frame rate, expressed as number of frames per second. Default
  10667. value is "25".
  10668. @item size, s
  10669. Specify the video size for the output. For the syntax of this option, check the
  10670. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10671. Default value is @code{hd720}.
  10672. @item scale
  10673. Set display scale.
  10674. It accepts the following values:
  10675. @table @samp
  10676. @item log
  10677. logarithmic
  10678. @item sqrt
  10679. square root
  10680. @item cbrt
  10681. cubic root
  10682. @item lin
  10683. linear
  10684. @item rlog
  10685. reverse logarithmic
  10686. @end table
  10687. Default is @code{log}.
  10688. @item ascale
  10689. Set amplitude scale.
  10690. It accepts the following values:
  10691. @table @samp
  10692. @item log
  10693. logarithmic
  10694. @item lin
  10695. linear
  10696. @end table
  10697. Default is @code{log}.
  10698. @item acount
  10699. Set how much frames to accumulate in histogram.
  10700. Defauls is 1. Setting this to -1 accumulates all frames.
  10701. @item rheight
  10702. Set histogram ratio of window height.
  10703. @item slide
  10704. Set sonogram sliding.
  10705. It accepts the following values:
  10706. @table @samp
  10707. @item replace
  10708. replace old rows with new ones.
  10709. @item scroll
  10710. scroll from top to bottom.
  10711. @end table
  10712. Default is @code{replace}.
  10713. @end table
  10714. @section aphasemeter
  10715. Convert input audio to a video output, displaying the audio phase.
  10716. The filter accepts the following options:
  10717. @table @option
  10718. @item rate, r
  10719. Set the output frame rate. Default value is @code{25}.
  10720. @item size, s
  10721. Set the video size for the output. For the syntax of this option, check the
  10722. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10723. Default value is @code{800x400}.
  10724. @item rc
  10725. @item gc
  10726. @item bc
  10727. Specify the red, green, blue contrast. Default values are @code{2},
  10728. @code{7} and @code{1}.
  10729. Allowed range is @code{[0, 255]}.
  10730. @item mpc
  10731. Set color which will be used for drawing median phase. If color is
  10732. @code{none} which is default, no median phase value will be drawn.
  10733. @end table
  10734. The filter also exports the frame metadata @code{lavfi.aphasemeter.phase} which
  10735. represents mean phase of current audio frame. Value is in range @code{[-1, 1]}.
  10736. The @code{-1} means left and right channels are completely out of phase and
  10737. @code{1} means channels are in phase.
  10738. @section avectorscope
  10739. Convert input audio to a video output, representing the audio vector
  10740. scope.
  10741. The filter is used to measure the difference between channels of stereo
  10742. audio stream. A monoaural signal, consisting of identical left and right
  10743. signal, results in straight vertical line. Any stereo separation is visible
  10744. as a deviation from this line, creating a Lissajous figure.
  10745. If the straight (or deviation from it) but horizontal line appears this
  10746. indicates that the left and right channels are out of phase.
  10747. The filter accepts the following options:
  10748. @table @option
  10749. @item mode, m
  10750. Set the vectorscope mode.
  10751. Available values are:
  10752. @table @samp
  10753. @item lissajous
  10754. Lissajous rotated by 45 degrees.
  10755. @item lissajous_xy
  10756. Same as above but not rotated.
  10757. @item polar
  10758. Shape resembling half of circle.
  10759. @end table
  10760. Default value is @samp{lissajous}.
  10761. @item size, s
  10762. Set the video size for the output. For the syntax of this option, check the
  10763. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10764. Default value is @code{400x400}.
  10765. @item rate, r
  10766. Set the output frame rate. Default value is @code{25}.
  10767. @item rc
  10768. @item gc
  10769. @item bc
  10770. @item ac
  10771. Specify the red, green, blue and alpha contrast. Default values are @code{40},
  10772. @code{160}, @code{80} and @code{255}.
  10773. Allowed range is @code{[0, 255]}.
  10774. @item rf
  10775. @item gf
  10776. @item bf
  10777. @item af
  10778. Specify the red, green, blue and alpha fade. Default values are @code{15},
  10779. @code{10}, @code{5} and @code{5}.
  10780. Allowed range is @code{[0, 255]}.
  10781. @item zoom
  10782. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  10783. @item draw
  10784. Set the vectorscope drawing mode.
  10785. Available values are:
  10786. @table @samp
  10787. @item dot
  10788. Draw dot for each sample.
  10789. @item line
  10790. Draw line between previous and current sample.
  10791. @end table
  10792. Default value is @samp{dot}.
  10793. @end table
  10794. @subsection Examples
  10795. @itemize
  10796. @item
  10797. Complete example using @command{ffplay}:
  10798. @example
  10799. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  10800. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  10801. @end example
  10802. @end itemize
  10803. @section concat
  10804. Concatenate audio and video streams, joining them together one after the
  10805. other.
  10806. The filter works on segments of synchronized video and audio streams. All
  10807. segments must have the same number of streams of each type, and that will
  10808. also be the number of streams at output.
  10809. The filter accepts the following options:
  10810. @table @option
  10811. @item n
  10812. Set the number of segments. Default is 2.
  10813. @item v
  10814. Set the number of output video streams, that is also the number of video
  10815. streams in each segment. Default is 1.
  10816. @item a
  10817. Set the number of output audio streams, that is also the number of audio
  10818. streams in each segment. Default is 0.
  10819. @item unsafe
  10820. Activate unsafe mode: do not fail if segments have a different format.
  10821. @end table
  10822. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  10823. @var{a} audio outputs.
  10824. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  10825. segment, in the same order as the outputs, then the inputs for the second
  10826. segment, etc.
  10827. Related streams do not always have exactly the same duration, for various
  10828. reasons including codec frame size or sloppy authoring. For that reason,
  10829. related synchronized streams (e.g. a video and its audio track) should be
  10830. concatenated at once. The concat filter will use the duration of the longest
  10831. stream in each segment (except the last one), and if necessary pad shorter
  10832. audio streams with silence.
  10833. For this filter to work correctly, all segments must start at timestamp 0.
  10834. All corresponding streams must have the same parameters in all segments; the
  10835. filtering system will automatically select a common pixel format for video
  10836. streams, and a common sample format, sample rate and channel layout for
  10837. audio streams, but other settings, such as resolution, must be converted
  10838. explicitly by the user.
  10839. Different frame rates are acceptable but will result in variable frame rate
  10840. at output; be sure to configure the output file to handle it.
  10841. @subsection Examples
  10842. @itemize
  10843. @item
  10844. Concatenate an opening, an episode and an ending, all in bilingual version
  10845. (video in stream 0, audio in streams 1 and 2):
  10846. @example
  10847. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  10848. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  10849. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  10850. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  10851. @end example
  10852. @item
  10853. Concatenate two parts, handling audio and video separately, using the
  10854. (a)movie sources, and adjusting the resolution:
  10855. @example
  10856. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  10857. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  10858. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  10859. @end example
  10860. Note that a desync will happen at the stitch if the audio and video streams
  10861. do not have exactly the same duration in the first file.
  10862. @end itemize
  10863. @anchor{ebur128}
  10864. @section ebur128
  10865. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  10866. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  10867. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  10868. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  10869. The filter also has a video output (see the @var{video} option) with a real
  10870. time graph to observe the loudness evolution. The graphic contains the logged
  10871. message mentioned above, so it is not printed anymore when this option is set,
  10872. unless the verbose logging is set. The main graphing area contains the
  10873. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  10874. the momentary loudness (400 milliseconds).
  10875. More information about the Loudness Recommendation EBU R128 on
  10876. @url{http://tech.ebu.ch/loudness}.
  10877. The filter accepts the following options:
  10878. @table @option
  10879. @item video
  10880. Activate the video output. The audio stream is passed unchanged whether this
  10881. option is set or no. The video stream will be the first output stream if
  10882. activated. Default is @code{0}.
  10883. @item size
  10884. Set the video size. This option is for video only. For the syntax of this
  10885. option, check the
  10886. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10887. Default and minimum resolution is @code{640x480}.
  10888. @item meter
  10889. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  10890. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  10891. other integer value between this range is allowed.
  10892. @item metadata
  10893. Set metadata injection. If set to @code{1}, the audio input will be segmented
  10894. into 100ms output frames, each of them containing various loudness information
  10895. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  10896. Default is @code{0}.
  10897. @item framelog
  10898. Force the frame logging level.
  10899. Available values are:
  10900. @table @samp
  10901. @item info
  10902. information logging level
  10903. @item verbose
  10904. verbose logging level
  10905. @end table
  10906. By default, the logging level is set to @var{info}. If the @option{video} or
  10907. the @option{metadata} options are set, it switches to @var{verbose}.
  10908. @item peak
  10909. Set peak mode(s).
  10910. Available modes can be cumulated (the option is a @code{flag} type). Possible
  10911. values are:
  10912. @table @samp
  10913. @item none
  10914. Disable any peak mode (default).
  10915. @item sample
  10916. Enable sample-peak mode.
  10917. Simple peak mode looking for the higher sample value. It logs a message
  10918. for sample-peak (identified by @code{SPK}).
  10919. @item true
  10920. Enable true-peak mode.
  10921. If enabled, the peak lookup is done on an over-sampled version of the input
  10922. stream for better peak accuracy. It logs a message for true-peak.
  10923. (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
  10924. This mode requires a build with @code{libswresample}.
  10925. @end table
  10926. @item dualmono
  10927. Treat mono input files as "dual mono". If a mono file is intended for playback
  10928. on a stereo system, its EBU R128 measurement will be perceptually incorrect.
  10929. If set to @code{true}, this option will compensate for this effect.
  10930. Multi-channel input files are not affected by this option.
  10931. @item panlaw
  10932. Set a specific pan law to be used for the measurement of dual mono files.
  10933. This parameter is optional, and has a default value of -3.01dB.
  10934. @end table
  10935. @subsection Examples
  10936. @itemize
  10937. @item
  10938. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  10939. @example
  10940. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  10941. @end example
  10942. @item
  10943. Run an analysis with @command{ffmpeg}:
  10944. @example
  10945. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  10946. @end example
  10947. @end itemize
  10948. @section interleave, ainterleave
  10949. Temporally interleave frames from several inputs.
  10950. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  10951. These filters read frames from several inputs and send the oldest
  10952. queued frame to the output.
  10953. Input streams must have a well defined, monotonically increasing frame
  10954. timestamp values.
  10955. In order to submit one frame to output, these filters need to enqueue
  10956. at least one frame for each input, so they cannot work in case one
  10957. input is not yet terminated and will not receive incoming frames.
  10958. For example consider the case when one input is a @code{select} filter
  10959. which always drop input frames. The @code{interleave} filter will keep
  10960. reading from that input, but it will never be able to send new frames
  10961. to output until the input will send an end-of-stream signal.
  10962. Also, depending on inputs synchronization, the filters will drop
  10963. frames in case one input receives more frames than the other ones, and
  10964. the queue is already filled.
  10965. These filters accept the following options:
  10966. @table @option
  10967. @item nb_inputs, n
  10968. Set the number of different inputs, it is 2 by default.
  10969. @end table
  10970. @subsection Examples
  10971. @itemize
  10972. @item
  10973. Interleave frames belonging to different streams using @command{ffmpeg}:
  10974. @example
  10975. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  10976. @end example
  10977. @item
  10978. Add flickering blur effect:
  10979. @example
  10980. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  10981. @end example
  10982. @end itemize
  10983. @section perms, aperms
  10984. Set read/write permissions for the output frames.
  10985. These filters are mainly aimed at developers to test direct path in the
  10986. following filter in the filtergraph.
  10987. The filters accept the following options:
  10988. @table @option
  10989. @item mode
  10990. Select the permissions mode.
  10991. It accepts the following values:
  10992. @table @samp
  10993. @item none
  10994. Do nothing. This is the default.
  10995. @item ro
  10996. Set all the output frames read-only.
  10997. @item rw
  10998. Set all the output frames directly writable.
  10999. @item toggle
  11000. Make the frame read-only if writable, and writable if read-only.
  11001. @item random
  11002. Set each output frame read-only or writable randomly.
  11003. @end table
  11004. @item seed
  11005. Set the seed for the @var{random} mode, must be an integer included between
  11006. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  11007. @code{-1}, the filter will try to use a good random seed on a best effort
  11008. basis.
  11009. @end table
  11010. Note: in case of auto-inserted filter between the permission filter and the
  11011. following one, the permission might not be received as expected in that
  11012. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  11013. perms/aperms filter can avoid this problem.
  11014. @section realtime, arealtime
  11015. Slow down filtering to match real time approximatively.
  11016. These filters will pause the filtering for a variable amount of time to
  11017. match the output rate with the input timestamps.
  11018. They are similar to the @option{re} option to @code{ffmpeg}.
  11019. They accept the following options:
  11020. @table @option
  11021. @item limit
  11022. Time limit for the pauses. Any pause longer than that will be considered
  11023. a timestamp discontinuity and reset the timer. Default is 2 seconds.
  11024. @end table
  11025. @section select, aselect
  11026. Select frames to pass in output.
  11027. This filter accepts the following options:
  11028. @table @option
  11029. @item expr, e
  11030. Set expression, which is evaluated for each input frame.
  11031. If the expression is evaluated to zero, the frame is discarded.
  11032. If the evaluation result is negative or NaN, the frame is sent to the
  11033. first output; otherwise it is sent to the output with index
  11034. @code{ceil(val)-1}, assuming that the input index starts from 0.
  11035. For example a value of @code{1.2} corresponds to the output with index
  11036. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  11037. @item outputs, n
  11038. Set the number of outputs. The output to which to send the selected
  11039. frame is based on the result of the evaluation. Default value is 1.
  11040. @end table
  11041. The expression can contain the following constants:
  11042. @table @option
  11043. @item n
  11044. The (sequential) number of the filtered frame, starting from 0.
  11045. @item selected_n
  11046. The (sequential) number of the selected frame, starting from 0.
  11047. @item prev_selected_n
  11048. The sequential number of the last selected frame. It's NAN if undefined.
  11049. @item TB
  11050. The timebase of the input timestamps.
  11051. @item pts
  11052. The PTS (Presentation TimeStamp) of the filtered video frame,
  11053. expressed in @var{TB} units. It's NAN if undefined.
  11054. @item t
  11055. The PTS of the filtered video frame,
  11056. expressed in seconds. It's NAN if undefined.
  11057. @item prev_pts
  11058. The PTS of the previously filtered video frame. It's NAN if undefined.
  11059. @item prev_selected_pts
  11060. The PTS of the last previously filtered video frame. It's NAN if undefined.
  11061. @item prev_selected_t
  11062. The PTS of the last previously selected video frame. It's NAN if undefined.
  11063. @item start_pts
  11064. The PTS of the first video frame in the video. It's NAN if undefined.
  11065. @item start_t
  11066. The time of the first video frame in the video. It's NAN if undefined.
  11067. @item pict_type @emph{(video only)}
  11068. The type of the filtered frame. It can assume one of the following
  11069. values:
  11070. @table @option
  11071. @item I
  11072. @item P
  11073. @item B
  11074. @item S
  11075. @item SI
  11076. @item SP
  11077. @item BI
  11078. @end table
  11079. @item interlace_type @emph{(video only)}
  11080. The frame interlace type. It can assume one of the following values:
  11081. @table @option
  11082. @item PROGRESSIVE
  11083. The frame is progressive (not interlaced).
  11084. @item TOPFIRST
  11085. The frame is top-field-first.
  11086. @item BOTTOMFIRST
  11087. The frame is bottom-field-first.
  11088. @end table
  11089. @item consumed_sample_n @emph{(audio only)}
  11090. the number of selected samples before the current frame
  11091. @item samples_n @emph{(audio only)}
  11092. the number of samples in the current frame
  11093. @item sample_rate @emph{(audio only)}
  11094. the input sample rate
  11095. @item key
  11096. This is 1 if the filtered frame is a key-frame, 0 otherwise.
  11097. @item pos
  11098. the position in the file of the filtered frame, -1 if the information
  11099. is not available (e.g. for synthetic video)
  11100. @item scene @emph{(video only)}
  11101. value between 0 and 1 to indicate a new scene; a low value reflects a low
  11102. probability for the current frame to introduce a new scene, while a higher
  11103. value means the current frame is more likely to be one (see the example below)
  11104. @item concatdec_select
  11105. The concat demuxer can select only part of a concat input file by setting an
  11106. inpoint and an outpoint, but the output packets may not be entirely contained
  11107. in the selected interval. By using this variable, it is possible to skip frames
  11108. generated by the concat demuxer which are not exactly contained in the selected
  11109. interval.
  11110. This works by comparing the frame pts against the @var{lavf.concat.start_time}
  11111. and the @var{lavf.concat.duration} packet metadata values which are also
  11112. present in the decoded frames.
  11113. The @var{concatdec_select} variable is -1 if the frame pts is at least
  11114. start_time and either the duration metadata is missing or the frame pts is less
  11115. than start_time + duration, 0 otherwise, and NaN if the start_time metadata is
  11116. missing.
  11117. That basically means that an input frame is selected if its pts is within the
  11118. interval set by the concat demuxer.
  11119. @end table
  11120. The default value of the select expression is "1".
  11121. @subsection Examples
  11122. @itemize
  11123. @item
  11124. Select all frames in input:
  11125. @example
  11126. select
  11127. @end example
  11128. The example above is the same as:
  11129. @example
  11130. select=1
  11131. @end example
  11132. @item
  11133. Skip all frames:
  11134. @example
  11135. select=0
  11136. @end example
  11137. @item
  11138. Select only I-frames:
  11139. @example
  11140. select='eq(pict_type\,I)'
  11141. @end example
  11142. @item
  11143. Select one frame every 100:
  11144. @example
  11145. select='not(mod(n\,100))'
  11146. @end example
  11147. @item
  11148. Select only frames contained in the 10-20 time interval:
  11149. @example
  11150. select=between(t\,10\,20)
  11151. @end example
  11152. @item
  11153. Select only I frames contained in the 10-20 time interval:
  11154. @example
  11155. select=between(t\,10\,20)*eq(pict_type\,I)
  11156. @end example
  11157. @item
  11158. Select frames with a minimum distance of 10 seconds:
  11159. @example
  11160. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  11161. @end example
  11162. @item
  11163. Use aselect to select only audio frames with samples number > 100:
  11164. @example
  11165. aselect='gt(samples_n\,100)'
  11166. @end example
  11167. @item
  11168. Create a mosaic of the first scenes:
  11169. @example
  11170. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  11171. @end example
  11172. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  11173. choice.
  11174. @item
  11175. Send even and odd frames to separate outputs, and compose them:
  11176. @example
  11177. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  11178. @end example
  11179. @item
  11180. Select useful frames from an ffconcat file which is using inpoints and
  11181. outpoints but where the source files are not intra frame only.
  11182. @example
  11183. ffmpeg -copyts -vsync 0 -segment_time_metadata 1 -i input.ffconcat -vf select=concatdec_select -af aselect=concatdec_select output.avi
  11184. @end example
  11185. @end itemize
  11186. @section sendcmd, asendcmd
  11187. Send commands to filters in the filtergraph.
  11188. These filters read commands to be sent to other filters in the
  11189. filtergraph.
  11190. @code{sendcmd} must be inserted between two video filters,
  11191. @code{asendcmd} must be inserted between two audio filters, but apart
  11192. from that they act the same way.
  11193. The specification of commands can be provided in the filter arguments
  11194. with the @var{commands} option, or in a file specified by the
  11195. @var{filename} option.
  11196. These filters accept the following options:
  11197. @table @option
  11198. @item commands, c
  11199. Set the commands to be read and sent to the other filters.
  11200. @item filename, f
  11201. Set the filename of the commands to be read and sent to the other
  11202. filters.
  11203. @end table
  11204. @subsection Commands syntax
  11205. A commands description consists of a sequence of interval
  11206. specifications, comprising a list of commands to be executed when a
  11207. particular event related to that interval occurs. The occurring event
  11208. is typically the current frame time entering or leaving a given time
  11209. interval.
  11210. An interval is specified by the following syntax:
  11211. @example
  11212. @var{START}[-@var{END}] @var{COMMANDS};
  11213. @end example
  11214. The time interval is specified by the @var{START} and @var{END} times.
  11215. @var{END} is optional and defaults to the maximum time.
  11216. The current frame time is considered within the specified interval if
  11217. it is included in the interval [@var{START}, @var{END}), that is when
  11218. the time is greater or equal to @var{START} and is lesser than
  11219. @var{END}.
  11220. @var{COMMANDS} consists of a sequence of one or more command
  11221. specifications, separated by ",", relating to that interval. The
  11222. syntax of a command specification is given by:
  11223. @example
  11224. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  11225. @end example
  11226. @var{FLAGS} is optional and specifies the type of events relating to
  11227. the time interval which enable sending the specified command, and must
  11228. be a non-null sequence of identifier flags separated by "+" or "|" and
  11229. enclosed between "[" and "]".
  11230. The following flags are recognized:
  11231. @table @option
  11232. @item enter
  11233. The command is sent when the current frame timestamp enters the
  11234. specified interval. In other words, the command is sent when the
  11235. previous frame timestamp was not in the given interval, and the
  11236. current is.
  11237. @item leave
  11238. The command is sent when the current frame timestamp leaves the
  11239. specified interval. In other words, the command is sent when the
  11240. previous frame timestamp was in the given interval, and the
  11241. current is not.
  11242. @end table
  11243. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  11244. assumed.
  11245. @var{TARGET} specifies the target of the command, usually the name of
  11246. the filter class or a specific filter instance name.
  11247. @var{COMMAND} specifies the name of the command for the target filter.
  11248. @var{ARG} is optional and specifies the optional list of argument for
  11249. the given @var{COMMAND}.
  11250. Between one interval specification and another, whitespaces, or
  11251. sequences of characters starting with @code{#} until the end of line,
  11252. are ignored and can be used to annotate comments.
  11253. A simplified BNF description of the commands specification syntax
  11254. follows:
  11255. @example
  11256. @var{COMMAND_FLAG} ::= "enter" | "leave"
  11257. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  11258. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  11259. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  11260. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  11261. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  11262. @end example
  11263. @subsection Examples
  11264. @itemize
  11265. @item
  11266. Specify audio tempo change at second 4:
  11267. @example
  11268. asendcmd=c='4.0 atempo tempo 1.5',atempo
  11269. @end example
  11270. @item
  11271. Specify a list of drawtext and hue commands in a file.
  11272. @example
  11273. # show text in the interval 5-10
  11274. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  11275. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  11276. # desaturate the image in the interval 15-20
  11277. 15.0-20.0 [enter] hue s 0,
  11278. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  11279. [leave] hue s 1,
  11280. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  11281. # apply an exponential saturation fade-out effect, starting from time 25
  11282. 25 [enter] hue s exp(25-t)
  11283. @end example
  11284. A filtergraph allowing to read and process the above command list
  11285. stored in a file @file{test.cmd}, can be specified with:
  11286. @example
  11287. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  11288. @end example
  11289. @end itemize
  11290. @anchor{setpts}
  11291. @section setpts, asetpts
  11292. Change the PTS (presentation timestamp) of the input frames.
  11293. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  11294. This filter accepts the following options:
  11295. @table @option
  11296. @item expr
  11297. The expression which is evaluated for each frame to construct its timestamp.
  11298. @end table
  11299. The expression is evaluated through the eval API and can contain the following
  11300. constants:
  11301. @table @option
  11302. @item FRAME_RATE
  11303. frame rate, only defined for constant frame-rate video
  11304. @item PTS
  11305. The presentation timestamp in input
  11306. @item N
  11307. The count of the input frame for video or the number of consumed samples,
  11308. not including the current frame for audio, starting from 0.
  11309. @item NB_CONSUMED_SAMPLES
  11310. The number of consumed samples, not including the current frame (only
  11311. audio)
  11312. @item NB_SAMPLES, S
  11313. The number of samples in the current frame (only audio)
  11314. @item SAMPLE_RATE, SR
  11315. The audio sample rate.
  11316. @item STARTPTS
  11317. The PTS of the first frame.
  11318. @item STARTT
  11319. the time in seconds of the first frame
  11320. @item INTERLACED
  11321. State whether the current frame is interlaced.
  11322. @item T
  11323. the time in seconds of the current frame
  11324. @item POS
  11325. original position in the file of the frame, or undefined if undefined
  11326. for the current frame
  11327. @item PREV_INPTS
  11328. The previous input PTS.
  11329. @item PREV_INT
  11330. previous input time in seconds
  11331. @item PREV_OUTPTS
  11332. The previous output PTS.
  11333. @item PREV_OUTT
  11334. previous output time in seconds
  11335. @item RTCTIME
  11336. The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  11337. instead.
  11338. @item RTCSTART
  11339. The wallclock (RTC) time at the start of the movie in microseconds.
  11340. @item TB
  11341. The timebase of the input timestamps.
  11342. @end table
  11343. @subsection Examples
  11344. @itemize
  11345. @item
  11346. Start counting PTS from zero
  11347. @example
  11348. setpts=PTS-STARTPTS
  11349. @end example
  11350. @item
  11351. Apply fast motion effect:
  11352. @example
  11353. setpts=0.5*PTS
  11354. @end example
  11355. @item
  11356. Apply slow motion effect:
  11357. @example
  11358. setpts=2.0*PTS
  11359. @end example
  11360. @item
  11361. Set fixed rate of 25 frames per second:
  11362. @example
  11363. setpts=N/(25*TB)
  11364. @end example
  11365. @item
  11366. Set fixed rate 25 fps with some jitter:
  11367. @example
  11368. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  11369. @end example
  11370. @item
  11371. Apply an offset of 10 seconds to the input PTS:
  11372. @example
  11373. setpts=PTS+10/TB
  11374. @end example
  11375. @item
  11376. Generate timestamps from a "live source" and rebase onto the current timebase:
  11377. @example
  11378. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  11379. @end example
  11380. @item
  11381. Generate timestamps by counting samples:
  11382. @example
  11383. asetpts=N/SR/TB
  11384. @end example
  11385. @end itemize
  11386. @section settb, asettb
  11387. Set the timebase to use for the output frames timestamps.
  11388. It is mainly useful for testing timebase configuration.
  11389. It accepts the following parameters:
  11390. @table @option
  11391. @item expr, tb
  11392. The expression which is evaluated into the output timebase.
  11393. @end table
  11394. The value for @option{tb} is an arithmetic expression representing a
  11395. rational. The expression can contain the constants "AVTB" (the default
  11396. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  11397. audio only). Default value is "intb".
  11398. @subsection Examples
  11399. @itemize
  11400. @item
  11401. Set the timebase to 1/25:
  11402. @example
  11403. settb=expr=1/25
  11404. @end example
  11405. @item
  11406. Set the timebase to 1/10:
  11407. @example
  11408. settb=expr=0.1
  11409. @end example
  11410. @item
  11411. Set the timebase to 1001/1000:
  11412. @example
  11413. settb=1+0.001
  11414. @end example
  11415. @item
  11416. Set the timebase to 2*intb:
  11417. @example
  11418. settb=2*intb
  11419. @end example
  11420. @item
  11421. Set the default timebase value:
  11422. @example
  11423. settb=AVTB
  11424. @end example
  11425. @end itemize
  11426. @section showcqt
  11427. Convert input audio to a video output representing frequency spectrum
  11428. logarithmically using Brown-Puckette constant Q transform algorithm with
  11429. direct frequency domain coefficient calculation (but the transform itself
  11430. is not really constant Q, instead the Q factor is actually variable/clamped),
  11431. with musical tone scale, from E0 to D#10.
  11432. The filter accepts the following options:
  11433. @table @option
  11434. @item size, s
  11435. Specify the video size for the output. It must be even. For the syntax of this option,
  11436. check the @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11437. Default value is @code{1920x1080}.
  11438. @item fps, rate, r
  11439. Set the output frame rate. Default value is @code{25}.
  11440. @item bar_h
  11441. Set the bargraph height. It must be even. Default value is @code{-1} which
  11442. computes the bargraph height automatically.
  11443. @item axis_h
  11444. Set the axis height. It must be even. Default value is @code{-1} which computes
  11445. the axis height automatically.
  11446. @item sono_h
  11447. Set the sonogram height. It must be even. Default value is @code{-1} which
  11448. computes the sonogram height automatically.
  11449. @item fullhd
  11450. Set the fullhd resolution. This option is deprecated, use @var{size}, @var{s}
  11451. instead. Default value is @code{1}.
  11452. @item sono_v, volume
  11453. Specify the sonogram volume expression. It can contain variables:
  11454. @table @option
  11455. @item bar_v
  11456. the @var{bar_v} evaluated expression
  11457. @item frequency, freq, f
  11458. the frequency where it is evaluated
  11459. @item timeclamp, tc
  11460. the value of @var{timeclamp} option
  11461. @end table
  11462. and functions:
  11463. @table @option
  11464. @item a_weighting(f)
  11465. A-weighting of equal loudness
  11466. @item b_weighting(f)
  11467. B-weighting of equal loudness
  11468. @item c_weighting(f)
  11469. C-weighting of equal loudness.
  11470. @end table
  11471. Default value is @code{16}.
  11472. @item bar_v, volume2
  11473. Specify the bargraph volume expression. It can contain variables:
  11474. @table @option
  11475. @item sono_v
  11476. the @var{sono_v} evaluated expression
  11477. @item frequency, freq, f
  11478. the frequency where it is evaluated
  11479. @item timeclamp, tc
  11480. the value of @var{timeclamp} option
  11481. @end table
  11482. and functions:
  11483. @table @option
  11484. @item a_weighting(f)
  11485. A-weighting of equal loudness
  11486. @item b_weighting(f)
  11487. B-weighting of equal loudness
  11488. @item c_weighting(f)
  11489. C-weighting of equal loudness.
  11490. @end table
  11491. Default value is @code{sono_v}.
  11492. @item sono_g, gamma
  11493. Specify the sonogram gamma. Lower gamma makes the spectrum more contrast,
  11494. higher gamma makes the spectrum having more range. Default value is @code{3}.
  11495. Acceptable range is @code{[1, 7]}.
  11496. @item bar_g, gamma2
  11497. Specify the bargraph gamma. Default value is @code{1}. Acceptable range is
  11498. @code{[1, 7]}.
  11499. @item timeclamp, tc
  11500. Specify the transform timeclamp. At low frequency, there is trade-off between
  11501. accuracy in time domain and frequency domain. If timeclamp is lower,
  11502. event in time domain is represented more accurately (such as fast bass drum),
  11503. otherwise event in frequency domain is represented more accurately
  11504. (such as bass guitar). Acceptable range is @code{[0.1, 1]}. Default value is @code{0.17}.
  11505. @item basefreq
  11506. Specify the transform base frequency. Default value is @code{20.01523126408007475},
  11507. which is frequency 50 cents below E0. Acceptable range is @code{[10, 100000]}.
  11508. @item endfreq
  11509. Specify the transform end frequency. Default value is @code{20495.59681441799654},
  11510. which is frequency 50 cents above D#10. Acceptable range is @code{[10, 100000]}.
  11511. @item coeffclamp
  11512. This option is deprecated and ignored.
  11513. @item tlength
  11514. Specify the transform length in time domain. Use this option to control accuracy
  11515. trade-off between time domain and frequency domain at every frequency sample.
  11516. It can contain variables:
  11517. @table @option
  11518. @item frequency, freq, f
  11519. the frequency where it is evaluated
  11520. @item timeclamp, tc
  11521. the value of @var{timeclamp} option.
  11522. @end table
  11523. Default value is @code{384*tc/(384+tc*f)}.
  11524. @item count
  11525. Specify the transform count for every video frame. Default value is @code{6}.
  11526. Acceptable range is @code{[1, 30]}.
  11527. @item fcount
  11528. Specify the transform count for every single pixel. Default value is @code{0},
  11529. which makes it computed automatically. Acceptable range is @code{[0, 10]}.
  11530. @item fontfile
  11531. Specify font file for use with freetype to draw the axis. If not specified,
  11532. use embedded font. Note that drawing with font file or embedded font is not
  11533. implemented with custom @var{basefreq} and @var{endfreq}, use @var{axisfile}
  11534. option instead.
  11535. @item fontcolor
  11536. Specify font color expression. This is arithmetic expression that should return
  11537. integer value 0xRRGGBB. It can contain variables:
  11538. @table @option
  11539. @item frequency, freq, f
  11540. the frequency where it is evaluated
  11541. @item timeclamp, tc
  11542. the value of @var{timeclamp} option
  11543. @end table
  11544. and functions:
  11545. @table @option
  11546. @item midi(f)
  11547. midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
  11548. @item r(x), g(x), b(x)
  11549. red, green, and blue value of intensity x.
  11550. @end table
  11551. Default value is @code{st(0, (midi(f)-59.5)/12);
  11552. st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
  11553. r(1-ld(1)) + b(ld(1))}.
  11554. @item axisfile
  11555. Specify image file to draw the axis. This option override @var{fontfile} and
  11556. @var{fontcolor} option.
  11557. @item axis, text
  11558. Enable/disable drawing text to the axis. If it is set to @code{0}, drawing to
  11559. the axis is disabled, ignoring @var{fontfile} and @var{axisfile} option.
  11560. Default value is @code{1}.
  11561. @end table
  11562. @subsection Examples
  11563. @itemize
  11564. @item
  11565. Playing audio while showing the spectrum:
  11566. @example
  11567. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
  11568. @end example
  11569. @item
  11570. Same as above, but with frame rate 30 fps:
  11571. @example
  11572. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
  11573. @end example
  11574. @item
  11575. Playing at 1280x720:
  11576. @example
  11577. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=s=1280x720:count=4 [out0]'
  11578. @end example
  11579. @item
  11580. Disable sonogram display:
  11581. @example
  11582. sono_h=0
  11583. @end example
  11584. @item
  11585. A1 and its harmonics: A1, A2, (near)E3, A3:
  11586. @example
  11587. 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),
  11588. asplit[a][out1]; [a] showcqt [out0]'
  11589. @end example
  11590. @item
  11591. Same as above, but with more accuracy in frequency domain:
  11592. @example
  11593. 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),
  11594. asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
  11595. @end example
  11596. @item
  11597. Custom volume:
  11598. @example
  11599. bar_v=10:sono_v=bar_v*a_weighting(f)
  11600. @end example
  11601. @item
  11602. Custom gamma, now spectrum is linear to the amplitude.
  11603. @example
  11604. bar_g=2:sono_g=2
  11605. @end example
  11606. @item
  11607. Custom tlength equation:
  11608. @example
  11609. tc=0.33:tlength='st(0,0.17); 384*tc / (384 / ld(0) + tc*f /(1-ld(0))) + 384*tc / (tc*f / ld(0) + 384 /(1-ld(0)))'
  11610. @end example
  11611. @item
  11612. Custom fontcolor and fontfile, C-note is colored green, others are colored blue:
  11613. @example
  11614. fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))':fontfile=myfont.ttf
  11615. @end example
  11616. @item
  11617. Custom frequency range with custom axis using image file:
  11618. @example
  11619. axisfile=myaxis.png:basefreq=40:endfreq=10000
  11620. @end example
  11621. @end itemize
  11622. @section showfreqs
  11623. Convert input audio to video output representing the audio power spectrum.
  11624. Audio amplitude is on Y-axis while frequency is on X-axis.
  11625. The filter accepts the following options:
  11626. @table @option
  11627. @item size, s
  11628. Specify size of video. For the syntax of this option, check the
  11629. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11630. Default is @code{1024x512}.
  11631. @item mode
  11632. Set display mode.
  11633. This set how each frequency bin will be represented.
  11634. It accepts the following values:
  11635. @table @samp
  11636. @item line
  11637. @item bar
  11638. @item dot
  11639. @end table
  11640. Default is @code{bar}.
  11641. @item ascale
  11642. Set amplitude scale.
  11643. It accepts the following values:
  11644. @table @samp
  11645. @item lin
  11646. Linear scale.
  11647. @item sqrt
  11648. Square root scale.
  11649. @item cbrt
  11650. Cubic root scale.
  11651. @item log
  11652. Logarithmic scale.
  11653. @end table
  11654. Default is @code{log}.
  11655. @item fscale
  11656. Set frequency scale.
  11657. It accepts the following values:
  11658. @table @samp
  11659. @item lin
  11660. Linear scale.
  11661. @item log
  11662. Logarithmic scale.
  11663. @item rlog
  11664. Reverse logarithmic scale.
  11665. @end table
  11666. Default is @code{lin}.
  11667. @item win_size
  11668. Set window size.
  11669. It accepts the following values:
  11670. @table @samp
  11671. @item w16
  11672. @item w32
  11673. @item w64
  11674. @item w128
  11675. @item w256
  11676. @item w512
  11677. @item w1024
  11678. @item w2048
  11679. @item w4096
  11680. @item w8192
  11681. @item w16384
  11682. @item w32768
  11683. @item w65536
  11684. @end table
  11685. Default is @code{w2048}
  11686. @item win_func
  11687. Set windowing function.
  11688. It accepts the following values:
  11689. @table @samp
  11690. @item rect
  11691. @item bartlett
  11692. @item hanning
  11693. @item hamming
  11694. @item blackman
  11695. @item welch
  11696. @item flattop
  11697. @item bharris
  11698. @item bnuttall
  11699. @item bhann
  11700. @item sine
  11701. @item nuttall
  11702. @item lanczos
  11703. @item gauss
  11704. @item tukey
  11705. @end table
  11706. Default is @code{hanning}.
  11707. @item overlap
  11708. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  11709. which means optimal overlap for selected window function will be picked.
  11710. @item averaging
  11711. Set time averaging. Setting this to 0 will display current maximal peaks.
  11712. Default is @code{1}, which means time averaging is disabled.
  11713. @item colors
  11714. Specify list of colors separated by space or by '|' which will be used to
  11715. draw channel frequencies. Unrecognized or missing colors will be replaced
  11716. by white color.
  11717. @item cmode
  11718. Set channel display mode.
  11719. It accepts the following values:
  11720. @table @samp
  11721. @item combined
  11722. @item separate
  11723. @end table
  11724. Default is @code{combined}.
  11725. @end table
  11726. @anchor{showspectrum}
  11727. @section showspectrum
  11728. Convert input audio to a video output, representing the audio frequency
  11729. spectrum.
  11730. The filter accepts the following options:
  11731. @table @option
  11732. @item size, s
  11733. Specify the video size for the output. For the syntax of this option, check the
  11734. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11735. Default value is @code{640x512}.
  11736. @item slide
  11737. Specify how the spectrum should slide along the window.
  11738. It accepts the following values:
  11739. @table @samp
  11740. @item replace
  11741. the samples start again on the left when they reach the right
  11742. @item scroll
  11743. the samples scroll from right to left
  11744. @item rscroll
  11745. the samples scroll from left to right
  11746. @item fullframe
  11747. frames are only produced when the samples reach the right
  11748. @end table
  11749. Default value is @code{replace}.
  11750. @item mode
  11751. Specify display mode.
  11752. It accepts the following values:
  11753. @table @samp
  11754. @item combined
  11755. all channels are displayed in the same row
  11756. @item separate
  11757. all channels are displayed in separate rows
  11758. @end table
  11759. Default value is @samp{combined}.
  11760. @item color
  11761. Specify display color mode.
  11762. It accepts the following values:
  11763. @table @samp
  11764. @item channel
  11765. each channel is displayed in a separate color
  11766. @item intensity
  11767. each channel is displayed using the same color scheme
  11768. @item rainbow
  11769. each channel is displayed using the rainbow color scheme
  11770. @item moreland
  11771. each channel is displayed using the moreland color scheme
  11772. @item nebulae
  11773. each channel is displayed using the nebulae color scheme
  11774. @item fire
  11775. each channel is displayed using the fire color scheme
  11776. @item fiery
  11777. each channel is displayed using the fiery color scheme
  11778. @item fruit
  11779. each channel is displayed using the fruit color scheme
  11780. @item cool
  11781. each channel is displayed using the cool color scheme
  11782. @end table
  11783. Default value is @samp{channel}.
  11784. @item scale
  11785. Specify scale used for calculating intensity color values.
  11786. It accepts the following values:
  11787. @table @samp
  11788. @item lin
  11789. linear
  11790. @item sqrt
  11791. square root, default
  11792. @item cbrt
  11793. cubic root
  11794. @item 4thrt
  11795. 4th root
  11796. @item 5thrt
  11797. 5th root
  11798. @item log
  11799. logarithmic
  11800. @end table
  11801. Default value is @samp{sqrt}.
  11802. @item saturation
  11803. Set saturation modifier for displayed colors. Negative values provide
  11804. alternative color scheme. @code{0} is no saturation at all.
  11805. Saturation must be in [-10.0, 10.0] range.
  11806. Default value is @code{1}.
  11807. @item win_func
  11808. Set window function.
  11809. It accepts the following values:
  11810. @table @samp
  11811. @item rect
  11812. @item bartlett
  11813. @item hann
  11814. @item hanning
  11815. @item hamming
  11816. @item blackman
  11817. @item welch
  11818. @item flattop
  11819. @item bharris
  11820. @item bnuttall
  11821. @item bhann
  11822. @item sine
  11823. @item nuttall
  11824. @item lanczos
  11825. @item gauss
  11826. @item tukey
  11827. @end table
  11828. Default value is @code{hann}.
  11829. @item orientation
  11830. Set orientation of time vs frequency axis. Can be @code{vertical} or
  11831. @code{horizontal}. Default is @code{vertical}.
  11832. @item overlap
  11833. Set ratio of overlap window. Default value is @code{0}.
  11834. When value is @code{1} overlap is set to recommended size for specific
  11835. window function currently used.
  11836. @item gain
  11837. Set scale gain for calculating intensity color values.
  11838. Default value is @code{1}.
  11839. @item data
  11840. Set which data to display. Can be @code{magnitude}, default or @code{phase}.
  11841. @end table
  11842. The usage is very similar to the showwaves filter; see the examples in that
  11843. section.
  11844. @subsection Examples
  11845. @itemize
  11846. @item
  11847. Large window with logarithmic color scaling:
  11848. @example
  11849. showspectrum=s=1280x480:scale=log
  11850. @end example
  11851. @item
  11852. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  11853. @example
  11854. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  11855. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  11856. @end example
  11857. @end itemize
  11858. @section showspectrumpic
  11859. Convert input audio to a single video frame, representing the audio frequency
  11860. spectrum.
  11861. The filter accepts the following options:
  11862. @table @option
  11863. @item size, s
  11864. Specify the video size for the output. For the syntax of this option, check the
  11865. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11866. Default value is @code{4096x2048}.
  11867. @item mode
  11868. Specify display mode.
  11869. It accepts the following values:
  11870. @table @samp
  11871. @item combined
  11872. all channels are displayed in the same row
  11873. @item separate
  11874. all channels are displayed in separate rows
  11875. @end table
  11876. Default value is @samp{combined}.
  11877. @item color
  11878. Specify display color mode.
  11879. It accepts the following values:
  11880. @table @samp
  11881. @item channel
  11882. each channel is displayed in a separate color
  11883. @item intensity
  11884. each channel is displayed using the same color scheme
  11885. @item rainbow
  11886. each channel is displayed using the rainbow color scheme
  11887. @item moreland
  11888. each channel is displayed using the moreland color scheme
  11889. @item nebulae
  11890. each channel is displayed using the nebulae color scheme
  11891. @item fire
  11892. each channel is displayed using the fire color scheme
  11893. @item fiery
  11894. each channel is displayed using the fiery color scheme
  11895. @item fruit
  11896. each channel is displayed using the fruit color scheme
  11897. @item cool
  11898. each channel is displayed using the cool color scheme
  11899. @end table
  11900. Default value is @samp{intensity}.
  11901. @item scale
  11902. Specify scale used for calculating intensity color values.
  11903. It accepts the following values:
  11904. @table @samp
  11905. @item lin
  11906. linear
  11907. @item sqrt
  11908. square root, default
  11909. @item cbrt
  11910. cubic root
  11911. @item 4thrt
  11912. 4th root
  11913. @item 5thrt
  11914. 5th root
  11915. @item log
  11916. logarithmic
  11917. @end table
  11918. Default value is @samp{log}.
  11919. @item saturation
  11920. Set saturation modifier for displayed colors. Negative values provide
  11921. alternative color scheme. @code{0} is no saturation at all.
  11922. Saturation must be in [-10.0, 10.0] range.
  11923. Default value is @code{1}.
  11924. @item win_func
  11925. Set window function.
  11926. It accepts the following values:
  11927. @table @samp
  11928. @item rect
  11929. @item bartlett
  11930. @item hann
  11931. @item hanning
  11932. @item hamming
  11933. @item blackman
  11934. @item welch
  11935. @item flattop
  11936. @item bharris
  11937. @item bnuttall
  11938. @item bhann
  11939. @item sine
  11940. @item nuttall
  11941. @item lanczos
  11942. @item gauss
  11943. @item tukey
  11944. @end table
  11945. Default value is @code{hann}.
  11946. @item orientation
  11947. Set orientation of time vs frequency axis. Can be @code{vertical} or
  11948. @code{horizontal}. Default is @code{vertical}.
  11949. @item gain
  11950. Set scale gain for calculating intensity color values.
  11951. Default value is @code{1}.
  11952. @item legend
  11953. Draw time and frequency axes and legends. Default is enabled.
  11954. @end table
  11955. @subsection Examples
  11956. @itemize
  11957. @item
  11958. Extract an audio spectrogram of a whole audio track
  11959. in a 1024x1024 picture using @command{ffmpeg}:
  11960. @example
  11961. ffmpeg -i audio.flac -lavfi showspectrumpic=s=1024x1024 spectrogram.png
  11962. @end example
  11963. @end itemize
  11964. @section showvolume
  11965. Convert input audio volume to a video output.
  11966. The filter accepts the following options:
  11967. @table @option
  11968. @item rate, r
  11969. Set video rate.
  11970. @item b
  11971. Set border width, allowed range is [0, 5]. Default is 1.
  11972. @item w
  11973. Set channel width, allowed range is [80, 1080]. Default is 400.
  11974. @item h
  11975. Set channel height, allowed range is [1, 100]. Default is 20.
  11976. @item f
  11977. Set fade, allowed range is [0.001, 1]. Default is 0.95.
  11978. @item c
  11979. Set volume color expression.
  11980. The expression can use the following variables:
  11981. @table @option
  11982. @item VOLUME
  11983. Current max volume of channel in dB.
  11984. @item CHANNEL
  11985. Current channel number, starting from 0.
  11986. @end table
  11987. @item t
  11988. If set, displays channel names. Default is enabled.
  11989. @item v
  11990. If set, displays volume values. Default is enabled.
  11991. @end table
  11992. @section showwaves
  11993. Convert input audio to a video output, representing the samples waves.
  11994. The filter accepts the following options:
  11995. @table @option
  11996. @item size, s
  11997. Specify the video size for the output. For the syntax of this option, check the
  11998. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11999. Default value is @code{600x240}.
  12000. @item mode
  12001. Set display mode.
  12002. Available values are:
  12003. @table @samp
  12004. @item point
  12005. Draw a point for each sample.
  12006. @item line
  12007. Draw a vertical line for each sample.
  12008. @item p2p
  12009. Draw a point for each sample and a line between them.
  12010. @item cline
  12011. Draw a centered vertical line for each sample.
  12012. @end table
  12013. Default value is @code{point}.
  12014. @item n
  12015. Set the number of samples which are printed on the same column. A
  12016. larger value will decrease the frame rate. Must be a positive
  12017. integer. This option can be set only if the value for @var{rate}
  12018. is not explicitly specified.
  12019. @item rate, r
  12020. Set the (approximate) output frame rate. This is done by setting the
  12021. option @var{n}. Default value is "25".
  12022. @item split_channels
  12023. Set if channels should be drawn separately or overlap. Default value is 0.
  12024. @item colors
  12025. Set colors separated by '|' which are going to be used for drawing of each channel.
  12026. @item scale
  12027. Set amplitude scale. Can be linear @code{lin} or logarithmic @code{log}.
  12028. Default is linear.
  12029. @end table
  12030. @subsection Examples
  12031. @itemize
  12032. @item
  12033. Output the input file audio and the corresponding video representation
  12034. at the same time:
  12035. @example
  12036. amovie=a.mp3,asplit[out0],showwaves[out1]
  12037. @end example
  12038. @item
  12039. Create a synthetic signal and show it with showwaves, forcing a
  12040. frame rate of 30 frames per second:
  12041. @example
  12042. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  12043. @end example
  12044. @end itemize
  12045. @section showwavespic
  12046. Convert input audio to a single video frame, representing the samples waves.
  12047. The filter accepts the following options:
  12048. @table @option
  12049. @item size, s
  12050. Specify the video size for the output. For the syntax of this option, check the
  12051. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12052. Default value is @code{600x240}.
  12053. @item split_channels
  12054. Set if channels should be drawn separately or overlap. Default value is 0.
  12055. @item colors
  12056. Set colors separated by '|' which are going to be used for drawing of each channel.
  12057. @item scale
  12058. Set amplitude scale. Can be linear @code{lin} or logarithmic @code{log}.
  12059. Default is linear.
  12060. @end table
  12061. @subsection Examples
  12062. @itemize
  12063. @item
  12064. Extract a channel split representation of the wave form of a whole audio track
  12065. in a 1024x800 picture using @command{ffmpeg}:
  12066. @example
  12067. ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
  12068. @end example
  12069. @item
  12070. Colorize the waveform with colorchannelmixer. This example will make
  12071. the waveform a green color approximately RGB(66,217,150). Additional
  12072. channels will be shades of this color.
  12073. @example
  12074. ffmpeg -i audio.mp3 -filter_complex "showwavespic,colorchannelmixer=rr=66/255:gg=217/255:bb=150/255" waveform.png
  12075. @end example
  12076. @end itemize
  12077. @section spectrumsynth
  12078. Sythesize audio from 2 input video spectrums, first input stream represents
  12079. magnitude across time and second represents phase across time.
  12080. The filter will transform from frequency domain as displayed in videos back
  12081. to time domain as presented in audio output.
  12082. This filter is primarly created for reversing processed @ref{showspectrum}
  12083. filter outputs, but can synthesize sound from other spectrograms too.
  12084. But in such case results are going to be poor if the phase data is not
  12085. available, because in such cases phase data need to be recreated, usually
  12086. its just recreated from random noise.
  12087. For best results use gray only output (@code{channel} color mode in
  12088. @ref{showspectrum} filter) and @code{log} scale for magnitude video and
  12089. @code{lin} scale for phase video. To produce phase, for 2nd video, use
  12090. @code{data} option. Inputs videos should generally use @code{fullframe}
  12091. slide mode as that saves resources needed for decoding video.
  12092. The filter accepts the following options:
  12093. @table @option
  12094. @item sample_rate
  12095. Specify sample rate of output audio, the sample rate of audio from which
  12096. spectrum was generated may differ.
  12097. @item channels
  12098. Set number of channels represented in input video spectrums.
  12099. @item scale
  12100. Set scale which was used when generating magnitude input spectrum.
  12101. Can be @code{lin} or @code{log}. Default is @code{log}.
  12102. @item slide
  12103. Set slide which was used when generating inputs spectrums.
  12104. Can be @code{replace}, @code{scroll}, @code{fullframe} or @code{rscroll}.
  12105. Default is @code{fullframe}.
  12106. @item win_func
  12107. Set window function used for resynthesis.
  12108. @item overlap
  12109. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  12110. which means optimal overlap for selected window function will be picked.
  12111. @item orientation
  12112. Set orientation of input videos. Can be @code{vertical} or @code{horizontal}.
  12113. Default is @code{vertical}.
  12114. @end table
  12115. @subsection Examples
  12116. @itemize
  12117. @item
  12118. First create magnitude and phase videos from audio, assuming audio is stereo with 44100 sample rate,
  12119. then resynthesize videos back to audio with spectrumsynth:
  12120. @example
  12121. ffmpeg -i input.flac -lavfi showspectrum=mode=separate:scale=log:overlap=0.875:color=channel:slide=fullframe:data=magnitude -an -c:v rawvideo magnitude.nut
  12122. ffmpeg -i input.flac -lavfi showspectrum=mode=separate:scale=lin:overlap=0.875:color=channel:slide=fullframe:data=phase -an -c:v rawvideo phase.nut
  12123. ffmpeg -i magnitude.nut -i phase.nut -lavfi spectrumsynth=channels=2:sample_rate=44100:win_func=hann:overlap=0.875:slide=fullframe output.flac
  12124. @end example
  12125. @end itemize
  12126. @section split, asplit
  12127. Split input into several identical outputs.
  12128. @code{asplit} works with audio input, @code{split} with video.
  12129. The filter accepts a single parameter which specifies the number of outputs. If
  12130. unspecified, it defaults to 2.
  12131. @subsection Examples
  12132. @itemize
  12133. @item
  12134. Create two separate outputs from the same input:
  12135. @example
  12136. [in] split [out0][out1]
  12137. @end example
  12138. @item
  12139. To create 3 or more outputs, you need to specify the number of
  12140. outputs, like in:
  12141. @example
  12142. [in] asplit=3 [out0][out1][out2]
  12143. @end example
  12144. @item
  12145. Create two separate outputs from the same input, one cropped and
  12146. one padded:
  12147. @example
  12148. [in] split [splitout1][splitout2];
  12149. [splitout1] crop=100:100:0:0 [cropout];
  12150. [splitout2] pad=200:200:100:100 [padout];
  12151. @end example
  12152. @item
  12153. Create 5 copies of the input audio with @command{ffmpeg}:
  12154. @example
  12155. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  12156. @end example
  12157. @end itemize
  12158. @section zmq, azmq
  12159. Receive commands sent through a libzmq client, and forward them to
  12160. filters in the filtergraph.
  12161. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  12162. must be inserted between two video filters, @code{azmq} between two
  12163. audio filters.
  12164. To enable these filters you need to install the libzmq library and
  12165. headers and configure FFmpeg with @code{--enable-libzmq}.
  12166. For more information about libzmq see:
  12167. @url{http://www.zeromq.org/}
  12168. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  12169. receives messages sent through a network interface defined by the
  12170. @option{bind_address} option.
  12171. The received message must be in the form:
  12172. @example
  12173. @var{TARGET} @var{COMMAND} [@var{ARG}]
  12174. @end example
  12175. @var{TARGET} specifies the target of the command, usually the name of
  12176. the filter class or a specific filter instance name.
  12177. @var{COMMAND} specifies the name of the command for the target filter.
  12178. @var{ARG} is optional and specifies the optional argument list for the
  12179. given @var{COMMAND}.
  12180. Upon reception, the message is processed and the corresponding command
  12181. is injected into the filtergraph. Depending on the result, the filter
  12182. will send a reply to the client, adopting the format:
  12183. @example
  12184. @var{ERROR_CODE} @var{ERROR_REASON}
  12185. @var{MESSAGE}
  12186. @end example
  12187. @var{MESSAGE} is optional.
  12188. @subsection Examples
  12189. Look at @file{tools/zmqsend} for an example of a zmq client which can
  12190. be used to send commands processed by these filters.
  12191. Consider the following filtergraph generated by @command{ffplay}
  12192. @example
  12193. ffplay -dumpgraph 1 -f lavfi "
  12194. color=s=100x100:c=red [l];
  12195. color=s=100x100:c=blue [r];
  12196. nullsrc=s=200x100, zmq [bg];
  12197. [bg][l] overlay [bg+l];
  12198. [bg+l][r] overlay=x=100 "
  12199. @end example
  12200. To change the color of the left side of the video, the following
  12201. command can be used:
  12202. @example
  12203. echo Parsed_color_0 c yellow | tools/zmqsend
  12204. @end example
  12205. To change the right side:
  12206. @example
  12207. echo Parsed_color_1 c pink | tools/zmqsend
  12208. @end example
  12209. @c man end MULTIMEDIA FILTERS
  12210. @chapter Multimedia Sources
  12211. @c man begin MULTIMEDIA SOURCES
  12212. Below is a description of the currently available multimedia sources.
  12213. @section amovie
  12214. This is the same as @ref{movie} source, except it selects an audio
  12215. stream by default.
  12216. @anchor{movie}
  12217. @section movie
  12218. Read audio and/or video stream(s) from a movie container.
  12219. It accepts the following parameters:
  12220. @table @option
  12221. @item filename
  12222. The name of the resource to read (not necessarily a file; it can also be a
  12223. device or a stream accessed through some protocol).
  12224. @item format_name, f
  12225. Specifies the format assumed for the movie to read, and can be either
  12226. the name of a container or an input device. If not specified, the
  12227. format is guessed from @var{movie_name} or by probing.
  12228. @item seek_point, sp
  12229. Specifies the seek point in seconds. The frames will be output
  12230. starting from this seek point. The parameter is evaluated with
  12231. @code{av_strtod}, so the numerical value may be suffixed by an IS
  12232. postfix. The default value is "0".
  12233. @item streams, s
  12234. Specifies the streams to read. Several streams can be specified,
  12235. separated by "+". The source will then have as many outputs, in the
  12236. same order. The syntax is explained in the ``Stream specifiers''
  12237. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  12238. respectively the default (best suited) video and audio stream. Default
  12239. is "dv", or "da" if the filter is called as "amovie".
  12240. @item stream_index, si
  12241. Specifies the index of the video stream to read. If the value is -1,
  12242. the most suitable video stream will be automatically selected. The default
  12243. value is "-1". Deprecated. If the filter is called "amovie", it will select
  12244. audio instead of video.
  12245. @item loop
  12246. Specifies how many times to read the stream in sequence.
  12247. If the value is less than 1, the stream will be read again and again.
  12248. Default value is "1".
  12249. Note that when the movie is looped the source timestamps are not
  12250. changed, so it will generate non monotonically increasing timestamps.
  12251. @end table
  12252. It allows overlaying a second video on top of the main input of
  12253. a filtergraph, as shown in this graph:
  12254. @example
  12255. input -----------> deltapts0 --> overlay --> output
  12256. ^
  12257. |
  12258. movie --> scale--> deltapts1 -------+
  12259. @end example
  12260. @subsection Examples
  12261. @itemize
  12262. @item
  12263. Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
  12264. on top of the input labelled "in":
  12265. @example
  12266. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  12267. [in] setpts=PTS-STARTPTS [main];
  12268. [main][over] overlay=16:16 [out]
  12269. @end example
  12270. @item
  12271. Read from a video4linux2 device, and overlay it on top of the input
  12272. labelled "in":
  12273. @example
  12274. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  12275. [in] setpts=PTS-STARTPTS [main];
  12276. [main][over] overlay=16:16 [out]
  12277. @end example
  12278. @item
  12279. Read the first video stream and the audio stream with id 0x81 from
  12280. dvd.vob; the video is connected to the pad named "video" and the audio is
  12281. connected to the pad named "audio":
  12282. @example
  12283. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  12284. @end example
  12285. @end itemize
  12286. @c man end MULTIMEDIA SOURCES