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.

16222 lines
437KB

  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 firequalizer
  1860. Apply FIR Equalization using arbitrary frequency response.
  1861. The filter accepts the following option:
  1862. @table @option
  1863. @item gain
  1864. Set gain curve equation (in dB). The expression can contain variables:
  1865. @table @option
  1866. @item f
  1867. the evaluated frequency
  1868. @item sr
  1869. sample rate
  1870. @item ch
  1871. channel number, set to 0 when multichannels evaluation is disabled
  1872. @item chid
  1873. channel id, see libavutil/channel_layout.h, set to the first channel id when
  1874. multichannels evaluation is disabled
  1875. @item chs
  1876. number of channels
  1877. @item chlayout
  1878. channel_layout, see libavutil/channel_layout.h
  1879. @end table
  1880. and functions:
  1881. @table @option
  1882. @item gain_interpolate(f)
  1883. interpolate gain on frequency f based on gain_entry
  1884. @end table
  1885. This option is also available as command. Default is @code{gain_interpolate(f)}.
  1886. @item gain_entry
  1887. Set gain entry for gain_interpolate function. The expression can
  1888. contain functions:
  1889. @table @option
  1890. @item entry(f, g)
  1891. store gain entry at frequency f with value g
  1892. @end table
  1893. This option is also available as command.
  1894. @item delay
  1895. Set filter delay in seconds. Higher value means more accurate.
  1896. Default is @code{0.01}.
  1897. @item accuracy
  1898. Set filter accuracy in Hz. Lower value means more accurate.
  1899. Default is @code{5}.
  1900. @item wfunc
  1901. Set window function. Acceptable values are:
  1902. @table @option
  1903. @item rectangular
  1904. rectangular window, useful when gain curve is already smooth
  1905. @item hann
  1906. hann window (default)
  1907. @item hamming
  1908. hamming window
  1909. @item blackman
  1910. blackman window
  1911. @item nuttall3
  1912. 3-terms continuous 1st derivative nuttall window
  1913. @item mnuttall3
  1914. minimum 3-terms discontinuous nuttall window
  1915. @item nuttall
  1916. 4-terms continuous 1st derivative nuttall window
  1917. @item bnuttall
  1918. minimum 4-terms discontinuous nuttall (blackman-nuttall) window
  1919. @item bharris
  1920. blackman-harris window
  1921. @end table
  1922. @item fixed
  1923. If enabled, use fixed number of audio samples. This improves speed when
  1924. filtering with large delay. Default is disabled.
  1925. @item multi
  1926. Enable multichannels evaluation on gain. Default is disabled.
  1927. @end table
  1928. @subsection Examples
  1929. @itemize
  1930. @item
  1931. lowpass at 1000 Hz:
  1932. @example
  1933. firequalizer=gain='if(lt(f,1000), 0, -INF)'
  1934. @end example
  1935. @item
  1936. lowpass at 1000 Hz with gain_entry:
  1937. @example
  1938. firequalizer=gain_entry='entry(1000,0); entry(1001, -INF)'
  1939. @end example
  1940. @item
  1941. custom equalization:
  1942. @example
  1943. firequalizer=gain_entry='entry(100,0); entry(400, -4); entry(1000, -6); entry(2000, 0)'
  1944. @end example
  1945. @item
  1946. higher delay:
  1947. @example
  1948. firequalizer=delay=0.1:fixed=on
  1949. @end example
  1950. @item
  1951. lowpass on left channel, highpass on right channel:
  1952. @example
  1953. firequalizer=gain='if(eq(chid,1), gain_interpolate(f), if(eq(chid,2), gain_interpolate(1e6+f), 0))'
  1954. :gain_entry='entry(1000, 0); entry(1001,-INF); entry(1e6+1000,0)':multi=on
  1955. @end example
  1956. @end itemize
  1957. @section flanger
  1958. Apply a flanging effect to the audio.
  1959. The filter accepts the following options:
  1960. @table @option
  1961. @item delay
  1962. Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
  1963. @item depth
  1964. Set added swep delay in milliseconds. Range from 0 to 10. Default value is 2.
  1965. @item regen
  1966. Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
  1967. Default value is 0.
  1968. @item width
  1969. Set percentage of delayed signal mixed with original. Range from 0 to 100.
  1970. Default value is 71.
  1971. @item speed
  1972. Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
  1973. @item shape
  1974. Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
  1975. Default value is @var{sinusoidal}.
  1976. @item phase
  1977. Set swept wave percentage-shift for multi channel. Range from 0 to 100.
  1978. Default value is 25.
  1979. @item interp
  1980. Set delay-line interpolation, @var{linear} or @var{quadratic}.
  1981. Default is @var{linear}.
  1982. @end table
  1983. @section highpass
  1984. Apply a high-pass filter with 3dB point frequency.
  1985. The filter can be either single-pole, or double-pole (the default).
  1986. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1987. The filter accepts the following options:
  1988. @table @option
  1989. @item frequency, f
  1990. Set frequency in Hz. Default is 3000.
  1991. @item poles, p
  1992. Set number of poles. Default is 2.
  1993. @item width_type
  1994. Set method to specify band-width of filter.
  1995. @table @option
  1996. @item h
  1997. Hz
  1998. @item q
  1999. Q-Factor
  2000. @item o
  2001. octave
  2002. @item s
  2003. slope
  2004. @end table
  2005. @item width, w
  2006. Specify the band-width of a filter in width_type units.
  2007. Applies only to double-pole filter.
  2008. The default is 0.707q and gives a Butterworth response.
  2009. @end table
  2010. @section join
  2011. Join multiple input streams into one multi-channel stream.
  2012. It accepts the following parameters:
  2013. @table @option
  2014. @item inputs
  2015. The number of input streams. It defaults to 2.
  2016. @item channel_layout
  2017. The desired output channel layout. It defaults to stereo.
  2018. @item map
  2019. Map channels from inputs to output. The argument is a '|'-separated list of
  2020. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  2021. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  2022. can be either the name of the input channel (e.g. FL for front left) or its
  2023. index in the specified input stream. @var{out_channel} is the name of the output
  2024. channel.
  2025. @end table
  2026. The filter will attempt to guess the mappings when they are not specified
  2027. explicitly. It does so by first trying to find an unused matching input channel
  2028. and if that fails it picks the first unused input channel.
  2029. Join 3 inputs (with properly set channel layouts):
  2030. @example
  2031. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  2032. @end example
  2033. Build a 5.1 output from 6 single-channel streams:
  2034. @example
  2035. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  2036. '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'
  2037. out
  2038. @end example
  2039. @section ladspa
  2040. Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
  2041. To enable compilation of this filter you need to configure FFmpeg with
  2042. @code{--enable-ladspa}.
  2043. @table @option
  2044. @item file, f
  2045. Specifies the name of LADSPA plugin library to load. If the environment
  2046. variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
  2047. each one of the directories specified by the colon separated list in
  2048. @env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
  2049. this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
  2050. @file{/usr/lib/ladspa/}.
  2051. @item plugin, p
  2052. Specifies the plugin within the library. Some libraries contain only
  2053. one plugin, but others contain many of them. If this is not set filter
  2054. will list all available plugins within the specified library.
  2055. @item controls, c
  2056. Set the '|' separated list of controls which are zero or more floating point
  2057. values that determine the behavior of the loaded plugin (for example delay,
  2058. threshold or gain).
  2059. Controls need to be defined using the following syntax:
  2060. c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
  2061. @var{valuei} is the value set on the @var{i}-th control.
  2062. Alternatively they can be also defined using the following syntax:
  2063. @var{value0}|@var{value1}|@var{value2}|..., where
  2064. @var{valuei} is the value set on the @var{i}-th control.
  2065. If @option{controls} is set to @code{help}, all available controls and
  2066. their valid ranges are printed.
  2067. @item sample_rate, s
  2068. Specify the sample rate, default to 44100. Only used if plugin have
  2069. zero inputs.
  2070. @item nb_samples, n
  2071. Set the number of samples per channel per each output frame, default
  2072. is 1024. Only used if plugin have zero inputs.
  2073. @item duration, d
  2074. Set the minimum duration of the sourced audio. See
  2075. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  2076. for the accepted syntax.
  2077. Note that the resulting duration may be greater than the specified duration,
  2078. as the generated audio is always cut at the end of a complete frame.
  2079. If not specified, or the expressed duration is negative, the audio is
  2080. supposed to be generated forever.
  2081. Only used if plugin have zero inputs.
  2082. @end table
  2083. @subsection Examples
  2084. @itemize
  2085. @item
  2086. List all available plugins within amp (LADSPA example plugin) library:
  2087. @example
  2088. ladspa=file=amp
  2089. @end example
  2090. @item
  2091. List all available controls and their valid ranges for @code{vcf_notch}
  2092. plugin from @code{VCF} library:
  2093. @example
  2094. ladspa=f=vcf:p=vcf_notch:c=help
  2095. @end example
  2096. @item
  2097. Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
  2098. plugin library:
  2099. @example
  2100. ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
  2101. @end example
  2102. @item
  2103. Add reverberation to the audio using TAP-plugins
  2104. (Tom's Audio Processing plugins):
  2105. @example
  2106. ladspa=file=tap_reverb:tap_reverb
  2107. @end example
  2108. @item
  2109. Generate white noise, with 0.2 amplitude:
  2110. @example
  2111. ladspa=file=cmt:noise_source_white:c=c0=.2
  2112. @end example
  2113. @item
  2114. Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
  2115. @code{C* Audio Plugin Suite} (CAPS) library:
  2116. @example
  2117. ladspa=file=caps:Click:c=c1=20'
  2118. @end example
  2119. @item
  2120. Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
  2121. @example
  2122. ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
  2123. @end example
  2124. @item
  2125. Increase volume by 20dB using fast lookahead limiter from Steve Harris
  2126. @code{SWH Plugins} collection:
  2127. @example
  2128. ladspa=fast_lookahead_limiter_1913:fastLookaheadLimiter:20|0|2
  2129. @end example
  2130. @item
  2131. Attenuate low frequencies using Multiband EQ from Steve Harris
  2132. @code{SWH Plugins} collection:
  2133. @example
  2134. ladspa=mbeq_1197:mbeq:-24|-24|-24|0|0|0|0|0|0|0|0|0|0|0|0
  2135. @end example
  2136. @end itemize
  2137. @subsection Commands
  2138. This filter supports the following commands:
  2139. @table @option
  2140. @item cN
  2141. Modify the @var{N}-th control value.
  2142. If the specified value is not valid, it is ignored and prior one is kept.
  2143. @end table
  2144. @section lowpass
  2145. Apply a low-pass filter with 3dB point frequency.
  2146. The filter can be either single-pole or double-pole (the default).
  2147. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  2148. The filter accepts the following options:
  2149. @table @option
  2150. @item frequency, f
  2151. Set frequency in Hz. Default is 500.
  2152. @item poles, p
  2153. Set number of poles. Default is 2.
  2154. @item width_type
  2155. Set method to specify band-width of filter.
  2156. @table @option
  2157. @item h
  2158. Hz
  2159. @item q
  2160. Q-Factor
  2161. @item o
  2162. octave
  2163. @item s
  2164. slope
  2165. @end table
  2166. @item width, w
  2167. Specify the band-width of a filter in width_type units.
  2168. Applies only to double-pole filter.
  2169. The default is 0.707q and gives a Butterworth response.
  2170. @end table
  2171. @anchor{pan}
  2172. @section pan
  2173. Mix channels with specific gain levels. The filter accepts the output
  2174. channel layout followed by a set of channels definitions.
  2175. This filter is also designed to efficiently remap the channels of an audio
  2176. stream.
  2177. The filter accepts parameters of the form:
  2178. "@var{l}|@var{outdef}|@var{outdef}|..."
  2179. @table @option
  2180. @item l
  2181. output channel layout or number of channels
  2182. @item outdef
  2183. output channel specification, of the form:
  2184. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  2185. @item out_name
  2186. output channel to define, either a channel name (FL, FR, etc.) or a channel
  2187. number (c0, c1, etc.)
  2188. @item gain
  2189. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  2190. @item in_name
  2191. input channel to use, see out_name for details; it is not possible to mix
  2192. named and numbered input channels
  2193. @end table
  2194. If the `=' in a channel specification is replaced by `<', then the gains for
  2195. that specification will be renormalized so that the total is 1, thus
  2196. avoiding clipping noise.
  2197. @subsection Mixing examples
  2198. For example, if you want to down-mix from stereo to mono, but with a bigger
  2199. factor for the left channel:
  2200. @example
  2201. pan=1c|c0=0.9*c0+0.1*c1
  2202. @end example
  2203. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  2204. 7-channels surround:
  2205. @example
  2206. pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  2207. @end example
  2208. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  2209. that should be preferred (see "-ac" option) unless you have very specific
  2210. needs.
  2211. @subsection Remapping examples
  2212. The channel remapping will be effective if, and only if:
  2213. @itemize
  2214. @item gain coefficients are zeroes or ones,
  2215. @item only one input per channel output,
  2216. @end itemize
  2217. If all these conditions are satisfied, the filter will notify the user ("Pure
  2218. channel mapping detected"), and use an optimized and lossless method to do the
  2219. remapping.
  2220. For example, if you have a 5.1 source and want a stereo audio stream by
  2221. dropping the extra channels:
  2222. @example
  2223. pan="stereo| c0=FL | c1=FR"
  2224. @end example
  2225. Given the same source, you can also switch front left and front right channels
  2226. and keep the input channel layout:
  2227. @example
  2228. pan="5.1| c0=c1 | c1=c0 | c2=c2 | c3=c3 | c4=c4 | c5=c5"
  2229. @end example
  2230. If the input is a stereo audio stream, you can mute the front left channel (and
  2231. still keep the stereo channel layout) with:
  2232. @example
  2233. pan="stereo|c1=c1"
  2234. @end example
  2235. Still with a stereo audio stream input, you can copy the right channel in both
  2236. front left and right:
  2237. @example
  2238. pan="stereo| c0=FR | c1=FR"
  2239. @end example
  2240. @section replaygain
  2241. ReplayGain scanner filter. This filter takes an audio stream as an input and
  2242. outputs it unchanged.
  2243. At end of filtering it displays @code{track_gain} and @code{track_peak}.
  2244. @section resample
  2245. Convert the audio sample format, sample rate and channel layout. It is
  2246. not meant to be used directly.
  2247. @section rubberband
  2248. Apply time-stretching and pitch-shifting with librubberband.
  2249. The filter accepts the following options:
  2250. @table @option
  2251. @item tempo
  2252. Set tempo scale factor.
  2253. @item pitch
  2254. Set pitch scale factor.
  2255. @item transients
  2256. Set transients detector.
  2257. Possible values are:
  2258. @table @var
  2259. @item crisp
  2260. @item mixed
  2261. @item smooth
  2262. @end table
  2263. @item detector
  2264. Set detector.
  2265. Possible values are:
  2266. @table @var
  2267. @item compound
  2268. @item percussive
  2269. @item soft
  2270. @end table
  2271. @item phase
  2272. Set phase.
  2273. Possible values are:
  2274. @table @var
  2275. @item laminar
  2276. @item independent
  2277. @end table
  2278. @item window
  2279. Set processing window size.
  2280. Possible values are:
  2281. @table @var
  2282. @item standard
  2283. @item short
  2284. @item long
  2285. @end table
  2286. @item smoothing
  2287. Set smoothing.
  2288. Possible values are:
  2289. @table @var
  2290. @item off
  2291. @item on
  2292. @end table
  2293. @item formant
  2294. Enable formant preservation when shift pitching.
  2295. Possible values are:
  2296. @table @var
  2297. @item shifted
  2298. @item preserved
  2299. @end table
  2300. @item pitchq
  2301. Set pitch quality.
  2302. Possible values are:
  2303. @table @var
  2304. @item quality
  2305. @item speed
  2306. @item consistency
  2307. @end table
  2308. @item channels
  2309. Set channels.
  2310. Possible values are:
  2311. @table @var
  2312. @item apart
  2313. @item together
  2314. @end table
  2315. @end table
  2316. @section sidechaincompress
  2317. This filter acts like normal compressor but has the ability to compress
  2318. detected signal using second input signal.
  2319. It needs two input streams and returns one output stream.
  2320. First input stream will be processed depending on second stream signal.
  2321. The filtered signal then can be filtered with other filters in later stages of
  2322. processing. See @ref{pan} and @ref{amerge} filter.
  2323. The filter accepts the following options:
  2324. @table @option
  2325. @item level_in
  2326. Set input gain. Default is 1. Range is between 0.015625 and 64.
  2327. @item threshold
  2328. If a signal of second stream raises above this level it will affect the gain
  2329. reduction of first stream.
  2330. By default is 0.125. Range is between 0.00097563 and 1.
  2331. @item ratio
  2332. Set a ratio about which the signal is reduced. 1:2 means that if the level
  2333. raised 4dB above the threshold, it will be only 2dB above after the reduction.
  2334. Default is 2. Range is between 1 and 20.
  2335. @item attack
  2336. Amount of milliseconds the signal has to rise above the threshold before gain
  2337. reduction starts. Default is 20. Range is between 0.01 and 2000.
  2338. @item release
  2339. Amount of milliseconds the signal has to fall below the threshold before
  2340. reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
  2341. @item makeup
  2342. Set the amount by how much signal will be amplified after processing.
  2343. Default is 2. Range is from 1 and 64.
  2344. @item knee
  2345. Curve the sharp knee around the threshold to enter gain reduction more softly.
  2346. Default is 2.82843. Range is between 1 and 8.
  2347. @item link
  2348. Choose if the @code{average} level between all channels of side-chain stream
  2349. or the louder(@code{maximum}) channel of side-chain stream affects the
  2350. reduction. Default is @code{average}.
  2351. @item detection
  2352. Should the exact signal be taken in case of @code{peak} or an RMS one in case
  2353. of @code{rms}. Default is @code{rms} which is mainly smoother.
  2354. @item level_sc
  2355. Set sidechain gain. Default is 1. Range is between 0.015625 and 64.
  2356. @item mix
  2357. How much to use compressed signal in output. Default is 1.
  2358. Range is between 0 and 1.
  2359. @end table
  2360. @subsection Examples
  2361. @itemize
  2362. @item
  2363. Full ffmpeg example taking 2 audio inputs, 1st input to be compressed
  2364. depending on the signal of 2nd input and later compressed signal to be
  2365. merged with 2nd input:
  2366. @example
  2367. ffmpeg -i main.flac -i sidechain.flac -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge"
  2368. @end example
  2369. @end itemize
  2370. @section sidechaingate
  2371. A sidechain gate acts like a normal (wideband) gate but has the ability to
  2372. filter the detected signal before sending it to the gain reduction stage.
  2373. Normally a gate uses the full range signal to detect a level above the
  2374. threshold.
  2375. For example: If you cut all lower frequencies from your sidechain signal
  2376. the gate will decrease the volume of your track only if not enough highs
  2377. appear. With this technique you are able to reduce the resonation of a
  2378. natural drum or remove "rumbling" of muted strokes from a heavily distorted
  2379. guitar.
  2380. It needs two input streams and returns one output stream.
  2381. First input stream will be processed depending on second stream signal.
  2382. The filter accepts the following options:
  2383. @table @option
  2384. @item level_in
  2385. Set input level before filtering.
  2386. Default is 1. Allowed range is from 0.015625 to 64.
  2387. @item range
  2388. Set the level of gain reduction when the signal is below the threshold.
  2389. Default is 0.06125. Allowed range is from 0 to 1.
  2390. @item threshold
  2391. If a signal rises above this level the gain reduction is released.
  2392. Default is 0.125. Allowed range is from 0 to 1.
  2393. @item ratio
  2394. Set a ratio about which the signal is reduced.
  2395. Default is 2. Allowed range is from 1 to 9000.
  2396. @item attack
  2397. Amount of milliseconds the signal has to rise above the threshold before gain
  2398. reduction stops.
  2399. Default is 20 milliseconds. Allowed range is from 0.01 to 9000.
  2400. @item release
  2401. Amount of milliseconds the signal has to fall below the threshold before the
  2402. reduction is increased again. Default is 250 milliseconds.
  2403. Allowed range is from 0.01 to 9000.
  2404. @item makeup
  2405. Set amount of amplification of signal after processing.
  2406. Default is 1. Allowed range is from 1 to 64.
  2407. @item knee
  2408. Curve the sharp knee around the threshold to enter gain reduction more softly.
  2409. Default is 2.828427125. Allowed range is from 1 to 8.
  2410. @item detection
  2411. Choose if exact signal should be taken for detection or an RMS like one.
  2412. Default is rms. Can be peak or rms.
  2413. @item link
  2414. Choose if the average level between all channels or the louder channel affects
  2415. the reduction.
  2416. Default is average. Can be average or maximum.
  2417. @item level_sc
  2418. Set sidechain gain. Default is 1. Range is from 0.015625 to 64.
  2419. @end table
  2420. @section silencedetect
  2421. Detect silence in an audio stream.
  2422. This filter logs a message when it detects that the input audio volume is less
  2423. or equal to a noise tolerance value for a duration greater or equal to the
  2424. minimum detected noise duration.
  2425. The printed times and duration are expressed in seconds.
  2426. The filter accepts the following options:
  2427. @table @option
  2428. @item duration, d
  2429. Set silence duration until notification (default is 2 seconds).
  2430. @item noise, n
  2431. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  2432. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  2433. @end table
  2434. @subsection Examples
  2435. @itemize
  2436. @item
  2437. Detect 5 seconds of silence with -50dB noise tolerance:
  2438. @example
  2439. silencedetect=n=-50dB:d=5
  2440. @end example
  2441. @item
  2442. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  2443. tolerance in @file{silence.mp3}:
  2444. @example
  2445. ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
  2446. @end example
  2447. @end itemize
  2448. @section silenceremove
  2449. Remove silence from the beginning, middle or end of the audio.
  2450. The filter accepts the following options:
  2451. @table @option
  2452. @item start_periods
  2453. This value is used to indicate if audio should be trimmed at beginning of
  2454. the audio. A value of zero indicates no silence should be trimmed from the
  2455. beginning. When specifying a non-zero value, it trims audio up until it
  2456. finds non-silence. Normally, when trimming silence from beginning of audio
  2457. the @var{start_periods} will be @code{1} but it can be increased to higher
  2458. values to trim all audio up to specific count of non-silence periods.
  2459. Default value is @code{0}.
  2460. @item start_duration
  2461. Specify the amount of time that non-silence must be detected before it stops
  2462. trimming audio. By increasing the duration, bursts of noises can be treated
  2463. as silence and trimmed off. Default value is @code{0}.
  2464. @item start_threshold
  2465. This indicates what sample value should be treated as silence. For digital
  2466. audio, a value of @code{0} may be fine but for audio recorded from analog,
  2467. you may wish to increase the value to account for background noise.
  2468. Can be specified in dB (in case "dB" is appended to the specified value)
  2469. or amplitude ratio. Default value is @code{0}.
  2470. @item stop_periods
  2471. Set the count for trimming silence from the end of audio.
  2472. To remove silence from the middle of a file, specify a @var{stop_periods}
  2473. that is negative. This value is then treated as a positive value and is
  2474. used to indicate the effect should restart processing as specified by
  2475. @var{start_periods}, making it suitable for removing periods of silence
  2476. in the middle of the audio.
  2477. Default value is @code{0}.
  2478. @item stop_duration
  2479. Specify a duration of silence that must exist before audio is not copied any
  2480. more. By specifying a higher duration, silence that is wanted can be left in
  2481. the audio.
  2482. Default value is @code{0}.
  2483. @item stop_threshold
  2484. This is the same as @option{start_threshold} but for trimming silence from
  2485. the end of audio.
  2486. Can be specified in dB (in case "dB" is appended to the specified value)
  2487. or amplitude ratio. Default value is @code{0}.
  2488. @item leave_silence
  2489. This indicate that @var{stop_duration} length of audio should be left intact
  2490. at the beginning of each period of silence.
  2491. For example, if you want to remove long pauses between words but do not want
  2492. to remove the pauses completely. Default value is @code{0}.
  2493. @item detection
  2494. Set how is silence detected. Can be @code{rms} or @code{peak}. Second is faster
  2495. and works better with digital silence which is exactly 0.
  2496. Default value is @code{rms}.
  2497. @item window
  2498. Set ratio used to calculate size of window for detecting silence.
  2499. Default value is @code{0.02}. Allowed range is from @code{0} to @code{10}.
  2500. @end table
  2501. @subsection Examples
  2502. @itemize
  2503. @item
  2504. The following example shows how this filter can be used to start a recording
  2505. that does not contain the delay at the start which usually occurs between
  2506. pressing the record button and the start of the performance:
  2507. @example
  2508. silenceremove=1:5:0.02
  2509. @end example
  2510. @item
  2511. Trim all silence encountered from begining to end where there is more than 1
  2512. second of silence in audio:
  2513. @example
  2514. silenceremove=0:0:0:-1:1:-90dB
  2515. @end example
  2516. @end itemize
  2517. @section sofalizer
  2518. SOFAlizer uses head-related transfer functions (HRTFs) to create virtual
  2519. loudspeakers around the user for binaural listening via headphones (audio
  2520. formats up to 9 channels supported).
  2521. The HRTFs are stored in SOFA files (see @url{http://www.sofacoustics.org/} for a database).
  2522. SOFAlizer is developed at the Acoustics Research Institute (ARI) of the
  2523. Austrian Academy of Sciences.
  2524. To enable compilation of this filter you need to configure FFmpeg with
  2525. @code{--enable-netcdf}.
  2526. The filter accepts the following options:
  2527. @table @option
  2528. @item sofa
  2529. Set the SOFA file used for rendering.
  2530. @item gain
  2531. Set gain applied to audio. Value is in dB. Default is 0.
  2532. @item rotation
  2533. Set rotation of virtual loudspeakers in deg. Default is 0.
  2534. @item elevation
  2535. Set elevation of virtual speakers in deg. Default is 0.
  2536. @item radius
  2537. Set distance in meters between loudspeakers and the listener with near-field
  2538. HRTFs. Default is 1.
  2539. @item type
  2540. Set processing type. Can be @var{time} or @var{freq}. @var{time} is
  2541. processing audio in time domain which is slow but gives high quality output.
  2542. @var{freq} is processing audio in frequency domain which is fast but gives
  2543. mediocre output. Default is @var{freq}.
  2544. @end table
  2545. @section stereotools
  2546. This filter has some handy utilities to manage stereo signals, for converting
  2547. M/S stereo recordings to L/R signal while having control over the parameters
  2548. or spreading the stereo image of master track.
  2549. The filter accepts the following options:
  2550. @table @option
  2551. @item level_in
  2552. Set input level before filtering for both channels. Defaults is 1.
  2553. Allowed range is from 0.015625 to 64.
  2554. @item level_out
  2555. Set output level after filtering for both channels. Defaults is 1.
  2556. Allowed range is from 0.015625 to 64.
  2557. @item balance_in
  2558. Set input balance between both channels. Default is 0.
  2559. Allowed range is from -1 to 1.
  2560. @item balance_out
  2561. Set output balance between both channels. Default is 0.
  2562. Allowed range is from -1 to 1.
  2563. @item softclip
  2564. Enable softclipping. Results in analog distortion instead of harsh digital 0dB
  2565. clipping. Disabled by default.
  2566. @item mutel
  2567. Mute the left channel. Disabled by default.
  2568. @item muter
  2569. Mute the right channel. Disabled by default.
  2570. @item phasel
  2571. Change the phase of the left channel. Disabled by default.
  2572. @item phaser
  2573. Change the phase of the right channel. Disabled by default.
  2574. @item mode
  2575. Set stereo mode. Available values are:
  2576. @table @samp
  2577. @item lr>lr
  2578. Left/Right to Left/Right, this is default.
  2579. @item lr>ms
  2580. Left/Right to Mid/Side.
  2581. @item ms>lr
  2582. Mid/Side to Left/Right.
  2583. @item lr>ll
  2584. Left/Right to Left/Left.
  2585. @item lr>rr
  2586. Left/Right to Right/Right.
  2587. @item lr>l+r
  2588. Left/Right to Left + Right.
  2589. @item lr>rl
  2590. Left/Right to Right/Left.
  2591. @end table
  2592. @item slev
  2593. Set level of side signal. Default is 1.
  2594. Allowed range is from 0.015625 to 64.
  2595. @item sbal
  2596. Set balance of side signal. Default is 0.
  2597. Allowed range is from -1 to 1.
  2598. @item mlev
  2599. Set level of the middle signal. Default is 1.
  2600. Allowed range is from 0.015625 to 64.
  2601. @item mpan
  2602. Set middle signal pan. Default is 0. Allowed range is from -1 to 1.
  2603. @item base
  2604. Set stereo base between mono and inversed channels. Default is 0.
  2605. Allowed range is from -1 to 1.
  2606. @item delay
  2607. Set delay in milliseconds how much to delay left from right channel and
  2608. vice versa. Default is 0. Allowed range is from -20 to 20.
  2609. @item sclevel
  2610. Set S/C level. Default is 1. Allowed range is from 1 to 100.
  2611. @item phase
  2612. Set the stereo phase in degrees. Default is 0. Allowed range is from 0 to 360.
  2613. @end table
  2614. @section stereowiden
  2615. This filter enhance the stereo effect by suppressing signal common to both
  2616. channels and by delaying the signal of left into right and vice versa,
  2617. thereby widening the stereo effect.
  2618. The filter accepts the following options:
  2619. @table @option
  2620. @item delay
  2621. Time in milliseconds of the delay of left signal into right and vice versa.
  2622. Default is 20 milliseconds.
  2623. @item feedback
  2624. Amount of gain in delayed signal into right and vice versa. Gives a delay
  2625. effect of left signal in right output and vice versa which gives widening
  2626. effect. Default is 0.3.
  2627. @item crossfeed
  2628. Cross feed of left into right with inverted phase. This helps in suppressing
  2629. the mono. If the value is 1 it will cancel all the signal common to both
  2630. channels. Default is 0.3.
  2631. @item drymix
  2632. Set level of input signal of original channel. Default is 0.8.
  2633. @end table
  2634. @section treble
  2635. Boost or cut treble (upper) frequencies of the audio using a two-pole
  2636. shelving filter with a response similar to that of a standard
  2637. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  2638. The filter accepts the following options:
  2639. @table @option
  2640. @item gain, g
  2641. Give the gain at whichever is the lower of ~22 kHz and the
  2642. Nyquist frequency. Its useful range is about -20 (for a large cut)
  2643. to +20 (for a large boost). Beware of clipping when using a positive gain.
  2644. @item frequency, f
  2645. Set the filter's central frequency and so can be used
  2646. to extend or reduce the frequency range to be boosted or cut.
  2647. The default value is @code{3000} Hz.
  2648. @item width_type
  2649. Set method to specify band-width of filter.
  2650. @table @option
  2651. @item h
  2652. Hz
  2653. @item q
  2654. Q-Factor
  2655. @item o
  2656. octave
  2657. @item s
  2658. slope
  2659. @end table
  2660. @item width, w
  2661. Determine how steep is the filter's shelf transition.
  2662. @end table
  2663. @section tremolo
  2664. Sinusoidal amplitude modulation.
  2665. The filter accepts the following options:
  2666. @table @option
  2667. @item f
  2668. Modulation frequency in Hertz. Modulation frequencies in the subharmonic range
  2669. (20 Hz or lower) will result in a tremolo effect.
  2670. This filter may also be used as a ring modulator by specifying
  2671. a modulation frequency higher than 20 Hz.
  2672. Range is 0.1 - 20000.0. Default value is 5.0 Hz.
  2673. @item d
  2674. Depth of modulation as a percentage. Range is 0.0 - 1.0.
  2675. Default value is 0.5.
  2676. @end table
  2677. @section vibrato
  2678. Sinusoidal phase modulation.
  2679. The filter accepts the following options:
  2680. @table @option
  2681. @item f
  2682. Modulation frequency in Hertz.
  2683. Range is 0.1 - 20000.0. Default value is 5.0 Hz.
  2684. @item d
  2685. Depth of modulation as a percentage. Range is 0.0 - 1.0.
  2686. Default value is 0.5.
  2687. @end table
  2688. @section volume
  2689. Adjust the input audio volume.
  2690. It accepts the following parameters:
  2691. @table @option
  2692. @item volume
  2693. Set audio volume expression.
  2694. Output values are clipped to the maximum value.
  2695. The output audio volume is given by the relation:
  2696. @example
  2697. @var{output_volume} = @var{volume} * @var{input_volume}
  2698. @end example
  2699. The default value for @var{volume} is "1.0".
  2700. @item precision
  2701. This parameter represents the mathematical precision.
  2702. It determines which input sample formats will be allowed, which affects the
  2703. precision of the volume scaling.
  2704. @table @option
  2705. @item fixed
  2706. 8-bit fixed-point; this limits input sample format to U8, S16, and S32.
  2707. @item float
  2708. 32-bit floating-point; this limits input sample format to FLT. (default)
  2709. @item double
  2710. 64-bit floating-point; this limits input sample format to DBL.
  2711. @end table
  2712. @item replaygain
  2713. Choose the behaviour on encountering ReplayGain side data in input frames.
  2714. @table @option
  2715. @item drop
  2716. Remove ReplayGain side data, ignoring its contents (the default).
  2717. @item ignore
  2718. Ignore ReplayGain side data, but leave it in the frame.
  2719. @item track
  2720. Prefer the track gain, if present.
  2721. @item album
  2722. Prefer the album gain, if present.
  2723. @end table
  2724. @item replaygain_preamp
  2725. Pre-amplification gain in dB to apply to the selected replaygain gain.
  2726. Default value for @var{replaygain_preamp} is 0.0.
  2727. @item eval
  2728. Set when the volume expression is evaluated.
  2729. It accepts the following values:
  2730. @table @samp
  2731. @item once
  2732. only evaluate expression once during the filter initialization, or
  2733. when the @samp{volume} command is sent
  2734. @item frame
  2735. evaluate expression for each incoming frame
  2736. @end table
  2737. Default value is @samp{once}.
  2738. @end table
  2739. The volume expression can contain the following parameters.
  2740. @table @option
  2741. @item n
  2742. frame number (starting at zero)
  2743. @item nb_channels
  2744. number of channels
  2745. @item nb_consumed_samples
  2746. number of samples consumed by the filter
  2747. @item nb_samples
  2748. number of samples in the current frame
  2749. @item pos
  2750. original frame position in the file
  2751. @item pts
  2752. frame PTS
  2753. @item sample_rate
  2754. sample rate
  2755. @item startpts
  2756. PTS at start of stream
  2757. @item startt
  2758. time at start of stream
  2759. @item t
  2760. frame time
  2761. @item tb
  2762. timestamp timebase
  2763. @item volume
  2764. last set volume value
  2765. @end table
  2766. Note that when @option{eval} is set to @samp{once} only the
  2767. @var{sample_rate} and @var{tb} variables are available, all other
  2768. variables will evaluate to NAN.
  2769. @subsection Commands
  2770. This filter supports the following commands:
  2771. @table @option
  2772. @item volume
  2773. Modify the volume expression.
  2774. The command accepts the same syntax of the corresponding option.
  2775. If the specified expression is not valid, it is kept at its current
  2776. value.
  2777. @item replaygain_noclip
  2778. Prevent clipping by limiting the gain applied.
  2779. Default value for @var{replaygain_noclip} is 1.
  2780. @end table
  2781. @subsection Examples
  2782. @itemize
  2783. @item
  2784. Halve the input audio volume:
  2785. @example
  2786. volume=volume=0.5
  2787. volume=volume=1/2
  2788. volume=volume=-6.0206dB
  2789. @end example
  2790. In all the above example the named key for @option{volume} can be
  2791. omitted, for example like in:
  2792. @example
  2793. volume=0.5
  2794. @end example
  2795. @item
  2796. Increase input audio power by 6 decibels using fixed-point precision:
  2797. @example
  2798. volume=volume=6dB:precision=fixed
  2799. @end example
  2800. @item
  2801. Fade volume after time 10 with an annihilation period of 5 seconds:
  2802. @example
  2803. volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
  2804. @end example
  2805. @end itemize
  2806. @section volumedetect
  2807. Detect the volume of the input video.
  2808. The filter has no parameters. The input is not modified. Statistics about
  2809. the volume will be printed in the log when the input stream end is reached.
  2810. In particular it will show the mean volume (root mean square), maximum
  2811. volume (on a per-sample basis), and the beginning of a histogram of the
  2812. registered volume values (from the maximum value to a cumulated 1/1000 of
  2813. the samples).
  2814. All volumes are in decibels relative to the maximum PCM value.
  2815. @subsection Examples
  2816. Here is an excerpt of the output:
  2817. @example
  2818. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  2819. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  2820. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  2821. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  2822. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  2823. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  2824. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  2825. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  2826. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  2827. @end example
  2828. It means that:
  2829. @itemize
  2830. @item
  2831. The mean square energy is approximately -27 dB, or 10^-2.7.
  2832. @item
  2833. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  2834. @item
  2835. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  2836. @end itemize
  2837. In other words, raising the volume by +4 dB does not cause any clipping,
  2838. raising it by +5 dB causes clipping for 6 samples, etc.
  2839. @c man end AUDIO FILTERS
  2840. @chapter Audio Sources
  2841. @c man begin AUDIO SOURCES
  2842. Below is a description of the currently available audio sources.
  2843. @section abuffer
  2844. Buffer audio frames, and make them available to the filter chain.
  2845. This source is mainly intended for a programmatic use, in particular
  2846. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  2847. It accepts the following parameters:
  2848. @table @option
  2849. @item time_base
  2850. The timebase which will be used for timestamps of submitted frames. It must be
  2851. either a floating-point number or in @var{numerator}/@var{denominator} form.
  2852. @item sample_rate
  2853. The sample rate of the incoming audio buffers.
  2854. @item sample_fmt
  2855. The sample format of the incoming audio buffers.
  2856. Either a sample format name or its corresponding integer representation from
  2857. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  2858. @item channel_layout
  2859. The channel layout of the incoming audio buffers.
  2860. Either a channel layout name from channel_layout_map in
  2861. @file{libavutil/channel_layout.c} or its corresponding integer representation
  2862. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  2863. @item channels
  2864. The number of channels of the incoming audio buffers.
  2865. If both @var{channels} and @var{channel_layout} are specified, then they
  2866. must be consistent.
  2867. @end table
  2868. @subsection Examples
  2869. @example
  2870. abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
  2871. @end example
  2872. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  2873. Since the sample format with name "s16p" corresponds to the number
  2874. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  2875. equivalent to:
  2876. @example
  2877. abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
  2878. @end example
  2879. @section aevalsrc
  2880. Generate an audio signal specified by an expression.
  2881. This source accepts in input one or more expressions (one for each
  2882. channel), which are evaluated and used to generate a corresponding
  2883. audio signal.
  2884. This source accepts the following options:
  2885. @table @option
  2886. @item exprs
  2887. Set the '|'-separated expressions list for each separate channel. In case the
  2888. @option{channel_layout} option is not specified, the selected channel layout
  2889. depends on the number of provided expressions. Otherwise the last
  2890. specified expression is applied to the remaining output channels.
  2891. @item channel_layout, c
  2892. Set the channel layout. The number of channels in the specified layout
  2893. must be equal to the number of specified expressions.
  2894. @item duration, d
  2895. Set the minimum duration of the sourced audio. See
  2896. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  2897. for the accepted syntax.
  2898. Note that the resulting duration may be greater than the specified
  2899. duration, as the generated audio is always cut at the end of a
  2900. complete frame.
  2901. If not specified, or the expressed duration is negative, the audio is
  2902. supposed to be generated forever.
  2903. @item nb_samples, n
  2904. Set the number of samples per channel per each output frame,
  2905. default to 1024.
  2906. @item sample_rate, s
  2907. Specify the sample rate, default to 44100.
  2908. @end table
  2909. Each expression in @var{exprs} can contain the following constants:
  2910. @table @option
  2911. @item n
  2912. number of the evaluated sample, starting from 0
  2913. @item t
  2914. time of the evaluated sample expressed in seconds, starting from 0
  2915. @item s
  2916. sample rate
  2917. @end table
  2918. @subsection Examples
  2919. @itemize
  2920. @item
  2921. Generate silence:
  2922. @example
  2923. aevalsrc=0
  2924. @end example
  2925. @item
  2926. Generate a sin signal with frequency of 440 Hz, set sample rate to
  2927. 8000 Hz:
  2928. @example
  2929. aevalsrc="sin(440*2*PI*t):s=8000"
  2930. @end example
  2931. @item
  2932. Generate a two channels signal, specify the channel layout (Front
  2933. Center + Back Center) explicitly:
  2934. @example
  2935. aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
  2936. @end example
  2937. @item
  2938. Generate white noise:
  2939. @example
  2940. aevalsrc="-2+random(0)"
  2941. @end example
  2942. @item
  2943. Generate an amplitude modulated signal:
  2944. @example
  2945. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  2946. @end example
  2947. @item
  2948. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  2949. @example
  2950. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
  2951. @end example
  2952. @end itemize
  2953. @section anullsrc
  2954. The null audio source, return unprocessed audio frames. It is mainly useful
  2955. as a template and to be employed in analysis / debugging tools, or as
  2956. the source for filters which ignore the input data (for example the sox
  2957. synth filter).
  2958. This source accepts the following options:
  2959. @table @option
  2960. @item channel_layout, cl
  2961. Specifies the channel layout, and can be either an integer or a string
  2962. representing a channel layout. The default value of @var{channel_layout}
  2963. is "stereo".
  2964. Check the channel_layout_map definition in
  2965. @file{libavutil/channel_layout.c} for the mapping between strings and
  2966. channel layout values.
  2967. @item sample_rate, r
  2968. Specifies the sample rate, and defaults to 44100.
  2969. @item nb_samples, n
  2970. Set the number of samples per requested frames.
  2971. @end table
  2972. @subsection Examples
  2973. @itemize
  2974. @item
  2975. Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  2976. @example
  2977. anullsrc=r=48000:cl=4
  2978. @end example
  2979. @item
  2980. Do the same operation with a more obvious syntax:
  2981. @example
  2982. anullsrc=r=48000:cl=mono
  2983. @end example
  2984. @end itemize
  2985. All the parameters need to be explicitly defined.
  2986. @section flite
  2987. Synthesize a voice utterance using the libflite library.
  2988. To enable compilation of this filter you need to configure FFmpeg with
  2989. @code{--enable-libflite}.
  2990. Note that the flite library is not thread-safe.
  2991. The filter accepts the following options:
  2992. @table @option
  2993. @item list_voices
  2994. If set to 1, list the names of the available voices and exit
  2995. immediately. Default value is 0.
  2996. @item nb_samples, n
  2997. Set the maximum number of samples per frame. Default value is 512.
  2998. @item textfile
  2999. Set the filename containing the text to speak.
  3000. @item text
  3001. Set the text to speak.
  3002. @item voice, v
  3003. Set the voice to use for the speech synthesis. Default value is
  3004. @code{kal}. See also the @var{list_voices} option.
  3005. @end table
  3006. @subsection Examples
  3007. @itemize
  3008. @item
  3009. Read from file @file{speech.txt}, and synthesize the text using the
  3010. standard flite voice:
  3011. @example
  3012. flite=textfile=speech.txt
  3013. @end example
  3014. @item
  3015. Read the specified text selecting the @code{slt} voice:
  3016. @example
  3017. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  3018. @end example
  3019. @item
  3020. Input text to ffmpeg:
  3021. @example
  3022. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  3023. @end example
  3024. @item
  3025. Make @file{ffplay} speak the specified text, using @code{flite} and
  3026. the @code{lavfi} device:
  3027. @example
  3028. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  3029. @end example
  3030. @end itemize
  3031. For more information about libflite, check:
  3032. @url{http://www.speech.cs.cmu.edu/flite/}
  3033. @section anoisesrc
  3034. Generate a noise audio signal.
  3035. The filter accepts the following options:
  3036. @table @option
  3037. @item sample_rate, r
  3038. Specify the sample rate. Default value is 48000 Hz.
  3039. @item amplitude, a
  3040. Specify the amplitude (0.0 - 1.0) of the generated audio stream. Default value
  3041. is 1.0.
  3042. @item duration, d
  3043. Specify the duration of the generated audio stream. Not specifying this option
  3044. results in noise with an infinite length.
  3045. @item color, colour, c
  3046. Specify the color of noise. Available noise colors are white, pink, and brown.
  3047. Default color is white.
  3048. @item seed, s
  3049. Specify a value used to seed the PRNG.
  3050. @item nb_samples, n
  3051. Set the number of samples per each output frame, default is 1024.
  3052. @end table
  3053. @subsection Examples
  3054. @itemize
  3055. @item
  3056. Generate 60 seconds of pink noise, with a 44.1 kHz sampling rate and an amplitude of 0.5:
  3057. @example
  3058. anoisesrc=d=60:c=pink:r=44100:a=0.5
  3059. @end example
  3060. @end itemize
  3061. @section sine
  3062. Generate an audio signal made of a sine wave with amplitude 1/8.
  3063. The audio signal is bit-exact.
  3064. The filter accepts the following options:
  3065. @table @option
  3066. @item frequency, f
  3067. Set the carrier frequency. Default is 440 Hz.
  3068. @item beep_factor, b
  3069. Enable a periodic beep every second with frequency @var{beep_factor} times
  3070. the carrier frequency. Default is 0, meaning the beep is disabled.
  3071. @item sample_rate, r
  3072. Specify the sample rate, default is 44100.
  3073. @item duration, d
  3074. Specify the duration of the generated audio stream.
  3075. @item samples_per_frame
  3076. Set the number of samples per output frame.
  3077. The expression can contain the following constants:
  3078. @table @option
  3079. @item n
  3080. The (sequential) number of the output audio frame, starting from 0.
  3081. @item pts
  3082. The PTS (Presentation TimeStamp) of the output audio frame,
  3083. expressed in @var{TB} units.
  3084. @item t
  3085. The PTS of the output audio frame, expressed in seconds.
  3086. @item TB
  3087. The timebase of the output audio frames.
  3088. @end table
  3089. Default is @code{1024}.
  3090. @end table
  3091. @subsection Examples
  3092. @itemize
  3093. @item
  3094. Generate a simple 440 Hz sine wave:
  3095. @example
  3096. sine
  3097. @end example
  3098. @item
  3099. Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
  3100. @example
  3101. sine=220:4:d=5
  3102. sine=f=220:b=4:d=5
  3103. sine=frequency=220:beep_factor=4:duration=5
  3104. @end example
  3105. @item
  3106. Generate a 1 kHz sine wave following @code{1602,1601,1602,1601,1602} NTSC
  3107. pattern:
  3108. @example
  3109. sine=1000:samples_per_frame='st(0,mod(n,5)); 1602-not(not(eq(ld(0),1)+eq(ld(0),3)))'
  3110. @end example
  3111. @end itemize
  3112. @c man end AUDIO SOURCES
  3113. @chapter Audio Sinks
  3114. @c man begin AUDIO SINKS
  3115. Below is a description of the currently available audio sinks.
  3116. @section abuffersink
  3117. Buffer audio frames, and make them available to the end of filter chain.
  3118. This sink is mainly intended for programmatic use, in particular
  3119. through the interface defined in @file{libavfilter/buffersink.h}
  3120. or the options system.
  3121. It accepts a pointer to an AVABufferSinkContext structure, which
  3122. defines the incoming buffers' formats, to be passed as the opaque
  3123. parameter to @code{avfilter_init_filter} for initialization.
  3124. @section anullsink
  3125. Null audio sink; do absolutely nothing with the input audio. It is
  3126. mainly useful as a template and for use in analysis / debugging
  3127. tools.
  3128. @c man end AUDIO SINKS
  3129. @chapter Video Filters
  3130. @c man begin VIDEO FILTERS
  3131. When you configure your FFmpeg build, you can disable any of the
  3132. existing filters using @code{--disable-filters}.
  3133. The configure output will show the video filters included in your
  3134. build.
  3135. Below is a description of the currently available video filters.
  3136. @section alphaextract
  3137. Extract the alpha component from the input as a grayscale video. This
  3138. is especially useful with the @var{alphamerge} filter.
  3139. @section alphamerge
  3140. Add or replace the alpha component of the primary input with the
  3141. grayscale value of a second input. This is intended for use with
  3142. @var{alphaextract} to allow the transmission or storage of frame
  3143. sequences that have alpha in a format that doesn't support an alpha
  3144. channel.
  3145. For example, to reconstruct full frames from a normal YUV-encoded video
  3146. and a separate video created with @var{alphaextract}, you might use:
  3147. @example
  3148. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  3149. @end example
  3150. Since this filter is designed for reconstruction, it operates on frame
  3151. sequences without considering timestamps, and terminates when either
  3152. input reaches end of stream. This will cause problems if your encoding
  3153. pipeline drops frames. If you're trying to apply an image as an
  3154. overlay to a video stream, consider the @var{overlay} filter instead.
  3155. @section ass
  3156. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  3157. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  3158. Substation Alpha) subtitles files.
  3159. This filter accepts the following option in addition to the common options from
  3160. the @ref{subtitles} filter:
  3161. @table @option
  3162. @item shaping
  3163. Set the shaping engine
  3164. Available values are:
  3165. @table @samp
  3166. @item auto
  3167. The default libass shaping engine, which is the best available.
  3168. @item simple
  3169. Fast, font-agnostic shaper that can do only substitutions
  3170. @item complex
  3171. Slower shaper using OpenType for substitutions and positioning
  3172. @end table
  3173. The default is @code{auto}.
  3174. @end table
  3175. @section atadenoise
  3176. Apply an Adaptive Temporal Averaging Denoiser to the video input.
  3177. The filter accepts the following options:
  3178. @table @option
  3179. @item 0a
  3180. Set threshold A for 1st plane. Default is 0.02.
  3181. Valid range is 0 to 0.3.
  3182. @item 0b
  3183. Set threshold B for 1st plane. Default is 0.04.
  3184. Valid range is 0 to 5.
  3185. @item 1a
  3186. Set threshold A for 2nd plane. Default is 0.02.
  3187. Valid range is 0 to 0.3.
  3188. @item 1b
  3189. Set threshold B for 2nd plane. Default is 0.04.
  3190. Valid range is 0 to 5.
  3191. @item 2a
  3192. Set threshold A for 3rd plane. Default is 0.02.
  3193. Valid range is 0 to 0.3.
  3194. @item 2b
  3195. Set threshold B for 3rd plane. Default is 0.04.
  3196. Valid range is 0 to 5.
  3197. Threshold A is designed to react on abrupt changes in the input signal and
  3198. threshold B is designed to react on continuous changes in the input signal.
  3199. @item s
  3200. Set number of frames filter will use for averaging. Default is 33. Must be odd
  3201. number in range [5, 129].
  3202. @end table
  3203. @section bbox
  3204. Compute the bounding box for the non-black pixels in the input frame
  3205. luminance plane.
  3206. This filter computes the bounding box containing all the pixels with a
  3207. luminance value greater than the minimum allowed value.
  3208. The parameters describing the bounding box are printed on the filter
  3209. log.
  3210. The filter accepts the following option:
  3211. @table @option
  3212. @item min_val
  3213. Set the minimal luminance value. Default is @code{16}.
  3214. @end table
  3215. @section blackdetect
  3216. Detect video intervals that are (almost) completely black. Can be
  3217. useful to detect chapter transitions, commercials, or invalid
  3218. recordings. Output lines contains the time for the start, end and
  3219. duration of the detected black interval expressed in seconds.
  3220. In order to display the output lines, you need to set the loglevel at
  3221. least to the AV_LOG_INFO value.
  3222. The filter accepts the following options:
  3223. @table @option
  3224. @item black_min_duration, d
  3225. Set the minimum detected black duration expressed in seconds. It must
  3226. be a non-negative floating point number.
  3227. Default value is 2.0.
  3228. @item picture_black_ratio_th, pic_th
  3229. Set the threshold for considering a picture "black".
  3230. Express the minimum value for the ratio:
  3231. @example
  3232. @var{nb_black_pixels} / @var{nb_pixels}
  3233. @end example
  3234. for which a picture is considered black.
  3235. Default value is 0.98.
  3236. @item pixel_black_th, pix_th
  3237. Set the threshold for considering a pixel "black".
  3238. The threshold expresses the maximum pixel luminance value for which a
  3239. pixel is considered "black". The provided value is scaled according to
  3240. the following equation:
  3241. @example
  3242. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  3243. @end example
  3244. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  3245. the input video format, the range is [0-255] for YUV full-range
  3246. formats and [16-235] for YUV non full-range formats.
  3247. Default value is 0.10.
  3248. @end table
  3249. The following example sets the maximum pixel threshold to the minimum
  3250. value, and detects only black intervals of 2 or more seconds:
  3251. @example
  3252. blackdetect=d=2:pix_th=0.00
  3253. @end example
  3254. @section blackframe
  3255. Detect frames that are (almost) completely black. Can be useful to
  3256. detect chapter transitions or commercials. Output lines consist of
  3257. the frame number of the detected frame, the percentage of blackness,
  3258. the position in the file if known or -1 and the timestamp in seconds.
  3259. In order to display the output lines, you need to set the loglevel at
  3260. least to the AV_LOG_INFO value.
  3261. It accepts the following parameters:
  3262. @table @option
  3263. @item amount
  3264. The percentage of the pixels that have to be below the threshold; it defaults to
  3265. @code{98}.
  3266. @item threshold, thresh
  3267. The threshold below which a pixel value is considered black; it defaults to
  3268. @code{32}.
  3269. @end table
  3270. @section blend, tblend
  3271. Blend two video frames into each other.
  3272. The @code{blend} filter takes two input streams and outputs one
  3273. stream, the first input is the "top" layer and second input is
  3274. "bottom" layer. Output terminates when shortest input terminates.
  3275. The @code{tblend} (time blend) filter takes two consecutive frames
  3276. from one single stream, and outputs the result obtained by blending
  3277. the new frame on top of the old frame.
  3278. A description of the accepted options follows.
  3279. @table @option
  3280. @item c0_mode
  3281. @item c1_mode
  3282. @item c2_mode
  3283. @item c3_mode
  3284. @item all_mode
  3285. Set blend mode for specific pixel component or all pixel components in case
  3286. of @var{all_mode}. Default value is @code{normal}.
  3287. Available values for component modes are:
  3288. @table @samp
  3289. @item addition
  3290. @item addition128
  3291. @item and
  3292. @item average
  3293. @item burn
  3294. @item darken
  3295. @item difference
  3296. @item difference128
  3297. @item divide
  3298. @item dodge
  3299. @item freeze
  3300. @item exclusion
  3301. @item glow
  3302. @item hardlight
  3303. @item hardmix
  3304. @item heat
  3305. @item lighten
  3306. @item linearlight
  3307. @item multiply
  3308. @item multiply128
  3309. @item negation
  3310. @item normal
  3311. @item or
  3312. @item overlay
  3313. @item phoenix
  3314. @item pinlight
  3315. @item reflect
  3316. @item screen
  3317. @item softlight
  3318. @item subtract
  3319. @item vividlight
  3320. @item xor
  3321. @end table
  3322. @item c0_opacity
  3323. @item c1_opacity
  3324. @item c2_opacity
  3325. @item c3_opacity
  3326. @item all_opacity
  3327. Set blend opacity for specific pixel component or all pixel components in case
  3328. of @var{all_opacity}. Only used in combination with pixel component blend modes.
  3329. @item c0_expr
  3330. @item c1_expr
  3331. @item c2_expr
  3332. @item c3_expr
  3333. @item all_expr
  3334. Set blend expression for specific pixel component or all pixel components in case
  3335. of @var{all_expr}. Note that related mode options will be ignored if those are set.
  3336. The expressions can use the following variables:
  3337. @table @option
  3338. @item N
  3339. The sequential number of the filtered frame, starting from @code{0}.
  3340. @item X
  3341. @item Y
  3342. the coordinates of the current sample
  3343. @item W
  3344. @item H
  3345. the width and height of currently filtered plane
  3346. @item SW
  3347. @item SH
  3348. Width and height scale depending on the currently filtered plane. It is the
  3349. ratio between the corresponding luma plane number of pixels and the current
  3350. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  3351. @code{0.5,0.5} for chroma planes.
  3352. @item T
  3353. Time of the current frame, expressed in seconds.
  3354. @item TOP, A
  3355. Value of pixel component at current location for first video frame (top layer).
  3356. @item BOTTOM, B
  3357. Value of pixel component at current location for second video frame (bottom layer).
  3358. @end table
  3359. @item shortest
  3360. Force termination when the shortest input terminates. Default is
  3361. @code{0}. This option is only defined for the @code{blend} filter.
  3362. @item repeatlast
  3363. Continue applying the last bottom frame after the end of the stream. A value of
  3364. @code{0} disable the filter after the last frame of the bottom layer is reached.
  3365. Default is @code{1}. This option is only defined for the @code{blend} filter.
  3366. @end table
  3367. @subsection Examples
  3368. @itemize
  3369. @item
  3370. Apply transition from bottom layer to top layer in first 10 seconds:
  3371. @example
  3372. blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
  3373. @end example
  3374. @item
  3375. Apply 1x1 checkerboard effect:
  3376. @example
  3377. blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
  3378. @end example
  3379. @item
  3380. Apply uncover left effect:
  3381. @example
  3382. blend=all_expr='if(gte(N*SW+X,W),A,B)'
  3383. @end example
  3384. @item
  3385. Apply uncover down effect:
  3386. @example
  3387. blend=all_expr='if(gte(Y-N*SH,0),A,B)'
  3388. @end example
  3389. @item
  3390. Apply uncover up-left effect:
  3391. @example
  3392. blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
  3393. @end example
  3394. @item
  3395. Split diagonally video and shows top and bottom layer on each side:
  3396. @example
  3397. blend=all_expr=if(gt(X,Y*(W/H)),A,B)
  3398. @end example
  3399. @item
  3400. Display differences between the current and the previous frame:
  3401. @example
  3402. tblend=all_mode=difference128
  3403. @end example
  3404. @end itemize
  3405. @section bwdif
  3406. Deinterlace the input video ("bwdif" stands for "Bob Weaver
  3407. Deinterlacing Filter").
  3408. Motion adaptive deinterlacing based on yadif with the use of w3fdif and cubic
  3409. interpolation algorithms.
  3410. It accepts the following parameters:
  3411. @table @option
  3412. @item mode
  3413. The interlacing mode to adopt. It accepts one of the following values:
  3414. @table @option
  3415. @item 0, send_frame
  3416. Output one frame for each frame.
  3417. @item 1, send_field
  3418. Output one frame for each field.
  3419. @end table
  3420. The default value is @code{send_field}.
  3421. @item parity
  3422. The picture field parity assumed for the input interlaced video. It accepts one
  3423. of the following values:
  3424. @table @option
  3425. @item 0, tff
  3426. Assume the top field is first.
  3427. @item 1, bff
  3428. Assume the bottom field is first.
  3429. @item -1, auto
  3430. Enable automatic detection of field parity.
  3431. @end table
  3432. The default value is @code{auto}.
  3433. If the interlacing is unknown or the decoder does not export this information,
  3434. top field first will be assumed.
  3435. @item deint
  3436. Specify which frames to deinterlace. Accept one of the following
  3437. values:
  3438. @table @option
  3439. @item 0, all
  3440. Deinterlace all frames.
  3441. @item 1, interlaced
  3442. Only deinterlace frames marked as interlaced.
  3443. @end table
  3444. The default value is @code{all}.
  3445. @end table
  3446. @section boxblur
  3447. Apply a boxblur algorithm to the input video.
  3448. It accepts the following parameters:
  3449. @table @option
  3450. @item luma_radius, lr
  3451. @item luma_power, lp
  3452. @item chroma_radius, cr
  3453. @item chroma_power, cp
  3454. @item alpha_radius, ar
  3455. @item alpha_power, ap
  3456. @end table
  3457. A description of the accepted options follows.
  3458. @table @option
  3459. @item luma_radius, lr
  3460. @item chroma_radius, cr
  3461. @item alpha_radius, ar
  3462. Set an expression for the box radius in pixels used for blurring the
  3463. corresponding input plane.
  3464. The radius value must be a non-negative number, and must not be
  3465. greater than the value of the expression @code{min(w,h)/2} for the
  3466. luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
  3467. planes.
  3468. Default value for @option{luma_radius} is "2". If not specified,
  3469. @option{chroma_radius} and @option{alpha_radius} default to the
  3470. corresponding value set for @option{luma_radius}.
  3471. The expressions can contain the following constants:
  3472. @table @option
  3473. @item w
  3474. @item h
  3475. The input width and height in pixels.
  3476. @item cw
  3477. @item ch
  3478. The input chroma image width and height in pixels.
  3479. @item hsub
  3480. @item vsub
  3481. The horizontal and vertical chroma subsample values. For example, for the
  3482. pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
  3483. @end table
  3484. @item luma_power, lp
  3485. @item chroma_power, cp
  3486. @item alpha_power, ap
  3487. Specify how many times the boxblur filter is applied to the
  3488. corresponding plane.
  3489. Default value for @option{luma_power} is 2. If not specified,
  3490. @option{chroma_power} and @option{alpha_power} default to the
  3491. corresponding value set for @option{luma_power}.
  3492. A value of 0 will disable the effect.
  3493. @end table
  3494. @subsection Examples
  3495. @itemize
  3496. @item
  3497. Apply a boxblur filter with the luma, chroma, and alpha radii
  3498. set to 2:
  3499. @example
  3500. boxblur=luma_radius=2:luma_power=1
  3501. boxblur=2:1
  3502. @end example
  3503. @item
  3504. Set the luma radius to 2, and alpha and chroma radius to 0:
  3505. @example
  3506. boxblur=2:1:cr=0:ar=0
  3507. @end example
  3508. @item
  3509. Set the luma and chroma radii to a fraction of the video dimension:
  3510. @example
  3511. boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
  3512. @end example
  3513. @end itemize
  3514. @section chromakey
  3515. YUV colorspace color/chroma keying.
  3516. The filter accepts the following options:
  3517. @table @option
  3518. @item color
  3519. The color which will be replaced with transparency.
  3520. @item similarity
  3521. Similarity percentage with the key color.
  3522. 0.01 matches only the exact key color, while 1.0 matches everything.
  3523. @item blend
  3524. Blend percentage.
  3525. 0.0 makes pixels either fully transparent, or not transparent at all.
  3526. Higher values result in semi-transparent pixels, with a higher transparency
  3527. the more similar the pixels color is to the key color.
  3528. @item yuv
  3529. Signals that the color passed is already in YUV instead of RGB.
  3530. Litteral colors like "green" or "red" don't make sense with this enabled anymore.
  3531. This can be used to pass exact YUV values as hexadecimal numbers.
  3532. @end table
  3533. @subsection Examples
  3534. @itemize
  3535. @item
  3536. Make every green pixel in the input image transparent:
  3537. @example
  3538. ffmpeg -i input.png -vf chromakey=green out.png
  3539. @end example
  3540. @item
  3541. Overlay a greenscreen-video on top of a static black background.
  3542. @example
  3543. 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
  3544. @end example
  3545. @end itemize
  3546. @section codecview
  3547. Visualize information exported by some codecs.
  3548. Some codecs can export information through frames using side-data or other
  3549. means. For example, some MPEG based codecs export motion vectors through the
  3550. @var{export_mvs} flag in the codec @option{flags2} option.
  3551. The filter accepts the following option:
  3552. @table @option
  3553. @item mv
  3554. Set motion vectors to visualize.
  3555. Available flags for @var{mv} are:
  3556. @table @samp
  3557. @item pf
  3558. forward predicted MVs of P-frames
  3559. @item bf
  3560. forward predicted MVs of B-frames
  3561. @item bb
  3562. backward predicted MVs of B-frames
  3563. @end table
  3564. @item qp
  3565. Display quantization parameters using the chroma planes
  3566. @end table
  3567. @subsection Examples
  3568. @itemize
  3569. @item
  3570. Visualizes multi-directionals MVs from P and B-Frames using @command{ffplay}:
  3571. @example
  3572. ffplay -flags2 +export_mvs input.mpg -vf codecview=mv=pf+bf+bb
  3573. @end example
  3574. @end itemize
  3575. @section colorbalance
  3576. Modify intensity of primary colors (red, green and blue) of input frames.
  3577. The filter allows an input frame to be adjusted in the shadows, midtones or highlights
  3578. regions for the red-cyan, green-magenta or blue-yellow balance.
  3579. A positive adjustment value shifts the balance towards the primary color, a negative
  3580. value towards the complementary color.
  3581. The filter accepts the following options:
  3582. @table @option
  3583. @item rs
  3584. @item gs
  3585. @item bs
  3586. Adjust red, green and blue shadows (darkest pixels).
  3587. @item rm
  3588. @item gm
  3589. @item bm
  3590. Adjust red, green and blue midtones (medium pixels).
  3591. @item rh
  3592. @item gh
  3593. @item bh
  3594. Adjust red, green and blue highlights (brightest pixels).
  3595. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  3596. @end table
  3597. @subsection Examples
  3598. @itemize
  3599. @item
  3600. Add red color cast to shadows:
  3601. @example
  3602. colorbalance=rs=.3
  3603. @end example
  3604. @end itemize
  3605. @section colorkey
  3606. RGB colorspace color keying.
  3607. The filter accepts the following options:
  3608. @table @option
  3609. @item color
  3610. The color which will be replaced with transparency.
  3611. @item similarity
  3612. Similarity percentage with the key color.
  3613. 0.01 matches only the exact key color, while 1.0 matches everything.
  3614. @item blend
  3615. Blend percentage.
  3616. 0.0 makes pixels either fully transparent, or not transparent at all.
  3617. Higher values result in semi-transparent pixels, with a higher transparency
  3618. the more similar the pixels color is to the key color.
  3619. @end table
  3620. @subsection Examples
  3621. @itemize
  3622. @item
  3623. Make every green pixel in the input image transparent:
  3624. @example
  3625. ffmpeg -i input.png -vf colorkey=green out.png
  3626. @end example
  3627. @item
  3628. Overlay a greenscreen-video on top of a static background image.
  3629. @example
  3630. 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
  3631. @end example
  3632. @end itemize
  3633. @section colorlevels
  3634. Adjust video input frames using levels.
  3635. The filter accepts the following options:
  3636. @table @option
  3637. @item rimin
  3638. @item gimin
  3639. @item bimin
  3640. @item aimin
  3641. Adjust red, green, blue and alpha input black point.
  3642. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  3643. @item rimax
  3644. @item gimax
  3645. @item bimax
  3646. @item aimax
  3647. Adjust red, green, blue and alpha input white point.
  3648. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
  3649. Input levels are used to lighten highlights (bright tones), darken shadows
  3650. (dark tones), change the balance of bright and dark tones.
  3651. @item romin
  3652. @item gomin
  3653. @item bomin
  3654. @item aomin
  3655. Adjust red, green, blue and alpha output black point.
  3656. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
  3657. @item romax
  3658. @item gomax
  3659. @item bomax
  3660. @item aomax
  3661. Adjust red, green, blue and alpha output white point.
  3662. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
  3663. Output levels allows manual selection of a constrained output level range.
  3664. @end table
  3665. @subsection Examples
  3666. @itemize
  3667. @item
  3668. Make video output darker:
  3669. @example
  3670. colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
  3671. @end example
  3672. @item
  3673. Increase contrast:
  3674. @example
  3675. colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
  3676. @end example
  3677. @item
  3678. Make video output lighter:
  3679. @example
  3680. colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
  3681. @end example
  3682. @item
  3683. Increase brightness:
  3684. @example
  3685. colorlevels=romin=0.5:gomin=0.5:bomin=0.5
  3686. @end example
  3687. @end itemize
  3688. @section colorchannelmixer
  3689. Adjust video input frames by re-mixing color channels.
  3690. This filter modifies a color channel by adding the values associated to
  3691. the other channels of the same pixels. For example if the value to
  3692. modify is red, the output value will be:
  3693. @example
  3694. @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
  3695. @end example
  3696. The filter accepts the following options:
  3697. @table @option
  3698. @item rr
  3699. @item rg
  3700. @item rb
  3701. @item ra
  3702. Adjust contribution of input red, green, blue and alpha channels for output red channel.
  3703. Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
  3704. @item gr
  3705. @item gg
  3706. @item gb
  3707. @item ga
  3708. Adjust contribution of input red, green, blue and alpha channels for output green channel.
  3709. Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
  3710. @item br
  3711. @item bg
  3712. @item bb
  3713. @item ba
  3714. Adjust contribution of input red, green, blue and alpha channels for output blue channel.
  3715. Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
  3716. @item ar
  3717. @item ag
  3718. @item ab
  3719. @item aa
  3720. Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
  3721. Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
  3722. Allowed ranges for options are @code{[-2.0, 2.0]}.
  3723. @end table
  3724. @subsection Examples
  3725. @itemize
  3726. @item
  3727. Convert source to grayscale:
  3728. @example
  3729. colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
  3730. @end example
  3731. @item
  3732. Simulate sepia tones:
  3733. @example
  3734. colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
  3735. @end example
  3736. @end itemize
  3737. @section colormatrix
  3738. Convert color matrix.
  3739. The filter accepts the following options:
  3740. @table @option
  3741. @item src
  3742. @item dst
  3743. Specify the source and destination color matrix. Both values must be
  3744. specified.
  3745. The accepted values are:
  3746. @table @samp
  3747. @item bt709
  3748. BT.709
  3749. @item bt601
  3750. BT.601
  3751. @item smpte240m
  3752. SMPTE-240M
  3753. @item fcc
  3754. FCC
  3755. @end table
  3756. @end table
  3757. For example to convert from BT.601 to SMPTE-240M, use the command:
  3758. @example
  3759. colormatrix=bt601:smpte240m
  3760. @end example
  3761. @section convolution
  3762. Apply convolution 3x3 or 5x5 filter.
  3763. The filter accepts the following options:
  3764. @table @option
  3765. @item 0m
  3766. @item 1m
  3767. @item 2m
  3768. @item 3m
  3769. Set matrix for each plane.
  3770. Matrix is sequence of 9 or 25 signed integers.
  3771. @item 0rdiv
  3772. @item 1rdiv
  3773. @item 2rdiv
  3774. @item 3rdiv
  3775. Set multiplier for calculated value for each plane.
  3776. @item 0bias
  3777. @item 1bias
  3778. @item 2bias
  3779. @item 3bias
  3780. Set bias for each plane. This value is added to the result of the multiplication.
  3781. Useful for making the overall image brighter or darker. Default is 0.0.
  3782. @end table
  3783. @subsection Examples
  3784. @itemize
  3785. @item
  3786. Apply sharpen:
  3787. @example
  3788. 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"
  3789. @end example
  3790. @item
  3791. Apply blur:
  3792. @example
  3793. 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"
  3794. @end example
  3795. @item
  3796. Apply edge enhance:
  3797. @example
  3798. 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"
  3799. @end example
  3800. @item
  3801. Apply edge detect:
  3802. @example
  3803. 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"
  3804. @end example
  3805. @item
  3806. Apply emboss:
  3807. @example
  3808. 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"
  3809. @end example
  3810. @end itemize
  3811. @section copy
  3812. Copy the input source unchanged to the output. This is mainly useful for
  3813. testing purposes.
  3814. @section crop
  3815. Crop the input video to given dimensions.
  3816. It accepts the following parameters:
  3817. @table @option
  3818. @item w, out_w
  3819. The width of the output video. It defaults to @code{iw}.
  3820. This expression is evaluated only once during the filter
  3821. configuration, or when the @samp{w} or @samp{out_w} command is sent.
  3822. @item h, out_h
  3823. The height of the output video. It defaults to @code{ih}.
  3824. This expression is evaluated only once during the filter
  3825. configuration, or when the @samp{h} or @samp{out_h} command is sent.
  3826. @item x
  3827. The horizontal position, in the input video, of the left edge of the output
  3828. video. It defaults to @code{(in_w-out_w)/2}.
  3829. This expression is evaluated per-frame.
  3830. @item y
  3831. The vertical position, in the input video, of the top edge of the output video.
  3832. It defaults to @code{(in_h-out_h)/2}.
  3833. This expression is evaluated per-frame.
  3834. @item keep_aspect
  3835. If set to 1 will force the output display aspect ratio
  3836. to be the same of the input, by changing the output sample aspect
  3837. ratio. It defaults to 0.
  3838. @end table
  3839. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  3840. expressions containing the following constants:
  3841. @table @option
  3842. @item x
  3843. @item y
  3844. The computed values for @var{x} and @var{y}. They are evaluated for
  3845. each new frame.
  3846. @item in_w
  3847. @item in_h
  3848. The input width and height.
  3849. @item iw
  3850. @item ih
  3851. These are the same as @var{in_w} and @var{in_h}.
  3852. @item out_w
  3853. @item out_h
  3854. The output (cropped) width and height.
  3855. @item ow
  3856. @item oh
  3857. These are the same as @var{out_w} and @var{out_h}.
  3858. @item a
  3859. same as @var{iw} / @var{ih}
  3860. @item sar
  3861. input sample aspect ratio
  3862. @item dar
  3863. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  3864. @item hsub
  3865. @item vsub
  3866. horizontal and vertical chroma subsample values. For example for the
  3867. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3868. @item n
  3869. The number of the input frame, starting from 0.
  3870. @item pos
  3871. the position in the file of the input frame, NAN if unknown
  3872. @item t
  3873. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  3874. @end table
  3875. The expression for @var{out_w} may depend on the value of @var{out_h},
  3876. and the expression for @var{out_h} may depend on @var{out_w}, but they
  3877. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  3878. evaluated after @var{out_w} and @var{out_h}.
  3879. The @var{x} and @var{y} parameters specify the expressions for the
  3880. position of the top-left corner of the output (non-cropped) area. They
  3881. are evaluated for each frame. If the evaluated value is not valid, it
  3882. is approximated to the nearest valid value.
  3883. The expression for @var{x} may depend on @var{y}, and the expression
  3884. for @var{y} may depend on @var{x}.
  3885. @subsection Examples
  3886. @itemize
  3887. @item
  3888. Crop area with size 100x100 at position (12,34).
  3889. @example
  3890. crop=100:100:12:34
  3891. @end example
  3892. Using named options, the example above becomes:
  3893. @example
  3894. crop=w=100:h=100:x=12:y=34
  3895. @end example
  3896. @item
  3897. Crop the central input area with size 100x100:
  3898. @example
  3899. crop=100:100
  3900. @end example
  3901. @item
  3902. Crop the central input area with size 2/3 of the input video:
  3903. @example
  3904. crop=2/3*in_w:2/3*in_h
  3905. @end example
  3906. @item
  3907. Crop the input video central square:
  3908. @example
  3909. crop=out_w=in_h
  3910. crop=in_h
  3911. @end example
  3912. @item
  3913. Delimit the rectangle with the top-left corner placed at position
  3914. 100:100 and the right-bottom corner corresponding to the right-bottom
  3915. corner of the input image.
  3916. @example
  3917. crop=in_w-100:in_h-100:100:100
  3918. @end example
  3919. @item
  3920. Crop 10 pixels from the left and right borders, and 20 pixels from
  3921. the top and bottom borders
  3922. @example
  3923. crop=in_w-2*10:in_h-2*20
  3924. @end example
  3925. @item
  3926. Keep only the bottom right quarter of the input image:
  3927. @example
  3928. crop=in_w/2:in_h/2:in_w/2:in_h/2
  3929. @end example
  3930. @item
  3931. Crop height for getting Greek harmony:
  3932. @example
  3933. crop=in_w:1/PHI*in_w
  3934. @end example
  3935. @item
  3936. Apply trembling effect:
  3937. @example
  3938. 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)
  3939. @end example
  3940. @item
  3941. Apply erratic camera effect depending on timestamp:
  3942. @example
  3943. 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)"
  3944. @end example
  3945. @item
  3946. Set x depending on the value of y:
  3947. @example
  3948. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  3949. @end example
  3950. @end itemize
  3951. @subsection Commands
  3952. This filter supports the following commands:
  3953. @table @option
  3954. @item w, out_w
  3955. @item h, out_h
  3956. @item x
  3957. @item y
  3958. Set width/height of the output video and the horizontal/vertical position
  3959. in the input video.
  3960. The command accepts the same syntax of the corresponding option.
  3961. If the specified expression is not valid, it is kept at its current
  3962. value.
  3963. @end table
  3964. @section cropdetect
  3965. Auto-detect the crop size.
  3966. It calculates the necessary cropping parameters and prints the
  3967. recommended parameters via the logging system. The detected dimensions
  3968. correspond to the non-black area of the input video.
  3969. It accepts the following parameters:
  3970. @table @option
  3971. @item limit
  3972. Set higher black value threshold, which can be optionally specified
  3973. from nothing (0) to everything (255 for 8bit based formats). An intensity
  3974. value greater to the set value is considered non-black. It defaults to 24.
  3975. You can also specify a value between 0.0 and 1.0 which will be scaled depending
  3976. on the bitdepth of the pixel format.
  3977. @item round
  3978. The value which the width/height should be divisible by. It defaults to
  3979. 16. The offset is automatically adjusted to center the video. Use 2 to
  3980. get only even dimensions (needed for 4:2:2 video). 16 is best when
  3981. encoding to most video codecs.
  3982. @item reset_count, reset
  3983. Set the counter that determines after how many frames cropdetect will
  3984. reset the previously detected largest video area and start over to
  3985. detect the current optimal crop area. Default value is 0.
  3986. This can be useful when channel logos distort the video area. 0
  3987. indicates 'never reset', and returns the largest area encountered during
  3988. playback.
  3989. @end table
  3990. @anchor{curves}
  3991. @section curves
  3992. Apply color adjustments using curves.
  3993. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  3994. component (red, green and blue) has its values defined by @var{N} key points
  3995. tied from each other using a smooth curve. The x-axis represents the pixel
  3996. values from the input frame, and the y-axis the new pixel values to be set for
  3997. the output frame.
  3998. By default, a component curve is defined by the two points @var{(0;0)} and
  3999. @var{(1;1)}. This creates a straight line where each original pixel value is
  4000. "adjusted" to its own value, which means no change to the image.
  4001. The filter allows you to redefine these two points and add some more. A new
  4002. curve (using a natural cubic spline interpolation) will be define to pass
  4003. smoothly through all these new coordinates. The new defined points needs to be
  4004. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  4005. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  4006. the vector spaces, the values will be clipped accordingly.
  4007. If there is no key point defined in @code{x=0}, the filter will automatically
  4008. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  4009. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  4010. The filter accepts the following options:
  4011. @table @option
  4012. @item preset
  4013. Select one of the available color presets. This option can be used in addition
  4014. to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
  4015. options takes priority on the preset values.
  4016. Available presets are:
  4017. @table @samp
  4018. @item none
  4019. @item color_negative
  4020. @item cross_process
  4021. @item darker
  4022. @item increase_contrast
  4023. @item lighter
  4024. @item linear_contrast
  4025. @item medium_contrast
  4026. @item negative
  4027. @item strong_contrast
  4028. @item vintage
  4029. @end table
  4030. Default is @code{none}.
  4031. @item master, m
  4032. Set the master key points. These points will define a second pass mapping. It
  4033. is sometimes called a "luminance" or "value" mapping. It can be used with
  4034. @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
  4035. post-processing LUT.
  4036. @item red, r
  4037. Set the key points for the red component.
  4038. @item green, g
  4039. Set the key points for the green component.
  4040. @item blue, b
  4041. Set the key points for the blue component.
  4042. @item all
  4043. Set the key points for all components (not including master).
  4044. Can be used in addition to the other key points component
  4045. options. In this case, the unset component(s) will fallback on this
  4046. @option{all} setting.
  4047. @item psfile
  4048. Specify a Photoshop curves file (@code{.acv}) to import the settings from.
  4049. @end table
  4050. To avoid some filtergraph syntax conflicts, each key points list need to be
  4051. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  4052. @subsection Examples
  4053. @itemize
  4054. @item
  4055. Increase slightly the middle level of blue:
  4056. @example
  4057. curves=blue='0.5/0.58'
  4058. @end example
  4059. @item
  4060. Vintage effect:
  4061. @example
  4062. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  4063. @end example
  4064. Here we obtain the following coordinates for each components:
  4065. @table @var
  4066. @item red
  4067. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  4068. @item green
  4069. @code{(0;0) (0.50;0.48) (1;1)}
  4070. @item blue
  4071. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  4072. @end table
  4073. @item
  4074. The previous example can also be achieved with the associated built-in preset:
  4075. @example
  4076. curves=preset=vintage
  4077. @end example
  4078. @item
  4079. Or simply:
  4080. @example
  4081. curves=vintage
  4082. @end example
  4083. @item
  4084. Use a Photoshop preset and redefine the points of the green component:
  4085. @example
  4086. curves=psfile='MyCurvesPresets/purple.acv':green='0.45/0.53'
  4087. @end example
  4088. @end itemize
  4089. @section datascope
  4090. Video data analysis filter.
  4091. This filter shows hexadecimal pixel values of part of video.
  4092. The filter accepts the following options:
  4093. @table @option
  4094. @item size, s
  4095. Set output video size.
  4096. @item x
  4097. Set x offset from where to pick pixels.
  4098. @item y
  4099. Set y offset from where to pick pixels.
  4100. @item mode
  4101. Set scope mode, can be one of the following:
  4102. @table @samp
  4103. @item mono
  4104. Draw hexadecimal pixel values with white color on black background.
  4105. @item color
  4106. Draw hexadecimal pixel values with input video pixel color on black
  4107. background.
  4108. @item color2
  4109. Draw hexadecimal pixel values on color background picked from input video,
  4110. the text color is picked in such way so its always visible.
  4111. @end table
  4112. @item axis
  4113. Draw rows and columns numbers on left and top of video.
  4114. @end table
  4115. @section dctdnoiz
  4116. Denoise frames using 2D DCT (frequency domain filtering).
  4117. This filter is not designed for real time.
  4118. The filter accepts the following options:
  4119. @table @option
  4120. @item sigma, s
  4121. Set the noise sigma constant.
  4122. This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
  4123. coefficient (absolute value) below this threshold with be dropped.
  4124. If you need a more advanced filtering, see @option{expr}.
  4125. Default is @code{0}.
  4126. @item overlap
  4127. Set number overlapping pixels for each block. Since the filter can be slow, you
  4128. may want to reduce this value, at the cost of a less effective filter and the
  4129. risk of various artefacts.
  4130. If the overlapping value doesn't permit processing the whole input width or
  4131. height, a warning will be displayed and according borders won't be denoised.
  4132. Default value is @var{blocksize}-1, which is the best possible setting.
  4133. @item expr, e
  4134. Set the coefficient factor expression.
  4135. For each coefficient of a DCT block, this expression will be evaluated as a
  4136. multiplier value for the coefficient.
  4137. If this is option is set, the @option{sigma} option will be ignored.
  4138. The absolute value of the coefficient can be accessed through the @var{c}
  4139. variable.
  4140. @item n
  4141. Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
  4142. @var{blocksize}, which is the width and height of the processed blocks.
  4143. The default value is @var{3} (8x8) and can be raised to @var{4} for a
  4144. @var{blocksize} of 16x16. Note that changing this setting has huge consequences
  4145. on the speed processing. Also, a larger block size does not necessarily means a
  4146. better de-noising.
  4147. @end table
  4148. @subsection Examples
  4149. Apply a denoise with a @option{sigma} of @code{4.5}:
  4150. @example
  4151. dctdnoiz=4.5
  4152. @end example
  4153. The same operation can be achieved using the expression system:
  4154. @example
  4155. dctdnoiz=e='gte(c, 4.5*3)'
  4156. @end example
  4157. Violent denoise using a block size of @code{16x16}:
  4158. @example
  4159. dctdnoiz=15:n=4
  4160. @end example
  4161. @section deband
  4162. Remove banding artifacts from input video.
  4163. It works by replacing banded pixels with average value of referenced pixels.
  4164. The filter accepts the following options:
  4165. @table @option
  4166. @item 1thr
  4167. @item 2thr
  4168. @item 3thr
  4169. @item 4thr
  4170. Set banding detection threshold for each plane. Default is 0.02.
  4171. Valid range is 0.00003 to 0.5.
  4172. If difference between current pixel and reference pixel is less than threshold,
  4173. it will be considered as banded.
  4174. @item range, r
  4175. Banding detection range in pixels. Default is 16. If positive, random number
  4176. in range 0 to set value will be used. If negative, exact absolute value
  4177. will be used.
  4178. The range defines square of four pixels around current pixel.
  4179. @item direction, d
  4180. Set direction in radians from which four pixel will be compared. If positive,
  4181. random direction from 0 to set direction will be picked. If negative, exact of
  4182. absolute value will be picked. For example direction 0, -PI or -2*PI radians
  4183. will pick only pixels on same row and -PI/2 will pick only pixels on same
  4184. column.
  4185. @item blur
  4186. If enabled, current pixel is compared with average value of all four
  4187. surrounding pixels. The default is enabled. If disabled current pixel is
  4188. compared with all four surrounding pixels. The pixel is considered banded
  4189. if only all four differences with surrounding pixels are less than threshold.
  4190. @end table
  4191. @anchor{decimate}
  4192. @section decimate
  4193. Drop duplicated frames at regular intervals.
  4194. The filter accepts the following options:
  4195. @table @option
  4196. @item cycle
  4197. Set the number of frames from which one will be dropped. Setting this to
  4198. @var{N} means one frame in every batch of @var{N} frames will be dropped.
  4199. Default is @code{5}.
  4200. @item dupthresh
  4201. Set the threshold for duplicate detection. If the difference metric for a frame
  4202. is less than or equal to this value, then it is declared as duplicate. Default
  4203. is @code{1.1}
  4204. @item scthresh
  4205. Set scene change threshold. Default is @code{15}.
  4206. @item blockx
  4207. @item blocky
  4208. Set the size of the x and y-axis blocks used during metric calculations.
  4209. Larger blocks give better noise suppression, but also give worse detection of
  4210. small movements. Must be a power of two. Default is @code{32}.
  4211. @item ppsrc
  4212. Mark main input as a pre-processed input and activate clean source input
  4213. stream. This allows the input to be pre-processed with various filters to help
  4214. the metrics calculation while keeping the frame selection lossless. When set to
  4215. @code{1}, the first stream is for the pre-processed input, and the second
  4216. stream is the clean source from where the kept frames are chosen. Default is
  4217. @code{0}.
  4218. @item chroma
  4219. Set whether or not chroma is considered in the metric calculations. Default is
  4220. @code{1}.
  4221. @end table
  4222. @section deflate
  4223. Apply deflate effect to the video.
  4224. This filter replaces the pixel by the local(3x3) average by taking into account
  4225. only values lower than the pixel.
  4226. It accepts the following options:
  4227. @table @option
  4228. @item threshold0
  4229. @item threshold1
  4230. @item threshold2
  4231. @item threshold3
  4232. Limit the maximum change for each plane, default is 65535.
  4233. If 0, plane will remain unchanged.
  4234. @end table
  4235. @section dejudder
  4236. Remove judder produced by partially interlaced telecined content.
  4237. Judder can be introduced, for instance, by @ref{pullup} filter. If the original
  4238. source was partially telecined content then the output of @code{pullup,dejudder}
  4239. will have a variable frame rate. May change the recorded frame rate of the
  4240. container. Aside from that change, this filter will not affect constant frame
  4241. rate video.
  4242. The option available in this filter is:
  4243. @table @option
  4244. @item cycle
  4245. Specify the length of the window over which the judder repeats.
  4246. Accepts any integer greater than 1. Useful values are:
  4247. @table @samp
  4248. @item 4
  4249. If the original was telecined from 24 to 30 fps (Film to NTSC).
  4250. @item 5
  4251. If the original was telecined from 25 to 30 fps (PAL to NTSC).
  4252. @item 20
  4253. If a mixture of the two.
  4254. @end table
  4255. The default is @samp{4}.
  4256. @end table
  4257. @section delogo
  4258. Suppress a TV station logo by a simple interpolation of the surrounding
  4259. pixels. Just set a rectangle covering the logo and watch it disappear
  4260. (and sometimes something even uglier appear - your mileage may vary).
  4261. It accepts the following parameters:
  4262. @table @option
  4263. @item x
  4264. @item y
  4265. Specify the top left corner coordinates of the logo. They must be
  4266. specified.
  4267. @item w
  4268. @item h
  4269. Specify the width and height of the logo to clear. They must be
  4270. specified.
  4271. @item band, t
  4272. Specify the thickness of the fuzzy edge of the rectangle (added to
  4273. @var{w} and @var{h}). The default value is 1. This option is
  4274. deprecated, setting higher values should no longer be necessary and
  4275. is not recommended.
  4276. @item show
  4277. When set to 1, a green rectangle is drawn on the screen to simplify
  4278. finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
  4279. The default value is 0.
  4280. The rectangle is drawn on the outermost pixels which will be (partly)
  4281. replaced with interpolated values. The values of the next pixels
  4282. immediately outside this rectangle in each direction will be used to
  4283. compute the interpolated pixel values inside the rectangle.
  4284. @end table
  4285. @subsection Examples
  4286. @itemize
  4287. @item
  4288. Set a rectangle covering the area with top left corner coordinates 0,0
  4289. and size 100x77, and a band of size 10:
  4290. @example
  4291. delogo=x=0:y=0:w=100:h=77:band=10
  4292. @end example
  4293. @end itemize
  4294. @section deshake
  4295. Attempt to fix small changes in horizontal and/or vertical shift. This
  4296. filter helps remove camera shake from hand-holding a camera, bumping a
  4297. tripod, moving on a vehicle, etc.
  4298. The filter accepts the following options:
  4299. @table @option
  4300. @item x
  4301. @item y
  4302. @item w
  4303. @item h
  4304. Specify a rectangular area where to limit the search for motion
  4305. vectors.
  4306. If desired the search for motion vectors can be limited to a
  4307. rectangular area of the frame defined by its top left corner, width
  4308. and height. These parameters have the same meaning as the drawbox
  4309. filter which can be used to visualise the position of the bounding
  4310. box.
  4311. This is useful when simultaneous movement of subjects within the frame
  4312. might be confused for camera motion by the motion vector search.
  4313. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  4314. then the full frame is used. This allows later options to be set
  4315. without specifying the bounding box for the motion vector search.
  4316. Default - search the whole frame.
  4317. @item rx
  4318. @item ry
  4319. Specify the maximum extent of movement in x and y directions in the
  4320. range 0-64 pixels. Default 16.
  4321. @item edge
  4322. Specify how to generate pixels to fill blanks at the edge of the
  4323. frame. Available values are:
  4324. @table @samp
  4325. @item blank, 0
  4326. Fill zeroes at blank locations
  4327. @item original, 1
  4328. Original image at blank locations
  4329. @item clamp, 2
  4330. Extruded edge value at blank locations
  4331. @item mirror, 3
  4332. Mirrored edge at blank locations
  4333. @end table
  4334. Default value is @samp{mirror}.
  4335. @item blocksize
  4336. Specify the blocksize to use for motion search. Range 4-128 pixels,
  4337. default 8.
  4338. @item contrast
  4339. Specify the contrast threshold for blocks. Only blocks with more than
  4340. the specified contrast (difference between darkest and lightest
  4341. pixels) will be considered. Range 1-255, default 125.
  4342. @item search
  4343. Specify the search strategy. Available values are:
  4344. @table @samp
  4345. @item exhaustive, 0
  4346. Set exhaustive search
  4347. @item less, 1
  4348. Set less exhaustive search.
  4349. @end table
  4350. Default value is @samp{exhaustive}.
  4351. @item filename
  4352. If set then a detailed log of the motion search is written to the
  4353. specified file.
  4354. @item opencl
  4355. If set to 1, specify using OpenCL capabilities, only available if
  4356. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  4357. @end table
  4358. @section detelecine
  4359. Apply an exact inverse of the telecine operation. It requires a predefined
  4360. pattern specified using the pattern option which must be the same as that passed
  4361. to the telecine filter.
  4362. This filter accepts the following options:
  4363. @table @option
  4364. @item first_field
  4365. @table @samp
  4366. @item top, t
  4367. top field first
  4368. @item bottom, b
  4369. bottom field first
  4370. The default value is @code{top}.
  4371. @end table
  4372. @item pattern
  4373. A string of numbers representing the pulldown pattern you wish to apply.
  4374. The default value is @code{23}.
  4375. @item start_frame
  4376. A number representing position of the first frame with respect to the telecine
  4377. pattern. This is to be used if the stream is cut. The default value is @code{0}.
  4378. @end table
  4379. @section dilation
  4380. Apply dilation effect to the video.
  4381. This filter replaces the pixel by the local(3x3) maximum.
  4382. It accepts the following options:
  4383. @table @option
  4384. @item threshold0
  4385. @item threshold1
  4386. @item threshold2
  4387. @item threshold3
  4388. Limit the maximum change for each plane, default is 65535.
  4389. If 0, plane will remain unchanged.
  4390. @item coordinates
  4391. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  4392. pixels are used.
  4393. Flags to local 3x3 coordinates maps like this:
  4394. 1 2 3
  4395. 4 5
  4396. 6 7 8
  4397. @end table
  4398. @section displace
  4399. Displace pixels as indicated by second and third input stream.
  4400. It takes three input streams and outputs one stream, the first input is the
  4401. source, and second and third input are displacement maps.
  4402. The second input specifies how much to displace pixels along the
  4403. x-axis, while the third input specifies how much to displace pixels
  4404. along the y-axis.
  4405. If one of displacement map streams terminates, last frame from that
  4406. displacement map will be used.
  4407. Note that once generated, displacements maps can be reused over and over again.
  4408. A description of the accepted options follows.
  4409. @table @option
  4410. @item edge
  4411. Set displace behavior for pixels that are out of range.
  4412. Available values are:
  4413. @table @samp
  4414. @item blank
  4415. Missing pixels are replaced by black pixels.
  4416. @item smear
  4417. Adjacent pixels will spread out to replace missing pixels.
  4418. @item wrap
  4419. Out of range pixels are wrapped so they point to pixels of other side.
  4420. @end table
  4421. Default is @samp{smear}.
  4422. @end table
  4423. @subsection Examples
  4424. @itemize
  4425. @item
  4426. Add ripple effect to rgb input of video size hd720:
  4427. @example
  4428. 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
  4429. @end example
  4430. @item
  4431. Add wave effect to rgb input of video size hd720:
  4432. @example
  4433. 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
  4434. @end example
  4435. @end itemize
  4436. @section drawbox
  4437. Draw a colored box on the input image.
  4438. It accepts the following parameters:
  4439. @table @option
  4440. @item x
  4441. @item y
  4442. The expressions which specify the top left corner coordinates of the box. It defaults to 0.
  4443. @item width, w
  4444. @item height, h
  4445. The expressions which specify the width and height of the box; if 0 they are interpreted as
  4446. the input width and height. It defaults to 0.
  4447. @item color, c
  4448. Specify the color of the box to write. For the general syntax of this option,
  4449. check the "Color" section in the ffmpeg-utils manual. If the special
  4450. value @code{invert} is used, the box edge color is the same as the
  4451. video with inverted luma.
  4452. @item thickness, t
  4453. The expression which sets the thickness of the box edge. Default value is @code{3}.
  4454. See below for the list of accepted constants.
  4455. @end table
  4456. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  4457. following constants:
  4458. @table @option
  4459. @item dar
  4460. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  4461. @item hsub
  4462. @item vsub
  4463. horizontal and vertical chroma subsample values. For example for the
  4464. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4465. @item in_h, ih
  4466. @item in_w, iw
  4467. The input width and height.
  4468. @item sar
  4469. The input sample aspect ratio.
  4470. @item x
  4471. @item y
  4472. The x and y offset coordinates where the box is drawn.
  4473. @item w
  4474. @item h
  4475. The width and height of the drawn box.
  4476. @item t
  4477. The thickness of the drawn box.
  4478. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  4479. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  4480. @end table
  4481. @subsection Examples
  4482. @itemize
  4483. @item
  4484. Draw a black box around the edge of the input image:
  4485. @example
  4486. drawbox
  4487. @end example
  4488. @item
  4489. Draw a box with color red and an opacity of 50%:
  4490. @example
  4491. drawbox=10:20:200:60:red@@0.5
  4492. @end example
  4493. The previous example can be specified as:
  4494. @example
  4495. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  4496. @end example
  4497. @item
  4498. Fill the box with pink color:
  4499. @example
  4500. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  4501. @end example
  4502. @item
  4503. Draw a 2-pixel red 2.40:1 mask:
  4504. @example
  4505. 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
  4506. @end example
  4507. @end itemize
  4508. @section drawgraph, adrawgraph
  4509. Draw a graph using input video or audio metadata.
  4510. It accepts the following parameters:
  4511. @table @option
  4512. @item m1
  4513. Set 1st frame metadata key from which metadata values will be used to draw a graph.
  4514. @item fg1
  4515. Set 1st foreground color expression.
  4516. @item m2
  4517. Set 2nd frame metadata key from which metadata values will be used to draw a graph.
  4518. @item fg2
  4519. Set 2nd foreground color expression.
  4520. @item m3
  4521. Set 3rd frame metadata key from which metadata values will be used to draw a graph.
  4522. @item fg3
  4523. Set 3rd foreground color expression.
  4524. @item m4
  4525. Set 4th frame metadata key from which metadata values will be used to draw a graph.
  4526. @item fg4
  4527. Set 4th foreground color expression.
  4528. @item min
  4529. Set minimal value of metadata value.
  4530. @item max
  4531. Set maximal value of metadata value.
  4532. @item bg
  4533. Set graph background color. Default is white.
  4534. @item mode
  4535. Set graph mode.
  4536. Available values for mode is:
  4537. @table @samp
  4538. @item bar
  4539. @item dot
  4540. @item line
  4541. @end table
  4542. Default is @code{line}.
  4543. @item slide
  4544. Set slide mode.
  4545. Available values for slide is:
  4546. @table @samp
  4547. @item frame
  4548. Draw new frame when right border is reached.
  4549. @item replace
  4550. Replace old columns with new ones.
  4551. @item scroll
  4552. Scroll from right to left.
  4553. @item rscroll
  4554. Scroll from left to right.
  4555. @end table
  4556. Default is @code{frame}.
  4557. @item size
  4558. Set size of graph video. For the syntax of this option, check the
  4559. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  4560. The default value is @code{900x256}.
  4561. The foreground color expressions can use the following variables:
  4562. @table @option
  4563. @item MIN
  4564. Minimal value of metadata value.
  4565. @item MAX
  4566. Maximal value of metadata value.
  4567. @item VAL
  4568. Current metadata key value.
  4569. @end table
  4570. The color is defined as 0xAABBGGRR.
  4571. @end table
  4572. Example using metadata from @ref{signalstats} filter:
  4573. @example
  4574. signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255
  4575. @end example
  4576. Example using metadata from @ref{ebur128} filter:
  4577. @example
  4578. ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5
  4579. @end example
  4580. @section drawgrid
  4581. Draw a grid on the input image.
  4582. It accepts the following parameters:
  4583. @table @option
  4584. @item x
  4585. @item y
  4586. The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
  4587. @item width, w
  4588. @item height, h
  4589. The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
  4590. input width and height, respectively, minus @code{thickness}, so image gets
  4591. framed. Default to 0.
  4592. @item color, c
  4593. Specify the color of the grid. For the general syntax of this option,
  4594. check the "Color" section in the ffmpeg-utils manual. If the special
  4595. value @code{invert} is used, the grid color is the same as the
  4596. video with inverted luma.
  4597. @item thickness, t
  4598. The expression which sets the thickness of the grid line. Default value is @code{1}.
  4599. See below for the list of accepted constants.
  4600. @end table
  4601. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  4602. following constants:
  4603. @table @option
  4604. @item dar
  4605. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  4606. @item hsub
  4607. @item vsub
  4608. horizontal and vertical chroma subsample values. For example for the
  4609. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4610. @item in_h, ih
  4611. @item in_w, iw
  4612. The input grid cell width and height.
  4613. @item sar
  4614. The input sample aspect ratio.
  4615. @item x
  4616. @item y
  4617. The x and y coordinates of some point of grid intersection (meant to configure offset).
  4618. @item w
  4619. @item h
  4620. The width and height of the drawn cell.
  4621. @item t
  4622. The thickness of the drawn cell.
  4623. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  4624. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  4625. @end table
  4626. @subsection Examples
  4627. @itemize
  4628. @item
  4629. Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
  4630. @example
  4631. drawgrid=width=100:height=100:thickness=2:color=red@@0.5
  4632. @end example
  4633. @item
  4634. Draw a white 3x3 grid with an opacity of 50%:
  4635. @example
  4636. drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
  4637. @end example
  4638. @end itemize
  4639. @anchor{drawtext}
  4640. @section drawtext
  4641. Draw a text string or text from a specified file on top of a video, using the
  4642. libfreetype library.
  4643. To enable compilation of this filter, you need to configure FFmpeg with
  4644. @code{--enable-libfreetype}.
  4645. To enable default font fallback and the @var{font} option you need to
  4646. configure FFmpeg with @code{--enable-libfontconfig}.
  4647. To enable the @var{text_shaping} option, you need to configure FFmpeg with
  4648. @code{--enable-libfribidi}.
  4649. @subsection Syntax
  4650. It accepts the following parameters:
  4651. @table @option
  4652. @item box
  4653. Used to draw a box around text using the background color.
  4654. The value must be either 1 (enable) or 0 (disable).
  4655. The default value of @var{box} is 0.
  4656. @item boxborderw
  4657. Set the width of the border to be drawn around the box using @var{boxcolor}.
  4658. The default value of @var{boxborderw} is 0.
  4659. @item boxcolor
  4660. The color to be used for drawing box around text. For the syntax of this
  4661. option, check the "Color" section in the ffmpeg-utils manual.
  4662. The default value of @var{boxcolor} is "white".
  4663. @item borderw
  4664. Set the width of the border to be drawn around the text using @var{bordercolor}.
  4665. The default value of @var{borderw} is 0.
  4666. @item bordercolor
  4667. Set the color to be used for drawing border around text. For the syntax of this
  4668. option, check the "Color" section in the ffmpeg-utils manual.
  4669. The default value of @var{bordercolor} is "black".
  4670. @item expansion
  4671. Select how the @var{text} is expanded. Can be either @code{none},
  4672. @code{strftime} (deprecated) or
  4673. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  4674. below for details.
  4675. @item fix_bounds
  4676. If true, check and fix text coords to avoid clipping.
  4677. @item fontcolor
  4678. The color to be used for drawing fonts. For the syntax of this option, check
  4679. the "Color" section in the ffmpeg-utils manual.
  4680. The default value of @var{fontcolor} is "black".
  4681. @item fontcolor_expr
  4682. String which is expanded the same way as @var{text} to obtain dynamic
  4683. @var{fontcolor} value. By default this option has empty value and is not
  4684. processed. When this option is set, it overrides @var{fontcolor} option.
  4685. @item font
  4686. The font family to be used for drawing text. By default Sans.
  4687. @item fontfile
  4688. The font file to be used for drawing text. The path must be included.
  4689. This parameter is mandatory if the fontconfig support is disabled.
  4690. @item draw
  4691. This option does not exist, please see the timeline system
  4692. @item alpha
  4693. Draw the text applying alpha blending. The value can
  4694. be either a number between 0.0 and 1.0
  4695. The expression accepts the same variables @var{x, y} do.
  4696. The default value is 1.
  4697. Please see fontcolor_expr
  4698. @item fontsize
  4699. The font size to be used for drawing text.
  4700. The default value of @var{fontsize} is 16.
  4701. @item text_shaping
  4702. If set to 1, attempt to shape the text (for example, reverse the order of
  4703. right-to-left text and join Arabic characters) before drawing it.
  4704. Otherwise, just draw the text exactly as given.
  4705. By default 1 (if supported).
  4706. @item ft_load_flags
  4707. The flags to be used for loading the fonts.
  4708. The flags map the corresponding flags supported by libfreetype, and are
  4709. a combination of the following values:
  4710. @table @var
  4711. @item default
  4712. @item no_scale
  4713. @item no_hinting
  4714. @item render
  4715. @item no_bitmap
  4716. @item vertical_layout
  4717. @item force_autohint
  4718. @item crop_bitmap
  4719. @item pedantic
  4720. @item ignore_global_advance_width
  4721. @item no_recurse
  4722. @item ignore_transform
  4723. @item monochrome
  4724. @item linear_design
  4725. @item no_autohint
  4726. @end table
  4727. Default value is "default".
  4728. For more information consult the documentation for the FT_LOAD_*
  4729. libfreetype flags.
  4730. @item shadowcolor
  4731. The color to be used for drawing a shadow behind the drawn text. For the
  4732. syntax of this option, check the "Color" section in the ffmpeg-utils manual.
  4733. The default value of @var{shadowcolor} is "black".
  4734. @item shadowx
  4735. @item shadowy
  4736. The x and y offsets for the text shadow position with respect to the
  4737. position of the text. They can be either positive or negative
  4738. values. The default value for both is "0".
  4739. @item start_number
  4740. The starting frame number for the n/frame_num variable. The default value
  4741. is "0".
  4742. @item tabsize
  4743. The size in number of spaces to use for rendering the tab.
  4744. Default value is 4.
  4745. @item timecode
  4746. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  4747. format. It can be used with or without text parameter. @var{timecode_rate}
  4748. option must be specified.
  4749. @item timecode_rate, rate, r
  4750. Set the timecode frame rate (timecode only).
  4751. @item text
  4752. The text string to be drawn. The text must be a sequence of UTF-8
  4753. encoded characters.
  4754. This parameter is mandatory if no file is specified with the parameter
  4755. @var{textfile}.
  4756. @item textfile
  4757. A text file containing text to be drawn. The text must be a sequence
  4758. of UTF-8 encoded characters.
  4759. This parameter is mandatory if no text string is specified with the
  4760. parameter @var{text}.
  4761. If both @var{text} and @var{textfile} are specified, an error is thrown.
  4762. @item reload
  4763. If set to 1, the @var{textfile} will be reloaded before each frame.
  4764. Be sure to update it atomically, or it may be read partially, or even fail.
  4765. @item x
  4766. @item y
  4767. The expressions which specify the offsets where text will be drawn
  4768. within the video frame. They are relative to the top/left border of the
  4769. output image.
  4770. The default value of @var{x} and @var{y} is "0".
  4771. See below for the list of accepted constants and functions.
  4772. @end table
  4773. The parameters for @var{x} and @var{y} are expressions containing the
  4774. following constants and functions:
  4775. @table @option
  4776. @item dar
  4777. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  4778. @item hsub
  4779. @item vsub
  4780. horizontal and vertical chroma subsample values. For example for the
  4781. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4782. @item line_h, lh
  4783. the height of each text line
  4784. @item main_h, h, H
  4785. the input height
  4786. @item main_w, w, W
  4787. the input width
  4788. @item max_glyph_a, ascent
  4789. the maximum distance from the baseline to the highest/upper grid
  4790. coordinate used to place a glyph outline point, for all the rendered
  4791. glyphs.
  4792. It is a positive value, due to the grid's orientation with the Y axis
  4793. upwards.
  4794. @item max_glyph_d, descent
  4795. the maximum distance from the baseline to the lowest grid coordinate
  4796. used to place a glyph outline point, for all the rendered glyphs.
  4797. This is a negative value, due to the grid's orientation, with the Y axis
  4798. upwards.
  4799. @item max_glyph_h
  4800. maximum glyph height, that is the maximum height for all the glyphs
  4801. contained in the rendered text, it is equivalent to @var{ascent} -
  4802. @var{descent}.
  4803. @item max_glyph_w
  4804. maximum glyph width, that is the maximum width for all the glyphs
  4805. contained in the rendered text
  4806. @item n
  4807. the number of input frame, starting from 0
  4808. @item rand(min, max)
  4809. return a random number included between @var{min} and @var{max}
  4810. @item sar
  4811. The input sample aspect ratio.
  4812. @item t
  4813. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4814. @item text_h, th
  4815. the height of the rendered text
  4816. @item text_w, tw
  4817. the width of the rendered text
  4818. @item x
  4819. @item y
  4820. the x and y offset coordinates where the text is drawn.
  4821. These parameters allow the @var{x} and @var{y} expressions to refer
  4822. each other, so you can for example specify @code{y=x/dar}.
  4823. @end table
  4824. @anchor{drawtext_expansion}
  4825. @subsection Text expansion
  4826. If @option{expansion} is set to @code{strftime},
  4827. the filter recognizes strftime() sequences in the provided text and
  4828. expands them accordingly. Check the documentation of strftime(). This
  4829. feature is deprecated.
  4830. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  4831. If @option{expansion} is set to @code{normal} (which is the default),
  4832. the following expansion mechanism is used.
  4833. The backslash character @samp{\}, followed by any character, always expands to
  4834. the second character.
  4835. Sequence of the form @code{%@{...@}} are expanded. The text between the
  4836. braces is a function name, possibly followed by arguments separated by ':'.
  4837. If the arguments contain special characters or delimiters (':' or '@}'),
  4838. they should be escaped.
  4839. Note that they probably must also be escaped as the value for the
  4840. @option{text} option in the filter argument string and as the filter
  4841. argument in the filtergraph description, and possibly also for the shell,
  4842. that makes up to four levels of escaping; using a text file avoids these
  4843. problems.
  4844. The following functions are available:
  4845. @table @command
  4846. @item expr, e
  4847. The expression evaluation result.
  4848. It must take one argument specifying the expression to be evaluated,
  4849. which accepts the same constants and functions as the @var{x} and
  4850. @var{y} values. Note that not all constants should be used, for
  4851. example the text size is not known when evaluating the expression, so
  4852. the constants @var{text_w} and @var{text_h} will have an undefined
  4853. value.
  4854. @item expr_int_format, eif
  4855. Evaluate the expression's value and output as formatted integer.
  4856. The first argument is the expression to be evaluated, just as for the @var{expr} function.
  4857. The second argument specifies the output format. Allowed values are @samp{x},
  4858. @samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
  4859. @code{printf} function.
  4860. The third parameter is optional and sets the number of positions taken by the output.
  4861. It can be used to add padding with zeros from the left.
  4862. @item gmtime
  4863. The time at which the filter is running, expressed in UTC.
  4864. It can accept an argument: a strftime() format string.
  4865. @item localtime
  4866. The time at which the filter is running, expressed in the local time zone.
  4867. It can accept an argument: a strftime() format string.
  4868. @item metadata
  4869. Frame metadata. It must take one argument specifying metadata key.
  4870. @item n, frame_num
  4871. The frame number, starting from 0.
  4872. @item pict_type
  4873. A 1 character description of the current picture type.
  4874. @item pts
  4875. The timestamp of the current frame.
  4876. It can take up to three arguments.
  4877. The first argument is the format of the timestamp; it defaults to @code{flt}
  4878. for seconds as a decimal number with microsecond accuracy; @code{hms} stands
  4879. for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
  4880. @code{gmtime} stands for the timestamp of the frame formatted as UTC time;
  4881. @code{localtime} stands for the timestamp of the frame formatted as
  4882. local time zone time.
  4883. The second argument is an offset added to the timestamp.
  4884. If the format is set to @code{localtime} or @code{gmtime},
  4885. a third argument may be supplied: a strftime() format string.
  4886. By default, @var{YYYY-MM-DD HH:MM:SS} format will be used.
  4887. @end table
  4888. @subsection Examples
  4889. @itemize
  4890. @item
  4891. Draw "Test Text" with font FreeSerif, using the default values for the
  4892. optional parameters.
  4893. @example
  4894. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  4895. @end example
  4896. @item
  4897. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  4898. and y=50 (counting from the top-left corner of the screen), text is
  4899. yellow with a red box around it. Both the text and the box have an
  4900. opacity of 20%.
  4901. @example
  4902. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  4903. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  4904. @end example
  4905. Note that the double quotes are not necessary if spaces are not used
  4906. within the parameter list.
  4907. @item
  4908. Show the text at the center of the video frame:
  4909. @example
  4910. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2"
  4911. @end example
  4912. @item
  4913. Show a text line sliding from right to left in the last row of the video
  4914. frame. The file @file{LONG_LINE} is assumed to contain a single line
  4915. with no newlines.
  4916. @example
  4917. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  4918. @end example
  4919. @item
  4920. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  4921. @example
  4922. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  4923. @end example
  4924. @item
  4925. Draw a single green letter "g", at the center of the input video.
  4926. The glyph baseline is placed at half screen height.
  4927. @example
  4928. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  4929. @end example
  4930. @item
  4931. Show text for 1 second every 3 seconds:
  4932. @example
  4933. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  4934. @end example
  4935. @item
  4936. Use fontconfig to set the font. Note that the colons need to be escaped.
  4937. @example
  4938. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  4939. @end example
  4940. @item
  4941. Print the date of a real-time encoding (see strftime(3)):
  4942. @example
  4943. drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
  4944. @end example
  4945. @item
  4946. Show text fading in and out (appearing/disappearing):
  4947. @example
  4948. #!/bin/sh
  4949. DS=1.0 # display start
  4950. DE=10.0 # display end
  4951. FID=1.5 # fade in duration
  4952. FOD=5 # fade out duration
  4953. 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 @}"
  4954. @end example
  4955. @end itemize
  4956. For more information about libfreetype, check:
  4957. @url{http://www.freetype.org/}.
  4958. For more information about fontconfig, check:
  4959. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  4960. For more information about libfribidi, check:
  4961. @url{http://fribidi.org/}.
  4962. @section edgedetect
  4963. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  4964. The filter accepts the following options:
  4965. @table @option
  4966. @item low
  4967. @item high
  4968. Set low and high threshold values used by the Canny thresholding
  4969. algorithm.
  4970. The high threshold selects the "strong" edge pixels, which are then
  4971. connected through 8-connectivity with the "weak" edge pixels selected
  4972. by the low threshold.
  4973. @var{low} and @var{high} threshold values must be chosen in the range
  4974. [0,1], and @var{low} should be lesser or equal to @var{high}.
  4975. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  4976. is @code{50/255}.
  4977. @item mode
  4978. Define the drawing mode.
  4979. @table @samp
  4980. @item wires
  4981. Draw white/gray wires on black background.
  4982. @item colormix
  4983. Mix the colors to create a paint/cartoon effect.
  4984. @end table
  4985. Default value is @var{wires}.
  4986. @end table
  4987. @subsection Examples
  4988. @itemize
  4989. @item
  4990. Standard edge detection with custom values for the hysteresis thresholding:
  4991. @example
  4992. edgedetect=low=0.1:high=0.4
  4993. @end example
  4994. @item
  4995. Painting effect without thresholding:
  4996. @example
  4997. edgedetect=mode=colormix:high=0
  4998. @end example
  4999. @end itemize
  5000. @section eq
  5001. Set brightness, contrast, saturation and approximate gamma adjustment.
  5002. The filter accepts the following options:
  5003. @table @option
  5004. @item contrast
  5005. Set the contrast expression. The value must be a float value in range
  5006. @code{-2.0} to @code{2.0}. The default value is "1".
  5007. @item brightness
  5008. Set the brightness expression. The value must be a float value in
  5009. range @code{-1.0} to @code{1.0}. The default value is "0".
  5010. @item saturation
  5011. Set the saturation expression. The value must be a float in
  5012. range @code{0.0} to @code{3.0}. The default value is "1".
  5013. @item gamma
  5014. Set the gamma expression. The value must be a float in range
  5015. @code{0.1} to @code{10.0}. The default value is "1".
  5016. @item gamma_r
  5017. Set the gamma expression for red. The value must be a float in
  5018. range @code{0.1} to @code{10.0}. The default value is "1".
  5019. @item gamma_g
  5020. Set the gamma expression for green. The value must be a float in range
  5021. @code{0.1} to @code{10.0}. The default value is "1".
  5022. @item gamma_b
  5023. Set the gamma expression for blue. The value must be a float in range
  5024. @code{0.1} to @code{10.0}. The default value is "1".
  5025. @item gamma_weight
  5026. Set the gamma weight expression. It can be used to reduce the effect
  5027. of a high gamma value on bright image areas, e.g. keep them from
  5028. getting overamplified and just plain white. The value must be a float
  5029. in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
  5030. gamma correction all the way down while @code{1.0} leaves it at its
  5031. full strength. Default is "1".
  5032. @item eval
  5033. Set when the expressions for brightness, contrast, saturation and
  5034. gamma expressions are evaluated.
  5035. It accepts the following values:
  5036. @table @samp
  5037. @item init
  5038. only evaluate expressions once during the filter initialization or
  5039. when a command is processed
  5040. @item frame
  5041. evaluate expressions for each incoming frame
  5042. @end table
  5043. Default value is @samp{init}.
  5044. @end table
  5045. The expressions accept the following parameters:
  5046. @table @option
  5047. @item n
  5048. frame count of the input frame starting from 0
  5049. @item pos
  5050. byte position of the corresponding packet in the input file, NAN if
  5051. unspecified
  5052. @item r
  5053. frame rate of the input video, NAN if the input frame rate is unknown
  5054. @item t
  5055. timestamp expressed in seconds, NAN if the input timestamp is unknown
  5056. @end table
  5057. @subsection Commands
  5058. The filter supports the following commands:
  5059. @table @option
  5060. @item contrast
  5061. Set the contrast expression.
  5062. @item brightness
  5063. Set the brightness expression.
  5064. @item saturation
  5065. Set the saturation expression.
  5066. @item gamma
  5067. Set the gamma expression.
  5068. @item gamma_r
  5069. Set the gamma_r expression.
  5070. @item gamma_g
  5071. Set gamma_g expression.
  5072. @item gamma_b
  5073. Set gamma_b expression.
  5074. @item gamma_weight
  5075. Set gamma_weight expression.
  5076. The command accepts the same syntax of the corresponding option.
  5077. If the specified expression is not valid, it is kept at its current
  5078. value.
  5079. @end table
  5080. @section erosion
  5081. Apply erosion effect to the video.
  5082. This filter replaces the pixel by the local(3x3) minimum.
  5083. It accepts the following options:
  5084. @table @option
  5085. @item threshold0
  5086. @item threshold1
  5087. @item threshold2
  5088. @item threshold3
  5089. Limit the maximum change for each plane, default is 65535.
  5090. If 0, plane will remain unchanged.
  5091. @item coordinates
  5092. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  5093. pixels are used.
  5094. Flags to local 3x3 coordinates maps like this:
  5095. 1 2 3
  5096. 4 5
  5097. 6 7 8
  5098. @end table
  5099. @section extractplanes
  5100. Extract color channel components from input video stream into
  5101. separate grayscale video streams.
  5102. The filter accepts the following option:
  5103. @table @option
  5104. @item planes
  5105. Set plane(s) to extract.
  5106. Available values for planes are:
  5107. @table @samp
  5108. @item y
  5109. @item u
  5110. @item v
  5111. @item a
  5112. @item r
  5113. @item g
  5114. @item b
  5115. @end table
  5116. Choosing planes not available in the input will result in an error.
  5117. That means you cannot select @code{r}, @code{g}, @code{b} planes
  5118. with @code{y}, @code{u}, @code{v} planes at same time.
  5119. @end table
  5120. @subsection Examples
  5121. @itemize
  5122. @item
  5123. Extract luma, u and v color channel component from input video frame
  5124. into 3 grayscale outputs:
  5125. @example
  5126. 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
  5127. @end example
  5128. @end itemize
  5129. @section elbg
  5130. Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
  5131. For each input image, the filter will compute the optimal mapping from
  5132. the input to the output given the codebook length, that is the number
  5133. of distinct output colors.
  5134. This filter accepts the following options.
  5135. @table @option
  5136. @item codebook_length, l
  5137. Set codebook length. The value must be a positive integer, and
  5138. represents the number of distinct output colors. Default value is 256.
  5139. @item nb_steps, n
  5140. Set the maximum number of iterations to apply for computing the optimal
  5141. mapping. The higher the value the better the result and the higher the
  5142. computation time. Default value is 1.
  5143. @item seed, s
  5144. Set a random seed, must be an integer included between 0 and
  5145. UINT32_MAX. If not specified, or if explicitly set to -1, the filter
  5146. will try to use a good random seed on a best effort basis.
  5147. @item pal8
  5148. Set pal8 output pixel format. This option does not work with codebook
  5149. length greater than 256.
  5150. @end table
  5151. @section fade
  5152. Apply a fade-in/out effect to the input video.
  5153. It accepts the following parameters:
  5154. @table @option
  5155. @item type, t
  5156. The effect type can be either "in" for a fade-in, or "out" for a fade-out
  5157. effect.
  5158. Default is @code{in}.
  5159. @item start_frame, s
  5160. Specify the number of the frame to start applying the fade
  5161. effect at. Default is 0.
  5162. @item nb_frames, n
  5163. The number of frames that the fade effect lasts. At the end of the
  5164. fade-in effect, the output video will have the same intensity as the input video.
  5165. At the end of the fade-out transition, the output video will be filled with the
  5166. selected @option{color}.
  5167. Default is 25.
  5168. @item alpha
  5169. If set to 1, fade only alpha channel, if one exists on the input.
  5170. Default value is 0.
  5171. @item start_time, st
  5172. Specify the timestamp (in seconds) of the frame to start to apply the fade
  5173. effect. If both start_frame and start_time are specified, the fade will start at
  5174. whichever comes last. Default is 0.
  5175. @item duration, d
  5176. The number of seconds for which the fade effect has to last. At the end of the
  5177. fade-in effect the output video will have the same intensity as the input video,
  5178. at the end of the fade-out transition the output video will be filled with the
  5179. selected @option{color}.
  5180. If both duration and nb_frames are specified, duration is used. Default is 0
  5181. (nb_frames is used by default).
  5182. @item color, c
  5183. Specify the color of the fade. Default is "black".
  5184. @end table
  5185. @subsection Examples
  5186. @itemize
  5187. @item
  5188. Fade in the first 30 frames of video:
  5189. @example
  5190. fade=in:0:30
  5191. @end example
  5192. The command above is equivalent to:
  5193. @example
  5194. fade=t=in:s=0:n=30
  5195. @end example
  5196. @item
  5197. Fade out the last 45 frames of a 200-frame video:
  5198. @example
  5199. fade=out:155:45
  5200. fade=type=out:start_frame=155:nb_frames=45
  5201. @end example
  5202. @item
  5203. Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
  5204. @example
  5205. fade=in:0:25, fade=out:975:25
  5206. @end example
  5207. @item
  5208. Make the first 5 frames yellow, then fade in from frame 5-24:
  5209. @example
  5210. fade=in:5:20:color=yellow
  5211. @end example
  5212. @item
  5213. Fade in alpha over first 25 frames of video:
  5214. @example
  5215. fade=in:0:25:alpha=1
  5216. @end example
  5217. @item
  5218. Make the first 5.5 seconds black, then fade in for 0.5 seconds:
  5219. @example
  5220. fade=t=in:st=5.5:d=0.5
  5221. @end example
  5222. @end itemize
  5223. @section fftfilt
  5224. Apply arbitrary expressions to samples in frequency domain
  5225. @table @option
  5226. @item dc_Y
  5227. Adjust the dc value (gain) of the luma plane of the image. The filter
  5228. accepts an integer value in range @code{0} to @code{1000}. The default
  5229. value is set to @code{0}.
  5230. @item dc_U
  5231. Adjust the dc value (gain) of the 1st chroma plane of the image. The
  5232. filter accepts an integer value in range @code{0} to @code{1000}. The
  5233. default value is set to @code{0}.
  5234. @item dc_V
  5235. Adjust the dc value (gain) of the 2nd chroma plane of the image. The
  5236. filter accepts an integer value in range @code{0} to @code{1000}. The
  5237. default value is set to @code{0}.
  5238. @item weight_Y
  5239. Set the frequency domain weight expression for the luma plane.
  5240. @item weight_U
  5241. Set the frequency domain weight expression for the 1st chroma plane.
  5242. @item weight_V
  5243. Set the frequency domain weight expression for the 2nd chroma plane.
  5244. The filter accepts the following variables:
  5245. @item X
  5246. @item Y
  5247. The coordinates of the current sample.
  5248. @item W
  5249. @item H
  5250. The width and height of the image.
  5251. @end table
  5252. @subsection Examples
  5253. @itemize
  5254. @item
  5255. High-pass:
  5256. @example
  5257. fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
  5258. @end example
  5259. @item
  5260. Low-pass:
  5261. @example
  5262. fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
  5263. @end example
  5264. @item
  5265. Sharpen:
  5266. @example
  5267. fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
  5268. @end example
  5269. @item
  5270. Blur:
  5271. @example
  5272. fftfilt=dc_Y=0:weight_Y='exp(-4 * ((Y+X)/(W+H)))'
  5273. @end example
  5274. @end itemize
  5275. @section field
  5276. Extract a single field from an interlaced image using stride
  5277. arithmetic to avoid wasting CPU time. The output frames are marked as
  5278. non-interlaced.
  5279. The filter accepts the following options:
  5280. @table @option
  5281. @item type
  5282. Specify whether to extract the top (if the value is @code{0} or
  5283. @code{top}) or the bottom field (if the value is @code{1} or
  5284. @code{bottom}).
  5285. @end table
  5286. @section fieldhint
  5287. Create new frames by copying the top and bottom fields from surrounding frames
  5288. supplied as numbers by the hint file.
  5289. @table @option
  5290. @item hint
  5291. Set file containing hints: absolute/relative frame numbers.
  5292. There must be one line for each frame in a clip. Each line must contain two
  5293. numbers separated by the comma, optionally followed by @code{-} or @code{+}.
  5294. Numbers supplied on each line of file can not be out of [N-1,N+1] where N
  5295. is current frame number for @code{absolute} mode or out of [-1, 1] range
  5296. for @code{relative} mode. First number tells from which frame to pick up top
  5297. field and second number tells from which frame to pick up bottom field.
  5298. If optionally followed by @code{+} output frame will be marked as interlaced,
  5299. else if followed by @code{-} output frame will be marked as progressive, else
  5300. it will be marked same as input frame.
  5301. If line starts with @code{#} or @code{;} that line is skipped.
  5302. @item mode
  5303. Can be item @code{absolute} or @code{relative}. Default is @code{absolute}.
  5304. @end table
  5305. Example of first several lines of @code{hint} file for @code{relative} mode:
  5306. @example
  5307. 0,0 - # first frame
  5308. 1,0 - # second frame, use third's frame top field and second's frame bottom field
  5309. 1,0 - # third frame, use fourth's frame top field and third's frame bottom field
  5310. 1,0 -
  5311. 0,0 -
  5312. 0,0 -
  5313. 1,0 -
  5314. 1,0 -
  5315. 1,0 -
  5316. 0,0 -
  5317. 0,0 -
  5318. 1,0 -
  5319. 1,0 -
  5320. 1,0 -
  5321. 0,0 -
  5322. @end example
  5323. @section fieldmatch
  5324. Field matching filter for inverse telecine. It is meant to reconstruct the
  5325. progressive frames from a telecined stream. The filter does not drop duplicated
  5326. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  5327. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  5328. The separation of the field matching and the decimation is notably motivated by
  5329. the possibility of inserting a de-interlacing filter fallback between the two.
  5330. If the source has mixed telecined and real interlaced content,
  5331. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  5332. But these remaining combed frames will be marked as interlaced, and thus can be
  5333. de-interlaced by a later filter such as @ref{yadif} before decimation.
  5334. In addition to the various configuration options, @code{fieldmatch} can take an
  5335. optional second stream, activated through the @option{ppsrc} option. If
  5336. enabled, the frames reconstruction will be based on the fields and frames from
  5337. this second stream. This allows the first input to be pre-processed in order to
  5338. help the various algorithms of the filter, while keeping the output lossless
  5339. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  5340. or brightness/contrast adjustments can help.
  5341. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  5342. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  5343. which @code{fieldmatch} is based on. While the semantic and usage are very
  5344. close, some behaviour and options names can differ.
  5345. The @ref{decimate} filter currently only works for constant frame rate input.
  5346. If your input has mixed telecined (30fps) and progressive content with a lower
  5347. framerate like 24fps use the following filterchain to produce the necessary cfr
  5348. stream: @code{dejudder,fps=30000/1001,fieldmatch,decimate}.
  5349. The filter accepts the following options:
  5350. @table @option
  5351. @item order
  5352. Specify the assumed field order of the input stream. Available values are:
  5353. @table @samp
  5354. @item auto
  5355. Auto detect parity (use FFmpeg's internal parity value).
  5356. @item bff
  5357. Assume bottom field first.
  5358. @item tff
  5359. Assume top field first.
  5360. @end table
  5361. Note that it is sometimes recommended not to trust the parity announced by the
  5362. stream.
  5363. Default value is @var{auto}.
  5364. @item mode
  5365. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  5366. sense that it won't risk creating jerkiness due to duplicate frames when
  5367. possible, but if there are bad edits or blended fields it will end up
  5368. outputting combed frames when a good match might actually exist. On the other
  5369. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  5370. but will almost always find a good frame if there is one. The other values are
  5371. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  5372. jerkiness and creating duplicate frames versus finding good matches in sections
  5373. with bad edits, orphaned fields, blended fields, etc.
  5374. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  5375. Available values are:
  5376. @table @samp
  5377. @item pc
  5378. 2-way matching (p/c)
  5379. @item pc_n
  5380. 2-way matching, and trying 3rd match if still combed (p/c + n)
  5381. @item pc_u
  5382. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  5383. @item pc_n_ub
  5384. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  5385. still combed (p/c + n + u/b)
  5386. @item pcn
  5387. 3-way matching (p/c/n)
  5388. @item pcn_ub
  5389. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  5390. detected as combed (p/c/n + u/b)
  5391. @end table
  5392. The parenthesis at the end indicate the matches that would be used for that
  5393. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  5394. @var{top}).
  5395. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  5396. the slowest.
  5397. Default value is @var{pc_n}.
  5398. @item ppsrc
  5399. Mark the main input stream as a pre-processed input, and enable the secondary
  5400. input stream as the clean source to pick the fields from. See the filter
  5401. introduction for more details. It is similar to the @option{clip2} feature from
  5402. VFM/TFM.
  5403. Default value is @code{0} (disabled).
  5404. @item field
  5405. Set the field to match from. It is recommended to set this to the same value as
  5406. @option{order} unless you experience matching failures with that setting. In
  5407. certain circumstances changing the field that is used to match from can have a
  5408. large impact on matching performance. Available values are:
  5409. @table @samp
  5410. @item auto
  5411. Automatic (same value as @option{order}).
  5412. @item bottom
  5413. Match from the bottom field.
  5414. @item top
  5415. Match from the top field.
  5416. @end table
  5417. Default value is @var{auto}.
  5418. @item mchroma
  5419. Set whether or not chroma is included during the match comparisons. In most
  5420. cases it is recommended to leave this enabled. You should set this to @code{0}
  5421. only if your clip has bad chroma problems such as heavy rainbowing or other
  5422. artifacts. Setting this to @code{0} could also be used to speed things up at
  5423. the cost of some accuracy.
  5424. Default value is @code{1}.
  5425. @item y0
  5426. @item y1
  5427. These define an exclusion band which excludes the lines between @option{y0} and
  5428. @option{y1} from being included in the field matching decision. An exclusion
  5429. band can be used to ignore subtitles, a logo, or other things that may
  5430. interfere with the matching. @option{y0} sets the starting scan line and
  5431. @option{y1} sets the ending line; all lines in between @option{y0} and
  5432. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  5433. @option{y0} and @option{y1} to the same value will disable the feature.
  5434. @option{y0} and @option{y1} defaults to @code{0}.
  5435. @item scthresh
  5436. Set the scene change detection threshold as a percentage of maximum change on
  5437. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  5438. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  5439. @option{scthresh} is @code{[0.0, 100.0]}.
  5440. Default value is @code{12.0}.
  5441. @item combmatch
  5442. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  5443. account the combed scores of matches when deciding what match to use as the
  5444. final match. Available values are:
  5445. @table @samp
  5446. @item none
  5447. No final matching based on combed scores.
  5448. @item sc
  5449. Combed scores are only used when a scene change is detected.
  5450. @item full
  5451. Use combed scores all the time.
  5452. @end table
  5453. Default is @var{sc}.
  5454. @item combdbg
  5455. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  5456. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  5457. Available values are:
  5458. @table @samp
  5459. @item none
  5460. No forced calculation.
  5461. @item pcn
  5462. Force p/c/n calculations.
  5463. @item pcnub
  5464. Force p/c/n/u/b calculations.
  5465. @end table
  5466. Default value is @var{none}.
  5467. @item cthresh
  5468. This is the area combing threshold used for combed frame detection. This
  5469. essentially controls how "strong" or "visible" combing must be to be detected.
  5470. Larger values mean combing must be more visible and smaller values mean combing
  5471. can be less visible or strong and still be detected. Valid settings are from
  5472. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  5473. be detected as combed). This is basically a pixel difference value. A good
  5474. range is @code{[8, 12]}.
  5475. Default value is @code{9}.
  5476. @item chroma
  5477. Sets whether or not chroma is considered in the combed frame decision. Only
  5478. disable this if your source has chroma problems (rainbowing, etc.) that are
  5479. causing problems for the combed frame detection with chroma enabled. Actually,
  5480. using @option{chroma}=@var{0} is usually more reliable, except for the case
  5481. where there is chroma only combing in the source.
  5482. Default value is @code{0}.
  5483. @item blockx
  5484. @item blocky
  5485. Respectively set the x-axis and y-axis size of the window used during combed
  5486. frame detection. This has to do with the size of the area in which
  5487. @option{combpel} pixels are required to be detected as combed for a frame to be
  5488. declared combed. See the @option{combpel} parameter description for more info.
  5489. Possible values are any number that is a power of 2 starting at 4 and going up
  5490. to 512.
  5491. Default value is @code{16}.
  5492. @item combpel
  5493. The number of combed pixels inside any of the @option{blocky} by
  5494. @option{blockx} size blocks on the frame for the frame to be detected as
  5495. combed. While @option{cthresh} controls how "visible" the combing must be, this
  5496. setting controls "how much" combing there must be in any localized area (a
  5497. window defined by the @option{blockx} and @option{blocky} settings) on the
  5498. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  5499. which point no frames will ever be detected as combed). This setting is known
  5500. as @option{MI} in TFM/VFM vocabulary.
  5501. Default value is @code{80}.
  5502. @end table
  5503. @anchor{p/c/n/u/b meaning}
  5504. @subsection p/c/n/u/b meaning
  5505. @subsubsection p/c/n
  5506. We assume the following telecined stream:
  5507. @example
  5508. Top fields: 1 2 2 3 4
  5509. Bottom fields: 1 2 3 4 4
  5510. @end example
  5511. The numbers correspond to the progressive frame the fields relate to. Here, the
  5512. first two frames are progressive, the 3rd and 4th are combed, and so on.
  5513. When @code{fieldmatch} is configured to run a matching from bottom
  5514. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  5515. @example
  5516. Input stream:
  5517. T 1 2 2 3 4
  5518. B 1 2 3 4 4 <-- matching reference
  5519. Matches: c c n n c
  5520. Output stream:
  5521. T 1 2 3 4 4
  5522. B 1 2 3 4 4
  5523. @end example
  5524. As a result of the field matching, we can see that some frames get duplicated.
  5525. To perform a complete inverse telecine, you need to rely on a decimation filter
  5526. after this operation. See for instance the @ref{decimate} filter.
  5527. The same operation now matching from top fields (@option{field}=@var{top})
  5528. looks like this:
  5529. @example
  5530. Input stream:
  5531. T 1 2 2 3 4 <-- matching reference
  5532. B 1 2 3 4 4
  5533. Matches: c c p p c
  5534. Output stream:
  5535. T 1 2 2 3 4
  5536. B 1 2 2 3 4
  5537. @end example
  5538. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  5539. basically, they refer to the frame and field of the opposite parity:
  5540. @itemize
  5541. @item @var{p} matches the field of the opposite parity in the previous frame
  5542. @item @var{c} matches the field of the opposite parity in the current frame
  5543. @item @var{n} matches the field of the opposite parity in the next frame
  5544. @end itemize
  5545. @subsubsection u/b
  5546. The @var{u} and @var{b} matching are a bit special in the sense that they match
  5547. from the opposite parity flag. In the following examples, we assume that we are
  5548. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  5549. 'x' is placed above and below each matched fields.
  5550. With bottom matching (@option{field}=@var{bottom}):
  5551. @example
  5552. Match: c p n b u
  5553. x x x x x
  5554. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  5555. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  5556. x x x x x
  5557. Output frames:
  5558. 2 1 2 2 2
  5559. 2 2 2 1 3
  5560. @end example
  5561. With top matching (@option{field}=@var{top}):
  5562. @example
  5563. Match: c p n b u
  5564. x x x x x
  5565. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  5566. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  5567. x x x x x
  5568. Output frames:
  5569. 2 2 2 1 2
  5570. 2 1 3 2 2
  5571. @end example
  5572. @subsection Examples
  5573. Simple IVTC of a top field first telecined stream:
  5574. @example
  5575. fieldmatch=order=tff:combmatch=none, decimate
  5576. @end example
  5577. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  5578. @example
  5579. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  5580. @end example
  5581. @section fieldorder
  5582. Transform the field order of the input video.
  5583. It accepts the following parameters:
  5584. @table @option
  5585. @item order
  5586. The output field order. Valid values are @var{tff} for top field first or @var{bff}
  5587. for bottom field first.
  5588. @end table
  5589. The default value is @samp{tff}.
  5590. The transformation is done by shifting the picture content up or down
  5591. by one line, and filling the remaining line with appropriate picture content.
  5592. This method is consistent with most broadcast field order converters.
  5593. If the input video is not flagged as being interlaced, or it is already
  5594. flagged as being of the required output field order, then this filter does
  5595. not alter the incoming video.
  5596. It is very useful when converting to or from PAL DV material,
  5597. which is bottom field first.
  5598. For example:
  5599. @example
  5600. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  5601. @end example
  5602. @section fifo, afifo
  5603. Buffer input images and send them when they are requested.
  5604. It is mainly useful when auto-inserted by the libavfilter
  5605. framework.
  5606. It does not take parameters.
  5607. @section find_rect
  5608. Find a rectangular object
  5609. It accepts the following options:
  5610. @table @option
  5611. @item object
  5612. Filepath of the object image, needs to be in gray8.
  5613. @item threshold
  5614. Detection threshold, default is 0.5.
  5615. @item mipmaps
  5616. Number of mipmaps, default is 3.
  5617. @item xmin, ymin, xmax, ymax
  5618. Specifies the rectangle in which to search.
  5619. @end table
  5620. @subsection Examples
  5621. @itemize
  5622. @item
  5623. Generate a representative palette of a given video using @command{ffmpeg}:
  5624. @example
  5625. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  5626. @end example
  5627. @end itemize
  5628. @section cover_rect
  5629. Cover a rectangular object
  5630. It accepts the following options:
  5631. @table @option
  5632. @item cover
  5633. Filepath of the optional cover image, needs to be in yuv420.
  5634. @item mode
  5635. Set covering mode.
  5636. It accepts the following values:
  5637. @table @samp
  5638. @item cover
  5639. cover it by the supplied image
  5640. @item blur
  5641. cover it by interpolating the surrounding pixels
  5642. @end table
  5643. Default value is @var{blur}.
  5644. @end table
  5645. @subsection Examples
  5646. @itemize
  5647. @item
  5648. Generate a representative palette of a given video using @command{ffmpeg}:
  5649. @example
  5650. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  5651. @end example
  5652. @end itemize
  5653. @anchor{format}
  5654. @section format
  5655. Convert the input video to one of the specified pixel formats.
  5656. Libavfilter will try to pick one that is suitable as input to
  5657. the next filter.
  5658. It accepts the following parameters:
  5659. @table @option
  5660. @item pix_fmts
  5661. A '|'-separated list of pixel format names, such as
  5662. "pix_fmts=yuv420p|monow|rgb24".
  5663. @end table
  5664. @subsection Examples
  5665. @itemize
  5666. @item
  5667. Convert the input video to the @var{yuv420p} format
  5668. @example
  5669. format=pix_fmts=yuv420p
  5670. @end example
  5671. Convert the input video to any of the formats in the list
  5672. @example
  5673. format=pix_fmts=yuv420p|yuv444p|yuv410p
  5674. @end example
  5675. @end itemize
  5676. @anchor{fps}
  5677. @section fps
  5678. Convert the video to specified constant frame rate by duplicating or dropping
  5679. frames as necessary.
  5680. It accepts the following parameters:
  5681. @table @option
  5682. @item fps
  5683. The desired output frame rate. The default is @code{25}.
  5684. @item round
  5685. Rounding method.
  5686. Possible values are:
  5687. @table @option
  5688. @item zero
  5689. zero round towards 0
  5690. @item inf
  5691. round away from 0
  5692. @item down
  5693. round towards -infinity
  5694. @item up
  5695. round towards +infinity
  5696. @item near
  5697. round to nearest
  5698. @end table
  5699. The default is @code{near}.
  5700. @item start_time
  5701. Assume the first PTS should be the given value, in seconds. This allows for
  5702. padding/trimming at the start of stream. By default, no assumption is made
  5703. about the first frame's expected PTS, so no padding or trimming is done.
  5704. For example, this could be set to 0 to pad the beginning with duplicates of
  5705. the first frame if a video stream starts after the audio stream or to trim any
  5706. frames with a negative PTS.
  5707. @end table
  5708. Alternatively, the options can be specified as a flat string:
  5709. @var{fps}[:@var{round}].
  5710. See also the @ref{setpts} filter.
  5711. @subsection Examples
  5712. @itemize
  5713. @item
  5714. A typical usage in order to set the fps to 25:
  5715. @example
  5716. fps=fps=25
  5717. @end example
  5718. @item
  5719. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  5720. @example
  5721. fps=fps=film:round=near
  5722. @end example
  5723. @end itemize
  5724. @section framepack
  5725. Pack two different video streams into a stereoscopic video, setting proper
  5726. metadata on supported codecs. The two views should have the same size and
  5727. framerate and processing will stop when the shorter video ends. Please note
  5728. that you may conveniently adjust view properties with the @ref{scale} and
  5729. @ref{fps} filters.
  5730. It accepts the following parameters:
  5731. @table @option
  5732. @item format
  5733. The desired packing format. Supported values are:
  5734. @table @option
  5735. @item sbs
  5736. The views are next to each other (default).
  5737. @item tab
  5738. The views are on top of each other.
  5739. @item lines
  5740. The views are packed by line.
  5741. @item columns
  5742. The views are packed by column.
  5743. @item frameseq
  5744. The views are temporally interleaved.
  5745. @end table
  5746. @end table
  5747. Some examples:
  5748. @example
  5749. # Convert left and right views into a frame-sequential video
  5750. ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
  5751. # Convert views into a side-by-side video with the same output resolution as the input
  5752. 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
  5753. @end example
  5754. @section framerate
  5755. Change the frame rate by interpolating new video output frames from the source
  5756. frames.
  5757. This filter is not designed to function correctly with interlaced media. If
  5758. you wish to change the frame rate of interlaced media then you are required
  5759. to deinterlace before this filter and re-interlace after this filter.
  5760. A description of the accepted options follows.
  5761. @table @option
  5762. @item fps
  5763. Specify the output frames per second. This option can also be specified
  5764. as a value alone. The default is @code{50}.
  5765. @item interp_start
  5766. Specify the start of a range where the output frame will be created as a
  5767. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  5768. the default is @code{15}.
  5769. @item interp_end
  5770. Specify the end of a range where the output frame will be created as a
  5771. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  5772. the default is @code{240}.
  5773. @item scene
  5774. Specify the level at which a scene change is detected as a value between
  5775. 0 and 100 to indicate a new scene; a low value reflects a low
  5776. probability for the current frame to introduce a new scene, while a higher
  5777. value means the current frame is more likely to be one.
  5778. The default is @code{7}.
  5779. @item flags
  5780. Specify flags influencing the filter process.
  5781. Available value for @var{flags} is:
  5782. @table @option
  5783. @item scene_change_detect, scd
  5784. Enable scene change detection using the value of the option @var{scene}.
  5785. This flag is enabled by default.
  5786. @end table
  5787. @end table
  5788. @section framestep
  5789. Select one frame every N-th frame.
  5790. This filter accepts the following option:
  5791. @table @option
  5792. @item step
  5793. Select frame after every @code{step} frames.
  5794. Allowed values are positive integers higher than 0. Default value is @code{1}.
  5795. @end table
  5796. @anchor{frei0r}
  5797. @section frei0r
  5798. Apply a frei0r effect to the input video.
  5799. To enable the compilation of this filter, you need to install the frei0r
  5800. header and configure FFmpeg with @code{--enable-frei0r}.
  5801. It accepts the following parameters:
  5802. @table @option
  5803. @item filter_name
  5804. The name of the frei0r effect to load. If the environment variable
  5805. @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
  5806. directories specified by the colon-separated list in @env{FREIOR_PATH}.
  5807. Otherwise, the standard frei0r paths are searched, in this order:
  5808. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  5809. @file{/usr/lib/frei0r-1/}.
  5810. @item filter_params
  5811. A '|'-separated list of parameters to pass to the frei0r effect.
  5812. @end table
  5813. A frei0r effect parameter can be a boolean (its value is either
  5814. "y" or "n"), a double, a color (specified as
  5815. @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
  5816. numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
  5817. section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
  5818. @var{X} and @var{Y} are floating point numbers) and/or a string.
  5819. The number and types of parameters depend on the loaded effect. If an
  5820. effect parameter is not specified, the default value is set.
  5821. @subsection Examples
  5822. @itemize
  5823. @item
  5824. Apply the distort0r effect, setting the first two double parameters:
  5825. @example
  5826. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  5827. @end example
  5828. @item
  5829. Apply the colordistance effect, taking a color as the first parameter:
  5830. @example
  5831. frei0r=colordistance:0.2/0.3/0.4
  5832. frei0r=colordistance:violet
  5833. frei0r=colordistance:0x112233
  5834. @end example
  5835. @item
  5836. Apply the perspective effect, specifying the top left and top right image
  5837. positions:
  5838. @example
  5839. frei0r=perspective:0.2/0.2|0.8/0.2
  5840. @end example
  5841. @end itemize
  5842. For more information, see
  5843. @url{http://frei0r.dyne.org}
  5844. @section fspp
  5845. Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
  5846. It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
  5847. processing filter, one of them is performed once per block, not per pixel.
  5848. This allows for much higher speed.
  5849. The filter accepts the following options:
  5850. @table @option
  5851. @item quality
  5852. Set quality. This option defines the number of levels for averaging. It accepts
  5853. an integer in the range 4-5. Default value is @code{4}.
  5854. @item qp
  5855. Force a constant quantization parameter. It accepts an integer in range 0-63.
  5856. If not set, the filter will use the QP from the video stream (if available).
  5857. @item strength
  5858. Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
  5859. more details but also more artifacts, while higher values make the image smoother
  5860. but also blurrier. Default value is @code{0} − PSNR optimal.
  5861. @item use_bframe_qp
  5862. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  5863. option may cause flicker since the B-Frames have often larger QP. Default is
  5864. @code{0} (not enabled).
  5865. @end table
  5866. @section geq
  5867. The filter accepts the following options:
  5868. @table @option
  5869. @item lum_expr, lum
  5870. Set the luminance expression.
  5871. @item cb_expr, cb
  5872. Set the chrominance blue expression.
  5873. @item cr_expr, cr
  5874. Set the chrominance red expression.
  5875. @item alpha_expr, a
  5876. Set the alpha expression.
  5877. @item red_expr, r
  5878. Set the red expression.
  5879. @item green_expr, g
  5880. Set the green expression.
  5881. @item blue_expr, b
  5882. Set the blue expression.
  5883. @end table
  5884. The colorspace is selected according to the specified options. If one
  5885. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  5886. options is specified, the filter will automatically select a YCbCr
  5887. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  5888. @option{blue_expr} options is specified, it will select an RGB
  5889. colorspace.
  5890. If one of the chrominance expression is not defined, it falls back on the other
  5891. one. If no alpha expression is specified it will evaluate to opaque value.
  5892. If none of chrominance expressions are specified, they will evaluate
  5893. to the luminance expression.
  5894. The expressions can use the following variables and functions:
  5895. @table @option
  5896. @item N
  5897. The sequential number of the filtered frame, starting from @code{0}.
  5898. @item X
  5899. @item Y
  5900. The coordinates of the current sample.
  5901. @item W
  5902. @item H
  5903. The width and height of the image.
  5904. @item SW
  5905. @item SH
  5906. Width and height scale depending on the currently filtered plane. It is the
  5907. ratio between the corresponding luma plane number of pixels and the current
  5908. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  5909. @code{0.5,0.5} for chroma planes.
  5910. @item T
  5911. Time of the current frame, expressed in seconds.
  5912. @item p(x, y)
  5913. Return the value of the pixel at location (@var{x},@var{y}) of the current
  5914. plane.
  5915. @item lum(x, y)
  5916. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  5917. plane.
  5918. @item cb(x, y)
  5919. Return the value of the pixel at location (@var{x},@var{y}) of the
  5920. blue-difference chroma plane. Return 0 if there is no such plane.
  5921. @item cr(x, y)
  5922. Return the value of the pixel at location (@var{x},@var{y}) of the
  5923. red-difference chroma plane. Return 0 if there is no such plane.
  5924. @item r(x, y)
  5925. @item g(x, y)
  5926. @item b(x, y)
  5927. Return the value of the pixel at location (@var{x},@var{y}) of the
  5928. red/green/blue component. Return 0 if there is no such component.
  5929. @item alpha(x, y)
  5930. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  5931. plane. Return 0 if there is no such plane.
  5932. @end table
  5933. For functions, if @var{x} and @var{y} are outside the area, the value will be
  5934. automatically clipped to the closer edge.
  5935. @subsection Examples
  5936. @itemize
  5937. @item
  5938. Flip the image horizontally:
  5939. @example
  5940. geq=p(W-X\,Y)
  5941. @end example
  5942. @item
  5943. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  5944. wavelength of 100 pixels:
  5945. @example
  5946. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  5947. @end example
  5948. @item
  5949. Generate a fancy enigmatic moving light:
  5950. @example
  5951. 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
  5952. @end example
  5953. @item
  5954. Generate a quick emboss effect:
  5955. @example
  5956. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  5957. @end example
  5958. @item
  5959. Modify RGB components depending on pixel position:
  5960. @example
  5961. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  5962. @end example
  5963. @item
  5964. Create a radial gradient that is the same size as the input (also see
  5965. the @ref{vignette} filter):
  5966. @example
  5967. geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
  5968. @end example
  5969. @end itemize
  5970. @section gradfun
  5971. Fix the banding artifacts that are sometimes introduced into nearly flat
  5972. regions by truncation to 8bit color depth.
  5973. Interpolate the gradients that should go where the bands are, and
  5974. dither them.
  5975. It is designed for playback only. Do not use it prior to
  5976. lossy compression, because compression tends to lose the dither and
  5977. bring back the bands.
  5978. It accepts the following parameters:
  5979. @table @option
  5980. @item strength
  5981. The maximum amount by which the filter will change any one pixel. This is also
  5982. the threshold for detecting nearly flat regions. Acceptable values range from
  5983. .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
  5984. valid range.
  5985. @item radius
  5986. The neighborhood to fit the gradient to. A larger radius makes for smoother
  5987. gradients, but also prevents the filter from modifying the pixels near detailed
  5988. regions. Acceptable values are 8-32; the default value is 16. Out-of-range
  5989. values will be clipped to the valid range.
  5990. @end table
  5991. Alternatively, the options can be specified as a flat string:
  5992. @var{strength}[:@var{radius}]
  5993. @subsection Examples
  5994. @itemize
  5995. @item
  5996. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  5997. @example
  5998. gradfun=3.5:8
  5999. @end example
  6000. @item
  6001. Specify radius, omitting the strength (which will fall-back to the default
  6002. value):
  6003. @example
  6004. gradfun=radius=8
  6005. @end example
  6006. @end itemize
  6007. @anchor{haldclut}
  6008. @section haldclut
  6009. Apply a Hald CLUT to a video stream.
  6010. First input is the video stream to process, and second one is the Hald CLUT.
  6011. The Hald CLUT input can be a simple picture or a complete video stream.
  6012. The filter accepts the following options:
  6013. @table @option
  6014. @item shortest
  6015. Force termination when the shortest input terminates. Default is @code{0}.
  6016. @item repeatlast
  6017. Continue applying the last CLUT after the end of the stream. A value of
  6018. @code{0} disable the filter after the last frame of the CLUT is reached.
  6019. Default is @code{1}.
  6020. @end table
  6021. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  6022. filters share the same internals).
  6023. More information about the Hald CLUT can be found on Eskil Steenberg's website
  6024. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  6025. @subsection Workflow examples
  6026. @subsubsection Hald CLUT video stream
  6027. Generate an identity Hald CLUT stream altered with various effects:
  6028. @example
  6029. 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
  6030. @end example
  6031. Note: make sure you use a lossless codec.
  6032. Then use it with @code{haldclut} to apply it on some random stream:
  6033. @example
  6034. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  6035. @end example
  6036. The Hald CLUT will be applied to the 10 first seconds (duration of
  6037. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  6038. to the remaining frames of the @code{mandelbrot} stream.
  6039. @subsubsection Hald CLUT with preview
  6040. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  6041. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  6042. biggest possible square starting at the top left of the picture. The remaining
  6043. padding pixels (bottom or right) will be ignored. This area can be used to add
  6044. a preview of the Hald CLUT.
  6045. Typically, the following generated Hald CLUT will be supported by the
  6046. @code{haldclut} filter:
  6047. @example
  6048. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  6049. pad=iw+320 [padded_clut];
  6050. smptebars=s=320x256, split [a][b];
  6051. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  6052. [main][b] overlay=W-320" -frames:v 1 clut.png
  6053. @end example
  6054. It contains the original and a preview of the effect of the CLUT: SMPTE color
  6055. bars are displayed on the right-top, and below the same color bars processed by
  6056. the color changes.
  6057. Then, the effect of this Hald CLUT can be visualized with:
  6058. @example
  6059. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  6060. @end example
  6061. @section hflip
  6062. Flip the input video horizontally.
  6063. For example, to horizontally flip the input video with @command{ffmpeg}:
  6064. @example
  6065. ffmpeg -i in.avi -vf "hflip" out.avi
  6066. @end example
  6067. @section histeq
  6068. This filter applies a global color histogram equalization on a
  6069. per-frame basis.
  6070. It can be used to correct video that has a compressed range of pixel
  6071. intensities. The filter redistributes the pixel intensities to
  6072. equalize their distribution across the intensity range. It may be
  6073. viewed as an "automatically adjusting contrast filter". This filter is
  6074. useful only for correcting degraded or poorly captured source
  6075. video.
  6076. The filter accepts the following options:
  6077. @table @option
  6078. @item strength
  6079. Determine the amount of equalization to be applied. As the strength
  6080. is reduced, the distribution of pixel intensities more-and-more
  6081. approaches that of the input frame. The value must be a float number
  6082. in the range [0,1] and defaults to 0.200.
  6083. @item intensity
  6084. Set the maximum intensity that can generated and scale the output
  6085. values appropriately. The strength should be set as desired and then
  6086. the intensity can be limited if needed to avoid washing-out. The value
  6087. must be a float number in the range [0,1] and defaults to 0.210.
  6088. @item antibanding
  6089. Set the antibanding level. If enabled the filter will randomly vary
  6090. the luminance of output pixels by a small amount to avoid banding of
  6091. the histogram. Possible values are @code{none}, @code{weak} or
  6092. @code{strong}. It defaults to @code{none}.
  6093. @end table
  6094. @section histogram
  6095. Compute and draw a color distribution histogram for the input video.
  6096. The computed histogram is a representation of the color component
  6097. distribution in an image.
  6098. Standard histogram displays the color components distribution in an image.
  6099. Displays color graph for each color component. Shows distribution of
  6100. the Y, U, V, A or R, G, B components, depending on input format, in the
  6101. current frame. Below each graph a color component scale meter is shown.
  6102. The filter accepts the following options:
  6103. @table @option
  6104. @item level_height
  6105. Set height of level. Default value is @code{200}.
  6106. Allowed range is [50, 2048].
  6107. @item scale_height
  6108. Set height of color scale. Default value is @code{12}.
  6109. Allowed range is [0, 40].
  6110. @item display_mode
  6111. Set display mode.
  6112. It accepts the following values:
  6113. @table @samp
  6114. @item parade
  6115. Per color component graphs are placed below each other.
  6116. @item overlay
  6117. Presents information identical to that in the @code{parade}, except
  6118. that the graphs representing color components are superimposed directly
  6119. over one another.
  6120. @end table
  6121. Default is @code{parade}.
  6122. @item levels_mode
  6123. Set mode. Can be either @code{linear}, or @code{logarithmic}.
  6124. Default is @code{linear}.
  6125. @item components
  6126. Set what color components to display.
  6127. Default is @code{7}.
  6128. @end table
  6129. @subsection Examples
  6130. @itemize
  6131. @item
  6132. Calculate and draw histogram:
  6133. @example
  6134. ffplay -i input -vf histogram
  6135. @end example
  6136. @end itemize
  6137. @anchor{hqdn3d}
  6138. @section hqdn3d
  6139. This is a high precision/quality 3d denoise filter. It aims to reduce
  6140. image noise, producing smooth images and making still images really
  6141. still. It should enhance compressibility.
  6142. It accepts the following optional parameters:
  6143. @table @option
  6144. @item luma_spatial
  6145. A non-negative floating point number which specifies spatial luma strength.
  6146. It defaults to 4.0.
  6147. @item chroma_spatial
  6148. A non-negative floating point number which specifies spatial chroma strength.
  6149. It defaults to 3.0*@var{luma_spatial}/4.0.
  6150. @item luma_tmp
  6151. A floating point number which specifies luma temporal strength. It defaults to
  6152. 6.0*@var{luma_spatial}/4.0.
  6153. @item chroma_tmp
  6154. A floating point number which specifies chroma temporal strength. It defaults to
  6155. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
  6156. @end table
  6157. @anchor{hwupload_cuda}
  6158. @section hwupload_cuda
  6159. Upload system memory frames to a CUDA device.
  6160. It accepts the following optional parameters:
  6161. @table @option
  6162. @item device
  6163. The number of the CUDA device to use
  6164. @end table
  6165. @section hqx
  6166. Apply a high-quality magnification filter designed for pixel art. This filter
  6167. was originally created by Maxim Stepin.
  6168. It accepts the following option:
  6169. @table @option
  6170. @item n
  6171. Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
  6172. @code{hq3x} and @code{4} for @code{hq4x}.
  6173. Default is @code{3}.
  6174. @end table
  6175. @section hstack
  6176. Stack input videos horizontally.
  6177. All streams must be of same pixel format and of same height.
  6178. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  6179. to create same output.
  6180. The filter accept the following option:
  6181. @table @option
  6182. @item inputs
  6183. Set number of input streams. Default is 2.
  6184. @item shortest
  6185. If set to 1, force the output to terminate when the shortest input
  6186. terminates. Default value is 0.
  6187. @end table
  6188. @section hue
  6189. Modify the hue and/or the saturation of the input.
  6190. It accepts the following parameters:
  6191. @table @option
  6192. @item h
  6193. Specify the hue angle as a number of degrees. It accepts an expression,
  6194. and defaults to "0".
  6195. @item s
  6196. Specify the saturation in the [-10,10] range. It accepts an expression and
  6197. defaults to "1".
  6198. @item H
  6199. Specify the hue angle as a number of radians. It accepts an
  6200. expression, and defaults to "0".
  6201. @item b
  6202. Specify the brightness in the [-10,10] range. It accepts an expression and
  6203. defaults to "0".
  6204. @end table
  6205. @option{h} and @option{H} are mutually exclusive, and can't be
  6206. specified at the same time.
  6207. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  6208. expressions containing the following constants:
  6209. @table @option
  6210. @item n
  6211. frame count of the input frame starting from 0
  6212. @item pts
  6213. presentation timestamp of the input frame expressed in time base units
  6214. @item r
  6215. frame rate of the input video, NAN if the input frame rate is unknown
  6216. @item t
  6217. timestamp expressed in seconds, NAN if the input timestamp is unknown
  6218. @item tb
  6219. time base of the input video
  6220. @end table
  6221. @subsection Examples
  6222. @itemize
  6223. @item
  6224. Set the hue to 90 degrees and the saturation to 1.0:
  6225. @example
  6226. hue=h=90:s=1
  6227. @end example
  6228. @item
  6229. Same command but expressing the hue in radians:
  6230. @example
  6231. hue=H=PI/2:s=1
  6232. @end example
  6233. @item
  6234. Rotate hue and make the saturation swing between 0
  6235. and 2 over a period of 1 second:
  6236. @example
  6237. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  6238. @end example
  6239. @item
  6240. Apply a 3 seconds saturation fade-in effect starting at 0:
  6241. @example
  6242. hue="s=min(t/3\,1)"
  6243. @end example
  6244. The general fade-in expression can be written as:
  6245. @example
  6246. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  6247. @end example
  6248. @item
  6249. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  6250. @example
  6251. hue="s=max(0\, min(1\, (8-t)/3))"
  6252. @end example
  6253. The general fade-out expression can be written as:
  6254. @example
  6255. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  6256. @end example
  6257. @end itemize
  6258. @subsection Commands
  6259. This filter supports the following commands:
  6260. @table @option
  6261. @item b
  6262. @item s
  6263. @item h
  6264. @item H
  6265. Modify the hue and/or the saturation and/or brightness of the input video.
  6266. The command accepts the same syntax of the corresponding option.
  6267. If the specified expression is not valid, it is kept at its current
  6268. value.
  6269. @end table
  6270. @section idet
  6271. Detect video interlacing type.
  6272. This filter tries to detect if the input frames as interlaced, progressive,
  6273. top or bottom field first. It will also try and detect fields that are
  6274. repeated between adjacent frames (a sign of telecine).
  6275. Single frame detection considers only immediately adjacent frames when classifying each frame.
  6276. Multiple frame detection incorporates the classification history of previous frames.
  6277. The filter will log these metadata values:
  6278. @table @option
  6279. @item single.current_frame
  6280. Detected type of current frame using single-frame detection. One of:
  6281. ``tff'' (top field first), ``bff'' (bottom field first),
  6282. ``progressive'', or ``undetermined''
  6283. @item single.tff
  6284. Cumulative number of frames detected as top field first using single-frame detection.
  6285. @item multiple.tff
  6286. Cumulative number of frames detected as top field first using multiple-frame detection.
  6287. @item single.bff
  6288. Cumulative number of frames detected as bottom field first using single-frame detection.
  6289. @item multiple.current_frame
  6290. Detected type of current frame using multiple-frame detection. One of:
  6291. ``tff'' (top field first), ``bff'' (bottom field first),
  6292. ``progressive'', or ``undetermined''
  6293. @item multiple.bff
  6294. Cumulative number of frames detected as bottom field first using multiple-frame detection.
  6295. @item single.progressive
  6296. Cumulative number of frames detected as progressive using single-frame detection.
  6297. @item multiple.progressive
  6298. Cumulative number of frames detected as progressive using multiple-frame detection.
  6299. @item single.undetermined
  6300. Cumulative number of frames that could not be classified using single-frame detection.
  6301. @item multiple.undetermined
  6302. Cumulative number of frames that could not be classified using multiple-frame detection.
  6303. @item repeated.current_frame
  6304. Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
  6305. @item repeated.neither
  6306. Cumulative number of frames with no repeated field.
  6307. @item repeated.top
  6308. Cumulative number of frames with the top field repeated from the previous frame's top field.
  6309. @item repeated.bottom
  6310. Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
  6311. @end table
  6312. The filter accepts the following options:
  6313. @table @option
  6314. @item intl_thres
  6315. Set interlacing threshold.
  6316. @item prog_thres
  6317. Set progressive threshold.
  6318. @item rep_thres
  6319. Threshold for repeated field detection.
  6320. @item half_life
  6321. Number of frames after which a given frame's contribution to the
  6322. statistics is halved (i.e., it contributes only 0.5 to it's
  6323. classification). The default of 0 means that all frames seen are given
  6324. full weight of 1.0 forever.
  6325. @item analyze_interlaced_flag
  6326. When this is not 0 then idet will use the specified number of frames to determine
  6327. if the interlaced flag is accurate, it will not count undetermined frames.
  6328. If the flag is found to be accurate it will be used without any further
  6329. computations, if it is found to be inaccurate it will be cleared without any
  6330. further computations. This allows inserting the idet filter as a low computational
  6331. method to clean up the interlaced flag
  6332. @end table
  6333. @section il
  6334. Deinterleave or interleave fields.
  6335. This filter allows one to process interlaced images fields without
  6336. deinterlacing them. Deinterleaving splits the input frame into 2
  6337. fields (so called half pictures). Odd lines are moved to the top
  6338. half of the output image, even lines to the bottom half.
  6339. You can process (filter) them independently and then re-interleave them.
  6340. The filter accepts the following options:
  6341. @table @option
  6342. @item luma_mode, l
  6343. @item chroma_mode, c
  6344. @item alpha_mode, a
  6345. Available values for @var{luma_mode}, @var{chroma_mode} and
  6346. @var{alpha_mode} are:
  6347. @table @samp
  6348. @item none
  6349. Do nothing.
  6350. @item deinterleave, d
  6351. Deinterleave fields, placing one above the other.
  6352. @item interleave, i
  6353. Interleave fields. Reverse the effect of deinterleaving.
  6354. @end table
  6355. Default value is @code{none}.
  6356. @item luma_swap, ls
  6357. @item chroma_swap, cs
  6358. @item alpha_swap, as
  6359. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  6360. @end table
  6361. @section inflate
  6362. Apply inflate effect to the video.
  6363. This filter replaces the pixel by the local(3x3) average by taking into account
  6364. only values higher than the pixel.
  6365. It accepts the following options:
  6366. @table @option
  6367. @item threshold0
  6368. @item threshold1
  6369. @item threshold2
  6370. @item threshold3
  6371. Limit the maximum change for each plane, default is 65535.
  6372. If 0, plane will remain unchanged.
  6373. @end table
  6374. @section interlace
  6375. Simple interlacing filter from progressive contents. This interleaves upper (or
  6376. lower) lines from odd frames with lower (or upper) lines from even frames,
  6377. halving the frame rate and preserving image height.
  6378. @example
  6379. Original Original New Frame
  6380. Frame 'j' Frame 'j+1' (tff)
  6381. ========== =========== ==================
  6382. Line 0 --------------------> Frame 'j' Line 0
  6383. Line 1 Line 1 ----> Frame 'j+1' Line 1
  6384. Line 2 ---------------------> Frame 'j' Line 2
  6385. Line 3 Line 3 ----> Frame 'j+1' Line 3
  6386. ... ... ...
  6387. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  6388. @end example
  6389. It accepts the following optional parameters:
  6390. @table @option
  6391. @item scan
  6392. This determines whether the interlaced frame is taken from the even
  6393. (tff - default) or odd (bff) lines of the progressive frame.
  6394. @item lowpass
  6395. Enable (default) or disable the vertical lowpass filter to avoid twitter
  6396. interlacing and reduce moire patterns.
  6397. @end table
  6398. @section kerndeint
  6399. Deinterlace input video by applying Donald Graft's adaptive kernel
  6400. deinterling. Work on interlaced parts of a video to produce
  6401. progressive frames.
  6402. The description of the accepted parameters follows.
  6403. @table @option
  6404. @item thresh
  6405. Set the threshold which affects the filter's tolerance when
  6406. determining if a pixel line must be processed. It must be an integer
  6407. in the range [0,255] and defaults to 10. A value of 0 will result in
  6408. applying the process on every pixels.
  6409. @item map
  6410. Paint pixels exceeding the threshold value to white if set to 1.
  6411. Default is 0.
  6412. @item order
  6413. Set the fields order. Swap fields if set to 1, leave fields alone if
  6414. 0. Default is 0.
  6415. @item sharp
  6416. Enable additional sharpening if set to 1. Default is 0.
  6417. @item twoway
  6418. Enable twoway sharpening if set to 1. Default is 0.
  6419. @end table
  6420. @subsection Examples
  6421. @itemize
  6422. @item
  6423. Apply default values:
  6424. @example
  6425. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  6426. @end example
  6427. @item
  6428. Enable additional sharpening:
  6429. @example
  6430. kerndeint=sharp=1
  6431. @end example
  6432. @item
  6433. Paint processed pixels in white:
  6434. @example
  6435. kerndeint=map=1
  6436. @end example
  6437. @end itemize
  6438. @section lenscorrection
  6439. Correct radial lens distortion
  6440. This filter can be used to correct for radial distortion as can result from the use
  6441. of wide angle lenses, and thereby re-rectify the image. To find the right parameters
  6442. one can use tools available for example as part of opencv or simply trial-and-error.
  6443. To use opencv use the calibration sample (under samples/cpp) from the opencv sources
  6444. and extract the k1 and k2 coefficients from the resulting matrix.
  6445. Note that effectively the same filter is available in the open-source tools Krita and
  6446. Digikam from the KDE project.
  6447. In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
  6448. this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
  6449. brightness distribution, so you may want to use both filters together in certain
  6450. cases, though you will have to take care of ordering, i.e. whether vignetting should
  6451. be applied before or after lens correction.
  6452. @subsection Options
  6453. The filter accepts the following options:
  6454. @table @option
  6455. @item cx
  6456. Relative x-coordinate of the focal point of the image, and thereby the center of the
  6457. distortion. This value has a range [0,1] and is expressed as fractions of the image
  6458. width.
  6459. @item cy
  6460. Relative y-coordinate of the focal point of the image, and thereby the center of the
  6461. distortion. This value has a range [0,1] and is expressed as fractions of the image
  6462. height.
  6463. @item k1
  6464. Coefficient of the quadratic correction term. 0.5 means no correction.
  6465. @item k2
  6466. Coefficient of the double quadratic correction term. 0.5 means no correction.
  6467. @end table
  6468. The formula that generates the correction is:
  6469. @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)
  6470. where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
  6471. distances from the focal point in the source and target images, respectively.
  6472. @section loop, aloop
  6473. Loop video frames or audio samples.
  6474. Those filters accepts the following options:
  6475. @table @option
  6476. @item loop
  6477. Set the number of loops.
  6478. @item size
  6479. Set maximal size in number of frames for @code{loop} filter or maximal number
  6480. of samples in case of @code{aloop} filter.
  6481. @item start
  6482. Set first frame of loop for @code{loop} filter or first sample of loop in case
  6483. of @code{aloop} filter.
  6484. @end table
  6485. @anchor{lut3d}
  6486. @section lut3d
  6487. Apply a 3D LUT to an input video.
  6488. The filter accepts the following options:
  6489. @table @option
  6490. @item file
  6491. Set the 3D LUT file name.
  6492. Currently supported formats:
  6493. @table @samp
  6494. @item 3dl
  6495. AfterEffects
  6496. @item cube
  6497. Iridas
  6498. @item dat
  6499. DaVinci
  6500. @item m3d
  6501. Pandora
  6502. @end table
  6503. @item interp
  6504. Select interpolation mode.
  6505. Available values are:
  6506. @table @samp
  6507. @item nearest
  6508. Use values from the nearest defined point.
  6509. @item trilinear
  6510. Interpolate values using the 8 points defining a cube.
  6511. @item tetrahedral
  6512. Interpolate values using a tetrahedron.
  6513. @end table
  6514. @end table
  6515. @section lut, lutrgb, lutyuv
  6516. Compute a look-up table for binding each pixel component input value
  6517. to an output value, and apply it to the input video.
  6518. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  6519. to an RGB input video.
  6520. These filters accept the following parameters:
  6521. @table @option
  6522. @item c0
  6523. set first pixel component expression
  6524. @item c1
  6525. set second pixel component expression
  6526. @item c2
  6527. set third pixel component expression
  6528. @item c3
  6529. set fourth pixel component expression, corresponds to the alpha component
  6530. @item r
  6531. set red component expression
  6532. @item g
  6533. set green component expression
  6534. @item b
  6535. set blue component expression
  6536. @item a
  6537. alpha component expression
  6538. @item y
  6539. set Y/luminance component expression
  6540. @item u
  6541. set U/Cb component expression
  6542. @item v
  6543. set V/Cr component expression
  6544. @end table
  6545. Each of them specifies the expression to use for computing the lookup table for
  6546. the corresponding pixel component values.
  6547. The exact component associated to each of the @var{c*} options depends on the
  6548. format in input.
  6549. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  6550. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  6551. The expressions can contain the following constants and functions:
  6552. @table @option
  6553. @item w
  6554. @item h
  6555. The input width and height.
  6556. @item val
  6557. The input value for the pixel component.
  6558. @item clipval
  6559. The input value, clipped to the @var{minval}-@var{maxval} range.
  6560. @item maxval
  6561. The maximum value for the pixel component.
  6562. @item minval
  6563. The minimum value for the pixel component.
  6564. @item negval
  6565. The negated value for the pixel component value, clipped to the
  6566. @var{minval}-@var{maxval} range; it corresponds to the expression
  6567. "maxval-clipval+minval".
  6568. @item clip(val)
  6569. The computed value in @var{val}, clipped to the
  6570. @var{minval}-@var{maxval} range.
  6571. @item gammaval(gamma)
  6572. The computed gamma correction value of the pixel component value,
  6573. clipped to the @var{minval}-@var{maxval} range. It corresponds to the
  6574. expression
  6575. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  6576. @end table
  6577. All expressions default to "val".
  6578. @subsection Examples
  6579. @itemize
  6580. @item
  6581. Negate input video:
  6582. @example
  6583. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  6584. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  6585. @end example
  6586. The above is the same as:
  6587. @example
  6588. lutrgb="r=negval:g=negval:b=negval"
  6589. lutyuv="y=negval:u=negval:v=negval"
  6590. @end example
  6591. @item
  6592. Negate luminance:
  6593. @example
  6594. lutyuv=y=negval
  6595. @end example
  6596. @item
  6597. Remove chroma components, turning the video into a graytone image:
  6598. @example
  6599. lutyuv="u=128:v=128"
  6600. @end example
  6601. @item
  6602. Apply a luma burning effect:
  6603. @example
  6604. lutyuv="y=2*val"
  6605. @end example
  6606. @item
  6607. Remove green and blue components:
  6608. @example
  6609. lutrgb="g=0:b=0"
  6610. @end example
  6611. @item
  6612. Set a constant alpha channel value on input:
  6613. @example
  6614. format=rgba,lutrgb=a="maxval-minval/2"
  6615. @end example
  6616. @item
  6617. Correct luminance gamma by a factor of 0.5:
  6618. @example
  6619. lutyuv=y=gammaval(0.5)
  6620. @end example
  6621. @item
  6622. Discard least significant bits of luma:
  6623. @example
  6624. lutyuv=y='bitand(val, 128+64+32)'
  6625. @end example
  6626. @end itemize
  6627. @section maskedmerge
  6628. Merge the first input stream with the second input stream using per pixel
  6629. weights in the third input stream.
  6630. A value of 0 in the third stream pixel component means that pixel component
  6631. from first stream is returned unchanged, while maximum value (eg. 255 for
  6632. 8-bit videos) means that pixel component from second stream is returned
  6633. unchanged. Intermediate values define the amount of merging between both
  6634. input stream's pixel components.
  6635. This filter accepts the following options:
  6636. @table @option
  6637. @item planes
  6638. Set which planes will be processed as bitmap, unprocessed planes will be
  6639. copied from first stream.
  6640. By default value 0xf, all planes will be processed.
  6641. @end table
  6642. @section mcdeint
  6643. Apply motion-compensation deinterlacing.
  6644. It needs one field per frame as input and must thus be used together
  6645. with yadif=1/3 or equivalent.
  6646. This filter accepts the following options:
  6647. @table @option
  6648. @item mode
  6649. Set the deinterlacing mode.
  6650. It accepts one of the following values:
  6651. @table @samp
  6652. @item fast
  6653. @item medium
  6654. @item slow
  6655. use iterative motion estimation
  6656. @item extra_slow
  6657. like @samp{slow}, but use multiple reference frames.
  6658. @end table
  6659. Default value is @samp{fast}.
  6660. @item parity
  6661. Set the picture field parity assumed for the input video. It must be
  6662. one of the following values:
  6663. @table @samp
  6664. @item 0, tff
  6665. assume top field first
  6666. @item 1, bff
  6667. assume bottom field first
  6668. @end table
  6669. Default value is @samp{bff}.
  6670. @item qp
  6671. Set per-block quantization parameter (QP) used by the internal
  6672. encoder.
  6673. Higher values should result in a smoother motion vector field but less
  6674. optimal individual vectors. Default value is 1.
  6675. @end table
  6676. @section mergeplanes
  6677. Merge color channel components from several video streams.
  6678. The filter accepts up to 4 input streams, and merge selected input
  6679. planes to the output video.
  6680. This filter accepts the following options:
  6681. @table @option
  6682. @item mapping
  6683. Set input to output plane mapping. Default is @code{0}.
  6684. The mappings is specified as a bitmap. It should be specified as a
  6685. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  6686. mapping for the first plane of the output stream. 'A' sets the number of
  6687. the input stream to use (from 0 to 3), and 'a' the plane number of the
  6688. corresponding input to use (from 0 to 3). The rest of the mappings is
  6689. similar, 'Bb' describes the mapping for the output stream second
  6690. plane, 'Cc' describes the mapping for the output stream third plane and
  6691. 'Dd' describes the mapping for the output stream fourth plane.
  6692. @item format
  6693. Set output pixel format. Default is @code{yuva444p}.
  6694. @end table
  6695. @subsection Examples
  6696. @itemize
  6697. @item
  6698. Merge three gray video streams of same width and height into single video stream:
  6699. @example
  6700. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  6701. @end example
  6702. @item
  6703. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  6704. @example
  6705. [a0][a1]mergeplanes=0x00010210:yuva444p
  6706. @end example
  6707. @item
  6708. Swap Y and A plane in yuva444p stream:
  6709. @example
  6710. format=yuva444p,mergeplanes=0x03010200:yuva444p
  6711. @end example
  6712. @item
  6713. Swap U and V plane in yuv420p stream:
  6714. @example
  6715. format=yuv420p,mergeplanes=0x000201:yuv420p
  6716. @end example
  6717. @item
  6718. Cast a rgb24 clip to yuv444p:
  6719. @example
  6720. format=rgb24,mergeplanes=0x000102:yuv444p
  6721. @end example
  6722. @end itemize
  6723. @section metadata, ametadata
  6724. Manipulate frame metadata.
  6725. This filter accepts the following options:
  6726. @table @option
  6727. @item mode
  6728. Set mode of operation of the filter.
  6729. Can be one of the following:
  6730. @table @samp
  6731. @item select
  6732. If both @code{value} and @code{key} is set, select frames
  6733. which have such metadata. If only @code{key} is set, select
  6734. every frame that has such key in metadata.
  6735. @item add
  6736. Add new metadata @code{key} and @code{value}. If key is already available
  6737. do nothing.
  6738. @item modify
  6739. Modify value of already present key.
  6740. @item delete
  6741. If @code{value} is set, delete only keys that have such value.
  6742. Otherwise, delete key.
  6743. @item print
  6744. Print key and its value if metadata was found. If @code{key} is not set print all
  6745. metadata values available in frame.
  6746. @end table
  6747. @item key
  6748. Set key used with all modes. Must be set for all modes except @code{print}.
  6749. @item value
  6750. Set metadata value which will be used. This option is mandatory for
  6751. @code{modify} and @code{add} mode.
  6752. @item function
  6753. Which function to use when comparing metadata value and @code{value}.
  6754. Can be one of following:
  6755. @table @samp
  6756. @item same_str
  6757. Values are interpreted as strings, returns true if metadata value is same as @code{value}.
  6758. @item starts_with
  6759. Values are interpreted as strings, returns true if metadata value starts with
  6760. the @code{value} option string.
  6761. @item less
  6762. Values are interpreted as floats, returns true if metadata value is less than @code{value}.
  6763. @item equal
  6764. Values are interpreted as floats, returns true if @code{value} is equal with metadata value.
  6765. @item greater
  6766. Values are interpreted as floats, returns true if metadata value is greater than @code{value}.
  6767. @item expr
  6768. Values are interpreted as floats, returns true if expression from option @code{expr}
  6769. evaluates to true.
  6770. @end table
  6771. @item expr
  6772. Set expression which is used when @code{function} is set to @code{expr}.
  6773. The expression is evaluated through the eval API and can contain the following
  6774. constants:
  6775. @table @option
  6776. @item VALUE1
  6777. Float representation of @code{value} from metadata key.
  6778. @item VALUE2
  6779. Float representation of @code{value} as supplied by user in @code{value} option.
  6780. @end table
  6781. @item file
  6782. If specified in @code{print} mode, output is written to the named file. When
  6783. filename equals "-" data is written to standard output.
  6784. If @code{file} option is not set, output is written to the log with AV_LOG_INFO
  6785. loglevel.
  6786. @end table
  6787. @subsection Examples
  6788. @itemize
  6789. @item
  6790. Print all metadata values for frames with key @code{lavfi.singnalstats.YDIF} with values
  6791. between 0 and 1.
  6792. @example
  6793. @end example
  6794. signalstats,metadata=print:key=lavfi.signalstats.YDIF:value=0:function=expr:expr='between(VALUE1,0,1)'
  6795. @end itemize
  6796. @section mpdecimate
  6797. Drop frames that do not differ greatly from the previous frame in
  6798. order to reduce frame rate.
  6799. The main use of this filter is for very-low-bitrate encoding
  6800. (e.g. streaming over dialup modem), but it could in theory be used for
  6801. fixing movies that were inverse-telecined incorrectly.
  6802. A description of the accepted options follows.
  6803. @table @option
  6804. @item max
  6805. Set the maximum number of consecutive frames which can be dropped (if
  6806. positive), or the minimum interval between dropped frames (if
  6807. negative). If the value is 0, the frame is dropped unregarding the
  6808. number of previous sequentially dropped frames.
  6809. Default value is 0.
  6810. @item hi
  6811. @item lo
  6812. @item frac
  6813. Set the dropping threshold values.
  6814. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  6815. represent actual pixel value differences, so a threshold of 64
  6816. corresponds to 1 unit of difference for each pixel, or the same spread
  6817. out differently over the block.
  6818. A frame is a candidate for dropping if no 8x8 blocks differ by more
  6819. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  6820. meaning the whole image) differ by more than a threshold of @option{lo}.
  6821. Default value for @option{hi} is 64*12, default value for @option{lo} is
  6822. 64*5, and default value for @option{frac} is 0.33.
  6823. @end table
  6824. @section negate
  6825. Negate input video.
  6826. It accepts an integer in input; if non-zero it negates the
  6827. alpha component (if available). The default value in input is 0.
  6828. @section nnedi
  6829. Deinterlace video using neural network edge directed interpolation.
  6830. This filter accepts the following options:
  6831. @table @option
  6832. @item weights
  6833. Mandatory option, without binary file filter can not work.
  6834. Currently file can be found here:
  6835. https://github.com/dubhater/vapoursynth-nnedi3/blob/master/src/nnedi3_weights.bin
  6836. @item deint
  6837. Set which frames to deinterlace, by default it is @code{all}.
  6838. Can be @code{all} or @code{interlaced}.
  6839. @item field
  6840. Set mode of operation.
  6841. Can be one of the following:
  6842. @table @samp
  6843. @item af
  6844. Use frame flags, both fields.
  6845. @item a
  6846. Use frame flags, single field.
  6847. @item t
  6848. Use top field only.
  6849. @item b
  6850. Use bottom field only.
  6851. @item tf
  6852. Use both fields, top first.
  6853. @item bf
  6854. Use both fields, bottom first.
  6855. @end table
  6856. @item planes
  6857. Set which planes to process, by default filter process all frames.
  6858. @item nsize
  6859. Set size of local neighborhood around each pixel, used by the predictor neural
  6860. network.
  6861. Can be one of the following:
  6862. @table @samp
  6863. @item s8x6
  6864. @item s16x6
  6865. @item s32x6
  6866. @item s48x6
  6867. @item s8x4
  6868. @item s16x4
  6869. @item s32x4
  6870. @end table
  6871. @item nns
  6872. Set the number of neurons in predicctor neural network.
  6873. Can be one of the following:
  6874. @table @samp
  6875. @item n16
  6876. @item n32
  6877. @item n64
  6878. @item n128
  6879. @item n256
  6880. @end table
  6881. @item qual
  6882. Controls the number of different neural network predictions that are blended
  6883. together to compute the final output value. Can be @code{fast}, default or
  6884. @code{slow}.
  6885. @item etype
  6886. Set which set of weights to use in the predictor.
  6887. Can be one of the following:
  6888. @table @samp
  6889. @item a
  6890. weights trained to minimize absolute error
  6891. @item s
  6892. weights trained to minimize squared error
  6893. @end table
  6894. @item pscrn
  6895. Controls whether or not the prescreener neural network is used to decide
  6896. which pixels should be processed by the predictor neural network and which
  6897. can be handled by simple cubic interpolation.
  6898. The prescreener is trained to know whether cubic interpolation will be
  6899. sufficient for a pixel or whether it should be predicted by the predictor nn.
  6900. The computational complexity of the prescreener nn is much less than that of
  6901. the predictor nn. Since most pixels can be handled by cubic interpolation,
  6902. using the prescreener generally results in much faster processing.
  6903. The prescreener is pretty accurate, so the difference between using it and not
  6904. using it is almost always unnoticeable.
  6905. Can be one of the following:
  6906. @table @samp
  6907. @item none
  6908. @item original
  6909. @item new
  6910. @end table
  6911. Default is @code{new}.
  6912. @item fapprox
  6913. Set various debugging flags.
  6914. @end table
  6915. @section noformat
  6916. Force libavfilter not to use any of the specified pixel formats for the
  6917. input to the next filter.
  6918. It accepts the following parameters:
  6919. @table @option
  6920. @item pix_fmts
  6921. A '|'-separated list of pixel format names, such as
  6922. apix_fmts=yuv420p|monow|rgb24".
  6923. @end table
  6924. @subsection Examples
  6925. @itemize
  6926. @item
  6927. Force libavfilter to use a format different from @var{yuv420p} for the
  6928. input to the vflip filter:
  6929. @example
  6930. noformat=pix_fmts=yuv420p,vflip
  6931. @end example
  6932. @item
  6933. Convert the input video to any of the formats not contained in the list:
  6934. @example
  6935. noformat=yuv420p|yuv444p|yuv410p
  6936. @end example
  6937. @end itemize
  6938. @section noise
  6939. Add noise on video input frame.
  6940. The filter accepts the following options:
  6941. @table @option
  6942. @item all_seed
  6943. @item c0_seed
  6944. @item c1_seed
  6945. @item c2_seed
  6946. @item c3_seed
  6947. Set noise seed for specific pixel component or all pixel components in case
  6948. of @var{all_seed}. Default value is @code{123457}.
  6949. @item all_strength, alls
  6950. @item c0_strength, c0s
  6951. @item c1_strength, c1s
  6952. @item c2_strength, c2s
  6953. @item c3_strength, c3s
  6954. Set noise strength for specific pixel component or all pixel components in case
  6955. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  6956. @item all_flags, allf
  6957. @item c0_flags, c0f
  6958. @item c1_flags, c1f
  6959. @item c2_flags, c2f
  6960. @item c3_flags, c3f
  6961. Set pixel component flags or set flags for all components if @var{all_flags}.
  6962. Available values for component flags are:
  6963. @table @samp
  6964. @item a
  6965. averaged temporal noise (smoother)
  6966. @item p
  6967. mix random noise with a (semi)regular pattern
  6968. @item t
  6969. temporal noise (noise pattern changes between frames)
  6970. @item u
  6971. uniform noise (gaussian otherwise)
  6972. @end table
  6973. @end table
  6974. @subsection Examples
  6975. Add temporal and uniform noise to input video:
  6976. @example
  6977. noise=alls=20:allf=t+u
  6978. @end example
  6979. @section null
  6980. Pass the video source unchanged to the output.
  6981. @section ocr
  6982. Optical Character Recognition
  6983. This filter uses Tesseract for optical character recognition.
  6984. It accepts the following options:
  6985. @table @option
  6986. @item datapath
  6987. Set datapath to tesseract data. Default is to use whatever was
  6988. set at installation.
  6989. @item language
  6990. Set language, default is "eng".
  6991. @item whitelist
  6992. Set character whitelist.
  6993. @item blacklist
  6994. Set character blacklist.
  6995. @end table
  6996. The filter exports recognized text as the frame metadata @code{lavfi.ocr.text}.
  6997. @section ocv
  6998. Apply a video transform using libopencv.
  6999. To enable this filter, install the libopencv library and headers and
  7000. configure FFmpeg with @code{--enable-libopencv}.
  7001. It accepts the following parameters:
  7002. @table @option
  7003. @item filter_name
  7004. The name of the libopencv filter to apply.
  7005. @item filter_params
  7006. The parameters to pass to the libopencv filter. If not specified, the default
  7007. values are assumed.
  7008. @end table
  7009. Refer to the official libopencv documentation for more precise
  7010. information:
  7011. @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
  7012. Several libopencv filters are supported; see the following subsections.
  7013. @anchor{dilate}
  7014. @subsection dilate
  7015. Dilate an image by using a specific structuring element.
  7016. It corresponds to the libopencv function @code{cvDilate}.
  7017. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  7018. @var{struct_el} represents a structuring element, and has the syntax:
  7019. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  7020. @var{cols} and @var{rows} represent the number of columns and rows of
  7021. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  7022. point, and @var{shape} the shape for the structuring element. @var{shape}
  7023. must be "rect", "cross", "ellipse", or "custom".
  7024. If the value for @var{shape} is "custom", it must be followed by a
  7025. string of the form "=@var{filename}". The file with name
  7026. @var{filename} is assumed to represent a binary image, with each
  7027. printable character corresponding to a bright pixel. When a custom
  7028. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  7029. or columns and rows of the read file are assumed instead.
  7030. The default value for @var{struct_el} is "3x3+0x0/rect".
  7031. @var{nb_iterations} specifies the number of times the transform is
  7032. applied to the image, and defaults to 1.
  7033. Some examples:
  7034. @example
  7035. # Use the default values
  7036. ocv=dilate
  7037. # Dilate using a structuring element with a 5x5 cross, iterating two times
  7038. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  7039. # Read the shape from the file diamond.shape, iterating two times.
  7040. # The file diamond.shape may contain a pattern of characters like this
  7041. # *
  7042. # ***
  7043. # *****
  7044. # ***
  7045. # *
  7046. # The specified columns and rows are ignored
  7047. # but the anchor point coordinates are not
  7048. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  7049. @end example
  7050. @subsection erode
  7051. Erode an image by using a specific structuring element.
  7052. It corresponds to the libopencv function @code{cvErode}.
  7053. It accepts the parameters: @var{struct_el}:@var{nb_iterations},
  7054. with the same syntax and semantics as the @ref{dilate} filter.
  7055. @subsection smooth
  7056. Smooth the input video.
  7057. The filter takes the following parameters:
  7058. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  7059. @var{type} is the type of smooth filter to apply, and must be one of
  7060. the following values: "blur", "blur_no_scale", "median", "gaussian",
  7061. or "bilateral". The default value is "gaussian".
  7062. The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
  7063. depend on the smooth type. @var{param1} and
  7064. @var{param2} accept integer positive values or 0. @var{param3} and
  7065. @var{param4} accept floating point values.
  7066. The default value for @var{param1} is 3. The default value for the
  7067. other parameters is 0.
  7068. These parameters correspond to the parameters assigned to the
  7069. libopencv function @code{cvSmooth}.
  7070. @anchor{overlay}
  7071. @section overlay
  7072. Overlay one video on top of another.
  7073. It takes two inputs and has one output. The first input is the "main"
  7074. video on which the second input is overlaid.
  7075. It accepts the following parameters:
  7076. A description of the accepted options follows.
  7077. @table @option
  7078. @item x
  7079. @item y
  7080. Set the expression for the x and y coordinates of the overlaid video
  7081. on the main video. Default value is "0" for both expressions. In case
  7082. the expression is invalid, it is set to a huge value (meaning that the
  7083. overlay will not be displayed within the output visible area).
  7084. @item eof_action
  7085. The action to take when EOF is encountered on the secondary input; it accepts
  7086. one of the following values:
  7087. @table @option
  7088. @item repeat
  7089. Repeat the last frame (the default).
  7090. @item endall
  7091. End both streams.
  7092. @item pass
  7093. Pass the main input through.
  7094. @end table
  7095. @item eval
  7096. Set when the expressions for @option{x}, and @option{y} are evaluated.
  7097. It accepts the following values:
  7098. @table @samp
  7099. @item init
  7100. only evaluate expressions once during the filter initialization or
  7101. when a command is processed
  7102. @item frame
  7103. evaluate expressions for each incoming frame
  7104. @end table
  7105. Default value is @samp{frame}.
  7106. @item shortest
  7107. If set to 1, force the output to terminate when the shortest input
  7108. terminates. Default value is 0.
  7109. @item format
  7110. Set the format for the output video.
  7111. It accepts the following values:
  7112. @table @samp
  7113. @item yuv420
  7114. force YUV420 output
  7115. @item yuv422
  7116. force YUV422 output
  7117. @item yuv444
  7118. force YUV444 output
  7119. @item rgb
  7120. force RGB output
  7121. @end table
  7122. Default value is @samp{yuv420}.
  7123. @item rgb @emph{(deprecated)}
  7124. If set to 1, force the filter to accept inputs in the RGB
  7125. color space. Default value is 0. This option is deprecated, use
  7126. @option{format} instead.
  7127. @item repeatlast
  7128. If set to 1, force the filter to draw the last overlay frame over the
  7129. main input until the end of the stream. A value of 0 disables this
  7130. behavior. Default value is 1.
  7131. @end table
  7132. The @option{x}, and @option{y} expressions can contain the following
  7133. parameters.
  7134. @table @option
  7135. @item main_w, W
  7136. @item main_h, H
  7137. The main input width and height.
  7138. @item overlay_w, w
  7139. @item overlay_h, h
  7140. The overlay input width and height.
  7141. @item x
  7142. @item y
  7143. The computed values for @var{x} and @var{y}. They are evaluated for
  7144. each new frame.
  7145. @item hsub
  7146. @item vsub
  7147. horizontal and vertical chroma subsample values of the output
  7148. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  7149. @var{vsub} is 1.
  7150. @item n
  7151. the number of input frame, starting from 0
  7152. @item pos
  7153. the position in the file of the input frame, NAN if unknown
  7154. @item t
  7155. The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
  7156. @end table
  7157. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  7158. when evaluation is done @emph{per frame}, and will evaluate to NAN
  7159. when @option{eval} is set to @samp{init}.
  7160. Be aware that frames are taken from each input video in timestamp
  7161. order, hence, if their initial timestamps differ, it is a good idea
  7162. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  7163. have them begin in the same zero timestamp, as the example for
  7164. the @var{movie} filter does.
  7165. You can chain together more overlays but you should test the
  7166. efficiency of such approach.
  7167. @subsection Commands
  7168. This filter supports the following commands:
  7169. @table @option
  7170. @item x
  7171. @item y
  7172. Modify the x and y of the overlay input.
  7173. The command accepts the same syntax of the corresponding option.
  7174. If the specified expression is not valid, it is kept at its current
  7175. value.
  7176. @end table
  7177. @subsection Examples
  7178. @itemize
  7179. @item
  7180. Draw the overlay at 10 pixels from the bottom right corner of the main
  7181. video:
  7182. @example
  7183. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  7184. @end example
  7185. Using named options the example above becomes:
  7186. @example
  7187. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  7188. @end example
  7189. @item
  7190. Insert a transparent PNG logo in the bottom left corner of the input,
  7191. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  7192. @example
  7193. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  7194. @end example
  7195. @item
  7196. Insert 2 different transparent PNG logos (second logo on bottom
  7197. right corner) using the @command{ffmpeg} tool:
  7198. @example
  7199. 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
  7200. @end example
  7201. @item
  7202. Add a transparent color layer on top of the main video; @code{WxH}
  7203. must specify the size of the main input to the overlay filter:
  7204. @example
  7205. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  7206. @end example
  7207. @item
  7208. Play an original video and a filtered version (here with the deshake
  7209. filter) side by side using the @command{ffplay} tool:
  7210. @example
  7211. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  7212. @end example
  7213. The above command is the same as:
  7214. @example
  7215. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  7216. @end example
  7217. @item
  7218. Make a sliding overlay appearing from the left to the right top part of the
  7219. screen starting since time 2:
  7220. @example
  7221. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  7222. @end example
  7223. @item
  7224. Compose output by putting two input videos side to side:
  7225. @example
  7226. ffmpeg -i left.avi -i right.avi -filter_complex "
  7227. nullsrc=size=200x100 [background];
  7228. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  7229. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  7230. [background][left] overlay=shortest=1 [background+left];
  7231. [background+left][right] overlay=shortest=1:x=100 [left+right]
  7232. "
  7233. @end example
  7234. @item
  7235. Mask 10-20 seconds of a video by applying the delogo filter to a section
  7236. @example
  7237. ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
  7238. -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]'
  7239. masked.avi
  7240. @end example
  7241. @item
  7242. Chain several overlays in cascade:
  7243. @example
  7244. nullsrc=s=200x200 [bg];
  7245. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  7246. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  7247. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  7248. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  7249. [in3] null, [mid2] overlay=100:100 [out0]
  7250. @end example
  7251. @end itemize
  7252. @section owdenoise
  7253. Apply Overcomplete Wavelet denoiser.
  7254. The filter accepts the following options:
  7255. @table @option
  7256. @item depth
  7257. Set depth.
  7258. Larger depth values will denoise lower frequency components more, but
  7259. slow down filtering.
  7260. Must be an int in the range 8-16, default is @code{8}.
  7261. @item luma_strength, ls
  7262. Set luma strength.
  7263. Must be a double value in the range 0-1000, default is @code{1.0}.
  7264. @item chroma_strength, cs
  7265. Set chroma strength.
  7266. Must be a double value in the range 0-1000, default is @code{1.0}.
  7267. @end table
  7268. @anchor{pad}
  7269. @section pad
  7270. Add paddings to the input image, and place the original input at the
  7271. provided @var{x}, @var{y} coordinates.
  7272. It accepts the following parameters:
  7273. @table @option
  7274. @item width, w
  7275. @item height, h
  7276. Specify an expression for the size of the output image with the
  7277. paddings added. If the value for @var{width} or @var{height} is 0, the
  7278. corresponding input size is used for the output.
  7279. The @var{width} expression can reference the value set by the
  7280. @var{height} expression, and vice versa.
  7281. The default value of @var{width} and @var{height} is 0.
  7282. @item x
  7283. @item y
  7284. Specify the offsets to place the input image at within the padded area,
  7285. with respect to the top/left border of the output image.
  7286. The @var{x} expression can reference the value set by the @var{y}
  7287. expression, and vice versa.
  7288. The default value of @var{x} and @var{y} is 0.
  7289. @item color
  7290. Specify the color of the padded area. For the syntax of this option,
  7291. check the "Color" section in the ffmpeg-utils manual.
  7292. The default value of @var{color} is "black".
  7293. @end table
  7294. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  7295. options are expressions containing the following constants:
  7296. @table @option
  7297. @item in_w
  7298. @item in_h
  7299. The input video width and height.
  7300. @item iw
  7301. @item ih
  7302. These are the same as @var{in_w} and @var{in_h}.
  7303. @item out_w
  7304. @item out_h
  7305. The output width and height (the size of the padded area), as
  7306. specified by the @var{width} and @var{height} expressions.
  7307. @item ow
  7308. @item oh
  7309. These are the same as @var{out_w} and @var{out_h}.
  7310. @item x
  7311. @item y
  7312. The x and y offsets as specified by the @var{x} and @var{y}
  7313. expressions, or NAN if not yet specified.
  7314. @item a
  7315. same as @var{iw} / @var{ih}
  7316. @item sar
  7317. input sample aspect ratio
  7318. @item dar
  7319. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  7320. @item hsub
  7321. @item vsub
  7322. The horizontal and vertical chroma subsample values. For example for the
  7323. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7324. @end table
  7325. @subsection Examples
  7326. @itemize
  7327. @item
  7328. Add paddings with the color "violet" to the input video. The output video
  7329. size is 640x480, and the top-left corner of the input video is placed at
  7330. column 0, row 40
  7331. @example
  7332. pad=640:480:0:40:violet
  7333. @end example
  7334. The example above is equivalent to the following command:
  7335. @example
  7336. pad=width=640:height=480:x=0:y=40:color=violet
  7337. @end example
  7338. @item
  7339. Pad the input to get an output with dimensions increased by 3/2,
  7340. and put the input video at the center of the padded area:
  7341. @example
  7342. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  7343. @end example
  7344. @item
  7345. Pad the input to get a squared output with size equal to the maximum
  7346. value between the input width and height, and put the input video at
  7347. the center of the padded area:
  7348. @example
  7349. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  7350. @end example
  7351. @item
  7352. Pad the input to get a final w/h ratio of 16:9:
  7353. @example
  7354. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  7355. @end example
  7356. @item
  7357. In case of anamorphic video, in order to set the output display aspect
  7358. correctly, it is necessary to use @var{sar} in the expression,
  7359. according to the relation:
  7360. @example
  7361. (ih * X / ih) * sar = output_dar
  7362. X = output_dar / sar
  7363. @end example
  7364. Thus the previous example needs to be modified to:
  7365. @example
  7366. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  7367. @end example
  7368. @item
  7369. Double the output size and put the input video in the bottom-right
  7370. corner of the output padded area:
  7371. @example
  7372. pad="2*iw:2*ih:ow-iw:oh-ih"
  7373. @end example
  7374. @end itemize
  7375. @anchor{palettegen}
  7376. @section palettegen
  7377. Generate one palette for a whole video stream.
  7378. It accepts the following options:
  7379. @table @option
  7380. @item max_colors
  7381. Set the maximum number of colors to quantize in the palette.
  7382. Note: the palette will still contain 256 colors; the unused palette entries
  7383. will be black.
  7384. @item reserve_transparent
  7385. Create a palette of 255 colors maximum and reserve the last one for
  7386. transparency. Reserving the transparency color is useful for GIF optimization.
  7387. If not set, the maximum of colors in the palette will be 256. You probably want
  7388. to disable this option for a standalone image.
  7389. Set by default.
  7390. @item stats_mode
  7391. Set statistics mode.
  7392. It accepts the following values:
  7393. @table @samp
  7394. @item full
  7395. Compute full frame histograms.
  7396. @item diff
  7397. Compute histograms only for the part that differs from previous frame. This
  7398. might be relevant to give more importance to the moving part of your input if
  7399. the background is static.
  7400. @end table
  7401. Default value is @var{full}.
  7402. @end table
  7403. The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
  7404. (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
  7405. color quantization of the palette. This information is also visible at
  7406. @var{info} logging level.
  7407. @subsection Examples
  7408. @itemize
  7409. @item
  7410. Generate a representative palette of a given video using @command{ffmpeg}:
  7411. @example
  7412. ffmpeg -i input.mkv -vf palettegen palette.png
  7413. @end example
  7414. @end itemize
  7415. @section paletteuse
  7416. Use a palette to downsample an input video stream.
  7417. The filter takes two inputs: one video stream and a palette. The palette must
  7418. be a 256 pixels image.
  7419. It accepts the following options:
  7420. @table @option
  7421. @item dither
  7422. Select dithering mode. Available algorithms are:
  7423. @table @samp
  7424. @item bayer
  7425. Ordered 8x8 bayer dithering (deterministic)
  7426. @item heckbert
  7427. Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
  7428. Note: this dithering is sometimes considered "wrong" and is included as a
  7429. reference.
  7430. @item floyd_steinberg
  7431. Floyd and Steingberg dithering (error diffusion)
  7432. @item sierra2
  7433. Frankie Sierra dithering v2 (error diffusion)
  7434. @item sierra2_4a
  7435. Frankie Sierra dithering v2 "Lite" (error diffusion)
  7436. @end table
  7437. Default is @var{sierra2_4a}.
  7438. @item bayer_scale
  7439. When @var{bayer} dithering is selected, this option defines the scale of the
  7440. pattern (how much the crosshatch pattern is visible). A low value means more
  7441. visible pattern for less banding, and higher value means less visible pattern
  7442. at the cost of more banding.
  7443. The option must be an integer value in the range [0,5]. Default is @var{2}.
  7444. @item diff_mode
  7445. If set, define the zone to process
  7446. @table @samp
  7447. @item rectangle
  7448. Only the changing rectangle will be reprocessed. This is similar to GIF
  7449. cropping/offsetting compression mechanism. This option can be useful for speed
  7450. if only a part of the image is changing, and has use cases such as limiting the
  7451. scope of the error diffusal @option{dither} to the rectangle that bounds the
  7452. moving scene (it leads to more deterministic output if the scene doesn't change
  7453. much, and as a result less moving noise and better GIF compression).
  7454. @end table
  7455. Default is @var{none}.
  7456. @end table
  7457. @subsection Examples
  7458. @itemize
  7459. @item
  7460. Use a palette (generated for example with @ref{palettegen}) to encode a GIF
  7461. using @command{ffmpeg}:
  7462. @example
  7463. ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
  7464. @end example
  7465. @end itemize
  7466. @section perspective
  7467. Correct perspective of video not recorded perpendicular to the screen.
  7468. A description of the accepted parameters follows.
  7469. @table @option
  7470. @item x0
  7471. @item y0
  7472. @item x1
  7473. @item y1
  7474. @item x2
  7475. @item y2
  7476. @item x3
  7477. @item y3
  7478. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  7479. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  7480. If the @code{sense} option is set to @code{source}, then the specified points will be sent
  7481. to the corners of the destination. If the @code{sense} option is set to @code{destination},
  7482. then the corners of the source will be sent to the specified coordinates.
  7483. The expressions can use the following variables:
  7484. @table @option
  7485. @item W
  7486. @item H
  7487. the width and height of video frame.
  7488. @end table
  7489. @item interpolation
  7490. Set interpolation for perspective correction.
  7491. It accepts the following values:
  7492. @table @samp
  7493. @item linear
  7494. @item cubic
  7495. @end table
  7496. Default value is @samp{linear}.
  7497. @item sense
  7498. Set interpretation of coordinate options.
  7499. It accepts the following values:
  7500. @table @samp
  7501. @item 0, source
  7502. Send point in the source specified by the given coordinates to
  7503. the corners of the destination.
  7504. @item 1, destination
  7505. Send the corners of the source to the point in the destination specified
  7506. by the given coordinates.
  7507. Default value is @samp{source}.
  7508. @end table
  7509. @end table
  7510. @section phase
  7511. Delay interlaced video by one field time so that the field order changes.
  7512. The intended use is to fix PAL movies that have been captured with the
  7513. opposite field order to the film-to-video transfer.
  7514. A description of the accepted parameters follows.
  7515. @table @option
  7516. @item mode
  7517. Set phase mode.
  7518. It accepts the following values:
  7519. @table @samp
  7520. @item t
  7521. Capture field order top-first, transfer bottom-first.
  7522. Filter will delay the bottom field.
  7523. @item b
  7524. Capture field order bottom-first, transfer top-first.
  7525. Filter will delay the top field.
  7526. @item p
  7527. Capture and transfer with the same field order. This mode only exists
  7528. for the documentation of the other options to refer to, but if you
  7529. actually select it, the filter will faithfully do nothing.
  7530. @item a
  7531. Capture field order determined automatically by field flags, transfer
  7532. opposite.
  7533. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  7534. basis using field flags. If no field information is available,
  7535. then this works just like @samp{u}.
  7536. @item u
  7537. Capture unknown or varying, transfer opposite.
  7538. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  7539. analyzing the images and selecting the alternative that produces best
  7540. match between the fields.
  7541. @item T
  7542. Capture top-first, transfer unknown or varying.
  7543. Filter selects among @samp{t} and @samp{p} using image analysis.
  7544. @item B
  7545. Capture bottom-first, transfer unknown or varying.
  7546. Filter selects among @samp{b} and @samp{p} using image analysis.
  7547. @item A
  7548. Capture determined by field flags, transfer unknown or varying.
  7549. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  7550. image analysis. If no field information is available, then this works just
  7551. like @samp{U}. This is the default mode.
  7552. @item U
  7553. Both capture and transfer unknown or varying.
  7554. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  7555. @end table
  7556. @end table
  7557. @section pixdesctest
  7558. Pixel format descriptor test filter, mainly useful for internal
  7559. testing. The output video should be equal to the input video.
  7560. For example:
  7561. @example
  7562. format=monow, pixdesctest
  7563. @end example
  7564. can be used to test the monowhite pixel format descriptor definition.
  7565. @section pp
  7566. Enable the specified chain of postprocessing subfilters using libpostproc. This
  7567. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  7568. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  7569. Each subfilter and some options have a short and a long name that can be used
  7570. interchangeably, i.e. dr/dering are the same.
  7571. The filters accept the following options:
  7572. @table @option
  7573. @item subfilters
  7574. Set postprocessing subfilters string.
  7575. @end table
  7576. All subfilters share common options to determine their scope:
  7577. @table @option
  7578. @item a/autoq
  7579. Honor the quality commands for this subfilter.
  7580. @item c/chrom
  7581. Do chrominance filtering, too (default).
  7582. @item y/nochrom
  7583. Do luminance filtering only (no chrominance).
  7584. @item n/noluma
  7585. Do chrominance filtering only (no luminance).
  7586. @end table
  7587. These options can be appended after the subfilter name, separated by a '|'.
  7588. Available subfilters are:
  7589. @table @option
  7590. @item hb/hdeblock[|difference[|flatness]]
  7591. Horizontal deblocking filter
  7592. @table @option
  7593. @item difference
  7594. Difference factor where higher values mean more deblocking (default: @code{32}).
  7595. @item flatness
  7596. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7597. @end table
  7598. @item vb/vdeblock[|difference[|flatness]]
  7599. Vertical deblocking filter
  7600. @table @option
  7601. @item difference
  7602. Difference factor where higher values mean more deblocking (default: @code{32}).
  7603. @item flatness
  7604. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7605. @end table
  7606. @item ha/hadeblock[|difference[|flatness]]
  7607. Accurate horizontal deblocking filter
  7608. @table @option
  7609. @item difference
  7610. Difference factor where higher values mean more deblocking (default: @code{32}).
  7611. @item flatness
  7612. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7613. @end table
  7614. @item va/vadeblock[|difference[|flatness]]
  7615. Accurate vertical deblocking filter
  7616. @table @option
  7617. @item difference
  7618. Difference factor where higher values mean more deblocking (default: @code{32}).
  7619. @item flatness
  7620. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7621. @end table
  7622. @end table
  7623. The horizontal and vertical deblocking filters share the difference and
  7624. flatness values so you cannot set different horizontal and vertical
  7625. thresholds.
  7626. @table @option
  7627. @item h1/x1hdeblock
  7628. Experimental horizontal deblocking filter
  7629. @item v1/x1vdeblock
  7630. Experimental vertical deblocking filter
  7631. @item dr/dering
  7632. Deringing filter
  7633. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  7634. @table @option
  7635. @item threshold1
  7636. larger -> stronger filtering
  7637. @item threshold2
  7638. larger -> stronger filtering
  7639. @item threshold3
  7640. larger -> stronger filtering
  7641. @end table
  7642. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  7643. @table @option
  7644. @item f/fullyrange
  7645. Stretch luminance to @code{0-255}.
  7646. @end table
  7647. @item lb/linblenddeint
  7648. Linear blend deinterlacing filter that deinterlaces the given block by
  7649. filtering all lines with a @code{(1 2 1)} filter.
  7650. @item li/linipoldeint
  7651. Linear interpolating deinterlacing filter that deinterlaces the given block by
  7652. linearly interpolating every second line.
  7653. @item ci/cubicipoldeint
  7654. Cubic interpolating deinterlacing filter deinterlaces the given block by
  7655. cubically interpolating every second line.
  7656. @item md/mediandeint
  7657. Median deinterlacing filter that deinterlaces the given block by applying a
  7658. median filter to every second line.
  7659. @item fd/ffmpegdeint
  7660. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  7661. second line with a @code{(-1 4 2 4 -1)} filter.
  7662. @item l5/lowpass5
  7663. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  7664. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  7665. @item fq/forceQuant[|quantizer]
  7666. Overrides the quantizer table from the input with the constant quantizer you
  7667. specify.
  7668. @table @option
  7669. @item quantizer
  7670. Quantizer to use
  7671. @end table
  7672. @item de/default
  7673. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  7674. @item fa/fast
  7675. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  7676. @item ac
  7677. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  7678. @end table
  7679. @subsection Examples
  7680. @itemize
  7681. @item
  7682. Apply horizontal and vertical deblocking, deringing and automatic
  7683. brightness/contrast:
  7684. @example
  7685. pp=hb/vb/dr/al
  7686. @end example
  7687. @item
  7688. Apply default filters without brightness/contrast correction:
  7689. @example
  7690. pp=de/-al
  7691. @end example
  7692. @item
  7693. Apply default filters and temporal denoiser:
  7694. @example
  7695. pp=default/tmpnoise|1|2|3
  7696. @end example
  7697. @item
  7698. Apply deblocking on luminance only, and switch vertical deblocking on or off
  7699. automatically depending on available CPU time:
  7700. @example
  7701. pp=hb|y/vb|a
  7702. @end example
  7703. @end itemize
  7704. @section pp7
  7705. Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
  7706. similar to spp = 6 with 7 point DCT, where only the center sample is
  7707. used after IDCT.
  7708. The filter accepts the following options:
  7709. @table @option
  7710. @item qp
  7711. Force a constant quantization parameter. It accepts an integer in range
  7712. 0 to 63. If not set, the filter will use the QP from the video stream
  7713. (if available).
  7714. @item mode
  7715. Set thresholding mode. Available modes are:
  7716. @table @samp
  7717. @item hard
  7718. Set hard thresholding.
  7719. @item soft
  7720. Set soft thresholding (better de-ringing effect, but likely blurrier).
  7721. @item medium
  7722. Set medium thresholding (good results, default).
  7723. @end table
  7724. @end table
  7725. @section psnr
  7726. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  7727. Ratio) between two input videos.
  7728. This filter takes in input two input videos, the first input is
  7729. considered the "main" source and is passed unchanged to the
  7730. output. The second input is used as a "reference" video for computing
  7731. the PSNR.
  7732. Both video inputs must have the same resolution and pixel format for
  7733. this filter to work correctly. Also it assumes that both inputs
  7734. have the same number of frames, which are compared one by one.
  7735. The obtained average PSNR is printed through the logging system.
  7736. The filter stores the accumulated MSE (mean squared error) of each
  7737. frame, and at the end of the processing it is averaged across all frames
  7738. equally, and the following formula is applied to obtain the PSNR:
  7739. @example
  7740. PSNR = 10*log10(MAX^2/MSE)
  7741. @end example
  7742. Where MAX is the average of the maximum values of each component of the
  7743. image.
  7744. The description of the accepted parameters follows.
  7745. @table @option
  7746. @item stats_file, f
  7747. If specified the filter will use the named file to save the PSNR of
  7748. each individual frame. When filename equals "-" the data is sent to
  7749. standard output.
  7750. @end table
  7751. The file printed if @var{stats_file} is selected, contains a sequence of
  7752. key/value pairs of the form @var{key}:@var{value} for each compared
  7753. couple of frames.
  7754. A description of each shown parameter follows:
  7755. @table @option
  7756. @item n
  7757. sequential number of the input frame, starting from 1
  7758. @item mse_avg
  7759. Mean Square Error pixel-by-pixel average difference of the compared
  7760. frames, averaged over all the image components.
  7761. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  7762. Mean Square Error pixel-by-pixel average difference of the compared
  7763. frames for the component specified by the suffix.
  7764. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  7765. Peak Signal to Noise ratio of the compared frames for the component
  7766. specified by the suffix.
  7767. @end table
  7768. For example:
  7769. @example
  7770. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  7771. [main][ref] psnr="stats_file=stats.log" [out]
  7772. @end example
  7773. On this example the input file being processed is compared with the
  7774. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  7775. is stored in @file{stats.log}.
  7776. @anchor{pullup}
  7777. @section pullup
  7778. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  7779. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  7780. content.
  7781. The pullup filter is designed to take advantage of future context in making
  7782. its decisions. This filter is stateless in the sense that it does not lock
  7783. onto a pattern to follow, but it instead looks forward to the following
  7784. fields in order to identify matches and rebuild progressive frames.
  7785. To produce content with an even framerate, insert the fps filter after
  7786. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  7787. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  7788. The filter accepts the following options:
  7789. @table @option
  7790. @item jl
  7791. @item jr
  7792. @item jt
  7793. @item jb
  7794. These options set the amount of "junk" to ignore at the left, right, top, and
  7795. bottom of the image, respectively. Left and right are in units of 8 pixels,
  7796. while top and bottom are in units of 2 lines.
  7797. The default is 8 pixels on each side.
  7798. @item sb
  7799. Set the strict breaks. Setting this option to 1 will reduce the chances of
  7800. filter generating an occasional mismatched frame, but it may also cause an
  7801. excessive number of frames to be dropped during high motion sequences.
  7802. Conversely, setting it to -1 will make filter match fields more easily.
  7803. This may help processing of video where there is slight blurring between
  7804. the fields, but may also cause there to be interlaced frames in the output.
  7805. Default value is @code{0}.
  7806. @item mp
  7807. Set the metric plane to use. It accepts the following values:
  7808. @table @samp
  7809. @item l
  7810. Use luma plane.
  7811. @item u
  7812. Use chroma blue plane.
  7813. @item v
  7814. Use chroma red plane.
  7815. @end table
  7816. This option may be set to use chroma plane instead of the default luma plane
  7817. for doing filter's computations. This may improve accuracy on very clean
  7818. source material, but more likely will decrease accuracy, especially if there
  7819. is chroma noise (rainbow effect) or any grayscale video.
  7820. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  7821. load and make pullup usable in realtime on slow machines.
  7822. @end table
  7823. For best results (without duplicated frames in the output file) it is
  7824. necessary to change the output frame rate. For example, to inverse
  7825. telecine NTSC input:
  7826. @example
  7827. ffmpeg -i input -vf pullup -r 24000/1001 ...
  7828. @end example
  7829. @section qp
  7830. Change video quantization parameters (QP).
  7831. The filter accepts the following option:
  7832. @table @option
  7833. @item qp
  7834. Set expression for quantization parameter.
  7835. @end table
  7836. The expression is evaluated through the eval API and can contain, among others,
  7837. the following constants:
  7838. @table @var
  7839. @item known
  7840. 1 if index is not 129, 0 otherwise.
  7841. @item qp
  7842. Sequentional index starting from -129 to 128.
  7843. @end table
  7844. @subsection Examples
  7845. @itemize
  7846. @item
  7847. Some equation like:
  7848. @example
  7849. qp=2+2*sin(PI*qp)
  7850. @end example
  7851. @end itemize
  7852. @section random
  7853. Flush video frames from internal cache of frames into a random order.
  7854. No frame is discarded.
  7855. Inspired by @ref{frei0r} nervous filter.
  7856. @table @option
  7857. @item frames
  7858. Set size in number of frames of internal cache, in range from @code{2} to
  7859. @code{512}. Default is @code{30}.
  7860. @item seed
  7861. Set seed for random number generator, must be an integer included between
  7862. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  7863. less than @code{0}, the filter will try to use a good random seed on a
  7864. best effort basis.
  7865. @end table
  7866. @section removegrain
  7867. The removegrain filter is a spatial denoiser for progressive video.
  7868. @table @option
  7869. @item m0
  7870. Set mode for the first plane.
  7871. @item m1
  7872. Set mode for the second plane.
  7873. @item m2
  7874. Set mode for the third plane.
  7875. @item m3
  7876. Set mode for the fourth plane.
  7877. @end table
  7878. Range of mode is from 0 to 24. Description of each mode follows:
  7879. @table @var
  7880. @item 0
  7881. Leave input plane unchanged. Default.
  7882. @item 1
  7883. Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
  7884. @item 2
  7885. Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
  7886. @item 3
  7887. Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
  7888. @item 4
  7889. Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
  7890. This is equivalent to a median filter.
  7891. @item 5
  7892. Line-sensitive clipping giving the minimal change.
  7893. @item 6
  7894. Line-sensitive clipping, intermediate.
  7895. @item 7
  7896. Line-sensitive clipping, intermediate.
  7897. @item 8
  7898. Line-sensitive clipping, intermediate.
  7899. @item 9
  7900. Line-sensitive clipping on a line where the neighbours pixels are the closest.
  7901. @item 10
  7902. Replaces the target pixel with the closest neighbour.
  7903. @item 11
  7904. [1 2 1] horizontal and vertical kernel blur.
  7905. @item 12
  7906. Same as mode 11.
  7907. @item 13
  7908. Bob mode, interpolates top field from the line where the neighbours
  7909. pixels are the closest.
  7910. @item 14
  7911. Bob mode, interpolates bottom field from the line where the neighbours
  7912. pixels are the closest.
  7913. @item 15
  7914. Bob mode, interpolates top field. Same as 13 but with a more complicated
  7915. interpolation formula.
  7916. @item 16
  7917. Bob mode, interpolates bottom field. Same as 14 but with a more complicated
  7918. interpolation formula.
  7919. @item 17
  7920. Clips the pixel with the minimum and maximum of respectively the maximum and
  7921. minimum of each pair of opposite neighbour pixels.
  7922. @item 18
  7923. Line-sensitive clipping using opposite neighbours whose greatest distance from
  7924. the current pixel is minimal.
  7925. @item 19
  7926. Replaces the pixel with the average of its 8 neighbours.
  7927. @item 20
  7928. Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
  7929. @item 21
  7930. Clips pixels using the averages of opposite neighbour.
  7931. @item 22
  7932. Same as mode 21 but simpler and faster.
  7933. @item 23
  7934. Small edge and halo removal, but reputed useless.
  7935. @item 24
  7936. Similar as 23.
  7937. @end table
  7938. @section removelogo
  7939. Suppress a TV station logo, using an image file to determine which
  7940. pixels comprise the logo. It works by filling in the pixels that
  7941. comprise the logo with neighboring pixels.
  7942. The filter accepts the following options:
  7943. @table @option
  7944. @item filename, f
  7945. Set the filter bitmap file, which can be any image format supported by
  7946. libavformat. The width and height of the image file must match those of the
  7947. video stream being processed.
  7948. @end table
  7949. Pixels in the provided bitmap image with a value of zero are not
  7950. considered part of the logo, non-zero pixels are considered part of
  7951. the logo. If you use white (255) for the logo and black (0) for the
  7952. rest, you will be safe. For making the filter bitmap, it is
  7953. recommended to take a screen capture of a black frame with the logo
  7954. visible, and then using a threshold filter followed by the erode
  7955. filter once or twice.
  7956. If needed, little splotches can be fixed manually. Remember that if
  7957. logo pixels are not covered, the filter quality will be much
  7958. reduced. Marking too many pixels as part of the logo does not hurt as
  7959. much, but it will increase the amount of blurring needed to cover over
  7960. the image and will destroy more information than necessary, and extra
  7961. pixels will slow things down on a large logo.
  7962. @section repeatfields
  7963. This filter uses the repeat_field flag from the Video ES headers and hard repeats
  7964. fields based on its value.
  7965. @section reverse, areverse
  7966. Reverse a clip.
  7967. Warning: This filter requires memory to buffer the entire clip, so trimming
  7968. is suggested.
  7969. @subsection Examples
  7970. @itemize
  7971. @item
  7972. Take the first 5 seconds of a clip, and reverse it.
  7973. @example
  7974. trim=end=5,reverse
  7975. @end example
  7976. @end itemize
  7977. @section rotate
  7978. Rotate video by an arbitrary angle expressed in radians.
  7979. The filter accepts the following options:
  7980. A description of the optional parameters follows.
  7981. @table @option
  7982. @item angle, a
  7983. Set an expression for the angle by which to rotate the input video
  7984. clockwise, expressed as a number of radians. A negative value will
  7985. result in a counter-clockwise rotation. By default it is set to "0".
  7986. This expression is evaluated for each frame.
  7987. @item out_w, ow
  7988. Set the output width expression, default value is "iw".
  7989. This expression is evaluated just once during configuration.
  7990. @item out_h, oh
  7991. Set the output height expression, default value is "ih".
  7992. This expression is evaluated just once during configuration.
  7993. @item bilinear
  7994. Enable bilinear interpolation if set to 1, a value of 0 disables
  7995. it. Default value is 1.
  7996. @item fillcolor, c
  7997. Set the color used to fill the output area not covered by the rotated
  7998. image. For the general syntax of this option, check the "Color" section in the
  7999. ffmpeg-utils manual. If the special value "none" is selected then no
  8000. background is printed (useful for example if the background is never shown).
  8001. Default value is "black".
  8002. @end table
  8003. The expressions for the angle and the output size can contain the
  8004. following constants and functions:
  8005. @table @option
  8006. @item n
  8007. sequential number of the input frame, starting from 0. It is always NAN
  8008. before the first frame is filtered.
  8009. @item t
  8010. time in seconds of the input frame, it is set to 0 when the filter is
  8011. configured. It is always NAN before the first frame is filtered.
  8012. @item hsub
  8013. @item vsub
  8014. horizontal and vertical chroma subsample values. For example for the
  8015. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  8016. @item in_w, iw
  8017. @item in_h, ih
  8018. the input video width and height
  8019. @item out_w, ow
  8020. @item out_h, oh
  8021. the output width and height, that is the size of the padded area as
  8022. specified by the @var{width} and @var{height} expressions
  8023. @item rotw(a)
  8024. @item roth(a)
  8025. the minimal width/height required for completely containing the input
  8026. video rotated by @var{a} radians.
  8027. These are only available when computing the @option{out_w} and
  8028. @option{out_h} expressions.
  8029. @end table
  8030. @subsection Examples
  8031. @itemize
  8032. @item
  8033. Rotate the input by PI/6 radians clockwise:
  8034. @example
  8035. rotate=PI/6
  8036. @end example
  8037. @item
  8038. Rotate the input by PI/6 radians counter-clockwise:
  8039. @example
  8040. rotate=-PI/6
  8041. @end example
  8042. @item
  8043. Rotate the input by 45 degrees clockwise:
  8044. @example
  8045. rotate=45*PI/180
  8046. @end example
  8047. @item
  8048. Apply a constant rotation with period T, starting from an angle of PI/3:
  8049. @example
  8050. rotate=PI/3+2*PI*t/T
  8051. @end example
  8052. @item
  8053. Make the input video rotation oscillating with a period of T
  8054. seconds and an amplitude of A radians:
  8055. @example
  8056. rotate=A*sin(2*PI/T*t)
  8057. @end example
  8058. @item
  8059. Rotate the video, output size is chosen so that the whole rotating
  8060. input video is always completely contained in the output:
  8061. @example
  8062. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  8063. @end example
  8064. @item
  8065. Rotate the video, reduce the output size so that no background is ever
  8066. shown:
  8067. @example
  8068. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  8069. @end example
  8070. @end itemize
  8071. @subsection Commands
  8072. The filter supports the following commands:
  8073. @table @option
  8074. @item a, angle
  8075. Set the angle expression.
  8076. The command accepts the same syntax of the corresponding option.
  8077. If the specified expression is not valid, it is kept at its current
  8078. value.
  8079. @end table
  8080. @section sab
  8081. Apply Shape Adaptive Blur.
  8082. The filter accepts the following options:
  8083. @table @option
  8084. @item luma_radius, lr
  8085. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  8086. value is 1.0. A greater value will result in a more blurred image, and
  8087. in slower processing.
  8088. @item luma_pre_filter_radius, lpfr
  8089. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  8090. value is 1.0.
  8091. @item luma_strength, ls
  8092. Set luma maximum difference between pixels to still be considered, must
  8093. be a value in the 0.1-100.0 range, default value is 1.0.
  8094. @item chroma_radius, cr
  8095. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  8096. greater value will result in a more blurred image, and in slower
  8097. processing.
  8098. @item chroma_pre_filter_radius, cpfr
  8099. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  8100. @item chroma_strength, cs
  8101. Set chroma maximum difference between pixels to still be considered,
  8102. must be a value in the 0.1-100.0 range.
  8103. @end table
  8104. Each chroma option value, if not explicitly specified, is set to the
  8105. corresponding luma option value.
  8106. @anchor{scale}
  8107. @section scale
  8108. Scale (resize) the input video, using the libswscale library.
  8109. The scale filter forces the output display aspect ratio to be the same
  8110. of the input, by changing the output sample aspect ratio.
  8111. If the input image format is different from the format requested by
  8112. the next filter, the scale filter will convert the input to the
  8113. requested format.
  8114. @subsection Options
  8115. The filter accepts the following options, or any of the options
  8116. supported by the libswscale scaler.
  8117. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  8118. the complete list of scaler options.
  8119. @table @option
  8120. @item width, w
  8121. @item height, h
  8122. Set the output video dimension expression. Default value is the input
  8123. dimension.
  8124. If the value is 0, the input width is used for the output.
  8125. If one of the values is -1, the scale filter will use a value that
  8126. maintains the aspect ratio of the input image, calculated from the
  8127. other specified dimension. If both of them are -1, the input size is
  8128. used
  8129. If one of the values is -n with n > 1, the scale filter will also use a value
  8130. that maintains the aspect ratio of the input image, calculated from the other
  8131. specified dimension. After that it will, however, make sure that the calculated
  8132. dimension is divisible by n and adjust the value if necessary.
  8133. See below for the list of accepted constants for use in the dimension
  8134. expression.
  8135. @item eval
  8136. Specify when to evaluate @var{width} and @var{height} expression. It accepts the following values:
  8137. @table @samp
  8138. @item init
  8139. Only evaluate expressions once during the filter initialization or when a command is processed.
  8140. @item frame
  8141. Evaluate expressions for each incoming frame.
  8142. @end table
  8143. Default value is @samp{init}.
  8144. @item interl
  8145. Set the interlacing mode. It accepts the following values:
  8146. @table @samp
  8147. @item 1
  8148. Force interlaced aware scaling.
  8149. @item 0
  8150. Do not apply interlaced scaling.
  8151. @item -1
  8152. Select interlaced aware scaling depending on whether the source frames
  8153. are flagged as interlaced or not.
  8154. @end table
  8155. Default value is @samp{0}.
  8156. @item flags
  8157. Set libswscale scaling flags. See
  8158. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  8159. complete list of values. If not explicitly specified the filter applies
  8160. the default flags.
  8161. @item param0, param1
  8162. Set libswscale input parameters for scaling algorithms that need them. See
  8163. @ref{sws_params,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  8164. complete documentation. If not explicitly specified the filter applies
  8165. empty parameters.
  8166. @item size, s
  8167. Set the video size. For the syntax of this option, check the
  8168. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8169. @item in_color_matrix
  8170. @item out_color_matrix
  8171. Set in/output YCbCr color space type.
  8172. This allows the autodetected value to be overridden as well as allows forcing
  8173. a specific value used for the output and encoder.
  8174. If not specified, the color space type depends on the pixel format.
  8175. Possible values:
  8176. @table @samp
  8177. @item auto
  8178. Choose automatically.
  8179. @item bt709
  8180. Format conforming to International Telecommunication Union (ITU)
  8181. Recommendation BT.709.
  8182. @item fcc
  8183. Set color space conforming to the United States Federal Communications
  8184. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  8185. @item bt601
  8186. Set color space conforming to:
  8187. @itemize
  8188. @item
  8189. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  8190. @item
  8191. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  8192. @item
  8193. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  8194. @end itemize
  8195. @item smpte240m
  8196. Set color space conforming to SMPTE ST 240:1999.
  8197. @end table
  8198. @item in_range
  8199. @item out_range
  8200. Set in/output YCbCr sample range.
  8201. This allows the autodetected value to be overridden as well as allows forcing
  8202. a specific value used for the output and encoder. If not specified, the
  8203. range depends on the pixel format. Possible values:
  8204. @table @samp
  8205. @item auto
  8206. Choose automatically.
  8207. @item jpeg/full/pc
  8208. Set full range (0-255 in case of 8-bit luma).
  8209. @item mpeg/tv
  8210. Set "MPEG" range (16-235 in case of 8-bit luma).
  8211. @end table
  8212. @item force_original_aspect_ratio
  8213. Enable decreasing or increasing output video width or height if necessary to
  8214. keep the original aspect ratio. Possible values:
  8215. @table @samp
  8216. @item disable
  8217. Scale the video as specified and disable this feature.
  8218. @item decrease
  8219. The output video dimensions will automatically be decreased if needed.
  8220. @item increase
  8221. The output video dimensions will automatically be increased if needed.
  8222. @end table
  8223. One useful instance of this option is that when you know a specific device's
  8224. maximum allowed resolution, you can use this to limit the output video to
  8225. that, while retaining the aspect ratio. For example, device A allows
  8226. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  8227. decrease) and specifying 1280x720 to the command line makes the output
  8228. 1280x533.
  8229. Please note that this is a different thing than specifying -1 for @option{w}
  8230. or @option{h}, you still need to specify the output resolution for this option
  8231. to work.
  8232. @end table
  8233. The values of the @option{w} and @option{h} options are expressions
  8234. containing the following constants:
  8235. @table @var
  8236. @item in_w
  8237. @item in_h
  8238. The input width and height
  8239. @item iw
  8240. @item ih
  8241. These are the same as @var{in_w} and @var{in_h}.
  8242. @item out_w
  8243. @item out_h
  8244. The output (scaled) width and height
  8245. @item ow
  8246. @item oh
  8247. These are the same as @var{out_w} and @var{out_h}
  8248. @item a
  8249. The same as @var{iw} / @var{ih}
  8250. @item sar
  8251. input sample aspect ratio
  8252. @item dar
  8253. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  8254. @item hsub
  8255. @item vsub
  8256. horizontal and vertical input chroma subsample values. For example for the
  8257. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  8258. @item ohsub
  8259. @item ovsub
  8260. horizontal and vertical output chroma subsample values. For example for the
  8261. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  8262. @end table
  8263. @subsection Examples
  8264. @itemize
  8265. @item
  8266. Scale the input video to a size of 200x100
  8267. @example
  8268. scale=w=200:h=100
  8269. @end example
  8270. This is equivalent to:
  8271. @example
  8272. scale=200:100
  8273. @end example
  8274. or:
  8275. @example
  8276. scale=200x100
  8277. @end example
  8278. @item
  8279. Specify a size abbreviation for the output size:
  8280. @example
  8281. scale=qcif
  8282. @end example
  8283. which can also be written as:
  8284. @example
  8285. scale=size=qcif
  8286. @end example
  8287. @item
  8288. Scale the input to 2x:
  8289. @example
  8290. scale=w=2*iw:h=2*ih
  8291. @end example
  8292. @item
  8293. The above is the same as:
  8294. @example
  8295. scale=2*in_w:2*in_h
  8296. @end example
  8297. @item
  8298. Scale the input to 2x with forced interlaced scaling:
  8299. @example
  8300. scale=2*iw:2*ih:interl=1
  8301. @end example
  8302. @item
  8303. Scale the input to half size:
  8304. @example
  8305. scale=w=iw/2:h=ih/2
  8306. @end example
  8307. @item
  8308. Increase the width, and set the height to the same size:
  8309. @example
  8310. scale=3/2*iw:ow
  8311. @end example
  8312. @item
  8313. Seek Greek harmony:
  8314. @example
  8315. scale=iw:1/PHI*iw
  8316. scale=ih*PHI:ih
  8317. @end example
  8318. @item
  8319. Increase the height, and set the width to 3/2 of the height:
  8320. @example
  8321. scale=w=3/2*oh:h=3/5*ih
  8322. @end example
  8323. @item
  8324. Increase the size, making the size a multiple of the chroma
  8325. subsample values:
  8326. @example
  8327. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  8328. @end example
  8329. @item
  8330. Increase the width to a maximum of 500 pixels,
  8331. keeping the same aspect ratio as the input:
  8332. @example
  8333. scale=w='min(500\, iw*3/2):h=-1'
  8334. @end example
  8335. @end itemize
  8336. @subsection Commands
  8337. This filter supports the following commands:
  8338. @table @option
  8339. @item width, w
  8340. @item height, h
  8341. Set the output video dimension expression.
  8342. The command accepts the same syntax of the corresponding option.
  8343. If the specified expression is not valid, it is kept at its current
  8344. value.
  8345. @end table
  8346. @section scale2ref
  8347. Scale (resize) the input video, based on a reference video.
  8348. See the scale filter for available options, scale2ref supports the same but
  8349. uses the reference video instead of the main input as basis.
  8350. @subsection Examples
  8351. @itemize
  8352. @item
  8353. Scale a subtitle stream to match the main video in size before overlaying
  8354. @example
  8355. 'scale2ref[b][a];[a][b]overlay'
  8356. @end example
  8357. @end itemize
  8358. @anchor{selectivecolor}
  8359. @section selectivecolor
  8360. Adjust cyan, magenta, yellow and black (CMYK) to certain ranges of colors (such
  8361. as "reds", "yellows", "greens", "cyans", ...). The adjustment range is defined
  8362. by the "purity" of the color (that is, how saturated it already is).
  8363. This filter is similar to the Adobe Photoshop Selective Color tool.
  8364. The filter accepts the following options:
  8365. @table @option
  8366. @item correction_method
  8367. Select color correction method.
  8368. Available values are:
  8369. @table @samp
  8370. @item absolute
  8371. Specified adjustments are applied "as-is" (added/subtracted to original pixel
  8372. component value).
  8373. @item relative
  8374. Specified adjustments are relative to the original component value.
  8375. @end table
  8376. Default is @code{absolute}.
  8377. @item reds
  8378. Adjustments for red pixels (pixels where the red component is the maximum)
  8379. @item yellows
  8380. Adjustments for yellow pixels (pixels where the blue component is the minimum)
  8381. @item greens
  8382. Adjustments for green pixels (pixels where the green component is the maximum)
  8383. @item cyans
  8384. Adjustments for cyan pixels (pixels where the red component is the minimum)
  8385. @item blues
  8386. Adjustments for blue pixels (pixels where the blue component is the maximum)
  8387. @item magentas
  8388. Adjustments for magenta pixels (pixels where the green component is the minimum)
  8389. @item whites
  8390. Adjustments for white pixels (pixels where all components are greater than 128)
  8391. @item neutrals
  8392. Adjustments for all pixels except pure black and pure white
  8393. @item blacks
  8394. Adjustments for black pixels (pixels where all components are lesser than 128)
  8395. @item psfile
  8396. Specify a Photoshop selective color file (@code{.asv}) to import the settings from.
  8397. @end table
  8398. All the adjustment settings (@option{reds}, @option{yellows}, ...) accept up to
  8399. 4 space separated floating point adjustment values in the [-1,1] range,
  8400. respectively to adjust the amount of cyan, magenta, yellow and black for the
  8401. pixels of its range.
  8402. @subsection Examples
  8403. @itemize
  8404. @item
  8405. Increase cyan by 50% and reduce yellow by 33% in every green areas, and
  8406. increase magenta by 27% in blue areas:
  8407. @example
  8408. selectivecolor=greens=.5 0 -.33 0:blues=0 .27
  8409. @end example
  8410. @item
  8411. Use a Photoshop selective color preset:
  8412. @example
  8413. selectivecolor=psfile=MySelectiveColorPresets/Misty.asv
  8414. @end example
  8415. @end itemize
  8416. @section separatefields
  8417. The @code{separatefields} takes a frame-based video input and splits
  8418. each frame into its components fields, producing a new half height clip
  8419. with twice the frame rate and twice the frame count.
  8420. This filter use field-dominance information in frame to decide which
  8421. of each pair of fields to place first in the output.
  8422. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  8423. @section setdar, setsar
  8424. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  8425. output video.
  8426. This is done by changing the specified Sample (aka Pixel) Aspect
  8427. Ratio, according to the following equation:
  8428. @example
  8429. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  8430. @end example
  8431. Keep in mind that the @code{setdar} filter does not modify the pixel
  8432. dimensions of the video frame. Also, the display aspect ratio set by
  8433. this filter may be changed by later filters in the filterchain,
  8434. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  8435. applied.
  8436. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  8437. the filter output video.
  8438. Note that as a consequence of the application of this filter, the
  8439. output display aspect ratio will change according to the equation
  8440. above.
  8441. Keep in mind that the sample aspect ratio set by the @code{setsar}
  8442. filter may be changed by later filters in the filterchain, e.g. if
  8443. another "setsar" or a "setdar" filter is applied.
  8444. It accepts the following parameters:
  8445. @table @option
  8446. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  8447. Set the aspect ratio used by the filter.
  8448. The parameter can be a floating point number string, an expression, or
  8449. a string of the form @var{num}:@var{den}, where @var{num} and
  8450. @var{den} are the numerator and denominator of the aspect ratio. If
  8451. the parameter is not specified, it is assumed the value "0".
  8452. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  8453. should be escaped.
  8454. @item max
  8455. Set the maximum integer value to use for expressing numerator and
  8456. denominator when reducing the expressed aspect ratio to a rational.
  8457. Default value is @code{100}.
  8458. @end table
  8459. The parameter @var{sar} is an expression containing
  8460. the following constants:
  8461. @table @option
  8462. @item E, PI, PHI
  8463. These are approximated values for the mathematical constants e
  8464. (Euler's number), pi (Greek pi), and phi (the golden ratio).
  8465. @item w, h
  8466. The input width and height.
  8467. @item a
  8468. These are the same as @var{w} / @var{h}.
  8469. @item sar
  8470. The input sample aspect ratio.
  8471. @item dar
  8472. The input display aspect ratio. It is the same as
  8473. (@var{w} / @var{h}) * @var{sar}.
  8474. @item hsub, vsub
  8475. Horizontal and vertical chroma subsample values. For example, for the
  8476. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  8477. @end table
  8478. @subsection Examples
  8479. @itemize
  8480. @item
  8481. To change the display aspect ratio to 16:9, specify one of the following:
  8482. @example
  8483. setdar=dar=1.77777
  8484. setdar=dar=16/9
  8485. setdar=dar=1.77777
  8486. @end example
  8487. @item
  8488. To change the sample aspect ratio to 10:11, specify:
  8489. @example
  8490. setsar=sar=10/11
  8491. @end example
  8492. @item
  8493. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  8494. 1000 in the aspect ratio reduction, use the command:
  8495. @example
  8496. setdar=ratio=16/9:max=1000
  8497. @end example
  8498. @end itemize
  8499. @anchor{setfield}
  8500. @section setfield
  8501. Force field for the output video frame.
  8502. The @code{setfield} filter marks the interlace type field for the
  8503. output frames. It does not change the input frame, but only sets the
  8504. corresponding property, which affects how the frame is treated by
  8505. following filters (e.g. @code{fieldorder} or @code{yadif}).
  8506. The filter accepts the following options:
  8507. @table @option
  8508. @item mode
  8509. Available values are:
  8510. @table @samp
  8511. @item auto
  8512. Keep the same field property.
  8513. @item bff
  8514. Mark the frame as bottom-field-first.
  8515. @item tff
  8516. Mark the frame as top-field-first.
  8517. @item prog
  8518. Mark the frame as progressive.
  8519. @end table
  8520. @end table
  8521. @section showinfo
  8522. Show a line containing various information for each input video frame.
  8523. The input video is not modified.
  8524. The shown line contains a sequence of key/value pairs of the form
  8525. @var{key}:@var{value}.
  8526. The following values are shown in the output:
  8527. @table @option
  8528. @item n
  8529. The (sequential) number of the input frame, starting from 0.
  8530. @item pts
  8531. The Presentation TimeStamp of the input frame, expressed as a number of
  8532. time base units. The time base unit depends on the filter input pad.
  8533. @item pts_time
  8534. The Presentation TimeStamp of the input frame, expressed as a number of
  8535. seconds.
  8536. @item pos
  8537. The position of the frame in the input stream, or -1 if this information is
  8538. unavailable and/or meaningless (for example in case of synthetic video).
  8539. @item fmt
  8540. The pixel format name.
  8541. @item sar
  8542. The sample aspect ratio of the input frame, expressed in the form
  8543. @var{num}/@var{den}.
  8544. @item s
  8545. The size of the input frame. For the syntax of this option, check the
  8546. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8547. @item i
  8548. The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
  8549. for bottom field first).
  8550. @item iskey
  8551. This is 1 if the frame is a key frame, 0 otherwise.
  8552. @item type
  8553. The picture type of the input frame ("I" for an I-frame, "P" for a
  8554. P-frame, "B" for a B-frame, or "?" for an unknown type).
  8555. Also refer to the documentation of the @code{AVPictureType} enum and of
  8556. the @code{av_get_picture_type_char} function defined in
  8557. @file{libavutil/avutil.h}.
  8558. @item checksum
  8559. The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
  8560. @item plane_checksum
  8561. The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  8562. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
  8563. @end table
  8564. @section showpalette
  8565. Displays the 256 colors palette of each frame. This filter is only relevant for
  8566. @var{pal8} pixel format frames.
  8567. It accepts the following option:
  8568. @table @option
  8569. @item s
  8570. Set the size of the box used to represent one palette color entry. Default is
  8571. @code{30} (for a @code{30x30} pixel box).
  8572. @end table
  8573. @section shuffleframes
  8574. Reorder and/or duplicate video frames.
  8575. It accepts the following parameters:
  8576. @table @option
  8577. @item mapping
  8578. Set the destination indexes of input frames.
  8579. This is space or '|' separated list of indexes that maps input frames to output
  8580. frames. Number of indexes also sets maximal value that each index may have.
  8581. @end table
  8582. The first frame has the index 0. The default is to keep the input unchanged.
  8583. Swap second and third frame of every three frames of the input:
  8584. @example
  8585. ffmpeg -i INPUT -vf "shuffleframes=0 2 1" OUTPUT
  8586. @end example
  8587. @section shuffleplanes
  8588. Reorder and/or duplicate video planes.
  8589. It accepts the following parameters:
  8590. @table @option
  8591. @item map0
  8592. The index of the input plane to be used as the first output plane.
  8593. @item map1
  8594. The index of the input plane to be used as the second output plane.
  8595. @item map2
  8596. The index of the input plane to be used as the third output plane.
  8597. @item map3
  8598. The index of the input plane to be used as the fourth output plane.
  8599. @end table
  8600. The first plane has the index 0. The default is to keep the input unchanged.
  8601. Swap the second and third planes of the input:
  8602. @example
  8603. ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
  8604. @end example
  8605. @anchor{signalstats}
  8606. @section signalstats
  8607. Evaluate various visual metrics that assist in determining issues associated
  8608. with the digitization of analog video media.
  8609. By default the filter will log these metadata values:
  8610. @table @option
  8611. @item YMIN
  8612. Display the minimal Y value contained within the input frame. Expressed in
  8613. range of [0-255].
  8614. @item YLOW
  8615. Display the Y value at the 10% percentile within the input frame. Expressed in
  8616. range of [0-255].
  8617. @item YAVG
  8618. Display the average Y value within the input frame. Expressed in range of
  8619. [0-255].
  8620. @item YHIGH
  8621. Display the Y value at the 90% percentile within the input frame. Expressed in
  8622. range of [0-255].
  8623. @item YMAX
  8624. Display the maximum Y value contained within the input frame. Expressed in
  8625. range of [0-255].
  8626. @item UMIN
  8627. Display the minimal U value contained within the input frame. Expressed in
  8628. range of [0-255].
  8629. @item ULOW
  8630. Display the U value at the 10% percentile within the input frame. Expressed in
  8631. range of [0-255].
  8632. @item UAVG
  8633. Display the average U value within the input frame. Expressed in range of
  8634. [0-255].
  8635. @item UHIGH
  8636. Display the U value at the 90% percentile within the input frame. Expressed in
  8637. range of [0-255].
  8638. @item UMAX
  8639. Display the maximum U value contained within the input frame. Expressed in
  8640. range of [0-255].
  8641. @item VMIN
  8642. Display the minimal V value contained within the input frame. Expressed in
  8643. range of [0-255].
  8644. @item VLOW
  8645. Display the V value at the 10% percentile within the input frame. Expressed in
  8646. range of [0-255].
  8647. @item VAVG
  8648. Display the average V value within the input frame. Expressed in range of
  8649. [0-255].
  8650. @item VHIGH
  8651. Display the V value at the 90% percentile within the input frame. Expressed in
  8652. range of [0-255].
  8653. @item VMAX
  8654. Display the maximum V value contained within the input frame. Expressed in
  8655. range of [0-255].
  8656. @item SATMIN
  8657. Display the minimal saturation value contained within the input frame.
  8658. Expressed in range of [0-~181.02].
  8659. @item SATLOW
  8660. Display the saturation value at the 10% percentile within the input frame.
  8661. Expressed in range of [0-~181.02].
  8662. @item SATAVG
  8663. Display the average saturation value within the input frame. Expressed in range
  8664. of [0-~181.02].
  8665. @item SATHIGH
  8666. Display the saturation value at the 90% percentile within the input frame.
  8667. Expressed in range of [0-~181.02].
  8668. @item SATMAX
  8669. Display the maximum saturation value contained within the input frame.
  8670. Expressed in range of [0-~181.02].
  8671. @item HUEMED
  8672. Display the median value for hue within the input frame. Expressed in range of
  8673. [0-360].
  8674. @item HUEAVG
  8675. Display the average value for hue within the input frame. Expressed in range of
  8676. [0-360].
  8677. @item YDIF
  8678. Display the average of sample value difference between all values of the Y
  8679. plane in the current frame and corresponding values of the previous input frame.
  8680. Expressed in range of [0-255].
  8681. @item UDIF
  8682. Display the average of sample value difference between all values of the U
  8683. plane in the current frame and corresponding values of the previous input frame.
  8684. Expressed in range of [0-255].
  8685. @item VDIF
  8686. Display the average of sample value difference between all values of the V
  8687. plane in the current frame and corresponding values of the previous input frame.
  8688. Expressed in range of [0-255].
  8689. @end table
  8690. The filter accepts the following options:
  8691. @table @option
  8692. @item stat
  8693. @item out
  8694. @option{stat} specify an additional form of image analysis.
  8695. @option{out} output video with the specified type of pixel highlighted.
  8696. Both options accept the following values:
  8697. @table @samp
  8698. @item tout
  8699. Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
  8700. unlike the neighboring pixels of the same field. Examples of temporal outliers
  8701. include the results of video dropouts, head clogs, or tape tracking issues.
  8702. @item vrep
  8703. Identify @var{vertical line repetition}. Vertical line repetition includes
  8704. similar rows of pixels within a frame. In born-digital video vertical line
  8705. repetition is common, but this pattern is uncommon in video digitized from an
  8706. analog source. When it occurs in video that results from the digitization of an
  8707. analog source it can indicate concealment from a dropout compensator.
  8708. @item brng
  8709. Identify pixels that fall outside of legal broadcast range.
  8710. @end table
  8711. @item color, c
  8712. Set the highlight color for the @option{out} option. The default color is
  8713. yellow.
  8714. @end table
  8715. @subsection Examples
  8716. @itemize
  8717. @item
  8718. Output data of various video metrics:
  8719. @example
  8720. ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
  8721. @end example
  8722. @item
  8723. Output specific data about the minimum and maximum values of the Y plane per frame:
  8724. @example
  8725. ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
  8726. @end example
  8727. @item
  8728. Playback video while highlighting pixels that are outside of broadcast range in red.
  8729. @example
  8730. ffplay example.mov -vf signalstats="out=brng:color=red"
  8731. @end example
  8732. @item
  8733. Playback video with signalstats metadata drawn over the frame.
  8734. @example
  8735. ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
  8736. @end example
  8737. The contents of signalstat_drawtext.txt used in the command are:
  8738. @example
  8739. time %@{pts:hms@}
  8740. Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
  8741. U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
  8742. V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
  8743. saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
  8744. @end example
  8745. @end itemize
  8746. @anchor{smartblur}
  8747. @section smartblur
  8748. Blur the input video without impacting the outlines.
  8749. It accepts the following options:
  8750. @table @option
  8751. @item luma_radius, lr
  8752. Set the luma radius. The option value must be a float number in
  8753. the range [0.1,5.0] that specifies the variance of the gaussian filter
  8754. used to blur the image (slower if larger). Default value is 1.0.
  8755. @item luma_strength, ls
  8756. Set the luma strength. The option value must be a float number
  8757. in the range [-1.0,1.0] that configures the blurring. A value included
  8758. in [0.0,1.0] will blur the image whereas a value included in
  8759. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  8760. @item luma_threshold, lt
  8761. Set the luma threshold used as a coefficient to determine
  8762. whether a pixel should be blurred or not. The option value must be an
  8763. integer in the range [-30,30]. A value of 0 will filter all the image,
  8764. a value included in [0,30] will filter flat areas and a value included
  8765. in [-30,0] will filter edges. Default value is 0.
  8766. @item chroma_radius, cr
  8767. Set the chroma radius. The option value must be a float number in
  8768. the range [0.1,5.0] that specifies the variance of the gaussian filter
  8769. used to blur the image (slower if larger). Default value is 1.0.
  8770. @item chroma_strength, cs
  8771. Set the chroma strength. The option value must be a float number
  8772. in the range [-1.0,1.0] that configures the blurring. A value included
  8773. in [0.0,1.0] will blur the image whereas a value included in
  8774. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  8775. @item chroma_threshold, ct
  8776. Set the chroma threshold used as a coefficient to determine
  8777. whether a pixel should be blurred or not. The option value must be an
  8778. integer in the range [-30,30]. A value of 0 will filter all the image,
  8779. a value included in [0,30] will filter flat areas and a value included
  8780. in [-30,0] will filter edges. Default value is 0.
  8781. @end table
  8782. If a chroma option is not explicitly set, the corresponding luma value
  8783. is set.
  8784. @section ssim
  8785. Obtain the SSIM (Structural SImilarity Metric) between two input videos.
  8786. This filter takes in input two input videos, the first input is
  8787. considered the "main" source and is passed unchanged to the
  8788. output. The second input is used as a "reference" video for computing
  8789. the SSIM.
  8790. Both video inputs must have the same resolution and pixel format for
  8791. this filter to work correctly. Also it assumes that both inputs
  8792. have the same number of frames, which are compared one by one.
  8793. The filter stores the calculated SSIM of each frame.
  8794. The description of the accepted parameters follows.
  8795. @table @option
  8796. @item stats_file, f
  8797. If specified the filter will use the named file to save the SSIM of
  8798. each individual frame. When filename equals "-" the data is sent to
  8799. standard output.
  8800. @end table
  8801. The file printed if @var{stats_file} is selected, contains a sequence of
  8802. key/value pairs of the form @var{key}:@var{value} for each compared
  8803. couple of frames.
  8804. A description of each shown parameter follows:
  8805. @table @option
  8806. @item n
  8807. sequential number of the input frame, starting from 1
  8808. @item Y, U, V, R, G, B
  8809. SSIM of the compared frames for the component specified by the suffix.
  8810. @item All
  8811. SSIM of the compared frames for the whole frame.
  8812. @item dB
  8813. Same as above but in dB representation.
  8814. @end table
  8815. For example:
  8816. @example
  8817. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  8818. [main][ref] ssim="stats_file=stats.log" [out]
  8819. @end example
  8820. On this example the input file being processed is compared with the
  8821. reference file @file{ref_movie.mpg}. The SSIM of each individual frame
  8822. is stored in @file{stats.log}.
  8823. Another example with both psnr and ssim at same time:
  8824. @example
  8825. ffmpeg -i main.mpg -i ref.mpg -lavfi "ssim;[0:v][1:v]psnr" -f null -
  8826. @end example
  8827. @section stereo3d
  8828. Convert between different stereoscopic image formats.
  8829. The filters accept the following options:
  8830. @table @option
  8831. @item in
  8832. Set stereoscopic image format of input.
  8833. Available values for input image formats are:
  8834. @table @samp
  8835. @item sbsl
  8836. side by side parallel (left eye left, right eye right)
  8837. @item sbsr
  8838. side by side crosseye (right eye left, left eye right)
  8839. @item sbs2l
  8840. side by side parallel with half width resolution
  8841. (left eye left, right eye right)
  8842. @item sbs2r
  8843. side by side crosseye with half width resolution
  8844. (right eye left, left eye right)
  8845. @item abl
  8846. above-below (left eye above, right eye below)
  8847. @item abr
  8848. above-below (right eye above, left eye below)
  8849. @item ab2l
  8850. above-below with half height resolution
  8851. (left eye above, right eye below)
  8852. @item ab2r
  8853. above-below with half height resolution
  8854. (right eye above, left eye below)
  8855. @item al
  8856. alternating frames (left eye first, right eye second)
  8857. @item ar
  8858. alternating frames (right eye first, left eye second)
  8859. @item irl
  8860. interleaved rows (left eye has top row, right eye starts on next row)
  8861. @item irr
  8862. interleaved rows (right eye has top row, left eye starts on next row)
  8863. @item icl
  8864. interleaved columns, left eye first
  8865. @item icr
  8866. interleaved columns, right eye first
  8867. Default value is @samp{sbsl}.
  8868. @end table
  8869. @item out
  8870. Set stereoscopic image format of output.
  8871. @table @samp
  8872. @item sbsl
  8873. side by side parallel (left eye left, right eye right)
  8874. @item sbsr
  8875. side by side crosseye (right eye left, left eye right)
  8876. @item sbs2l
  8877. side by side parallel with half width resolution
  8878. (left eye left, right eye right)
  8879. @item sbs2r
  8880. side by side crosseye with half width resolution
  8881. (right eye left, left eye right)
  8882. @item abl
  8883. above-below (left eye above, right eye below)
  8884. @item abr
  8885. above-below (right eye above, left eye below)
  8886. @item ab2l
  8887. above-below with half height resolution
  8888. (left eye above, right eye below)
  8889. @item ab2r
  8890. above-below with half height resolution
  8891. (right eye above, left eye below)
  8892. @item al
  8893. alternating frames (left eye first, right eye second)
  8894. @item ar
  8895. alternating frames (right eye first, left eye second)
  8896. @item irl
  8897. interleaved rows (left eye has top row, right eye starts on next row)
  8898. @item irr
  8899. interleaved rows (right eye has top row, left eye starts on next row)
  8900. @item arbg
  8901. anaglyph red/blue gray
  8902. (red filter on left eye, blue filter on right eye)
  8903. @item argg
  8904. anaglyph red/green gray
  8905. (red filter on left eye, green filter on right eye)
  8906. @item arcg
  8907. anaglyph red/cyan gray
  8908. (red filter on left eye, cyan filter on right eye)
  8909. @item arch
  8910. anaglyph red/cyan half colored
  8911. (red filter on left eye, cyan filter on right eye)
  8912. @item arcc
  8913. anaglyph red/cyan color
  8914. (red filter on left eye, cyan filter on right eye)
  8915. @item arcd
  8916. anaglyph red/cyan color optimized with the least squares projection of dubois
  8917. (red filter on left eye, cyan filter on right eye)
  8918. @item agmg
  8919. anaglyph green/magenta gray
  8920. (green filter on left eye, magenta filter on right eye)
  8921. @item agmh
  8922. anaglyph green/magenta half colored
  8923. (green filter on left eye, magenta filter on right eye)
  8924. @item agmc
  8925. anaglyph green/magenta colored
  8926. (green filter on left eye, magenta filter on right eye)
  8927. @item agmd
  8928. anaglyph green/magenta color optimized with the least squares projection of dubois
  8929. (green filter on left eye, magenta filter on right eye)
  8930. @item aybg
  8931. anaglyph yellow/blue gray
  8932. (yellow filter on left eye, blue filter on right eye)
  8933. @item aybh
  8934. anaglyph yellow/blue half colored
  8935. (yellow filter on left eye, blue filter on right eye)
  8936. @item aybc
  8937. anaglyph yellow/blue colored
  8938. (yellow filter on left eye, blue filter on right eye)
  8939. @item aybd
  8940. anaglyph yellow/blue color optimized with the least squares projection of dubois
  8941. (yellow filter on left eye, blue filter on right eye)
  8942. @item ml
  8943. mono output (left eye only)
  8944. @item mr
  8945. mono output (right eye only)
  8946. @item chl
  8947. checkerboard, left eye first
  8948. @item chr
  8949. checkerboard, right eye first
  8950. @item icl
  8951. interleaved columns, left eye first
  8952. @item icr
  8953. interleaved columns, right eye first
  8954. @end table
  8955. Default value is @samp{arcd}.
  8956. @end table
  8957. @subsection Examples
  8958. @itemize
  8959. @item
  8960. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  8961. @example
  8962. stereo3d=sbsl:aybd
  8963. @end example
  8964. @item
  8965. Convert input video from above below (left eye above, right eye below) to side by side crosseye.
  8966. @example
  8967. stereo3d=abl:sbsr
  8968. @end example
  8969. @end itemize
  8970. @section streamselect, astreamselect
  8971. Select video or audio streams.
  8972. The filter accepts the following options:
  8973. @table @option
  8974. @item inputs
  8975. Set number of inputs. Default is 2.
  8976. @item map
  8977. Set input indexes to remap to outputs.
  8978. @end table
  8979. @subsection Commands
  8980. The @code{streamselect} and @code{astreamselect} filter supports the following
  8981. commands:
  8982. @table @option
  8983. @item map
  8984. Set input indexes to remap to outputs.
  8985. @end table
  8986. @subsection Examples
  8987. @itemize
  8988. @item
  8989. Select first 5 seconds 1st stream and rest of time 2nd stream:
  8990. @example
  8991. sendcmd='5.0 streamselect map 1',streamselect=inputs=2:map=0
  8992. @end example
  8993. @item
  8994. Same as above, but for audio:
  8995. @example
  8996. asendcmd='5.0 astreamselect map 1',astreamselect=inputs=2:map=0
  8997. @end example
  8998. @end itemize
  8999. @anchor{spp}
  9000. @section spp
  9001. Apply a simple postprocessing filter that compresses and decompresses the image
  9002. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  9003. and average the results.
  9004. The filter accepts the following options:
  9005. @table @option
  9006. @item quality
  9007. Set quality. This option defines the number of levels for averaging. It accepts
  9008. an integer in the range 0-6. If set to @code{0}, the filter will have no
  9009. effect. A value of @code{6} means the higher quality. For each increment of
  9010. that value the speed drops by a factor of approximately 2. Default value is
  9011. @code{3}.
  9012. @item qp
  9013. Force a constant quantization parameter. If not set, the filter will use the QP
  9014. from the video stream (if available).
  9015. @item mode
  9016. Set thresholding mode. Available modes are:
  9017. @table @samp
  9018. @item hard
  9019. Set hard thresholding (default).
  9020. @item soft
  9021. Set soft thresholding (better de-ringing effect, but likely blurrier).
  9022. @end table
  9023. @item use_bframe_qp
  9024. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  9025. option may cause flicker since the B-Frames have often larger QP. Default is
  9026. @code{0} (not enabled).
  9027. @end table
  9028. @anchor{subtitles}
  9029. @section subtitles
  9030. Draw subtitles on top of input video using the libass library.
  9031. To enable compilation of this filter you need to configure FFmpeg with
  9032. @code{--enable-libass}. This filter also requires a build with libavcodec and
  9033. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  9034. Alpha) subtitles format.
  9035. The filter accepts the following options:
  9036. @table @option
  9037. @item filename, f
  9038. Set the filename of the subtitle file to read. It must be specified.
  9039. @item original_size
  9040. Specify the size of the original video, the video for which the ASS file
  9041. was composed. For the syntax of this option, check the
  9042. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9043. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
  9044. correctly scale the fonts if the aspect ratio has been changed.
  9045. @item fontsdir
  9046. Set a directory path containing fonts that can be used by the filter.
  9047. These fonts will be used in addition to whatever the font provider uses.
  9048. @item charenc
  9049. Set subtitles input character encoding. @code{subtitles} filter only. Only
  9050. useful if not UTF-8.
  9051. @item stream_index, si
  9052. Set subtitles stream index. @code{subtitles} filter only.
  9053. @item force_style
  9054. Override default style or script info parameters of the subtitles. It accepts a
  9055. string containing ASS style format @code{KEY=VALUE} couples separated by ",".
  9056. @end table
  9057. If the first key is not specified, it is assumed that the first value
  9058. specifies the @option{filename}.
  9059. For example, to render the file @file{sub.srt} on top of the input
  9060. video, use the command:
  9061. @example
  9062. subtitles=sub.srt
  9063. @end example
  9064. which is equivalent to:
  9065. @example
  9066. subtitles=filename=sub.srt
  9067. @end example
  9068. To render the default subtitles stream from file @file{video.mkv}, use:
  9069. @example
  9070. subtitles=video.mkv
  9071. @end example
  9072. To render the second subtitles stream from that file, use:
  9073. @example
  9074. subtitles=video.mkv:si=1
  9075. @end example
  9076. To make the subtitles stream from @file{sub.srt} appear in transparent green
  9077. @code{DejaVu Serif}, use:
  9078. @example
  9079. subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
  9080. @end example
  9081. @section super2xsai
  9082. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  9083. Interpolate) pixel art scaling algorithm.
  9084. Useful for enlarging pixel art images without reducing sharpness.
  9085. @section swaprect
  9086. Swap two rectangular objects in video.
  9087. This filter accepts the following options:
  9088. @table @option
  9089. @item w
  9090. Set object width.
  9091. @item h
  9092. Set object height.
  9093. @item x1
  9094. Set 1st rect x coordinate.
  9095. @item y1
  9096. Set 1st rect y coordinate.
  9097. @item x2
  9098. Set 2nd rect x coordinate.
  9099. @item y2
  9100. Set 2nd rect y coordinate.
  9101. All expressions are evaluated once for each frame.
  9102. @end table
  9103. The all options are expressions containing the following constants:
  9104. @table @option
  9105. @item w
  9106. @item h
  9107. The input width and height.
  9108. @item a
  9109. same as @var{w} / @var{h}
  9110. @item sar
  9111. input sample aspect ratio
  9112. @item dar
  9113. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  9114. @item n
  9115. The number of the input frame, starting from 0.
  9116. @item t
  9117. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  9118. @item pos
  9119. the position in the file of the input frame, NAN if unknown
  9120. @end table
  9121. @section swapuv
  9122. Swap U & V plane.
  9123. @section telecine
  9124. Apply telecine process to the video.
  9125. This filter accepts the following options:
  9126. @table @option
  9127. @item first_field
  9128. @table @samp
  9129. @item top, t
  9130. top field first
  9131. @item bottom, b
  9132. bottom field first
  9133. The default value is @code{top}.
  9134. @end table
  9135. @item pattern
  9136. A string of numbers representing the pulldown pattern you wish to apply.
  9137. The default value is @code{23}.
  9138. @end table
  9139. @example
  9140. Some typical patterns:
  9141. NTSC output (30i):
  9142. 27.5p: 32222
  9143. 24p: 23 (classic)
  9144. 24p: 2332 (preferred)
  9145. 20p: 33
  9146. 18p: 334
  9147. 16p: 3444
  9148. PAL output (25i):
  9149. 27.5p: 12222
  9150. 24p: 222222222223 ("Euro pulldown")
  9151. 16.67p: 33
  9152. 16p: 33333334
  9153. @end example
  9154. @section thumbnail
  9155. Select the most representative frame in a given sequence of consecutive frames.
  9156. The filter accepts the following options:
  9157. @table @option
  9158. @item n
  9159. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  9160. will pick one of them, and then handle the next batch of @var{n} frames until
  9161. the end. Default is @code{100}.
  9162. @end table
  9163. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  9164. value will result in a higher memory usage, so a high value is not recommended.
  9165. @subsection Examples
  9166. @itemize
  9167. @item
  9168. Extract one picture each 50 frames:
  9169. @example
  9170. thumbnail=50
  9171. @end example
  9172. @item
  9173. Complete example of a thumbnail creation with @command{ffmpeg}:
  9174. @example
  9175. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  9176. @end example
  9177. @end itemize
  9178. @section tile
  9179. Tile several successive frames together.
  9180. The filter accepts the following options:
  9181. @table @option
  9182. @item layout
  9183. Set the grid size (i.e. the number of lines and columns). For the syntax of
  9184. this option, check the
  9185. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9186. @item nb_frames
  9187. Set the maximum number of frames to render in the given area. It must be less
  9188. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  9189. the area will be used.
  9190. @item margin
  9191. Set the outer border margin in pixels.
  9192. @item padding
  9193. Set the inner border thickness (i.e. the number of pixels between frames). For
  9194. more advanced padding options (such as having different values for the edges),
  9195. refer to the pad video filter.
  9196. @item color
  9197. Specify the color of the unused area. For the syntax of this option, check the
  9198. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  9199. is "black".
  9200. @end table
  9201. @subsection Examples
  9202. @itemize
  9203. @item
  9204. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  9205. @example
  9206. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  9207. @end example
  9208. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  9209. duplicating each output frame to accommodate the originally detected frame
  9210. rate.
  9211. @item
  9212. Display @code{5} pictures in an area of @code{3x2} frames,
  9213. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  9214. mixed flat and named options:
  9215. @example
  9216. tile=3x2:nb_frames=5:padding=7:margin=2
  9217. @end example
  9218. @end itemize
  9219. @section tinterlace
  9220. Perform various types of temporal field interlacing.
  9221. Frames are counted starting from 1, so the first input frame is
  9222. considered odd.
  9223. The filter accepts the following options:
  9224. @table @option
  9225. @item mode
  9226. Specify the mode of the interlacing. This option can also be specified
  9227. as a value alone. See below for a list of values for this option.
  9228. Available values are:
  9229. @table @samp
  9230. @item merge, 0
  9231. Move odd frames into the upper field, even into the lower field,
  9232. generating a double height frame at half frame rate.
  9233. @example
  9234. ------> time
  9235. Input:
  9236. Frame 1 Frame 2 Frame 3 Frame 4
  9237. 11111 22222 33333 44444
  9238. 11111 22222 33333 44444
  9239. 11111 22222 33333 44444
  9240. 11111 22222 33333 44444
  9241. Output:
  9242. 11111 33333
  9243. 22222 44444
  9244. 11111 33333
  9245. 22222 44444
  9246. 11111 33333
  9247. 22222 44444
  9248. 11111 33333
  9249. 22222 44444
  9250. @end example
  9251. @item drop_odd, 1
  9252. Only output even frames, odd frames are dropped, generating a frame with
  9253. unchanged height at half frame rate.
  9254. @example
  9255. ------> time
  9256. Input:
  9257. Frame 1 Frame 2 Frame 3 Frame 4
  9258. 11111 22222 33333 44444
  9259. 11111 22222 33333 44444
  9260. 11111 22222 33333 44444
  9261. 11111 22222 33333 44444
  9262. Output:
  9263. 22222 44444
  9264. 22222 44444
  9265. 22222 44444
  9266. 22222 44444
  9267. @end example
  9268. @item drop_even, 2
  9269. Only output odd frames, even frames are dropped, generating a frame with
  9270. unchanged height at half frame rate.
  9271. @example
  9272. ------> time
  9273. Input:
  9274. Frame 1 Frame 2 Frame 3 Frame 4
  9275. 11111 22222 33333 44444
  9276. 11111 22222 33333 44444
  9277. 11111 22222 33333 44444
  9278. 11111 22222 33333 44444
  9279. Output:
  9280. 11111 33333
  9281. 11111 33333
  9282. 11111 33333
  9283. 11111 33333
  9284. @end example
  9285. @item pad, 3
  9286. Expand each frame to full height, but pad alternate lines with black,
  9287. generating a frame with double height at the same input frame rate.
  9288. @example
  9289. ------> time
  9290. Input:
  9291. Frame 1 Frame 2 Frame 3 Frame 4
  9292. 11111 22222 33333 44444
  9293. 11111 22222 33333 44444
  9294. 11111 22222 33333 44444
  9295. 11111 22222 33333 44444
  9296. Output:
  9297. 11111 ..... 33333 .....
  9298. ..... 22222 ..... 44444
  9299. 11111 ..... 33333 .....
  9300. ..... 22222 ..... 44444
  9301. 11111 ..... 33333 .....
  9302. ..... 22222 ..... 44444
  9303. 11111 ..... 33333 .....
  9304. ..... 22222 ..... 44444
  9305. @end example
  9306. @item interleave_top, 4
  9307. Interleave the upper field from odd frames with the lower field from
  9308. even frames, generating a frame with unchanged height at half frame rate.
  9309. @example
  9310. ------> time
  9311. Input:
  9312. Frame 1 Frame 2 Frame 3 Frame 4
  9313. 11111<- 22222 33333<- 44444
  9314. 11111 22222<- 33333 44444<-
  9315. 11111<- 22222 33333<- 44444
  9316. 11111 22222<- 33333 44444<-
  9317. Output:
  9318. 11111 33333
  9319. 22222 44444
  9320. 11111 33333
  9321. 22222 44444
  9322. @end example
  9323. @item interleave_bottom, 5
  9324. Interleave the lower field from odd frames with the upper field from
  9325. even frames, generating a frame with unchanged height at half frame rate.
  9326. @example
  9327. ------> time
  9328. Input:
  9329. Frame 1 Frame 2 Frame 3 Frame 4
  9330. 11111 22222<- 33333 44444<-
  9331. 11111<- 22222 33333<- 44444
  9332. 11111 22222<- 33333 44444<-
  9333. 11111<- 22222 33333<- 44444
  9334. Output:
  9335. 22222 44444
  9336. 11111 33333
  9337. 22222 44444
  9338. 11111 33333
  9339. @end example
  9340. @item interlacex2, 6
  9341. Double frame rate with unchanged height. Frames are inserted each
  9342. containing the second temporal field from the previous input frame and
  9343. the first temporal field from the next input frame. This mode relies on
  9344. the top_field_first flag. Useful for interlaced video displays with no
  9345. field synchronisation.
  9346. @example
  9347. ------> time
  9348. Input:
  9349. Frame 1 Frame 2 Frame 3 Frame 4
  9350. 11111 22222 33333 44444
  9351. 11111 22222 33333 44444
  9352. 11111 22222 33333 44444
  9353. 11111 22222 33333 44444
  9354. Output:
  9355. 11111 22222 22222 33333 33333 44444 44444
  9356. 11111 11111 22222 22222 33333 33333 44444
  9357. 11111 22222 22222 33333 33333 44444 44444
  9358. 11111 11111 22222 22222 33333 33333 44444
  9359. @end example
  9360. @item mergex2, 7
  9361. Move odd frames into the upper field, even into the lower field,
  9362. generating a double height frame at same frame rate.
  9363. @example
  9364. ------> time
  9365. Input:
  9366. Frame 1 Frame 2 Frame 3 Frame 4
  9367. 11111 22222 33333 44444
  9368. 11111 22222 33333 44444
  9369. 11111 22222 33333 44444
  9370. 11111 22222 33333 44444
  9371. Output:
  9372. 11111 33333 33333 55555
  9373. 22222 22222 44444 44444
  9374. 11111 33333 33333 55555
  9375. 22222 22222 44444 44444
  9376. 11111 33333 33333 55555
  9377. 22222 22222 44444 44444
  9378. 11111 33333 33333 55555
  9379. 22222 22222 44444 44444
  9380. @end example
  9381. @end table
  9382. Numeric values are deprecated but are accepted for backward
  9383. compatibility reasons.
  9384. Default mode is @code{merge}.
  9385. @item flags
  9386. Specify flags influencing the filter process.
  9387. Available value for @var{flags} is:
  9388. @table @option
  9389. @item low_pass_filter, vlfp
  9390. Enable vertical low-pass filtering in the filter.
  9391. Vertical low-pass filtering is required when creating an interlaced
  9392. destination from a progressive source which contains high-frequency
  9393. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  9394. patterning.
  9395. Vertical low-pass filtering can only be enabled for @option{mode}
  9396. @var{interleave_top} and @var{interleave_bottom}.
  9397. @end table
  9398. @end table
  9399. @section transpose
  9400. Transpose rows with columns in the input video and optionally flip it.
  9401. It accepts the following parameters:
  9402. @table @option
  9403. @item dir
  9404. Specify the transposition direction.
  9405. Can assume the following values:
  9406. @table @samp
  9407. @item 0, 4, cclock_flip
  9408. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  9409. @example
  9410. L.R L.l
  9411. . . -> . .
  9412. l.r R.r
  9413. @end example
  9414. @item 1, 5, clock
  9415. Rotate by 90 degrees clockwise, that is:
  9416. @example
  9417. L.R l.L
  9418. . . -> . .
  9419. l.r r.R
  9420. @end example
  9421. @item 2, 6, cclock
  9422. Rotate by 90 degrees counterclockwise, that is:
  9423. @example
  9424. L.R R.r
  9425. . . -> . .
  9426. l.r L.l
  9427. @end example
  9428. @item 3, 7, clock_flip
  9429. Rotate by 90 degrees clockwise and vertically flip, that is:
  9430. @example
  9431. L.R r.R
  9432. . . -> . .
  9433. l.r l.L
  9434. @end example
  9435. @end table
  9436. For values between 4-7, the transposition is only done if the input
  9437. video geometry is portrait and not landscape. These values are
  9438. deprecated, the @code{passthrough} option should be used instead.
  9439. Numerical values are deprecated, and should be dropped in favor of
  9440. symbolic constants.
  9441. @item passthrough
  9442. Do not apply the transposition if the input geometry matches the one
  9443. specified by the specified value. It accepts the following values:
  9444. @table @samp
  9445. @item none
  9446. Always apply transposition.
  9447. @item portrait
  9448. Preserve portrait geometry (when @var{height} >= @var{width}).
  9449. @item landscape
  9450. Preserve landscape geometry (when @var{width} >= @var{height}).
  9451. @end table
  9452. Default value is @code{none}.
  9453. @end table
  9454. For example to rotate by 90 degrees clockwise and preserve portrait
  9455. layout:
  9456. @example
  9457. transpose=dir=1:passthrough=portrait
  9458. @end example
  9459. The command above can also be specified as:
  9460. @example
  9461. transpose=1:portrait
  9462. @end example
  9463. @section trim
  9464. Trim the input so that the output contains one continuous subpart of the input.
  9465. It accepts the following parameters:
  9466. @table @option
  9467. @item start
  9468. Specify the time of the start of the kept section, i.e. the frame with the
  9469. timestamp @var{start} will be the first frame in the output.
  9470. @item end
  9471. Specify the time of the first frame that will be dropped, i.e. the frame
  9472. immediately preceding the one with the timestamp @var{end} will be the last
  9473. frame in the output.
  9474. @item start_pts
  9475. This is the same as @var{start}, except this option sets the start timestamp
  9476. in timebase units instead of seconds.
  9477. @item end_pts
  9478. This is the same as @var{end}, except this option sets the end timestamp
  9479. in timebase units instead of seconds.
  9480. @item duration
  9481. The maximum duration of the output in seconds.
  9482. @item start_frame
  9483. The number of the first frame that should be passed to the output.
  9484. @item end_frame
  9485. The number of the first frame that should be dropped.
  9486. @end table
  9487. @option{start}, @option{end}, and @option{duration} are expressed as time
  9488. duration specifications; see
  9489. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  9490. for the accepted syntax.
  9491. Note that the first two sets of the start/end options and the @option{duration}
  9492. option look at the frame timestamp, while the _frame variants simply count the
  9493. frames that pass through the filter. Also note that this filter does not modify
  9494. the timestamps. If you wish for the output timestamps to start at zero, insert a
  9495. setpts filter after the trim filter.
  9496. If multiple start or end options are set, this filter tries to be greedy and
  9497. keep all the frames that match at least one of the specified constraints. To keep
  9498. only the part that matches all the constraints at once, chain multiple trim
  9499. filters.
  9500. The defaults are such that all the input is kept. So it is possible to set e.g.
  9501. just the end values to keep everything before the specified time.
  9502. Examples:
  9503. @itemize
  9504. @item
  9505. Drop everything except the second minute of input:
  9506. @example
  9507. ffmpeg -i INPUT -vf trim=60:120
  9508. @end example
  9509. @item
  9510. Keep only the first second:
  9511. @example
  9512. ffmpeg -i INPUT -vf trim=duration=1
  9513. @end example
  9514. @end itemize
  9515. @anchor{unsharp}
  9516. @section unsharp
  9517. Sharpen or blur the input video.
  9518. It accepts the following parameters:
  9519. @table @option
  9520. @item luma_msize_x, lx
  9521. Set the luma matrix horizontal size. It must be an odd integer between
  9522. 3 and 63. The default value is 5.
  9523. @item luma_msize_y, ly
  9524. Set the luma matrix vertical size. It must be an odd integer between 3
  9525. and 63. The default value is 5.
  9526. @item luma_amount, la
  9527. Set the luma effect strength. It must be a floating point number, reasonable
  9528. values lay between -1.5 and 1.5.
  9529. Negative values will blur the input video, while positive values will
  9530. sharpen it, a value of zero will disable the effect.
  9531. Default value is 1.0.
  9532. @item chroma_msize_x, cx
  9533. Set the chroma matrix horizontal size. It must be an odd integer
  9534. between 3 and 63. The default value is 5.
  9535. @item chroma_msize_y, cy
  9536. Set the chroma matrix vertical size. It must be an odd integer
  9537. between 3 and 63. The default value is 5.
  9538. @item chroma_amount, ca
  9539. Set the chroma effect strength. It must be a floating point number, reasonable
  9540. values lay between -1.5 and 1.5.
  9541. Negative values will blur the input video, while positive values will
  9542. sharpen it, a value of zero will disable the effect.
  9543. Default value is 0.0.
  9544. @item opencl
  9545. If set to 1, specify using OpenCL capabilities, only available if
  9546. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  9547. @end table
  9548. All parameters are optional and default to the equivalent of the
  9549. string '5:5:1.0:5:5:0.0'.
  9550. @subsection Examples
  9551. @itemize
  9552. @item
  9553. Apply strong luma sharpen effect:
  9554. @example
  9555. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  9556. @end example
  9557. @item
  9558. Apply a strong blur of both luma and chroma parameters:
  9559. @example
  9560. unsharp=7:7:-2:7:7:-2
  9561. @end example
  9562. @end itemize
  9563. @section uspp
  9564. Apply ultra slow/simple postprocessing filter that compresses and decompresses
  9565. the image at several (or - in the case of @option{quality} level @code{8} - all)
  9566. shifts and average the results.
  9567. The way this differs from the behavior of spp is that uspp actually encodes &
  9568. decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
  9569. DCT similar to MJPEG.
  9570. The filter accepts the following options:
  9571. @table @option
  9572. @item quality
  9573. Set quality. This option defines the number of levels for averaging. It accepts
  9574. an integer in the range 0-8. If set to @code{0}, the filter will have no
  9575. effect. A value of @code{8} means the higher quality. For each increment of
  9576. that value the speed drops by a factor of approximately 2. Default value is
  9577. @code{3}.
  9578. @item qp
  9579. Force a constant quantization parameter. If not set, the filter will use the QP
  9580. from the video stream (if available).
  9581. @end table
  9582. @section vectorscope
  9583. Display 2 color component values in the two dimensional graph (which is called
  9584. a vectorscope).
  9585. This filter accepts the following options:
  9586. @table @option
  9587. @item mode, m
  9588. Set vectorscope mode.
  9589. It accepts the following values:
  9590. @table @samp
  9591. @item gray
  9592. Gray values are displayed on graph, higher brightness means more pixels have
  9593. same component color value on location in graph. This is the default mode.
  9594. @item color
  9595. Gray values are displayed on graph. Surrounding pixels values which are not
  9596. present in video frame are drawn in gradient of 2 color components which are
  9597. set by option @code{x} and @code{y}. The 3rd color component is static.
  9598. @item color2
  9599. Actual color components values present in video frame are displayed on graph.
  9600. @item color3
  9601. Similar as color2 but higher frequency of same values @code{x} and @code{y}
  9602. on graph increases value of another color component, which is luminance by
  9603. default values of @code{x} and @code{y}.
  9604. @item color4
  9605. Actual colors present in video frame are displayed on graph. If two different
  9606. colors map to same position on graph then color with higher value of component
  9607. not present in graph is picked.
  9608. @item color5
  9609. Gray values are displayed on graph. Similar to @code{color} but with 3rd color
  9610. component picked from radial gradient.
  9611. @end table
  9612. @item x
  9613. Set which color component will be represented on X-axis. Default is @code{1}.
  9614. @item y
  9615. Set which color component will be represented on Y-axis. Default is @code{2}.
  9616. @item intensity, i
  9617. Set intensity, used by modes: gray, color, color3 and color5 for increasing brightness
  9618. of color component which represents frequency of (X, Y) location in graph.
  9619. @item envelope, e
  9620. @table @samp
  9621. @item none
  9622. No envelope, this is default.
  9623. @item instant
  9624. Instant envelope, even darkest single pixel will be clearly highlighted.
  9625. @item peak
  9626. Hold maximum and minimum values presented in graph over time. This way you
  9627. can still spot out of range values without constantly looking at vectorscope.
  9628. @item peak+instant
  9629. Peak and instant envelope combined together.
  9630. @end table
  9631. @end table
  9632. @anchor{vidstabdetect}
  9633. @section vidstabdetect
  9634. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  9635. @ref{vidstabtransform} for pass 2.
  9636. This filter generates a file with relative translation and rotation
  9637. transform information about subsequent frames, which is then used by
  9638. the @ref{vidstabtransform} filter.
  9639. To enable compilation of this filter you need to configure FFmpeg with
  9640. @code{--enable-libvidstab}.
  9641. This filter accepts the following options:
  9642. @table @option
  9643. @item result
  9644. Set the path to the file used to write the transforms information.
  9645. Default value is @file{transforms.trf}.
  9646. @item shakiness
  9647. Set how shaky the video is and how quick the camera is. It accepts an
  9648. integer in the range 1-10, a value of 1 means little shakiness, a
  9649. value of 10 means strong shakiness. Default value is 5.
  9650. @item accuracy
  9651. Set the accuracy of the detection process. It must be a value in the
  9652. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  9653. accuracy. Default value is 15.
  9654. @item stepsize
  9655. Set stepsize of the search process. The region around minimum is
  9656. scanned with 1 pixel resolution. Default value is 6.
  9657. @item mincontrast
  9658. Set minimum contrast. Below this value a local measurement field is
  9659. discarded. Must be a floating point value in the range 0-1. Default
  9660. value is 0.3.
  9661. @item tripod
  9662. Set reference frame number for tripod mode.
  9663. If enabled, the motion of the frames is compared to a reference frame
  9664. in the filtered stream, identified by the specified number. The idea
  9665. is to compensate all movements in a more-or-less static scene and keep
  9666. the camera view absolutely still.
  9667. If set to 0, it is disabled. The frames are counted starting from 1.
  9668. @item show
  9669. Show fields and transforms in the resulting frames. It accepts an
  9670. integer in the range 0-2. Default value is 0, which disables any
  9671. visualization.
  9672. @end table
  9673. @subsection Examples
  9674. @itemize
  9675. @item
  9676. Use default values:
  9677. @example
  9678. vidstabdetect
  9679. @end example
  9680. @item
  9681. Analyze strongly shaky movie and put the results in file
  9682. @file{mytransforms.trf}:
  9683. @example
  9684. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  9685. @end example
  9686. @item
  9687. Visualize the result of internal transformations in the resulting
  9688. video:
  9689. @example
  9690. vidstabdetect=show=1
  9691. @end example
  9692. @item
  9693. Analyze a video with medium shakiness using @command{ffmpeg}:
  9694. @example
  9695. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  9696. @end example
  9697. @end itemize
  9698. @anchor{vidstabtransform}
  9699. @section vidstabtransform
  9700. Video stabilization/deshaking: pass 2 of 2,
  9701. see @ref{vidstabdetect} for pass 1.
  9702. Read a file with transform information for each frame and
  9703. apply/compensate them. Together with the @ref{vidstabdetect}
  9704. filter this can be used to deshake videos. See also
  9705. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  9706. the @ref{unsharp} filter, see below.
  9707. To enable compilation of this filter you need to configure FFmpeg with
  9708. @code{--enable-libvidstab}.
  9709. @subsection Options
  9710. @table @option
  9711. @item input
  9712. Set path to the file used to read the transforms. Default value is
  9713. @file{transforms.trf}.
  9714. @item smoothing
  9715. Set the number of frames (value*2 + 1) used for lowpass filtering the
  9716. camera movements. Default value is 10.
  9717. For example a number of 10 means that 21 frames are used (10 in the
  9718. past and 10 in the future) to smoothen the motion in the video. A
  9719. larger value leads to a smoother video, but limits the acceleration of
  9720. the camera (pan/tilt movements). 0 is a special case where a static
  9721. camera is simulated.
  9722. @item optalgo
  9723. Set the camera path optimization algorithm.
  9724. Accepted values are:
  9725. @table @samp
  9726. @item gauss
  9727. gaussian kernel low-pass filter on camera motion (default)
  9728. @item avg
  9729. averaging on transformations
  9730. @end table
  9731. @item maxshift
  9732. Set maximal number of pixels to translate frames. Default value is -1,
  9733. meaning no limit.
  9734. @item maxangle
  9735. Set maximal angle in radians (degree*PI/180) to rotate frames. Default
  9736. value is -1, meaning no limit.
  9737. @item crop
  9738. Specify how to deal with borders that may be visible due to movement
  9739. compensation.
  9740. Available values are:
  9741. @table @samp
  9742. @item keep
  9743. keep image information from previous frame (default)
  9744. @item black
  9745. fill the border black
  9746. @end table
  9747. @item invert
  9748. Invert transforms if set to 1. Default value is 0.
  9749. @item relative
  9750. Consider transforms as relative to previous frame if set to 1,
  9751. absolute if set to 0. Default value is 0.
  9752. @item zoom
  9753. Set percentage to zoom. A positive value will result in a zoom-in
  9754. effect, a negative value in a zoom-out effect. Default value is 0 (no
  9755. zoom).
  9756. @item optzoom
  9757. Set optimal zooming to avoid borders.
  9758. Accepted values are:
  9759. @table @samp
  9760. @item 0
  9761. disabled
  9762. @item 1
  9763. optimal static zoom value is determined (only very strong movements
  9764. will lead to visible borders) (default)
  9765. @item 2
  9766. optimal adaptive zoom value is determined (no borders will be
  9767. visible), see @option{zoomspeed}
  9768. @end table
  9769. Note that the value given at zoom is added to the one calculated here.
  9770. @item zoomspeed
  9771. Set percent to zoom maximally each frame (enabled when
  9772. @option{optzoom} is set to 2). Range is from 0 to 5, default value is
  9773. 0.25.
  9774. @item interpol
  9775. Specify type of interpolation.
  9776. Available values are:
  9777. @table @samp
  9778. @item no
  9779. no interpolation
  9780. @item linear
  9781. linear only horizontal
  9782. @item bilinear
  9783. linear in both directions (default)
  9784. @item bicubic
  9785. cubic in both directions (slow)
  9786. @end table
  9787. @item tripod
  9788. Enable virtual tripod mode if set to 1, which is equivalent to
  9789. @code{relative=0:smoothing=0}. Default value is 0.
  9790. Use also @code{tripod} option of @ref{vidstabdetect}.
  9791. @item debug
  9792. Increase log verbosity if set to 1. Also the detected global motions
  9793. are written to the temporary file @file{global_motions.trf}. Default
  9794. value is 0.
  9795. @end table
  9796. @subsection Examples
  9797. @itemize
  9798. @item
  9799. Use @command{ffmpeg} for a typical stabilization with default values:
  9800. @example
  9801. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  9802. @end example
  9803. Note the use of the @ref{unsharp} filter which is always recommended.
  9804. @item
  9805. Zoom in a bit more and load transform data from a given file:
  9806. @example
  9807. vidstabtransform=zoom=5:input="mytransforms.trf"
  9808. @end example
  9809. @item
  9810. Smoothen the video even more:
  9811. @example
  9812. vidstabtransform=smoothing=30
  9813. @end example
  9814. @end itemize
  9815. @section vflip
  9816. Flip the input video vertically.
  9817. For example, to vertically flip a video with @command{ffmpeg}:
  9818. @example
  9819. ffmpeg -i in.avi -vf "vflip" out.avi
  9820. @end example
  9821. @anchor{vignette}
  9822. @section vignette
  9823. Make or reverse a natural vignetting effect.
  9824. The filter accepts the following options:
  9825. @table @option
  9826. @item angle, a
  9827. Set lens angle expression as a number of radians.
  9828. The value is clipped in the @code{[0,PI/2]} range.
  9829. Default value: @code{"PI/5"}
  9830. @item x0
  9831. @item y0
  9832. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  9833. by default.
  9834. @item mode
  9835. Set forward/backward mode.
  9836. Available modes are:
  9837. @table @samp
  9838. @item forward
  9839. The larger the distance from the central point, the darker the image becomes.
  9840. @item backward
  9841. The larger the distance from the central point, the brighter the image becomes.
  9842. This can be used to reverse a vignette effect, though there is no automatic
  9843. detection to extract the lens @option{angle} and other settings (yet). It can
  9844. also be used to create a burning effect.
  9845. @end table
  9846. Default value is @samp{forward}.
  9847. @item eval
  9848. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  9849. It accepts the following values:
  9850. @table @samp
  9851. @item init
  9852. Evaluate expressions only once during the filter initialization.
  9853. @item frame
  9854. Evaluate expressions for each incoming frame. This is way slower than the
  9855. @samp{init} mode since it requires all the scalers to be re-computed, but it
  9856. allows advanced dynamic expressions.
  9857. @end table
  9858. Default value is @samp{init}.
  9859. @item dither
  9860. Set dithering to reduce the circular banding effects. Default is @code{1}
  9861. (enabled).
  9862. @item aspect
  9863. Set vignette aspect. This setting allows one to adjust the shape of the vignette.
  9864. Setting this value to the SAR of the input will make a rectangular vignetting
  9865. following the dimensions of the video.
  9866. Default is @code{1/1}.
  9867. @end table
  9868. @subsection Expressions
  9869. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  9870. following parameters.
  9871. @table @option
  9872. @item w
  9873. @item h
  9874. input width and height
  9875. @item n
  9876. the number of input frame, starting from 0
  9877. @item pts
  9878. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  9879. @var{TB} units, NAN if undefined
  9880. @item r
  9881. frame rate of the input video, NAN if the input frame rate is unknown
  9882. @item t
  9883. the PTS (Presentation TimeStamp) of the filtered video frame,
  9884. expressed in seconds, NAN if undefined
  9885. @item tb
  9886. time base of the input video
  9887. @end table
  9888. @subsection Examples
  9889. @itemize
  9890. @item
  9891. Apply simple strong vignetting effect:
  9892. @example
  9893. vignette=PI/4
  9894. @end example
  9895. @item
  9896. Make a flickering vignetting:
  9897. @example
  9898. vignette='PI/4+random(1)*PI/50':eval=frame
  9899. @end example
  9900. @end itemize
  9901. @section vstack
  9902. Stack input videos vertically.
  9903. All streams must be of same pixel format and of same width.
  9904. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  9905. to create same output.
  9906. The filter accept the following option:
  9907. @table @option
  9908. @item inputs
  9909. Set number of input streams. Default is 2.
  9910. @item shortest
  9911. If set to 1, force the output to terminate when the shortest input
  9912. terminates. Default value is 0.
  9913. @end table
  9914. @section w3fdif
  9915. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  9916. Deinterlacing Filter").
  9917. Based on the process described by Martin Weston for BBC R&D, and
  9918. implemented based on the de-interlace algorithm written by Jim
  9919. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  9920. uses filter coefficients calculated by BBC R&D.
  9921. There are two sets of filter coefficients, so called "simple":
  9922. and "complex". Which set of filter coefficients is used can
  9923. be set by passing an optional parameter:
  9924. @table @option
  9925. @item filter
  9926. Set the interlacing filter coefficients. Accepts one of the following values:
  9927. @table @samp
  9928. @item simple
  9929. Simple filter coefficient set.
  9930. @item complex
  9931. More-complex filter coefficient set.
  9932. @end table
  9933. Default value is @samp{complex}.
  9934. @item deint
  9935. Specify which frames to deinterlace. Accept one of the following values:
  9936. @table @samp
  9937. @item all
  9938. Deinterlace all frames,
  9939. @item interlaced
  9940. Only deinterlace frames marked as interlaced.
  9941. @end table
  9942. Default value is @samp{all}.
  9943. @end table
  9944. @section waveform
  9945. Video waveform monitor.
  9946. The waveform monitor plots color component intensity. By default luminance
  9947. only. Each column of the waveform corresponds to a column of pixels in the
  9948. source video.
  9949. It accepts the following options:
  9950. @table @option
  9951. @item mode, m
  9952. Can be either @code{row}, or @code{column}. Default is @code{column}.
  9953. In row mode, the graph on the left side represents color component value 0 and
  9954. the right side represents value = 255. In column mode, the top side represents
  9955. color component value = 0 and bottom side represents value = 255.
  9956. @item intensity, i
  9957. Set intensity. Smaller values are useful to find out how many values of the same
  9958. luminance are distributed across input rows/columns.
  9959. Default value is @code{0.04}. Allowed range is [0, 1].
  9960. @item mirror, r
  9961. Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored.
  9962. In mirrored mode, higher values will be represented on the left
  9963. side for @code{row} mode and at the top for @code{column} mode. Default is
  9964. @code{1} (mirrored).
  9965. @item display, d
  9966. Set display mode.
  9967. It accepts the following values:
  9968. @table @samp
  9969. @item overlay
  9970. Presents information identical to that in the @code{parade}, except
  9971. that the graphs representing color components are superimposed directly
  9972. over one another.
  9973. This display mode makes it easier to spot relative differences or similarities
  9974. in overlapping areas of the color components that are supposed to be identical,
  9975. such as neutral whites, grays, or blacks.
  9976. @item parade
  9977. Display separate graph for the color components side by side in
  9978. @code{row} mode or one below the other in @code{column} mode.
  9979. Using this display mode makes it easy to spot color casts in the highlights
  9980. and shadows of an image, by comparing the contours of the top and the bottom
  9981. graphs of each waveform. Since whites, grays, and blacks are characterized
  9982. by exactly equal amounts of red, green, and blue, neutral areas of the picture
  9983. should display three waveforms of roughly equal width/height. If not, the
  9984. correction is easy to perform by making level adjustments the three waveforms.
  9985. @end table
  9986. Default is @code{parade}.
  9987. @item components, c
  9988. Set which color components to display. Default is 1, which means only luminance
  9989. or red color component if input is in RGB colorspace. If is set for example to
  9990. 7 it will display all 3 (if) available color components.
  9991. @item envelope, e
  9992. @table @samp
  9993. @item none
  9994. No envelope, this is default.
  9995. @item instant
  9996. Instant envelope, minimum and maximum values presented in graph will be easily
  9997. visible even with small @code{step} value.
  9998. @item peak
  9999. Hold minimum and maximum values presented in graph across time. This way you
  10000. can still spot out of range values without constantly looking at waveforms.
  10001. @item peak+instant
  10002. Peak and instant envelope combined together.
  10003. @end table
  10004. @item filter, f
  10005. @table @samp
  10006. @item lowpass
  10007. No filtering, this is default.
  10008. @item flat
  10009. Luma and chroma combined together.
  10010. @item aflat
  10011. Similar as above, but shows difference between blue and red chroma.
  10012. @item chroma
  10013. Displays only chroma.
  10014. @item achroma
  10015. Similar as above, but shows difference between blue and red chroma.
  10016. @item color
  10017. Displays actual color value on waveform.
  10018. @end table
  10019. @end table
  10020. @section xbr
  10021. Apply the xBR high-quality magnification filter which is designed for pixel
  10022. art. It follows a set of edge-detection rules, see
  10023. @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
  10024. It accepts the following option:
  10025. @table @option
  10026. @item n
  10027. Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
  10028. @code{3xBR} and @code{4} for @code{4xBR}.
  10029. Default is @code{3}.
  10030. @end table
  10031. @anchor{yadif}
  10032. @section yadif
  10033. Deinterlace the input video ("yadif" means "yet another deinterlacing
  10034. filter").
  10035. It accepts the following parameters:
  10036. @table @option
  10037. @item mode
  10038. The interlacing mode to adopt. It accepts one of the following values:
  10039. @table @option
  10040. @item 0, send_frame
  10041. Output one frame for each frame.
  10042. @item 1, send_field
  10043. Output one frame for each field.
  10044. @item 2, send_frame_nospatial
  10045. Like @code{send_frame}, but it skips the spatial interlacing check.
  10046. @item 3, send_field_nospatial
  10047. Like @code{send_field}, but it skips the spatial interlacing check.
  10048. @end table
  10049. The default value is @code{send_frame}.
  10050. @item parity
  10051. The picture field parity assumed for the input interlaced video. It accepts one
  10052. of the following values:
  10053. @table @option
  10054. @item 0, tff
  10055. Assume the top field is first.
  10056. @item 1, bff
  10057. Assume the bottom field is first.
  10058. @item -1, auto
  10059. Enable automatic detection of field parity.
  10060. @end table
  10061. The default value is @code{auto}.
  10062. If the interlacing is unknown or the decoder does not export this information,
  10063. top field first will be assumed.
  10064. @item deint
  10065. Specify which frames to deinterlace. Accept one of the following
  10066. values:
  10067. @table @option
  10068. @item 0, all
  10069. Deinterlace all frames.
  10070. @item 1, interlaced
  10071. Only deinterlace frames marked as interlaced.
  10072. @end table
  10073. The default value is @code{all}.
  10074. @end table
  10075. @section zoompan
  10076. Apply Zoom & Pan effect.
  10077. This filter accepts the following options:
  10078. @table @option
  10079. @item zoom, z
  10080. Set the zoom expression. Default is 1.
  10081. @item x
  10082. @item y
  10083. Set the x and y expression. Default is 0.
  10084. @item d
  10085. Set the duration expression in number of frames.
  10086. This sets for how many number of frames effect will last for
  10087. single input image.
  10088. @item s
  10089. Set the output image size, default is 'hd720'.
  10090. @item fps
  10091. Set the output frame rate, default is '25'.
  10092. @end table
  10093. Each expression can contain the following constants:
  10094. @table @option
  10095. @item in_w, iw
  10096. Input width.
  10097. @item in_h, ih
  10098. Input height.
  10099. @item out_w, ow
  10100. Output width.
  10101. @item out_h, oh
  10102. Output height.
  10103. @item in
  10104. Input frame count.
  10105. @item on
  10106. Output frame count.
  10107. @item x
  10108. @item y
  10109. Last calculated 'x' and 'y' position from 'x' and 'y' expression
  10110. for current input frame.
  10111. @item px
  10112. @item py
  10113. 'x' and 'y' of last output frame of previous input frame or 0 when there was
  10114. not yet such frame (first input frame).
  10115. @item zoom
  10116. Last calculated zoom from 'z' expression for current input frame.
  10117. @item pzoom
  10118. Last calculated zoom of last output frame of previous input frame.
  10119. @item duration
  10120. Number of output frames for current input frame. Calculated from 'd' expression
  10121. for each input frame.
  10122. @item pduration
  10123. number of output frames created for previous input frame
  10124. @item a
  10125. Rational number: input width / input height
  10126. @item sar
  10127. sample aspect ratio
  10128. @item dar
  10129. display aspect ratio
  10130. @end table
  10131. @subsection Examples
  10132. @itemize
  10133. @item
  10134. Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
  10135. @example
  10136. 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
  10137. @end example
  10138. @item
  10139. Zoom-in up to 1.5 and pan always at center of picture:
  10140. @example
  10141. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
  10142. @end example
  10143. @end itemize
  10144. @section zscale
  10145. Scale (resize) the input video, using the z.lib library:
  10146. https://github.com/sekrit-twc/zimg.
  10147. The zscale filter forces the output display aspect ratio to be the same
  10148. as the input, by changing the output sample aspect ratio.
  10149. If the input image format is different from the format requested by
  10150. the next filter, the zscale filter will convert the input to the
  10151. requested format.
  10152. @subsection Options
  10153. The filter accepts the following options.
  10154. @table @option
  10155. @item width, w
  10156. @item height, h
  10157. Set the output video dimension expression. Default value is the input
  10158. dimension.
  10159. If the @var{width} or @var{w} is 0, the input width is used for the output.
  10160. If the @var{height} or @var{h} is 0, the input height is used for the output.
  10161. If one of the values is -1, the zscale filter will use a value that
  10162. maintains the aspect ratio of the input image, calculated from the
  10163. other specified dimension. If both of them are -1, the input size is
  10164. used
  10165. If one of the values is -n with n > 1, the zscale filter will also use a value
  10166. that maintains the aspect ratio of the input image, calculated from the other
  10167. specified dimension. After that it will, however, make sure that the calculated
  10168. dimension is divisible by n and adjust the value if necessary.
  10169. See below for the list of accepted constants for use in the dimension
  10170. expression.
  10171. @item size, s
  10172. Set the video size. For the syntax of this option, check the
  10173. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10174. @item dither, d
  10175. Set the dither type.
  10176. Possible values are:
  10177. @table @var
  10178. @item none
  10179. @item ordered
  10180. @item random
  10181. @item error_diffusion
  10182. @end table
  10183. Default is none.
  10184. @item filter, f
  10185. Set the resize filter type.
  10186. Possible values are:
  10187. @table @var
  10188. @item point
  10189. @item bilinear
  10190. @item bicubic
  10191. @item spline16
  10192. @item spline36
  10193. @item lanczos
  10194. @end table
  10195. Default is bilinear.
  10196. @item range, r
  10197. Set the color range.
  10198. Possible values are:
  10199. @table @var
  10200. @item input
  10201. @item limited
  10202. @item full
  10203. @end table
  10204. Default is same as input.
  10205. @item primaries, p
  10206. Set the color primaries.
  10207. Possible values are:
  10208. @table @var
  10209. @item input
  10210. @item 709
  10211. @item unspecified
  10212. @item 170m
  10213. @item 240m
  10214. @item 2020
  10215. @end table
  10216. Default is same as input.
  10217. @item transfer, t
  10218. Set the transfer characteristics.
  10219. Possible values are:
  10220. @table @var
  10221. @item input
  10222. @item 709
  10223. @item unspecified
  10224. @item 601
  10225. @item linear
  10226. @item 2020_10
  10227. @item 2020_12
  10228. @end table
  10229. Default is same as input.
  10230. @item matrix, m
  10231. Set the colorspace matrix.
  10232. Possible value are:
  10233. @table @var
  10234. @item input
  10235. @item 709
  10236. @item unspecified
  10237. @item 470bg
  10238. @item 170m
  10239. @item 2020_ncl
  10240. @item 2020_cl
  10241. @end table
  10242. Default is same as input.
  10243. @item rangein, rin
  10244. Set the input color range.
  10245. Possible values are:
  10246. @table @var
  10247. @item input
  10248. @item limited
  10249. @item full
  10250. @end table
  10251. Default is same as input.
  10252. @item primariesin, pin
  10253. Set the input color primaries.
  10254. Possible values are:
  10255. @table @var
  10256. @item input
  10257. @item 709
  10258. @item unspecified
  10259. @item 170m
  10260. @item 240m
  10261. @item 2020
  10262. @end table
  10263. Default is same as input.
  10264. @item transferin, tin
  10265. Set the input transfer characteristics.
  10266. Possible values are:
  10267. @table @var
  10268. @item input
  10269. @item 709
  10270. @item unspecified
  10271. @item 601
  10272. @item linear
  10273. @item 2020_10
  10274. @item 2020_12
  10275. @end table
  10276. Default is same as input.
  10277. @item matrixin, min
  10278. Set the input colorspace matrix.
  10279. Possible value are:
  10280. @table @var
  10281. @item input
  10282. @item 709
  10283. @item unspecified
  10284. @item 470bg
  10285. @item 170m
  10286. @item 2020_ncl
  10287. @item 2020_cl
  10288. @end table
  10289. @end table
  10290. The values of the @option{w} and @option{h} options are expressions
  10291. containing the following constants:
  10292. @table @var
  10293. @item in_w
  10294. @item in_h
  10295. The input width and height
  10296. @item iw
  10297. @item ih
  10298. These are the same as @var{in_w} and @var{in_h}.
  10299. @item out_w
  10300. @item out_h
  10301. The output (scaled) width and height
  10302. @item ow
  10303. @item oh
  10304. These are the same as @var{out_w} and @var{out_h}
  10305. @item a
  10306. The same as @var{iw} / @var{ih}
  10307. @item sar
  10308. input sample aspect ratio
  10309. @item dar
  10310. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  10311. @item hsub
  10312. @item vsub
  10313. horizontal and vertical input chroma subsample values. For example for the
  10314. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  10315. @item ohsub
  10316. @item ovsub
  10317. horizontal and vertical output chroma subsample values. For example for the
  10318. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  10319. @end table
  10320. @table @option
  10321. @end table
  10322. @c man end VIDEO FILTERS
  10323. @chapter Video Sources
  10324. @c man begin VIDEO SOURCES
  10325. Below is a description of the currently available video sources.
  10326. @section buffer
  10327. Buffer video frames, and make them available to the filter chain.
  10328. This source is mainly intended for a programmatic use, in particular
  10329. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  10330. It accepts the following parameters:
  10331. @table @option
  10332. @item video_size
  10333. Specify the size (width and height) of the buffered video frames. For the
  10334. syntax of this option, check the
  10335. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10336. @item width
  10337. The input video width.
  10338. @item height
  10339. The input video height.
  10340. @item pix_fmt
  10341. A string representing the pixel format of the buffered video frames.
  10342. It may be a number corresponding to a pixel format, or a pixel format
  10343. name.
  10344. @item time_base
  10345. Specify the timebase assumed by the timestamps of the buffered frames.
  10346. @item frame_rate
  10347. Specify the frame rate expected for the video stream.
  10348. @item pixel_aspect, sar
  10349. The sample (pixel) aspect ratio of the input video.
  10350. @item sws_param
  10351. Specify the optional parameters to be used for the scale filter which
  10352. is automatically inserted when an input change is detected in the
  10353. input size or format.
  10354. @item hw_frames_ctx
  10355. When using a hardware pixel format, this should be a reference to an
  10356. AVHWFramesContext describing input frames.
  10357. @end table
  10358. For example:
  10359. @example
  10360. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  10361. @end example
  10362. will instruct the source to accept video frames with size 320x240 and
  10363. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  10364. square pixels (1:1 sample aspect ratio).
  10365. Since the pixel format with name "yuv410p" corresponds to the number 6
  10366. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  10367. this example corresponds to:
  10368. @example
  10369. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  10370. @end example
  10371. Alternatively, the options can be specified as a flat string, but this
  10372. syntax is deprecated:
  10373. @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}]
  10374. @section cellauto
  10375. Create a pattern generated by an elementary cellular automaton.
  10376. The initial state of the cellular automaton can be defined through the
  10377. @option{filename}, and @option{pattern} options. If such options are
  10378. not specified an initial state is created randomly.
  10379. At each new frame a new row in the video is filled with the result of
  10380. the cellular automaton next generation. The behavior when the whole
  10381. frame is filled is defined by the @option{scroll} option.
  10382. This source accepts the following options:
  10383. @table @option
  10384. @item filename, f
  10385. Read the initial cellular automaton state, i.e. the starting row, from
  10386. the specified file.
  10387. In the file, each non-whitespace character is considered an alive
  10388. cell, a newline will terminate the row, and further characters in the
  10389. file will be ignored.
  10390. @item pattern, p
  10391. Read the initial cellular automaton state, i.e. the starting row, from
  10392. the specified string.
  10393. Each non-whitespace character in the string is considered an alive
  10394. cell, a newline will terminate the row, and further characters in the
  10395. string will be ignored.
  10396. @item rate, r
  10397. Set the video rate, that is the number of frames generated per second.
  10398. Default is 25.
  10399. @item random_fill_ratio, ratio
  10400. Set the random fill ratio for the initial cellular automaton row. It
  10401. is a floating point number value ranging from 0 to 1, defaults to
  10402. 1/PHI.
  10403. This option is ignored when a file or a pattern is specified.
  10404. @item random_seed, seed
  10405. Set the seed for filling randomly the initial row, must be an integer
  10406. included between 0 and UINT32_MAX. If not specified, or if explicitly
  10407. set to -1, the filter will try to use a good random seed on a best
  10408. effort basis.
  10409. @item rule
  10410. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  10411. Default value is 110.
  10412. @item size, s
  10413. Set the size of the output video. For the syntax of this option, check the
  10414. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10415. If @option{filename} or @option{pattern} is specified, the size is set
  10416. by default to the width of the specified initial state row, and the
  10417. height is set to @var{width} * PHI.
  10418. If @option{size} is set, it must contain the width of the specified
  10419. pattern string, and the specified pattern will be centered in the
  10420. larger row.
  10421. If a filename or a pattern string is not specified, the size value
  10422. defaults to "320x518" (used for a randomly generated initial state).
  10423. @item scroll
  10424. If set to 1, scroll the output upward when all the rows in the output
  10425. have been already filled. If set to 0, the new generated row will be
  10426. written over the top row just after the bottom row is filled.
  10427. Defaults to 1.
  10428. @item start_full, full
  10429. If set to 1, completely fill the output with generated rows before
  10430. outputting the first frame.
  10431. This is the default behavior, for disabling set the value to 0.
  10432. @item stitch
  10433. If set to 1, stitch the left and right row edges together.
  10434. This is the default behavior, for disabling set the value to 0.
  10435. @end table
  10436. @subsection Examples
  10437. @itemize
  10438. @item
  10439. Read the initial state from @file{pattern}, and specify an output of
  10440. size 200x400.
  10441. @example
  10442. cellauto=f=pattern:s=200x400
  10443. @end example
  10444. @item
  10445. Generate a random initial row with a width of 200 cells, with a fill
  10446. ratio of 2/3:
  10447. @example
  10448. cellauto=ratio=2/3:s=200x200
  10449. @end example
  10450. @item
  10451. Create a pattern generated by rule 18 starting by a single alive cell
  10452. centered on an initial row with width 100:
  10453. @example
  10454. cellauto=p=@@:s=100x400:full=0:rule=18
  10455. @end example
  10456. @item
  10457. Specify a more elaborated initial pattern:
  10458. @example
  10459. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  10460. @end example
  10461. @end itemize
  10462. @section mandelbrot
  10463. Generate a Mandelbrot set fractal, and progressively zoom towards the
  10464. point specified with @var{start_x} and @var{start_y}.
  10465. This source accepts the following options:
  10466. @table @option
  10467. @item end_pts
  10468. Set the terminal pts value. Default value is 400.
  10469. @item end_scale
  10470. Set the terminal scale value.
  10471. Must be a floating point value. Default value is 0.3.
  10472. @item inner
  10473. Set the inner coloring mode, that is the algorithm used to draw the
  10474. Mandelbrot fractal internal region.
  10475. It shall assume one of the following values:
  10476. @table @option
  10477. @item black
  10478. Set black mode.
  10479. @item convergence
  10480. Show time until convergence.
  10481. @item mincol
  10482. Set color based on point closest to the origin of the iterations.
  10483. @item period
  10484. Set period mode.
  10485. @end table
  10486. Default value is @var{mincol}.
  10487. @item bailout
  10488. Set the bailout value. Default value is 10.0.
  10489. @item maxiter
  10490. Set the maximum of iterations performed by the rendering
  10491. algorithm. Default value is 7189.
  10492. @item outer
  10493. Set outer coloring mode.
  10494. It shall assume one of following values:
  10495. @table @option
  10496. @item iteration_count
  10497. Set iteration cound mode.
  10498. @item normalized_iteration_count
  10499. set normalized iteration count mode.
  10500. @end table
  10501. Default value is @var{normalized_iteration_count}.
  10502. @item rate, r
  10503. Set frame rate, expressed as number of frames per second. Default
  10504. value is "25".
  10505. @item size, s
  10506. Set frame size. For the syntax of this option, check the "Video
  10507. size" section in the ffmpeg-utils manual. Default value is "640x480".
  10508. @item start_scale
  10509. Set the initial scale value. Default value is 3.0.
  10510. @item start_x
  10511. Set the initial x position. Must be a floating point value between
  10512. -100 and 100. Default value is -0.743643887037158704752191506114774.
  10513. @item start_y
  10514. Set the initial y position. Must be a floating point value between
  10515. -100 and 100. Default value is -0.131825904205311970493132056385139.
  10516. @end table
  10517. @section mptestsrc
  10518. Generate various test patterns, as generated by the MPlayer test filter.
  10519. The size of the generated video is fixed, and is 256x256.
  10520. This source is useful in particular for testing encoding features.
  10521. This source accepts the following options:
  10522. @table @option
  10523. @item rate, r
  10524. Specify the frame rate of the sourced video, as the number of frames
  10525. generated per second. It has to be a string in the format
  10526. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  10527. number or a valid video frame rate abbreviation. The default value is
  10528. "25".
  10529. @item duration, d
  10530. Set the duration of the sourced video. See
  10531. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  10532. for the accepted syntax.
  10533. If not specified, or the expressed duration is negative, the video is
  10534. supposed to be generated forever.
  10535. @item test, t
  10536. Set the number or the name of the test to perform. Supported tests are:
  10537. @table @option
  10538. @item dc_luma
  10539. @item dc_chroma
  10540. @item freq_luma
  10541. @item freq_chroma
  10542. @item amp_luma
  10543. @item amp_chroma
  10544. @item cbp
  10545. @item mv
  10546. @item ring1
  10547. @item ring2
  10548. @item all
  10549. @end table
  10550. Default value is "all", which will cycle through the list of all tests.
  10551. @end table
  10552. Some examples:
  10553. @example
  10554. mptestsrc=t=dc_luma
  10555. @end example
  10556. will generate a "dc_luma" test pattern.
  10557. @section frei0r_src
  10558. Provide a frei0r source.
  10559. To enable compilation of this filter you need to install the frei0r
  10560. header and configure FFmpeg with @code{--enable-frei0r}.
  10561. This source accepts the following parameters:
  10562. @table @option
  10563. @item size
  10564. The size of the video to generate. For the syntax of this option, check the
  10565. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10566. @item framerate
  10567. The framerate of the generated video. It may be a string of the form
  10568. @var{num}/@var{den} or a frame rate abbreviation.
  10569. @item filter_name
  10570. The name to the frei0r source to load. For more information regarding frei0r and
  10571. how to set the parameters, read the @ref{frei0r} section in the video filters
  10572. documentation.
  10573. @item filter_params
  10574. A '|'-separated list of parameters to pass to the frei0r source.
  10575. @end table
  10576. For example, to generate a frei0r partik0l source with size 200x200
  10577. and frame rate 10 which is overlaid on the overlay filter main input:
  10578. @example
  10579. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  10580. @end example
  10581. @section life
  10582. Generate a life pattern.
  10583. This source is based on a generalization of John Conway's life game.
  10584. The sourced input represents a life grid, each pixel represents a cell
  10585. which can be in one of two possible states, alive or dead. Every cell
  10586. interacts with its eight neighbours, which are the cells that are
  10587. horizontally, vertically, or diagonally adjacent.
  10588. At each interaction the grid evolves according to the adopted rule,
  10589. which specifies the number of neighbor alive cells which will make a
  10590. cell stay alive or born. The @option{rule} option allows one to specify
  10591. the rule to adopt.
  10592. This source accepts the following options:
  10593. @table @option
  10594. @item filename, f
  10595. Set the file from which to read the initial grid state. In the file,
  10596. each non-whitespace character is considered an alive cell, and newline
  10597. is used to delimit the end of each row.
  10598. If this option is not specified, the initial grid is generated
  10599. randomly.
  10600. @item rate, r
  10601. Set the video rate, that is the number of frames generated per second.
  10602. Default is 25.
  10603. @item random_fill_ratio, ratio
  10604. Set the random fill ratio for the initial random grid. It is a
  10605. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  10606. It is ignored when a file is specified.
  10607. @item random_seed, seed
  10608. Set the seed for filling the initial random grid, must be an integer
  10609. included between 0 and UINT32_MAX. If not specified, or if explicitly
  10610. set to -1, the filter will try to use a good random seed on a best
  10611. effort basis.
  10612. @item rule
  10613. Set the life rule.
  10614. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  10615. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  10616. @var{NS} specifies the number of alive neighbor cells which make a
  10617. live cell stay alive, and @var{NB} the number of alive neighbor cells
  10618. which make a dead cell to become alive (i.e. to "born").
  10619. "s" and "b" can be used in place of "S" and "B", respectively.
  10620. Alternatively a rule can be specified by an 18-bits integer. The 9
  10621. high order bits are used to encode the next cell state if it is alive
  10622. for each number of neighbor alive cells, the low order bits specify
  10623. the rule for "borning" new cells. Higher order bits encode for an
  10624. higher number of neighbor cells.
  10625. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  10626. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  10627. Default value is "S23/B3", which is the original Conway's game of life
  10628. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  10629. cells, and will born a new cell if there are three alive cells around
  10630. a dead cell.
  10631. @item size, s
  10632. Set the size of the output video. For the syntax of this option, check the
  10633. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10634. If @option{filename} is specified, the size is set by default to the
  10635. same size of the input file. If @option{size} is set, it must contain
  10636. the size specified in the input file, and the initial grid defined in
  10637. that file is centered in the larger resulting area.
  10638. If a filename is not specified, the size value defaults to "320x240"
  10639. (used for a randomly generated initial grid).
  10640. @item stitch
  10641. If set to 1, stitch the left and right grid edges together, and the
  10642. top and bottom edges also. Defaults to 1.
  10643. @item mold
  10644. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  10645. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  10646. value from 0 to 255.
  10647. @item life_color
  10648. Set the color of living (or new born) cells.
  10649. @item death_color
  10650. Set the color of dead cells. If @option{mold} is set, this is the first color
  10651. used to represent a dead cell.
  10652. @item mold_color
  10653. Set mold color, for definitely dead and moldy cells.
  10654. For the syntax of these 3 color options, check the "Color" section in the
  10655. ffmpeg-utils manual.
  10656. @end table
  10657. @subsection Examples
  10658. @itemize
  10659. @item
  10660. Read a grid from @file{pattern}, and center it on a grid of size
  10661. 300x300 pixels:
  10662. @example
  10663. life=f=pattern:s=300x300
  10664. @end example
  10665. @item
  10666. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  10667. @example
  10668. life=ratio=2/3:s=200x200
  10669. @end example
  10670. @item
  10671. Specify a custom rule for evolving a randomly generated grid:
  10672. @example
  10673. life=rule=S14/B34
  10674. @end example
  10675. @item
  10676. Full example with slow death effect (mold) using @command{ffplay}:
  10677. @example
  10678. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  10679. @end example
  10680. @end itemize
  10681. @anchor{allrgb}
  10682. @anchor{allyuv}
  10683. @anchor{color}
  10684. @anchor{haldclutsrc}
  10685. @anchor{nullsrc}
  10686. @anchor{rgbtestsrc}
  10687. @anchor{smptebars}
  10688. @anchor{smptehdbars}
  10689. @anchor{testsrc}
  10690. @section allrgb, allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  10691. The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
  10692. The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
  10693. The @code{color} source provides an uniformly colored input.
  10694. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  10695. @ref{haldclut} filter.
  10696. The @code{nullsrc} source returns unprocessed video frames. It is
  10697. mainly useful to be employed in analysis / debugging tools, or as the
  10698. source for filters which ignore the input data.
  10699. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  10700. detecting RGB vs BGR issues. You should see a red, green and blue
  10701. stripe from top to bottom.
  10702. The @code{smptebars} source generates a color bars pattern, based on
  10703. the SMPTE Engineering Guideline EG 1-1990.
  10704. The @code{smptehdbars} source generates a color bars pattern, based on
  10705. the SMPTE RP 219-2002.
  10706. The @code{testsrc} source generates a test video pattern, showing a
  10707. color pattern, a scrolling gradient and a timestamp. This is mainly
  10708. intended for testing purposes.
  10709. The sources accept the following parameters:
  10710. @table @option
  10711. @item color, c
  10712. Specify the color of the source, only available in the @code{color}
  10713. source. For the syntax of this option, check the "Color" section in the
  10714. ffmpeg-utils manual.
  10715. @item level
  10716. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  10717. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  10718. pixels to be used as identity matrix for 3D lookup tables. Each component is
  10719. coded on a @code{1/(N*N)} scale.
  10720. @item size, s
  10721. Specify the size of the sourced video. For the syntax of this option, check the
  10722. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10723. The default value is @code{320x240}.
  10724. This option is not available with the @code{haldclutsrc} filter.
  10725. @item rate, r
  10726. Specify the frame rate of the sourced video, as the number of frames
  10727. generated per second. It has to be a string in the format
  10728. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  10729. number or a valid video frame rate abbreviation. The default value is
  10730. "25".
  10731. @item sar
  10732. Set the sample aspect ratio of the sourced video.
  10733. @item duration, d
  10734. Set the duration of the sourced video. See
  10735. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  10736. for the accepted syntax.
  10737. If not specified, or the expressed duration is negative, the video is
  10738. supposed to be generated forever.
  10739. @item decimals, n
  10740. Set the number of decimals to show in the timestamp, only available in the
  10741. @code{testsrc} source.
  10742. The displayed timestamp value will correspond to the original
  10743. timestamp value multiplied by the power of 10 of the specified
  10744. value. Default value is 0.
  10745. @end table
  10746. For example the following:
  10747. @example
  10748. testsrc=duration=5.3:size=qcif:rate=10
  10749. @end example
  10750. will generate a video with a duration of 5.3 seconds, with size
  10751. 176x144 and a frame rate of 10 frames per second.
  10752. The following graph description will generate a red source
  10753. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  10754. frames per second.
  10755. @example
  10756. color=c=red@@0.2:s=qcif:r=10
  10757. @end example
  10758. If the input content is to be ignored, @code{nullsrc} can be used. The
  10759. following command generates noise in the luminance plane by employing
  10760. the @code{geq} filter:
  10761. @example
  10762. nullsrc=s=256x256, geq=random(1)*255:128:128
  10763. @end example
  10764. @subsection Commands
  10765. The @code{color} source supports the following commands:
  10766. @table @option
  10767. @item c, color
  10768. Set the color of the created image. Accepts the same syntax of the
  10769. corresponding @option{color} option.
  10770. @end table
  10771. @c man end VIDEO SOURCES
  10772. @chapter Video Sinks
  10773. @c man begin VIDEO SINKS
  10774. Below is a description of the currently available video sinks.
  10775. @section buffersink
  10776. Buffer video frames, and make them available to the end of the filter
  10777. graph.
  10778. This sink is mainly intended for programmatic use, in particular
  10779. through the interface defined in @file{libavfilter/buffersink.h}
  10780. or the options system.
  10781. It accepts a pointer to an AVBufferSinkContext structure, which
  10782. defines the incoming buffers' formats, to be passed as the opaque
  10783. parameter to @code{avfilter_init_filter} for initialization.
  10784. @section nullsink
  10785. Null video sink: do absolutely nothing with the input video. It is
  10786. mainly useful as a template and for use in analysis / debugging
  10787. tools.
  10788. @c man end VIDEO SINKS
  10789. @chapter Multimedia Filters
  10790. @c man begin MULTIMEDIA FILTERS
  10791. Below is a description of the currently available multimedia filters.
  10792. @section ahistogram
  10793. Convert input audio to a video output, displaying the volume histogram.
  10794. The filter accepts the following options:
  10795. @table @option
  10796. @item dmode
  10797. Specify how histogram is calculated.
  10798. It accepts the following values:
  10799. @table @samp
  10800. @item single
  10801. Use single histogram for all channels.
  10802. @item separate
  10803. Use separate histogram for each channel.
  10804. @end table
  10805. Default is @code{single}.
  10806. @item rate, r
  10807. Set frame rate, expressed as number of frames per second. Default
  10808. value is "25".
  10809. @item size, s
  10810. Specify the video size for the output. For the syntax of this option, check the
  10811. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10812. Default value is @code{hd720}.
  10813. @item scale
  10814. Set display scale.
  10815. It accepts the following values:
  10816. @table @samp
  10817. @item log
  10818. logarithmic
  10819. @item sqrt
  10820. square root
  10821. @item cbrt
  10822. cubic root
  10823. @item lin
  10824. linear
  10825. @item rlog
  10826. reverse logarithmic
  10827. @end table
  10828. Default is @code{log}.
  10829. @item ascale
  10830. Set amplitude scale.
  10831. It accepts the following values:
  10832. @table @samp
  10833. @item log
  10834. logarithmic
  10835. @item lin
  10836. linear
  10837. @end table
  10838. Default is @code{log}.
  10839. @item acount
  10840. Set how much frames to accumulate in histogram.
  10841. Defauls is 1. Setting this to -1 accumulates all frames.
  10842. @item rheight
  10843. Set histogram ratio of window height.
  10844. @item slide
  10845. Set sonogram sliding.
  10846. It accepts the following values:
  10847. @table @samp
  10848. @item replace
  10849. replace old rows with new ones.
  10850. @item scroll
  10851. scroll from top to bottom.
  10852. @end table
  10853. Default is @code{replace}.
  10854. @end table
  10855. @section aphasemeter
  10856. Convert input audio to a video output, displaying the audio phase.
  10857. The filter accepts the following options:
  10858. @table @option
  10859. @item rate, r
  10860. Set the output frame rate. Default value is @code{25}.
  10861. @item size, s
  10862. Set the video size for the output. For the syntax of this option, check the
  10863. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10864. Default value is @code{800x400}.
  10865. @item rc
  10866. @item gc
  10867. @item bc
  10868. Specify the red, green, blue contrast. Default values are @code{2},
  10869. @code{7} and @code{1}.
  10870. Allowed range is @code{[0, 255]}.
  10871. @item mpc
  10872. Set color which will be used for drawing median phase. If color is
  10873. @code{none} which is default, no median phase value will be drawn.
  10874. @end table
  10875. The filter also exports the frame metadata @code{lavfi.aphasemeter.phase} which
  10876. represents mean phase of current audio frame. Value is in range @code{[-1, 1]}.
  10877. The @code{-1} means left and right channels are completely out of phase and
  10878. @code{1} means channels are in phase.
  10879. @section avectorscope
  10880. Convert input audio to a video output, representing the audio vector
  10881. scope.
  10882. The filter is used to measure the difference between channels of stereo
  10883. audio stream. A monoaural signal, consisting of identical left and right
  10884. signal, results in straight vertical line. Any stereo separation is visible
  10885. as a deviation from this line, creating a Lissajous figure.
  10886. If the straight (or deviation from it) but horizontal line appears this
  10887. indicates that the left and right channels are out of phase.
  10888. The filter accepts the following options:
  10889. @table @option
  10890. @item mode, m
  10891. Set the vectorscope mode.
  10892. Available values are:
  10893. @table @samp
  10894. @item lissajous
  10895. Lissajous rotated by 45 degrees.
  10896. @item lissajous_xy
  10897. Same as above but not rotated.
  10898. @item polar
  10899. Shape resembling half of circle.
  10900. @end table
  10901. Default value is @samp{lissajous}.
  10902. @item size, s
  10903. Set the video size for the output. For the syntax of this option, check the
  10904. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10905. Default value is @code{400x400}.
  10906. @item rate, r
  10907. Set the output frame rate. Default value is @code{25}.
  10908. @item rc
  10909. @item gc
  10910. @item bc
  10911. @item ac
  10912. Specify the red, green, blue and alpha contrast. Default values are @code{40},
  10913. @code{160}, @code{80} and @code{255}.
  10914. Allowed range is @code{[0, 255]}.
  10915. @item rf
  10916. @item gf
  10917. @item bf
  10918. @item af
  10919. Specify the red, green, blue and alpha fade. Default values are @code{15},
  10920. @code{10}, @code{5} and @code{5}.
  10921. Allowed range is @code{[0, 255]}.
  10922. @item zoom
  10923. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  10924. @item draw
  10925. Set the vectorscope drawing mode.
  10926. Available values are:
  10927. @table @samp
  10928. @item dot
  10929. Draw dot for each sample.
  10930. @item line
  10931. Draw line between previous and current sample.
  10932. @end table
  10933. Default value is @samp{dot}.
  10934. @end table
  10935. @subsection Examples
  10936. @itemize
  10937. @item
  10938. Complete example using @command{ffplay}:
  10939. @example
  10940. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  10941. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  10942. @end example
  10943. @end itemize
  10944. @section bench, abench
  10945. Benchmark part of a filtergraph.
  10946. The filter accepts the following options:
  10947. @table @option
  10948. @item action
  10949. Start or stop a timer.
  10950. Available values are:
  10951. @table @samp
  10952. @item start
  10953. Get the current time, set it as frame metadata (using the key
  10954. @code{lavfi.bench.start_time}), and forward the frame to the next filter.
  10955. @item stop
  10956. Get the current time and fetch the @code{lavfi.bench.start_time} metadata from
  10957. the input frame metadata to get the time difference. Time difference, average,
  10958. maximum and minimum time (respectively @code{t}, @code{avg}, @code{max} and
  10959. @code{min}) are then printed. The timestamps are expressed in seconds.
  10960. @end table
  10961. @end table
  10962. @subsection Examples
  10963. @itemize
  10964. @item
  10965. Benchmark @ref{selectivecolor} filter:
  10966. @example
  10967. bench=start,selectivecolor=reds=-.2 .12 -.49,bench=stop
  10968. @end example
  10969. @end itemize
  10970. @section concat
  10971. Concatenate audio and video streams, joining them together one after the
  10972. other.
  10973. The filter works on segments of synchronized video and audio streams. All
  10974. segments must have the same number of streams of each type, and that will
  10975. also be the number of streams at output.
  10976. The filter accepts the following options:
  10977. @table @option
  10978. @item n
  10979. Set the number of segments. Default is 2.
  10980. @item v
  10981. Set the number of output video streams, that is also the number of video
  10982. streams in each segment. Default is 1.
  10983. @item a
  10984. Set the number of output audio streams, that is also the number of audio
  10985. streams in each segment. Default is 0.
  10986. @item unsafe
  10987. Activate unsafe mode: do not fail if segments have a different format.
  10988. @end table
  10989. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  10990. @var{a} audio outputs.
  10991. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  10992. segment, in the same order as the outputs, then the inputs for the second
  10993. segment, etc.
  10994. Related streams do not always have exactly the same duration, for various
  10995. reasons including codec frame size or sloppy authoring. For that reason,
  10996. related synchronized streams (e.g. a video and its audio track) should be
  10997. concatenated at once. The concat filter will use the duration of the longest
  10998. stream in each segment (except the last one), and if necessary pad shorter
  10999. audio streams with silence.
  11000. For this filter to work correctly, all segments must start at timestamp 0.
  11001. All corresponding streams must have the same parameters in all segments; the
  11002. filtering system will automatically select a common pixel format for video
  11003. streams, and a common sample format, sample rate and channel layout for
  11004. audio streams, but other settings, such as resolution, must be converted
  11005. explicitly by the user.
  11006. Different frame rates are acceptable but will result in variable frame rate
  11007. at output; be sure to configure the output file to handle it.
  11008. @subsection Examples
  11009. @itemize
  11010. @item
  11011. Concatenate an opening, an episode and an ending, all in bilingual version
  11012. (video in stream 0, audio in streams 1 and 2):
  11013. @example
  11014. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  11015. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  11016. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  11017. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  11018. @end example
  11019. @item
  11020. Concatenate two parts, handling audio and video separately, using the
  11021. (a)movie sources, and adjusting the resolution:
  11022. @example
  11023. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  11024. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  11025. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  11026. @end example
  11027. Note that a desync will happen at the stitch if the audio and video streams
  11028. do not have exactly the same duration in the first file.
  11029. @end itemize
  11030. @anchor{ebur128}
  11031. @section ebur128
  11032. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  11033. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  11034. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  11035. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  11036. The filter also has a video output (see the @var{video} option) with a real
  11037. time graph to observe the loudness evolution. The graphic contains the logged
  11038. message mentioned above, so it is not printed anymore when this option is set,
  11039. unless the verbose logging is set. The main graphing area contains the
  11040. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  11041. the momentary loudness (400 milliseconds).
  11042. More information about the Loudness Recommendation EBU R128 on
  11043. @url{http://tech.ebu.ch/loudness}.
  11044. The filter accepts the following options:
  11045. @table @option
  11046. @item video
  11047. Activate the video output. The audio stream is passed unchanged whether this
  11048. option is set or no. The video stream will be the first output stream if
  11049. activated. Default is @code{0}.
  11050. @item size
  11051. Set the video size. This option is for video only. For the syntax of this
  11052. option, check the
  11053. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11054. Default and minimum resolution is @code{640x480}.
  11055. @item meter
  11056. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  11057. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  11058. other integer value between this range is allowed.
  11059. @item metadata
  11060. Set metadata injection. If set to @code{1}, the audio input will be segmented
  11061. into 100ms output frames, each of them containing various loudness information
  11062. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  11063. Default is @code{0}.
  11064. @item framelog
  11065. Force the frame logging level.
  11066. Available values are:
  11067. @table @samp
  11068. @item info
  11069. information logging level
  11070. @item verbose
  11071. verbose logging level
  11072. @end table
  11073. By default, the logging level is set to @var{info}. If the @option{video} or
  11074. the @option{metadata} options are set, it switches to @var{verbose}.
  11075. @item peak
  11076. Set peak mode(s).
  11077. Available modes can be cumulated (the option is a @code{flag} type). Possible
  11078. values are:
  11079. @table @samp
  11080. @item none
  11081. Disable any peak mode (default).
  11082. @item sample
  11083. Enable sample-peak mode.
  11084. Simple peak mode looking for the higher sample value. It logs a message
  11085. for sample-peak (identified by @code{SPK}).
  11086. @item true
  11087. Enable true-peak mode.
  11088. If enabled, the peak lookup is done on an over-sampled version of the input
  11089. stream for better peak accuracy. It logs a message for true-peak.
  11090. (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
  11091. This mode requires a build with @code{libswresample}.
  11092. @end table
  11093. @item dualmono
  11094. Treat mono input files as "dual mono". If a mono file is intended for playback
  11095. on a stereo system, its EBU R128 measurement will be perceptually incorrect.
  11096. If set to @code{true}, this option will compensate for this effect.
  11097. Multi-channel input files are not affected by this option.
  11098. @item panlaw
  11099. Set a specific pan law to be used for the measurement of dual mono files.
  11100. This parameter is optional, and has a default value of -3.01dB.
  11101. @end table
  11102. @subsection Examples
  11103. @itemize
  11104. @item
  11105. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  11106. @example
  11107. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  11108. @end example
  11109. @item
  11110. Run an analysis with @command{ffmpeg}:
  11111. @example
  11112. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  11113. @end example
  11114. @end itemize
  11115. @section interleave, ainterleave
  11116. Temporally interleave frames from several inputs.
  11117. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  11118. These filters read frames from several inputs and send the oldest
  11119. queued frame to the output.
  11120. Input streams must have a well defined, monotonically increasing frame
  11121. timestamp values.
  11122. In order to submit one frame to output, these filters need to enqueue
  11123. at least one frame for each input, so they cannot work in case one
  11124. input is not yet terminated and will not receive incoming frames.
  11125. For example consider the case when one input is a @code{select} filter
  11126. which always drop input frames. The @code{interleave} filter will keep
  11127. reading from that input, but it will never be able to send new frames
  11128. to output until the input will send an end-of-stream signal.
  11129. Also, depending on inputs synchronization, the filters will drop
  11130. frames in case one input receives more frames than the other ones, and
  11131. the queue is already filled.
  11132. These filters accept the following options:
  11133. @table @option
  11134. @item nb_inputs, n
  11135. Set the number of different inputs, it is 2 by default.
  11136. @end table
  11137. @subsection Examples
  11138. @itemize
  11139. @item
  11140. Interleave frames belonging to different streams using @command{ffmpeg}:
  11141. @example
  11142. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  11143. @end example
  11144. @item
  11145. Add flickering blur effect:
  11146. @example
  11147. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  11148. @end example
  11149. @end itemize
  11150. @section perms, aperms
  11151. Set read/write permissions for the output frames.
  11152. These filters are mainly aimed at developers to test direct path in the
  11153. following filter in the filtergraph.
  11154. The filters accept the following options:
  11155. @table @option
  11156. @item mode
  11157. Select the permissions mode.
  11158. It accepts the following values:
  11159. @table @samp
  11160. @item none
  11161. Do nothing. This is the default.
  11162. @item ro
  11163. Set all the output frames read-only.
  11164. @item rw
  11165. Set all the output frames directly writable.
  11166. @item toggle
  11167. Make the frame read-only if writable, and writable if read-only.
  11168. @item random
  11169. Set each output frame read-only or writable randomly.
  11170. @end table
  11171. @item seed
  11172. Set the seed for the @var{random} mode, must be an integer included between
  11173. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  11174. @code{-1}, the filter will try to use a good random seed on a best effort
  11175. basis.
  11176. @end table
  11177. Note: in case of auto-inserted filter between the permission filter and the
  11178. following one, the permission might not be received as expected in that
  11179. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  11180. perms/aperms filter can avoid this problem.
  11181. @section realtime, arealtime
  11182. Slow down filtering to match real time approximatively.
  11183. These filters will pause the filtering for a variable amount of time to
  11184. match the output rate with the input timestamps.
  11185. They are similar to the @option{re} option to @code{ffmpeg}.
  11186. They accept the following options:
  11187. @table @option
  11188. @item limit
  11189. Time limit for the pauses. Any pause longer than that will be considered
  11190. a timestamp discontinuity and reset the timer. Default is 2 seconds.
  11191. @end table
  11192. @section select, aselect
  11193. Select frames to pass in output.
  11194. This filter accepts the following options:
  11195. @table @option
  11196. @item expr, e
  11197. Set expression, which is evaluated for each input frame.
  11198. If the expression is evaluated to zero, the frame is discarded.
  11199. If the evaluation result is negative or NaN, the frame is sent to the
  11200. first output; otherwise it is sent to the output with index
  11201. @code{ceil(val)-1}, assuming that the input index starts from 0.
  11202. For example a value of @code{1.2} corresponds to the output with index
  11203. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  11204. @item outputs, n
  11205. Set the number of outputs. The output to which to send the selected
  11206. frame is based on the result of the evaluation. Default value is 1.
  11207. @end table
  11208. The expression can contain the following constants:
  11209. @table @option
  11210. @item n
  11211. The (sequential) number of the filtered frame, starting from 0.
  11212. @item selected_n
  11213. The (sequential) number of the selected frame, starting from 0.
  11214. @item prev_selected_n
  11215. The sequential number of the last selected frame. It's NAN if undefined.
  11216. @item TB
  11217. The timebase of the input timestamps.
  11218. @item pts
  11219. The PTS (Presentation TimeStamp) of the filtered video frame,
  11220. expressed in @var{TB} units. It's NAN if undefined.
  11221. @item t
  11222. The PTS of the filtered video frame,
  11223. expressed in seconds. It's NAN if undefined.
  11224. @item prev_pts
  11225. The PTS of the previously filtered video frame. It's NAN if undefined.
  11226. @item prev_selected_pts
  11227. The PTS of the last previously filtered video frame. It's NAN if undefined.
  11228. @item prev_selected_t
  11229. The PTS of the last previously selected video frame. It's NAN if undefined.
  11230. @item start_pts
  11231. The PTS of the first video frame in the video. It's NAN if undefined.
  11232. @item start_t
  11233. The time of the first video frame in the video. It's NAN if undefined.
  11234. @item pict_type @emph{(video only)}
  11235. The type of the filtered frame. It can assume one of the following
  11236. values:
  11237. @table @option
  11238. @item I
  11239. @item P
  11240. @item B
  11241. @item S
  11242. @item SI
  11243. @item SP
  11244. @item BI
  11245. @end table
  11246. @item interlace_type @emph{(video only)}
  11247. The frame interlace type. It can assume one of the following values:
  11248. @table @option
  11249. @item PROGRESSIVE
  11250. The frame is progressive (not interlaced).
  11251. @item TOPFIRST
  11252. The frame is top-field-first.
  11253. @item BOTTOMFIRST
  11254. The frame is bottom-field-first.
  11255. @end table
  11256. @item consumed_sample_n @emph{(audio only)}
  11257. the number of selected samples before the current frame
  11258. @item samples_n @emph{(audio only)}
  11259. the number of samples in the current frame
  11260. @item sample_rate @emph{(audio only)}
  11261. the input sample rate
  11262. @item key
  11263. This is 1 if the filtered frame is a key-frame, 0 otherwise.
  11264. @item pos
  11265. the position in the file of the filtered frame, -1 if the information
  11266. is not available (e.g. for synthetic video)
  11267. @item scene @emph{(video only)}
  11268. value between 0 and 1 to indicate a new scene; a low value reflects a low
  11269. probability for the current frame to introduce a new scene, while a higher
  11270. value means the current frame is more likely to be one (see the example below)
  11271. @item concatdec_select
  11272. The concat demuxer can select only part of a concat input file by setting an
  11273. inpoint and an outpoint, but the output packets may not be entirely contained
  11274. in the selected interval. By using this variable, it is possible to skip frames
  11275. generated by the concat demuxer which are not exactly contained in the selected
  11276. interval.
  11277. This works by comparing the frame pts against the @var{lavf.concat.start_time}
  11278. and the @var{lavf.concat.duration} packet metadata values which are also
  11279. present in the decoded frames.
  11280. The @var{concatdec_select} variable is -1 if the frame pts is at least
  11281. start_time and either the duration metadata is missing or the frame pts is less
  11282. than start_time + duration, 0 otherwise, and NaN if the start_time metadata is
  11283. missing.
  11284. That basically means that an input frame is selected if its pts is within the
  11285. interval set by the concat demuxer.
  11286. @end table
  11287. The default value of the select expression is "1".
  11288. @subsection Examples
  11289. @itemize
  11290. @item
  11291. Select all frames in input:
  11292. @example
  11293. select
  11294. @end example
  11295. The example above is the same as:
  11296. @example
  11297. select=1
  11298. @end example
  11299. @item
  11300. Skip all frames:
  11301. @example
  11302. select=0
  11303. @end example
  11304. @item
  11305. Select only I-frames:
  11306. @example
  11307. select='eq(pict_type\,I)'
  11308. @end example
  11309. @item
  11310. Select one frame every 100:
  11311. @example
  11312. select='not(mod(n\,100))'
  11313. @end example
  11314. @item
  11315. Select only frames contained in the 10-20 time interval:
  11316. @example
  11317. select=between(t\,10\,20)
  11318. @end example
  11319. @item
  11320. Select only I frames contained in the 10-20 time interval:
  11321. @example
  11322. select=between(t\,10\,20)*eq(pict_type\,I)
  11323. @end example
  11324. @item
  11325. Select frames with a minimum distance of 10 seconds:
  11326. @example
  11327. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  11328. @end example
  11329. @item
  11330. Use aselect to select only audio frames with samples number > 100:
  11331. @example
  11332. aselect='gt(samples_n\,100)'
  11333. @end example
  11334. @item
  11335. Create a mosaic of the first scenes:
  11336. @example
  11337. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  11338. @end example
  11339. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  11340. choice.
  11341. @item
  11342. Send even and odd frames to separate outputs, and compose them:
  11343. @example
  11344. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  11345. @end example
  11346. @item
  11347. Select useful frames from an ffconcat file which is using inpoints and
  11348. outpoints but where the source files are not intra frame only.
  11349. @example
  11350. ffmpeg -copyts -vsync 0 -segment_time_metadata 1 -i input.ffconcat -vf select=concatdec_select -af aselect=concatdec_select output.avi
  11351. @end example
  11352. @end itemize
  11353. @section sendcmd, asendcmd
  11354. Send commands to filters in the filtergraph.
  11355. These filters read commands to be sent to other filters in the
  11356. filtergraph.
  11357. @code{sendcmd} must be inserted between two video filters,
  11358. @code{asendcmd} must be inserted between two audio filters, but apart
  11359. from that they act the same way.
  11360. The specification of commands can be provided in the filter arguments
  11361. with the @var{commands} option, or in a file specified by the
  11362. @var{filename} option.
  11363. These filters accept the following options:
  11364. @table @option
  11365. @item commands, c
  11366. Set the commands to be read and sent to the other filters.
  11367. @item filename, f
  11368. Set the filename of the commands to be read and sent to the other
  11369. filters.
  11370. @end table
  11371. @subsection Commands syntax
  11372. A commands description consists of a sequence of interval
  11373. specifications, comprising a list of commands to be executed when a
  11374. particular event related to that interval occurs. The occurring event
  11375. is typically the current frame time entering or leaving a given time
  11376. interval.
  11377. An interval is specified by the following syntax:
  11378. @example
  11379. @var{START}[-@var{END}] @var{COMMANDS};
  11380. @end example
  11381. The time interval is specified by the @var{START} and @var{END} times.
  11382. @var{END} is optional and defaults to the maximum time.
  11383. The current frame time is considered within the specified interval if
  11384. it is included in the interval [@var{START}, @var{END}), that is when
  11385. the time is greater or equal to @var{START} and is lesser than
  11386. @var{END}.
  11387. @var{COMMANDS} consists of a sequence of one or more command
  11388. specifications, separated by ",", relating to that interval. The
  11389. syntax of a command specification is given by:
  11390. @example
  11391. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  11392. @end example
  11393. @var{FLAGS} is optional and specifies the type of events relating to
  11394. the time interval which enable sending the specified command, and must
  11395. be a non-null sequence of identifier flags separated by "+" or "|" and
  11396. enclosed between "[" and "]".
  11397. The following flags are recognized:
  11398. @table @option
  11399. @item enter
  11400. The command is sent when the current frame timestamp enters the
  11401. specified interval. In other words, the command is sent when the
  11402. previous frame timestamp was not in the given interval, and the
  11403. current is.
  11404. @item leave
  11405. The command is sent when the current frame timestamp leaves the
  11406. specified interval. In other words, the command is sent when the
  11407. previous frame timestamp was in the given interval, and the
  11408. current is not.
  11409. @end table
  11410. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  11411. assumed.
  11412. @var{TARGET} specifies the target of the command, usually the name of
  11413. the filter class or a specific filter instance name.
  11414. @var{COMMAND} specifies the name of the command for the target filter.
  11415. @var{ARG} is optional and specifies the optional list of argument for
  11416. the given @var{COMMAND}.
  11417. Between one interval specification and another, whitespaces, or
  11418. sequences of characters starting with @code{#} until the end of line,
  11419. are ignored and can be used to annotate comments.
  11420. A simplified BNF description of the commands specification syntax
  11421. follows:
  11422. @example
  11423. @var{COMMAND_FLAG} ::= "enter" | "leave"
  11424. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  11425. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  11426. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  11427. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  11428. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  11429. @end example
  11430. @subsection Examples
  11431. @itemize
  11432. @item
  11433. Specify audio tempo change at second 4:
  11434. @example
  11435. asendcmd=c='4.0 atempo tempo 1.5',atempo
  11436. @end example
  11437. @item
  11438. Specify a list of drawtext and hue commands in a file.
  11439. @example
  11440. # show text in the interval 5-10
  11441. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  11442. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  11443. # desaturate the image in the interval 15-20
  11444. 15.0-20.0 [enter] hue s 0,
  11445. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  11446. [leave] hue s 1,
  11447. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  11448. # apply an exponential saturation fade-out effect, starting from time 25
  11449. 25 [enter] hue s exp(25-t)
  11450. @end example
  11451. A filtergraph allowing to read and process the above command list
  11452. stored in a file @file{test.cmd}, can be specified with:
  11453. @example
  11454. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  11455. @end example
  11456. @end itemize
  11457. @anchor{setpts}
  11458. @section setpts, asetpts
  11459. Change the PTS (presentation timestamp) of the input frames.
  11460. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  11461. This filter accepts the following options:
  11462. @table @option
  11463. @item expr
  11464. The expression which is evaluated for each frame to construct its timestamp.
  11465. @end table
  11466. The expression is evaluated through the eval API and can contain the following
  11467. constants:
  11468. @table @option
  11469. @item FRAME_RATE
  11470. frame rate, only defined for constant frame-rate video
  11471. @item PTS
  11472. The presentation timestamp in input
  11473. @item N
  11474. The count of the input frame for video or the number of consumed samples,
  11475. not including the current frame for audio, starting from 0.
  11476. @item NB_CONSUMED_SAMPLES
  11477. The number of consumed samples, not including the current frame (only
  11478. audio)
  11479. @item NB_SAMPLES, S
  11480. The number of samples in the current frame (only audio)
  11481. @item SAMPLE_RATE, SR
  11482. The audio sample rate.
  11483. @item STARTPTS
  11484. The PTS of the first frame.
  11485. @item STARTT
  11486. the time in seconds of the first frame
  11487. @item INTERLACED
  11488. State whether the current frame is interlaced.
  11489. @item T
  11490. the time in seconds of the current frame
  11491. @item POS
  11492. original position in the file of the frame, or undefined if undefined
  11493. for the current frame
  11494. @item PREV_INPTS
  11495. The previous input PTS.
  11496. @item PREV_INT
  11497. previous input time in seconds
  11498. @item PREV_OUTPTS
  11499. The previous output PTS.
  11500. @item PREV_OUTT
  11501. previous output time in seconds
  11502. @item RTCTIME
  11503. The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  11504. instead.
  11505. @item RTCSTART
  11506. The wallclock (RTC) time at the start of the movie in microseconds.
  11507. @item TB
  11508. The timebase of the input timestamps.
  11509. @end table
  11510. @subsection Examples
  11511. @itemize
  11512. @item
  11513. Start counting PTS from zero
  11514. @example
  11515. setpts=PTS-STARTPTS
  11516. @end example
  11517. @item
  11518. Apply fast motion effect:
  11519. @example
  11520. setpts=0.5*PTS
  11521. @end example
  11522. @item
  11523. Apply slow motion effect:
  11524. @example
  11525. setpts=2.0*PTS
  11526. @end example
  11527. @item
  11528. Set fixed rate of 25 frames per second:
  11529. @example
  11530. setpts=N/(25*TB)
  11531. @end example
  11532. @item
  11533. Set fixed rate 25 fps with some jitter:
  11534. @example
  11535. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  11536. @end example
  11537. @item
  11538. Apply an offset of 10 seconds to the input PTS:
  11539. @example
  11540. setpts=PTS+10/TB
  11541. @end example
  11542. @item
  11543. Generate timestamps from a "live source" and rebase onto the current timebase:
  11544. @example
  11545. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  11546. @end example
  11547. @item
  11548. Generate timestamps by counting samples:
  11549. @example
  11550. asetpts=N/SR/TB
  11551. @end example
  11552. @end itemize
  11553. @section settb, asettb
  11554. Set the timebase to use for the output frames timestamps.
  11555. It is mainly useful for testing timebase configuration.
  11556. It accepts the following parameters:
  11557. @table @option
  11558. @item expr, tb
  11559. The expression which is evaluated into the output timebase.
  11560. @end table
  11561. The value for @option{tb} is an arithmetic expression representing a
  11562. rational. The expression can contain the constants "AVTB" (the default
  11563. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  11564. audio only). Default value is "intb".
  11565. @subsection Examples
  11566. @itemize
  11567. @item
  11568. Set the timebase to 1/25:
  11569. @example
  11570. settb=expr=1/25
  11571. @end example
  11572. @item
  11573. Set the timebase to 1/10:
  11574. @example
  11575. settb=expr=0.1
  11576. @end example
  11577. @item
  11578. Set the timebase to 1001/1000:
  11579. @example
  11580. settb=1+0.001
  11581. @end example
  11582. @item
  11583. Set the timebase to 2*intb:
  11584. @example
  11585. settb=2*intb
  11586. @end example
  11587. @item
  11588. Set the default timebase value:
  11589. @example
  11590. settb=AVTB
  11591. @end example
  11592. @end itemize
  11593. @section showcqt
  11594. Convert input audio to a video output representing frequency spectrum
  11595. logarithmically using Brown-Puckette constant Q transform algorithm with
  11596. direct frequency domain coefficient calculation (but the transform itself
  11597. is not really constant Q, instead the Q factor is actually variable/clamped),
  11598. with musical tone scale, from E0 to D#10.
  11599. The filter accepts the following options:
  11600. @table @option
  11601. @item size, s
  11602. Specify the video size for the output. It must be even. For the syntax of this option,
  11603. check the @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11604. Default value is @code{1920x1080}.
  11605. @item fps, rate, r
  11606. Set the output frame rate. Default value is @code{25}.
  11607. @item bar_h
  11608. Set the bargraph height. It must be even. Default value is @code{-1} which
  11609. computes the bargraph height automatically.
  11610. @item axis_h
  11611. Set the axis height. It must be even. Default value is @code{-1} which computes
  11612. the axis height automatically.
  11613. @item sono_h
  11614. Set the sonogram height. It must be even. Default value is @code{-1} which
  11615. computes the sonogram height automatically.
  11616. @item fullhd
  11617. Set the fullhd resolution. This option is deprecated, use @var{size}, @var{s}
  11618. instead. Default value is @code{1}.
  11619. @item sono_v, volume
  11620. Specify the sonogram volume expression. It can contain variables:
  11621. @table @option
  11622. @item bar_v
  11623. the @var{bar_v} evaluated expression
  11624. @item frequency, freq, f
  11625. the frequency where it is evaluated
  11626. @item timeclamp, tc
  11627. the value of @var{timeclamp} option
  11628. @end table
  11629. and functions:
  11630. @table @option
  11631. @item a_weighting(f)
  11632. A-weighting of equal loudness
  11633. @item b_weighting(f)
  11634. B-weighting of equal loudness
  11635. @item c_weighting(f)
  11636. C-weighting of equal loudness.
  11637. @end table
  11638. Default value is @code{16}.
  11639. @item bar_v, volume2
  11640. Specify the bargraph volume expression. It can contain variables:
  11641. @table @option
  11642. @item sono_v
  11643. the @var{sono_v} evaluated expression
  11644. @item frequency, freq, f
  11645. the frequency where it is evaluated
  11646. @item timeclamp, tc
  11647. the value of @var{timeclamp} option
  11648. @end table
  11649. and functions:
  11650. @table @option
  11651. @item a_weighting(f)
  11652. A-weighting of equal loudness
  11653. @item b_weighting(f)
  11654. B-weighting of equal loudness
  11655. @item c_weighting(f)
  11656. C-weighting of equal loudness.
  11657. @end table
  11658. Default value is @code{sono_v}.
  11659. @item sono_g, gamma
  11660. Specify the sonogram gamma. Lower gamma makes the spectrum more contrast,
  11661. higher gamma makes the spectrum having more range. Default value is @code{3}.
  11662. Acceptable range is @code{[1, 7]}.
  11663. @item bar_g, gamma2
  11664. Specify the bargraph gamma. Default value is @code{1}. Acceptable range is
  11665. @code{[1, 7]}.
  11666. @item timeclamp, tc
  11667. Specify the transform timeclamp. At low frequency, there is trade-off between
  11668. accuracy in time domain and frequency domain. If timeclamp is lower,
  11669. event in time domain is represented more accurately (such as fast bass drum),
  11670. otherwise event in frequency domain is represented more accurately
  11671. (such as bass guitar). Acceptable range is @code{[0.1, 1]}. Default value is @code{0.17}.
  11672. @item basefreq
  11673. Specify the transform base frequency. Default value is @code{20.01523126408007475},
  11674. which is frequency 50 cents below E0. Acceptable range is @code{[10, 100000]}.
  11675. @item endfreq
  11676. Specify the transform end frequency. Default value is @code{20495.59681441799654},
  11677. which is frequency 50 cents above D#10. Acceptable range is @code{[10, 100000]}.
  11678. @item coeffclamp
  11679. This option is deprecated and ignored.
  11680. @item tlength
  11681. Specify the transform length in time domain. Use this option to control accuracy
  11682. trade-off between time domain and frequency domain at every frequency sample.
  11683. It can contain variables:
  11684. @table @option
  11685. @item frequency, freq, f
  11686. the frequency where it is evaluated
  11687. @item timeclamp, tc
  11688. the value of @var{timeclamp} option.
  11689. @end table
  11690. Default value is @code{384*tc/(384+tc*f)}.
  11691. @item count
  11692. Specify the transform count for every video frame. Default value is @code{6}.
  11693. Acceptable range is @code{[1, 30]}.
  11694. @item fcount
  11695. Specify the transform count for every single pixel. Default value is @code{0},
  11696. which makes it computed automatically. Acceptable range is @code{[0, 10]}.
  11697. @item fontfile
  11698. Specify font file for use with freetype to draw the axis. If not specified,
  11699. use embedded font. Note that drawing with font file or embedded font is not
  11700. implemented with custom @var{basefreq} and @var{endfreq}, use @var{axisfile}
  11701. option instead.
  11702. @item fontcolor
  11703. Specify font color expression. This is arithmetic expression that should return
  11704. integer value 0xRRGGBB. It can contain variables:
  11705. @table @option
  11706. @item frequency, freq, f
  11707. the frequency where it is evaluated
  11708. @item timeclamp, tc
  11709. the value of @var{timeclamp} option
  11710. @end table
  11711. and functions:
  11712. @table @option
  11713. @item midi(f)
  11714. midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
  11715. @item r(x), g(x), b(x)
  11716. red, green, and blue value of intensity x.
  11717. @end table
  11718. Default value is @code{st(0, (midi(f)-59.5)/12);
  11719. st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
  11720. r(1-ld(1)) + b(ld(1))}.
  11721. @item axisfile
  11722. Specify image file to draw the axis. This option override @var{fontfile} and
  11723. @var{fontcolor} option.
  11724. @item axis, text
  11725. Enable/disable drawing text to the axis. If it is set to @code{0}, drawing to
  11726. the axis is disabled, ignoring @var{fontfile} and @var{axisfile} option.
  11727. Default value is @code{1}.
  11728. @end table
  11729. @subsection Examples
  11730. @itemize
  11731. @item
  11732. Playing audio while showing the spectrum:
  11733. @example
  11734. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
  11735. @end example
  11736. @item
  11737. Same as above, but with frame rate 30 fps:
  11738. @example
  11739. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
  11740. @end example
  11741. @item
  11742. Playing at 1280x720:
  11743. @example
  11744. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=s=1280x720:count=4 [out0]'
  11745. @end example
  11746. @item
  11747. Disable sonogram display:
  11748. @example
  11749. sono_h=0
  11750. @end example
  11751. @item
  11752. A1 and its harmonics: A1, A2, (near)E3, A3:
  11753. @example
  11754. 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),
  11755. asplit[a][out1]; [a] showcqt [out0]'
  11756. @end example
  11757. @item
  11758. Same as above, but with more accuracy in frequency domain:
  11759. @example
  11760. 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),
  11761. asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
  11762. @end example
  11763. @item
  11764. Custom volume:
  11765. @example
  11766. bar_v=10:sono_v=bar_v*a_weighting(f)
  11767. @end example
  11768. @item
  11769. Custom gamma, now spectrum is linear to the amplitude.
  11770. @example
  11771. bar_g=2:sono_g=2
  11772. @end example
  11773. @item
  11774. Custom tlength equation:
  11775. @example
  11776. 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)))'
  11777. @end example
  11778. @item
  11779. Custom fontcolor and fontfile, C-note is colored green, others are colored blue:
  11780. @example
  11781. fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))':fontfile=myfont.ttf
  11782. @end example
  11783. @item
  11784. Custom frequency range with custom axis using image file:
  11785. @example
  11786. axisfile=myaxis.png:basefreq=40:endfreq=10000
  11787. @end example
  11788. @end itemize
  11789. @section showfreqs
  11790. Convert input audio to video output representing the audio power spectrum.
  11791. Audio amplitude is on Y-axis while frequency is on X-axis.
  11792. The filter accepts the following options:
  11793. @table @option
  11794. @item size, s
  11795. Specify size of video. For the syntax of this option, check the
  11796. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11797. Default is @code{1024x512}.
  11798. @item mode
  11799. Set display mode.
  11800. This set how each frequency bin will be represented.
  11801. It accepts the following values:
  11802. @table @samp
  11803. @item line
  11804. @item bar
  11805. @item dot
  11806. @end table
  11807. Default is @code{bar}.
  11808. @item ascale
  11809. Set amplitude scale.
  11810. It accepts the following values:
  11811. @table @samp
  11812. @item lin
  11813. Linear scale.
  11814. @item sqrt
  11815. Square root scale.
  11816. @item cbrt
  11817. Cubic root scale.
  11818. @item log
  11819. Logarithmic scale.
  11820. @end table
  11821. Default is @code{log}.
  11822. @item fscale
  11823. Set frequency scale.
  11824. It accepts the following values:
  11825. @table @samp
  11826. @item lin
  11827. Linear scale.
  11828. @item log
  11829. Logarithmic scale.
  11830. @item rlog
  11831. Reverse logarithmic scale.
  11832. @end table
  11833. Default is @code{lin}.
  11834. @item win_size
  11835. Set window size.
  11836. It accepts the following values:
  11837. @table @samp
  11838. @item w16
  11839. @item w32
  11840. @item w64
  11841. @item w128
  11842. @item w256
  11843. @item w512
  11844. @item w1024
  11845. @item w2048
  11846. @item w4096
  11847. @item w8192
  11848. @item w16384
  11849. @item w32768
  11850. @item w65536
  11851. @end table
  11852. Default is @code{w2048}
  11853. @item win_func
  11854. Set windowing function.
  11855. It accepts the following values:
  11856. @table @samp
  11857. @item rect
  11858. @item bartlett
  11859. @item hanning
  11860. @item hamming
  11861. @item blackman
  11862. @item welch
  11863. @item flattop
  11864. @item bharris
  11865. @item bnuttall
  11866. @item bhann
  11867. @item sine
  11868. @item nuttall
  11869. @item lanczos
  11870. @item gauss
  11871. @item tukey
  11872. @end table
  11873. Default is @code{hanning}.
  11874. @item overlap
  11875. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  11876. which means optimal overlap for selected window function will be picked.
  11877. @item averaging
  11878. Set time averaging. Setting this to 0 will display current maximal peaks.
  11879. Default is @code{1}, which means time averaging is disabled.
  11880. @item colors
  11881. Specify list of colors separated by space or by '|' which will be used to
  11882. draw channel frequencies. Unrecognized or missing colors will be replaced
  11883. by white color.
  11884. @item cmode
  11885. Set channel display mode.
  11886. It accepts the following values:
  11887. @table @samp
  11888. @item combined
  11889. @item separate
  11890. @end table
  11891. Default is @code{combined}.
  11892. @end table
  11893. @anchor{showspectrum}
  11894. @section showspectrum
  11895. Convert input audio to a video output, representing the audio frequency
  11896. spectrum.
  11897. The filter accepts the following options:
  11898. @table @option
  11899. @item size, s
  11900. Specify the video size for the output. For the syntax of this option, check the
  11901. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11902. Default value is @code{640x512}.
  11903. @item slide
  11904. Specify how the spectrum should slide along the window.
  11905. It accepts the following values:
  11906. @table @samp
  11907. @item replace
  11908. the samples start again on the left when they reach the right
  11909. @item scroll
  11910. the samples scroll from right to left
  11911. @item rscroll
  11912. the samples scroll from left to right
  11913. @item fullframe
  11914. frames are only produced when the samples reach the right
  11915. @end table
  11916. Default value is @code{replace}.
  11917. @item mode
  11918. Specify display mode.
  11919. It accepts the following values:
  11920. @table @samp
  11921. @item combined
  11922. all channels are displayed in the same row
  11923. @item separate
  11924. all channels are displayed in separate rows
  11925. @end table
  11926. Default value is @samp{combined}.
  11927. @item color
  11928. Specify display color mode.
  11929. It accepts the following values:
  11930. @table @samp
  11931. @item channel
  11932. each channel is displayed in a separate color
  11933. @item intensity
  11934. each channel is displayed using the same color scheme
  11935. @item rainbow
  11936. each channel is displayed using the rainbow color scheme
  11937. @item moreland
  11938. each channel is displayed using the moreland color scheme
  11939. @item nebulae
  11940. each channel is displayed using the nebulae color scheme
  11941. @item fire
  11942. each channel is displayed using the fire color scheme
  11943. @item fiery
  11944. each channel is displayed using the fiery color scheme
  11945. @item fruit
  11946. each channel is displayed using the fruit color scheme
  11947. @item cool
  11948. each channel is displayed using the cool color scheme
  11949. @end table
  11950. Default value is @samp{channel}.
  11951. @item scale
  11952. Specify scale used for calculating intensity color values.
  11953. It accepts the following values:
  11954. @table @samp
  11955. @item lin
  11956. linear
  11957. @item sqrt
  11958. square root, default
  11959. @item cbrt
  11960. cubic root
  11961. @item 4thrt
  11962. 4th root
  11963. @item 5thrt
  11964. 5th root
  11965. @item log
  11966. logarithmic
  11967. @end table
  11968. Default value is @samp{sqrt}.
  11969. @item saturation
  11970. Set saturation modifier for displayed colors. Negative values provide
  11971. alternative color scheme. @code{0} is no saturation at all.
  11972. Saturation must be in [-10.0, 10.0] range.
  11973. Default value is @code{1}.
  11974. @item win_func
  11975. Set window function.
  11976. It accepts the following values:
  11977. @table @samp
  11978. @item rect
  11979. @item bartlett
  11980. @item hann
  11981. @item hanning
  11982. @item hamming
  11983. @item blackman
  11984. @item welch
  11985. @item flattop
  11986. @item bharris
  11987. @item bnuttall
  11988. @item bhann
  11989. @item sine
  11990. @item nuttall
  11991. @item lanczos
  11992. @item gauss
  11993. @item tukey
  11994. @end table
  11995. Default value is @code{hann}.
  11996. @item orientation
  11997. Set orientation of time vs frequency axis. Can be @code{vertical} or
  11998. @code{horizontal}. Default is @code{vertical}.
  11999. @item overlap
  12000. Set ratio of overlap window. Default value is @code{0}.
  12001. When value is @code{1} overlap is set to recommended size for specific
  12002. window function currently used.
  12003. @item gain
  12004. Set scale gain for calculating intensity color values.
  12005. Default value is @code{1}.
  12006. @item data
  12007. Set which data to display. Can be @code{magnitude}, default or @code{phase}.
  12008. @end table
  12009. The usage is very similar to the showwaves filter; see the examples in that
  12010. section.
  12011. @subsection Examples
  12012. @itemize
  12013. @item
  12014. Large window with logarithmic color scaling:
  12015. @example
  12016. showspectrum=s=1280x480:scale=log
  12017. @end example
  12018. @item
  12019. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  12020. @example
  12021. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  12022. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  12023. @end example
  12024. @end itemize
  12025. @section showspectrumpic
  12026. Convert input audio to a single video frame, representing the audio frequency
  12027. spectrum.
  12028. The filter accepts the following options:
  12029. @table @option
  12030. @item size, s
  12031. Specify the video size for the output. For the syntax of this option, check the
  12032. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12033. Default value is @code{4096x2048}.
  12034. @item mode
  12035. Specify display mode.
  12036. It accepts the following values:
  12037. @table @samp
  12038. @item combined
  12039. all channels are displayed in the same row
  12040. @item separate
  12041. all channels are displayed in separate rows
  12042. @end table
  12043. Default value is @samp{combined}.
  12044. @item color
  12045. Specify display color mode.
  12046. It accepts the following values:
  12047. @table @samp
  12048. @item channel
  12049. each channel is displayed in a separate color
  12050. @item intensity
  12051. each channel is displayed using the same color scheme
  12052. @item rainbow
  12053. each channel is displayed using the rainbow color scheme
  12054. @item moreland
  12055. each channel is displayed using the moreland color scheme
  12056. @item nebulae
  12057. each channel is displayed using the nebulae color scheme
  12058. @item fire
  12059. each channel is displayed using the fire color scheme
  12060. @item fiery
  12061. each channel is displayed using the fiery color scheme
  12062. @item fruit
  12063. each channel is displayed using the fruit color scheme
  12064. @item cool
  12065. each channel is displayed using the cool color scheme
  12066. @end table
  12067. Default value is @samp{intensity}.
  12068. @item scale
  12069. Specify scale used for calculating intensity color values.
  12070. It accepts the following values:
  12071. @table @samp
  12072. @item lin
  12073. linear
  12074. @item sqrt
  12075. square root, default
  12076. @item cbrt
  12077. cubic root
  12078. @item 4thrt
  12079. 4th root
  12080. @item 5thrt
  12081. 5th root
  12082. @item log
  12083. logarithmic
  12084. @end table
  12085. Default value is @samp{log}.
  12086. @item saturation
  12087. Set saturation modifier for displayed colors. Negative values provide
  12088. alternative color scheme. @code{0} is no saturation at all.
  12089. Saturation must be in [-10.0, 10.0] range.
  12090. Default value is @code{1}.
  12091. @item win_func
  12092. Set window function.
  12093. It accepts the following values:
  12094. @table @samp
  12095. @item rect
  12096. @item bartlett
  12097. @item hann
  12098. @item hanning
  12099. @item hamming
  12100. @item blackman
  12101. @item welch
  12102. @item flattop
  12103. @item bharris
  12104. @item bnuttall
  12105. @item bhann
  12106. @item sine
  12107. @item nuttall
  12108. @item lanczos
  12109. @item gauss
  12110. @item tukey
  12111. @end table
  12112. Default value is @code{hann}.
  12113. @item orientation
  12114. Set orientation of time vs frequency axis. Can be @code{vertical} or
  12115. @code{horizontal}. Default is @code{vertical}.
  12116. @item gain
  12117. Set scale gain for calculating intensity color values.
  12118. Default value is @code{1}.
  12119. @item legend
  12120. Draw time and frequency axes and legends. Default is enabled.
  12121. @end table
  12122. @subsection Examples
  12123. @itemize
  12124. @item
  12125. Extract an audio spectrogram of a whole audio track
  12126. in a 1024x1024 picture using @command{ffmpeg}:
  12127. @example
  12128. ffmpeg -i audio.flac -lavfi showspectrumpic=s=1024x1024 spectrogram.png
  12129. @end example
  12130. @end itemize
  12131. @section showvolume
  12132. Convert input audio volume to a video output.
  12133. The filter accepts the following options:
  12134. @table @option
  12135. @item rate, r
  12136. Set video rate.
  12137. @item b
  12138. Set border width, allowed range is [0, 5]. Default is 1.
  12139. @item w
  12140. Set channel width, allowed range is [80, 8192]. Default is 400.
  12141. @item h
  12142. Set channel height, allowed range is [1, 900]. Default is 20.
  12143. @item f
  12144. Set fade, allowed range is [0.001, 1]. Default is 0.95.
  12145. @item c
  12146. Set volume color expression.
  12147. The expression can use the following variables:
  12148. @table @option
  12149. @item VOLUME
  12150. Current max volume of channel in dB.
  12151. @item CHANNEL
  12152. Current channel number, starting from 0.
  12153. @end table
  12154. @item t
  12155. If set, displays channel names. Default is enabled.
  12156. @item v
  12157. If set, displays volume values. Default is enabled.
  12158. @item o
  12159. Set orientation, can be @code{horizontal} or @code{vertical},
  12160. default is @code{horizontal}.
  12161. @item s
  12162. Set step size, allowed range s [0, 5]. Default is 0, which means
  12163. step is disabled.
  12164. @end table
  12165. @section showwaves
  12166. Convert input audio to a video output, representing the samples waves.
  12167. The filter accepts the following options:
  12168. @table @option
  12169. @item size, s
  12170. Specify the video size for the output. For the syntax of this option, check the
  12171. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12172. Default value is @code{600x240}.
  12173. @item mode
  12174. Set display mode.
  12175. Available values are:
  12176. @table @samp
  12177. @item point
  12178. Draw a point for each sample.
  12179. @item line
  12180. Draw a vertical line for each sample.
  12181. @item p2p
  12182. Draw a point for each sample and a line between them.
  12183. @item cline
  12184. Draw a centered vertical line for each sample.
  12185. @end table
  12186. Default value is @code{point}.
  12187. @item n
  12188. Set the number of samples which are printed on the same column. A
  12189. larger value will decrease the frame rate. Must be a positive
  12190. integer. This option can be set only if the value for @var{rate}
  12191. is not explicitly specified.
  12192. @item rate, r
  12193. Set the (approximate) output frame rate. This is done by setting the
  12194. option @var{n}. Default value is "25".
  12195. @item split_channels
  12196. Set if channels should be drawn separately or overlap. Default value is 0.
  12197. @item colors
  12198. Set colors separated by '|' which are going to be used for drawing of each channel.
  12199. @item scale
  12200. Set amplitude scale. Can be linear @code{lin} or logarithmic @code{log}.
  12201. Default is linear.
  12202. @end table
  12203. @subsection Examples
  12204. @itemize
  12205. @item
  12206. Output the input file audio and the corresponding video representation
  12207. at the same time:
  12208. @example
  12209. amovie=a.mp3,asplit[out0],showwaves[out1]
  12210. @end example
  12211. @item
  12212. Create a synthetic signal and show it with showwaves, forcing a
  12213. frame rate of 30 frames per second:
  12214. @example
  12215. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  12216. @end example
  12217. @end itemize
  12218. @section showwavespic
  12219. Convert input audio to a single video frame, representing the samples waves.
  12220. The filter accepts the following options:
  12221. @table @option
  12222. @item size, s
  12223. Specify the video size for the output. For the syntax of this option, check the
  12224. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12225. Default value is @code{600x240}.
  12226. @item split_channels
  12227. Set if channels should be drawn separately or overlap. Default value is 0.
  12228. @item colors
  12229. Set colors separated by '|' which are going to be used for drawing of each channel.
  12230. @item scale
  12231. Set amplitude scale. Can be linear @code{lin} or logarithmic @code{log}.
  12232. Default is linear.
  12233. @end table
  12234. @subsection Examples
  12235. @itemize
  12236. @item
  12237. Extract a channel split representation of the wave form of a whole audio track
  12238. in a 1024x800 picture using @command{ffmpeg}:
  12239. @example
  12240. ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
  12241. @end example
  12242. @item
  12243. Colorize the waveform with colorchannelmixer. This example will make
  12244. the waveform a green color approximately RGB(66,217,150). Additional
  12245. channels will be shades of this color.
  12246. @example
  12247. ffmpeg -i audio.mp3 -filter_complex "showwavespic,colorchannelmixer=rr=66/255:gg=217/255:bb=150/255" waveform.png
  12248. @end example
  12249. @end itemize
  12250. @section spectrumsynth
  12251. Sythesize audio from 2 input video spectrums, first input stream represents
  12252. magnitude across time and second represents phase across time.
  12253. The filter will transform from frequency domain as displayed in videos back
  12254. to time domain as presented in audio output.
  12255. This filter is primarly created for reversing processed @ref{showspectrum}
  12256. filter outputs, but can synthesize sound from other spectrograms too.
  12257. But in such case results are going to be poor if the phase data is not
  12258. available, because in such cases phase data need to be recreated, usually
  12259. its just recreated from random noise.
  12260. For best results use gray only output (@code{channel} color mode in
  12261. @ref{showspectrum} filter) and @code{log} scale for magnitude video and
  12262. @code{lin} scale for phase video. To produce phase, for 2nd video, use
  12263. @code{data} option. Inputs videos should generally use @code{fullframe}
  12264. slide mode as that saves resources needed for decoding video.
  12265. The filter accepts the following options:
  12266. @table @option
  12267. @item sample_rate
  12268. Specify sample rate of output audio, the sample rate of audio from which
  12269. spectrum was generated may differ.
  12270. @item channels
  12271. Set number of channels represented in input video spectrums.
  12272. @item scale
  12273. Set scale which was used when generating magnitude input spectrum.
  12274. Can be @code{lin} or @code{log}. Default is @code{log}.
  12275. @item slide
  12276. Set slide which was used when generating inputs spectrums.
  12277. Can be @code{replace}, @code{scroll}, @code{fullframe} or @code{rscroll}.
  12278. Default is @code{fullframe}.
  12279. @item win_func
  12280. Set window function used for resynthesis.
  12281. @item overlap
  12282. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  12283. which means optimal overlap for selected window function will be picked.
  12284. @item orientation
  12285. Set orientation of input videos. Can be @code{vertical} or @code{horizontal}.
  12286. Default is @code{vertical}.
  12287. @end table
  12288. @subsection Examples
  12289. @itemize
  12290. @item
  12291. First create magnitude and phase videos from audio, assuming audio is stereo with 44100 sample rate,
  12292. then resynthesize videos back to audio with spectrumsynth:
  12293. @example
  12294. 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
  12295. 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
  12296. ffmpeg -i magnitude.nut -i phase.nut -lavfi spectrumsynth=channels=2:sample_rate=44100:win_func=hann:overlap=0.875:slide=fullframe output.flac
  12297. @end example
  12298. @end itemize
  12299. @section split, asplit
  12300. Split input into several identical outputs.
  12301. @code{asplit} works with audio input, @code{split} with video.
  12302. The filter accepts a single parameter which specifies the number of outputs. If
  12303. unspecified, it defaults to 2.
  12304. @subsection Examples
  12305. @itemize
  12306. @item
  12307. Create two separate outputs from the same input:
  12308. @example
  12309. [in] split [out0][out1]
  12310. @end example
  12311. @item
  12312. To create 3 or more outputs, you need to specify the number of
  12313. outputs, like in:
  12314. @example
  12315. [in] asplit=3 [out0][out1][out2]
  12316. @end example
  12317. @item
  12318. Create two separate outputs from the same input, one cropped and
  12319. one padded:
  12320. @example
  12321. [in] split [splitout1][splitout2];
  12322. [splitout1] crop=100:100:0:0 [cropout];
  12323. [splitout2] pad=200:200:100:100 [padout];
  12324. @end example
  12325. @item
  12326. Create 5 copies of the input audio with @command{ffmpeg}:
  12327. @example
  12328. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  12329. @end example
  12330. @end itemize
  12331. @section zmq, azmq
  12332. Receive commands sent through a libzmq client, and forward them to
  12333. filters in the filtergraph.
  12334. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  12335. must be inserted between two video filters, @code{azmq} between two
  12336. audio filters.
  12337. To enable these filters you need to install the libzmq library and
  12338. headers and configure FFmpeg with @code{--enable-libzmq}.
  12339. For more information about libzmq see:
  12340. @url{http://www.zeromq.org/}
  12341. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  12342. receives messages sent through a network interface defined by the
  12343. @option{bind_address} option.
  12344. The received message must be in the form:
  12345. @example
  12346. @var{TARGET} @var{COMMAND} [@var{ARG}]
  12347. @end example
  12348. @var{TARGET} specifies the target of the command, usually the name of
  12349. the filter class or a specific filter instance name.
  12350. @var{COMMAND} specifies the name of the command for the target filter.
  12351. @var{ARG} is optional and specifies the optional argument list for the
  12352. given @var{COMMAND}.
  12353. Upon reception, the message is processed and the corresponding command
  12354. is injected into the filtergraph. Depending on the result, the filter
  12355. will send a reply to the client, adopting the format:
  12356. @example
  12357. @var{ERROR_CODE} @var{ERROR_REASON}
  12358. @var{MESSAGE}
  12359. @end example
  12360. @var{MESSAGE} is optional.
  12361. @subsection Examples
  12362. Look at @file{tools/zmqsend} for an example of a zmq client which can
  12363. be used to send commands processed by these filters.
  12364. Consider the following filtergraph generated by @command{ffplay}
  12365. @example
  12366. ffplay -dumpgraph 1 -f lavfi "
  12367. color=s=100x100:c=red [l];
  12368. color=s=100x100:c=blue [r];
  12369. nullsrc=s=200x100, zmq [bg];
  12370. [bg][l] overlay [bg+l];
  12371. [bg+l][r] overlay=x=100 "
  12372. @end example
  12373. To change the color of the left side of the video, the following
  12374. command can be used:
  12375. @example
  12376. echo Parsed_color_0 c yellow | tools/zmqsend
  12377. @end example
  12378. To change the right side:
  12379. @example
  12380. echo Parsed_color_1 c pink | tools/zmqsend
  12381. @end example
  12382. @c man end MULTIMEDIA FILTERS
  12383. @chapter Multimedia Sources
  12384. @c man begin MULTIMEDIA SOURCES
  12385. Below is a description of the currently available multimedia sources.
  12386. @section amovie
  12387. This is the same as @ref{movie} source, except it selects an audio
  12388. stream by default.
  12389. @anchor{movie}
  12390. @section movie
  12391. Read audio and/or video stream(s) from a movie container.
  12392. It accepts the following parameters:
  12393. @table @option
  12394. @item filename
  12395. The name of the resource to read (not necessarily a file; it can also be a
  12396. device or a stream accessed through some protocol).
  12397. @item format_name, f
  12398. Specifies the format assumed for the movie to read, and can be either
  12399. the name of a container or an input device. If not specified, the
  12400. format is guessed from @var{movie_name} or by probing.
  12401. @item seek_point, sp
  12402. Specifies the seek point in seconds. The frames will be output
  12403. starting from this seek point. The parameter is evaluated with
  12404. @code{av_strtod}, so the numerical value may be suffixed by an IS
  12405. postfix. The default value is "0".
  12406. @item streams, s
  12407. Specifies the streams to read. Several streams can be specified,
  12408. separated by "+". The source will then have as many outputs, in the
  12409. same order. The syntax is explained in the ``Stream specifiers''
  12410. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  12411. respectively the default (best suited) video and audio stream. Default
  12412. is "dv", or "da" if the filter is called as "amovie".
  12413. @item stream_index, si
  12414. Specifies the index of the video stream to read. If the value is -1,
  12415. the most suitable video stream will be automatically selected. The default
  12416. value is "-1". Deprecated. If the filter is called "amovie", it will select
  12417. audio instead of video.
  12418. @item loop
  12419. Specifies how many times to read the stream in sequence.
  12420. If the value is less than 1, the stream will be read again and again.
  12421. Default value is "1".
  12422. Note that when the movie is looped the source timestamps are not
  12423. changed, so it will generate non monotonically increasing timestamps.
  12424. @end table
  12425. It allows overlaying a second video on top of the main input of
  12426. a filtergraph, as shown in this graph:
  12427. @example
  12428. input -----------> deltapts0 --> overlay --> output
  12429. ^
  12430. |
  12431. movie --> scale--> deltapts1 -------+
  12432. @end example
  12433. @subsection Examples
  12434. @itemize
  12435. @item
  12436. Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
  12437. on top of the input labelled "in":
  12438. @example
  12439. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  12440. [in] setpts=PTS-STARTPTS [main];
  12441. [main][over] overlay=16:16 [out]
  12442. @end example
  12443. @item
  12444. Read from a video4linux2 device, and overlay it on top of the input
  12445. labelled "in":
  12446. @example
  12447. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  12448. [in] setpts=PTS-STARTPTS [main];
  12449. [main][over] overlay=16:16 [out]
  12450. @end example
  12451. @item
  12452. Read the first video stream and the audio stream with id 0x81 from
  12453. dvd.vob; the video is connected to the pad named "video" and the audio is
  12454. connected to the pad named "audio":
  12455. @example
  12456. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  12457. @end example
  12458. @end itemize
  12459. @c man end MULTIMEDIA SOURCES