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.

14847 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. @end table
  2295. @section stereotools
  2296. This filter has some handy utilities to manage stereo signals, for converting
  2297. M/S stereo recordings to L/R signal while having control over the parameters
  2298. or spreading the stereo image of master track.
  2299. The filter accepts the following options:
  2300. @table @option
  2301. @item level_in
  2302. Set input level before filtering for both channels. Defaults is 1.
  2303. Allowed range is from 0.015625 to 64.
  2304. @item level_out
  2305. Set output level after filtering for both channels. Defaults is 1.
  2306. Allowed range is from 0.015625 to 64.
  2307. @item balance_in
  2308. Set input balance between both channels. Default is 0.
  2309. Allowed range is from -1 to 1.
  2310. @item balance_out
  2311. Set output balance between both channels. Default is 0.
  2312. Allowed range is from -1 to 1.
  2313. @item softclip
  2314. Enable softclipping. Results in analog distortion instead of harsh digital 0dB
  2315. clipping. Disabled by default.
  2316. @item mutel
  2317. Mute the left channel. Disabled by default.
  2318. @item muter
  2319. Mute the right channel. Disabled by default.
  2320. @item phasel
  2321. Change the phase of the left channel. Disabled by default.
  2322. @item phaser
  2323. Change the phase of the right channel. Disabled by default.
  2324. @item mode
  2325. Set stereo mode. Available values are:
  2326. @table @samp
  2327. @item lr>lr
  2328. Left/Right to Left/Right, this is default.
  2329. @item lr>ms
  2330. Left/Right to Mid/Side.
  2331. @item ms>lr
  2332. Mid/Side to Left/Right.
  2333. @item lr>ll
  2334. Left/Right to Left/Left.
  2335. @item lr>rr
  2336. Left/Right to Right/Right.
  2337. @item lr>l+r
  2338. Left/Right to Left + Right.
  2339. @item lr>rl
  2340. Left/Right to Right/Left.
  2341. @end table
  2342. @item slev
  2343. Set level of side signal. Default is 1.
  2344. Allowed range is from 0.015625 to 64.
  2345. @item sbal
  2346. Set balance of side signal. Default is 0.
  2347. Allowed range is from -1 to 1.
  2348. @item mlev
  2349. Set level of the middle signal. Default is 1.
  2350. Allowed range is from 0.015625 to 64.
  2351. @item mpan
  2352. Set middle signal pan. Default is 0. Allowed range is from -1 to 1.
  2353. @item base
  2354. Set stereo base between mono and inversed channels. Default is 0.
  2355. Allowed range is from -1 to 1.
  2356. @item delay
  2357. Set delay in milliseconds how much to delay left from right channel and
  2358. vice versa. Default is 0. Allowed range is from -20 to 20.
  2359. @item sclevel
  2360. Set S/C level. Default is 1. Allowed range is from 1 to 100.
  2361. @item phase
  2362. Set the stereo phase in degrees. Default is 0. Allowed range is from 0 to 360.
  2363. @end table
  2364. @section stereowiden
  2365. This filter enhance the stereo effect by suppressing signal common to both
  2366. channels and by delaying the signal of left into right and vice versa,
  2367. thereby widening the stereo effect.
  2368. The filter accepts the following options:
  2369. @table @option
  2370. @item delay
  2371. Time in milliseconds of the delay of left signal into right and vice versa.
  2372. Default is 20 milliseconds.
  2373. @item feedback
  2374. Amount of gain in delayed signal into right and vice versa. Gives a delay
  2375. effect of left signal in right output and vice versa which gives widening
  2376. effect. Default is 0.3.
  2377. @item crossfeed
  2378. Cross feed of left into right with inverted phase. This helps in suppressing
  2379. the mono. If the value is 1 it will cancel all the signal common to both
  2380. channels. Default is 0.3.
  2381. @item drymix
  2382. Set level of input signal of original channel. Default is 0.8.
  2383. @end table
  2384. @section treble
  2385. Boost or cut treble (upper) frequencies of the audio using a two-pole
  2386. shelving filter with a response similar to that of a standard
  2387. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  2388. The filter accepts the following options:
  2389. @table @option
  2390. @item gain, g
  2391. Give the gain at whichever is the lower of ~22 kHz and the
  2392. Nyquist frequency. Its useful range is about -20 (for a large cut)
  2393. to +20 (for a large boost). Beware of clipping when using a positive gain.
  2394. @item frequency, f
  2395. Set the filter's central frequency and so can be used
  2396. to extend or reduce the frequency range to be boosted or cut.
  2397. The default value is @code{3000} Hz.
  2398. @item width_type
  2399. Set method to specify band-width of filter.
  2400. @table @option
  2401. @item h
  2402. Hz
  2403. @item q
  2404. Q-Factor
  2405. @item o
  2406. octave
  2407. @item s
  2408. slope
  2409. @end table
  2410. @item width, w
  2411. Determine how steep is the filter's shelf transition.
  2412. @end table
  2413. @section tremolo
  2414. Sinusoidal amplitude modulation.
  2415. The filter accepts the following options:
  2416. @table @option
  2417. @item f
  2418. Modulation frequency in Hertz. Modulation frequencies in the subharmonic range
  2419. (20 Hz or lower) will result in a tremolo effect.
  2420. This filter may also be used as a ring modulator by specifying
  2421. a modulation frequency higher than 20 Hz.
  2422. Range is 0.1 - 20000.0. Default value is 5.0 Hz.
  2423. @item d
  2424. Depth of modulation as a percentage. Range is 0.0 - 1.0.
  2425. Default value is 0.5.
  2426. @end table
  2427. @section vibrato
  2428. Sinusoidal phase modulation.
  2429. The filter accepts the following options:
  2430. @table @option
  2431. @item f
  2432. Modulation frequency in Hertz.
  2433. Range is 0.1 - 20000.0. Default value is 5.0 Hz.
  2434. @item d
  2435. Depth of modulation as a percentage. Range is 0.0 - 1.0.
  2436. Default value is 0.5.
  2437. @end table
  2438. @section volume
  2439. Adjust the input audio volume.
  2440. It accepts the following parameters:
  2441. @table @option
  2442. @item volume
  2443. Set audio volume expression.
  2444. Output values are clipped to the maximum value.
  2445. The output audio volume is given by the relation:
  2446. @example
  2447. @var{output_volume} = @var{volume} * @var{input_volume}
  2448. @end example
  2449. The default value for @var{volume} is "1.0".
  2450. @item precision
  2451. This parameter represents the mathematical precision.
  2452. It determines which input sample formats will be allowed, which affects the
  2453. precision of the volume scaling.
  2454. @table @option
  2455. @item fixed
  2456. 8-bit fixed-point; this limits input sample format to U8, S16, and S32.
  2457. @item float
  2458. 32-bit floating-point; this limits input sample format to FLT. (default)
  2459. @item double
  2460. 64-bit floating-point; this limits input sample format to DBL.
  2461. @end table
  2462. @item replaygain
  2463. Choose the behaviour on encountering ReplayGain side data in input frames.
  2464. @table @option
  2465. @item drop
  2466. Remove ReplayGain side data, ignoring its contents (the default).
  2467. @item ignore
  2468. Ignore ReplayGain side data, but leave it in the frame.
  2469. @item track
  2470. Prefer the track gain, if present.
  2471. @item album
  2472. Prefer the album gain, if present.
  2473. @end table
  2474. @item replaygain_preamp
  2475. Pre-amplification gain in dB to apply to the selected replaygain gain.
  2476. Default value for @var{replaygain_preamp} is 0.0.
  2477. @item eval
  2478. Set when the volume expression is evaluated.
  2479. It accepts the following values:
  2480. @table @samp
  2481. @item once
  2482. only evaluate expression once during the filter initialization, or
  2483. when the @samp{volume} command is sent
  2484. @item frame
  2485. evaluate expression for each incoming frame
  2486. @end table
  2487. Default value is @samp{once}.
  2488. @end table
  2489. The volume expression can contain the following parameters.
  2490. @table @option
  2491. @item n
  2492. frame number (starting at zero)
  2493. @item nb_channels
  2494. number of channels
  2495. @item nb_consumed_samples
  2496. number of samples consumed by the filter
  2497. @item nb_samples
  2498. number of samples in the current frame
  2499. @item pos
  2500. original frame position in the file
  2501. @item pts
  2502. frame PTS
  2503. @item sample_rate
  2504. sample rate
  2505. @item startpts
  2506. PTS at start of stream
  2507. @item startt
  2508. time at start of stream
  2509. @item t
  2510. frame time
  2511. @item tb
  2512. timestamp timebase
  2513. @item volume
  2514. last set volume value
  2515. @end table
  2516. Note that when @option{eval} is set to @samp{once} only the
  2517. @var{sample_rate} and @var{tb} variables are available, all other
  2518. variables will evaluate to NAN.
  2519. @subsection Commands
  2520. This filter supports the following commands:
  2521. @table @option
  2522. @item volume
  2523. Modify the volume expression.
  2524. The command accepts the same syntax of the corresponding option.
  2525. If the specified expression is not valid, it is kept at its current
  2526. value.
  2527. @item replaygain_noclip
  2528. Prevent clipping by limiting the gain applied.
  2529. Default value for @var{replaygain_noclip} is 1.
  2530. @end table
  2531. @subsection Examples
  2532. @itemize
  2533. @item
  2534. Halve the input audio volume:
  2535. @example
  2536. volume=volume=0.5
  2537. volume=volume=1/2
  2538. volume=volume=-6.0206dB
  2539. @end example
  2540. In all the above example the named key for @option{volume} can be
  2541. omitted, for example like in:
  2542. @example
  2543. volume=0.5
  2544. @end example
  2545. @item
  2546. Increase input audio power by 6 decibels using fixed-point precision:
  2547. @example
  2548. volume=volume=6dB:precision=fixed
  2549. @end example
  2550. @item
  2551. Fade volume after time 10 with an annihilation period of 5 seconds:
  2552. @example
  2553. volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
  2554. @end example
  2555. @end itemize
  2556. @section volumedetect
  2557. Detect the volume of the input video.
  2558. The filter has no parameters. The input is not modified. Statistics about
  2559. the volume will be printed in the log when the input stream end is reached.
  2560. In particular it will show the mean volume (root mean square), maximum
  2561. volume (on a per-sample basis), and the beginning of a histogram of the
  2562. registered volume values (from the maximum value to a cumulated 1/1000 of
  2563. the samples).
  2564. All volumes are in decibels relative to the maximum PCM value.
  2565. @subsection Examples
  2566. Here is an excerpt of the output:
  2567. @example
  2568. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  2569. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  2570. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  2571. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  2572. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  2573. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  2574. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  2575. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  2576. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  2577. @end example
  2578. It means that:
  2579. @itemize
  2580. @item
  2581. The mean square energy is approximately -27 dB, or 10^-2.7.
  2582. @item
  2583. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  2584. @item
  2585. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  2586. @end itemize
  2587. In other words, raising the volume by +4 dB does not cause any clipping,
  2588. raising it by +5 dB causes clipping for 6 samples, etc.
  2589. @c man end AUDIO FILTERS
  2590. @chapter Audio Sources
  2591. @c man begin AUDIO SOURCES
  2592. Below is a description of the currently available audio sources.
  2593. @section abuffer
  2594. Buffer audio frames, and make them available to the filter chain.
  2595. This source is mainly intended for a programmatic use, in particular
  2596. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  2597. It accepts the following parameters:
  2598. @table @option
  2599. @item time_base
  2600. The timebase which will be used for timestamps of submitted frames. It must be
  2601. either a floating-point number or in @var{numerator}/@var{denominator} form.
  2602. @item sample_rate
  2603. The sample rate of the incoming audio buffers.
  2604. @item sample_fmt
  2605. The sample format of the incoming audio buffers.
  2606. Either a sample format name or its corresponding integer representation from
  2607. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  2608. @item channel_layout
  2609. The channel layout of the incoming audio buffers.
  2610. Either a channel layout name from channel_layout_map in
  2611. @file{libavutil/channel_layout.c} or its corresponding integer representation
  2612. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  2613. @item channels
  2614. The number of channels of the incoming audio buffers.
  2615. If both @var{channels} and @var{channel_layout} are specified, then they
  2616. must be consistent.
  2617. @end table
  2618. @subsection Examples
  2619. @example
  2620. abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
  2621. @end example
  2622. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  2623. Since the sample format with name "s16p" corresponds to the number
  2624. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  2625. equivalent to:
  2626. @example
  2627. abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
  2628. @end example
  2629. @section aevalsrc
  2630. Generate an audio signal specified by an expression.
  2631. This source accepts in input one or more expressions (one for each
  2632. channel), which are evaluated and used to generate a corresponding
  2633. audio signal.
  2634. This source accepts the following options:
  2635. @table @option
  2636. @item exprs
  2637. Set the '|'-separated expressions list for each separate channel. In case the
  2638. @option{channel_layout} option is not specified, the selected channel layout
  2639. depends on the number of provided expressions. Otherwise the last
  2640. specified expression is applied to the remaining output channels.
  2641. @item channel_layout, c
  2642. Set the channel layout. The number of channels in the specified layout
  2643. must be equal to the number of specified expressions.
  2644. @item duration, d
  2645. Set the minimum duration of the sourced audio. See
  2646. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  2647. for the accepted syntax.
  2648. Note that the resulting duration may be greater than the specified
  2649. duration, as the generated audio is always cut at the end of a
  2650. complete frame.
  2651. If not specified, or the expressed duration is negative, the audio is
  2652. supposed to be generated forever.
  2653. @item nb_samples, n
  2654. Set the number of samples per channel per each output frame,
  2655. default to 1024.
  2656. @item sample_rate, s
  2657. Specify the sample rate, default to 44100.
  2658. @end table
  2659. Each expression in @var{exprs} can contain the following constants:
  2660. @table @option
  2661. @item n
  2662. number of the evaluated sample, starting from 0
  2663. @item t
  2664. time of the evaluated sample expressed in seconds, starting from 0
  2665. @item s
  2666. sample rate
  2667. @end table
  2668. @subsection Examples
  2669. @itemize
  2670. @item
  2671. Generate silence:
  2672. @example
  2673. aevalsrc=0
  2674. @end example
  2675. @item
  2676. Generate a sin signal with frequency of 440 Hz, set sample rate to
  2677. 8000 Hz:
  2678. @example
  2679. aevalsrc="sin(440*2*PI*t):s=8000"
  2680. @end example
  2681. @item
  2682. Generate a two channels signal, specify the channel layout (Front
  2683. Center + Back Center) explicitly:
  2684. @example
  2685. aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
  2686. @end example
  2687. @item
  2688. Generate white noise:
  2689. @example
  2690. aevalsrc="-2+random(0)"
  2691. @end example
  2692. @item
  2693. Generate an amplitude modulated signal:
  2694. @example
  2695. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  2696. @end example
  2697. @item
  2698. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  2699. @example
  2700. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
  2701. @end example
  2702. @end itemize
  2703. @section anullsrc
  2704. The null audio source, return unprocessed audio frames. It is mainly useful
  2705. as a template and to be employed in analysis / debugging tools, or as
  2706. the source for filters which ignore the input data (for example the sox
  2707. synth filter).
  2708. This source accepts the following options:
  2709. @table @option
  2710. @item channel_layout, cl
  2711. Specifies the channel layout, and can be either an integer or a string
  2712. representing a channel layout. The default value of @var{channel_layout}
  2713. is "stereo".
  2714. Check the channel_layout_map definition in
  2715. @file{libavutil/channel_layout.c} for the mapping between strings and
  2716. channel layout values.
  2717. @item sample_rate, r
  2718. Specifies the sample rate, and defaults to 44100.
  2719. @item nb_samples, n
  2720. Set the number of samples per requested frames.
  2721. @end table
  2722. @subsection Examples
  2723. @itemize
  2724. @item
  2725. Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  2726. @example
  2727. anullsrc=r=48000:cl=4
  2728. @end example
  2729. @item
  2730. Do the same operation with a more obvious syntax:
  2731. @example
  2732. anullsrc=r=48000:cl=mono
  2733. @end example
  2734. @end itemize
  2735. All the parameters need to be explicitly defined.
  2736. @section flite
  2737. Synthesize a voice utterance using the libflite library.
  2738. To enable compilation of this filter you need to configure FFmpeg with
  2739. @code{--enable-libflite}.
  2740. Note that the flite library is not thread-safe.
  2741. The filter accepts the following options:
  2742. @table @option
  2743. @item list_voices
  2744. If set to 1, list the names of the available voices and exit
  2745. immediately. Default value is 0.
  2746. @item nb_samples, n
  2747. Set the maximum number of samples per frame. Default value is 512.
  2748. @item textfile
  2749. Set the filename containing the text to speak.
  2750. @item text
  2751. Set the text to speak.
  2752. @item voice, v
  2753. Set the voice to use for the speech synthesis. Default value is
  2754. @code{kal}. See also the @var{list_voices} option.
  2755. @end table
  2756. @subsection Examples
  2757. @itemize
  2758. @item
  2759. Read from file @file{speech.txt}, and synthesize the text using the
  2760. standard flite voice:
  2761. @example
  2762. flite=textfile=speech.txt
  2763. @end example
  2764. @item
  2765. Read the specified text selecting the @code{slt} voice:
  2766. @example
  2767. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2768. @end example
  2769. @item
  2770. Input text to ffmpeg:
  2771. @example
  2772. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2773. @end example
  2774. @item
  2775. Make @file{ffplay} speak the specified text, using @code{flite} and
  2776. the @code{lavfi} device:
  2777. @example
  2778. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  2779. @end example
  2780. @end itemize
  2781. For more information about libflite, check:
  2782. @url{http://www.speech.cs.cmu.edu/flite/}
  2783. @section anoisesrc
  2784. Generate a noise audio signal.
  2785. The filter accepts the following options:
  2786. @table @option
  2787. @item sample_rate, r
  2788. Specify the sample rate. Default value is 48000 Hz.
  2789. @item amplitude, a
  2790. Specify the amplitude (0.0 - 1.0) of the generated audio stream. Default value
  2791. is 1.0.
  2792. @item duration, d
  2793. Specify the duration of the generated audio stream. Not specifying this option
  2794. results in noise with an infinite length.
  2795. @item color, colour, c
  2796. Specify the color of noise. Available noise colors are white, pink, and brown.
  2797. Default color is white.
  2798. @item seed, s
  2799. Specify a value used to seed the PRNG.
  2800. @item nb_samples, n
  2801. Set the number of samples per each output frame, default is 1024.
  2802. @end table
  2803. @subsection Examples
  2804. @itemize
  2805. @item
  2806. Generate 60 seconds of pink noise, with a 44.1 kHz sampling rate and an amplitude of 0.5:
  2807. @example
  2808. anoisesrc=d=60:c=pink:r=44100:a=0.5
  2809. @end example
  2810. @end itemize
  2811. @section sine
  2812. Generate an audio signal made of a sine wave with amplitude 1/8.
  2813. The audio signal is bit-exact.
  2814. The filter accepts the following options:
  2815. @table @option
  2816. @item frequency, f
  2817. Set the carrier frequency. Default is 440 Hz.
  2818. @item beep_factor, b
  2819. Enable a periodic beep every second with frequency @var{beep_factor} times
  2820. the carrier frequency. Default is 0, meaning the beep is disabled.
  2821. @item sample_rate, r
  2822. Specify the sample rate, default is 44100.
  2823. @item duration, d
  2824. Specify the duration of the generated audio stream.
  2825. @item samples_per_frame
  2826. Set the number of samples per output frame.
  2827. The expression can contain the following constants:
  2828. @table @option
  2829. @item n
  2830. The (sequential) number of the output audio frame, starting from 0.
  2831. @item pts
  2832. The PTS (Presentation TimeStamp) of the output audio frame,
  2833. expressed in @var{TB} units.
  2834. @item t
  2835. The PTS of the output audio frame, expressed in seconds.
  2836. @item TB
  2837. The timebase of the output audio frames.
  2838. @end table
  2839. Default is @code{1024}.
  2840. @end table
  2841. @subsection Examples
  2842. @itemize
  2843. @item
  2844. Generate a simple 440 Hz sine wave:
  2845. @example
  2846. sine
  2847. @end example
  2848. @item
  2849. Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
  2850. @example
  2851. sine=220:4:d=5
  2852. sine=f=220:b=4:d=5
  2853. sine=frequency=220:beep_factor=4:duration=5
  2854. @end example
  2855. @item
  2856. Generate a 1 kHz sine wave following @code{1602,1601,1602,1601,1602} NTSC
  2857. pattern:
  2858. @example
  2859. sine=1000:samples_per_frame='st(0,mod(n,5)); 1602-not(not(eq(ld(0),1)+eq(ld(0),3)))'
  2860. @end example
  2861. @end itemize
  2862. @c man end AUDIO SOURCES
  2863. @chapter Audio Sinks
  2864. @c man begin AUDIO SINKS
  2865. Below is a description of the currently available audio sinks.
  2866. @section abuffersink
  2867. Buffer audio frames, and make them available to the end of filter chain.
  2868. This sink is mainly intended for programmatic use, in particular
  2869. through the interface defined in @file{libavfilter/buffersink.h}
  2870. or the options system.
  2871. It accepts a pointer to an AVABufferSinkContext structure, which
  2872. defines the incoming buffers' formats, to be passed as the opaque
  2873. parameter to @code{avfilter_init_filter} for initialization.
  2874. @section anullsink
  2875. Null audio sink; do absolutely nothing with the input audio. It is
  2876. mainly useful as a template and for use in analysis / debugging
  2877. tools.
  2878. @c man end AUDIO SINKS
  2879. @chapter Video Filters
  2880. @c man begin VIDEO FILTERS
  2881. When you configure your FFmpeg build, you can disable any of the
  2882. existing filters using @code{--disable-filters}.
  2883. The configure output will show the video filters included in your
  2884. build.
  2885. Below is a description of the currently available video filters.
  2886. @section alphaextract
  2887. Extract the alpha component from the input as a grayscale video. This
  2888. is especially useful with the @var{alphamerge} filter.
  2889. @section alphamerge
  2890. Add or replace the alpha component of the primary input with the
  2891. grayscale value of a second input. This is intended for use with
  2892. @var{alphaextract} to allow the transmission or storage of frame
  2893. sequences that have alpha in a format that doesn't support an alpha
  2894. channel.
  2895. For example, to reconstruct full frames from a normal YUV-encoded video
  2896. and a separate video created with @var{alphaextract}, you might use:
  2897. @example
  2898. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  2899. @end example
  2900. Since this filter is designed for reconstruction, it operates on frame
  2901. sequences without considering timestamps, and terminates when either
  2902. input reaches end of stream. This will cause problems if your encoding
  2903. pipeline drops frames. If you're trying to apply an image as an
  2904. overlay to a video stream, consider the @var{overlay} filter instead.
  2905. @section ass
  2906. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  2907. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  2908. Substation Alpha) subtitles files.
  2909. This filter accepts the following option in addition to the common options from
  2910. the @ref{subtitles} filter:
  2911. @table @option
  2912. @item shaping
  2913. Set the shaping engine
  2914. Available values are:
  2915. @table @samp
  2916. @item auto
  2917. The default libass shaping engine, which is the best available.
  2918. @item simple
  2919. Fast, font-agnostic shaper that can do only substitutions
  2920. @item complex
  2921. Slower shaper using OpenType for substitutions and positioning
  2922. @end table
  2923. The default is @code{auto}.
  2924. @end table
  2925. @section atadenoise
  2926. Apply an Adaptive Temporal Averaging Denoiser to the video input.
  2927. The filter accepts the following options:
  2928. @table @option
  2929. @item 0a
  2930. Set threshold A for 1st plane. Default is 0.02.
  2931. Valid range is 0 to 0.3.
  2932. @item 0b
  2933. Set threshold B for 1st plane. Default is 0.04.
  2934. Valid range is 0 to 5.
  2935. @item 1a
  2936. Set threshold A for 2nd plane. Default is 0.02.
  2937. Valid range is 0 to 0.3.
  2938. @item 1b
  2939. Set threshold B for 2nd plane. Default is 0.04.
  2940. Valid range is 0 to 5.
  2941. @item 2a
  2942. Set threshold A for 3rd plane. Default is 0.02.
  2943. Valid range is 0 to 0.3.
  2944. @item 2b
  2945. Set threshold B for 3rd plane. Default is 0.04.
  2946. Valid range is 0 to 5.
  2947. Threshold A is designed to react on abrupt changes in the input signal and
  2948. threshold B is designed to react on continuous changes in the input signal.
  2949. @item s
  2950. Set number of frames filter will use for averaging. Default is 33. Must be odd
  2951. number in range [5, 129].
  2952. @end table
  2953. @section bbox
  2954. Compute the bounding box for the non-black pixels in the input frame
  2955. luminance plane.
  2956. This filter computes the bounding box containing all the pixels with a
  2957. luminance value greater than the minimum allowed value.
  2958. The parameters describing the bounding box are printed on the filter
  2959. log.
  2960. The filter accepts the following option:
  2961. @table @option
  2962. @item min_val
  2963. Set the minimal luminance value. Default is @code{16}.
  2964. @end table
  2965. @section blackdetect
  2966. Detect video intervals that are (almost) completely black. Can be
  2967. useful to detect chapter transitions, commercials, or invalid
  2968. recordings. Output lines contains the time for the start, end and
  2969. duration of the detected black interval expressed in seconds.
  2970. In order to display the output lines, you need to set the loglevel at
  2971. least to the AV_LOG_INFO value.
  2972. The filter accepts the following options:
  2973. @table @option
  2974. @item black_min_duration, d
  2975. Set the minimum detected black duration expressed in seconds. It must
  2976. be a non-negative floating point number.
  2977. Default value is 2.0.
  2978. @item picture_black_ratio_th, pic_th
  2979. Set the threshold for considering a picture "black".
  2980. Express the minimum value for the ratio:
  2981. @example
  2982. @var{nb_black_pixels} / @var{nb_pixels}
  2983. @end example
  2984. for which a picture is considered black.
  2985. Default value is 0.98.
  2986. @item pixel_black_th, pix_th
  2987. Set the threshold for considering a pixel "black".
  2988. The threshold expresses the maximum pixel luminance value for which a
  2989. pixel is considered "black". The provided value is scaled according to
  2990. the following equation:
  2991. @example
  2992. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  2993. @end example
  2994. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  2995. the input video format, the range is [0-255] for YUV full-range
  2996. formats and [16-235] for YUV non full-range formats.
  2997. Default value is 0.10.
  2998. @end table
  2999. The following example sets the maximum pixel threshold to the minimum
  3000. value, and detects only black intervals of 2 or more seconds:
  3001. @example
  3002. blackdetect=d=2:pix_th=0.00
  3003. @end example
  3004. @section blackframe
  3005. Detect frames that are (almost) completely black. Can be useful to
  3006. detect chapter transitions or commercials. Output lines consist of
  3007. the frame number of the detected frame, the percentage of blackness,
  3008. the position in the file if known or -1 and the timestamp in seconds.
  3009. In order to display the output lines, you need to set the loglevel at
  3010. least to the AV_LOG_INFO value.
  3011. It accepts the following parameters:
  3012. @table @option
  3013. @item amount
  3014. The percentage of the pixels that have to be below the threshold; it defaults to
  3015. @code{98}.
  3016. @item threshold, thresh
  3017. The threshold below which a pixel value is considered black; it defaults to
  3018. @code{32}.
  3019. @end table
  3020. @section blend, tblend
  3021. Blend two video frames into each other.
  3022. The @code{blend} filter takes two input streams and outputs one
  3023. stream, the first input is the "top" layer and second input is
  3024. "bottom" layer. Output terminates when shortest input terminates.
  3025. The @code{tblend} (time blend) filter takes two consecutive frames
  3026. from one single stream, and outputs the result obtained by blending
  3027. the new frame on top of the old frame.
  3028. A description of the accepted options follows.
  3029. @table @option
  3030. @item c0_mode
  3031. @item c1_mode
  3032. @item c2_mode
  3033. @item c3_mode
  3034. @item all_mode
  3035. Set blend mode for specific pixel component or all pixel components in case
  3036. of @var{all_mode}. Default value is @code{normal}.
  3037. Available values for component modes are:
  3038. @table @samp
  3039. @item addition
  3040. @item addition128
  3041. @item and
  3042. @item average
  3043. @item burn
  3044. @item darken
  3045. @item difference
  3046. @item difference128
  3047. @item divide
  3048. @item dodge
  3049. @item exclusion
  3050. @item glow
  3051. @item hardlight
  3052. @item hardmix
  3053. @item lighten
  3054. @item linearlight
  3055. @item multiply
  3056. @item negation
  3057. @item normal
  3058. @item or
  3059. @item overlay
  3060. @item phoenix
  3061. @item pinlight
  3062. @item reflect
  3063. @item screen
  3064. @item softlight
  3065. @item subtract
  3066. @item vividlight
  3067. @item xor
  3068. @end table
  3069. @item c0_opacity
  3070. @item c1_opacity
  3071. @item c2_opacity
  3072. @item c3_opacity
  3073. @item all_opacity
  3074. Set blend opacity for specific pixel component or all pixel components in case
  3075. of @var{all_opacity}. Only used in combination with pixel component blend modes.
  3076. @item c0_expr
  3077. @item c1_expr
  3078. @item c2_expr
  3079. @item c3_expr
  3080. @item all_expr
  3081. Set blend expression for specific pixel component or all pixel components in case
  3082. of @var{all_expr}. Note that related mode options will be ignored if those are set.
  3083. The expressions can use the following variables:
  3084. @table @option
  3085. @item N
  3086. The sequential number of the filtered frame, starting from @code{0}.
  3087. @item X
  3088. @item Y
  3089. the coordinates of the current sample
  3090. @item W
  3091. @item H
  3092. the width and height of currently filtered plane
  3093. @item SW
  3094. @item SH
  3095. Width and height scale depending on the currently filtered plane. It is the
  3096. ratio between the corresponding luma plane number of pixels and the current
  3097. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  3098. @code{0.5,0.5} for chroma planes.
  3099. @item T
  3100. Time of the current frame, expressed in seconds.
  3101. @item TOP, A
  3102. Value of pixel component at current location for first video frame (top layer).
  3103. @item BOTTOM, B
  3104. Value of pixel component at current location for second video frame (bottom layer).
  3105. @end table
  3106. @item shortest
  3107. Force termination when the shortest input terminates. Default is
  3108. @code{0}. This option is only defined for the @code{blend} filter.
  3109. @item repeatlast
  3110. Continue applying the last bottom frame after the end of the stream. A value of
  3111. @code{0} disable the filter after the last frame of the bottom layer is reached.
  3112. Default is @code{1}. This option is only defined for the @code{blend} filter.
  3113. @end table
  3114. @subsection Examples
  3115. @itemize
  3116. @item
  3117. Apply transition from bottom layer to top layer in first 10 seconds:
  3118. @example
  3119. blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
  3120. @end example
  3121. @item
  3122. Apply 1x1 checkerboard effect:
  3123. @example
  3124. blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
  3125. @end example
  3126. @item
  3127. Apply uncover left effect:
  3128. @example
  3129. blend=all_expr='if(gte(N*SW+X,W),A,B)'
  3130. @end example
  3131. @item
  3132. Apply uncover down effect:
  3133. @example
  3134. blend=all_expr='if(gte(Y-N*SH,0),A,B)'
  3135. @end example
  3136. @item
  3137. Apply uncover up-left effect:
  3138. @example
  3139. blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
  3140. @end example
  3141. @item
  3142. Display differences between the current and the previous frame:
  3143. @example
  3144. tblend=all_mode=difference128
  3145. @end example
  3146. @end itemize
  3147. @section boxblur
  3148. Apply a boxblur algorithm to the input video.
  3149. It accepts the following parameters:
  3150. @table @option
  3151. @item luma_radius, lr
  3152. @item luma_power, lp
  3153. @item chroma_radius, cr
  3154. @item chroma_power, cp
  3155. @item alpha_radius, ar
  3156. @item alpha_power, ap
  3157. @end table
  3158. A description of the accepted options follows.
  3159. @table @option
  3160. @item luma_radius, lr
  3161. @item chroma_radius, cr
  3162. @item alpha_radius, ar
  3163. Set an expression for the box radius in pixels used for blurring the
  3164. corresponding input plane.
  3165. The radius value must be a non-negative number, and must not be
  3166. greater than the value of the expression @code{min(w,h)/2} for the
  3167. luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
  3168. planes.
  3169. Default value for @option{luma_radius} is "2". If not specified,
  3170. @option{chroma_radius} and @option{alpha_radius} default to the
  3171. corresponding value set for @option{luma_radius}.
  3172. The expressions can contain the following constants:
  3173. @table @option
  3174. @item w
  3175. @item h
  3176. The input width and height in pixels.
  3177. @item cw
  3178. @item ch
  3179. The input chroma image width and height in pixels.
  3180. @item hsub
  3181. @item vsub
  3182. The horizontal and vertical chroma subsample values. For example, for the
  3183. pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
  3184. @end table
  3185. @item luma_power, lp
  3186. @item chroma_power, cp
  3187. @item alpha_power, ap
  3188. Specify how many times the boxblur filter is applied to the
  3189. corresponding plane.
  3190. Default value for @option{luma_power} is 2. If not specified,
  3191. @option{chroma_power} and @option{alpha_power} default to the
  3192. corresponding value set for @option{luma_power}.
  3193. A value of 0 will disable the effect.
  3194. @end table
  3195. @subsection Examples
  3196. @itemize
  3197. @item
  3198. Apply a boxblur filter with the luma, chroma, and alpha radii
  3199. set to 2:
  3200. @example
  3201. boxblur=luma_radius=2:luma_power=1
  3202. boxblur=2:1
  3203. @end example
  3204. @item
  3205. Set the luma radius to 2, and alpha and chroma radius to 0:
  3206. @example
  3207. boxblur=2:1:cr=0:ar=0
  3208. @end example
  3209. @item
  3210. Set the luma and chroma radii to a fraction of the video dimension:
  3211. @example
  3212. boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
  3213. @end example
  3214. @end itemize
  3215. @section chromakey
  3216. YUV colorspace color/chroma keying.
  3217. The filter accepts the following options:
  3218. @table @option
  3219. @item color
  3220. The color which will be replaced with transparency.
  3221. @item similarity
  3222. Similarity percentage with the key color.
  3223. 0.01 matches only the exact key color, while 1.0 matches everything.
  3224. @item blend
  3225. Blend percentage.
  3226. 0.0 makes pixels either fully transparent, or not transparent at all.
  3227. Higher values result in semi-transparent pixels, with a higher transparency
  3228. the more similar the pixels color is to the key color.
  3229. @item yuv
  3230. Signals that the color passed is already in YUV instead of RGB.
  3231. Litteral colors like "green" or "red" don't make sense with this enabled anymore.
  3232. This can be used to pass exact YUV values as hexadecimal numbers.
  3233. @end table
  3234. @subsection Examples
  3235. @itemize
  3236. @item
  3237. Make every green pixel in the input image transparent:
  3238. @example
  3239. ffmpeg -i input.png -vf chromakey=green out.png
  3240. @end example
  3241. @item
  3242. Overlay a greenscreen-video on top of a static black background.
  3243. @example
  3244. 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
  3245. @end example
  3246. @end itemize
  3247. @section codecview
  3248. Visualize information exported by some codecs.
  3249. Some codecs can export information through frames using side-data or other
  3250. means. For example, some MPEG based codecs export motion vectors through the
  3251. @var{export_mvs} flag in the codec @option{flags2} option.
  3252. The filter accepts the following option:
  3253. @table @option
  3254. @item mv
  3255. Set motion vectors to visualize.
  3256. Available flags for @var{mv} are:
  3257. @table @samp
  3258. @item pf
  3259. forward predicted MVs of P-frames
  3260. @item bf
  3261. forward predicted MVs of B-frames
  3262. @item bb
  3263. backward predicted MVs of B-frames
  3264. @end table
  3265. @item qp
  3266. Display quantization parameters using the chroma planes
  3267. @end table
  3268. @subsection Examples
  3269. @itemize
  3270. @item
  3271. Visualizes multi-directionals MVs from P and B-Frames using @command{ffplay}:
  3272. @example
  3273. ffplay -flags2 +export_mvs input.mpg -vf codecview=mv=pf+bf+bb
  3274. @end example
  3275. @end itemize
  3276. @section colorbalance
  3277. Modify intensity of primary colors (red, green and blue) of input frames.
  3278. The filter allows an input frame to be adjusted in the shadows, midtones or highlights
  3279. regions for the red-cyan, green-magenta or blue-yellow balance.
  3280. A positive adjustment value shifts the balance towards the primary color, a negative
  3281. value towards the complementary color.
  3282. The filter accepts the following options:
  3283. @table @option
  3284. @item rs
  3285. @item gs
  3286. @item bs
  3287. Adjust red, green and blue shadows (darkest pixels).
  3288. @item rm
  3289. @item gm
  3290. @item bm
  3291. Adjust red, green and blue midtones (medium pixels).
  3292. @item rh
  3293. @item gh
  3294. @item bh
  3295. Adjust red, green and blue highlights (brightest pixels).
  3296. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  3297. @end table
  3298. @subsection Examples
  3299. @itemize
  3300. @item
  3301. Add red color cast to shadows:
  3302. @example
  3303. colorbalance=rs=.3
  3304. @end example
  3305. @end itemize
  3306. @section colorkey
  3307. RGB colorspace color keying.
  3308. The filter accepts the following options:
  3309. @table @option
  3310. @item color
  3311. The color which will be replaced with transparency.
  3312. @item similarity
  3313. Similarity percentage with the key color.
  3314. 0.01 matches only the exact key color, while 1.0 matches everything.
  3315. @item blend
  3316. Blend percentage.
  3317. 0.0 makes pixels either fully transparent, or not transparent at all.
  3318. Higher values result in semi-transparent pixels, with a higher transparency
  3319. the more similar the pixels color is to the key color.
  3320. @end table
  3321. @subsection Examples
  3322. @itemize
  3323. @item
  3324. Make every green pixel in the input image transparent:
  3325. @example
  3326. ffmpeg -i input.png -vf colorkey=green out.png
  3327. @end example
  3328. @item
  3329. Overlay a greenscreen-video on top of a static background image.
  3330. @example
  3331. 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
  3332. @end example
  3333. @end itemize
  3334. @section colorlevels
  3335. Adjust video input frames using levels.
  3336. The filter accepts the following options:
  3337. @table @option
  3338. @item rimin
  3339. @item gimin
  3340. @item bimin
  3341. @item aimin
  3342. Adjust red, green, blue and alpha input black point.
  3343. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  3344. @item rimax
  3345. @item gimax
  3346. @item bimax
  3347. @item aimax
  3348. Adjust red, green, blue and alpha input white point.
  3349. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
  3350. Input levels are used to lighten highlights (bright tones), darken shadows
  3351. (dark tones), change the balance of bright and dark tones.
  3352. @item romin
  3353. @item gomin
  3354. @item bomin
  3355. @item aomin
  3356. Adjust red, green, blue and alpha output black point.
  3357. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
  3358. @item romax
  3359. @item gomax
  3360. @item bomax
  3361. @item aomax
  3362. Adjust red, green, blue and alpha output white point.
  3363. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
  3364. Output levels allows manual selection of a constrained output level range.
  3365. @end table
  3366. @subsection Examples
  3367. @itemize
  3368. @item
  3369. Make video output darker:
  3370. @example
  3371. colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
  3372. @end example
  3373. @item
  3374. Increase contrast:
  3375. @example
  3376. colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
  3377. @end example
  3378. @item
  3379. Make video output lighter:
  3380. @example
  3381. colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
  3382. @end example
  3383. @item
  3384. Increase brightness:
  3385. @example
  3386. colorlevels=romin=0.5:gomin=0.5:bomin=0.5
  3387. @end example
  3388. @end itemize
  3389. @section colorchannelmixer
  3390. Adjust video input frames by re-mixing color channels.
  3391. This filter modifies a color channel by adding the values associated to
  3392. the other channels of the same pixels. For example if the value to
  3393. modify is red, the output value will be:
  3394. @example
  3395. @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
  3396. @end example
  3397. The filter accepts the following options:
  3398. @table @option
  3399. @item rr
  3400. @item rg
  3401. @item rb
  3402. @item ra
  3403. Adjust contribution of input red, green, blue and alpha channels for output red channel.
  3404. Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
  3405. @item gr
  3406. @item gg
  3407. @item gb
  3408. @item ga
  3409. Adjust contribution of input red, green, blue and alpha channels for output green channel.
  3410. Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
  3411. @item br
  3412. @item bg
  3413. @item bb
  3414. @item ba
  3415. Adjust contribution of input red, green, blue and alpha channels for output blue channel.
  3416. Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
  3417. @item ar
  3418. @item ag
  3419. @item ab
  3420. @item aa
  3421. Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
  3422. Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
  3423. Allowed ranges for options are @code{[-2.0, 2.0]}.
  3424. @end table
  3425. @subsection Examples
  3426. @itemize
  3427. @item
  3428. Convert source to grayscale:
  3429. @example
  3430. colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
  3431. @end example
  3432. @item
  3433. Simulate sepia tones:
  3434. @example
  3435. colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
  3436. @end example
  3437. @end itemize
  3438. @section colormatrix
  3439. Convert color matrix.
  3440. The filter accepts the following options:
  3441. @table @option
  3442. @item src
  3443. @item dst
  3444. Specify the source and destination color matrix. Both values must be
  3445. specified.
  3446. The accepted values are:
  3447. @table @samp
  3448. @item bt709
  3449. BT.709
  3450. @item bt601
  3451. BT.601
  3452. @item smpte240m
  3453. SMPTE-240M
  3454. @item fcc
  3455. FCC
  3456. @end table
  3457. @end table
  3458. For example to convert from BT.601 to SMPTE-240M, use the command:
  3459. @example
  3460. colormatrix=bt601:smpte240m
  3461. @end example
  3462. @section copy
  3463. Copy the input source unchanged to the output. This is mainly useful for
  3464. testing purposes.
  3465. @section crop
  3466. Crop the input video to given dimensions.
  3467. It accepts the following parameters:
  3468. @table @option
  3469. @item w, out_w
  3470. The width of the output video. It defaults to @code{iw}.
  3471. This expression is evaluated only once during the filter
  3472. configuration, or when the @samp{w} or @samp{out_w} command is sent.
  3473. @item h, out_h
  3474. The height of the output video. It defaults to @code{ih}.
  3475. This expression is evaluated only once during the filter
  3476. configuration, or when the @samp{h} or @samp{out_h} command is sent.
  3477. @item x
  3478. The horizontal position, in the input video, of the left edge of the output
  3479. video. It defaults to @code{(in_w-out_w)/2}.
  3480. This expression is evaluated per-frame.
  3481. @item y
  3482. The vertical position, in the input video, of the top edge of the output video.
  3483. It defaults to @code{(in_h-out_h)/2}.
  3484. This expression is evaluated per-frame.
  3485. @item keep_aspect
  3486. If set to 1 will force the output display aspect ratio
  3487. to be the same of the input, by changing the output sample aspect
  3488. ratio. It defaults to 0.
  3489. @end table
  3490. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  3491. expressions containing the following constants:
  3492. @table @option
  3493. @item x
  3494. @item y
  3495. The computed values for @var{x} and @var{y}. They are evaluated for
  3496. each new frame.
  3497. @item in_w
  3498. @item in_h
  3499. The input width and height.
  3500. @item iw
  3501. @item ih
  3502. These are the same as @var{in_w} and @var{in_h}.
  3503. @item out_w
  3504. @item out_h
  3505. The output (cropped) width and height.
  3506. @item ow
  3507. @item oh
  3508. These are the same as @var{out_w} and @var{out_h}.
  3509. @item a
  3510. same as @var{iw} / @var{ih}
  3511. @item sar
  3512. input sample aspect ratio
  3513. @item dar
  3514. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  3515. @item hsub
  3516. @item vsub
  3517. horizontal and vertical chroma subsample values. For example for the
  3518. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3519. @item n
  3520. The number of the input frame, starting from 0.
  3521. @item pos
  3522. the position in the file of the input frame, NAN if unknown
  3523. @item t
  3524. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  3525. @end table
  3526. The expression for @var{out_w} may depend on the value of @var{out_h},
  3527. and the expression for @var{out_h} may depend on @var{out_w}, but they
  3528. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  3529. evaluated after @var{out_w} and @var{out_h}.
  3530. The @var{x} and @var{y} parameters specify the expressions for the
  3531. position of the top-left corner of the output (non-cropped) area. They
  3532. are evaluated for each frame. If the evaluated value is not valid, it
  3533. is approximated to the nearest valid value.
  3534. The expression for @var{x} may depend on @var{y}, and the expression
  3535. for @var{y} may depend on @var{x}.
  3536. @subsection Examples
  3537. @itemize
  3538. @item
  3539. Crop area with size 100x100 at position (12,34).
  3540. @example
  3541. crop=100:100:12:34
  3542. @end example
  3543. Using named options, the example above becomes:
  3544. @example
  3545. crop=w=100:h=100:x=12:y=34
  3546. @end example
  3547. @item
  3548. Crop the central input area with size 100x100:
  3549. @example
  3550. crop=100:100
  3551. @end example
  3552. @item
  3553. Crop the central input area with size 2/3 of the input video:
  3554. @example
  3555. crop=2/3*in_w:2/3*in_h
  3556. @end example
  3557. @item
  3558. Crop the input video central square:
  3559. @example
  3560. crop=out_w=in_h
  3561. crop=in_h
  3562. @end example
  3563. @item
  3564. Delimit the rectangle with the top-left corner placed at position
  3565. 100:100 and the right-bottom corner corresponding to the right-bottom
  3566. corner of the input image.
  3567. @example
  3568. crop=in_w-100:in_h-100:100:100
  3569. @end example
  3570. @item
  3571. Crop 10 pixels from the left and right borders, and 20 pixels from
  3572. the top and bottom borders
  3573. @example
  3574. crop=in_w-2*10:in_h-2*20
  3575. @end example
  3576. @item
  3577. Keep only the bottom right quarter of the input image:
  3578. @example
  3579. crop=in_w/2:in_h/2:in_w/2:in_h/2
  3580. @end example
  3581. @item
  3582. Crop height for getting Greek harmony:
  3583. @example
  3584. crop=in_w:1/PHI*in_w
  3585. @end example
  3586. @item
  3587. Apply trembling effect:
  3588. @example
  3589. 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)
  3590. @end example
  3591. @item
  3592. Apply erratic camera effect depending on timestamp:
  3593. @example
  3594. 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)"
  3595. @end example
  3596. @item
  3597. Set x depending on the value of y:
  3598. @example
  3599. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  3600. @end example
  3601. @end itemize
  3602. @subsection Commands
  3603. This filter supports the following commands:
  3604. @table @option
  3605. @item w, out_w
  3606. @item h, out_h
  3607. @item x
  3608. @item y
  3609. Set width/height of the output video and the horizontal/vertical position
  3610. in the input video.
  3611. The command accepts the same syntax of the corresponding option.
  3612. If the specified expression is not valid, it is kept at its current
  3613. value.
  3614. @end table
  3615. @section cropdetect
  3616. Auto-detect the crop size.
  3617. It calculates the necessary cropping parameters and prints the
  3618. recommended parameters via the logging system. The detected dimensions
  3619. correspond to the non-black area of the input video.
  3620. It accepts the following parameters:
  3621. @table @option
  3622. @item limit
  3623. Set higher black value threshold, which can be optionally specified
  3624. from nothing (0) to everything (255 for 8bit based formats). An intensity
  3625. value greater to the set value is considered non-black. It defaults to 24.
  3626. You can also specify a value between 0.0 and 1.0 which will be scaled depending
  3627. on the bitdepth of the pixel format.
  3628. @item round
  3629. The value which the width/height should be divisible by. It defaults to
  3630. 16. The offset is automatically adjusted to center the video. Use 2 to
  3631. get only even dimensions (needed for 4:2:2 video). 16 is best when
  3632. encoding to most video codecs.
  3633. @item reset_count, reset
  3634. Set the counter that determines after how many frames cropdetect will
  3635. reset the previously detected largest video area and start over to
  3636. detect the current optimal crop area. Default value is 0.
  3637. This can be useful when channel logos distort the video area. 0
  3638. indicates 'never reset', and returns the largest area encountered during
  3639. playback.
  3640. @end table
  3641. @anchor{curves}
  3642. @section curves
  3643. Apply color adjustments using curves.
  3644. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  3645. component (red, green and blue) has its values defined by @var{N} key points
  3646. tied from each other using a smooth curve. The x-axis represents the pixel
  3647. values from the input frame, and the y-axis the new pixel values to be set for
  3648. the output frame.
  3649. By default, a component curve is defined by the two points @var{(0;0)} and
  3650. @var{(1;1)}. This creates a straight line where each original pixel value is
  3651. "adjusted" to its own value, which means no change to the image.
  3652. The filter allows you to redefine these two points and add some more. A new
  3653. curve (using a natural cubic spline interpolation) will be define to pass
  3654. smoothly through all these new coordinates. The new defined points needs to be
  3655. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  3656. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  3657. the vector spaces, the values will be clipped accordingly.
  3658. If there is no key point defined in @code{x=0}, the filter will automatically
  3659. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  3660. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  3661. The filter accepts the following options:
  3662. @table @option
  3663. @item preset
  3664. Select one of the available color presets. This option can be used in addition
  3665. to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
  3666. options takes priority on the preset values.
  3667. Available presets are:
  3668. @table @samp
  3669. @item none
  3670. @item color_negative
  3671. @item cross_process
  3672. @item darker
  3673. @item increase_contrast
  3674. @item lighter
  3675. @item linear_contrast
  3676. @item medium_contrast
  3677. @item negative
  3678. @item strong_contrast
  3679. @item vintage
  3680. @end table
  3681. Default is @code{none}.
  3682. @item master, m
  3683. Set the master key points. These points will define a second pass mapping. It
  3684. is sometimes called a "luminance" or "value" mapping. It can be used with
  3685. @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
  3686. post-processing LUT.
  3687. @item red, r
  3688. Set the key points for the red component.
  3689. @item green, g
  3690. Set the key points for the green component.
  3691. @item blue, b
  3692. Set the key points for the blue component.
  3693. @item all
  3694. Set the key points for all components (not including master).
  3695. Can be used in addition to the other key points component
  3696. options. In this case, the unset component(s) will fallback on this
  3697. @option{all} setting.
  3698. @item psfile
  3699. Specify a Photoshop curves file (@code{.acv}) to import the settings from.
  3700. @end table
  3701. To avoid some filtergraph syntax conflicts, each key points list need to be
  3702. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  3703. @subsection Examples
  3704. @itemize
  3705. @item
  3706. Increase slightly the middle level of blue:
  3707. @example
  3708. curves=blue='0.5/0.58'
  3709. @end example
  3710. @item
  3711. Vintage effect:
  3712. @example
  3713. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  3714. @end example
  3715. Here we obtain the following coordinates for each components:
  3716. @table @var
  3717. @item red
  3718. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  3719. @item green
  3720. @code{(0;0) (0.50;0.48) (1;1)}
  3721. @item blue
  3722. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  3723. @end table
  3724. @item
  3725. The previous example can also be achieved with the associated built-in preset:
  3726. @example
  3727. curves=preset=vintage
  3728. @end example
  3729. @item
  3730. Or simply:
  3731. @example
  3732. curves=vintage
  3733. @end example
  3734. @item
  3735. Use a Photoshop preset and redefine the points of the green component:
  3736. @example
  3737. curves=psfile='MyCurvesPresets/purple.acv':green='0.45/0.53'
  3738. @end example
  3739. @end itemize
  3740. @section dctdnoiz
  3741. Denoise frames using 2D DCT (frequency domain filtering).
  3742. This filter is not designed for real time.
  3743. The filter accepts the following options:
  3744. @table @option
  3745. @item sigma, s
  3746. Set the noise sigma constant.
  3747. This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
  3748. coefficient (absolute value) below this threshold with be dropped.
  3749. If you need a more advanced filtering, see @option{expr}.
  3750. Default is @code{0}.
  3751. @item overlap
  3752. Set number overlapping pixels for each block. Since the filter can be slow, you
  3753. may want to reduce this value, at the cost of a less effective filter and the
  3754. risk of various artefacts.
  3755. If the overlapping value doesn't permit processing the whole input width or
  3756. height, a warning will be displayed and according borders won't be denoised.
  3757. Default value is @var{blocksize}-1, which is the best possible setting.
  3758. @item expr, e
  3759. Set the coefficient factor expression.
  3760. For each coefficient of a DCT block, this expression will be evaluated as a
  3761. multiplier value for the coefficient.
  3762. If this is option is set, the @option{sigma} option will be ignored.
  3763. The absolute value of the coefficient can be accessed through the @var{c}
  3764. variable.
  3765. @item n
  3766. Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
  3767. @var{blocksize}, which is the width and height of the processed blocks.
  3768. The default value is @var{3} (8x8) and can be raised to @var{4} for a
  3769. @var{blocksize} of 16x16. Note that changing this setting has huge consequences
  3770. on the speed processing. Also, a larger block size does not necessarily means a
  3771. better de-noising.
  3772. @end table
  3773. @subsection Examples
  3774. Apply a denoise with a @option{sigma} of @code{4.5}:
  3775. @example
  3776. dctdnoiz=4.5
  3777. @end example
  3778. The same operation can be achieved using the expression system:
  3779. @example
  3780. dctdnoiz=e='gte(c, 4.5*3)'
  3781. @end example
  3782. Violent denoise using a block size of @code{16x16}:
  3783. @example
  3784. dctdnoiz=15:n=4
  3785. @end example
  3786. @section deband
  3787. Remove banding artifacts from input video.
  3788. It works by replacing banded pixels with average value of referenced pixels.
  3789. The filter accepts the following options:
  3790. @table @option
  3791. @item 1thr
  3792. @item 2thr
  3793. @item 3thr
  3794. @item 4thr
  3795. Set banding detection threshold for each plane. Default is 0.02.
  3796. Valid range is 0.00003 to 0.5.
  3797. If difference between current pixel and reference pixel is less than threshold,
  3798. it will be considered as banded.
  3799. @item range, r
  3800. Banding detection range in pixels. Default is 16. If positive, random number
  3801. in range 0 to set value will be used. If negative, exact absolute value
  3802. will be used.
  3803. The range defines square of four pixels around current pixel.
  3804. @item direction, d
  3805. Set direction in radians from which four pixel will be compared. If positive,
  3806. random direction from 0 to set direction will be picked. If negative, exact of
  3807. absolute value will be picked. For example direction 0, -PI or -2*PI radians
  3808. will pick only pixels on same row and -PI/2 will pick only pixels on same
  3809. column.
  3810. @item blur
  3811. If enabled, current pixel is compared with average value of all four
  3812. surrounding pixels. The default is enabled. If disabled current pixel is
  3813. compared with all four surrounding pixels. The pixel is considered banded
  3814. if only all four differences with surrounding pixels are less than threshold.
  3815. @end table
  3816. @anchor{decimate}
  3817. @section decimate
  3818. Drop duplicated frames at regular intervals.
  3819. The filter accepts the following options:
  3820. @table @option
  3821. @item cycle
  3822. Set the number of frames from which one will be dropped. Setting this to
  3823. @var{N} means one frame in every batch of @var{N} frames will be dropped.
  3824. Default is @code{5}.
  3825. @item dupthresh
  3826. Set the threshold for duplicate detection. If the difference metric for a frame
  3827. is less than or equal to this value, then it is declared as duplicate. Default
  3828. is @code{1.1}
  3829. @item scthresh
  3830. Set scene change threshold. Default is @code{15}.
  3831. @item blockx
  3832. @item blocky
  3833. Set the size of the x and y-axis blocks used during metric calculations.
  3834. Larger blocks give better noise suppression, but also give worse detection of
  3835. small movements. Must be a power of two. Default is @code{32}.
  3836. @item ppsrc
  3837. Mark main input as a pre-processed input and activate clean source input
  3838. stream. This allows the input to be pre-processed with various filters to help
  3839. the metrics calculation while keeping the frame selection lossless. When set to
  3840. @code{1}, the first stream is for the pre-processed input, and the second
  3841. stream is the clean source from where the kept frames are chosen. Default is
  3842. @code{0}.
  3843. @item chroma
  3844. Set whether or not chroma is considered in the metric calculations. Default is
  3845. @code{1}.
  3846. @end table
  3847. @section deflate
  3848. Apply deflate effect to the video.
  3849. This filter replaces the pixel by the local(3x3) average by taking into account
  3850. only values lower than the pixel.
  3851. It accepts the following options:
  3852. @table @option
  3853. @item threshold0
  3854. @item threshold1
  3855. @item threshold2
  3856. @item threshold3
  3857. Limit the maximum change for each plane, default is 65535.
  3858. If 0, plane will remain unchanged.
  3859. @end table
  3860. @section dejudder
  3861. Remove judder produced by partially interlaced telecined content.
  3862. Judder can be introduced, for instance, by @ref{pullup} filter. If the original
  3863. source was partially telecined content then the output of @code{pullup,dejudder}
  3864. will have a variable frame rate. May change the recorded frame rate of the
  3865. container. Aside from that change, this filter will not affect constant frame
  3866. rate video.
  3867. The option available in this filter is:
  3868. @table @option
  3869. @item cycle
  3870. Specify the length of the window over which the judder repeats.
  3871. Accepts any integer greater than 1. Useful values are:
  3872. @table @samp
  3873. @item 4
  3874. If the original was telecined from 24 to 30 fps (Film to NTSC).
  3875. @item 5
  3876. If the original was telecined from 25 to 30 fps (PAL to NTSC).
  3877. @item 20
  3878. If a mixture of the two.
  3879. @end table
  3880. The default is @samp{4}.
  3881. @end table
  3882. @section delogo
  3883. Suppress a TV station logo by a simple interpolation of the surrounding
  3884. pixels. Just set a rectangle covering the logo and watch it disappear
  3885. (and sometimes something even uglier appear - your mileage may vary).
  3886. It accepts the following parameters:
  3887. @table @option
  3888. @item x
  3889. @item y
  3890. Specify the top left corner coordinates of the logo. They must be
  3891. specified.
  3892. @item w
  3893. @item h
  3894. Specify the width and height of the logo to clear. They must be
  3895. specified.
  3896. @item band, t
  3897. Specify the thickness of the fuzzy edge of the rectangle (added to
  3898. @var{w} and @var{h}). The default value is 1. This option is
  3899. deprecated, setting higher values should no longer be necessary and
  3900. is not recommended.
  3901. @item show
  3902. When set to 1, a green rectangle is drawn on the screen to simplify
  3903. finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
  3904. The default value is 0.
  3905. The rectangle is drawn on the outermost pixels which will be (partly)
  3906. replaced with interpolated values. The values of the next pixels
  3907. immediately outside this rectangle in each direction will be used to
  3908. compute the interpolated pixel values inside the rectangle.
  3909. @end table
  3910. @subsection Examples
  3911. @itemize
  3912. @item
  3913. Set a rectangle covering the area with top left corner coordinates 0,0
  3914. and size 100x77, and a band of size 10:
  3915. @example
  3916. delogo=x=0:y=0:w=100:h=77:band=10
  3917. @end example
  3918. @end itemize
  3919. @section deshake
  3920. Attempt to fix small changes in horizontal and/or vertical shift. This
  3921. filter helps remove camera shake from hand-holding a camera, bumping a
  3922. tripod, moving on a vehicle, etc.
  3923. The filter accepts the following options:
  3924. @table @option
  3925. @item x
  3926. @item y
  3927. @item w
  3928. @item h
  3929. Specify a rectangular area where to limit the search for motion
  3930. vectors.
  3931. If desired the search for motion vectors can be limited to a
  3932. rectangular area of the frame defined by its top left corner, width
  3933. and height. These parameters have the same meaning as the drawbox
  3934. filter which can be used to visualise the position of the bounding
  3935. box.
  3936. This is useful when simultaneous movement of subjects within the frame
  3937. might be confused for camera motion by the motion vector search.
  3938. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  3939. then the full frame is used. This allows later options to be set
  3940. without specifying the bounding box for the motion vector search.
  3941. Default - search the whole frame.
  3942. @item rx
  3943. @item ry
  3944. Specify the maximum extent of movement in x and y directions in the
  3945. range 0-64 pixels. Default 16.
  3946. @item edge
  3947. Specify how to generate pixels to fill blanks at the edge of the
  3948. frame. Available values are:
  3949. @table @samp
  3950. @item blank, 0
  3951. Fill zeroes at blank locations
  3952. @item original, 1
  3953. Original image at blank locations
  3954. @item clamp, 2
  3955. Extruded edge value at blank locations
  3956. @item mirror, 3
  3957. Mirrored edge at blank locations
  3958. @end table
  3959. Default value is @samp{mirror}.
  3960. @item blocksize
  3961. Specify the blocksize to use for motion search. Range 4-128 pixels,
  3962. default 8.
  3963. @item contrast
  3964. Specify the contrast threshold for blocks. Only blocks with more than
  3965. the specified contrast (difference between darkest and lightest
  3966. pixels) will be considered. Range 1-255, default 125.
  3967. @item search
  3968. Specify the search strategy. Available values are:
  3969. @table @samp
  3970. @item exhaustive, 0
  3971. Set exhaustive search
  3972. @item less, 1
  3973. Set less exhaustive search.
  3974. @end table
  3975. Default value is @samp{exhaustive}.
  3976. @item filename
  3977. If set then a detailed log of the motion search is written to the
  3978. specified file.
  3979. @item opencl
  3980. If set to 1, specify using OpenCL capabilities, only available if
  3981. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  3982. @end table
  3983. @section detelecine
  3984. Apply an exact inverse of the telecine operation. It requires a predefined
  3985. pattern specified using the pattern option which must be the same as that passed
  3986. to the telecine filter.
  3987. This filter accepts the following options:
  3988. @table @option
  3989. @item first_field
  3990. @table @samp
  3991. @item top, t
  3992. top field first
  3993. @item bottom, b
  3994. bottom field first
  3995. The default value is @code{top}.
  3996. @end table
  3997. @item pattern
  3998. A string of numbers representing the pulldown pattern you wish to apply.
  3999. The default value is @code{23}.
  4000. @item start_frame
  4001. A number representing position of the first frame with respect to the telecine
  4002. pattern. This is to be used if the stream is cut. The default value is @code{0}.
  4003. @end table
  4004. @section dilation
  4005. Apply dilation effect to the video.
  4006. This filter replaces the pixel by the local(3x3) maximum.
  4007. It accepts the following options:
  4008. @table @option
  4009. @item threshold0
  4010. @item threshold1
  4011. @item threshold2
  4012. @item threshold3
  4013. Limit the maximum change for each plane, default is 65535.
  4014. If 0, plane will remain unchanged.
  4015. @item coordinates
  4016. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  4017. pixels are used.
  4018. Flags to local 3x3 coordinates maps like this:
  4019. 1 2 3
  4020. 4 5
  4021. 6 7 8
  4022. @end table
  4023. @section displace
  4024. Displace pixels as indicated by second and third input stream.
  4025. It takes three input streams and outputs one stream, the first input is the
  4026. source, and second and third input are displacement maps.
  4027. The second input specifies how much to displace pixels along the
  4028. x-axis, while the third input specifies how much to displace pixels
  4029. along the y-axis.
  4030. If one of displacement map streams terminates, last frame from that
  4031. displacement map will be used.
  4032. Note that once generated, displacements maps can be reused over and over again.
  4033. A description of the accepted options follows.
  4034. @table @option
  4035. @item edge
  4036. Set displace behavior for pixels that are out of range.
  4037. Available values are:
  4038. @table @samp
  4039. @item blank
  4040. Missing pixels are replaced by black pixels.
  4041. @item smear
  4042. Adjacent pixels will spread out to replace missing pixels.
  4043. @item wrap
  4044. Out of range pixels are wrapped so they point to pixels of other side.
  4045. @end table
  4046. Default is @samp{smear}.
  4047. @end table
  4048. @subsection Examples
  4049. @itemize
  4050. @item
  4051. Add ripple effect to rgb input of video size hd720:
  4052. @example
  4053. 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
  4054. @end example
  4055. @item
  4056. Add wave effect to rgb input of video size hd720:
  4057. @example
  4058. 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
  4059. @end example
  4060. @end itemize
  4061. @section drawbox
  4062. Draw a colored box on the input image.
  4063. It accepts the following parameters:
  4064. @table @option
  4065. @item x
  4066. @item y
  4067. The expressions which specify the top left corner coordinates of the box. It defaults to 0.
  4068. @item width, w
  4069. @item height, h
  4070. The expressions which specify the width and height of the box; if 0 they are interpreted as
  4071. the input width and height. It defaults to 0.
  4072. @item color, c
  4073. Specify the color of the box to write. For the general syntax of this option,
  4074. check the "Color" section in the ffmpeg-utils manual. If the special
  4075. value @code{invert} is used, the box edge color is the same as the
  4076. video with inverted luma.
  4077. @item thickness, t
  4078. The expression which sets the thickness of the box edge. Default value is @code{3}.
  4079. See below for the list of accepted constants.
  4080. @end table
  4081. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  4082. following constants:
  4083. @table @option
  4084. @item dar
  4085. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  4086. @item hsub
  4087. @item vsub
  4088. horizontal and vertical chroma subsample values. For example for the
  4089. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4090. @item in_h, ih
  4091. @item in_w, iw
  4092. The input width and height.
  4093. @item sar
  4094. The input sample aspect ratio.
  4095. @item x
  4096. @item y
  4097. The x and y offset coordinates where the box is drawn.
  4098. @item w
  4099. @item h
  4100. The width and height of the drawn box.
  4101. @item t
  4102. The thickness of the drawn box.
  4103. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  4104. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  4105. @end table
  4106. @subsection Examples
  4107. @itemize
  4108. @item
  4109. Draw a black box around the edge of the input image:
  4110. @example
  4111. drawbox
  4112. @end example
  4113. @item
  4114. Draw a box with color red and an opacity of 50%:
  4115. @example
  4116. drawbox=10:20:200:60:red@@0.5
  4117. @end example
  4118. The previous example can be specified as:
  4119. @example
  4120. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  4121. @end example
  4122. @item
  4123. Fill the box with pink color:
  4124. @example
  4125. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  4126. @end example
  4127. @item
  4128. Draw a 2-pixel red 2.40:1 mask:
  4129. @example
  4130. 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
  4131. @end example
  4132. @end itemize
  4133. @section drawgraph, adrawgraph
  4134. Draw a graph using input video or audio metadata.
  4135. It accepts the following parameters:
  4136. @table @option
  4137. @item m1
  4138. Set 1st frame metadata key from which metadata values will be used to draw a graph.
  4139. @item fg1
  4140. Set 1st foreground color expression.
  4141. @item m2
  4142. Set 2nd frame metadata key from which metadata values will be used to draw a graph.
  4143. @item fg2
  4144. Set 2nd foreground color expression.
  4145. @item m3
  4146. Set 3rd frame metadata key from which metadata values will be used to draw a graph.
  4147. @item fg3
  4148. Set 3rd foreground color expression.
  4149. @item m4
  4150. Set 4th frame metadata key from which metadata values will be used to draw a graph.
  4151. @item fg4
  4152. Set 4th foreground color expression.
  4153. @item min
  4154. Set minimal value of metadata value.
  4155. @item max
  4156. Set maximal value of metadata value.
  4157. @item bg
  4158. Set graph background color. Default is white.
  4159. @item mode
  4160. Set graph mode.
  4161. Available values for mode is:
  4162. @table @samp
  4163. @item bar
  4164. @item dot
  4165. @item line
  4166. @end table
  4167. Default is @code{line}.
  4168. @item slide
  4169. Set slide mode.
  4170. Available values for slide is:
  4171. @table @samp
  4172. @item frame
  4173. Draw new frame when right border is reached.
  4174. @item replace
  4175. Replace old columns with new ones.
  4176. @item scroll
  4177. Scroll from right to left.
  4178. @item rscroll
  4179. Scroll from left to right.
  4180. @end table
  4181. Default is @code{frame}.
  4182. @item size
  4183. Set size of graph video. For the syntax of this option, check the
  4184. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  4185. The default value is @code{900x256}.
  4186. The foreground color expressions can use the following variables:
  4187. @table @option
  4188. @item MIN
  4189. Minimal value of metadata value.
  4190. @item MAX
  4191. Maximal value of metadata value.
  4192. @item VAL
  4193. Current metadata key value.
  4194. @end table
  4195. The color is defined as 0xAABBGGRR.
  4196. @end table
  4197. Example using metadata from @ref{signalstats} filter:
  4198. @example
  4199. signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255
  4200. @end example
  4201. Example using metadata from @ref{ebur128} filter:
  4202. @example
  4203. ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5
  4204. @end example
  4205. @section drawgrid
  4206. Draw a grid on the input image.
  4207. It accepts the following parameters:
  4208. @table @option
  4209. @item x
  4210. @item y
  4211. The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
  4212. @item width, w
  4213. @item height, h
  4214. The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
  4215. input width and height, respectively, minus @code{thickness}, so image gets
  4216. framed. Default to 0.
  4217. @item color, c
  4218. Specify the color of the grid. For the general syntax of this option,
  4219. check the "Color" section in the ffmpeg-utils manual. If the special
  4220. value @code{invert} is used, the grid color is the same as the
  4221. video with inverted luma.
  4222. @item thickness, t
  4223. The expression which sets the thickness of the grid line. Default value is @code{1}.
  4224. See below for the list of accepted constants.
  4225. @end table
  4226. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  4227. following constants:
  4228. @table @option
  4229. @item dar
  4230. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  4231. @item hsub
  4232. @item vsub
  4233. horizontal and vertical chroma subsample values. For example for the
  4234. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4235. @item in_h, ih
  4236. @item in_w, iw
  4237. The input grid cell width and height.
  4238. @item sar
  4239. The input sample aspect ratio.
  4240. @item x
  4241. @item y
  4242. The x and y coordinates of some point of grid intersection (meant to configure offset).
  4243. @item w
  4244. @item h
  4245. The width and height of the drawn cell.
  4246. @item t
  4247. The thickness of the drawn cell.
  4248. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  4249. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  4250. @end table
  4251. @subsection Examples
  4252. @itemize
  4253. @item
  4254. Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
  4255. @example
  4256. drawgrid=width=100:height=100:thickness=2:color=red@@0.5
  4257. @end example
  4258. @item
  4259. Draw a white 3x3 grid with an opacity of 50%:
  4260. @example
  4261. drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
  4262. @end example
  4263. @end itemize
  4264. @anchor{drawtext}
  4265. @section drawtext
  4266. Draw a text string or text from a specified file on top of a video, using the
  4267. libfreetype library.
  4268. To enable compilation of this filter, you need to configure FFmpeg with
  4269. @code{--enable-libfreetype}.
  4270. To enable default font fallback and the @var{font} option you need to
  4271. configure FFmpeg with @code{--enable-libfontconfig}.
  4272. To enable the @var{text_shaping} option, you need to configure FFmpeg with
  4273. @code{--enable-libfribidi}.
  4274. @subsection Syntax
  4275. It accepts the following parameters:
  4276. @table @option
  4277. @item box
  4278. Used to draw a box around text using the background color.
  4279. The value must be either 1 (enable) or 0 (disable).
  4280. The default value of @var{box} is 0.
  4281. @item boxborderw
  4282. Set the width of the border to be drawn around the box using @var{boxcolor}.
  4283. The default value of @var{boxborderw} is 0.
  4284. @item boxcolor
  4285. The color to be used for drawing box around text. For the syntax of this
  4286. option, check the "Color" section in the ffmpeg-utils manual.
  4287. The default value of @var{boxcolor} is "white".
  4288. @item borderw
  4289. Set the width of the border to be drawn around the text using @var{bordercolor}.
  4290. The default value of @var{borderw} is 0.
  4291. @item bordercolor
  4292. Set the color to be used for drawing border around text. For the syntax of this
  4293. option, check the "Color" section in the ffmpeg-utils manual.
  4294. The default value of @var{bordercolor} is "black".
  4295. @item expansion
  4296. Select how the @var{text} is expanded. Can be either @code{none},
  4297. @code{strftime} (deprecated) or
  4298. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  4299. below for details.
  4300. @item fix_bounds
  4301. If true, check and fix text coords to avoid clipping.
  4302. @item fontcolor
  4303. The color to be used for drawing fonts. For the syntax of this option, check
  4304. the "Color" section in the ffmpeg-utils manual.
  4305. The default value of @var{fontcolor} is "black".
  4306. @item fontcolor_expr
  4307. String which is expanded the same way as @var{text} to obtain dynamic
  4308. @var{fontcolor} value. By default this option has empty value and is not
  4309. processed. When this option is set, it overrides @var{fontcolor} option.
  4310. @item font
  4311. The font family to be used for drawing text. By default Sans.
  4312. @item fontfile
  4313. The font file to be used for drawing text. The path must be included.
  4314. This parameter is mandatory if the fontconfig support is disabled.
  4315. @item draw
  4316. This option does not exist, please see the timeline system
  4317. @item alpha
  4318. Draw the text applying alpha blending. The value can
  4319. be either a number between 0.0 and 1.0
  4320. The expression accepts the same variables @var{x, y} do.
  4321. The default value is 1.
  4322. Please see fontcolor_expr
  4323. @item fontsize
  4324. The font size to be used for drawing text.
  4325. The default value of @var{fontsize} is 16.
  4326. @item text_shaping
  4327. If set to 1, attempt to shape the text (for example, reverse the order of
  4328. right-to-left text and join Arabic characters) before drawing it.
  4329. Otherwise, just draw the text exactly as given.
  4330. By default 1 (if supported).
  4331. @item ft_load_flags
  4332. The flags to be used for loading the fonts.
  4333. The flags map the corresponding flags supported by libfreetype, and are
  4334. a combination of the following values:
  4335. @table @var
  4336. @item default
  4337. @item no_scale
  4338. @item no_hinting
  4339. @item render
  4340. @item no_bitmap
  4341. @item vertical_layout
  4342. @item force_autohint
  4343. @item crop_bitmap
  4344. @item pedantic
  4345. @item ignore_global_advance_width
  4346. @item no_recurse
  4347. @item ignore_transform
  4348. @item monochrome
  4349. @item linear_design
  4350. @item no_autohint
  4351. @end table
  4352. Default value is "default".
  4353. For more information consult the documentation for the FT_LOAD_*
  4354. libfreetype flags.
  4355. @item shadowcolor
  4356. The color to be used for drawing a shadow behind the drawn text. For the
  4357. syntax of this option, check the "Color" section in the ffmpeg-utils manual.
  4358. The default value of @var{shadowcolor} is "black".
  4359. @item shadowx
  4360. @item shadowy
  4361. The x and y offsets for the text shadow position with respect to the
  4362. position of the text. They can be either positive or negative
  4363. values. The default value for both is "0".
  4364. @item start_number
  4365. The starting frame number for the n/frame_num variable. The default value
  4366. is "0".
  4367. @item tabsize
  4368. The size in number of spaces to use for rendering the tab.
  4369. Default value is 4.
  4370. @item timecode
  4371. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  4372. format. It can be used with or without text parameter. @var{timecode_rate}
  4373. option must be specified.
  4374. @item timecode_rate, rate, r
  4375. Set the timecode frame rate (timecode only).
  4376. @item text
  4377. The text string to be drawn. The text must be a sequence of UTF-8
  4378. encoded characters.
  4379. This parameter is mandatory if no file is specified with the parameter
  4380. @var{textfile}.
  4381. @item textfile
  4382. A text file containing text to be drawn. The text must be a sequence
  4383. of UTF-8 encoded characters.
  4384. This parameter is mandatory if no text string is specified with the
  4385. parameter @var{text}.
  4386. If both @var{text} and @var{textfile} are specified, an error is thrown.
  4387. @item reload
  4388. If set to 1, the @var{textfile} will be reloaded before each frame.
  4389. Be sure to update it atomically, or it may be read partially, or even fail.
  4390. @item x
  4391. @item y
  4392. The expressions which specify the offsets where text will be drawn
  4393. within the video frame. They are relative to the top/left border of the
  4394. output image.
  4395. The default value of @var{x} and @var{y} is "0".
  4396. See below for the list of accepted constants and functions.
  4397. @end table
  4398. The parameters for @var{x} and @var{y} are expressions containing the
  4399. following constants and functions:
  4400. @table @option
  4401. @item dar
  4402. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  4403. @item hsub
  4404. @item vsub
  4405. horizontal and vertical chroma subsample values. For example for the
  4406. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4407. @item line_h, lh
  4408. the height of each text line
  4409. @item main_h, h, H
  4410. the input height
  4411. @item main_w, w, W
  4412. the input width
  4413. @item max_glyph_a, ascent
  4414. the maximum distance from the baseline to the highest/upper grid
  4415. coordinate used to place a glyph outline point, for all the rendered
  4416. glyphs.
  4417. It is a positive value, due to the grid's orientation with the Y axis
  4418. upwards.
  4419. @item max_glyph_d, descent
  4420. the maximum distance from the baseline to the lowest grid coordinate
  4421. used to place a glyph outline point, for all the rendered glyphs.
  4422. This is a negative value, due to the grid's orientation, with the Y axis
  4423. upwards.
  4424. @item max_glyph_h
  4425. maximum glyph height, that is the maximum height for all the glyphs
  4426. contained in the rendered text, it is equivalent to @var{ascent} -
  4427. @var{descent}.
  4428. @item max_glyph_w
  4429. maximum glyph width, that is the maximum width for all the glyphs
  4430. contained in the rendered text
  4431. @item n
  4432. the number of input frame, starting from 0
  4433. @item rand(min, max)
  4434. return a random number included between @var{min} and @var{max}
  4435. @item sar
  4436. The input sample aspect ratio.
  4437. @item t
  4438. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4439. @item text_h, th
  4440. the height of the rendered text
  4441. @item text_w, tw
  4442. the width of the rendered text
  4443. @item x
  4444. @item y
  4445. the x and y offset coordinates where the text is drawn.
  4446. These parameters allow the @var{x} and @var{y} expressions to refer
  4447. each other, so you can for example specify @code{y=x/dar}.
  4448. @end table
  4449. @anchor{drawtext_expansion}
  4450. @subsection Text expansion
  4451. If @option{expansion} is set to @code{strftime},
  4452. the filter recognizes strftime() sequences in the provided text and
  4453. expands them accordingly. Check the documentation of strftime(). This
  4454. feature is deprecated.
  4455. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  4456. If @option{expansion} is set to @code{normal} (which is the default),
  4457. the following expansion mechanism is used.
  4458. The backslash character @samp{\}, followed by any character, always expands to
  4459. the second character.
  4460. Sequence of the form @code{%@{...@}} are expanded. The text between the
  4461. braces is a function name, possibly followed by arguments separated by ':'.
  4462. If the arguments contain special characters or delimiters (':' or '@}'),
  4463. they should be escaped.
  4464. Note that they probably must also be escaped as the value for the
  4465. @option{text} option in the filter argument string and as the filter
  4466. argument in the filtergraph description, and possibly also for the shell,
  4467. that makes up to four levels of escaping; using a text file avoids these
  4468. problems.
  4469. The following functions are available:
  4470. @table @command
  4471. @item expr, e
  4472. The expression evaluation result.
  4473. It must take one argument specifying the expression to be evaluated,
  4474. which accepts the same constants and functions as the @var{x} and
  4475. @var{y} values. Note that not all constants should be used, for
  4476. example the text size is not known when evaluating the expression, so
  4477. the constants @var{text_w} and @var{text_h} will have an undefined
  4478. value.
  4479. @item expr_int_format, eif
  4480. Evaluate the expression's value and output as formatted integer.
  4481. The first argument is the expression to be evaluated, just as for the @var{expr} function.
  4482. The second argument specifies the output format. Allowed values are @samp{x},
  4483. @samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
  4484. @code{printf} function.
  4485. The third parameter is optional and sets the number of positions taken by the output.
  4486. It can be used to add padding with zeros from the left.
  4487. @item gmtime
  4488. The time at which the filter is running, expressed in UTC.
  4489. It can accept an argument: a strftime() format string.
  4490. @item localtime
  4491. The time at which the filter is running, expressed in the local time zone.
  4492. It can accept an argument: a strftime() format string.
  4493. @item metadata
  4494. Frame metadata. It must take one argument specifying metadata key.
  4495. @item n, frame_num
  4496. The frame number, starting from 0.
  4497. @item pict_type
  4498. A 1 character description of the current picture type.
  4499. @item pts
  4500. The timestamp of the current frame.
  4501. It can take up to three arguments.
  4502. The first argument is the format of the timestamp; it defaults to @code{flt}
  4503. for seconds as a decimal number with microsecond accuracy; @code{hms} stands
  4504. for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
  4505. @code{gmtime} stands for the timestamp of the frame formatted as UTC time;
  4506. @code{localtime} stands for the timestamp of the frame formatted as
  4507. local time zone time.
  4508. The second argument is an offset added to the timestamp.
  4509. If the format is set to @code{localtime} or @code{gmtime},
  4510. a third argument may be supplied: a strftime() format string.
  4511. By default, @var{YYYY-MM-DD HH:MM:SS} format will be used.
  4512. @end table
  4513. @subsection Examples
  4514. @itemize
  4515. @item
  4516. Draw "Test Text" with font FreeSerif, using the default values for the
  4517. optional parameters.
  4518. @example
  4519. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  4520. @end example
  4521. @item
  4522. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  4523. and y=50 (counting from the top-left corner of the screen), text is
  4524. yellow with a red box around it. Both the text and the box have an
  4525. opacity of 20%.
  4526. @example
  4527. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  4528. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  4529. @end example
  4530. Note that the double quotes are not necessary if spaces are not used
  4531. within the parameter list.
  4532. @item
  4533. Show the text at the center of the video frame:
  4534. @example
  4535. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2"
  4536. @end example
  4537. @item
  4538. Show a text line sliding from right to left in the last row of the video
  4539. frame. The file @file{LONG_LINE} is assumed to contain a single line
  4540. with no newlines.
  4541. @example
  4542. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  4543. @end example
  4544. @item
  4545. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  4546. @example
  4547. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  4548. @end example
  4549. @item
  4550. Draw a single green letter "g", at the center of the input video.
  4551. The glyph baseline is placed at half screen height.
  4552. @example
  4553. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  4554. @end example
  4555. @item
  4556. Show text for 1 second every 3 seconds:
  4557. @example
  4558. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  4559. @end example
  4560. @item
  4561. Use fontconfig to set the font. Note that the colons need to be escaped.
  4562. @example
  4563. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  4564. @end example
  4565. @item
  4566. Print the date of a real-time encoding (see strftime(3)):
  4567. @example
  4568. drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
  4569. @end example
  4570. @item
  4571. Show text fading in and out (appearing/disappearing):
  4572. @example
  4573. #!/bin/sh
  4574. DS=1.0 # display start
  4575. DE=10.0 # display end
  4576. FID=1.5 # fade in duration
  4577. FOD=5 # fade out duration
  4578. 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 @}"
  4579. @end example
  4580. @end itemize
  4581. For more information about libfreetype, check:
  4582. @url{http://www.freetype.org/}.
  4583. For more information about fontconfig, check:
  4584. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  4585. For more information about libfribidi, check:
  4586. @url{http://fribidi.org/}.
  4587. @section edgedetect
  4588. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  4589. The filter accepts the following options:
  4590. @table @option
  4591. @item low
  4592. @item high
  4593. Set low and high threshold values used by the Canny thresholding
  4594. algorithm.
  4595. The high threshold selects the "strong" edge pixels, which are then
  4596. connected through 8-connectivity with the "weak" edge pixels selected
  4597. by the low threshold.
  4598. @var{low} and @var{high} threshold values must be chosen in the range
  4599. [0,1], and @var{low} should be lesser or equal to @var{high}.
  4600. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  4601. is @code{50/255}.
  4602. @item mode
  4603. Define the drawing mode.
  4604. @table @samp
  4605. @item wires
  4606. Draw white/gray wires on black background.
  4607. @item colormix
  4608. Mix the colors to create a paint/cartoon effect.
  4609. @end table
  4610. Default value is @var{wires}.
  4611. @end table
  4612. @subsection Examples
  4613. @itemize
  4614. @item
  4615. Standard edge detection with custom values for the hysteresis thresholding:
  4616. @example
  4617. edgedetect=low=0.1:high=0.4
  4618. @end example
  4619. @item
  4620. Painting effect without thresholding:
  4621. @example
  4622. edgedetect=mode=colormix:high=0
  4623. @end example
  4624. @end itemize
  4625. @section eq
  4626. Set brightness, contrast, saturation and approximate gamma adjustment.
  4627. The filter accepts the following options:
  4628. @table @option
  4629. @item contrast
  4630. Set the contrast expression. The value must be a float value in range
  4631. @code{-2.0} to @code{2.0}. The default value is "1".
  4632. @item brightness
  4633. Set the brightness expression. The value must be a float value in
  4634. range @code{-1.0} to @code{1.0}. The default value is "0".
  4635. @item saturation
  4636. Set the saturation expression. The value must be a float in
  4637. range @code{0.0} to @code{3.0}. The default value is "1".
  4638. @item gamma
  4639. Set the gamma expression. The value must be a float in range
  4640. @code{0.1} to @code{10.0}. The default value is "1".
  4641. @item gamma_r
  4642. Set the gamma expression for red. The value must be a float in
  4643. range @code{0.1} to @code{10.0}. The default value is "1".
  4644. @item gamma_g
  4645. Set the gamma expression for green. The value must be a float in range
  4646. @code{0.1} to @code{10.0}. The default value is "1".
  4647. @item gamma_b
  4648. Set the gamma expression for blue. The value must be a float in range
  4649. @code{0.1} to @code{10.0}. The default value is "1".
  4650. @item gamma_weight
  4651. Set the gamma weight expression. It can be used to reduce the effect
  4652. of a high gamma value on bright image areas, e.g. keep them from
  4653. getting overamplified and just plain white. The value must be a float
  4654. in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
  4655. gamma correction all the way down while @code{1.0} leaves it at its
  4656. full strength. Default is "1".
  4657. @item eval
  4658. Set when the expressions for brightness, contrast, saturation and
  4659. gamma expressions are evaluated.
  4660. It accepts the following values:
  4661. @table @samp
  4662. @item init
  4663. only evaluate expressions once during the filter initialization or
  4664. when a command is processed
  4665. @item frame
  4666. evaluate expressions for each incoming frame
  4667. @end table
  4668. Default value is @samp{init}.
  4669. @end table
  4670. The expressions accept the following parameters:
  4671. @table @option
  4672. @item n
  4673. frame count of the input frame starting from 0
  4674. @item pos
  4675. byte position of the corresponding packet in the input file, NAN if
  4676. unspecified
  4677. @item r
  4678. frame rate of the input video, NAN if the input frame rate is unknown
  4679. @item t
  4680. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4681. @end table
  4682. @subsection Commands
  4683. The filter supports the following commands:
  4684. @table @option
  4685. @item contrast
  4686. Set the contrast expression.
  4687. @item brightness
  4688. Set the brightness expression.
  4689. @item saturation
  4690. Set the saturation expression.
  4691. @item gamma
  4692. Set the gamma expression.
  4693. @item gamma_r
  4694. Set the gamma_r expression.
  4695. @item gamma_g
  4696. Set gamma_g expression.
  4697. @item gamma_b
  4698. Set gamma_b expression.
  4699. @item gamma_weight
  4700. Set gamma_weight expression.
  4701. The command accepts the same syntax of the corresponding option.
  4702. If the specified expression is not valid, it is kept at its current
  4703. value.
  4704. @end table
  4705. @section erosion
  4706. Apply erosion effect to the video.
  4707. This filter replaces the pixel by the local(3x3) minimum.
  4708. It accepts the following options:
  4709. @table @option
  4710. @item threshold0
  4711. @item threshold1
  4712. @item threshold2
  4713. @item threshold3
  4714. Limit the maximum change for each plane, default is 65535.
  4715. If 0, plane will remain unchanged.
  4716. @item coordinates
  4717. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  4718. pixels are used.
  4719. Flags to local 3x3 coordinates maps like this:
  4720. 1 2 3
  4721. 4 5
  4722. 6 7 8
  4723. @end table
  4724. @section extractplanes
  4725. Extract color channel components from input video stream into
  4726. separate grayscale video streams.
  4727. The filter accepts the following option:
  4728. @table @option
  4729. @item planes
  4730. Set plane(s) to extract.
  4731. Available values for planes are:
  4732. @table @samp
  4733. @item y
  4734. @item u
  4735. @item v
  4736. @item a
  4737. @item r
  4738. @item g
  4739. @item b
  4740. @end table
  4741. Choosing planes not available in the input will result in an error.
  4742. That means you cannot select @code{r}, @code{g}, @code{b} planes
  4743. with @code{y}, @code{u}, @code{v} planes at same time.
  4744. @end table
  4745. @subsection Examples
  4746. @itemize
  4747. @item
  4748. Extract luma, u and v color channel component from input video frame
  4749. into 3 grayscale outputs:
  4750. @example
  4751. 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
  4752. @end example
  4753. @end itemize
  4754. @section elbg
  4755. Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
  4756. For each input image, the filter will compute the optimal mapping from
  4757. the input to the output given the codebook length, that is the number
  4758. of distinct output colors.
  4759. This filter accepts the following options.
  4760. @table @option
  4761. @item codebook_length, l
  4762. Set codebook length. The value must be a positive integer, and
  4763. represents the number of distinct output colors. Default value is 256.
  4764. @item nb_steps, n
  4765. Set the maximum number of iterations to apply for computing the optimal
  4766. mapping. The higher the value the better the result and the higher the
  4767. computation time. Default value is 1.
  4768. @item seed, s
  4769. Set a random seed, must be an integer included between 0 and
  4770. UINT32_MAX. If not specified, or if explicitly set to -1, the filter
  4771. will try to use a good random seed on a best effort basis.
  4772. @item pal8
  4773. Set pal8 output pixel format. This option does not work with codebook
  4774. length greater than 256.
  4775. @end table
  4776. @section fade
  4777. Apply a fade-in/out effect to the input video.
  4778. It accepts the following parameters:
  4779. @table @option
  4780. @item type, t
  4781. The effect type can be either "in" for a fade-in, or "out" for a fade-out
  4782. effect.
  4783. Default is @code{in}.
  4784. @item start_frame, s
  4785. Specify the number of the frame to start applying the fade
  4786. effect at. Default is 0.
  4787. @item nb_frames, n
  4788. The number of frames that the fade effect lasts. At the end of the
  4789. fade-in effect, the output video will have the same intensity as the input video.
  4790. At the end of the fade-out transition, the output video will be filled with the
  4791. selected @option{color}.
  4792. Default is 25.
  4793. @item alpha
  4794. If set to 1, fade only alpha channel, if one exists on the input.
  4795. Default value is 0.
  4796. @item start_time, st
  4797. Specify the timestamp (in seconds) of the frame to start to apply the fade
  4798. effect. If both start_frame and start_time are specified, the fade will start at
  4799. whichever comes last. Default is 0.
  4800. @item duration, d
  4801. The number of seconds for which the fade effect has to last. At the end of the
  4802. fade-in effect the output video will have the same intensity as the input video,
  4803. at the end of the fade-out transition the output video will be filled with the
  4804. selected @option{color}.
  4805. If both duration and nb_frames are specified, duration is used. Default is 0
  4806. (nb_frames is used by default).
  4807. @item color, c
  4808. Specify the color of the fade. Default is "black".
  4809. @end table
  4810. @subsection Examples
  4811. @itemize
  4812. @item
  4813. Fade in the first 30 frames of video:
  4814. @example
  4815. fade=in:0:30
  4816. @end example
  4817. The command above is equivalent to:
  4818. @example
  4819. fade=t=in:s=0:n=30
  4820. @end example
  4821. @item
  4822. Fade out the last 45 frames of a 200-frame video:
  4823. @example
  4824. fade=out:155:45
  4825. fade=type=out:start_frame=155:nb_frames=45
  4826. @end example
  4827. @item
  4828. Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
  4829. @example
  4830. fade=in:0:25, fade=out:975:25
  4831. @end example
  4832. @item
  4833. Make the first 5 frames yellow, then fade in from frame 5-24:
  4834. @example
  4835. fade=in:5:20:color=yellow
  4836. @end example
  4837. @item
  4838. Fade in alpha over first 25 frames of video:
  4839. @example
  4840. fade=in:0:25:alpha=1
  4841. @end example
  4842. @item
  4843. Make the first 5.5 seconds black, then fade in for 0.5 seconds:
  4844. @example
  4845. fade=t=in:st=5.5:d=0.5
  4846. @end example
  4847. @end itemize
  4848. @section fftfilt
  4849. Apply arbitrary expressions to samples in frequency domain
  4850. @table @option
  4851. @item dc_Y
  4852. Adjust the dc value (gain) of the luma plane of the image. The filter
  4853. accepts an integer value in range @code{0} to @code{1000}. The default
  4854. value is set to @code{0}.
  4855. @item dc_U
  4856. Adjust the dc value (gain) of the 1st chroma plane of the image. The
  4857. filter accepts an integer value in range @code{0} to @code{1000}. The
  4858. default value is set to @code{0}.
  4859. @item dc_V
  4860. Adjust the dc value (gain) of the 2nd chroma plane of the image. The
  4861. filter accepts an integer value in range @code{0} to @code{1000}. The
  4862. default value is set to @code{0}.
  4863. @item weight_Y
  4864. Set the frequency domain weight expression for the luma plane.
  4865. @item weight_U
  4866. Set the frequency domain weight expression for the 1st chroma plane.
  4867. @item weight_V
  4868. Set the frequency domain weight expression for the 2nd chroma plane.
  4869. The filter accepts the following variables:
  4870. @item X
  4871. @item Y
  4872. The coordinates of the current sample.
  4873. @item W
  4874. @item H
  4875. The width and height of the image.
  4876. @end table
  4877. @subsection Examples
  4878. @itemize
  4879. @item
  4880. High-pass:
  4881. @example
  4882. fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
  4883. @end example
  4884. @item
  4885. Low-pass:
  4886. @example
  4887. fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
  4888. @end example
  4889. @item
  4890. Sharpen:
  4891. @example
  4892. fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
  4893. @end example
  4894. @end itemize
  4895. @section field
  4896. Extract a single field from an interlaced image using stride
  4897. arithmetic to avoid wasting CPU time. The output frames are marked as
  4898. non-interlaced.
  4899. The filter accepts the following options:
  4900. @table @option
  4901. @item type
  4902. Specify whether to extract the top (if the value is @code{0} or
  4903. @code{top}) or the bottom field (if the value is @code{1} or
  4904. @code{bottom}).
  4905. @end table
  4906. @section fieldmatch
  4907. Field matching filter for inverse telecine. It is meant to reconstruct the
  4908. progressive frames from a telecined stream. The filter does not drop duplicated
  4909. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  4910. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  4911. The separation of the field matching and the decimation is notably motivated by
  4912. the possibility of inserting a de-interlacing filter fallback between the two.
  4913. If the source has mixed telecined and real interlaced content,
  4914. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  4915. But these remaining combed frames will be marked as interlaced, and thus can be
  4916. de-interlaced by a later filter such as @ref{yadif} before decimation.
  4917. In addition to the various configuration options, @code{fieldmatch} can take an
  4918. optional second stream, activated through the @option{ppsrc} option. If
  4919. enabled, the frames reconstruction will be based on the fields and frames from
  4920. this second stream. This allows the first input to be pre-processed in order to
  4921. help the various algorithms of the filter, while keeping the output lossless
  4922. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  4923. or brightness/contrast adjustments can help.
  4924. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  4925. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  4926. which @code{fieldmatch} is based on. While the semantic and usage are very
  4927. close, some behaviour and options names can differ.
  4928. The @ref{decimate} filter currently only works for constant frame rate input.
  4929. If your input has mixed telecined (30fps) and progressive content with a lower
  4930. framerate like 24fps use the following filterchain to produce the necessary cfr
  4931. stream: @code{dejudder,fps=30000/1001,fieldmatch,decimate}.
  4932. The filter accepts the following options:
  4933. @table @option
  4934. @item order
  4935. Specify the assumed field order of the input stream. Available values are:
  4936. @table @samp
  4937. @item auto
  4938. Auto detect parity (use FFmpeg's internal parity value).
  4939. @item bff
  4940. Assume bottom field first.
  4941. @item tff
  4942. Assume top field first.
  4943. @end table
  4944. Note that it is sometimes recommended not to trust the parity announced by the
  4945. stream.
  4946. Default value is @var{auto}.
  4947. @item mode
  4948. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  4949. sense that it won't risk creating jerkiness due to duplicate frames when
  4950. possible, but if there are bad edits or blended fields it will end up
  4951. outputting combed frames when a good match might actually exist. On the other
  4952. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  4953. but will almost always find a good frame if there is one. The other values are
  4954. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  4955. jerkiness and creating duplicate frames versus finding good matches in sections
  4956. with bad edits, orphaned fields, blended fields, etc.
  4957. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  4958. Available values are:
  4959. @table @samp
  4960. @item pc
  4961. 2-way matching (p/c)
  4962. @item pc_n
  4963. 2-way matching, and trying 3rd match if still combed (p/c + n)
  4964. @item pc_u
  4965. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  4966. @item pc_n_ub
  4967. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  4968. still combed (p/c + n + u/b)
  4969. @item pcn
  4970. 3-way matching (p/c/n)
  4971. @item pcn_ub
  4972. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  4973. detected as combed (p/c/n + u/b)
  4974. @end table
  4975. The parenthesis at the end indicate the matches that would be used for that
  4976. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  4977. @var{top}).
  4978. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  4979. the slowest.
  4980. Default value is @var{pc_n}.
  4981. @item ppsrc
  4982. Mark the main input stream as a pre-processed input, and enable the secondary
  4983. input stream as the clean source to pick the fields from. See the filter
  4984. introduction for more details. It is similar to the @option{clip2} feature from
  4985. VFM/TFM.
  4986. Default value is @code{0} (disabled).
  4987. @item field
  4988. Set the field to match from. It is recommended to set this to the same value as
  4989. @option{order} unless you experience matching failures with that setting. In
  4990. certain circumstances changing the field that is used to match from can have a
  4991. large impact on matching performance. Available values are:
  4992. @table @samp
  4993. @item auto
  4994. Automatic (same value as @option{order}).
  4995. @item bottom
  4996. Match from the bottom field.
  4997. @item top
  4998. Match from the top field.
  4999. @end table
  5000. Default value is @var{auto}.
  5001. @item mchroma
  5002. Set whether or not chroma is included during the match comparisons. In most
  5003. cases it is recommended to leave this enabled. You should set this to @code{0}
  5004. only if your clip has bad chroma problems such as heavy rainbowing or other
  5005. artifacts. Setting this to @code{0} could also be used to speed things up at
  5006. the cost of some accuracy.
  5007. Default value is @code{1}.
  5008. @item y0
  5009. @item y1
  5010. These define an exclusion band which excludes the lines between @option{y0} and
  5011. @option{y1} from being included in the field matching decision. An exclusion
  5012. band can be used to ignore subtitles, a logo, or other things that may
  5013. interfere with the matching. @option{y0} sets the starting scan line and
  5014. @option{y1} sets the ending line; all lines in between @option{y0} and
  5015. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  5016. @option{y0} and @option{y1} to the same value will disable the feature.
  5017. @option{y0} and @option{y1} defaults to @code{0}.
  5018. @item scthresh
  5019. Set the scene change detection threshold as a percentage of maximum change on
  5020. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  5021. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  5022. @option{scthresh} is @code{[0.0, 100.0]}.
  5023. Default value is @code{12.0}.
  5024. @item combmatch
  5025. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  5026. account the combed scores of matches when deciding what match to use as the
  5027. final match. Available values are:
  5028. @table @samp
  5029. @item none
  5030. No final matching based on combed scores.
  5031. @item sc
  5032. Combed scores are only used when a scene change is detected.
  5033. @item full
  5034. Use combed scores all the time.
  5035. @end table
  5036. Default is @var{sc}.
  5037. @item combdbg
  5038. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  5039. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  5040. Available values are:
  5041. @table @samp
  5042. @item none
  5043. No forced calculation.
  5044. @item pcn
  5045. Force p/c/n calculations.
  5046. @item pcnub
  5047. Force p/c/n/u/b calculations.
  5048. @end table
  5049. Default value is @var{none}.
  5050. @item cthresh
  5051. This is the area combing threshold used for combed frame detection. This
  5052. essentially controls how "strong" or "visible" combing must be to be detected.
  5053. Larger values mean combing must be more visible and smaller values mean combing
  5054. can be less visible or strong and still be detected. Valid settings are from
  5055. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  5056. be detected as combed). This is basically a pixel difference value. A good
  5057. range is @code{[8, 12]}.
  5058. Default value is @code{9}.
  5059. @item chroma
  5060. Sets whether or not chroma is considered in the combed frame decision. Only
  5061. disable this if your source has chroma problems (rainbowing, etc.) that are
  5062. causing problems for the combed frame detection with chroma enabled. Actually,
  5063. using @option{chroma}=@var{0} is usually more reliable, except for the case
  5064. where there is chroma only combing in the source.
  5065. Default value is @code{0}.
  5066. @item blockx
  5067. @item blocky
  5068. Respectively set the x-axis and y-axis size of the window used during combed
  5069. frame detection. This has to do with the size of the area in which
  5070. @option{combpel} pixels are required to be detected as combed for a frame to be
  5071. declared combed. See the @option{combpel} parameter description for more info.
  5072. Possible values are any number that is a power of 2 starting at 4 and going up
  5073. to 512.
  5074. Default value is @code{16}.
  5075. @item combpel
  5076. The number of combed pixels inside any of the @option{blocky} by
  5077. @option{blockx} size blocks on the frame for the frame to be detected as
  5078. combed. While @option{cthresh} controls how "visible" the combing must be, this
  5079. setting controls "how much" combing there must be in any localized area (a
  5080. window defined by the @option{blockx} and @option{blocky} settings) on the
  5081. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  5082. which point no frames will ever be detected as combed). This setting is known
  5083. as @option{MI} in TFM/VFM vocabulary.
  5084. Default value is @code{80}.
  5085. @end table
  5086. @anchor{p/c/n/u/b meaning}
  5087. @subsection p/c/n/u/b meaning
  5088. @subsubsection p/c/n
  5089. We assume the following telecined stream:
  5090. @example
  5091. Top fields: 1 2 2 3 4
  5092. Bottom fields: 1 2 3 4 4
  5093. @end example
  5094. The numbers correspond to the progressive frame the fields relate to. Here, the
  5095. first two frames are progressive, the 3rd and 4th are combed, and so on.
  5096. When @code{fieldmatch} is configured to run a matching from bottom
  5097. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  5098. @example
  5099. Input stream:
  5100. T 1 2 2 3 4
  5101. B 1 2 3 4 4 <-- matching reference
  5102. Matches: c c n n c
  5103. Output stream:
  5104. T 1 2 3 4 4
  5105. B 1 2 3 4 4
  5106. @end example
  5107. As a result of the field matching, we can see that some frames get duplicated.
  5108. To perform a complete inverse telecine, you need to rely on a decimation filter
  5109. after this operation. See for instance the @ref{decimate} filter.
  5110. The same operation now matching from top fields (@option{field}=@var{top})
  5111. looks like this:
  5112. @example
  5113. Input stream:
  5114. T 1 2 2 3 4 <-- matching reference
  5115. B 1 2 3 4 4
  5116. Matches: c c p p c
  5117. Output stream:
  5118. T 1 2 2 3 4
  5119. B 1 2 2 3 4
  5120. @end example
  5121. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  5122. basically, they refer to the frame and field of the opposite parity:
  5123. @itemize
  5124. @item @var{p} matches the field of the opposite parity in the previous frame
  5125. @item @var{c} matches the field of the opposite parity in the current frame
  5126. @item @var{n} matches the field of the opposite parity in the next frame
  5127. @end itemize
  5128. @subsubsection u/b
  5129. The @var{u} and @var{b} matching are a bit special in the sense that they match
  5130. from the opposite parity flag. In the following examples, we assume that we are
  5131. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  5132. 'x' is placed above and below each matched fields.
  5133. With bottom matching (@option{field}=@var{bottom}):
  5134. @example
  5135. Match: c p n b u
  5136. x x x x x
  5137. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  5138. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  5139. x x x x x
  5140. Output frames:
  5141. 2 1 2 2 2
  5142. 2 2 2 1 3
  5143. @end example
  5144. With top matching (@option{field}=@var{top}):
  5145. @example
  5146. Match: c p n b u
  5147. x x x x x
  5148. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  5149. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  5150. x x x x x
  5151. Output frames:
  5152. 2 2 2 1 2
  5153. 2 1 3 2 2
  5154. @end example
  5155. @subsection Examples
  5156. Simple IVTC of a top field first telecined stream:
  5157. @example
  5158. fieldmatch=order=tff:combmatch=none, decimate
  5159. @end example
  5160. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  5161. @example
  5162. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  5163. @end example
  5164. @section fieldorder
  5165. Transform the field order of the input video.
  5166. It accepts the following parameters:
  5167. @table @option
  5168. @item order
  5169. The output field order. Valid values are @var{tff} for top field first or @var{bff}
  5170. for bottom field first.
  5171. @end table
  5172. The default value is @samp{tff}.
  5173. The transformation is done by shifting the picture content up or down
  5174. by one line, and filling the remaining line with appropriate picture content.
  5175. This method is consistent with most broadcast field order converters.
  5176. If the input video is not flagged as being interlaced, or it is already
  5177. flagged as being of the required output field order, then this filter does
  5178. not alter the incoming video.
  5179. It is very useful when converting to or from PAL DV material,
  5180. which is bottom field first.
  5181. For example:
  5182. @example
  5183. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  5184. @end example
  5185. @section fifo, afifo
  5186. Buffer input images and send them when they are requested.
  5187. It is mainly useful when auto-inserted by the libavfilter
  5188. framework.
  5189. It does not take parameters.
  5190. @section find_rect
  5191. Find a rectangular object
  5192. It accepts the following options:
  5193. @table @option
  5194. @item object
  5195. Filepath of the object image, needs to be in gray8.
  5196. @item threshold
  5197. Detection threshold, default is 0.5.
  5198. @item mipmaps
  5199. Number of mipmaps, default is 3.
  5200. @item xmin, ymin, xmax, ymax
  5201. Specifies the rectangle in which to search.
  5202. @end table
  5203. @subsection Examples
  5204. @itemize
  5205. @item
  5206. Generate a representative palette of a given video using @command{ffmpeg}:
  5207. @example
  5208. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  5209. @end example
  5210. @end itemize
  5211. @section cover_rect
  5212. Cover a rectangular object
  5213. It accepts the following options:
  5214. @table @option
  5215. @item cover
  5216. Filepath of the optional cover image, needs to be in yuv420.
  5217. @item mode
  5218. Set covering mode.
  5219. It accepts the following values:
  5220. @table @samp
  5221. @item cover
  5222. cover it by the supplied image
  5223. @item blur
  5224. cover it by interpolating the surrounding pixels
  5225. @end table
  5226. Default value is @var{blur}.
  5227. @end table
  5228. @subsection Examples
  5229. @itemize
  5230. @item
  5231. Generate a representative palette of a given video using @command{ffmpeg}:
  5232. @example
  5233. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  5234. @end example
  5235. @end itemize
  5236. @anchor{format}
  5237. @section format
  5238. Convert the input video to one of the specified pixel formats.
  5239. Libavfilter will try to pick one that is suitable as input to
  5240. the next filter.
  5241. It accepts the following parameters:
  5242. @table @option
  5243. @item pix_fmts
  5244. A '|'-separated list of pixel format names, such as
  5245. "pix_fmts=yuv420p|monow|rgb24".
  5246. @end table
  5247. @subsection Examples
  5248. @itemize
  5249. @item
  5250. Convert the input video to the @var{yuv420p} format
  5251. @example
  5252. format=pix_fmts=yuv420p
  5253. @end example
  5254. Convert the input video to any of the formats in the list
  5255. @example
  5256. format=pix_fmts=yuv420p|yuv444p|yuv410p
  5257. @end example
  5258. @end itemize
  5259. @anchor{fps}
  5260. @section fps
  5261. Convert the video to specified constant frame rate by duplicating or dropping
  5262. frames as necessary.
  5263. It accepts the following parameters:
  5264. @table @option
  5265. @item fps
  5266. The desired output frame rate. The default is @code{25}.
  5267. @item round
  5268. Rounding method.
  5269. Possible values are:
  5270. @table @option
  5271. @item zero
  5272. zero round towards 0
  5273. @item inf
  5274. round away from 0
  5275. @item down
  5276. round towards -infinity
  5277. @item up
  5278. round towards +infinity
  5279. @item near
  5280. round to nearest
  5281. @end table
  5282. The default is @code{near}.
  5283. @item start_time
  5284. Assume the first PTS should be the given value, in seconds. This allows for
  5285. padding/trimming at the start of stream. By default, no assumption is made
  5286. about the first frame's expected PTS, so no padding or trimming is done.
  5287. For example, this could be set to 0 to pad the beginning with duplicates of
  5288. the first frame if a video stream starts after the audio stream or to trim any
  5289. frames with a negative PTS.
  5290. @end table
  5291. Alternatively, the options can be specified as a flat string:
  5292. @var{fps}[:@var{round}].
  5293. See also the @ref{setpts} filter.
  5294. @subsection Examples
  5295. @itemize
  5296. @item
  5297. A typical usage in order to set the fps to 25:
  5298. @example
  5299. fps=fps=25
  5300. @end example
  5301. @item
  5302. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  5303. @example
  5304. fps=fps=film:round=near
  5305. @end example
  5306. @end itemize
  5307. @section framepack
  5308. Pack two different video streams into a stereoscopic video, setting proper
  5309. metadata on supported codecs. The two views should have the same size and
  5310. framerate and processing will stop when the shorter video ends. Please note
  5311. that you may conveniently adjust view properties with the @ref{scale} and
  5312. @ref{fps} filters.
  5313. It accepts the following parameters:
  5314. @table @option
  5315. @item format
  5316. The desired packing format. Supported values are:
  5317. @table @option
  5318. @item sbs
  5319. The views are next to each other (default).
  5320. @item tab
  5321. The views are on top of each other.
  5322. @item lines
  5323. The views are packed by line.
  5324. @item columns
  5325. The views are packed by column.
  5326. @item frameseq
  5327. The views are temporally interleaved.
  5328. @end table
  5329. @end table
  5330. Some examples:
  5331. @example
  5332. # Convert left and right views into a frame-sequential video
  5333. ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
  5334. # Convert views into a side-by-side video with the same output resolution as the input
  5335. 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
  5336. @end example
  5337. @section framerate
  5338. Change the frame rate by interpolating new video output frames from the source
  5339. frames.
  5340. This filter is not designed to function correctly with interlaced media. If
  5341. you wish to change the frame rate of interlaced media then you are required
  5342. to deinterlace before this filter and re-interlace after this filter.
  5343. A description of the accepted options follows.
  5344. @table @option
  5345. @item fps
  5346. Specify the output frames per second. This option can also be specified
  5347. as a value alone. The default is @code{50}.
  5348. @item interp_start
  5349. Specify the start of a range where the output frame will be created as a
  5350. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  5351. the default is @code{15}.
  5352. @item interp_end
  5353. Specify the end of a range where the output frame will be created as a
  5354. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  5355. the default is @code{240}.
  5356. @item scene
  5357. Specify the level at which a scene change is detected as a value between
  5358. 0 and 100 to indicate a new scene; a low value reflects a low
  5359. probability for the current frame to introduce a new scene, while a higher
  5360. value means the current frame is more likely to be one.
  5361. The default is @code{7}.
  5362. @item flags
  5363. Specify flags influencing the filter process.
  5364. Available value for @var{flags} is:
  5365. @table @option
  5366. @item scene_change_detect, scd
  5367. Enable scene change detection using the value of the option @var{scene}.
  5368. This flag is enabled by default.
  5369. @end table
  5370. @end table
  5371. @section framestep
  5372. Select one frame every N-th frame.
  5373. This filter accepts the following option:
  5374. @table @option
  5375. @item step
  5376. Select frame after every @code{step} frames.
  5377. Allowed values are positive integers higher than 0. Default value is @code{1}.
  5378. @end table
  5379. @anchor{frei0r}
  5380. @section frei0r
  5381. Apply a frei0r effect to the input video.
  5382. To enable the compilation of this filter, you need to install the frei0r
  5383. header and configure FFmpeg with @code{--enable-frei0r}.
  5384. It accepts the following parameters:
  5385. @table @option
  5386. @item filter_name
  5387. The name of the frei0r effect to load. If the environment variable
  5388. @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
  5389. directories specified by the colon-separated list in @env{FREIOR_PATH}.
  5390. Otherwise, the standard frei0r paths are searched, in this order:
  5391. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  5392. @file{/usr/lib/frei0r-1/}.
  5393. @item filter_params
  5394. A '|'-separated list of parameters to pass to the frei0r effect.
  5395. @end table
  5396. A frei0r effect parameter can be a boolean (its value is either
  5397. "y" or "n"), a double, a color (specified as
  5398. @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
  5399. numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
  5400. section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
  5401. @var{X} and @var{Y} are floating point numbers) and/or a string.
  5402. The number and types of parameters depend on the loaded effect. If an
  5403. effect parameter is not specified, the default value is set.
  5404. @subsection Examples
  5405. @itemize
  5406. @item
  5407. Apply the distort0r effect, setting the first two double parameters:
  5408. @example
  5409. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  5410. @end example
  5411. @item
  5412. Apply the colordistance effect, taking a color as the first parameter:
  5413. @example
  5414. frei0r=colordistance:0.2/0.3/0.4
  5415. frei0r=colordistance:violet
  5416. frei0r=colordistance:0x112233
  5417. @end example
  5418. @item
  5419. Apply the perspective effect, specifying the top left and top right image
  5420. positions:
  5421. @example
  5422. frei0r=perspective:0.2/0.2|0.8/0.2
  5423. @end example
  5424. @end itemize
  5425. For more information, see
  5426. @url{http://frei0r.dyne.org}
  5427. @section fspp
  5428. Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
  5429. It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
  5430. processing filter, one of them is performed once per block, not per pixel.
  5431. This allows for much higher speed.
  5432. The filter accepts the following options:
  5433. @table @option
  5434. @item quality
  5435. Set quality. This option defines the number of levels for averaging. It accepts
  5436. an integer in the range 4-5. Default value is @code{4}.
  5437. @item qp
  5438. Force a constant quantization parameter. It accepts an integer in range 0-63.
  5439. If not set, the filter will use the QP from the video stream (if available).
  5440. @item strength
  5441. Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
  5442. more details but also more artifacts, while higher values make the image smoother
  5443. but also blurrier. Default value is @code{0} − PSNR optimal.
  5444. @item use_bframe_qp
  5445. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  5446. option may cause flicker since the B-Frames have often larger QP. Default is
  5447. @code{0} (not enabled).
  5448. @end table
  5449. @section geq
  5450. The filter accepts the following options:
  5451. @table @option
  5452. @item lum_expr, lum
  5453. Set the luminance expression.
  5454. @item cb_expr, cb
  5455. Set the chrominance blue expression.
  5456. @item cr_expr, cr
  5457. Set the chrominance red expression.
  5458. @item alpha_expr, a
  5459. Set the alpha expression.
  5460. @item red_expr, r
  5461. Set the red expression.
  5462. @item green_expr, g
  5463. Set the green expression.
  5464. @item blue_expr, b
  5465. Set the blue expression.
  5466. @end table
  5467. The colorspace is selected according to the specified options. If one
  5468. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  5469. options is specified, the filter will automatically select a YCbCr
  5470. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  5471. @option{blue_expr} options is specified, it will select an RGB
  5472. colorspace.
  5473. If one of the chrominance expression is not defined, it falls back on the other
  5474. one. If no alpha expression is specified it will evaluate to opaque value.
  5475. If none of chrominance expressions are specified, they will evaluate
  5476. to the luminance expression.
  5477. The expressions can use the following variables and functions:
  5478. @table @option
  5479. @item N
  5480. The sequential number of the filtered frame, starting from @code{0}.
  5481. @item X
  5482. @item Y
  5483. The coordinates of the current sample.
  5484. @item W
  5485. @item H
  5486. The width and height of the image.
  5487. @item SW
  5488. @item SH
  5489. Width and height scale depending on the currently filtered plane. It is the
  5490. ratio between the corresponding luma plane number of pixels and the current
  5491. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  5492. @code{0.5,0.5} for chroma planes.
  5493. @item T
  5494. Time of the current frame, expressed in seconds.
  5495. @item p(x, y)
  5496. Return the value of the pixel at location (@var{x},@var{y}) of the current
  5497. plane.
  5498. @item lum(x, y)
  5499. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  5500. plane.
  5501. @item cb(x, y)
  5502. Return the value of the pixel at location (@var{x},@var{y}) of the
  5503. blue-difference chroma plane. Return 0 if there is no such plane.
  5504. @item cr(x, y)
  5505. Return the value of the pixel at location (@var{x},@var{y}) of the
  5506. red-difference chroma plane. Return 0 if there is no such plane.
  5507. @item r(x, y)
  5508. @item g(x, y)
  5509. @item b(x, y)
  5510. Return the value of the pixel at location (@var{x},@var{y}) of the
  5511. red/green/blue component. Return 0 if there is no such component.
  5512. @item alpha(x, y)
  5513. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  5514. plane. Return 0 if there is no such plane.
  5515. @end table
  5516. For functions, if @var{x} and @var{y} are outside the area, the value will be
  5517. automatically clipped to the closer edge.
  5518. @subsection Examples
  5519. @itemize
  5520. @item
  5521. Flip the image horizontally:
  5522. @example
  5523. geq=p(W-X\,Y)
  5524. @end example
  5525. @item
  5526. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  5527. wavelength of 100 pixels:
  5528. @example
  5529. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  5530. @end example
  5531. @item
  5532. Generate a fancy enigmatic moving light:
  5533. @example
  5534. 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
  5535. @end example
  5536. @item
  5537. Generate a quick emboss effect:
  5538. @example
  5539. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  5540. @end example
  5541. @item
  5542. Modify RGB components depending on pixel position:
  5543. @example
  5544. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  5545. @end example
  5546. @item
  5547. Create a radial gradient that is the same size as the input (also see
  5548. the @ref{vignette} filter):
  5549. @example
  5550. geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
  5551. @end example
  5552. @item
  5553. Create a linear gradient to use as a mask for another filter, then
  5554. compose with @ref{overlay}. In this example the video will gradually
  5555. become more blurry from the top to the bottom of the y-axis as defined
  5556. by the linear gradient:
  5557. @example
  5558. 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
  5559. @end example
  5560. @end itemize
  5561. @section gradfun
  5562. Fix the banding artifacts that are sometimes introduced into nearly flat
  5563. regions by truncation to 8bit color depth.
  5564. Interpolate the gradients that should go where the bands are, and
  5565. dither them.
  5566. It is designed for playback only. Do not use it prior to
  5567. lossy compression, because compression tends to lose the dither and
  5568. bring back the bands.
  5569. It accepts the following parameters:
  5570. @table @option
  5571. @item strength
  5572. The maximum amount by which the filter will change any one pixel. This is also
  5573. the threshold for detecting nearly flat regions. Acceptable values range from
  5574. .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
  5575. valid range.
  5576. @item radius
  5577. The neighborhood to fit the gradient to. A larger radius makes for smoother
  5578. gradients, but also prevents the filter from modifying the pixels near detailed
  5579. regions. Acceptable values are 8-32; the default value is 16. Out-of-range
  5580. values will be clipped to the valid range.
  5581. @end table
  5582. Alternatively, the options can be specified as a flat string:
  5583. @var{strength}[:@var{radius}]
  5584. @subsection Examples
  5585. @itemize
  5586. @item
  5587. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  5588. @example
  5589. gradfun=3.5:8
  5590. @end example
  5591. @item
  5592. Specify radius, omitting the strength (which will fall-back to the default
  5593. value):
  5594. @example
  5595. gradfun=radius=8
  5596. @end example
  5597. @end itemize
  5598. @anchor{haldclut}
  5599. @section haldclut
  5600. Apply a Hald CLUT to a video stream.
  5601. First input is the video stream to process, and second one is the Hald CLUT.
  5602. The Hald CLUT input can be a simple picture or a complete video stream.
  5603. The filter accepts the following options:
  5604. @table @option
  5605. @item shortest
  5606. Force termination when the shortest input terminates. Default is @code{0}.
  5607. @item repeatlast
  5608. Continue applying the last CLUT after the end of the stream. A value of
  5609. @code{0} disable the filter after the last frame of the CLUT is reached.
  5610. Default is @code{1}.
  5611. @end table
  5612. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  5613. filters share the same internals).
  5614. More information about the Hald CLUT can be found on Eskil Steenberg's website
  5615. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  5616. @subsection Workflow examples
  5617. @subsubsection Hald CLUT video stream
  5618. Generate an identity Hald CLUT stream altered with various effects:
  5619. @example
  5620. 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
  5621. @end example
  5622. Note: make sure you use a lossless codec.
  5623. Then use it with @code{haldclut} to apply it on some random stream:
  5624. @example
  5625. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  5626. @end example
  5627. The Hald CLUT will be applied to the 10 first seconds (duration of
  5628. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  5629. to the remaining frames of the @code{mandelbrot} stream.
  5630. @subsubsection Hald CLUT with preview
  5631. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  5632. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  5633. biggest possible square starting at the top left of the picture. The remaining
  5634. padding pixels (bottom or right) will be ignored. This area can be used to add
  5635. a preview of the Hald CLUT.
  5636. Typically, the following generated Hald CLUT will be supported by the
  5637. @code{haldclut} filter:
  5638. @example
  5639. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  5640. pad=iw+320 [padded_clut];
  5641. smptebars=s=320x256, split [a][b];
  5642. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  5643. [main][b] overlay=W-320" -frames:v 1 clut.png
  5644. @end example
  5645. It contains the original and a preview of the effect of the CLUT: SMPTE color
  5646. bars are displayed on the right-top, and below the same color bars processed by
  5647. the color changes.
  5648. Then, the effect of this Hald CLUT can be visualized with:
  5649. @example
  5650. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  5651. @end example
  5652. @section hflip
  5653. Flip the input video horizontally.
  5654. For example, to horizontally flip the input video with @command{ffmpeg}:
  5655. @example
  5656. ffmpeg -i in.avi -vf "hflip" out.avi
  5657. @end example
  5658. @section histeq
  5659. This filter applies a global color histogram equalization on a
  5660. per-frame basis.
  5661. It can be used to correct video that has a compressed range of pixel
  5662. intensities. The filter redistributes the pixel intensities to
  5663. equalize their distribution across the intensity range. It may be
  5664. viewed as an "automatically adjusting contrast filter". This filter is
  5665. useful only for correcting degraded or poorly captured source
  5666. video.
  5667. The filter accepts the following options:
  5668. @table @option
  5669. @item strength
  5670. Determine the amount of equalization to be applied. As the strength
  5671. is reduced, the distribution of pixel intensities more-and-more
  5672. approaches that of the input frame. The value must be a float number
  5673. in the range [0,1] and defaults to 0.200.
  5674. @item intensity
  5675. Set the maximum intensity that can generated and scale the output
  5676. values appropriately. The strength should be set as desired and then
  5677. the intensity can be limited if needed to avoid washing-out. The value
  5678. must be a float number in the range [0,1] and defaults to 0.210.
  5679. @item antibanding
  5680. Set the antibanding level. If enabled the filter will randomly vary
  5681. the luminance of output pixels by a small amount to avoid banding of
  5682. the histogram. Possible values are @code{none}, @code{weak} or
  5683. @code{strong}. It defaults to @code{none}.
  5684. @end table
  5685. @section histogram
  5686. Compute and draw a color distribution histogram for the input video.
  5687. The computed histogram is a representation of the color component
  5688. distribution in an image.
  5689. Standard histogram displays the color components distribution in an image.
  5690. Displays color graph for each color component. Shows distribution of
  5691. the Y, U, V, A or R, G, B components, depending on input format, in the
  5692. current frame. Below each graph a color component scale meter is shown.
  5693. The filter accepts the following options:
  5694. @table @option
  5695. @item level_height
  5696. Set height of level. Default value is @code{200}.
  5697. Allowed range is [50, 2048].
  5698. @item scale_height
  5699. Set height of color scale. Default value is @code{12}.
  5700. Allowed range is [0, 40].
  5701. @item display_mode
  5702. Set display mode.
  5703. It accepts the following values:
  5704. @table @samp
  5705. @item parade
  5706. Per color component graphs are placed below each other.
  5707. @item overlay
  5708. Presents information identical to that in the @code{parade}, except
  5709. that the graphs representing color components are superimposed directly
  5710. over one another.
  5711. @end table
  5712. Default is @code{parade}.
  5713. @item levels_mode
  5714. Set mode. Can be either @code{linear}, or @code{logarithmic}.
  5715. Default is @code{linear}.
  5716. @item components
  5717. Set what color components to display.
  5718. Default is @code{7}.
  5719. @end table
  5720. @subsection Examples
  5721. @itemize
  5722. @item
  5723. Calculate and draw histogram:
  5724. @example
  5725. ffplay -i input -vf histogram
  5726. @end example
  5727. @end itemize
  5728. @anchor{hqdn3d}
  5729. @section hqdn3d
  5730. This is a high precision/quality 3d denoise filter. It aims to reduce
  5731. image noise, producing smooth images and making still images really
  5732. still. It should enhance compressibility.
  5733. It accepts the following optional parameters:
  5734. @table @option
  5735. @item luma_spatial
  5736. A non-negative floating point number which specifies spatial luma strength.
  5737. It defaults to 4.0.
  5738. @item chroma_spatial
  5739. A non-negative floating point number which specifies spatial chroma strength.
  5740. It defaults to 3.0*@var{luma_spatial}/4.0.
  5741. @item luma_tmp
  5742. A floating point number which specifies luma temporal strength. It defaults to
  5743. 6.0*@var{luma_spatial}/4.0.
  5744. @item chroma_tmp
  5745. A floating point number which specifies chroma temporal strength. It defaults to
  5746. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
  5747. @end table
  5748. @section hqx
  5749. Apply a high-quality magnification filter designed for pixel art. This filter
  5750. was originally created by Maxim Stepin.
  5751. It accepts the following option:
  5752. @table @option
  5753. @item n
  5754. Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
  5755. @code{hq3x} and @code{4} for @code{hq4x}.
  5756. Default is @code{3}.
  5757. @end table
  5758. @section hstack
  5759. Stack input videos horizontally.
  5760. All streams must be of same pixel format and of same height.
  5761. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  5762. to create same output.
  5763. The filter accept the following option:
  5764. @table @option
  5765. @item inputs
  5766. Set number of input streams. Default is 2.
  5767. @item shortest
  5768. If set to 1, force the output to terminate when the shortest input
  5769. terminates. Default value is 0.
  5770. @end table
  5771. @section hue
  5772. Modify the hue and/or the saturation of the input.
  5773. It accepts the following parameters:
  5774. @table @option
  5775. @item h
  5776. Specify the hue angle as a number of degrees. It accepts an expression,
  5777. and defaults to "0".
  5778. @item s
  5779. Specify the saturation in the [-10,10] range. It accepts an expression and
  5780. defaults to "1".
  5781. @item H
  5782. Specify the hue angle as a number of radians. It accepts an
  5783. expression, and defaults to "0".
  5784. @item b
  5785. Specify the brightness in the [-10,10] range. It accepts an expression and
  5786. defaults to "0".
  5787. @end table
  5788. @option{h} and @option{H} are mutually exclusive, and can't be
  5789. specified at the same time.
  5790. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  5791. expressions containing the following constants:
  5792. @table @option
  5793. @item n
  5794. frame count of the input frame starting from 0
  5795. @item pts
  5796. presentation timestamp of the input frame expressed in time base units
  5797. @item r
  5798. frame rate of the input video, NAN if the input frame rate is unknown
  5799. @item t
  5800. timestamp expressed in seconds, NAN if the input timestamp is unknown
  5801. @item tb
  5802. time base of the input video
  5803. @end table
  5804. @subsection Examples
  5805. @itemize
  5806. @item
  5807. Set the hue to 90 degrees and the saturation to 1.0:
  5808. @example
  5809. hue=h=90:s=1
  5810. @end example
  5811. @item
  5812. Same command but expressing the hue in radians:
  5813. @example
  5814. hue=H=PI/2:s=1
  5815. @end example
  5816. @item
  5817. Rotate hue and make the saturation swing between 0
  5818. and 2 over a period of 1 second:
  5819. @example
  5820. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  5821. @end example
  5822. @item
  5823. Apply a 3 seconds saturation fade-in effect starting at 0:
  5824. @example
  5825. hue="s=min(t/3\,1)"
  5826. @end example
  5827. The general fade-in expression can be written as:
  5828. @example
  5829. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  5830. @end example
  5831. @item
  5832. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  5833. @example
  5834. hue="s=max(0\, min(1\, (8-t)/3))"
  5835. @end example
  5836. The general fade-out expression can be written as:
  5837. @example
  5838. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  5839. @end example
  5840. @end itemize
  5841. @subsection Commands
  5842. This filter supports the following commands:
  5843. @table @option
  5844. @item b
  5845. @item s
  5846. @item h
  5847. @item H
  5848. Modify the hue and/or the saturation and/or brightness of the input video.
  5849. The command accepts the same syntax of the corresponding option.
  5850. If the specified expression is not valid, it is kept at its current
  5851. value.
  5852. @end table
  5853. @section idet
  5854. Detect video interlacing type.
  5855. This filter tries to detect if the input frames as interlaced, progressive,
  5856. top or bottom field first. It will also try and detect fields that are
  5857. repeated between adjacent frames (a sign of telecine).
  5858. Single frame detection considers only immediately adjacent frames when classifying each frame.
  5859. Multiple frame detection incorporates the classification history of previous frames.
  5860. The filter will log these metadata values:
  5861. @table @option
  5862. @item single.current_frame
  5863. Detected type of current frame using single-frame detection. One of:
  5864. ``tff'' (top field first), ``bff'' (bottom field first),
  5865. ``progressive'', or ``undetermined''
  5866. @item single.tff
  5867. Cumulative number of frames detected as top field first using single-frame detection.
  5868. @item multiple.tff
  5869. Cumulative number of frames detected as top field first using multiple-frame detection.
  5870. @item single.bff
  5871. Cumulative number of frames detected as bottom field first using single-frame detection.
  5872. @item multiple.current_frame
  5873. Detected type of current frame using multiple-frame detection. One of:
  5874. ``tff'' (top field first), ``bff'' (bottom field first),
  5875. ``progressive'', or ``undetermined''
  5876. @item multiple.bff
  5877. Cumulative number of frames detected as bottom field first using multiple-frame detection.
  5878. @item single.progressive
  5879. Cumulative number of frames detected as progressive using single-frame detection.
  5880. @item multiple.progressive
  5881. Cumulative number of frames detected as progressive using multiple-frame detection.
  5882. @item single.undetermined
  5883. Cumulative number of frames that could not be classified using single-frame detection.
  5884. @item multiple.undetermined
  5885. Cumulative number of frames that could not be classified using multiple-frame detection.
  5886. @item repeated.current_frame
  5887. Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
  5888. @item repeated.neither
  5889. Cumulative number of frames with no repeated field.
  5890. @item repeated.top
  5891. Cumulative number of frames with the top field repeated from the previous frame's top field.
  5892. @item repeated.bottom
  5893. Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
  5894. @end table
  5895. The filter accepts the following options:
  5896. @table @option
  5897. @item intl_thres
  5898. Set interlacing threshold.
  5899. @item prog_thres
  5900. Set progressive threshold.
  5901. @item repeat_thres
  5902. Threshold for repeated field detection.
  5903. @item half_life
  5904. Number of frames after which a given frame's contribution to the
  5905. statistics is halved (i.e., it contributes only 0.5 to it's
  5906. classification). The default of 0 means that all frames seen are given
  5907. full weight of 1.0 forever.
  5908. @item analyze_interlaced_flag
  5909. When this is not 0 then idet will use the specified number of frames to determine
  5910. if the interlaced flag is accurate, it will not count undetermined frames.
  5911. If the flag is found to be accurate it will be used without any further
  5912. computations, if it is found to be inaccurate it will be cleared without any
  5913. further computations. This allows inserting the idet filter as a low computational
  5914. method to clean up the interlaced flag
  5915. @end table
  5916. @section il
  5917. Deinterleave or interleave fields.
  5918. This filter allows one to process interlaced images fields without
  5919. deinterlacing them. Deinterleaving splits the input frame into 2
  5920. fields (so called half pictures). Odd lines are moved to the top
  5921. half of the output image, even lines to the bottom half.
  5922. You can process (filter) them independently and then re-interleave them.
  5923. The filter accepts the following options:
  5924. @table @option
  5925. @item luma_mode, l
  5926. @item chroma_mode, c
  5927. @item alpha_mode, a
  5928. Available values for @var{luma_mode}, @var{chroma_mode} and
  5929. @var{alpha_mode} are:
  5930. @table @samp
  5931. @item none
  5932. Do nothing.
  5933. @item deinterleave, d
  5934. Deinterleave fields, placing one above the other.
  5935. @item interleave, i
  5936. Interleave fields. Reverse the effect of deinterleaving.
  5937. @end table
  5938. Default value is @code{none}.
  5939. @item luma_swap, ls
  5940. @item chroma_swap, cs
  5941. @item alpha_swap, as
  5942. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  5943. @end table
  5944. @section inflate
  5945. Apply inflate effect to the video.
  5946. This filter replaces the pixel by the local(3x3) average by taking into account
  5947. only values higher than the pixel.
  5948. It accepts the following options:
  5949. @table @option
  5950. @item threshold0
  5951. @item threshold1
  5952. @item threshold2
  5953. @item threshold3
  5954. Limit the maximum change for each plane, default is 65535.
  5955. If 0, plane will remain unchanged.
  5956. @end table
  5957. @section interlace
  5958. Simple interlacing filter from progressive contents. This interleaves upper (or
  5959. lower) lines from odd frames with lower (or upper) lines from even frames,
  5960. halving the frame rate and preserving image height.
  5961. @example
  5962. Original Original New Frame
  5963. Frame 'j' Frame 'j+1' (tff)
  5964. ========== =========== ==================
  5965. Line 0 --------------------> Frame 'j' Line 0
  5966. Line 1 Line 1 ----> Frame 'j+1' Line 1
  5967. Line 2 ---------------------> Frame 'j' Line 2
  5968. Line 3 Line 3 ----> Frame 'j+1' Line 3
  5969. ... ... ...
  5970. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  5971. @end example
  5972. It accepts the following optional parameters:
  5973. @table @option
  5974. @item scan
  5975. This determines whether the interlaced frame is taken from the even
  5976. (tff - default) or odd (bff) lines of the progressive frame.
  5977. @item lowpass
  5978. Enable (default) or disable the vertical lowpass filter to avoid twitter
  5979. interlacing and reduce moire patterns.
  5980. @end table
  5981. @section kerndeint
  5982. Deinterlace input video by applying Donald Graft's adaptive kernel
  5983. deinterling. Work on interlaced parts of a video to produce
  5984. progressive frames.
  5985. The description of the accepted parameters follows.
  5986. @table @option
  5987. @item thresh
  5988. Set the threshold which affects the filter's tolerance when
  5989. determining if a pixel line must be processed. It must be an integer
  5990. in the range [0,255] and defaults to 10. A value of 0 will result in
  5991. applying the process on every pixels.
  5992. @item map
  5993. Paint pixels exceeding the threshold value to white if set to 1.
  5994. Default is 0.
  5995. @item order
  5996. Set the fields order. Swap fields if set to 1, leave fields alone if
  5997. 0. Default is 0.
  5998. @item sharp
  5999. Enable additional sharpening if set to 1. Default is 0.
  6000. @item twoway
  6001. Enable twoway sharpening if set to 1. Default is 0.
  6002. @end table
  6003. @subsection Examples
  6004. @itemize
  6005. @item
  6006. Apply default values:
  6007. @example
  6008. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  6009. @end example
  6010. @item
  6011. Enable additional sharpening:
  6012. @example
  6013. kerndeint=sharp=1
  6014. @end example
  6015. @item
  6016. Paint processed pixels in white:
  6017. @example
  6018. kerndeint=map=1
  6019. @end example
  6020. @end itemize
  6021. @section lenscorrection
  6022. Correct radial lens distortion
  6023. This filter can be used to correct for radial distortion as can result from the use
  6024. of wide angle lenses, and thereby re-rectify the image. To find the right parameters
  6025. one can use tools available for example as part of opencv or simply trial-and-error.
  6026. To use opencv use the calibration sample (under samples/cpp) from the opencv sources
  6027. and extract the k1 and k2 coefficients from the resulting matrix.
  6028. Note that effectively the same filter is available in the open-source tools Krita and
  6029. Digikam from the KDE project.
  6030. In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
  6031. this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
  6032. brightness distribution, so you may want to use both filters together in certain
  6033. cases, though you will have to take care of ordering, i.e. whether vignetting should
  6034. be applied before or after lens correction.
  6035. @subsection Options
  6036. The filter accepts the following options:
  6037. @table @option
  6038. @item cx
  6039. Relative x-coordinate of the focal point of the image, and thereby the center of the
  6040. distortion. This value has a range [0,1] and is expressed as fractions of the image
  6041. width.
  6042. @item cy
  6043. Relative y-coordinate of the focal point of the image, and thereby the center of the
  6044. distortion. This value has a range [0,1] and is expressed as fractions of the image
  6045. height.
  6046. @item k1
  6047. Coefficient of the quadratic correction term. 0.5 means no correction.
  6048. @item k2
  6049. Coefficient of the double quadratic correction term. 0.5 means no correction.
  6050. @end table
  6051. The formula that generates the correction is:
  6052. @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)
  6053. where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
  6054. distances from the focal point in the source and target images, respectively.
  6055. @anchor{lut3d}
  6056. @section lut3d
  6057. Apply a 3D LUT to an input video.
  6058. The filter accepts the following options:
  6059. @table @option
  6060. @item file
  6061. Set the 3D LUT file name.
  6062. Currently supported formats:
  6063. @table @samp
  6064. @item 3dl
  6065. AfterEffects
  6066. @item cube
  6067. Iridas
  6068. @item dat
  6069. DaVinci
  6070. @item m3d
  6071. Pandora
  6072. @end table
  6073. @item interp
  6074. Select interpolation mode.
  6075. Available values are:
  6076. @table @samp
  6077. @item nearest
  6078. Use values from the nearest defined point.
  6079. @item trilinear
  6080. Interpolate values using the 8 points defining a cube.
  6081. @item tetrahedral
  6082. Interpolate values using a tetrahedron.
  6083. @end table
  6084. @end table
  6085. @section lut, lutrgb, lutyuv
  6086. Compute a look-up table for binding each pixel component input value
  6087. to an output value, and apply it to the input video.
  6088. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  6089. to an RGB input video.
  6090. These filters accept the following parameters:
  6091. @table @option
  6092. @item c0
  6093. set first pixel component expression
  6094. @item c1
  6095. set second pixel component expression
  6096. @item c2
  6097. set third pixel component expression
  6098. @item c3
  6099. set fourth pixel component expression, corresponds to the alpha component
  6100. @item r
  6101. set red component expression
  6102. @item g
  6103. set green component expression
  6104. @item b
  6105. set blue component expression
  6106. @item a
  6107. alpha component expression
  6108. @item y
  6109. set Y/luminance component expression
  6110. @item u
  6111. set U/Cb component expression
  6112. @item v
  6113. set V/Cr component expression
  6114. @end table
  6115. Each of them specifies the expression to use for computing the lookup table for
  6116. the corresponding pixel component values.
  6117. The exact component associated to each of the @var{c*} options depends on the
  6118. format in input.
  6119. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  6120. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  6121. The expressions can contain the following constants and functions:
  6122. @table @option
  6123. @item w
  6124. @item h
  6125. The input width and height.
  6126. @item val
  6127. The input value for the pixel component.
  6128. @item clipval
  6129. The input value, clipped to the @var{minval}-@var{maxval} range.
  6130. @item maxval
  6131. The maximum value for the pixel component.
  6132. @item minval
  6133. The minimum value for the pixel component.
  6134. @item negval
  6135. The negated value for the pixel component value, clipped to the
  6136. @var{minval}-@var{maxval} range; it corresponds to the expression
  6137. "maxval-clipval+minval".
  6138. @item clip(val)
  6139. The computed value in @var{val}, clipped to the
  6140. @var{minval}-@var{maxval} range.
  6141. @item gammaval(gamma)
  6142. The computed gamma correction value of the pixel component value,
  6143. clipped to the @var{minval}-@var{maxval} range. It corresponds to the
  6144. expression
  6145. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  6146. @end table
  6147. All expressions default to "val".
  6148. @subsection Examples
  6149. @itemize
  6150. @item
  6151. Negate input video:
  6152. @example
  6153. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  6154. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  6155. @end example
  6156. The above is the same as:
  6157. @example
  6158. lutrgb="r=negval:g=negval:b=negval"
  6159. lutyuv="y=negval:u=negval:v=negval"
  6160. @end example
  6161. @item
  6162. Negate luminance:
  6163. @example
  6164. lutyuv=y=negval
  6165. @end example
  6166. @item
  6167. Remove chroma components, turning the video into a graytone image:
  6168. @example
  6169. lutyuv="u=128:v=128"
  6170. @end example
  6171. @item
  6172. Apply a luma burning effect:
  6173. @example
  6174. lutyuv="y=2*val"
  6175. @end example
  6176. @item
  6177. Remove green and blue components:
  6178. @example
  6179. lutrgb="g=0:b=0"
  6180. @end example
  6181. @item
  6182. Set a constant alpha channel value on input:
  6183. @example
  6184. format=rgba,lutrgb=a="maxval-minval/2"
  6185. @end example
  6186. @item
  6187. Correct luminance gamma by a factor of 0.5:
  6188. @example
  6189. lutyuv=y=gammaval(0.5)
  6190. @end example
  6191. @item
  6192. Discard least significant bits of luma:
  6193. @example
  6194. lutyuv=y='bitand(val, 128+64+32)'
  6195. @end example
  6196. @end itemize
  6197. @section maskedmerge
  6198. Merge the first input stream with the second input stream using per pixel
  6199. weights in the third input stream.
  6200. A value of 0 in the third stream pixel component means that pixel component
  6201. from first stream is returned unchanged, while maximum value (eg. 255 for
  6202. 8-bit videos) means that pixel component from second stream is returned
  6203. unchanged. Intermediate values define the amount of merging between both
  6204. input stream's pixel components.
  6205. This filter accepts the following options:
  6206. @table @option
  6207. @item planes
  6208. Set which planes will be processed as bitmap, unprocessed planes will be
  6209. copied from first stream.
  6210. By default value 0xf, all planes will be processed.
  6211. @end table
  6212. @section mcdeint
  6213. Apply motion-compensation deinterlacing.
  6214. It needs one field per frame as input and must thus be used together
  6215. with yadif=1/3 or equivalent.
  6216. This filter accepts the following options:
  6217. @table @option
  6218. @item mode
  6219. Set the deinterlacing mode.
  6220. It accepts one of the following values:
  6221. @table @samp
  6222. @item fast
  6223. @item medium
  6224. @item slow
  6225. use iterative motion estimation
  6226. @item extra_slow
  6227. like @samp{slow}, but use multiple reference frames.
  6228. @end table
  6229. Default value is @samp{fast}.
  6230. @item parity
  6231. Set the picture field parity assumed for the input video. It must be
  6232. one of the following values:
  6233. @table @samp
  6234. @item 0, tff
  6235. assume top field first
  6236. @item 1, bff
  6237. assume bottom field first
  6238. @end table
  6239. Default value is @samp{bff}.
  6240. @item qp
  6241. Set per-block quantization parameter (QP) used by the internal
  6242. encoder.
  6243. Higher values should result in a smoother motion vector field but less
  6244. optimal individual vectors. Default value is 1.
  6245. @end table
  6246. @section mergeplanes
  6247. Merge color channel components from several video streams.
  6248. The filter accepts up to 4 input streams, and merge selected input
  6249. planes to the output video.
  6250. This filter accepts the following options:
  6251. @table @option
  6252. @item mapping
  6253. Set input to output plane mapping. Default is @code{0}.
  6254. The mappings is specified as a bitmap. It should be specified as a
  6255. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  6256. mapping for the first plane of the output stream. 'A' sets the number of
  6257. the input stream to use (from 0 to 3), and 'a' the plane number of the
  6258. corresponding input to use (from 0 to 3). The rest of the mappings is
  6259. similar, 'Bb' describes the mapping for the output stream second
  6260. plane, 'Cc' describes the mapping for the output stream third plane and
  6261. 'Dd' describes the mapping for the output stream fourth plane.
  6262. @item format
  6263. Set output pixel format. Default is @code{yuva444p}.
  6264. @end table
  6265. @subsection Examples
  6266. @itemize
  6267. @item
  6268. Merge three gray video streams of same width and height into single video stream:
  6269. @example
  6270. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  6271. @end example
  6272. @item
  6273. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  6274. @example
  6275. [a0][a1]mergeplanes=0x00010210:yuva444p
  6276. @end example
  6277. @item
  6278. Swap Y and A plane in yuva444p stream:
  6279. @example
  6280. format=yuva444p,mergeplanes=0x03010200:yuva444p
  6281. @end example
  6282. @item
  6283. Swap U and V plane in yuv420p stream:
  6284. @example
  6285. format=yuv420p,mergeplanes=0x000201:yuv420p
  6286. @end example
  6287. @item
  6288. Cast a rgb24 clip to yuv444p:
  6289. @example
  6290. format=rgb24,mergeplanes=0x000102:yuv444p
  6291. @end example
  6292. @end itemize
  6293. @section mpdecimate
  6294. Drop frames that do not differ greatly from the previous frame in
  6295. order to reduce frame rate.
  6296. The main use of this filter is for very-low-bitrate encoding
  6297. (e.g. streaming over dialup modem), but it could in theory be used for
  6298. fixing movies that were inverse-telecined incorrectly.
  6299. A description of the accepted options follows.
  6300. @table @option
  6301. @item max
  6302. Set the maximum number of consecutive frames which can be dropped (if
  6303. positive), or the minimum interval between dropped frames (if
  6304. negative). If the value is 0, the frame is dropped unregarding the
  6305. number of previous sequentially dropped frames.
  6306. Default value is 0.
  6307. @item hi
  6308. @item lo
  6309. @item frac
  6310. Set the dropping threshold values.
  6311. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  6312. represent actual pixel value differences, so a threshold of 64
  6313. corresponds to 1 unit of difference for each pixel, or the same spread
  6314. out differently over the block.
  6315. A frame is a candidate for dropping if no 8x8 blocks differ by more
  6316. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  6317. meaning the whole image) differ by more than a threshold of @option{lo}.
  6318. Default value for @option{hi} is 64*12, default value for @option{lo} is
  6319. 64*5, and default value for @option{frac} is 0.33.
  6320. @end table
  6321. @section negate
  6322. Negate input video.
  6323. It accepts an integer in input; if non-zero it negates the
  6324. alpha component (if available). The default value in input is 0.
  6325. @section noformat
  6326. Force libavfilter not to use any of the specified pixel formats for the
  6327. input to the next filter.
  6328. It accepts the following parameters:
  6329. @table @option
  6330. @item pix_fmts
  6331. A '|'-separated list of pixel format names, such as
  6332. apix_fmts=yuv420p|monow|rgb24".
  6333. @end table
  6334. @subsection Examples
  6335. @itemize
  6336. @item
  6337. Force libavfilter to use a format different from @var{yuv420p} for the
  6338. input to the vflip filter:
  6339. @example
  6340. noformat=pix_fmts=yuv420p,vflip
  6341. @end example
  6342. @item
  6343. Convert the input video to any of the formats not contained in the list:
  6344. @example
  6345. noformat=yuv420p|yuv444p|yuv410p
  6346. @end example
  6347. @end itemize
  6348. @section noise
  6349. Add noise on video input frame.
  6350. The filter accepts the following options:
  6351. @table @option
  6352. @item all_seed
  6353. @item c0_seed
  6354. @item c1_seed
  6355. @item c2_seed
  6356. @item c3_seed
  6357. Set noise seed for specific pixel component or all pixel components in case
  6358. of @var{all_seed}. Default value is @code{123457}.
  6359. @item all_strength, alls
  6360. @item c0_strength, c0s
  6361. @item c1_strength, c1s
  6362. @item c2_strength, c2s
  6363. @item c3_strength, c3s
  6364. Set noise strength for specific pixel component or all pixel components in case
  6365. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  6366. @item all_flags, allf
  6367. @item c0_flags, c0f
  6368. @item c1_flags, c1f
  6369. @item c2_flags, c2f
  6370. @item c3_flags, c3f
  6371. Set pixel component flags or set flags for all components if @var{all_flags}.
  6372. Available values for component flags are:
  6373. @table @samp
  6374. @item a
  6375. averaged temporal noise (smoother)
  6376. @item p
  6377. mix random noise with a (semi)regular pattern
  6378. @item t
  6379. temporal noise (noise pattern changes between frames)
  6380. @item u
  6381. uniform noise (gaussian otherwise)
  6382. @end table
  6383. @end table
  6384. @subsection Examples
  6385. Add temporal and uniform noise to input video:
  6386. @example
  6387. noise=alls=20:allf=t+u
  6388. @end example
  6389. @section null
  6390. Pass the video source unchanged to the output.
  6391. @section ocr
  6392. Optical Character Recognition
  6393. This filter uses Tesseract for optical character recognition.
  6394. It accepts the following options:
  6395. @table @option
  6396. @item datapath
  6397. Set datapath to tesseract data. Default is to use whatever was
  6398. set at installation.
  6399. @item language
  6400. Set language, default is "eng".
  6401. @item whitelist
  6402. Set character whitelist.
  6403. @item blacklist
  6404. Set character blacklist.
  6405. @end table
  6406. The filter exports recognized text as the frame metadata @code{lavfi.ocr.text}.
  6407. @section ocv
  6408. Apply a video transform using libopencv.
  6409. To enable this filter, install the libopencv library and headers and
  6410. configure FFmpeg with @code{--enable-libopencv}.
  6411. It accepts the following parameters:
  6412. @table @option
  6413. @item filter_name
  6414. The name of the libopencv filter to apply.
  6415. @item filter_params
  6416. The parameters to pass to the libopencv filter. If not specified, the default
  6417. values are assumed.
  6418. @end table
  6419. Refer to the official libopencv documentation for more precise
  6420. information:
  6421. @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
  6422. Several libopencv filters are supported; see the following subsections.
  6423. @anchor{dilate}
  6424. @subsection dilate
  6425. Dilate an image by using a specific structuring element.
  6426. It corresponds to the libopencv function @code{cvDilate}.
  6427. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  6428. @var{struct_el} represents a structuring element, and has the syntax:
  6429. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  6430. @var{cols} and @var{rows} represent the number of columns and rows of
  6431. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  6432. point, and @var{shape} the shape for the structuring element. @var{shape}
  6433. must be "rect", "cross", "ellipse", or "custom".
  6434. If the value for @var{shape} is "custom", it must be followed by a
  6435. string of the form "=@var{filename}". The file with name
  6436. @var{filename} is assumed to represent a binary image, with each
  6437. printable character corresponding to a bright pixel. When a custom
  6438. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  6439. or columns and rows of the read file are assumed instead.
  6440. The default value for @var{struct_el} is "3x3+0x0/rect".
  6441. @var{nb_iterations} specifies the number of times the transform is
  6442. applied to the image, and defaults to 1.
  6443. Some examples:
  6444. @example
  6445. # Use the default values
  6446. ocv=dilate
  6447. # Dilate using a structuring element with a 5x5 cross, iterating two times
  6448. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  6449. # Read the shape from the file diamond.shape, iterating two times.
  6450. # The file diamond.shape may contain a pattern of characters like this
  6451. # *
  6452. # ***
  6453. # *****
  6454. # ***
  6455. # *
  6456. # The specified columns and rows are ignored
  6457. # but the anchor point coordinates are not
  6458. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  6459. @end example
  6460. @subsection erode
  6461. Erode an image by using a specific structuring element.
  6462. It corresponds to the libopencv function @code{cvErode}.
  6463. It accepts the parameters: @var{struct_el}:@var{nb_iterations},
  6464. with the same syntax and semantics as the @ref{dilate} filter.
  6465. @subsection smooth
  6466. Smooth the input video.
  6467. The filter takes the following parameters:
  6468. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  6469. @var{type} is the type of smooth filter to apply, and must be one of
  6470. the following values: "blur", "blur_no_scale", "median", "gaussian",
  6471. or "bilateral". The default value is "gaussian".
  6472. The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
  6473. depend on the smooth type. @var{param1} and
  6474. @var{param2} accept integer positive values or 0. @var{param3} and
  6475. @var{param4} accept floating point values.
  6476. The default value for @var{param1} is 3. The default value for the
  6477. other parameters is 0.
  6478. These parameters correspond to the parameters assigned to the
  6479. libopencv function @code{cvSmooth}.
  6480. @anchor{overlay}
  6481. @section overlay
  6482. Overlay one video on top of another.
  6483. It takes two inputs and has one output. The first input is the "main"
  6484. video on which the second input is overlaid.
  6485. It accepts the following parameters:
  6486. A description of the accepted options follows.
  6487. @table @option
  6488. @item x
  6489. @item y
  6490. Set the expression for the x and y coordinates of the overlaid video
  6491. on the main video. Default value is "0" for both expressions. In case
  6492. the expression is invalid, it is set to a huge value (meaning that the
  6493. overlay will not be displayed within the output visible area).
  6494. @item eof_action
  6495. The action to take when EOF is encountered on the secondary input; it accepts
  6496. one of the following values:
  6497. @table @option
  6498. @item repeat
  6499. Repeat the last frame (the default).
  6500. @item endall
  6501. End both streams.
  6502. @item pass
  6503. Pass the main input through.
  6504. @end table
  6505. @item eval
  6506. Set when the expressions for @option{x}, and @option{y} are evaluated.
  6507. It accepts the following values:
  6508. @table @samp
  6509. @item init
  6510. only evaluate expressions once during the filter initialization or
  6511. when a command is processed
  6512. @item frame
  6513. evaluate expressions for each incoming frame
  6514. @end table
  6515. Default value is @samp{frame}.
  6516. @item shortest
  6517. If set to 1, force the output to terminate when the shortest input
  6518. terminates. Default value is 0.
  6519. @item format
  6520. Set the format for the output video.
  6521. It accepts the following values:
  6522. @table @samp
  6523. @item yuv420
  6524. force YUV420 output
  6525. @item yuv422
  6526. force YUV422 output
  6527. @item yuv444
  6528. force YUV444 output
  6529. @item rgb
  6530. force RGB output
  6531. @end table
  6532. Default value is @samp{yuv420}.
  6533. @item rgb @emph{(deprecated)}
  6534. If set to 1, force the filter to accept inputs in the RGB
  6535. color space. Default value is 0. This option is deprecated, use
  6536. @option{format} instead.
  6537. @item repeatlast
  6538. If set to 1, force the filter to draw the last overlay frame over the
  6539. main input until the end of the stream. A value of 0 disables this
  6540. behavior. Default value is 1.
  6541. @end table
  6542. The @option{x}, and @option{y} expressions can contain the following
  6543. parameters.
  6544. @table @option
  6545. @item main_w, W
  6546. @item main_h, H
  6547. The main input width and height.
  6548. @item overlay_w, w
  6549. @item overlay_h, h
  6550. The overlay input width and height.
  6551. @item x
  6552. @item y
  6553. The computed values for @var{x} and @var{y}. They are evaluated for
  6554. each new frame.
  6555. @item hsub
  6556. @item vsub
  6557. horizontal and vertical chroma subsample values of the output
  6558. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  6559. @var{vsub} is 1.
  6560. @item n
  6561. the number of input frame, starting from 0
  6562. @item pos
  6563. the position in the file of the input frame, NAN if unknown
  6564. @item t
  6565. The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
  6566. @end table
  6567. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  6568. when evaluation is done @emph{per frame}, and will evaluate to NAN
  6569. when @option{eval} is set to @samp{init}.
  6570. Be aware that frames are taken from each input video in timestamp
  6571. order, hence, if their initial timestamps differ, it is a good idea
  6572. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  6573. have them begin in the same zero timestamp, as the example for
  6574. the @var{movie} filter does.
  6575. You can chain together more overlays but you should test the
  6576. efficiency of such approach.
  6577. @subsection Commands
  6578. This filter supports the following commands:
  6579. @table @option
  6580. @item x
  6581. @item y
  6582. Modify the x and y of the overlay input.
  6583. The command accepts the same syntax of the corresponding option.
  6584. If the specified expression is not valid, it is kept at its current
  6585. value.
  6586. @end table
  6587. @subsection Examples
  6588. @itemize
  6589. @item
  6590. Draw the overlay at 10 pixels from the bottom right corner of the main
  6591. video:
  6592. @example
  6593. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  6594. @end example
  6595. Using named options the example above becomes:
  6596. @example
  6597. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  6598. @end example
  6599. @item
  6600. Insert a transparent PNG logo in the bottom left corner of the input,
  6601. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  6602. @example
  6603. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  6604. @end example
  6605. @item
  6606. Insert 2 different transparent PNG logos (second logo on bottom
  6607. right corner) using the @command{ffmpeg} tool:
  6608. @example
  6609. 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
  6610. @end example
  6611. @item
  6612. Add a transparent color layer on top of the main video; @code{WxH}
  6613. must specify the size of the main input to the overlay filter:
  6614. @example
  6615. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  6616. @end example
  6617. @item
  6618. Play an original video and a filtered version (here with the deshake
  6619. filter) side by side using the @command{ffplay} tool:
  6620. @example
  6621. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  6622. @end example
  6623. The above command is the same as:
  6624. @example
  6625. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  6626. @end example
  6627. @item
  6628. Make a sliding overlay appearing from the left to the right top part of the
  6629. screen starting since time 2:
  6630. @example
  6631. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  6632. @end example
  6633. @item
  6634. Compose output by putting two input videos side to side:
  6635. @example
  6636. ffmpeg -i left.avi -i right.avi -filter_complex "
  6637. nullsrc=size=200x100 [background];
  6638. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  6639. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  6640. [background][left] overlay=shortest=1 [background+left];
  6641. [background+left][right] overlay=shortest=1:x=100 [left+right]
  6642. "
  6643. @end example
  6644. @item
  6645. Mask 10-20 seconds of a video by applying the delogo filter to a section
  6646. @example
  6647. ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
  6648. -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]'
  6649. masked.avi
  6650. @end example
  6651. @item
  6652. Chain several overlays in cascade:
  6653. @example
  6654. nullsrc=s=200x200 [bg];
  6655. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  6656. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  6657. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  6658. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  6659. [in3] null, [mid2] overlay=100:100 [out0]
  6660. @end example
  6661. @end itemize
  6662. @section owdenoise
  6663. Apply Overcomplete Wavelet denoiser.
  6664. The filter accepts the following options:
  6665. @table @option
  6666. @item depth
  6667. Set depth.
  6668. Larger depth values will denoise lower frequency components more, but
  6669. slow down filtering.
  6670. Must be an int in the range 8-16, default is @code{8}.
  6671. @item luma_strength, ls
  6672. Set luma strength.
  6673. Must be a double value in the range 0-1000, default is @code{1.0}.
  6674. @item chroma_strength, cs
  6675. Set chroma strength.
  6676. Must be a double value in the range 0-1000, default is @code{1.0}.
  6677. @end table
  6678. @anchor{pad}
  6679. @section pad
  6680. Add paddings to the input image, and place the original input at the
  6681. provided @var{x}, @var{y} coordinates.
  6682. It accepts the following parameters:
  6683. @table @option
  6684. @item width, w
  6685. @item height, h
  6686. Specify an expression for the size of the output image with the
  6687. paddings added. If the value for @var{width} or @var{height} is 0, the
  6688. corresponding input size is used for the output.
  6689. The @var{width} expression can reference the value set by the
  6690. @var{height} expression, and vice versa.
  6691. The default value of @var{width} and @var{height} is 0.
  6692. @item x
  6693. @item y
  6694. Specify the offsets to place the input image at within the padded area,
  6695. with respect to the top/left border of the output image.
  6696. The @var{x} expression can reference the value set by the @var{y}
  6697. expression, and vice versa.
  6698. The default value of @var{x} and @var{y} is 0.
  6699. @item color
  6700. Specify the color of the padded area. For the syntax of this option,
  6701. check the "Color" section in the ffmpeg-utils manual.
  6702. The default value of @var{color} is "black".
  6703. @end table
  6704. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  6705. options are expressions containing the following constants:
  6706. @table @option
  6707. @item in_w
  6708. @item in_h
  6709. The input video width and height.
  6710. @item iw
  6711. @item ih
  6712. These are the same as @var{in_w} and @var{in_h}.
  6713. @item out_w
  6714. @item out_h
  6715. The output width and height (the size of the padded area), as
  6716. specified by the @var{width} and @var{height} expressions.
  6717. @item ow
  6718. @item oh
  6719. These are the same as @var{out_w} and @var{out_h}.
  6720. @item x
  6721. @item y
  6722. The x and y offsets as specified by the @var{x} and @var{y}
  6723. expressions, or NAN if not yet specified.
  6724. @item a
  6725. same as @var{iw} / @var{ih}
  6726. @item sar
  6727. input sample aspect ratio
  6728. @item dar
  6729. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  6730. @item hsub
  6731. @item vsub
  6732. The horizontal and vertical chroma subsample values. For example for the
  6733. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6734. @end table
  6735. @subsection Examples
  6736. @itemize
  6737. @item
  6738. Add paddings with the color "violet" to the input video. The output video
  6739. size is 640x480, and the top-left corner of the input video is placed at
  6740. column 0, row 40
  6741. @example
  6742. pad=640:480:0:40:violet
  6743. @end example
  6744. The example above is equivalent to the following command:
  6745. @example
  6746. pad=width=640:height=480:x=0:y=40:color=violet
  6747. @end example
  6748. @item
  6749. Pad the input to get an output with dimensions increased by 3/2,
  6750. and put the input video at the center of the padded area:
  6751. @example
  6752. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  6753. @end example
  6754. @item
  6755. Pad the input to get a squared output with size equal to the maximum
  6756. value between the input width and height, and put the input video at
  6757. the center of the padded area:
  6758. @example
  6759. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  6760. @end example
  6761. @item
  6762. Pad the input to get a final w/h ratio of 16:9:
  6763. @example
  6764. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  6765. @end example
  6766. @item
  6767. In case of anamorphic video, in order to set the output display aspect
  6768. correctly, it is necessary to use @var{sar} in the expression,
  6769. according to the relation:
  6770. @example
  6771. (ih * X / ih) * sar = output_dar
  6772. X = output_dar / sar
  6773. @end example
  6774. Thus the previous example needs to be modified to:
  6775. @example
  6776. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  6777. @end example
  6778. @item
  6779. Double the output size and put the input video in the bottom-right
  6780. corner of the output padded area:
  6781. @example
  6782. pad="2*iw:2*ih:ow-iw:oh-ih"
  6783. @end example
  6784. @end itemize
  6785. @anchor{palettegen}
  6786. @section palettegen
  6787. Generate one palette for a whole video stream.
  6788. It accepts the following options:
  6789. @table @option
  6790. @item max_colors
  6791. Set the maximum number of colors to quantize in the palette.
  6792. Note: the palette will still contain 256 colors; the unused palette entries
  6793. will be black.
  6794. @item reserve_transparent
  6795. Create a palette of 255 colors maximum and reserve the last one for
  6796. transparency. Reserving the transparency color is useful for GIF optimization.
  6797. If not set, the maximum of colors in the palette will be 256. You probably want
  6798. to disable this option for a standalone image.
  6799. Set by default.
  6800. @item stats_mode
  6801. Set statistics mode.
  6802. It accepts the following values:
  6803. @table @samp
  6804. @item full
  6805. Compute full frame histograms.
  6806. @item diff
  6807. Compute histograms only for the part that differs from previous frame. This
  6808. might be relevant to give more importance to the moving part of your input if
  6809. the background is static.
  6810. @end table
  6811. Default value is @var{full}.
  6812. @end table
  6813. The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
  6814. (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
  6815. color quantization of the palette. This information is also visible at
  6816. @var{info} logging level.
  6817. @subsection Examples
  6818. @itemize
  6819. @item
  6820. Generate a representative palette of a given video using @command{ffmpeg}:
  6821. @example
  6822. ffmpeg -i input.mkv -vf palettegen palette.png
  6823. @end example
  6824. @end itemize
  6825. @section paletteuse
  6826. Use a palette to downsample an input video stream.
  6827. The filter takes two inputs: one video stream and a palette. The palette must
  6828. be a 256 pixels image.
  6829. It accepts the following options:
  6830. @table @option
  6831. @item dither
  6832. Select dithering mode. Available algorithms are:
  6833. @table @samp
  6834. @item bayer
  6835. Ordered 8x8 bayer dithering (deterministic)
  6836. @item heckbert
  6837. Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
  6838. Note: this dithering is sometimes considered "wrong" and is included as a
  6839. reference.
  6840. @item floyd_steinberg
  6841. Floyd and Steingberg dithering (error diffusion)
  6842. @item sierra2
  6843. Frankie Sierra dithering v2 (error diffusion)
  6844. @item sierra2_4a
  6845. Frankie Sierra dithering v2 "Lite" (error diffusion)
  6846. @end table
  6847. Default is @var{sierra2_4a}.
  6848. @item bayer_scale
  6849. When @var{bayer} dithering is selected, this option defines the scale of the
  6850. pattern (how much the crosshatch pattern is visible). A low value means more
  6851. visible pattern for less banding, and higher value means less visible pattern
  6852. at the cost of more banding.
  6853. The option must be an integer value in the range [0,5]. Default is @var{2}.
  6854. @item diff_mode
  6855. If set, define the zone to process
  6856. @table @samp
  6857. @item rectangle
  6858. Only the changing rectangle will be reprocessed. This is similar to GIF
  6859. cropping/offsetting compression mechanism. This option can be useful for speed
  6860. if only a part of the image is changing, and has use cases such as limiting the
  6861. scope of the error diffusal @option{dither} to the rectangle that bounds the
  6862. moving scene (it leads to more deterministic output if the scene doesn't change
  6863. much, and as a result less moving noise and better GIF compression).
  6864. @end table
  6865. Default is @var{none}.
  6866. @end table
  6867. @subsection Examples
  6868. @itemize
  6869. @item
  6870. Use a palette (generated for example with @ref{palettegen}) to encode a GIF
  6871. using @command{ffmpeg}:
  6872. @example
  6873. ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
  6874. @end example
  6875. @end itemize
  6876. @section perspective
  6877. Correct perspective of video not recorded perpendicular to the screen.
  6878. A description of the accepted parameters follows.
  6879. @table @option
  6880. @item x0
  6881. @item y0
  6882. @item x1
  6883. @item y1
  6884. @item x2
  6885. @item y2
  6886. @item x3
  6887. @item y3
  6888. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  6889. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  6890. If the @code{sense} option is set to @code{source}, then the specified points will be sent
  6891. to the corners of the destination. If the @code{sense} option is set to @code{destination},
  6892. then the corners of the source will be sent to the specified coordinates.
  6893. The expressions can use the following variables:
  6894. @table @option
  6895. @item W
  6896. @item H
  6897. the width and height of video frame.
  6898. @end table
  6899. @item interpolation
  6900. Set interpolation for perspective correction.
  6901. It accepts the following values:
  6902. @table @samp
  6903. @item linear
  6904. @item cubic
  6905. @end table
  6906. Default value is @samp{linear}.
  6907. @item sense
  6908. Set interpretation of coordinate options.
  6909. It accepts the following values:
  6910. @table @samp
  6911. @item 0, source
  6912. Send point in the source specified by the given coordinates to
  6913. the corners of the destination.
  6914. @item 1, destination
  6915. Send the corners of the source to the point in the destination specified
  6916. by the given coordinates.
  6917. Default value is @samp{source}.
  6918. @end table
  6919. @end table
  6920. @section phase
  6921. Delay interlaced video by one field time so that the field order changes.
  6922. The intended use is to fix PAL movies that have been captured with the
  6923. opposite field order to the film-to-video transfer.
  6924. A description of the accepted parameters follows.
  6925. @table @option
  6926. @item mode
  6927. Set phase mode.
  6928. It accepts the following values:
  6929. @table @samp
  6930. @item t
  6931. Capture field order top-first, transfer bottom-first.
  6932. Filter will delay the bottom field.
  6933. @item b
  6934. Capture field order bottom-first, transfer top-first.
  6935. Filter will delay the top field.
  6936. @item p
  6937. Capture and transfer with the same field order. This mode only exists
  6938. for the documentation of the other options to refer to, but if you
  6939. actually select it, the filter will faithfully do nothing.
  6940. @item a
  6941. Capture field order determined automatically by field flags, transfer
  6942. opposite.
  6943. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  6944. basis using field flags. If no field information is available,
  6945. then this works just like @samp{u}.
  6946. @item u
  6947. Capture unknown or varying, transfer opposite.
  6948. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  6949. analyzing the images and selecting the alternative that produces best
  6950. match between the fields.
  6951. @item T
  6952. Capture top-first, transfer unknown or varying.
  6953. Filter selects among @samp{t} and @samp{p} using image analysis.
  6954. @item B
  6955. Capture bottom-first, transfer unknown or varying.
  6956. Filter selects among @samp{b} and @samp{p} using image analysis.
  6957. @item A
  6958. Capture determined by field flags, transfer unknown or varying.
  6959. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  6960. image analysis. If no field information is available, then this works just
  6961. like @samp{U}. This is the default mode.
  6962. @item U
  6963. Both capture and transfer unknown or varying.
  6964. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  6965. @end table
  6966. @end table
  6967. @section pixdesctest
  6968. Pixel format descriptor test filter, mainly useful for internal
  6969. testing. The output video should be equal to the input video.
  6970. For example:
  6971. @example
  6972. format=monow, pixdesctest
  6973. @end example
  6974. can be used to test the monowhite pixel format descriptor definition.
  6975. @section pp
  6976. Enable the specified chain of postprocessing subfilters using libpostproc. This
  6977. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  6978. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  6979. Each subfilter and some options have a short and a long name that can be used
  6980. interchangeably, i.e. dr/dering are the same.
  6981. The filters accept the following options:
  6982. @table @option
  6983. @item subfilters
  6984. Set postprocessing subfilters string.
  6985. @end table
  6986. All subfilters share common options to determine their scope:
  6987. @table @option
  6988. @item a/autoq
  6989. Honor the quality commands for this subfilter.
  6990. @item c/chrom
  6991. Do chrominance filtering, too (default).
  6992. @item y/nochrom
  6993. Do luminance filtering only (no chrominance).
  6994. @item n/noluma
  6995. Do chrominance filtering only (no luminance).
  6996. @end table
  6997. These options can be appended after the subfilter name, separated by a '|'.
  6998. Available subfilters are:
  6999. @table @option
  7000. @item hb/hdeblock[|difference[|flatness]]
  7001. Horizontal deblocking filter
  7002. @table @option
  7003. @item difference
  7004. Difference factor where higher values mean more deblocking (default: @code{32}).
  7005. @item flatness
  7006. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7007. @end table
  7008. @item vb/vdeblock[|difference[|flatness]]
  7009. Vertical deblocking filter
  7010. @table @option
  7011. @item difference
  7012. Difference factor where higher values mean more deblocking (default: @code{32}).
  7013. @item flatness
  7014. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7015. @end table
  7016. @item ha/hadeblock[|difference[|flatness]]
  7017. Accurate horizontal deblocking filter
  7018. @table @option
  7019. @item difference
  7020. Difference factor where higher values mean more deblocking (default: @code{32}).
  7021. @item flatness
  7022. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7023. @end table
  7024. @item va/vadeblock[|difference[|flatness]]
  7025. Accurate vertical deblocking filter
  7026. @table @option
  7027. @item difference
  7028. Difference factor where higher values mean more deblocking (default: @code{32}).
  7029. @item flatness
  7030. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7031. @end table
  7032. @end table
  7033. The horizontal and vertical deblocking filters share the difference and
  7034. flatness values so you cannot set different horizontal and vertical
  7035. thresholds.
  7036. @table @option
  7037. @item h1/x1hdeblock
  7038. Experimental horizontal deblocking filter
  7039. @item v1/x1vdeblock
  7040. Experimental vertical deblocking filter
  7041. @item dr/dering
  7042. Deringing filter
  7043. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  7044. @table @option
  7045. @item threshold1
  7046. larger -> stronger filtering
  7047. @item threshold2
  7048. larger -> stronger filtering
  7049. @item threshold3
  7050. larger -> stronger filtering
  7051. @end table
  7052. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  7053. @table @option
  7054. @item f/fullyrange
  7055. Stretch luminance to @code{0-255}.
  7056. @end table
  7057. @item lb/linblenddeint
  7058. Linear blend deinterlacing filter that deinterlaces the given block by
  7059. filtering all lines with a @code{(1 2 1)} filter.
  7060. @item li/linipoldeint
  7061. Linear interpolating deinterlacing filter that deinterlaces the given block by
  7062. linearly interpolating every second line.
  7063. @item ci/cubicipoldeint
  7064. Cubic interpolating deinterlacing filter deinterlaces the given block by
  7065. cubically interpolating every second line.
  7066. @item md/mediandeint
  7067. Median deinterlacing filter that deinterlaces the given block by applying a
  7068. median filter to every second line.
  7069. @item fd/ffmpegdeint
  7070. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  7071. second line with a @code{(-1 4 2 4 -1)} filter.
  7072. @item l5/lowpass5
  7073. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  7074. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  7075. @item fq/forceQuant[|quantizer]
  7076. Overrides the quantizer table from the input with the constant quantizer you
  7077. specify.
  7078. @table @option
  7079. @item quantizer
  7080. Quantizer to use
  7081. @end table
  7082. @item de/default
  7083. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  7084. @item fa/fast
  7085. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  7086. @item ac
  7087. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  7088. @end table
  7089. @subsection Examples
  7090. @itemize
  7091. @item
  7092. Apply horizontal and vertical deblocking, deringing and automatic
  7093. brightness/contrast:
  7094. @example
  7095. pp=hb/vb/dr/al
  7096. @end example
  7097. @item
  7098. Apply default filters without brightness/contrast correction:
  7099. @example
  7100. pp=de/-al
  7101. @end example
  7102. @item
  7103. Apply default filters and temporal denoiser:
  7104. @example
  7105. pp=default/tmpnoise|1|2|3
  7106. @end example
  7107. @item
  7108. Apply deblocking on luminance only, and switch vertical deblocking on or off
  7109. automatically depending on available CPU time:
  7110. @example
  7111. pp=hb|y/vb|a
  7112. @end example
  7113. @end itemize
  7114. @section pp7
  7115. Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
  7116. similar to spp = 6 with 7 point DCT, where only the center sample is
  7117. used after IDCT.
  7118. The filter accepts the following options:
  7119. @table @option
  7120. @item qp
  7121. Force a constant quantization parameter. It accepts an integer in range
  7122. 0 to 63. If not set, the filter will use the QP from the video stream
  7123. (if available).
  7124. @item mode
  7125. Set thresholding mode. Available modes are:
  7126. @table @samp
  7127. @item hard
  7128. Set hard thresholding.
  7129. @item soft
  7130. Set soft thresholding (better de-ringing effect, but likely blurrier).
  7131. @item medium
  7132. Set medium thresholding (good results, default).
  7133. @end table
  7134. @end table
  7135. @section psnr
  7136. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  7137. Ratio) between two input videos.
  7138. This filter takes in input two input videos, the first input is
  7139. considered the "main" source and is passed unchanged to the
  7140. output. The second input is used as a "reference" video for computing
  7141. the PSNR.
  7142. Both video inputs must have the same resolution and pixel format for
  7143. this filter to work correctly. Also it assumes that both inputs
  7144. have the same number of frames, which are compared one by one.
  7145. The obtained average PSNR is printed through the logging system.
  7146. The filter stores the accumulated MSE (mean squared error) of each
  7147. frame, and at the end of the processing it is averaged across all frames
  7148. equally, and the following formula is applied to obtain the PSNR:
  7149. @example
  7150. PSNR = 10*log10(MAX^2/MSE)
  7151. @end example
  7152. Where MAX is the average of the maximum values of each component of the
  7153. image.
  7154. The description of the accepted parameters follows.
  7155. @table @option
  7156. @item stats_file, f
  7157. If specified the filter will use the named file to save the PSNR of
  7158. each individual frame. When filename equals "-" the data is sent to
  7159. standard output.
  7160. @end table
  7161. The file printed if @var{stats_file} is selected, contains a sequence of
  7162. key/value pairs of the form @var{key}:@var{value} for each compared
  7163. couple of frames.
  7164. A description of each shown parameter follows:
  7165. @table @option
  7166. @item n
  7167. sequential number of the input frame, starting from 1
  7168. @item mse_avg
  7169. Mean Square Error pixel-by-pixel average difference of the compared
  7170. frames, averaged over all the image components.
  7171. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  7172. Mean Square Error pixel-by-pixel average difference of the compared
  7173. frames for the component specified by the suffix.
  7174. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  7175. Peak Signal to Noise ratio of the compared frames for the component
  7176. specified by the suffix.
  7177. @end table
  7178. For example:
  7179. @example
  7180. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  7181. [main][ref] psnr="stats_file=stats.log" [out]
  7182. @end example
  7183. On this example the input file being processed is compared with the
  7184. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  7185. is stored in @file{stats.log}.
  7186. @anchor{pullup}
  7187. @section pullup
  7188. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  7189. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  7190. content.
  7191. The pullup filter is designed to take advantage of future context in making
  7192. its decisions. This filter is stateless in the sense that it does not lock
  7193. onto a pattern to follow, but it instead looks forward to the following
  7194. fields in order to identify matches and rebuild progressive frames.
  7195. To produce content with an even framerate, insert the fps filter after
  7196. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  7197. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  7198. The filter accepts the following options:
  7199. @table @option
  7200. @item jl
  7201. @item jr
  7202. @item jt
  7203. @item jb
  7204. These options set the amount of "junk" to ignore at the left, right, top, and
  7205. bottom of the image, respectively. Left and right are in units of 8 pixels,
  7206. while top and bottom are in units of 2 lines.
  7207. The default is 8 pixels on each side.
  7208. @item sb
  7209. Set the strict breaks. Setting this option to 1 will reduce the chances of
  7210. filter generating an occasional mismatched frame, but it may also cause an
  7211. excessive number of frames to be dropped during high motion sequences.
  7212. Conversely, setting it to -1 will make filter match fields more easily.
  7213. This may help processing of video where there is slight blurring between
  7214. the fields, but may also cause there to be interlaced frames in the output.
  7215. Default value is @code{0}.
  7216. @item mp
  7217. Set the metric plane to use. It accepts the following values:
  7218. @table @samp
  7219. @item l
  7220. Use luma plane.
  7221. @item u
  7222. Use chroma blue plane.
  7223. @item v
  7224. Use chroma red plane.
  7225. @end table
  7226. This option may be set to use chroma plane instead of the default luma plane
  7227. for doing filter's computations. This may improve accuracy on very clean
  7228. source material, but more likely will decrease accuracy, especially if there
  7229. is chroma noise (rainbow effect) or any grayscale video.
  7230. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  7231. load and make pullup usable in realtime on slow machines.
  7232. @end table
  7233. For best results (without duplicated frames in the output file) it is
  7234. necessary to change the output frame rate. For example, to inverse
  7235. telecine NTSC input:
  7236. @example
  7237. ffmpeg -i input -vf pullup -r 24000/1001 ...
  7238. @end example
  7239. @section qp
  7240. Change video quantization parameters (QP).
  7241. The filter accepts the following option:
  7242. @table @option
  7243. @item qp
  7244. Set expression for quantization parameter.
  7245. @end table
  7246. The expression is evaluated through the eval API and can contain, among others,
  7247. the following constants:
  7248. @table @var
  7249. @item known
  7250. 1 if index is not 129, 0 otherwise.
  7251. @item qp
  7252. Sequentional index starting from -129 to 128.
  7253. @end table
  7254. @subsection Examples
  7255. @itemize
  7256. @item
  7257. Some equation like:
  7258. @example
  7259. qp=2+2*sin(PI*qp)
  7260. @end example
  7261. @end itemize
  7262. @section random
  7263. Flush video frames from internal cache of frames into a random order.
  7264. No frame is discarded.
  7265. Inspired by @ref{frei0r} nervous filter.
  7266. @table @option
  7267. @item frames
  7268. Set size in number of frames of internal cache, in range from @code{2} to
  7269. @code{512}. Default is @code{30}.
  7270. @item seed
  7271. Set seed for random number generator, must be an integer included between
  7272. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  7273. less than @code{0}, the filter will try to use a good random seed on a
  7274. best effort basis.
  7275. @end table
  7276. @section removegrain
  7277. The removegrain filter is a spatial denoiser for progressive video.
  7278. @table @option
  7279. @item m0
  7280. Set mode for the first plane.
  7281. @item m1
  7282. Set mode for the second plane.
  7283. @item m2
  7284. Set mode for the third plane.
  7285. @item m3
  7286. Set mode for the fourth plane.
  7287. @end table
  7288. Range of mode is from 0 to 24. Description of each mode follows:
  7289. @table @var
  7290. @item 0
  7291. Leave input plane unchanged. Default.
  7292. @item 1
  7293. Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
  7294. @item 2
  7295. Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
  7296. @item 3
  7297. Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
  7298. @item 4
  7299. Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
  7300. This is equivalent to a median filter.
  7301. @item 5
  7302. Line-sensitive clipping giving the minimal change.
  7303. @item 6
  7304. Line-sensitive clipping, intermediate.
  7305. @item 7
  7306. Line-sensitive clipping, intermediate.
  7307. @item 8
  7308. Line-sensitive clipping, intermediate.
  7309. @item 9
  7310. Line-sensitive clipping on a line where the neighbours pixels are the closest.
  7311. @item 10
  7312. Replaces the target pixel with the closest neighbour.
  7313. @item 11
  7314. [1 2 1] horizontal and vertical kernel blur.
  7315. @item 12
  7316. Same as mode 11.
  7317. @item 13
  7318. Bob mode, interpolates top field from the line where the neighbours
  7319. pixels are the closest.
  7320. @item 14
  7321. Bob mode, interpolates bottom field from the line where the neighbours
  7322. pixels are the closest.
  7323. @item 15
  7324. Bob mode, interpolates top field. Same as 13 but with a more complicated
  7325. interpolation formula.
  7326. @item 16
  7327. Bob mode, interpolates bottom field. Same as 14 but with a more complicated
  7328. interpolation formula.
  7329. @item 17
  7330. Clips the pixel with the minimum and maximum of respectively the maximum and
  7331. minimum of each pair of opposite neighbour pixels.
  7332. @item 18
  7333. Line-sensitive clipping using opposite neighbours whose greatest distance from
  7334. the current pixel is minimal.
  7335. @item 19
  7336. Replaces the pixel with the average of its 8 neighbours.
  7337. @item 20
  7338. Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
  7339. @item 21
  7340. Clips pixels using the averages of opposite neighbour.
  7341. @item 22
  7342. Same as mode 21 but simpler and faster.
  7343. @item 23
  7344. Small edge and halo removal, but reputed useless.
  7345. @item 24
  7346. Similar as 23.
  7347. @end table
  7348. @section removelogo
  7349. Suppress a TV station logo, using an image file to determine which
  7350. pixels comprise the logo. It works by filling in the pixels that
  7351. comprise the logo with neighboring pixels.
  7352. The filter accepts the following options:
  7353. @table @option
  7354. @item filename, f
  7355. Set the filter bitmap file, which can be any image format supported by
  7356. libavformat. The width and height of the image file must match those of the
  7357. video stream being processed.
  7358. @end table
  7359. Pixels in the provided bitmap image with a value of zero are not
  7360. considered part of the logo, non-zero pixels are considered part of
  7361. the logo. If you use white (255) for the logo and black (0) for the
  7362. rest, you will be safe. For making the filter bitmap, it is
  7363. recommended to take a screen capture of a black frame with the logo
  7364. visible, and then using a threshold filter followed by the erode
  7365. filter once or twice.
  7366. If needed, little splotches can be fixed manually. Remember that if
  7367. logo pixels are not covered, the filter quality will be much
  7368. reduced. Marking too many pixels as part of the logo does not hurt as
  7369. much, but it will increase the amount of blurring needed to cover over
  7370. the image and will destroy more information than necessary, and extra
  7371. pixels will slow things down on a large logo.
  7372. @section repeatfields
  7373. This filter uses the repeat_field flag from the Video ES headers and hard repeats
  7374. fields based on its value.
  7375. @section reverse, areverse
  7376. Reverse a clip.
  7377. Warning: This filter requires memory to buffer the entire clip, so trimming
  7378. is suggested.
  7379. @subsection Examples
  7380. @itemize
  7381. @item
  7382. Take the first 5 seconds of a clip, and reverse it.
  7383. @example
  7384. trim=end=5,reverse
  7385. @end example
  7386. @end itemize
  7387. @section rotate
  7388. Rotate video by an arbitrary angle expressed in radians.
  7389. The filter accepts the following options:
  7390. A description of the optional parameters follows.
  7391. @table @option
  7392. @item angle, a
  7393. Set an expression for the angle by which to rotate the input video
  7394. clockwise, expressed as a number of radians. A negative value will
  7395. result in a counter-clockwise rotation. By default it is set to "0".
  7396. This expression is evaluated for each frame.
  7397. @item out_w, ow
  7398. Set the output width expression, default value is "iw".
  7399. This expression is evaluated just once during configuration.
  7400. @item out_h, oh
  7401. Set the output height expression, default value is "ih".
  7402. This expression is evaluated just once during configuration.
  7403. @item bilinear
  7404. Enable bilinear interpolation if set to 1, a value of 0 disables
  7405. it. Default value is 1.
  7406. @item fillcolor, c
  7407. Set the color used to fill the output area not covered by the rotated
  7408. image. For the general syntax of this option, check the "Color" section in the
  7409. ffmpeg-utils manual. If the special value "none" is selected then no
  7410. background is printed (useful for example if the background is never shown).
  7411. Default value is "black".
  7412. @end table
  7413. The expressions for the angle and the output size can contain the
  7414. following constants and functions:
  7415. @table @option
  7416. @item n
  7417. sequential number of the input frame, starting from 0. It is always NAN
  7418. before the first frame is filtered.
  7419. @item t
  7420. time in seconds of the input frame, it is set to 0 when the filter is
  7421. configured. It is always NAN before the first frame is filtered.
  7422. @item hsub
  7423. @item vsub
  7424. horizontal and vertical chroma subsample values. For example for the
  7425. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7426. @item in_w, iw
  7427. @item in_h, ih
  7428. the input video width and height
  7429. @item out_w, ow
  7430. @item out_h, oh
  7431. the output width and height, that is the size of the padded area as
  7432. specified by the @var{width} and @var{height} expressions
  7433. @item rotw(a)
  7434. @item roth(a)
  7435. the minimal width/height required for completely containing the input
  7436. video rotated by @var{a} radians.
  7437. These are only available when computing the @option{out_w} and
  7438. @option{out_h} expressions.
  7439. @end table
  7440. @subsection Examples
  7441. @itemize
  7442. @item
  7443. Rotate the input by PI/6 radians clockwise:
  7444. @example
  7445. rotate=PI/6
  7446. @end example
  7447. @item
  7448. Rotate the input by PI/6 radians counter-clockwise:
  7449. @example
  7450. rotate=-PI/6
  7451. @end example
  7452. @item
  7453. Rotate the input by 45 degrees clockwise:
  7454. @example
  7455. rotate=45*PI/180
  7456. @end example
  7457. @item
  7458. Apply a constant rotation with period T, starting from an angle of PI/3:
  7459. @example
  7460. rotate=PI/3+2*PI*t/T
  7461. @end example
  7462. @item
  7463. Make the input video rotation oscillating with a period of T
  7464. seconds and an amplitude of A radians:
  7465. @example
  7466. rotate=A*sin(2*PI/T*t)
  7467. @end example
  7468. @item
  7469. Rotate the video, output size is chosen so that the whole rotating
  7470. input video is always completely contained in the output:
  7471. @example
  7472. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  7473. @end example
  7474. @item
  7475. Rotate the video, reduce the output size so that no background is ever
  7476. shown:
  7477. @example
  7478. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  7479. @end example
  7480. @end itemize
  7481. @subsection Commands
  7482. The filter supports the following commands:
  7483. @table @option
  7484. @item a, angle
  7485. Set the angle expression.
  7486. The command accepts the same syntax of the corresponding option.
  7487. If the specified expression is not valid, it is kept at its current
  7488. value.
  7489. @end table
  7490. @section sab
  7491. Apply Shape Adaptive Blur.
  7492. The filter accepts the following options:
  7493. @table @option
  7494. @item luma_radius, lr
  7495. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  7496. value is 1.0. A greater value will result in a more blurred image, and
  7497. in slower processing.
  7498. @item luma_pre_filter_radius, lpfr
  7499. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  7500. value is 1.0.
  7501. @item luma_strength, ls
  7502. Set luma maximum difference between pixels to still be considered, must
  7503. be a value in the 0.1-100.0 range, default value is 1.0.
  7504. @item chroma_radius, cr
  7505. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  7506. greater value will result in a more blurred image, and in slower
  7507. processing.
  7508. @item chroma_pre_filter_radius, cpfr
  7509. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  7510. @item chroma_strength, cs
  7511. Set chroma maximum difference between pixels to still be considered,
  7512. must be a value in the 0.1-100.0 range.
  7513. @end table
  7514. Each chroma option value, if not explicitly specified, is set to the
  7515. corresponding luma option value.
  7516. @anchor{scale}
  7517. @section scale
  7518. Scale (resize) the input video, using the libswscale library.
  7519. The scale filter forces the output display aspect ratio to be the same
  7520. of the input, by changing the output sample aspect ratio.
  7521. If the input image format is different from the format requested by
  7522. the next filter, the scale filter will convert the input to the
  7523. requested format.
  7524. @subsection Options
  7525. The filter accepts the following options, or any of the options
  7526. supported by the libswscale scaler.
  7527. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  7528. the complete list of scaler options.
  7529. @table @option
  7530. @item width, w
  7531. @item height, h
  7532. Set the output video dimension expression. Default value is the input
  7533. dimension.
  7534. If the value is 0, the input width is used for the output.
  7535. If one of the values is -1, the scale filter will use a value that
  7536. maintains the aspect ratio of the input image, calculated from the
  7537. other specified dimension. If both of them are -1, the input size is
  7538. used
  7539. If one of the values is -n with n > 1, the scale filter will also use a value
  7540. that maintains the aspect ratio of the input image, calculated from the other
  7541. specified dimension. After that it will, however, make sure that the calculated
  7542. dimension is divisible by n and adjust the value if necessary.
  7543. See below for the list of accepted constants for use in the dimension
  7544. expression.
  7545. @item interl
  7546. Set the interlacing mode. It accepts the following values:
  7547. @table @samp
  7548. @item 1
  7549. Force interlaced aware scaling.
  7550. @item 0
  7551. Do not apply interlaced scaling.
  7552. @item -1
  7553. Select interlaced aware scaling depending on whether the source frames
  7554. are flagged as interlaced or not.
  7555. @end table
  7556. Default value is @samp{0}.
  7557. @item flags
  7558. Set libswscale scaling flags. See
  7559. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  7560. complete list of values. If not explicitly specified the filter applies
  7561. the default flags.
  7562. @item size, s
  7563. Set the video size. For the syntax of this option, check the
  7564. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7565. @item in_color_matrix
  7566. @item out_color_matrix
  7567. Set in/output YCbCr color space type.
  7568. This allows the autodetected value to be overridden as well as allows forcing
  7569. a specific value used for the output and encoder.
  7570. If not specified, the color space type depends on the pixel format.
  7571. Possible values:
  7572. @table @samp
  7573. @item auto
  7574. Choose automatically.
  7575. @item bt709
  7576. Format conforming to International Telecommunication Union (ITU)
  7577. Recommendation BT.709.
  7578. @item fcc
  7579. Set color space conforming to the United States Federal Communications
  7580. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  7581. @item bt601
  7582. Set color space conforming to:
  7583. @itemize
  7584. @item
  7585. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  7586. @item
  7587. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  7588. @item
  7589. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  7590. @end itemize
  7591. @item smpte240m
  7592. Set color space conforming to SMPTE ST 240:1999.
  7593. @end table
  7594. @item in_range
  7595. @item out_range
  7596. Set in/output YCbCr sample range.
  7597. This allows the autodetected value to be overridden as well as allows forcing
  7598. a specific value used for the output and encoder. If not specified, the
  7599. range depends on the pixel format. Possible values:
  7600. @table @samp
  7601. @item auto
  7602. Choose automatically.
  7603. @item jpeg/full/pc
  7604. Set full range (0-255 in case of 8-bit luma).
  7605. @item mpeg/tv
  7606. Set "MPEG" range (16-235 in case of 8-bit luma).
  7607. @end table
  7608. @item force_original_aspect_ratio
  7609. Enable decreasing or increasing output video width or height if necessary to
  7610. keep the original aspect ratio. Possible values:
  7611. @table @samp
  7612. @item disable
  7613. Scale the video as specified and disable this feature.
  7614. @item decrease
  7615. The output video dimensions will automatically be decreased if needed.
  7616. @item increase
  7617. The output video dimensions will automatically be increased if needed.
  7618. @end table
  7619. One useful instance of this option is that when you know a specific device's
  7620. maximum allowed resolution, you can use this to limit the output video to
  7621. that, while retaining the aspect ratio. For example, device A allows
  7622. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  7623. decrease) and specifying 1280x720 to the command line makes the output
  7624. 1280x533.
  7625. Please note that this is a different thing than specifying -1 for @option{w}
  7626. or @option{h}, you still need to specify the output resolution for this option
  7627. to work.
  7628. @end table
  7629. The values of the @option{w} and @option{h} options are expressions
  7630. containing the following constants:
  7631. @table @var
  7632. @item in_w
  7633. @item in_h
  7634. The input width and height
  7635. @item iw
  7636. @item ih
  7637. These are the same as @var{in_w} and @var{in_h}.
  7638. @item out_w
  7639. @item out_h
  7640. The output (scaled) width and height
  7641. @item ow
  7642. @item oh
  7643. These are the same as @var{out_w} and @var{out_h}
  7644. @item a
  7645. The same as @var{iw} / @var{ih}
  7646. @item sar
  7647. input sample aspect ratio
  7648. @item dar
  7649. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  7650. @item hsub
  7651. @item vsub
  7652. horizontal and vertical input chroma subsample values. For example for the
  7653. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7654. @item ohsub
  7655. @item ovsub
  7656. horizontal and vertical output chroma subsample values. For example for the
  7657. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7658. @end table
  7659. @subsection Examples
  7660. @itemize
  7661. @item
  7662. Scale the input video to a size of 200x100
  7663. @example
  7664. scale=w=200:h=100
  7665. @end example
  7666. This is equivalent to:
  7667. @example
  7668. scale=200:100
  7669. @end example
  7670. or:
  7671. @example
  7672. scale=200x100
  7673. @end example
  7674. @item
  7675. Specify a size abbreviation for the output size:
  7676. @example
  7677. scale=qcif
  7678. @end example
  7679. which can also be written as:
  7680. @example
  7681. scale=size=qcif
  7682. @end example
  7683. @item
  7684. Scale the input to 2x:
  7685. @example
  7686. scale=w=2*iw:h=2*ih
  7687. @end example
  7688. @item
  7689. The above is the same as:
  7690. @example
  7691. scale=2*in_w:2*in_h
  7692. @end example
  7693. @item
  7694. Scale the input to 2x with forced interlaced scaling:
  7695. @example
  7696. scale=2*iw:2*ih:interl=1
  7697. @end example
  7698. @item
  7699. Scale the input to half size:
  7700. @example
  7701. scale=w=iw/2:h=ih/2
  7702. @end example
  7703. @item
  7704. Increase the width, and set the height to the same size:
  7705. @example
  7706. scale=3/2*iw:ow
  7707. @end example
  7708. @item
  7709. Seek Greek harmony:
  7710. @example
  7711. scale=iw:1/PHI*iw
  7712. scale=ih*PHI:ih
  7713. @end example
  7714. @item
  7715. Increase the height, and set the width to 3/2 of the height:
  7716. @example
  7717. scale=w=3/2*oh:h=3/5*ih
  7718. @end example
  7719. @item
  7720. Increase the size, making the size a multiple of the chroma
  7721. subsample values:
  7722. @example
  7723. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  7724. @end example
  7725. @item
  7726. Increase the width to a maximum of 500 pixels,
  7727. keeping the same aspect ratio as the input:
  7728. @example
  7729. scale=w='min(500\, iw*3/2):h=-1'
  7730. @end example
  7731. @end itemize
  7732. @subsection Commands
  7733. This filter supports the following commands:
  7734. @table @option
  7735. @item width, w
  7736. @item height, h
  7737. Set the output video dimension expression.
  7738. The command accepts the same syntax of the corresponding option.
  7739. If the specified expression is not valid, it is kept at its current
  7740. value.
  7741. @end table
  7742. @section scale2ref
  7743. Scale (resize) the input video, based on a reference video.
  7744. See the scale filter for available options, scale2ref supports the same but
  7745. uses the reference video instead of the main input as basis.
  7746. @subsection Examples
  7747. @itemize
  7748. @item
  7749. Scale a subtitle stream to match the main video in size before overlaying
  7750. @example
  7751. 'scale2ref[b][a];[a][b]overlay'
  7752. @end example
  7753. @end itemize
  7754. @section selectivecolor
  7755. Adjust cyan, magenta, yellow and black (CMYK) to certain ranges of colors (such
  7756. as "reds", "yellows", "greens", "cyans", ...). The adjustment range is defined
  7757. by the "purity" of the color (that is, how saturated it already is).
  7758. This filter is similar to the Adobe Photoshop Selective Color tool.
  7759. The filter accepts the following options:
  7760. @table @option
  7761. @item correction_method
  7762. Select color correction method.
  7763. Available values are:
  7764. @table @samp
  7765. @item absolute
  7766. Specified adjustments are applied "as-is" (added/subtracted to original pixel
  7767. component value).
  7768. @item relative
  7769. Specified adjustments are relative to the original component value.
  7770. @end table
  7771. Default is @code{absolute}.
  7772. @item reds
  7773. Adjustments for red pixels (pixels where the red component is the maximum)
  7774. @item yellows
  7775. Adjustments for yellow pixels (pixels where the blue component is the minimum)
  7776. @item greens
  7777. Adjustments for green pixels (pixels where the green component is the maximum)
  7778. @item cyans
  7779. Adjustments for cyan pixels (pixels where the red component is the minimum)
  7780. @item blues
  7781. Adjustments for blue pixels (pixels where the blue component is the maximum)
  7782. @item magentas
  7783. Adjustments for magenta pixels (pixels where the green component is the minimum)
  7784. @item whites
  7785. Adjustments for white pixels (pixels where all components are greater than 128)
  7786. @item neutrals
  7787. Adjustments for all pixels except pure black and pure white
  7788. @item blacks
  7789. Adjustments for black pixels (pixels where all components are lesser than 128)
  7790. @item psfile
  7791. Specify a Photoshop selective color file (@code{.asv}) to import the settings from.
  7792. @end table
  7793. All the adjustment settings (@option{reds}, @option{yellows}, ...) accept up to
  7794. 4 space separated floating point adjustment values in the [-1,1] range,
  7795. respectively to adjust the amount of cyan, magenta, yellow and black for the
  7796. pixels of its range.
  7797. @subsection Examples
  7798. @itemize
  7799. @item
  7800. Increase cyan by 50% and reduce yellow by 33% in every green areas, and
  7801. increase magenta by 27% in blue areas:
  7802. @example
  7803. selectivecolor=greens=.5 0 -.33 0:blues=0 .27
  7804. @end example
  7805. @item
  7806. Use a Photoshop selective color preset:
  7807. @example
  7808. selectivecolor=psfile=MySelectiveColorPresets/Misty.asv
  7809. @end example
  7810. @end itemize
  7811. @section separatefields
  7812. The @code{separatefields} takes a frame-based video input and splits
  7813. each frame into its components fields, producing a new half height clip
  7814. with twice the frame rate and twice the frame count.
  7815. This filter use field-dominance information in frame to decide which
  7816. of each pair of fields to place first in the output.
  7817. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  7818. @section setdar, setsar
  7819. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  7820. output video.
  7821. This is done by changing the specified Sample (aka Pixel) Aspect
  7822. Ratio, according to the following equation:
  7823. @example
  7824. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  7825. @end example
  7826. Keep in mind that the @code{setdar} filter does not modify the pixel
  7827. dimensions of the video frame. Also, the display aspect ratio set by
  7828. this filter may be changed by later filters in the filterchain,
  7829. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  7830. applied.
  7831. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  7832. the filter output video.
  7833. Note that as a consequence of the application of this filter, the
  7834. output display aspect ratio will change according to the equation
  7835. above.
  7836. Keep in mind that the sample aspect ratio set by the @code{setsar}
  7837. filter may be changed by later filters in the filterchain, e.g. if
  7838. another "setsar" or a "setdar" filter is applied.
  7839. It accepts the following parameters:
  7840. @table @option
  7841. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  7842. Set the aspect ratio used by the filter.
  7843. The parameter can be a floating point number string, an expression, or
  7844. a string of the form @var{num}:@var{den}, where @var{num} and
  7845. @var{den} are the numerator and denominator of the aspect ratio. If
  7846. the parameter is not specified, it is assumed the value "0".
  7847. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  7848. should be escaped.
  7849. @item max
  7850. Set the maximum integer value to use for expressing numerator and
  7851. denominator when reducing the expressed aspect ratio to a rational.
  7852. Default value is @code{100}.
  7853. @end table
  7854. The parameter @var{sar} is an expression containing
  7855. the following constants:
  7856. @table @option
  7857. @item E, PI, PHI
  7858. These are approximated values for the mathematical constants e
  7859. (Euler's number), pi (Greek pi), and phi (the golden ratio).
  7860. @item w, h
  7861. The input width and height.
  7862. @item a
  7863. These are the same as @var{w} / @var{h}.
  7864. @item sar
  7865. The input sample aspect ratio.
  7866. @item dar
  7867. The input display aspect ratio. It is the same as
  7868. (@var{w} / @var{h}) * @var{sar}.
  7869. @item hsub, vsub
  7870. Horizontal and vertical chroma subsample values. For example, for the
  7871. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7872. @end table
  7873. @subsection Examples
  7874. @itemize
  7875. @item
  7876. To change the display aspect ratio to 16:9, specify one of the following:
  7877. @example
  7878. setdar=dar=1.77777
  7879. setdar=dar=16/9
  7880. setdar=dar=1.77777
  7881. @end example
  7882. @item
  7883. To change the sample aspect ratio to 10:11, specify:
  7884. @example
  7885. setsar=sar=10/11
  7886. @end example
  7887. @item
  7888. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  7889. 1000 in the aspect ratio reduction, use the command:
  7890. @example
  7891. setdar=ratio=16/9:max=1000
  7892. @end example
  7893. @end itemize
  7894. @anchor{setfield}
  7895. @section setfield
  7896. Force field for the output video frame.
  7897. The @code{setfield} filter marks the interlace type field for the
  7898. output frames. It does not change the input frame, but only sets the
  7899. corresponding property, which affects how the frame is treated by
  7900. following filters (e.g. @code{fieldorder} or @code{yadif}).
  7901. The filter accepts the following options:
  7902. @table @option
  7903. @item mode
  7904. Available values are:
  7905. @table @samp
  7906. @item auto
  7907. Keep the same field property.
  7908. @item bff
  7909. Mark the frame as bottom-field-first.
  7910. @item tff
  7911. Mark the frame as top-field-first.
  7912. @item prog
  7913. Mark the frame as progressive.
  7914. @end table
  7915. @end table
  7916. @section showinfo
  7917. Show a line containing various information for each input video frame.
  7918. The input video is not modified.
  7919. The shown line contains a sequence of key/value pairs of the form
  7920. @var{key}:@var{value}.
  7921. The following values are shown in the output:
  7922. @table @option
  7923. @item n
  7924. The (sequential) number of the input frame, starting from 0.
  7925. @item pts
  7926. The Presentation TimeStamp of the input frame, expressed as a number of
  7927. time base units. The time base unit depends on the filter input pad.
  7928. @item pts_time
  7929. The Presentation TimeStamp of the input frame, expressed as a number of
  7930. seconds.
  7931. @item pos
  7932. The position of the frame in the input stream, or -1 if this information is
  7933. unavailable and/or meaningless (for example in case of synthetic video).
  7934. @item fmt
  7935. The pixel format name.
  7936. @item sar
  7937. The sample aspect ratio of the input frame, expressed in the form
  7938. @var{num}/@var{den}.
  7939. @item s
  7940. The size of the input frame. For the syntax of this option, check the
  7941. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7942. @item i
  7943. The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
  7944. for bottom field first).
  7945. @item iskey
  7946. This is 1 if the frame is a key frame, 0 otherwise.
  7947. @item type
  7948. The picture type of the input frame ("I" for an I-frame, "P" for a
  7949. P-frame, "B" for a B-frame, or "?" for an unknown type).
  7950. Also refer to the documentation of the @code{AVPictureType} enum and of
  7951. the @code{av_get_picture_type_char} function defined in
  7952. @file{libavutil/avutil.h}.
  7953. @item checksum
  7954. The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
  7955. @item plane_checksum
  7956. The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  7957. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
  7958. @end table
  7959. @section showpalette
  7960. Displays the 256 colors palette of each frame. This filter is only relevant for
  7961. @var{pal8} pixel format frames.
  7962. It accepts the following option:
  7963. @table @option
  7964. @item s
  7965. Set the size of the box used to represent one palette color entry. Default is
  7966. @code{30} (for a @code{30x30} pixel box).
  7967. @end table
  7968. @section shuffleframes
  7969. Reorder and/or duplicate video frames.
  7970. It accepts the following parameters:
  7971. @table @option
  7972. @item mapping
  7973. Set the destination indexes of input frames.
  7974. This is space or '|' separated list of indexes that maps input frames to output
  7975. frames. Number of indexes also sets maximal value that each index may have.
  7976. @end table
  7977. The first frame has the index 0. The default is to keep the input unchanged.
  7978. Swap second and third frame of every three frames of the input:
  7979. @example
  7980. ffmpeg -i INPUT -vf "shuffleframes=0 2 1" OUTPUT
  7981. @end example
  7982. @section shuffleplanes
  7983. Reorder and/or duplicate video planes.
  7984. It accepts the following parameters:
  7985. @table @option
  7986. @item map0
  7987. The index of the input plane to be used as the first output plane.
  7988. @item map1
  7989. The index of the input plane to be used as the second output plane.
  7990. @item map2
  7991. The index of the input plane to be used as the third output plane.
  7992. @item map3
  7993. The index of the input plane to be used as the fourth output plane.
  7994. @end table
  7995. The first plane has the index 0. The default is to keep the input unchanged.
  7996. Swap the second and third planes of the input:
  7997. @example
  7998. ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
  7999. @end example
  8000. @anchor{signalstats}
  8001. @section signalstats
  8002. Evaluate various visual metrics that assist in determining issues associated
  8003. with the digitization of analog video media.
  8004. By default the filter will log these metadata values:
  8005. @table @option
  8006. @item YMIN
  8007. Display the minimal Y value contained within the input frame. Expressed in
  8008. range of [0-255].
  8009. @item YLOW
  8010. Display the Y value at the 10% percentile within the input frame. Expressed in
  8011. range of [0-255].
  8012. @item YAVG
  8013. Display the average Y value within the input frame. Expressed in range of
  8014. [0-255].
  8015. @item YHIGH
  8016. Display the Y value at the 90% percentile within the input frame. Expressed in
  8017. range of [0-255].
  8018. @item YMAX
  8019. Display the maximum Y value contained within the input frame. Expressed in
  8020. range of [0-255].
  8021. @item UMIN
  8022. Display the minimal U value contained within the input frame. Expressed in
  8023. range of [0-255].
  8024. @item ULOW
  8025. Display the U value at the 10% percentile within the input frame. Expressed in
  8026. range of [0-255].
  8027. @item UAVG
  8028. Display the average U value within the input frame. Expressed in range of
  8029. [0-255].
  8030. @item UHIGH
  8031. Display the U value at the 90% percentile within the input frame. Expressed in
  8032. range of [0-255].
  8033. @item UMAX
  8034. Display the maximum U value contained within the input frame. Expressed in
  8035. range of [0-255].
  8036. @item VMIN
  8037. Display the minimal V value contained within the input frame. Expressed in
  8038. range of [0-255].
  8039. @item VLOW
  8040. Display the V value at the 10% percentile within the input frame. Expressed in
  8041. range of [0-255].
  8042. @item VAVG
  8043. Display the average V value within the input frame. Expressed in range of
  8044. [0-255].
  8045. @item VHIGH
  8046. Display the V value at the 90% percentile within the input frame. Expressed in
  8047. range of [0-255].
  8048. @item VMAX
  8049. Display the maximum V value contained within the input frame. Expressed in
  8050. range of [0-255].
  8051. @item SATMIN
  8052. Display the minimal saturation value contained within the input frame.
  8053. Expressed in range of [0-~181.02].
  8054. @item SATLOW
  8055. Display the saturation value at the 10% percentile within the input frame.
  8056. Expressed in range of [0-~181.02].
  8057. @item SATAVG
  8058. Display the average saturation value within the input frame. Expressed in range
  8059. of [0-~181.02].
  8060. @item SATHIGH
  8061. Display the saturation value at the 90% percentile within the input frame.
  8062. Expressed in range of [0-~181.02].
  8063. @item SATMAX
  8064. Display the maximum saturation value contained within the input frame.
  8065. Expressed in range of [0-~181.02].
  8066. @item HUEMED
  8067. Display the median value for hue within the input frame. Expressed in range of
  8068. [0-360].
  8069. @item HUEAVG
  8070. Display the average value for hue within the input frame. Expressed in range of
  8071. [0-360].
  8072. @item YDIF
  8073. Display the average of sample value difference between all values of the Y
  8074. plane in the current frame and corresponding values of the previous input frame.
  8075. Expressed in range of [0-255].
  8076. @item UDIF
  8077. Display the average of sample value difference between all values of the U
  8078. plane in the current frame and corresponding values of the previous input frame.
  8079. Expressed in range of [0-255].
  8080. @item VDIF
  8081. Display the average of sample value difference between all values of the V
  8082. plane in the current frame and corresponding values of the previous input frame.
  8083. Expressed in range of [0-255].
  8084. @end table
  8085. The filter accepts the following options:
  8086. @table @option
  8087. @item stat
  8088. @item out
  8089. @option{stat} specify an additional form of image analysis.
  8090. @option{out} output video with the specified type of pixel highlighted.
  8091. Both options accept the following values:
  8092. @table @samp
  8093. @item tout
  8094. Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
  8095. unlike the neighboring pixels of the same field. Examples of temporal outliers
  8096. include the results of video dropouts, head clogs, or tape tracking issues.
  8097. @item vrep
  8098. Identify @var{vertical line repetition}. Vertical line repetition includes
  8099. similar rows of pixels within a frame. In born-digital video vertical line
  8100. repetition is common, but this pattern is uncommon in video digitized from an
  8101. analog source. When it occurs in video that results from the digitization of an
  8102. analog source it can indicate concealment from a dropout compensator.
  8103. @item brng
  8104. Identify pixels that fall outside of legal broadcast range.
  8105. @end table
  8106. @item color, c
  8107. Set the highlight color for the @option{out} option. The default color is
  8108. yellow.
  8109. @end table
  8110. @subsection Examples
  8111. @itemize
  8112. @item
  8113. Output data of various video metrics:
  8114. @example
  8115. ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
  8116. @end example
  8117. @item
  8118. Output specific data about the minimum and maximum values of the Y plane per frame:
  8119. @example
  8120. ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
  8121. @end example
  8122. @item
  8123. Playback video while highlighting pixels that are outside of broadcast range in red.
  8124. @example
  8125. ffplay example.mov -vf signalstats="out=brng:color=red"
  8126. @end example
  8127. @item
  8128. Playback video with signalstats metadata drawn over the frame.
  8129. @example
  8130. ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
  8131. @end example
  8132. The contents of signalstat_drawtext.txt used in the command are:
  8133. @example
  8134. time %@{pts:hms@}
  8135. Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
  8136. U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
  8137. V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
  8138. saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
  8139. @end example
  8140. @end itemize
  8141. @anchor{smartblur}
  8142. @section smartblur
  8143. Blur the input video without impacting the outlines.
  8144. It accepts the following options:
  8145. @table @option
  8146. @item luma_radius, lr
  8147. Set the luma radius. The option value must be a float number in
  8148. the range [0.1,5.0] that specifies the variance of the gaussian filter
  8149. used to blur the image (slower if larger). Default value is 1.0.
  8150. @item luma_strength, ls
  8151. Set the luma strength. The option value must be a float number
  8152. in the range [-1.0,1.0] that configures the blurring. A value included
  8153. in [0.0,1.0] will blur the image whereas a value included in
  8154. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  8155. @item luma_threshold, lt
  8156. Set the luma threshold used as a coefficient to determine
  8157. whether a pixel should be blurred or not. The option value must be an
  8158. integer in the range [-30,30]. A value of 0 will filter all the image,
  8159. a value included in [0,30] will filter flat areas and a value included
  8160. in [-30,0] will filter edges. Default value is 0.
  8161. @item chroma_radius, cr
  8162. Set the chroma radius. The option value must be a float number in
  8163. the range [0.1,5.0] that specifies the variance of the gaussian filter
  8164. used to blur the image (slower if larger). Default value is 1.0.
  8165. @item chroma_strength, cs
  8166. Set the chroma strength. The option value must be a float number
  8167. in the range [-1.0,1.0] that configures the blurring. A value included
  8168. in [0.0,1.0] will blur the image whereas a value included in
  8169. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  8170. @item chroma_threshold, ct
  8171. Set the chroma threshold used as a coefficient to determine
  8172. whether a pixel should be blurred or not. The option value must be an
  8173. integer in the range [-30,30]. A value of 0 will filter all the image,
  8174. a value included in [0,30] will filter flat areas and a value included
  8175. in [-30,0] will filter edges. Default value is 0.
  8176. @end table
  8177. If a chroma option is not explicitly set, the corresponding luma value
  8178. is set.
  8179. @section ssim
  8180. Obtain the SSIM (Structural SImilarity Metric) between two input videos.
  8181. This filter takes in input two input videos, the first input is
  8182. considered the "main" source and is passed unchanged to the
  8183. output. The second input is used as a "reference" video for computing
  8184. the SSIM.
  8185. Both video inputs must have the same resolution and pixel format for
  8186. this filter to work correctly. Also it assumes that both inputs
  8187. have the same number of frames, which are compared one by one.
  8188. The filter stores the calculated SSIM of each frame.
  8189. The description of the accepted parameters follows.
  8190. @table @option
  8191. @item stats_file, f
  8192. If specified the filter will use the named file to save the SSIM of
  8193. each individual frame. When filename equals "-" the data is sent to
  8194. standard output.
  8195. @end table
  8196. The file printed if @var{stats_file} is selected, contains a sequence of
  8197. key/value pairs of the form @var{key}:@var{value} for each compared
  8198. couple of frames.
  8199. A description of each shown parameter follows:
  8200. @table @option
  8201. @item n
  8202. sequential number of the input frame, starting from 1
  8203. @item Y, U, V, R, G, B
  8204. SSIM of the compared frames for the component specified by the suffix.
  8205. @item All
  8206. SSIM of the compared frames for the whole frame.
  8207. @item dB
  8208. Same as above but in dB representation.
  8209. @end table
  8210. For example:
  8211. @example
  8212. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  8213. [main][ref] ssim="stats_file=stats.log" [out]
  8214. @end example
  8215. On this example the input file being processed is compared with the
  8216. reference file @file{ref_movie.mpg}. The SSIM of each individual frame
  8217. is stored in @file{stats.log}.
  8218. Another example with both psnr and ssim at same time:
  8219. @example
  8220. ffmpeg -i main.mpg -i ref.mpg -lavfi "ssim;[0:v][1:v]psnr" -f null -
  8221. @end example
  8222. @section stereo3d
  8223. Convert between different stereoscopic image formats.
  8224. The filters accept the following options:
  8225. @table @option
  8226. @item in
  8227. Set stereoscopic image format of input.
  8228. Available values for input image formats are:
  8229. @table @samp
  8230. @item sbsl
  8231. side by side parallel (left eye left, right eye right)
  8232. @item sbsr
  8233. side by side crosseye (right eye left, left eye right)
  8234. @item sbs2l
  8235. side by side parallel with half width resolution
  8236. (left eye left, right eye right)
  8237. @item sbs2r
  8238. side by side crosseye with half width resolution
  8239. (right eye left, left eye right)
  8240. @item abl
  8241. above-below (left eye above, right eye below)
  8242. @item abr
  8243. above-below (right eye above, left eye below)
  8244. @item ab2l
  8245. above-below with half height resolution
  8246. (left eye above, right eye below)
  8247. @item ab2r
  8248. above-below with half height resolution
  8249. (right eye above, left eye below)
  8250. @item al
  8251. alternating frames (left eye first, right eye second)
  8252. @item ar
  8253. alternating frames (right eye first, left eye second)
  8254. @item irl
  8255. interleaved rows (left eye has top row, right eye starts on next row)
  8256. @item irr
  8257. interleaved rows (right eye has top row, left eye starts on next row)
  8258. Default value is @samp{sbsl}.
  8259. @end table
  8260. @item out
  8261. Set stereoscopic image format of output.
  8262. Available values for output image formats are all the input formats as well as:
  8263. @table @samp
  8264. @item arbg
  8265. anaglyph red/blue gray
  8266. (red filter on left eye, blue filter on right eye)
  8267. @item argg
  8268. anaglyph red/green gray
  8269. (red filter on left eye, green filter on right eye)
  8270. @item arcg
  8271. anaglyph red/cyan gray
  8272. (red filter on left eye, cyan filter on right eye)
  8273. @item arch
  8274. anaglyph red/cyan half colored
  8275. (red filter on left eye, cyan filter on right eye)
  8276. @item arcc
  8277. anaglyph red/cyan color
  8278. (red filter on left eye, cyan filter on right eye)
  8279. @item arcd
  8280. anaglyph red/cyan color optimized with the least squares projection of dubois
  8281. (red filter on left eye, cyan filter on right eye)
  8282. @item agmg
  8283. anaglyph green/magenta gray
  8284. (green filter on left eye, magenta filter on right eye)
  8285. @item agmh
  8286. anaglyph green/magenta half colored
  8287. (green filter on left eye, magenta filter on right eye)
  8288. @item agmc
  8289. anaglyph green/magenta colored
  8290. (green filter on left eye, magenta filter on right eye)
  8291. @item agmd
  8292. anaglyph green/magenta color optimized with the least squares projection of dubois
  8293. (green filter on left eye, magenta filter on right eye)
  8294. @item aybg
  8295. anaglyph yellow/blue gray
  8296. (yellow filter on left eye, blue filter on right eye)
  8297. @item aybh
  8298. anaglyph yellow/blue half colored
  8299. (yellow filter on left eye, blue filter on right eye)
  8300. @item aybc
  8301. anaglyph yellow/blue colored
  8302. (yellow filter on left eye, blue filter on right eye)
  8303. @item aybd
  8304. anaglyph yellow/blue color optimized with the least squares projection of dubois
  8305. (yellow filter on left eye, blue filter on right eye)
  8306. @item ml
  8307. mono output (left eye only)
  8308. @item mr
  8309. mono output (right eye only)
  8310. @item chl
  8311. checkerboard, left eye first
  8312. @item chr
  8313. checkerboard, right eye first
  8314. @item icl
  8315. interleaved columns, left eye first
  8316. @item icr
  8317. interleaved columns, right eye first
  8318. @end table
  8319. Default value is @samp{arcd}.
  8320. @end table
  8321. @subsection Examples
  8322. @itemize
  8323. @item
  8324. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  8325. @example
  8326. stereo3d=sbsl:aybd
  8327. @end example
  8328. @item
  8329. Convert input video from above below (left eye above, right eye below) to side by side crosseye.
  8330. @example
  8331. stereo3d=abl:sbsr
  8332. @end example
  8333. @end itemize
  8334. @anchor{spp}
  8335. @section spp
  8336. Apply a simple postprocessing filter that compresses and decompresses the image
  8337. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  8338. and average the results.
  8339. The filter accepts the following options:
  8340. @table @option
  8341. @item quality
  8342. Set quality. This option defines the number of levels for averaging. It accepts
  8343. an integer in the range 0-6. If set to @code{0}, the filter will have no
  8344. effect. A value of @code{6} means the higher quality. For each increment of
  8345. that value the speed drops by a factor of approximately 2. Default value is
  8346. @code{3}.
  8347. @item qp
  8348. Force a constant quantization parameter. If not set, the filter will use the QP
  8349. from the video stream (if available).
  8350. @item mode
  8351. Set thresholding mode. Available modes are:
  8352. @table @samp
  8353. @item hard
  8354. Set hard thresholding (default).
  8355. @item soft
  8356. Set soft thresholding (better de-ringing effect, but likely blurrier).
  8357. @end table
  8358. @item use_bframe_qp
  8359. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  8360. option may cause flicker since the B-Frames have often larger QP. Default is
  8361. @code{0} (not enabled).
  8362. @end table
  8363. @anchor{subtitles}
  8364. @section subtitles
  8365. Draw subtitles on top of input video using the libass library.
  8366. To enable compilation of this filter you need to configure FFmpeg with
  8367. @code{--enable-libass}. This filter also requires a build with libavcodec and
  8368. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  8369. Alpha) subtitles format.
  8370. The filter accepts the following options:
  8371. @table @option
  8372. @item filename, f
  8373. Set the filename of the subtitle file to read. It must be specified.
  8374. @item original_size
  8375. Specify the size of the original video, the video for which the ASS file
  8376. was composed. For the syntax of this option, check the
  8377. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8378. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
  8379. correctly scale the fonts if the aspect ratio has been changed.
  8380. @item fontsdir
  8381. Set a directory path containing fonts that can be used by the filter.
  8382. These fonts will be used in addition to whatever the font provider uses.
  8383. @item charenc
  8384. Set subtitles input character encoding. @code{subtitles} filter only. Only
  8385. useful if not UTF-8.
  8386. @item stream_index, si
  8387. Set subtitles stream index. @code{subtitles} filter only.
  8388. @item force_style
  8389. Override default style or script info parameters of the subtitles. It accepts a
  8390. string containing ASS style format @code{KEY=VALUE} couples separated by ",".
  8391. @end table
  8392. If the first key is not specified, it is assumed that the first value
  8393. specifies the @option{filename}.
  8394. For example, to render the file @file{sub.srt} on top of the input
  8395. video, use the command:
  8396. @example
  8397. subtitles=sub.srt
  8398. @end example
  8399. which is equivalent to:
  8400. @example
  8401. subtitles=filename=sub.srt
  8402. @end example
  8403. To render the default subtitles stream from file @file{video.mkv}, use:
  8404. @example
  8405. subtitles=video.mkv
  8406. @end example
  8407. To render the second subtitles stream from that file, use:
  8408. @example
  8409. subtitles=video.mkv:si=1
  8410. @end example
  8411. To make the subtitles stream from @file{sub.srt} appear in transparent green
  8412. @code{DejaVu Serif}, use:
  8413. @example
  8414. subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
  8415. @end example
  8416. @section super2xsai
  8417. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  8418. Interpolate) pixel art scaling algorithm.
  8419. Useful for enlarging pixel art images without reducing sharpness.
  8420. @section swapuv
  8421. Swap U & V plane.
  8422. @section telecine
  8423. Apply telecine process to the video.
  8424. This filter accepts the following options:
  8425. @table @option
  8426. @item first_field
  8427. @table @samp
  8428. @item top, t
  8429. top field first
  8430. @item bottom, b
  8431. bottom field first
  8432. The default value is @code{top}.
  8433. @end table
  8434. @item pattern
  8435. A string of numbers representing the pulldown pattern you wish to apply.
  8436. The default value is @code{23}.
  8437. @end table
  8438. @example
  8439. Some typical patterns:
  8440. NTSC output (30i):
  8441. 27.5p: 32222
  8442. 24p: 23 (classic)
  8443. 24p: 2332 (preferred)
  8444. 20p: 33
  8445. 18p: 334
  8446. 16p: 3444
  8447. PAL output (25i):
  8448. 27.5p: 12222
  8449. 24p: 222222222223 ("Euro pulldown")
  8450. 16.67p: 33
  8451. 16p: 33333334
  8452. @end example
  8453. @section thumbnail
  8454. Select the most representative frame in a given sequence of consecutive frames.
  8455. The filter accepts the following options:
  8456. @table @option
  8457. @item n
  8458. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  8459. will pick one of them, and then handle the next batch of @var{n} frames until
  8460. the end. Default is @code{100}.
  8461. @end table
  8462. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  8463. value will result in a higher memory usage, so a high value is not recommended.
  8464. @subsection Examples
  8465. @itemize
  8466. @item
  8467. Extract one picture each 50 frames:
  8468. @example
  8469. thumbnail=50
  8470. @end example
  8471. @item
  8472. Complete example of a thumbnail creation with @command{ffmpeg}:
  8473. @example
  8474. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  8475. @end example
  8476. @end itemize
  8477. @section tile
  8478. Tile several successive frames together.
  8479. The filter accepts the following options:
  8480. @table @option
  8481. @item layout
  8482. Set the grid size (i.e. the number of lines and columns). For the syntax of
  8483. this option, check the
  8484. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8485. @item nb_frames
  8486. Set the maximum number of frames to render in the given area. It must be less
  8487. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  8488. the area will be used.
  8489. @item margin
  8490. Set the outer border margin in pixels.
  8491. @item padding
  8492. Set the inner border thickness (i.e. the number of pixels between frames). For
  8493. more advanced padding options (such as having different values for the edges),
  8494. refer to the pad video filter.
  8495. @item color
  8496. Specify the color of the unused area. For the syntax of this option, check the
  8497. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  8498. is "black".
  8499. @end table
  8500. @subsection Examples
  8501. @itemize
  8502. @item
  8503. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  8504. @example
  8505. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  8506. @end example
  8507. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  8508. duplicating each output frame to accommodate the originally detected frame
  8509. rate.
  8510. @item
  8511. Display @code{5} pictures in an area of @code{3x2} frames,
  8512. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  8513. mixed flat and named options:
  8514. @example
  8515. tile=3x2:nb_frames=5:padding=7:margin=2
  8516. @end example
  8517. @end itemize
  8518. @section tinterlace
  8519. Perform various types of temporal field interlacing.
  8520. Frames are counted starting from 1, so the first input frame is
  8521. considered odd.
  8522. The filter accepts the following options:
  8523. @table @option
  8524. @item mode
  8525. Specify the mode of the interlacing. This option can also be specified
  8526. as a value alone. See below for a list of values for this option.
  8527. Available values are:
  8528. @table @samp
  8529. @item merge, 0
  8530. Move odd frames into the upper field, even into the lower field,
  8531. generating a double height frame at half frame rate.
  8532. @example
  8533. ------> time
  8534. Input:
  8535. Frame 1 Frame 2 Frame 3 Frame 4
  8536. 11111 22222 33333 44444
  8537. 11111 22222 33333 44444
  8538. 11111 22222 33333 44444
  8539. 11111 22222 33333 44444
  8540. Output:
  8541. 11111 33333
  8542. 22222 44444
  8543. 11111 33333
  8544. 22222 44444
  8545. 11111 33333
  8546. 22222 44444
  8547. 11111 33333
  8548. 22222 44444
  8549. @end example
  8550. @item drop_odd, 1
  8551. Only output even frames, odd frames are dropped, generating a frame with
  8552. unchanged height at half frame rate.
  8553. @example
  8554. ------> time
  8555. Input:
  8556. Frame 1 Frame 2 Frame 3 Frame 4
  8557. 11111 22222 33333 44444
  8558. 11111 22222 33333 44444
  8559. 11111 22222 33333 44444
  8560. 11111 22222 33333 44444
  8561. Output:
  8562. 22222 44444
  8563. 22222 44444
  8564. 22222 44444
  8565. 22222 44444
  8566. @end example
  8567. @item drop_even, 2
  8568. Only output odd frames, even frames are dropped, generating a frame with
  8569. unchanged height at half frame rate.
  8570. @example
  8571. ------> time
  8572. Input:
  8573. Frame 1 Frame 2 Frame 3 Frame 4
  8574. 11111 22222 33333 44444
  8575. 11111 22222 33333 44444
  8576. 11111 22222 33333 44444
  8577. 11111 22222 33333 44444
  8578. Output:
  8579. 11111 33333
  8580. 11111 33333
  8581. 11111 33333
  8582. 11111 33333
  8583. @end example
  8584. @item pad, 3
  8585. Expand each frame to full height, but pad alternate lines with black,
  8586. generating a frame with double height at the same input frame rate.
  8587. @example
  8588. ------> time
  8589. Input:
  8590. Frame 1 Frame 2 Frame 3 Frame 4
  8591. 11111 22222 33333 44444
  8592. 11111 22222 33333 44444
  8593. 11111 22222 33333 44444
  8594. 11111 22222 33333 44444
  8595. Output:
  8596. 11111 ..... 33333 .....
  8597. ..... 22222 ..... 44444
  8598. 11111 ..... 33333 .....
  8599. ..... 22222 ..... 44444
  8600. 11111 ..... 33333 .....
  8601. ..... 22222 ..... 44444
  8602. 11111 ..... 33333 .....
  8603. ..... 22222 ..... 44444
  8604. @end example
  8605. @item interleave_top, 4
  8606. Interleave the upper field from odd frames with the lower field from
  8607. even frames, generating a frame with unchanged height at half frame rate.
  8608. @example
  8609. ------> time
  8610. Input:
  8611. Frame 1 Frame 2 Frame 3 Frame 4
  8612. 11111<- 22222 33333<- 44444
  8613. 11111 22222<- 33333 44444<-
  8614. 11111<- 22222 33333<- 44444
  8615. 11111 22222<- 33333 44444<-
  8616. Output:
  8617. 11111 33333
  8618. 22222 44444
  8619. 11111 33333
  8620. 22222 44444
  8621. @end example
  8622. @item interleave_bottom, 5
  8623. Interleave the lower field from odd frames with the upper field from
  8624. even frames, generating a frame with unchanged height at half frame rate.
  8625. @example
  8626. ------> time
  8627. Input:
  8628. Frame 1 Frame 2 Frame 3 Frame 4
  8629. 11111 22222<- 33333 44444<-
  8630. 11111<- 22222 33333<- 44444
  8631. 11111 22222<- 33333 44444<-
  8632. 11111<- 22222 33333<- 44444
  8633. Output:
  8634. 22222 44444
  8635. 11111 33333
  8636. 22222 44444
  8637. 11111 33333
  8638. @end example
  8639. @item interlacex2, 6
  8640. Double frame rate with unchanged height. Frames are inserted each
  8641. containing the second temporal field from the previous input frame and
  8642. the first temporal field from the next input frame. This mode relies on
  8643. the top_field_first flag. Useful for interlaced video displays with no
  8644. field synchronisation.
  8645. @example
  8646. ------> time
  8647. Input:
  8648. Frame 1 Frame 2 Frame 3 Frame 4
  8649. 11111 22222 33333 44444
  8650. 11111 22222 33333 44444
  8651. 11111 22222 33333 44444
  8652. 11111 22222 33333 44444
  8653. Output:
  8654. 11111 22222 22222 33333 33333 44444 44444
  8655. 11111 11111 22222 22222 33333 33333 44444
  8656. 11111 22222 22222 33333 33333 44444 44444
  8657. 11111 11111 22222 22222 33333 33333 44444
  8658. @end example
  8659. @item mergex2, 7
  8660. Move odd frames into the upper field, even into the lower field,
  8661. generating a double height frame at same frame rate.
  8662. @example
  8663. ------> time
  8664. Input:
  8665. Frame 1 Frame 2 Frame 3 Frame 4
  8666. 11111 22222 33333 44444
  8667. 11111 22222 33333 44444
  8668. 11111 22222 33333 44444
  8669. 11111 22222 33333 44444
  8670. Output:
  8671. 11111 33333 33333 55555
  8672. 22222 22222 44444 44444
  8673. 11111 33333 33333 55555
  8674. 22222 22222 44444 44444
  8675. 11111 33333 33333 55555
  8676. 22222 22222 44444 44444
  8677. 11111 33333 33333 55555
  8678. 22222 22222 44444 44444
  8679. @end example
  8680. @end table
  8681. Numeric values are deprecated but are accepted for backward
  8682. compatibility reasons.
  8683. Default mode is @code{merge}.
  8684. @item flags
  8685. Specify flags influencing the filter process.
  8686. Available value for @var{flags} is:
  8687. @table @option
  8688. @item low_pass_filter, vlfp
  8689. Enable vertical low-pass filtering in the filter.
  8690. Vertical low-pass filtering is required when creating an interlaced
  8691. destination from a progressive source which contains high-frequency
  8692. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  8693. patterning.
  8694. Vertical low-pass filtering can only be enabled for @option{mode}
  8695. @var{interleave_top} and @var{interleave_bottom}.
  8696. @end table
  8697. @end table
  8698. @section transpose
  8699. Transpose rows with columns in the input video and optionally flip it.
  8700. It accepts the following parameters:
  8701. @table @option
  8702. @item dir
  8703. Specify the transposition direction.
  8704. Can assume the following values:
  8705. @table @samp
  8706. @item 0, 4, cclock_flip
  8707. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  8708. @example
  8709. L.R L.l
  8710. . . -> . .
  8711. l.r R.r
  8712. @end example
  8713. @item 1, 5, clock
  8714. Rotate by 90 degrees clockwise, that is:
  8715. @example
  8716. L.R l.L
  8717. . . -> . .
  8718. l.r r.R
  8719. @end example
  8720. @item 2, 6, cclock
  8721. Rotate by 90 degrees counterclockwise, that is:
  8722. @example
  8723. L.R R.r
  8724. . . -> . .
  8725. l.r L.l
  8726. @end example
  8727. @item 3, 7, clock_flip
  8728. Rotate by 90 degrees clockwise and vertically flip, that is:
  8729. @example
  8730. L.R r.R
  8731. . . -> . .
  8732. l.r l.L
  8733. @end example
  8734. @end table
  8735. For values between 4-7, the transposition is only done if the input
  8736. video geometry is portrait and not landscape. These values are
  8737. deprecated, the @code{passthrough} option should be used instead.
  8738. Numerical values are deprecated, and should be dropped in favor of
  8739. symbolic constants.
  8740. @item passthrough
  8741. Do not apply the transposition if the input geometry matches the one
  8742. specified by the specified value. It accepts the following values:
  8743. @table @samp
  8744. @item none
  8745. Always apply transposition.
  8746. @item portrait
  8747. Preserve portrait geometry (when @var{height} >= @var{width}).
  8748. @item landscape
  8749. Preserve landscape geometry (when @var{width} >= @var{height}).
  8750. @end table
  8751. Default value is @code{none}.
  8752. @end table
  8753. For example to rotate by 90 degrees clockwise and preserve portrait
  8754. layout:
  8755. @example
  8756. transpose=dir=1:passthrough=portrait
  8757. @end example
  8758. The command above can also be specified as:
  8759. @example
  8760. transpose=1:portrait
  8761. @end example
  8762. @section trim
  8763. Trim the input so that the output contains one continuous subpart of the input.
  8764. It accepts the following parameters:
  8765. @table @option
  8766. @item start
  8767. Specify the time of the start of the kept section, i.e. the frame with the
  8768. timestamp @var{start} will be the first frame in the output.
  8769. @item end
  8770. Specify the time of the first frame that will be dropped, i.e. the frame
  8771. immediately preceding the one with the timestamp @var{end} will be the last
  8772. frame in the output.
  8773. @item start_pts
  8774. This is the same as @var{start}, except this option sets the start timestamp
  8775. in timebase units instead of seconds.
  8776. @item end_pts
  8777. This is the same as @var{end}, except this option sets the end timestamp
  8778. in timebase units instead of seconds.
  8779. @item duration
  8780. The maximum duration of the output in seconds.
  8781. @item start_frame
  8782. The number of the first frame that should be passed to the output.
  8783. @item end_frame
  8784. The number of the first frame that should be dropped.
  8785. @end table
  8786. @option{start}, @option{end}, and @option{duration} are expressed as time
  8787. duration specifications; see
  8788. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  8789. for the accepted syntax.
  8790. Note that the first two sets of the start/end options and the @option{duration}
  8791. option look at the frame timestamp, while the _frame variants simply count the
  8792. frames that pass through the filter. Also note that this filter does not modify
  8793. the timestamps. If you wish for the output timestamps to start at zero, insert a
  8794. setpts filter after the trim filter.
  8795. If multiple start or end options are set, this filter tries to be greedy and
  8796. keep all the frames that match at least one of the specified constraints. To keep
  8797. only the part that matches all the constraints at once, chain multiple trim
  8798. filters.
  8799. The defaults are such that all the input is kept. So it is possible to set e.g.
  8800. just the end values to keep everything before the specified time.
  8801. Examples:
  8802. @itemize
  8803. @item
  8804. Drop everything except the second minute of input:
  8805. @example
  8806. ffmpeg -i INPUT -vf trim=60:120
  8807. @end example
  8808. @item
  8809. Keep only the first second:
  8810. @example
  8811. ffmpeg -i INPUT -vf trim=duration=1
  8812. @end example
  8813. @end itemize
  8814. @anchor{unsharp}
  8815. @section unsharp
  8816. Sharpen or blur the input video.
  8817. It accepts the following parameters:
  8818. @table @option
  8819. @item luma_msize_x, lx
  8820. Set the luma matrix horizontal size. It must be an odd integer between
  8821. 3 and 63. The default value is 5.
  8822. @item luma_msize_y, ly
  8823. Set the luma matrix vertical size. It must be an odd integer between 3
  8824. and 63. The default value is 5.
  8825. @item luma_amount, la
  8826. Set the luma effect strength. It must be a floating point number, reasonable
  8827. values lay between -1.5 and 1.5.
  8828. Negative values will blur the input video, while positive values will
  8829. sharpen it, a value of zero will disable the effect.
  8830. Default value is 1.0.
  8831. @item chroma_msize_x, cx
  8832. Set the chroma matrix horizontal size. It must be an odd integer
  8833. between 3 and 63. The default value is 5.
  8834. @item chroma_msize_y, cy
  8835. Set the chroma matrix vertical size. It must be an odd integer
  8836. between 3 and 63. The default value is 5.
  8837. @item chroma_amount, ca
  8838. Set the chroma effect strength. It must be a floating point number, reasonable
  8839. values lay between -1.5 and 1.5.
  8840. Negative values will blur the input video, while positive values will
  8841. sharpen it, a value of zero will disable the effect.
  8842. Default value is 0.0.
  8843. @item opencl
  8844. If set to 1, specify using OpenCL capabilities, only available if
  8845. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  8846. @end table
  8847. All parameters are optional and default to the equivalent of the
  8848. string '5:5:1.0:5:5:0.0'.
  8849. @subsection Examples
  8850. @itemize
  8851. @item
  8852. Apply strong luma sharpen effect:
  8853. @example
  8854. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  8855. @end example
  8856. @item
  8857. Apply a strong blur of both luma and chroma parameters:
  8858. @example
  8859. unsharp=7:7:-2:7:7:-2
  8860. @end example
  8861. @end itemize
  8862. @section uspp
  8863. Apply ultra slow/simple postprocessing filter that compresses and decompresses
  8864. the image at several (or - in the case of @option{quality} level @code{8} - all)
  8865. shifts and average the results.
  8866. The way this differs from the behavior of spp is that uspp actually encodes &
  8867. decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
  8868. DCT similar to MJPEG.
  8869. The filter accepts the following options:
  8870. @table @option
  8871. @item quality
  8872. Set quality. This option defines the number of levels for averaging. It accepts
  8873. an integer in the range 0-8. If set to @code{0}, the filter will have no
  8874. effect. A value of @code{8} means the higher quality. For each increment of
  8875. that value the speed drops by a factor of approximately 2. Default value is
  8876. @code{3}.
  8877. @item qp
  8878. Force a constant quantization parameter. If not set, the filter will use the QP
  8879. from the video stream (if available).
  8880. @end table
  8881. @section vectorscope
  8882. Display 2 color component values in the two dimensional graph (which is called
  8883. a vectorscope).
  8884. This filter accepts the following options:
  8885. @table @option
  8886. @item mode, m
  8887. Set vectorscope mode.
  8888. It accepts the following values:
  8889. @table @samp
  8890. @item gray
  8891. Gray values are displayed on graph, higher brightness means more pixels have
  8892. same component color value on location in graph. This is the default mode.
  8893. @item color
  8894. Gray values are displayed on graph. Surrounding pixels values which are not
  8895. present in video frame are drawn in gradient of 2 color components which are
  8896. set by option @code{x} and @code{y}.
  8897. @item color2
  8898. Actual color components values present in video frame are displayed on graph.
  8899. @item color3
  8900. Similar as color2 but higher frequency of same values @code{x} and @code{y}
  8901. on graph increases value of another color component, which is luminance by
  8902. default values of @code{x} and @code{y}.
  8903. @item color4
  8904. Actual colors present in video frame are displayed on graph. If two different
  8905. colors map to same position on graph then color with higher value of component
  8906. not present in graph is picked.
  8907. @end table
  8908. @item x
  8909. Set which color component will be represented on X-axis. Default is @code{1}.
  8910. @item y
  8911. Set which color component will be represented on Y-axis. Default is @code{2}.
  8912. @item intensity, i
  8913. Set intensity, used by modes: gray, color and color3 for increasing brightness
  8914. of color component which represents frequency of (X, Y) location in graph.
  8915. @item envelope, e
  8916. @table @samp
  8917. @item none
  8918. No envelope, this is default.
  8919. @item instant
  8920. Instant envelope, even darkest single pixel will be clearly highlighted.
  8921. @item peak
  8922. Hold maximum and minimum values presented in graph over time. This way you
  8923. can still spot out of range values without constantly looking at vectorscope.
  8924. @item peak+instant
  8925. Peak and instant envelope combined together.
  8926. @end table
  8927. @end table
  8928. @anchor{vidstabdetect}
  8929. @section vidstabdetect
  8930. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  8931. @ref{vidstabtransform} for pass 2.
  8932. This filter generates a file with relative translation and rotation
  8933. transform information about subsequent frames, which is then used by
  8934. the @ref{vidstabtransform} filter.
  8935. To enable compilation of this filter you need to configure FFmpeg with
  8936. @code{--enable-libvidstab}.
  8937. This filter accepts the following options:
  8938. @table @option
  8939. @item result
  8940. Set the path to the file used to write the transforms information.
  8941. Default value is @file{transforms.trf}.
  8942. @item shakiness
  8943. Set how shaky the video is and how quick the camera is. It accepts an
  8944. integer in the range 1-10, a value of 1 means little shakiness, a
  8945. value of 10 means strong shakiness. Default value is 5.
  8946. @item accuracy
  8947. Set the accuracy of the detection process. It must be a value in the
  8948. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  8949. accuracy. Default value is 15.
  8950. @item stepsize
  8951. Set stepsize of the search process. The region around minimum is
  8952. scanned with 1 pixel resolution. Default value is 6.
  8953. @item mincontrast
  8954. Set minimum contrast. Below this value a local measurement field is
  8955. discarded. Must be a floating point value in the range 0-1. Default
  8956. value is 0.3.
  8957. @item tripod
  8958. Set reference frame number for tripod mode.
  8959. If enabled, the motion of the frames is compared to a reference frame
  8960. in the filtered stream, identified by the specified number. The idea
  8961. is to compensate all movements in a more-or-less static scene and keep
  8962. the camera view absolutely still.
  8963. If set to 0, it is disabled. The frames are counted starting from 1.
  8964. @item show
  8965. Show fields and transforms in the resulting frames. It accepts an
  8966. integer in the range 0-2. Default value is 0, which disables any
  8967. visualization.
  8968. @end table
  8969. @subsection Examples
  8970. @itemize
  8971. @item
  8972. Use default values:
  8973. @example
  8974. vidstabdetect
  8975. @end example
  8976. @item
  8977. Analyze strongly shaky movie and put the results in file
  8978. @file{mytransforms.trf}:
  8979. @example
  8980. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  8981. @end example
  8982. @item
  8983. Visualize the result of internal transformations in the resulting
  8984. video:
  8985. @example
  8986. vidstabdetect=show=1
  8987. @end example
  8988. @item
  8989. Analyze a video with medium shakiness using @command{ffmpeg}:
  8990. @example
  8991. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  8992. @end example
  8993. @end itemize
  8994. @anchor{vidstabtransform}
  8995. @section vidstabtransform
  8996. Video stabilization/deshaking: pass 2 of 2,
  8997. see @ref{vidstabdetect} for pass 1.
  8998. Read a file with transform information for each frame and
  8999. apply/compensate them. Together with the @ref{vidstabdetect}
  9000. filter this can be used to deshake videos. See also
  9001. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  9002. the @ref{unsharp} filter, see below.
  9003. To enable compilation of this filter you need to configure FFmpeg with
  9004. @code{--enable-libvidstab}.
  9005. @subsection Options
  9006. @table @option
  9007. @item input
  9008. Set path to the file used to read the transforms. Default value is
  9009. @file{transforms.trf}.
  9010. @item smoothing
  9011. Set the number of frames (value*2 + 1) used for lowpass filtering the
  9012. camera movements. Default value is 10.
  9013. For example a number of 10 means that 21 frames are used (10 in the
  9014. past and 10 in the future) to smoothen the motion in the video. A
  9015. larger value leads to a smoother video, but limits the acceleration of
  9016. the camera (pan/tilt movements). 0 is a special case where a static
  9017. camera is simulated.
  9018. @item optalgo
  9019. Set the camera path optimization algorithm.
  9020. Accepted values are:
  9021. @table @samp
  9022. @item gauss
  9023. gaussian kernel low-pass filter on camera motion (default)
  9024. @item avg
  9025. averaging on transformations
  9026. @end table
  9027. @item maxshift
  9028. Set maximal number of pixels to translate frames. Default value is -1,
  9029. meaning no limit.
  9030. @item maxangle
  9031. Set maximal angle in radians (degree*PI/180) to rotate frames. Default
  9032. value is -1, meaning no limit.
  9033. @item crop
  9034. Specify how to deal with borders that may be visible due to movement
  9035. compensation.
  9036. Available values are:
  9037. @table @samp
  9038. @item keep
  9039. keep image information from previous frame (default)
  9040. @item black
  9041. fill the border black
  9042. @end table
  9043. @item invert
  9044. Invert transforms if set to 1. Default value is 0.
  9045. @item relative
  9046. Consider transforms as relative to previous frame if set to 1,
  9047. absolute if set to 0. Default value is 0.
  9048. @item zoom
  9049. Set percentage to zoom. A positive value will result in a zoom-in
  9050. effect, a negative value in a zoom-out effect. Default value is 0 (no
  9051. zoom).
  9052. @item optzoom
  9053. Set optimal zooming to avoid borders.
  9054. Accepted values are:
  9055. @table @samp
  9056. @item 0
  9057. disabled
  9058. @item 1
  9059. optimal static zoom value is determined (only very strong movements
  9060. will lead to visible borders) (default)
  9061. @item 2
  9062. optimal adaptive zoom value is determined (no borders will be
  9063. visible), see @option{zoomspeed}
  9064. @end table
  9065. Note that the value given at zoom is added to the one calculated here.
  9066. @item zoomspeed
  9067. Set percent to zoom maximally each frame (enabled when
  9068. @option{optzoom} is set to 2). Range is from 0 to 5, default value is
  9069. 0.25.
  9070. @item interpol
  9071. Specify type of interpolation.
  9072. Available values are:
  9073. @table @samp
  9074. @item no
  9075. no interpolation
  9076. @item linear
  9077. linear only horizontal
  9078. @item bilinear
  9079. linear in both directions (default)
  9080. @item bicubic
  9081. cubic in both directions (slow)
  9082. @end table
  9083. @item tripod
  9084. Enable virtual tripod mode if set to 1, which is equivalent to
  9085. @code{relative=0:smoothing=0}. Default value is 0.
  9086. Use also @code{tripod} option of @ref{vidstabdetect}.
  9087. @item debug
  9088. Increase log verbosity if set to 1. Also the detected global motions
  9089. are written to the temporary file @file{global_motions.trf}. Default
  9090. value is 0.
  9091. @end table
  9092. @subsection Examples
  9093. @itemize
  9094. @item
  9095. Use @command{ffmpeg} for a typical stabilization with default values:
  9096. @example
  9097. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  9098. @end example
  9099. Note the use of the @ref{unsharp} filter which is always recommended.
  9100. @item
  9101. Zoom in a bit more and load transform data from a given file:
  9102. @example
  9103. vidstabtransform=zoom=5:input="mytransforms.trf"
  9104. @end example
  9105. @item
  9106. Smoothen the video even more:
  9107. @example
  9108. vidstabtransform=smoothing=30
  9109. @end example
  9110. @end itemize
  9111. @section vflip
  9112. Flip the input video vertically.
  9113. For example, to vertically flip a video with @command{ffmpeg}:
  9114. @example
  9115. ffmpeg -i in.avi -vf "vflip" out.avi
  9116. @end example
  9117. @anchor{vignette}
  9118. @section vignette
  9119. Make or reverse a natural vignetting effect.
  9120. The filter accepts the following options:
  9121. @table @option
  9122. @item angle, a
  9123. Set lens angle expression as a number of radians.
  9124. The value is clipped in the @code{[0,PI/2]} range.
  9125. Default value: @code{"PI/5"}
  9126. @item x0
  9127. @item y0
  9128. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  9129. by default.
  9130. @item mode
  9131. Set forward/backward mode.
  9132. Available modes are:
  9133. @table @samp
  9134. @item forward
  9135. The larger the distance from the central point, the darker the image becomes.
  9136. @item backward
  9137. The larger the distance from the central point, the brighter the image becomes.
  9138. This can be used to reverse a vignette effect, though there is no automatic
  9139. detection to extract the lens @option{angle} and other settings (yet). It can
  9140. also be used to create a burning effect.
  9141. @end table
  9142. Default value is @samp{forward}.
  9143. @item eval
  9144. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  9145. It accepts the following values:
  9146. @table @samp
  9147. @item init
  9148. Evaluate expressions only once during the filter initialization.
  9149. @item frame
  9150. Evaluate expressions for each incoming frame. This is way slower than the
  9151. @samp{init} mode since it requires all the scalers to be re-computed, but it
  9152. allows advanced dynamic expressions.
  9153. @end table
  9154. Default value is @samp{init}.
  9155. @item dither
  9156. Set dithering to reduce the circular banding effects. Default is @code{1}
  9157. (enabled).
  9158. @item aspect
  9159. Set vignette aspect. This setting allows one to adjust the shape of the vignette.
  9160. Setting this value to the SAR of the input will make a rectangular vignetting
  9161. following the dimensions of the video.
  9162. Default is @code{1/1}.
  9163. @end table
  9164. @subsection Expressions
  9165. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  9166. following parameters.
  9167. @table @option
  9168. @item w
  9169. @item h
  9170. input width and height
  9171. @item n
  9172. the number of input frame, starting from 0
  9173. @item pts
  9174. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  9175. @var{TB} units, NAN if undefined
  9176. @item r
  9177. frame rate of the input video, NAN if the input frame rate is unknown
  9178. @item t
  9179. the PTS (Presentation TimeStamp) of the filtered video frame,
  9180. expressed in seconds, NAN if undefined
  9181. @item tb
  9182. time base of the input video
  9183. @end table
  9184. @subsection Examples
  9185. @itemize
  9186. @item
  9187. Apply simple strong vignetting effect:
  9188. @example
  9189. vignette=PI/4
  9190. @end example
  9191. @item
  9192. Make a flickering vignetting:
  9193. @example
  9194. vignette='PI/4+random(1)*PI/50':eval=frame
  9195. @end example
  9196. @end itemize
  9197. @section vstack
  9198. Stack input videos vertically.
  9199. All streams must be of same pixel format and of same width.
  9200. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  9201. to create same output.
  9202. The filter accept the following option:
  9203. @table @option
  9204. @item inputs
  9205. Set number of input streams. Default is 2.
  9206. @item shortest
  9207. If set to 1, force the output to terminate when the shortest input
  9208. terminates. Default value is 0.
  9209. @end table
  9210. @section w3fdif
  9211. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  9212. Deinterlacing Filter").
  9213. Based on the process described by Martin Weston for BBC R&D, and
  9214. implemented based on the de-interlace algorithm written by Jim
  9215. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  9216. uses filter coefficients calculated by BBC R&D.
  9217. There are two sets of filter coefficients, so called "simple":
  9218. and "complex". Which set of filter coefficients is used can
  9219. be set by passing an optional parameter:
  9220. @table @option
  9221. @item filter
  9222. Set the interlacing filter coefficients. Accepts one of the following values:
  9223. @table @samp
  9224. @item simple
  9225. Simple filter coefficient set.
  9226. @item complex
  9227. More-complex filter coefficient set.
  9228. @end table
  9229. Default value is @samp{complex}.
  9230. @item deint
  9231. Specify which frames to deinterlace. Accept one of the following values:
  9232. @table @samp
  9233. @item all
  9234. Deinterlace all frames,
  9235. @item interlaced
  9236. Only deinterlace frames marked as interlaced.
  9237. @end table
  9238. Default value is @samp{all}.
  9239. @end table
  9240. @section waveform
  9241. Video waveform monitor.
  9242. The waveform monitor plots color component intensity. By default luminance
  9243. only. Each column of the waveform corresponds to a column of pixels in the
  9244. source video.
  9245. It accepts the following options:
  9246. @table @option
  9247. @item mode, m
  9248. Can be either @code{row}, or @code{column}. Default is @code{column}.
  9249. In row mode, the graph on the left side represents color component value 0 and
  9250. the right side represents value = 255. In column mode, the top side represents
  9251. color component value = 0 and bottom side represents value = 255.
  9252. @item intensity, i
  9253. Set intensity. Smaller values are useful to find out how many values of the same
  9254. luminance are distributed across input rows/columns.
  9255. Default value is @code{0.04}. Allowed range is [0, 1].
  9256. @item mirror, r
  9257. Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored.
  9258. In mirrored mode, higher values will be represented on the left
  9259. side for @code{row} mode and at the top for @code{column} mode. Default is
  9260. @code{1} (mirrored).
  9261. @item display, d
  9262. Set display mode.
  9263. It accepts the following values:
  9264. @table @samp
  9265. @item overlay
  9266. Presents information identical to that in the @code{parade}, except
  9267. that the graphs representing color components are superimposed directly
  9268. over one another.
  9269. This display mode makes it easier to spot relative differences or similarities
  9270. in overlapping areas of the color components that are supposed to be identical,
  9271. such as neutral whites, grays, or blacks.
  9272. @item parade
  9273. Display separate graph for the color components side by side in
  9274. @code{row} mode or one below the other in @code{column} mode.
  9275. Using this display mode makes it easy to spot color casts in the highlights
  9276. and shadows of an image, by comparing the contours of the top and the bottom
  9277. graphs of each waveform. Since whites, grays, and blacks are characterized
  9278. by exactly equal amounts of red, green, and blue, neutral areas of the picture
  9279. should display three waveforms of roughly equal width/height. If not, the
  9280. correction is easy to perform by making level adjustments the three waveforms.
  9281. @end table
  9282. Default is @code{parade}.
  9283. @item components, c
  9284. Set which color components to display. Default is 1, which means only luminance
  9285. or red color component if input is in RGB colorspace. If is set for example to
  9286. 7 it will display all 3 (if) available color components.
  9287. @item envelope, e
  9288. @table @samp
  9289. @item none
  9290. No envelope, this is default.
  9291. @item instant
  9292. Instant envelope, minimum and maximum values presented in graph will be easily
  9293. visible even with small @code{step} value.
  9294. @item peak
  9295. Hold minimum and maximum values presented in graph across time. This way you
  9296. can still spot out of range values without constantly looking at waveforms.
  9297. @item peak+instant
  9298. Peak and instant envelope combined together.
  9299. @end table
  9300. @item filter, f
  9301. @table @samp
  9302. @item lowpass
  9303. No filtering, this is default.
  9304. @item flat
  9305. Luma and chroma combined together.
  9306. @item aflat
  9307. Similar as above, but shows difference between blue and red chroma.
  9308. @item chroma
  9309. Displays only chroma.
  9310. @item achroma
  9311. Similar as above, but shows difference between blue and red chroma.
  9312. @item color
  9313. Displays actual color value on waveform.
  9314. @end table
  9315. @end table
  9316. @section xbr
  9317. Apply the xBR high-quality magnification filter which is designed for pixel
  9318. art. It follows a set of edge-detection rules, see
  9319. @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
  9320. It accepts the following option:
  9321. @table @option
  9322. @item n
  9323. Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
  9324. @code{3xBR} and @code{4} for @code{4xBR}.
  9325. Default is @code{3}.
  9326. @end table
  9327. @anchor{yadif}
  9328. @section yadif
  9329. Deinterlace the input video ("yadif" means "yet another deinterlacing
  9330. filter").
  9331. It accepts the following parameters:
  9332. @table @option
  9333. @item mode
  9334. The interlacing mode to adopt. It accepts one of the following values:
  9335. @table @option
  9336. @item 0, send_frame
  9337. Output one frame for each frame.
  9338. @item 1, send_field
  9339. Output one frame for each field.
  9340. @item 2, send_frame_nospatial
  9341. Like @code{send_frame}, but it skips the spatial interlacing check.
  9342. @item 3, send_field_nospatial
  9343. Like @code{send_field}, but it skips the spatial interlacing check.
  9344. @end table
  9345. The default value is @code{send_frame}.
  9346. @item parity
  9347. The picture field parity assumed for the input interlaced video. It accepts one
  9348. of the following values:
  9349. @table @option
  9350. @item 0, tff
  9351. Assume the top field is first.
  9352. @item 1, bff
  9353. Assume the bottom field is first.
  9354. @item -1, auto
  9355. Enable automatic detection of field parity.
  9356. @end table
  9357. The default value is @code{auto}.
  9358. If the interlacing is unknown or the decoder does not export this information,
  9359. top field first will be assumed.
  9360. @item deint
  9361. Specify which frames to deinterlace. Accept one of the following
  9362. values:
  9363. @table @option
  9364. @item 0, all
  9365. Deinterlace all frames.
  9366. @item 1, interlaced
  9367. Only deinterlace frames marked as interlaced.
  9368. @end table
  9369. The default value is @code{all}.
  9370. @end table
  9371. @section zoompan
  9372. Apply Zoom & Pan effect.
  9373. This filter accepts the following options:
  9374. @table @option
  9375. @item zoom, z
  9376. Set the zoom expression. Default is 1.
  9377. @item x
  9378. @item y
  9379. Set the x and y expression. Default is 0.
  9380. @item d
  9381. Set the duration expression in number of frames.
  9382. This sets for how many number of frames effect will last for
  9383. single input image.
  9384. @item s
  9385. Set the output image size, default is 'hd720'.
  9386. @end table
  9387. Each expression can contain the following constants:
  9388. @table @option
  9389. @item in_w, iw
  9390. Input width.
  9391. @item in_h, ih
  9392. Input height.
  9393. @item out_w, ow
  9394. Output width.
  9395. @item out_h, oh
  9396. Output height.
  9397. @item in
  9398. Input frame count.
  9399. @item on
  9400. Output frame count.
  9401. @item x
  9402. @item y
  9403. Last calculated 'x' and 'y' position from 'x' and 'y' expression
  9404. for current input frame.
  9405. @item px
  9406. @item py
  9407. 'x' and 'y' of last output frame of previous input frame or 0 when there was
  9408. not yet such frame (first input frame).
  9409. @item zoom
  9410. Last calculated zoom from 'z' expression for current input frame.
  9411. @item pzoom
  9412. Last calculated zoom of last output frame of previous input frame.
  9413. @item duration
  9414. Number of output frames for current input frame. Calculated from 'd' expression
  9415. for each input frame.
  9416. @item pduration
  9417. number of output frames created for previous input frame
  9418. @item a
  9419. Rational number: input width / input height
  9420. @item sar
  9421. sample aspect ratio
  9422. @item dar
  9423. display aspect ratio
  9424. @end table
  9425. @subsection Examples
  9426. @itemize
  9427. @item
  9428. Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
  9429. @example
  9430. 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
  9431. @end example
  9432. @item
  9433. Zoom-in up to 1.5 and pan always at center of picture:
  9434. @example
  9435. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
  9436. @end example
  9437. @end itemize
  9438. @section zscale
  9439. Scale (resize) the input video, using the z.lib library:
  9440. https://github.com/sekrit-twc/zimg.
  9441. The zscale filter forces the output display aspect ratio to be the same
  9442. as the input, by changing the output sample aspect ratio.
  9443. If the input image format is different from the format requested by
  9444. the next filter, the zscale filter will convert the input to the
  9445. requested format.
  9446. @subsection Options
  9447. The filter accepts the following options.
  9448. @table @option
  9449. @item width, w
  9450. @item height, h
  9451. Set the output video dimension expression. Default value is the input
  9452. dimension.
  9453. If the @var{width} or @var{w} is 0, the input width is used for the output.
  9454. If the @var{height} or @var{h} is 0, the input height is used for the output.
  9455. If one of the values is -1, the zscale filter will use a value that
  9456. maintains the aspect ratio of the input image, calculated from the
  9457. other specified dimension. If both of them are -1, the input size is
  9458. used
  9459. If one of the values is -n with n > 1, the zscale filter will also use a value
  9460. that maintains the aspect ratio of the input image, calculated from the other
  9461. specified dimension. After that it will, however, make sure that the calculated
  9462. dimension is divisible by n and adjust the value if necessary.
  9463. See below for the list of accepted constants for use in the dimension
  9464. expression.
  9465. @item size, s
  9466. Set the video size. For the syntax of this option, check the
  9467. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9468. @item dither, d
  9469. Set the dither type.
  9470. Possible values are:
  9471. @table @var
  9472. @item none
  9473. @item ordered
  9474. @item random
  9475. @item error_diffusion
  9476. @end table
  9477. Default is none.
  9478. @item filter, f
  9479. Set the resize filter type.
  9480. Possible values are:
  9481. @table @var
  9482. @item point
  9483. @item bilinear
  9484. @item bicubic
  9485. @item spline16
  9486. @item spline36
  9487. @item lanczos
  9488. @end table
  9489. Default is bilinear.
  9490. @item range, r
  9491. Set the color range.
  9492. Possible values are:
  9493. @table @var
  9494. @item input
  9495. @item limited
  9496. @item full
  9497. @end table
  9498. Default is same as input.
  9499. @item primaries, p
  9500. Set the color primaries.
  9501. Possible values are:
  9502. @table @var
  9503. @item input
  9504. @item 709
  9505. @item unspecified
  9506. @item 170m
  9507. @item 240m
  9508. @item 2020
  9509. @end table
  9510. Default is same as input.
  9511. @item transfer, t
  9512. Set the transfer characteristics.
  9513. Possible values are:
  9514. @table @var
  9515. @item input
  9516. @item 709
  9517. @item unspecified
  9518. @item 601
  9519. @item linear
  9520. @item 2020_10
  9521. @item 2020_12
  9522. @end table
  9523. Default is same as input.
  9524. @item matrix, m
  9525. Set the colorspace matrix.
  9526. Possible value are:
  9527. @table @var
  9528. @item input
  9529. @item 709
  9530. @item unspecified
  9531. @item 470bg
  9532. @item 170m
  9533. @item 2020_ncl
  9534. @item 2020_cl
  9535. @end table
  9536. Default is same as input.
  9537. @end table
  9538. The values of the @option{w} and @option{h} options are expressions
  9539. containing the following constants:
  9540. @table @var
  9541. @item in_w
  9542. @item in_h
  9543. The input width and height
  9544. @item iw
  9545. @item ih
  9546. These are the same as @var{in_w} and @var{in_h}.
  9547. @item out_w
  9548. @item out_h
  9549. The output (scaled) width and height
  9550. @item ow
  9551. @item oh
  9552. These are the same as @var{out_w} and @var{out_h}
  9553. @item a
  9554. The same as @var{iw} / @var{ih}
  9555. @item sar
  9556. input sample aspect ratio
  9557. @item dar
  9558. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  9559. @item hsub
  9560. @item vsub
  9561. horizontal and vertical input chroma subsample values. For example for the
  9562. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  9563. @item ohsub
  9564. @item ovsub
  9565. horizontal and vertical output chroma subsample values. For example for the
  9566. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  9567. @end table
  9568. @table @option
  9569. @end table
  9570. @c man end VIDEO FILTERS
  9571. @chapter Video Sources
  9572. @c man begin VIDEO SOURCES
  9573. Below is a description of the currently available video sources.
  9574. @section buffer
  9575. Buffer video frames, and make them available to the filter chain.
  9576. This source is mainly intended for a programmatic use, in particular
  9577. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  9578. It accepts the following parameters:
  9579. @table @option
  9580. @item video_size
  9581. Specify the size (width and height) of the buffered video frames. For the
  9582. syntax of this option, check the
  9583. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9584. @item width
  9585. The input video width.
  9586. @item height
  9587. The input video height.
  9588. @item pix_fmt
  9589. A string representing the pixel format of the buffered video frames.
  9590. It may be a number corresponding to a pixel format, or a pixel format
  9591. name.
  9592. @item time_base
  9593. Specify the timebase assumed by the timestamps of the buffered frames.
  9594. @item frame_rate
  9595. Specify the frame rate expected for the video stream.
  9596. @item pixel_aspect, sar
  9597. The sample (pixel) aspect ratio of the input video.
  9598. @item sws_param
  9599. Specify the optional parameters to be used for the scale filter which
  9600. is automatically inserted when an input change is detected in the
  9601. input size or format.
  9602. @end table
  9603. For example:
  9604. @example
  9605. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  9606. @end example
  9607. will instruct the source to accept video frames with size 320x240 and
  9608. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  9609. square pixels (1:1 sample aspect ratio).
  9610. Since the pixel format with name "yuv410p" corresponds to the number 6
  9611. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  9612. this example corresponds to:
  9613. @example
  9614. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  9615. @end example
  9616. Alternatively, the options can be specified as a flat string, but this
  9617. syntax is deprecated:
  9618. @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}]
  9619. @section cellauto
  9620. Create a pattern generated by an elementary cellular automaton.
  9621. The initial state of the cellular automaton can be defined through the
  9622. @option{filename}, and @option{pattern} options. If such options are
  9623. not specified an initial state is created randomly.
  9624. At each new frame a new row in the video is filled with the result of
  9625. the cellular automaton next generation. The behavior when the whole
  9626. frame is filled is defined by the @option{scroll} option.
  9627. This source accepts the following options:
  9628. @table @option
  9629. @item filename, f
  9630. Read the initial cellular automaton state, i.e. the starting row, from
  9631. the specified file.
  9632. In the file, each non-whitespace character is considered an alive
  9633. cell, a newline will terminate the row, and further characters in the
  9634. file will be ignored.
  9635. @item pattern, p
  9636. Read the initial cellular automaton state, i.e. the starting row, from
  9637. the specified string.
  9638. Each non-whitespace character in the string is considered an alive
  9639. cell, a newline will terminate the row, and further characters in the
  9640. string will be ignored.
  9641. @item rate, r
  9642. Set the video rate, that is the number of frames generated per second.
  9643. Default is 25.
  9644. @item random_fill_ratio, ratio
  9645. Set the random fill ratio for the initial cellular automaton row. It
  9646. is a floating point number value ranging from 0 to 1, defaults to
  9647. 1/PHI.
  9648. This option is ignored when a file or a pattern is specified.
  9649. @item random_seed, seed
  9650. Set the seed for filling randomly the initial row, must be an integer
  9651. included between 0 and UINT32_MAX. If not specified, or if explicitly
  9652. set to -1, the filter will try to use a good random seed on a best
  9653. effort basis.
  9654. @item rule
  9655. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  9656. Default value is 110.
  9657. @item size, s
  9658. Set the size of the output video. For the syntax of this option, check the
  9659. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9660. If @option{filename} or @option{pattern} is specified, the size is set
  9661. by default to the width of the specified initial state row, and the
  9662. height is set to @var{width} * PHI.
  9663. If @option{size} is set, it must contain the width of the specified
  9664. pattern string, and the specified pattern will be centered in the
  9665. larger row.
  9666. If a filename or a pattern string is not specified, the size value
  9667. defaults to "320x518" (used for a randomly generated initial state).
  9668. @item scroll
  9669. If set to 1, scroll the output upward when all the rows in the output
  9670. have been already filled. If set to 0, the new generated row will be
  9671. written over the top row just after the bottom row is filled.
  9672. Defaults to 1.
  9673. @item start_full, full
  9674. If set to 1, completely fill the output with generated rows before
  9675. outputting the first frame.
  9676. This is the default behavior, for disabling set the value to 0.
  9677. @item stitch
  9678. If set to 1, stitch the left and right row edges together.
  9679. This is the default behavior, for disabling set the value to 0.
  9680. @end table
  9681. @subsection Examples
  9682. @itemize
  9683. @item
  9684. Read the initial state from @file{pattern}, and specify an output of
  9685. size 200x400.
  9686. @example
  9687. cellauto=f=pattern:s=200x400
  9688. @end example
  9689. @item
  9690. Generate a random initial row with a width of 200 cells, with a fill
  9691. ratio of 2/3:
  9692. @example
  9693. cellauto=ratio=2/3:s=200x200
  9694. @end example
  9695. @item
  9696. Create a pattern generated by rule 18 starting by a single alive cell
  9697. centered on an initial row with width 100:
  9698. @example
  9699. cellauto=p=@@:s=100x400:full=0:rule=18
  9700. @end example
  9701. @item
  9702. Specify a more elaborated initial pattern:
  9703. @example
  9704. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  9705. @end example
  9706. @end itemize
  9707. @section mandelbrot
  9708. Generate a Mandelbrot set fractal, and progressively zoom towards the
  9709. point specified with @var{start_x} and @var{start_y}.
  9710. This source accepts the following options:
  9711. @table @option
  9712. @item end_pts
  9713. Set the terminal pts value. Default value is 400.
  9714. @item end_scale
  9715. Set the terminal scale value.
  9716. Must be a floating point value. Default value is 0.3.
  9717. @item inner
  9718. Set the inner coloring mode, that is the algorithm used to draw the
  9719. Mandelbrot fractal internal region.
  9720. It shall assume one of the following values:
  9721. @table @option
  9722. @item black
  9723. Set black mode.
  9724. @item convergence
  9725. Show time until convergence.
  9726. @item mincol
  9727. Set color based on point closest to the origin of the iterations.
  9728. @item period
  9729. Set period mode.
  9730. @end table
  9731. Default value is @var{mincol}.
  9732. @item bailout
  9733. Set the bailout value. Default value is 10.0.
  9734. @item maxiter
  9735. Set the maximum of iterations performed by the rendering
  9736. algorithm. Default value is 7189.
  9737. @item outer
  9738. Set outer coloring mode.
  9739. It shall assume one of following values:
  9740. @table @option
  9741. @item iteration_count
  9742. Set iteration cound mode.
  9743. @item normalized_iteration_count
  9744. set normalized iteration count mode.
  9745. @end table
  9746. Default value is @var{normalized_iteration_count}.
  9747. @item rate, r
  9748. Set frame rate, expressed as number of frames per second. Default
  9749. value is "25".
  9750. @item size, s
  9751. Set frame size. For the syntax of this option, check the "Video
  9752. size" section in the ffmpeg-utils manual. Default value is "640x480".
  9753. @item start_scale
  9754. Set the initial scale value. Default value is 3.0.
  9755. @item start_x
  9756. Set the initial x position. Must be a floating point value between
  9757. -100 and 100. Default value is -0.743643887037158704752191506114774.
  9758. @item start_y
  9759. Set the initial y position. Must be a floating point value between
  9760. -100 and 100. Default value is -0.131825904205311970493132056385139.
  9761. @end table
  9762. @section mptestsrc
  9763. Generate various test patterns, as generated by the MPlayer test filter.
  9764. The size of the generated video is fixed, and is 256x256.
  9765. This source is useful in particular for testing encoding features.
  9766. This source accepts the following options:
  9767. @table @option
  9768. @item rate, r
  9769. Specify the frame rate of the sourced video, as the number of frames
  9770. generated per second. It has to be a string in the format
  9771. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  9772. number or a valid video frame rate abbreviation. The default value is
  9773. "25".
  9774. @item duration, d
  9775. Set the duration of the sourced video. See
  9776. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  9777. for the accepted syntax.
  9778. If not specified, or the expressed duration is negative, the video is
  9779. supposed to be generated forever.
  9780. @item test, t
  9781. Set the number or the name of the test to perform. Supported tests are:
  9782. @table @option
  9783. @item dc_luma
  9784. @item dc_chroma
  9785. @item freq_luma
  9786. @item freq_chroma
  9787. @item amp_luma
  9788. @item amp_chroma
  9789. @item cbp
  9790. @item mv
  9791. @item ring1
  9792. @item ring2
  9793. @item all
  9794. @end table
  9795. Default value is "all", which will cycle through the list of all tests.
  9796. @end table
  9797. Some examples:
  9798. @example
  9799. mptestsrc=t=dc_luma
  9800. @end example
  9801. will generate a "dc_luma" test pattern.
  9802. @section frei0r_src
  9803. Provide a frei0r source.
  9804. To enable compilation of this filter you need to install the frei0r
  9805. header and configure FFmpeg with @code{--enable-frei0r}.
  9806. This source accepts the following parameters:
  9807. @table @option
  9808. @item size
  9809. The size of the video to generate. For the syntax of this option, check the
  9810. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9811. @item framerate
  9812. The framerate of the generated video. It may be a string of the form
  9813. @var{num}/@var{den} or a frame rate abbreviation.
  9814. @item filter_name
  9815. The name to the frei0r source to load. For more information regarding frei0r and
  9816. how to set the parameters, read the @ref{frei0r} section in the video filters
  9817. documentation.
  9818. @item filter_params
  9819. A '|'-separated list of parameters to pass to the frei0r source.
  9820. @end table
  9821. For example, to generate a frei0r partik0l source with size 200x200
  9822. and frame rate 10 which is overlaid on the overlay filter main input:
  9823. @example
  9824. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  9825. @end example
  9826. @section life
  9827. Generate a life pattern.
  9828. This source is based on a generalization of John Conway's life game.
  9829. The sourced input represents a life grid, each pixel represents a cell
  9830. which can be in one of two possible states, alive or dead. Every cell
  9831. interacts with its eight neighbours, which are the cells that are
  9832. horizontally, vertically, or diagonally adjacent.
  9833. At each interaction the grid evolves according to the adopted rule,
  9834. which specifies the number of neighbor alive cells which will make a
  9835. cell stay alive or born. The @option{rule} option allows one to specify
  9836. the rule to adopt.
  9837. This source accepts the following options:
  9838. @table @option
  9839. @item filename, f
  9840. Set the file from which to read the initial grid state. In the file,
  9841. each non-whitespace character is considered an alive cell, and newline
  9842. is used to delimit the end of each row.
  9843. If this option is not specified, the initial grid is generated
  9844. randomly.
  9845. @item rate, r
  9846. Set the video rate, that is the number of frames generated per second.
  9847. Default is 25.
  9848. @item random_fill_ratio, ratio
  9849. Set the random fill ratio for the initial random grid. It is a
  9850. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  9851. It is ignored when a file is specified.
  9852. @item random_seed, seed
  9853. Set the seed for filling the initial random grid, must be an integer
  9854. included between 0 and UINT32_MAX. If not specified, or if explicitly
  9855. set to -1, the filter will try to use a good random seed on a best
  9856. effort basis.
  9857. @item rule
  9858. Set the life rule.
  9859. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  9860. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  9861. @var{NS} specifies the number of alive neighbor cells which make a
  9862. live cell stay alive, and @var{NB} the number of alive neighbor cells
  9863. which make a dead cell to become alive (i.e. to "born").
  9864. "s" and "b" can be used in place of "S" and "B", respectively.
  9865. Alternatively a rule can be specified by an 18-bits integer. The 9
  9866. high order bits are used to encode the next cell state if it is alive
  9867. for each number of neighbor alive cells, the low order bits specify
  9868. the rule for "borning" new cells. Higher order bits encode for an
  9869. higher number of neighbor cells.
  9870. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  9871. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  9872. Default value is "S23/B3", which is the original Conway's game of life
  9873. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  9874. cells, and will born a new cell if there are three alive cells around
  9875. a dead cell.
  9876. @item size, s
  9877. Set the size of the output video. For the syntax of this option, check the
  9878. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9879. If @option{filename} is specified, the size is set by default to the
  9880. same size of the input file. If @option{size} is set, it must contain
  9881. the size specified in the input file, and the initial grid defined in
  9882. that file is centered in the larger resulting area.
  9883. If a filename is not specified, the size value defaults to "320x240"
  9884. (used for a randomly generated initial grid).
  9885. @item stitch
  9886. If set to 1, stitch the left and right grid edges together, and the
  9887. top and bottom edges also. Defaults to 1.
  9888. @item mold
  9889. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  9890. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  9891. value from 0 to 255.
  9892. @item life_color
  9893. Set the color of living (or new born) cells.
  9894. @item death_color
  9895. Set the color of dead cells. If @option{mold} is set, this is the first color
  9896. used to represent a dead cell.
  9897. @item mold_color
  9898. Set mold color, for definitely dead and moldy cells.
  9899. For the syntax of these 3 color options, check the "Color" section in the
  9900. ffmpeg-utils manual.
  9901. @end table
  9902. @subsection Examples
  9903. @itemize
  9904. @item
  9905. Read a grid from @file{pattern}, and center it on a grid of size
  9906. 300x300 pixels:
  9907. @example
  9908. life=f=pattern:s=300x300
  9909. @end example
  9910. @item
  9911. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  9912. @example
  9913. life=ratio=2/3:s=200x200
  9914. @end example
  9915. @item
  9916. Specify a custom rule for evolving a randomly generated grid:
  9917. @example
  9918. life=rule=S14/B34
  9919. @end example
  9920. @item
  9921. Full example with slow death effect (mold) using @command{ffplay}:
  9922. @example
  9923. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  9924. @end example
  9925. @end itemize
  9926. @anchor{allrgb}
  9927. @anchor{allyuv}
  9928. @anchor{color}
  9929. @anchor{haldclutsrc}
  9930. @anchor{nullsrc}
  9931. @anchor{rgbtestsrc}
  9932. @anchor{smptebars}
  9933. @anchor{smptehdbars}
  9934. @anchor{testsrc}
  9935. @section allrgb, allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  9936. The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
  9937. The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
  9938. The @code{color} source provides an uniformly colored input.
  9939. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  9940. @ref{haldclut} filter.
  9941. The @code{nullsrc} source returns unprocessed video frames. It is
  9942. mainly useful to be employed in analysis / debugging tools, or as the
  9943. source for filters which ignore the input data.
  9944. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  9945. detecting RGB vs BGR issues. You should see a red, green and blue
  9946. stripe from top to bottom.
  9947. The @code{smptebars} source generates a color bars pattern, based on
  9948. the SMPTE Engineering Guideline EG 1-1990.
  9949. The @code{smptehdbars} source generates a color bars pattern, based on
  9950. the SMPTE RP 219-2002.
  9951. The @code{testsrc} source generates a test video pattern, showing a
  9952. color pattern, a scrolling gradient and a timestamp. This is mainly
  9953. intended for testing purposes.
  9954. The sources accept the following parameters:
  9955. @table @option
  9956. @item color, c
  9957. Specify the color of the source, only available in the @code{color}
  9958. source. For the syntax of this option, check the "Color" section in the
  9959. ffmpeg-utils manual.
  9960. @item level
  9961. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  9962. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  9963. pixels to be used as identity matrix for 3D lookup tables. Each component is
  9964. coded on a @code{1/(N*N)} scale.
  9965. @item size, s
  9966. Specify the size of the sourced video. For the syntax of this option, check the
  9967. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9968. The default value is @code{320x240}.
  9969. This option is not available with the @code{haldclutsrc} filter.
  9970. @item rate, r
  9971. Specify the frame rate of the sourced video, as the number of frames
  9972. generated per second. It has to be a string in the format
  9973. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  9974. number or a valid video frame rate abbreviation. The default value is
  9975. "25".
  9976. @item sar
  9977. Set the sample aspect ratio of the sourced video.
  9978. @item duration, d
  9979. Set the duration of the sourced video. See
  9980. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  9981. for the accepted syntax.
  9982. If not specified, or the expressed duration is negative, the video is
  9983. supposed to be generated forever.
  9984. @item decimals, n
  9985. Set the number of decimals to show in the timestamp, only available in the
  9986. @code{testsrc} source.
  9987. The displayed timestamp value will correspond to the original
  9988. timestamp value multiplied by the power of 10 of the specified
  9989. value. Default value is 0.
  9990. @end table
  9991. For example the following:
  9992. @example
  9993. testsrc=duration=5.3:size=qcif:rate=10
  9994. @end example
  9995. will generate a video with a duration of 5.3 seconds, with size
  9996. 176x144 and a frame rate of 10 frames per second.
  9997. The following graph description will generate a red source
  9998. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  9999. frames per second.
  10000. @example
  10001. color=c=red@@0.2:s=qcif:r=10
  10002. @end example
  10003. If the input content is to be ignored, @code{nullsrc} can be used. The
  10004. following command generates noise in the luminance plane by employing
  10005. the @code{geq} filter:
  10006. @example
  10007. nullsrc=s=256x256, geq=random(1)*255:128:128
  10008. @end example
  10009. @subsection Commands
  10010. The @code{color} source supports the following commands:
  10011. @table @option
  10012. @item c, color
  10013. Set the color of the created image. Accepts the same syntax of the
  10014. corresponding @option{color} option.
  10015. @end table
  10016. @c man end VIDEO SOURCES
  10017. @chapter Video Sinks
  10018. @c man begin VIDEO SINKS
  10019. Below is a description of the currently available video sinks.
  10020. @section buffersink
  10021. Buffer video frames, and make them available to the end of the filter
  10022. graph.
  10023. This sink is mainly intended for programmatic use, in particular
  10024. through the interface defined in @file{libavfilter/buffersink.h}
  10025. or the options system.
  10026. It accepts a pointer to an AVBufferSinkContext structure, which
  10027. defines the incoming buffers' formats, to be passed as the opaque
  10028. parameter to @code{avfilter_init_filter} for initialization.
  10029. @section nullsink
  10030. Null video sink: do absolutely nothing with the input video. It is
  10031. mainly useful as a template and for use in analysis / debugging
  10032. tools.
  10033. @c man end VIDEO SINKS
  10034. @chapter Multimedia Filters
  10035. @c man begin MULTIMEDIA FILTERS
  10036. Below is a description of the currently available multimedia filters.
  10037. @section aphasemeter
  10038. Convert input audio to a video output, displaying the audio phase.
  10039. The filter accepts the following options:
  10040. @table @option
  10041. @item rate, r
  10042. Set the output frame rate. Default value is @code{25}.
  10043. @item size, s
  10044. Set the video size for the output. For the syntax of this option, check the
  10045. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10046. Default value is @code{800x400}.
  10047. @item rc
  10048. @item gc
  10049. @item bc
  10050. Specify the red, green, blue contrast. Default values are @code{2},
  10051. @code{7} and @code{1}.
  10052. Allowed range is @code{[0, 255]}.
  10053. @item mpc
  10054. Set color which will be used for drawing median phase. If color is
  10055. @code{none} which is default, no median phase value will be drawn.
  10056. @end table
  10057. The filter also exports the frame metadata @code{lavfi.aphasemeter.phase} which
  10058. represents mean phase of current audio frame. Value is in range @code{[-1, 1]}.
  10059. The @code{-1} means left and right channels are completely out of phase and
  10060. @code{1} means channels are in phase.
  10061. @section avectorscope
  10062. Convert input audio to a video output, representing the audio vector
  10063. scope.
  10064. The filter is used to measure the difference between channels of stereo
  10065. audio stream. A monoaural signal, consisting of identical left and right
  10066. signal, results in straight vertical line. Any stereo separation is visible
  10067. as a deviation from this line, creating a Lissajous figure.
  10068. If the straight (or deviation from it) but horizontal line appears this
  10069. indicates that the left and right channels are out of phase.
  10070. The filter accepts the following options:
  10071. @table @option
  10072. @item mode, m
  10073. Set the vectorscope mode.
  10074. Available values are:
  10075. @table @samp
  10076. @item lissajous
  10077. Lissajous rotated by 45 degrees.
  10078. @item lissajous_xy
  10079. Same as above but not rotated.
  10080. @item polar
  10081. Shape resembling half of circle.
  10082. @end table
  10083. Default value is @samp{lissajous}.
  10084. @item size, s
  10085. Set the video size for the output. For the syntax of this option, check the
  10086. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10087. Default value is @code{400x400}.
  10088. @item rate, r
  10089. Set the output frame rate. Default value is @code{25}.
  10090. @item rc
  10091. @item gc
  10092. @item bc
  10093. @item ac
  10094. Specify the red, green, blue and alpha contrast. Default values are @code{40},
  10095. @code{160}, @code{80} and @code{255}.
  10096. Allowed range is @code{[0, 255]}.
  10097. @item rf
  10098. @item gf
  10099. @item bf
  10100. @item af
  10101. Specify the red, green, blue and alpha fade. Default values are @code{15},
  10102. @code{10}, @code{5} and @code{5}.
  10103. Allowed range is @code{[0, 255]}.
  10104. @item zoom
  10105. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  10106. @end table
  10107. @subsection Examples
  10108. @itemize
  10109. @item
  10110. Complete example using @command{ffplay}:
  10111. @example
  10112. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  10113. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  10114. @end example
  10115. @end itemize
  10116. @section concat
  10117. Concatenate audio and video streams, joining them together one after the
  10118. other.
  10119. The filter works on segments of synchronized video and audio streams. All
  10120. segments must have the same number of streams of each type, and that will
  10121. also be the number of streams at output.
  10122. The filter accepts the following options:
  10123. @table @option
  10124. @item n
  10125. Set the number of segments. Default is 2.
  10126. @item v
  10127. Set the number of output video streams, that is also the number of video
  10128. streams in each segment. Default is 1.
  10129. @item a
  10130. Set the number of output audio streams, that is also the number of audio
  10131. streams in each segment. Default is 0.
  10132. @item unsafe
  10133. Activate unsafe mode: do not fail if segments have a different format.
  10134. @end table
  10135. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  10136. @var{a} audio outputs.
  10137. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  10138. segment, in the same order as the outputs, then the inputs for the second
  10139. segment, etc.
  10140. Related streams do not always have exactly the same duration, for various
  10141. reasons including codec frame size or sloppy authoring. For that reason,
  10142. related synchronized streams (e.g. a video and its audio track) should be
  10143. concatenated at once. The concat filter will use the duration of the longest
  10144. stream in each segment (except the last one), and if necessary pad shorter
  10145. audio streams with silence.
  10146. For this filter to work correctly, all segments must start at timestamp 0.
  10147. All corresponding streams must have the same parameters in all segments; the
  10148. filtering system will automatically select a common pixel format for video
  10149. streams, and a common sample format, sample rate and channel layout for
  10150. audio streams, but other settings, such as resolution, must be converted
  10151. explicitly by the user.
  10152. Different frame rates are acceptable but will result in variable frame rate
  10153. at output; be sure to configure the output file to handle it.
  10154. @subsection Examples
  10155. @itemize
  10156. @item
  10157. Concatenate an opening, an episode and an ending, all in bilingual version
  10158. (video in stream 0, audio in streams 1 and 2):
  10159. @example
  10160. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  10161. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  10162. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  10163. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  10164. @end example
  10165. @item
  10166. Concatenate two parts, handling audio and video separately, using the
  10167. (a)movie sources, and adjusting the resolution:
  10168. @example
  10169. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  10170. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  10171. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  10172. @end example
  10173. Note that a desync will happen at the stitch if the audio and video streams
  10174. do not have exactly the same duration in the first file.
  10175. @end itemize
  10176. @anchor{ebur128}
  10177. @section ebur128
  10178. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  10179. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  10180. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  10181. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  10182. The filter also has a video output (see the @var{video} option) with a real
  10183. time graph to observe the loudness evolution. The graphic contains the logged
  10184. message mentioned above, so it is not printed anymore when this option is set,
  10185. unless the verbose logging is set. The main graphing area contains the
  10186. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  10187. the momentary loudness (400 milliseconds).
  10188. More information about the Loudness Recommendation EBU R128 on
  10189. @url{http://tech.ebu.ch/loudness}.
  10190. The filter accepts the following options:
  10191. @table @option
  10192. @item video
  10193. Activate the video output. The audio stream is passed unchanged whether this
  10194. option is set or no. The video stream will be the first output stream if
  10195. activated. Default is @code{0}.
  10196. @item size
  10197. Set the video size. This option is for video only. For the syntax of this
  10198. option, check the
  10199. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10200. Default and minimum resolution is @code{640x480}.
  10201. @item meter
  10202. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  10203. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  10204. other integer value between this range is allowed.
  10205. @item metadata
  10206. Set metadata injection. If set to @code{1}, the audio input will be segmented
  10207. into 100ms output frames, each of them containing various loudness information
  10208. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  10209. Default is @code{0}.
  10210. @item framelog
  10211. Force the frame logging level.
  10212. Available values are:
  10213. @table @samp
  10214. @item info
  10215. information logging level
  10216. @item verbose
  10217. verbose logging level
  10218. @end table
  10219. By default, the logging level is set to @var{info}. If the @option{video} or
  10220. the @option{metadata} options are set, it switches to @var{verbose}.
  10221. @item peak
  10222. Set peak mode(s).
  10223. Available modes can be cumulated (the option is a @code{flag} type). Possible
  10224. values are:
  10225. @table @samp
  10226. @item none
  10227. Disable any peak mode (default).
  10228. @item sample
  10229. Enable sample-peak mode.
  10230. Simple peak mode looking for the higher sample value. It logs a message
  10231. for sample-peak (identified by @code{SPK}).
  10232. @item true
  10233. Enable true-peak mode.
  10234. If enabled, the peak lookup is done on an over-sampled version of the input
  10235. stream for better peak accuracy. It logs a message for true-peak.
  10236. (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
  10237. This mode requires a build with @code{libswresample}.
  10238. @end table
  10239. @item dualmono
  10240. Treat mono input files as "dual mono". If a mono file is intended for playback
  10241. on a stereo system, its EBU R128 measurement will be perceptually incorrect.
  10242. If set to @code{true}, this option will compensate for this effect.
  10243. Multi-channel input files are not affected by this option.
  10244. @item panlaw
  10245. Set a specific pan law to be used for the measurement of dual mono files.
  10246. This parameter is optional, and has a default value of -3.01dB.
  10247. @end table
  10248. @subsection Examples
  10249. @itemize
  10250. @item
  10251. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  10252. @example
  10253. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  10254. @end example
  10255. @item
  10256. Run an analysis with @command{ffmpeg}:
  10257. @example
  10258. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  10259. @end example
  10260. @end itemize
  10261. @section interleave, ainterleave
  10262. Temporally interleave frames from several inputs.
  10263. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  10264. These filters read frames from several inputs and send the oldest
  10265. queued frame to the output.
  10266. Input streams must have a well defined, monotonically increasing frame
  10267. timestamp values.
  10268. In order to submit one frame to output, these filters need to enqueue
  10269. at least one frame for each input, so they cannot work in case one
  10270. input is not yet terminated and will not receive incoming frames.
  10271. For example consider the case when one input is a @code{select} filter
  10272. which always drop input frames. The @code{interleave} filter will keep
  10273. reading from that input, but it will never be able to send new frames
  10274. to output until the input will send an end-of-stream signal.
  10275. Also, depending on inputs synchronization, the filters will drop
  10276. frames in case one input receives more frames than the other ones, and
  10277. the queue is already filled.
  10278. These filters accept the following options:
  10279. @table @option
  10280. @item nb_inputs, n
  10281. Set the number of different inputs, it is 2 by default.
  10282. @end table
  10283. @subsection Examples
  10284. @itemize
  10285. @item
  10286. Interleave frames belonging to different streams using @command{ffmpeg}:
  10287. @example
  10288. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  10289. @end example
  10290. @item
  10291. Add flickering blur effect:
  10292. @example
  10293. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  10294. @end example
  10295. @end itemize
  10296. @section perms, aperms
  10297. Set read/write permissions for the output frames.
  10298. These filters are mainly aimed at developers to test direct path in the
  10299. following filter in the filtergraph.
  10300. The filters accept the following options:
  10301. @table @option
  10302. @item mode
  10303. Select the permissions mode.
  10304. It accepts the following values:
  10305. @table @samp
  10306. @item none
  10307. Do nothing. This is the default.
  10308. @item ro
  10309. Set all the output frames read-only.
  10310. @item rw
  10311. Set all the output frames directly writable.
  10312. @item toggle
  10313. Make the frame read-only if writable, and writable if read-only.
  10314. @item random
  10315. Set each output frame read-only or writable randomly.
  10316. @end table
  10317. @item seed
  10318. Set the seed for the @var{random} mode, must be an integer included between
  10319. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  10320. @code{-1}, the filter will try to use a good random seed on a best effort
  10321. basis.
  10322. @end table
  10323. Note: in case of auto-inserted filter between the permission filter and the
  10324. following one, the permission might not be received as expected in that
  10325. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  10326. perms/aperms filter can avoid this problem.
  10327. @section realtime, arealtime
  10328. Slow down filtering to match real time approximatively.
  10329. These filters will pause the filtering for a variable amount of time to
  10330. match the output rate with the input timestamps.
  10331. They are similar to the @option{re} option to @code{ffmpeg}.
  10332. They accept the following options:
  10333. @table @option
  10334. @item limit
  10335. Time limit for the pauses. Any pause longer than that will be considered
  10336. a timestamp discontinuity and reset the timer. Default is 2 seconds.
  10337. @end table
  10338. @section select, aselect
  10339. Select frames to pass in output.
  10340. This filter accepts the following options:
  10341. @table @option
  10342. @item expr, e
  10343. Set expression, which is evaluated for each input frame.
  10344. If the expression is evaluated to zero, the frame is discarded.
  10345. If the evaluation result is negative or NaN, the frame is sent to the
  10346. first output; otherwise it is sent to the output with index
  10347. @code{ceil(val)-1}, assuming that the input index starts from 0.
  10348. For example a value of @code{1.2} corresponds to the output with index
  10349. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  10350. @item outputs, n
  10351. Set the number of outputs. The output to which to send the selected
  10352. frame is based on the result of the evaluation. Default value is 1.
  10353. @end table
  10354. The expression can contain the following constants:
  10355. @table @option
  10356. @item n
  10357. The (sequential) number of the filtered frame, starting from 0.
  10358. @item selected_n
  10359. The (sequential) number of the selected frame, starting from 0.
  10360. @item prev_selected_n
  10361. The sequential number of the last selected frame. It's NAN if undefined.
  10362. @item TB
  10363. The timebase of the input timestamps.
  10364. @item pts
  10365. The PTS (Presentation TimeStamp) of the filtered video frame,
  10366. expressed in @var{TB} units. It's NAN if undefined.
  10367. @item t
  10368. The PTS of the filtered video frame,
  10369. expressed in seconds. It's NAN if undefined.
  10370. @item prev_pts
  10371. The PTS of the previously filtered video frame. It's NAN if undefined.
  10372. @item prev_selected_pts
  10373. The PTS of the last previously filtered video frame. It's NAN if undefined.
  10374. @item prev_selected_t
  10375. The PTS of the last previously selected video frame. It's NAN if undefined.
  10376. @item start_pts
  10377. The PTS of the first video frame in the video. It's NAN if undefined.
  10378. @item start_t
  10379. The time of the first video frame in the video. It's NAN if undefined.
  10380. @item pict_type @emph{(video only)}
  10381. The type of the filtered frame. It can assume one of the following
  10382. values:
  10383. @table @option
  10384. @item I
  10385. @item P
  10386. @item B
  10387. @item S
  10388. @item SI
  10389. @item SP
  10390. @item BI
  10391. @end table
  10392. @item interlace_type @emph{(video only)}
  10393. The frame interlace type. It can assume one of the following values:
  10394. @table @option
  10395. @item PROGRESSIVE
  10396. The frame is progressive (not interlaced).
  10397. @item TOPFIRST
  10398. The frame is top-field-first.
  10399. @item BOTTOMFIRST
  10400. The frame is bottom-field-first.
  10401. @end table
  10402. @item consumed_sample_n @emph{(audio only)}
  10403. the number of selected samples before the current frame
  10404. @item samples_n @emph{(audio only)}
  10405. the number of samples in the current frame
  10406. @item sample_rate @emph{(audio only)}
  10407. the input sample rate
  10408. @item key
  10409. This is 1 if the filtered frame is a key-frame, 0 otherwise.
  10410. @item pos
  10411. the position in the file of the filtered frame, -1 if the information
  10412. is not available (e.g. for synthetic video)
  10413. @item scene @emph{(video only)}
  10414. value between 0 and 1 to indicate a new scene; a low value reflects a low
  10415. probability for the current frame to introduce a new scene, while a higher
  10416. value means the current frame is more likely to be one (see the example below)
  10417. @item concatdec_select
  10418. The concat demuxer can select only part of a concat input file by setting an
  10419. inpoint and an outpoint, but the output packets may not be entirely contained
  10420. in the selected interval. By using this variable, it is possible to skip frames
  10421. generated by the concat demuxer which are not exactly contained in the selected
  10422. interval.
  10423. This works by comparing the frame pts against the @var{lavf.concat.start_time}
  10424. and the @var{lavf.concat.duration} packet metadata values which are also
  10425. present in the decoded frames.
  10426. The @var{concatdec_select} variable is -1 if the frame pts is at least
  10427. start_time and either the duration metadata is missing or the frame pts is less
  10428. than start_time + duration, 0 otherwise, and NaN if the start_time metadata is
  10429. missing.
  10430. That basically means that an input frame is selected if its pts is within the
  10431. interval set by the concat demuxer.
  10432. @end table
  10433. The default value of the select expression is "1".
  10434. @subsection Examples
  10435. @itemize
  10436. @item
  10437. Select all frames in input:
  10438. @example
  10439. select
  10440. @end example
  10441. The example above is the same as:
  10442. @example
  10443. select=1
  10444. @end example
  10445. @item
  10446. Skip all frames:
  10447. @example
  10448. select=0
  10449. @end example
  10450. @item
  10451. Select only I-frames:
  10452. @example
  10453. select='eq(pict_type\,I)'
  10454. @end example
  10455. @item
  10456. Select one frame every 100:
  10457. @example
  10458. select='not(mod(n\,100))'
  10459. @end example
  10460. @item
  10461. Select only frames contained in the 10-20 time interval:
  10462. @example
  10463. select=between(t\,10\,20)
  10464. @end example
  10465. @item
  10466. Select only I frames contained in the 10-20 time interval:
  10467. @example
  10468. select=between(t\,10\,20)*eq(pict_type\,I)
  10469. @end example
  10470. @item
  10471. Select frames with a minimum distance of 10 seconds:
  10472. @example
  10473. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  10474. @end example
  10475. @item
  10476. Use aselect to select only audio frames with samples number > 100:
  10477. @example
  10478. aselect='gt(samples_n\,100)'
  10479. @end example
  10480. @item
  10481. Create a mosaic of the first scenes:
  10482. @example
  10483. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  10484. @end example
  10485. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  10486. choice.
  10487. @item
  10488. Send even and odd frames to separate outputs, and compose them:
  10489. @example
  10490. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  10491. @end example
  10492. @item
  10493. Select useful frames from an ffconcat file which is using inpoints and
  10494. outpoints but where the source files are not intra frame only.
  10495. @example
  10496. ffmpeg -copyts -vsync 0 -segment_time_metadata 1 -i input.ffconcat -vf select=concatdec_select -af aselect=concatdec_select output.avi
  10497. @end example
  10498. @end itemize
  10499. @section sendcmd, asendcmd
  10500. Send commands to filters in the filtergraph.
  10501. These filters read commands to be sent to other filters in the
  10502. filtergraph.
  10503. @code{sendcmd} must be inserted between two video filters,
  10504. @code{asendcmd} must be inserted between two audio filters, but apart
  10505. from that they act the same way.
  10506. The specification of commands can be provided in the filter arguments
  10507. with the @var{commands} option, or in a file specified by the
  10508. @var{filename} option.
  10509. These filters accept the following options:
  10510. @table @option
  10511. @item commands, c
  10512. Set the commands to be read and sent to the other filters.
  10513. @item filename, f
  10514. Set the filename of the commands to be read and sent to the other
  10515. filters.
  10516. @end table
  10517. @subsection Commands syntax
  10518. A commands description consists of a sequence of interval
  10519. specifications, comprising a list of commands to be executed when a
  10520. particular event related to that interval occurs. The occurring event
  10521. is typically the current frame time entering or leaving a given time
  10522. interval.
  10523. An interval is specified by the following syntax:
  10524. @example
  10525. @var{START}[-@var{END}] @var{COMMANDS};
  10526. @end example
  10527. The time interval is specified by the @var{START} and @var{END} times.
  10528. @var{END} is optional and defaults to the maximum time.
  10529. The current frame time is considered within the specified interval if
  10530. it is included in the interval [@var{START}, @var{END}), that is when
  10531. the time is greater or equal to @var{START} and is lesser than
  10532. @var{END}.
  10533. @var{COMMANDS} consists of a sequence of one or more command
  10534. specifications, separated by ",", relating to that interval. The
  10535. syntax of a command specification is given by:
  10536. @example
  10537. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  10538. @end example
  10539. @var{FLAGS} is optional and specifies the type of events relating to
  10540. the time interval which enable sending the specified command, and must
  10541. be a non-null sequence of identifier flags separated by "+" or "|" and
  10542. enclosed between "[" and "]".
  10543. The following flags are recognized:
  10544. @table @option
  10545. @item enter
  10546. The command is sent when the current frame timestamp enters the
  10547. specified interval. In other words, the command is sent when the
  10548. previous frame timestamp was not in the given interval, and the
  10549. current is.
  10550. @item leave
  10551. The command is sent when the current frame timestamp leaves the
  10552. specified interval. In other words, the command is sent when the
  10553. previous frame timestamp was in the given interval, and the
  10554. current is not.
  10555. @end table
  10556. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  10557. assumed.
  10558. @var{TARGET} specifies the target of the command, usually the name of
  10559. the filter class or a specific filter instance name.
  10560. @var{COMMAND} specifies the name of the command for the target filter.
  10561. @var{ARG} is optional and specifies the optional list of argument for
  10562. the given @var{COMMAND}.
  10563. Between one interval specification and another, whitespaces, or
  10564. sequences of characters starting with @code{#} until the end of line,
  10565. are ignored and can be used to annotate comments.
  10566. A simplified BNF description of the commands specification syntax
  10567. follows:
  10568. @example
  10569. @var{COMMAND_FLAG} ::= "enter" | "leave"
  10570. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  10571. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  10572. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  10573. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  10574. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  10575. @end example
  10576. @subsection Examples
  10577. @itemize
  10578. @item
  10579. Specify audio tempo change at second 4:
  10580. @example
  10581. asendcmd=c='4.0 atempo tempo 1.5',atempo
  10582. @end example
  10583. @item
  10584. Specify a list of drawtext and hue commands in a file.
  10585. @example
  10586. # show text in the interval 5-10
  10587. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  10588. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  10589. # desaturate the image in the interval 15-20
  10590. 15.0-20.0 [enter] hue s 0,
  10591. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  10592. [leave] hue s 1,
  10593. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  10594. # apply an exponential saturation fade-out effect, starting from time 25
  10595. 25 [enter] hue s exp(25-t)
  10596. @end example
  10597. A filtergraph allowing to read and process the above command list
  10598. stored in a file @file{test.cmd}, can be specified with:
  10599. @example
  10600. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  10601. @end example
  10602. @end itemize
  10603. @anchor{setpts}
  10604. @section setpts, asetpts
  10605. Change the PTS (presentation timestamp) of the input frames.
  10606. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  10607. This filter accepts the following options:
  10608. @table @option
  10609. @item expr
  10610. The expression which is evaluated for each frame to construct its timestamp.
  10611. @end table
  10612. The expression is evaluated through the eval API and can contain the following
  10613. constants:
  10614. @table @option
  10615. @item FRAME_RATE
  10616. frame rate, only defined for constant frame-rate video
  10617. @item PTS
  10618. The presentation timestamp in input
  10619. @item N
  10620. The count of the input frame for video or the number of consumed samples,
  10621. not including the current frame for audio, starting from 0.
  10622. @item NB_CONSUMED_SAMPLES
  10623. The number of consumed samples, not including the current frame (only
  10624. audio)
  10625. @item NB_SAMPLES, S
  10626. The number of samples in the current frame (only audio)
  10627. @item SAMPLE_RATE, SR
  10628. The audio sample rate.
  10629. @item STARTPTS
  10630. The PTS of the first frame.
  10631. @item STARTT
  10632. the time in seconds of the first frame
  10633. @item INTERLACED
  10634. State whether the current frame is interlaced.
  10635. @item T
  10636. the time in seconds of the current frame
  10637. @item POS
  10638. original position in the file of the frame, or undefined if undefined
  10639. for the current frame
  10640. @item PREV_INPTS
  10641. The previous input PTS.
  10642. @item PREV_INT
  10643. previous input time in seconds
  10644. @item PREV_OUTPTS
  10645. The previous output PTS.
  10646. @item PREV_OUTT
  10647. previous output time in seconds
  10648. @item RTCTIME
  10649. The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  10650. instead.
  10651. @item RTCSTART
  10652. The wallclock (RTC) time at the start of the movie in microseconds.
  10653. @item TB
  10654. The timebase of the input timestamps.
  10655. @end table
  10656. @subsection Examples
  10657. @itemize
  10658. @item
  10659. Start counting PTS from zero
  10660. @example
  10661. setpts=PTS-STARTPTS
  10662. @end example
  10663. @item
  10664. Apply fast motion effect:
  10665. @example
  10666. setpts=0.5*PTS
  10667. @end example
  10668. @item
  10669. Apply slow motion effect:
  10670. @example
  10671. setpts=2.0*PTS
  10672. @end example
  10673. @item
  10674. Set fixed rate of 25 frames per second:
  10675. @example
  10676. setpts=N/(25*TB)
  10677. @end example
  10678. @item
  10679. Set fixed rate 25 fps with some jitter:
  10680. @example
  10681. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  10682. @end example
  10683. @item
  10684. Apply an offset of 10 seconds to the input PTS:
  10685. @example
  10686. setpts=PTS+10/TB
  10687. @end example
  10688. @item
  10689. Generate timestamps from a "live source" and rebase onto the current timebase:
  10690. @example
  10691. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  10692. @end example
  10693. @item
  10694. Generate timestamps by counting samples:
  10695. @example
  10696. asetpts=N/SR/TB
  10697. @end example
  10698. @end itemize
  10699. @section settb, asettb
  10700. Set the timebase to use for the output frames timestamps.
  10701. It is mainly useful for testing timebase configuration.
  10702. It accepts the following parameters:
  10703. @table @option
  10704. @item expr, tb
  10705. The expression which is evaluated into the output timebase.
  10706. @end table
  10707. The value for @option{tb} is an arithmetic expression representing a
  10708. rational. The expression can contain the constants "AVTB" (the default
  10709. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  10710. audio only). Default value is "intb".
  10711. @subsection Examples
  10712. @itemize
  10713. @item
  10714. Set the timebase to 1/25:
  10715. @example
  10716. settb=expr=1/25
  10717. @end example
  10718. @item
  10719. Set the timebase to 1/10:
  10720. @example
  10721. settb=expr=0.1
  10722. @end example
  10723. @item
  10724. Set the timebase to 1001/1000:
  10725. @example
  10726. settb=1+0.001
  10727. @end example
  10728. @item
  10729. Set the timebase to 2*intb:
  10730. @example
  10731. settb=2*intb
  10732. @end example
  10733. @item
  10734. Set the default timebase value:
  10735. @example
  10736. settb=AVTB
  10737. @end example
  10738. @end itemize
  10739. @section showcqt
  10740. Convert input audio to a video output representing frequency spectrum
  10741. logarithmically using Brown-Puckette constant Q transform algorithm with
  10742. direct frequency domain coefficient calculation (but the transform itself
  10743. is not really constant Q, instead the Q factor is actually variable/clamped),
  10744. with musical tone scale, from E0 to D#10.
  10745. The filter accepts the following options:
  10746. @table @option
  10747. @item size, s
  10748. Specify the video size for the output. It must be even. For the syntax of this option,
  10749. check the @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10750. Default value is @code{1920x1080}.
  10751. @item fps, rate, r
  10752. Set the output frame rate. Default value is @code{25}.
  10753. @item bar_h
  10754. Set the bargraph height. It must be even. Default value is @code{-1} which
  10755. computes the bargraph height automatically.
  10756. @item axis_h
  10757. Set the axis height. It must be even. Default value is @code{-1} which computes
  10758. the axis height automatically.
  10759. @item sono_h
  10760. Set the sonogram height. It must be even. Default value is @code{-1} which
  10761. computes the sonogram height automatically.
  10762. @item fullhd
  10763. Set the fullhd resolution. This option is deprecated, use @var{size}, @var{s}
  10764. instead. Default value is @code{1}.
  10765. @item sono_v, volume
  10766. Specify the sonogram volume expression. It can contain variables:
  10767. @table @option
  10768. @item bar_v
  10769. the @var{bar_v} evaluated expression
  10770. @item frequency, freq, f
  10771. the frequency where it is evaluated
  10772. @item timeclamp, tc
  10773. the value of @var{timeclamp} option
  10774. @end table
  10775. and functions:
  10776. @table @option
  10777. @item a_weighting(f)
  10778. A-weighting of equal loudness
  10779. @item b_weighting(f)
  10780. B-weighting of equal loudness
  10781. @item c_weighting(f)
  10782. C-weighting of equal loudness.
  10783. @end table
  10784. Default value is @code{16}.
  10785. @item bar_v, volume2
  10786. Specify the bargraph volume expression. It can contain variables:
  10787. @table @option
  10788. @item sono_v
  10789. the @var{sono_v} evaluated expression
  10790. @item frequency, freq, f
  10791. the frequency where it is evaluated
  10792. @item timeclamp, tc
  10793. the value of @var{timeclamp} option
  10794. @end table
  10795. and functions:
  10796. @table @option
  10797. @item a_weighting(f)
  10798. A-weighting of equal loudness
  10799. @item b_weighting(f)
  10800. B-weighting of equal loudness
  10801. @item c_weighting(f)
  10802. C-weighting of equal loudness.
  10803. @end table
  10804. Default value is @code{sono_v}.
  10805. @item sono_g, gamma
  10806. Specify the sonogram gamma. Lower gamma makes the spectrum more contrast,
  10807. higher gamma makes the spectrum having more range. Default value is @code{3}.
  10808. Acceptable range is @code{[1, 7]}.
  10809. @item bar_g, gamma2
  10810. Specify the bargraph gamma. Default value is @code{1}. Acceptable range is
  10811. @code{[1, 7]}.
  10812. @item timeclamp, tc
  10813. Specify the transform timeclamp. At low frequency, there is trade-off between
  10814. accuracy in time domain and frequency domain. If timeclamp is lower,
  10815. event in time domain is represented more accurately (such as fast bass drum),
  10816. otherwise event in frequency domain is represented more accurately
  10817. (such as bass guitar). Acceptable range is @code{[0.1, 1]}. Default value is @code{0.17}.
  10818. @item basefreq
  10819. Specify the transform base frequency. Default value is @code{20.01523126408007475},
  10820. which is frequency 50 cents below E0. Acceptable range is @code{[10, 100000]}.
  10821. @item endfreq
  10822. Specify the transform end frequency. Default value is @code{20495.59681441799654},
  10823. which is frequency 50 cents above D#10. Acceptable range is @code{[10, 100000]}.
  10824. @item coeffclamp
  10825. This option is deprecated and ignored.
  10826. @item tlength
  10827. Specify the transform length in time domain. Use this option to control accuracy
  10828. trade-off between time domain and frequency domain at every frequency sample.
  10829. It can contain variables:
  10830. @table @option
  10831. @item frequency, freq, f
  10832. the frequency where it is evaluated
  10833. @item timeclamp, tc
  10834. the value of @var{timeclamp} option.
  10835. @end table
  10836. Default value is @code{384*tc/(384+tc*f)}.
  10837. @item count
  10838. Specify the transform count for every video frame. Default value is @code{6}.
  10839. Acceptable range is @code{[1, 30]}.
  10840. @item fcount
  10841. Specify the transform count for every single pixel. Default value is @code{0},
  10842. which makes it computed automatically. Acceptable range is @code{[0, 10]}.
  10843. @item fontfile
  10844. Specify font file for use with freetype to draw the axis. If not specified,
  10845. use embedded font. Note that drawing with font file or embedded font is not
  10846. implemented with custom @var{basefreq} and @var{endfreq}, use @var{axisfile}
  10847. option instead.
  10848. @item fontcolor
  10849. Specify font color expression. This is arithmetic expression that should return
  10850. integer value 0xRRGGBB. It can contain variables:
  10851. @table @option
  10852. @item frequency, freq, f
  10853. the frequency where it is evaluated
  10854. @item timeclamp, tc
  10855. the value of @var{timeclamp} option
  10856. @end table
  10857. and functions:
  10858. @table @option
  10859. @item midi(f)
  10860. midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
  10861. @item r(x), g(x), b(x)
  10862. red, green, and blue value of intensity x.
  10863. @end table
  10864. Default value is @code{st(0, (midi(f)-59.5)/12);
  10865. st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
  10866. r(1-ld(1)) + b(ld(1))}.
  10867. @item axisfile
  10868. Specify image file to draw the axis. This option override @var{fontfile} and
  10869. @var{fontcolor} option.
  10870. @item axis, text
  10871. Enable/disable drawing text to the axis. If it is set to @code{0}, drawing to
  10872. the axis is disabled, ignoring @var{fontfile} and @var{axisfile} option.
  10873. Default value is @code{1}.
  10874. @end table
  10875. @subsection Examples
  10876. @itemize
  10877. @item
  10878. Playing audio while showing the spectrum:
  10879. @example
  10880. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
  10881. @end example
  10882. @item
  10883. Same as above, but with frame rate 30 fps:
  10884. @example
  10885. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
  10886. @end example
  10887. @item
  10888. Playing at 1280x720:
  10889. @example
  10890. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=s=1280x720:count=4 [out0]'
  10891. @end example
  10892. @item
  10893. Disable sonogram display:
  10894. @example
  10895. sono_h=0
  10896. @end example
  10897. @item
  10898. A1 and its harmonics: A1, A2, (near)E3, A3:
  10899. @example
  10900. 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),
  10901. asplit[a][out1]; [a] showcqt [out0]'
  10902. @end example
  10903. @item
  10904. Same as above, but with more accuracy in frequency domain:
  10905. @example
  10906. 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),
  10907. asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
  10908. @end example
  10909. @item
  10910. Custom volume:
  10911. @example
  10912. bar_v=10:sono_v=bar_v*a_weighting(f)
  10913. @end example
  10914. @item
  10915. Custom gamma, now spectrum is linear to the amplitude.
  10916. @example
  10917. bar_g=2:sono_g=2
  10918. @end example
  10919. @item
  10920. Custom tlength equation:
  10921. @example
  10922. 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)))'
  10923. @end example
  10924. @item
  10925. Custom fontcolor and fontfile, C-note is colored green, others are colored blue:
  10926. @example
  10927. fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))':fontfile=myfont.ttf
  10928. @end example
  10929. @item
  10930. Custom frequency range with custom axis using image file:
  10931. @example
  10932. axisfile=myaxis.png:basefreq=40:endfreq=10000
  10933. @end example
  10934. @end itemize
  10935. @section showfreqs
  10936. Convert input audio to video output representing the audio power spectrum.
  10937. Audio amplitude is on Y-axis while frequency is on X-axis.
  10938. The filter accepts the following options:
  10939. @table @option
  10940. @item size, s
  10941. Specify size of video. For the syntax of this option, check the
  10942. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10943. Default is @code{1024x512}.
  10944. @item mode
  10945. Set display mode.
  10946. This set how each frequency bin will be represented.
  10947. It accepts the following values:
  10948. @table @samp
  10949. @item line
  10950. @item bar
  10951. @item dot
  10952. @end table
  10953. Default is @code{bar}.
  10954. @item ascale
  10955. Set amplitude scale.
  10956. It accepts the following values:
  10957. @table @samp
  10958. @item lin
  10959. Linear scale.
  10960. @item sqrt
  10961. Square root scale.
  10962. @item cbrt
  10963. Cubic root scale.
  10964. @item log
  10965. Logarithmic scale.
  10966. @end table
  10967. Default is @code{log}.
  10968. @item fscale
  10969. Set frequency scale.
  10970. It accepts the following values:
  10971. @table @samp
  10972. @item lin
  10973. Linear scale.
  10974. @item log
  10975. Logarithmic scale.
  10976. @item rlog
  10977. Reverse logarithmic scale.
  10978. @end table
  10979. Default is @code{lin}.
  10980. @item win_size
  10981. Set window size.
  10982. It accepts the following values:
  10983. @table @samp
  10984. @item w16
  10985. @item w32
  10986. @item w64
  10987. @item w128
  10988. @item w256
  10989. @item w512
  10990. @item w1024
  10991. @item w2048
  10992. @item w4096
  10993. @item w8192
  10994. @item w16384
  10995. @item w32768
  10996. @item w65536
  10997. @end table
  10998. Default is @code{w2048}
  10999. @item win_func
  11000. Set windowing function.
  11001. It accepts the following values:
  11002. @table @samp
  11003. @item rect
  11004. @item bartlett
  11005. @item hanning
  11006. @item hamming
  11007. @item blackman
  11008. @item welch
  11009. @item flattop
  11010. @item bharris
  11011. @item bnuttall
  11012. @item bhann
  11013. @item sine
  11014. @item nuttall
  11015. @item lanczos
  11016. @item gauss
  11017. @end table
  11018. Default is @code{hanning}.
  11019. @item overlap
  11020. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  11021. which means optimal overlap for selected window function will be picked.
  11022. @item averaging
  11023. Set time averaging. Setting this to 0 will display current maximal peaks.
  11024. Default is @code{1}, which means time averaging is disabled.
  11025. @item colors
  11026. Specify list of colors separated by space or by '|' which will be used to
  11027. draw channel frequencies. Unrecognized or missing colors will be replaced
  11028. by white color.
  11029. @end table
  11030. @section showspectrum
  11031. Convert input audio to a video output, representing the audio frequency
  11032. spectrum.
  11033. The filter accepts the following options:
  11034. @table @option
  11035. @item size, s
  11036. Specify the video size for the output. For the syntax of this option, check the
  11037. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11038. Default value is @code{640x512}.
  11039. @item slide
  11040. Specify how the spectrum should slide along the window.
  11041. It accepts the following values:
  11042. @table @samp
  11043. @item replace
  11044. the samples start again on the left when they reach the right
  11045. @item scroll
  11046. the samples scroll from right to left
  11047. @item fullframe
  11048. frames are only produced when the samples reach the right
  11049. @end table
  11050. Default value is @code{replace}.
  11051. @item mode
  11052. Specify display mode.
  11053. It accepts the following values:
  11054. @table @samp
  11055. @item combined
  11056. all channels are displayed in the same row
  11057. @item separate
  11058. all channels are displayed in separate rows
  11059. @end table
  11060. Default value is @samp{combined}.
  11061. @item color
  11062. Specify display color mode.
  11063. It accepts the following values:
  11064. @table @samp
  11065. @item channel
  11066. each channel is displayed in a separate color
  11067. @item intensity
  11068. each channel is is displayed using the same color scheme
  11069. @end table
  11070. Default value is @samp{channel}.
  11071. @item scale
  11072. Specify scale used for calculating intensity color values.
  11073. It accepts the following values:
  11074. @table @samp
  11075. @item lin
  11076. linear
  11077. @item sqrt
  11078. square root, default
  11079. @item cbrt
  11080. cubic root
  11081. @item log
  11082. logarithmic
  11083. @end table
  11084. Default value is @samp{sqrt}.
  11085. @item saturation
  11086. Set saturation modifier for displayed colors. Negative values provide
  11087. alternative color scheme. @code{0} is no saturation at all.
  11088. Saturation must be in [-10.0, 10.0] range.
  11089. Default value is @code{1}.
  11090. @item win_func
  11091. Set window function.
  11092. It accepts the following values:
  11093. @table @samp
  11094. @item none
  11095. No samples pre-processing (do not expect this to be faster)
  11096. @item hann
  11097. Hann window
  11098. @item hamming
  11099. Hamming window
  11100. @item blackman
  11101. Blackman window
  11102. @end table
  11103. Default value is @code{hann}.
  11104. @end table
  11105. The usage is very similar to the showwaves filter; see the examples in that
  11106. section.
  11107. @subsection Examples
  11108. @itemize
  11109. @item
  11110. Large window with logarithmic color scaling:
  11111. @example
  11112. showspectrum=s=1280x480:scale=log
  11113. @end example
  11114. @item
  11115. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  11116. @example
  11117. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  11118. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  11119. @end example
  11120. @end itemize
  11121. @section showvolume
  11122. Convert input audio volume to a video output.
  11123. The filter accepts the following options:
  11124. @table @option
  11125. @item rate, r
  11126. Set video rate.
  11127. @item b
  11128. Set border width, allowed range is [0, 5]. Default is 1.
  11129. @item w
  11130. Set channel width, allowed range is [80, 1080]. Default is 400.
  11131. @item h
  11132. Set channel height, allowed range is [1, 100]. Default is 20.
  11133. @item f
  11134. Set fade, allowed range is [0.001, 1]. Default is 0.95.
  11135. @item c
  11136. Set volume color expression.
  11137. The expression can use the following variables:
  11138. @table @option
  11139. @item VOLUME
  11140. Current max volume of channel in dB.
  11141. @item CHANNEL
  11142. Current channel number, starting from 0.
  11143. @end table
  11144. @item t
  11145. If set, displays channel names. Default is enabled.
  11146. @item v
  11147. If set, displays volume values. Default is enabled.
  11148. @end table
  11149. @section showwaves
  11150. Convert input audio to a video output, representing the samples waves.
  11151. The filter accepts the following options:
  11152. @table @option
  11153. @item size, s
  11154. Specify the video size for the output. For the syntax of this option, check the
  11155. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11156. Default value is @code{600x240}.
  11157. @item mode
  11158. Set display mode.
  11159. Available values are:
  11160. @table @samp
  11161. @item point
  11162. Draw a point for each sample.
  11163. @item line
  11164. Draw a vertical line for each sample.
  11165. @item p2p
  11166. Draw a point for each sample and a line between them.
  11167. @item cline
  11168. Draw a centered vertical line for each sample.
  11169. @end table
  11170. Default value is @code{point}.
  11171. @item n
  11172. Set the number of samples which are printed on the same column. A
  11173. larger value will decrease the frame rate. Must be a positive
  11174. integer. This option can be set only if the value for @var{rate}
  11175. is not explicitly specified.
  11176. @item rate, r
  11177. Set the (approximate) output frame rate. This is done by setting the
  11178. option @var{n}. Default value is "25".
  11179. @item split_channels
  11180. Set if channels should be drawn separately or overlap. Default value is 0.
  11181. @end table
  11182. @subsection Examples
  11183. @itemize
  11184. @item
  11185. Output the input file audio and the corresponding video representation
  11186. at the same time:
  11187. @example
  11188. amovie=a.mp3,asplit[out0],showwaves[out1]
  11189. @end example
  11190. @item
  11191. Create a synthetic signal and show it with showwaves, forcing a
  11192. frame rate of 30 frames per second:
  11193. @example
  11194. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  11195. @end example
  11196. @end itemize
  11197. @section showwavespic
  11198. Convert input audio to a single video frame, representing the samples waves.
  11199. The filter accepts the following options:
  11200. @table @option
  11201. @item size, s
  11202. Specify the video size for the output. For the syntax of this option, check the
  11203. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11204. Default value is @code{600x240}.
  11205. @item split_channels
  11206. Set if channels should be drawn separately or overlap. Default value is 0.
  11207. @end table
  11208. @subsection Examples
  11209. @itemize
  11210. @item
  11211. Extract a channel split representation of the wave form of a whole audio track
  11212. in a 1024x800 picture using @command{ffmpeg}:
  11213. @example
  11214. ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
  11215. @end example
  11216. @end itemize
  11217. @section split, asplit
  11218. Split input into several identical outputs.
  11219. @code{asplit} works with audio input, @code{split} with video.
  11220. The filter accepts a single parameter which specifies the number of outputs. If
  11221. unspecified, it defaults to 2.
  11222. @subsection Examples
  11223. @itemize
  11224. @item
  11225. Create two separate outputs from the same input:
  11226. @example
  11227. [in] split [out0][out1]
  11228. @end example
  11229. @item
  11230. To create 3 or more outputs, you need to specify the number of
  11231. outputs, like in:
  11232. @example
  11233. [in] asplit=3 [out0][out1][out2]
  11234. @end example
  11235. @item
  11236. Create two separate outputs from the same input, one cropped and
  11237. one padded:
  11238. @example
  11239. [in] split [splitout1][splitout2];
  11240. [splitout1] crop=100:100:0:0 [cropout];
  11241. [splitout2] pad=200:200:100:100 [padout];
  11242. @end example
  11243. @item
  11244. Create 5 copies of the input audio with @command{ffmpeg}:
  11245. @example
  11246. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  11247. @end example
  11248. @end itemize
  11249. @section zmq, azmq
  11250. Receive commands sent through a libzmq client, and forward them to
  11251. filters in the filtergraph.
  11252. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  11253. must be inserted between two video filters, @code{azmq} between two
  11254. audio filters.
  11255. To enable these filters you need to install the libzmq library and
  11256. headers and configure FFmpeg with @code{--enable-libzmq}.
  11257. For more information about libzmq see:
  11258. @url{http://www.zeromq.org/}
  11259. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  11260. receives messages sent through a network interface defined by the
  11261. @option{bind_address} option.
  11262. The received message must be in the form:
  11263. @example
  11264. @var{TARGET} @var{COMMAND} [@var{ARG}]
  11265. @end example
  11266. @var{TARGET} specifies the target of the command, usually the name of
  11267. the filter class or a specific filter instance name.
  11268. @var{COMMAND} specifies the name of the command for the target filter.
  11269. @var{ARG} is optional and specifies the optional argument list for the
  11270. given @var{COMMAND}.
  11271. Upon reception, the message is processed and the corresponding command
  11272. is injected into the filtergraph. Depending on the result, the filter
  11273. will send a reply to the client, adopting the format:
  11274. @example
  11275. @var{ERROR_CODE} @var{ERROR_REASON}
  11276. @var{MESSAGE}
  11277. @end example
  11278. @var{MESSAGE} is optional.
  11279. @subsection Examples
  11280. Look at @file{tools/zmqsend} for an example of a zmq client which can
  11281. be used to send commands processed by these filters.
  11282. Consider the following filtergraph generated by @command{ffplay}
  11283. @example
  11284. ffplay -dumpgraph 1 -f lavfi "
  11285. color=s=100x100:c=red [l];
  11286. color=s=100x100:c=blue [r];
  11287. nullsrc=s=200x100, zmq [bg];
  11288. [bg][l] overlay [bg+l];
  11289. [bg+l][r] overlay=x=100 "
  11290. @end example
  11291. To change the color of the left side of the video, the following
  11292. command can be used:
  11293. @example
  11294. echo Parsed_color_0 c yellow | tools/zmqsend
  11295. @end example
  11296. To change the right side:
  11297. @example
  11298. echo Parsed_color_1 c pink | tools/zmqsend
  11299. @end example
  11300. @c man end MULTIMEDIA FILTERS
  11301. @chapter Multimedia Sources
  11302. @c man begin MULTIMEDIA SOURCES
  11303. Below is a description of the currently available multimedia sources.
  11304. @section amovie
  11305. This is the same as @ref{movie} source, except it selects an audio
  11306. stream by default.
  11307. @anchor{movie}
  11308. @section movie
  11309. Read audio and/or video stream(s) from a movie container.
  11310. It accepts the following parameters:
  11311. @table @option
  11312. @item filename
  11313. The name of the resource to read (not necessarily a file; it can also be a
  11314. device or a stream accessed through some protocol).
  11315. @item format_name, f
  11316. Specifies the format assumed for the movie to read, and can be either
  11317. the name of a container or an input device. If not specified, the
  11318. format is guessed from @var{movie_name} or by probing.
  11319. @item seek_point, sp
  11320. Specifies the seek point in seconds. The frames will be output
  11321. starting from this seek point. The parameter is evaluated with
  11322. @code{av_strtod}, so the numerical value may be suffixed by an IS
  11323. postfix. The default value is "0".
  11324. @item streams, s
  11325. Specifies the streams to read. Several streams can be specified,
  11326. separated by "+". The source will then have as many outputs, in the
  11327. same order. The syntax is explained in the ``Stream specifiers''
  11328. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  11329. respectively the default (best suited) video and audio stream. Default
  11330. is "dv", or "da" if the filter is called as "amovie".
  11331. @item stream_index, si
  11332. Specifies the index of the video stream to read. If the value is -1,
  11333. the most suitable video stream will be automatically selected. The default
  11334. value is "-1". Deprecated. If the filter is called "amovie", it will select
  11335. audio instead of video.
  11336. @item loop
  11337. Specifies how many times to read the stream in sequence.
  11338. If the value is less than 1, the stream will be read again and again.
  11339. Default value is "1".
  11340. Note that when the movie is looped the source timestamps are not
  11341. changed, so it will generate non monotonically increasing timestamps.
  11342. @end table
  11343. It allows overlaying a second video on top of the main input of
  11344. a filtergraph, as shown in this graph:
  11345. @example
  11346. input -----------> deltapts0 --> overlay --> output
  11347. ^
  11348. |
  11349. movie --> scale--> deltapts1 -------+
  11350. @end example
  11351. @subsection Examples
  11352. @itemize
  11353. @item
  11354. Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
  11355. on top of the input labelled "in":
  11356. @example
  11357. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  11358. [in] setpts=PTS-STARTPTS [main];
  11359. [main][over] overlay=16:16 [out]
  11360. @end example
  11361. @item
  11362. Read from a video4linux2 device, and overlay it on top of the input
  11363. labelled "in":
  11364. @example
  11365. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  11366. [in] setpts=PTS-STARTPTS [main];
  11367. [main][over] overlay=16:16 [out]
  11368. @end example
  11369. @item
  11370. Read the first video stream and the audio stream with id 0x81 from
  11371. dvd.vob; the video is connected to the pad named "video" and the audio is
  11372. connected to the pad named "audio":
  11373. @example
  11374. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  11375. @end example
  11376. @end itemize
  11377. @c man end MULTIMEDIA SOURCES