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.

14853 lines
406KB

  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. @anchor{aformat}
  588. @section aformat
  589. Set output format constraints for the input audio. The framework will
  590. negotiate the most appropriate format to minimize conversions.
  591. It accepts the following parameters:
  592. @table @option
  593. @item sample_fmts
  594. A '|'-separated list of requested sample formats.
  595. @item sample_rates
  596. A '|'-separated list of requested sample rates.
  597. @item channel_layouts
  598. A '|'-separated list of requested channel layouts.
  599. See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  600. for the required syntax.
  601. @end table
  602. If a parameter is omitted, all values are allowed.
  603. Force the output to either unsigned 8-bit or signed 16-bit stereo
  604. @example
  605. aformat=sample_fmts=u8|s16:channel_layouts=stereo
  606. @end example
  607. @section agate
  608. A gate is mainly used to reduce lower parts of a signal. This kind of signal
  609. processing reduces disturbing noise between useful signals.
  610. Gating is done by detecting the volume below a chosen level @var{threshold}
  611. and divide it by the factor set with @var{ratio}. The bottom of the noise
  612. floor is set via @var{range}. Because an exact manipulation of the signal
  613. would cause distortion of the waveform the reduction can be levelled over
  614. time. This is done by setting @var{attack} and @var{release}.
  615. @var{attack} determines how long the signal has to fall below the threshold
  616. before any reduction will occur and @var{release} sets the time the signal
  617. has to raise above the threshold to reduce the reduction again.
  618. Shorter signals than the chosen attack time will be left untouched.
  619. @table @option
  620. @item level_in
  621. Set input level before filtering.
  622. Default is 1. Allowed range is from 0.015625 to 64.
  623. @item range
  624. Set the level of gain reduction when the signal is below the threshold.
  625. Default is 0.06125. Allowed range is from 0 to 1.
  626. @item threshold
  627. If a signal rises above this level the gain reduction is released.
  628. Default is 0.125. Allowed range is from 0 to 1.
  629. @item ratio
  630. Set a ratio about which the signal is reduced.
  631. Default is 2. Allowed range is from 1 to 9000.
  632. @item attack
  633. Amount of milliseconds the signal has to rise above the threshold before gain
  634. reduction stops.
  635. Default is 20 milliseconds. Allowed range is from 0.01 to 9000.
  636. @item release
  637. Amount of milliseconds the signal has to fall below the threshold before the
  638. reduction is increased again. Default is 250 milliseconds.
  639. Allowed range is from 0.01 to 9000.
  640. @item makeup
  641. Set amount of amplification of signal after processing.
  642. Default is 1. Allowed range is from 1 to 64.
  643. @item knee
  644. Curve the sharp knee around the threshold to enter gain reduction more softly.
  645. Default is 2.828427125. Allowed range is from 1 to 8.
  646. @item detection
  647. Choose if exact signal should be taken for detection or an RMS like one.
  648. Default is rms. Can be peak or rms.
  649. @item link
  650. Choose if the average level between all channels or the louder channel affects
  651. the reduction.
  652. Default is average. Can be average or maximum.
  653. @end table
  654. @section alimiter
  655. The limiter prevents input signal from raising over a desired threshold.
  656. This limiter uses lookahead technology to prevent your signal from distorting.
  657. It means that there is a small delay after signal is processed. Keep in mind
  658. that the delay it produces is the attack time you set.
  659. The filter accepts the following options:
  660. @table @option
  661. @item level_in
  662. Set input gain. Default is 1.
  663. @item level_out
  664. Set output gain. Default is 1.
  665. @item limit
  666. Don't let signals above this level pass the limiter. Default is 1.
  667. @item attack
  668. The limiter will reach its attenuation level in this amount of time in
  669. milliseconds. Default is 5 milliseconds.
  670. @item release
  671. Come back from limiting to attenuation 1.0 in this amount of milliseconds.
  672. Default is 50 milliseconds.
  673. @item asc
  674. When gain reduction is always needed ASC takes care of releasing to an
  675. average reduction level rather than reaching a reduction of 0 in the release
  676. time.
  677. @item asc_level
  678. Select how much the release time is affected by ASC, 0 means nearly no changes
  679. in release time while 1 produces higher release times.
  680. @item level
  681. Auto level output signal. Default is enabled.
  682. This normalizes audio back to 0dB if enabled.
  683. @end table
  684. Depending on picked setting it is recommended to upsample input 2x or 4x times
  685. with @ref{aresample} before applying this filter.
  686. @section allpass
  687. Apply a two-pole all-pass filter with central frequency (in Hz)
  688. @var{frequency}, and filter-width @var{width}.
  689. An all-pass filter changes the audio's frequency to phase relationship
  690. without changing its frequency to amplitude relationship.
  691. The filter accepts the following options:
  692. @table @option
  693. @item frequency, f
  694. Set frequency in Hz.
  695. @item width_type
  696. Set method to specify band-width of filter.
  697. @table @option
  698. @item h
  699. Hz
  700. @item q
  701. Q-Factor
  702. @item o
  703. octave
  704. @item s
  705. slope
  706. @end table
  707. @item width, w
  708. Specify the band-width of a filter in width_type units.
  709. @end table
  710. @anchor{amerge}
  711. @section amerge
  712. Merge two or more audio streams into a single multi-channel stream.
  713. The filter accepts the following options:
  714. @table @option
  715. @item inputs
  716. Set the number of inputs. Default is 2.
  717. @end table
  718. If the channel layouts of the inputs are disjoint, and therefore compatible,
  719. the channel layout of the output will be set accordingly and the channels
  720. will be reordered as necessary. If the channel layouts of the inputs are not
  721. disjoint, the output will have all the channels of the first input then all
  722. the channels of the second input, in that order, and the channel layout of
  723. the output will be the default value corresponding to the total number of
  724. channels.
  725. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  726. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  727. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  728. first input, b1 is the first channel of the second input).
  729. On the other hand, if both input are in stereo, the output channels will be
  730. in the default order: a1, a2, b1, b2, and the channel layout will be
  731. arbitrarily set to 4.0, which may or may not be the expected value.
  732. All inputs must have the same sample rate, and format.
  733. If inputs do not have the same duration, the output will stop with the
  734. shortest.
  735. @subsection Examples
  736. @itemize
  737. @item
  738. Merge two mono files into a stereo stream:
  739. @example
  740. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  741. @end example
  742. @item
  743. Multiple merges assuming 1 video stream and 6 audio streams in @file{input.mkv}:
  744. @example
  745. 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
  746. @end example
  747. @end itemize
  748. @section amix
  749. Mixes multiple audio inputs into a single output.
  750. Note that this filter only supports float samples (the @var{amerge}
  751. and @var{pan} audio filters support many formats). If the @var{amix}
  752. input has integer samples then @ref{aresample} will be automatically
  753. inserted to perform the conversion to float samples.
  754. For example
  755. @example
  756. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  757. @end example
  758. will mix 3 input audio streams to a single output with the same duration as the
  759. first input and a dropout transition time of 3 seconds.
  760. It accepts the following parameters:
  761. @table @option
  762. @item inputs
  763. The number of inputs. If unspecified, it defaults to 2.
  764. @item duration
  765. How to determine the end-of-stream.
  766. @table @option
  767. @item longest
  768. The duration of the longest input. (default)
  769. @item shortest
  770. The duration of the shortest input.
  771. @item first
  772. The duration of the first input.
  773. @end table
  774. @item dropout_transition
  775. The transition time, in seconds, for volume renormalization when an input
  776. stream ends. The default value is 2 seconds.
  777. @end table
  778. @section anull
  779. Pass the audio source unchanged to the output.
  780. @section apad
  781. Pad the end of an audio stream with silence.
  782. This can be used together with @command{ffmpeg} @option{-shortest} to
  783. extend audio streams to the same length as the video stream.
  784. A description of the accepted options follows.
  785. @table @option
  786. @item packet_size
  787. Set silence packet size. Default value is 4096.
  788. @item pad_len
  789. Set the number of samples of silence to add to the end. After the
  790. value is reached, the stream is terminated. This option is mutually
  791. exclusive with @option{whole_len}.
  792. @item whole_len
  793. Set the minimum total number of samples in the output audio stream. If
  794. the value is longer than the input audio length, silence is added to
  795. the end, until the value is reached. This option is mutually exclusive
  796. with @option{pad_len}.
  797. @end table
  798. If neither the @option{pad_len} nor the @option{whole_len} option is
  799. set, the filter will add silence to the end of the input stream
  800. indefinitely.
  801. @subsection Examples
  802. @itemize
  803. @item
  804. Add 1024 samples of silence to the end of the input:
  805. @example
  806. apad=pad_len=1024
  807. @end example
  808. @item
  809. Make sure the audio output will contain at least 10000 samples, pad
  810. the input with silence if required:
  811. @example
  812. apad=whole_len=10000
  813. @end example
  814. @item
  815. Use @command{ffmpeg} to pad the audio input with silence, so that the
  816. video stream will always result the shortest and will be converted
  817. until the end in the output file when using the @option{shortest}
  818. option:
  819. @example
  820. ffmpeg -i VIDEO -i AUDIO -filter_complex "[1:0]apad" -shortest OUTPUT
  821. @end example
  822. @end itemize
  823. @section aphaser
  824. Add a phasing effect to the input audio.
  825. A phaser filter creates series of peaks and troughs in the frequency spectrum.
  826. The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
  827. A description of the accepted parameters follows.
  828. @table @option
  829. @item in_gain
  830. Set input gain. Default is 0.4.
  831. @item out_gain
  832. Set output gain. Default is 0.74
  833. @item delay
  834. Set delay in milliseconds. Default is 3.0.
  835. @item decay
  836. Set decay. Default is 0.4.
  837. @item speed
  838. Set modulation speed in Hz. Default is 0.5.
  839. @item type
  840. Set modulation type. Default is triangular.
  841. It accepts the following values:
  842. @table @samp
  843. @item triangular, t
  844. @item sinusoidal, s
  845. @end table
  846. @end table
  847. @section apulsator
  848. Audio pulsator is something between an autopanner and a tremolo.
  849. But it can produce funny stereo effects as well. Pulsator changes the volume
  850. of the left and right channel based on a LFO (low frequency oscillator) with
  851. different waveforms and shifted phases.
  852. This filter have the ability to define an offset between left and right
  853. channel. An offset of 0 means that both LFO shapes match each other.
  854. The left and right channel are altered equally - a conventional tremolo.
  855. An offset of 50% means that the shape of the right channel is exactly shifted
  856. in phase (or moved backwards about half of the frequency) - pulsator acts as
  857. an autopanner. At 1 both curves match again. Every setting in between moves the
  858. phase shift gapless between all stages and produces some "bypassing" sounds with
  859. sine and triangle waveforms. The more you set the offset near 1 (starting from
  860. the 0.5) the faster the signal passes from the left to the right speaker.
  861. The filter accepts the following options:
  862. @table @option
  863. @item level_in
  864. Set input gain. By default it is 1. Range is [0.015625 - 64].
  865. @item level_out
  866. Set output gain. By default it is 1. Range is [0.015625 - 64].
  867. @item mode
  868. Set waveform shape the LFO will use. Can be one of: sine, triangle, square,
  869. sawup or sawdown. Default is sine.
  870. @item amount
  871. Set modulation. Define how much of original signal is affected by the LFO.
  872. @item offset_l
  873. Set left channel offset. Default is 0. Allowed range is [0 - 1].
  874. @item offset_r
  875. Set right channel offset. Default is 0.5. Allowed range is [0 - 1].
  876. @item width
  877. Set pulse width. Default is 1. Allowed range is [0 - 2].
  878. @item timing
  879. Set possible timing mode. Can be one of: bpm, ms or hz. Default is hz.
  880. @item bpm
  881. Set bpm. Default is 120. Allowed range is [30 - 300]. Only used if timing
  882. is set to bpm.
  883. @item ms
  884. Set ms. Default is 500. Allowed range is [10 - 2000]. Only used if timing
  885. is set to ms.
  886. @item hz
  887. Set frequency in Hz. Default is 2. Allowed range is [0.01 - 100]. Only used
  888. if timing is set to hz.
  889. @end table
  890. @anchor{aresample}
  891. @section aresample
  892. Resample the input audio to the specified parameters, using the
  893. libswresample library. If none are specified then the filter will
  894. automatically convert between its input and output.
  895. This filter is also able to stretch/squeeze the audio data to make it match
  896. the timestamps or to inject silence / cut out audio to make it match the
  897. timestamps, do a combination of both or do neither.
  898. The filter accepts the syntax
  899. [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
  900. expresses a sample rate and @var{resampler_options} is a list of
  901. @var{key}=@var{value} pairs, separated by ":". See the
  902. ffmpeg-resampler manual for the complete list of supported options.
  903. @subsection Examples
  904. @itemize
  905. @item
  906. Resample the input audio to 44100Hz:
  907. @example
  908. aresample=44100
  909. @end example
  910. @item
  911. Stretch/squeeze samples to the given timestamps, with a maximum of 1000
  912. samples per second compensation:
  913. @example
  914. aresample=async=1000
  915. @end example
  916. @end itemize
  917. @section asetnsamples
  918. Set the number of samples per each output audio frame.
  919. The last output packet may contain a different number of samples, as
  920. the filter will flush all the remaining samples when the input audio
  921. signal its end.
  922. The filter accepts the following options:
  923. @table @option
  924. @item nb_out_samples, n
  925. Set the number of frames per each output audio frame. The number is
  926. intended as the number of samples @emph{per each channel}.
  927. Default value is 1024.
  928. @item pad, p
  929. If set to 1, the filter will pad the last audio frame with zeroes, so
  930. that the last frame will contain the same number of samples as the
  931. previous ones. Default value is 1.
  932. @end table
  933. For example, to set the number of per-frame samples to 1234 and
  934. disable padding for the last frame, use:
  935. @example
  936. asetnsamples=n=1234:p=0
  937. @end example
  938. @section asetrate
  939. Set the sample rate without altering the PCM data.
  940. This will result in a change of speed and pitch.
  941. The filter accepts the following options:
  942. @table @option
  943. @item sample_rate, r
  944. Set the output sample rate. Default is 44100 Hz.
  945. @end table
  946. @section ashowinfo
  947. Show a line containing various information for each input audio frame.
  948. The input audio is not modified.
  949. The shown line contains a sequence of key/value pairs of the form
  950. @var{key}:@var{value}.
  951. The following values are shown in the output:
  952. @table @option
  953. @item n
  954. The (sequential) number of the input frame, starting from 0.
  955. @item pts
  956. The presentation timestamp of the input frame, in time base units; the time base
  957. depends on the filter input pad, and is usually 1/@var{sample_rate}.
  958. @item pts_time
  959. The presentation timestamp of the input frame in seconds.
  960. @item pos
  961. position of the frame in the input stream, -1 if this information in
  962. unavailable and/or meaningless (for example in case of synthetic audio)
  963. @item fmt
  964. The sample format.
  965. @item chlayout
  966. The channel layout.
  967. @item rate
  968. The sample rate for the audio frame.
  969. @item nb_samples
  970. The number of samples (per channel) in the frame.
  971. @item checksum
  972. The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
  973. audio, the data is treated as if all the planes were concatenated.
  974. @item plane_checksums
  975. A list of Adler-32 checksums for each data plane.
  976. @end table
  977. @anchor{astats}
  978. @section astats
  979. Display time domain statistical information about the audio channels.
  980. Statistics are calculated and displayed for each audio channel and,
  981. where applicable, an overall figure is also given.
  982. It accepts the following option:
  983. @table @option
  984. @item length
  985. Short window length in seconds, used for peak and trough RMS measurement.
  986. Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.1 - 10]}.
  987. @item metadata
  988. Set metadata injection. All the metadata keys are prefixed with @code{lavfi.astats.X},
  989. where @code{X} is channel number starting from 1 or string @code{Overall}. Default is
  990. disabled.
  991. Available keys for each channel are:
  992. DC_offset
  993. Min_level
  994. Max_level
  995. Min_difference
  996. Max_difference
  997. Mean_difference
  998. Peak_level
  999. RMS_peak
  1000. RMS_trough
  1001. Crest_factor
  1002. Flat_factor
  1003. Peak_count
  1004. Bit_depth
  1005. and for Overall:
  1006. DC_offset
  1007. Min_level
  1008. Max_level
  1009. Min_difference
  1010. Max_difference
  1011. Mean_difference
  1012. Peak_level
  1013. RMS_level
  1014. RMS_peak
  1015. RMS_trough
  1016. Flat_factor
  1017. Peak_count
  1018. Bit_depth
  1019. Number_of_samples
  1020. For example full key look like this @code{lavfi.astats.1.DC_offset} or
  1021. this @code{lavfi.astats.Overall.Peak_count}.
  1022. For description what each key means read below.
  1023. @item reset
  1024. Set number of frame after which stats are going to be recalculated.
  1025. Default is disabled.
  1026. @end table
  1027. A description of each shown parameter follows:
  1028. @table @option
  1029. @item DC offset
  1030. Mean amplitude displacement from zero.
  1031. @item Min level
  1032. Minimal sample level.
  1033. @item Max level
  1034. Maximal sample level.
  1035. @item Min difference
  1036. Minimal difference between two consecutive samples.
  1037. @item Max difference
  1038. Maximal difference between two consecutive samples.
  1039. @item Mean difference
  1040. Mean difference between two consecutive samples.
  1041. The average of each difference between two consecutive samples.
  1042. @item Peak level dB
  1043. @item RMS level dB
  1044. Standard peak and RMS level measured in dBFS.
  1045. @item RMS peak dB
  1046. @item RMS trough dB
  1047. Peak and trough values for RMS level measured over a short window.
  1048. @item Crest factor
  1049. Standard ratio of peak to RMS level (note: not in dB).
  1050. @item Flat factor
  1051. Flatness (i.e. consecutive samples with the same value) of the signal at its peak levels
  1052. (i.e. either @var{Min level} or @var{Max level}).
  1053. @item Peak count
  1054. Number of occasions (not the number of samples) that the signal attained either
  1055. @var{Min level} or @var{Max level}.
  1056. @item Bit depth
  1057. Overall bit depth of audio. Number of bits used for each sample.
  1058. @end table
  1059. @section asyncts
  1060. Synchronize audio data with timestamps by squeezing/stretching it and/or
  1061. dropping samples/adding silence when needed.
  1062. This filter is not built by default, please use @ref{aresample} to do squeezing/stretching.
  1063. It accepts the following parameters:
  1064. @table @option
  1065. @item compensate
  1066. Enable stretching/squeezing the data to make it match the timestamps. Disabled
  1067. by default. When disabled, time gaps are covered with silence.
  1068. @item min_delta
  1069. The minimum difference between timestamps and audio data (in seconds) to trigger
  1070. adding/dropping samples. The default value is 0.1. If you get an imperfect
  1071. sync with this filter, try setting this parameter to 0.
  1072. @item max_comp
  1073. The maximum compensation in samples per second. Only relevant with compensate=1.
  1074. The default value is 500.
  1075. @item first_pts
  1076. Assume that the first PTS should be this value. The time base is 1 / sample
  1077. rate. This allows for padding/trimming at the start of the stream. By default,
  1078. no assumption is made about the first frame's expected PTS, so no padding or
  1079. trimming is done. For example, this could be set to 0 to pad the beginning with
  1080. silence if an audio stream starts after the video stream or to trim any samples
  1081. with a negative PTS due to encoder delay.
  1082. @end table
  1083. @section atempo
  1084. Adjust audio tempo.
  1085. The filter accepts exactly one parameter, the audio tempo. If not
  1086. specified then the filter will assume nominal 1.0 tempo. Tempo must
  1087. be in the [0.5, 2.0] range.
  1088. @subsection Examples
  1089. @itemize
  1090. @item
  1091. Slow down audio to 80% tempo:
  1092. @example
  1093. atempo=0.8
  1094. @end example
  1095. @item
  1096. To speed up audio to 125% tempo:
  1097. @example
  1098. atempo=1.25
  1099. @end example
  1100. @end itemize
  1101. @section atrim
  1102. Trim the input so that the output contains one continuous subpart of the input.
  1103. It accepts the following parameters:
  1104. @table @option
  1105. @item start
  1106. Timestamp (in seconds) of the start of the section to keep. I.e. the audio
  1107. sample with the timestamp @var{start} will be the first sample in the output.
  1108. @item end
  1109. Specify time of the first audio sample that will be dropped, i.e. the
  1110. audio sample immediately preceding the one with the timestamp @var{end} will be
  1111. the last sample in the output.
  1112. @item start_pts
  1113. Same as @var{start}, except this option sets the start timestamp in samples
  1114. instead of seconds.
  1115. @item end_pts
  1116. Same as @var{end}, except this option sets the end timestamp in samples instead
  1117. of seconds.
  1118. @item duration
  1119. The maximum duration of the output in seconds.
  1120. @item start_sample
  1121. The number of the first sample that should be output.
  1122. @item end_sample
  1123. The number of the first sample that should be dropped.
  1124. @end table
  1125. @option{start}, @option{end}, and @option{duration} are expressed as time
  1126. duration specifications; see
  1127. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  1128. Note that the first two sets of the start/end options and the @option{duration}
  1129. option look at the frame timestamp, while the _sample options simply count the
  1130. samples that pass through the filter. So start/end_pts and start/end_sample will
  1131. give different results when the timestamps are wrong, inexact or do not start at
  1132. zero. Also note that this filter does not modify the timestamps. If you wish
  1133. to have the output timestamps start at zero, insert the asetpts filter after the
  1134. atrim filter.
  1135. If multiple start or end options are set, this filter tries to be greedy and
  1136. keep all samples that match at least one of the specified constraints. To keep
  1137. only the part that matches all the constraints at once, chain multiple atrim
  1138. filters.
  1139. The defaults are such that all the input is kept. So it is possible to set e.g.
  1140. just the end values to keep everything before the specified time.
  1141. Examples:
  1142. @itemize
  1143. @item
  1144. Drop everything except the second minute of input:
  1145. @example
  1146. ffmpeg -i INPUT -af atrim=60:120
  1147. @end example
  1148. @item
  1149. Keep only the first 1000 samples:
  1150. @example
  1151. ffmpeg -i INPUT -af atrim=end_sample=1000
  1152. @end example
  1153. @end itemize
  1154. @section bandpass
  1155. Apply a two-pole Butterworth band-pass filter with central
  1156. frequency @var{frequency}, and (3dB-point) band-width width.
  1157. The @var{csg} option selects a constant skirt gain (peak gain = Q)
  1158. instead of the default: constant 0dB peak gain.
  1159. The filter roll off at 6dB per octave (20dB per decade).
  1160. The filter accepts the following options:
  1161. @table @option
  1162. @item frequency, f
  1163. Set the filter's central frequency. Default is @code{3000}.
  1164. @item csg
  1165. Constant skirt gain if set to 1. Defaults to 0.
  1166. @item width_type
  1167. Set method to specify band-width of filter.
  1168. @table @option
  1169. @item h
  1170. Hz
  1171. @item q
  1172. Q-Factor
  1173. @item o
  1174. octave
  1175. @item s
  1176. slope
  1177. @end table
  1178. @item width, w
  1179. Specify the band-width of a filter in width_type units.
  1180. @end table
  1181. @section bandreject
  1182. Apply a two-pole Butterworth band-reject filter with central
  1183. frequency @var{frequency}, and (3dB-point) band-width @var{width}.
  1184. The filter roll off at 6dB per octave (20dB per decade).
  1185. The filter accepts the following options:
  1186. @table @option
  1187. @item frequency, f
  1188. Set the filter's central frequency. Default is @code{3000}.
  1189. @item width_type
  1190. Set method to specify band-width of filter.
  1191. @table @option
  1192. @item h
  1193. Hz
  1194. @item q
  1195. Q-Factor
  1196. @item o
  1197. octave
  1198. @item s
  1199. slope
  1200. @end table
  1201. @item width, w
  1202. Specify the band-width of a filter in width_type units.
  1203. @end table
  1204. @section bass
  1205. Boost or cut the bass (lower) frequencies of the audio using a two-pole
  1206. shelving filter with a response similar to that of a standard
  1207. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  1208. The filter accepts the following options:
  1209. @table @option
  1210. @item gain, g
  1211. Give the gain at 0 Hz. Its useful range is about -20
  1212. (for a large cut) to +20 (for a large boost).
  1213. Beware of clipping when using a positive gain.
  1214. @item frequency, f
  1215. Set the filter's central frequency and so can be used
  1216. to extend or reduce the frequency range to be boosted or cut.
  1217. The default value is @code{100} Hz.
  1218. @item width_type
  1219. Set method to specify band-width of filter.
  1220. @table @option
  1221. @item h
  1222. Hz
  1223. @item q
  1224. Q-Factor
  1225. @item o
  1226. octave
  1227. @item s
  1228. slope
  1229. @end table
  1230. @item width, w
  1231. Determine how steep is the filter's shelf transition.
  1232. @end table
  1233. @section biquad
  1234. Apply a biquad IIR filter with the given coefficients.
  1235. Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
  1236. are the numerator and denominator coefficients respectively.
  1237. @section bs2b
  1238. Bauer stereo to binaural transformation, which improves headphone listening of
  1239. stereo audio records.
  1240. It accepts the following parameters:
  1241. @table @option
  1242. @item profile
  1243. Pre-defined crossfeed level.
  1244. @table @option
  1245. @item default
  1246. Default level (fcut=700, feed=50).
  1247. @item cmoy
  1248. Chu Moy circuit (fcut=700, feed=60).
  1249. @item jmeier
  1250. Jan Meier circuit (fcut=650, feed=95).
  1251. @end table
  1252. @item fcut
  1253. Cut frequency (in Hz).
  1254. @item feed
  1255. Feed level (in Hz).
  1256. @end table
  1257. @section channelmap
  1258. Remap input channels to new locations.
  1259. It accepts the following parameters:
  1260. @table @option
  1261. @item channel_layout
  1262. The channel layout of the output stream.
  1263. @item map
  1264. Map channels from input to output. The argument is a '|'-separated list of
  1265. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  1266. @var{in_channel} form. @var{in_channel} can be either the name of the input
  1267. channel (e.g. FL for front left) or its index in the input channel layout.
  1268. @var{out_channel} is the name of the output channel or its index in the output
  1269. channel layout. If @var{out_channel} is not given then it is implicitly an
  1270. index, starting with zero and increasing by one for each mapping.
  1271. @end table
  1272. If no mapping is present, the filter will implicitly map input channels to
  1273. output channels, preserving indices.
  1274. For example, assuming a 5.1+downmix input MOV file,
  1275. @example
  1276. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
  1277. @end example
  1278. will create an output WAV file tagged as stereo from the downmix channels of
  1279. the input.
  1280. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  1281. @example
  1282. ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:5.1' out.wav
  1283. @end example
  1284. @section channelsplit
  1285. Split each channel from an input audio stream into a separate output stream.
  1286. It accepts the following parameters:
  1287. @table @option
  1288. @item channel_layout
  1289. The channel layout of the input stream. The default is "stereo".
  1290. @end table
  1291. For example, assuming a stereo input MP3 file,
  1292. @example
  1293. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  1294. @end example
  1295. will create an output Matroska file with two audio streams, one containing only
  1296. the left channel and the other the right channel.
  1297. Split a 5.1 WAV file into per-channel files:
  1298. @example
  1299. ffmpeg -i in.wav -filter_complex
  1300. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  1301. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  1302. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  1303. side_right.wav
  1304. @end example
  1305. @section chorus
  1306. Add a chorus effect to the audio.
  1307. Can make a single vocal sound like a chorus, but can also be applied to instrumentation.
  1308. Chorus resembles an echo effect with a short delay, but whereas with echo the delay is
  1309. constant, with chorus, it is varied using using sinusoidal or triangular modulation.
  1310. The modulation depth defines the range the modulated delay is played before or after
  1311. the delay. Hence the delayed sound will sound slower or faster, that is the delayed
  1312. sound tuned around the original one, like in a chorus where some vocals are slightly
  1313. off key.
  1314. It accepts the following parameters:
  1315. @table @option
  1316. @item in_gain
  1317. Set input gain. Default is 0.4.
  1318. @item out_gain
  1319. Set output gain. Default is 0.4.
  1320. @item delays
  1321. Set delays. A typical delay is around 40ms to 60ms.
  1322. @item decays
  1323. Set decays.
  1324. @item speeds
  1325. Set speeds.
  1326. @item depths
  1327. Set depths.
  1328. @end table
  1329. @subsection Examples
  1330. @itemize
  1331. @item
  1332. A single delay:
  1333. @example
  1334. chorus=0.7:0.9:55:0.4:0.25:2
  1335. @end example
  1336. @item
  1337. Two delays:
  1338. @example
  1339. chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3
  1340. @end example
  1341. @item
  1342. Fuller sounding chorus with three delays:
  1343. @example
  1344. 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
  1345. @end example
  1346. @end itemize
  1347. @section compand
  1348. Compress or expand the audio's dynamic range.
  1349. It accepts the following parameters:
  1350. @table @option
  1351. @item attacks
  1352. @item decays
  1353. A list of times in seconds for each channel over which the instantaneous level
  1354. of the input signal is averaged to determine its volume. @var{attacks} refers to
  1355. increase of volume and @var{decays} refers to decrease of volume. For most
  1356. situations, the attack time (response to the audio getting louder) should be
  1357. shorter than the decay time, because the human ear is more sensitive to sudden
  1358. loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
  1359. a typical value for decay is 0.8 seconds.
  1360. If specified number of attacks & decays is lower than number of channels, the last
  1361. set attack/decay will be used for all remaining channels.
  1362. @item points
  1363. A list of points for the transfer function, specified in dB relative to the
  1364. maximum possible signal amplitude. Each key points list must be defined using
  1365. the following syntax: @code{x0/y0|x1/y1|x2/y2|....} or
  1366. @code{x0/y0 x1/y1 x2/y2 ....}
  1367. The input values must be in strictly increasing order but the transfer function
  1368. does not have to be monotonically rising. The point @code{0/0} is assumed but
  1369. may be overridden (by @code{0/out-dBn}). Typical values for the transfer
  1370. function are @code{-70/-70|-60/-20}.
  1371. @item soft-knee
  1372. Set the curve radius in dB for all joints. It defaults to 0.01.
  1373. @item gain
  1374. Set the additional gain in dB to be applied at all points on the transfer
  1375. function. This allows for easy adjustment of the overall gain.
  1376. It defaults to 0.
  1377. @item volume
  1378. Set an initial volume, in dB, to be assumed for each channel when filtering
  1379. starts. This permits the user to supply a nominal level initially, so that, for
  1380. example, a very large gain is not applied to initial signal levels before the
  1381. companding has begun to operate. A typical value for audio which is initially
  1382. quiet is -90 dB. It defaults to 0.
  1383. @item delay
  1384. Set a delay, in seconds. The input audio is analyzed immediately, but audio is
  1385. delayed before being fed to the volume adjuster. Specifying a delay
  1386. approximately equal to the attack/decay times allows the filter to effectively
  1387. operate in predictive rather than reactive mode. It defaults to 0.
  1388. @end table
  1389. @subsection Examples
  1390. @itemize
  1391. @item
  1392. Make music with both quiet and loud passages suitable for listening to in a
  1393. noisy environment:
  1394. @example
  1395. compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
  1396. @end example
  1397. Another example for audio with whisper and explosion parts:
  1398. @example
  1399. compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0
  1400. @end example
  1401. @item
  1402. A noise gate for when the noise is at a lower level than the signal:
  1403. @example
  1404. compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
  1405. @end example
  1406. @item
  1407. Here is another noise gate, this time for when the noise is at a higher level
  1408. than the signal (making it, in some ways, similar to squelch):
  1409. @example
  1410. compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
  1411. @end example
  1412. @item
  1413. 2:1 compression starting at -6dB:
  1414. @example
  1415. compand=points=-80/-80|-6/-6|0/-3.8|20/3.5
  1416. @end example
  1417. @item
  1418. 2:1 compression starting at -9dB:
  1419. @example
  1420. compand=points=-80/-80|-9/-9|0/-5.3|20/2.9
  1421. @end example
  1422. @item
  1423. 2:1 compression starting at -12dB:
  1424. @example
  1425. compand=points=-80/-80|-12/-12|0/-6.8|20/1.9
  1426. @end example
  1427. @item
  1428. 2:1 compression starting at -18dB:
  1429. @example
  1430. compand=points=-80/-80|-18/-18|0/-9.8|20/0.7
  1431. @end example
  1432. @item
  1433. 3:1 compression starting at -15dB:
  1434. @example
  1435. compand=points=-80/-80|-15/-15|0/-10.8|20/-5.2
  1436. @end example
  1437. @item
  1438. Compressor/Gate:
  1439. @example
  1440. compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6
  1441. @end example
  1442. @item
  1443. Expander:
  1444. @example
  1445. 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
  1446. @end example
  1447. @item
  1448. Hard limiter at -6dB:
  1449. @example
  1450. compand=attacks=0:points=-80/-80|-6/-6|20/-6
  1451. @end example
  1452. @item
  1453. Hard limiter at -12dB:
  1454. @example
  1455. compand=attacks=0:points=-80/-80|-12/-12|20/-12
  1456. @end example
  1457. @item
  1458. Hard noise gate at -35 dB:
  1459. @example
  1460. compand=attacks=0:points=-80/-115|-35.1/-80|-35/-35|20/20
  1461. @end example
  1462. @item
  1463. Soft limiter:
  1464. @example
  1465. compand=attacks=0:points=-80/-80|-12.4/-12.4|-6/-8|0/-6.8|20/-2.8
  1466. @end example
  1467. @end itemize
  1468. @section compensationdelay
  1469. Compensation Delay Line is a metric based delay to compensate differing
  1470. positions of microphones or speakers.
  1471. For example, you have recorded guitar with two microphones placed in
  1472. different location. Because the front of sound wave has fixed speed in
  1473. normal conditions, the phasing of microphones can vary and depends on
  1474. their location and interposition. The best sound mix can be achieved when
  1475. these microphones are in phase (synchronized). Note that distance of
  1476. ~30 cm between microphones makes one microphone to capture signal in
  1477. antiphase to another microphone. That makes the final mix sounding moody.
  1478. This filter helps to solve phasing problems by adding different delays
  1479. to each microphone track and make them synchronized.
  1480. The best result can be reached when you take one track as base and
  1481. synchronize other tracks one by one with it.
  1482. Remember that synchronization/delay tolerance depends on sample rate, too.
  1483. Higher sample rates will give more tolerance.
  1484. It accepts the following parameters:
  1485. @table @option
  1486. @item mm
  1487. Set millimeters distance. This is compensation distance for fine tuning.
  1488. Default is 0.
  1489. @item cm
  1490. Set cm distance. This is compensation distance for tightening distance setup.
  1491. Default is 0.
  1492. @item m
  1493. Set meters distance. This is compensation distance for hard distance setup.
  1494. Default is 0.
  1495. @item dry
  1496. Set dry amount. Amount of unprocessed (dry) signal.
  1497. Default is 0.
  1498. @item wet
  1499. Set wet amount. Amount of processed (wet) signal.
  1500. Default is 1.
  1501. @item temp
  1502. Set temperature degree in Celsius. This is the temperature of the environment.
  1503. Default is 20.
  1504. @end table
  1505. @section dcshift
  1506. Apply a DC shift to the audio.
  1507. This can be useful to remove a DC offset (caused perhaps by a hardware problem
  1508. in the recording chain) from the audio. The effect of a DC offset is reduced
  1509. headroom and hence volume. The @ref{astats} filter can be used to determine if
  1510. a signal has a DC offset.
  1511. @table @option
  1512. @item shift
  1513. Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift
  1514. the audio.
  1515. @item limitergain
  1516. Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
  1517. used to prevent clipping.
  1518. @end table
  1519. @section dynaudnorm
  1520. Dynamic Audio Normalizer.
  1521. This filter applies a certain amount of gain to the input audio in order
  1522. to bring its peak magnitude to a target level (e.g. 0 dBFS). However, in
  1523. contrast to more "simple" normalization algorithms, the Dynamic Audio
  1524. Normalizer *dynamically* re-adjusts the gain factor to the input audio.
  1525. This allows for applying extra gain to the "quiet" sections of the audio
  1526. while avoiding distortions or clipping the "loud" sections. In other words:
  1527. The Dynamic Audio Normalizer will "even out" the volume of quiet and loud
  1528. sections, in the sense that the volume of each section is brought to the
  1529. same target level. Note, however, that the Dynamic Audio Normalizer achieves
  1530. this goal *without* applying "dynamic range compressing". It will retain 100%
  1531. of the dynamic range *within* each section of the audio file.
  1532. @table @option
  1533. @item f
  1534. Set the frame length in milliseconds. In range from 10 to 8000 milliseconds.
  1535. Default is 500 milliseconds.
  1536. The Dynamic Audio Normalizer processes the input audio in small chunks,
  1537. referred to as frames. This is required, because a peak magnitude has no
  1538. meaning for just a single sample value. Instead, we need to determine the
  1539. peak magnitude for a contiguous sequence of sample values. While a "standard"
  1540. normalizer would simply use the peak magnitude of the complete file, the
  1541. Dynamic Audio Normalizer determines the peak magnitude individually for each
  1542. frame. The length of a frame is specified in milliseconds. By default, the
  1543. Dynamic Audio Normalizer uses a frame length of 500 milliseconds, which has
  1544. been found to give good results with most files.
  1545. Note that the exact frame length, in number of samples, will be determined
  1546. automatically, based on the sampling rate of the individual input audio file.
  1547. @item g
  1548. Set the Gaussian filter window size. In range from 3 to 301, must be odd
  1549. number. Default is 31.
  1550. Probably the most important parameter of the Dynamic Audio Normalizer is the
  1551. @code{window size} of the Gaussian smoothing filter. The filter's window size
  1552. is specified in frames, centered around the current frame. For the sake of
  1553. simplicity, this must be an odd number. Consequently, the default value of 31
  1554. takes into account the current frame, as well as the 15 preceding frames and
  1555. the 15 subsequent frames. Using a larger window results in a stronger
  1556. smoothing effect and thus in less gain variation, i.e. slower gain
  1557. adaptation. Conversely, using a smaller window results in a weaker smoothing
  1558. effect and thus in more gain variation, i.e. faster gain adaptation.
  1559. In other words, the more you increase this value, the more the Dynamic Audio
  1560. Normalizer will behave like a "traditional" normalization filter. On the
  1561. contrary, the more you decrease this value, the more the Dynamic Audio
  1562. Normalizer will behave like a dynamic range compressor.
  1563. @item p
  1564. Set the target peak value. This specifies the highest permissible magnitude
  1565. level for the normalized audio input. This filter will try to approach the
  1566. target peak magnitude as closely as possible, but at the same time it also
  1567. makes sure that the normalized signal will never exceed the peak magnitude.
  1568. A frame's maximum local gain factor is imposed directly by the target peak
  1569. magnitude. The default value is 0.95 and thus leaves a headroom of 5%*.
  1570. It is not recommended to go above this value.
  1571. @item m
  1572. Set the maximum gain factor. In range from 1.0 to 100.0. Default is 10.0.
  1573. The Dynamic Audio Normalizer determines the maximum possible (local) gain
  1574. factor for each input frame, i.e. the maximum gain factor that does not
  1575. result in clipping or distortion. The maximum gain factor is determined by
  1576. the frame's highest magnitude sample. However, the Dynamic Audio Normalizer
  1577. additionally bounds the frame's maximum gain factor by a predetermined
  1578. (global) maximum gain factor. This is done in order to avoid excessive gain
  1579. factors in "silent" or almost silent frames. By default, the maximum gain
  1580. factor is 10.0, For most inputs the default value should be sufficient and
  1581. it usually is not recommended to increase this value. Though, for input
  1582. with an extremely low overall volume level, it may be necessary to allow even
  1583. higher gain factors. Note, however, that the Dynamic Audio Normalizer does
  1584. not simply apply a "hard" threshold (i.e. cut off values above the threshold).
  1585. Instead, a "sigmoid" threshold function will be applied. This way, the
  1586. gain factors will smoothly approach the threshold value, but never exceed that
  1587. value.
  1588. @item r
  1589. Set the target RMS. In range from 0.0 to 1.0. Default is 0.0 - disabled.
  1590. By default, the Dynamic Audio Normalizer performs "peak" normalization.
  1591. This means that the maximum local gain factor for each frame is defined
  1592. (only) by the frame's highest magnitude sample. This way, the samples can
  1593. be amplified as much as possible without exceeding the maximum signal
  1594. level, i.e. without clipping. Optionally, however, the Dynamic Audio
  1595. Normalizer can also take into account the frame's root mean square,
  1596. abbreviated RMS. In electrical engineering, the RMS is commonly used to
  1597. determine the power of a time-varying signal. It is therefore considered
  1598. that the RMS is a better approximation of the "perceived loudness" than
  1599. just looking at the signal's peak magnitude. Consequently, by adjusting all
  1600. frames to a constant RMS value, a uniform "perceived loudness" can be
  1601. established. If a target RMS value has been specified, a frame's local gain
  1602. factor is defined as the factor that would result in exactly that RMS value.
  1603. Note, however, that the maximum local gain factor is still restricted by the
  1604. frame's highest magnitude sample, in order to prevent clipping.
  1605. @item n
  1606. Enable channels coupling. By default is enabled.
  1607. By default, the Dynamic Audio Normalizer will amplify all channels by the same
  1608. amount. This means the same gain factor will be applied to all channels, i.e.
  1609. the maximum possible gain factor is determined by the "loudest" channel.
  1610. However, in some recordings, it may happen that the volume of the different
  1611. channels is uneven, e.g. one channel may be "quieter" than the other one(s).
  1612. In this case, this option can be used to disable the channel coupling. This way,
  1613. the gain factor will be determined independently for each channel, depending
  1614. only on the individual channel's highest magnitude sample. This allows for
  1615. harmonizing the volume of the different channels.
  1616. @item c
  1617. Enable DC bias correction. By default is disabled.
  1618. An audio signal (in the time domain) is a sequence of sample values.
  1619. In the Dynamic Audio Normalizer these sample values are represented in the
  1620. -1.0 to 1.0 range, regardless of the original input format. Normally, the
  1621. audio signal, or "waveform", should be centered around the zero point.
  1622. That means if we calculate the mean value of all samples in a file, or in a
  1623. single frame, then the result should be 0.0 or at least very close to that
  1624. value. If, however, there is a significant deviation of the mean value from
  1625. 0.0, in either positive or negative direction, this is referred to as a
  1626. DC bias or DC offset. Since a DC bias is clearly undesirable, the Dynamic
  1627. Audio Normalizer provides optional DC bias correction.
  1628. With DC bias correction enabled, the Dynamic Audio Normalizer will determine
  1629. the mean value, or "DC correction" offset, of each input frame and subtract
  1630. that value from all of the frame's sample values which ensures those samples
  1631. are centered around 0.0 again. Also, in order to avoid "gaps" at the frame
  1632. boundaries, the DC correction offset values will be interpolated smoothly
  1633. between neighbouring frames.
  1634. @item b
  1635. Enable alternative boundary mode. By default is disabled.
  1636. The Dynamic Audio Normalizer takes into account a certain neighbourhood
  1637. around each frame. This includes the preceding frames as well as the
  1638. subsequent frames. However, for the "boundary" frames, located at the very
  1639. beginning and at the very end of the audio file, not all neighbouring
  1640. frames are available. In particular, for the first few frames in the audio
  1641. file, the preceding frames are not known. And, similarly, for the last few
  1642. frames in the audio file, the subsequent frames are not known. Thus, the
  1643. question arises which gain factors should be assumed for the missing frames
  1644. in the "boundary" region. The Dynamic Audio Normalizer implements two modes
  1645. to deal with this situation. The default boundary mode assumes a gain factor
  1646. of exactly 1.0 for the missing frames, resulting in a smooth "fade in" and
  1647. "fade out" at the beginning and at the end of the input, respectively.
  1648. @item s
  1649. Set the compress factor. In range from 0.0 to 30.0. Default is 0.0.
  1650. By default, the Dynamic Audio Normalizer does not apply "traditional"
  1651. compression. This means that signal peaks will not be pruned and thus the
  1652. full dynamic range will be retained within each local neighbourhood. However,
  1653. in some cases it may be desirable to combine the Dynamic Audio Normalizer's
  1654. normalization algorithm with a more "traditional" compression.
  1655. For this purpose, the Dynamic Audio Normalizer provides an optional compression
  1656. (thresholding) function. If (and only if) the compression feature is enabled,
  1657. all input frames will be processed by a soft knee thresholding function prior
  1658. to the actual normalization process. Put simply, the thresholding function is
  1659. going to prune all samples whose magnitude exceeds a certain threshold value.
  1660. However, the Dynamic Audio Normalizer does not simply apply a fixed threshold
  1661. value. Instead, the threshold value will be adjusted for each individual
  1662. frame.
  1663. In general, smaller parameters result in stronger compression, and vice versa.
  1664. Values below 3.0 are not recommended, because audible distortion may appear.
  1665. @end table
  1666. @section earwax
  1667. Make audio easier to listen to on headphones.
  1668. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  1669. so that when listened to on headphones the stereo image is moved from
  1670. inside your head (standard for headphones) to outside and in front of
  1671. the listener (standard for speakers).
  1672. Ported from SoX.
  1673. @section equalizer
  1674. Apply a two-pole peaking equalisation (EQ) filter. With this
  1675. filter, the signal-level at and around a selected frequency can
  1676. be increased or decreased, whilst (unlike bandpass and bandreject
  1677. filters) that at all other frequencies is unchanged.
  1678. In order to produce complex equalisation curves, this filter can
  1679. be given several times, each with a different central frequency.
  1680. The filter accepts the following options:
  1681. @table @option
  1682. @item frequency, f
  1683. Set the filter's central frequency in Hz.
  1684. @item width_type
  1685. Set method to specify band-width of filter.
  1686. @table @option
  1687. @item h
  1688. Hz
  1689. @item q
  1690. Q-Factor
  1691. @item o
  1692. octave
  1693. @item s
  1694. slope
  1695. @end table
  1696. @item width, w
  1697. Specify the band-width of a filter in width_type units.
  1698. @item gain, g
  1699. Set the required gain or attenuation in dB.
  1700. Beware of clipping when using a positive gain.
  1701. @end table
  1702. @subsection Examples
  1703. @itemize
  1704. @item
  1705. Attenuate 10 dB at 1000 Hz, with a bandwidth of 200 Hz:
  1706. @example
  1707. equalizer=f=1000:width_type=h:width=200:g=-10
  1708. @end example
  1709. @item
  1710. Apply 2 dB gain at 1000 Hz with Q 1 and attenuate 5 dB at 100 Hz with Q 2:
  1711. @example
  1712. equalizer=f=1000:width_type=q:width=1:g=2,equalizer=f=100:width_type=q:width=2:g=-5
  1713. @end example
  1714. @end itemize
  1715. @section extrastereo
  1716. Linearly increases the difference between left and right channels which
  1717. adds some sort of "live" effect to playback.
  1718. The filter accepts the following option:
  1719. @table @option
  1720. @item m
  1721. Sets the difference coefficient (default: 2.5). 0.0 means mono sound
  1722. (average of both channels), with 1.0 sound will be unchanged, with
  1723. -1.0 left and right channels will be swapped.
  1724. @item c
  1725. Enable clipping. By default is enabled.
  1726. @end table
  1727. @section flanger
  1728. Apply a flanging effect to the audio.
  1729. The filter accepts the following options:
  1730. @table @option
  1731. @item delay
  1732. Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
  1733. @item depth
  1734. Set added swep delay in milliseconds. Range from 0 to 10. Default value is 2.
  1735. @item regen
  1736. Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
  1737. Default value is 0.
  1738. @item width
  1739. Set percentage of delayed signal mixed with original. Range from 0 to 100.
  1740. Default value is 71.
  1741. @item speed
  1742. Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
  1743. @item shape
  1744. Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
  1745. Default value is @var{sinusoidal}.
  1746. @item phase
  1747. Set swept wave percentage-shift for multi channel. Range from 0 to 100.
  1748. Default value is 25.
  1749. @item interp
  1750. Set delay-line interpolation, @var{linear} or @var{quadratic}.
  1751. Default is @var{linear}.
  1752. @end table
  1753. @section highpass
  1754. Apply a high-pass filter with 3dB point frequency.
  1755. The filter can be either single-pole, or double-pole (the default).
  1756. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1757. The filter accepts the following options:
  1758. @table @option
  1759. @item frequency, f
  1760. Set frequency in Hz. Default is 3000.
  1761. @item poles, p
  1762. Set number of poles. Default is 2.
  1763. @item width_type
  1764. Set method to specify band-width of filter.
  1765. @table @option
  1766. @item h
  1767. Hz
  1768. @item q
  1769. Q-Factor
  1770. @item o
  1771. octave
  1772. @item s
  1773. slope
  1774. @end table
  1775. @item width, w
  1776. Specify the band-width of a filter in width_type units.
  1777. Applies only to double-pole filter.
  1778. The default is 0.707q and gives a Butterworth response.
  1779. @end table
  1780. @section join
  1781. Join multiple input streams into one multi-channel stream.
  1782. It accepts the following parameters:
  1783. @table @option
  1784. @item inputs
  1785. The number of input streams. It defaults to 2.
  1786. @item channel_layout
  1787. The desired output channel layout. It defaults to stereo.
  1788. @item map
  1789. Map channels from inputs to output. The argument is a '|'-separated list of
  1790. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  1791. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  1792. can be either the name of the input channel (e.g. FL for front left) or its
  1793. index in the specified input stream. @var{out_channel} is the name of the output
  1794. channel.
  1795. @end table
  1796. The filter will attempt to guess the mappings when they are not specified
  1797. explicitly. It does so by first trying to find an unused matching input channel
  1798. and if that fails it picks the first unused input channel.
  1799. Join 3 inputs (with properly set channel layouts):
  1800. @example
  1801. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  1802. @end example
  1803. Build a 5.1 output from 6 single-channel streams:
  1804. @example
  1805. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  1806. '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'
  1807. out
  1808. @end example
  1809. @section ladspa
  1810. Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
  1811. To enable compilation of this filter you need to configure FFmpeg with
  1812. @code{--enable-ladspa}.
  1813. @table @option
  1814. @item file, f
  1815. Specifies the name of LADSPA plugin library to load. If the environment
  1816. variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
  1817. each one of the directories specified by the colon separated list in
  1818. @env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
  1819. this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
  1820. @file{/usr/lib/ladspa/}.
  1821. @item plugin, p
  1822. Specifies the plugin within the library. Some libraries contain only
  1823. one plugin, but others contain many of them. If this is not set filter
  1824. will list all available plugins within the specified library.
  1825. @item controls, c
  1826. Set the '|' separated list of controls which are zero or more floating point
  1827. values that determine the behavior of the loaded plugin (for example delay,
  1828. threshold or gain).
  1829. Controls need to be defined using the following syntax:
  1830. c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
  1831. @var{valuei} is the value set on the @var{i}-th control.
  1832. Alternatively they can be also defined using the following syntax:
  1833. @var{value0}|@var{value1}|@var{value2}|..., where
  1834. @var{valuei} is the value set on the @var{i}-th control.
  1835. If @option{controls} is set to @code{help}, all available controls and
  1836. their valid ranges are printed.
  1837. @item sample_rate, s
  1838. Specify the sample rate, default to 44100. Only used if plugin have
  1839. zero inputs.
  1840. @item nb_samples, n
  1841. Set the number of samples per channel per each output frame, default
  1842. is 1024. Only used if plugin have zero inputs.
  1843. @item duration, d
  1844. Set the minimum duration of the sourced audio. See
  1845. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  1846. for the accepted syntax.
  1847. Note that the resulting duration may be greater than the specified duration,
  1848. as the generated audio is always cut at the end of a complete frame.
  1849. If not specified, or the expressed duration is negative, the audio is
  1850. supposed to be generated forever.
  1851. Only used if plugin have zero inputs.
  1852. @end table
  1853. @subsection Examples
  1854. @itemize
  1855. @item
  1856. List all available plugins within amp (LADSPA example plugin) library:
  1857. @example
  1858. ladspa=file=amp
  1859. @end example
  1860. @item
  1861. List all available controls and their valid ranges for @code{vcf_notch}
  1862. plugin from @code{VCF} library:
  1863. @example
  1864. ladspa=f=vcf:p=vcf_notch:c=help
  1865. @end example
  1866. @item
  1867. Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
  1868. plugin library:
  1869. @example
  1870. ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
  1871. @end example
  1872. @item
  1873. Add reverberation to the audio using TAP-plugins
  1874. (Tom's Audio Processing plugins):
  1875. @example
  1876. ladspa=file=tap_reverb:tap_reverb
  1877. @end example
  1878. @item
  1879. Generate white noise, with 0.2 amplitude:
  1880. @example
  1881. ladspa=file=cmt:noise_source_white:c=c0=.2
  1882. @end example
  1883. @item
  1884. Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
  1885. @code{C* Audio Plugin Suite} (CAPS) library:
  1886. @example
  1887. ladspa=file=caps:Click:c=c1=20'
  1888. @end example
  1889. @item
  1890. Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
  1891. @example
  1892. ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
  1893. @end example
  1894. @item
  1895. Increase volume by 20dB using fast lookahead limiter from Steve Harris
  1896. @code{SWH Plugins} collection:
  1897. @example
  1898. ladspa=fast_lookahead_limiter_1913:fastLookaheadLimiter:20|0|2
  1899. @end example
  1900. @item
  1901. Attenuate low frequencies using Multiband EQ from Steve Harris
  1902. @code{SWH Plugins} collection:
  1903. @example
  1904. ladspa=mbeq_1197:mbeq:-24|-24|-24|0|0|0|0|0|0|0|0|0|0|0|0
  1905. @end example
  1906. @end itemize
  1907. @subsection Commands
  1908. This filter supports the following commands:
  1909. @table @option
  1910. @item cN
  1911. Modify the @var{N}-th control value.
  1912. If the specified value is not valid, it is ignored and prior one is kept.
  1913. @end table
  1914. @section lowpass
  1915. Apply a low-pass filter with 3dB point frequency.
  1916. The filter can be either single-pole or double-pole (the default).
  1917. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1918. The filter accepts the following options:
  1919. @table @option
  1920. @item frequency, f
  1921. Set frequency in Hz. Default is 500.
  1922. @item poles, p
  1923. Set number of poles. Default is 2.
  1924. @item width_type
  1925. Set method to specify band-width of filter.
  1926. @table @option
  1927. @item h
  1928. Hz
  1929. @item q
  1930. Q-Factor
  1931. @item o
  1932. octave
  1933. @item s
  1934. slope
  1935. @end table
  1936. @item width, w
  1937. Specify the band-width of a filter in width_type units.
  1938. Applies only to double-pole filter.
  1939. The default is 0.707q and gives a Butterworth response.
  1940. @end table
  1941. @anchor{pan}
  1942. @section pan
  1943. Mix channels with specific gain levels. The filter accepts the output
  1944. channel layout followed by a set of channels definitions.
  1945. This filter is also designed to efficiently remap the channels of an audio
  1946. stream.
  1947. The filter accepts parameters of the form:
  1948. "@var{l}|@var{outdef}|@var{outdef}|..."
  1949. @table @option
  1950. @item l
  1951. output channel layout or number of channels
  1952. @item outdef
  1953. output channel specification, of the form:
  1954. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  1955. @item out_name
  1956. output channel to define, either a channel name (FL, FR, etc.) or a channel
  1957. number (c0, c1, etc.)
  1958. @item gain
  1959. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  1960. @item in_name
  1961. input channel to use, see out_name for details; it is not possible to mix
  1962. named and numbered input channels
  1963. @end table
  1964. If the `=' in a channel specification is replaced by `<', then the gains for
  1965. that specification will be renormalized so that the total is 1, thus
  1966. avoiding clipping noise.
  1967. @subsection Mixing examples
  1968. For example, if you want to down-mix from stereo to mono, but with a bigger
  1969. factor for the left channel:
  1970. @example
  1971. pan=1c|c0=0.9*c0+0.1*c1
  1972. @end example
  1973. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  1974. 7-channels surround:
  1975. @example
  1976. pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  1977. @end example
  1978. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  1979. that should be preferred (see "-ac" option) unless you have very specific
  1980. needs.
  1981. @subsection Remapping examples
  1982. The channel remapping will be effective if, and only if:
  1983. @itemize
  1984. @item gain coefficients are zeroes or ones,
  1985. @item only one input per channel output,
  1986. @end itemize
  1987. If all these conditions are satisfied, the filter will notify the user ("Pure
  1988. channel mapping detected"), and use an optimized and lossless method to do the
  1989. remapping.
  1990. For example, if you have a 5.1 source and want a stereo audio stream by
  1991. dropping the extra channels:
  1992. @example
  1993. pan="stereo| c0=FL | c1=FR"
  1994. @end example
  1995. Given the same source, you can also switch front left and front right channels
  1996. and keep the input channel layout:
  1997. @example
  1998. pan="5.1| c0=c1 | c1=c0 | c2=c2 | c3=c3 | c4=c4 | c5=c5"
  1999. @end example
  2000. If the input is a stereo audio stream, you can mute the front left channel (and
  2001. still keep the stereo channel layout) with:
  2002. @example
  2003. pan="stereo|c1=c1"
  2004. @end example
  2005. Still with a stereo audio stream input, you can copy the right channel in both
  2006. front left and right:
  2007. @example
  2008. pan="stereo| c0=FR | c1=FR"
  2009. @end example
  2010. @section replaygain
  2011. ReplayGain scanner filter. This filter takes an audio stream as an input and
  2012. outputs it unchanged.
  2013. At end of filtering it displays @code{track_gain} and @code{track_peak}.
  2014. @section resample
  2015. Convert the audio sample format, sample rate and channel layout. It is
  2016. not meant to be used directly.
  2017. @section rubberband
  2018. Apply time-stretching and pitch-shifting with librubberband.
  2019. The filter accepts the following options:
  2020. @table @option
  2021. @item tempo
  2022. Set tempo scale factor.
  2023. @item pitch
  2024. Set pitch scale factor.
  2025. @item transients
  2026. Set transients detector.
  2027. Possible values are:
  2028. @table @var
  2029. @item crisp
  2030. @item mixed
  2031. @item smooth
  2032. @end table
  2033. @item detector
  2034. Set detector.
  2035. Possible values are:
  2036. @table @var
  2037. @item compound
  2038. @item percussive
  2039. @item soft
  2040. @end table
  2041. @item phase
  2042. Set phase.
  2043. Possible values are:
  2044. @table @var
  2045. @item laminar
  2046. @item independent
  2047. @end table
  2048. @item window
  2049. Set processing window size.
  2050. Possible values are:
  2051. @table @var
  2052. @item standard
  2053. @item short
  2054. @item long
  2055. @end table
  2056. @item smoothing
  2057. Set smoothing.
  2058. Possible values are:
  2059. @table @var
  2060. @item off
  2061. @item on
  2062. @end table
  2063. @item formant
  2064. Enable formant preservation when shift pitching.
  2065. Possible values are:
  2066. @table @var
  2067. @item shifted
  2068. @item preserved
  2069. @end table
  2070. @item pitchq
  2071. Set pitch quality.
  2072. Possible values are:
  2073. @table @var
  2074. @item quality
  2075. @item speed
  2076. @item consistency
  2077. @end table
  2078. @item channels
  2079. Set channels.
  2080. Possible values are:
  2081. @table @var
  2082. @item apart
  2083. @item together
  2084. @end table
  2085. @end table
  2086. @section sidechaincompress
  2087. This filter acts like normal compressor but has the ability to compress
  2088. detected signal using second input signal.
  2089. It needs two input streams and returns one output stream.
  2090. First input stream will be processed depending on second stream signal.
  2091. The filtered signal then can be filtered with other filters in later stages of
  2092. processing. See @ref{pan} and @ref{amerge} filter.
  2093. The filter accepts the following options:
  2094. @table @option
  2095. @item level_in
  2096. Set input gain. Default is 1. Range is between 0.015625 and 64.
  2097. @item threshold
  2098. If a signal of second stream raises above this level it will affect the gain
  2099. reduction of first stream.
  2100. By default is 0.125. Range is between 0.00097563 and 1.
  2101. @item ratio
  2102. Set a ratio about which the signal is reduced. 1:2 means that if the level
  2103. raised 4dB above the threshold, it will be only 2dB above after the reduction.
  2104. Default is 2. Range is between 1 and 20.
  2105. @item attack
  2106. Amount of milliseconds the signal has to rise above the threshold before gain
  2107. reduction starts. Default is 20. Range is between 0.01 and 2000.
  2108. @item release
  2109. Amount of milliseconds the signal has to fall below the threshold before
  2110. reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
  2111. @item makeup
  2112. Set the amount by how much signal will be amplified after processing.
  2113. Default is 2. Range is from 1 and 64.
  2114. @item knee
  2115. Curve the sharp knee around the threshold to enter gain reduction more softly.
  2116. Default is 2.82843. Range is between 1 and 8.
  2117. @item link
  2118. Choose if the @code{average} level between all channels of side-chain stream
  2119. or the louder(@code{maximum}) channel of side-chain stream affects the
  2120. reduction. Default is @code{average}.
  2121. @item detection
  2122. Should the exact signal be taken in case of @code{peak} or an RMS one in case
  2123. of @code{rms}. Default is @code{rms} which is mainly smoother.
  2124. @item level_sc
  2125. Set sidechain gain. Default is 1. Range is between 0.015625 and 64.
  2126. @item mix
  2127. How much to use compressed signal in output. Default is 1.
  2128. Range is between 0 and 1.
  2129. @end table
  2130. @subsection Examples
  2131. @itemize
  2132. @item
  2133. Full ffmpeg example taking 2 audio inputs, 1st input to be compressed
  2134. depending on the signal of 2nd input and later compressed signal to be
  2135. merged with 2nd input:
  2136. @example
  2137. ffmpeg -i main.flac -i sidechain.flac -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge"
  2138. @end example
  2139. @end itemize
  2140. @section sidechaingate
  2141. A sidechain gate acts like a normal (wideband) gate but has the ability to
  2142. filter the detected signal before sending it to the gain reduction stage.
  2143. Normally a gate uses the full range signal to detect a level above the
  2144. threshold.
  2145. For example: If you cut all lower frequencies from your sidechain signal
  2146. the gate will decrease the volume of your track only if not enough highs
  2147. appear. With this technique you are able to reduce the resonation of a
  2148. natural drum or remove "rumbling" of muted strokes from a heavily distorted
  2149. guitar.
  2150. It needs two input streams and returns one output stream.
  2151. First input stream will be processed depending on second stream signal.
  2152. The filter accepts the following options:
  2153. @table @option
  2154. @item level_in
  2155. Set input level before filtering.
  2156. Default is 1. Allowed range is from 0.015625 to 64.
  2157. @item range
  2158. Set the level of gain reduction when the signal is below the threshold.
  2159. Default is 0.06125. Allowed range is from 0 to 1.
  2160. @item threshold
  2161. If a signal rises above this level the gain reduction is released.
  2162. Default is 0.125. Allowed range is from 0 to 1.
  2163. @item ratio
  2164. Set a ratio about which the signal is reduced.
  2165. Default is 2. Allowed range is from 1 to 9000.
  2166. @item attack
  2167. Amount of milliseconds the signal has to rise above the threshold before gain
  2168. reduction stops.
  2169. Default is 20 milliseconds. Allowed range is from 0.01 to 9000.
  2170. @item release
  2171. Amount of milliseconds the signal has to fall below the threshold before the
  2172. reduction is increased again. Default is 250 milliseconds.
  2173. Allowed range is from 0.01 to 9000.
  2174. @item makeup
  2175. Set amount of amplification of signal after processing.
  2176. Default is 1. Allowed range is from 1 to 64.
  2177. @item knee
  2178. Curve the sharp knee around the threshold to enter gain reduction more softly.
  2179. Default is 2.828427125. Allowed range is from 1 to 8.
  2180. @item detection
  2181. Choose if exact signal should be taken for detection or an RMS like one.
  2182. Default is rms. Can be peak or rms.
  2183. @item link
  2184. Choose if the average level between all channels or the louder channel affects
  2185. the reduction.
  2186. Default is average. Can be average or maximum.
  2187. @item level_sc
  2188. Set sidechain gain. Default is 1. Range is from 0.015625 to 64.
  2189. @end table
  2190. @section silencedetect
  2191. Detect silence in an audio stream.
  2192. This filter logs a message when it detects that the input audio volume is less
  2193. or equal to a noise tolerance value for a duration greater or equal to the
  2194. minimum detected noise duration.
  2195. The printed times and duration are expressed in seconds.
  2196. The filter accepts the following options:
  2197. @table @option
  2198. @item duration, d
  2199. Set silence duration until notification (default is 2 seconds).
  2200. @item noise, n
  2201. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  2202. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  2203. @end table
  2204. @subsection Examples
  2205. @itemize
  2206. @item
  2207. Detect 5 seconds of silence with -50dB noise tolerance:
  2208. @example
  2209. silencedetect=n=-50dB:d=5
  2210. @end example
  2211. @item
  2212. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  2213. tolerance in @file{silence.mp3}:
  2214. @example
  2215. ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
  2216. @end example
  2217. @end itemize
  2218. @section silenceremove
  2219. Remove silence from the beginning, middle or end of the audio.
  2220. The filter accepts the following options:
  2221. @table @option
  2222. @item start_periods
  2223. This value is used to indicate if audio should be trimmed at beginning of
  2224. the audio. A value of zero indicates no silence should be trimmed from the
  2225. beginning. When specifying a non-zero value, it trims audio up until it
  2226. finds non-silence. Normally, when trimming silence from beginning of audio
  2227. the @var{start_periods} will be @code{1} but it can be increased to higher
  2228. values to trim all audio up to specific count of non-silence periods.
  2229. Default value is @code{0}.
  2230. @item start_duration
  2231. Specify the amount of time that non-silence must be detected before it stops
  2232. trimming audio. By increasing the duration, bursts of noises can be treated
  2233. as silence and trimmed off. Default value is @code{0}.
  2234. @item start_threshold
  2235. This indicates what sample value should be treated as silence. For digital
  2236. audio, a value of @code{0} may be fine but for audio recorded from analog,
  2237. you may wish to increase the value to account for background noise.
  2238. Can be specified in dB (in case "dB" is appended to the specified value)
  2239. or amplitude ratio. Default value is @code{0}.
  2240. @item stop_periods
  2241. Set the count for trimming silence from the end of audio.
  2242. To remove silence from the middle of a file, specify a @var{stop_periods}
  2243. that is negative. This value is then treated as a positive value and is
  2244. used to indicate the effect should restart processing as specified by
  2245. @var{start_periods}, making it suitable for removing periods of silence
  2246. in the middle of the audio.
  2247. Default value is @code{0}.
  2248. @item stop_duration
  2249. Specify a duration of silence that must exist before audio is not copied any
  2250. more. By specifying a higher duration, silence that is wanted can be left in
  2251. the audio.
  2252. Default value is @code{0}.
  2253. @item stop_threshold
  2254. This is the same as @option{start_threshold} but for trimming silence from
  2255. the end of audio.
  2256. Can be specified in dB (in case "dB" is appended to the specified value)
  2257. or amplitude ratio. Default value is @code{0}.
  2258. @item leave_silence
  2259. This indicate that @var{stop_duration} length of audio should be left intact
  2260. at the beginning of each period of silence.
  2261. For example, if you want to remove long pauses between words but do not want
  2262. to remove the pauses completely. Default value is @code{0}.
  2263. @end table
  2264. @subsection Examples
  2265. @itemize
  2266. @item
  2267. The following example shows how this filter can be used to start a recording
  2268. that does not contain the delay at the start which usually occurs between
  2269. pressing the record button and the start of the performance:
  2270. @example
  2271. silenceremove=1:5:0.02
  2272. @end example
  2273. @end itemize
  2274. @section sofalizer
  2275. SOFAlizer uses head-related transfer functions (HRTFs) to create virtual
  2276. loudspeakers around the user for binaural listening via headphones (audio
  2277. formats up to 9 channels supported).
  2278. The HRTFs are stored in SOFA files (see www.sofacoustics.org for a database).
  2279. SOFAlizer is developed at the Acoustics Research Institute (ARI) of the
  2280. Austrian Academy of Sciences.
  2281. The filter accepts the following options:
  2282. @table @option
  2283. @item sofa
  2284. Set the SOFA file used for rendering.
  2285. @item gain
  2286. Set gain applied to audio. Value is in dB. Default is 0.
  2287. @item rotation
  2288. Set rotation of virtual loudspeakers in deg. Default is 0.
  2289. @item elevation
  2290. Set elevation of virtual speakers in deg. Default is 0.
  2291. @item radius
  2292. Set distance in meters between loudspeakers and the listener with near-field
  2293. HRTFs. Default is 1.
  2294. @item type
  2295. Set processing type. Can be @var{time} or @var{freq}. @var{time} is
  2296. processing audio in time domain which is slow but gives high quality output.
  2297. @var{freq} is processing audio in frequency domain which is fast but gives
  2298. mediocre output. Default is @var{freq}.
  2299. @end table
  2300. @section stereotools
  2301. This filter has some handy utilities to manage stereo signals, for converting
  2302. M/S stereo recordings to L/R signal while having control over the parameters
  2303. or spreading the stereo image of master track.
  2304. The filter accepts the following options:
  2305. @table @option
  2306. @item level_in
  2307. Set input level before filtering for both channels. Defaults is 1.
  2308. Allowed range is from 0.015625 to 64.
  2309. @item level_out
  2310. Set output level after filtering for both channels. Defaults is 1.
  2311. Allowed range is from 0.015625 to 64.
  2312. @item balance_in
  2313. Set input balance between both channels. Default is 0.
  2314. Allowed range is from -1 to 1.
  2315. @item balance_out
  2316. Set output balance between both channels. Default is 0.
  2317. Allowed range is from -1 to 1.
  2318. @item softclip
  2319. Enable softclipping. Results in analog distortion instead of harsh digital 0dB
  2320. clipping. Disabled by default.
  2321. @item mutel
  2322. Mute the left channel. Disabled by default.
  2323. @item muter
  2324. Mute the right channel. Disabled by default.
  2325. @item phasel
  2326. Change the phase of the left channel. Disabled by default.
  2327. @item phaser
  2328. Change the phase of the right channel. Disabled by default.
  2329. @item mode
  2330. Set stereo mode. Available values are:
  2331. @table @samp
  2332. @item lr>lr
  2333. Left/Right to Left/Right, this is default.
  2334. @item lr>ms
  2335. Left/Right to Mid/Side.
  2336. @item ms>lr
  2337. Mid/Side to Left/Right.
  2338. @item lr>ll
  2339. Left/Right to Left/Left.
  2340. @item lr>rr
  2341. Left/Right to Right/Right.
  2342. @item lr>l+r
  2343. Left/Right to Left + Right.
  2344. @item lr>rl
  2345. Left/Right to Right/Left.
  2346. @end table
  2347. @item slev
  2348. Set level of side signal. Default is 1.
  2349. Allowed range is from 0.015625 to 64.
  2350. @item sbal
  2351. Set balance of side signal. Default is 0.
  2352. Allowed range is from -1 to 1.
  2353. @item mlev
  2354. Set level of the middle signal. Default is 1.
  2355. Allowed range is from 0.015625 to 64.
  2356. @item mpan
  2357. Set middle signal pan. Default is 0. Allowed range is from -1 to 1.
  2358. @item base
  2359. Set stereo base between mono and inversed channels. Default is 0.
  2360. Allowed range is from -1 to 1.
  2361. @item delay
  2362. Set delay in milliseconds how much to delay left from right channel and
  2363. vice versa. Default is 0. Allowed range is from -20 to 20.
  2364. @item sclevel
  2365. Set S/C level. Default is 1. Allowed range is from 1 to 100.
  2366. @item phase
  2367. Set the stereo phase in degrees. Default is 0. Allowed range is from 0 to 360.
  2368. @end table
  2369. @section stereowiden
  2370. This filter enhance the stereo effect by suppressing signal common to both
  2371. channels and by delaying the signal of left into right and vice versa,
  2372. thereby widening the stereo effect.
  2373. The filter accepts the following options:
  2374. @table @option
  2375. @item delay
  2376. Time in milliseconds of the delay of left signal into right and vice versa.
  2377. Default is 20 milliseconds.
  2378. @item feedback
  2379. Amount of gain in delayed signal into right and vice versa. Gives a delay
  2380. effect of left signal in right output and vice versa which gives widening
  2381. effect. Default is 0.3.
  2382. @item crossfeed
  2383. Cross feed of left into right with inverted phase. This helps in suppressing
  2384. the mono. If the value is 1 it will cancel all the signal common to both
  2385. channels. Default is 0.3.
  2386. @item drymix
  2387. Set level of input signal of original channel. Default is 0.8.
  2388. @end table
  2389. @section treble
  2390. Boost or cut treble (upper) frequencies of the audio using a two-pole
  2391. shelving filter with a response similar to that of a standard
  2392. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  2393. The filter accepts the following options:
  2394. @table @option
  2395. @item gain, g
  2396. Give the gain at whichever is the lower of ~22 kHz and the
  2397. Nyquist frequency. Its useful range is about -20 (for a large cut)
  2398. to +20 (for a large boost). Beware of clipping when using a positive gain.
  2399. @item frequency, f
  2400. Set the filter's central frequency and so can be used
  2401. to extend or reduce the frequency range to be boosted or cut.
  2402. The default value is @code{3000} Hz.
  2403. @item width_type
  2404. Set method to specify band-width of filter.
  2405. @table @option
  2406. @item h
  2407. Hz
  2408. @item q
  2409. Q-Factor
  2410. @item o
  2411. octave
  2412. @item s
  2413. slope
  2414. @end table
  2415. @item width, w
  2416. Determine how steep is the filter's shelf transition.
  2417. @end table
  2418. @section tremolo
  2419. Sinusoidal amplitude modulation.
  2420. The filter accepts the following options:
  2421. @table @option
  2422. @item f
  2423. Modulation frequency in Hertz. Modulation frequencies in the subharmonic range
  2424. (20 Hz or lower) will result in a tremolo effect.
  2425. This filter may also be used as a ring modulator by specifying
  2426. a modulation frequency higher than 20 Hz.
  2427. Range is 0.1 - 20000.0. Default value is 5.0 Hz.
  2428. @item d
  2429. Depth of modulation as a percentage. Range is 0.0 - 1.0.
  2430. Default value is 0.5.
  2431. @end table
  2432. @section vibrato
  2433. Sinusoidal phase modulation.
  2434. The filter accepts the following options:
  2435. @table @option
  2436. @item f
  2437. Modulation frequency in Hertz.
  2438. Range is 0.1 - 20000.0. Default value is 5.0 Hz.
  2439. @item d
  2440. Depth of modulation as a percentage. Range is 0.0 - 1.0.
  2441. Default value is 0.5.
  2442. @end table
  2443. @section volume
  2444. Adjust the input audio volume.
  2445. It accepts the following parameters:
  2446. @table @option
  2447. @item volume
  2448. Set audio volume expression.
  2449. Output values are clipped to the maximum value.
  2450. The output audio volume is given by the relation:
  2451. @example
  2452. @var{output_volume} = @var{volume} * @var{input_volume}
  2453. @end example
  2454. The default value for @var{volume} is "1.0".
  2455. @item precision
  2456. This parameter represents the mathematical precision.
  2457. It determines which input sample formats will be allowed, which affects the
  2458. precision of the volume scaling.
  2459. @table @option
  2460. @item fixed
  2461. 8-bit fixed-point; this limits input sample format to U8, S16, and S32.
  2462. @item float
  2463. 32-bit floating-point; this limits input sample format to FLT. (default)
  2464. @item double
  2465. 64-bit floating-point; this limits input sample format to DBL.
  2466. @end table
  2467. @item replaygain
  2468. Choose the behaviour on encountering ReplayGain side data in input frames.
  2469. @table @option
  2470. @item drop
  2471. Remove ReplayGain side data, ignoring its contents (the default).
  2472. @item ignore
  2473. Ignore ReplayGain side data, but leave it in the frame.
  2474. @item track
  2475. Prefer the track gain, if present.
  2476. @item album
  2477. Prefer the album gain, if present.
  2478. @end table
  2479. @item replaygain_preamp
  2480. Pre-amplification gain in dB to apply to the selected replaygain gain.
  2481. Default value for @var{replaygain_preamp} is 0.0.
  2482. @item eval
  2483. Set when the volume expression is evaluated.
  2484. It accepts the following values:
  2485. @table @samp
  2486. @item once
  2487. only evaluate expression once during the filter initialization, or
  2488. when the @samp{volume} command is sent
  2489. @item frame
  2490. evaluate expression for each incoming frame
  2491. @end table
  2492. Default value is @samp{once}.
  2493. @end table
  2494. The volume expression can contain the following parameters.
  2495. @table @option
  2496. @item n
  2497. frame number (starting at zero)
  2498. @item nb_channels
  2499. number of channels
  2500. @item nb_consumed_samples
  2501. number of samples consumed by the filter
  2502. @item nb_samples
  2503. number of samples in the current frame
  2504. @item pos
  2505. original frame position in the file
  2506. @item pts
  2507. frame PTS
  2508. @item sample_rate
  2509. sample rate
  2510. @item startpts
  2511. PTS at start of stream
  2512. @item startt
  2513. time at start of stream
  2514. @item t
  2515. frame time
  2516. @item tb
  2517. timestamp timebase
  2518. @item volume
  2519. last set volume value
  2520. @end table
  2521. Note that when @option{eval} is set to @samp{once} only the
  2522. @var{sample_rate} and @var{tb} variables are available, all other
  2523. variables will evaluate to NAN.
  2524. @subsection Commands
  2525. This filter supports the following commands:
  2526. @table @option
  2527. @item volume
  2528. Modify the volume expression.
  2529. The command accepts the same syntax of the corresponding option.
  2530. If the specified expression is not valid, it is kept at its current
  2531. value.
  2532. @item replaygain_noclip
  2533. Prevent clipping by limiting the gain applied.
  2534. Default value for @var{replaygain_noclip} is 1.
  2535. @end table
  2536. @subsection Examples
  2537. @itemize
  2538. @item
  2539. Halve the input audio volume:
  2540. @example
  2541. volume=volume=0.5
  2542. volume=volume=1/2
  2543. volume=volume=-6.0206dB
  2544. @end example
  2545. In all the above example the named key for @option{volume} can be
  2546. omitted, for example like in:
  2547. @example
  2548. volume=0.5
  2549. @end example
  2550. @item
  2551. Increase input audio power by 6 decibels using fixed-point precision:
  2552. @example
  2553. volume=volume=6dB:precision=fixed
  2554. @end example
  2555. @item
  2556. Fade volume after time 10 with an annihilation period of 5 seconds:
  2557. @example
  2558. volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
  2559. @end example
  2560. @end itemize
  2561. @section volumedetect
  2562. Detect the volume of the input video.
  2563. The filter has no parameters. The input is not modified. Statistics about
  2564. the volume will be printed in the log when the input stream end is reached.
  2565. In particular it will show the mean volume (root mean square), maximum
  2566. volume (on a per-sample basis), and the beginning of a histogram of the
  2567. registered volume values (from the maximum value to a cumulated 1/1000 of
  2568. the samples).
  2569. All volumes are in decibels relative to the maximum PCM value.
  2570. @subsection Examples
  2571. Here is an excerpt of the output:
  2572. @example
  2573. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  2574. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  2575. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  2576. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  2577. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  2578. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  2579. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  2580. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  2581. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  2582. @end example
  2583. It means that:
  2584. @itemize
  2585. @item
  2586. The mean square energy is approximately -27 dB, or 10^-2.7.
  2587. @item
  2588. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  2589. @item
  2590. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  2591. @end itemize
  2592. In other words, raising the volume by +4 dB does not cause any clipping,
  2593. raising it by +5 dB causes clipping for 6 samples, etc.
  2594. @c man end AUDIO FILTERS
  2595. @chapter Audio Sources
  2596. @c man begin AUDIO SOURCES
  2597. Below is a description of the currently available audio sources.
  2598. @section abuffer
  2599. Buffer audio frames, and make them available to the filter chain.
  2600. This source is mainly intended for a programmatic use, in particular
  2601. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  2602. It accepts the following parameters:
  2603. @table @option
  2604. @item time_base
  2605. The timebase which will be used for timestamps of submitted frames. It must be
  2606. either a floating-point number or in @var{numerator}/@var{denominator} form.
  2607. @item sample_rate
  2608. The sample rate of the incoming audio buffers.
  2609. @item sample_fmt
  2610. The sample format of the incoming audio buffers.
  2611. Either a sample format name or its corresponding integer representation from
  2612. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  2613. @item channel_layout
  2614. The channel layout of the incoming audio buffers.
  2615. Either a channel layout name from channel_layout_map in
  2616. @file{libavutil/channel_layout.c} or its corresponding integer representation
  2617. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  2618. @item channels
  2619. The number of channels of the incoming audio buffers.
  2620. If both @var{channels} and @var{channel_layout} are specified, then they
  2621. must be consistent.
  2622. @end table
  2623. @subsection Examples
  2624. @example
  2625. abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
  2626. @end example
  2627. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  2628. Since the sample format with name "s16p" corresponds to the number
  2629. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  2630. equivalent to:
  2631. @example
  2632. abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
  2633. @end example
  2634. @section aevalsrc
  2635. Generate an audio signal specified by an expression.
  2636. This source accepts in input one or more expressions (one for each
  2637. channel), which are evaluated and used to generate a corresponding
  2638. audio signal.
  2639. This source accepts the following options:
  2640. @table @option
  2641. @item exprs
  2642. Set the '|'-separated expressions list for each separate channel. In case the
  2643. @option{channel_layout} option is not specified, the selected channel layout
  2644. depends on the number of provided expressions. Otherwise the last
  2645. specified expression is applied to the remaining output channels.
  2646. @item channel_layout, c
  2647. Set the channel layout. The number of channels in the specified layout
  2648. must be equal to the number of specified expressions.
  2649. @item duration, d
  2650. Set the minimum duration of the sourced audio. See
  2651. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  2652. for the accepted syntax.
  2653. Note that the resulting duration may be greater than the specified
  2654. duration, as the generated audio is always cut at the end of a
  2655. complete frame.
  2656. If not specified, or the expressed duration is negative, the audio is
  2657. supposed to be generated forever.
  2658. @item nb_samples, n
  2659. Set the number of samples per channel per each output frame,
  2660. default to 1024.
  2661. @item sample_rate, s
  2662. Specify the sample rate, default to 44100.
  2663. @end table
  2664. Each expression in @var{exprs} can contain the following constants:
  2665. @table @option
  2666. @item n
  2667. number of the evaluated sample, starting from 0
  2668. @item t
  2669. time of the evaluated sample expressed in seconds, starting from 0
  2670. @item s
  2671. sample rate
  2672. @end table
  2673. @subsection Examples
  2674. @itemize
  2675. @item
  2676. Generate silence:
  2677. @example
  2678. aevalsrc=0
  2679. @end example
  2680. @item
  2681. Generate a sin signal with frequency of 440 Hz, set sample rate to
  2682. 8000 Hz:
  2683. @example
  2684. aevalsrc="sin(440*2*PI*t):s=8000"
  2685. @end example
  2686. @item
  2687. Generate a two channels signal, specify the channel layout (Front
  2688. Center + Back Center) explicitly:
  2689. @example
  2690. aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
  2691. @end example
  2692. @item
  2693. Generate white noise:
  2694. @example
  2695. aevalsrc="-2+random(0)"
  2696. @end example
  2697. @item
  2698. Generate an amplitude modulated signal:
  2699. @example
  2700. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  2701. @end example
  2702. @item
  2703. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  2704. @example
  2705. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
  2706. @end example
  2707. @end itemize
  2708. @section anullsrc
  2709. The null audio source, return unprocessed audio frames. It is mainly useful
  2710. as a template and to be employed in analysis / debugging tools, or as
  2711. the source for filters which ignore the input data (for example the sox
  2712. synth filter).
  2713. This source accepts the following options:
  2714. @table @option
  2715. @item channel_layout, cl
  2716. Specifies the channel layout, and can be either an integer or a string
  2717. representing a channel layout. The default value of @var{channel_layout}
  2718. is "stereo".
  2719. Check the channel_layout_map definition in
  2720. @file{libavutil/channel_layout.c} for the mapping between strings and
  2721. channel layout values.
  2722. @item sample_rate, r
  2723. Specifies the sample rate, and defaults to 44100.
  2724. @item nb_samples, n
  2725. Set the number of samples per requested frames.
  2726. @end table
  2727. @subsection Examples
  2728. @itemize
  2729. @item
  2730. Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  2731. @example
  2732. anullsrc=r=48000:cl=4
  2733. @end example
  2734. @item
  2735. Do the same operation with a more obvious syntax:
  2736. @example
  2737. anullsrc=r=48000:cl=mono
  2738. @end example
  2739. @end itemize
  2740. All the parameters need to be explicitly defined.
  2741. @section flite
  2742. Synthesize a voice utterance using the libflite library.
  2743. To enable compilation of this filter you need to configure FFmpeg with
  2744. @code{--enable-libflite}.
  2745. Note that the flite library is not thread-safe.
  2746. The filter accepts the following options:
  2747. @table @option
  2748. @item list_voices
  2749. If set to 1, list the names of the available voices and exit
  2750. immediately. Default value is 0.
  2751. @item nb_samples, n
  2752. Set the maximum number of samples per frame. Default value is 512.
  2753. @item textfile
  2754. Set the filename containing the text to speak.
  2755. @item text
  2756. Set the text to speak.
  2757. @item voice, v
  2758. Set the voice to use for the speech synthesis. Default value is
  2759. @code{kal}. See also the @var{list_voices} option.
  2760. @end table
  2761. @subsection Examples
  2762. @itemize
  2763. @item
  2764. Read from file @file{speech.txt}, and synthesize the text using the
  2765. standard flite voice:
  2766. @example
  2767. flite=textfile=speech.txt
  2768. @end example
  2769. @item
  2770. Read the specified text selecting the @code{slt} voice:
  2771. @example
  2772. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2773. @end example
  2774. @item
  2775. Input text to ffmpeg:
  2776. @example
  2777. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2778. @end example
  2779. @item
  2780. Make @file{ffplay} speak the specified text, using @code{flite} and
  2781. the @code{lavfi} device:
  2782. @example
  2783. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  2784. @end example
  2785. @end itemize
  2786. For more information about libflite, check:
  2787. @url{http://www.speech.cs.cmu.edu/flite/}
  2788. @section anoisesrc
  2789. Generate a noise audio signal.
  2790. The filter accepts the following options:
  2791. @table @option
  2792. @item sample_rate, r
  2793. Specify the sample rate. Default value is 48000 Hz.
  2794. @item amplitude, a
  2795. Specify the amplitude (0.0 - 1.0) of the generated audio stream. Default value
  2796. is 1.0.
  2797. @item duration, d
  2798. Specify the duration of the generated audio stream. Not specifying this option
  2799. results in noise with an infinite length.
  2800. @item color, colour, c
  2801. Specify the color of noise. Available noise colors are white, pink, and brown.
  2802. Default color is white.
  2803. @item seed, s
  2804. Specify a value used to seed the PRNG.
  2805. @item nb_samples, n
  2806. Set the number of samples per each output frame, default is 1024.
  2807. @end table
  2808. @subsection Examples
  2809. @itemize
  2810. @item
  2811. Generate 60 seconds of pink noise, with a 44.1 kHz sampling rate and an amplitude of 0.5:
  2812. @example
  2813. anoisesrc=d=60:c=pink:r=44100:a=0.5
  2814. @end example
  2815. @end itemize
  2816. @section sine
  2817. Generate an audio signal made of a sine wave with amplitude 1/8.
  2818. The audio signal is bit-exact.
  2819. The filter accepts the following options:
  2820. @table @option
  2821. @item frequency, f
  2822. Set the carrier frequency. Default is 440 Hz.
  2823. @item beep_factor, b
  2824. Enable a periodic beep every second with frequency @var{beep_factor} times
  2825. the carrier frequency. Default is 0, meaning the beep is disabled.
  2826. @item sample_rate, r
  2827. Specify the sample rate, default is 44100.
  2828. @item duration, d
  2829. Specify the duration of the generated audio stream.
  2830. @item samples_per_frame
  2831. Set the number of samples per output frame.
  2832. The expression can contain the following constants:
  2833. @table @option
  2834. @item n
  2835. The (sequential) number of the output audio frame, starting from 0.
  2836. @item pts
  2837. The PTS (Presentation TimeStamp) of the output audio frame,
  2838. expressed in @var{TB} units.
  2839. @item t
  2840. The PTS of the output audio frame, expressed in seconds.
  2841. @item TB
  2842. The timebase of the output audio frames.
  2843. @end table
  2844. Default is @code{1024}.
  2845. @end table
  2846. @subsection Examples
  2847. @itemize
  2848. @item
  2849. Generate a simple 440 Hz sine wave:
  2850. @example
  2851. sine
  2852. @end example
  2853. @item
  2854. Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
  2855. @example
  2856. sine=220:4:d=5
  2857. sine=f=220:b=4:d=5
  2858. sine=frequency=220:beep_factor=4:duration=5
  2859. @end example
  2860. @item
  2861. Generate a 1 kHz sine wave following @code{1602,1601,1602,1601,1602} NTSC
  2862. pattern:
  2863. @example
  2864. sine=1000:samples_per_frame='st(0,mod(n,5)); 1602-not(not(eq(ld(0),1)+eq(ld(0),3)))'
  2865. @end example
  2866. @end itemize
  2867. @c man end AUDIO SOURCES
  2868. @chapter Audio Sinks
  2869. @c man begin AUDIO SINKS
  2870. Below is a description of the currently available audio sinks.
  2871. @section abuffersink
  2872. Buffer audio frames, and make them available to the end of filter chain.
  2873. This sink is mainly intended for programmatic use, in particular
  2874. through the interface defined in @file{libavfilter/buffersink.h}
  2875. or the options system.
  2876. It accepts a pointer to an AVABufferSinkContext structure, which
  2877. defines the incoming buffers' formats, to be passed as the opaque
  2878. parameter to @code{avfilter_init_filter} for initialization.
  2879. @section anullsink
  2880. Null audio sink; do absolutely nothing with the input audio. It is
  2881. mainly useful as a template and for use in analysis / debugging
  2882. tools.
  2883. @c man end AUDIO SINKS
  2884. @chapter Video Filters
  2885. @c man begin VIDEO FILTERS
  2886. When you configure your FFmpeg build, you can disable any of the
  2887. existing filters using @code{--disable-filters}.
  2888. The configure output will show the video filters included in your
  2889. build.
  2890. Below is a description of the currently available video filters.
  2891. @section alphaextract
  2892. Extract the alpha component from the input as a grayscale video. This
  2893. is especially useful with the @var{alphamerge} filter.
  2894. @section alphamerge
  2895. Add or replace the alpha component of the primary input with the
  2896. grayscale value of a second input. This is intended for use with
  2897. @var{alphaextract} to allow the transmission or storage of frame
  2898. sequences that have alpha in a format that doesn't support an alpha
  2899. channel.
  2900. For example, to reconstruct full frames from a normal YUV-encoded video
  2901. and a separate video created with @var{alphaextract}, you might use:
  2902. @example
  2903. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  2904. @end example
  2905. Since this filter is designed for reconstruction, it operates on frame
  2906. sequences without considering timestamps, and terminates when either
  2907. input reaches end of stream. This will cause problems if your encoding
  2908. pipeline drops frames. If you're trying to apply an image as an
  2909. overlay to a video stream, consider the @var{overlay} filter instead.
  2910. @section ass
  2911. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  2912. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  2913. Substation Alpha) subtitles files.
  2914. This filter accepts the following option in addition to the common options from
  2915. the @ref{subtitles} filter:
  2916. @table @option
  2917. @item shaping
  2918. Set the shaping engine
  2919. Available values are:
  2920. @table @samp
  2921. @item auto
  2922. The default libass shaping engine, which is the best available.
  2923. @item simple
  2924. Fast, font-agnostic shaper that can do only substitutions
  2925. @item complex
  2926. Slower shaper using OpenType for substitutions and positioning
  2927. @end table
  2928. The default is @code{auto}.
  2929. @end table
  2930. @section atadenoise
  2931. Apply an Adaptive Temporal Averaging Denoiser to the video input.
  2932. The filter accepts the following options:
  2933. @table @option
  2934. @item 0a
  2935. Set threshold A for 1st plane. Default is 0.02.
  2936. Valid range is 0 to 0.3.
  2937. @item 0b
  2938. Set threshold B for 1st plane. Default is 0.04.
  2939. Valid range is 0 to 5.
  2940. @item 1a
  2941. Set threshold A for 2nd plane. Default is 0.02.
  2942. Valid range is 0 to 0.3.
  2943. @item 1b
  2944. Set threshold B for 2nd plane. Default is 0.04.
  2945. Valid range is 0 to 5.
  2946. @item 2a
  2947. Set threshold A for 3rd plane. Default is 0.02.
  2948. Valid range is 0 to 0.3.
  2949. @item 2b
  2950. Set threshold B for 3rd plane. Default is 0.04.
  2951. Valid range is 0 to 5.
  2952. Threshold A is designed to react on abrupt changes in the input signal and
  2953. threshold B is designed to react on continuous changes in the input signal.
  2954. @item s
  2955. Set number of frames filter will use for averaging. Default is 33. Must be odd
  2956. number in range [5, 129].
  2957. @end table
  2958. @section bbox
  2959. Compute the bounding box for the non-black pixels in the input frame
  2960. luminance plane.
  2961. This filter computes the bounding box containing all the pixels with a
  2962. luminance value greater than the minimum allowed value.
  2963. The parameters describing the bounding box are printed on the filter
  2964. log.
  2965. The filter accepts the following option:
  2966. @table @option
  2967. @item min_val
  2968. Set the minimal luminance value. Default is @code{16}.
  2969. @end table
  2970. @section blackdetect
  2971. Detect video intervals that are (almost) completely black. Can be
  2972. useful to detect chapter transitions, commercials, or invalid
  2973. recordings. Output lines contains the time for the start, end and
  2974. duration of the detected black interval expressed in seconds.
  2975. In order to display the output lines, you need to set the loglevel at
  2976. least to the AV_LOG_INFO value.
  2977. The filter accepts the following options:
  2978. @table @option
  2979. @item black_min_duration, d
  2980. Set the minimum detected black duration expressed in seconds. It must
  2981. be a non-negative floating point number.
  2982. Default value is 2.0.
  2983. @item picture_black_ratio_th, pic_th
  2984. Set the threshold for considering a picture "black".
  2985. Express the minimum value for the ratio:
  2986. @example
  2987. @var{nb_black_pixels} / @var{nb_pixels}
  2988. @end example
  2989. for which a picture is considered black.
  2990. Default value is 0.98.
  2991. @item pixel_black_th, pix_th
  2992. Set the threshold for considering a pixel "black".
  2993. The threshold expresses the maximum pixel luminance value for which a
  2994. pixel is considered "black". The provided value is scaled according to
  2995. the following equation:
  2996. @example
  2997. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  2998. @end example
  2999. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  3000. the input video format, the range is [0-255] for YUV full-range
  3001. formats and [16-235] for YUV non full-range formats.
  3002. Default value is 0.10.
  3003. @end table
  3004. The following example sets the maximum pixel threshold to the minimum
  3005. value, and detects only black intervals of 2 or more seconds:
  3006. @example
  3007. blackdetect=d=2:pix_th=0.00
  3008. @end example
  3009. @section blackframe
  3010. Detect frames that are (almost) completely black. Can be useful to
  3011. detect chapter transitions or commercials. Output lines consist of
  3012. the frame number of the detected frame, the percentage of blackness,
  3013. the position in the file if known or -1 and the timestamp in seconds.
  3014. In order to display the output lines, you need to set the loglevel at
  3015. least to the AV_LOG_INFO value.
  3016. It accepts the following parameters:
  3017. @table @option
  3018. @item amount
  3019. The percentage of the pixels that have to be below the threshold; it defaults to
  3020. @code{98}.
  3021. @item threshold, thresh
  3022. The threshold below which a pixel value is considered black; it defaults to
  3023. @code{32}.
  3024. @end table
  3025. @section blend, tblend
  3026. Blend two video frames into each other.
  3027. The @code{blend} filter takes two input streams and outputs one
  3028. stream, the first input is the "top" layer and second input is
  3029. "bottom" layer. Output terminates when shortest input terminates.
  3030. The @code{tblend} (time blend) filter takes two consecutive frames
  3031. from one single stream, and outputs the result obtained by blending
  3032. the new frame on top of the old frame.
  3033. A description of the accepted options follows.
  3034. @table @option
  3035. @item c0_mode
  3036. @item c1_mode
  3037. @item c2_mode
  3038. @item c3_mode
  3039. @item all_mode
  3040. Set blend mode for specific pixel component or all pixel components in case
  3041. of @var{all_mode}. Default value is @code{normal}.
  3042. Available values for component modes are:
  3043. @table @samp
  3044. @item addition
  3045. @item addition128
  3046. @item and
  3047. @item average
  3048. @item burn
  3049. @item darken
  3050. @item difference
  3051. @item difference128
  3052. @item divide
  3053. @item dodge
  3054. @item exclusion
  3055. @item glow
  3056. @item hardlight
  3057. @item hardmix
  3058. @item lighten
  3059. @item linearlight
  3060. @item multiply
  3061. @item negation
  3062. @item normal
  3063. @item or
  3064. @item overlay
  3065. @item phoenix
  3066. @item pinlight
  3067. @item reflect
  3068. @item screen
  3069. @item softlight
  3070. @item subtract
  3071. @item vividlight
  3072. @item xor
  3073. @end table
  3074. @item c0_opacity
  3075. @item c1_opacity
  3076. @item c2_opacity
  3077. @item c3_opacity
  3078. @item all_opacity
  3079. Set blend opacity for specific pixel component or all pixel components in case
  3080. of @var{all_opacity}. Only used in combination with pixel component blend modes.
  3081. @item c0_expr
  3082. @item c1_expr
  3083. @item c2_expr
  3084. @item c3_expr
  3085. @item all_expr
  3086. Set blend expression for specific pixel component or all pixel components in case
  3087. of @var{all_expr}. Note that related mode options will be ignored if those are set.
  3088. The expressions can use the following variables:
  3089. @table @option
  3090. @item N
  3091. The sequential number of the filtered frame, starting from @code{0}.
  3092. @item X
  3093. @item Y
  3094. the coordinates of the current sample
  3095. @item W
  3096. @item H
  3097. the width and height of currently filtered plane
  3098. @item SW
  3099. @item SH
  3100. Width and height scale depending on the currently filtered plane. It is the
  3101. ratio between the corresponding luma plane number of pixels and the current
  3102. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  3103. @code{0.5,0.5} for chroma planes.
  3104. @item T
  3105. Time of the current frame, expressed in seconds.
  3106. @item TOP, A
  3107. Value of pixel component at current location for first video frame (top layer).
  3108. @item BOTTOM, B
  3109. Value of pixel component at current location for second video frame (bottom layer).
  3110. @end table
  3111. @item shortest
  3112. Force termination when the shortest input terminates. Default is
  3113. @code{0}. This option is only defined for the @code{blend} filter.
  3114. @item repeatlast
  3115. Continue applying the last bottom frame after the end of the stream. A value of
  3116. @code{0} disable the filter after the last frame of the bottom layer is reached.
  3117. Default is @code{1}. This option is only defined for the @code{blend} filter.
  3118. @end table
  3119. @subsection Examples
  3120. @itemize
  3121. @item
  3122. Apply transition from bottom layer to top layer in first 10 seconds:
  3123. @example
  3124. blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
  3125. @end example
  3126. @item
  3127. Apply 1x1 checkerboard effect:
  3128. @example
  3129. blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
  3130. @end example
  3131. @item
  3132. Apply uncover left effect:
  3133. @example
  3134. blend=all_expr='if(gte(N*SW+X,W),A,B)'
  3135. @end example
  3136. @item
  3137. Apply uncover down effect:
  3138. @example
  3139. blend=all_expr='if(gte(Y-N*SH,0),A,B)'
  3140. @end example
  3141. @item
  3142. Apply uncover up-left effect:
  3143. @example
  3144. blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
  3145. @end example
  3146. @item
  3147. Display differences between the current and the previous frame:
  3148. @example
  3149. tblend=all_mode=difference128
  3150. @end example
  3151. @end itemize
  3152. @section boxblur
  3153. Apply a boxblur algorithm to the input video.
  3154. It accepts the following parameters:
  3155. @table @option
  3156. @item luma_radius, lr
  3157. @item luma_power, lp
  3158. @item chroma_radius, cr
  3159. @item chroma_power, cp
  3160. @item alpha_radius, ar
  3161. @item alpha_power, ap
  3162. @end table
  3163. A description of the accepted options follows.
  3164. @table @option
  3165. @item luma_radius, lr
  3166. @item chroma_radius, cr
  3167. @item alpha_radius, ar
  3168. Set an expression for the box radius in pixels used for blurring the
  3169. corresponding input plane.
  3170. The radius value must be a non-negative number, and must not be
  3171. greater than the value of the expression @code{min(w,h)/2} for the
  3172. luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
  3173. planes.
  3174. Default value for @option{luma_radius} is "2". If not specified,
  3175. @option{chroma_radius} and @option{alpha_radius} default to the
  3176. corresponding value set for @option{luma_radius}.
  3177. The expressions can contain the following constants:
  3178. @table @option
  3179. @item w
  3180. @item h
  3181. The input width and height in pixels.
  3182. @item cw
  3183. @item ch
  3184. The input chroma image width and height in pixels.
  3185. @item hsub
  3186. @item vsub
  3187. The horizontal and vertical chroma subsample values. For example, for the
  3188. pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
  3189. @end table
  3190. @item luma_power, lp
  3191. @item chroma_power, cp
  3192. @item alpha_power, ap
  3193. Specify how many times the boxblur filter is applied to the
  3194. corresponding plane.
  3195. Default value for @option{luma_power} is 2. If not specified,
  3196. @option{chroma_power} and @option{alpha_power} default to the
  3197. corresponding value set for @option{luma_power}.
  3198. A value of 0 will disable the effect.
  3199. @end table
  3200. @subsection Examples
  3201. @itemize
  3202. @item
  3203. Apply a boxblur filter with the luma, chroma, and alpha radii
  3204. set to 2:
  3205. @example
  3206. boxblur=luma_radius=2:luma_power=1
  3207. boxblur=2:1
  3208. @end example
  3209. @item
  3210. Set the luma radius to 2, and alpha and chroma radius to 0:
  3211. @example
  3212. boxblur=2:1:cr=0:ar=0
  3213. @end example
  3214. @item
  3215. Set the luma and chroma radii to a fraction of the video dimension:
  3216. @example
  3217. boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
  3218. @end example
  3219. @end itemize
  3220. @section chromakey
  3221. YUV colorspace color/chroma keying.
  3222. The filter accepts the following options:
  3223. @table @option
  3224. @item color
  3225. The color which will be replaced with transparency.
  3226. @item similarity
  3227. Similarity percentage with the key color.
  3228. 0.01 matches only the exact key color, while 1.0 matches everything.
  3229. @item blend
  3230. Blend percentage.
  3231. 0.0 makes pixels either fully transparent, or not transparent at all.
  3232. Higher values result in semi-transparent pixels, with a higher transparency
  3233. the more similar the pixels color is to the key color.
  3234. @item yuv
  3235. Signals that the color passed is already in YUV instead of RGB.
  3236. Litteral colors like "green" or "red" don't make sense with this enabled anymore.
  3237. This can be used to pass exact YUV values as hexadecimal numbers.
  3238. @end table
  3239. @subsection Examples
  3240. @itemize
  3241. @item
  3242. Make every green pixel in the input image transparent:
  3243. @example
  3244. ffmpeg -i input.png -vf chromakey=green out.png
  3245. @end example
  3246. @item
  3247. Overlay a greenscreen-video on top of a static black background.
  3248. @example
  3249. 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
  3250. @end example
  3251. @end itemize
  3252. @section codecview
  3253. Visualize information exported by some codecs.
  3254. Some codecs can export information through frames using side-data or other
  3255. means. For example, some MPEG based codecs export motion vectors through the
  3256. @var{export_mvs} flag in the codec @option{flags2} option.
  3257. The filter accepts the following option:
  3258. @table @option
  3259. @item mv
  3260. Set motion vectors to visualize.
  3261. Available flags for @var{mv} are:
  3262. @table @samp
  3263. @item pf
  3264. forward predicted MVs of P-frames
  3265. @item bf
  3266. forward predicted MVs of B-frames
  3267. @item bb
  3268. backward predicted MVs of B-frames
  3269. @end table
  3270. @item qp
  3271. Display quantization parameters using the chroma planes
  3272. @end table
  3273. @subsection Examples
  3274. @itemize
  3275. @item
  3276. Visualizes multi-directionals MVs from P and B-Frames using @command{ffplay}:
  3277. @example
  3278. ffplay -flags2 +export_mvs input.mpg -vf codecview=mv=pf+bf+bb
  3279. @end example
  3280. @end itemize
  3281. @section colorbalance
  3282. Modify intensity of primary colors (red, green and blue) of input frames.
  3283. The filter allows an input frame to be adjusted in the shadows, midtones or highlights
  3284. regions for the red-cyan, green-magenta or blue-yellow balance.
  3285. A positive adjustment value shifts the balance towards the primary color, a negative
  3286. value towards the complementary color.
  3287. The filter accepts the following options:
  3288. @table @option
  3289. @item rs
  3290. @item gs
  3291. @item bs
  3292. Adjust red, green and blue shadows (darkest pixels).
  3293. @item rm
  3294. @item gm
  3295. @item bm
  3296. Adjust red, green and blue midtones (medium pixels).
  3297. @item rh
  3298. @item gh
  3299. @item bh
  3300. Adjust red, green and blue highlights (brightest pixels).
  3301. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  3302. @end table
  3303. @subsection Examples
  3304. @itemize
  3305. @item
  3306. Add red color cast to shadows:
  3307. @example
  3308. colorbalance=rs=.3
  3309. @end example
  3310. @end itemize
  3311. @section colorkey
  3312. RGB colorspace color keying.
  3313. The filter accepts the following options:
  3314. @table @option
  3315. @item color
  3316. The color which will be replaced with transparency.
  3317. @item similarity
  3318. Similarity percentage with the key color.
  3319. 0.01 matches only the exact key color, while 1.0 matches everything.
  3320. @item blend
  3321. Blend percentage.
  3322. 0.0 makes pixels either fully transparent, or not transparent at all.
  3323. Higher values result in semi-transparent pixels, with a higher transparency
  3324. the more similar the pixels color is to the key color.
  3325. @end table
  3326. @subsection Examples
  3327. @itemize
  3328. @item
  3329. Make every green pixel in the input image transparent:
  3330. @example
  3331. ffmpeg -i input.png -vf colorkey=green out.png
  3332. @end example
  3333. @item
  3334. Overlay a greenscreen-video on top of a static background image.
  3335. @example
  3336. 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
  3337. @end example
  3338. @end itemize
  3339. @section colorlevels
  3340. Adjust video input frames using levels.
  3341. The filter accepts the following options:
  3342. @table @option
  3343. @item rimin
  3344. @item gimin
  3345. @item bimin
  3346. @item aimin
  3347. Adjust red, green, blue and alpha input black point.
  3348. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  3349. @item rimax
  3350. @item gimax
  3351. @item bimax
  3352. @item aimax
  3353. Adjust red, green, blue and alpha input white point.
  3354. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
  3355. Input levels are used to lighten highlights (bright tones), darken shadows
  3356. (dark tones), change the balance of bright and dark tones.
  3357. @item romin
  3358. @item gomin
  3359. @item bomin
  3360. @item aomin
  3361. Adjust red, green, blue and alpha output black point.
  3362. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
  3363. @item romax
  3364. @item gomax
  3365. @item bomax
  3366. @item aomax
  3367. Adjust red, green, blue and alpha output white point.
  3368. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
  3369. Output levels allows manual selection of a constrained output level range.
  3370. @end table
  3371. @subsection Examples
  3372. @itemize
  3373. @item
  3374. Make video output darker:
  3375. @example
  3376. colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
  3377. @end example
  3378. @item
  3379. Increase contrast:
  3380. @example
  3381. colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
  3382. @end example
  3383. @item
  3384. Make video output lighter:
  3385. @example
  3386. colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
  3387. @end example
  3388. @item
  3389. Increase brightness:
  3390. @example
  3391. colorlevels=romin=0.5:gomin=0.5:bomin=0.5
  3392. @end example
  3393. @end itemize
  3394. @section colorchannelmixer
  3395. Adjust video input frames by re-mixing color channels.
  3396. This filter modifies a color channel by adding the values associated to
  3397. the other channels of the same pixels. For example if the value to
  3398. modify is red, the output value will be:
  3399. @example
  3400. @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
  3401. @end example
  3402. The filter accepts the following options:
  3403. @table @option
  3404. @item rr
  3405. @item rg
  3406. @item rb
  3407. @item ra
  3408. Adjust contribution of input red, green, blue and alpha channels for output red channel.
  3409. Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
  3410. @item gr
  3411. @item gg
  3412. @item gb
  3413. @item ga
  3414. Adjust contribution of input red, green, blue and alpha channels for output green channel.
  3415. Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
  3416. @item br
  3417. @item bg
  3418. @item bb
  3419. @item ba
  3420. Adjust contribution of input red, green, blue and alpha channels for output blue channel.
  3421. Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
  3422. @item ar
  3423. @item ag
  3424. @item ab
  3425. @item aa
  3426. Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
  3427. Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
  3428. Allowed ranges for options are @code{[-2.0, 2.0]}.
  3429. @end table
  3430. @subsection Examples
  3431. @itemize
  3432. @item
  3433. Convert source to grayscale:
  3434. @example
  3435. colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
  3436. @end example
  3437. @item
  3438. Simulate sepia tones:
  3439. @example
  3440. colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
  3441. @end example
  3442. @end itemize
  3443. @section colormatrix
  3444. Convert color matrix.
  3445. The filter accepts the following options:
  3446. @table @option
  3447. @item src
  3448. @item dst
  3449. Specify the source and destination color matrix. Both values must be
  3450. specified.
  3451. The accepted values are:
  3452. @table @samp
  3453. @item bt709
  3454. BT.709
  3455. @item bt601
  3456. BT.601
  3457. @item smpte240m
  3458. SMPTE-240M
  3459. @item fcc
  3460. FCC
  3461. @end table
  3462. @end table
  3463. For example to convert from BT.601 to SMPTE-240M, use the command:
  3464. @example
  3465. colormatrix=bt601:smpte240m
  3466. @end example
  3467. @section copy
  3468. Copy the input source unchanged to the output. This is mainly useful for
  3469. testing purposes.
  3470. @section crop
  3471. Crop the input video to given dimensions.
  3472. It accepts the following parameters:
  3473. @table @option
  3474. @item w, out_w
  3475. The width of the output video. It defaults to @code{iw}.
  3476. This expression is evaluated only once during the filter
  3477. configuration, or when the @samp{w} or @samp{out_w} command is sent.
  3478. @item h, out_h
  3479. The height of the output video. It defaults to @code{ih}.
  3480. This expression is evaluated only once during the filter
  3481. configuration, or when the @samp{h} or @samp{out_h} command is sent.
  3482. @item x
  3483. The horizontal position, in the input video, of the left edge of the output
  3484. video. It defaults to @code{(in_w-out_w)/2}.
  3485. This expression is evaluated per-frame.
  3486. @item y
  3487. The vertical position, in the input video, of the top edge of the output video.
  3488. It defaults to @code{(in_h-out_h)/2}.
  3489. This expression is evaluated per-frame.
  3490. @item keep_aspect
  3491. If set to 1 will force the output display aspect ratio
  3492. to be the same of the input, by changing the output sample aspect
  3493. ratio. It defaults to 0.
  3494. @end table
  3495. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  3496. expressions containing the following constants:
  3497. @table @option
  3498. @item x
  3499. @item y
  3500. The computed values for @var{x} and @var{y}. They are evaluated for
  3501. each new frame.
  3502. @item in_w
  3503. @item in_h
  3504. The input width and height.
  3505. @item iw
  3506. @item ih
  3507. These are the same as @var{in_w} and @var{in_h}.
  3508. @item out_w
  3509. @item out_h
  3510. The output (cropped) width and height.
  3511. @item ow
  3512. @item oh
  3513. These are the same as @var{out_w} and @var{out_h}.
  3514. @item a
  3515. same as @var{iw} / @var{ih}
  3516. @item sar
  3517. input sample aspect ratio
  3518. @item dar
  3519. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  3520. @item hsub
  3521. @item vsub
  3522. horizontal and vertical chroma subsample values. For example for the
  3523. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3524. @item n
  3525. The number of the input frame, starting from 0.
  3526. @item pos
  3527. the position in the file of the input frame, NAN if unknown
  3528. @item t
  3529. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  3530. @end table
  3531. The expression for @var{out_w} may depend on the value of @var{out_h},
  3532. and the expression for @var{out_h} may depend on @var{out_w}, but they
  3533. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  3534. evaluated after @var{out_w} and @var{out_h}.
  3535. The @var{x} and @var{y} parameters specify the expressions for the
  3536. position of the top-left corner of the output (non-cropped) area. They
  3537. are evaluated for each frame. If the evaluated value is not valid, it
  3538. is approximated to the nearest valid value.
  3539. The expression for @var{x} may depend on @var{y}, and the expression
  3540. for @var{y} may depend on @var{x}.
  3541. @subsection Examples
  3542. @itemize
  3543. @item
  3544. Crop area with size 100x100 at position (12,34).
  3545. @example
  3546. crop=100:100:12:34
  3547. @end example
  3548. Using named options, the example above becomes:
  3549. @example
  3550. crop=w=100:h=100:x=12:y=34
  3551. @end example
  3552. @item
  3553. Crop the central input area with size 100x100:
  3554. @example
  3555. crop=100:100
  3556. @end example
  3557. @item
  3558. Crop the central input area with size 2/3 of the input video:
  3559. @example
  3560. crop=2/3*in_w:2/3*in_h
  3561. @end example
  3562. @item
  3563. Crop the input video central square:
  3564. @example
  3565. crop=out_w=in_h
  3566. crop=in_h
  3567. @end example
  3568. @item
  3569. Delimit the rectangle with the top-left corner placed at position
  3570. 100:100 and the right-bottom corner corresponding to the right-bottom
  3571. corner of the input image.
  3572. @example
  3573. crop=in_w-100:in_h-100:100:100
  3574. @end example
  3575. @item
  3576. Crop 10 pixels from the left and right borders, and 20 pixels from
  3577. the top and bottom borders
  3578. @example
  3579. crop=in_w-2*10:in_h-2*20
  3580. @end example
  3581. @item
  3582. Keep only the bottom right quarter of the input image:
  3583. @example
  3584. crop=in_w/2:in_h/2:in_w/2:in_h/2
  3585. @end example
  3586. @item
  3587. Crop height for getting Greek harmony:
  3588. @example
  3589. crop=in_w:1/PHI*in_w
  3590. @end example
  3591. @item
  3592. Apply trembling effect:
  3593. @example
  3594. 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)
  3595. @end example
  3596. @item
  3597. Apply erratic camera effect depending on timestamp:
  3598. @example
  3599. 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)"
  3600. @end example
  3601. @item
  3602. Set x depending on the value of y:
  3603. @example
  3604. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  3605. @end example
  3606. @end itemize
  3607. @subsection Commands
  3608. This filter supports the following commands:
  3609. @table @option
  3610. @item w, out_w
  3611. @item h, out_h
  3612. @item x
  3613. @item y
  3614. Set width/height of the output video and the horizontal/vertical position
  3615. in the input video.
  3616. The command accepts the same syntax of the corresponding option.
  3617. If the specified expression is not valid, it is kept at its current
  3618. value.
  3619. @end table
  3620. @section cropdetect
  3621. Auto-detect the crop size.
  3622. It calculates the necessary cropping parameters and prints the
  3623. recommended parameters via the logging system. The detected dimensions
  3624. correspond to the non-black area of the input video.
  3625. It accepts the following parameters:
  3626. @table @option
  3627. @item limit
  3628. Set higher black value threshold, which can be optionally specified
  3629. from nothing (0) to everything (255 for 8bit based formats). An intensity
  3630. value greater to the set value is considered non-black. It defaults to 24.
  3631. You can also specify a value between 0.0 and 1.0 which will be scaled depending
  3632. on the bitdepth of the pixel format.
  3633. @item round
  3634. The value which the width/height should be divisible by. It defaults to
  3635. 16. The offset is automatically adjusted to center the video. Use 2 to
  3636. get only even dimensions (needed for 4:2:2 video). 16 is best when
  3637. encoding to most video codecs.
  3638. @item reset_count, reset
  3639. Set the counter that determines after how many frames cropdetect will
  3640. reset the previously detected largest video area and start over to
  3641. detect the current optimal crop area. Default value is 0.
  3642. This can be useful when channel logos distort the video area. 0
  3643. indicates 'never reset', and returns the largest area encountered during
  3644. playback.
  3645. @end table
  3646. @anchor{curves}
  3647. @section curves
  3648. Apply color adjustments using curves.
  3649. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  3650. component (red, green and blue) has its values defined by @var{N} key points
  3651. tied from each other using a smooth curve. The x-axis represents the pixel
  3652. values from the input frame, and the y-axis the new pixel values to be set for
  3653. the output frame.
  3654. By default, a component curve is defined by the two points @var{(0;0)} and
  3655. @var{(1;1)}. This creates a straight line where each original pixel value is
  3656. "adjusted" to its own value, which means no change to the image.
  3657. The filter allows you to redefine these two points and add some more. A new
  3658. curve (using a natural cubic spline interpolation) will be define to pass
  3659. smoothly through all these new coordinates. The new defined points needs to be
  3660. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  3661. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  3662. the vector spaces, the values will be clipped accordingly.
  3663. If there is no key point defined in @code{x=0}, the filter will automatically
  3664. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  3665. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  3666. The filter accepts the following options:
  3667. @table @option
  3668. @item preset
  3669. Select one of the available color presets. This option can be used in addition
  3670. to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
  3671. options takes priority on the preset values.
  3672. Available presets are:
  3673. @table @samp
  3674. @item none
  3675. @item color_negative
  3676. @item cross_process
  3677. @item darker
  3678. @item increase_contrast
  3679. @item lighter
  3680. @item linear_contrast
  3681. @item medium_contrast
  3682. @item negative
  3683. @item strong_contrast
  3684. @item vintage
  3685. @end table
  3686. Default is @code{none}.
  3687. @item master, m
  3688. Set the master key points. These points will define a second pass mapping. It
  3689. is sometimes called a "luminance" or "value" mapping. It can be used with
  3690. @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
  3691. post-processing LUT.
  3692. @item red, r
  3693. Set the key points for the red component.
  3694. @item green, g
  3695. Set the key points for the green component.
  3696. @item blue, b
  3697. Set the key points for the blue component.
  3698. @item all
  3699. Set the key points for all components (not including master).
  3700. Can be used in addition to the other key points component
  3701. options. In this case, the unset component(s) will fallback on this
  3702. @option{all} setting.
  3703. @item psfile
  3704. Specify a Photoshop curves file (@code{.acv}) to import the settings from.
  3705. @end table
  3706. To avoid some filtergraph syntax conflicts, each key points list need to be
  3707. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  3708. @subsection Examples
  3709. @itemize
  3710. @item
  3711. Increase slightly the middle level of blue:
  3712. @example
  3713. curves=blue='0.5/0.58'
  3714. @end example
  3715. @item
  3716. Vintage effect:
  3717. @example
  3718. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  3719. @end example
  3720. Here we obtain the following coordinates for each components:
  3721. @table @var
  3722. @item red
  3723. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  3724. @item green
  3725. @code{(0;0) (0.50;0.48) (1;1)}
  3726. @item blue
  3727. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  3728. @end table
  3729. @item
  3730. The previous example can also be achieved with the associated built-in preset:
  3731. @example
  3732. curves=preset=vintage
  3733. @end example
  3734. @item
  3735. Or simply:
  3736. @example
  3737. curves=vintage
  3738. @end example
  3739. @item
  3740. Use a Photoshop preset and redefine the points of the green component:
  3741. @example
  3742. curves=psfile='MyCurvesPresets/purple.acv':green='0.45/0.53'
  3743. @end example
  3744. @end itemize
  3745. @section dctdnoiz
  3746. Denoise frames using 2D DCT (frequency domain filtering).
  3747. This filter is not designed for real time.
  3748. The filter accepts the following options:
  3749. @table @option
  3750. @item sigma, s
  3751. Set the noise sigma constant.
  3752. This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
  3753. coefficient (absolute value) below this threshold with be dropped.
  3754. If you need a more advanced filtering, see @option{expr}.
  3755. Default is @code{0}.
  3756. @item overlap
  3757. Set number overlapping pixels for each block. Since the filter can be slow, you
  3758. may want to reduce this value, at the cost of a less effective filter and the
  3759. risk of various artefacts.
  3760. If the overlapping value doesn't permit processing the whole input width or
  3761. height, a warning will be displayed and according borders won't be denoised.
  3762. Default value is @var{blocksize}-1, which is the best possible setting.
  3763. @item expr, e
  3764. Set the coefficient factor expression.
  3765. For each coefficient of a DCT block, this expression will be evaluated as a
  3766. multiplier value for the coefficient.
  3767. If this is option is set, the @option{sigma} option will be ignored.
  3768. The absolute value of the coefficient can be accessed through the @var{c}
  3769. variable.
  3770. @item n
  3771. Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
  3772. @var{blocksize}, which is the width and height of the processed blocks.
  3773. The default value is @var{3} (8x8) and can be raised to @var{4} for a
  3774. @var{blocksize} of 16x16. Note that changing this setting has huge consequences
  3775. on the speed processing. Also, a larger block size does not necessarily means a
  3776. better de-noising.
  3777. @end table
  3778. @subsection Examples
  3779. Apply a denoise with a @option{sigma} of @code{4.5}:
  3780. @example
  3781. dctdnoiz=4.5
  3782. @end example
  3783. The same operation can be achieved using the expression system:
  3784. @example
  3785. dctdnoiz=e='gte(c, 4.5*3)'
  3786. @end example
  3787. Violent denoise using a block size of @code{16x16}:
  3788. @example
  3789. dctdnoiz=15:n=4
  3790. @end example
  3791. @section deband
  3792. Remove banding artifacts from input video.
  3793. It works by replacing banded pixels with average value of referenced pixels.
  3794. The filter accepts the following options:
  3795. @table @option
  3796. @item 1thr
  3797. @item 2thr
  3798. @item 3thr
  3799. @item 4thr
  3800. Set banding detection threshold for each plane. Default is 0.02.
  3801. Valid range is 0.00003 to 0.5.
  3802. If difference between current pixel and reference pixel is less than threshold,
  3803. it will be considered as banded.
  3804. @item range, r
  3805. Banding detection range in pixels. Default is 16. If positive, random number
  3806. in range 0 to set value will be used. If negative, exact absolute value
  3807. will be used.
  3808. The range defines square of four pixels around current pixel.
  3809. @item direction, d
  3810. Set direction in radians from which four pixel will be compared. If positive,
  3811. random direction from 0 to set direction will be picked. If negative, exact of
  3812. absolute value will be picked. For example direction 0, -PI or -2*PI radians
  3813. will pick only pixels on same row and -PI/2 will pick only pixels on same
  3814. column.
  3815. @item blur
  3816. If enabled, current pixel is compared with average value of all four
  3817. surrounding pixels. The default is enabled. If disabled current pixel is
  3818. compared with all four surrounding pixels. The pixel is considered banded
  3819. if only all four differences with surrounding pixels are less than threshold.
  3820. @end table
  3821. @anchor{decimate}
  3822. @section decimate
  3823. Drop duplicated frames at regular intervals.
  3824. The filter accepts the following options:
  3825. @table @option
  3826. @item cycle
  3827. Set the number of frames from which one will be dropped. Setting this to
  3828. @var{N} means one frame in every batch of @var{N} frames will be dropped.
  3829. Default is @code{5}.
  3830. @item dupthresh
  3831. Set the threshold for duplicate detection. If the difference metric for a frame
  3832. is less than or equal to this value, then it is declared as duplicate. Default
  3833. is @code{1.1}
  3834. @item scthresh
  3835. Set scene change threshold. Default is @code{15}.
  3836. @item blockx
  3837. @item blocky
  3838. Set the size of the x and y-axis blocks used during metric calculations.
  3839. Larger blocks give better noise suppression, but also give worse detection of
  3840. small movements. Must be a power of two. Default is @code{32}.
  3841. @item ppsrc
  3842. Mark main input as a pre-processed input and activate clean source input
  3843. stream. This allows the input to be pre-processed with various filters to help
  3844. the metrics calculation while keeping the frame selection lossless. When set to
  3845. @code{1}, the first stream is for the pre-processed input, and the second
  3846. stream is the clean source from where the kept frames are chosen. Default is
  3847. @code{0}.
  3848. @item chroma
  3849. Set whether or not chroma is considered in the metric calculations. Default is
  3850. @code{1}.
  3851. @end table
  3852. @section deflate
  3853. Apply deflate effect to the video.
  3854. This filter replaces the pixel by the local(3x3) average by taking into account
  3855. only values lower than the pixel.
  3856. It accepts the following options:
  3857. @table @option
  3858. @item threshold0
  3859. @item threshold1
  3860. @item threshold2
  3861. @item threshold3
  3862. Limit the maximum change for each plane, default is 65535.
  3863. If 0, plane will remain unchanged.
  3864. @end table
  3865. @section dejudder
  3866. Remove judder produced by partially interlaced telecined content.
  3867. Judder can be introduced, for instance, by @ref{pullup} filter. If the original
  3868. source was partially telecined content then the output of @code{pullup,dejudder}
  3869. will have a variable frame rate. May change the recorded frame rate of the
  3870. container. Aside from that change, this filter will not affect constant frame
  3871. rate video.
  3872. The option available in this filter is:
  3873. @table @option
  3874. @item cycle
  3875. Specify the length of the window over which the judder repeats.
  3876. Accepts any integer greater than 1. Useful values are:
  3877. @table @samp
  3878. @item 4
  3879. If the original was telecined from 24 to 30 fps (Film to NTSC).
  3880. @item 5
  3881. If the original was telecined from 25 to 30 fps (PAL to NTSC).
  3882. @item 20
  3883. If a mixture of the two.
  3884. @end table
  3885. The default is @samp{4}.
  3886. @end table
  3887. @section delogo
  3888. Suppress a TV station logo by a simple interpolation of the surrounding
  3889. pixels. Just set a rectangle covering the logo and watch it disappear
  3890. (and sometimes something even uglier appear - your mileage may vary).
  3891. It accepts the following parameters:
  3892. @table @option
  3893. @item x
  3894. @item y
  3895. Specify the top left corner coordinates of the logo. They must be
  3896. specified.
  3897. @item w
  3898. @item h
  3899. Specify the width and height of the logo to clear. They must be
  3900. specified.
  3901. @item band, t
  3902. Specify the thickness of the fuzzy edge of the rectangle (added to
  3903. @var{w} and @var{h}). The default value is 1. This option is
  3904. deprecated, setting higher values should no longer be necessary and
  3905. is not recommended.
  3906. @item show
  3907. When set to 1, a green rectangle is drawn on the screen to simplify
  3908. finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
  3909. The default value is 0.
  3910. The rectangle is drawn on the outermost pixels which will be (partly)
  3911. replaced with interpolated values. The values of the next pixels
  3912. immediately outside this rectangle in each direction will be used to
  3913. compute the interpolated pixel values inside the rectangle.
  3914. @end table
  3915. @subsection Examples
  3916. @itemize
  3917. @item
  3918. Set a rectangle covering the area with top left corner coordinates 0,0
  3919. and size 100x77, and a band of size 10:
  3920. @example
  3921. delogo=x=0:y=0:w=100:h=77:band=10
  3922. @end example
  3923. @end itemize
  3924. @section deshake
  3925. Attempt to fix small changes in horizontal and/or vertical shift. This
  3926. filter helps remove camera shake from hand-holding a camera, bumping a
  3927. tripod, moving on a vehicle, etc.
  3928. The filter accepts the following options:
  3929. @table @option
  3930. @item x
  3931. @item y
  3932. @item w
  3933. @item h
  3934. Specify a rectangular area where to limit the search for motion
  3935. vectors.
  3936. If desired the search for motion vectors can be limited to a
  3937. rectangular area of the frame defined by its top left corner, width
  3938. and height. These parameters have the same meaning as the drawbox
  3939. filter which can be used to visualise the position of the bounding
  3940. box.
  3941. This is useful when simultaneous movement of subjects within the frame
  3942. might be confused for camera motion by the motion vector search.
  3943. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  3944. then the full frame is used. This allows later options to be set
  3945. without specifying the bounding box for the motion vector search.
  3946. Default - search the whole frame.
  3947. @item rx
  3948. @item ry
  3949. Specify the maximum extent of movement in x and y directions in the
  3950. range 0-64 pixels. Default 16.
  3951. @item edge
  3952. Specify how to generate pixels to fill blanks at the edge of the
  3953. frame. Available values are:
  3954. @table @samp
  3955. @item blank, 0
  3956. Fill zeroes at blank locations
  3957. @item original, 1
  3958. Original image at blank locations
  3959. @item clamp, 2
  3960. Extruded edge value at blank locations
  3961. @item mirror, 3
  3962. Mirrored edge at blank locations
  3963. @end table
  3964. Default value is @samp{mirror}.
  3965. @item blocksize
  3966. Specify the blocksize to use for motion search. Range 4-128 pixels,
  3967. default 8.
  3968. @item contrast
  3969. Specify the contrast threshold for blocks. Only blocks with more than
  3970. the specified contrast (difference between darkest and lightest
  3971. pixels) will be considered. Range 1-255, default 125.
  3972. @item search
  3973. Specify the search strategy. Available values are:
  3974. @table @samp
  3975. @item exhaustive, 0
  3976. Set exhaustive search
  3977. @item less, 1
  3978. Set less exhaustive search.
  3979. @end table
  3980. Default value is @samp{exhaustive}.
  3981. @item filename
  3982. If set then a detailed log of the motion search is written to the
  3983. specified file.
  3984. @item opencl
  3985. If set to 1, specify using OpenCL capabilities, only available if
  3986. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  3987. @end table
  3988. @section detelecine
  3989. Apply an exact inverse of the telecine operation. It requires a predefined
  3990. pattern specified using the pattern option which must be the same as that passed
  3991. to the telecine filter.
  3992. This filter accepts the following options:
  3993. @table @option
  3994. @item first_field
  3995. @table @samp
  3996. @item top, t
  3997. top field first
  3998. @item bottom, b
  3999. bottom field first
  4000. The default value is @code{top}.
  4001. @end table
  4002. @item pattern
  4003. A string of numbers representing the pulldown pattern you wish to apply.
  4004. The default value is @code{23}.
  4005. @item start_frame
  4006. A number representing position of the first frame with respect to the telecine
  4007. pattern. This is to be used if the stream is cut. The default value is @code{0}.
  4008. @end table
  4009. @section dilation
  4010. Apply dilation effect to the video.
  4011. This filter replaces the pixel by the local(3x3) maximum.
  4012. It accepts the following options:
  4013. @table @option
  4014. @item threshold0
  4015. @item threshold1
  4016. @item threshold2
  4017. @item threshold3
  4018. Limit the maximum change for each plane, default is 65535.
  4019. If 0, plane will remain unchanged.
  4020. @item coordinates
  4021. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  4022. pixels are used.
  4023. Flags to local 3x3 coordinates maps like this:
  4024. 1 2 3
  4025. 4 5
  4026. 6 7 8
  4027. @end table
  4028. @section displace
  4029. Displace pixels as indicated by second and third input stream.
  4030. It takes three input streams and outputs one stream, the first input is the
  4031. source, and second and third input are displacement maps.
  4032. The second input specifies how much to displace pixels along the
  4033. x-axis, while the third input specifies how much to displace pixels
  4034. along the y-axis.
  4035. If one of displacement map streams terminates, last frame from that
  4036. displacement map will be used.
  4037. Note that once generated, displacements maps can be reused over and over again.
  4038. A description of the accepted options follows.
  4039. @table @option
  4040. @item edge
  4041. Set displace behavior for pixels that are out of range.
  4042. Available values are:
  4043. @table @samp
  4044. @item blank
  4045. Missing pixels are replaced by black pixels.
  4046. @item smear
  4047. Adjacent pixels will spread out to replace missing pixels.
  4048. @item wrap
  4049. Out of range pixels are wrapped so they point to pixels of other side.
  4050. @end table
  4051. Default is @samp{smear}.
  4052. @end table
  4053. @subsection Examples
  4054. @itemize
  4055. @item
  4056. Add ripple effect to rgb input of video size hd720:
  4057. @example
  4058. 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
  4059. @end example
  4060. @item
  4061. Add wave effect to rgb input of video size hd720:
  4062. @example
  4063. 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
  4064. @end example
  4065. @end itemize
  4066. @section drawbox
  4067. Draw a colored box on the input image.
  4068. It accepts the following parameters:
  4069. @table @option
  4070. @item x
  4071. @item y
  4072. The expressions which specify the top left corner coordinates of the box. It defaults to 0.
  4073. @item width, w
  4074. @item height, h
  4075. The expressions which specify the width and height of the box; if 0 they are interpreted as
  4076. the input width and height. It defaults to 0.
  4077. @item color, c
  4078. Specify the color of the box to write. For the general syntax of this option,
  4079. check the "Color" section in the ffmpeg-utils manual. If the special
  4080. value @code{invert} is used, the box edge color is the same as the
  4081. video with inverted luma.
  4082. @item thickness, t
  4083. The expression which sets the thickness of the box edge. Default value is @code{3}.
  4084. See below for the list of accepted constants.
  4085. @end table
  4086. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  4087. following constants:
  4088. @table @option
  4089. @item dar
  4090. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  4091. @item hsub
  4092. @item vsub
  4093. horizontal and vertical chroma subsample values. For example for the
  4094. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4095. @item in_h, ih
  4096. @item in_w, iw
  4097. The input width and height.
  4098. @item sar
  4099. The input sample aspect ratio.
  4100. @item x
  4101. @item y
  4102. The x and y offset coordinates where the box is drawn.
  4103. @item w
  4104. @item h
  4105. The width and height of the drawn box.
  4106. @item t
  4107. The thickness of the drawn box.
  4108. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  4109. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  4110. @end table
  4111. @subsection Examples
  4112. @itemize
  4113. @item
  4114. Draw a black box around the edge of the input image:
  4115. @example
  4116. drawbox
  4117. @end example
  4118. @item
  4119. Draw a box with color red and an opacity of 50%:
  4120. @example
  4121. drawbox=10:20:200:60:red@@0.5
  4122. @end example
  4123. The previous example can be specified as:
  4124. @example
  4125. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  4126. @end example
  4127. @item
  4128. Fill the box with pink color:
  4129. @example
  4130. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  4131. @end example
  4132. @item
  4133. Draw a 2-pixel red 2.40:1 mask:
  4134. @example
  4135. 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
  4136. @end example
  4137. @end itemize
  4138. @section drawgraph, adrawgraph
  4139. Draw a graph using input video or audio metadata.
  4140. It accepts the following parameters:
  4141. @table @option
  4142. @item m1
  4143. Set 1st frame metadata key from which metadata values will be used to draw a graph.
  4144. @item fg1
  4145. Set 1st foreground color expression.
  4146. @item m2
  4147. Set 2nd frame metadata key from which metadata values will be used to draw a graph.
  4148. @item fg2
  4149. Set 2nd foreground color expression.
  4150. @item m3
  4151. Set 3rd frame metadata key from which metadata values will be used to draw a graph.
  4152. @item fg3
  4153. Set 3rd foreground color expression.
  4154. @item m4
  4155. Set 4th frame metadata key from which metadata values will be used to draw a graph.
  4156. @item fg4
  4157. Set 4th foreground color expression.
  4158. @item min
  4159. Set minimal value of metadata value.
  4160. @item max
  4161. Set maximal value of metadata value.
  4162. @item bg
  4163. Set graph background color. Default is white.
  4164. @item mode
  4165. Set graph mode.
  4166. Available values for mode is:
  4167. @table @samp
  4168. @item bar
  4169. @item dot
  4170. @item line
  4171. @end table
  4172. Default is @code{line}.
  4173. @item slide
  4174. Set slide mode.
  4175. Available values for slide is:
  4176. @table @samp
  4177. @item frame
  4178. Draw new frame when right border is reached.
  4179. @item replace
  4180. Replace old columns with new ones.
  4181. @item scroll
  4182. Scroll from right to left.
  4183. @item rscroll
  4184. Scroll from left to right.
  4185. @end table
  4186. Default is @code{frame}.
  4187. @item size
  4188. Set size of graph video. For the syntax of this option, check the
  4189. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  4190. The default value is @code{900x256}.
  4191. The foreground color expressions can use the following variables:
  4192. @table @option
  4193. @item MIN
  4194. Minimal value of metadata value.
  4195. @item MAX
  4196. Maximal value of metadata value.
  4197. @item VAL
  4198. Current metadata key value.
  4199. @end table
  4200. The color is defined as 0xAABBGGRR.
  4201. @end table
  4202. Example using metadata from @ref{signalstats} filter:
  4203. @example
  4204. signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255
  4205. @end example
  4206. Example using metadata from @ref{ebur128} filter:
  4207. @example
  4208. ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5
  4209. @end example
  4210. @section drawgrid
  4211. Draw a grid on the input image.
  4212. It accepts the following parameters:
  4213. @table @option
  4214. @item x
  4215. @item y
  4216. The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
  4217. @item width, w
  4218. @item height, h
  4219. The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
  4220. input width and height, respectively, minus @code{thickness}, so image gets
  4221. framed. Default to 0.
  4222. @item color, c
  4223. Specify the color of the grid. For the general syntax of this option,
  4224. check the "Color" section in the ffmpeg-utils manual. If the special
  4225. value @code{invert} is used, the grid color is the same as the
  4226. video with inverted luma.
  4227. @item thickness, t
  4228. The expression which sets the thickness of the grid line. Default value is @code{1}.
  4229. See below for the list of accepted constants.
  4230. @end table
  4231. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  4232. following constants:
  4233. @table @option
  4234. @item dar
  4235. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  4236. @item hsub
  4237. @item vsub
  4238. horizontal and vertical chroma subsample values. For example for the
  4239. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4240. @item in_h, ih
  4241. @item in_w, iw
  4242. The input grid cell width and height.
  4243. @item sar
  4244. The input sample aspect ratio.
  4245. @item x
  4246. @item y
  4247. The x and y coordinates of some point of grid intersection (meant to configure offset).
  4248. @item w
  4249. @item h
  4250. The width and height of the drawn cell.
  4251. @item t
  4252. The thickness of the drawn cell.
  4253. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  4254. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  4255. @end table
  4256. @subsection Examples
  4257. @itemize
  4258. @item
  4259. Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
  4260. @example
  4261. drawgrid=width=100:height=100:thickness=2:color=red@@0.5
  4262. @end example
  4263. @item
  4264. Draw a white 3x3 grid with an opacity of 50%:
  4265. @example
  4266. drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
  4267. @end example
  4268. @end itemize
  4269. @anchor{drawtext}
  4270. @section drawtext
  4271. Draw a text string or text from a specified file on top of a video, using the
  4272. libfreetype library.
  4273. To enable compilation of this filter, you need to configure FFmpeg with
  4274. @code{--enable-libfreetype}.
  4275. To enable default font fallback and the @var{font} option you need to
  4276. configure FFmpeg with @code{--enable-libfontconfig}.
  4277. To enable the @var{text_shaping} option, you need to configure FFmpeg with
  4278. @code{--enable-libfribidi}.
  4279. @subsection Syntax
  4280. It accepts the following parameters:
  4281. @table @option
  4282. @item box
  4283. Used to draw a box around text using the background color.
  4284. The value must be either 1 (enable) or 0 (disable).
  4285. The default value of @var{box} is 0.
  4286. @item boxborderw
  4287. Set the width of the border to be drawn around the box using @var{boxcolor}.
  4288. The default value of @var{boxborderw} is 0.
  4289. @item boxcolor
  4290. The color to be used for drawing box around text. For the syntax of this
  4291. option, check the "Color" section in the ffmpeg-utils manual.
  4292. The default value of @var{boxcolor} is "white".
  4293. @item borderw
  4294. Set the width of the border to be drawn around the text using @var{bordercolor}.
  4295. The default value of @var{borderw} is 0.
  4296. @item bordercolor
  4297. Set the color to be used for drawing border around text. For the syntax of this
  4298. option, check the "Color" section in the ffmpeg-utils manual.
  4299. The default value of @var{bordercolor} is "black".
  4300. @item expansion
  4301. Select how the @var{text} is expanded. Can be either @code{none},
  4302. @code{strftime} (deprecated) or
  4303. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  4304. below for details.
  4305. @item fix_bounds
  4306. If true, check and fix text coords to avoid clipping.
  4307. @item fontcolor
  4308. The color to be used for drawing fonts. For the syntax of this option, check
  4309. the "Color" section in the ffmpeg-utils manual.
  4310. The default value of @var{fontcolor} is "black".
  4311. @item fontcolor_expr
  4312. String which is expanded the same way as @var{text} to obtain dynamic
  4313. @var{fontcolor} value. By default this option has empty value and is not
  4314. processed. When this option is set, it overrides @var{fontcolor} option.
  4315. @item font
  4316. The font family to be used for drawing text. By default Sans.
  4317. @item fontfile
  4318. The font file to be used for drawing text. The path must be included.
  4319. This parameter is mandatory if the fontconfig support is disabled.
  4320. @item draw
  4321. This option does not exist, please see the timeline system
  4322. @item alpha
  4323. Draw the text applying alpha blending. The value can
  4324. be either a number between 0.0 and 1.0
  4325. The expression accepts the same variables @var{x, y} do.
  4326. The default value is 1.
  4327. Please see fontcolor_expr
  4328. @item fontsize
  4329. The font size to be used for drawing text.
  4330. The default value of @var{fontsize} is 16.
  4331. @item text_shaping
  4332. If set to 1, attempt to shape the text (for example, reverse the order of
  4333. right-to-left text and join Arabic characters) before drawing it.
  4334. Otherwise, just draw the text exactly as given.
  4335. By default 1 (if supported).
  4336. @item ft_load_flags
  4337. The flags to be used for loading the fonts.
  4338. The flags map the corresponding flags supported by libfreetype, and are
  4339. a combination of the following values:
  4340. @table @var
  4341. @item default
  4342. @item no_scale
  4343. @item no_hinting
  4344. @item render
  4345. @item no_bitmap
  4346. @item vertical_layout
  4347. @item force_autohint
  4348. @item crop_bitmap
  4349. @item pedantic
  4350. @item ignore_global_advance_width
  4351. @item no_recurse
  4352. @item ignore_transform
  4353. @item monochrome
  4354. @item linear_design
  4355. @item no_autohint
  4356. @end table
  4357. Default value is "default".
  4358. For more information consult the documentation for the FT_LOAD_*
  4359. libfreetype flags.
  4360. @item shadowcolor
  4361. The color to be used for drawing a shadow behind the drawn text. For the
  4362. syntax of this option, check the "Color" section in the ffmpeg-utils manual.
  4363. The default value of @var{shadowcolor} is "black".
  4364. @item shadowx
  4365. @item shadowy
  4366. The x and y offsets for the text shadow position with respect to the
  4367. position of the text. They can be either positive or negative
  4368. values. The default value for both is "0".
  4369. @item start_number
  4370. The starting frame number for the n/frame_num variable. The default value
  4371. is "0".
  4372. @item tabsize
  4373. The size in number of spaces to use for rendering the tab.
  4374. Default value is 4.
  4375. @item timecode
  4376. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  4377. format. It can be used with or without text parameter. @var{timecode_rate}
  4378. option must be specified.
  4379. @item timecode_rate, rate, r
  4380. Set the timecode frame rate (timecode only).
  4381. @item text
  4382. The text string to be drawn. The text must be a sequence of UTF-8
  4383. encoded characters.
  4384. This parameter is mandatory if no file is specified with the parameter
  4385. @var{textfile}.
  4386. @item textfile
  4387. A text file containing text to be drawn. The text must be a sequence
  4388. of UTF-8 encoded characters.
  4389. This parameter is mandatory if no text string is specified with the
  4390. parameter @var{text}.
  4391. If both @var{text} and @var{textfile} are specified, an error is thrown.
  4392. @item reload
  4393. If set to 1, the @var{textfile} will be reloaded before each frame.
  4394. Be sure to update it atomically, or it may be read partially, or even fail.
  4395. @item x
  4396. @item y
  4397. The expressions which specify the offsets where text will be drawn
  4398. within the video frame. They are relative to the top/left border of the
  4399. output image.
  4400. The default value of @var{x} and @var{y} is "0".
  4401. See below for the list of accepted constants and functions.
  4402. @end table
  4403. The parameters for @var{x} and @var{y} are expressions containing the
  4404. following constants and functions:
  4405. @table @option
  4406. @item dar
  4407. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  4408. @item hsub
  4409. @item vsub
  4410. horizontal and vertical chroma subsample values. For example for the
  4411. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4412. @item line_h, lh
  4413. the height of each text line
  4414. @item main_h, h, H
  4415. the input height
  4416. @item main_w, w, W
  4417. the input width
  4418. @item max_glyph_a, ascent
  4419. the maximum distance from the baseline to the highest/upper grid
  4420. coordinate used to place a glyph outline point, for all the rendered
  4421. glyphs.
  4422. It is a positive value, due to the grid's orientation with the Y axis
  4423. upwards.
  4424. @item max_glyph_d, descent
  4425. the maximum distance from the baseline to the lowest grid coordinate
  4426. used to place a glyph outline point, for all the rendered glyphs.
  4427. This is a negative value, due to the grid's orientation, with the Y axis
  4428. upwards.
  4429. @item max_glyph_h
  4430. maximum glyph height, that is the maximum height for all the glyphs
  4431. contained in the rendered text, it is equivalent to @var{ascent} -
  4432. @var{descent}.
  4433. @item max_glyph_w
  4434. maximum glyph width, that is the maximum width for all the glyphs
  4435. contained in the rendered text
  4436. @item n
  4437. the number of input frame, starting from 0
  4438. @item rand(min, max)
  4439. return a random number included between @var{min} and @var{max}
  4440. @item sar
  4441. The input sample aspect ratio.
  4442. @item t
  4443. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4444. @item text_h, th
  4445. the height of the rendered text
  4446. @item text_w, tw
  4447. the width of the rendered text
  4448. @item x
  4449. @item y
  4450. the x and y offset coordinates where the text is drawn.
  4451. These parameters allow the @var{x} and @var{y} expressions to refer
  4452. each other, so you can for example specify @code{y=x/dar}.
  4453. @end table
  4454. @anchor{drawtext_expansion}
  4455. @subsection Text expansion
  4456. If @option{expansion} is set to @code{strftime},
  4457. the filter recognizes strftime() sequences in the provided text and
  4458. expands them accordingly. Check the documentation of strftime(). This
  4459. feature is deprecated.
  4460. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  4461. If @option{expansion} is set to @code{normal} (which is the default),
  4462. the following expansion mechanism is used.
  4463. The backslash character @samp{\}, followed by any character, always expands to
  4464. the second character.
  4465. Sequence of the form @code{%@{...@}} are expanded. The text between the
  4466. braces is a function name, possibly followed by arguments separated by ':'.
  4467. If the arguments contain special characters or delimiters (':' or '@}'),
  4468. they should be escaped.
  4469. Note that they probably must also be escaped as the value for the
  4470. @option{text} option in the filter argument string and as the filter
  4471. argument in the filtergraph description, and possibly also for the shell,
  4472. that makes up to four levels of escaping; using a text file avoids these
  4473. problems.
  4474. The following functions are available:
  4475. @table @command
  4476. @item expr, e
  4477. The expression evaluation result.
  4478. It must take one argument specifying the expression to be evaluated,
  4479. which accepts the same constants and functions as the @var{x} and
  4480. @var{y} values. Note that not all constants should be used, for
  4481. example the text size is not known when evaluating the expression, so
  4482. the constants @var{text_w} and @var{text_h} will have an undefined
  4483. value.
  4484. @item expr_int_format, eif
  4485. Evaluate the expression's value and output as formatted integer.
  4486. The first argument is the expression to be evaluated, just as for the @var{expr} function.
  4487. The second argument specifies the output format. Allowed values are @samp{x},
  4488. @samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
  4489. @code{printf} function.
  4490. The third parameter is optional and sets the number of positions taken by the output.
  4491. It can be used to add padding with zeros from the left.
  4492. @item gmtime
  4493. The time at which the filter is running, expressed in UTC.
  4494. It can accept an argument: a strftime() format string.
  4495. @item localtime
  4496. The time at which the filter is running, expressed in the local time zone.
  4497. It can accept an argument: a strftime() format string.
  4498. @item metadata
  4499. Frame metadata. It must take one argument specifying metadata key.
  4500. @item n, frame_num
  4501. The frame number, starting from 0.
  4502. @item pict_type
  4503. A 1 character description of the current picture type.
  4504. @item pts
  4505. The timestamp of the current frame.
  4506. It can take up to three arguments.
  4507. The first argument is the format of the timestamp; it defaults to @code{flt}
  4508. for seconds as a decimal number with microsecond accuracy; @code{hms} stands
  4509. for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
  4510. @code{gmtime} stands for the timestamp of the frame formatted as UTC time;
  4511. @code{localtime} stands for the timestamp of the frame formatted as
  4512. local time zone time.
  4513. The second argument is an offset added to the timestamp.
  4514. If the format is set to @code{localtime} or @code{gmtime},
  4515. a third argument may be supplied: a strftime() format string.
  4516. By default, @var{YYYY-MM-DD HH:MM:SS} format will be used.
  4517. @end table
  4518. @subsection Examples
  4519. @itemize
  4520. @item
  4521. Draw "Test Text" with font FreeSerif, using the default values for the
  4522. optional parameters.
  4523. @example
  4524. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  4525. @end example
  4526. @item
  4527. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  4528. and y=50 (counting from the top-left corner of the screen), text is
  4529. yellow with a red box around it. Both the text and the box have an
  4530. opacity of 20%.
  4531. @example
  4532. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  4533. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  4534. @end example
  4535. Note that the double quotes are not necessary if spaces are not used
  4536. within the parameter list.
  4537. @item
  4538. Show the text at the center of the video frame:
  4539. @example
  4540. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2"
  4541. @end example
  4542. @item
  4543. Show a text line sliding from right to left in the last row of the video
  4544. frame. The file @file{LONG_LINE} is assumed to contain a single line
  4545. with no newlines.
  4546. @example
  4547. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  4548. @end example
  4549. @item
  4550. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  4551. @example
  4552. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  4553. @end example
  4554. @item
  4555. Draw a single green letter "g", at the center of the input video.
  4556. The glyph baseline is placed at half screen height.
  4557. @example
  4558. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  4559. @end example
  4560. @item
  4561. Show text for 1 second every 3 seconds:
  4562. @example
  4563. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  4564. @end example
  4565. @item
  4566. Use fontconfig to set the font. Note that the colons need to be escaped.
  4567. @example
  4568. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  4569. @end example
  4570. @item
  4571. Print the date of a real-time encoding (see strftime(3)):
  4572. @example
  4573. drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
  4574. @end example
  4575. @item
  4576. Show text fading in and out (appearing/disappearing):
  4577. @example
  4578. #!/bin/sh
  4579. DS=1.0 # display start
  4580. DE=10.0 # display end
  4581. FID=1.5 # fade in duration
  4582. FOD=5 # fade out duration
  4583. 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 @}"
  4584. @end example
  4585. @end itemize
  4586. For more information about libfreetype, check:
  4587. @url{http://www.freetype.org/}.
  4588. For more information about fontconfig, check:
  4589. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  4590. For more information about libfribidi, check:
  4591. @url{http://fribidi.org/}.
  4592. @section edgedetect
  4593. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  4594. The filter accepts the following options:
  4595. @table @option
  4596. @item low
  4597. @item high
  4598. Set low and high threshold values used by the Canny thresholding
  4599. algorithm.
  4600. The high threshold selects the "strong" edge pixels, which are then
  4601. connected through 8-connectivity with the "weak" edge pixels selected
  4602. by the low threshold.
  4603. @var{low} and @var{high} threshold values must be chosen in the range
  4604. [0,1], and @var{low} should be lesser or equal to @var{high}.
  4605. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  4606. is @code{50/255}.
  4607. @item mode
  4608. Define the drawing mode.
  4609. @table @samp
  4610. @item wires
  4611. Draw white/gray wires on black background.
  4612. @item colormix
  4613. Mix the colors to create a paint/cartoon effect.
  4614. @end table
  4615. Default value is @var{wires}.
  4616. @end table
  4617. @subsection Examples
  4618. @itemize
  4619. @item
  4620. Standard edge detection with custom values for the hysteresis thresholding:
  4621. @example
  4622. edgedetect=low=0.1:high=0.4
  4623. @end example
  4624. @item
  4625. Painting effect without thresholding:
  4626. @example
  4627. edgedetect=mode=colormix:high=0
  4628. @end example
  4629. @end itemize
  4630. @section eq
  4631. Set brightness, contrast, saturation and approximate gamma adjustment.
  4632. The filter accepts the following options:
  4633. @table @option
  4634. @item contrast
  4635. Set the contrast expression. The value must be a float value in range
  4636. @code{-2.0} to @code{2.0}. The default value is "1".
  4637. @item brightness
  4638. Set the brightness expression. The value must be a float value in
  4639. range @code{-1.0} to @code{1.0}. The default value is "0".
  4640. @item saturation
  4641. Set the saturation expression. The value must be a float in
  4642. range @code{0.0} to @code{3.0}. The default value is "1".
  4643. @item gamma
  4644. Set the gamma expression. The value must be a float in range
  4645. @code{0.1} to @code{10.0}. The default value is "1".
  4646. @item gamma_r
  4647. Set the gamma expression for red. The value must be a float in
  4648. range @code{0.1} to @code{10.0}. The default value is "1".
  4649. @item gamma_g
  4650. Set the gamma expression for green. The value must be a float in range
  4651. @code{0.1} to @code{10.0}. The default value is "1".
  4652. @item gamma_b
  4653. Set the gamma expression for blue. The value must be a float in range
  4654. @code{0.1} to @code{10.0}. The default value is "1".
  4655. @item gamma_weight
  4656. Set the gamma weight expression. It can be used to reduce the effect
  4657. of a high gamma value on bright image areas, e.g. keep them from
  4658. getting overamplified and just plain white. The value must be a float
  4659. in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
  4660. gamma correction all the way down while @code{1.0} leaves it at its
  4661. full strength. Default is "1".
  4662. @item eval
  4663. Set when the expressions for brightness, contrast, saturation and
  4664. gamma expressions are evaluated.
  4665. It accepts the following values:
  4666. @table @samp
  4667. @item init
  4668. only evaluate expressions once during the filter initialization or
  4669. when a command is processed
  4670. @item frame
  4671. evaluate expressions for each incoming frame
  4672. @end table
  4673. Default value is @samp{init}.
  4674. @end table
  4675. The expressions accept the following parameters:
  4676. @table @option
  4677. @item n
  4678. frame count of the input frame starting from 0
  4679. @item pos
  4680. byte position of the corresponding packet in the input file, NAN if
  4681. unspecified
  4682. @item r
  4683. frame rate of the input video, NAN if the input frame rate is unknown
  4684. @item t
  4685. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4686. @end table
  4687. @subsection Commands
  4688. The filter supports the following commands:
  4689. @table @option
  4690. @item contrast
  4691. Set the contrast expression.
  4692. @item brightness
  4693. Set the brightness expression.
  4694. @item saturation
  4695. Set the saturation expression.
  4696. @item gamma
  4697. Set the gamma expression.
  4698. @item gamma_r
  4699. Set the gamma_r expression.
  4700. @item gamma_g
  4701. Set gamma_g expression.
  4702. @item gamma_b
  4703. Set gamma_b expression.
  4704. @item gamma_weight
  4705. Set gamma_weight expression.
  4706. The command accepts the same syntax of the corresponding option.
  4707. If the specified expression is not valid, it is kept at its current
  4708. value.
  4709. @end table
  4710. @section erosion
  4711. Apply erosion effect to the video.
  4712. This filter replaces the pixel by the local(3x3) minimum.
  4713. It accepts the following options:
  4714. @table @option
  4715. @item threshold0
  4716. @item threshold1
  4717. @item threshold2
  4718. @item threshold3
  4719. Limit the maximum change for each plane, default is 65535.
  4720. If 0, plane will remain unchanged.
  4721. @item coordinates
  4722. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  4723. pixels are used.
  4724. Flags to local 3x3 coordinates maps like this:
  4725. 1 2 3
  4726. 4 5
  4727. 6 7 8
  4728. @end table
  4729. @section extractplanes
  4730. Extract color channel components from input video stream into
  4731. separate grayscale video streams.
  4732. The filter accepts the following option:
  4733. @table @option
  4734. @item planes
  4735. Set plane(s) to extract.
  4736. Available values for planes are:
  4737. @table @samp
  4738. @item y
  4739. @item u
  4740. @item v
  4741. @item a
  4742. @item r
  4743. @item g
  4744. @item b
  4745. @end table
  4746. Choosing planes not available in the input will result in an error.
  4747. That means you cannot select @code{r}, @code{g}, @code{b} planes
  4748. with @code{y}, @code{u}, @code{v} planes at same time.
  4749. @end table
  4750. @subsection Examples
  4751. @itemize
  4752. @item
  4753. Extract luma, u and v color channel component from input video frame
  4754. into 3 grayscale outputs:
  4755. @example
  4756. 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
  4757. @end example
  4758. @end itemize
  4759. @section elbg
  4760. Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
  4761. For each input image, the filter will compute the optimal mapping from
  4762. the input to the output given the codebook length, that is the number
  4763. of distinct output colors.
  4764. This filter accepts the following options.
  4765. @table @option
  4766. @item codebook_length, l
  4767. Set codebook length. The value must be a positive integer, and
  4768. represents the number of distinct output colors. Default value is 256.
  4769. @item nb_steps, n
  4770. Set the maximum number of iterations to apply for computing the optimal
  4771. mapping. The higher the value the better the result and the higher the
  4772. computation time. Default value is 1.
  4773. @item seed, s
  4774. Set a random seed, must be an integer included between 0 and
  4775. UINT32_MAX. If not specified, or if explicitly set to -1, the filter
  4776. will try to use a good random seed on a best effort basis.
  4777. @item pal8
  4778. Set pal8 output pixel format. This option does not work with codebook
  4779. length greater than 256.
  4780. @end table
  4781. @section fade
  4782. Apply a fade-in/out effect to the input video.
  4783. It accepts the following parameters:
  4784. @table @option
  4785. @item type, t
  4786. The effect type can be either "in" for a fade-in, or "out" for a fade-out
  4787. effect.
  4788. Default is @code{in}.
  4789. @item start_frame, s
  4790. Specify the number of the frame to start applying the fade
  4791. effect at. Default is 0.
  4792. @item nb_frames, n
  4793. The number of frames that the fade effect lasts. At the end of the
  4794. fade-in effect, the output video will have the same intensity as the input video.
  4795. At the end of the fade-out transition, the output video will be filled with the
  4796. selected @option{color}.
  4797. Default is 25.
  4798. @item alpha
  4799. If set to 1, fade only alpha channel, if one exists on the input.
  4800. Default value is 0.
  4801. @item start_time, st
  4802. Specify the timestamp (in seconds) of the frame to start to apply the fade
  4803. effect. If both start_frame and start_time are specified, the fade will start at
  4804. whichever comes last. Default is 0.
  4805. @item duration, d
  4806. The number of seconds for which the fade effect has to last. At the end of the
  4807. fade-in effect the output video will have the same intensity as the input video,
  4808. at the end of the fade-out transition the output video will be filled with the
  4809. selected @option{color}.
  4810. If both duration and nb_frames are specified, duration is used. Default is 0
  4811. (nb_frames is used by default).
  4812. @item color, c
  4813. Specify the color of the fade. Default is "black".
  4814. @end table
  4815. @subsection Examples
  4816. @itemize
  4817. @item
  4818. Fade in the first 30 frames of video:
  4819. @example
  4820. fade=in:0:30
  4821. @end example
  4822. The command above is equivalent to:
  4823. @example
  4824. fade=t=in:s=0:n=30
  4825. @end example
  4826. @item
  4827. Fade out the last 45 frames of a 200-frame video:
  4828. @example
  4829. fade=out:155:45
  4830. fade=type=out:start_frame=155:nb_frames=45
  4831. @end example
  4832. @item
  4833. Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
  4834. @example
  4835. fade=in:0:25, fade=out:975:25
  4836. @end example
  4837. @item
  4838. Make the first 5 frames yellow, then fade in from frame 5-24:
  4839. @example
  4840. fade=in:5:20:color=yellow
  4841. @end example
  4842. @item
  4843. Fade in alpha over first 25 frames of video:
  4844. @example
  4845. fade=in:0:25:alpha=1
  4846. @end example
  4847. @item
  4848. Make the first 5.5 seconds black, then fade in for 0.5 seconds:
  4849. @example
  4850. fade=t=in:st=5.5:d=0.5
  4851. @end example
  4852. @end itemize
  4853. @section fftfilt
  4854. Apply arbitrary expressions to samples in frequency domain
  4855. @table @option
  4856. @item dc_Y
  4857. Adjust the dc value (gain) of the luma plane of the image. The filter
  4858. accepts an integer value in range @code{0} to @code{1000}. The default
  4859. value is set to @code{0}.
  4860. @item dc_U
  4861. Adjust the dc value (gain) of the 1st chroma plane of the image. The
  4862. filter accepts an integer value in range @code{0} to @code{1000}. The
  4863. default value is set to @code{0}.
  4864. @item dc_V
  4865. Adjust the dc value (gain) of the 2nd chroma plane of the image. The
  4866. filter accepts an integer value in range @code{0} to @code{1000}. The
  4867. default value is set to @code{0}.
  4868. @item weight_Y
  4869. Set the frequency domain weight expression for the luma plane.
  4870. @item weight_U
  4871. Set the frequency domain weight expression for the 1st chroma plane.
  4872. @item weight_V
  4873. Set the frequency domain weight expression for the 2nd chroma plane.
  4874. The filter accepts the following variables:
  4875. @item X
  4876. @item Y
  4877. The coordinates of the current sample.
  4878. @item W
  4879. @item H
  4880. The width and height of the image.
  4881. @end table
  4882. @subsection Examples
  4883. @itemize
  4884. @item
  4885. High-pass:
  4886. @example
  4887. fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
  4888. @end example
  4889. @item
  4890. Low-pass:
  4891. @example
  4892. fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
  4893. @end example
  4894. @item
  4895. Sharpen:
  4896. @example
  4897. fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
  4898. @end example
  4899. @end itemize
  4900. @section field
  4901. Extract a single field from an interlaced image using stride
  4902. arithmetic to avoid wasting CPU time. The output frames are marked as
  4903. non-interlaced.
  4904. The filter accepts the following options:
  4905. @table @option
  4906. @item type
  4907. Specify whether to extract the top (if the value is @code{0} or
  4908. @code{top}) or the bottom field (if the value is @code{1} or
  4909. @code{bottom}).
  4910. @end table
  4911. @section fieldmatch
  4912. Field matching filter for inverse telecine. It is meant to reconstruct the
  4913. progressive frames from a telecined stream. The filter does not drop duplicated
  4914. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  4915. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  4916. The separation of the field matching and the decimation is notably motivated by
  4917. the possibility of inserting a de-interlacing filter fallback between the two.
  4918. If the source has mixed telecined and real interlaced content,
  4919. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  4920. But these remaining combed frames will be marked as interlaced, and thus can be
  4921. de-interlaced by a later filter such as @ref{yadif} before decimation.
  4922. In addition to the various configuration options, @code{fieldmatch} can take an
  4923. optional second stream, activated through the @option{ppsrc} option. If
  4924. enabled, the frames reconstruction will be based on the fields and frames from
  4925. this second stream. This allows the first input to be pre-processed in order to
  4926. help the various algorithms of the filter, while keeping the output lossless
  4927. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  4928. or brightness/contrast adjustments can help.
  4929. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  4930. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  4931. which @code{fieldmatch} is based on. While the semantic and usage are very
  4932. close, some behaviour and options names can differ.
  4933. The @ref{decimate} filter currently only works for constant frame rate input.
  4934. If your input has mixed telecined (30fps) and progressive content with a lower
  4935. framerate like 24fps use the following filterchain to produce the necessary cfr
  4936. stream: @code{dejudder,fps=30000/1001,fieldmatch,decimate}.
  4937. The filter accepts the following options:
  4938. @table @option
  4939. @item order
  4940. Specify the assumed field order of the input stream. Available values are:
  4941. @table @samp
  4942. @item auto
  4943. Auto detect parity (use FFmpeg's internal parity value).
  4944. @item bff
  4945. Assume bottom field first.
  4946. @item tff
  4947. Assume top field first.
  4948. @end table
  4949. Note that it is sometimes recommended not to trust the parity announced by the
  4950. stream.
  4951. Default value is @var{auto}.
  4952. @item mode
  4953. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  4954. sense that it won't risk creating jerkiness due to duplicate frames when
  4955. possible, but if there are bad edits or blended fields it will end up
  4956. outputting combed frames when a good match might actually exist. On the other
  4957. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  4958. but will almost always find a good frame if there is one. The other values are
  4959. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  4960. jerkiness and creating duplicate frames versus finding good matches in sections
  4961. with bad edits, orphaned fields, blended fields, etc.
  4962. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  4963. Available values are:
  4964. @table @samp
  4965. @item pc
  4966. 2-way matching (p/c)
  4967. @item pc_n
  4968. 2-way matching, and trying 3rd match if still combed (p/c + n)
  4969. @item pc_u
  4970. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  4971. @item pc_n_ub
  4972. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  4973. still combed (p/c + n + u/b)
  4974. @item pcn
  4975. 3-way matching (p/c/n)
  4976. @item pcn_ub
  4977. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  4978. detected as combed (p/c/n + u/b)
  4979. @end table
  4980. The parenthesis at the end indicate the matches that would be used for that
  4981. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  4982. @var{top}).
  4983. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  4984. the slowest.
  4985. Default value is @var{pc_n}.
  4986. @item ppsrc
  4987. Mark the main input stream as a pre-processed input, and enable the secondary
  4988. input stream as the clean source to pick the fields from. See the filter
  4989. introduction for more details. It is similar to the @option{clip2} feature from
  4990. VFM/TFM.
  4991. Default value is @code{0} (disabled).
  4992. @item field
  4993. Set the field to match from. It is recommended to set this to the same value as
  4994. @option{order} unless you experience matching failures with that setting. In
  4995. certain circumstances changing the field that is used to match from can have a
  4996. large impact on matching performance. Available values are:
  4997. @table @samp
  4998. @item auto
  4999. Automatic (same value as @option{order}).
  5000. @item bottom
  5001. Match from the bottom field.
  5002. @item top
  5003. Match from the top field.
  5004. @end table
  5005. Default value is @var{auto}.
  5006. @item mchroma
  5007. Set whether or not chroma is included during the match comparisons. In most
  5008. cases it is recommended to leave this enabled. You should set this to @code{0}
  5009. only if your clip has bad chroma problems such as heavy rainbowing or other
  5010. artifacts. Setting this to @code{0} could also be used to speed things up at
  5011. the cost of some accuracy.
  5012. Default value is @code{1}.
  5013. @item y0
  5014. @item y1
  5015. These define an exclusion band which excludes the lines between @option{y0} and
  5016. @option{y1} from being included in the field matching decision. An exclusion
  5017. band can be used to ignore subtitles, a logo, or other things that may
  5018. interfere with the matching. @option{y0} sets the starting scan line and
  5019. @option{y1} sets the ending line; all lines in between @option{y0} and
  5020. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  5021. @option{y0} and @option{y1} to the same value will disable the feature.
  5022. @option{y0} and @option{y1} defaults to @code{0}.
  5023. @item scthresh
  5024. Set the scene change detection threshold as a percentage of maximum change on
  5025. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  5026. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  5027. @option{scthresh} is @code{[0.0, 100.0]}.
  5028. Default value is @code{12.0}.
  5029. @item combmatch
  5030. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  5031. account the combed scores of matches when deciding what match to use as the
  5032. final match. Available values are:
  5033. @table @samp
  5034. @item none
  5035. No final matching based on combed scores.
  5036. @item sc
  5037. Combed scores are only used when a scene change is detected.
  5038. @item full
  5039. Use combed scores all the time.
  5040. @end table
  5041. Default is @var{sc}.
  5042. @item combdbg
  5043. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  5044. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  5045. Available values are:
  5046. @table @samp
  5047. @item none
  5048. No forced calculation.
  5049. @item pcn
  5050. Force p/c/n calculations.
  5051. @item pcnub
  5052. Force p/c/n/u/b calculations.
  5053. @end table
  5054. Default value is @var{none}.
  5055. @item cthresh
  5056. This is the area combing threshold used for combed frame detection. This
  5057. essentially controls how "strong" or "visible" combing must be to be detected.
  5058. Larger values mean combing must be more visible and smaller values mean combing
  5059. can be less visible or strong and still be detected. Valid settings are from
  5060. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  5061. be detected as combed). This is basically a pixel difference value. A good
  5062. range is @code{[8, 12]}.
  5063. Default value is @code{9}.
  5064. @item chroma
  5065. Sets whether or not chroma is considered in the combed frame decision. Only
  5066. disable this if your source has chroma problems (rainbowing, etc.) that are
  5067. causing problems for the combed frame detection with chroma enabled. Actually,
  5068. using @option{chroma}=@var{0} is usually more reliable, except for the case
  5069. where there is chroma only combing in the source.
  5070. Default value is @code{0}.
  5071. @item blockx
  5072. @item blocky
  5073. Respectively set the x-axis and y-axis size of the window used during combed
  5074. frame detection. This has to do with the size of the area in which
  5075. @option{combpel} pixels are required to be detected as combed for a frame to be
  5076. declared combed. See the @option{combpel} parameter description for more info.
  5077. Possible values are any number that is a power of 2 starting at 4 and going up
  5078. to 512.
  5079. Default value is @code{16}.
  5080. @item combpel
  5081. The number of combed pixels inside any of the @option{blocky} by
  5082. @option{blockx} size blocks on the frame for the frame to be detected as
  5083. combed. While @option{cthresh} controls how "visible" the combing must be, this
  5084. setting controls "how much" combing there must be in any localized area (a
  5085. window defined by the @option{blockx} and @option{blocky} settings) on the
  5086. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  5087. which point no frames will ever be detected as combed). This setting is known
  5088. as @option{MI} in TFM/VFM vocabulary.
  5089. Default value is @code{80}.
  5090. @end table
  5091. @anchor{p/c/n/u/b meaning}
  5092. @subsection p/c/n/u/b meaning
  5093. @subsubsection p/c/n
  5094. We assume the following telecined stream:
  5095. @example
  5096. Top fields: 1 2 2 3 4
  5097. Bottom fields: 1 2 3 4 4
  5098. @end example
  5099. The numbers correspond to the progressive frame the fields relate to. Here, the
  5100. first two frames are progressive, the 3rd and 4th are combed, and so on.
  5101. When @code{fieldmatch} is configured to run a matching from bottom
  5102. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  5103. @example
  5104. Input stream:
  5105. T 1 2 2 3 4
  5106. B 1 2 3 4 4 <-- matching reference
  5107. Matches: c c n n c
  5108. Output stream:
  5109. T 1 2 3 4 4
  5110. B 1 2 3 4 4
  5111. @end example
  5112. As a result of the field matching, we can see that some frames get duplicated.
  5113. To perform a complete inverse telecine, you need to rely on a decimation filter
  5114. after this operation. See for instance the @ref{decimate} filter.
  5115. The same operation now matching from top fields (@option{field}=@var{top})
  5116. looks like this:
  5117. @example
  5118. Input stream:
  5119. T 1 2 2 3 4 <-- matching reference
  5120. B 1 2 3 4 4
  5121. Matches: c c p p c
  5122. Output stream:
  5123. T 1 2 2 3 4
  5124. B 1 2 2 3 4
  5125. @end example
  5126. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  5127. basically, they refer to the frame and field of the opposite parity:
  5128. @itemize
  5129. @item @var{p} matches the field of the opposite parity in the previous frame
  5130. @item @var{c} matches the field of the opposite parity in the current frame
  5131. @item @var{n} matches the field of the opposite parity in the next frame
  5132. @end itemize
  5133. @subsubsection u/b
  5134. The @var{u} and @var{b} matching are a bit special in the sense that they match
  5135. from the opposite parity flag. In the following examples, we assume that we are
  5136. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  5137. 'x' is placed above and below each matched fields.
  5138. With bottom matching (@option{field}=@var{bottom}):
  5139. @example
  5140. Match: c p n b u
  5141. x x x x x
  5142. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  5143. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  5144. x x x x x
  5145. Output frames:
  5146. 2 1 2 2 2
  5147. 2 2 2 1 3
  5148. @end example
  5149. With top matching (@option{field}=@var{top}):
  5150. @example
  5151. Match: c p n b u
  5152. x x x x x
  5153. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  5154. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  5155. x x x x x
  5156. Output frames:
  5157. 2 2 2 1 2
  5158. 2 1 3 2 2
  5159. @end example
  5160. @subsection Examples
  5161. Simple IVTC of a top field first telecined stream:
  5162. @example
  5163. fieldmatch=order=tff:combmatch=none, decimate
  5164. @end example
  5165. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  5166. @example
  5167. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  5168. @end example
  5169. @section fieldorder
  5170. Transform the field order of the input video.
  5171. It accepts the following parameters:
  5172. @table @option
  5173. @item order
  5174. The output field order. Valid values are @var{tff} for top field first or @var{bff}
  5175. for bottom field first.
  5176. @end table
  5177. The default value is @samp{tff}.
  5178. The transformation is done by shifting the picture content up or down
  5179. by one line, and filling the remaining line with appropriate picture content.
  5180. This method is consistent with most broadcast field order converters.
  5181. If the input video is not flagged as being interlaced, or it is already
  5182. flagged as being of the required output field order, then this filter does
  5183. not alter the incoming video.
  5184. It is very useful when converting to or from PAL DV material,
  5185. which is bottom field first.
  5186. For example:
  5187. @example
  5188. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  5189. @end example
  5190. @section fifo, afifo
  5191. Buffer input images and send them when they are requested.
  5192. It is mainly useful when auto-inserted by the libavfilter
  5193. framework.
  5194. It does not take parameters.
  5195. @section find_rect
  5196. Find a rectangular object
  5197. It accepts the following options:
  5198. @table @option
  5199. @item object
  5200. Filepath of the object image, needs to be in gray8.
  5201. @item threshold
  5202. Detection threshold, default is 0.5.
  5203. @item mipmaps
  5204. Number of mipmaps, default is 3.
  5205. @item xmin, ymin, xmax, ymax
  5206. Specifies the rectangle in which to search.
  5207. @end table
  5208. @subsection Examples
  5209. @itemize
  5210. @item
  5211. Generate a representative palette of a given video using @command{ffmpeg}:
  5212. @example
  5213. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  5214. @end example
  5215. @end itemize
  5216. @section cover_rect
  5217. Cover a rectangular object
  5218. It accepts the following options:
  5219. @table @option
  5220. @item cover
  5221. Filepath of the optional cover image, needs to be in yuv420.
  5222. @item mode
  5223. Set covering mode.
  5224. It accepts the following values:
  5225. @table @samp
  5226. @item cover
  5227. cover it by the supplied image
  5228. @item blur
  5229. cover it by interpolating the surrounding pixels
  5230. @end table
  5231. Default value is @var{blur}.
  5232. @end table
  5233. @subsection Examples
  5234. @itemize
  5235. @item
  5236. Generate a representative palette of a given video using @command{ffmpeg}:
  5237. @example
  5238. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  5239. @end example
  5240. @end itemize
  5241. @anchor{format}
  5242. @section format
  5243. Convert the input video to one of the specified pixel formats.
  5244. Libavfilter will try to pick one that is suitable as input to
  5245. the next filter.
  5246. It accepts the following parameters:
  5247. @table @option
  5248. @item pix_fmts
  5249. A '|'-separated list of pixel format names, such as
  5250. "pix_fmts=yuv420p|monow|rgb24".
  5251. @end table
  5252. @subsection Examples
  5253. @itemize
  5254. @item
  5255. Convert the input video to the @var{yuv420p} format
  5256. @example
  5257. format=pix_fmts=yuv420p
  5258. @end example
  5259. Convert the input video to any of the formats in the list
  5260. @example
  5261. format=pix_fmts=yuv420p|yuv444p|yuv410p
  5262. @end example
  5263. @end itemize
  5264. @anchor{fps}
  5265. @section fps
  5266. Convert the video to specified constant frame rate by duplicating or dropping
  5267. frames as necessary.
  5268. It accepts the following parameters:
  5269. @table @option
  5270. @item fps
  5271. The desired output frame rate. The default is @code{25}.
  5272. @item round
  5273. Rounding method.
  5274. Possible values are:
  5275. @table @option
  5276. @item zero
  5277. zero round towards 0
  5278. @item inf
  5279. round away from 0
  5280. @item down
  5281. round towards -infinity
  5282. @item up
  5283. round towards +infinity
  5284. @item near
  5285. round to nearest
  5286. @end table
  5287. The default is @code{near}.
  5288. @item start_time
  5289. Assume the first PTS should be the given value, in seconds. This allows for
  5290. padding/trimming at the start of stream. By default, no assumption is made
  5291. about the first frame's expected PTS, so no padding or trimming is done.
  5292. For example, this could be set to 0 to pad the beginning with duplicates of
  5293. the first frame if a video stream starts after the audio stream or to trim any
  5294. frames with a negative PTS.
  5295. @end table
  5296. Alternatively, the options can be specified as a flat string:
  5297. @var{fps}[:@var{round}].
  5298. See also the @ref{setpts} filter.
  5299. @subsection Examples
  5300. @itemize
  5301. @item
  5302. A typical usage in order to set the fps to 25:
  5303. @example
  5304. fps=fps=25
  5305. @end example
  5306. @item
  5307. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  5308. @example
  5309. fps=fps=film:round=near
  5310. @end example
  5311. @end itemize
  5312. @section framepack
  5313. Pack two different video streams into a stereoscopic video, setting proper
  5314. metadata on supported codecs. The two views should have the same size and
  5315. framerate and processing will stop when the shorter video ends. Please note
  5316. that you may conveniently adjust view properties with the @ref{scale} and
  5317. @ref{fps} filters.
  5318. It accepts the following parameters:
  5319. @table @option
  5320. @item format
  5321. The desired packing format. Supported values are:
  5322. @table @option
  5323. @item sbs
  5324. The views are next to each other (default).
  5325. @item tab
  5326. The views are on top of each other.
  5327. @item lines
  5328. The views are packed by line.
  5329. @item columns
  5330. The views are packed by column.
  5331. @item frameseq
  5332. The views are temporally interleaved.
  5333. @end table
  5334. @end table
  5335. Some examples:
  5336. @example
  5337. # Convert left and right views into a frame-sequential video
  5338. ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
  5339. # Convert views into a side-by-side video with the same output resolution as the input
  5340. 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
  5341. @end example
  5342. @section framerate
  5343. Change the frame rate by interpolating new video output frames from the source
  5344. frames.
  5345. This filter is not designed to function correctly with interlaced media. If
  5346. you wish to change the frame rate of interlaced media then you are required
  5347. to deinterlace before this filter and re-interlace after this filter.
  5348. A description of the accepted options follows.
  5349. @table @option
  5350. @item fps
  5351. Specify the output frames per second. This option can also be specified
  5352. as a value alone. The default is @code{50}.
  5353. @item interp_start
  5354. Specify the start of a range where the output frame will be created as a
  5355. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  5356. the default is @code{15}.
  5357. @item interp_end
  5358. Specify the end of a range where the output frame will be created as a
  5359. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  5360. the default is @code{240}.
  5361. @item scene
  5362. Specify the level at which a scene change is detected as a value between
  5363. 0 and 100 to indicate a new scene; a low value reflects a low
  5364. probability for the current frame to introduce a new scene, while a higher
  5365. value means the current frame is more likely to be one.
  5366. The default is @code{7}.
  5367. @item flags
  5368. Specify flags influencing the filter process.
  5369. Available value for @var{flags} is:
  5370. @table @option
  5371. @item scene_change_detect, scd
  5372. Enable scene change detection using the value of the option @var{scene}.
  5373. This flag is enabled by default.
  5374. @end table
  5375. @end table
  5376. @section framestep
  5377. Select one frame every N-th frame.
  5378. This filter accepts the following option:
  5379. @table @option
  5380. @item step
  5381. Select frame after every @code{step} frames.
  5382. Allowed values are positive integers higher than 0. Default value is @code{1}.
  5383. @end table
  5384. @anchor{frei0r}
  5385. @section frei0r
  5386. Apply a frei0r effect to the input video.
  5387. To enable the compilation of this filter, you need to install the frei0r
  5388. header and configure FFmpeg with @code{--enable-frei0r}.
  5389. It accepts the following parameters:
  5390. @table @option
  5391. @item filter_name
  5392. The name of the frei0r effect to load. If the environment variable
  5393. @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
  5394. directories specified by the colon-separated list in @env{FREIOR_PATH}.
  5395. Otherwise, the standard frei0r paths are searched, in this order:
  5396. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  5397. @file{/usr/lib/frei0r-1/}.
  5398. @item filter_params
  5399. A '|'-separated list of parameters to pass to the frei0r effect.
  5400. @end table
  5401. A frei0r effect parameter can be a boolean (its value is either
  5402. "y" or "n"), a double, a color (specified as
  5403. @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
  5404. numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
  5405. section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
  5406. @var{X} and @var{Y} are floating point numbers) and/or a string.
  5407. The number and types of parameters depend on the loaded effect. If an
  5408. effect parameter is not specified, the default value is set.
  5409. @subsection Examples
  5410. @itemize
  5411. @item
  5412. Apply the distort0r effect, setting the first two double parameters:
  5413. @example
  5414. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  5415. @end example
  5416. @item
  5417. Apply the colordistance effect, taking a color as the first parameter:
  5418. @example
  5419. frei0r=colordistance:0.2/0.3/0.4
  5420. frei0r=colordistance:violet
  5421. frei0r=colordistance:0x112233
  5422. @end example
  5423. @item
  5424. Apply the perspective effect, specifying the top left and top right image
  5425. positions:
  5426. @example
  5427. frei0r=perspective:0.2/0.2|0.8/0.2
  5428. @end example
  5429. @end itemize
  5430. For more information, see
  5431. @url{http://frei0r.dyne.org}
  5432. @section fspp
  5433. Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
  5434. It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
  5435. processing filter, one of them is performed once per block, not per pixel.
  5436. This allows for much higher speed.
  5437. The filter accepts the following options:
  5438. @table @option
  5439. @item quality
  5440. Set quality. This option defines the number of levels for averaging. It accepts
  5441. an integer in the range 4-5. Default value is @code{4}.
  5442. @item qp
  5443. Force a constant quantization parameter. It accepts an integer in range 0-63.
  5444. If not set, the filter will use the QP from the video stream (if available).
  5445. @item strength
  5446. Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
  5447. more details but also more artifacts, while higher values make the image smoother
  5448. but also blurrier. Default value is @code{0} − PSNR optimal.
  5449. @item use_bframe_qp
  5450. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  5451. option may cause flicker since the B-Frames have often larger QP. Default is
  5452. @code{0} (not enabled).
  5453. @end table
  5454. @section geq
  5455. The filter accepts the following options:
  5456. @table @option
  5457. @item lum_expr, lum
  5458. Set the luminance expression.
  5459. @item cb_expr, cb
  5460. Set the chrominance blue expression.
  5461. @item cr_expr, cr
  5462. Set the chrominance red expression.
  5463. @item alpha_expr, a
  5464. Set the alpha expression.
  5465. @item red_expr, r
  5466. Set the red expression.
  5467. @item green_expr, g
  5468. Set the green expression.
  5469. @item blue_expr, b
  5470. Set the blue expression.
  5471. @end table
  5472. The colorspace is selected according to the specified options. If one
  5473. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  5474. options is specified, the filter will automatically select a YCbCr
  5475. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  5476. @option{blue_expr} options is specified, it will select an RGB
  5477. colorspace.
  5478. If one of the chrominance expression is not defined, it falls back on the other
  5479. one. If no alpha expression is specified it will evaluate to opaque value.
  5480. If none of chrominance expressions are specified, they will evaluate
  5481. to the luminance expression.
  5482. The expressions can use the following variables and functions:
  5483. @table @option
  5484. @item N
  5485. The sequential number of the filtered frame, starting from @code{0}.
  5486. @item X
  5487. @item Y
  5488. The coordinates of the current sample.
  5489. @item W
  5490. @item H
  5491. The width and height of the image.
  5492. @item SW
  5493. @item SH
  5494. Width and height scale depending on the currently filtered plane. It is the
  5495. ratio between the corresponding luma plane number of pixels and the current
  5496. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  5497. @code{0.5,0.5} for chroma planes.
  5498. @item T
  5499. Time of the current frame, expressed in seconds.
  5500. @item p(x, y)
  5501. Return the value of the pixel at location (@var{x},@var{y}) of the current
  5502. plane.
  5503. @item lum(x, y)
  5504. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  5505. plane.
  5506. @item cb(x, y)
  5507. Return the value of the pixel at location (@var{x},@var{y}) of the
  5508. blue-difference chroma plane. Return 0 if there is no such plane.
  5509. @item cr(x, y)
  5510. Return the value of the pixel at location (@var{x},@var{y}) of the
  5511. red-difference chroma plane. Return 0 if there is no such plane.
  5512. @item r(x, y)
  5513. @item g(x, y)
  5514. @item b(x, y)
  5515. Return the value of the pixel at location (@var{x},@var{y}) of the
  5516. red/green/blue component. Return 0 if there is no such component.
  5517. @item alpha(x, y)
  5518. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  5519. plane. Return 0 if there is no such plane.
  5520. @end table
  5521. For functions, if @var{x} and @var{y} are outside the area, the value will be
  5522. automatically clipped to the closer edge.
  5523. @subsection Examples
  5524. @itemize
  5525. @item
  5526. Flip the image horizontally:
  5527. @example
  5528. geq=p(W-X\,Y)
  5529. @end example
  5530. @item
  5531. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  5532. wavelength of 100 pixels:
  5533. @example
  5534. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  5535. @end example
  5536. @item
  5537. Generate a fancy enigmatic moving light:
  5538. @example
  5539. 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
  5540. @end example
  5541. @item
  5542. Generate a quick emboss effect:
  5543. @example
  5544. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  5545. @end example
  5546. @item
  5547. Modify RGB components depending on pixel position:
  5548. @example
  5549. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  5550. @end example
  5551. @item
  5552. Create a radial gradient that is the same size as the input (also see
  5553. the @ref{vignette} filter):
  5554. @example
  5555. geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
  5556. @end example
  5557. @item
  5558. Create a linear gradient to use as a mask for another filter, then
  5559. compose with @ref{overlay}. In this example the video will gradually
  5560. become more blurry from the top to the bottom of the y-axis as defined
  5561. by the linear gradient:
  5562. @example
  5563. ffmpeg -i input.mp4 -filter_complex "geq=lum=255*(Y/H),format=gray[grad];[0:v]boxblur=4[blur];[blur][grad]alphamerge[alpha];[0:v][alpha]overlay" output.mp4
  5564. @end example
  5565. @end itemize
  5566. @section gradfun
  5567. Fix the banding artifacts that are sometimes introduced into nearly flat
  5568. regions by truncation to 8bit color depth.
  5569. Interpolate the gradients that should go where the bands are, and
  5570. dither them.
  5571. It is designed for playback only. Do not use it prior to
  5572. lossy compression, because compression tends to lose the dither and
  5573. bring back the bands.
  5574. It accepts the following parameters:
  5575. @table @option
  5576. @item strength
  5577. The maximum amount by which the filter will change any one pixel. This is also
  5578. the threshold for detecting nearly flat regions. Acceptable values range from
  5579. .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
  5580. valid range.
  5581. @item radius
  5582. The neighborhood to fit the gradient to. A larger radius makes for smoother
  5583. gradients, but also prevents the filter from modifying the pixels near detailed
  5584. regions. Acceptable values are 8-32; the default value is 16. Out-of-range
  5585. values will be clipped to the valid range.
  5586. @end table
  5587. Alternatively, the options can be specified as a flat string:
  5588. @var{strength}[:@var{radius}]
  5589. @subsection Examples
  5590. @itemize
  5591. @item
  5592. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  5593. @example
  5594. gradfun=3.5:8
  5595. @end example
  5596. @item
  5597. Specify radius, omitting the strength (which will fall-back to the default
  5598. value):
  5599. @example
  5600. gradfun=radius=8
  5601. @end example
  5602. @end itemize
  5603. @anchor{haldclut}
  5604. @section haldclut
  5605. Apply a Hald CLUT to a video stream.
  5606. First input is the video stream to process, and second one is the Hald CLUT.
  5607. The Hald CLUT input can be a simple picture or a complete video stream.
  5608. The filter accepts the following options:
  5609. @table @option
  5610. @item shortest
  5611. Force termination when the shortest input terminates. Default is @code{0}.
  5612. @item repeatlast
  5613. Continue applying the last CLUT after the end of the stream. A value of
  5614. @code{0} disable the filter after the last frame of the CLUT is reached.
  5615. Default is @code{1}.
  5616. @end table
  5617. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  5618. filters share the same internals).
  5619. More information about the Hald CLUT can be found on Eskil Steenberg's website
  5620. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  5621. @subsection Workflow examples
  5622. @subsubsection Hald CLUT video stream
  5623. Generate an identity Hald CLUT stream altered with various effects:
  5624. @example
  5625. 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
  5626. @end example
  5627. Note: make sure you use a lossless codec.
  5628. Then use it with @code{haldclut} to apply it on some random stream:
  5629. @example
  5630. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  5631. @end example
  5632. The Hald CLUT will be applied to the 10 first seconds (duration of
  5633. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  5634. to the remaining frames of the @code{mandelbrot} stream.
  5635. @subsubsection Hald CLUT with preview
  5636. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  5637. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  5638. biggest possible square starting at the top left of the picture. The remaining
  5639. padding pixels (bottom or right) will be ignored. This area can be used to add
  5640. a preview of the Hald CLUT.
  5641. Typically, the following generated Hald CLUT will be supported by the
  5642. @code{haldclut} filter:
  5643. @example
  5644. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  5645. pad=iw+320 [padded_clut];
  5646. smptebars=s=320x256, split [a][b];
  5647. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  5648. [main][b] overlay=W-320" -frames:v 1 clut.png
  5649. @end example
  5650. It contains the original and a preview of the effect of the CLUT: SMPTE color
  5651. bars are displayed on the right-top, and below the same color bars processed by
  5652. the color changes.
  5653. Then, the effect of this Hald CLUT can be visualized with:
  5654. @example
  5655. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  5656. @end example
  5657. @section hflip
  5658. Flip the input video horizontally.
  5659. For example, to horizontally flip the input video with @command{ffmpeg}:
  5660. @example
  5661. ffmpeg -i in.avi -vf "hflip" out.avi
  5662. @end example
  5663. @section histeq
  5664. This filter applies a global color histogram equalization on a
  5665. per-frame basis.
  5666. It can be used to correct video that has a compressed range of pixel
  5667. intensities. The filter redistributes the pixel intensities to
  5668. equalize their distribution across the intensity range. It may be
  5669. viewed as an "automatically adjusting contrast filter". This filter is
  5670. useful only for correcting degraded or poorly captured source
  5671. video.
  5672. The filter accepts the following options:
  5673. @table @option
  5674. @item strength
  5675. Determine the amount of equalization to be applied. As the strength
  5676. is reduced, the distribution of pixel intensities more-and-more
  5677. approaches that of the input frame. The value must be a float number
  5678. in the range [0,1] and defaults to 0.200.
  5679. @item intensity
  5680. Set the maximum intensity that can generated and scale the output
  5681. values appropriately. The strength should be set as desired and then
  5682. the intensity can be limited if needed to avoid washing-out. The value
  5683. must be a float number in the range [0,1] and defaults to 0.210.
  5684. @item antibanding
  5685. Set the antibanding level. If enabled the filter will randomly vary
  5686. the luminance of output pixels by a small amount to avoid banding of
  5687. the histogram. Possible values are @code{none}, @code{weak} or
  5688. @code{strong}. It defaults to @code{none}.
  5689. @end table
  5690. @section histogram
  5691. Compute and draw a color distribution histogram for the input video.
  5692. The computed histogram is a representation of the color component
  5693. distribution in an image.
  5694. Standard histogram displays the color components distribution in an image.
  5695. Displays color graph for each color component. Shows distribution of
  5696. the Y, U, V, A or R, G, B components, depending on input format, in the
  5697. current frame. Below each graph a color component scale meter is shown.
  5698. The filter accepts the following options:
  5699. @table @option
  5700. @item level_height
  5701. Set height of level. Default value is @code{200}.
  5702. Allowed range is [50, 2048].
  5703. @item scale_height
  5704. Set height of color scale. Default value is @code{12}.
  5705. Allowed range is [0, 40].
  5706. @item display_mode
  5707. Set display mode.
  5708. It accepts the following values:
  5709. @table @samp
  5710. @item parade
  5711. Per color component graphs are placed below each other.
  5712. @item overlay
  5713. Presents information identical to that in the @code{parade}, except
  5714. that the graphs representing color components are superimposed directly
  5715. over one another.
  5716. @end table
  5717. Default is @code{parade}.
  5718. @item levels_mode
  5719. Set mode. Can be either @code{linear}, or @code{logarithmic}.
  5720. Default is @code{linear}.
  5721. @item components
  5722. Set what color components to display.
  5723. Default is @code{7}.
  5724. @end table
  5725. @subsection Examples
  5726. @itemize
  5727. @item
  5728. Calculate and draw histogram:
  5729. @example
  5730. ffplay -i input -vf histogram
  5731. @end example
  5732. @end itemize
  5733. @anchor{hqdn3d}
  5734. @section hqdn3d
  5735. This is a high precision/quality 3d denoise filter. It aims to reduce
  5736. image noise, producing smooth images and making still images really
  5737. still. It should enhance compressibility.
  5738. It accepts the following optional parameters:
  5739. @table @option
  5740. @item luma_spatial
  5741. A non-negative floating point number which specifies spatial luma strength.
  5742. It defaults to 4.0.
  5743. @item chroma_spatial
  5744. A non-negative floating point number which specifies spatial chroma strength.
  5745. It defaults to 3.0*@var{luma_spatial}/4.0.
  5746. @item luma_tmp
  5747. A floating point number which specifies luma temporal strength. It defaults to
  5748. 6.0*@var{luma_spatial}/4.0.
  5749. @item chroma_tmp
  5750. A floating point number which specifies chroma temporal strength. It defaults to
  5751. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
  5752. @end table
  5753. @section hqx
  5754. Apply a high-quality magnification filter designed for pixel art. This filter
  5755. was originally created by Maxim Stepin.
  5756. It accepts the following option:
  5757. @table @option
  5758. @item n
  5759. Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
  5760. @code{hq3x} and @code{4} for @code{hq4x}.
  5761. Default is @code{3}.
  5762. @end table
  5763. @section hstack
  5764. Stack input videos horizontally.
  5765. All streams must be of same pixel format and of same height.
  5766. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  5767. to create same output.
  5768. The filter accept the following option:
  5769. @table @option
  5770. @item inputs
  5771. Set number of input streams. Default is 2.
  5772. @item shortest
  5773. If set to 1, force the output to terminate when the shortest input
  5774. terminates. Default value is 0.
  5775. @end table
  5776. @section hue
  5777. Modify the hue and/or the saturation of the input.
  5778. It accepts the following parameters:
  5779. @table @option
  5780. @item h
  5781. Specify the hue angle as a number of degrees. It accepts an expression,
  5782. and defaults to "0".
  5783. @item s
  5784. Specify the saturation in the [-10,10] range. It accepts an expression and
  5785. defaults to "1".
  5786. @item H
  5787. Specify the hue angle as a number of radians. It accepts an
  5788. expression, and defaults to "0".
  5789. @item b
  5790. Specify the brightness in the [-10,10] range. It accepts an expression and
  5791. defaults to "0".
  5792. @end table
  5793. @option{h} and @option{H} are mutually exclusive, and can't be
  5794. specified at the same time.
  5795. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  5796. expressions containing the following constants:
  5797. @table @option
  5798. @item n
  5799. frame count of the input frame starting from 0
  5800. @item pts
  5801. presentation timestamp of the input frame expressed in time base units
  5802. @item r
  5803. frame rate of the input video, NAN if the input frame rate is unknown
  5804. @item t
  5805. timestamp expressed in seconds, NAN if the input timestamp is unknown
  5806. @item tb
  5807. time base of the input video
  5808. @end table
  5809. @subsection Examples
  5810. @itemize
  5811. @item
  5812. Set the hue to 90 degrees and the saturation to 1.0:
  5813. @example
  5814. hue=h=90:s=1
  5815. @end example
  5816. @item
  5817. Same command but expressing the hue in radians:
  5818. @example
  5819. hue=H=PI/2:s=1
  5820. @end example
  5821. @item
  5822. Rotate hue and make the saturation swing between 0
  5823. and 2 over a period of 1 second:
  5824. @example
  5825. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  5826. @end example
  5827. @item
  5828. Apply a 3 seconds saturation fade-in effect starting at 0:
  5829. @example
  5830. hue="s=min(t/3\,1)"
  5831. @end example
  5832. The general fade-in expression can be written as:
  5833. @example
  5834. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  5835. @end example
  5836. @item
  5837. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  5838. @example
  5839. hue="s=max(0\, min(1\, (8-t)/3))"
  5840. @end example
  5841. The general fade-out expression can be written as:
  5842. @example
  5843. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  5844. @end example
  5845. @end itemize
  5846. @subsection Commands
  5847. This filter supports the following commands:
  5848. @table @option
  5849. @item b
  5850. @item s
  5851. @item h
  5852. @item H
  5853. Modify the hue and/or the saturation and/or brightness of the input video.
  5854. The command accepts the same syntax of the corresponding option.
  5855. If the specified expression is not valid, it is kept at its current
  5856. value.
  5857. @end table
  5858. @section idet
  5859. Detect video interlacing type.
  5860. This filter tries to detect if the input frames as interlaced, progressive,
  5861. top or bottom field first. It will also try and detect fields that are
  5862. repeated between adjacent frames (a sign of telecine).
  5863. Single frame detection considers only immediately adjacent frames when classifying each frame.
  5864. Multiple frame detection incorporates the classification history of previous frames.
  5865. The filter will log these metadata values:
  5866. @table @option
  5867. @item single.current_frame
  5868. Detected type of current frame using single-frame detection. One of:
  5869. ``tff'' (top field first), ``bff'' (bottom field first),
  5870. ``progressive'', or ``undetermined''
  5871. @item single.tff
  5872. Cumulative number of frames detected as top field first using single-frame detection.
  5873. @item multiple.tff
  5874. Cumulative number of frames detected as top field first using multiple-frame detection.
  5875. @item single.bff
  5876. Cumulative number of frames detected as bottom field first using single-frame detection.
  5877. @item multiple.current_frame
  5878. Detected type of current frame using multiple-frame detection. One of:
  5879. ``tff'' (top field first), ``bff'' (bottom field first),
  5880. ``progressive'', or ``undetermined''
  5881. @item multiple.bff
  5882. Cumulative number of frames detected as bottom field first using multiple-frame detection.
  5883. @item single.progressive
  5884. Cumulative number of frames detected as progressive using single-frame detection.
  5885. @item multiple.progressive
  5886. Cumulative number of frames detected as progressive using multiple-frame detection.
  5887. @item single.undetermined
  5888. Cumulative number of frames that could not be classified using single-frame detection.
  5889. @item multiple.undetermined
  5890. Cumulative number of frames that could not be classified using multiple-frame detection.
  5891. @item repeated.current_frame
  5892. Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
  5893. @item repeated.neither
  5894. Cumulative number of frames with no repeated field.
  5895. @item repeated.top
  5896. Cumulative number of frames with the top field repeated from the previous frame's top field.
  5897. @item repeated.bottom
  5898. Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
  5899. @end table
  5900. The filter accepts the following options:
  5901. @table @option
  5902. @item intl_thres
  5903. Set interlacing threshold.
  5904. @item prog_thres
  5905. Set progressive threshold.
  5906. @item repeat_thres
  5907. Threshold for repeated field detection.
  5908. @item half_life
  5909. Number of frames after which a given frame's contribution to the
  5910. statistics is halved (i.e., it contributes only 0.5 to it's
  5911. classification). The default of 0 means that all frames seen are given
  5912. full weight of 1.0 forever.
  5913. @item analyze_interlaced_flag
  5914. When this is not 0 then idet will use the specified number of frames to determine
  5915. if the interlaced flag is accurate, it will not count undetermined frames.
  5916. If the flag is found to be accurate it will be used without any further
  5917. computations, if it is found to be inaccurate it will be cleared without any
  5918. further computations. This allows inserting the idet filter as a low computational
  5919. method to clean up the interlaced flag
  5920. @end table
  5921. @section il
  5922. Deinterleave or interleave fields.
  5923. This filter allows one to process interlaced images fields without
  5924. deinterlacing them. Deinterleaving splits the input frame into 2
  5925. fields (so called half pictures). Odd lines are moved to the top
  5926. half of the output image, even lines to the bottom half.
  5927. You can process (filter) them independently and then re-interleave them.
  5928. The filter accepts the following options:
  5929. @table @option
  5930. @item luma_mode, l
  5931. @item chroma_mode, c
  5932. @item alpha_mode, a
  5933. Available values for @var{luma_mode}, @var{chroma_mode} and
  5934. @var{alpha_mode} are:
  5935. @table @samp
  5936. @item none
  5937. Do nothing.
  5938. @item deinterleave, d
  5939. Deinterleave fields, placing one above the other.
  5940. @item interleave, i
  5941. Interleave fields. Reverse the effect of deinterleaving.
  5942. @end table
  5943. Default value is @code{none}.
  5944. @item luma_swap, ls
  5945. @item chroma_swap, cs
  5946. @item alpha_swap, as
  5947. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  5948. @end table
  5949. @section inflate
  5950. Apply inflate effect to the video.
  5951. This filter replaces the pixel by the local(3x3) average by taking into account
  5952. only values higher than the pixel.
  5953. It accepts the following options:
  5954. @table @option
  5955. @item threshold0
  5956. @item threshold1
  5957. @item threshold2
  5958. @item threshold3
  5959. Limit the maximum change for each plane, default is 65535.
  5960. If 0, plane will remain unchanged.
  5961. @end table
  5962. @section interlace
  5963. Simple interlacing filter from progressive contents. This interleaves upper (or
  5964. lower) lines from odd frames with lower (or upper) lines from even frames,
  5965. halving the frame rate and preserving image height.
  5966. @example
  5967. Original Original New Frame
  5968. Frame 'j' Frame 'j+1' (tff)
  5969. ========== =========== ==================
  5970. Line 0 --------------------> Frame 'j' Line 0
  5971. Line 1 Line 1 ----> Frame 'j+1' Line 1
  5972. Line 2 ---------------------> Frame 'j' Line 2
  5973. Line 3 Line 3 ----> Frame 'j+1' Line 3
  5974. ... ... ...
  5975. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  5976. @end example
  5977. It accepts the following optional parameters:
  5978. @table @option
  5979. @item scan
  5980. This determines whether the interlaced frame is taken from the even
  5981. (tff - default) or odd (bff) lines of the progressive frame.
  5982. @item lowpass
  5983. Enable (default) or disable the vertical lowpass filter to avoid twitter
  5984. interlacing and reduce moire patterns.
  5985. @end table
  5986. @section kerndeint
  5987. Deinterlace input video by applying Donald Graft's adaptive kernel
  5988. deinterling. Work on interlaced parts of a video to produce
  5989. progressive frames.
  5990. The description of the accepted parameters follows.
  5991. @table @option
  5992. @item thresh
  5993. Set the threshold which affects the filter's tolerance when
  5994. determining if a pixel line must be processed. It must be an integer
  5995. in the range [0,255] and defaults to 10. A value of 0 will result in
  5996. applying the process on every pixels.
  5997. @item map
  5998. Paint pixels exceeding the threshold value to white if set to 1.
  5999. Default is 0.
  6000. @item order
  6001. Set the fields order. Swap fields if set to 1, leave fields alone if
  6002. 0. Default is 0.
  6003. @item sharp
  6004. Enable additional sharpening if set to 1. Default is 0.
  6005. @item twoway
  6006. Enable twoway sharpening if set to 1. Default is 0.
  6007. @end table
  6008. @subsection Examples
  6009. @itemize
  6010. @item
  6011. Apply default values:
  6012. @example
  6013. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  6014. @end example
  6015. @item
  6016. Enable additional sharpening:
  6017. @example
  6018. kerndeint=sharp=1
  6019. @end example
  6020. @item
  6021. Paint processed pixels in white:
  6022. @example
  6023. kerndeint=map=1
  6024. @end example
  6025. @end itemize
  6026. @section lenscorrection
  6027. Correct radial lens distortion
  6028. This filter can be used to correct for radial distortion as can result from the use
  6029. of wide angle lenses, and thereby re-rectify the image. To find the right parameters
  6030. one can use tools available for example as part of opencv or simply trial-and-error.
  6031. To use opencv use the calibration sample (under samples/cpp) from the opencv sources
  6032. and extract the k1 and k2 coefficients from the resulting matrix.
  6033. Note that effectively the same filter is available in the open-source tools Krita and
  6034. Digikam from the KDE project.
  6035. In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
  6036. this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
  6037. brightness distribution, so you may want to use both filters together in certain
  6038. cases, though you will have to take care of ordering, i.e. whether vignetting should
  6039. be applied before or after lens correction.
  6040. @subsection Options
  6041. The filter accepts the following options:
  6042. @table @option
  6043. @item cx
  6044. Relative x-coordinate of the focal point of the image, and thereby the center of the
  6045. distortion. This value has a range [0,1] and is expressed as fractions of the image
  6046. width.
  6047. @item cy
  6048. Relative y-coordinate of the focal point of the image, and thereby the center of the
  6049. distortion. This value has a range [0,1] and is expressed as fractions of the image
  6050. height.
  6051. @item k1
  6052. Coefficient of the quadratic correction term. 0.5 means no correction.
  6053. @item k2
  6054. Coefficient of the double quadratic correction term. 0.5 means no correction.
  6055. @end table
  6056. The formula that generates the correction is:
  6057. @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)
  6058. where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
  6059. distances from the focal point in the source and target images, respectively.
  6060. @anchor{lut3d}
  6061. @section lut3d
  6062. Apply a 3D LUT to an input video.
  6063. The filter accepts the following options:
  6064. @table @option
  6065. @item file
  6066. Set the 3D LUT file name.
  6067. Currently supported formats:
  6068. @table @samp
  6069. @item 3dl
  6070. AfterEffects
  6071. @item cube
  6072. Iridas
  6073. @item dat
  6074. DaVinci
  6075. @item m3d
  6076. Pandora
  6077. @end table
  6078. @item interp
  6079. Select interpolation mode.
  6080. Available values are:
  6081. @table @samp
  6082. @item nearest
  6083. Use values from the nearest defined point.
  6084. @item trilinear
  6085. Interpolate values using the 8 points defining a cube.
  6086. @item tetrahedral
  6087. Interpolate values using a tetrahedron.
  6088. @end table
  6089. @end table
  6090. @section lut, lutrgb, lutyuv
  6091. Compute a look-up table for binding each pixel component input value
  6092. to an output value, and apply it to the input video.
  6093. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  6094. to an RGB input video.
  6095. These filters accept the following parameters:
  6096. @table @option
  6097. @item c0
  6098. set first pixel component expression
  6099. @item c1
  6100. set second pixel component expression
  6101. @item c2
  6102. set third pixel component expression
  6103. @item c3
  6104. set fourth pixel component expression, corresponds to the alpha component
  6105. @item r
  6106. set red component expression
  6107. @item g
  6108. set green component expression
  6109. @item b
  6110. set blue component expression
  6111. @item a
  6112. alpha component expression
  6113. @item y
  6114. set Y/luminance component expression
  6115. @item u
  6116. set U/Cb component expression
  6117. @item v
  6118. set V/Cr component expression
  6119. @end table
  6120. Each of them specifies the expression to use for computing the lookup table for
  6121. the corresponding pixel component values.
  6122. The exact component associated to each of the @var{c*} options depends on the
  6123. format in input.
  6124. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  6125. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  6126. The expressions can contain the following constants and functions:
  6127. @table @option
  6128. @item w
  6129. @item h
  6130. The input width and height.
  6131. @item val
  6132. The input value for the pixel component.
  6133. @item clipval
  6134. The input value, clipped to the @var{minval}-@var{maxval} range.
  6135. @item maxval
  6136. The maximum value for the pixel component.
  6137. @item minval
  6138. The minimum value for the pixel component.
  6139. @item negval
  6140. The negated value for the pixel component value, clipped to the
  6141. @var{minval}-@var{maxval} range; it corresponds to the expression
  6142. "maxval-clipval+minval".
  6143. @item clip(val)
  6144. The computed value in @var{val}, clipped to the
  6145. @var{minval}-@var{maxval} range.
  6146. @item gammaval(gamma)
  6147. The computed gamma correction value of the pixel component value,
  6148. clipped to the @var{minval}-@var{maxval} range. It corresponds to the
  6149. expression
  6150. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  6151. @end table
  6152. All expressions default to "val".
  6153. @subsection Examples
  6154. @itemize
  6155. @item
  6156. Negate input video:
  6157. @example
  6158. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  6159. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  6160. @end example
  6161. The above is the same as:
  6162. @example
  6163. lutrgb="r=negval:g=negval:b=negval"
  6164. lutyuv="y=negval:u=negval:v=negval"
  6165. @end example
  6166. @item
  6167. Negate luminance:
  6168. @example
  6169. lutyuv=y=negval
  6170. @end example
  6171. @item
  6172. Remove chroma components, turning the video into a graytone image:
  6173. @example
  6174. lutyuv="u=128:v=128"
  6175. @end example
  6176. @item
  6177. Apply a luma burning effect:
  6178. @example
  6179. lutyuv="y=2*val"
  6180. @end example
  6181. @item
  6182. Remove green and blue components:
  6183. @example
  6184. lutrgb="g=0:b=0"
  6185. @end example
  6186. @item
  6187. Set a constant alpha channel value on input:
  6188. @example
  6189. format=rgba,lutrgb=a="maxval-minval/2"
  6190. @end example
  6191. @item
  6192. Correct luminance gamma by a factor of 0.5:
  6193. @example
  6194. lutyuv=y=gammaval(0.5)
  6195. @end example
  6196. @item
  6197. Discard least significant bits of luma:
  6198. @example
  6199. lutyuv=y='bitand(val, 128+64+32)'
  6200. @end example
  6201. @end itemize
  6202. @section maskedmerge
  6203. Merge the first input stream with the second input stream using per pixel
  6204. weights in the third input stream.
  6205. A value of 0 in the third stream pixel component means that pixel component
  6206. from first stream is returned unchanged, while maximum value (eg. 255 for
  6207. 8-bit videos) means that pixel component from second stream is returned
  6208. unchanged. Intermediate values define the amount of merging between both
  6209. input stream's pixel components.
  6210. This filter accepts the following options:
  6211. @table @option
  6212. @item planes
  6213. Set which planes will be processed as bitmap, unprocessed planes will be
  6214. copied from first stream.
  6215. By default value 0xf, all planes will be processed.
  6216. @end table
  6217. @section mcdeint
  6218. Apply motion-compensation deinterlacing.
  6219. It needs one field per frame as input and must thus be used together
  6220. with yadif=1/3 or equivalent.
  6221. This filter accepts the following options:
  6222. @table @option
  6223. @item mode
  6224. Set the deinterlacing mode.
  6225. It accepts one of the following values:
  6226. @table @samp
  6227. @item fast
  6228. @item medium
  6229. @item slow
  6230. use iterative motion estimation
  6231. @item extra_slow
  6232. like @samp{slow}, but use multiple reference frames.
  6233. @end table
  6234. Default value is @samp{fast}.
  6235. @item parity
  6236. Set the picture field parity assumed for the input video. It must be
  6237. one of the following values:
  6238. @table @samp
  6239. @item 0, tff
  6240. assume top field first
  6241. @item 1, bff
  6242. assume bottom field first
  6243. @end table
  6244. Default value is @samp{bff}.
  6245. @item qp
  6246. Set per-block quantization parameter (QP) used by the internal
  6247. encoder.
  6248. Higher values should result in a smoother motion vector field but less
  6249. optimal individual vectors. Default value is 1.
  6250. @end table
  6251. @section mergeplanes
  6252. Merge color channel components from several video streams.
  6253. The filter accepts up to 4 input streams, and merge selected input
  6254. planes to the output video.
  6255. This filter accepts the following options:
  6256. @table @option
  6257. @item mapping
  6258. Set input to output plane mapping. Default is @code{0}.
  6259. The mappings is specified as a bitmap. It should be specified as a
  6260. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  6261. mapping for the first plane of the output stream. 'A' sets the number of
  6262. the input stream to use (from 0 to 3), and 'a' the plane number of the
  6263. corresponding input to use (from 0 to 3). The rest of the mappings is
  6264. similar, 'Bb' describes the mapping for the output stream second
  6265. plane, 'Cc' describes the mapping for the output stream third plane and
  6266. 'Dd' describes the mapping for the output stream fourth plane.
  6267. @item format
  6268. Set output pixel format. Default is @code{yuva444p}.
  6269. @end table
  6270. @subsection Examples
  6271. @itemize
  6272. @item
  6273. Merge three gray video streams of same width and height into single video stream:
  6274. @example
  6275. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  6276. @end example
  6277. @item
  6278. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  6279. @example
  6280. [a0][a1]mergeplanes=0x00010210:yuva444p
  6281. @end example
  6282. @item
  6283. Swap Y and A plane in yuva444p stream:
  6284. @example
  6285. format=yuva444p,mergeplanes=0x03010200:yuva444p
  6286. @end example
  6287. @item
  6288. Swap U and V plane in yuv420p stream:
  6289. @example
  6290. format=yuv420p,mergeplanes=0x000201:yuv420p
  6291. @end example
  6292. @item
  6293. Cast a rgb24 clip to yuv444p:
  6294. @example
  6295. format=rgb24,mergeplanes=0x000102:yuv444p
  6296. @end example
  6297. @end itemize
  6298. @section mpdecimate
  6299. Drop frames that do not differ greatly from the previous frame in
  6300. order to reduce frame rate.
  6301. The main use of this filter is for very-low-bitrate encoding
  6302. (e.g. streaming over dialup modem), but it could in theory be used for
  6303. fixing movies that were inverse-telecined incorrectly.
  6304. A description of the accepted options follows.
  6305. @table @option
  6306. @item max
  6307. Set the maximum number of consecutive frames which can be dropped (if
  6308. positive), or the minimum interval between dropped frames (if
  6309. negative). If the value is 0, the frame is dropped unregarding the
  6310. number of previous sequentially dropped frames.
  6311. Default value is 0.
  6312. @item hi
  6313. @item lo
  6314. @item frac
  6315. Set the dropping threshold values.
  6316. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  6317. represent actual pixel value differences, so a threshold of 64
  6318. corresponds to 1 unit of difference for each pixel, or the same spread
  6319. out differently over the block.
  6320. A frame is a candidate for dropping if no 8x8 blocks differ by more
  6321. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  6322. meaning the whole image) differ by more than a threshold of @option{lo}.
  6323. Default value for @option{hi} is 64*12, default value for @option{lo} is
  6324. 64*5, and default value for @option{frac} is 0.33.
  6325. @end table
  6326. @section negate
  6327. Negate input video.
  6328. It accepts an integer in input; if non-zero it negates the
  6329. alpha component (if available). The default value in input is 0.
  6330. @section noformat
  6331. Force libavfilter not to use any of the specified pixel formats for the
  6332. input to the next filter.
  6333. It accepts the following parameters:
  6334. @table @option
  6335. @item pix_fmts
  6336. A '|'-separated list of pixel format names, such as
  6337. apix_fmts=yuv420p|monow|rgb24".
  6338. @end table
  6339. @subsection Examples
  6340. @itemize
  6341. @item
  6342. Force libavfilter to use a format different from @var{yuv420p} for the
  6343. input to the vflip filter:
  6344. @example
  6345. noformat=pix_fmts=yuv420p,vflip
  6346. @end example
  6347. @item
  6348. Convert the input video to any of the formats not contained in the list:
  6349. @example
  6350. noformat=yuv420p|yuv444p|yuv410p
  6351. @end example
  6352. @end itemize
  6353. @section noise
  6354. Add noise on video input frame.
  6355. The filter accepts the following options:
  6356. @table @option
  6357. @item all_seed
  6358. @item c0_seed
  6359. @item c1_seed
  6360. @item c2_seed
  6361. @item c3_seed
  6362. Set noise seed for specific pixel component or all pixel components in case
  6363. of @var{all_seed}. Default value is @code{123457}.
  6364. @item all_strength, alls
  6365. @item c0_strength, c0s
  6366. @item c1_strength, c1s
  6367. @item c2_strength, c2s
  6368. @item c3_strength, c3s
  6369. Set noise strength for specific pixel component or all pixel components in case
  6370. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  6371. @item all_flags, allf
  6372. @item c0_flags, c0f
  6373. @item c1_flags, c1f
  6374. @item c2_flags, c2f
  6375. @item c3_flags, c3f
  6376. Set pixel component flags or set flags for all components if @var{all_flags}.
  6377. Available values for component flags are:
  6378. @table @samp
  6379. @item a
  6380. averaged temporal noise (smoother)
  6381. @item p
  6382. mix random noise with a (semi)regular pattern
  6383. @item t
  6384. temporal noise (noise pattern changes between frames)
  6385. @item u
  6386. uniform noise (gaussian otherwise)
  6387. @end table
  6388. @end table
  6389. @subsection Examples
  6390. Add temporal and uniform noise to input video:
  6391. @example
  6392. noise=alls=20:allf=t+u
  6393. @end example
  6394. @section null
  6395. Pass the video source unchanged to the output.
  6396. @section ocr
  6397. Optical Character Recognition
  6398. This filter uses Tesseract for optical character recognition.
  6399. It accepts the following options:
  6400. @table @option
  6401. @item datapath
  6402. Set datapath to tesseract data. Default is to use whatever was
  6403. set at installation.
  6404. @item language
  6405. Set language, default is "eng".
  6406. @item whitelist
  6407. Set character whitelist.
  6408. @item blacklist
  6409. Set character blacklist.
  6410. @end table
  6411. The filter exports recognized text as the frame metadata @code{lavfi.ocr.text}.
  6412. @section ocv
  6413. Apply a video transform using libopencv.
  6414. To enable this filter, install the libopencv library and headers and
  6415. configure FFmpeg with @code{--enable-libopencv}.
  6416. It accepts the following parameters:
  6417. @table @option
  6418. @item filter_name
  6419. The name of the libopencv filter to apply.
  6420. @item filter_params
  6421. The parameters to pass to the libopencv filter. If not specified, the default
  6422. values are assumed.
  6423. @end table
  6424. Refer to the official libopencv documentation for more precise
  6425. information:
  6426. @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
  6427. Several libopencv filters are supported; see the following subsections.
  6428. @anchor{dilate}
  6429. @subsection dilate
  6430. Dilate an image by using a specific structuring element.
  6431. It corresponds to the libopencv function @code{cvDilate}.
  6432. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  6433. @var{struct_el} represents a structuring element, and has the syntax:
  6434. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  6435. @var{cols} and @var{rows} represent the number of columns and rows of
  6436. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  6437. point, and @var{shape} the shape for the structuring element. @var{shape}
  6438. must be "rect", "cross", "ellipse", or "custom".
  6439. If the value for @var{shape} is "custom", it must be followed by a
  6440. string of the form "=@var{filename}". The file with name
  6441. @var{filename} is assumed to represent a binary image, with each
  6442. printable character corresponding to a bright pixel. When a custom
  6443. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  6444. or columns and rows of the read file are assumed instead.
  6445. The default value for @var{struct_el} is "3x3+0x0/rect".
  6446. @var{nb_iterations} specifies the number of times the transform is
  6447. applied to the image, and defaults to 1.
  6448. Some examples:
  6449. @example
  6450. # Use the default values
  6451. ocv=dilate
  6452. # Dilate using a structuring element with a 5x5 cross, iterating two times
  6453. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  6454. # Read the shape from the file diamond.shape, iterating two times.
  6455. # The file diamond.shape may contain a pattern of characters like this
  6456. # *
  6457. # ***
  6458. # *****
  6459. # ***
  6460. # *
  6461. # The specified columns and rows are ignored
  6462. # but the anchor point coordinates are not
  6463. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  6464. @end example
  6465. @subsection erode
  6466. Erode an image by using a specific structuring element.
  6467. It corresponds to the libopencv function @code{cvErode}.
  6468. It accepts the parameters: @var{struct_el}:@var{nb_iterations},
  6469. with the same syntax and semantics as the @ref{dilate} filter.
  6470. @subsection smooth
  6471. Smooth the input video.
  6472. The filter takes the following parameters:
  6473. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  6474. @var{type} is the type of smooth filter to apply, and must be one of
  6475. the following values: "blur", "blur_no_scale", "median", "gaussian",
  6476. or "bilateral". The default value is "gaussian".
  6477. The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
  6478. depend on the smooth type. @var{param1} and
  6479. @var{param2} accept integer positive values or 0. @var{param3} and
  6480. @var{param4} accept floating point values.
  6481. The default value for @var{param1} is 3. The default value for the
  6482. other parameters is 0.
  6483. These parameters correspond to the parameters assigned to the
  6484. libopencv function @code{cvSmooth}.
  6485. @anchor{overlay}
  6486. @section overlay
  6487. Overlay one video on top of another.
  6488. It takes two inputs and has one output. The first input is the "main"
  6489. video on which the second input is overlaid.
  6490. It accepts the following parameters:
  6491. A description of the accepted options follows.
  6492. @table @option
  6493. @item x
  6494. @item y
  6495. Set the expression for the x and y coordinates of the overlaid video
  6496. on the main video. Default value is "0" for both expressions. In case
  6497. the expression is invalid, it is set to a huge value (meaning that the
  6498. overlay will not be displayed within the output visible area).
  6499. @item eof_action
  6500. The action to take when EOF is encountered on the secondary input; it accepts
  6501. one of the following values:
  6502. @table @option
  6503. @item repeat
  6504. Repeat the last frame (the default).
  6505. @item endall
  6506. End both streams.
  6507. @item pass
  6508. Pass the main input through.
  6509. @end table
  6510. @item eval
  6511. Set when the expressions for @option{x}, and @option{y} are evaluated.
  6512. It accepts the following values:
  6513. @table @samp
  6514. @item init
  6515. only evaluate expressions once during the filter initialization or
  6516. when a command is processed
  6517. @item frame
  6518. evaluate expressions for each incoming frame
  6519. @end table
  6520. Default value is @samp{frame}.
  6521. @item shortest
  6522. If set to 1, force the output to terminate when the shortest input
  6523. terminates. Default value is 0.
  6524. @item format
  6525. Set the format for the output video.
  6526. It accepts the following values:
  6527. @table @samp
  6528. @item yuv420
  6529. force YUV420 output
  6530. @item yuv422
  6531. force YUV422 output
  6532. @item yuv444
  6533. force YUV444 output
  6534. @item rgb
  6535. force RGB output
  6536. @end table
  6537. Default value is @samp{yuv420}.
  6538. @item rgb @emph{(deprecated)}
  6539. If set to 1, force the filter to accept inputs in the RGB
  6540. color space. Default value is 0. This option is deprecated, use
  6541. @option{format} instead.
  6542. @item repeatlast
  6543. If set to 1, force the filter to draw the last overlay frame over the
  6544. main input until the end of the stream. A value of 0 disables this
  6545. behavior. Default value is 1.
  6546. @end table
  6547. The @option{x}, and @option{y} expressions can contain the following
  6548. parameters.
  6549. @table @option
  6550. @item main_w, W
  6551. @item main_h, H
  6552. The main input width and height.
  6553. @item overlay_w, w
  6554. @item overlay_h, h
  6555. The overlay input width and height.
  6556. @item x
  6557. @item y
  6558. The computed values for @var{x} and @var{y}. They are evaluated for
  6559. each new frame.
  6560. @item hsub
  6561. @item vsub
  6562. horizontal and vertical chroma subsample values of the output
  6563. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  6564. @var{vsub} is 1.
  6565. @item n
  6566. the number of input frame, starting from 0
  6567. @item pos
  6568. the position in the file of the input frame, NAN if unknown
  6569. @item t
  6570. The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
  6571. @end table
  6572. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  6573. when evaluation is done @emph{per frame}, and will evaluate to NAN
  6574. when @option{eval} is set to @samp{init}.
  6575. Be aware that frames are taken from each input video in timestamp
  6576. order, hence, if their initial timestamps differ, it is a good idea
  6577. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  6578. have them begin in the same zero timestamp, as the example for
  6579. the @var{movie} filter does.
  6580. You can chain together more overlays but you should test the
  6581. efficiency of such approach.
  6582. @subsection Commands
  6583. This filter supports the following commands:
  6584. @table @option
  6585. @item x
  6586. @item y
  6587. Modify the x and y of the overlay input.
  6588. The command accepts the same syntax of the corresponding option.
  6589. If the specified expression is not valid, it is kept at its current
  6590. value.
  6591. @end table
  6592. @subsection Examples
  6593. @itemize
  6594. @item
  6595. Draw the overlay at 10 pixels from the bottom right corner of the main
  6596. video:
  6597. @example
  6598. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  6599. @end example
  6600. Using named options the example above becomes:
  6601. @example
  6602. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  6603. @end example
  6604. @item
  6605. Insert a transparent PNG logo in the bottom left corner of the input,
  6606. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  6607. @example
  6608. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  6609. @end example
  6610. @item
  6611. Insert 2 different transparent PNG logos (second logo on bottom
  6612. right corner) using the @command{ffmpeg} tool:
  6613. @example
  6614. 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
  6615. @end example
  6616. @item
  6617. Add a transparent color layer on top of the main video; @code{WxH}
  6618. must specify the size of the main input to the overlay filter:
  6619. @example
  6620. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  6621. @end example
  6622. @item
  6623. Play an original video and a filtered version (here with the deshake
  6624. filter) side by side using the @command{ffplay} tool:
  6625. @example
  6626. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  6627. @end example
  6628. The above command is the same as:
  6629. @example
  6630. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  6631. @end example
  6632. @item
  6633. Make a sliding overlay appearing from the left to the right top part of the
  6634. screen starting since time 2:
  6635. @example
  6636. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  6637. @end example
  6638. @item
  6639. Compose output by putting two input videos side to side:
  6640. @example
  6641. ffmpeg -i left.avi -i right.avi -filter_complex "
  6642. nullsrc=size=200x100 [background];
  6643. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  6644. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  6645. [background][left] overlay=shortest=1 [background+left];
  6646. [background+left][right] overlay=shortest=1:x=100 [left+right]
  6647. "
  6648. @end example
  6649. @item
  6650. Mask 10-20 seconds of a video by applying the delogo filter to a section
  6651. @example
  6652. ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
  6653. -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]'
  6654. masked.avi
  6655. @end example
  6656. @item
  6657. Chain several overlays in cascade:
  6658. @example
  6659. nullsrc=s=200x200 [bg];
  6660. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  6661. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  6662. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  6663. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  6664. [in3] null, [mid2] overlay=100:100 [out0]
  6665. @end example
  6666. @end itemize
  6667. @section owdenoise
  6668. Apply Overcomplete Wavelet denoiser.
  6669. The filter accepts the following options:
  6670. @table @option
  6671. @item depth
  6672. Set depth.
  6673. Larger depth values will denoise lower frequency components more, but
  6674. slow down filtering.
  6675. Must be an int in the range 8-16, default is @code{8}.
  6676. @item luma_strength, ls
  6677. Set luma strength.
  6678. Must be a double value in the range 0-1000, default is @code{1.0}.
  6679. @item chroma_strength, cs
  6680. Set chroma strength.
  6681. Must be a double value in the range 0-1000, default is @code{1.0}.
  6682. @end table
  6683. @anchor{pad}
  6684. @section pad
  6685. Add paddings to the input image, and place the original input at the
  6686. provided @var{x}, @var{y} coordinates.
  6687. It accepts the following parameters:
  6688. @table @option
  6689. @item width, w
  6690. @item height, h
  6691. Specify an expression for the size of the output image with the
  6692. paddings added. If the value for @var{width} or @var{height} is 0, the
  6693. corresponding input size is used for the output.
  6694. The @var{width} expression can reference the value set by the
  6695. @var{height} expression, and vice versa.
  6696. The default value of @var{width} and @var{height} is 0.
  6697. @item x
  6698. @item y
  6699. Specify the offsets to place the input image at within the padded area,
  6700. with respect to the top/left border of the output image.
  6701. The @var{x} expression can reference the value set by the @var{y}
  6702. expression, and vice versa.
  6703. The default value of @var{x} and @var{y} is 0.
  6704. @item color
  6705. Specify the color of the padded area. For the syntax of this option,
  6706. check the "Color" section in the ffmpeg-utils manual.
  6707. The default value of @var{color} is "black".
  6708. @end table
  6709. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  6710. options are expressions containing the following constants:
  6711. @table @option
  6712. @item in_w
  6713. @item in_h
  6714. The input video width and height.
  6715. @item iw
  6716. @item ih
  6717. These are the same as @var{in_w} and @var{in_h}.
  6718. @item out_w
  6719. @item out_h
  6720. The output width and height (the size of the padded area), as
  6721. specified by the @var{width} and @var{height} expressions.
  6722. @item ow
  6723. @item oh
  6724. These are the same as @var{out_w} and @var{out_h}.
  6725. @item x
  6726. @item y
  6727. The x and y offsets as specified by the @var{x} and @var{y}
  6728. expressions, or NAN if not yet specified.
  6729. @item a
  6730. same as @var{iw} / @var{ih}
  6731. @item sar
  6732. input sample aspect ratio
  6733. @item dar
  6734. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  6735. @item hsub
  6736. @item vsub
  6737. The horizontal and vertical chroma subsample values. For example for the
  6738. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6739. @end table
  6740. @subsection Examples
  6741. @itemize
  6742. @item
  6743. Add paddings with the color "violet" to the input video. The output video
  6744. size is 640x480, and the top-left corner of the input video is placed at
  6745. column 0, row 40
  6746. @example
  6747. pad=640:480:0:40:violet
  6748. @end example
  6749. The example above is equivalent to the following command:
  6750. @example
  6751. pad=width=640:height=480:x=0:y=40:color=violet
  6752. @end example
  6753. @item
  6754. Pad the input to get an output with dimensions increased by 3/2,
  6755. and put the input video at the center of the padded area:
  6756. @example
  6757. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  6758. @end example
  6759. @item
  6760. Pad the input to get a squared output with size equal to the maximum
  6761. value between the input width and height, and put the input video at
  6762. the center of the padded area:
  6763. @example
  6764. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  6765. @end example
  6766. @item
  6767. Pad the input to get a final w/h ratio of 16:9:
  6768. @example
  6769. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  6770. @end example
  6771. @item
  6772. In case of anamorphic video, in order to set the output display aspect
  6773. correctly, it is necessary to use @var{sar} in the expression,
  6774. according to the relation:
  6775. @example
  6776. (ih * X / ih) * sar = output_dar
  6777. X = output_dar / sar
  6778. @end example
  6779. Thus the previous example needs to be modified to:
  6780. @example
  6781. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  6782. @end example
  6783. @item
  6784. Double the output size and put the input video in the bottom-right
  6785. corner of the output padded area:
  6786. @example
  6787. pad="2*iw:2*ih:ow-iw:oh-ih"
  6788. @end example
  6789. @end itemize
  6790. @anchor{palettegen}
  6791. @section palettegen
  6792. Generate one palette for a whole video stream.
  6793. It accepts the following options:
  6794. @table @option
  6795. @item max_colors
  6796. Set the maximum number of colors to quantize in the palette.
  6797. Note: the palette will still contain 256 colors; the unused palette entries
  6798. will be black.
  6799. @item reserve_transparent
  6800. Create a palette of 255 colors maximum and reserve the last one for
  6801. transparency. Reserving the transparency color is useful for GIF optimization.
  6802. If not set, the maximum of colors in the palette will be 256. You probably want
  6803. to disable this option for a standalone image.
  6804. Set by default.
  6805. @item stats_mode
  6806. Set statistics mode.
  6807. It accepts the following values:
  6808. @table @samp
  6809. @item full
  6810. Compute full frame histograms.
  6811. @item diff
  6812. Compute histograms only for the part that differs from previous frame. This
  6813. might be relevant to give more importance to the moving part of your input if
  6814. the background is static.
  6815. @end table
  6816. Default value is @var{full}.
  6817. @end table
  6818. The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
  6819. (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
  6820. color quantization of the palette. This information is also visible at
  6821. @var{info} logging level.
  6822. @subsection Examples
  6823. @itemize
  6824. @item
  6825. Generate a representative palette of a given video using @command{ffmpeg}:
  6826. @example
  6827. ffmpeg -i input.mkv -vf palettegen palette.png
  6828. @end example
  6829. @end itemize
  6830. @section paletteuse
  6831. Use a palette to downsample an input video stream.
  6832. The filter takes two inputs: one video stream and a palette. The palette must
  6833. be a 256 pixels image.
  6834. It accepts the following options:
  6835. @table @option
  6836. @item dither
  6837. Select dithering mode. Available algorithms are:
  6838. @table @samp
  6839. @item bayer
  6840. Ordered 8x8 bayer dithering (deterministic)
  6841. @item heckbert
  6842. Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
  6843. Note: this dithering is sometimes considered "wrong" and is included as a
  6844. reference.
  6845. @item floyd_steinberg
  6846. Floyd and Steingberg dithering (error diffusion)
  6847. @item sierra2
  6848. Frankie Sierra dithering v2 (error diffusion)
  6849. @item sierra2_4a
  6850. Frankie Sierra dithering v2 "Lite" (error diffusion)
  6851. @end table
  6852. Default is @var{sierra2_4a}.
  6853. @item bayer_scale
  6854. When @var{bayer} dithering is selected, this option defines the scale of the
  6855. pattern (how much the crosshatch pattern is visible). A low value means more
  6856. visible pattern for less banding, and higher value means less visible pattern
  6857. at the cost of more banding.
  6858. The option must be an integer value in the range [0,5]. Default is @var{2}.
  6859. @item diff_mode
  6860. If set, define the zone to process
  6861. @table @samp
  6862. @item rectangle
  6863. Only the changing rectangle will be reprocessed. This is similar to GIF
  6864. cropping/offsetting compression mechanism. This option can be useful for speed
  6865. if only a part of the image is changing, and has use cases such as limiting the
  6866. scope of the error diffusal @option{dither} to the rectangle that bounds the
  6867. moving scene (it leads to more deterministic output if the scene doesn't change
  6868. much, and as a result less moving noise and better GIF compression).
  6869. @end table
  6870. Default is @var{none}.
  6871. @end table
  6872. @subsection Examples
  6873. @itemize
  6874. @item
  6875. Use a palette (generated for example with @ref{palettegen}) to encode a GIF
  6876. using @command{ffmpeg}:
  6877. @example
  6878. ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
  6879. @end example
  6880. @end itemize
  6881. @section perspective
  6882. Correct perspective of video not recorded perpendicular to the screen.
  6883. A description of the accepted parameters follows.
  6884. @table @option
  6885. @item x0
  6886. @item y0
  6887. @item x1
  6888. @item y1
  6889. @item x2
  6890. @item y2
  6891. @item x3
  6892. @item y3
  6893. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  6894. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  6895. If the @code{sense} option is set to @code{source}, then the specified points will be sent
  6896. to the corners of the destination. If the @code{sense} option is set to @code{destination},
  6897. then the corners of the source will be sent to the specified coordinates.
  6898. The expressions can use the following variables:
  6899. @table @option
  6900. @item W
  6901. @item H
  6902. the width and height of video frame.
  6903. @end table
  6904. @item interpolation
  6905. Set interpolation for perspective correction.
  6906. It accepts the following values:
  6907. @table @samp
  6908. @item linear
  6909. @item cubic
  6910. @end table
  6911. Default value is @samp{linear}.
  6912. @item sense
  6913. Set interpretation of coordinate options.
  6914. It accepts the following values:
  6915. @table @samp
  6916. @item 0, source
  6917. Send point in the source specified by the given coordinates to
  6918. the corners of the destination.
  6919. @item 1, destination
  6920. Send the corners of the source to the point in the destination specified
  6921. by the given coordinates.
  6922. Default value is @samp{source}.
  6923. @end table
  6924. @end table
  6925. @section phase
  6926. Delay interlaced video by one field time so that the field order changes.
  6927. The intended use is to fix PAL movies that have been captured with the
  6928. opposite field order to the film-to-video transfer.
  6929. A description of the accepted parameters follows.
  6930. @table @option
  6931. @item mode
  6932. Set phase mode.
  6933. It accepts the following values:
  6934. @table @samp
  6935. @item t
  6936. Capture field order top-first, transfer bottom-first.
  6937. Filter will delay the bottom field.
  6938. @item b
  6939. Capture field order bottom-first, transfer top-first.
  6940. Filter will delay the top field.
  6941. @item p
  6942. Capture and transfer with the same field order. This mode only exists
  6943. for the documentation of the other options to refer to, but if you
  6944. actually select it, the filter will faithfully do nothing.
  6945. @item a
  6946. Capture field order determined automatically by field flags, transfer
  6947. opposite.
  6948. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  6949. basis using field flags. If no field information is available,
  6950. then this works just like @samp{u}.
  6951. @item u
  6952. Capture unknown or varying, transfer opposite.
  6953. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  6954. analyzing the images and selecting the alternative that produces best
  6955. match between the fields.
  6956. @item T
  6957. Capture top-first, transfer unknown or varying.
  6958. Filter selects among @samp{t} and @samp{p} using image analysis.
  6959. @item B
  6960. Capture bottom-first, transfer unknown or varying.
  6961. Filter selects among @samp{b} and @samp{p} using image analysis.
  6962. @item A
  6963. Capture determined by field flags, transfer unknown or varying.
  6964. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  6965. image analysis. If no field information is available, then this works just
  6966. like @samp{U}. This is the default mode.
  6967. @item U
  6968. Both capture and transfer unknown or varying.
  6969. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  6970. @end table
  6971. @end table
  6972. @section pixdesctest
  6973. Pixel format descriptor test filter, mainly useful for internal
  6974. testing. The output video should be equal to the input video.
  6975. For example:
  6976. @example
  6977. format=monow, pixdesctest
  6978. @end example
  6979. can be used to test the monowhite pixel format descriptor definition.
  6980. @section pp
  6981. Enable the specified chain of postprocessing subfilters using libpostproc. This
  6982. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  6983. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  6984. Each subfilter and some options have a short and a long name that can be used
  6985. interchangeably, i.e. dr/dering are the same.
  6986. The filters accept the following options:
  6987. @table @option
  6988. @item subfilters
  6989. Set postprocessing subfilters string.
  6990. @end table
  6991. All subfilters share common options to determine their scope:
  6992. @table @option
  6993. @item a/autoq
  6994. Honor the quality commands for this subfilter.
  6995. @item c/chrom
  6996. Do chrominance filtering, too (default).
  6997. @item y/nochrom
  6998. Do luminance filtering only (no chrominance).
  6999. @item n/noluma
  7000. Do chrominance filtering only (no luminance).
  7001. @end table
  7002. These options can be appended after the subfilter name, separated by a '|'.
  7003. Available subfilters are:
  7004. @table @option
  7005. @item hb/hdeblock[|difference[|flatness]]
  7006. Horizontal deblocking filter
  7007. @table @option
  7008. @item difference
  7009. Difference factor where higher values mean more deblocking (default: @code{32}).
  7010. @item flatness
  7011. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7012. @end table
  7013. @item vb/vdeblock[|difference[|flatness]]
  7014. Vertical deblocking filter
  7015. @table @option
  7016. @item difference
  7017. Difference factor where higher values mean more deblocking (default: @code{32}).
  7018. @item flatness
  7019. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7020. @end table
  7021. @item ha/hadeblock[|difference[|flatness]]
  7022. Accurate horizontal deblocking filter
  7023. @table @option
  7024. @item difference
  7025. Difference factor where higher values mean more deblocking (default: @code{32}).
  7026. @item flatness
  7027. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7028. @end table
  7029. @item va/vadeblock[|difference[|flatness]]
  7030. Accurate vertical deblocking filter
  7031. @table @option
  7032. @item difference
  7033. Difference factor where higher values mean more deblocking (default: @code{32}).
  7034. @item flatness
  7035. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7036. @end table
  7037. @end table
  7038. The horizontal and vertical deblocking filters share the difference and
  7039. flatness values so you cannot set different horizontal and vertical
  7040. thresholds.
  7041. @table @option
  7042. @item h1/x1hdeblock
  7043. Experimental horizontal deblocking filter
  7044. @item v1/x1vdeblock
  7045. Experimental vertical deblocking filter
  7046. @item dr/dering
  7047. Deringing filter
  7048. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  7049. @table @option
  7050. @item threshold1
  7051. larger -> stronger filtering
  7052. @item threshold2
  7053. larger -> stronger filtering
  7054. @item threshold3
  7055. larger -> stronger filtering
  7056. @end table
  7057. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  7058. @table @option
  7059. @item f/fullyrange
  7060. Stretch luminance to @code{0-255}.
  7061. @end table
  7062. @item lb/linblenddeint
  7063. Linear blend deinterlacing filter that deinterlaces the given block by
  7064. filtering all lines with a @code{(1 2 1)} filter.
  7065. @item li/linipoldeint
  7066. Linear interpolating deinterlacing filter that deinterlaces the given block by
  7067. linearly interpolating every second line.
  7068. @item ci/cubicipoldeint
  7069. Cubic interpolating deinterlacing filter deinterlaces the given block by
  7070. cubically interpolating every second line.
  7071. @item md/mediandeint
  7072. Median deinterlacing filter that deinterlaces the given block by applying a
  7073. median filter to every second line.
  7074. @item fd/ffmpegdeint
  7075. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  7076. second line with a @code{(-1 4 2 4 -1)} filter.
  7077. @item l5/lowpass5
  7078. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  7079. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  7080. @item fq/forceQuant[|quantizer]
  7081. Overrides the quantizer table from the input with the constant quantizer you
  7082. specify.
  7083. @table @option
  7084. @item quantizer
  7085. Quantizer to use
  7086. @end table
  7087. @item de/default
  7088. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  7089. @item fa/fast
  7090. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  7091. @item ac
  7092. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  7093. @end table
  7094. @subsection Examples
  7095. @itemize
  7096. @item
  7097. Apply horizontal and vertical deblocking, deringing and automatic
  7098. brightness/contrast:
  7099. @example
  7100. pp=hb/vb/dr/al
  7101. @end example
  7102. @item
  7103. Apply default filters without brightness/contrast correction:
  7104. @example
  7105. pp=de/-al
  7106. @end example
  7107. @item
  7108. Apply default filters and temporal denoiser:
  7109. @example
  7110. pp=default/tmpnoise|1|2|3
  7111. @end example
  7112. @item
  7113. Apply deblocking on luminance only, and switch vertical deblocking on or off
  7114. automatically depending on available CPU time:
  7115. @example
  7116. pp=hb|y/vb|a
  7117. @end example
  7118. @end itemize
  7119. @section pp7
  7120. Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
  7121. similar to spp = 6 with 7 point DCT, where only the center sample is
  7122. used after IDCT.
  7123. The filter accepts the following options:
  7124. @table @option
  7125. @item qp
  7126. Force a constant quantization parameter. It accepts an integer in range
  7127. 0 to 63. If not set, the filter will use the QP from the video stream
  7128. (if available).
  7129. @item mode
  7130. Set thresholding mode. Available modes are:
  7131. @table @samp
  7132. @item hard
  7133. Set hard thresholding.
  7134. @item soft
  7135. Set soft thresholding (better de-ringing effect, but likely blurrier).
  7136. @item medium
  7137. Set medium thresholding (good results, default).
  7138. @end table
  7139. @end table
  7140. @section psnr
  7141. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  7142. Ratio) between two input videos.
  7143. This filter takes in input two input videos, the first input is
  7144. considered the "main" source and is passed unchanged to the
  7145. output. The second input is used as a "reference" video for computing
  7146. the PSNR.
  7147. Both video inputs must have the same resolution and pixel format for
  7148. this filter to work correctly. Also it assumes that both inputs
  7149. have the same number of frames, which are compared one by one.
  7150. The obtained average PSNR is printed through the logging system.
  7151. The filter stores the accumulated MSE (mean squared error) of each
  7152. frame, and at the end of the processing it is averaged across all frames
  7153. equally, and the following formula is applied to obtain the PSNR:
  7154. @example
  7155. PSNR = 10*log10(MAX^2/MSE)
  7156. @end example
  7157. Where MAX is the average of the maximum values of each component of the
  7158. image.
  7159. The description of the accepted parameters follows.
  7160. @table @option
  7161. @item stats_file, f
  7162. If specified the filter will use the named file to save the PSNR of
  7163. each individual frame. When filename equals "-" the data is sent to
  7164. standard output.
  7165. @end table
  7166. The file printed if @var{stats_file} is selected, contains a sequence of
  7167. key/value pairs of the form @var{key}:@var{value} for each compared
  7168. couple of frames.
  7169. A description of each shown parameter follows:
  7170. @table @option
  7171. @item n
  7172. sequential number of the input frame, starting from 1
  7173. @item mse_avg
  7174. Mean Square Error pixel-by-pixel average difference of the compared
  7175. frames, averaged over all the image components.
  7176. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  7177. Mean Square Error pixel-by-pixel average difference of the compared
  7178. frames for the component specified by the suffix.
  7179. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  7180. Peak Signal to Noise ratio of the compared frames for the component
  7181. specified by the suffix.
  7182. @end table
  7183. For example:
  7184. @example
  7185. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  7186. [main][ref] psnr="stats_file=stats.log" [out]
  7187. @end example
  7188. On this example the input file being processed is compared with the
  7189. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  7190. is stored in @file{stats.log}.
  7191. @anchor{pullup}
  7192. @section pullup
  7193. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  7194. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  7195. content.
  7196. The pullup filter is designed to take advantage of future context in making
  7197. its decisions. This filter is stateless in the sense that it does not lock
  7198. onto a pattern to follow, but it instead looks forward to the following
  7199. fields in order to identify matches and rebuild progressive frames.
  7200. To produce content with an even framerate, insert the fps filter after
  7201. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  7202. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  7203. The filter accepts the following options:
  7204. @table @option
  7205. @item jl
  7206. @item jr
  7207. @item jt
  7208. @item jb
  7209. These options set the amount of "junk" to ignore at the left, right, top, and
  7210. bottom of the image, respectively. Left and right are in units of 8 pixels,
  7211. while top and bottom are in units of 2 lines.
  7212. The default is 8 pixels on each side.
  7213. @item sb
  7214. Set the strict breaks. Setting this option to 1 will reduce the chances of
  7215. filter generating an occasional mismatched frame, but it may also cause an
  7216. excessive number of frames to be dropped during high motion sequences.
  7217. Conversely, setting it to -1 will make filter match fields more easily.
  7218. This may help processing of video where there is slight blurring between
  7219. the fields, but may also cause there to be interlaced frames in the output.
  7220. Default value is @code{0}.
  7221. @item mp
  7222. Set the metric plane to use. It accepts the following values:
  7223. @table @samp
  7224. @item l
  7225. Use luma plane.
  7226. @item u
  7227. Use chroma blue plane.
  7228. @item v
  7229. Use chroma red plane.
  7230. @end table
  7231. This option may be set to use chroma plane instead of the default luma plane
  7232. for doing filter's computations. This may improve accuracy on very clean
  7233. source material, but more likely will decrease accuracy, especially if there
  7234. is chroma noise (rainbow effect) or any grayscale video.
  7235. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  7236. load and make pullup usable in realtime on slow machines.
  7237. @end table
  7238. For best results (without duplicated frames in the output file) it is
  7239. necessary to change the output frame rate. For example, to inverse
  7240. telecine NTSC input:
  7241. @example
  7242. ffmpeg -i input -vf pullup -r 24000/1001 ...
  7243. @end example
  7244. @section qp
  7245. Change video quantization parameters (QP).
  7246. The filter accepts the following option:
  7247. @table @option
  7248. @item qp
  7249. Set expression for quantization parameter.
  7250. @end table
  7251. The expression is evaluated through the eval API and can contain, among others,
  7252. the following constants:
  7253. @table @var
  7254. @item known
  7255. 1 if index is not 129, 0 otherwise.
  7256. @item qp
  7257. Sequentional index starting from -129 to 128.
  7258. @end table
  7259. @subsection Examples
  7260. @itemize
  7261. @item
  7262. Some equation like:
  7263. @example
  7264. qp=2+2*sin(PI*qp)
  7265. @end example
  7266. @end itemize
  7267. @section random
  7268. Flush video frames from internal cache of frames into a random order.
  7269. No frame is discarded.
  7270. Inspired by @ref{frei0r} nervous filter.
  7271. @table @option
  7272. @item frames
  7273. Set size in number of frames of internal cache, in range from @code{2} to
  7274. @code{512}. Default is @code{30}.
  7275. @item seed
  7276. Set seed for random number generator, must be an integer included between
  7277. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  7278. less than @code{0}, the filter will try to use a good random seed on a
  7279. best effort basis.
  7280. @end table
  7281. @section removegrain
  7282. The removegrain filter is a spatial denoiser for progressive video.
  7283. @table @option
  7284. @item m0
  7285. Set mode for the first plane.
  7286. @item m1
  7287. Set mode for the second plane.
  7288. @item m2
  7289. Set mode for the third plane.
  7290. @item m3
  7291. Set mode for the fourth plane.
  7292. @end table
  7293. Range of mode is from 0 to 24. Description of each mode follows:
  7294. @table @var
  7295. @item 0
  7296. Leave input plane unchanged. Default.
  7297. @item 1
  7298. Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
  7299. @item 2
  7300. Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
  7301. @item 3
  7302. Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
  7303. @item 4
  7304. Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
  7305. This is equivalent to a median filter.
  7306. @item 5
  7307. Line-sensitive clipping giving the minimal change.
  7308. @item 6
  7309. Line-sensitive clipping, intermediate.
  7310. @item 7
  7311. Line-sensitive clipping, intermediate.
  7312. @item 8
  7313. Line-sensitive clipping, intermediate.
  7314. @item 9
  7315. Line-sensitive clipping on a line where the neighbours pixels are the closest.
  7316. @item 10
  7317. Replaces the target pixel with the closest neighbour.
  7318. @item 11
  7319. [1 2 1] horizontal and vertical kernel blur.
  7320. @item 12
  7321. Same as mode 11.
  7322. @item 13
  7323. Bob mode, interpolates top field from the line where the neighbours
  7324. pixels are the closest.
  7325. @item 14
  7326. Bob mode, interpolates bottom field from the line where the neighbours
  7327. pixels are the closest.
  7328. @item 15
  7329. Bob mode, interpolates top field. Same as 13 but with a more complicated
  7330. interpolation formula.
  7331. @item 16
  7332. Bob mode, interpolates bottom field. Same as 14 but with a more complicated
  7333. interpolation formula.
  7334. @item 17
  7335. Clips the pixel with the minimum and maximum of respectively the maximum and
  7336. minimum of each pair of opposite neighbour pixels.
  7337. @item 18
  7338. Line-sensitive clipping using opposite neighbours whose greatest distance from
  7339. the current pixel is minimal.
  7340. @item 19
  7341. Replaces the pixel with the average of its 8 neighbours.
  7342. @item 20
  7343. Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
  7344. @item 21
  7345. Clips pixels using the averages of opposite neighbour.
  7346. @item 22
  7347. Same as mode 21 but simpler and faster.
  7348. @item 23
  7349. Small edge and halo removal, but reputed useless.
  7350. @item 24
  7351. Similar as 23.
  7352. @end table
  7353. @section removelogo
  7354. Suppress a TV station logo, using an image file to determine which
  7355. pixels comprise the logo. It works by filling in the pixels that
  7356. comprise the logo with neighboring pixels.
  7357. The filter accepts the following options:
  7358. @table @option
  7359. @item filename, f
  7360. Set the filter bitmap file, which can be any image format supported by
  7361. libavformat. The width and height of the image file must match those of the
  7362. video stream being processed.
  7363. @end table
  7364. Pixels in the provided bitmap image with a value of zero are not
  7365. considered part of the logo, non-zero pixels are considered part of
  7366. the logo. If you use white (255) for the logo and black (0) for the
  7367. rest, you will be safe. For making the filter bitmap, it is
  7368. recommended to take a screen capture of a black frame with the logo
  7369. visible, and then using a threshold filter followed by the erode
  7370. filter once or twice.
  7371. If needed, little splotches can be fixed manually. Remember that if
  7372. logo pixels are not covered, the filter quality will be much
  7373. reduced. Marking too many pixels as part of the logo does not hurt as
  7374. much, but it will increase the amount of blurring needed to cover over
  7375. the image and will destroy more information than necessary, and extra
  7376. pixels will slow things down on a large logo.
  7377. @section repeatfields
  7378. This filter uses the repeat_field flag from the Video ES headers and hard repeats
  7379. fields based on its value.
  7380. @section reverse, areverse
  7381. Reverse a clip.
  7382. Warning: This filter requires memory to buffer the entire clip, so trimming
  7383. is suggested.
  7384. @subsection Examples
  7385. @itemize
  7386. @item
  7387. Take the first 5 seconds of a clip, and reverse it.
  7388. @example
  7389. trim=end=5,reverse
  7390. @end example
  7391. @end itemize
  7392. @section rotate
  7393. Rotate video by an arbitrary angle expressed in radians.
  7394. The filter accepts the following options:
  7395. A description of the optional parameters follows.
  7396. @table @option
  7397. @item angle, a
  7398. Set an expression for the angle by which to rotate the input video
  7399. clockwise, expressed as a number of radians. A negative value will
  7400. result in a counter-clockwise rotation. By default it is set to "0".
  7401. This expression is evaluated for each frame.
  7402. @item out_w, ow
  7403. Set the output width expression, default value is "iw".
  7404. This expression is evaluated just once during configuration.
  7405. @item out_h, oh
  7406. Set the output height expression, default value is "ih".
  7407. This expression is evaluated just once during configuration.
  7408. @item bilinear
  7409. Enable bilinear interpolation if set to 1, a value of 0 disables
  7410. it. Default value is 1.
  7411. @item fillcolor, c
  7412. Set the color used to fill the output area not covered by the rotated
  7413. image. For the general syntax of this option, check the "Color" section in the
  7414. ffmpeg-utils manual. If the special value "none" is selected then no
  7415. background is printed (useful for example if the background is never shown).
  7416. Default value is "black".
  7417. @end table
  7418. The expressions for the angle and the output size can contain the
  7419. following constants and functions:
  7420. @table @option
  7421. @item n
  7422. sequential number of the input frame, starting from 0. It is always NAN
  7423. before the first frame is filtered.
  7424. @item t
  7425. time in seconds of the input frame, it is set to 0 when the filter is
  7426. configured. It is always NAN before the first frame is filtered.
  7427. @item hsub
  7428. @item vsub
  7429. horizontal and vertical chroma subsample values. For example for the
  7430. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7431. @item in_w, iw
  7432. @item in_h, ih
  7433. the input video width and height
  7434. @item out_w, ow
  7435. @item out_h, oh
  7436. the output width and height, that is the size of the padded area as
  7437. specified by the @var{width} and @var{height} expressions
  7438. @item rotw(a)
  7439. @item roth(a)
  7440. the minimal width/height required for completely containing the input
  7441. video rotated by @var{a} radians.
  7442. These are only available when computing the @option{out_w} and
  7443. @option{out_h} expressions.
  7444. @end table
  7445. @subsection Examples
  7446. @itemize
  7447. @item
  7448. Rotate the input by PI/6 radians clockwise:
  7449. @example
  7450. rotate=PI/6
  7451. @end example
  7452. @item
  7453. Rotate the input by PI/6 radians counter-clockwise:
  7454. @example
  7455. rotate=-PI/6
  7456. @end example
  7457. @item
  7458. Rotate the input by 45 degrees clockwise:
  7459. @example
  7460. rotate=45*PI/180
  7461. @end example
  7462. @item
  7463. Apply a constant rotation with period T, starting from an angle of PI/3:
  7464. @example
  7465. rotate=PI/3+2*PI*t/T
  7466. @end example
  7467. @item
  7468. Make the input video rotation oscillating with a period of T
  7469. seconds and an amplitude of A radians:
  7470. @example
  7471. rotate=A*sin(2*PI/T*t)
  7472. @end example
  7473. @item
  7474. Rotate the video, output size is chosen so that the whole rotating
  7475. input video is always completely contained in the output:
  7476. @example
  7477. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  7478. @end example
  7479. @item
  7480. Rotate the video, reduce the output size so that no background is ever
  7481. shown:
  7482. @example
  7483. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  7484. @end example
  7485. @end itemize
  7486. @subsection Commands
  7487. The filter supports the following commands:
  7488. @table @option
  7489. @item a, angle
  7490. Set the angle expression.
  7491. The command accepts the same syntax of the corresponding option.
  7492. If the specified expression is not valid, it is kept at its current
  7493. value.
  7494. @end table
  7495. @section sab
  7496. Apply Shape Adaptive Blur.
  7497. The filter accepts the following options:
  7498. @table @option
  7499. @item luma_radius, lr
  7500. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  7501. value is 1.0. A greater value will result in a more blurred image, and
  7502. in slower processing.
  7503. @item luma_pre_filter_radius, lpfr
  7504. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  7505. value is 1.0.
  7506. @item luma_strength, ls
  7507. Set luma maximum difference between pixels to still be considered, must
  7508. be a value in the 0.1-100.0 range, default value is 1.0.
  7509. @item chroma_radius, cr
  7510. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  7511. greater value will result in a more blurred image, and in slower
  7512. processing.
  7513. @item chroma_pre_filter_radius, cpfr
  7514. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  7515. @item chroma_strength, cs
  7516. Set chroma maximum difference between pixels to still be considered,
  7517. must be a value in the 0.1-100.0 range.
  7518. @end table
  7519. Each chroma option value, if not explicitly specified, is set to the
  7520. corresponding luma option value.
  7521. @anchor{scale}
  7522. @section scale
  7523. Scale (resize) the input video, using the libswscale library.
  7524. The scale filter forces the output display aspect ratio to be the same
  7525. of the input, by changing the output sample aspect ratio.
  7526. If the input image format is different from the format requested by
  7527. the next filter, the scale filter will convert the input to the
  7528. requested format.
  7529. @subsection Options
  7530. The filter accepts the following options, or any of the options
  7531. supported by the libswscale scaler.
  7532. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  7533. the complete list of scaler options.
  7534. @table @option
  7535. @item width, w
  7536. @item height, h
  7537. Set the output video dimension expression. Default value is the input
  7538. dimension.
  7539. If the value is 0, the input width is used for the output.
  7540. If one of the values is -1, the scale filter will use a value that
  7541. maintains the aspect ratio of the input image, calculated from the
  7542. other specified dimension. If both of them are -1, the input size is
  7543. used
  7544. If one of the values is -n with n > 1, the scale filter will also use a value
  7545. that maintains the aspect ratio of the input image, calculated from the other
  7546. specified dimension. After that it will, however, make sure that the calculated
  7547. dimension is divisible by n and adjust the value if necessary.
  7548. See below for the list of accepted constants for use in the dimension
  7549. expression.
  7550. @item interl
  7551. Set the interlacing mode. It accepts the following values:
  7552. @table @samp
  7553. @item 1
  7554. Force interlaced aware scaling.
  7555. @item 0
  7556. Do not apply interlaced scaling.
  7557. @item -1
  7558. Select interlaced aware scaling depending on whether the source frames
  7559. are flagged as interlaced or not.
  7560. @end table
  7561. Default value is @samp{0}.
  7562. @item flags
  7563. Set libswscale scaling flags. See
  7564. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  7565. complete list of values. If not explicitly specified the filter applies
  7566. the default flags.
  7567. @item size, s
  7568. Set the video size. For the syntax of this option, check the
  7569. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7570. @item in_color_matrix
  7571. @item out_color_matrix
  7572. Set in/output YCbCr color space type.
  7573. This allows the autodetected value to be overridden as well as allows forcing
  7574. a specific value used for the output and encoder.
  7575. If not specified, the color space type depends on the pixel format.
  7576. Possible values:
  7577. @table @samp
  7578. @item auto
  7579. Choose automatically.
  7580. @item bt709
  7581. Format conforming to International Telecommunication Union (ITU)
  7582. Recommendation BT.709.
  7583. @item fcc
  7584. Set color space conforming to the United States Federal Communications
  7585. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  7586. @item bt601
  7587. Set color space conforming to:
  7588. @itemize
  7589. @item
  7590. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  7591. @item
  7592. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  7593. @item
  7594. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  7595. @end itemize
  7596. @item smpte240m
  7597. Set color space conforming to SMPTE ST 240:1999.
  7598. @end table
  7599. @item in_range
  7600. @item out_range
  7601. Set in/output YCbCr sample range.
  7602. This allows the autodetected value to be overridden as well as allows forcing
  7603. a specific value used for the output and encoder. If not specified, the
  7604. range depends on the pixel format. Possible values:
  7605. @table @samp
  7606. @item auto
  7607. Choose automatically.
  7608. @item jpeg/full/pc
  7609. Set full range (0-255 in case of 8-bit luma).
  7610. @item mpeg/tv
  7611. Set "MPEG" range (16-235 in case of 8-bit luma).
  7612. @end table
  7613. @item force_original_aspect_ratio
  7614. Enable decreasing or increasing output video width or height if necessary to
  7615. keep the original aspect ratio. Possible values:
  7616. @table @samp
  7617. @item disable
  7618. Scale the video as specified and disable this feature.
  7619. @item decrease
  7620. The output video dimensions will automatically be decreased if needed.
  7621. @item increase
  7622. The output video dimensions will automatically be increased if needed.
  7623. @end table
  7624. One useful instance of this option is that when you know a specific device's
  7625. maximum allowed resolution, you can use this to limit the output video to
  7626. that, while retaining the aspect ratio. For example, device A allows
  7627. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  7628. decrease) and specifying 1280x720 to the command line makes the output
  7629. 1280x533.
  7630. Please note that this is a different thing than specifying -1 for @option{w}
  7631. or @option{h}, you still need to specify the output resolution for this option
  7632. to work.
  7633. @end table
  7634. The values of the @option{w} and @option{h} options are expressions
  7635. containing the following constants:
  7636. @table @var
  7637. @item in_w
  7638. @item in_h
  7639. The input width and height
  7640. @item iw
  7641. @item ih
  7642. These are the same as @var{in_w} and @var{in_h}.
  7643. @item out_w
  7644. @item out_h
  7645. The output (scaled) width and height
  7646. @item ow
  7647. @item oh
  7648. These are the same as @var{out_w} and @var{out_h}
  7649. @item a
  7650. The same as @var{iw} / @var{ih}
  7651. @item sar
  7652. input sample aspect ratio
  7653. @item dar
  7654. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  7655. @item hsub
  7656. @item vsub
  7657. horizontal and vertical input chroma subsample values. For example for the
  7658. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7659. @item ohsub
  7660. @item ovsub
  7661. horizontal and vertical output chroma subsample values. For example for the
  7662. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7663. @end table
  7664. @subsection Examples
  7665. @itemize
  7666. @item
  7667. Scale the input video to a size of 200x100
  7668. @example
  7669. scale=w=200:h=100
  7670. @end example
  7671. This is equivalent to:
  7672. @example
  7673. scale=200:100
  7674. @end example
  7675. or:
  7676. @example
  7677. scale=200x100
  7678. @end example
  7679. @item
  7680. Specify a size abbreviation for the output size:
  7681. @example
  7682. scale=qcif
  7683. @end example
  7684. which can also be written as:
  7685. @example
  7686. scale=size=qcif
  7687. @end example
  7688. @item
  7689. Scale the input to 2x:
  7690. @example
  7691. scale=w=2*iw:h=2*ih
  7692. @end example
  7693. @item
  7694. The above is the same as:
  7695. @example
  7696. scale=2*in_w:2*in_h
  7697. @end example
  7698. @item
  7699. Scale the input to 2x with forced interlaced scaling:
  7700. @example
  7701. scale=2*iw:2*ih:interl=1
  7702. @end example
  7703. @item
  7704. Scale the input to half size:
  7705. @example
  7706. scale=w=iw/2:h=ih/2
  7707. @end example
  7708. @item
  7709. Increase the width, and set the height to the same size:
  7710. @example
  7711. scale=3/2*iw:ow
  7712. @end example
  7713. @item
  7714. Seek Greek harmony:
  7715. @example
  7716. scale=iw:1/PHI*iw
  7717. scale=ih*PHI:ih
  7718. @end example
  7719. @item
  7720. Increase the height, and set the width to 3/2 of the height:
  7721. @example
  7722. scale=w=3/2*oh:h=3/5*ih
  7723. @end example
  7724. @item
  7725. Increase the size, making the size a multiple of the chroma
  7726. subsample values:
  7727. @example
  7728. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  7729. @end example
  7730. @item
  7731. Increase the width to a maximum of 500 pixels,
  7732. keeping the same aspect ratio as the input:
  7733. @example
  7734. scale=w='min(500\, iw*3/2):h=-1'
  7735. @end example
  7736. @end itemize
  7737. @subsection Commands
  7738. This filter supports the following commands:
  7739. @table @option
  7740. @item width, w
  7741. @item height, h
  7742. Set the output video dimension expression.
  7743. The command accepts the same syntax of the corresponding option.
  7744. If the specified expression is not valid, it is kept at its current
  7745. value.
  7746. @end table
  7747. @section scale2ref
  7748. Scale (resize) the input video, based on a reference video.
  7749. See the scale filter for available options, scale2ref supports the same but
  7750. uses the reference video instead of the main input as basis.
  7751. @subsection Examples
  7752. @itemize
  7753. @item
  7754. Scale a subtitle stream to match the main video in size before overlaying
  7755. @example
  7756. 'scale2ref[b][a];[a][b]overlay'
  7757. @end example
  7758. @end itemize
  7759. @section selectivecolor
  7760. Adjust cyan, magenta, yellow and black (CMYK) to certain ranges of colors (such
  7761. as "reds", "yellows", "greens", "cyans", ...). The adjustment range is defined
  7762. by the "purity" of the color (that is, how saturated it already is).
  7763. This filter is similar to the Adobe Photoshop Selective Color tool.
  7764. The filter accepts the following options:
  7765. @table @option
  7766. @item correction_method
  7767. Select color correction method.
  7768. Available values are:
  7769. @table @samp
  7770. @item absolute
  7771. Specified adjustments are applied "as-is" (added/subtracted to original pixel
  7772. component value).
  7773. @item relative
  7774. Specified adjustments are relative to the original component value.
  7775. @end table
  7776. Default is @code{absolute}.
  7777. @item reds
  7778. Adjustments for red pixels (pixels where the red component is the maximum)
  7779. @item yellows
  7780. Adjustments for yellow pixels (pixels where the blue component is the minimum)
  7781. @item greens
  7782. Adjustments for green pixels (pixels where the green component is the maximum)
  7783. @item cyans
  7784. Adjustments for cyan pixels (pixels where the red component is the minimum)
  7785. @item blues
  7786. Adjustments for blue pixels (pixels where the blue component is the maximum)
  7787. @item magentas
  7788. Adjustments for magenta pixels (pixels where the green component is the minimum)
  7789. @item whites
  7790. Adjustments for white pixels (pixels where all components are greater than 128)
  7791. @item neutrals
  7792. Adjustments for all pixels except pure black and pure white
  7793. @item blacks
  7794. Adjustments for black pixels (pixels where all components are lesser than 128)
  7795. @item psfile
  7796. Specify a Photoshop selective color file (@code{.asv}) to import the settings from.
  7797. @end table
  7798. All the adjustment settings (@option{reds}, @option{yellows}, ...) accept up to
  7799. 4 space separated floating point adjustment values in the [-1,1] range,
  7800. respectively to adjust the amount of cyan, magenta, yellow and black for the
  7801. pixels of its range.
  7802. @subsection Examples
  7803. @itemize
  7804. @item
  7805. Increase cyan by 50% and reduce yellow by 33% in every green areas, and
  7806. increase magenta by 27% in blue areas:
  7807. @example
  7808. selectivecolor=greens=.5 0 -.33 0:blues=0 .27
  7809. @end example
  7810. @item
  7811. Use a Photoshop selective color preset:
  7812. @example
  7813. selectivecolor=psfile=MySelectiveColorPresets/Misty.asv
  7814. @end example
  7815. @end itemize
  7816. @section separatefields
  7817. The @code{separatefields} takes a frame-based video input and splits
  7818. each frame into its components fields, producing a new half height clip
  7819. with twice the frame rate and twice the frame count.
  7820. This filter use field-dominance information in frame to decide which
  7821. of each pair of fields to place first in the output.
  7822. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  7823. @section setdar, setsar
  7824. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  7825. output video.
  7826. This is done by changing the specified Sample (aka Pixel) Aspect
  7827. Ratio, according to the following equation:
  7828. @example
  7829. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  7830. @end example
  7831. Keep in mind that the @code{setdar} filter does not modify the pixel
  7832. dimensions of the video frame. Also, the display aspect ratio set by
  7833. this filter may be changed by later filters in the filterchain,
  7834. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  7835. applied.
  7836. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  7837. the filter output video.
  7838. Note that as a consequence of the application of this filter, the
  7839. output display aspect ratio will change according to the equation
  7840. above.
  7841. Keep in mind that the sample aspect ratio set by the @code{setsar}
  7842. filter may be changed by later filters in the filterchain, e.g. if
  7843. another "setsar" or a "setdar" filter is applied.
  7844. It accepts the following parameters:
  7845. @table @option
  7846. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  7847. Set the aspect ratio used by the filter.
  7848. The parameter can be a floating point number string, an expression, or
  7849. a string of the form @var{num}:@var{den}, where @var{num} and
  7850. @var{den} are the numerator and denominator of the aspect ratio. If
  7851. the parameter is not specified, it is assumed the value "0".
  7852. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  7853. should be escaped.
  7854. @item max
  7855. Set the maximum integer value to use for expressing numerator and
  7856. denominator when reducing the expressed aspect ratio to a rational.
  7857. Default value is @code{100}.
  7858. @end table
  7859. The parameter @var{sar} is an expression containing
  7860. the following constants:
  7861. @table @option
  7862. @item E, PI, PHI
  7863. These are approximated values for the mathematical constants e
  7864. (Euler's number), pi (Greek pi), and phi (the golden ratio).
  7865. @item w, h
  7866. The input width and height.
  7867. @item a
  7868. These are the same as @var{w} / @var{h}.
  7869. @item sar
  7870. The input sample aspect ratio.
  7871. @item dar
  7872. The input display aspect ratio. It is the same as
  7873. (@var{w} / @var{h}) * @var{sar}.
  7874. @item hsub, vsub
  7875. Horizontal and vertical chroma subsample values. For example, for the
  7876. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7877. @end table
  7878. @subsection Examples
  7879. @itemize
  7880. @item
  7881. To change the display aspect ratio to 16:9, specify one of the following:
  7882. @example
  7883. setdar=dar=1.77777
  7884. setdar=dar=16/9
  7885. setdar=dar=1.77777
  7886. @end example
  7887. @item
  7888. To change the sample aspect ratio to 10:11, specify:
  7889. @example
  7890. setsar=sar=10/11
  7891. @end example
  7892. @item
  7893. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  7894. 1000 in the aspect ratio reduction, use the command:
  7895. @example
  7896. setdar=ratio=16/9:max=1000
  7897. @end example
  7898. @end itemize
  7899. @anchor{setfield}
  7900. @section setfield
  7901. Force field for the output video frame.
  7902. The @code{setfield} filter marks the interlace type field for the
  7903. output frames. It does not change the input frame, but only sets the
  7904. corresponding property, which affects how the frame is treated by
  7905. following filters (e.g. @code{fieldorder} or @code{yadif}).
  7906. The filter accepts the following options:
  7907. @table @option
  7908. @item mode
  7909. Available values are:
  7910. @table @samp
  7911. @item auto
  7912. Keep the same field property.
  7913. @item bff
  7914. Mark the frame as bottom-field-first.
  7915. @item tff
  7916. Mark the frame as top-field-first.
  7917. @item prog
  7918. Mark the frame as progressive.
  7919. @end table
  7920. @end table
  7921. @section showinfo
  7922. Show a line containing various information for each input video frame.
  7923. The input video is not modified.
  7924. The shown line contains a sequence of key/value pairs of the form
  7925. @var{key}:@var{value}.
  7926. The following values are shown in the output:
  7927. @table @option
  7928. @item n
  7929. The (sequential) number of the input frame, starting from 0.
  7930. @item pts
  7931. The Presentation TimeStamp of the input frame, expressed as a number of
  7932. time base units. The time base unit depends on the filter input pad.
  7933. @item pts_time
  7934. The Presentation TimeStamp of the input frame, expressed as a number of
  7935. seconds.
  7936. @item pos
  7937. The position of the frame in the input stream, or -1 if this information is
  7938. unavailable and/or meaningless (for example in case of synthetic video).
  7939. @item fmt
  7940. The pixel format name.
  7941. @item sar
  7942. The sample aspect ratio of the input frame, expressed in the form
  7943. @var{num}/@var{den}.
  7944. @item s
  7945. The size of the input frame. For the syntax of this option, check the
  7946. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7947. @item i
  7948. The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
  7949. for bottom field first).
  7950. @item iskey
  7951. This is 1 if the frame is a key frame, 0 otherwise.
  7952. @item type
  7953. The picture type of the input frame ("I" for an I-frame, "P" for a
  7954. P-frame, "B" for a B-frame, or "?" for an unknown type).
  7955. Also refer to the documentation of the @code{AVPictureType} enum and of
  7956. the @code{av_get_picture_type_char} function defined in
  7957. @file{libavutil/avutil.h}.
  7958. @item checksum
  7959. The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
  7960. @item plane_checksum
  7961. The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  7962. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
  7963. @end table
  7964. @section showpalette
  7965. Displays the 256 colors palette of each frame. This filter is only relevant for
  7966. @var{pal8} pixel format frames.
  7967. It accepts the following option:
  7968. @table @option
  7969. @item s
  7970. Set the size of the box used to represent one palette color entry. Default is
  7971. @code{30} (for a @code{30x30} pixel box).
  7972. @end table
  7973. @section shuffleframes
  7974. Reorder and/or duplicate video frames.
  7975. It accepts the following parameters:
  7976. @table @option
  7977. @item mapping
  7978. Set the destination indexes of input frames.
  7979. This is space or '|' separated list of indexes that maps input frames to output
  7980. frames. Number of indexes also sets maximal value that each index may have.
  7981. @end table
  7982. The first frame has the index 0. The default is to keep the input unchanged.
  7983. Swap second and third frame of every three frames of the input:
  7984. @example
  7985. ffmpeg -i INPUT -vf "shuffleframes=0 2 1" OUTPUT
  7986. @end example
  7987. @section shuffleplanes
  7988. Reorder and/or duplicate video planes.
  7989. It accepts the following parameters:
  7990. @table @option
  7991. @item map0
  7992. The index of the input plane to be used as the first output plane.
  7993. @item map1
  7994. The index of the input plane to be used as the second output plane.
  7995. @item map2
  7996. The index of the input plane to be used as the third output plane.
  7997. @item map3
  7998. The index of the input plane to be used as the fourth output plane.
  7999. @end table
  8000. The first plane has the index 0. The default is to keep the input unchanged.
  8001. Swap the second and third planes of the input:
  8002. @example
  8003. ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
  8004. @end example
  8005. @anchor{signalstats}
  8006. @section signalstats
  8007. Evaluate various visual metrics that assist in determining issues associated
  8008. with the digitization of analog video media.
  8009. By default the filter will log these metadata values:
  8010. @table @option
  8011. @item YMIN
  8012. Display the minimal Y value contained within the input frame. Expressed in
  8013. range of [0-255].
  8014. @item YLOW
  8015. Display the Y value at the 10% percentile within the input frame. Expressed in
  8016. range of [0-255].
  8017. @item YAVG
  8018. Display the average Y value within the input frame. Expressed in range of
  8019. [0-255].
  8020. @item YHIGH
  8021. Display the Y value at the 90% percentile within the input frame. Expressed in
  8022. range of [0-255].
  8023. @item YMAX
  8024. Display the maximum Y value contained within the input frame. Expressed in
  8025. range of [0-255].
  8026. @item UMIN
  8027. Display the minimal U value contained within the input frame. Expressed in
  8028. range of [0-255].
  8029. @item ULOW
  8030. Display the U value at the 10% percentile within the input frame. Expressed in
  8031. range of [0-255].
  8032. @item UAVG
  8033. Display the average U value within the input frame. Expressed in range of
  8034. [0-255].
  8035. @item UHIGH
  8036. Display the U value at the 90% percentile within the input frame. Expressed in
  8037. range of [0-255].
  8038. @item UMAX
  8039. Display the maximum U value contained within the input frame. Expressed in
  8040. range of [0-255].
  8041. @item VMIN
  8042. Display the minimal V value contained within the input frame. Expressed in
  8043. range of [0-255].
  8044. @item VLOW
  8045. Display the V value at the 10% percentile within the input frame. Expressed in
  8046. range of [0-255].
  8047. @item VAVG
  8048. Display the average V value within the input frame. Expressed in range of
  8049. [0-255].
  8050. @item VHIGH
  8051. Display the V value at the 90% percentile within the input frame. Expressed in
  8052. range of [0-255].
  8053. @item VMAX
  8054. Display the maximum V value contained within the input frame. Expressed in
  8055. range of [0-255].
  8056. @item SATMIN
  8057. Display the minimal saturation value contained within the input frame.
  8058. Expressed in range of [0-~181.02].
  8059. @item SATLOW
  8060. Display the saturation value at the 10% percentile within the input frame.
  8061. Expressed in range of [0-~181.02].
  8062. @item SATAVG
  8063. Display the average saturation value within the input frame. Expressed in range
  8064. of [0-~181.02].
  8065. @item SATHIGH
  8066. Display the saturation value at the 90% percentile within the input frame.
  8067. Expressed in range of [0-~181.02].
  8068. @item SATMAX
  8069. Display the maximum saturation value contained within the input frame.
  8070. Expressed in range of [0-~181.02].
  8071. @item HUEMED
  8072. Display the median value for hue within the input frame. Expressed in range of
  8073. [0-360].
  8074. @item HUEAVG
  8075. Display the average value for hue within the input frame. Expressed in range of
  8076. [0-360].
  8077. @item YDIF
  8078. Display the average of sample value difference between all values of the Y
  8079. plane in the current frame and corresponding values of the previous input frame.
  8080. Expressed in range of [0-255].
  8081. @item UDIF
  8082. Display the average of sample value difference between all values of the U
  8083. plane in the current frame and corresponding values of the previous input frame.
  8084. Expressed in range of [0-255].
  8085. @item VDIF
  8086. Display the average of sample value difference between all values of the V
  8087. plane in the current frame and corresponding values of the previous input frame.
  8088. Expressed in range of [0-255].
  8089. @end table
  8090. The filter accepts the following options:
  8091. @table @option
  8092. @item stat
  8093. @item out
  8094. @option{stat} specify an additional form of image analysis.
  8095. @option{out} output video with the specified type of pixel highlighted.
  8096. Both options accept the following values:
  8097. @table @samp
  8098. @item tout
  8099. Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
  8100. unlike the neighboring pixels of the same field. Examples of temporal outliers
  8101. include the results of video dropouts, head clogs, or tape tracking issues.
  8102. @item vrep
  8103. Identify @var{vertical line repetition}. Vertical line repetition includes
  8104. similar rows of pixels within a frame. In born-digital video vertical line
  8105. repetition is common, but this pattern is uncommon in video digitized from an
  8106. analog source. When it occurs in video that results from the digitization of an
  8107. analog source it can indicate concealment from a dropout compensator.
  8108. @item brng
  8109. Identify pixels that fall outside of legal broadcast range.
  8110. @end table
  8111. @item color, c
  8112. Set the highlight color for the @option{out} option. The default color is
  8113. yellow.
  8114. @end table
  8115. @subsection Examples
  8116. @itemize
  8117. @item
  8118. Output data of various video metrics:
  8119. @example
  8120. ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
  8121. @end example
  8122. @item
  8123. Output specific data about the minimum and maximum values of the Y plane per frame:
  8124. @example
  8125. ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
  8126. @end example
  8127. @item
  8128. Playback video while highlighting pixels that are outside of broadcast range in red.
  8129. @example
  8130. ffplay example.mov -vf signalstats="out=brng:color=red"
  8131. @end example
  8132. @item
  8133. Playback video with signalstats metadata drawn over the frame.
  8134. @example
  8135. ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
  8136. @end example
  8137. The contents of signalstat_drawtext.txt used in the command are:
  8138. @example
  8139. time %@{pts:hms@}
  8140. Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
  8141. U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
  8142. V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
  8143. saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
  8144. @end example
  8145. @end itemize
  8146. @anchor{smartblur}
  8147. @section smartblur
  8148. Blur the input video without impacting the outlines.
  8149. It accepts the following options:
  8150. @table @option
  8151. @item luma_radius, lr
  8152. Set the luma radius. The option value must be a float number in
  8153. the range [0.1,5.0] that specifies the variance of the gaussian filter
  8154. used to blur the image (slower if larger). Default value is 1.0.
  8155. @item luma_strength, ls
  8156. Set the luma strength. The option value must be a float number
  8157. in the range [-1.0,1.0] that configures the blurring. A value included
  8158. in [0.0,1.0] will blur the image whereas a value included in
  8159. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  8160. @item luma_threshold, lt
  8161. Set the luma threshold used as a coefficient to determine
  8162. whether a pixel should be blurred or not. The option value must be an
  8163. integer in the range [-30,30]. A value of 0 will filter all the image,
  8164. a value included in [0,30] will filter flat areas and a value included
  8165. in [-30,0] will filter edges. Default value is 0.
  8166. @item chroma_radius, cr
  8167. Set the chroma radius. The option value must be a float number in
  8168. the range [0.1,5.0] that specifies the variance of the gaussian filter
  8169. used to blur the image (slower if larger). Default value is 1.0.
  8170. @item chroma_strength, cs
  8171. Set the chroma strength. The option value must be a float number
  8172. in the range [-1.0,1.0] that configures the blurring. A value included
  8173. in [0.0,1.0] will blur the image whereas a value included in
  8174. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  8175. @item chroma_threshold, ct
  8176. Set the chroma threshold used as a coefficient to determine
  8177. whether a pixel should be blurred or not. The option value must be an
  8178. integer in the range [-30,30]. A value of 0 will filter all the image,
  8179. a value included in [0,30] will filter flat areas and a value included
  8180. in [-30,0] will filter edges. Default value is 0.
  8181. @end table
  8182. If a chroma option is not explicitly set, the corresponding luma value
  8183. is set.
  8184. @section ssim
  8185. Obtain the SSIM (Structural SImilarity Metric) between two input videos.
  8186. This filter takes in input two input videos, the first input is
  8187. considered the "main" source and is passed unchanged to the
  8188. output. The second input is used as a "reference" video for computing
  8189. the SSIM.
  8190. Both video inputs must have the same resolution and pixel format for
  8191. this filter to work correctly. Also it assumes that both inputs
  8192. have the same number of frames, which are compared one by one.
  8193. The filter stores the calculated SSIM of each frame.
  8194. The description of the accepted parameters follows.
  8195. @table @option
  8196. @item stats_file, f
  8197. If specified the filter will use the named file to save the SSIM of
  8198. each individual frame. When filename equals "-" the data is sent to
  8199. standard output.
  8200. @end table
  8201. The file printed if @var{stats_file} is selected, contains a sequence of
  8202. key/value pairs of the form @var{key}:@var{value} for each compared
  8203. couple of frames.
  8204. A description of each shown parameter follows:
  8205. @table @option
  8206. @item n
  8207. sequential number of the input frame, starting from 1
  8208. @item Y, U, V, R, G, B
  8209. SSIM of the compared frames for the component specified by the suffix.
  8210. @item All
  8211. SSIM of the compared frames for the whole frame.
  8212. @item dB
  8213. Same as above but in dB representation.
  8214. @end table
  8215. For example:
  8216. @example
  8217. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  8218. [main][ref] ssim="stats_file=stats.log" [out]
  8219. @end example
  8220. On this example the input file being processed is compared with the
  8221. reference file @file{ref_movie.mpg}. The SSIM of each individual frame
  8222. is stored in @file{stats.log}.
  8223. Another example with both psnr and ssim at same time:
  8224. @example
  8225. ffmpeg -i main.mpg -i ref.mpg -lavfi "ssim;[0:v][1:v]psnr" -f null -
  8226. @end example
  8227. @section stereo3d
  8228. Convert between different stereoscopic image formats.
  8229. The filters accept the following options:
  8230. @table @option
  8231. @item in
  8232. Set stereoscopic image format of input.
  8233. Available values for input image formats are:
  8234. @table @samp
  8235. @item sbsl
  8236. side by side parallel (left eye left, right eye right)
  8237. @item sbsr
  8238. side by side crosseye (right eye left, left eye right)
  8239. @item sbs2l
  8240. side by side parallel with half width resolution
  8241. (left eye left, right eye right)
  8242. @item sbs2r
  8243. side by side crosseye with half width resolution
  8244. (right eye left, left eye right)
  8245. @item abl
  8246. above-below (left eye above, right eye below)
  8247. @item abr
  8248. above-below (right eye above, left eye below)
  8249. @item ab2l
  8250. above-below with half height resolution
  8251. (left eye above, right eye below)
  8252. @item ab2r
  8253. above-below with half height resolution
  8254. (right eye above, left eye below)
  8255. @item al
  8256. alternating frames (left eye first, right eye second)
  8257. @item ar
  8258. alternating frames (right eye first, left eye second)
  8259. @item irl
  8260. interleaved rows (left eye has top row, right eye starts on next row)
  8261. @item irr
  8262. interleaved rows (right eye has top row, left eye starts on next row)
  8263. Default value is @samp{sbsl}.
  8264. @end table
  8265. @item out
  8266. Set stereoscopic image format of output.
  8267. Available values for output image formats are all the input formats as well as:
  8268. @table @samp
  8269. @item arbg
  8270. anaglyph red/blue gray
  8271. (red filter on left eye, blue filter on right eye)
  8272. @item argg
  8273. anaglyph red/green gray
  8274. (red filter on left eye, green filter on right eye)
  8275. @item arcg
  8276. anaglyph red/cyan gray
  8277. (red filter on left eye, cyan filter on right eye)
  8278. @item arch
  8279. anaglyph red/cyan half colored
  8280. (red filter on left eye, cyan filter on right eye)
  8281. @item arcc
  8282. anaglyph red/cyan color
  8283. (red filter on left eye, cyan filter on right eye)
  8284. @item arcd
  8285. anaglyph red/cyan color optimized with the least squares projection of dubois
  8286. (red filter on left eye, cyan filter on right eye)
  8287. @item agmg
  8288. anaglyph green/magenta gray
  8289. (green filter on left eye, magenta filter on right eye)
  8290. @item agmh
  8291. anaglyph green/magenta half colored
  8292. (green filter on left eye, magenta filter on right eye)
  8293. @item agmc
  8294. anaglyph green/magenta colored
  8295. (green filter on left eye, magenta filter on right eye)
  8296. @item agmd
  8297. anaglyph green/magenta color optimized with the least squares projection of dubois
  8298. (green filter on left eye, magenta filter on right eye)
  8299. @item aybg
  8300. anaglyph yellow/blue gray
  8301. (yellow filter on left eye, blue filter on right eye)
  8302. @item aybh
  8303. anaglyph yellow/blue half colored
  8304. (yellow filter on left eye, blue filter on right eye)
  8305. @item aybc
  8306. anaglyph yellow/blue colored
  8307. (yellow filter on left eye, blue filter on right eye)
  8308. @item aybd
  8309. anaglyph yellow/blue color optimized with the least squares projection of dubois
  8310. (yellow filter on left eye, blue filter on right eye)
  8311. @item ml
  8312. mono output (left eye only)
  8313. @item mr
  8314. mono output (right eye only)
  8315. @item chl
  8316. checkerboard, left eye first
  8317. @item chr
  8318. checkerboard, right eye first
  8319. @item icl
  8320. interleaved columns, left eye first
  8321. @item icr
  8322. interleaved columns, right eye first
  8323. @end table
  8324. Default value is @samp{arcd}.
  8325. @end table
  8326. @subsection Examples
  8327. @itemize
  8328. @item
  8329. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  8330. @example
  8331. stereo3d=sbsl:aybd
  8332. @end example
  8333. @item
  8334. Convert input video from above below (left eye above, right eye below) to side by side crosseye.
  8335. @example
  8336. stereo3d=abl:sbsr
  8337. @end example
  8338. @end itemize
  8339. @anchor{spp}
  8340. @section spp
  8341. Apply a simple postprocessing filter that compresses and decompresses the image
  8342. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  8343. and average the results.
  8344. The filter accepts the following options:
  8345. @table @option
  8346. @item quality
  8347. Set quality. This option defines the number of levels for averaging. It accepts
  8348. an integer in the range 0-6. If set to @code{0}, the filter will have no
  8349. effect. A value of @code{6} means the higher quality. For each increment of
  8350. that value the speed drops by a factor of approximately 2. Default value is
  8351. @code{3}.
  8352. @item qp
  8353. Force a constant quantization parameter. If not set, the filter will use the QP
  8354. from the video stream (if available).
  8355. @item mode
  8356. Set thresholding mode. Available modes are:
  8357. @table @samp
  8358. @item hard
  8359. Set hard thresholding (default).
  8360. @item soft
  8361. Set soft thresholding (better de-ringing effect, but likely blurrier).
  8362. @end table
  8363. @item use_bframe_qp
  8364. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  8365. option may cause flicker since the B-Frames have often larger QP. Default is
  8366. @code{0} (not enabled).
  8367. @end table
  8368. @anchor{subtitles}
  8369. @section subtitles
  8370. Draw subtitles on top of input video using the libass library.
  8371. To enable compilation of this filter you need to configure FFmpeg with
  8372. @code{--enable-libass}. This filter also requires a build with libavcodec and
  8373. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  8374. Alpha) subtitles format.
  8375. The filter accepts the following options:
  8376. @table @option
  8377. @item filename, f
  8378. Set the filename of the subtitle file to read. It must be specified.
  8379. @item original_size
  8380. Specify the size of the original video, the video for which the ASS file
  8381. was composed. For the syntax of this option, check the
  8382. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8383. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
  8384. correctly scale the fonts if the aspect ratio has been changed.
  8385. @item fontsdir
  8386. Set a directory path containing fonts that can be used by the filter.
  8387. These fonts will be used in addition to whatever the font provider uses.
  8388. @item charenc
  8389. Set subtitles input character encoding. @code{subtitles} filter only. Only
  8390. useful if not UTF-8.
  8391. @item stream_index, si
  8392. Set subtitles stream index. @code{subtitles} filter only.
  8393. @item force_style
  8394. Override default style or script info parameters of the subtitles. It accepts a
  8395. string containing ASS style format @code{KEY=VALUE} couples separated by ",".
  8396. @end table
  8397. If the first key is not specified, it is assumed that the first value
  8398. specifies the @option{filename}.
  8399. For example, to render the file @file{sub.srt} on top of the input
  8400. video, use the command:
  8401. @example
  8402. subtitles=sub.srt
  8403. @end example
  8404. which is equivalent to:
  8405. @example
  8406. subtitles=filename=sub.srt
  8407. @end example
  8408. To render the default subtitles stream from file @file{video.mkv}, use:
  8409. @example
  8410. subtitles=video.mkv
  8411. @end example
  8412. To render the second subtitles stream from that file, use:
  8413. @example
  8414. subtitles=video.mkv:si=1
  8415. @end example
  8416. To make the subtitles stream from @file{sub.srt} appear in transparent green
  8417. @code{DejaVu Serif}, use:
  8418. @example
  8419. subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
  8420. @end example
  8421. @section super2xsai
  8422. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  8423. Interpolate) pixel art scaling algorithm.
  8424. Useful for enlarging pixel art images without reducing sharpness.
  8425. @section swapuv
  8426. Swap U & V plane.
  8427. @section telecine
  8428. Apply telecine process to the video.
  8429. This filter accepts the following options:
  8430. @table @option
  8431. @item first_field
  8432. @table @samp
  8433. @item top, t
  8434. top field first
  8435. @item bottom, b
  8436. bottom field first
  8437. The default value is @code{top}.
  8438. @end table
  8439. @item pattern
  8440. A string of numbers representing the pulldown pattern you wish to apply.
  8441. The default value is @code{23}.
  8442. @end table
  8443. @example
  8444. Some typical patterns:
  8445. NTSC output (30i):
  8446. 27.5p: 32222
  8447. 24p: 23 (classic)
  8448. 24p: 2332 (preferred)
  8449. 20p: 33
  8450. 18p: 334
  8451. 16p: 3444
  8452. PAL output (25i):
  8453. 27.5p: 12222
  8454. 24p: 222222222223 ("Euro pulldown")
  8455. 16.67p: 33
  8456. 16p: 33333334
  8457. @end example
  8458. @section thumbnail
  8459. Select the most representative frame in a given sequence of consecutive frames.
  8460. The filter accepts the following options:
  8461. @table @option
  8462. @item n
  8463. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  8464. will pick one of them, and then handle the next batch of @var{n} frames until
  8465. the end. Default is @code{100}.
  8466. @end table
  8467. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  8468. value will result in a higher memory usage, so a high value is not recommended.
  8469. @subsection Examples
  8470. @itemize
  8471. @item
  8472. Extract one picture each 50 frames:
  8473. @example
  8474. thumbnail=50
  8475. @end example
  8476. @item
  8477. Complete example of a thumbnail creation with @command{ffmpeg}:
  8478. @example
  8479. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  8480. @end example
  8481. @end itemize
  8482. @section tile
  8483. Tile several successive frames together.
  8484. The filter accepts the following options:
  8485. @table @option
  8486. @item layout
  8487. Set the grid size (i.e. the number of lines and columns). For the syntax of
  8488. this option, check the
  8489. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8490. @item nb_frames
  8491. Set the maximum number of frames to render in the given area. It must be less
  8492. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  8493. the area will be used.
  8494. @item margin
  8495. Set the outer border margin in pixels.
  8496. @item padding
  8497. Set the inner border thickness (i.e. the number of pixels between frames). For
  8498. more advanced padding options (such as having different values for the edges),
  8499. refer to the pad video filter.
  8500. @item color
  8501. Specify the color of the unused area. For the syntax of this option, check the
  8502. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  8503. is "black".
  8504. @end table
  8505. @subsection Examples
  8506. @itemize
  8507. @item
  8508. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  8509. @example
  8510. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  8511. @end example
  8512. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  8513. duplicating each output frame to accommodate the originally detected frame
  8514. rate.
  8515. @item
  8516. Display @code{5} pictures in an area of @code{3x2} frames,
  8517. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  8518. mixed flat and named options:
  8519. @example
  8520. tile=3x2:nb_frames=5:padding=7:margin=2
  8521. @end example
  8522. @end itemize
  8523. @section tinterlace
  8524. Perform various types of temporal field interlacing.
  8525. Frames are counted starting from 1, so the first input frame is
  8526. considered odd.
  8527. The filter accepts the following options:
  8528. @table @option
  8529. @item mode
  8530. Specify the mode of the interlacing. This option can also be specified
  8531. as a value alone. See below for a list of values for this option.
  8532. Available values are:
  8533. @table @samp
  8534. @item merge, 0
  8535. Move odd frames into the upper field, even into the lower field,
  8536. generating a double height frame at half frame rate.
  8537. @example
  8538. ------> time
  8539. Input:
  8540. Frame 1 Frame 2 Frame 3 Frame 4
  8541. 11111 22222 33333 44444
  8542. 11111 22222 33333 44444
  8543. 11111 22222 33333 44444
  8544. 11111 22222 33333 44444
  8545. Output:
  8546. 11111 33333
  8547. 22222 44444
  8548. 11111 33333
  8549. 22222 44444
  8550. 11111 33333
  8551. 22222 44444
  8552. 11111 33333
  8553. 22222 44444
  8554. @end example
  8555. @item drop_odd, 1
  8556. Only output even frames, odd frames are dropped, generating a frame with
  8557. unchanged height at half frame rate.
  8558. @example
  8559. ------> time
  8560. Input:
  8561. Frame 1 Frame 2 Frame 3 Frame 4
  8562. 11111 22222 33333 44444
  8563. 11111 22222 33333 44444
  8564. 11111 22222 33333 44444
  8565. 11111 22222 33333 44444
  8566. Output:
  8567. 22222 44444
  8568. 22222 44444
  8569. 22222 44444
  8570. 22222 44444
  8571. @end example
  8572. @item drop_even, 2
  8573. Only output odd frames, even frames are dropped, generating a frame with
  8574. unchanged height at half frame rate.
  8575. @example
  8576. ------> time
  8577. Input:
  8578. Frame 1 Frame 2 Frame 3 Frame 4
  8579. 11111 22222 33333 44444
  8580. 11111 22222 33333 44444
  8581. 11111 22222 33333 44444
  8582. 11111 22222 33333 44444
  8583. Output:
  8584. 11111 33333
  8585. 11111 33333
  8586. 11111 33333
  8587. 11111 33333
  8588. @end example
  8589. @item pad, 3
  8590. Expand each frame to full height, but pad alternate lines with black,
  8591. generating a frame with double height at the same input frame rate.
  8592. @example
  8593. ------> time
  8594. Input:
  8595. Frame 1 Frame 2 Frame 3 Frame 4
  8596. 11111 22222 33333 44444
  8597. 11111 22222 33333 44444
  8598. 11111 22222 33333 44444
  8599. 11111 22222 33333 44444
  8600. Output:
  8601. 11111 ..... 33333 .....
  8602. ..... 22222 ..... 44444
  8603. 11111 ..... 33333 .....
  8604. ..... 22222 ..... 44444
  8605. 11111 ..... 33333 .....
  8606. ..... 22222 ..... 44444
  8607. 11111 ..... 33333 .....
  8608. ..... 22222 ..... 44444
  8609. @end example
  8610. @item interleave_top, 4
  8611. Interleave the upper field from odd frames with the lower field from
  8612. even frames, generating a frame with unchanged height at half frame rate.
  8613. @example
  8614. ------> time
  8615. Input:
  8616. Frame 1 Frame 2 Frame 3 Frame 4
  8617. 11111<- 22222 33333<- 44444
  8618. 11111 22222<- 33333 44444<-
  8619. 11111<- 22222 33333<- 44444
  8620. 11111 22222<- 33333 44444<-
  8621. Output:
  8622. 11111 33333
  8623. 22222 44444
  8624. 11111 33333
  8625. 22222 44444
  8626. @end example
  8627. @item interleave_bottom, 5
  8628. Interleave the lower field from odd frames with the upper field from
  8629. even frames, generating a frame with unchanged height at half frame rate.
  8630. @example
  8631. ------> time
  8632. Input:
  8633. Frame 1 Frame 2 Frame 3 Frame 4
  8634. 11111 22222<- 33333 44444<-
  8635. 11111<- 22222 33333<- 44444
  8636. 11111 22222<- 33333 44444<-
  8637. 11111<- 22222 33333<- 44444
  8638. Output:
  8639. 22222 44444
  8640. 11111 33333
  8641. 22222 44444
  8642. 11111 33333
  8643. @end example
  8644. @item interlacex2, 6
  8645. Double frame rate with unchanged height. Frames are inserted each
  8646. containing the second temporal field from the previous input frame and
  8647. the first temporal field from the next input frame. This mode relies on
  8648. the top_field_first flag. Useful for interlaced video displays with no
  8649. field synchronisation.
  8650. @example
  8651. ------> time
  8652. Input:
  8653. Frame 1 Frame 2 Frame 3 Frame 4
  8654. 11111 22222 33333 44444
  8655. 11111 22222 33333 44444
  8656. 11111 22222 33333 44444
  8657. 11111 22222 33333 44444
  8658. Output:
  8659. 11111 22222 22222 33333 33333 44444 44444
  8660. 11111 11111 22222 22222 33333 33333 44444
  8661. 11111 22222 22222 33333 33333 44444 44444
  8662. 11111 11111 22222 22222 33333 33333 44444
  8663. @end example
  8664. @item mergex2, 7
  8665. Move odd frames into the upper field, even into the lower field,
  8666. generating a double height frame at same frame rate.
  8667. @example
  8668. ------> time
  8669. Input:
  8670. Frame 1 Frame 2 Frame 3 Frame 4
  8671. 11111 22222 33333 44444
  8672. 11111 22222 33333 44444
  8673. 11111 22222 33333 44444
  8674. 11111 22222 33333 44444
  8675. Output:
  8676. 11111 33333 33333 55555
  8677. 22222 22222 44444 44444
  8678. 11111 33333 33333 55555
  8679. 22222 22222 44444 44444
  8680. 11111 33333 33333 55555
  8681. 22222 22222 44444 44444
  8682. 11111 33333 33333 55555
  8683. 22222 22222 44444 44444
  8684. @end example
  8685. @end table
  8686. Numeric values are deprecated but are accepted for backward
  8687. compatibility reasons.
  8688. Default mode is @code{merge}.
  8689. @item flags
  8690. Specify flags influencing the filter process.
  8691. Available value for @var{flags} is:
  8692. @table @option
  8693. @item low_pass_filter, vlfp
  8694. Enable vertical low-pass filtering in the filter.
  8695. Vertical low-pass filtering is required when creating an interlaced
  8696. destination from a progressive source which contains high-frequency
  8697. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  8698. patterning.
  8699. Vertical low-pass filtering can only be enabled for @option{mode}
  8700. @var{interleave_top} and @var{interleave_bottom}.
  8701. @end table
  8702. @end table
  8703. @section transpose
  8704. Transpose rows with columns in the input video and optionally flip it.
  8705. It accepts the following parameters:
  8706. @table @option
  8707. @item dir
  8708. Specify the transposition direction.
  8709. Can assume the following values:
  8710. @table @samp
  8711. @item 0, 4, cclock_flip
  8712. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  8713. @example
  8714. L.R L.l
  8715. . . -> . .
  8716. l.r R.r
  8717. @end example
  8718. @item 1, 5, clock
  8719. Rotate by 90 degrees clockwise, that is:
  8720. @example
  8721. L.R l.L
  8722. . . -> . .
  8723. l.r r.R
  8724. @end example
  8725. @item 2, 6, cclock
  8726. Rotate by 90 degrees counterclockwise, that is:
  8727. @example
  8728. L.R R.r
  8729. . . -> . .
  8730. l.r L.l
  8731. @end example
  8732. @item 3, 7, clock_flip
  8733. Rotate by 90 degrees clockwise and vertically flip, that is:
  8734. @example
  8735. L.R r.R
  8736. . . -> . .
  8737. l.r l.L
  8738. @end example
  8739. @end table
  8740. For values between 4-7, the transposition is only done if the input
  8741. video geometry is portrait and not landscape. These values are
  8742. deprecated, the @code{passthrough} option should be used instead.
  8743. Numerical values are deprecated, and should be dropped in favor of
  8744. symbolic constants.
  8745. @item passthrough
  8746. Do not apply the transposition if the input geometry matches the one
  8747. specified by the specified value. It accepts the following values:
  8748. @table @samp
  8749. @item none
  8750. Always apply transposition.
  8751. @item portrait
  8752. Preserve portrait geometry (when @var{height} >= @var{width}).
  8753. @item landscape
  8754. Preserve landscape geometry (when @var{width} >= @var{height}).
  8755. @end table
  8756. Default value is @code{none}.
  8757. @end table
  8758. For example to rotate by 90 degrees clockwise and preserve portrait
  8759. layout:
  8760. @example
  8761. transpose=dir=1:passthrough=portrait
  8762. @end example
  8763. The command above can also be specified as:
  8764. @example
  8765. transpose=1:portrait
  8766. @end example
  8767. @section trim
  8768. Trim the input so that the output contains one continuous subpart of the input.
  8769. It accepts the following parameters:
  8770. @table @option
  8771. @item start
  8772. Specify the time of the start of the kept section, i.e. the frame with the
  8773. timestamp @var{start} will be the first frame in the output.
  8774. @item end
  8775. Specify the time of the first frame that will be dropped, i.e. the frame
  8776. immediately preceding the one with the timestamp @var{end} will be the last
  8777. frame in the output.
  8778. @item start_pts
  8779. This is the same as @var{start}, except this option sets the start timestamp
  8780. in timebase units instead of seconds.
  8781. @item end_pts
  8782. This is the same as @var{end}, except this option sets the end timestamp
  8783. in timebase units instead of seconds.
  8784. @item duration
  8785. The maximum duration of the output in seconds.
  8786. @item start_frame
  8787. The number of the first frame that should be passed to the output.
  8788. @item end_frame
  8789. The number of the first frame that should be dropped.
  8790. @end table
  8791. @option{start}, @option{end}, and @option{duration} are expressed as time
  8792. duration specifications; see
  8793. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  8794. for the accepted syntax.
  8795. Note that the first two sets of the start/end options and the @option{duration}
  8796. option look at the frame timestamp, while the _frame variants simply count the
  8797. frames that pass through the filter. Also note that this filter does not modify
  8798. the timestamps. If you wish for the output timestamps to start at zero, insert a
  8799. setpts filter after the trim filter.
  8800. If multiple start or end options are set, this filter tries to be greedy and
  8801. keep all the frames that match at least one of the specified constraints. To keep
  8802. only the part that matches all the constraints at once, chain multiple trim
  8803. filters.
  8804. The defaults are such that all the input is kept. So it is possible to set e.g.
  8805. just the end values to keep everything before the specified time.
  8806. Examples:
  8807. @itemize
  8808. @item
  8809. Drop everything except the second minute of input:
  8810. @example
  8811. ffmpeg -i INPUT -vf trim=60:120
  8812. @end example
  8813. @item
  8814. Keep only the first second:
  8815. @example
  8816. ffmpeg -i INPUT -vf trim=duration=1
  8817. @end example
  8818. @end itemize
  8819. @anchor{unsharp}
  8820. @section unsharp
  8821. Sharpen or blur the input video.
  8822. It accepts the following parameters:
  8823. @table @option
  8824. @item luma_msize_x, lx
  8825. Set the luma matrix horizontal size. It must be an odd integer between
  8826. 3 and 63. The default value is 5.
  8827. @item luma_msize_y, ly
  8828. Set the luma matrix vertical size. It must be an odd integer between 3
  8829. and 63. The default value is 5.
  8830. @item luma_amount, la
  8831. Set the luma effect strength. It must be a floating point number, reasonable
  8832. values lay between -1.5 and 1.5.
  8833. Negative values will blur the input video, while positive values will
  8834. sharpen it, a value of zero will disable the effect.
  8835. Default value is 1.0.
  8836. @item chroma_msize_x, cx
  8837. Set the chroma matrix horizontal size. It must be an odd integer
  8838. between 3 and 63. The default value is 5.
  8839. @item chroma_msize_y, cy
  8840. Set the chroma matrix vertical size. It must be an odd integer
  8841. between 3 and 63. The default value is 5.
  8842. @item chroma_amount, ca
  8843. Set the chroma effect strength. It must be a floating point number, reasonable
  8844. values lay between -1.5 and 1.5.
  8845. Negative values will blur the input video, while positive values will
  8846. sharpen it, a value of zero will disable the effect.
  8847. Default value is 0.0.
  8848. @item opencl
  8849. If set to 1, specify using OpenCL capabilities, only available if
  8850. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  8851. @end table
  8852. All parameters are optional and default to the equivalent of the
  8853. string '5:5:1.0:5:5:0.0'.
  8854. @subsection Examples
  8855. @itemize
  8856. @item
  8857. Apply strong luma sharpen effect:
  8858. @example
  8859. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  8860. @end example
  8861. @item
  8862. Apply a strong blur of both luma and chroma parameters:
  8863. @example
  8864. unsharp=7:7:-2:7:7:-2
  8865. @end example
  8866. @end itemize
  8867. @section uspp
  8868. Apply ultra slow/simple postprocessing filter that compresses and decompresses
  8869. the image at several (or - in the case of @option{quality} level @code{8} - all)
  8870. shifts and average the results.
  8871. The way this differs from the behavior of spp is that uspp actually encodes &
  8872. decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
  8873. DCT similar to MJPEG.
  8874. The filter accepts the following options:
  8875. @table @option
  8876. @item quality
  8877. Set quality. This option defines the number of levels for averaging. It accepts
  8878. an integer in the range 0-8. If set to @code{0}, the filter will have no
  8879. effect. A value of @code{8} means the higher quality. For each increment of
  8880. that value the speed drops by a factor of approximately 2. Default value is
  8881. @code{3}.
  8882. @item qp
  8883. Force a constant quantization parameter. If not set, the filter will use the QP
  8884. from the video stream (if available).
  8885. @end table
  8886. @section vectorscope
  8887. Display 2 color component values in the two dimensional graph (which is called
  8888. a vectorscope).
  8889. This filter accepts the following options:
  8890. @table @option
  8891. @item mode, m
  8892. Set vectorscope mode.
  8893. It accepts the following values:
  8894. @table @samp
  8895. @item gray
  8896. Gray values are displayed on graph, higher brightness means more pixels have
  8897. same component color value on location in graph. This is the default mode.
  8898. @item color
  8899. Gray values are displayed on graph. Surrounding pixels values which are not
  8900. present in video frame are drawn in gradient of 2 color components which are
  8901. set by option @code{x} and @code{y}.
  8902. @item color2
  8903. Actual color components values present in video frame are displayed on graph.
  8904. @item color3
  8905. Similar as color2 but higher frequency of same values @code{x} and @code{y}
  8906. on graph increases value of another color component, which is luminance by
  8907. default values of @code{x} and @code{y}.
  8908. @item color4
  8909. Actual colors present in video frame are displayed on graph. If two different
  8910. colors map to same position on graph then color with higher value of component
  8911. not present in graph is picked.
  8912. @end table
  8913. @item x
  8914. Set which color component will be represented on X-axis. Default is @code{1}.
  8915. @item y
  8916. Set which color component will be represented on Y-axis. Default is @code{2}.
  8917. @item intensity, i
  8918. Set intensity, used by modes: gray, color and color3 for increasing brightness
  8919. of color component which represents frequency of (X, Y) location in graph.
  8920. @item envelope, e
  8921. @table @samp
  8922. @item none
  8923. No envelope, this is default.
  8924. @item instant
  8925. Instant envelope, even darkest single pixel will be clearly highlighted.
  8926. @item peak
  8927. Hold maximum and minimum values presented in graph over time. This way you
  8928. can still spot out of range values without constantly looking at vectorscope.
  8929. @item peak+instant
  8930. Peak and instant envelope combined together.
  8931. @end table
  8932. @end table
  8933. @anchor{vidstabdetect}
  8934. @section vidstabdetect
  8935. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  8936. @ref{vidstabtransform} for pass 2.
  8937. This filter generates a file with relative translation and rotation
  8938. transform information about subsequent frames, which is then used by
  8939. the @ref{vidstabtransform} filter.
  8940. To enable compilation of this filter you need to configure FFmpeg with
  8941. @code{--enable-libvidstab}.
  8942. This filter accepts the following options:
  8943. @table @option
  8944. @item result
  8945. Set the path to the file used to write the transforms information.
  8946. Default value is @file{transforms.trf}.
  8947. @item shakiness
  8948. Set how shaky the video is and how quick the camera is. It accepts an
  8949. integer in the range 1-10, a value of 1 means little shakiness, a
  8950. value of 10 means strong shakiness. Default value is 5.
  8951. @item accuracy
  8952. Set the accuracy of the detection process. It must be a value in the
  8953. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  8954. accuracy. Default value is 15.
  8955. @item stepsize
  8956. Set stepsize of the search process. The region around minimum is
  8957. scanned with 1 pixel resolution. Default value is 6.
  8958. @item mincontrast
  8959. Set minimum contrast. Below this value a local measurement field is
  8960. discarded. Must be a floating point value in the range 0-1. Default
  8961. value is 0.3.
  8962. @item tripod
  8963. Set reference frame number for tripod mode.
  8964. If enabled, the motion of the frames is compared to a reference frame
  8965. in the filtered stream, identified by the specified number. The idea
  8966. is to compensate all movements in a more-or-less static scene and keep
  8967. the camera view absolutely still.
  8968. If set to 0, it is disabled. The frames are counted starting from 1.
  8969. @item show
  8970. Show fields and transforms in the resulting frames. It accepts an
  8971. integer in the range 0-2. Default value is 0, which disables any
  8972. visualization.
  8973. @end table
  8974. @subsection Examples
  8975. @itemize
  8976. @item
  8977. Use default values:
  8978. @example
  8979. vidstabdetect
  8980. @end example
  8981. @item
  8982. Analyze strongly shaky movie and put the results in file
  8983. @file{mytransforms.trf}:
  8984. @example
  8985. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  8986. @end example
  8987. @item
  8988. Visualize the result of internal transformations in the resulting
  8989. video:
  8990. @example
  8991. vidstabdetect=show=1
  8992. @end example
  8993. @item
  8994. Analyze a video with medium shakiness using @command{ffmpeg}:
  8995. @example
  8996. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  8997. @end example
  8998. @end itemize
  8999. @anchor{vidstabtransform}
  9000. @section vidstabtransform
  9001. Video stabilization/deshaking: pass 2 of 2,
  9002. see @ref{vidstabdetect} for pass 1.
  9003. Read a file with transform information for each frame and
  9004. apply/compensate them. Together with the @ref{vidstabdetect}
  9005. filter this can be used to deshake videos. See also
  9006. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  9007. the @ref{unsharp} filter, see below.
  9008. To enable compilation of this filter you need to configure FFmpeg with
  9009. @code{--enable-libvidstab}.
  9010. @subsection Options
  9011. @table @option
  9012. @item input
  9013. Set path to the file used to read the transforms. Default value is
  9014. @file{transforms.trf}.
  9015. @item smoothing
  9016. Set the number of frames (value*2 + 1) used for lowpass filtering the
  9017. camera movements. Default value is 10.
  9018. For example a number of 10 means that 21 frames are used (10 in the
  9019. past and 10 in the future) to smoothen the motion in the video. A
  9020. larger value leads to a smoother video, but limits the acceleration of
  9021. the camera (pan/tilt movements). 0 is a special case where a static
  9022. camera is simulated.
  9023. @item optalgo
  9024. Set the camera path optimization algorithm.
  9025. Accepted values are:
  9026. @table @samp
  9027. @item gauss
  9028. gaussian kernel low-pass filter on camera motion (default)
  9029. @item avg
  9030. averaging on transformations
  9031. @end table
  9032. @item maxshift
  9033. Set maximal number of pixels to translate frames. Default value is -1,
  9034. meaning no limit.
  9035. @item maxangle
  9036. Set maximal angle in radians (degree*PI/180) to rotate frames. Default
  9037. value is -1, meaning no limit.
  9038. @item crop
  9039. Specify how to deal with borders that may be visible due to movement
  9040. compensation.
  9041. Available values are:
  9042. @table @samp
  9043. @item keep
  9044. keep image information from previous frame (default)
  9045. @item black
  9046. fill the border black
  9047. @end table
  9048. @item invert
  9049. Invert transforms if set to 1. Default value is 0.
  9050. @item relative
  9051. Consider transforms as relative to previous frame if set to 1,
  9052. absolute if set to 0. Default value is 0.
  9053. @item zoom
  9054. Set percentage to zoom. A positive value will result in a zoom-in
  9055. effect, a negative value in a zoom-out effect. Default value is 0 (no
  9056. zoom).
  9057. @item optzoom
  9058. Set optimal zooming to avoid borders.
  9059. Accepted values are:
  9060. @table @samp
  9061. @item 0
  9062. disabled
  9063. @item 1
  9064. optimal static zoom value is determined (only very strong movements
  9065. will lead to visible borders) (default)
  9066. @item 2
  9067. optimal adaptive zoom value is determined (no borders will be
  9068. visible), see @option{zoomspeed}
  9069. @end table
  9070. Note that the value given at zoom is added to the one calculated here.
  9071. @item zoomspeed
  9072. Set percent to zoom maximally each frame (enabled when
  9073. @option{optzoom} is set to 2). Range is from 0 to 5, default value is
  9074. 0.25.
  9075. @item interpol
  9076. Specify type of interpolation.
  9077. Available values are:
  9078. @table @samp
  9079. @item no
  9080. no interpolation
  9081. @item linear
  9082. linear only horizontal
  9083. @item bilinear
  9084. linear in both directions (default)
  9085. @item bicubic
  9086. cubic in both directions (slow)
  9087. @end table
  9088. @item tripod
  9089. Enable virtual tripod mode if set to 1, which is equivalent to
  9090. @code{relative=0:smoothing=0}. Default value is 0.
  9091. Use also @code{tripod} option of @ref{vidstabdetect}.
  9092. @item debug
  9093. Increase log verbosity if set to 1. Also the detected global motions
  9094. are written to the temporary file @file{global_motions.trf}. Default
  9095. value is 0.
  9096. @end table
  9097. @subsection Examples
  9098. @itemize
  9099. @item
  9100. Use @command{ffmpeg} for a typical stabilization with default values:
  9101. @example
  9102. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  9103. @end example
  9104. Note the use of the @ref{unsharp} filter which is always recommended.
  9105. @item
  9106. Zoom in a bit more and load transform data from a given file:
  9107. @example
  9108. vidstabtransform=zoom=5:input="mytransforms.trf"
  9109. @end example
  9110. @item
  9111. Smoothen the video even more:
  9112. @example
  9113. vidstabtransform=smoothing=30
  9114. @end example
  9115. @end itemize
  9116. @section vflip
  9117. Flip the input video vertically.
  9118. For example, to vertically flip a video with @command{ffmpeg}:
  9119. @example
  9120. ffmpeg -i in.avi -vf "vflip" out.avi
  9121. @end example
  9122. @anchor{vignette}
  9123. @section vignette
  9124. Make or reverse a natural vignetting effect.
  9125. The filter accepts the following options:
  9126. @table @option
  9127. @item angle, a
  9128. Set lens angle expression as a number of radians.
  9129. The value is clipped in the @code{[0,PI/2]} range.
  9130. Default value: @code{"PI/5"}
  9131. @item x0
  9132. @item y0
  9133. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  9134. by default.
  9135. @item mode
  9136. Set forward/backward mode.
  9137. Available modes are:
  9138. @table @samp
  9139. @item forward
  9140. The larger the distance from the central point, the darker the image becomes.
  9141. @item backward
  9142. The larger the distance from the central point, the brighter the image becomes.
  9143. This can be used to reverse a vignette effect, though there is no automatic
  9144. detection to extract the lens @option{angle} and other settings (yet). It can
  9145. also be used to create a burning effect.
  9146. @end table
  9147. Default value is @samp{forward}.
  9148. @item eval
  9149. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  9150. It accepts the following values:
  9151. @table @samp
  9152. @item init
  9153. Evaluate expressions only once during the filter initialization.
  9154. @item frame
  9155. Evaluate expressions for each incoming frame. This is way slower than the
  9156. @samp{init} mode since it requires all the scalers to be re-computed, but it
  9157. allows advanced dynamic expressions.
  9158. @end table
  9159. Default value is @samp{init}.
  9160. @item dither
  9161. Set dithering to reduce the circular banding effects. Default is @code{1}
  9162. (enabled).
  9163. @item aspect
  9164. Set vignette aspect. This setting allows one to adjust the shape of the vignette.
  9165. Setting this value to the SAR of the input will make a rectangular vignetting
  9166. following the dimensions of the video.
  9167. Default is @code{1/1}.
  9168. @end table
  9169. @subsection Expressions
  9170. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  9171. following parameters.
  9172. @table @option
  9173. @item w
  9174. @item h
  9175. input width and height
  9176. @item n
  9177. the number of input frame, starting from 0
  9178. @item pts
  9179. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  9180. @var{TB} units, NAN if undefined
  9181. @item r
  9182. frame rate of the input video, NAN if the input frame rate is unknown
  9183. @item t
  9184. the PTS (Presentation TimeStamp) of the filtered video frame,
  9185. expressed in seconds, NAN if undefined
  9186. @item tb
  9187. time base of the input video
  9188. @end table
  9189. @subsection Examples
  9190. @itemize
  9191. @item
  9192. Apply simple strong vignetting effect:
  9193. @example
  9194. vignette=PI/4
  9195. @end example
  9196. @item
  9197. Make a flickering vignetting:
  9198. @example
  9199. vignette='PI/4+random(1)*PI/50':eval=frame
  9200. @end example
  9201. @end itemize
  9202. @section vstack
  9203. Stack input videos vertically.
  9204. All streams must be of same pixel format and of same width.
  9205. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  9206. to create same output.
  9207. The filter accept the following option:
  9208. @table @option
  9209. @item inputs
  9210. Set number of input streams. Default is 2.
  9211. @item shortest
  9212. If set to 1, force the output to terminate when the shortest input
  9213. terminates. Default value is 0.
  9214. @end table
  9215. @section w3fdif
  9216. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  9217. Deinterlacing Filter").
  9218. Based on the process described by Martin Weston for BBC R&D, and
  9219. implemented based on the de-interlace algorithm written by Jim
  9220. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  9221. uses filter coefficients calculated by BBC R&D.
  9222. There are two sets of filter coefficients, so called "simple":
  9223. and "complex". Which set of filter coefficients is used can
  9224. be set by passing an optional parameter:
  9225. @table @option
  9226. @item filter
  9227. Set the interlacing filter coefficients. Accepts one of the following values:
  9228. @table @samp
  9229. @item simple
  9230. Simple filter coefficient set.
  9231. @item complex
  9232. More-complex filter coefficient set.
  9233. @end table
  9234. Default value is @samp{complex}.
  9235. @item deint
  9236. Specify which frames to deinterlace. Accept one of the following values:
  9237. @table @samp
  9238. @item all
  9239. Deinterlace all frames,
  9240. @item interlaced
  9241. Only deinterlace frames marked as interlaced.
  9242. @end table
  9243. Default value is @samp{all}.
  9244. @end table
  9245. @section waveform
  9246. Video waveform monitor.
  9247. The waveform monitor plots color component intensity. By default luminance
  9248. only. Each column of the waveform corresponds to a column of pixels in the
  9249. source video.
  9250. It accepts the following options:
  9251. @table @option
  9252. @item mode, m
  9253. Can be either @code{row}, or @code{column}. Default is @code{column}.
  9254. In row mode, the graph on the left side represents color component value 0 and
  9255. the right side represents value = 255. In column mode, the top side represents
  9256. color component value = 0 and bottom side represents value = 255.
  9257. @item intensity, i
  9258. Set intensity. Smaller values are useful to find out how many values of the same
  9259. luminance are distributed across input rows/columns.
  9260. Default value is @code{0.04}. Allowed range is [0, 1].
  9261. @item mirror, r
  9262. Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored.
  9263. In mirrored mode, higher values will be represented on the left
  9264. side for @code{row} mode and at the top for @code{column} mode. Default is
  9265. @code{1} (mirrored).
  9266. @item display, d
  9267. Set display mode.
  9268. It accepts the following values:
  9269. @table @samp
  9270. @item overlay
  9271. Presents information identical to that in the @code{parade}, except
  9272. that the graphs representing color components are superimposed directly
  9273. over one another.
  9274. This display mode makes it easier to spot relative differences or similarities
  9275. in overlapping areas of the color components that are supposed to be identical,
  9276. such as neutral whites, grays, or blacks.
  9277. @item parade
  9278. Display separate graph for the color components side by side in
  9279. @code{row} mode or one below the other in @code{column} mode.
  9280. Using this display mode makes it easy to spot color casts in the highlights
  9281. and shadows of an image, by comparing the contours of the top and the bottom
  9282. graphs of each waveform. Since whites, grays, and blacks are characterized
  9283. by exactly equal amounts of red, green, and blue, neutral areas of the picture
  9284. should display three waveforms of roughly equal width/height. If not, the
  9285. correction is easy to perform by making level adjustments the three waveforms.
  9286. @end table
  9287. Default is @code{parade}.
  9288. @item components, c
  9289. Set which color components to display. Default is 1, which means only luminance
  9290. or red color component if input is in RGB colorspace. If is set for example to
  9291. 7 it will display all 3 (if) available color components.
  9292. @item envelope, e
  9293. @table @samp
  9294. @item none
  9295. No envelope, this is default.
  9296. @item instant
  9297. Instant envelope, minimum and maximum values presented in graph will be easily
  9298. visible even with small @code{step} value.
  9299. @item peak
  9300. Hold minimum and maximum values presented in graph across time. This way you
  9301. can still spot out of range values without constantly looking at waveforms.
  9302. @item peak+instant
  9303. Peak and instant envelope combined together.
  9304. @end table
  9305. @item filter, f
  9306. @table @samp
  9307. @item lowpass
  9308. No filtering, this is default.
  9309. @item flat
  9310. Luma and chroma combined together.
  9311. @item aflat
  9312. Similar as above, but shows difference between blue and red chroma.
  9313. @item chroma
  9314. Displays only chroma.
  9315. @item achroma
  9316. Similar as above, but shows difference between blue and red chroma.
  9317. @item color
  9318. Displays actual color value on waveform.
  9319. @end table
  9320. @end table
  9321. @section xbr
  9322. Apply the xBR high-quality magnification filter which is designed for pixel
  9323. art. It follows a set of edge-detection rules, see
  9324. @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
  9325. It accepts the following option:
  9326. @table @option
  9327. @item n
  9328. Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
  9329. @code{3xBR} and @code{4} for @code{4xBR}.
  9330. Default is @code{3}.
  9331. @end table
  9332. @anchor{yadif}
  9333. @section yadif
  9334. Deinterlace the input video ("yadif" means "yet another deinterlacing
  9335. filter").
  9336. It accepts the following parameters:
  9337. @table @option
  9338. @item mode
  9339. The interlacing mode to adopt. It accepts one of the following values:
  9340. @table @option
  9341. @item 0, send_frame
  9342. Output one frame for each frame.
  9343. @item 1, send_field
  9344. Output one frame for each field.
  9345. @item 2, send_frame_nospatial
  9346. Like @code{send_frame}, but it skips the spatial interlacing check.
  9347. @item 3, send_field_nospatial
  9348. Like @code{send_field}, but it skips the spatial interlacing check.
  9349. @end table
  9350. The default value is @code{send_frame}.
  9351. @item parity
  9352. The picture field parity assumed for the input interlaced video. It accepts one
  9353. of the following values:
  9354. @table @option
  9355. @item 0, tff
  9356. Assume the top field is first.
  9357. @item 1, bff
  9358. Assume the bottom field is first.
  9359. @item -1, auto
  9360. Enable automatic detection of field parity.
  9361. @end table
  9362. The default value is @code{auto}.
  9363. If the interlacing is unknown or the decoder does not export this information,
  9364. top field first will be assumed.
  9365. @item deint
  9366. Specify which frames to deinterlace. Accept one of the following
  9367. values:
  9368. @table @option
  9369. @item 0, all
  9370. Deinterlace all frames.
  9371. @item 1, interlaced
  9372. Only deinterlace frames marked as interlaced.
  9373. @end table
  9374. The default value is @code{all}.
  9375. @end table
  9376. @section zoompan
  9377. Apply Zoom & Pan effect.
  9378. This filter accepts the following options:
  9379. @table @option
  9380. @item zoom, z
  9381. Set the zoom expression. Default is 1.
  9382. @item x
  9383. @item y
  9384. Set the x and y expression. Default is 0.
  9385. @item d
  9386. Set the duration expression in number of frames.
  9387. This sets for how many number of frames effect will last for
  9388. single input image.
  9389. @item s
  9390. Set the output image size, default is 'hd720'.
  9391. @end table
  9392. Each expression can contain the following constants:
  9393. @table @option
  9394. @item in_w, iw
  9395. Input width.
  9396. @item in_h, ih
  9397. Input height.
  9398. @item out_w, ow
  9399. Output width.
  9400. @item out_h, oh
  9401. Output height.
  9402. @item in
  9403. Input frame count.
  9404. @item on
  9405. Output frame count.
  9406. @item x
  9407. @item y
  9408. Last calculated 'x' and 'y' position from 'x' and 'y' expression
  9409. for current input frame.
  9410. @item px
  9411. @item py
  9412. 'x' and 'y' of last output frame of previous input frame or 0 when there was
  9413. not yet such frame (first input frame).
  9414. @item zoom
  9415. Last calculated zoom from 'z' expression for current input frame.
  9416. @item pzoom
  9417. Last calculated zoom of last output frame of previous input frame.
  9418. @item duration
  9419. Number of output frames for current input frame. Calculated from 'd' expression
  9420. for each input frame.
  9421. @item pduration
  9422. number of output frames created for previous input frame
  9423. @item a
  9424. Rational number: input width / input height
  9425. @item sar
  9426. sample aspect ratio
  9427. @item dar
  9428. display aspect ratio
  9429. @end table
  9430. @subsection Examples
  9431. @itemize
  9432. @item
  9433. Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
  9434. @example
  9435. 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
  9436. @end example
  9437. @item
  9438. Zoom-in up to 1.5 and pan always at center of picture:
  9439. @example
  9440. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
  9441. @end example
  9442. @end itemize
  9443. @section zscale
  9444. Scale (resize) the input video, using the z.lib library:
  9445. https://github.com/sekrit-twc/zimg.
  9446. The zscale filter forces the output display aspect ratio to be the same
  9447. as the input, by changing the output sample aspect ratio.
  9448. If the input image format is different from the format requested by
  9449. the next filter, the zscale filter will convert the input to the
  9450. requested format.
  9451. @subsection Options
  9452. The filter accepts the following options.
  9453. @table @option
  9454. @item width, w
  9455. @item height, h
  9456. Set the output video dimension expression. Default value is the input
  9457. dimension.
  9458. If the @var{width} or @var{w} is 0, the input width is used for the output.
  9459. If the @var{height} or @var{h} is 0, the input height is used for the output.
  9460. If one of the values is -1, the zscale filter will use a value that
  9461. maintains the aspect ratio of the input image, calculated from the
  9462. other specified dimension. If both of them are -1, the input size is
  9463. used
  9464. If one of the values is -n with n > 1, the zscale filter will also use a value
  9465. that maintains the aspect ratio of the input image, calculated from the other
  9466. specified dimension. After that it will, however, make sure that the calculated
  9467. dimension is divisible by n and adjust the value if necessary.
  9468. See below for the list of accepted constants for use in the dimension
  9469. expression.
  9470. @item size, s
  9471. Set the video size. For the syntax of this option, check the
  9472. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9473. @item dither, d
  9474. Set the dither type.
  9475. Possible values are:
  9476. @table @var
  9477. @item none
  9478. @item ordered
  9479. @item random
  9480. @item error_diffusion
  9481. @end table
  9482. Default is none.
  9483. @item filter, f
  9484. Set the resize filter type.
  9485. Possible values are:
  9486. @table @var
  9487. @item point
  9488. @item bilinear
  9489. @item bicubic
  9490. @item spline16
  9491. @item spline36
  9492. @item lanczos
  9493. @end table
  9494. Default is bilinear.
  9495. @item range, r
  9496. Set the color range.
  9497. Possible values are:
  9498. @table @var
  9499. @item input
  9500. @item limited
  9501. @item full
  9502. @end table
  9503. Default is same as input.
  9504. @item primaries, p
  9505. Set the color primaries.
  9506. Possible values are:
  9507. @table @var
  9508. @item input
  9509. @item 709
  9510. @item unspecified
  9511. @item 170m
  9512. @item 240m
  9513. @item 2020
  9514. @end table
  9515. Default is same as input.
  9516. @item transfer, t
  9517. Set the transfer characteristics.
  9518. Possible values are:
  9519. @table @var
  9520. @item input
  9521. @item 709
  9522. @item unspecified
  9523. @item 601
  9524. @item linear
  9525. @item 2020_10
  9526. @item 2020_12
  9527. @end table
  9528. Default is same as input.
  9529. @item matrix, m
  9530. Set the colorspace matrix.
  9531. Possible value are:
  9532. @table @var
  9533. @item input
  9534. @item 709
  9535. @item unspecified
  9536. @item 470bg
  9537. @item 170m
  9538. @item 2020_ncl
  9539. @item 2020_cl
  9540. @end table
  9541. Default is same as input.
  9542. @end table
  9543. The values of the @option{w} and @option{h} options are expressions
  9544. containing the following constants:
  9545. @table @var
  9546. @item in_w
  9547. @item in_h
  9548. The input width and height
  9549. @item iw
  9550. @item ih
  9551. These are the same as @var{in_w} and @var{in_h}.
  9552. @item out_w
  9553. @item out_h
  9554. The output (scaled) width and height
  9555. @item ow
  9556. @item oh
  9557. These are the same as @var{out_w} and @var{out_h}
  9558. @item a
  9559. The same as @var{iw} / @var{ih}
  9560. @item sar
  9561. input sample aspect ratio
  9562. @item dar
  9563. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  9564. @item hsub
  9565. @item vsub
  9566. horizontal and vertical input chroma subsample values. For example for the
  9567. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  9568. @item ohsub
  9569. @item ovsub
  9570. horizontal and vertical output chroma subsample values. For example for the
  9571. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  9572. @end table
  9573. @table @option
  9574. @end table
  9575. @c man end VIDEO FILTERS
  9576. @chapter Video Sources
  9577. @c man begin VIDEO SOURCES
  9578. Below is a description of the currently available video sources.
  9579. @section buffer
  9580. Buffer video frames, and make them available to the filter chain.
  9581. This source is mainly intended for a programmatic use, in particular
  9582. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  9583. It accepts the following parameters:
  9584. @table @option
  9585. @item video_size
  9586. Specify the size (width and height) of the buffered video frames. For the
  9587. syntax of this option, check the
  9588. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9589. @item width
  9590. The input video width.
  9591. @item height
  9592. The input video height.
  9593. @item pix_fmt
  9594. A string representing the pixel format of the buffered video frames.
  9595. It may be a number corresponding to a pixel format, or a pixel format
  9596. name.
  9597. @item time_base
  9598. Specify the timebase assumed by the timestamps of the buffered frames.
  9599. @item frame_rate
  9600. Specify the frame rate expected for the video stream.
  9601. @item pixel_aspect, sar
  9602. The sample (pixel) aspect ratio of the input video.
  9603. @item sws_param
  9604. Specify the optional parameters to be used for the scale filter which
  9605. is automatically inserted when an input change is detected in the
  9606. input size or format.
  9607. @end table
  9608. For example:
  9609. @example
  9610. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  9611. @end example
  9612. will instruct the source to accept video frames with size 320x240 and
  9613. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  9614. square pixels (1:1 sample aspect ratio).
  9615. Since the pixel format with name "yuv410p" corresponds to the number 6
  9616. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  9617. this example corresponds to:
  9618. @example
  9619. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  9620. @end example
  9621. Alternatively, the options can be specified as a flat string, but this
  9622. syntax is deprecated:
  9623. @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}]
  9624. @section cellauto
  9625. Create a pattern generated by an elementary cellular automaton.
  9626. The initial state of the cellular automaton can be defined through the
  9627. @option{filename}, and @option{pattern} options. If such options are
  9628. not specified an initial state is created randomly.
  9629. At each new frame a new row in the video is filled with the result of
  9630. the cellular automaton next generation. The behavior when the whole
  9631. frame is filled is defined by the @option{scroll} option.
  9632. This source accepts the following options:
  9633. @table @option
  9634. @item filename, f
  9635. Read the initial cellular automaton state, i.e. the starting row, from
  9636. the specified file.
  9637. In the file, each non-whitespace character is considered an alive
  9638. cell, a newline will terminate the row, and further characters in the
  9639. file will be ignored.
  9640. @item pattern, p
  9641. Read the initial cellular automaton state, i.e. the starting row, from
  9642. the specified string.
  9643. Each non-whitespace character in the string is considered an alive
  9644. cell, a newline will terminate the row, and further characters in the
  9645. string will be ignored.
  9646. @item rate, r
  9647. Set the video rate, that is the number of frames generated per second.
  9648. Default is 25.
  9649. @item random_fill_ratio, ratio
  9650. Set the random fill ratio for the initial cellular automaton row. It
  9651. is a floating point number value ranging from 0 to 1, defaults to
  9652. 1/PHI.
  9653. This option is ignored when a file or a pattern is specified.
  9654. @item random_seed, seed
  9655. Set the seed for filling randomly the initial row, must be an integer
  9656. included between 0 and UINT32_MAX. If not specified, or if explicitly
  9657. set to -1, the filter will try to use a good random seed on a best
  9658. effort basis.
  9659. @item rule
  9660. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  9661. Default value is 110.
  9662. @item size, s
  9663. Set the size of the output video. For the syntax of this option, check the
  9664. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9665. If @option{filename} or @option{pattern} is specified, the size is set
  9666. by default to the width of the specified initial state row, and the
  9667. height is set to @var{width} * PHI.
  9668. If @option{size} is set, it must contain the width of the specified
  9669. pattern string, and the specified pattern will be centered in the
  9670. larger row.
  9671. If a filename or a pattern string is not specified, the size value
  9672. defaults to "320x518" (used for a randomly generated initial state).
  9673. @item scroll
  9674. If set to 1, scroll the output upward when all the rows in the output
  9675. have been already filled. If set to 0, the new generated row will be
  9676. written over the top row just after the bottom row is filled.
  9677. Defaults to 1.
  9678. @item start_full, full
  9679. If set to 1, completely fill the output with generated rows before
  9680. outputting the first frame.
  9681. This is the default behavior, for disabling set the value to 0.
  9682. @item stitch
  9683. If set to 1, stitch the left and right row edges together.
  9684. This is the default behavior, for disabling set the value to 0.
  9685. @end table
  9686. @subsection Examples
  9687. @itemize
  9688. @item
  9689. Read the initial state from @file{pattern}, and specify an output of
  9690. size 200x400.
  9691. @example
  9692. cellauto=f=pattern:s=200x400
  9693. @end example
  9694. @item
  9695. Generate a random initial row with a width of 200 cells, with a fill
  9696. ratio of 2/3:
  9697. @example
  9698. cellauto=ratio=2/3:s=200x200
  9699. @end example
  9700. @item
  9701. Create a pattern generated by rule 18 starting by a single alive cell
  9702. centered on an initial row with width 100:
  9703. @example
  9704. cellauto=p=@@:s=100x400:full=0:rule=18
  9705. @end example
  9706. @item
  9707. Specify a more elaborated initial pattern:
  9708. @example
  9709. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  9710. @end example
  9711. @end itemize
  9712. @section mandelbrot
  9713. Generate a Mandelbrot set fractal, and progressively zoom towards the
  9714. point specified with @var{start_x} and @var{start_y}.
  9715. This source accepts the following options:
  9716. @table @option
  9717. @item end_pts
  9718. Set the terminal pts value. Default value is 400.
  9719. @item end_scale
  9720. Set the terminal scale value.
  9721. Must be a floating point value. Default value is 0.3.
  9722. @item inner
  9723. Set the inner coloring mode, that is the algorithm used to draw the
  9724. Mandelbrot fractal internal region.
  9725. It shall assume one of the following values:
  9726. @table @option
  9727. @item black
  9728. Set black mode.
  9729. @item convergence
  9730. Show time until convergence.
  9731. @item mincol
  9732. Set color based on point closest to the origin of the iterations.
  9733. @item period
  9734. Set period mode.
  9735. @end table
  9736. Default value is @var{mincol}.
  9737. @item bailout
  9738. Set the bailout value. Default value is 10.0.
  9739. @item maxiter
  9740. Set the maximum of iterations performed by the rendering
  9741. algorithm. Default value is 7189.
  9742. @item outer
  9743. Set outer coloring mode.
  9744. It shall assume one of following values:
  9745. @table @option
  9746. @item iteration_count
  9747. Set iteration cound mode.
  9748. @item normalized_iteration_count
  9749. set normalized iteration count mode.
  9750. @end table
  9751. Default value is @var{normalized_iteration_count}.
  9752. @item rate, r
  9753. Set frame rate, expressed as number of frames per second. Default
  9754. value is "25".
  9755. @item size, s
  9756. Set frame size. For the syntax of this option, check the "Video
  9757. size" section in the ffmpeg-utils manual. Default value is "640x480".
  9758. @item start_scale
  9759. Set the initial scale value. Default value is 3.0.
  9760. @item start_x
  9761. Set the initial x position. Must be a floating point value between
  9762. -100 and 100. Default value is -0.743643887037158704752191506114774.
  9763. @item start_y
  9764. Set the initial y position. Must be a floating point value between
  9765. -100 and 100. Default value is -0.131825904205311970493132056385139.
  9766. @end table
  9767. @section mptestsrc
  9768. Generate various test patterns, as generated by the MPlayer test filter.
  9769. The size of the generated video is fixed, and is 256x256.
  9770. This source is useful in particular for testing encoding features.
  9771. This source accepts the following options:
  9772. @table @option
  9773. @item rate, r
  9774. Specify the frame rate of the sourced video, as the number of frames
  9775. generated per second. It has to be a string in the format
  9776. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  9777. number or a valid video frame rate abbreviation. The default value is
  9778. "25".
  9779. @item duration, d
  9780. Set the duration of the sourced video. See
  9781. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  9782. for the accepted syntax.
  9783. If not specified, or the expressed duration is negative, the video is
  9784. supposed to be generated forever.
  9785. @item test, t
  9786. Set the number or the name of the test to perform. Supported tests are:
  9787. @table @option
  9788. @item dc_luma
  9789. @item dc_chroma
  9790. @item freq_luma
  9791. @item freq_chroma
  9792. @item amp_luma
  9793. @item amp_chroma
  9794. @item cbp
  9795. @item mv
  9796. @item ring1
  9797. @item ring2
  9798. @item all
  9799. @end table
  9800. Default value is "all", which will cycle through the list of all tests.
  9801. @end table
  9802. Some examples:
  9803. @example
  9804. mptestsrc=t=dc_luma
  9805. @end example
  9806. will generate a "dc_luma" test pattern.
  9807. @section frei0r_src
  9808. Provide a frei0r source.
  9809. To enable compilation of this filter you need to install the frei0r
  9810. header and configure FFmpeg with @code{--enable-frei0r}.
  9811. This source accepts the following parameters:
  9812. @table @option
  9813. @item size
  9814. The size of the video to generate. For the syntax of this option, check the
  9815. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9816. @item framerate
  9817. The framerate of the generated video. It may be a string of the form
  9818. @var{num}/@var{den} or a frame rate abbreviation.
  9819. @item filter_name
  9820. The name to the frei0r source to load. For more information regarding frei0r and
  9821. how to set the parameters, read the @ref{frei0r} section in the video filters
  9822. documentation.
  9823. @item filter_params
  9824. A '|'-separated list of parameters to pass to the frei0r source.
  9825. @end table
  9826. For example, to generate a frei0r partik0l source with size 200x200
  9827. and frame rate 10 which is overlaid on the overlay filter main input:
  9828. @example
  9829. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  9830. @end example
  9831. @section life
  9832. Generate a life pattern.
  9833. This source is based on a generalization of John Conway's life game.
  9834. The sourced input represents a life grid, each pixel represents a cell
  9835. which can be in one of two possible states, alive or dead. Every cell
  9836. interacts with its eight neighbours, which are the cells that are
  9837. horizontally, vertically, or diagonally adjacent.
  9838. At each interaction the grid evolves according to the adopted rule,
  9839. which specifies the number of neighbor alive cells which will make a
  9840. cell stay alive or born. The @option{rule} option allows one to specify
  9841. the rule to adopt.
  9842. This source accepts the following options:
  9843. @table @option
  9844. @item filename, f
  9845. Set the file from which to read the initial grid state. In the file,
  9846. each non-whitespace character is considered an alive cell, and newline
  9847. is used to delimit the end of each row.
  9848. If this option is not specified, the initial grid is generated
  9849. randomly.
  9850. @item rate, r
  9851. Set the video rate, that is the number of frames generated per second.
  9852. Default is 25.
  9853. @item random_fill_ratio, ratio
  9854. Set the random fill ratio for the initial random grid. It is a
  9855. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  9856. It is ignored when a file is specified.
  9857. @item random_seed, seed
  9858. Set the seed for filling the initial random grid, must be an integer
  9859. included between 0 and UINT32_MAX. If not specified, or if explicitly
  9860. set to -1, the filter will try to use a good random seed on a best
  9861. effort basis.
  9862. @item rule
  9863. Set the life rule.
  9864. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  9865. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  9866. @var{NS} specifies the number of alive neighbor cells which make a
  9867. live cell stay alive, and @var{NB} the number of alive neighbor cells
  9868. which make a dead cell to become alive (i.e. to "born").
  9869. "s" and "b" can be used in place of "S" and "B", respectively.
  9870. Alternatively a rule can be specified by an 18-bits integer. The 9
  9871. high order bits are used to encode the next cell state if it is alive
  9872. for each number of neighbor alive cells, the low order bits specify
  9873. the rule for "borning" new cells. Higher order bits encode for an
  9874. higher number of neighbor cells.
  9875. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  9876. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  9877. Default value is "S23/B3", which is the original Conway's game of life
  9878. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  9879. cells, and will born a new cell if there are three alive cells around
  9880. a dead cell.
  9881. @item size, s
  9882. Set the size of the output video. For the syntax of this option, check the
  9883. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9884. If @option{filename} is specified, the size is set by default to the
  9885. same size of the input file. If @option{size} is set, it must contain
  9886. the size specified in the input file, and the initial grid defined in
  9887. that file is centered in the larger resulting area.
  9888. If a filename is not specified, the size value defaults to "320x240"
  9889. (used for a randomly generated initial grid).
  9890. @item stitch
  9891. If set to 1, stitch the left and right grid edges together, and the
  9892. top and bottom edges also. Defaults to 1.
  9893. @item mold
  9894. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  9895. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  9896. value from 0 to 255.
  9897. @item life_color
  9898. Set the color of living (or new born) cells.
  9899. @item death_color
  9900. Set the color of dead cells. If @option{mold} is set, this is the first color
  9901. used to represent a dead cell.
  9902. @item mold_color
  9903. Set mold color, for definitely dead and moldy cells.
  9904. For the syntax of these 3 color options, check the "Color" section in the
  9905. ffmpeg-utils manual.
  9906. @end table
  9907. @subsection Examples
  9908. @itemize
  9909. @item
  9910. Read a grid from @file{pattern}, and center it on a grid of size
  9911. 300x300 pixels:
  9912. @example
  9913. life=f=pattern:s=300x300
  9914. @end example
  9915. @item
  9916. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  9917. @example
  9918. life=ratio=2/3:s=200x200
  9919. @end example
  9920. @item
  9921. Specify a custom rule for evolving a randomly generated grid:
  9922. @example
  9923. life=rule=S14/B34
  9924. @end example
  9925. @item
  9926. Full example with slow death effect (mold) using @command{ffplay}:
  9927. @example
  9928. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  9929. @end example
  9930. @end itemize
  9931. @anchor{allrgb}
  9932. @anchor{allyuv}
  9933. @anchor{color}
  9934. @anchor{haldclutsrc}
  9935. @anchor{nullsrc}
  9936. @anchor{rgbtestsrc}
  9937. @anchor{smptebars}
  9938. @anchor{smptehdbars}
  9939. @anchor{testsrc}
  9940. @section allrgb, allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  9941. The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
  9942. The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
  9943. The @code{color} source provides an uniformly colored input.
  9944. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  9945. @ref{haldclut} filter.
  9946. The @code{nullsrc} source returns unprocessed video frames. It is
  9947. mainly useful to be employed in analysis / debugging tools, or as the
  9948. source for filters which ignore the input data.
  9949. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  9950. detecting RGB vs BGR issues. You should see a red, green and blue
  9951. stripe from top to bottom.
  9952. The @code{smptebars} source generates a color bars pattern, based on
  9953. the SMPTE Engineering Guideline EG 1-1990.
  9954. The @code{smptehdbars} source generates a color bars pattern, based on
  9955. the SMPTE RP 219-2002.
  9956. The @code{testsrc} source generates a test video pattern, showing a
  9957. color pattern, a scrolling gradient and a timestamp. This is mainly
  9958. intended for testing purposes.
  9959. The sources accept the following parameters:
  9960. @table @option
  9961. @item color, c
  9962. Specify the color of the source, only available in the @code{color}
  9963. source. For the syntax of this option, check the "Color" section in the
  9964. ffmpeg-utils manual.
  9965. @item level
  9966. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  9967. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  9968. pixels to be used as identity matrix for 3D lookup tables. Each component is
  9969. coded on a @code{1/(N*N)} scale.
  9970. @item size, s
  9971. Specify the size of the sourced video. For the syntax of this option, check the
  9972. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9973. The default value is @code{320x240}.
  9974. This option is not available with the @code{haldclutsrc} filter.
  9975. @item rate, r
  9976. Specify the frame rate of the sourced video, as the number of frames
  9977. generated per second. It has to be a string in the format
  9978. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  9979. number or a valid video frame rate abbreviation. The default value is
  9980. "25".
  9981. @item sar
  9982. Set the sample aspect ratio of the sourced video.
  9983. @item duration, d
  9984. Set the duration of the sourced video. See
  9985. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  9986. for the accepted syntax.
  9987. If not specified, or the expressed duration is negative, the video is
  9988. supposed to be generated forever.
  9989. @item decimals, n
  9990. Set the number of decimals to show in the timestamp, only available in the
  9991. @code{testsrc} source.
  9992. The displayed timestamp value will correspond to the original
  9993. timestamp value multiplied by the power of 10 of the specified
  9994. value. Default value is 0.
  9995. @end table
  9996. For example the following:
  9997. @example
  9998. testsrc=duration=5.3:size=qcif:rate=10
  9999. @end example
  10000. will generate a video with a duration of 5.3 seconds, with size
  10001. 176x144 and a frame rate of 10 frames per second.
  10002. The following graph description will generate a red source
  10003. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  10004. frames per second.
  10005. @example
  10006. color=c=red@@0.2:s=qcif:r=10
  10007. @end example
  10008. If the input content is to be ignored, @code{nullsrc} can be used. The
  10009. following command generates noise in the luminance plane by employing
  10010. the @code{geq} filter:
  10011. @example
  10012. nullsrc=s=256x256, geq=random(1)*255:128:128
  10013. @end example
  10014. @subsection Commands
  10015. The @code{color} source supports the following commands:
  10016. @table @option
  10017. @item c, color
  10018. Set the color of the created image. Accepts the same syntax of the
  10019. corresponding @option{color} option.
  10020. @end table
  10021. @c man end VIDEO SOURCES
  10022. @chapter Video Sinks
  10023. @c man begin VIDEO SINKS
  10024. Below is a description of the currently available video sinks.
  10025. @section buffersink
  10026. Buffer video frames, and make them available to the end of the filter
  10027. graph.
  10028. This sink is mainly intended for programmatic use, in particular
  10029. through the interface defined in @file{libavfilter/buffersink.h}
  10030. or the options system.
  10031. It accepts a pointer to an AVBufferSinkContext structure, which
  10032. defines the incoming buffers' formats, to be passed as the opaque
  10033. parameter to @code{avfilter_init_filter} for initialization.
  10034. @section nullsink
  10035. Null video sink: do absolutely nothing with the input video. It is
  10036. mainly useful as a template and for use in analysis / debugging
  10037. tools.
  10038. @c man end VIDEO SINKS
  10039. @chapter Multimedia Filters
  10040. @c man begin MULTIMEDIA FILTERS
  10041. Below is a description of the currently available multimedia filters.
  10042. @section aphasemeter
  10043. Convert input audio to a video output, displaying the audio phase.
  10044. The filter accepts the following options:
  10045. @table @option
  10046. @item rate, r
  10047. Set the output frame rate. Default value is @code{25}.
  10048. @item size, s
  10049. Set the video size for the output. For the syntax of this option, check the
  10050. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10051. Default value is @code{800x400}.
  10052. @item rc
  10053. @item gc
  10054. @item bc
  10055. Specify the red, green, blue contrast. Default values are @code{2},
  10056. @code{7} and @code{1}.
  10057. Allowed range is @code{[0, 255]}.
  10058. @item mpc
  10059. Set color which will be used for drawing median phase. If color is
  10060. @code{none} which is default, no median phase value will be drawn.
  10061. @end table
  10062. The filter also exports the frame metadata @code{lavfi.aphasemeter.phase} which
  10063. represents mean phase of current audio frame. Value is in range @code{[-1, 1]}.
  10064. The @code{-1} means left and right channels are completely out of phase and
  10065. @code{1} means channels are in phase.
  10066. @section avectorscope
  10067. Convert input audio to a video output, representing the audio vector
  10068. scope.
  10069. The filter is used to measure the difference between channels of stereo
  10070. audio stream. A monoaural signal, consisting of identical left and right
  10071. signal, results in straight vertical line. Any stereo separation is visible
  10072. as a deviation from this line, creating a Lissajous figure.
  10073. If the straight (or deviation from it) but horizontal line appears this
  10074. indicates that the left and right channels are out of phase.
  10075. The filter accepts the following options:
  10076. @table @option
  10077. @item mode, m
  10078. Set the vectorscope mode.
  10079. Available values are:
  10080. @table @samp
  10081. @item lissajous
  10082. Lissajous rotated by 45 degrees.
  10083. @item lissajous_xy
  10084. Same as above but not rotated.
  10085. @item polar
  10086. Shape resembling half of circle.
  10087. @end table
  10088. Default value is @samp{lissajous}.
  10089. @item size, s
  10090. Set the video size for the output. For the syntax of this option, check the
  10091. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10092. Default value is @code{400x400}.
  10093. @item rate, r
  10094. Set the output frame rate. Default value is @code{25}.
  10095. @item rc
  10096. @item gc
  10097. @item bc
  10098. @item ac
  10099. Specify the red, green, blue and alpha contrast. Default values are @code{40},
  10100. @code{160}, @code{80} and @code{255}.
  10101. Allowed range is @code{[0, 255]}.
  10102. @item rf
  10103. @item gf
  10104. @item bf
  10105. @item af
  10106. Specify the red, green, blue and alpha fade. Default values are @code{15},
  10107. @code{10}, @code{5} and @code{5}.
  10108. Allowed range is @code{[0, 255]}.
  10109. @item zoom
  10110. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  10111. @end table
  10112. @subsection Examples
  10113. @itemize
  10114. @item
  10115. Complete example using @command{ffplay}:
  10116. @example
  10117. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  10118. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  10119. @end example
  10120. @end itemize
  10121. @section concat
  10122. Concatenate audio and video streams, joining them together one after the
  10123. other.
  10124. The filter works on segments of synchronized video and audio streams. All
  10125. segments must have the same number of streams of each type, and that will
  10126. also be the number of streams at output.
  10127. The filter accepts the following options:
  10128. @table @option
  10129. @item n
  10130. Set the number of segments. Default is 2.
  10131. @item v
  10132. Set the number of output video streams, that is also the number of video
  10133. streams in each segment. Default is 1.
  10134. @item a
  10135. Set the number of output audio streams, that is also the number of audio
  10136. streams in each segment. Default is 0.
  10137. @item unsafe
  10138. Activate unsafe mode: do not fail if segments have a different format.
  10139. @end table
  10140. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  10141. @var{a} audio outputs.
  10142. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  10143. segment, in the same order as the outputs, then the inputs for the second
  10144. segment, etc.
  10145. Related streams do not always have exactly the same duration, for various
  10146. reasons including codec frame size or sloppy authoring. For that reason,
  10147. related synchronized streams (e.g. a video and its audio track) should be
  10148. concatenated at once. The concat filter will use the duration of the longest
  10149. stream in each segment (except the last one), and if necessary pad shorter
  10150. audio streams with silence.
  10151. For this filter to work correctly, all segments must start at timestamp 0.
  10152. All corresponding streams must have the same parameters in all segments; the
  10153. filtering system will automatically select a common pixel format for video
  10154. streams, and a common sample format, sample rate and channel layout for
  10155. audio streams, but other settings, such as resolution, must be converted
  10156. explicitly by the user.
  10157. Different frame rates are acceptable but will result in variable frame rate
  10158. at output; be sure to configure the output file to handle it.
  10159. @subsection Examples
  10160. @itemize
  10161. @item
  10162. Concatenate an opening, an episode and an ending, all in bilingual version
  10163. (video in stream 0, audio in streams 1 and 2):
  10164. @example
  10165. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  10166. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  10167. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  10168. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  10169. @end example
  10170. @item
  10171. Concatenate two parts, handling audio and video separately, using the
  10172. (a)movie sources, and adjusting the resolution:
  10173. @example
  10174. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  10175. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  10176. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  10177. @end example
  10178. Note that a desync will happen at the stitch if the audio and video streams
  10179. do not have exactly the same duration in the first file.
  10180. @end itemize
  10181. @anchor{ebur128}
  10182. @section ebur128
  10183. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  10184. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  10185. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  10186. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  10187. The filter also has a video output (see the @var{video} option) with a real
  10188. time graph to observe the loudness evolution. The graphic contains the logged
  10189. message mentioned above, so it is not printed anymore when this option is set,
  10190. unless the verbose logging is set. The main graphing area contains the
  10191. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  10192. the momentary loudness (400 milliseconds).
  10193. More information about the Loudness Recommendation EBU R128 on
  10194. @url{http://tech.ebu.ch/loudness}.
  10195. The filter accepts the following options:
  10196. @table @option
  10197. @item video
  10198. Activate the video output. The audio stream is passed unchanged whether this
  10199. option is set or no. The video stream will be the first output stream if
  10200. activated. Default is @code{0}.
  10201. @item size
  10202. Set the video size. This option is for video only. For the syntax of this
  10203. option, check the
  10204. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10205. Default and minimum resolution is @code{640x480}.
  10206. @item meter
  10207. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  10208. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  10209. other integer value between this range is allowed.
  10210. @item metadata
  10211. Set metadata injection. If set to @code{1}, the audio input will be segmented
  10212. into 100ms output frames, each of them containing various loudness information
  10213. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  10214. Default is @code{0}.
  10215. @item framelog
  10216. Force the frame logging level.
  10217. Available values are:
  10218. @table @samp
  10219. @item info
  10220. information logging level
  10221. @item verbose
  10222. verbose logging level
  10223. @end table
  10224. By default, the logging level is set to @var{info}. If the @option{video} or
  10225. the @option{metadata} options are set, it switches to @var{verbose}.
  10226. @item peak
  10227. Set peak mode(s).
  10228. Available modes can be cumulated (the option is a @code{flag} type). Possible
  10229. values are:
  10230. @table @samp
  10231. @item none
  10232. Disable any peak mode (default).
  10233. @item sample
  10234. Enable sample-peak mode.
  10235. Simple peak mode looking for the higher sample value. It logs a message
  10236. for sample-peak (identified by @code{SPK}).
  10237. @item true
  10238. Enable true-peak mode.
  10239. If enabled, the peak lookup is done on an over-sampled version of the input
  10240. stream for better peak accuracy. It logs a message for true-peak.
  10241. (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
  10242. This mode requires a build with @code{libswresample}.
  10243. @end table
  10244. @item dualmono
  10245. Treat mono input files as "dual mono". If a mono file is intended for playback
  10246. on a stereo system, its EBU R128 measurement will be perceptually incorrect.
  10247. If set to @code{true}, this option will compensate for this effect.
  10248. Multi-channel input files are not affected by this option.
  10249. @item panlaw
  10250. Set a specific pan law to be used for the measurement of dual mono files.
  10251. This parameter is optional, and has a default value of -3.01dB.
  10252. @end table
  10253. @subsection Examples
  10254. @itemize
  10255. @item
  10256. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  10257. @example
  10258. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  10259. @end example
  10260. @item
  10261. Run an analysis with @command{ffmpeg}:
  10262. @example
  10263. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  10264. @end example
  10265. @end itemize
  10266. @section interleave, ainterleave
  10267. Temporally interleave frames from several inputs.
  10268. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  10269. These filters read frames from several inputs and send the oldest
  10270. queued frame to the output.
  10271. Input streams must have a well defined, monotonically increasing frame
  10272. timestamp values.
  10273. In order to submit one frame to output, these filters need to enqueue
  10274. at least one frame for each input, so they cannot work in case one
  10275. input is not yet terminated and will not receive incoming frames.
  10276. For example consider the case when one input is a @code{select} filter
  10277. which always drop input frames. The @code{interleave} filter will keep
  10278. reading from that input, but it will never be able to send new frames
  10279. to output until the input will send an end-of-stream signal.
  10280. Also, depending on inputs synchronization, the filters will drop
  10281. frames in case one input receives more frames than the other ones, and
  10282. the queue is already filled.
  10283. These filters accept the following options:
  10284. @table @option
  10285. @item nb_inputs, n
  10286. Set the number of different inputs, it is 2 by default.
  10287. @end table
  10288. @subsection Examples
  10289. @itemize
  10290. @item
  10291. Interleave frames belonging to different streams using @command{ffmpeg}:
  10292. @example
  10293. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  10294. @end example
  10295. @item
  10296. Add flickering blur effect:
  10297. @example
  10298. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  10299. @end example
  10300. @end itemize
  10301. @section perms, aperms
  10302. Set read/write permissions for the output frames.
  10303. These filters are mainly aimed at developers to test direct path in the
  10304. following filter in the filtergraph.
  10305. The filters accept the following options:
  10306. @table @option
  10307. @item mode
  10308. Select the permissions mode.
  10309. It accepts the following values:
  10310. @table @samp
  10311. @item none
  10312. Do nothing. This is the default.
  10313. @item ro
  10314. Set all the output frames read-only.
  10315. @item rw
  10316. Set all the output frames directly writable.
  10317. @item toggle
  10318. Make the frame read-only if writable, and writable if read-only.
  10319. @item random
  10320. Set each output frame read-only or writable randomly.
  10321. @end table
  10322. @item seed
  10323. Set the seed for the @var{random} mode, must be an integer included between
  10324. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  10325. @code{-1}, the filter will try to use a good random seed on a best effort
  10326. basis.
  10327. @end table
  10328. Note: in case of auto-inserted filter between the permission filter and the
  10329. following one, the permission might not be received as expected in that
  10330. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  10331. perms/aperms filter can avoid this problem.
  10332. @section realtime, arealtime
  10333. Slow down filtering to match real time approximatively.
  10334. These filters will pause the filtering for a variable amount of time to
  10335. match the output rate with the input timestamps.
  10336. They are similar to the @option{re} option to @code{ffmpeg}.
  10337. They accept the following options:
  10338. @table @option
  10339. @item limit
  10340. Time limit for the pauses. Any pause longer than that will be considered
  10341. a timestamp discontinuity and reset the timer. Default is 2 seconds.
  10342. @end table
  10343. @section select, aselect
  10344. Select frames to pass in output.
  10345. This filter accepts the following options:
  10346. @table @option
  10347. @item expr, e
  10348. Set expression, which is evaluated for each input frame.
  10349. If the expression is evaluated to zero, the frame is discarded.
  10350. If the evaluation result is negative or NaN, the frame is sent to the
  10351. first output; otherwise it is sent to the output with index
  10352. @code{ceil(val)-1}, assuming that the input index starts from 0.
  10353. For example a value of @code{1.2} corresponds to the output with index
  10354. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  10355. @item outputs, n
  10356. Set the number of outputs. The output to which to send the selected
  10357. frame is based on the result of the evaluation. Default value is 1.
  10358. @end table
  10359. The expression can contain the following constants:
  10360. @table @option
  10361. @item n
  10362. The (sequential) number of the filtered frame, starting from 0.
  10363. @item selected_n
  10364. The (sequential) number of the selected frame, starting from 0.
  10365. @item prev_selected_n
  10366. The sequential number of the last selected frame. It's NAN if undefined.
  10367. @item TB
  10368. The timebase of the input timestamps.
  10369. @item pts
  10370. The PTS (Presentation TimeStamp) of the filtered video frame,
  10371. expressed in @var{TB} units. It's NAN if undefined.
  10372. @item t
  10373. The PTS of the filtered video frame,
  10374. expressed in seconds. It's NAN if undefined.
  10375. @item prev_pts
  10376. The PTS of the previously filtered video frame. It's NAN if undefined.
  10377. @item prev_selected_pts
  10378. The PTS of the last previously filtered video frame. It's NAN if undefined.
  10379. @item prev_selected_t
  10380. The PTS of the last previously selected video frame. It's NAN if undefined.
  10381. @item start_pts
  10382. The PTS of the first video frame in the video. It's NAN if undefined.
  10383. @item start_t
  10384. The time of the first video frame in the video. It's NAN if undefined.
  10385. @item pict_type @emph{(video only)}
  10386. The type of the filtered frame. It can assume one of the following
  10387. values:
  10388. @table @option
  10389. @item I
  10390. @item P
  10391. @item B
  10392. @item S
  10393. @item SI
  10394. @item SP
  10395. @item BI
  10396. @end table
  10397. @item interlace_type @emph{(video only)}
  10398. The frame interlace type. It can assume one of the following values:
  10399. @table @option
  10400. @item PROGRESSIVE
  10401. The frame is progressive (not interlaced).
  10402. @item TOPFIRST
  10403. The frame is top-field-first.
  10404. @item BOTTOMFIRST
  10405. The frame is bottom-field-first.
  10406. @end table
  10407. @item consumed_sample_n @emph{(audio only)}
  10408. the number of selected samples before the current frame
  10409. @item samples_n @emph{(audio only)}
  10410. the number of samples in the current frame
  10411. @item sample_rate @emph{(audio only)}
  10412. the input sample rate
  10413. @item key
  10414. This is 1 if the filtered frame is a key-frame, 0 otherwise.
  10415. @item pos
  10416. the position in the file of the filtered frame, -1 if the information
  10417. is not available (e.g. for synthetic video)
  10418. @item scene @emph{(video only)}
  10419. value between 0 and 1 to indicate a new scene; a low value reflects a low
  10420. probability for the current frame to introduce a new scene, while a higher
  10421. value means the current frame is more likely to be one (see the example below)
  10422. @item concatdec_select
  10423. The concat demuxer can select only part of a concat input file by setting an
  10424. inpoint and an outpoint, but the output packets may not be entirely contained
  10425. in the selected interval. By using this variable, it is possible to skip frames
  10426. generated by the concat demuxer which are not exactly contained in the selected
  10427. interval.
  10428. This works by comparing the frame pts against the @var{lavf.concat.start_time}
  10429. and the @var{lavf.concat.duration} packet metadata values which are also
  10430. present in the decoded frames.
  10431. The @var{concatdec_select} variable is -1 if the frame pts is at least
  10432. start_time and either the duration metadata is missing or the frame pts is less
  10433. than start_time + duration, 0 otherwise, and NaN if the start_time metadata is
  10434. missing.
  10435. That basically means that an input frame is selected if its pts is within the
  10436. interval set by the concat demuxer.
  10437. @end table
  10438. The default value of the select expression is "1".
  10439. @subsection Examples
  10440. @itemize
  10441. @item
  10442. Select all frames in input:
  10443. @example
  10444. select
  10445. @end example
  10446. The example above is the same as:
  10447. @example
  10448. select=1
  10449. @end example
  10450. @item
  10451. Skip all frames:
  10452. @example
  10453. select=0
  10454. @end example
  10455. @item
  10456. Select only I-frames:
  10457. @example
  10458. select='eq(pict_type\,I)'
  10459. @end example
  10460. @item
  10461. Select one frame every 100:
  10462. @example
  10463. select='not(mod(n\,100))'
  10464. @end example
  10465. @item
  10466. Select only frames contained in the 10-20 time interval:
  10467. @example
  10468. select=between(t\,10\,20)
  10469. @end example
  10470. @item
  10471. Select only I frames contained in the 10-20 time interval:
  10472. @example
  10473. select=between(t\,10\,20)*eq(pict_type\,I)
  10474. @end example
  10475. @item
  10476. Select frames with a minimum distance of 10 seconds:
  10477. @example
  10478. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  10479. @end example
  10480. @item
  10481. Use aselect to select only audio frames with samples number > 100:
  10482. @example
  10483. aselect='gt(samples_n\,100)'
  10484. @end example
  10485. @item
  10486. Create a mosaic of the first scenes:
  10487. @example
  10488. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  10489. @end example
  10490. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  10491. choice.
  10492. @item
  10493. Send even and odd frames to separate outputs, and compose them:
  10494. @example
  10495. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  10496. @end example
  10497. @item
  10498. Select useful frames from an ffconcat file which is using inpoints and
  10499. outpoints but where the source files are not intra frame only.
  10500. @example
  10501. ffmpeg -copyts -vsync 0 -segment_time_metadata 1 -i input.ffconcat -vf select=concatdec_select -af aselect=concatdec_select output.avi
  10502. @end example
  10503. @end itemize
  10504. @section sendcmd, asendcmd
  10505. Send commands to filters in the filtergraph.
  10506. These filters read commands to be sent to other filters in the
  10507. filtergraph.
  10508. @code{sendcmd} must be inserted between two video filters,
  10509. @code{asendcmd} must be inserted between two audio filters, but apart
  10510. from that they act the same way.
  10511. The specification of commands can be provided in the filter arguments
  10512. with the @var{commands} option, or in a file specified by the
  10513. @var{filename} option.
  10514. These filters accept the following options:
  10515. @table @option
  10516. @item commands, c
  10517. Set the commands to be read and sent to the other filters.
  10518. @item filename, f
  10519. Set the filename of the commands to be read and sent to the other
  10520. filters.
  10521. @end table
  10522. @subsection Commands syntax
  10523. A commands description consists of a sequence of interval
  10524. specifications, comprising a list of commands to be executed when a
  10525. particular event related to that interval occurs. The occurring event
  10526. is typically the current frame time entering or leaving a given time
  10527. interval.
  10528. An interval is specified by the following syntax:
  10529. @example
  10530. @var{START}[-@var{END}] @var{COMMANDS};
  10531. @end example
  10532. The time interval is specified by the @var{START} and @var{END} times.
  10533. @var{END} is optional and defaults to the maximum time.
  10534. The current frame time is considered within the specified interval if
  10535. it is included in the interval [@var{START}, @var{END}), that is when
  10536. the time is greater or equal to @var{START} and is lesser than
  10537. @var{END}.
  10538. @var{COMMANDS} consists of a sequence of one or more command
  10539. specifications, separated by ",", relating to that interval. The
  10540. syntax of a command specification is given by:
  10541. @example
  10542. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  10543. @end example
  10544. @var{FLAGS} is optional and specifies the type of events relating to
  10545. the time interval which enable sending the specified command, and must
  10546. be a non-null sequence of identifier flags separated by "+" or "|" and
  10547. enclosed between "[" and "]".
  10548. The following flags are recognized:
  10549. @table @option
  10550. @item enter
  10551. The command is sent when the current frame timestamp enters the
  10552. specified interval. In other words, the command is sent when the
  10553. previous frame timestamp was not in the given interval, and the
  10554. current is.
  10555. @item leave
  10556. The command is sent when the current frame timestamp leaves the
  10557. specified interval. In other words, the command is sent when the
  10558. previous frame timestamp was in the given interval, and the
  10559. current is not.
  10560. @end table
  10561. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  10562. assumed.
  10563. @var{TARGET} specifies the target of the command, usually the name of
  10564. the filter class or a specific filter instance name.
  10565. @var{COMMAND} specifies the name of the command for the target filter.
  10566. @var{ARG} is optional and specifies the optional list of argument for
  10567. the given @var{COMMAND}.
  10568. Between one interval specification and another, whitespaces, or
  10569. sequences of characters starting with @code{#} until the end of line,
  10570. are ignored and can be used to annotate comments.
  10571. A simplified BNF description of the commands specification syntax
  10572. follows:
  10573. @example
  10574. @var{COMMAND_FLAG} ::= "enter" | "leave"
  10575. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  10576. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  10577. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  10578. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  10579. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  10580. @end example
  10581. @subsection Examples
  10582. @itemize
  10583. @item
  10584. Specify audio tempo change at second 4:
  10585. @example
  10586. asendcmd=c='4.0 atempo tempo 1.5',atempo
  10587. @end example
  10588. @item
  10589. Specify a list of drawtext and hue commands in a file.
  10590. @example
  10591. # show text in the interval 5-10
  10592. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  10593. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  10594. # desaturate the image in the interval 15-20
  10595. 15.0-20.0 [enter] hue s 0,
  10596. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  10597. [leave] hue s 1,
  10598. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  10599. # apply an exponential saturation fade-out effect, starting from time 25
  10600. 25 [enter] hue s exp(25-t)
  10601. @end example
  10602. A filtergraph allowing to read and process the above command list
  10603. stored in a file @file{test.cmd}, can be specified with:
  10604. @example
  10605. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  10606. @end example
  10607. @end itemize
  10608. @anchor{setpts}
  10609. @section setpts, asetpts
  10610. Change the PTS (presentation timestamp) of the input frames.
  10611. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  10612. This filter accepts the following options:
  10613. @table @option
  10614. @item expr
  10615. The expression which is evaluated for each frame to construct its timestamp.
  10616. @end table
  10617. The expression is evaluated through the eval API and can contain the following
  10618. constants:
  10619. @table @option
  10620. @item FRAME_RATE
  10621. frame rate, only defined for constant frame-rate video
  10622. @item PTS
  10623. The presentation timestamp in input
  10624. @item N
  10625. The count of the input frame for video or the number of consumed samples,
  10626. not including the current frame for audio, starting from 0.
  10627. @item NB_CONSUMED_SAMPLES
  10628. The number of consumed samples, not including the current frame (only
  10629. audio)
  10630. @item NB_SAMPLES, S
  10631. The number of samples in the current frame (only audio)
  10632. @item SAMPLE_RATE, SR
  10633. The audio sample rate.
  10634. @item STARTPTS
  10635. The PTS of the first frame.
  10636. @item STARTT
  10637. the time in seconds of the first frame
  10638. @item INTERLACED
  10639. State whether the current frame is interlaced.
  10640. @item T
  10641. the time in seconds of the current frame
  10642. @item POS
  10643. original position in the file of the frame, or undefined if undefined
  10644. for the current frame
  10645. @item PREV_INPTS
  10646. The previous input PTS.
  10647. @item PREV_INT
  10648. previous input time in seconds
  10649. @item PREV_OUTPTS
  10650. The previous output PTS.
  10651. @item PREV_OUTT
  10652. previous output time in seconds
  10653. @item RTCTIME
  10654. The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  10655. instead.
  10656. @item RTCSTART
  10657. The wallclock (RTC) time at the start of the movie in microseconds.
  10658. @item TB
  10659. The timebase of the input timestamps.
  10660. @end table
  10661. @subsection Examples
  10662. @itemize
  10663. @item
  10664. Start counting PTS from zero
  10665. @example
  10666. setpts=PTS-STARTPTS
  10667. @end example
  10668. @item
  10669. Apply fast motion effect:
  10670. @example
  10671. setpts=0.5*PTS
  10672. @end example
  10673. @item
  10674. Apply slow motion effect:
  10675. @example
  10676. setpts=2.0*PTS
  10677. @end example
  10678. @item
  10679. Set fixed rate of 25 frames per second:
  10680. @example
  10681. setpts=N/(25*TB)
  10682. @end example
  10683. @item
  10684. Set fixed rate 25 fps with some jitter:
  10685. @example
  10686. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  10687. @end example
  10688. @item
  10689. Apply an offset of 10 seconds to the input PTS:
  10690. @example
  10691. setpts=PTS+10/TB
  10692. @end example
  10693. @item
  10694. Generate timestamps from a "live source" and rebase onto the current timebase:
  10695. @example
  10696. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  10697. @end example
  10698. @item
  10699. Generate timestamps by counting samples:
  10700. @example
  10701. asetpts=N/SR/TB
  10702. @end example
  10703. @end itemize
  10704. @section settb, asettb
  10705. Set the timebase to use for the output frames timestamps.
  10706. It is mainly useful for testing timebase configuration.
  10707. It accepts the following parameters:
  10708. @table @option
  10709. @item expr, tb
  10710. The expression which is evaluated into the output timebase.
  10711. @end table
  10712. The value for @option{tb} is an arithmetic expression representing a
  10713. rational. The expression can contain the constants "AVTB" (the default
  10714. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  10715. audio only). Default value is "intb".
  10716. @subsection Examples
  10717. @itemize
  10718. @item
  10719. Set the timebase to 1/25:
  10720. @example
  10721. settb=expr=1/25
  10722. @end example
  10723. @item
  10724. Set the timebase to 1/10:
  10725. @example
  10726. settb=expr=0.1
  10727. @end example
  10728. @item
  10729. Set the timebase to 1001/1000:
  10730. @example
  10731. settb=1+0.001
  10732. @end example
  10733. @item
  10734. Set the timebase to 2*intb:
  10735. @example
  10736. settb=2*intb
  10737. @end example
  10738. @item
  10739. Set the default timebase value:
  10740. @example
  10741. settb=AVTB
  10742. @end example
  10743. @end itemize
  10744. @section showcqt
  10745. Convert input audio to a video output representing frequency spectrum
  10746. logarithmically using Brown-Puckette constant Q transform algorithm with
  10747. direct frequency domain coefficient calculation (but the transform itself
  10748. is not really constant Q, instead the Q factor is actually variable/clamped),
  10749. with musical tone scale, from E0 to D#10.
  10750. The filter accepts the following options:
  10751. @table @option
  10752. @item size, s
  10753. Specify the video size for the output. It must be even. For the syntax of this option,
  10754. check the @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10755. Default value is @code{1920x1080}.
  10756. @item fps, rate, r
  10757. Set the output frame rate. Default value is @code{25}.
  10758. @item bar_h
  10759. Set the bargraph height. It must be even. Default value is @code{-1} which
  10760. computes the bargraph height automatically.
  10761. @item axis_h
  10762. Set the axis height. It must be even. Default value is @code{-1} which computes
  10763. the axis height automatically.
  10764. @item sono_h
  10765. Set the sonogram height. It must be even. Default value is @code{-1} which
  10766. computes the sonogram height automatically.
  10767. @item fullhd
  10768. Set the fullhd resolution. This option is deprecated, use @var{size}, @var{s}
  10769. instead. Default value is @code{1}.
  10770. @item sono_v, volume
  10771. Specify the sonogram volume expression. It can contain variables:
  10772. @table @option
  10773. @item bar_v
  10774. the @var{bar_v} evaluated expression
  10775. @item frequency, freq, f
  10776. the frequency where it is evaluated
  10777. @item timeclamp, tc
  10778. the value of @var{timeclamp} option
  10779. @end table
  10780. and functions:
  10781. @table @option
  10782. @item a_weighting(f)
  10783. A-weighting of equal loudness
  10784. @item b_weighting(f)
  10785. B-weighting of equal loudness
  10786. @item c_weighting(f)
  10787. C-weighting of equal loudness.
  10788. @end table
  10789. Default value is @code{16}.
  10790. @item bar_v, volume2
  10791. Specify the bargraph volume expression. It can contain variables:
  10792. @table @option
  10793. @item sono_v
  10794. the @var{sono_v} evaluated expression
  10795. @item frequency, freq, f
  10796. the frequency where it is evaluated
  10797. @item timeclamp, tc
  10798. the value of @var{timeclamp} option
  10799. @end table
  10800. and functions:
  10801. @table @option
  10802. @item a_weighting(f)
  10803. A-weighting of equal loudness
  10804. @item b_weighting(f)
  10805. B-weighting of equal loudness
  10806. @item c_weighting(f)
  10807. C-weighting of equal loudness.
  10808. @end table
  10809. Default value is @code{sono_v}.
  10810. @item sono_g, gamma
  10811. Specify the sonogram gamma. Lower gamma makes the spectrum more contrast,
  10812. higher gamma makes the spectrum having more range. Default value is @code{3}.
  10813. Acceptable range is @code{[1, 7]}.
  10814. @item bar_g, gamma2
  10815. Specify the bargraph gamma. Default value is @code{1}. Acceptable range is
  10816. @code{[1, 7]}.
  10817. @item timeclamp, tc
  10818. Specify the transform timeclamp. At low frequency, there is trade-off between
  10819. accuracy in time domain and frequency domain. If timeclamp is lower,
  10820. event in time domain is represented more accurately (such as fast bass drum),
  10821. otherwise event in frequency domain is represented more accurately
  10822. (such as bass guitar). Acceptable range is @code{[0.1, 1]}. Default value is @code{0.17}.
  10823. @item basefreq
  10824. Specify the transform base frequency. Default value is @code{20.01523126408007475},
  10825. which is frequency 50 cents below E0. Acceptable range is @code{[10, 100000]}.
  10826. @item endfreq
  10827. Specify the transform end frequency. Default value is @code{20495.59681441799654},
  10828. which is frequency 50 cents above D#10. Acceptable range is @code{[10, 100000]}.
  10829. @item coeffclamp
  10830. This option is deprecated and ignored.
  10831. @item tlength
  10832. Specify the transform length in time domain. Use this option to control accuracy
  10833. trade-off between time domain and frequency domain at every frequency sample.
  10834. It can contain variables:
  10835. @table @option
  10836. @item frequency, freq, f
  10837. the frequency where it is evaluated
  10838. @item timeclamp, tc
  10839. the value of @var{timeclamp} option.
  10840. @end table
  10841. Default value is @code{384*tc/(384+tc*f)}.
  10842. @item count
  10843. Specify the transform count for every video frame. Default value is @code{6}.
  10844. Acceptable range is @code{[1, 30]}.
  10845. @item fcount
  10846. Specify the transform count for every single pixel. Default value is @code{0},
  10847. which makes it computed automatically. Acceptable range is @code{[0, 10]}.
  10848. @item fontfile
  10849. Specify font file for use with freetype to draw the axis. If not specified,
  10850. use embedded font. Note that drawing with font file or embedded font is not
  10851. implemented with custom @var{basefreq} and @var{endfreq}, use @var{axisfile}
  10852. option instead.
  10853. @item fontcolor
  10854. Specify font color expression. This is arithmetic expression that should return
  10855. integer value 0xRRGGBB. It can contain variables:
  10856. @table @option
  10857. @item frequency, freq, f
  10858. the frequency where it is evaluated
  10859. @item timeclamp, tc
  10860. the value of @var{timeclamp} option
  10861. @end table
  10862. and functions:
  10863. @table @option
  10864. @item midi(f)
  10865. midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
  10866. @item r(x), g(x), b(x)
  10867. red, green, and blue value of intensity x.
  10868. @end table
  10869. Default value is @code{st(0, (midi(f)-59.5)/12);
  10870. st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
  10871. r(1-ld(1)) + b(ld(1))}.
  10872. @item axisfile
  10873. Specify image file to draw the axis. This option override @var{fontfile} and
  10874. @var{fontcolor} option.
  10875. @item axis, text
  10876. Enable/disable drawing text to the axis. If it is set to @code{0}, drawing to
  10877. the axis is disabled, ignoring @var{fontfile} and @var{axisfile} option.
  10878. Default value is @code{1}.
  10879. @end table
  10880. @subsection Examples
  10881. @itemize
  10882. @item
  10883. Playing audio while showing the spectrum:
  10884. @example
  10885. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
  10886. @end example
  10887. @item
  10888. Same as above, but with frame rate 30 fps:
  10889. @example
  10890. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
  10891. @end example
  10892. @item
  10893. Playing at 1280x720:
  10894. @example
  10895. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=s=1280x720:count=4 [out0]'
  10896. @end example
  10897. @item
  10898. Disable sonogram display:
  10899. @example
  10900. sono_h=0
  10901. @end example
  10902. @item
  10903. A1 and its harmonics: A1, A2, (near)E3, A3:
  10904. @example
  10905. 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),
  10906. asplit[a][out1]; [a] showcqt [out0]'
  10907. @end example
  10908. @item
  10909. Same as above, but with more accuracy in frequency domain:
  10910. @example
  10911. 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),
  10912. asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
  10913. @end example
  10914. @item
  10915. Custom volume:
  10916. @example
  10917. bar_v=10:sono_v=bar_v*a_weighting(f)
  10918. @end example
  10919. @item
  10920. Custom gamma, now spectrum is linear to the amplitude.
  10921. @example
  10922. bar_g=2:sono_g=2
  10923. @end example
  10924. @item
  10925. Custom tlength equation:
  10926. @example
  10927. 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)))'
  10928. @end example
  10929. @item
  10930. Custom fontcolor and fontfile, C-note is colored green, others are colored blue:
  10931. @example
  10932. fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))':fontfile=myfont.ttf
  10933. @end example
  10934. @item
  10935. Custom frequency range with custom axis using image file:
  10936. @example
  10937. axisfile=myaxis.png:basefreq=40:endfreq=10000
  10938. @end example
  10939. @end itemize
  10940. @section showfreqs
  10941. Convert input audio to video output representing the audio power spectrum.
  10942. Audio amplitude is on Y-axis while frequency is on X-axis.
  10943. The filter accepts the following options:
  10944. @table @option
  10945. @item size, s
  10946. Specify size of video. For the syntax of this option, check the
  10947. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10948. Default is @code{1024x512}.
  10949. @item mode
  10950. Set display mode.
  10951. This set how each frequency bin will be represented.
  10952. It accepts the following values:
  10953. @table @samp
  10954. @item line
  10955. @item bar
  10956. @item dot
  10957. @end table
  10958. Default is @code{bar}.
  10959. @item ascale
  10960. Set amplitude scale.
  10961. It accepts the following values:
  10962. @table @samp
  10963. @item lin
  10964. Linear scale.
  10965. @item sqrt
  10966. Square root scale.
  10967. @item cbrt
  10968. Cubic root scale.
  10969. @item log
  10970. Logarithmic scale.
  10971. @end table
  10972. Default is @code{log}.
  10973. @item fscale
  10974. Set frequency scale.
  10975. It accepts the following values:
  10976. @table @samp
  10977. @item lin
  10978. Linear scale.
  10979. @item log
  10980. Logarithmic scale.
  10981. @item rlog
  10982. Reverse logarithmic scale.
  10983. @end table
  10984. Default is @code{lin}.
  10985. @item win_size
  10986. Set window size.
  10987. It accepts the following values:
  10988. @table @samp
  10989. @item w16
  10990. @item w32
  10991. @item w64
  10992. @item w128
  10993. @item w256
  10994. @item w512
  10995. @item w1024
  10996. @item w2048
  10997. @item w4096
  10998. @item w8192
  10999. @item w16384
  11000. @item w32768
  11001. @item w65536
  11002. @end table
  11003. Default is @code{w2048}
  11004. @item win_func
  11005. Set windowing function.
  11006. It accepts the following values:
  11007. @table @samp
  11008. @item rect
  11009. @item bartlett
  11010. @item hanning
  11011. @item hamming
  11012. @item blackman
  11013. @item welch
  11014. @item flattop
  11015. @item bharris
  11016. @item bnuttall
  11017. @item bhann
  11018. @item sine
  11019. @item nuttall
  11020. @item lanczos
  11021. @item gauss
  11022. @end table
  11023. Default is @code{hanning}.
  11024. @item overlap
  11025. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  11026. which means optimal overlap for selected window function will be picked.
  11027. @item averaging
  11028. Set time averaging. Setting this to 0 will display current maximal peaks.
  11029. Default is @code{1}, which means time averaging is disabled.
  11030. @item colors
  11031. Specify list of colors separated by space or by '|' which will be used to
  11032. draw channel frequencies. Unrecognized or missing colors will be replaced
  11033. by white color.
  11034. @end table
  11035. @section showspectrum
  11036. Convert input audio to a video output, representing the audio frequency
  11037. spectrum.
  11038. The filter accepts the following options:
  11039. @table @option
  11040. @item size, s
  11041. Specify the video size for the output. For the syntax of this option, check the
  11042. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11043. Default value is @code{640x512}.
  11044. @item slide
  11045. Specify how the spectrum should slide along the window.
  11046. It accepts the following values:
  11047. @table @samp
  11048. @item replace
  11049. the samples start again on the left when they reach the right
  11050. @item scroll
  11051. the samples scroll from right to left
  11052. @item fullframe
  11053. frames are only produced when the samples reach the right
  11054. @end table
  11055. Default value is @code{replace}.
  11056. @item mode
  11057. Specify display mode.
  11058. It accepts the following values:
  11059. @table @samp
  11060. @item combined
  11061. all channels are displayed in the same row
  11062. @item separate
  11063. all channels are displayed in separate rows
  11064. @end table
  11065. Default value is @samp{combined}.
  11066. @item color
  11067. Specify display color mode.
  11068. It accepts the following values:
  11069. @table @samp
  11070. @item channel
  11071. each channel is displayed in a separate color
  11072. @item intensity
  11073. each channel is is displayed using the same color scheme
  11074. @end table
  11075. Default value is @samp{channel}.
  11076. @item scale
  11077. Specify scale used for calculating intensity color values.
  11078. It accepts the following values:
  11079. @table @samp
  11080. @item lin
  11081. linear
  11082. @item sqrt
  11083. square root, default
  11084. @item cbrt
  11085. cubic root
  11086. @item log
  11087. logarithmic
  11088. @end table
  11089. Default value is @samp{sqrt}.
  11090. @item saturation
  11091. Set saturation modifier for displayed colors. Negative values provide
  11092. alternative color scheme. @code{0} is no saturation at all.
  11093. Saturation must be in [-10.0, 10.0] range.
  11094. Default value is @code{1}.
  11095. @item win_func
  11096. Set window function.
  11097. It accepts the following values:
  11098. @table @samp
  11099. @item none
  11100. No samples pre-processing (do not expect this to be faster)
  11101. @item hann
  11102. Hann window
  11103. @item hamming
  11104. Hamming window
  11105. @item blackman
  11106. Blackman window
  11107. @end table
  11108. Default value is @code{hann}.
  11109. @end table
  11110. The usage is very similar to the showwaves filter; see the examples in that
  11111. section.
  11112. @subsection Examples
  11113. @itemize
  11114. @item
  11115. Large window with logarithmic color scaling:
  11116. @example
  11117. showspectrum=s=1280x480:scale=log
  11118. @end example
  11119. @item
  11120. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  11121. @example
  11122. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  11123. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  11124. @end example
  11125. @end itemize
  11126. @section showvolume
  11127. Convert input audio volume to a video output.
  11128. The filter accepts the following options:
  11129. @table @option
  11130. @item rate, r
  11131. Set video rate.
  11132. @item b
  11133. Set border width, allowed range is [0, 5]. Default is 1.
  11134. @item w
  11135. Set channel width, allowed range is [80, 1080]. Default is 400.
  11136. @item h
  11137. Set channel height, allowed range is [1, 100]. Default is 20.
  11138. @item f
  11139. Set fade, allowed range is [0.001, 1]. Default is 0.95.
  11140. @item c
  11141. Set volume color expression.
  11142. The expression can use the following variables:
  11143. @table @option
  11144. @item VOLUME
  11145. Current max volume of channel in dB.
  11146. @item CHANNEL
  11147. Current channel number, starting from 0.
  11148. @end table
  11149. @item t
  11150. If set, displays channel names. Default is enabled.
  11151. @item v
  11152. If set, displays volume values. Default is enabled.
  11153. @end table
  11154. @section showwaves
  11155. Convert input audio to a video output, representing the samples waves.
  11156. The filter accepts the following options:
  11157. @table @option
  11158. @item size, s
  11159. Specify the video size for the output. For the syntax of this option, check the
  11160. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11161. Default value is @code{600x240}.
  11162. @item mode
  11163. Set display mode.
  11164. Available values are:
  11165. @table @samp
  11166. @item point
  11167. Draw a point for each sample.
  11168. @item line
  11169. Draw a vertical line for each sample.
  11170. @item p2p
  11171. Draw a point for each sample and a line between them.
  11172. @item cline
  11173. Draw a centered vertical line for each sample.
  11174. @end table
  11175. Default value is @code{point}.
  11176. @item n
  11177. Set the number of samples which are printed on the same column. A
  11178. larger value will decrease the frame rate. Must be a positive
  11179. integer. This option can be set only if the value for @var{rate}
  11180. is not explicitly specified.
  11181. @item rate, r
  11182. Set the (approximate) output frame rate. This is done by setting the
  11183. option @var{n}. Default value is "25".
  11184. @item split_channels
  11185. Set if channels should be drawn separately or overlap. Default value is 0.
  11186. @end table
  11187. @subsection Examples
  11188. @itemize
  11189. @item
  11190. Output the input file audio and the corresponding video representation
  11191. at the same time:
  11192. @example
  11193. amovie=a.mp3,asplit[out0],showwaves[out1]
  11194. @end example
  11195. @item
  11196. Create a synthetic signal and show it with showwaves, forcing a
  11197. frame rate of 30 frames per second:
  11198. @example
  11199. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  11200. @end example
  11201. @end itemize
  11202. @section showwavespic
  11203. Convert input audio to a single video frame, representing the samples waves.
  11204. The filter accepts the following options:
  11205. @table @option
  11206. @item size, s
  11207. Specify the video size for the output. For the syntax of this option, check the
  11208. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11209. Default value is @code{600x240}.
  11210. @item split_channels
  11211. Set if channels should be drawn separately or overlap. Default value is 0.
  11212. @end table
  11213. @subsection Examples
  11214. @itemize
  11215. @item
  11216. Extract a channel split representation of the wave form of a whole audio track
  11217. in a 1024x800 picture using @command{ffmpeg}:
  11218. @example
  11219. ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
  11220. @end example
  11221. @end itemize
  11222. @section split, asplit
  11223. Split input into several identical outputs.
  11224. @code{asplit} works with audio input, @code{split} with video.
  11225. The filter accepts a single parameter which specifies the number of outputs. If
  11226. unspecified, it defaults to 2.
  11227. @subsection Examples
  11228. @itemize
  11229. @item
  11230. Create two separate outputs from the same input:
  11231. @example
  11232. [in] split [out0][out1]
  11233. @end example
  11234. @item
  11235. To create 3 or more outputs, you need to specify the number of
  11236. outputs, like in:
  11237. @example
  11238. [in] asplit=3 [out0][out1][out2]
  11239. @end example
  11240. @item
  11241. Create two separate outputs from the same input, one cropped and
  11242. one padded:
  11243. @example
  11244. [in] split [splitout1][splitout2];
  11245. [splitout1] crop=100:100:0:0 [cropout];
  11246. [splitout2] pad=200:200:100:100 [padout];
  11247. @end example
  11248. @item
  11249. Create 5 copies of the input audio with @command{ffmpeg}:
  11250. @example
  11251. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  11252. @end example
  11253. @end itemize
  11254. @section zmq, azmq
  11255. Receive commands sent through a libzmq client, and forward them to
  11256. filters in the filtergraph.
  11257. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  11258. must be inserted between two video filters, @code{azmq} between two
  11259. audio filters.
  11260. To enable these filters you need to install the libzmq library and
  11261. headers and configure FFmpeg with @code{--enable-libzmq}.
  11262. For more information about libzmq see:
  11263. @url{http://www.zeromq.org/}
  11264. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  11265. receives messages sent through a network interface defined by the
  11266. @option{bind_address} option.
  11267. The received message must be in the form:
  11268. @example
  11269. @var{TARGET} @var{COMMAND} [@var{ARG}]
  11270. @end example
  11271. @var{TARGET} specifies the target of the command, usually the name of
  11272. the filter class or a specific filter instance name.
  11273. @var{COMMAND} specifies the name of the command for the target filter.
  11274. @var{ARG} is optional and specifies the optional argument list for the
  11275. given @var{COMMAND}.
  11276. Upon reception, the message is processed and the corresponding command
  11277. is injected into the filtergraph. Depending on the result, the filter
  11278. will send a reply to the client, adopting the format:
  11279. @example
  11280. @var{ERROR_CODE} @var{ERROR_REASON}
  11281. @var{MESSAGE}
  11282. @end example
  11283. @var{MESSAGE} is optional.
  11284. @subsection Examples
  11285. Look at @file{tools/zmqsend} for an example of a zmq client which can
  11286. be used to send commands processed by these filters.
  11287. Consider the following filtergraph generated by @command{ffplay}
  11288. @example
  11289. ffplay -dumpgraph 1 -f lavfi "
  11290. color=s=100x100:c=red [l];
  11291. color=s=100x100:c=blue [r];
  11292. nullsrc=s=200x100, zmq [bg];
  11293. [bg][l] overlay [bg+l];
  11294. [bg+l][r] overlay=x=100 "
  11295. @end example
  11296. To change the color of the left side of the video, the following
  11297. command can be used:
  11298. @example
  11299. echo Parsed_color_0 c yellow | tools/zmqsend
  11300. @end example
  11301. To change the right side:
  11302. @example
  11303. echo Parsed_color_1 c pink | tools/zmqsend
  11304. @end example
  11305. @c man end MULTIMEDIA FILTERS
  11306. @chapter Multimedia Sources
  11307. @c man begin MULTIMEDIA SOURCES
  11308. Below is a description of the currently available multimedia sources.
  11309. @section amovie
  11310. This is the same as @ref{movie} source, except it selects an audio
  11311. stream by default.
  11312. @anchor{movie}
  11313. @section movie
  11314. Read audio and/or video stream(s) from a movie container.
  11315. It accepts the following parameters:
  11316. @table @option
  11317. @item filename
  11318. The name of the resource to read (not necessarily a file; it can also be a
  11319. device or a stream accessed through some protocol).
  11320. @item format_name, f
  11321. Specifies the format assumed for the movie to read, and can be either
  11322. the name of a container or an input device. If not specified, the
  11323. format is guessed from @var{movie_name} or by probing.
  11324. @item seek_point, sp
  11325. Specifies the seek point in seconds. The frames will be output
  11326. starting from this seek point. The parameter is evaluated with
  11327. @code{av_strtod}, so the numerical value may be suffixed by an IS
  11328. postfix. The default value is "0".
  11329. @item streams, s
  11330. Specifies the streams to read. Several streams can be specified,
  11331. separated by "+". The source will then have as many outputs, in the
  11332. same order. The syntax is explained in the ``Stream specifiers''
  11333. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  11334. respectively the default (best suited) video and audio stream. Default
  11335. is "dv", or "da" if the filter is called as "amovie".
  11336. @item stream_index, si
  11337. Specifies the index of the video stream to read. If the value is -1,
  11338. the most suitable video stream will be automatically selected. The default
  11339. value is "-1". Deprecated. If the filter is called "amovie", it will select
  11340. audio instead of video.
  11341. @item loop
  11342. Specifies how many times to read the stream in sequence.
  11343. If the value is less than 1, the stream will be read again and again.
  11344. Default value is "1".
  11345. Note that when the movie is looped the source timestamps are not
  11346. changed, so it will generate non monotonically increasing timestamps.
  11347. @end table
  11348. It allows overlaying a second video on top of the main input of
  11349. a filtergraph, as shown in this graph:
  11350. @example
  11351. input -----------> deltapts0 --> overlay --> output
  11352. ^
  11353. |
  11354. movie --> scale--> deltapts1 -------+
  11355. @end example
  11356. @subsection Examples
  11357. @itemize
  11358. @item
  11359. Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
  11360. on top of the input labelled "in":
  11361. @example
  11362. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  11363. [in] setpts=PTS-STARTPTS [main];
  11364. [main][over] overlay=16:16 [out]
  11365. @end example
  11366. @item
  11367. Read from a video4linux2 device, and overlay it on top of the input
  11368. labelled "in":
  11369. @example
  11370. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  11371. [in] setpts=PTS-STARTPTS [main];
  11372. [main][over] overlay=16:16 [out]
  11373. @end example
  11374. @item
  11375. Read the first video stream and the audio stream with id 0x81 from
  11376. dvd.vob; the video is connected to the pad named "video" and the audio is
  11377. connected to the pad named "audio":
  11378. @example
  11379. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  11380. @end example
  11381. @end itemize
  11382. @c man end MULTIMEDIA SOURCES