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.

16895 lines
454KB

  1. @chapter Filtering Introduction
  2. @c man begin FILTERING INTRODUCTION
  3. Filtering in FFmpeg is enabled through the libavfilter library.
  4. In libavfilter, a filter can have multiple inputs and multiple
  5. outputs.
  6. To illustrate the sorts of things that are possible, we consider the
  7. following filtergraph.
  8. @verbatim
  9. [main]
  10. input --> split ---------------------> overlay --> output
  11. | ^
  12. |[tmp] [flip]|
  13. +-----> crop --> vflip -------+
  14. @end verbatim
  15. This filtergraph splits the input stream in two streams, then sends one
  16. stream through the crop filter and the vflip filter, before merging it
  17. back with the other stream by overlaying it on top. You can use the
  18. following command to achieve this:
  19. @example
  20. ffmpeg -i INPUT -vf "split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2" OUTPUT
  21. @end example
  22. The result will be that the top half of the video is mirrored
  23. onto the bottom half of the output video.
  24. Filters in the same linear chain are separated by commas, and distinct
  25. linear chains of filters are separated by semicolons. In our example,
  26. @var{crop,vflip} are in one linear chain, @var{split} and
  27. @var{overlay} are separately in another. The points where the linear
  28. chains join are labelled by names enclosed in square brackets. In the
  29. example, the split filter generates two outputs that are associated to
  30. the labels @var{[main]} and @var{[tmp]}.
  31. The stream sent to the second output of @var{split}, labelled as
  32. @var{[tmp]}, is processed through the @var{crop} filter, which crops
  33. away the lower half part of the video, and then vertically flipped. The
  34. @var{overlay} filter takes in input the first unchanged output of the
  35. split filter (which was labelled as @var{[main]}), and overlay on its
  36. lower half the output generated by the @var{crop,vflip} filterchain.
  37. Some filters take in input a list of parameters: they are specified
  38. after the filter name and an equal sign, and are separated from each other
  39. by a colon.
  40. There exist so-called @var{source filters} that do not have an
  41. audio/video input, and @var{sink filters} that will not have audio/video
  42. output.
  43. @c man end FILTERING INTRODUCTION
  44. @chapter graph2dot
  45. @c man begin GRAPH2DOT
  46. The @file{graph2dot} program included in the FFmpeg @file{tools}
  47. directory can be used to parse a filtergraph description and issue a
  48. corresponding textual representation in the dot language.
  49. Invoke the command:
  50. @example
  51. graph2dot -h
  52. @end example
  53. to see how to use @file{graph2dot}.
  54. You can then pass the dot description to the @file{dot} program (from
  55. the graphviz suite of programs) and obtain a graphical representation
  56. of the filtergraph.
  57. For example the sequence of commands:
  58. @example
  59. echo @var{GRAPH_DESCRIPTION} | \
  60. tools/graph2dot -o graph.tmp && \
  61. dot -Tpng graph.tmp -o graph.png && \
  62. display graph.png
  63. @end example
  64. can be used to create and display an image representing the graph
  65. described by the @var{GRAPH_DESCRIPTION} string. Note that this string must be
  66. a complete self-contained graph, with its inputs and outputs explicitly defined.
  67. For example if your command line is of the form:
  68. @example
  69. ffmpeg -i infile -vf scale=640:360 outfile
  70. @end example
  71. your @var{GRAPH_DESCRIPTION} string will need to be of the form:
  72. @example
  73. nullsrc,scale=640:360,nullsink
  74. @end example
  75. you may also need to set the @var{nullsrc} parameters and add a @var{format}
  76. filter in order to simulate a specific input file.
  77. @c man end GRAPH2DOT
  78. @chapter Filtergraph description
  79. @c man begin FILTERGRAPH DESCRIPTION
  80. A filtergraph is a directed graph of connected filters. It can contain
  81. cycles, and there can be multiple links between a pair of
  82. filters. Each link has one input pad on one side connecting it to one
  83. filter from which it takes its input, and one output pad on the other
  84. side connecting it to one filter accepting its output.
  85. Each filter in a filtergraph is an instance of a filter class
  86. registered in the application, which defines the features and the
  87. number of input and output pads of the filter.
  88. A filter with no input pads is called a "source", and a filter with no
  89. output pads is called a "sink".
  90. @anchor{Filtergraph syntax}
  91. @section Filtergraph syntax
  92. A filtergraph has a textual representation, which is recognized by the
  93. @option{-filter}/@option{-vf}/@option{-af} and
  94. @option{-filter_complex} options in @command{ffmpeg} and
  95. @option{-vf}/@option{-af} in @command{ffplay}, and by the
  96. @code{avfilter_graph_parse_ptr()} function defined in
  97. @file{libavfilter/avfilter.h}.
  98. A filterchain consists of a sequence of connected filters, each one
  99. connected to the previous one in the sequence. A filterchain is
  100. represented by a list of ","-separated filter descriptions.
  101. A filtergraph consists of a sequence of filterchains. A sequence of
  102. filterchains is represented by a list of ";"-separated filterchain
  103. descriptions.
  104. A filter is represented by a string of the form:
  105. [@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
  106. @var{filter_name} is the name of the filter class of which the
  107. described filter is an instance of, and has to be the name of one of
  108. the filter classes registered in the program.
  109. The name of the filter class is optionally followed by a string
  110. "=@var{arguments}".
  111. @var{arguments} is a string which contains the parameters used to
  112. initialize the filter instance. It may have one of two forms:
  113. @itemize
  114. @item
  115. A ':'-separated list of @var{key=value} pairs.
  116. @item
  117. A ':'-separated list of @var{value}. In this case, the keys are assumed to be
  118. the option names in the order they are declared. E.g. the @code{fade} filter
  119. declares three options in this order -- @option{type}, @option{start_frame} and
  120. @option{nb_frames}. Then the parameter list @var{in:0:30} means that the value
  121. @var{in} is assigned to the option @option{type}, @var{0} to
  122. @option{start_frame} and @var{30} to @option{nb_frames}.
  123. @item
  124. A ':'-separated list of mixed direct @var{value} and long @var{key=value}
  125. pairs. The direct @var{value} must precede the @var{key=value} pairs, and
  126. follow the same constraints order of the previous point. The following
  127. @var{key=value} pairs can be set in any preferred order.
  128. @end itemize
  129. If the option value itself is a list of items (e.g. the @code{format} filter
  130. takes a list of pixel formats), the items in the list are usually separated by
  131. @samp{|}.
  132. The list of arguments can be quoted using the character @samp{'} as initial
  133. and ending mark, and the character @samp{\} for escaping the characters
  134. within the quoted text; otherwise the argument string is considered
  135. terminated when the next special character (belonging to the set
  136. @samp{[]=;,}) is encountered.
  137. The name and arguments of the filter are optionally preceded and
  138. followed by a list of link labels.
  139. A link label allows one to name a link and associate it to a filter output
  140. or input pad. The preceding labels @var{in_link_1}
  141. ... @var{in_link_N}, are associated to the filter input pads,
  142. the following labels @var{out_link_1} ... @var{out_link_M}, are
  143. associated to the output pads.
  144. When two link labels with the same name are found in the
  145. filtergraph, a link between the corresponding input and output pad is
  146. created.
  147. If an output pad is not labelled, it is linked by default to the first
  148. unlabelled input pad of the next filter in the filterchain.
  149. For example in the filterchain
  150. @example
  151. nullsrc, split[L1], [L2]overlay, nullsink
  152. @end example
  153. the split filter instance has two output pads, and the overlay filter
  154. instance two input pads. The first output pad of split is labelled
  155. "L1", the first input pad of overlay is labelled "L2", and the second
  156. output pad of split is linked to the second input pad of overlay,
  157. which are both unlabelled.
  158. In a filter description, if the input label of the first filter is not
  159. specified, "in" is assumed; if the output label of the last filter is not
  160. specified, "out" is assumed.
  161. In a complete filterchain all the unlabelled filter input and output
  162. pads must be connected. A filtergraph is considered valid if all the
  163. filter input and output pads of all the filterchains are connected.
  164. Libavfilter will automatically insert @ref{scale} filters where format
  165. conversion is required. It is possible to specify swscale flags
  166. for those automatically inserted scalers by prepending
  167. @code{sws_flags=@var{flags};}
  168. to the filtergraph description.
  169. Here is a BNF description of the filtergraph syntax:
  170. @example
  171. @var{NAME} ::= sequence of alphanumeric characters and '_'
  172. @var{LINKLABEL} ::= "[" @var{NAME} "]"
  173. @var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
  174. @var{FILTER_ARGUMENTS} ::= sequence of chars (possibly quoted)
  175. @var{FILTER} ::= [@var{LINKLABELS}] @var{NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}]
  176. @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
  177. @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
  178. @end example
  179. @section Notes on filtergraph escaping
  180. Filtergraph description composition entails several levels of
  181. escaping. See @ref{quoting_and_escaping,,the "Quoting and escaping"
  182. section in the ffmpeg-utils(1) manual,ffmpeg-utils} for more
  183. information about the employed escaping procedure.
  184. A first level escaping affects the content of each filter option
  185. value, which may contain the special character @code{:} used to
  186. separate values, or one of the escaping characters @code{\'}.
  187. A second level escaping affects the whole filter description, which
  188. may contain the escaping characters @code{\'} or the special
  189. characters @code{[],;} used by the filtergraph description.
  190. Finally, when you specify a filtergraph on a shell commandline, you
  191. need to perform a third level escaping for the shell special
  192. characters contained within it.
  193. For example, consider the following string to be embedded in
  194. the @ref{drawtext} filter description @option{text} value:
  195. @example
  196. this is a 'string': may contain one, or more, special characters
  197. @end example
  198. This string contains the @code{'} special escaping character, and the
  199. @code{:} special character, so it needs to be escaped in this way:
  200. @example
  201. text=this is a \'string\'\: may contain one, or more, special characters
  202. @end example
  203. A second level of escaping is required when embedding the filter
  204. description in a filtergraph description, in order to escape all the
  205. filtergraph special characters. Thus the example above becomes:
  206. @example
  207. drawtext=text=this is a \\\'string\\\'\\: may contain one\, or more\, special characters
  208. @end example
  209. (note that in addition to the @code{\'} escaping special characters,
  210. also @code{,} needs to be escaped).
  211. Finally an additional level of escaping is needed when writing the
  212. filtergraph description in a shell command, which depends on the
  213. escaping rules of the adopted shell. For example, assuming that
  214. @code{\} is special and needs to be escaped with another @code{\}, the
  215. previous string will finally result in:
  216. @example
  217. -vf "drawtext=text=this is a \\\\\\'string\\\\\\'\\\\: may contain one\\, or more\\, special characters"
  218. @end example
  219. @chapter Timeline editing
  220. Some filters support a generic @option{enable} option. For the filters
  221. supporting timeline editing, this option can be set to an expression which is
  222. evaluated before sending a frame to the filter. If the evaluation is non-zero,
  223. the filter will be enabled, otherwise the frame will be sent unchanged to the
  224. next filter in the filtergraph.
  225. The expression accepts the following values:
  226. @table @samp
  227. @item t
  228. timestamp expressed in seconds, NAN if the input timestamp is unknown
  229. @item n
  230. sequential number of the input frame, starting from 0
  231. @item pos
  232. the position in the file of the input frame, NAN if unknown
  233. @item w
  234. @item h
  235. width and height of the input frame if video
  236. @end table
  237. Additionally, these filters support an @option{enable} command that can be used
  238. to re-define the expression.
  239. Like any other filtering option, the @option{enable} option follows the same
  240. rules.
  241. For example, to enable a blur filter (@ref{smartblur}) from 10 seconds to 3
  242. minutes, and a @ref{curves} filter starting at 3 seconds:
  243. @example
  244. smartblur = enable='between(t,10,3*60)',
  245. curves = enable='gte(t,3)' : preset=cross_process
  246. @end example
  247. @c man end FILTERGRAPH DESCRIPTION
  248. @chapter Audio Filters
  249. @c man begin AUDIO FILTERS
  250. When you configure your FFmpeg build, you can disable any of the
  251. existing filters using @code{--disable-filters}.
  252. The configure output will show the audio filters included in your
  253. build.
  254. Below is a description of the currently available audio filters.
  255. @section acompressor
  256. A compressor is mainly used to reduce the dynamic range of a signal.
  257. Especially modern music is mostly compressed at a high ratio to
  258. improve the overall loudness. It's done to get the highest attention
  259. of a listener, "fatten" the sound and bring more "power" to the track.
  260. If a signal is compressed too much it may sound dull or "dead"
  261. afterwards or it may start to "pump" (which could be a powerful effect
  262. but can also destroy a track completely).
  263. The right compression is the key to reach a professional sound and is
  264. the high art of mixing and mastering. Because of its complex settings
  265. it may take a long time to get the right feeling for this kind of effect.
  266. Compression is done by detecting the volume above a chosen level
  267. @code{threshold} and dividing it by the factor set with @code{ratio}.
  268. So if you set the threshold to -12dB and your signal reaches -6dB a ratio
  269. of 2:1 will result in a signal at -9dB. Because an exact manipulation of
  270. the signal would cause distortion of the waveform the reduction can be
  271. levelled over the time. This is done by setting "Attack" and "Release".
  272. @code{attack} determines how long the signal has to rise above the threshold
  273. before any reduction will occur and @code{release} sets the time the signal
  274. has to fall below the threshold to reduce the reduction again. Shorter signals
  275. than the chosen attack time will be left untouched.
  276. The overall reduction of the signal can be made up afterwards with the
  277. @code{makeup} setting. So compressing the peaks of a signal about 6dB and
  278. raising the makeup to this level results in a signal twice as loud than the
  279. source. To gain a softer entry in the compression the @code{knee} flattens the
  280. hard edge at the threshold in the range of the chosen decibels.
  281. The filter accepts the following options:
  282. @table @option
  283. @item level_in
  284. Set input gain. Default is 1. Range is between 0.015625 and 64.
  285. @item threshold
  286. If a signal of second stream rises above this level it will affect the gain
  287. reduction of the first stream.
  288. By default it is 0.125. Range is between 0.00097563 and 1.
  289. @item ratio
  290. Set a ratio by which the signal is reduced. 1:2 means that if the level
  291. rose 4dB above the threshold, it will be only 2dB above after the reduction.
  292. Default is 2. Range is between 1 and 20.
  293. @item attack
  294. Amount of milliseconds the signal has to rise above the threshold before gain
  295. reduction starts. Default is 20. Range is between 0.01 and 2000.
  296. @item release
  297. Amount of milliseconds the signal has to fall below the threshold before
  298. reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
  299. @item makeup
  300. Set the amount by how much signal will be amplified after processing.
  301. Default is 2. Range is from 1 and 64.
  302. @item knee
  303. Curve the sharp knee around the threshold to enter gain reduction more softly.
  304. Default is 2.82843. Range is between 1 and 8.
  305. @item link
  306. Choose if the @code{average} level between all channels of input stream
  307. or the louder(@code{maximum}) channel of input stream affects the
  308. reduction. Default is @code{average}.
  309. @item detection
  310. Should the exact signal be taken in case of @code{peak} or an RMS one in case
  311. of @code{rms}. Default is @code{rms} which is mostly smoother.
  312. @item mix
  313. How much to use compressed signal in output. Default is 1.
  314. Range is between 0 and 1.
  315. @end table
  316. @section acrossfade
  317. Apply cross fade from one input audio stream to another input audio stream.
  318. The cross fade is applied for specified duration near the end of first stream.
  319. The filter accepts the following options:
  320. @table @option
  321. @item nb_samples, ns
  322. Specify the number of samples for which the cross fade effect has to last.
  323. At the end of the cross fade effect the first input audio will be completely
  324. silent. Default is 44100.
  325. @item duration, d
  326. Specify the duration of the cross fade effect. See
  327. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  328. for the accepted syntax.
  329. By default the duration is determined by @var{nb_samples}.
  330. If set this option is used instead of @var{nb_samples}.
  331. @item overlap, o
  332. Should first stream end overlap with second stream start. Default is enabled.
  333. @item curve1
  334. Set curve for cross fade transition for first stream.
  335. @item curve2
  336. Set curve for cross fade transition for second stream.
  337. For description of available curve types see @ref{afade} filter description.
  338. @end table
  339. @subsection Examples
  340. @itemize
  341. @item
  342. Cross fade from one input to another:
  343. @example
  344. ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:c1=exp:c2=exp output.flac
  345. @end example
  346. @item
  347. Cross fade from one input to another but without overlapping:
  348. @example
  349. ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:o=0:c1=exp:c2=exp output.flac
  350. @end example
  351. @end itemize
  352. @section adelay
  353. Delay one or more audio channels.
  354. Samples in delayed channel are filled with silence.
  355. The filter accepts the following option:
  356. @table @option
  357. @item delays
  358. Set list of delays in milliseconds for each channel separated by '|'.
  359. At least one delay greater than 0 should be provided.
  360. Unused delays will be silently ignored. If number of given delays is
  361. smaller than number of channels all remaining channels will not be delayed.
  362. @end table
  363. @subsection Examples
  364. @itemize
  365. @item
  366. Delay first channel by 1.5 seconds, the third channel by 0.5 seconds and leave
  367. the second channel (and any other channels that may be present) unchanged.
  368. @example
  369. adelay=1500|0|500
  370. @end example
  371. @end itemize
  372. @section aecho
  373. Apply echoing to the input audio.
  374. Echoes are reflected sound and can occur naturally amongst mountains
  375. (and sometimes large buildings) when talking or shouting; digital echo
  376. effects emulate this behaviour and are often used to help fill out the
  377. sound of a single instrument or vocal. The time difference between the
  378. original signal and the reflection is the @code{delay}, and the
  379. loudness of the reflected signal is the @code{decay}.
  380. Multiple echoes can have different delays and decays.
  381. A description of the accepted parameters follows.
  382. @table @option
  383. @item in_gain
  384. Set input gain of reflected signal. Default is @code{0.6}.
  385. @item out_gain
  386. Set output gain of reflected signal. Default is @code{0.3}.
  387. @item delays
  388. Set list of time intervals in milliseconds between original signal and reflections
  389. separated by '|'. Allowed range for each @code{delay} is @code{(0 - 90000.0]}.
  390. Default is @code{1000}.
  391. @item decays
  392. Set list of loudnesses of reflected signals separated by '|'.
  393. Allowed range for each @code{decay} is @code{(0 - 1.0]}.
  394. Default is @code{0.5}.
  395. @end table
  396. @subsection Examples
  397. @itemize
  398. @item
  399. Make it sound as if there are twice as many instruments as are actually playing:
  400. @example
  401. aecho=0.8:0.88:60:0.4
  402. @end example
  403. @item
  404. If delay is very short, then it sound like a (metallic) robot playing music:
  405. @example
  406. aecho=0.8:0.88:6:0.4
  407. @end example
  408. @item
  409. A longer delay will sound like an open air concert in the mountains:
  410. @example
  411. aecho=0.8:0.9:1000:0.3
  412. @end example
  413. @item
  414. Same as above but with one more mountain:
  415. @example
  416. aecho=0.8:0.9:1000|1800:0.3|0.25
  417. @end example
  418. @end itemize
  419. @section aemphasis
  420. Audio emphasis filter creates or restores material directly taken from LPs or
  421. emphased CDs with different filter curves. E.g. to store music on vinyl the
  422. signal has to be altered by a filter first to even out the disadvantages of
  423. this recording medium.
  424. Once the material is played back the inverse filter has to be applied to
  425. restore the distortion of the frequency response.
  426. The filter accepts the following options:
  427. @table @option
  428. @item level_in
  429. Set input gain.
  430. @item level_out
  431. Set output gain.
  432. @item mode
  433. Set filter mode. For restoring material use @code{reproduction} mode, otherwise
  434. use @code{production} mode. Default is @code{reproduction} mode.
  435. @item type
  436. Set filter type. Selects medium. Can be one of the following:
  437. @table @option
  438. @item col
  439. select Columbia.
  440. @item emi
  441. select EMI.
  442. @item bsi
  443. select BSI (78RPM).
  444. @item riaa
  445. select RIAA.
  446. @item cd
  447. select Compact Disc (CD).
  448. @item 50fm
  449. select 50µs (FM).
  450. @item 75fm
  451. select 75µs (FM).
  452. @item 50kf
  453. select 50µs (FM-KF).
  454. @item 75kf
  455. select 75µs (FM-KF).
  456. @end table
  457. @end table
  458. @section aeval
  459. Modify an audio signal according to the specified expressions.
  460. This filter accepts one or more expressions (one for each channel),
  461. which are evaluated and used to modify a corresponding audio signal.
  462. It accepts the following parameters:
  463. @table @option
  464. @item exprs
  465. Set the '|'-separated expressions list for each separate channel. If
  466. the number of input channels is greater than the number of
  467. expressions, the last specified expression is used for the remaining
  468. output channels.
  469. @item channel_layout, c
  470. Set output channel layout. If not specified, the channel layout is
  471. specified by the number of expressions. If set to @samp{same}, it will
  472. use by default the same input channel layout.
  473. @end table
  474. Each expression in @var{exprs} can contain the following constants and functions:
  475. @table @option
  476. @item ch
  477. channel number of the current expression
  478. @item n
  479. number of the evaluated sample, starting from 0
  480. @item s
  481. sample rate
  482. @item t
  483. time of the evaluated sample expressed in seconds
  484. @item nb_in_channels
  485. @item nb_out_channels
  486. input and output number of channels
  487. @item val(CH)
  488. the value of input channel with number @var{CH}
  489. @end table
  490. Note: this filter is slow. For faster processing you should use a
  491. dedicated filter.
  492. @subsection Examples
  493. @itemize
  494. @item
  495. Half volume:
  496. @example
  497. aeval=val(ch)/2:c=same
  498. @end example
  499. @item
  500. Invert phase of the second channel:
  501. @example
  502. aeval=val(0)|-val(1)
  503. @end example
  504. @end itemize
  505. @anchor{afade}
  506. @section afade
  507. Apply fade-in/out effect to input audio.
  508. A description of the accepted parameters follows.
  509. @table @option
  510. @item type, t
  511. Specify the effect type, can be either @code{in} for fade-in, or
  512. @code{out} for a fade-out effect. Default is @code{in}.
  513. @item start_sample, ss
  514. Specify the number of the start sample for starting to apply the fade
  515. effect. Default is 0.
  516. @item nb_samples, ns
  517. Specify the number of samples for which the fade effect has to last. At
  518. the end of the fade-in effect the output audio will have the same
  519. volume as the input audio, at the end of the fade-out transition
  520. the output audio will be silence. Default is 44100.
  521. @item start_time, st
  522. Specify the start time of the fade effect. Default is 0.
  523. The value must be specified as a time duration; see
  524. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  525. for the accepted syntax.
  526. If set this option is used instead of @var{start_sample}.
  527. @item duration, d
  528. Specify the duration of the fade effect. See
  529. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  530. for the accepted syntax.
  531. At the end of the fade-in effect the output audio will have the same
  532. volume as the input audio, at the end of the fade-out transition
  533. the output audio will be silence.
  534. By default the duration is determined by @var{nb_samples}.
  535. If set this option is used instead of @var{nb_samples}.
  536. @item curve
  537. Set curve for fade transition.
  538. It accepts the following values:
  539. @table @option
  540. @item tri
  541. select triangular, linear slope (default)
  542. @item qsin
  543. select quarter of sine wave
  544. @item hsin
  545. select half of sine wave
  546. @item esin
  547. select exponential sine wave
  548. @item log
  549. select logarithmic
  550. @item ipar
  551. select inverted parabola
  552. @item qua
  553. select quadratic
  554. @item cub
  555. select cubic
  556. @item squ
  557. select square root
  558. @item cbr
  559. select cubic root
  560. @item par
  561. select parabola
  562. @item exp
  563. select exponential
  564. @item iqsin
  565. select inverted quarter of sine wave
  566. @item ihsin
  567. select inverted half of sine wave
  568. @item dese
  569. select double-exponential seat
  570. @item desi
  571. select double-exponential sigmoid
  572. @end table
  573. @end table
  574. @subsection Examples
  575. @itemize
  576. @item
  577. Fade in first 15 seconds of audio:
  578. @example
  579. afade=t=in:ss=0:d=15
  580. @end example
  581. @item
  582. Fade out last 25 seconds of a 900 seconds audio:
  583. @example
  584. afade=t=out:st=875:d=25
  585. @end example
  586. @end itemize
  587. @section afftfilt
  588. Apply arbitrary expressions to samples in frequency domain.
  589. @table @option
  590. @item real
  591. Set frequency domain real expression for each separate channel separated
  592. by '|'. Default is "1".
  593. If the number of input channels is greater than the number of
  594. expressions, the last specified expression is used for the remaining
  595. output channels.
  596. @item imag
  597. Set frequency domain imaginary expression for each separate channel
  598. separated by '|'. If not set, @var{real} option is used.
  599. Each expression in @var{real} and @var{imag} can contain the following
  600. constants:
  601. @table @option
  602. @item sr
  603. sample rate
  604. @item b
  605. current frequency bin number
  606. @item nb
  607. number of available bins
  608. @item ch
  609. channel number of the current expression
  610. @item chs
  611. number of channels
  612. @item pts
  613. current frame pts
  614. @end table
  615. @item win_size
  616. Set window size.
  617. It accepts the following values:
  618. @table @samp
  619. @item w16
  620. @item w32
  621. @item w64
  622. @item w128
  623. @item w256
  624. @item w512
  625. @item w1024
  626. @item w2048
  627. @item w4096
  628. @item w8192
  629. @item w16384
  630. @item w32768
  631. @item w65536
  632. @end table
  633. Default is @code{w4096}
  634. @item win_func
  635. Set window function. Default is @code{hann}.
  636. @item overlap
  637. Set window overlap. If set to 1, the recommended overlap for selected
  638. window function will be picked. Default is @code{0.75}.
  639. @end table
  640. @subsection Examples
  641. @itemize
  642. @item
  643. Leave almost only low frequencies in audio:
  644. @example
  645. afftfilt="1-clip((b/nb)*b,0,1)"
  646. @end example
  647. @end itemize
  648. @anchor{aformat}
  649. @section aformat
  650. Set output format constraints for the input audio. The framework will
  651. negotiate the most appropriate format to minimize conversions.
  652. It accepts the following parameters:
  653. @table @option
  654. @item sample_fmts
  655. A '|'-separated list of requested sample formats.
  656. @item sample_rates
  657. A '|'-separated list of requested sample rates.
  658. @item channel_layouts
  659. A '|'-separated list of requested channel layouts.
  660. See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  661. for the required syntax.
  662. @end table
  663. If a parameter is omitted, all values are allowed.
  664. Force the output to either unsigned 8-bit or signed 16-bit stereo
  665. @example
  666. aformat=sample_fmts=u8|s16:channel_layouts=stereo
  667. @end example
  668. @section agate
  669. A gate is mainly used to reduce lower parts of a signal. This kind of signal
  670. processing reduces disturbing noise between useful signals.
  671. Gating is done by detecting the volume below a chosen level @var{threshold}
  672. and divide it by the factor set with @var{ratio}. The bottom of the noise
  673. floor is set via @var{range}. Because an exact manipulation of the signal
  674. would cause distortion of the waveform the reduction can be levelled over
  675. time. This is done by setting @var{attack} and @var{release}.
  676. @var{attack} determines how long the signal has to fall below the threshold
  677. before any reduction will occur and @var{release} sets the time the signal
  678. has to raise above the threshold to reduce the reduction again.
  679. Shorter signals than the chosen attack time will be left untouched.
  680. @table @option
  681. @item level_in
  682. Set input level before filtering.
  683. Default is 1. Allowed range is from 0.015625 to 64.
  684. @item range
  685. Set the level of gain reduction when the signal is below the threshold.
  686. Default is 0.06125. Allowed range is from 0 to 1.
  687. @item threshold
  688. If a signal rises above this level the gain reduction is released.
  689. Default is 0.125. Allowed range is from 0 to 1.
  690. @item ratio
  691. Set a ratio about which the signal is reduced.
  692. Default is 2. Allowed range is from 1 to 9000.
  693. @item attack
  694. Amount of milliseconds the signal has to rise above the threshold before gain
  695. reduction stops.
  696. Default is 20 milliseconds. Allowed range is from 0.01 to 9000.
  697. @item release
  698. Amount of milliseconds the signal has to fall below the threshold before the
  699. reduction is increased again. Default is 250 milliseconds.
  700. Allowed range is from 0.01 to 9000.
  701. @item makeup
  702. Set amount of amplification of signal after processing.
  703. Default is 1. Allowed range is from 1 to 64.
  704. @item knee
  705. Curve the sharp knee around the threshold to enter gain reduction more softly.
  706. Default is 2.828427125. Allowed range is from 1 to 8.
  707. @item detection
  708. Choose if exact signal should be taken for detection or an RMS like one.
  709. Default is rms. Can be peak or rms.
  710. @item link
  711. Choose if the average level between all channels or the louder channel affects
  712. the reduction.
  713. Default is average. Can be average or maximum.
  714. @end table
  715. @section alimiter
  716. The limiter prevents input signal from raising over a desired threshold.
  717. This limiter uses lookahead technology to prevent your signal from distorting.
  718. It means that there is a small delay after signal is processed. Keep in mind
  719. that the delay it produces is the attack time you set.
  720. The filter accepts the following options:
  721. @table @option
  722. @item level_in
  723. Set input gain. Default is 1.
  724. @item level_out
  725. Set output gain. Default is 1.
  726. @item limit
  727. Don't let signals above this level pass the limiter. Default is 1.
  728. @item attack
  729. The limiter will reach its attenuation level in this amount of time in
  730. milliseconds. Default is 5 milliseconds.
  731. @item release
  732. Come back from limiting to attenuation 1.0 in this amount of milliseconds.
  733. Default is 50 milliseconds.
  734. @item asc
  735. When gain reduction is always needed ASC takes care of releasing to an
  736. average reduction level rather than reaching a reduction of 0 in the release
  737. time.
  738. @item asc_level
  739. Select how much the release time is affected by ASC, 0 means nearly no changes
  740. in release time while 1 produces higher release times.
  741. @item level
  742. Auto level output signal. Default is enabled.
  743. This normalizes audio back to 0dB if enabled.
  744. @end table
  745. Depending on picked setting it is recommended to upsample input 2x or 4x times
  746. with @ref{aresample} before applying this filter.
  747. @section allpass
  748. Apply a two-pole all-pass filter with central frequency (in Hz)
  749. @var{frequency}, and filter-width @var{width}.
  750. An all-pass filter changes the audio's frequency to phase relationship
  751. without changing its frequency to amplitude relationship.
  752. The filter accepts the following options:
  753. @table @option
  754. @item frequency, f
  755. Set frequency in Hz.
  756. @item width_type
  757. Set method to specify band-width of filter.
  758. @table @option
  759. @item h
  760. Hz
  761. @item q
  762. Q-Factor
  763. @item o
  764. octave
  765. @item s
  766. slope
  767. @end table
  768. @item width, w
  769. Specify the band-width of a filter in width_type units.
  770. @end table
  771. @anchor{amerge}
  772. @section amerge
  773. Merge two or more audio streams into a single multi-channel stream.
  774. The filter accepts the following options:
  775. @table @option
  776. @item inputs
  777. Set the number of inputs. Default is 2.
  778. @end table
  779. If the channel layouts of the inputs are disjoint, and therefore compatible,
  780. the channel layout of the output will be set accordingly and the channels
  781. will be reordered as necessary. If the channel layouts of the inputs are not
  782. disjoint, the output will have all the channels of the first input then all
  783. the channels of the second input, in that order, and the channel layout of
  784. the output will be the default value corresponding to the total number of
  785. channels.
  786. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  787. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  788. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  789. first input, b1 is the first channel of the second input).
  790. On the other hand, if both input are in stereo, the output channels will be
  791. in the default order: a1, a2, b1, b2, and the channel layout will be
  792. arbitrarily set to 4.0, which may or may not be the expected value.
  793. All inputs must have the same sample rate, and format.
  794. If inputs do not have the same duration, the output will stop with the
  795. shortest.
  796. @subsection Examples
  797. @itemize
  798. @item
  799. Merge two mono files into a stereo stream:
  800. @example
  801. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  802. @end example
  803. @item
  804. Multiple merges assuming 1 video stream and 6 audio streams in @file{input.mkv}:
  805. @example
  806. ffmpeg -i input.mkv -filter_complex "[0:1][0:2][0:3][0:4][0:5][0:6] amerge=inputs=6" -c:a pcm_s16le output.mkv
  807. @end example
  808. @end itemize
  809. @section amix
  810. Mixes multiple audio inputs into a single output.
  811. Note that this filter only supports float samples (the @var{amerge}
  812. and @var{pan} audio filters support many formats). If the @var{amix}
  813. input has integer samples then @ref{aresample} will be automatically
  814. inserted to perform the conversion to float samples.
  815. For example
  816. @example
  817. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  818. @end example
  819. will mix 3 input audio streams to a single output with the same duration as the
  820. first input and a dropout transition time of 3 seconds.
  821. It accepts the following parameters:
  822. @table @option
  823. @item inputs
  824. The number of inputs. If unspecified, it defaults to 2.
  825. @item duration
  826. How to determine the end-of-stream.
  827. @table @option
  828. @item longest
  829. The duration of the longest input. (default)
  830. @item shortest
  831. The duration of the shortest input.
  832. @item first
  833. The duration of the first input.
  834. @end table
  835. @item dropout_transition
  836. The transition time, in seconds, for volume renormalization when an input
  837. stream ends. The default value is 2 seconds.
  838. @end table
  839. @section anequalizer
  840. High-order parametric multiband equalizer for each channel.
  841. It accepts the following parameters:
  842. @table @option
  843. @item params
  844. This option string is in format:
  845. "c@var{chn} f=@var{cf} w=@var{w} g=@var{g} t=@var{f} | ..."
  846. Each equalizer band is separated by '|'.
  847. @table @option
  848. @item chn
  849. Set channel number to which equalization will be applied.
  850. If input doesn't have that channel the entry is ignored.
  851. @item cf
  852. Set central frequency for band.
  853. If input doesn't have that frequency the entry is ignored.
  854. @item w
  855. Set band width in hertz.
  856. @item g
  857. Set band gain in dB.
  858. @item f
  859. Set filter type for band, optional, can be:
  860. @table @samp
  861. @item 0
  862. Butterworth, this is default.
  863. @item 1
  864. Chebyshev type 1.
  865. @item 2
  866. Chebyshev type 2.
  867. @end table
  868. @end table
  869. @item curves
  870. With this option activated frequency response of anequalizer is displayed
  871. in video stream.
  872. @item size
  873. Set video stream size. Only useful if curves option is activated.
  874. @item mgain
  875. Set max gain that will be displayed. Only useful if curves option is activated.
  876. Setting this to reasonable value allows to display gain which is derived from
  877. neighbour bands which are too close to each other and thus produce higher gain
  878. when both are activated.
  879. @item fscale
  880. Set frequency scale used to draw frequency response in video output.
  881. Can be linear or logarithmic. Default is logarithmic.
  882. @item colors
  883. Set color for each channel curve which is going to be displayed in video stream.
  884. This is list of color names separated by space or by '|'.
  885. Unrecognised or missing colors will be replaced by white color.
  886. @end table
  887. @subsection Examples
  888. @itemize
  889. @item
  890. Lower gain by 10 of central frequency 200Hz and width 100 Hz
  891. for first 2 channels using Chebyshev type 1 filter:
  892. @example
  893. anequalizer=c0 f=200 w=100 g=-10 t=1|c1 f=200 w=100 g=-10 t=1
  894. @end example
  895. @end itemize
  896. @subsection Commands
  897. This filter supports the following commands:
  898. @table @option
  899. @item change
  900. Alter existing filter parameters.
  901. Syntax for the commands is : "@var{fN}|f=@var{freq}|w=@var{width}|g=@var{gain}"
  902. @var{fN} is existing filter number, starting from 0, if no such filter is available
  903. error is returned.
  904. @var{freq} set new frequency parameter.
  905. @var{width} set new width parameter in herz.
  906. @var{gain} set new gain parameter in dB.
  907. Full filter invocation with asendcmd may look like this:
  908. asendcmd=c='4.0 anequalizer change 0|f=200|w=50|g=1',anequalizer=...
  909. @end table
  910. @section anull
  911. Pass the audio source unchanged to the output.
  912. @section apad
  913. Pad the end of an audio stream with silence.
  914. This can be used together with @command{ffmpeg} @option{-shortest} to
  915. extend audio streams to the same length as the video stream.
  916. A description of the accepted options follows.
  917. @table @option
  918. @item packet_size
  919. Set silence packet size. Default value is 4096.
  920. @item pad_len
  921. Set the number of samples of silence to add to the end. After the
  922. value is reached, the stream is terminated. This option is mutually
  923. exclusive with @option{whole_len}.
  924. @item whole_len
  925. Set the minimum total number of samples in the output audio stream. If
  926. the value is longer than the input audio length, silence is added to
  927. the end, until the value is reached. This option is mutually exclusive
  928. with @option{pad_len}.
  929. @end table
  930. If neither the @option{pad_len} nor the @option{whole_len} option is
  931. set, the filter will add silence to the end of the input stream
  932. indefinitely.
  933. @subsection Examples
  934. @itemize
  935. @item
  936. Add 1024 samples of silence to the end of the input:
  937. @example
  938. apad=pad_len=1024
  939. @end example
  940. @item
  941. Make sure the audio output will contain at least 10000 samples, pad
  942. the input with silence if required:
  943. @example
  944. apad=whole_len=10000
  945. @end example
  946. @item
  947. Use @command{ffmpeg} to pad the audio input with silence, so that the
  948. video stream will always result the shortest and will be converted
  949. until the end in the output file when using the @option{shortest}
  950. option:
  951. @example
  952. ffmpeg -i VIDEO -i AUDIO -filter_complex "[1:0]apad" -shortest OUTPUT
  953. @end example
  954. @end itemize
  955. @section aphaser
  956. Add a phasing effect to the input audio.
  957. A phaser filter creates series of peaks and troughs in the frequency spectrum.
  958. The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
  959. A description of the accepted parameters follows.
  960. @table @option
  961. @item in_gain
  962. Set input gain. Default is 0.4.
  963. @item out_gain
  964. Set output gain. Default is 0.74
  965. @item delay
  966. Set delay in milliseconds. Default is 3.0.
  967. @item decay
  968. Set decay. Default is 0.4.
  969. @item speed
  970. Set modulation speed in Hz. Default is 0.5.
  971. @item type
  972. Set modulation type. Default is triangular.
  973. It accepts the following values:
  974. @table @samp
  975. @item triangular, t
  976. @item sinusoidal, s
  977. @end table
  978. @end table
  979. @section apulsator
  980. Audio pulsator is something between an autopanner and a tremolo.
  981. But it can produce funny stereo effects as well. Pulsator changes the volume
  982. of the left and right channel based on a LFO (low frequency oscillator) with
  983. different waveforms and shifted phases.
  984. This filter have the ability to define an offset between left and right
  985. channel. An offset of 0 means that both LFO shapes match each other.
  986. The left and right channel are altered equally - a conventional tremolo.
  987. An offset of 50% means that the shape of the right channel is exactly shifted
  988. in phase (or moved backwards about half of the frequency) - pulsator acts as
  989. an autopanner. At 1 both curves match again. Every setting in between moves the
  990. phase shift gapless between all stages and produces some "bypassing" sounds with
  991. sine and triangle waveforms. The more you set the offset near 1 (starting from
  992. the 0.5) the faster the signal passes from the left to the right speaker.
  993. The filter accepts the following options:
  994. @table @option
  995. @item level_in
  996. Set input gain. By default it is 1. Range is [0.015625 - 64].
  997. @item level_out
  998. Set output gain. By default it is 1. Range is [0.015625 - 64].
  999. @item mode
  1000. Set waveform shape the LFO will use. Can be one of: sine, triangle, square,
  1001. sawup or sawdown. Default is sine.
  1002. @item amount
  1003. Set modulation. Define how much of original signal is affected by the LFO.
  1004. @item offset_l
  1005. Set left channel offset. Default is 0. Allowed range is [0 - 1].
  1006. @item offset_r
  1007. Set right channel offset. Default is 0.5. Allowed range is [0 - 1].
  1008. @item width
  1009. Set pulse width. Default is 1. Allowed range is [0 - 2].
  1010. @item timing
  1011. Set possible timing mode. Can be one of: bpm, ms or hz. Default is hz.
  1012. @item bpm
  1013. Set bpm. Default is 120. Allowed range is [30 - 300]. Only used if timing
  1014. is set to bpm.
  1015. @item ms
  1016. Set ms. Default is 500. Allowed range is [10 - 2000]. Only used if timing
  1017. is set to ms.
  1018. @item hz
  1019. Set frequency in Hz. Default is 2. Allowed range is [0.01 - 100]. Only used
  1020. if timing is set to hz.
  1021. @end table
  1022. @anchor{aresample}
  1023. @section aresample
  1024. Resample the input audio to the specified parameters, using the
  1025. libswresample library. If none are specified then the filter will
  1026. automatically convert between its input and output.
  1027. This filter is also able to stretch/squeeze the audio data to make it match
  1028. the timestamps or to inject silence / cut out audio to make it match the
  1029. timestamps, do a combination of both or do neither.
  1030. The filter accepts the syntax
  1031. [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
  1032. expresses a sample rate and @var{resampler_options} is a list of
  1033. @var{key}=@var{value} pairs, separated by ":". See the
  1034. ffmpeg-resampler manual for the complete list of supported options.
  1035. @subsection Examples
  1036. @itemize
  1037. @item
  1038. Resample the input audio to 44100Hz:
  1039. @example
  1040. aresample=44100
  1041. @end example
  1042. @item
  1043. Stretch/squeeze samples to the given timestamps, with a maximum of 1000
  1044. samples per second compensation:
  1045. @example
  1046. aresample=async=1000
  1047. @end example
  1048. @end itemize
  1049. @section asetnsamples
  1050. Set the number of samples per each output audio frame.
  1051. The last output packet may contain a different number of samples, as
  1052. the filter will flush all the remaining samples when the input audio
  1053. signal its end.
  1054. The filter accepts the following options:
  1055. @table @option
  1056. @item nb_out_samples, n
  1057. Set the number of frames per each output audio frame. The number is
  1058. intended as the number of samples @emph{per each channel}.
  1059. Default value is 1024.
  1060. @item pad, p
  1061. If set to 1, the filter will pad the last audio frame with zeroes, so
  1062. that the last frame will contain the same number of samples as the
  1063. previous ones. Default value is 1.
  1064. @end table
  1065. For example, to set the number of per-frame samples to 1234 and
  1066. disable padding for the last frame, use:
  1067. @example
  1068. asetnsamples=n=1234:p=0
  1069. @end example
  1070. @section asetrate
  1071. Set the sample rate without altering the PCM data.
  1072. This will result in a change of speed and pitch.
  1073. The filter accepts the following options:
  1074. @table @option
  1075. @item sample_rate, r
  1076. Set the output sample rate. Default is 44100 Hz.
  1077. @end table
  1078. @section ashowinfo
  1079. Show a line containing various information for each input audio frame.
  1080. The input audio is not modified.
  1081. The shown line contains a sequence of key/value pairs of the form
  1082. @var{key}:@var{value}.
  1083. The following values are shown in the output:
  1084. @table @option
  1085. @item n
  1086. The (sequential) number of the input frame, starting from 0.
  1087. @item pts
  1088. The presentation timestamp of the input frame, in time base units; the time base
  1089. depends on the filter input pad, and is usually 1/@var{sample_rate}.
  1090. @item pts_time
  1091. The presentation timestamp of the input frame in seconds.
  1092. @item pos
  1093. position of the frame in the input stream, -1 if this information in
  1094. unavailable and/or meaningless (for example in case of synthetic audio)
  1095. @item fmt
  1096. The sample format.
  1097. @item chlayout
  1098. The channel layout.
  1099. @item rate
  1100. The sample rate for the audio frame.
  1101. @item nb_samples
  1102. The number of samples (per channel) in the frame.
  1103. @item checksum
  1104. The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
  1105. audio, the data is treated as if all the planes were concatenated.
  1106. @item plane_checksums
  1107. A list of Adler-32 checksums for each data plane.
  1108. @end table
  1109. @anchor{astats}
  1110. @section astats
  1111. Display time domain statistical information about the audio channels.
  1112. Statistics are calculated and displayed for each audio channel and,
  1113. where applicable, an overall figure is also given.
  1114. It accepts the following option:
  1115. @table @option
  1116. @item length
  1117. Short window length in seconds, used for peak and trough RMS measurement.
  1118. Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.1 - 10]}.
  1119. @item metadata
  1120. Set metadata injection. All the metadata keys are prefixed with @code{lavfi.astats.X},
  1121. where @code{X} is channel number starting from 1 or string @code{Overall}. Default is
  1122. disabled.
  1123. Available keys for each channel are:
  1124. DC_offset
  1125. Min_level
  1126. Max_level
  1127. Min_difference
  1128. Max_difference
  1129. Mean_difference
  1130. Peak_level
  1131. RMS_peak
  1132. RMS_trough
  1133. Crest_factor
  1134. Flat_factor
  1135. Peak_count
  1136. Bit_depth
  1137. and for Overall:
  1138. DC_offset
  1139. Min_level
  1140. Max_level
  1141. Min_difference
  1142. Max_difference
  1143. Mean_difference
  1144. Peak_level
  1145. RMS_level
  1146. RMS_peak
  1147. RMS_trough
  1148. Flat_factor
  1149. Peak_count
  1150. Bit_depth
  1151. Number_of_samples
  1152. For example full key look like this @code{lavfi.astats.1.DC_offset} or
  1153. this @code{lavfi.astats.Overall.Peak_count}.
  1154. For description what each key means read below.
  1155. @item reset
  1156. Set number of frame after which stats are going to be recalculated.
  1157. Default is disabled.
  1158. @end table
  1159. A description of each shown parameter follows:
  1160. @table @option
  1161. @item DC offset
  1162. Mean amplitude displacement from zero.
  1163. @item Min level
  1164. Minimal sample level.
  1165. @item Max level
  1166. Maximal sample level.
  1167. @item Min difference
  1168. Minimal difference between two consecutive samples.
  1169. @item Max difference
  1170. Maximal difference between two consecutive samples.
  1171. @item Mean difference
  1172. Mean difference between two consecutive samples.
  1173. The average of each difference between two consecutive samples.
  1174. @item Peak level dB
  1175. @item RMS level dB
  1176. Standard peak and RMS level measured in dBFS.
  1177. @item RMS peak dB
  1178. @item RMS trough dB
  1179. Peak and trough values for RMS level measured over a short window.
  1180. @item Crest factor
  1181. Standard ratio of peak to RMS level (note: not in dB).
  1182. @item Flat factor
  1183. Flatness (i.e. consecutive samples with the same value) of the signal at its peak levels
  1184. (i.e. either @var{Min level} or @var{Max level}).
  1185. @item Peak count
  1186. Number of occasions (not the number of samples) that the signal attained either
  1187. @var{Min level} or @var{Max level}.
  1188. @item Bit depth
  1189. Overall bit depth of audio. Number of bits used for each sample.
  1190. @end table
  1191. @section asyncts
  1192. Synchronize audio data with timestamps by squeezing/stretching it and/or
  1193. dropping samples/adding silence when needed.
  1194. This filter is not built by default, please use @ref{aresample} to do squeezing/stretching.
  1195. It accepts the following parameters:
  1196. @table @option
  1197. @item compensate
  1198. Enable stretching/squeezing the data to make it match the timestamps. Disabled
  1199. by default. When disabled, time gaps are covered with silence.
  1200. @item min_delta
  1201. The minimum difference between timestamps and audio data (in seconds) to trigger
  1202. adding/dropping samples. The default value is 0.1. If you get an imperfect
  1203. sync with this filter, try setting this parameter to 0.
  1204. @item max_comp
  1205. The maximum compensation in samples per second. Only relevant with compensate=1.
  1206. The default value is 500.
  1207. @item first_pts
  1208. Assume that the first PTS should be this value. The time base is 1 / sample
  1209. rate. This allows for padding/trimming at the start of the stream. By default,
  1210. no assumption is made about the first frame's expected PTS, so no padding or
  1211. trimming is done. For example, this could be set to 0 to pad the beginning with
  1212. silence if an audio stream starts after the video stream or to trim any samples
  1213. with a negative PTS due to encoder delay.
  1214. @end table
  1215. @section atempo
  1216. Adjust audio tempo.
  1217. The filter accepts exactly one parameter, the audio tempo. If not
  1218. specified then the filter will assume nominal 1.0 tempo. Tempo must
  1219. be in the [0.5, 2.0] range.
  1220. @subsection Examples
  1221. @itemize
  1222. @item
  1223. Slow down audio to 80% tempo:
  1224. @example
  1225. atempo=0.8
  1226. @end example
  1227. @item
  1228. To speed up audio to 125% tempo:
  1229. @example
  1230. atempo=1.25
  1231. @end example
  1232. @end itemize
  1233. @section atrim
  1234. Trim the input so that the output contains one continuous subpart of the input.
  1235. It accepts the following parameters:
  1236. @table @option
  1237. @item start
  1238. Timestamp (in seconds) of the start of the section to keep. I.e. the audio
  1239. sample with the timestamp @var{start} will be the first sample in the output.
  1240. @item end
  1241. Specify time of the first audio sample that will be dropped, i.e. the
  1242. audio sample immediately preceding the one with the timestamp @var{end} will be
  1243. the last sample in the output.
  1244. @item start_pts
  1245. Same as @var{start}, except this option sets the start timestamp in samples
  1246. instead of seconds.
  1247. @item end_pts
  1248. Same as @var{end}, except this option sets the end timestamp in samples instead
  1249. of seconds.
  1250. @item duration
  1251. The maximum duration of the output in seconds.
  1252. @item start_sample
  1253. The number of the first sample that should be output.
  1254. @item end_sample
  1255. The number of the first sample that should be dropped.
  1256. @end table
  1257. @option{start}, @option{end}, and @option{duration} are expressed as time
  1258. duration specifications; see
  1259. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  1260. Note that the first two sets of the start/end options and the @option{duration}
  1261. option look at the frame timestamp, while the _sample options simply count the
  1262. samples that pass through the filter. So start/end_pts and start/end_sample will
  1263. give different results when the timestamps are wrong, inexact or do not start at
  1264. zero. Also note that this filter does not modify the timestamps. If you wish
  1265. to have the output timestamps start at zero, insert the asetpts filter after the
  1266. atrim filter.
  1267. If multiple start or end options are set, this filter tries to be greedy and
  1268. keep all samples that match at least one of the specified constraints. To keep
  1269. only the part that matches all the constraints at once, chain multiple atrim
  1270. filters.
  1271. The defaults are such that all the input is kept. So it is possible to set e.g.
  1272. just the end values to keep everything before the specified time.
  1273. Examples:
  1274. @itemize
  1275. @item
  1276. Drop everything except the second minute of input:
  1277. @example
  1278. ffmpeg -i INPUT -af atrim=60:120
  1279. @end example
  1280. @item
  1281. Keep only the first 1000 samples:
  1282. @example
  1283. ffmpeg -i INPUT -af atrim=end_sample=1000
  1284. @end example
  1285. @end itemize
  1286. @section bandpass
  1287. Apply a two-pole Butterworth band-pass filter with central
  1288. frequency @var{frequency}, and (3dB-point) band-width width.
  1289. The @var{csg} option selects a constant skirt gain (peak gain = Q)
  1290. instead of the default: constant 0dB peak gain.
  1291. The filter roll off at 6dB per octave (20dB per decade).
  1292. The filter accepts the following options:
  1293. @table @option
  1294. @item frequency, f
  1295. Set the filter's central frequency. Default is @code{3000}.
  1296. @item csg
  1297. Constant skirt gain if set to 1. Defaults to 0.
  1298. @item width_type
  1299. Set method to specify band-width of filter.
  1300. @table @option
  1301. @item h
  1302. Hz
  1303. @item q
  1304. Q-Factor
  1305. @item o
  1306. octave
  1307. @item s
  1308. slope
  1309. @end table
  1310. @item width, w
  1311. Specify the band-width of a filter in width_type units.
  1312. @end table
  1313. @section bandreject
  1314. Apply a two-pole Butterworth band-reject filter with central
  1315. frequency @var{frequency}, and (3dB-point) band-width @var{width}.
  1316. The filter roll off at 6dB per octave (20dB per decade).
  1317. The filter accepts the following options:
  1318. @table @option
  1319. @item frequency, f
  1320. Set the filter's central frequency. Default is @code{3000}.
  1321. @item width_type
  1322. Set method to specify band-width of filter.
  1323. @table @option
  1324. @item h
  1325. Hz
  1326. @item q
  1327. Q-Factor
  1328. @item o
  1329. octave
  1330. @item s
  1331. slope
  1332. @end table
  1333. @item width, w
  1334. Specify the band-width of a filter in width_type units.
  1335. @end table
  1336. @section bass
  1337. Boost or cut the bass (lower) frequencies of the audio using a two-pole
  1338. shelving filter with a response similar to that of a standard
  1339. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  1340. The filter accepts the following options:
  1341. @table @option
  1342. @item gain, g
  1343. Give the gain at 0 Hz. Its useful range is about -20
  1344. (for a large cut) to +20 (for a large boost).
  1345. Beware of clipping when using a positive gain.
  1346. @item frequency, f
  1347. Set the filter's central frequency and so can be used
  1348. to extend or reduce the frequency range to be boosted or cut.
  1349. The default value is @code{100} Hz.
  1350. @item width_type
  1351. Set method to specify band-width of filter.
  1352. @table @option
  1353. @item h
  1354. Hz
  1355. @item q
  1356. Q-Factor
  1357. @item o
  1358. octave
  1359. @item s
  1360. slope
  1361. @end table
  1362. @item width, w
  1363. Determine how steep is the filter's shelf transition.
  1364. @end table
  1365. @section biquad
  1366. Apply a biquad IIR filter with the given coefficients.
  1367. Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
  1368. are the numerator and denominator coefficients respectively.
  1369. @section bs2b
  1370. Bauer stereo to binaural transformation, which improves headphone listening of
  1371. stereo audio records.
  1372. It accepts the following parameters:
  1373. @table @option
  1374. @item profile
  1375. Pre-defined crossfeed level.
  1376. @table @option
  1377. @item default
  1378. Default level (fcut=700, feed=50).
  1379. @item cmoy
  1380. Chu Moy circuit (fcut=700, feed=60).
  1381. @item jmeier
  1382. Jan Meier circuit (fcut=650, feed=95).
  1383. @end table
  1384. @item fcut
  1385. Cut frequency (in Hz).
  1386. @item feed
  1387. Feed level (in Hz).
  1388. @end table
  1389. @section channelmap
  1390. Remap input channels to new locations.
  1391. It accepts the following parameters:
  1392. @table @option
  1393. @item channel_layout
  1394. The channel layout of the output stream.
  1395. @item map
  1396. Map channels from input to output. The argument is a '|'-separated list of
  1397. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  1398. @var{in_channel} form. @var{in_channel} can be either the name of the input
  1399. channel (e.g. FL for front left) or its index in the input channel layout.
  1400. @var{out_channel} is the name of the output channel or its index in the output
  1401. channel layout. If @var{out_channel} is not given then it is implicitly an
  1402. index, starting with zero and increasing by one for each mapping.
  1403. @end table
  1404. If no mapping is present, the filter will implicitly map input channels to
  1405. output channels, preserving indices.
  1406. For example, assuming a 5.1+downmix input MOV file,
  1407. @example
  1408. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
  1409. @end example
  1410. will create an output WAV file tagged as stereo from the downmix channels of
  1411. the input.
  1412. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  1413. @example
  1414. ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:5.1' out.wav
  1415. @end example
  1416. @section channelsplit
  1417. Split each channel from an input audio stream into a separate output stream.
  1418. It accepts the following parameters:
  1419. @table @option
  1420. @item channel_layout
  1421. The channel layout of the input stream. The default is "stereo".
  1422. @end table
  1423. For example, assuming a stereo input MP3 file,
  1424. @example
  1425. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  1426. @end example
  1427. will create an output Matroska file with two audio streams, one containing only
  1428. the left channel and the other the right channel.
  1429. Split a 5.1 WAV file into per-channel files:
  1430. @example
  1431. ffmpeg -i in.wav -filter_complex
  1432. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  1433. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  1434. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  1435. side_right.wav
  1436. @end example
  1437. @section chorus
  1438. Add a chorus effect to the audio.
  1439. Can make a single vocal sound like a chorus, but can also be applied to instrumentation.
  1440. Chorus resembles an echo effect with a short delay, but whereas with echo the delay is
  1441. constant, with chorus, it is varied using using sinusoidal or triangular modulation.
  1442. The modulation depth defines the range the modulated delay is played before or after
  1443. the delay. Hence the delayed sound will sound slower or faster, that is the delayed
  1444. sound tuned around the original one, like in a chorus where some vocals are slightly
  1445. off key.
  1446. It accepts the following parameters:
  1447. @table @option
  1448. @item in_gain
  1449. Set input gain. Default is 0.4.
  1450. @item out_gain
  1451. Set output gain. Default is 0.4.
  1452. @item delays
  1453. Set delays. A typical delay is around 40ms to 60ms.
  1454. @item decays
  1455. Set decays.
  1456. @item speeds
  1457. Set speeds.
  1458. @item depths
  1459. Set depths.
  1460. @end table
  1461. @subsection Examples
  1462. @itemize
  1463. @item
  1464. A single delay:
  1465. @example
  1466. chorus=0.7:0.9:55:0.4:0.25:2
  1467. @end example
  1468. @item
  1469. Two delays:
  1470. @example
  1471. chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3
  1472. @end example
  1473. @item
  1474. Fuller sounding chorus with three delays:
  1475. @example
  1476. chorus=0.5:0.9:50|60|40:0.4|0.32|0.3:0.25|0.4|0.3:2|2.3|1.3
  1477. @end example
  1478. @end itemize
  1479. @section compand
  1480. Compress or expand the audio's dynamic range.
  1481. It accepts the following parameters:
  1482. @table @option
  1483. @item attacks
  1484. @item decays
  1485. A list of times in seconds for each channel over which the instantaneous level
  1486. of the input signal is averaged to determine its volume. @var{attacks} refers to
  1487. increase of volume and @var{decays} refers to decrease of volume. For most
  1488. situations, the attack time (response to the audio getting louder) should be
  1489. shorter than the decay time, because the human ear is more sensitive to sudden
  1490. loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
  1491. a typical value for decay is 0.8 seconds.
  1492. If specified number of attacks & decays is lower than number of channels, the last
  1493. set attack/decay will be used for all remaining channels.
  1494. @item points
  1495. A list of points for the transfer function, specified in dB relative to the
  1496. maximum possible signal amplitude. Each key points list must be defined using
  1497. the following syntax: @code{x0/y0|x1/y1|x2/y2|....} or
  1498. @code{x0/y0 x1/y1 x2/y2 ....}
  1499. The input values must be in strictly increasing order but the transfer function
  1500. does not have to be monotonically rising. The point @code{0/0} is assumed but
  1501. may be overridden (by @code{0/out-dBn}). Typical values for the transfer
  1502. function are @code{-70/-70|-60/-20}.
  1503. @item soft-knee
  1504. Set the curve radius in dB for all joints. It defaults to 0.01.
  1505. @item gain
  1506. Set the additional gain in dB to be applied at all points on the transfer
  1507. function. This allows for easy adjustment of the overall gain.
  1508. It defaults to 0.
  1509. @item volume
  1510. Set an initial volume, in dB, to be assumed for each channel when filtering
  1511. starts. This permits the user to supply a nominal level initially, so that, for
  1512. example, a very large gain is not applied to initial signal levels before the
  1513. companding has begun to operate. A typical value for audio which is initially
  1514. quiet is -90 dB. It defaults to 0.
  1515. @item delay
  1516. Set a delay, in seconds. The input audio is analyzed immediately, but audio is
  1517. delayed before being fed to the volume adjuster. Specifying a delay
  1518. approximately equal to the attack/decay times allows the filter to effectively
  1519. operate in predictive rather than reactive mode. It defaults to 0.
  1520. @end table
  1521. @subsection Examples
  1522. @itemize
  1523. @item
  1524. Make music with both quiet and loud passages suitable for listening to in a
  1525. noisy environment:
  1526. @example
  1527. compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
  1528. @end example
  1529. Another example for audio with whisper and explosion parts:
  1530. @example
  1531. compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0
  1532. @end example
  1533. @item
  1534. A noise gate for when the noise is at a lower level than the signal:
  1535. @example
  1536. compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
  1537. @end example
  1538. @item
  1539. Here is another noise gate, this time for when the noise is at a higher level
  1540. than the signal (making it, in some ways, similar to squelch):
  1541. @example
  1542. compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
  1543. @end example
  1544. @item
  1545. 2:1 compression starting at -6dB:
  1546. @example
  1547. compand=points=-80/-80|-6/-6|0/-3.8|20/3.5
  1548. @end example
  1549. @item
  1550. 2:1 compression starting at -9dB:
  1551. @example
  1552. compand=points=-80/-80|-9/-9|0/-5.3|20/2.9
  1553. @end example
  1554. @item
  1555. 2:1 compression starting at -12dB:
  1556. @example
  1557. compand=points=-80/-80|-12/-12|0/-6.8|20/1.9
  1558. @end example
  1559. @item
  1560. 2:1 compression starting at -18dB:
  1561. @example
  1562. compand=points=-80/-80|-18/-18|0/-9.8|20/0.7
  1563. @end example
  1564. @item
  1565. 3:1 compression starting at -15dB:
  1566. @example
  1567. compand=points=-80/-80|-15/-15|0/-10.8|20/-5.2
  1568. @end example
  1569. @item
  1570. Compressor/Gate:
  1571. @example
  1572. compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6
  1573. @end example
  1574. @item
  1575. Expander:
  1576. @example
  1577. compand=attacks=0:points=-80/-169|-54/-80|-49.5/-64.6|-41.1/-41.1|-25.8/-15|-10.8/-4.5|0/0|20/8.3
  1578. @end example
  1579. @item
  1580. Hard limiter at -6dB:
  1581. @example
  1582. compand=attacks=0:points=-80/-80|-6/-6|20/-6
  1583. @end example
  1584. @item
  1585. Hard limiter at -12dB:
  1586. @example
  1587. compand=attacks=0:points=-80/-80|-12/-12|20/-12
  1588. @end example
  1589. @item
  1590. Hard noise gate at -35 dB:
  1591. @example
  1592. compand=attacks=0:points=-80/-115|-35.1/-80|-35/-35|20/20
  1593. @end example
  1594. @item
  1595. Soft limiter:
  1596. @example
  1597. compand=attacks=0:points=-80/-80|-12.4/-12.4|-6/-8|0/-6.8|20/-2.8
  1598. @end example
  1599. @end itemize
  1600. @section compensationdelay
  1601. Compensation Delay Line is a metric based delay to compensate differing
  1602. positions of microphones or speakers.
  1603. For example, you have recorded guitar with two microphones placed in
  1604. different location. Because the front of sound wave has fixed speed in
  1605. normal conditions, the phasing of microphones can vary and depends on
  1606. their location and interposition. The best sound mix can be achieved when
  1607. these microphones are in phase (synchronized). Note that distance of
  1608. ~30 cm between microphones makes one microphone to capture signal in
  1609. antiphase to another microphone. That makes the final mix sounding moody.
  1610. This filter helps to solve phasing problems by adding different delays
  1611. to each microphone track and make them synchronized.
  1612. The best result can be reached when you take one track as base and
  1613. synchronize other tracks one by one with it.
  1614. Remember that synchronization/delay tolerance depends on sample rate, too.
  1615. Higher sample rates will give more tolerance.
  1616. It accepts the following parameters:
  1617. @table @option
  1618. @item mm
  1619. Set millimeters distance. This is compensation distance for fine tuning.
  1620. Default is 0.
  1621. @item cm
  1622. Set cm distance. This is compensation distance for tightening distance setup.
  1623. Default is 0.
  1624. @item m
  1625. Set meters distance. This is compensation distance for hard distance setup.
  1626. Default is 0.
  1627. @item dry
  1628. Set dry amount. Amount of unprocessed (dry) signal.
  1629. Default is 0.
  1630. @item wet
  1631. Set wet amount. Amount of processed (wet) signal.
  1632. Default is 1.
  1633. @item temp
  1634. Set temperature degree in Celsius. This is the temperature of the environment.
  1635. Default is 20.
  1636. @end table
  1637. @section dcshift
  1638. Apply a DC shift to the audio.
  1639. This can be useful to remove a DC offset (caused perhaps by a hardware problem
  1640. in the recording chain) from the audio. The effect of a DC offset is reduced
  1641. headroom and hence volume. The @ref{astats} filter can be used to determine if
  1642. a signal has a DC offset.
  1643. @table @option
  1644. @item shift
  1645. Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift
  1646. the audio.
  1647. @item limitergain
  1648. Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
  1649. used to prevent clipping.
  1650. @end table
  1651. @section dynaudnorm
  1652. Dynamic Audio Normalizer.
  1653. This filter applies a certain amount of gain to the input audio in order
  1654. to bring its peak magnitude to a target level (e.g. 0 dBFS). However, in
  1655. contrast to more "simple" normalization algorithms, the Dynamic Audio
  1656. Normalizer *dynamically* re-adjusts the gain factor to the input audio.
  1657. This allows for applying extra gain to the "quiet" sections of the audio
  1658. while avoiding distortions or clipping the "loud" sections. In other words:
  1659. The Dynamic Audio Normalizer will "even out" the volume of quiet and loud
  1660. sections, in the sense that the volume of each section is brought to the
  1661. same target level. Note, however, that the Dynamic Audio Normalizer achieves
  1662. this goal *without* applying "dynamic range compressing". It will retain 100%
  1663. of the dynamic range *within* each section of the audio file.
  1664. @table @option
  1665. @item f
  1666. Set the frame length in milliseconds. In range from 10 to 8000 milliseconds.
  1667. Default is 500 milliseconds.
  1668. The Dynamic Audio Normalizer processes the input audio in small chunks,
  1669. referred to as frames. This is required, because a peak magnitude has no
  1670. meaning for just a single sample value. Instead, we need to determine the
  1671. peak magnitude for a contiguous sequence of sample values. While a "standard"
  1672. normalizer would simply use the peak magnitude of the complete file, the
  1673. Dynamic Audio Normalizer determines the peak magnitude individually for each
  1674. frame. The length of a frame is specified in milliseconds. By default, the
  1675. Dynamic Audio Normalizer uses a frame length of 500 milliseconds, which has
  1676. been found to give good results with most files.
  1677. Note that the exact frame length, in number of samples, will be determined
  1678. automatically, based on the sampling rate of the individual input audio file.
  1679. @item g
  1680. Set the Gaussian filter window size. In range from 3 to 301, must be odd
  1681. number. Default is 31.
  1682. Probably the most important parameter of the Dynamic Audio Normalizer is the
  1683. @code{window size} of the Gaussian smoothing filter. The filter's window size
  1684. is specified in frames, centered around the current frame. For the sake of
  1685. simplicity, this must be an odd number. Consequently, the default value of 31
  1686. takes into account the current frame, as well as the 15 preceding frames and
  1687. the 15 subsequent frames. Using a larger window results in a stronger
  1688. smoothing effect and thus in less gain variation, i.e. slower gain
  1689. adaptation. Conversely, using a smaller window results in a weaker smoothing
  1690. effect and thus in more gain variation, i.e. faster gain adaptation.
  1691. In other words, the more you increase this value, the more the Dynamic Audio
  1692. Normalizer will behave like a "traditional" normalization filter. On the
  1693. contrary, the more you decrease this value, the more the Dynamic Audio
  1694. Normalizer will behave like a dynamic range compressor.
  1695. @item p
  1696. Set the target peak value. This specifies the highest permissible magnitude
  1697. level for the normalized audio input. This filter will try to approach the
  1698. target peak magnitude as closely as possible, but at the same time it also
  1699. makes sure that the normalized signal will never exceed the peak magnitude.
  1700. A frame's maximum local gain factor is imposed directly by the target peak
  1701. magnitude. The default value is 0.95 and thus leaves a headroom of 5%*.
  1702. It is not recommended to go above this value.
  1703. @item m
  1704. Set the maximum gain factor. In range from 1.0 to 100.0. Default is 10.0.
  1705. The Dynamic Audio Normalizer determines the maximum possible (local) gain
  1706. factor for each input frame, i.e. the maximum gain factor that does not
  1707. result in clipping or distortion. The maximum gain factor is determined by
  1708. the frame's highest magnitude sample. However, the Dynamic Audio Normalizer
  1709. additionally bounds the frame's maximum gain factor by a predetermined
  1710. (global) maximum gain factor. This is done in order to avoid excessive gain
  1711. factors in "silent" or almost silent frames. By default, the maximum gain
  1712. factor is 10.0, For most inputs the default value should be sufficient and
  1713. it usually is not recommended to increase this value. Though, for input
  1714. with an extremely low overall volume level, it may be necessary to allow even
  1715. higher gain factors. Note, however, that the Dynamic Audio Normalizer does
  1716. not simply apply a "hard" threshold (i.e. cut off values above the threshold).
  1717. Instead, a "sigmoid" threshold function will be applied. This way, the
  1718. gain factors will smoothly approach the threshold value, but never exceed that
  1719. value.
  1720. @item r
  1721. Set the target RMS. In range from 0.0 to 1.0. Default is 0.0 - disabled.
  1722. By default, the Dynamic Audio Normalizer performs "peak" normalization.
  1723. This means that the maximum local gain factor for each frame is defined
  1724. (only) by the frame's highest magnitude sample. This way, the samples can
  1725. be amplified as much as possible without exceeding the maximum signal
  1726. level, i.e. without clipping. Optionally, however, the Dynamic Audio
  1727. Normalizer can also take into account the frame's root mean square,
  1728. abbreviated RMS. In electrical engineering, the RMS is commonly used to
  1729. determine the power of a time-varying signal. It is therefore considered
  1730. that the RMS is a better approximation of the "perceived loudness" than
  1731. just looking at the signal's peak magnitude. Consequently, by adjusting all
  1732. frames to a constant RMS value, a uniform "perceived loudness" can be
  1733. established. If a target RMS value has been specified, a frame's local gain
  1734. factor is defined as the factor that would result in exactly that RMS value.
  1735. Note, however, that the maximum local gain factor is still restricted by the
  1736. frame's highest magnitude sample, in order to prevent clipping.
  1737. @item n
  1738. Enable channels coupling. By default is enabled.
  1739. By default, the Dynamic Audio Normalizer will amplify all channels by the same
  1740. amount. This means the same gain factor will be applied to all channels, i.e.
  1741. the maximum possible gain factor is determined by the "loudest" channel.
  1742. However, in some recordings, it may happen that the volume of the different
  1743. channels is uneven, e.g. one channel may be "quieter" than the other one(s).
  1744. In this case, this option can be used to disable the channel coupling. This way,
  1745. the gain factor will be determined independently for each channel, depending
  1746. only on the individual channel's highest magnitude sample. This allows for
  1747. harmonizing the volume of the different channels.
  1748. @item c
  1749. Enable DC bias correction. By default is disabled.
  1750. An audio signal (in the time domain) is a sequence of sample values.
  1751. In the Dynamic Audio Normalizer these sample values are represented in the
  1752. -1.0 to 1.0 range, regardless of the original input format. Normally, the
  1753. audio signal, or "waveform", should be centered around the zero point.
  1754. That means if we calculate the mean value of all samples in a file, or in a
  1755. single frame, then the result should be 0.0 or at least very close to that
  1756. value. If, however, there is a significant deviation of the mean value from
  1757. 0.0, in either positive or negative direction, this is referred to as a
  1758. DC bias or DC offset. Since a DC bias is clearly undesirable, the Dynamic
  1759. Audio Normalizer provides optional DC bias correction.
  1760. With DC bias correction enabled, the Dynamic Audio Normalizer will determine
  1761. the mean value, or "DC correction" offset, of each input frame and subtract
  1762. that value from all of the frame's sample values which ensures those samples
  1763. are centered around 0.0 again. Also, in order to avoid "gaps" at the frame
  1764. boundaries, the DC correction offset values will be interpolated smoothly
  1765. between neighbouring frames.
  1766. @item b
  1767. Enable alternative boundary mode. By default is disabled.
  1768. The Dynamic Audio Normalizer takes into account a certain neighbourhood
  1769. around each frame. This includes the preceding frames as well as the
  1770. subsequent frames. However, for the "boundary" frames, located at the very
  1771. beginning and at the very end of the audio file, not all neighbouring
  1772. frames are available. In particular, for the first few frames in the audio
  1773. file, the preceding frames are not known. And, similarly, for the last few
  1774. frames in the audio file, the subsequent frames are not known. Thus, the
  1775. question arises which gain factors should be assumed for the missing frames
  1776. in the "boundary" region. The Dynamic Audio Normalizer implements two modes
  1777. to deal with this situation. The default boundary mode assumes a gain factor
  1778. of exactly 1.0 for the missing frames, resulting in a smooth "fade in" and
  1779. "fade out" at the beginning and at the end of the input, respectively.
  1780. @item s
  1781. Set the compress factor. In range from 0.0 to 30.0. Default is 0.0.
  1782. By default, the Dynamic Audio Normalizer does not apply "traditional"
  1783. compression. This means that signal peaks will not be pruned and thus the
  1784. full dynamic range will be retained within each local neighbourhood. However,
  1785. in some cases it may be desirable to combine the Dynamic Audio Normalizer's
  1786. normalization algorithm with a more "traditional" compression.
  1787. For this purpose, the Dynamic Audio Normalizer provides an optional compression
  1788. (thresholding) function. If (and only if) the compression feature is enabled,
  1789. all input frames will be processed by a soft knee thresholding function prior
  1790. to the actual normalization process. Put simply, the thresholding function is
  1791. going to prune all samples whose magnitude exceeds a certain threshold value.
  1792. However, the Dynamic Audio Normalizer does not simply apply a fixed threshold
  1793. value. Instead, the threshold value will be adjusted for each individual
  1794. frame.
  1795. In general, smaller parameters result in stronger compression, and vice versa.
  1796. Values below 3.0 are not recommended, because audible distortion may appear.
  1797. @end table
  1798. @section earwax
  1799. Make audio easier to listen to on headphones.
  1800. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  1801. so that when listened to on headphones the stereo image is moved from
  1802. inside your head (standard for headphones) to outside and in front of
  1803. the listener (standard for speakers).
  1804. Ported from SoX.
  1805. @section equalizer
  1806. Apply a two-pole peaking equalisation (EQ) filter. With this
  1807. filter, the signal-level at and around a selected frequency can
  1808. be increased or decreased, whilst (unlike bandpass and bandreject
  1809. filters) that at all other frequencies is unchanged.
  1810. In order to produce complex equalisation curves, this filter can
  1811. be given several times, each with a different central frequency.
  1812. The filter accepts the following options:
  1813. @table @option
  1814. @item frequency, f
  1815. Set the filter's central frequency in Hz.
  1816. @item width_type
  1817. Set method to specify band-width of filter.
  1818. @table @option
  1819. @item h
  1820. Hz
  1821. @item q
  1822. Q-Factor
  1823. @item o
  1824. octave
  1825. @item s
  1826. slope
  1827. @end table
  1828. @item width, w
  1829. Specify the band-width of a filter in width_type units.
  1830. @item gain, g
  1831. Set the required gain or attenuation in dB.
  1832. Beware of clipping when using a positive gain.
  1833. @end table
  1834. @subsection Examples
  1835. @itemize
  1836. @item
  1837. Attenuate 10 dB at 1000 Hz, with a bandwidth of 200 Hz:
  1838. @example
  1839. equalizer=f=1000:width_type=h:width=200:g=-10
  1840. @end example
  1841. @item
  1842. Apply 2 dB gain at 1000 Hz with Q 1 and attenuate 5 dB at 100 Hz with Q 2:
  1843. @example
  1844. equalizer=f=1000:width_type=q:width=1:g=2,equalizer=f=100:width_type=q:width=2:g=-5
  1845. @end example
  1846. @end itemize
  1847. @section extrastereo
  1848. Linearly increases the difference between left and right channels which
  1849. adds some sort of "live" effect to playback.
  1850. The filter accepts the following option:
  1851. @table @option
  1852. @item m
  1853. Sets the difference coefficient (default: 2.5). 0.0 means mono sound
  1854. (average of both channels), with 1.0 sound will be unchanged, with
  1855. -1.0 left and right channels will be swapped.
  1856. @item c
  1857. Enable clipping. By default is enabled.
  1858. @end table
  1859. @section firequalizer
  1860. Apply FIR Equalization using arbitrary frequency response.
  1861. The filter accepts the following option:
  1862. @table @option
  1863. @item gain
  1864. Set gain curve equation (in dB). The expression can contain variables:
  1865. @table @option
  1866. @item f
  1867. the evaluated frequency
  1868. @item sr
  1869. sample rate
  1870. @item ch
  1871. channel number, set to 0 when multichannels evaluation is disabled
  1872. @item chid
  1873. channel id, see libavutil/channel_layout.h, set to the first channel id when
  1874. multichannels evaluation is disabled
  1875. @item chs
  1876. number of channels
  1877. @item chlayout
  1878. channel_layout, see libavutil/channel_layout.h
  1879. @end table
  1880. and functions:
  1881. @table @option
  1882. @item gain_interpolate(f)
  1883. interpolate gain on frequency f based on gain_entry
  1884. @end table
  1885. This option is also available as command. Default is @code{gain_interpolate(f)}.
  1886. @item gain_entry
  1887. Set gain entry for gain_interpolate function. The expression can
  1888. contain functions:
  1889. @table @option
  1890. @item entry(f, g)
  1891. store gain entry at frequency f with value g
  1892. @end table
  1893. This option is also available as command.
  1894. @item delay
  1895. Set filter delay in seconds. Higher value means more accurate.
  1896. Default is @code{0.01}.
  1897. @item accuracy
  1898. Set filter accuracy in Hz. Lower value means more accurate.
  1899. Default is @code{5}.
  1900. @item wfunc
  1901. Set window function. Acceptable values are:
  1902. @table @option
  1903. @item rectangular
  1904. rectangular window, useful when gain curve is already smooth
  1905. @item hann
  1906. hann window (default)
  1907. @item hamming
  1908. hamming window
  1909. @item blackman
  1910. blackman window
  1911. @item nuttall3
  1912. 3-terms continuous 1st derivative nuttall window
  1913. @item mnuttall3
  1914. minimum 3-terms discontinuous nuttall window
  1915. @item nuttall
  1916. 4-terms continuous 1st derivative nuttall window
  1917. @item bnuttall
  1918. minimum 4-terms discontinuous nuttall (blackman-nuttall) window
  1919. @item bharris
  1920. blackman-harris window
  1921. @end table
  1922. @item fixed
  1923. If enabled, use fixed number of audio samples. This improves speed when
  1924. filtering with large delay. Default is disabled.
  1925. @item multi
  1926. Enable multichannels evaluation on gain. Default is disabled.
  1927. @end table
  1928. @subsection Examples
  1929. @itemize
  1930. @item
  1931. lowpass at 1000 Hz:
  1932. @example
  1933. firequalizer=gain='if(lt(f,1000), 0, -INF)'
  1934. @end example
  1935. @item
  1936. lowpass at 1000 Hz with gain_entry:
  1937. @example
  1938. firequalizer=gain_entry='entry(1000,0); entry(1001, -INF)'
  1939. @end example
  1940. @item
  1941. custom equalization:
  1942. @example
  1943. firequalizer=gain_entry='entry(100,0); entry(400, -4); entry(1000, -6); entry(2000, 0)'
  1944. @end example
  1945. @item
  1946. higher delay:
  1947. @example
  1948. firequalizer=delay=0.1:fixed=on
  1949. @end example
  1950. @item
  1951. lowpass on left channel, highpass on right channel:
  1952. @example
  1953. firequalizer=gain='if(eq(chid,1), gain_interpolate(f), if(eq(chid,2), gain_interpolate(1e6+f), 0))'
  1954. :gain_entry='entry(1000, 0); entry(1001,-INF); entry(1e6+1000,0)':multi=on
  1955. @end example
  1956. @end itemize
  1957. @section flanger
  1958. Apply a flanging effect to the audio.
  1959. The filter accepts the following options:
  1960. @table @option
  1961. @item delay
  1962. Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
  1963. @item depth
  1964. Set added swep delay in milliseconds. Range from 0 to 10. Default value is 2.
  1965. @item regen
  1966. Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
  1967. Default value is 0.
  1968. @item width
  1969. Set percentage of delayed signal mixed with original. Range from 0 to 100.
  1970. Default value is 71.
  1971. @item speed
  1972. Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
  1973. @item shape
  1974. Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
  1975. Default value is @var{sinusoidal}.
  1976. @item phase
  1977. Set swept wave percentage-shift for multi channel. Range from 0 to 100.
  1978. Default value is 25.
  1979. @item interp
  1980. Set delay-line interpolation, @var{linear} or @var{quadratic}.
  1981. Default is @var{linear}.
  1982. @end table
  1983. @section highpass
  1984. Apply a high-pass filter with 3dB point frequency.
  1985. The filter can be either single-pole, or double-pole (the default).
  1986. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1987. The filter accepts the following options:
  1988. @table @option
  1989. @item frequency, f
  1990. Set frequency in Hz. Default is 3000.
  1991. @item poles, p
  1992. Set number of poles. Default is 2.
  1993. @item width_type
  1994. Set method to specify band-width of filter.
  1995. @table @option
  1996. @item h
  1997. Hz
  1998. @item q
  1999. Q-Factor
  2000. @item o
  2001. octave
  2002. @item s
  2003. slope
  2004. @end table
  2005. @item width, w
  2006. Specify the band-width of a filter in width_type units.
  2007. Applies only to double-pole filter.
  2008. The default is 0.707q and gives a Butterworth response.
  2009. @end table
  2010. @section join
  2011. Join multiple input streams into one multi-channel stream.
  2012. It accepts the following parameters:
  2013. @table @option
  2014. @item inputs
  2015. The number of input streams. It defaults to 2.
  2016. @item channel_layout
  2017. The desired output channel layout. It defaults to stereo.
  2018. @item map
  2019. Map channels from inputs to output. The argument is a '|'-separated list of
  2020. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  2021. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  2022. can be either the name of the input channel (e.g. FL for front left) or its
  2023. index in the specified input stream. @var{out_channel} is the name of the output
  2024. channel.
  2025. @end table
  2026. The filter will attempt to guess the mappings when they are not specified
  2027. explicitly. It does so by first trying to find an unused matching input channel
  2028. and if that fails it picks the first unused input channel.
  2029. Join 3 inputs (with properly set channel layouts):
  2030. @example
  2031. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  2032. @end example
  2033. Build a 5.1 output from 6 single-channel streams:
  2034. @example
  2035. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  2036. 'join=inputs=6:channel_layout=5.1:map=0.0-FL|1.0-FR|2.0-FC|3.0-SL|4.0-SR|5.0-LFE'
  2037. out
  2038. @end example
  2039. @section ladspa
  2040. Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
  2041. To enable compilation of this filter you need to configure FFmpeg with
  2042. @code{--enable-ladspa}.
  2043. @table @option
  2044. @item file, f
  2045. Specifies the name of LADSPA plugin library to load. If the environment
  2046. variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
  2047. each one of the directories specified by the colon separated list in
  2048. @env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
  2049. this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
  2050. @file{/usr/lib/ladspa/}.
  2051. @item plugin, p
  2052. Specifies the plugin within the library. Some libraries contain only
  2053. one plugin, but others contain many of them. If this is not set filter
  2054. will list all available plugins within the specified library.
  2055. @item controls, c
  2056. Set the '|' separated list of controls which are zero or more floating point
  2057. values that determine the behavior of the loaded plugin (for example delay,
  2058. threshold or gain).
  2059. Controls need to be defined using the following syntax:
  2060. c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
  2061. @var{valuei} is the value set on the @var{i}-th control.
  2062. Alternatively they can be also defined using the following syntax:
  2063. @var{value0}|@var{value1}|@var{value2}|..., where
  2064. @var{valuei} is the value set on the @var{i}-th control.
  2065. If @option{controls} is set to @code{help}, all available controls and
  2066. their valid ranges are printed.
  2067. @item sample_rate, s
  2068. Specify the sample rate, default to 44100. Only used if plugin have
  2069. zero inputs.
  2070. @item nb_samples, n
  2071. Set the number of samples per channel per each output frame, default
  2072. is 1024. Only used if plugin have zero inputs.
  2073. @item duration, d
  2074. Set the minimum duration of the sourced audio. See
  2075. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  2076. for the accepted syntax.
  2077. Note that the resulting duration may be greater than the specified duration,
  2078. as the generated audio is always cut at the end of a complete frame.
  2079. If not specified, or the expressed duration is negative, the audio is
  2080. supposed to be generated forever.
  2081. Only used if plugin have zero inputs.
  2082. @end table
  2083. @subsection Examples
  2084. @itemize
  2085. @item
  2086. List all available plugins within amp (LADSPA example plugin) library:
  2087. @example
  2088. ladspa=file=amp
  2089. @end example
  2090. @item
  2091. List all available controls and their valid ranges for @code{vcf_notch}
  2092. plugin from @code{VCF} library:
  2093. @example
  2094. ladspa=f=vcf:p=vcf_notch:c=help
  2095. @end example
  2096. @item
  2097. Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
  2098. plugin library:
  2099. @example
  2100. ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
  2101. @end example
  2102. @item
  2103. Add reverberation to the audio using TAP-plugins
  2104. (Tom's Audio Processing plugins):
  2105. @example
  2106. ladspa=file=tap_reverb:tap_reverb
  2107. @end example
  2108. @item
  2109. Generate white noise, with 0.2 amplitude:
  2110. @example
  2111. ladspa=file=cmt:noise_source_white:c=c0=.2
  2112. @end example
  2113. @item
  2114. Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
  2115. @code{C* Audio Plugin Suite} (CAPS) library:
  2116. @example
  2117. ladspa=file=caps:Click:c=c1=20'
  2118. @end example
  2119. @item
  2120. Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
  2121. @example
  2122. ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
  2123. @end example
  2124. @item
  2125. Increase volume by 20dB using fast lookahead limiter from Steve Harris
  2126. @code{SWH Plugins} collection:
  2127. @example
  2128. ladspa=fast_lookahead_limiter_1913:fastLookaheadLimiter:20|0|2
  2129. @end example
  2130. @item
  2131. Attenuate low frequencies using Multiband EQ from Steve Harris
  2132. @code{SWH Plugins} collection:
  2133. @example
  2134. ladspa=mbeq_1197:mbeq:-24|-24|-24|0|0|0|0|0|0|0|0|0|0|0|0
  2135. @end example
  2136. @end itemize
  2137. @subsection Commands
  2138. This filter supports the following commands:
  2139. @table @option
  2140. @item cN
  2141. Modify the @var{N}-th control value.
  2142. If the specified value is not valid, it is ignored and prior one is kept.
  2143. @end table
  2144. @section lowpass
  2145. Apply a low-pass filter with 3dB point frequency.
  2146. The filter can be either single-pole or double-pole (the default).
  2147. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  2148. The filter accepts the following options:
  2149. @table @option
  2150. @item frequency, f
  2151. Set frequency in Hz. Default is 500.
  2152. @item poles, p
  2153. Set number of poles. Default is 2.
  2154. @item width_type
  2155. Set method to specify band-width of filter.
  2156. @table @option
  2157. @item h
  2158. Hz
  2159. @item q
  2160. Q-Factor
  2161. @item o
  2162. octave
  2163. @item s
  2164. slope
  2165. @end table
  2166. @item width, w
  2167. Specify the band-width of a filter in width_type units.
  2168. Applies only to double-pole filter.
  2169. The default is 0.707q and gives a Butterworth response.
  2170. @end table
  2171. @anchor{pan}
  2172. @section pan
  2173. Mix channels with specific gain levels. The filter accepts the output
  2174. channel layout followed by a set of channels definitions.
  2175. This filter is also designed to efficiently remap the channels of an audio
  2176. stream.
  2177. The filter accepts parameters of the form:
  2178. "@var{l}|@var{outdef}|@var{outdef}|..."
  2179. @table @option
  2180. @item l
  2181. output channel layout or number of channels
  2182. @item outdef
  2183. output channel specification, of the form:
  2184. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  2185. @item out_name
  2186. output channel to define, either a channel name (FL, FR, etc.) or a channel
  2187. number (c0, c1, etc.)
  2188. @item gain
  2189. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  2190. @item in_name
  2191. input channel to use, see out_name for details; it is not possible to mix
  2192. named and numbered input channels
  2193. @end table
  2194. If the `=' in a channel specification is replaced by `<', then the gains for
  2195. that specification will be renormalized so that the total is 1, thus
  2196. avoiding clipping noise.
  2197. @subsection Mixing examples
  2198. For example, if you want to down-mix from stereo to mono, but with a bigger
  2199. factor for the left channel:
  2200. @example
  2201. pan=1c|c0=0.9*c0+0.1*c1
  2202. @end example
  2203. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  2204. 7-channels surround:
  2205. @example
  2206. pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  2207. @end example
  2208. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  2209. that should be preferred (see "-ac" option) unless you have very specific
  2210. needs.
  2211. @subsection Remapping examples
  2212. The channel remapping will be effective if, and only if:
  2213. @itemize
  2214. @item gain coefficients are zeroes or ones,
  2215. @item only one input per channel output,
  2216. @end itemize
  2217. If all these conditions are satisfied, the filter will notify the user ("Pure
  2218. channel mapping detected"), and use an optimized and lossless method to do the
  2219. remapping.
  2220. For example, if you have a 5.1 source and want a stereo audio stream by
  2221. dropping the extra channels:
  2222. @example
  2223. pan="stereo| c0=FL | c1=FR"
  2224. @end example
  2225. Given the same source, you can also switch front left and front right channels
  2226. and keep the input channel layout:
  2227. @example
  2228. pan="5.1| c0=c1 | c1=c0 | c2=c2 | c3=c3 | c4=c4 | c5=c5"
  2229. @end example
  2230. If the input is a stereo audio stream, you can mute the front left channel (and
  2231. still keep the stereo channel layout) with:
  2232. @example
  2233. pan="stereo|c1=c1"
  2234. @end example
  2235. Still with a stereo audio stream input, you can copy the right channel in both
  2236. front left and right:
  2237. @example
  2238. pan="stereo| c0=FR | c1=FR"
  2239. @end example
  2240. @section replaygain
  2241. ReplayGain scanner filter. This filter takes an audio stream as an input and
  2242. outputs it unchanged.
  2243. At end of filtering it displays @code{track_gain} and @code{track_peak}.
  2244. @section resample
  2245. Convert the audio sample format, sample rate and channel layout. It is
  2246. not meant to be used directly.
  2247. @section rubberband
  2248. Apply time-stretching and pitch-shifting with librubberband.
  2249. The filter accepts the following options:
  2250. @table @option
  2251. @item tempo
  2252. Set tempo scale factor.
  2253. @item pitch
  2254. Set pitch scale factor.
  2255. @item transients
  2256. Set transients detector.
  2257. Possible values are:
  2258. @table @var
  2259. @item crisp
  2260. @item mixed
  2261. @item smooth
  2262. @end table
  2263. @item detector
  2264. Set detector.
  2265. Possible values are:
  2266. @table @var
  2267. @item compound
  2268. @item percussive
  2269. @item soft
  2270. @end table
  2271. @item phase
  2272. Set phase.
  2273. Possible values are:
  2274. @table @var
  2275. @item laminar
  2276. @item independent
  2277. @end table
  2278. @item window
  2279. Set processing window size.
  2280. Possible values are:
  2281. @table @var
  2282. @item standard
  2283. @item short
  2284. @item long
  2285. @end table
  2286. @item smoothing
  2287. Set smoothing.
  2288. Possible values are:
  2289. @table @var
  2290. @item off
  2291. @item on
  2292. @end table
  2293. @item formant
  2294. Enable formant preservation when shift pitching.
  2295. Possible values are:
  2296. @table @var
  2297. @item shifted
  2298. @item preserved
  2299. @end table
  2300. @item pitchq
  2301. Set pitch quality.
  2302. Possible values are:
  2303. @table @var
  2304. @item quality
  2305. @item speed
  2306. @item consistency
  2307. @end table
  2308. @item channels
  2309. Set channels.
  2310. Possible values are:
  2311. @table @var
  2312. @item apart
  2313. @item together
  2314. @end table
  2315. @end table
  2316. @section sidechaincompress
  2317. This filter acts like normal compressor but has the ability to compress
  2318. detected signal using second input signal.
  2319. It needs two input streams and returns one output stream.
  2320. First input stream will be processed depending on second stream signal.
  2321. The filtered signal then can be filtered with other filters in later stages of
  2322. processing. See @ref{pan} and @ref{amerge} filter.
  2323. The filter accepts the following options:
  2324. @table @option
  2325. @item level_in
  2326. Set input gain. Default is 1. Range is between 0.015625 and 64.
  2327. @item threshold
  2328. If a signal of second stream raises above this level it will affect the gain
  2329. reduction of first stream.
  2330. By default is 0.125. Range is between 0.00097563 and 1.
  2331. @item ratio
  2332. Set a ratio about which the signal is reduced. 1:2 means that if the level
  2333. raised 4dB above the threshold, it will be only 2dB above after the reduction.
  2334. Default is 2. Range is between 1 and 20.
  2335. @item attack
  2336. Amount of milliseconds the signal has to rise above the threshold before gain
  2337. reduction starts. Default is 20. Range is between 0.01 and 2000.
  2338. @item release
  2339. Amount of milliseconds the signal has to fall below the threshold before
  2340. reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
  2341. @item makeup
  2342. Set the amount by how much signal will be amplified after processing.
  2343. Default is 2. Range is from 1 and 64.
  2344. @item knee
  2345. Curve the sharp knee around the threshold to enter gain reduction more softly.
  2346. Default is 2.82843. Range is between 1 and 8.
  2347. @item link
  2348. Choose if the @code{average} level between all channels of side-chain stream
  2349. or the louder(@code{maximum}) channel of side-chain stream affects the
  2350. reduction. Default is @code{average}.
  2351. @item detection
  2352. Should the exact signal be taken in case of @code{peak} or an RMS one in case
  2353. of @code{rms}. Default is @code{rms} which is mainly smoother.
  2354. @item level_sc
  2355. Set sidechain gain. Default is 1. Range is between 0.015625 and 64.
  2356. @item mix
  2357. How much to use compressed signal in output. Default is 1.
  2358. Range is between 0 and 1.
  2359. @end table
  2360. @subsection Examples
  2361. @itemize
  2362. @item
  2363. Full ffmpeg example taking 2 audio inputs, 1st input to be compressed
  2364. depending on the signal of 2nd input and later compressed signal to be
  2365. merged with 2nd input:
  2366. @example
  2367. ffmpeg -i main.flac -i sidechain.flac -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge"
  2368. @end example
  2369. @end itemize
  2370. @section sidechaingate
  2371. A sidechain gate acts like a normal (wideband) gate but has the ability to
  2372. filter the detected signal before sending it to the gain reduction stage.
  2373. Normally a gate uses the full range signal to detect a level above the
  2374. threshold.
  2375. For example: If you cut all lower frequencies from your sidechain signal
  2376. the gate will decrease the volume of your track only if not enough highs
  2377. appear. With this technique you are able to reduce the resonation of a
  2378. natural drum or remove "rumbling" of muted strokes from a heavily distorted
  2379. guitar.
  2380. It needs two input streams and returns one output stream.
  2381. First input stream will be processed depending on second stream signal.
  2382. The filter accepts the following options:
  2383. @table @option
  2384. @item level_in
  2385. Set input level before filtering.
  2386. Default is 1. Allowed range is from 0.015625 to 64.
  2387. @item range
  2388. Set the level of gain reduction when the signal is below the threshold.
  2389. Default is 0.06125. Allowed range is from 0 to 1.
  2390. @item threshold
  2391. If a signal rises above this level the gain reduction is released.
  2392. Default is 0.125. Allowed range is from 0 to 1.
  2393. @item ratio
  2394. Set a ratio about which the signal is reduced.
  2395. Default is 2. Allowed range is from 1 to 9000.
  2396. @item attack
  2397. Amount of milliseconds the signal has to rise above the threshold before gain
  2398. reduction stops.
  2399. Default is 20 milliseconds. Allowed range is from 0.01 to 9000.
  2400. @item release
  2401. Amount of milliseconds the signal has to fall below the threshold before the
  2402. reduction is increased again. Default is 250 milliseconds.
  2403. Allowed range is from 0.01 to 9000.
  2404. @item makeup
  2405. Set amount of amplification of signal after processing.
  2406. Default is 1. Allowed range is from 1 to 64.
  2407. @item knee
  2408. Curve the sharp knee around the threshold to enter gain reduction more softly.
  2409. Default is 2.828427125. Allowed range is from 1 to 8.
  2410. @item detection
  2411. Choose if exact signal should be taken for detection or an RMS like one.
  2412. Default is rms. Can be peak or rms.
  2413. @item link
  2414. Choose if the average level between all channels or the louder channel affects
  2415. the reduction.
  2416. Default is average. Can be average or maximum.
  2417. @item level_sc
  2418. Set sidechain gain. Default is 1. Range is from 0.015625 to 64.
  2419. @end table
  2420. @section silencedetect
  2421. Detect silence in an audio stream.
  2422. This filter logs a message when it detects that the input audio volume is less
  2423. or equal to a noise tolerance value for a duration greater or equal to the
  2424. minimum detected noise duration.
  2425. The printed times and duration are expressed in seconds.
  2426. The filter accepts the following options:
  2427. @table @option
  2428. @item duration, d
  2429. Set silence duration until notification (default is 2 seconds).
  2430. @item noise, n
  2431. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  2432. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  2433. @end table
  2434. @subsection Examples
  2435. @itemize
  2436. @item
  2437. Detect 5 seconds of silence with -50dB noise tolerance:
  2438. @example
  2439. silencedetect=n=-50dB:d=5
  2440. @end example
  2441. @item
  2442. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  2443. tolerance in @file{silence.mp3}:
  2444. @example
  2445. ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
  2446. @end example
  2447. @end itemize
  2448. @section silenceremove
  2449. Remove silence from the beginning, middle or end of the audio.
  2450. The filter accepts the following options:
  2451. @table @option
  2452. @item start_periods
  2453. This value is used to indicate if audio should be trimmed at beginning of
  2454. the audio. A value of zero indicates no silence should be trimmed from the
  2455. beginning. When specifying a non-zero value, it trims audio up until it
  2456. finds non-silence. Normally, when trimming silence from beginning of audio
  2457. the @var{start_periods} will be @code{1} but it can be increased to higher
  2458. values to trim all audio up to specific count of non-silence periods.
  2459. Default value is @code{0}.
  2460. @item start_duration
  2461. Specify the amount of time that non-silence must be detected before it stops
  2462. trimming audio. By increasing the duration, bursts of noises can be treated
  2463. as silence and trimmed off. Default value is @code{0}.
  2464. @item start_threshold
  2465. This indicates what sample value should be treated as silence. For digital
  2466. audio, a value of @code{0} may be fine but for audio recorded from analog,
  2467. you may wish to increase the value to account for background noise.
  2468. Can be specified in dB (in case "dB" is appended to the specified value)
  2469. or amplitude ratio. Default value is @code{0}.
  2470. @item stop_periods
  2471. Set the count for trimming silence from the end of audio.
  2472. To remove silence from the middle of a file, specify a @var{stop_periods}
  2473. that is negative. This value is then treated as a positive value and is
  2474. used to indicate the effect should restart processing as specified by
  2475. @var{start_periods}, making it suitable for removing periods of silence
  2476. in the middle of the audio.
  2477. Default value is @code{0}.
  2478. @item stop_duration
  2479. Specify a duration of silence that must exist before audio is not copied any
  2480. more. By specifying a higher duration, silence that is wanted can be left in
  2481. the audio.
  2482. Default value is @code{0}.
  2483. @item stop_threshold
  2484. This is the same as @option{start_threshold} but for trimming silence from
  2485. the end of audio.
  2486. Can be specified in dB (in case "dB" is appended to the specified value)
  2487. or amplitude ratio. Default value is @code{0}.
  2488. @item leave_silence
  2489. This indicate that @var{stop_duration} length of audio should be left intact
  2490. at the beginning of each period of silence.
  2491. For example, if you want to remove long pauses between words but do not want
  2492. to remove the pauses completely. Default value is @code{0}.
  2493. @item detection
  2494. Set how is silence detected. Can be @code{rms} or @code{peak}. Second is faster
  2495. and works better with digital silence which is exactly 0.
  2496. Default value is @code{rms}.
  2497. @item window
  2498. Set ratio used to calculate size of window for detecting silence.
  2499. Default value is @code{0.02}. Allowed range is from @code{0} to @code{10}.
  2500. @end table
  2501. @subsection Examples
  2502. @itemize
  2503. @item
  2504. The following example shows how this filter can be used to start a recording
  2505. that does not contain the delay at the start which usually occurs between
  2506. pressing the record button and the start of the performance:
  2507. @example
  2508. silenceremove=1:5:0.02
  2509. @end example
  2510. @item
  2511. Trim all silence encountered from begining to end where there is more than 1
  2512. second of silence in audio:
  2513. @example
  2514. silenceremove=0:0:0:-1:1:-90dB
  2515. @end example
  2516. @end itemize
  2517. @section sofalizer
  2518. SOFAlizer uses head-related transfer functions (HRTFs) to create virtual
  2519. loudspeakers around the user for binaural listening via headphones (audio
  2520. formats up to 9 channels supported).
  2521. The HRTFs are stored in SOFA files (see @url{http://www.sofacoustics.org/} for a database).
  2522. SOFAlizer is developed at the Acoustics Research Institute (ARI) of the
  2523. Austrian Academy of Sciences.
  2524. To enable compilation of this filter you need to configure FFmpeg with
  2525. @code{--enable-netcdf}.
  2526. The filter accepts the following options:
  2527. @table @option
  2528. @item sofa
  2529. Set the SOFA file used for rendering.
  2530. @item gain
  2531. Set gain applied to audio. Value is in dB. Default is 0.
  2532. @item rotation
  2533. Set rotation of virtual loudspeakers in deg. Default is 0.
  2534. @item elevation
  2535. Set elevation of virtual speakers in deg. Default is 0.
  2536. @item radius
  2537. Set distance in meters between loudspeakers and the listener with near-field
  2538. HRTFs. Default is 1.
  2539. @item type
  2540. Set processing type. Can be @var{time} or @var{freq}. @var{time} is
  2541. processing audio in time domain which is slow.
  2542. @var{freq} is processing audio in frequency domain which is fast.
  2543. Default is @var{freq}.
  2544. @item speakers
  2545. Set custom positions of virtual loudspeakers. Syntax for this option is:
  2546. <CH> <AZIM> <ELEV>[|<CH> <AZIM> <ELEV>|...].
  2547. Each virtual loudspeaker is described with short channel name following with
  2548. azimuth and elevation in degreees.
  2549. Each virtual loudspeaker description is separated by '|'.
  2550. For example to override front left and front right channel positions use:
  2551. 'speakers=FL 45 15|FR 345 15'.
  2552. Descriptions with unrecognised channel names are ignored.
  2553. @end table
  2554. @subsection Examples
  2555. @itemize
  2556. @item
  2557. Using ClubFritz6 sofa file:
  2558. @example
  2559. sofalizer=sofa=/path/to/ClubFritz6.sofa:type=freq:radius=1
  2560. @end example
  2561. @item
  2562. Using ClubFritz12 sofa file and bigger radius with small rotation:
  2563. @example
  2564. sofalizer=sofa=/path/to/ClubFritz12.sofa:type=freq:radius=2:rotation=5
  2565. @end example
  2566. @item
  2567. Similar as above but with custom speaker positions for front left, front right, rear left and rear right
  2568. and also with custom gain:
  2569. @example
  2570. "sofalizer=sofa=/path/to/ClubFritz6.sofa:type=freq:radius=2:speakers=FL 45|FR 315|RL 135|RR 225:gain=28"
  2571. @end example
  2572. @end itemize
  2573. @section stereotools
  2574. This filter has some handy utilities to manage stereo signals, for converting
  2575. M/S stereo recordings to L/R signal while having control over the parameters
  2576. or spreading the stereo image of master track.
  2577. The filter accepts the following options:
  2578. @table @option
  2579. @item level_in
  2580. Set input level before filtering for both channels. Defaults is 1.
  2581. Allowed range is from 0.015625 to 64.
  2582. @item level_out
  2583. Set output level after filtering for both channels. Defaults is 1.
  2584. Allowed range is from 0.015625 to 64.
  2585. @item balance_in
  2586. Set input balance between both channels. Default is 0.
  2587. Allowed range is from -1 to 1.
  2588. @item balance_out
  2589. Set output balance between both channels. Default is 0.
  2590. Allowed range is from -1 to 1.
  2591. @item softclip
  2592. Enable softclipping. Results in analog distortion instead of harsh digital 0dB
  2593. clipping. Disabled by default.
  2594. @item mutel
  2595. Mute the left channel. Disabled by default.
  2596. @item muter
  2597. Mute the right channel. Disabled by default.
  2598. @item phasel
  2599. Change the phase of the left channel. Disabled by default.
  2600. @item phaser
  2601. Change the phase of the right channel. Disabled by default.
  2602. @item mode
  2603. Set stereo mode. Available values are:
  2604. @table @samp
  2605. @item lr>lr
  2606. Left/Right to Left/Right, this is default.
  2607. @item lr>ms
  2608. Left/Right to Mid/Side.
  2609. @item ms>lr
  2610. Mid/Side to Left/Right.
  2611. @item lr>ll
  2612. Left/Right to Left/Left.
  2613. @item lr>rr
  2614. Left/Right to Right/Right.
  2615. @item lr>l+r
  2616. Left/Right to Left + Right.
  2617. @item lr>rl
  2618. Left/Right to Right/Left.
  2619. @end table
  2620. @item slev
  2621. Set level of side signal. Default is 1.
  2622. Allowed range is from 0.015625 to 64.
  2623. @item sbal
  2624. Set balance of side signal. Default is 0.
  2625. Allowed range is from -1 to 1.
  2626. @item mlev
  2627. Set level of the middle signal. Default is 1.
  2628. Allowed range is from 0.015625 to 64.
  2629. @item mpan
  2630. Set middle signal pan. Default is 0. Allowed range is from -1 to 1.
  2631. @item base
  2632. Set stereo base between mono and inversed channels. Default is 0.
  2633. Allowed range is from -1 to 1.
  2634. @item delay
  2635. Set delay in milliseconds how much to delay left from right channel and
  2636. vice versa. Default is 0. Allowed range is from -20 to 20.
  2637. @item sclevel
  2638. Set S/C level. Default is 1. Allowed range is from 1 to 100.
  2639. @item phase
  2640. Set the stereo phase in degrees. Default is 0. Allowed range is from 0 to 360.
  2641. @end table
  2642. @subsection Examples
  2643. @itemize
  2644. @item
  2645. Apply karaoke like effect:
  2646. @example
  2647. stereotools=mlev=0.015625
  2648. @end example
  2649. @item
  2650. Convert M/S signal to L/R:
  2651. @example
  2652. "stereotools=mode=ms>lr"
  2653. @end example
  2654. @end itemize
  2655. @section stereowiden
  2656. This filter enhance the stereo effect by suppressing signal common to both
  2657. channels and by delaying the signal of left into right and vice versa,
  2658. thereby widening the stereo effect.
  2659. The filter accepts the following options:
  2660. @table @option
  2661. @item delay
  2662. Time in milliseconds of the delay of left signal into right and vice versa.
  2663. Default is 20 milliseconds.
  2664. @item feedback
  2665. Amount of gain in delayed signal into right and vice versa. Gives a delay
  2666. effect of left signal in right output and vice versa which gives widening
  2667. effect. Default is 0.3.
  2668. @item crossfeed
  2669. Cross feed of left into right with inverted phase. This helps in suppressing
  2670. the mono. If the value is 1 it will cancel all the signal common to both
  2671. channels. Default is 0.3.
  2672. @item drymix
  2673. Set level of input signal of original channel. Default is 0.8.
  2674. @end table
  2675. @section scale_npp
  2676. Use the NVIDIA Performance Primitives (libnpp) to perform scaling and/or pixel
  2677. format conversion on CUDA video frames. Setting the output width and height
  2678. works in the same way as for the @var{scale} filter.
  2679. The following additional options are accepted:
  2680. @table @option
  2681. @item format
  2682. The pixel format of the output CUDA frames. If set to the string "same" (the
  2683. default), the input format will be kept. Note that automatic format negotiation
  2684. and conversion is not yet supported for hardware frames
  2685. @item interp_algo
  2686. The interpolation algorithm used for resizing. One of the following:
  2687. @table @option
  2688. @item nn
  2689. Nearest neighbour.
  2690. @item linear
  2691. @item cubic
  2692. @item cubic2p_bspline
  2693. 2-parameter cubic (B=1, C=0)
  2694. @item cubic2p_catmullrom
  2695. 2-parameter cubic (B=0, C=1/2)
  2696. @item cubic2p_b05c03
  2697. 2-parameter cubic (B=1/2, C=3/10)
  2698. @item super
  2699. Supersampling
  2700. @item lanczos
  2701. @end table
  2702. @end table
  2703. @section select
  2704. Select frames to pass in output.
  2705. @section treble
  2706. Boost or cut treble (upper) frequencies of the audio using a two-pole
  2707. shelving filter with a response similar to that of a standard
  2708. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  2709. The filter accepts the following options:
  2710. @table @option
  2711. @item gain, g
  2712. Give the gain at whichever is the lower of ~22 kHz and the
  2713. Nyquist frequency. Its useful range is about -20 (for a large cut)
  2714. to +20 (for a large boost). Beware of clipping when using a positive gain.
  2715. @item frequency, f
  2716. Set the filter's central frequency and so can be used
  2717. to extend or reduce the frequency range to be boosted or cut.
  2718. The default value is @code{3000} Hz.
  2719. @item width_type
  2720. Set method to specify band-width of filter.
  2721. @table @option
  2722. @item h
  2723. Hz
  2724. @item q
  2725. Q-Factor
  2726. @item o
  2727. octave
  2728. @item s
  2729. slope
  2730. @end table
  2731. @item width, w
  2732. Determine how steep is the filter's shelf transition.
  2733. @end table
  2734. @section tremolo
  2735. Sinusoidal amplitude modulation.
  2736. The filter accepts the following options:
  2737. @table @option
  2738. @item f
  2739. Modulation frequency in Hertz. Modulation frequencies in the subharmonic range
  2740. (20 Hz or lower) will result in a tremolo effect.
  2741. This filter may also be used as a ring modulator by specifying
  2742. a modulation frequency higher than 20 Hz.
  2743. Range is 0.1 - 20000.0. Default value is 5.0 Hz.
  2744. @item d
  2745. Depth of modulation as a percentage. Range is 0.0 - 1.0.
  2746. Default value is 0.5.
  2747. @end table
  2748. @section vibrato
  2749. Sinusoidal phase modulation.
  2750. The filter accepts the following options:
  2751. @table @option
  2752. @item f
  2753. Modulation frequency in Hertz.
  2754. Range is 0.1 - 20000.0. Default value is 5.0 Hz.
  2755. @item d
  2756. Depth of modulation as a percentage. Range is 0.0 - 1.0.
  2757. Default value is 0.5.
  2758. @end table
  2759. @section volume
  2760. Adjust the input audio volume.
  2761. It accepts the following parameters:
  2762. @table @option
  2763. @item volume
  2764. Set audio volume expression.
  2765. Output values are clipped to the maximum value.
  2766. The output audio volume is given by the relation:
  2767. @example
  2768. @var{output_volume} = @var{volume} * @var{input_volume}
  2769. @end example
  2770. The default value for @var{volume} is "1.0".
  2771. @item precision
  2772. This parameter represents the mathematical precision.
  2773. It determines which input sample formats will be allowed, which affects the
  2774. precision of the volume scaling.
  2775. @table @option
  2776. @item fixed
  2777. 8-bit fixed-point; this limits input sample format to U8, S16, and S32.
  2778. @item float
  2779. 32-bit floating-point; this limits input sample format to FLT. (default)
  2780. @item double
  2781. 64-bit floating-point; this limits input sample format to DBL.
  2782. @end table
  2783. @item replaygain
  2784. Choose the behaviour on encountering ReplayGain side data in input frames.
  2785. @table @option
  2786. @item drop
  2787. Remove ReplayGain side data, ignoring its contents (the default).
  2788. @item ignore
  2789. Ignore ReplayGain side data, but leave it in the frame.
  2790. @item track
  2791. Prefer the track gain, if present.
  2792. @item album
  2793. Prefer the album gain, if present.
  2794. @end table
  2795. @item replaygain_preamp
  2796. Pre-amplification gain in dB to apply to the selected replaygain gain.
  2797. Default value for @var{replaygain_preamp} is 0.0.
  2798. @item eval
  2799. Set when the volume expression is evaluated.
  2800. It accepts the following values:
  2801. @table @samp
  2802. @item once
  2803. only evaluate expression once during the filter initialization, or
  2804. when the @samp{volume} command is sent
  2805. @item frame
  2806. evaluate expression for each incoming frame
  2807. @end table
  2808. Default value is @samp{once}.
  2809. @end table
  2810. The volume expression can contain the following parameters.
  2811. @table @option
  2812. @item n
  2813. frame number (starting at zero)
  2814. @item nb_channels
  2815. number of channels
  2816. @item nb_consumed_samples
  2817. number of samples consumed by the filter
  2818. @item nb_samples
  2819. number of samples in the current frame
  2820. @item pos
  2821. original frame position in the file
  2822. @item pts
  2823. frame PTS
  2824. @item sample_rate
  2825. sample rate
  2826. @item startpts
  2827. PTS at start of stream
  2828. @item startt
  2829. time at start of stream
  2830. @item t
  2831. frame time
  2832. @item tb
  2833. timestamp timebase
  2834. @item volume
  2835. last set volume value
  2836. @end table
  2837. Note that when @option{eval} is set to @samp{once} only the
  2838. @var{sample_rate} and @var{tb} variables are available, all other
  2839. variables will evaluate to NAN.
  2840. @subsection Commands
  2841. This filter supports the following commands:
  2842. @table @option
  2843. @item volume
  2844. Modify the volume expression.
  2845. The command accepts the same syntax of the corresponding option.
  2846. If the specified expression is not valid, it is kept at its current
  2847. value.
  2848. @item replaygain_noclip
  2849. Prevent clipping by limiting the gain applied.
  2850. Default value for @var{replaygain_noclip} is 1.
  2851. @end table
  2852. @subsection Examples
  2853. @itemize
  2854. @item
  2855. Halve the input audio volume:
  2856. @example
  2857. volume=volume=0.5
  2858. volume=volume=1/2
  2859. volume=volume=-6.0206dB
  2860. @end example
  2861. In all the above example the named key for @option{volume} can be
  2862. omitted, for example like in:
  2863. @example
  2864. volume=0.5
  2865. @end example
  2866. @item
  2867. Increase input audio power by 6 decibels using fixed-point precision:
  2868. @example
  2869. volume=volume=6dB:precision=fixed
  2870. @end example
  2871. @item
  2872. Fade volume after time 10 with an annihilation period of 5 seconds:
  2873. @example
  2874. volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
  2875. @end example
  2876. @end itemize
  2877. @section volumedetect
  2878. Detect the volume of the input video.
  2879. The filter has no parameters. The input is not modified. Statistics about
  2880. the volume will be printed in the log when the input stream end is reached.
  2881. In particular it will show the mean volume (root mean square), maximum
  2882. volume (on a per-sample basis), and the beginning of a histogram of the
  2883. registered volume values (from the maximum value to a cumulated 1/1000 of
  2884. the samples).
  2885. All volumes are in decibels relative to the maximum PCM value.
  2886. @subsection Examples
  2887. Here is an excerpt of the output:
  2888. @example
  2889. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  2890. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  2891. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  2892. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  2893. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  2894. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  2895. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  2896. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  2897. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  2898. @end example
  2899. It means that:
  2900. @itemize
  2901. @item
  2902. The mean square energy is approximately -27 dB, or 10^-2.7.
  2903. @item
  2904. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  2905. @item
  2906. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  2907. @end itemize
  2908. In other words, raising the volume by +4 dB does not cause any clipping,
  2909. raising it by +5 dB causes clipping for 6 samples, etc.
  2910. @c man end AUDIO FILTERS
  2911. @chapter Audio Sources
  2912. @c man begin AUDIO SOURCES
  2913. Below is a description of the currently available audio sources.
  2914. @section abuffer
  2915. Buffer audio frames, and make them available to the filter chain.
  2916. This source is mainly intended for a programmatic use, in particular
  2917. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  2918. It accepts the following parameters:
  2919. @table @option
  2920. @item time_base
  2921. The timebase which will be used for timestamps of submitted frames. It must be
  2922. either a floating-point number or in @var{numerator}/@var{denominator} form.
  2923. @item sample_rate
  2924. The sample rate of the incoming audio buffers.
  2925. @item sample_fmt
  2926. The sample format of the incoming audio buffers.
  2927. Either a sample format name or its corresponding integer representation from
  2928. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  2929. @item channel_layout
  2930. The channel layout of the incoming audio buffers.
  2931. Either a channel layout name from channel_layout_map in
  2932. @file{libavutil/channel_layout.c} or its corresponding integer representation
  2933. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  2934. @item channels
  2935. The number of channels of the incoming audio buffers.
  2936. If both @var{channels} and @var{channel_layout} are specified, then they
  2937. must be consistent.
  2938. @end table
  2939. @subsection Examples
  2940. @example
  2941. abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
  2942. @end example
  2943. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  2944. Since the sample format with name "s16p" corresponds to the number
  2945. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  2946. equivalent to:
  2947. @example
  2948. abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
  2949. @end example
  2950. @section aevalsrc
  2951. Generate an audio signal specified by an expression.
  2952. This source accepts in input one or more expressions (one for each
  2953. channel), which are evaluated and used to generate a corresponding
  2954. audio signal.
  2955. This source accepts the following options:
  2956. @table @option
  2957. @item exprs
  2958. Set the '|'-separated expressions list for each separate channel. In case the
  2959. @option{channel_layout} option is not specified, the selected channel layout
  2960. depends on the number of provided expressions. Otherwise the last
  2961. specified expression is applied to the remaining output channels.
  2962. @item channel_layout, c
  2963. Set the channel layout. The number of channels in the specified layout
  2964. must be equal to the number of specified expressions.
  2965. @item duration, d
  2966. Set the minimum duration of the sourced audio. See
  2967. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  2968. for the accepted syntax.
  2969. Note that the resulting duration may be greater than the specified
  2970. duration, as the generated audio is always cut at the end of a
  2971. complete frame.
  2972. If not specified, or the expressed duration is negative, the audio is
  2973. supposed to be generated forever.
  2974. @item nb_samples, n
  2975. Set the number of samples per channel per each output frame,
  2976. default to 1024.
  2977. @item sample_rate, s
  2978. Specify the sample rate, default to 44100.
  2979. @end table
  2980. Each expression in @var{exprs} can contain the following constants:
  2981. @table @option
  2982. @item n
  2983. number of the evaluated sample, starting from 0
  2984. @item t
  2985. time of the evaluated sample expressed in seconds, starting from 0
  2986. @item s
  2987. sample rate
  2988. @end table
  2989. @subsection Examples
  2990. @itemize
  2991. @item
  2992. Generate silence:
  2993. @example
  2994. aevalsrc=0
  2995. @end example
  2996. @item
  2997. Generate a sin signal with frequency of 440 Hz, set sample rate to
  2998. 8000 Hz:
  2999. @example
  3000. aevalsrc="sin(440*2*PI*t):s=8000"
  3001. @end example
  3002. @item
  3003. Generate a two channels signal, specify the channel layout (Front
  3004. Center + Back Center) explicitly:
  3005. @example
  3006. aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
  3007. @end example
  3008. @item
  3009. Generate white noise:
  3010. @example
  3011. aevalsrc="-2+random(0)"
  3012. @end example
  3013. @item
  3014. Generate an amplitude modulated signal:
  3015. @example
  3016. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  3017. @end example
  3018. @item
  3019. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  3020. @example
  3021. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
  3022. @end example
  3023. @end itemize
  3024. @section anullsrc
  3025. The null audio source, return unprocessed audio frames. It is mainly useful
  3026. as a template and to be employed in analysis / debugging tools, or as
  3027. the source for filters which ignore the input data (for example the sox
  3028. synth filter).
  3029. This source accepts the following options:
  3030. @table @option
  3031. @item channel_layout, cl
  3032. Specifies the channel layout, and can be either an integer or a string
  3033. representing a channel layout. The default value of @var{channel_layout}
  3034. is "stereo".
  3035. Check the channel_layout_map definition in
  3036. @file{libavutil/channel_layout.c} for the mapping between strings and
  3037. channel layout values.
  3038. @item sample_rate, r
  3039. Specifies the sample rate, and defaults to 44100.
  3040. @item nb_samples, n
  3041. Set the number of samples per requested frames.
  3042. @end table
  3043. @subsection Examples
  3044. @itemize
  3045. @item
  3046. Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  3047. @example
  3048. anullsrc=r=48000:cl=4
  3049. @end example
  3050. @item
  3051. Do the same operation with a more obvious syntax:
  3052. @example
  3053. anullsrc=r=48000:cl=mono
  3054. @end example
  3055. @end itemize
  3056. All the parameters need to be explicitly defined.
  3057. @section flite
  3058. Synthesize a voice utterance using the libflite library.
  3059. To enable compilation of this filter you need to configure FFmpeg with
  3060. @code{--enable-libflite}.
  3061. Note that the flite library is not thread-safe.
  3062. The filter accepts the following options:
  3063. @table @option
  3064. @item list_voices
  3065. If set to 1, list the names of the available voices and exit
  3066. immediately. Default value is 0.
  3067. @item nb_samples, n
  3068. Set the maximum number of samples per frame. Default value is 512.
  3069. @item textfile
  3070. Set the filename containing the text to speak.
  3071. @item text
  3072. Set the text to speak.
  3073. @item voice, v
  3074. Set the voice to use for the speech synthesis. Default value is
  3075. @code{kal}. See also the @var{list_voices} option.
  3076. @end table
  3077. @subsection Examples
  3078. @itemize
  3079. @item
  3080. Read from file @file{speech.txt}, and synthesize the text using the
  3081. standard flite voice:
  3082. @example
  3083. flite=textfile=speech.txt
  3084. @end example
  3085. @item
  3086. Read the specified text selecting the @code{slt} voice:
  3087. @example
  3088. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  3089. @end example
  3090. @item
  3091. Input text to ffmpeg:
  3092. @example
  3093. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  3094. @end example
  3095. @item
  3096. Make @file{ffplay} speak the specified text, using @code{flite} and
  3097. the @code{lavfi} device:
  3098. @example
  3099. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  3100. @end example
  3101. @end itemize
  3102. For more information about libflite, check:
  3103. @url{http://www.speech.cs.cmu.edu/flite/}
  3104. @section anoisesrc
  3105. Generate a noise audio signal.
  3106. The filter accepts the following options:
  3107. @table @option
  3108. @item sample_rate, r
  3109. Specify the sample rate. Default value is 48000 Hz.
  3110. @item amplitude, a
  3111. Specify the amplitude (0.0 - 1.0) of the generated audio stream. Default value
  3112. is 1.0.
  3113. @item duration, d
  3114. Specify the duration of the generated audio stream. Not specifying this option
  3115. results in noise with an infinite length.
  3116. @item color, colour, c
  3117. Specify the color of noise. Available noise colors are white, pink, and brown.
  3118. Default color is white.
  3119. @item seed, s
  3120. Specify a value used to seed the PRNG.
  3121. @item nb_samples, n
  3122. Set the number of samples per each output frame, default is 1024.
  3123. @end table
  3124. @subsection Examples
  3125. @itemize
  3126. @item
  3127. Generate 60 seconds of pink noise, with a 44.1 kHz sampling rate and an amplitude of 0.5:
  3128. @example
  3129. anoisesrc=d=60:c=pink:r=44100:a=0.5
  3130. @end example
  3131. @end itemize
  3132. @section sine
  3133. Generate an audio signal made of a sine wave with amplitude 1/8.
  3134. The audio signal is bit-exact.
  3135. The filter accepts the following options:
  3136. @table @option
  3137. @item frequency, f
  3138. Set the carrier frequency. Default is 440 Hz.
  3139. @item beep_factor, b
  3140. Enable a periodic beep every second with frequency @var{beep_factor} times
  3141. the carrier frequency. Default is 0, meaning the beep is disabled.
  3142. @item sample_rate, r
  3143. Specify the sample rate, default is 44100.
  3144. @item duration, d
  3145. Specify the duration of the generated audio stream.
  3146. @item samples_per_frame
  3147. Set the number of samples per output frame.
  3148. The expression can contain the following constants:
  3149. @table @option
  3150. @item n
  3151. The (sequential) number of the output audio frame, starting from 0.
  3152. @item pts
  3153. The PTS (Presentation TimeStamp) of the output audio frame,
  3154. expressed in @var{TB} units.
  3155. @item t
  3156. The PTS of the output audio frame, expressed in seconds.
  3157. @item TB
  3158. The timebase of the output audio frames.
  3159. @end table
  3160. Default is @code{1024}.
  3161. @end table
  3162. @subsection Examples
  3163. @itemize
  3164. @item
  3165. Generate a simple 440 Hz sine wave:
  3166. @example
  3167. sine
  3168. @end example
  3169. @item
  3170. Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
  3171. @example
  3172. sine=220:4:d=5
  3173. sine=f=220:b=4:d=5
  3174. sine=frequency=220:beep_factor=4:duration=5
  3175. @end example
  3176. @item
  3177. Generate a 1 kHz sine wave following @code{1602,1601,1602,1601,1602} NTSC
  3178. pattern:
  3179. @example
  3180. sine=1000:samples_per_frame='st(0,mod(n,5)); 1602-not(not(eq(ld(0),1)+eq(ld(0),3)))'
  3181. @end example
  3182. @end itemize
  3183. @c man end AUDIO SOURCES
  3184. @chapter Audio Sinks
  3185. @c man begin AUDIO SINKS
  3186. Below is a description of the currently available audio sinks.
  3187. @section abuffersink
  3188. Buffer audio frames, and make them available to the end of filter chain.
  3189. This sink is mainly intended for programmatic use, in particular
  3190. through the interface defined in @file{libavfilter/buffersink.h}
  3191. or the options system.
  3192. It accepts a pointer to an AVABufferSinkContext structure, which
  3193. defines the incoming buffers' formats, to be passed as the opaque
  3194. parameter to @code{avfilter_init_filter} for initialization.
  3195. @section anullsink
  3196. Null audio sink; do absolutely nothing with the input audio. It is
  3197. mainly useful as a template and for use in analysis / debugging
  3198. tools.
  3199. @c man end AUDIO SINKS
  3200. @chapter Video Filters
  3201. @c man begin VIDEO FILTERS
  3202. When you configure your FFmpeg build, you can disable any of the
  3203. existing filters using @code{--disable-filters}.
  3204. The configure output will show the video filters included in your
  3205. build.
  3206. Below is a description of the currently available video filters.
  3207. @section alphaextract
  3208. Extract the alpha component from the input as a grayscale video. This
  3209. is especially useful with the @var{alphamerge} filter.
  3210. @section alphamerge
  3211. Add or replace the alpha component of the primary input with the
  3212. grayscale value of a second input. This is intended for use with
  3213. @var{alphaextract} to allow the transmission or storage of frame
  3214. sequences that have alpha in a format that doesn't support an alpha
  3215. channel.
  3216. For example, to reconstruct full frames from a normal YUV-encoded video
  3217. and a separate video created with @var{alphaextract}, you might use:
  3218. @example
  3219. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  3220. @end example
  3221. Since this filter is designed for reconstruction, it operates on frame
  3222. sequences without considering timestamps, and terminates when either
  3223. input reaches end of stream. This will cause problems if your encoding
  3224. pipeline drops frames. If you're trying to apply an image as an
  3225. overlay to a video stream, consider the @var{overlay} filter instead.
  3226. @section ass
  3227. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  3228. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  3229. Substation Alpha) subtitles files.
  3230. This filter accepts the following option in addition to the common options from
  3231. the @ref{subtitles} filter:
  3232. @table @option
  3233. @item shaping
  3234. Set the shaping engine
  3235. Available values are:
  3236. @table @samp
  3237. @item auto
  3238. The default libass shaping engine, which is the best available.
  3239. @item simple
  3240. Fast, font-agnostic shaper that can do only substitutions
  3241. @item complex
  3242. Slower shaper using OpenType for substitutions and positioning
  3243. @end table
  3244. The default is @code{auto}.
  3245. @end table
  3246. @section atadenoise
  3247. Apply an Adaptive Temporal Averaging Denoiser to the video input.
  3248. The filter accepts the following options:
  3249. @table @option
  3250. @item 0a
  3251. Set threshold A for 1st plane. Default is 0.02.
  3252. Valid range is 0 to 0.3.
  3253. @item 0b
  3254. Set threshold B for 1st plane. Default is 0.04.
  3255. Valid range is 0 to 5.
  3256. @item 1a
  3257. Set threshold A for 2nd plane. Default is 0.02.
  3258. Valid range is 0 to 0.3.
  3259. @item 1b
  3260. Set threshold B for 2nd plane. Default is 0.04.
  3261. Valid range is 0 to 5.
  3262. @item 2a
  3263. Set threshold A for 3rd plane. Default is 0.02.
  3264. Valid range is 0 to 0.3.
  3265. @item 2b
  3266. Set threshold B for 3rd plane. Default is 0.04.
  3267. Valid range is 0 to 5.
  3268. Threshold A is designed to react on abrupt changes in the input signal and
  3269. threshold B is designed to react on continuous changes in the input signal.
  3270. @item s
  3271. Set number of frames filter will use for averaging. Default is 33. Must be odd
  3272. number in range [5, 129].
  3273. @end table
  3274. @section bbox
  3275. Compute the bounding box for the non-black pixels in the input frame
  3276. luminance plane.
  3277. This filter computes the bounding box containing all the pixels with a
  3278. luminance value greater than the minimum allowed value.
  3279. The parameters describing the bounding box are printed on the filter
  3280. log.
  3281. The filter accepts the following option:
  3282. @table @option
  3283. @item min_val
  3284. Set the minimal luminance value. Default is @code{16}.
  3285. @end table
  3286. @section blackdetect
  3287. Detect video intervals that are (almost) completely black. Can be
  3288. useful to detect chapter transitions, commercials, or invalid
  3289. recordings. Output lines contains the time for the start, end and
  3290. duration of the detected black interval expressed in seconds.
  3291. In order to display the output lines, you need to set the loglevel at
  3292. least to the AV_LOG_INFO value.
  3293. The filter accepts the following options:
  3294. @table @option
  3295. @item black_min_duration, d
  3296. Set the minimum detected black duration expressed in seconds. It must
  3297. be a non-negative floating point number.
  3298. Default value is 2.0.
  3299. @item picture_black_ratio_th, pic_th
  3300. Set the threshold for considering a picture "black".
  3301. Express the minimum value for the ratio:
  3302. @example
  3303. @var{nb_black_pixels} / @var{nb_pixels}
  3304. @end example
  3305. for which a picture is considered black.
  3306. Default value is 0.98.
  3307. @item pixel_black_th, pix_th
  3308. Set the threshold for considering a pixel "black".
  3309. The threshold expresses the maximum pixel luminance value for which a
  3310. pixel is considered "black". The provided value is scaled according to
  3311. the following equation:
  3312. @example
  3313. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  3314. @end example
  3315. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  3316. the input video format, the range is [0-255] for YUV full-range
  3317. formats and [16-235] for YUV non full-range formats.
  3318. Default value is 0.10.
  3319. @end table
  3320. The following example sets the maximum pixel threshold to the minimum
  3321. value, and detects only black intervals of 2 or more seconds:
  3322. @example
  3323. blackdetect=d=2:pix_th=0.00
  3324. @end example
  3325. @section blackframe
  3326. Detect frames that are (almost) completely black. Can be useful to
  3327. detect chapter transitions or commercials. Output lines consist of
  3328. the frame number of the detected frame, the percentage of blackness,
  3329. the position in the file if known or -1 and the timestamp in seconds.
  3330. In order to display the output lines, you need to set the loglevel at
  3331. least to the AV_LOG_INFO value.
  3332. It accepts the following parameters:
  3333. @table @option
  3334. @item amount
  3335. The percentage of the pixels that have to be below the threshold; it defaults to
  3336. @code{98}.
  3337. @item threshold, thresh
  3338. The threshold below which a pixel value is considered black; it defaults to
  3339. @code{32}.
  3340. @end table
  3341. @section blend, tblend
  3342. Blend two video frames into each other.
  3343. The @code{blend} filter takes two input streams and outputs one
  3344. stream, the first input is the "top" layer and second input is
  3345. "bottom" layer. Output terminates when shortest input terminates.
  3346. The @code{tblend} (time blend) filter takes two consecutive frames
  3347. from one single stream, and outputs the result obtained by blending
  3348. the new frame on top of the old frame.
  3349. A description of the accepted options follows.
  3350. @table @option
  3351. @item c0_mode
  3352. @item c1_mode
  3353. @item c2_mode
  3354. @item c3_mode
  3355. @item all_mode
  3356. Set blend mode for specific pixel component or all pixel components in case
  3357. of @var{all_mode}. Default value is @code{normal}.
  3358. Available values for component modes are:
  3359. @table @samp
  3360. @item addition
  3361. @item addition128
  3362. @item and
  3363. @item average
  3364. @item burn
  3365. @item darken
  3366. @item difference
  3367. @item difference128
  3368. @item divide
  3369. @item dodge
  3370. @item freeze
  3371. @item exclusion
  3372. @item glow
  3373. @item hardlight
  3374. @item hardmix
  3375. @item heat
  3376. @item lighten
  3377. @item linearlight
  3378. @item multiply
  3379. @item multiply128
  3380. @item negation
  3381. @item normal
  3382. @item or
  3383. @item overlay
  3384. @item phoenix
  3385. @item pinlight
  3386. @item reflect
  3387. @item screen
  3388. @item softlight
  3389. @item subtract
  3390. @item vividlight
  3391. @item xor
  3392. @end table
  3393. @item c0_opacity
  3394. @item c1_opacity
  3395. @item c2_opacity
  3396. @item c3_opacity
  3397. @item all_opacity
  3398. Set blend opacity for specific pixel component or all pixel components in case
  3399. of @var{all_opacity}. Only used in combination with pixel component blend modes.
  3400. @item c0_expr
  3401. @item c1_expr
  3402. @item c2_expr
  3403. @item c3_expr
  3404. @item all_expr
  3405. Set blend expression for specific pixel component or all pixel components in case
  3406. of @var{all_expr}. Note that related mode options will be ignored if those are set.
  3407. The expressions can use the following variables:
  3408. @table @option
  3409. @item N
  3410. The sequential number of the filtered frame, starting from @code{0}.
  3411. @item X
  3412. @item Y
  3413. the coordinates of the current sample
  3414. @item W
  3415. @item H
  3416. the width and height of currently filtered plane
  3417. @item SW
  3418. @item SH
  3419. Width and height scale depending on the currently filtered plane. It is the
  3420. ratio between the corresponding luma plane number of pixels and the current
  3421. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  3422. @code{0.5,0.5} for chroma planes.
  3423. @item T
  3424. Time of the current frame, expressed in seconds.
  3425. @item TOP, A
  3426. Value of pixel component at current location for first video frame (top layer).
  3427. @item BOTTOM, B
  3428. Value of pixel component at current location for second video frame (bottom layer).
  3429. @end table
  3430. @item shortest
  3431. Force termination when the shortest input terminates. Default is
  3432. @code{0}. This option is only defined for the @code{blend} filter.
  3433. @item repeatlast
  3434. Continue applying the last bottom frame after the end of the stream. A value of
  3435. @code{0} disable the filter after the last frame of the bottom layer is reached.
  3436. Default is @code{1}. This option is only defined for the @code{blend} filter.
  3437. @end table
  3438. @subsection Examples
  3439. @itemize
  3440. @item
  3441. Apply transition from bottom layer to top layer in first 10 seconds:
  3442. @example
  3443. blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
  3444. @end example
  3445. @item
  3446. Apply 1x1 checkerboard effect:
  3447. @example
  3448. blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
  3449. @end example
  3450. @item
  3451. Apply uncover left effect:
  3452. @example
  3453. blend=all_expr='if(gte(N*SW+X,W),A,B)'
  3454. @end example
  3455. @item
  3456. Apply uncover down effect:
  3457. @example
  3458. blend=all_expr='if(gte(Y-N*SH,0),A,B)'
  3459. @end example
  3460. @item
  3461. Apply uncover up-left effect:
  3462. @example
  3463. blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
  3464. @end example
  3465. @item
  3466. Split diagonally video and shows top and bottom layer on each side:
  3467. @example
  3468. blend=all_expr=if(gt(X,Y*(W/H)),A,B)
  3469. @end example
  3470. @item
  3471. Display differences between the current and the previous frame:
  3472. @example
  3473. tblend=all_mode=difference128
  3474. @end example
  3475. @end itemize
  3476. @section bwdif
  3477. Deinterlace the input video ("bwdif" stands for "Bob Weaver
  3478. Deinterlacing Filter").
  3479. Motion adaptive deinterlacing based on yadif with the use of w3fdif and cubic
  3480. interpolation algorithms.
  3481. It accepts the following parameters:
  3482. @table @option
  3483. @item mode
  3484. The interlacing mode to adopt. It accepts one of the following values:
  3485. @table @option
  3486. @item 0, send_frame
  3487. Output one frame for each frame.
  3488. @item 1, send_field
  3489. Output one frame for each field.
  3490. @end table
  3491. The default value is @code{send_field}.
  3492. @item parity
  3493. The picture field parity assumed for the input interlaced video. It accepts one
  3494. of the following values:
  3495. @table @option
  3496. @item 0, tff
  3497. Assume the top field is first.
  3498. @item 1, bff
  3499. Assume the bottom field is first.
  3500. @item -1, auto
  3501. Enable automatic detection of field parity.
  3502. @end table
  3503. The default value is @code{auto}.
  3504. If the interlacing is unknown or the decoder does not export this information,
  3505. top field first will be assumed.
  3506. @item deint
  3507. Specify which frames to deinterlace. Accept one of the following
  3508. values:
  3509. @table @option
  3510. @item 0, all
  3511. Deinterlace all frames.
  3512. @item 1, interlaced
  3513. Only deinterlace frames marked as interlaced.
  3514. @end table
  3515. The default value is @code{all}.
  3516. @end table
  3517. @section boxblur
  3518. Apply a boxblur algorithm to the input video.
  3519. It accepts the following parameters:
  3520. @table @option
  3521. @item luma_radius, lr
  3522. @item luma_power, lp
  3523. @item chroma_radius, cr
  3524. @item chroma_power, cp
  3525. @item alpha_radius, ar
  3526. @item alpha_power, ap
  3527. @end table
  3528. A description of the accepted options follows.
  3529. @table @option
  3530. @item luma_radius, lr
  3531. @item chroma_radius, cr
  3532. @item alpha_radius, ar
  3533. Set an expression for the box radius in pixels used for blurring the
  3534. corresponding input plane.
  3535. The radius value must be a non-negative number, and must not be
  3536. greater than the value of the expression @code{min(w,h)/2} for the
  3537. luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
  3538. planes.
  3539. Default value for @option{luma_radius} is "2". If not specified,
  3540. @option{chroma_radius} and @option{alpha_radius} default to the
  3541. corresponding value set for @option{luma_radius}.
  3542. The expressions can contain the following constants:
  3543. @table @option
  3544. @item w
  3545. @item h
  3546. The input width and height in pixels.
  3547. @item cw
  3548. @item ch
  3549. The input chroma image width and height in pixels.
  3550. @item hsub
  3551. @item vsub
  3552. The horizontal and vertical chroma subsample values. For example, for the
  3553. pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
  3554. @end table
  3555. @item luma_power, lp
  3556. @item chroma_power, cp
  3557. @item alpha_power, ap
  3558. Specify how many times the boxblur filter is applied to the
  3559. corresponding plane.
  3560. Default value for @option{luma_power} is 2. If not specified,
  3561. @option{chroma_power} and @option{alpha_power} default to the
  3562. corresponding value set for @option{luma_power}.
  3563. A value of 0 will disable the effect.
  3564. @end table
  3565. @subsection Examples
  3566. @itemize
  3567. @item
  3568. Apply a boxblur filter with the luma, chroma, and alpha radii
  3569. set to 2:
  3570. @example
  3571. boxblur=luma_radius=2:luma_power=1
  3572. boxblur=2:1
  3573. @end example
  3574. @item
  3575. Set the luma radius to 2, and alpha and chroma radius to 0:
  3576. @example
  3577. boxblur=2:1:cr=0:ar=0
  3578. @end example
  3579. @item
  3580. Set the luma and chroma radii to a fraction of the video dimension:
  3581. @example
  3582. boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
  3583. @end example
  3584. @end itemize
  3585. @section chromakey
  3586. YUV colorspace color/chroma keying.
  3587. The filter accepts the following options:
  3588. @table @option
  3589. @item color
  3590. The color which will be replaced with transparency.
  3591. @item similarity
  3592. Similarity percentage with the key color.
  3593. 0.01 matches only the exact key color, while 1.0 matches everything.
  3594. @item blend
  3595. Blend percentage.
  3596. 0.0 makes pixels either fully transparent, or not transparent at all.
  3597. Higher values result in semi-transparent pixels, with a higher transparency
  3598. the more similar the pixels color is to the key color.
  3599. @item yuv
  3600. Signals that the color passed is already in YUV instead of RGB.
  3601. Litteral colors like "green" or "red" don't make sense with this enabled anymore.
  3602. This can be used to pass exact YUV values as hexadecimal numbers.
  3603. @end table
  3604. @subsection Examples
  3605. @itemize
  3606. @item
  3607. Make every green pixel in the input image transparent:
  3608. @example
  3609. ffmpeg -i input.png -vf chromakey=green out.png
  3610. @end example
  3611. @item
  3612. Overlay a greenscreen-video on top of a static black background.
  3613. @example
  3614. 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
  3615. @end example
  3616. @end itemize
  3617. @section ciescope
  3618. Display CIE color diagram with pixels overlaid onto it.
  3619. The filter acccepts the following options:
  3620. @table @option
  3621. @item system
  3622. Set color system.
  3623. @table @samp
  3624. @item ntsc, 470m
  3625. @item ebu, 470bg
  3626. @item smpte
  3627. @item 240m
  3628. @item apple
  3629. @item widergb
  3630. @item cie1931
  3631. @item rec709, hdtv
  3632. @item uhdtv, rec2020
  3633. @end table
  3634. @item cie
  3635. Set CIE system.
  3636. @table @samp
  3637. @item xyy
  3638. @item ucs
  3639. @item luv
  3640. @end table
  3641. @item gamuts
  3642. Set what gamuts to draw.
  3643. See @code{system} option for avaiable values.
  3644. @item size, s
  3645. Set ciescope size, by default set to 512.
  3646. @item intensity, i
  3647. Set intensity used to map input pixel values to CIE diagram.
  3648. @item contrast
  3649. Set contrast used to draw tongue colors that are out of active color system gamut.
  3650. @item corrgamma
  3651. Correct gamma displayed on scope, by default enabled.
  3652. @item showwhite
  3653. Show white point on CIE diagram, by default disabled.
  3654. @item gamma
  3655. Set input gamma. Used only with XYZ input color space.
  3656. @end table
  3657. @section codecview
  3658. Visualize information exported by some codecs.
  3659. Some codecs can export information through frames using side-data or other
  3660. means. For example, some MPEG based codecs export motion vectors through the
  3661. @var{export_mvs} flag in the codec @option{flags2} option.
  3662. The filter accepts the following option:
  3663. @table @option
  3664. @item mv
  3665. Set motion vectors to visualize.
  3666. Available flags for @var{mv} are:
  3667. @table @samp
  3668. @item pf
  3669. forward predicted MVs of P-frames
  3670. @item bf
  3671. forward predicted MVs of B-frames
  3672. @item bb
  3673. backward predicted MVs of B-frames
  3674. @end table
  3675. @item qp
  3676. Display quantization parameters using the chroma planes
  3677. @end table
  3678. @subsection Examples
  3679. @itemize
  3680. @item
  3681. Visualizes multi-directionals MVs from P and B-Frames using @command{ffplay}:
  3682. @example
  3683. ffplay -flags2 +export_mvs input.mpg -vf codecview=mv=pf+bf+bb
  3684. @end example
  3685. @end itemize
  3686. @section colorbalance
  3687. Modify intensity of primary colors (red, green and blue) of input frames.
  3688. The filter allows an input frame to be adjusted in the shadows, midtones or highlights
  3689. regions for the red-cyan, green-magenta or blue-yellow balance.
  3690. A positive adjustment value shifts the balance towards the primary color, a negative
  3691. value towards the complementary color.
  3692. The filter accepts the following options:
  3693. @table @option
  3694. @item rs
  3695. @item gs
  3696. @item bs
  3697. Adjust red, green and blue shadows (darkest pixels).
  3698. @item rm
  3699. @item gm
  3700. @item bm
  3701. Adjust red, green and blue midtones (medium pixels).
  3702. @item rh
  3703. @item gh
  3704. @item bh
  3705. Adjust red, green and blue highlights (brightest pixels).
  3706. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  3707. @end table
  3708. @subsection Examples
  3709. @itemize
  3710. @item
  3711. Add red color cast to shadows:
  3712. @example
  3713. colorbalance=rs=.3
  3714. @end example
  3715. @end itemize
  3716. @section colorkey
  3717. RGB colorspace color keying.
  3718. The filter accepts the following options:
  3719. @table @option
  3720. @item color
  3721. The color which will be replaced with transparency.
  3722. @item similarity
  3723. Similarity percentage with the key color.
  3724. 0.01 matches only the exact key color, while 1.0 matches everything.
  3725. @item blend
  3726. Blend percentage.
  3727. 0.0 makes pixels either fully transparent, or not transparent at all.
  3728. Higher values result in semi-transparent pixels, with a higher transparency
  3729. the more similar the pixels color is to the key color.
  3730. @end table
  3731. @subsection Examples
  3732. @itemize
  3733. @item
  3734. Make every green pixel in the input image transparent:
  3735. @example
  3736. ffmpeg -i input.png -vf colorkey=green out.png
  3737. @end example
  3738. @item
  3739. Overlay a greenscreen-video on top of a static background image.
  3740. @example
  3741. 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
  3742. @end example
  3743. @end itemize
  3744. @section colorlevels
  3745. Adjust video input frames using levels.
  3746. The filter accepts the following options:
  3747. @table @option
  3748. @item rimin
  3749. @item gimin
  3750. @item bimin
  3751. @item aimin
  3752. Adjust red, green, blue and alpha input black point.
  3753. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  3754. @item rimax
  3755. @item gimax
  3756. @item bimax
  3757. @item aimax
  3758. Adjust red, green, blue and alpha input white point.
  3759. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
  3760. Input levels are used to lighten highlights (bright tones), darken shadows
  3761. (dark tones), change the balance of bright and dark tones.
  3762. @item romin
  3763. @item gomin
  3764. @item bomin
  3765. @item aomin
  3766. Adjust red, green, blue and alpha output black point.
  3767. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
  3768. @item romax
  3769. @item gomax
  3770. @item bomax
  3771. @item aomax
  3772. Adjust red, green, blue and alpha output white point.
  3773. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
  3774. Output levels allows manual selection of a constrained output level range.
  3775. @end table
  3776. @subsection Examples
  3777. @itemize
  3778. @item
  3779. Make video output darker:
  3780. @example
  3781. colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
  3782. @end example
  3783. @item
  3784. Increase contrast:
  3785. @example
  3786. colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
  3787. @end example
  3788. @item
  3789. Make video output lighter:
  3790. @example
  3791. colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
  3792. @end example
  3793. @item
  3794. Increase brightness:
  3795. @example
  3796. colorlevels=romin=0.5:gomin=0.5:bomin=0.5
  3797. @end example
  3798. @end itemize
  3799. @section colorchannelmixer
  3800. Adjust video input frames by re-mixing color channels.
  3801. This filter modifies a color channel by adding the values associated to
  3802. the other channels of the same pixels. For example if the value to
  3803. modify is red, the output value will be:
  3804. @example
  3805. @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
  3806. @end example
  3807. The filter accepts the following options:
  3808. @table @option
  3809. @item rr
  3810. @item rg
  3811. @item rb
  3812. @item ra
  3813. Adjust contribution of input red, green, blue and alpha channels for output red channel.
  3814. Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
  3815. @item gr
  3816. @item gg
  3817. @item gb
  3818. @item ga
  3819. Adjust contribution of input red, green, blue and alpha channels for output green channel.
  3820. Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
  3821. @item br
  3822. @item bg
  3823. @item bb
  3824. @item ba
  3825. Adjust contribution of input red, green, blue and alpha channels for output blue channel.
  3826. Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
  3827. @item ar
  3828. @item ag
  3829. @item ab
  3830. @item aa
  3831. Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
  3832. Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
  3833. Allowed ranges for options are @code{[-2.0, 2.0]}.
  3834. @end table
  3835. @subsection Examples
  3836. @itemize
  3837. @item
  3838. Convert source to grayscale:
  3839. @example
  3840. colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
  3841. @end example
  3842. @item
  3843. Simulate sepia tones:
  3844. @example
  3845. colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
  3846. @end example
  3847. @end itemize
  3848. @section colormatrix
  3849. Convert color matrix.
  3850. The filter accepts the following options:
  3851. @table @option
  3852. @item src
  3853. @item dst
  3854. Specify the source and destination color matrix. Both values must be
  3855. specified.
  3856. The accepted values are:
  3857. @table @samp
  3858. @item bt709
  3859. BT.709
  3860. @item bt601
  3861. BT.601
  3862. @item smpte240m
  3863. SMPTE-240M
  3864. @item fcc
  3865. FCC
  3866. @end table
  3867. @end table
  3868. For example to convert from BT.601 to SMPTE-240M, use the command:
  3869. @example
  3870. colormatrix=bt601:smpte240m
  3871. @end example
  3872. @section colorspace
  3873. Convert colorspace, transfer characteristics or color primaries.
  3874. The filter accepts the following options:
  3875. @table @option
  3876. @item all
  3877. Specify all color properties at once.
  3878. The accepted values are:
  3879. @table @samp
  3880. @item bt470m
  3881. BT.470M
  3882. @item bt470bg
  3883. BT.470BG
  3884. @item bt601-6-525
  3885. BT.601-6 525
  3886. @item bt601-6-625
  3887. BT.601-6 625
  3888. @item bt709
  3889. BT.709
  3890. @item smpte170m
  3891. SMPTE-170M
  3892. @item smpte240m
  3893. SMPTE-240M
  3894. @item bt2020
  3895. BT.2020
  3896. @end table
  3897. @item space
  3898. Specify output colorspace.
  3899. The accepted values are:
  3900. @table @samp
  3901. @item bt709
  3902. BT.709
  3903. @item fcc
  3904. FCC
  3905. @item bt470bg
  3906. BT.470BG or BT.601-6 625
  3907. @item smpte170m
  3908. SMPTE-170M or BT.601-6 525
  3909. @item smpte240m
  3910. SMPTE-240M
  3911. @item bt2020ncl
  3912. BT.2020 with non-constant luminance
  3913. @end table
  3914. @item trc
  3915. Specify output transfer characteristics.
  3916. The accepted values are:
  3917. @table @samp
  3918. @item bt709
  3919. BT.709
  3920. @item gamma22
  3921. Constant gamma of 2.2
  3922. @item gamma28
  3923. Constant gamma of 2.8
  3924. @item smpte170m
  3925. SMPTE-170M, BT.601-6 625 or BT.601-6 525
  3926. @item smpte240m
  3927. SMPTE-240M
  3928. @item bt2020-10
  3929. BT.2020 for 10-bits content
  3930. @item bt2020-12
  3931. BT.2020 for 12-bits content
  3932. @end table
  3933. @item prm
  3934. Specify output color primaries.
  3935. The accepted values are:
  3936. @table @samp
  3937. @item bt709
  3938. BT.709
  3939. @item bt470m
  3940. BT.470M
  3941. @item bt470bg
  3942. BT.470BG or BT.601-6 625
  3943. @item smpte170m
  3944. SMPTE-170M or BT.601-6 525
  3945. @item smpte240m
  3946. SMPTE-240M
  3947. @item bt2020
  3948. BT.2020
  3949. @end table
  3950. @item rng
  3951. Specify output color range.
  3952. The accepted values are:
  3953. @table @samp
  3954. @item mpeg
  3955. MPEG (restricted) range
  3956. @item jpeg
  3957. JPEG (full) range
  3958. @end table
  3959. @item format
  3960. Specify output color format.
  3961. The accepted values are:
  3962. @table @samp
  3963. @item yuv420p
  3964. YUV 4:2:0 planar 8-bits
  3965. @item yuv420p10
  3966. YUV 4:2:0 planar 10-bits
  3967. @item yuv420p12
  3968. YUV 4:2:0 planar 12-bits
  3969. @item yuv422p
  3970. YUV 4:2:2 planar 8-bits
  3971. @item yuv422p10
  3972. YUV 4:2:2 planar 10-bits
  3973. @item yuv422p12
  3974. YUV 4:2:2 planar 12-bits
  3975. @item yuv444p
  3976. YUV 4:4:4 planar 8-bits
  3977. @item yuv444p10
  3978. YUV 4:4:4 planar 10-bits
  3979. @item yuv444p12
  3980. YUV 4:4:4 planar 12-bits
  3981. @end table
  3982. @item fast
  3983. Do a fast conversion, which skips gamma/primary correction. This will take
  3984. significantly less CPU, but will be mathematically incorrect. To get output
  3985. compatible with that produced by the colormatrix filter, use fast=1.
  3986. @end table
  3987. The filter converts the transfer characteristics, color space and color
  3988. primaries to the specified user values. The output value, if not specified,
  3989. is set to a default value based on the "all" property. If that property is
  3990. also not specified, the filter will log an error. The output color range and
  3991. format default to the same value as the input color range and format. The
  3992. input transfer characteristics, color space, color primaries and color range
  3993. should be set on the input data. If any of these are missing, the filter will
  3994. log an error and no conversion will take place.
  3995. For example to convert the input to SMPTE-240M, use the command:
  3996. @example
  3997. colorspace=smpte240m
  3998. @end example
  3999. @section convolution
  4000. Apply convolution 3x3 or 5x5 filter.
  4001. The filter accepts the following options:
  4002. @table @option
  4003. @item 0m
  4004. @item 1m
  4005. @item 2m
  4006. @item 3m
  4007. Set matrix for each plane.
  4008. Matrix is sequence of 9 or 25 signed integers.
  4009. @item 0rdiv
  4010. @item 1rdiv
  4011. @item 2rdiv
  4012. @item 3rdiv
  4013. Set multiplier for calculated value for each plane.
  4014. @item 0bias
  4015. @item 1bias
  4016. @item 2bias
  4017. @item 3bias
  4018. Set bias for each plane. This value is added to the result of the multiplication.
  4019. Useful for making the overall image brighter or darker. Default is 0.0.
  4020. @end table
  4021. @subsection Examples
  4022. @itemize
  4023. @item
  4024. Apply sharpen:
  4025. @example
  4026. convolution="0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0"
  4027. @end example
  4028. @item
  4029. Apply blur:
  4030. @example
  4031. convolution="1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1/9:1/9:1/9:1/9"
  4032. @end example
  4033. @item
  4034. Apply edge enhance:
  4035. @example
  4036. convolution="0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:5:1:1:1:0:128:128:128"
  4037. @end example
  4038. @item
  4039. Apply edge detect:
  4040. @example
  4041. convolution="0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:5:5:5:1:0:128:128:128"
  4042. @end example
  4043. @item
  4044. Apply emboss:
  4045. @example
  4046. convolution="-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2"
  4047. @end example
  4048. @end itemize
  4049. @section copy
  4050. Copy the input source unchanged to the output. This is mainly useful for
  4051. testing purposes.
  4052. @anchor{coreimage}
  4053. @section coreimage
  4054. Video filtering on GPU using Apple's CoreImage API on OSX.
  4055. Hardware acceleration is based on an OpenGL context. Usually, this means it is
  4056. processed by video hardware. However, software-based OpenGL implementations
  4057. exist which means there is no guarantee for hardware processing. It depends on
  4058. the respective OSX.
  4059. There are many filters and image generators provided by Apple that come with a
  4060. large variety of options. The filter has to be referenced by its name along
  4061. with its options.
  4062. The coreimage filter accepts the following options:
  4063. @table @option
  4064. @item list_filters
  4065. List all available filters and generators along with all their respective
  4066. options as well as possible minimum and maximum values along with the default
  4067. values.
  4068. @example
  4069. list_filters=true
  4070. @end example
  4071. @item filter
  4072. Specify all filters by their respective name and options.
  4073. Use @var{list_filters} to determine all valid filter names and options.
  4074. Numerical options are specified by a float value and are automatically clamped
  4075. to their respective value range. Vector and color options have to be specified
  4076. by a list of space separated float values. Character escaping has to be done.
  4077. A special option name @code{default} is available to use default options for a
  4078. filter.
  4079. It is required to specify either @code{default} or at least one of the filter options.
  4080. All omitted options are used with their default values.
  4081. The syntax of the filter string is as follows:
  4082. @example
  4083. filter=<NAME>@@<OPTION>=<VALUE>[@@<OPTION>=<VALUE>][@@...][#<NAME>@@<OPTION>=<VALUE>[@@<OPTION>=<VALUE>][@@...]][#...]
  4084. @end example
  4085. @item output_rect
  4086. Specify a rectangle where the output of the filter chain is copied into the
  4087. input image. It is given by a list of space separated float values:
  4088. @example
  4089. output_rect=x\ y\ width\ height
  4090. @end example
  4091. If not given, the output rectangle equals the dimensions of the input image.
  4092. The output rectangle is automatically cropped at the borders of the input
  4093. image. Negative values are valid for each component.
  4094. @example
  4095. output_rect=25\ 25\ 100\ 100
  4096. @end example
  4097. @end table
  4098. Several filters can be chained for successive processing without GPU-HOST
  4099. transfers allowing for fast processing of complex filter chains.
  4100. Currently, only filters with zero (generators) or exactly one (filters) input
  4101. image and one output image are supported. Also, transition filters are not yet
  4102. usable as intended.
  4103. Some filters generate output images with additional padding depending on the
  4104. respective filter kernel. The padding is automatically removed to ensure the
  4105. filter output has the same size as the input image.
  4106. For image generators, the size of the output image is determined by the
  4107. previous output image of the filter chain or the input image of the whole
  4108. filterchain, respectively. The generators do not use the pixel information of
  4109. this image to generate their output. However, the generated output is
  4110. blended onto this image, resulting in partial or complete coverage of the
  4111. output image.
  4112. The @ref{coreimagesrc} video source can be used for generating input images
  4113. which are directly fed into the filter chain. By using it, providing input
  4114. images by another video source or an input video is not required.
  4115. @subsection Examples
  4116. @itemize
  4117. @item
  4118. List all filters available:
  4119. @example
  4120. coreimage=list_filters=true
  4121. @end example
  4122. @item
  4123. Use the CIBoxBlur filter with default options to blur an image:
  4124. @example
  4125. coreimage=filter=CIBoxBlur@@default
  4126. @end example
  4127. @item
  4128. Use a filter chain with CISepiaTone at default values and CIVignetteEffect with
  4129. its center at 100x100 and a radius of 50 pixels:
  4130. @example
  4131. coreimage=filter=CIBoxBlur@@default#CIVignetteEffect@@inputCenter=100\ 100@@inputRadius=50
  4132. @end example
  4133. @item
  4134. Use nullsrc and CIQRCodeGenerator to create a QR code for the FFmpeg homepage,
  4135. given as complete and escaped command-line for Apple's standard bash shell:
  4136. @example
  4137. ffmpeg -f lavfi -i nullsrc=s=100x100,coreimage=filter=CIQRCodeGenerator@@inputMessage=https\\\\\://FFmpeg.org/@@inputCorrectionLevel=H -frames:v 1 QRCode.png
  4138. @end example
  4139. @end itemize
  4140. @section crop
  4141. Crop the input video to given dimensions.
  4142. It accepts the following parameters:
  4143. @table @option
  4144. @item w, out_w
  4145. The width of the output video. It defaults to @code{iw}.
  4146. This expression is evaluated only once during the filter
  4147. configuration, or when the @samp{w} or @samp{out_w} command is sent.
  4148. @item h, out_h
  4149. The height of the output video. It defaults to @code{ih}.
  4150. This expression is evaluated only once during the filter
  4151. configuration, or when the @samp{h} or @samp{out_h} command is sent.
  4152. @item x
  4153. The horizontal position, in the input video, of the left edge of the output
  4154. video. It defaults to @code{(in_w-out_w)/2}.
  4155. This expression is evaluated per-frame.
  4156. @item y
  4157. The vertical position, in the input video, of the top edge of the output video.
  4158. It defaults to @code{(in_h-out_h)/2}.
  4159. This expression is evaluated per-frame.
  4160. @item keep_aspect
  4161. If set to 1 will force the output display aspect ratio
  4162. to be the same of the input, by changing the output sample aspect
  4163. ratio. It defaults to 0.
  4164. @end table
  4165. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  4166. expressions containing the following constants:
  4167. @table @option
  4168. @item x
  4169. @item y
  4170. The computed values for @var{x} and @var{y}. They are evaluated for
  4171. each new frame.
  4172. @item in_w
  4173. @item in_h
  4174. The input width and height.
  4175. @item iw
  4176. @item ih
  4177. These are the same as @var{in_w} and @var{in_h}.
  4178. @item out_w
  4179. @item out_h
  4180. The output (cropped) width and height.
  4181. @item ow
  4182. @item oh
  4183. These are the same as @var{out_w} and @var{out_h}.
  4184. @item a
  4185. same as @var{iw} / @var{ih}
  4186. @item sar
  4187. input sample aspect ratio
  4188. @item dar
  4189. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  4190. @item hsub
  4191. @item vsub
  4192. horizontal and vertical chroma subsample values. For example for the
  4193. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4194. @item n
  4195. The number of the input frame, starting from 0.
  4196. @item pos
  4197. the position in the file of the input frame, NAN if unknown
  4198. @item t
  4199. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  4200. @end table
  4201. The expression for @var{out_w} may depend on the value of @var{out_h},
  4202. and the expression for @var{out_h} may depend on @var{out_w}, but they
  4203. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  4204. evaluated after @var{out_w} and @var{out_h}.
  4205. The @var{x} and @var{y} parameters specify the expressions for the
  4206. position of the top-left corner of the output (non-cropped) area. They
  4207. are evaluated for each frame. If the evaluated value is not valid, it
  4208. is approximated to the nearest valid value.
  4209. The expression for @var{x} may depend on @var{y}, and the expression
  4210. for @var{y} may depend on @var{x}.
  4211. @subsection Examples
  4212. @itemize
  4213. @item
  4214. Crop area with size 100x100 at position (12,34).
  4215. @example
  4216. crop=100:100:12:34
  4217. @end example
  4218. Using named options, the example above becomes:
  4219. @example
  4220. crop=w=100:h=100:x=12:y=34
  4221. @end example
  4222. @item
  4223. Crop the central input area with size 100x100:
  4224. @example
  4225. crop=100:100
  4226. @end example
  4227. @item
  4228. Crop the central input area with size 2/3 of the input video:
  4229. @example
  4230. crop=2/3*in_w:2/3*in_h
  4231. @end example
  4232. @item
  4233. Crop the input video central square:
  4234. @example
  4235. crop=out_w=in_h
  4236. crop=in_h
  4237. @end example
  4238. @item
  4239. Delimit the rectangle with the top-left corner placed at position
  4240. 100:100 and the right-bottom corner corresponding to the right-bottom
  4241. corner of the input image.
  4242. @example
  4243. crop=in_w-100:in_h-100:100:100
  4244. @end example
  4245. @item
  4246. Crop 10 pixels from the left and right borders, and 20 pixels from
  4247. the top and bottom borders
  4248. @example
  4249. crop=in_w-2*10:in_h-2*20
  4250. @end example
  4251. @item
  4252. Keep only the bottom right quarter of the input image:
  4253. @example
  4254. crop=in_w/2:in_h/2:in_w/2:in_h/2
  4255. @end example
  4256. @item
  4257. Crop height for getting Greek harmony:
  4258. @example
  4259. crop=in_w:1/PHI*in_w
  4260. @end example
  4261. @item
  4262. Apply trembling effect:
  4263. @example
  4264. 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)
  4265. @end example
  4266. @item
  4267. Apply erratic camera effect depending on timestamp:
  4268. @example
  4269. 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)"
  4270. @end example
  4271. @item
  4272. Set x depending on the value of y:
  4273. @example
  4274. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  4275. @end example
  4276. @end itemize
  4277. @subsection Commands
  4278. This filter supports the following commands:
  4279. @table @option
  4280. @item w, out_w
  4281. @item h, out_h
  4282. @item x
  4283. @item y
  4284. Set width/height of the output video and the horizontal/vertical position
  4285. in the input video.
  4286. The command accepts the same syntax of the corresponding option.
  4287. If the specified expression is not valid, it is kept at its current
  4288. value.
  4289. @end table
  4290. @section cropdetect
  4291. Auto-detect the crop size.
  4292. It calculates the necessary cropping parameters and prints the
  4293. recommended parameters via the logging system. The detected dimensions
  4294. correspond to the non-black area of the input video.
  4295. It accepts the following parameters:
  4296. @table @option
  4297. @item limit
  4298. Set higher black value threshold, which can be optionally specified
  4299. from nothing (0) to everything (255 for 8bit based formats). An intensity
  4300. value greater to the set value is considered non-black. It defaults to 24.
  4301. You can also specify a value between 0.0 and 1.0 which will be scaled depending
  4302. on the bitdepth of the pixel format.
  4303. @item round
  4304. The value which the width/height should be divisible by. It defaults to
  4305. 16. The offset is automatically adjusted to center the video. Use 2 to
  4306. get only even dimensions (needed for 4:2:2 video). 16 is best when
  4307. encoding to most video codecs.
  4308. @item reset_count, reset
  4309. Set the counter that determines after how many frames cropdetect will
  4310. reset the previously detected largest video area and start over to
  4311. detect the current optimal crop area. Default value is 0.
  4312. This can be useful when channel logos distort the video area. 0
  4313. indicates 'never reset', and returns the largest area encountered during
  4314. playback.
  4315. @end table
  4316. @anchor{curves}
  4317. @section curves
  4318. Apply color adjustments using curves.
  4319. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  4320. component (red, green and blue) has its values defined by @var{N} key points
  4321. tied from each other using a smooth curve. The x-axis represents the pixel
  4322. values from the input frame, and the y-axis the new pixel values to be set for
  4323. the output frame.
  4324. By default, a component curve is defined by the two points @var{(0;0)} and
  4325. @var{(1;1)}. This creates a straight line where each original pixel value is
  4326. "adjusted" to its own value, which means no change to the image.
  4327. The filter allows you to redefine these two points and add some more. A new
  4328. curve (using a natural cubic spline interpolation) will be define to pass
  4329. smoothly through all these new coordinates. The new defined points needs to be
  4330. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  4331. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  4332. the vector spaces, the values will be clipped accordingly.
  4333. If there is no key point defined in @code{x=0}, the filter will automatically
  4334. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  4335. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  4336. The filter accepts the following options:
  4337. @table @option
  4338. @item preset
  4339. Select one of the available color presets. This option can be used in addition
  4340. to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
  4341. options takes priority on the preset values.
  4342. Available presets are:
  4343. @table @samp
  4344. @item none
  4345. @item color_negative
  4346. @item cross_process
  4347. @item darker
  4348. @item increase_contrast
  4349. @item lighter
  4350. @item linear_contrast
  4351. @item medium_contrast
  4352. @item negative
  4353. @item strong_contrast
  4354. @item vintage
  4355. @end table
  4356. Default is @code{none}.
  4357. @item master, m
  4358. Set the master key points. These points will define a second pass mapping. It
  4359. is sometimes called a "luminance" or "value" mapping. It can be used with
  4360. @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
  4361. post-processing LUT.
  4362. @item red, r
  4363. Set the key points for the red component.
  4364. @item green, g
  4365. Set the key points for the green component.
  4366. @item blue, b
  4367. Set the key points for the blue component.
  4368. @item all
  4369. Set the key points for all components (not including master).
  4370. Can be used in addition to the other key points component
  4371. options. In this case, the unset component(s) will fallback on this
  4372. @option{all} setting.
  4373. @item psfile
  4374. Specify a Photoshop curves file (@code{.acv}) to import the settings from.
  4375. @end table
  4376. To avoid some filtergraph syntax conflicts, each key points list need to be
  4377. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  4378. @subsection Examples
  4379. @itemize
  4380. @item
  4381. Increase slightly the middle level of blue:
  4382. @example
  4383. curves=blue='0.5/0.58'
  4384. @end example
  4385. @item
  4386. Vintage effect:
  4387. @example
  4388. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  4389. @end example
  4390. Here we obtain the following coordinates for each components:
  4391. @table @var
  4392. @item red
  4393. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  4394. @item green
  4395. @code{(0;0) (0.50;0.48) (1;1)}
  4396. @item blue
  4397. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  4398. @end table
  4399. @item
  4400. The previous example can also be achieved with the associated built-in preset:
  4401. @example
  4402. curves=preset=vintage
  4403. @end example
  4404. @item
  4405. Or simply:
  4406. @example
  4407. curves=vintage
  4408. @end example
  4409. @item
  4410. Use a Photoshop preset and redefine the points of the green component:
  4411. @example
  4412. curves=psfile='MyCurvesPresets/purple.acv':green='0.45/0.53'
  4413. @end example
  4414. @end itemize
  4415. @section datascope
  4416. Video data analysis filter.
  4417. This filter shows hexadecimal pixel values of part of video.
  4418. The filter accepts the following options:
  4419. @table @option
  4420. @item size, s
  4421. Set output video size.
  4422. @item x
  4423. Set x offset from where to pick pixels.
  4424. @item y
  4425. Set y offset from where to pick pixels.
  4426. @item mode
  4427. Set scope mode, can be one of the following:
  4428. @table @samp
  4429. @item mono
  4430. Draw hexadecimal pixel values with white color on black background.
  4431. @item color
  4432. Draw hexadecimal pixel values with input video pixel color on black
  4433. background.
  4434. @item color2
  4435. Draw hexadecimal pixel values on color background picked from input video,
  4436. the text color is picked in such way so its always visible.
  4437. @end table
  4438. @item axis
  4439. Draw rows and columns numbers on left and top of video.
  4440. @end table
  4441. @section dctdnoiz
  4442. Denoise frames using 2D DCT (frequency domain filtering).
  4443. This filter is not designed for real time.
  4444. The filter accepts the following options:
  4445. @table @option
  4446. @item sigma, s
  4447. Set the noise sigma constant.
  4448. This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
  4449. coefficient (absolute value) below this threshold with be dropped.
  4450. If you need a more advanced filtering, see @option{expr}.
  4451. Default is @code{0}.
  4452. @item overlap
  4453. Set number overlapping pixels for each block. Since the filter can be slow, you
  4454. may want to reduce this value, at the cost of a less effective filter and the
  4455. risk of various artefacts.
  4456. If the overlapping value doesn't permit processing the whole input width or
  4457. height, a warning will be displayed and according borders won't be denoised.
  4458. Default value is @var{blocksize}-1, which is the best possible setting.
  4459. @item expr, e
  4460. Set the coefficient factor expression.
  4461. For each coefficient of a DCT block, this expression will be evaluated as a
  4462. multiplier value for the coefficient.
  4463. If this is option is set, the @option{sigma} option will be ignored.
  4464. The absolute value of the coefficient can be accessed through the @var{c}
  4465. variable.
  4466. @item n
  4467. Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
  4468. @var{blocksize}, which is the width and height of the processed blocks.
  4469. The default value is @var{3} (8x8) and can be raised to @var{4} for a
  4470. @var{blocksize} of 16x16. Note that changing this setting has huge consequences
  4471. on the speed processing. Also, a larger block size does not necessarily means a
  4472. better de-noising.
  4473. @end table
  4474. @subsection Examples
  4475. Apply a denoise with a @option{sigma} of @code{4.5}:
  4476. @example
  4477. dctdnoiz=4.5
  4478. @end example
  4479. The same operation can be achieved using the expression system:
  4480. @example
  4481. dctdnoiz=e='gte(c, 4.5*3)'
  4482. @end example
  4483. Violent denoise using a block size of @code{16x16}:
  4484. @example
  4485. dctdnoiz=15:n=4
  4486. @end example
  4487. @section deband
  4488. Remove banding artifacts from input video.
  4489. It works by replacing banded pixels with average value of referenced pixels.
  4490. The filter accepts the following options:
  4491. @table @option
  4492. @item 1thr
  4493. @item 2thr
  4494. @item 3thr
  4495. @item 4thr
  4496. Set banding detection threshold for each plane. Default is 0.02.
  4497. Valid range is 0.00003 to 0.5.
  4498. If difference between current pixel and reference pixel is less than threshold,
  4499. it will be considered as banded.
  4500. @item range, r
  4501. Banding detection range in pixels. Default is 16. If positive, random number
  4502. in range 0 to set value will be used. If negative, exact absolute value
  4503. will be used.
  4504. The range defines square of four pixels around current pixel.
  4505. @item direction, d
  4506. Set direction in radians from which four pixel will be compared. If positive,
  4507. random direction from 0 to set direction will be picked. If negative, exact of
  4508. absolute value will be picked. For example direction 0, -PI or -2*PI radians
  4509. will pick only pixels on same row and -PI/2 will pick only pixels on same
  4510. column.
  4511. @item blur
  4512. If enabled, current pixel is compared with average value of all four
  4513. surrounding pixels. The default is enabled. If disabled current pixel is
  4514. compared with all four surrounding pixels. The pixel is considered banded
  4515. if only all four differences with surrounding pixels are less than threshold.
  4516. @end table
  4517. @anchor{decimate}
  4518. @section decimate
  4519. Drop duplicated frames at regular intervals.
  4520. The filter accepts the following options:
  4521. @table @option
  4522. @item cycle
  4523. Set the number of frames from which one will be dropped. Setting this to
  4524. @var{N} means one frame in every batch of @var{N} frames will be dropped.
  4525. Default is @code{5}.
  4526. @item dupthresh
  4527. Set the threshold for duplicate detection. If the difference metric for a frame
  4528. is less than or equal to this value, then it is declared as duplicate. Default
  4529. is @code{1.1}
  4530. @item scthresh
  4531. Set scene change threshold. Default is @code{15}.
  4532. @item blockx
  4533. @item blocky
  4534. Set the size of the x and y-axis blocks used during metric calculations.
  4535. Larger blocks give better noise suppression, but also give worse detection of
  4536. small movements. Must be a power of two. Default is @code{32}.
  4537. @item ppsrc
  4538. Mark main input as a pre-processed input and activate clean source input
  4539. stream. This allows the input to be pre-processed with various filters to help
  4540. the metrics calculation while keeping the frame selection lossless. When set to
  4541. @code{1}, the first stream is for the pre-processed input, and the second
  4542. stream is the clean source from where the kept frames are chosen. Default is
  4543. @code{0}.
  4544. @item chroma
  4545. Set whether or not chroma is considered in the metric calculations. Default is
  4546. @code{1}.
  4547. @end table
  4548. @section deflate
  4549. Apply deflate effect to the video.
  4550. This filter replaces the pixel by the local(3x3) average by taking into account
  4551. only values lower than the pixel.
  4552. It accepts the following options:
  4553. @table @option
  4554. @item threshold0
  4555. @item threshold1
  4556. @item threshold2
  4557. @item threshold3
  4558. Limit the maximum change for each plane, default is 65535.
  4559. If 0, plane will remain unchanged.
  4560. @end table
  4561. @section dejudder
  4562. Remove judder produced by partially interlaced telecined content.
  4563. Judder can be introduced, for instance, by @ref{pullup} filter. If the original
  4564. source was partially telecined content then the output of @code{pullup,dejudder}
  4565. will have a variable frame rate. May change the recorded frame rate of the
  4566. container. Aside from that change, this filter will not affect constant frame
  4567. rate video.
  4568. The option available in this filter is:
  4569. @table @option
  4570. @item cycle
  4571. Specify the length of the window over which the judder repeats.
  4572. Accepts any integer greater than 1. Useful values are:
  4573. @table @samp
  4574. @item 4
  4575. If the original was telecined from 24 to 30 fps (Film to NTSC).
  4576. @item 5
  4577. If the original was telecined from 25 to 30 fps (PAL to NTSC).
  4578. @item 20
  4579. If a mixture of the two.
  4580. @end table
  4581. The default is @samp{4}.
  4582. @end table
  4583. @section delogo
  4584. Suppress a TV station logo by a simple interpolation of the surrounding
  4585. pixels. Just set a rectangle covering the logo and watch it disappear
  4586. (and sometimes something even uglier appear - your mileage may vary).
  4587. It accepts the following parameters:
  4588. @table @option
  4589. @item x
  4590. @item y
  4591. Specify the top left corner coordinates of the logo. They must be
  4592. specified.
  4593. @item w
  4594. @item h
  4595. Specify the width and height of the logo to clear. They must be
  4596. specified.
  4597. @item band, t
  4598. Specify the thickness of the fuzzy edge of the rectangle (added to
  4599. @var{w} and @var{h}). The default value is 1. This option is
  4600. deprecated, setting higher values should no longer be necessary and
  4601. is not recommended.
  4602. @item show
  4603. When set to 1, a green rectangle is drawn on the screen to simplify
  4604. finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
  4605. The default value is 0.
  4606. The rectangle is drawn on the outermost pixels which will be (partly)
  4607. replaced with interpolated values. The values of the next pixels
  4608. immediately outside this rectangle in each direction will be used to
  4609. compute the interpolated pixel values inside the rectangle.
  4610. @end table
  4611. @subsection Examples
  4612. @itemize
  4613. @item
  4614. Set a rectangle covering the area with top left corner coordinates 0,0
  4615. and size 100x77, and a band of size 10:
  4616. @example
  4617. delogo=x=0:y=0:w=100:h=77:band=10
  4618. @end example
  4619. @end itemize
  4620. @section deshake
  4621. Attempt to fix small changes in horizontal and/or vertical shift. This
  4622. filter helps remove camera shake from hand-holding a camera, bumping a
  4623. tripod, moving on a vehicle, etc.
  4624. The filter accepts the following options:
  4625. @table @option
  4626. @item x
  4627. @item y
  4628. @item w
  4629. @item h
  4630. Specify a rectangular area where to limit the search for motion
  4631. vectors.
  4632. If desired the search for motion vectors can be limited to a
  4633. rectangular area of the frame defined by its top left corner, width
  4634. and height. These parameters have the same meaning as the drawbox
  4635. filter which can be used to visualise the position of the bounding
  4636. box.
  4637. This is useful when simultaneous movement of subjects within the frame
  4638. might be confused for camera motion by the motion vector search.
  4639. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  4640. then the full frame is used. This allows later options to be set
  4641. without specifying the bounding box for the motion vector search.
  4642. Default - search the whole frame.
  4643. @item rx
  4644. @item ry
  4645. Specify the maximum extent of movement in x and y directions in the
  4646. range 0-64 pixels. Default 16.
  4647. @item edge
  4648. Specify how to generate pixels to fill blanks at the edge of the
  4649. frame. Available values are:
  4650. @table @samp
  4651. @item blank, 0
  4652. Fill zeroes at blank locations
  4653. @item original, 1
  4654. Original image at blank locations
  4655. @item clamp, 2
  4656. Extruded edge value at blank locations
  4657. @item mirror, 3
  4658. Mirrored edge at blank locations
  4659. @end table
  4660. Default value is @samp{mirror}.
  4661. @item blocksize
  4662. Specify the blocksize to use for motion search. Range 4-128 pixels,
  4663. default 8.
  4664. @item contrast
  4665. Specify the contrast threshold for blocks. Only blocks with more than
  4666. the specified contrast (difference between darkest and lightest
  4667. pixels) will be considered. Range 1-255, default 125.
  4668. @item search
  4669. Specify the search strategy. Available values are:
  4670. @table @samp
  4671. @item exhaustive, 0
  4672. Set exhaustive search
  4673. @item less, 1
  4674. Set less exhaustive search.
  4675. @end table
  4676. Default value is @samp{exhaustive}.
  4677. @item filename
  4678. If set then a detailed log of the motion search is written to the
  4679. specified file.
  4680. @item opencl
  4681. If set to 1, specify using OpenCL capabilities, only available if
  4682. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  4683. @end table
  4684. @section detelecine
  4685. Apply an exact inverse of the telecine operation. It requires a predefined
  4686. pattern specified using the pattern option which must be the same as that passed
  4687. to the telecine filter.
  4688. This filter accepts the following options:
  4689. @table @option
  4690. @item first_field
  4691. @table @samp
  4692. @item top, t
  4693. top field first
  4694. @item bottom, b
  4695. bottom field first
  4696. The default value is @code{top}.
  4697. @end table
  4698. @item pattern
  4699. A string of numbers representing the pulldown pattern you wish to apply.
  4700. The default value is @code{23}.
  4701. @item start_frame
  4702. A number representing position of the first frame with respect to the telecine
  4703. pattern. This is to be used if the stream is cut. The default value is @code{0}.
  4704. @end table
  4705. @section dilation
  4706. Apply dilation effect to the video.
  4707. This filter replaces the pixel by the local(3x3) maximum.
  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 displace
  4725. Displace pixels as indicated by second and third input stream.
  4726. It takes three input streams and outputs one stream, the first input is the
  4727. source, and second and third input are displacement maps.
  4728. The second input specifies how much to displace pixels along the
  4729. x-axis, while the third input specifies how much to displace pixels
  4730. along the y-axis.
  4731. If one of displacement map streams terminates, last frame from that
  4732. displacement map will be used.
  4733. Note that once generated, displacements maps can be reused over and over again.
  4734. A description of the accepted options follows.
  4735. @table @option
  4736. @item edge
  4737. Set displace behavior for pixels that are out of range.
  4738. Available values are:
  4739. @table @samp
  4740. @item blank
  4741. Missing pixels are replaced by black pixels.
  4742. @item smear
  4743. Adjacent pixels will spread out to replace missing pixels.
  4744. @item wrap
  4745. Out of range pixels are wrapped so they point to pixels of other side.
  4746. @end table
  4747. Default is @samp{smear}.
  4748. @end table
  4749. @subsection Examples
  4750. @itemize
  4751. @item
  4752. Add ripple effect to rgb input of video size hd720:
  4753. @example
  4754. 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
  4755. @end example
  4756. @item
  4757. Add wave effect to rgb input of video size hd720:
  4758. @example
  4759. 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
  4760. @end example
  4761. @end itemize
  4762. @section drawbox
  4763. Draw a colored box on the input image.
  4764. It accepts the following parameters:
  4765. @table @option
  4766. @item x
  4767. @item y
  4768. The expressions which specify the top left corner coordinates of the box. It defaults to 0.
  4769. @item width, w
  4770. @item height, h
  4771. The expressions which specify the width and height of the box; if 0 they are interpreted as
  4772. the input width and height. It defaults to 0.
  4773. @item color, c
  4774. Specify the color of the box to write. For the general syntax of this option,
  4775. check the "Color" section in the ffmpeg-utils manual. If the special
  4776. value @code{invert} is used, the box edge color is the same as the
  4777. video with inverted luma.
  4778. @item thickness, t
  4779. The expression which sets the thickness of the box edge. Default value is @code{3}.
  4780. See below for the list of accepted constants.
  4781. @end table
  4782. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  4783. following constants:
  4784. @table @option
  4785. @item dar
  4786. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  4787. @item hsub
  4788. @item vsub
  4789. horizontal and vertical chroma subsample values. For example for the
  4790. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4791. @item in_h, ih
  4792. @item in_w, iw
  4793. The input width and height.
  4794. @item sar
  4795. The input sample aspect ratio.
  4796. @item x
  4797. @item y
  4798. The x and y offset coordinates where the box is drawn.
  4799. @item w
  4800. @item h
  4801. The width and height of the drawn box.
  4802. @item t
  4803. The thickness of the drawn box.
  4804. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  4805. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  4806. @end table
  4807. @subsection Examples
  4808. @itemize
  4809. @item
  4810. Draw a black box around the edge of the input image:
  4811. @example
  4812. drawbox
  4813. @end example
  4814. @item
  4815. Draw a box with color red and an opacity of 50%:
  4816. @example
  4817. drawbox=10:20:200:60:red@@0.5
  4818. @end example
  4819. The previous example can be specified as:
  4820. @example
  4821. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  4822. @end example
  4823. @item
  4824. Fill the box with pink color:
  4825. @example
  4826. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  4827. @end example
  4828. @item
  4829. Draw a 2-pixel red 2.40:1 mask:
  4830. @example
  4831. 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
  4832. @end example
  4833. @end itemize
  4834. @section drawgraph, adrawgraph
  4835. Draw a graph using input video or audio metadata.
  4836. It accepts the following parameters:
  4837. @table @option
  4838. @item m1
  4839. Set 1st frame metadata key from which metadata values will be used to draw a graph.
  4840. @item fg1
  4841. Set 1st foreground color expression.
  4842. @item m2
  4843. Set 2nd frame metadata key from which metadata values will be used to draw a graph.
  4844. @item fg2
  4845. Set 2nd foreground color expression.
  4846. @item m3
  4847. Set 3rd frame metadata key from which metadata values will be used to draw a graph.
  4848. @item fg3
  4849. Set 3rd foreground color expression.
  4850. @item m4
  4851. Set 4th frame metadata key from which metadata values will be used to draw a graph.
  4852. @item fg4
  4853. Set 4th foreground color expression.
  4854. @item min
  4855. Set minimal value of metadata value.
  4856. @item max
  4857. Set maximal value of metadata value.
  4858. @item bg
  4859. Set graph background color. Default is white.
  4860. @item mode
  4861. Set graph mode.
  4862. Available values for mode is:
  4863. @table @samp
  4864. @item bar
  4865. @item dot
  4866. @item line
  4867. @end table
  4868. Default is @code{line}.
  4869. @item slide
  4870. Set slide mode.
  4871. Available values for slide is:
  4872. @table @samp
  4873. @item frame
  4874. Draw new frame when right border is reached.
  4875. @item replace
  4876. Replace old columns with new ones.
  4877. @item scroll
  4878. Scroll from right to left.
  4879. @item rscroll
  4880. Scroll from left to right.
  4881. @end table
  4882. Default is @code{frame}.
  4883. @item size
  4884. Set size of graph video. For the syntax of this option, check the
  4885. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  4886. The default value is @code{900x256}.
  4887. The foreground color expressions can use the following variables:
  4888. @table @option
  4889. @item MIN
  4890. Minimal value of metadata value.
  4891. @item MAX
  4892. Maximal value of metadata value.
  4893. @item VAL
  4894. Current metadata key value.
  4895. @end table
  4896. The color is defined as 0xAABBGGRR.
  4897. @end table
  4898. Example using metadata from @ref{signalstats} filter:
  4899. @example
  4900. signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255
  4901. @end example
  4902. Example using metadata from @ref{ebur128} filter:
  4903. @example
  4904. ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5
  4905. @end example
  4906. @section drawgrid
  4907. Draw a grid on the input image.
  4908. It accepts the following parameters:
  4909. @table @option
  4910. @item x
  4911. @item y
  4912. The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
  4913. @item width, w
  4914. @item height, h
  4915. The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
  4916. input width and height, respectively, minus @code{thickness}, so image gets
  4917. framed. Default to 0.
  4918. @item color, c
  4919. Specify the color of the grid. For the general syntax of this option,
  4920. check the "Color" section in the ffmpeg-utils manual. If the special
  4921. value @code{invert} is used, the grid color is the same as the
  4922. video with inverted luma.
  4923. @item thickness, t
  4924. The expression which sets the thickness of the grid line. Default value is @code{1}.
  4925. See below for the list of accepted constants.
  4926. @end table
  4927. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  4928. following constants:
  4929. @table @option
  4930. @item dar
  4931. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  4932. @item hsub
  4933. @item vsub
  4934. horizontal and vertical chroma subsample values. For example for the
  4935. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4936. @item in_h, ih
  4937. @item in_w, iw
  4938. The input grid cell width and height.
  4939. @item sar
  4940. The input sample aspect ratio.
  4941. @item x
  4942. @item y
  4943. The x and y coordinates of some point of grid intersection (meant to configure offset).
  4944. @item w
  4945. @item h
  4946. The width and height of the drawn cell.
  4947. @item t
  4948. The thickness of the drawn cell.
  4949. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  4950. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  4951. @end table
  4952. @subsection Examples
  4953. @itemize
  4954. @item
  4955. Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
  4956. @example
  4957. drawgrid=width=100:height=100:thickness=2:color=red@@0.5
  4958. @end example
  4959. @item
  4960. Draw a white 3x3 grid with an opacity of 50%:
  4961. @example
  4962. drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
  4963. @end example
  4964. @end itemize
  4965. @anchor{drawtext}
  4966. @section drawtext
  4967. Draw a text string or text from a specified file on top of a video, using the
  4968. libfreetype library.
  4969. To enable compilation of this filter, you need to configure FFmpeg with
  4970. @code{--enable-libfreetype}.
  4971. To enable default font fallback and the @var{font} option you need to
  4972. configure FFmpeg with @code{--enable-libfontconfig}.
  4973. To enable the @var{text_shaping} option, you need to configure FFmpeg with
  4974. @code{--enable-libfribidi}.
  4975. @subsection Syntax
  4976. It accepts the following parameters:
  4977. @table @option
  4978. @item box
  4979. Used to draw a box around text using the background color.
  4980. The value must be either 1 (enable) or 0 (disable).
  4981. The default value of @var{box} is 0.
  4982. @item boxborderw
  4983. Set the width of the border to be drawn around the box using @var{boxcolor}.
  4984. The default value of @var{boxborderw} is 0.
  4985. @item boxcolor
  4986. The color to be used for drawing box around text. For the syntax of this
  4987. option, check the "Color" section in the ffmpeg-utils manual.
  4988. The default value of @var{boxcolor} is "white".
  4989. @item borderw
  4990. Set the width of the border to be drawn around the text using @var{bordercolor}.
  4991. The default value of @var{borderw} is 0.
  4992. @item bordercolor
  4993. Set the color to be used for drawing border around text. For the syntax of this
  4994. option, check the "Color" section in the ffmpeg-utils manual.
  4995. The default value of @var{bordercolor} is "black".
  4996. @item expansion
  4997. Select how the @var{text} is expanded. Can be either @code{none},
  4998. @code{strftime} (deprecated) or
  4999. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  5000. below for details.
  5001. @item fix_bounds
  5002. If true, check and fix text coords to avoid clipping.
  5003. @item fontcolor
  5004. The color to be used for drawing fonts. For the syntax of this option, check
  5005. the "Color" section in the ffmpeg-utils manual.
  5006. The default value of @var{fontcolor} is "black".
  5007. @item fontcolor_expr
  5008. String which is expanded the same way as @var{text} to obtain dynamic
  5009. @var{fontcolor} value. By default this option has empty value and is not
  5010. processed. When this option is set, it overrides @var{fontcolor} option.
  5011. @item font
  5012. The font family to be used for drawing text. By default Sans.
  5013. @item fontfile
  5014. The font file to be used for drawing text. The path must be included.
  5015. This parameter is mandatory if the fontconfig support is disabled.
  5016. @item draw
  5017. This option does not exist, please see the timeline system
  5018. @item alpha
  5019. Draw the text applying alpha blending. The value can
  5020. be either a number between 0.0 and 1.0
  5021. The expression accepts the same variables @var{x, y} do.
  5022. The default value is 1.
  5023. Please see fontcolor_expr
  5024. @item fontsize
  5025. The font size to be used for drawing text.
  5026. The default value of @var{fontsize} is 16.
  5027. @item text_shaping
  5028. If set to 1, attempt to shape the text (for example, reverse the order of
  5029. right-to-left text and join Arabic characters) before drawing it.
  5030. Otherwise, just draw the text exactly as given.
  5031. By default 1 (if supported).
  5032. @item ft_load_flags
  5033. The flags to be used for loading the fonts.
  5034. The flags map the corresponding flags supported by libfreetype, and are
  5035. a combination of the following values:
  5036. @table @var
  5037. @item default
  5038. @item no_scale
  5039. @item no_hinting
  5040. @item render
  5041. @item no_bitmap
  5042. @item vertical_layout
  5043. @item force_autohint
  5044. @item crop_bitmap
  5045. @item pedantic
  5046. @item ignore_global_advance_width
  5047. @item no_recurse
  5048. @item ignore_transform
  5049. @item monochrome
  5050. @item linear_design
  5051. @item no_autohint
  5052. @end table
  5053. Default value is "default".
  5054. For more information consult the documentation for the FT_LOAD_*
  5055. libfreetype flags.
  5056. @item shadowcolor
  5057. The color to be used for drawing a shadow behind the drawn text. For the
  5058. syntax of this option, check the "Color" section in the ffmpeg-utils manual.
  5059. The default value of @var{shadowcolor} is "black".
  5060. @item shadowx
  5061. @item shadowy
  5062. The x and y offsets for the text shadow position with respect to the
  5063. position of the text. They can be either positive or negative
  5064. values. The default value for both is "0".
  5065. @item start_number
  5066. The starting frame number for the n/frame_num variable. The default value
  5067. is "0".
  5068. @item tabsize
  5069. The size in number of spaces to use for rendering the tab.
  5070. Default value is 4.
  5071. @item timecode
  5072. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  5073. format. It can be used with or without text parameter. @var{timecode_rate}
  5074. option must be specified.
  5075. @item timecode_rate, rate, r
  5076. Set the timecode frame rate (timecode only).
  5077. @item text
  5078. The text string to be drawn. The text must be a sequence of UTF-8
  5079. encoded characters.
  5080. This parameter is mandatory if no file is specified with the parameter
  5081. @var{textfile}.
  5082. @item textfile
  5083. A text file containing text to be drawn. The text must be a sequence
  5084. of UTF-8 encoded characters.
  5085. This parameter is mandatory if no text string is specified with the
  5086. parameter @var{text}.
  5087. If both @var{text} and @var{textfile} are specified, an error is thrown.
  5088. @item reload
  5089. If set to 1, the @var{textfile} will be reloaded before each frame.
  5090. Be sure to update it atomically, or it may be read partially, or even fail.
  5091. @item x
  5092. @item y
  5093. The expressions which specify the offsets where text will be drawn
  5094. within the video frame. They are relative to the top/left border of the
  5095. output image.
  5096. The default value of @var{x} and @var{y} is "0".
  5097. See below for the list of accepted constants and functions.
  5098. @end table
  5099. The parameters for @var{x} and @var{y} are expressions containing the
  5100. following constants and functions:
  5101. @table @option
  5102. @item dar
  5103. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  5104. @item hsub
  5105. @item vsub
  5106. horizontal and vertical chroma subsample values. For example for the
  5107. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  5108. @item line_h, lh
  5109. the height of each text line
  5110. @item main_h, h, H
  5111. the input height
  5112. @item main_w, w, W
  5113. the input width
  5114. @item max_glyph_a, ascent
  5115. the maximum distance from the baseline to the highest/upper grid
  5116. coordinate used to place a glyph outline point, for all the rendered
  5117. glyphs.
  5118. It is a positive value, due to the grid's orientation with the Y axis
  5119. upwards.
  5120. @item max_glyph_d, descent
  5121. the maximum distance from the baseline to the lowest grid coordinate
  5122. used to place a glyph outline point, for all the rendered glyphs.
  5123. This is a negative value, due to the grid's orientation, with the Y axis
  5124. upwards.
  5125. @item max_glyph_h
  5126. maximum glyph height, that is the maximum height for all the glyphs
  5127. contained in the rendered text, it is equivalent to @var{ascent} -
  5128. @var{descent}.
  5129. @item max_glyph_w
  5130. maximum glyph width, that is the maximum width for all the glyphs
  5131. contained in the rendered text
  5132. @item n
  5133. the number of input frame, starting from 0
  5134. @item rand(min, max)
  5135. return a random number included between @var{min} and @var{max}
  5136. @item sar
  5137. The input sample aspect ratio.
  5138. @item t
  5139. timestamp expressed in seconds, NAN if the input timestamp is unknown
  5140. @item text_h, th
  5141. the height of the rendered text
  5142. @item text_w, tw
  5143. the width of the rendered text
  5144. @item x
  5145. @item y
  5146. the x and y offset coordinates where the text is drawn.
  5147. These parameters allow the @var{x} and @var{y} expressions to refer
  5148. each other, so you can for example specify @code{y=x/dar}.
  5149. @end table
  5150. @anchor{drawtext_expansion}
  5151. @subsection Text expansion
  5152. If @option{expansion} is set to @code{strftime},
  5153. the filter recognizes strftime() sequences in the provided text and
  5154. expands them accordingly. Check the documentation of strftime(). This
  5155. feature is deprecated.
  5156. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  5157. If @option{expansion} is set to @code{normal} (which is the default),
  5158. the following expansion mechanism is used.
  5159. The backslash character @samp{\}, followed by any character, always expands to
  5160. the second character.
  5161. Sequence of the form @code{%@{...@}} are expanded. The text between the
  5162. braces is a function name, possibly followed by arguments separated by ':'.
  5163. If the arguments contain special characters or delimiters (':' or '@}'),
  5164. they should be escaped.
  5165. Note that they probably must also be escaped as the value for the
  5166. @option{text} option in the filter argument string and as the filter
  5167. argument in the filtergraph description, and possibly also for the shell,
  5168. that makes up to four levels of escaping; using a text file avoids these
  5169. problems.
  5170. The following functions are available:
  5171. @table @command
  5172. @item expr, e
  5173. The expression evaluation result.
  5174. It must take one argument specifying the expression to be evaluated,
  5175. which accepts the same constants and functions as the @var{x} and
  5176. @var{y} values. Note that not all constants should be used, for
  5177. example the text size is not known when evaluating the expression, so
  5178. the constants @var{text_w} and @var{text_h} will have an undefined
  5179. value.
  5180. @item expr_int_format, eif
  5181. Evaluate the expression's value and output as formatted integer.
  5182. The first argument is the expression to be evaluated, just as for the @var{expr} function.
  5183. The second argument specifies the output format. Allowed values are @samp{x},
  5184. @samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
  5185. @code{printf} function.
  5186. The third parameter is optional and sets the number of positions taken by the output.
  5187. It can be used to add padding with zeros from the left.
  5188. @item gmtime
  5189. The time at which the filter is running, expressed in UTC.
  5190. It can accept an argument: a strftime() format string.
  5191. @item localtime
  5192. The time at which the filter is running, expressed in the local time zone.
  5193. It can accept an argument: a strftime() format string.
  5194. @item metadata
  5195. Frame metadata. Takes one or two arguments.
  5196. The first argument is mandatory and specifies the metadata key.
  5197. The second argument is optional and specifies a default value, used when the
  5198. metadata key is not found or empty.
  5199. @item n, frame_num
  5200. The frame number, starting from 0.
  5201. @item pict_type
  5202. A 1 character description of the current picture type.
  5203. @item pts
  5204. The timestamp of the current frame.
  5205. It can take up to three arguments.
  5206. The first argument is the format of the timestamp; it defaults to @code{flt}
  5207. for seconds as a decimal number with microsecond accuracy; @code{hms} stands
  5208. for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
  5209. @code{gmtime} stands for the timestamp of the frame formatted as UTC time;
  5210. @code{localtime} stands for the timestamp of the frame formatted as
  5211. local time zone time.
  5212. The second argument is an offset added to the timestamp.
  5213. If the format is set to @code{localtime} or @code{gmtime},
  5214. a third argument may be supplied: a strftime() format string.
  5215. By default, @var{YYYY-MM-DD HH:MM:SS} format will be used.
  5216. @end table
  5217. @subsection Examples
  5218. @itemize
  5219. @item
  5220. Draw "Test Text" with font FreeSerif, using the default values for the
  5221. optional parameters.
  5222. @example
  5223. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  5224. @end example
  5225. @item
  5226. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  5227. and y=50 (counting from the top-left corner of the screen), text is
  5228. yellow with a red box around it. Both the text and the box have an
  5229. opacity of 20%.
  5230. @example
  5231. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  5232. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  5233. @end example
  5234. Note that the double quotes are not necessary if spaces are not used
  5235. within the parameter list.
  5236. @item
  5237. Show the text at the center of the video frame:
  5238. @example
  5239. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2"
  5240. @end example
  5241. @item
  5242. Show the text at a random position, switching to a new position every 30 seconds:
  5243. @example
  5244. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=if(eq(mod(t\,30)\,0)\,rand(0\,(w-text_w))\,x):y=if(eq(mod(t\,30)\,0)\,rand(0\,(h-text_h))\,y)"
  5245. @end example
  5246. @item
  5247. Show a text line sliding from right to left in the last row of the video
  5248. frame. The file @file{LONG_LINE} is assumed to contain a single line
  5249. with no newlines.
  5250. @example
  5251. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  5252. @end example
  5253. @item
  5254. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  5255. @example
  5256. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  5257. @end example
  5258. @item
  5259. Draw a single green letter "g", at the center of the input video.
  5260. The glyph baseline is placed at half screen height.
  5261. @example
  5262. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  5263. @end example
  5264. @item
  5265. Show text for 1 second every 3 seconds:
  5266. @example
  5267. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  5268. @end example
  5269. @item
  5270. Use fontconfig to set the font. Note that the colons need to be escaped.
  5271. @example
  5272. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  5273. @end example
  5274. @item
  5275. Print the date of a real-time encoding (see strftime(3)):
  5276. @example
  5277. drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
  5278. @end example
  5279. @item
  5280. Show text fading in and out (appearing/disappearing):
  5281. @example
  5282. #!/bin/sh
  5283. DS=1.0 # display start
  5284. DE=10.0 # display end
  5285. FID=1.5 # fade in duration
  5286. FOD=5 # fade out duration
  5287. 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 @}"
  5288. @end example
  5289. @end itemize
  5290. For more information about libfreetype, check:
  5291. @url{http://www.freetype.org/}.
  5292. For more information about fontconfig, check:
  5293. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  5294. For more information about libfribidi, check:
  5295. @url{http://fribidi.org/}.
  5296. @section edgedetect
  5297. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  5298. The filter accepts the following options:
  5299. @table @option
  5300. @item low
  5301. @item high
  5302. Set low and high threshold values used by the Canny thresholding
  5303. algorithm.
  5304. The high threshold selects the "strong" edge pixels, which are then
  5305. connected through 8-connectivity with the "weak" edge pixels selected
  5306. by the low threshold.
  5307. @var{low} and @var{high} threshold values must be chosen in the range
  5308. [0,1], and @var{low} should be lesser or equal to @var{high}.
  5309. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  5310. is @code{50/255}.
  5311. @item mode
  5312. Define the drawing mode.
  5313. @table @samp
  5314. @item wires
  5315. Draw white/gray wires on black background.
  5316. @item colormix
  5317. Mix the colors to create a paint/cartoon effect.
  5318. @end table
  5319. Default value is @var{wires}.
  5320. @end table
  5321. @subsection Examples
  5322. @itemize
  5323. @item
  5324. Standard edge detection with custom values for the hysteresis thresholding:
  5325. @example
  5326. edgedetect=low=0.1:high=0.4
  5327. @end example
  5328. @item
  5329. Painting effect without thresholding:
  5330. @example
  5331. edgedetect=mode=colormix:high=0
  5332. @end example
  5333. @end itemize
  5334. @section eq
  5335. Set brightness, contrast, saturation and approximate gamma adjustment.
  5336. The filter accepts the following options:
  5337. @table @option
  5338. @item contrast
  5339. Set the contrast expression. The value must be a float value in range
  5340. @code{-2.0} to @code{2.0}. The default value is "1".
  5341. @item brightness
  5342. Set the brightness expression. The value must be a float value in
  5343. range @code{-1.0} to @code{1.0}. The default value is "0".
  5344. @item saturation
  5345. Set the saturation expression. The value must be a float in
  5346. range @code{0.0} to @code{3.0}. The default value is "1".
  5347. @item gamma
  5348. Set the gamma expression. The value must be a float in range
  5349. @code{0.1} to @code{10.0}. The default value is "1".
  5350. @item gamma_r
  5351. Set the gamma expression for red. The value must be a float in
  5352. range @code{0.1} to @code{10.0}. The default value is "1".
  5353. @item gamma_g
  5354. Set the gamma expression for green. The value must be a float in range
  5355. @code{0.1} to @code{10.0}. The default value is "1".
  5356. @item gamma_b
  5357. Set the gamma expression for blue. The value must be a float in range
  5358. @code{0.1} to @code{10.0}. The default value is "1".
  5359. @item gamma_weight
  5360. Set the gamma weight expression. It can be used to reduce the effect
  5361. of a high gamma value on bright image areas, e.g. keep them from
  5362. getting overamplified and just plain white. The value must be a float
  5363. in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
  5364. gamma correction all the way down while @code{1.0} leaves it at its
  5365. full strength. Default is "1".
  5366. @item eval
  5367. Set when the expressions for brightness, contrast, saturation and
  5368. gamma expressions are evaluated.
  5369. It accepts the following values:
  5370. @table @samp
  5371. @item init
  5372. only evaluate expressions once during the filter initialization or
  5373. when a command is processed
  5374. @item frame
  5375. evaluate expressions for each incoming frame
  5376. @end table
  5377. Default value is @samp{init}.
  5378. @end table
  5379. The expressions accept the following parameters:
  5380. @table @option
  5381. @item n
  5382. frame count of the input frame starting from 0
  5383. @item pos
  5384. byte position of the corresponding packet in the input file, NAN if
  5385. unspecified
  5386. @item r
  5387. frame rate of the input video, NAN if the input frame rate is unknown
  5388. @item t
  5389. timestamp expressed in seconds, NAN if the input timestamp is unknown
  5390. @end table
  5391. @subsection Commands
  5392. The filter supports the following commands:
  5393. @table @option
  5394. @item contrast
  5395. Set the contrast expression.
  5396. @item brightness
  5397. Set the brightness expression.
  5398. @item saturation
  5399. Set the saturation expression.
  5400. @item gamma
  5401. Set the gamma expression.
  5402. @item gamma_r
  5403. Set the gamma_r expression.
  5404. @item gamma_g
  5405. Set gamma_g expression.
  5406. @item gamma_b
  5407. Set gamma_b expression.
  5408. @item gamma_weight
  5409. Set gamma_weight expression.
  5410. The command accepts the same syntax of the corresponding option.
  5411. If the specified expression is not valid, it is kept at its current
  5412. value.
  5413. @end table
  5414. @section erosion
  5415. Apply erosion effect to the video.
  5416. This filter replaces the pixel by the local(3x3) minimum.
  5417. It accepts the following options:
  5418. @table @option
  5419. @item threshold0
  5420. @item threshold1
  5421. @item threshold2
  5422. @item threshold3
  5423. Limit the maximum change for each plane, default is 65535.
  5424. If 0, plane will remain unchanged.
  5425. @item coordinates
  5426. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  5427. pixels are used.
  5428. Flags to local 3x3 coordinates maps like this:
  5429. 1 2 3
  5430. 4 5
  5431. 6 7 8
  5432. @end table
  5433. @section extractplanes
  5434. Extract color channel components from input video stream into
  5435. separate grayscale video streams.
  5436. The filter accepts the following option:
  5437. @table @option
  5438. @item planes
  5439. Set plane(s) to extract.
  5440. Available values for planes are:
  5441. @table @samp
  5442. @item y
  5443. @item u
  5444. @item v
  5445. @item a
  5446. @item r
  5447. @item g
  5448. @item b
  5449. @end table
  5450. Choosing planes not available in the input will result in an error.
  5451. That means you cannot select @code{r}, @code{g}, @code{b} planes
  5452. with @code{y}, @code{u}, @code{v} planes at same time.
  5453. @end table
  5454. @subsection Examples
  5455. @itemize
  5456. @item
  5457. Extract luma, u and v color channel component from input video frame
  5458. into 3 grayscale outputs:
  5459. @example
  5460. 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
  5461. @end example
  5462. @end itemize
  5463. @section elbg
  5464. Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
  5465. For each input image, the filter will compute the optimal mapping from
  5466. the input to the output given the codebook length, that is the number
  5467. of distinct output colors.
  5468. This filter accepts the following options.
  5469. @table @option
  5470. @item codebook_length, l
  5471. Set codebook length. The value must be a positive integer, and
  5472. represents the number of distinct output colors. Default value is 256.
  5473. @item nb_steps, n
  5474. Set the maximum number of iterations to apply for computing the optimal
  5475. mapping. The higher the value the better the result and the higher the
  5476. computation time. Default value is 1.
  5477. @item seed, s
  5478. Set a random seed, must be an integer included between 0 and
  5479. UINT32_MAX. If not specified, or if explicitly set to -1, the filter
  5480. will try to use a good random seed on a best effort basis.
  5481. @item pal8
  5482. Set pal8 output pixel format. This option does not work with codebook
  5483. length greater than 256.
  5484. @end table
  5485. @section fade
  5486. Apply a fade-in/out effect to the input video.
  5487. It accepts the following parameters:
  5488. @table @option
  5489. @item type, t
  5490. The effect type can be either "in" for a fade-in, or "out" for a fade-out
  5491. effect.
  5492. Default is @code{in}.
  5493. @item start_frame, s
  5494. Specify the number of the frame to start applying the fade
  5495. effect at. Default is 0.
  5496. @item nb_frames, n
  5497. The number of frames that the fade effect lasts. At the end of the
  5498. fade-in effect, the output video will have the same intensity as the input video.
  5499. At the end of the fade-out transition, the output video will be filled with the
  5500. selected @option{color}.
  5501. Default is 25.
  5502. @item alpha
  5503. If set to 1, fade only alpha channel, if one exists on the input.
  5504. Default value is 0.
  5505. @item start_time, st
  5506. Specify the timestamp (in seconds) of the frame to start to apply the fade
  5507. effect. If both start_frame and start_time are specified, the fade will start at
  5508. whichever comes last. Default is 0.
  5509. @item duration, d
  5510. The number of seconds for which the fade effect has to last. At the end of the
  5511. fade-in effect the output video will have the same intensity as the input video,
  5512. at the end of the fade-out transition the output video will be filled with the
  5513. selected @option{color}.
  5514. If both duration and nb_frames are specified, duration is used. Default is 0
  5515. (nb_frames is used by default).
  5516. @item color, c
  5517. Specify the color of the fade. Default is "black".
  5518. @end table
  5519. @subsection Examples
  5520. @itemize
  5521. @item
  5522. Fade in the first 30 frames of video:
  5523. @example
  5524. fade=in:0:30
  5525. @end example
  5526. The command above is equivalent to:
  5527. @example
  5528. fade=t=in:s=0:n=30
  5529. @end example
  5530. @item
  5531. Fade out the last 45 frames of a 200-frame video:
  5532. @example
  5533. fade=out:155:45
  5534. fade=type=out:start_frame=155:nb_frames=45
  5535. @end example
  5536. @item
  5537. Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
  5538. @example
  5539. fade=in:0:25, fade=out:975:25
  5540. @end example
  5541. @item
  5542. Make the first 5 frames yellow, then fade in from frame 5-24:
  5543. @example
  5544. fade=in:5:20:color=yellow
  5545. @end example
  5546. @item
  5547. Fade in alpha over first 25 frames of video:
  5548. @example
  5549. fade=in:0:25:alpha=1
  5550. @end example
  5551. @item
  5552. Make the first 5.5 seconds black, then fade in for 0.5 seconds:
  5553. @example
  5554. fade=t=in:st=5.5:d=0.5
  5555. @end example
  5556. @end itemize
  5557. @section fftfilt
  5558. Apply arbitrary expressions to samples in frequency domain
  5559. @table @option
  5560. @item dc_Y
  5561. Adjust the dc value (gain) of the luma plane of the image. The filter
  5562. accepts an integer value in range @code{0} to @code{1000}. The default
  5563. value is set to @code{0}.
  5564. @item dc_U
  5565. Adjust the dc value (gain) of the 1st chroma plane of the image. The
  5566. filter accepts an integer value in range @code{0} to @code{1000}. The
  5567. default value is set to @code{0}.
  5568. @item dc_V
  5569. Adjust the dc value (gain) of the 2nd chroma plane of the image. The
  5570. filter accepts an integer value in range @code{0} to @code{1000}. The
  5571. default value is set to @code{0}.
  5572. @item weight_Y
  5573. Set the frequency domain weight expression for the luma plane.
  5574. @item weight_U
  5575. Set the frequency domain weight expression for the 1st chroma plane.
  5576. @item weight_V
  5577. Set the frequency domain weight expression for the 2nd chroma plane.
  5578. The filter accepts the following variables:
  5579. @item X
  5580. @item Y
  5581. The coordinates of the current sample.
  5582. @item W
  5583. @item H
  5584. The width and height of the image.
  5585. @end table
  5586. @subsection Examples
  5587. @itemize
  5588. @item
  5589. High-pass:
  5590. @example
  5591. fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
  5592. @end example
  5593. @item
  5594. Low-pass:
  5595. @example
  5596. fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
  5597. @end example
  5598. @item
  5599. Sharpen:
  5600. @example
  5601. fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
  5602. @end example
  5603. @item
  5604. Blur:
  5605. @example
  5606. fftfilt=dc_Y=0:weight_Y='exp(-4 * ((Y+X)/(W+H)))'
  5607. @end example
  5608. @end itemize
  5609. @section field
  5610. Extract a single field from an interlaced image using stride
  5611. arithmetic to avoid wasting CPU time. The output frames are marked as
  5612. non-interlaced.
  5613. The filter accepts the following options:
  5614. @table @option
  5615. @item type
  5616. Specify whether to extract the top (if the value is @code{0} or
  5617. @code{top}) or the bottom field (if the value is @code{1} or
  5618. @code{bottom}).
  5619. @end table
  5620. @section fieldhint
  5621. Create new frames by copying the top and bottom fields from surrounding frames
  5622. supplied as numbers by the hint file.
  5623. @table @option
  5624. @item hint
  5625. Set file containing hints: absolute/relative frame numbers.
  5626. There must be one line for each frame in a clip. Each line must contain two
  5627. numbers separated by the comma, optionally followed by @code{-} or @code{+}.
  5628. Numbers supplied on each line of file can not be out of [N-1,N+1] where N
  5629. is current frame number for @code{absolute} mode or out of [-1, 1] range
  5630. for @code{relative} mode. First number tells from which frame to pick up top
  5631. field and second number tells from which frame to pick up bottom field.
  5632. If optionally followed by @code{+} output frame will be marked as interlaced,
  5633. else if followed by @code{-} output frame will be marked as progressive, else
  5634. it will be marked same as input frame.
  5635. If line starts with @code{#} or @code{;} that line is skipped.
  5636. @item mode
  5637. Can be item @code{absolute} or @code{relative}. Default is @code{absolute}.
  5638. @end table
  5639. Example of first several lines of @code{hint} file for @code{relative} mode:
  5640. @example
  5641. 0,0 - # first frame
  5642. 1,0 - # second frame, use third's frame top field and second's frame bottom field
  5643. 1,0 - # third frame, use fourth's frame top field and third's frame bottom field
  5644. 1,0 -
  5645. 0,0 -
  5646. 0,0 -
  5647. 1,0 -
  5648. 1,0 -
  5649. 1,0 -
  5650. 0,0 -
  5651. 0,0 -
  5652. 1,0 -
  5653. 1,0 -
  5654. 1,0 -
  5655. 0,0 -
  5656. @end example
  5657. @section fieldmatch
  5658. Field matching filter for inverse telecine. It is meant to reconstruct the
  5659. progressive frames from a telecined stream. The filter does not drop duplicated
  5660. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  5661. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  5662. The separation of the field matching and the decimation is notably motivated by
  5663. the possibility of inserting a de-interlacing filter fallback between the two.
  5664. If the source has mixed telecined and real interlaced content,
  5665. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  5666. But these remaining combed frames will be marked as interlaced, and thus can be
  5667. de-interlaced by a later filter such as @ref{yadif} before decimation.
  5668. In addition to the various configuration options, @code{fieldmatch} can take an
  5669. optional second stream, activated through the @option{ppsrc} option. If
  5670. enabled, the frames reconstruction will be based on the fields and frames from
  5671. this second stream. This allows the first input to be pre-processed in order to
  5672. help the various algorithms of the filter, while keeping the output lossless
  5673. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  5674. or brightness/contrast adjustments can help.
  5675. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  5676. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  5677. which @code{fieldmatch} is based on. While the semantic and usage are very
  5678. close, some behaviour and options names can differ.
  5679. The @ref{decimate} filter currently only works for constant frame rate input.
  5680. If your input has mixed telecined (30fps) and progressive content with a lower
  5681. framerate like 24fps use the following filterchain to produce the necessary cfr
  5682. stream: @code{dejudder,fps=30000/1001,fieldmatch,decimate}.
  5683. The filter accepts the following options:
  5684. @table @option
  5685. @item order
  5686. Specify the assumed field order of the input stream. Available values are:
  5687. @table @samp
  5688. @item auto
  5689. Auto detect parity (use FFmpeg's internal parity value).
  5690. @item bff
  5691. Assume bottom field first.
  5692. @item tff
  5693. Assume top field first.
  5694. @end table
  5695. Note that it is sometimes recommended not to trust the parity announced by the
  5696. stream.
  5697. Default value is @var{auto}.
  5698. @item mode
  5699. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  5700. sense that it won't risk creating jerkiness due to duplicate frames when
  5701. possible, but if there are bad edits or blended fields it will end up
  5702. outputting combed frames when a good match might actually exist. On the other
  5703. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  5704. but will almost always find a good frame if there is one. The other values are
  5705. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  5706. jerkiness and creating duplicate frames versus finding good matches in sections
  5707. with bad edits, orphaned fields, blended fields, etc.
  5708. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  5709. Available values are:
  5710. @table @samp
  5711. @item pc
  5712. 2-way matching (p/c)
  5713. @item pc_n
  5714. 2-way matching, and trying 3rd match if still combed (p/c + n)
  5715. @item pc_u
  5716. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  5717. @item pc_n_ub
  5718. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  5719. still combed (p/c + n + u/b)
  5720. @item pcn
  5721. 3-way matching (p/c/n)
  5722. @item pcn_ub
  5723. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  5724. detected as combed (p/c/n + u/b)
  5725. @end table
  5726. The parenthesis at the end indicate the matches that would be used for that
  5727. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  5728. @var{top}).
  5729. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  5730. the slowest.
  5731. Default value is @var{pc_n}.
  5732. @item ppsrc
  5733. Mark the main input stream as a pre-processed input, and enable the secondary
  5734. input stream as the clean source to pick the fields from. See the filter
  5735. introduction for more details. It is similar to the @option{clip2} feature from
  5736. VFM/TFM.
  5737. Default value is @code{0} (disabled).
  5738. @item field
  5739. Set the field to match from. It is recommended to set this to the same value as
  5740. @option{order} unless you experience matching failures with that setting. In
  5741. certain circumstances changing the field that is used to match from can have a
  5742. large impact on matching performance. Available values are:
  5743. @table @samp
  5744. @item auto
  5745. Automatic (same value as @option{order}).
  5746. @item bottom
  5747. Match from the bottom field.
  5748. @item top
  5749. Match from the top field.
  5750. @end table
  5751. Default value is @var{auto}.
  5752. @item mchroma
  5753. Set whether or not chroma is included during the match comparisons. In most
  5754. cases it is recommended to leave this enabled. You should set this to @code{0}
  5755. only if your clip has bad chroma problems such as heavy rainbowing or other
  5756. artifacts. Setting this to @code{0} could also be used to speed things up at
  5757. the cost of some accuracy.
  5758. Default value is @code{1}.
  5759. @item y0
  5760. @item y1
  5761. These define an exclusion band which excludes the lines between @option{y0} and
  5762. @option{y1} from being included in the field matching decision. An exclusion
  5763. band can be used to ignore subtitles, a logo, or other things that may
  5764. interfere with the matching. @option{y0} sets the starting scan line and
  5765. @option{y1} sets the ending line; all lines in between @option{y0} and
  5766. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  5767. @option{y0} and @option{y1} to the same value will disable the feature.
  5768. @option{y0} and @option{y1} defaults to @code{0}.
  5769. @item scthresh
  5770. Set the scene change detection threshold as a percentage of maximum change on
  5771. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  5772. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  5773. @option{scthresh} is @code{[0.0, 100.0]}.
  5774. Default value is @code{12.0}.
  5775. @item combmatch
  5776. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  5777. account the combed scores of matches when deciding what match to use as the
  5778. final match. Available values are:
  5779. @table @samp
  5780. @item none
  5781. No final matching based on combed scores.
  5782. @item sc
  5783. Combed scores are only used when a scene change is detected.
  5784. @item full
  5785. Use combed scores all the time.
  5786. @end table
  5787. Default is @var{sc}.
  5788. @item combdbg
  5789. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  5790. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  5791. Available values are:
  5792. @table @samp
  5793. @item none
  5794. No forced calculation.
  5795. @item pcn
  5796. Force p/c/n calculations.
  5797. @item pcnub
  5798. Force p/c/n/u/b calculations.
  5799. @end table
  5800. Default value is @var{none}.
  5801. @item cthresh
  5802. This is the area combing threshold used for combed frame detection. This
  5803. essentially controls how "strong" or "visible" combing must be to be detected.
  5804. Larger values mean combing must be more visible and smaller values mean combing
  5805. can be less visible or strong and still be detected. Valid settings are from
  5806. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  5807. be detected as combed). This is basically a pixel difference value. A good
  5808. range is @code{[8, 12]}.
  5809. Default value is @code{9}.
  5810. @item chroma
  5811. Sets whether or not chroma is considered in the combed frame decision. Only
  5812. disable this if your source has chroma problems (rainbowing, etc.) that are
  5813. causing problems for the combed frame detection with chroma enabled. Actually,
  5814. using @option{chroma}=@var{0} is usually more reliable, except for the case
  5815. where there is chroma only combing in the source.
  5816. Default value is @code{0}.
  5817. @item blockx
  5818. @item blocky
  5819. Respectively set the x-axis and y-axis size of the window used during combed
  5820. frame detection. This has to do with the size of the area in which
  5821. @option{combpel} pixels are required to be detected as combed for a frame to be
  5822. declared combed. See the @option{combpel} parameter description for more info.
  5823. Possible values are any number that is a power of 2 starting at 4 and going up
  5824. to 512.
  5825. Default value is @code{16}.
  5826. @item combpel
  5827. The number of combed pixels inside any of the @option{blocky} by
  5828. @option{blockx} size blocks on the frame for the frame to be detected as
  5829. combed. While @option{cthresh} controls how "visible" the combing must be, this
  5830. setting controls "how much" combing there must be in any localized area (a
  5831. window defined by the @option{blockx} and @option{blocky} settings) on the
  5832. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  5833. which point no frames will ever be detected as combed). This setting is known
  5834. as @option{MI} in TFM/VFM vocabulary.
  5835. Default value is @code{80}.
  5836. @end table
  5837. @anchor{p/c/n/u/b meaning}
  5838. @subsection p/c/n/u/b meaning
  5839. @subsubsection p/c/n
  5840. We assume the following telecined stream:
  5841. @example
  5842. Top fields: 1 2 2 3 4
  5843. Bottom fields: 1 2 3 4 4
  5844. @end example
  5845. The numbers correspond to the progressive frame the fields relate to. Here, the
  5846. first two frames are progressive, the 3rd and 4th are combed, and so on.
  5847. When @code{fieldmatch} is configured to run a matching from bottom
  5848. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  5849. @example
  5850. Input stream:
  5851. T 1 2 2 3 4
  5852. B 1 2 3 4 4 <-- matching reference
  5853. Matches: c c n n c
  5854. Output stream:
  5855. T 1 2 3 4 4
  5856. B 1 2 3 4 4
  5857. @end example
  5858. As a result of the field matching, we can see that some frames get duplicated.
  5859. To perform a complete inverse telecine, you need to rely on a decimation filter
  5860. after this operation. See for instance the @ref{decimate} filter.
  5861. The same operation now matching from top fields (@option{field}=@var{top})
  5862. looks like this:
  5863. @example
  5864. Input stream:
  5865. T 1 2 2 3 4 <-- matching reference
  5866. B 1 2 3 4 4
  5867. Matches: c c p p c
  5868. Output stream:
  5869. T 1 2 2 3 4
  5870. B 1 2 2 3 4
  5871. @end example
  5872. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  5873. basically, they refer to the frame and field of the opposite parity:
  5874. @itemize
  5875. @item @var{p} matches the field of the opposite parity in the previous frame
  5876. @item @var{c} matches the field of the opposite parity in the current frame
  5877. @item @var{n} matches the field of the opposite parity in the next frame
  5878. @end itemize
  5879. @subsubsection u/b
  5880. The @var{u} and @var{b} matching are a bit special in the sense that they match
  5881. from the opposite parity flag. In the following examples, we assume that we are
  5882. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  5883. 'x' is placed above and below each matched fields.
  5884. With bottom matching (@option{field}=@var{bottom}):
  5885. @example
  5886. Match: c p n b u
  5887. x x x x x
  5888. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  5889. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  5890. x x x x x
  5891. Output frames:
  5892. 2 1 2 2 2
  5893. 2 2 2 1 3
  5894. @end example
  5895. With top matching (@option{field}=@var{top}):
  5896. @example
  5897. Match: c p n b u
  5898. x x x x x
  5899. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  5900. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  5901. x x x x x
  5902. Output frames:
  5903. 2 2 2 1 2
  5904. 2 1 3 2 2
  5905. @end example
  5906. @subsection Examples
  5907. Simple IVTC of a top field first telecined stream:
  5908. @example
  5909. fieldmatch=order=tff:combmatch=none, decimate
  5910. @end example
  5911. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  5912. @example
  5913. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  5914. @end example
  5915. @section fieldorder
  5916. Transform the field order of the input video.
  5917. It accepts the following parameters:
  5918. @table @option
  5919. @item order
  5920. The output field order. Valid values are @var{tff} for top field first or @var{bff}
  5921. for bottom field first.
  5922. @end table
  5923. The default value is @samp{tff}.
  5924. The transformation is done by shifting the picture content up or down
  5925. by one line, and filling the remaining line with appropriate picture content.
  5926. This method is consistent with most broadcast field order converters.
  5927. If the input video is not flagged as being interlaced, or it is already
  5928. flagged as being of the required output field order, then this filter does
  5929. not alter the incoming video.
  5930. It is very useful when converting to or from PAL DV material,
  5931. which is bottom field first.
  5932. For example:
  5933. @example
  5934. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  5935. @end example
  5936. @section fifo, afifo
  5937. Buffer input images and send them when they are requested.
  5938. It is mainly useful when auto-inserted by the libavfilter
  5939. framework.
  5940. It does not take parameters.
  5941. @section find_rect
  5942. Find a rectangular object
  5943. It accepts the following options:
  5944. @table @option
  5945. @item object
  5946. Filepath of the object image, needs to be in gray8.
  5947. @item threshold
  5948. Detection threshold, default is 0.5.
  5949. @item mipmaps
  5950. Number of mipmaps, default is 3.
  5951. @item xmin, ymin, xmax, ymax
  5952. Specifies the rectangle in which to search.
  5953. @end table
  5954. @subsection Examples
  5955. @itemize
  5956. @item
  5957. Generate a representative palette of a given video using @command{ffmpeg}:
  5958. @example
  5959. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  5960. @end example
  5961. @end itemize
  5962. @section cover_rect
  5963. Cover a rectangular object
  5964. It accepts the following options:
  5965. @table @option
  5966. @item cover
  5967. Filepath of the optional cover image, needs to be in yuv420.
  5968. @item mode
  5969. Set covering mode.
  5970. It accepts the following values:
  5971. @table @samp
  5972. @item cover
  5973. cover it by the supplied image
  5974. @item blur
  5975. cover it by interpolating the surrounding pixels
  5976. @end table
  5977. Default value is @var{blur}.
  5978. @end table
  5979. @subsection Examples
  5980. @itemize
  5981. @item
  5982. Generate a representative palette of a given video using @command{ffmpeg}:
  5983. @example
  5984. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  5985. @end example
  5986. @end itemize
  5987. @anchor{format}
  5988. @section format
  5989. Convert the input video to one of the specified pixel formats.
  5990. Libavfilter will try to pick one that is suitable as input to
  5991. the next filter.
  5992. It accepts the following parameters:
  5993. @table @option
  5994. @item pix_fmts
  5995. A '|'-separated list of pixel format names, such as
  5996. "pix_fmts=yuv420p|monow|rgb24".
  5997. @end table
  5998. @subsection Examples
  5999. @itemize
  6000. @item
  6001. Convert the input video to the @var{yuv420p} format
  6002. @example
  6003. format=pix_fmts=yuv420p
  6004. @end example
  6005. Convert the input video to any of the formats in the list
  6006. @example
  6007. format=pix_fmts=yuv420p|yuv444p|yuv410p
  6008. @end example
  6009. @end itemize
  6010. @anchor{fps}
  6011. @section fps
  6012. Convert the video to specified constant frame rate by duplicating or dropping
  6013. frames as necessary.
  6014. It accepts the following parameters:
  6015. @table @option
  6016. @item fps
  6017. The desired output frame rate. The default is @code{25}.
  6018. @item round
  6019. Rounding method.
  6020. Possible values are:
  6021. @table @option
  6022. @item zero
  6023. zero round towards 0
  6024. @item inf
  6025. round away from 0
  6026. @item down
  6027. round towards -infinity
  6028. @item up
  6029. round towards +infinity
  6030. @item near
  6031. round to nearest
  6032. @end table
  6033. The default is @code{near}.
  6034. @item start_time
  6035. Assume the first PTS should be the given value, in seconds. This allows for
  6036. padding/trimming at the start of stream. By default, no assumption is made
  6037. about the first frame's expected PTS, so no padding or trimming is done.
  6038. For example, this could be set to 0 to pad the beginning with duplicates of
  6039. the first frame if a video stream starts after the audio stream or to trim any
  6040. frames with a negative PTS.
  6041. @end table
  6042. Alternatively, the options can be specified as a flat string:
  6043. @var{fps}[:@var{round}].
  6044. See also the @ref{setpts} filter.
  6045. @subsection Examples
  6046. @itemize
  6047. @item
  6048. A typical usage in order to set the fps to 25:
  6049. @example
  6050. fps=fps=25
  6051. @end example
  6052. @item
  6053. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  6054. @example
  6055. fps=fps=film:round=near
  6056. @end example
  6057. @end itemize
  6058. @section framepack
  6059. Pack two different video streams into a stereoscopic video, setting proper
  6060. metadata on supported codecs. The two views should have the same size and
  6061. framerate and processing will stop when the shorter video ends. Please note
  6062. that you may conveniently adjust view properties with the @ref{scale} and
  6063. @ref{fps} filters.
  6064. It accepts the following parameters:
  6065. @table @option
  6066. @item format
  6067. The desired packing format. Supported values are:
  6068. @table @option
  6069. @item sbs
  6070. The views are next to each other (default).
  6071. @item tab
  6072. The views are on top of each other.
  6073. @item lines
  6074. The views are packed by line.
  6075. @item columns
  6076. The views are packed by column.
  6077. @item frameseq
  6078. The views are temporally interleaved.
  6079. @end table
  6080. @end table
  6081. Some examples:
  6082. @example
  6083. # Convert left and right views into a frame-sequential video
  6084. ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
  6085. # Convert views into a side-by-side video with the same output resolution as the input
  6086. 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
  6087. @end example
  6088. @section framerate
  6089. Change the frame rate by interpolating new video output frames from the source
  6090. frames.
  6091. This filter is not designed to function correctly with interlaced media. If
  6092. you wish to change the frame rate of interlaced media then you are required
  6093. to deinterlace before this filter and re-interlace after this filter.
  6094. A description of the accepted options follows.
  6095. @table @option
  6096. @item fps
  6097. Specify the output frames per second. This option can also be specified
  6098. as a value alone. The default is @code{50}.
  6099. @item interp_start
  6100. Specify the start of a range where the output frame will be created as a
  6101. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  6102. the default is @code{15}.
  6103. @item interp_end
  6104. Specify the end of a range where the output frame will be created as a
  6105. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  6106. the default is @code{240}.
  6107. @item scene
  6108. Specify the level at which a scene change is detected as a value between
  6109. 0 and 100 to indicate a new scene; a low value reflects a low
  6110. probability for the current frame to introduce a new scene, while a higher
  6111. value means the current frame is more likely to be one.
  6112. The default is @code{7}.
  6113. @item flags
  6114. Specify flags influencing the filter process.
  6115. Available value for @var{flags} is:
  6116. @table @option
  6117. @item scene_change_detect, scd
  6118. Enable scene change detection using the value of the option @var{scene}.
  6119. This flag is enabled by default.
  6120. @end table
  6121. @end table
  6122. @section framestep
  6123. Select one frame every N-th frame.
  6124. This filter accepts the following option:
  6125. @table @option
  6126. @item step
  6127. Select frame after every @code{step} frames.
  6128. Allowed values are positive integers higher than 0. Default value is @code{1}.
  6129. @end table
  6130. @anchor{frei0r}
  6131. @section frei0r
  6132. Apply a frei0r effect to the input video.
  6133. To enable the compilation of this filter, you need to install the frei0r
  6134. header and configure FFmpeg with @code{--enable-frei0r}.
  6135. It accepts the following parameters:
  6136. @table @option
  6137. @item filter_name
  6138. The name of the frei0r effect to load. If the environment variable
  6139. @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
  6140. directories specified by the colon-separated list in @env{FREIOR_PATH}.
  6141. Otherwise, the standard frei0r paths are searched, in this order:
  6142. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  6143. @file{/usr/lib/frei0r-1/}.
  6144. @item filter_params
  6145. A '|'-separated list of parameters to pass to the frei0r effect.
  6146. @end table
  6147. A frei0r effect parameter can be a boolean (its value is either
  6148. "y" or "n"), a double, a color (specified as
  6149. @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
  6150. numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
  6151. section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
  6152. @var{X} and @var{Y} are floating point numbers) and/or a string.
  6153. The number and types of parameters depend on the loaded effect. If an
  6154. effect parameter is not specified, the default value is set.
  6155. @subsection Examples
  6156. @itemize
  6157. @item
  6158. Apply the distort0r effect, setting the first two double parameters:
  6159. @example
  6160. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  6161. @end example
  6162. @item
  6163. Apply the colordistance effect, taking a color as the first parameter:
  6164. @example
  6165. frei0r=colordistance:0.2/0.3/0.4
  6166. frei0r=colordistance:violet
  6167. frei0r=colordistance:0x112233
  6168. @end example
  6169. @item
  6170. Apply the perspective effect, specifying the top left and top right image
  6171. positions:
  6172. @example
  6173. frei0r=perspective:0.2/0.2|0.8/0.2
  6174. @end example
  6175. @end itemize
  6176. For more information, see
  6177. @url{http://frei0r.dyne.org}
  6178. @section fspp
  6179. Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
  6180. It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
  6181. processing filter, one of them is performed once per block, not per pixel.
  6182. This allows for much higher speed.
  6183. The filter accepts the following options:
  6184. @table @option
  6185. @item quality
  6186. Set quality. This option defines the number of levels for averaging. It accepts
  6187. an integer in the range 4-5. Default value is @code{4}.
  6188. @item qp
  6189. Force a constant quantization parameter. It accepts an integer in range 0-63.
  6190. If not set, the filter will use the QP from the video stream (if available).
  6191. @item strength
  6192. Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
  6193. more details but also more artifacts, while higher values make the image smoother
  6194. but also blurrier. Default value is @code{0} − PSNR optimal.
  6195. @item use_bframe_qp
  6196. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  6197. option may cause flicker since the B-Frames have often larger QP. Default is
  6198. @code{0} (not enabled).
  6199. @end table
  6200. @section geq
  6201. The filter accepts the following options:
  6202. @table @option
  6203. @item lum_expr, lum
  6204. Set the luminance expression.
  6205. @item cb_expr, cb
  6206. Set the chrominance blue expression.
  6207. @item cr_expr, cr
  6208. Set the chrominance red expression.
  6209. @item alpha_expr, a
  6210. Set the alpha expression.
  6211. @item red_expr, r
  6212. Set the red expression.
  6213. @item green_expr, g
  6214. Set the green expression.
  6215. @item blue_expr, b
  6216. Set the blue expression.
  6217. @end table
  6218. The colorspace is selected according to the specified options. If one
  6219. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  6220. options is specified, the filter will automatically select a YCbCr
  6221. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  6222. @option{blue_expr} options is specified, it will select an RGB
  6223. colorspace.
  6224. If one of the chrominance expression is not defined, it falls back on the other
  6225. one. If no alpha expression is specified it will evaluate to opaque value.
  6226. If none of chrominance expressions are specified, they will evaluate
  6227. to the luminance expression.
  6228. The expressions can use the following variables and functions:
  6229. @table @option
  6230. @item N
  6231. The sequential number of the filtered frame, starting from @code{0}.
  6232. @item X
  6233. @item Y
  6234. The coordinates of the current sample.
  6235. @item W
  6236. @item H
  6237. The width and height of the image.
  6238. @item SW
  6239. @item SH
  6240. Width and height scale depending on the currently filtered plane. It is the
  6241. ratio between the corresponding luma plane number of pixels and the current
  6242. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  6243. @code{0.5,0.5} for chroma planes.
  6244. @item T
  6245. Time of the current frame, expressed in seconds.
  6246. @item p(x, y)
  6247. Return the value of the pixel at location (@var{x},@var{y}) of the current
  6248. plane.
  6249. @item lum(x, y)
  6250. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  6251. plane.
  6252. @item cb(x, y)
  6253. Return the value of the pixel at location (@var{x},@var{y}) of the
  6254. blue-difference chroma plane. Return 0 if there is no such plane.
  6255. @item cr(x, y)
  6256. Return the value of the pixel at location (@var{x},@var{y}) of the
  6257. red-difference chroma plane. Return 0 if there is no such plane.
  6258. @item r(x, y)
  6259. @item g(x, y)
  6260. @item b(x, y)
  6261. Return the value of the pixel at location (@var{x},@var{y}) of the
  6262. red/green/blue component. Return 0 if there is no such component.
  6263. @item alpha(x, y)
  6264. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  6265. plane. Return 0 if there is no such plane.
  6266. @end table
  6267. For functions, if @var{x} and @var{y} are outside the area, the value will be
  6268. automatically clipped to the closer edge.
  6269. @subsection Examples
  6270. @itemize
  6271. @item
  6272. Flip the image horizontally:
  6273. @example
  6274. geq=p(W-X\,Y)
  6275. @end example
  6276. @item
  6277. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  6278. wavelength of 100 pixels:
  6279. @example
  6280. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  6281. @end example
  6282. @item
  6283. Generate a fancy enigmatic moving light:
  6284. @example
  6285. 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
  6286. @end example
  6287. @item
  6288. Generate a quick emboss effect:
  6289. @example
  6290. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  6291. @end example
  6292. @item
  6293. Modify RGB components depending on pixel position:
  6294. @example
  6295. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  6296. @end example
  6297. @item
  6298. Create a radial gradient that is the same size as the input (also see
  6299. the @ref{vignette} filter):
  6300. @example
  6301. geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
  6302. @end example
  6303. @end itemize
  6304. @section gradfun
  6305. Fix the banding artifacts that are sometimes introduced into nearly flat
  6306. regions by truncation to 8bit color depth.
  6307. Interpolate the gradients that should go where the bands are, and
  6308. dither them.
  6309. It is designed for playback only. Do not use it prior to
  6310. lossy compression, because compression tends to lose the dither and
  6311. bring back the bands.
  6312. It accepts the following parameters:
  6313. @table @option
  6314. @item strength
  6315. The maximum amount by which the filter will change any one pixel. This is also
  6316. the threshold for detecting nearly flat regions. Acceptable values range from
  6317. .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
  6318. valid range.
  6319. @item radius
  6320. The neighborhood to fit the gradient to. A larger radius makes for smoother
  6321. gradients, but also prevents the filter from modifying the pixels near detailed
  6322. regions. Acceptable values are 8-32; the default value is 16. Out-of-range
  6323. values will be clipped to the valid range.
  6324. @end table
  6325. Alternatively, the options can be specified as a flat string:
  6326. @var{strength}[:@var{radius}]
  6327. @subsection Examples
  6328. @itemize
  6329. @item
  6330. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  6331. @example
  6332. gradfun=3.5:8
  6333. @end example
  6334. @item
  6335. Specify radius, omitting the strength (which will fall-back to the default
  6336. value):
  6337. @example
  6338. gradfun=radius=8
  6339. @end example
  6340. @end itemize
  6341. @anchor{haldclut}
  6342. @section haldclut
  6343. Apply a Hald CLUT to a video stream.
  6344. First input is the video stream to process, and second one is the Hald CLUT.
  6345. The Hald CLUT input can be a simple picture or a complete video stream.
  6346. The filter accepts the following options:
  6347. @table @option
  6348. @item shortest
  6349. Force termination when the shortest input terminates. Default is @code{0}.
  6350. @item repeatlast
  6351. Continue applying the last CLUT after the end of the stream. A value of
  6352. @code{0} disable the filter after the last frame of the CLUT is reached.
  6353. Default is @code{1}.
  6354. @end table
  6355. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  6356. filters share the same internals).
  6357. More information about the Hald CLUT can be found on Eskil Steenberg's website
  6358. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  6359. @subsection Workflow examples
  6360. @subsubsection Hald CLUT video stream
  6361. Generate an identity Hald CLUT stream altered with various effects:
  6362. @example
  6363. 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
  6364. @end example
  6365. Note: make sure you use a lossless codec.
  6366. Then use it with @code{haldclut} to apply it on some random stream:
  6367. @example
  6368. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  6369. @end example
  6370. The Hald CLUT will be applied to the 10 first seconds (duration of
  6371. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  6372. to the remaining frames of the @code{mandelbrot} stream.
  6373. @subsubsection Hald CLUT with preview
  6374. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  6375. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  6376. biggest possible square starting at the top left of the picture. The remaining
  6377. padding pixels (bottom or right) will be ignored. This area can be used to add
  6378. a preview of the Hald CLUT.
  6379. Typically, the following generated Hald CLUT will be supported by the
  6380. @code{haldclut} filter:
  6381. @example
  6382. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  6383. pad=iw+320 [padded_clut];
  6384. smptebars=s=320x256, split [a][b];
  6385. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  6386. [main][b] overlay=W-320" -frames:v 1 clut.png
  6387. @end example
  6388. It contains the original and a preview of the effect of the CLUT: SMPTE color
  6389. bars are displayed on the right-top, and below the same color bars processed by
  6390. the color changes.
  6391. Then, the effect of this Hald CLUT can be visualized with:
  6392. @example
  6393. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  6394. @end example
  6395. @section hdcd
  6396. Decodes high definition audio cd data. 16-Bit PCM stream containing hdcd flags
  6397. is converted to 20-bit PCM stream.
  6398. @section hflip
  6399. Flip the input video horizontally.
  6400. For example, to horizontally flip the input video with @command{ffmpeg}:
  6401. @example
  6402. ffmpeg -i in.avi -vf "hflip" out.avi
  6403. @end example
  6404. @section histeq
  6405. This filter applies a global color histogram equalization on a
  6406. per-frame basis.
  6407. It can be used to correct video that has a compressed range of pixel
  6408. intensities. The filter redistributes the pixel intensities to
  6409. equalize their distribution across the intensity range. It may be
  6410. viewed as an "automatically adjusting contrast filter". This filter is
  6411. useful only for correcting degraded or poorly captured source
  6412. video.
  6413. The filter accepts the following options:
  6414. @table @option
  6415. @item strength
  6416. Determine the amount of equalization to be applied. As the strength
  6417. is reduced, the distribution of pixel intensities more-and-more
  6418. approaches that of the input frame. The value must be a float number
  6419. in the range [0,1] and defaults to 0.200.
  6420. @item intensity
  6421. Set the maximum intensity that can generated and scale the output
  6422. values appropriately. The strength should be set as desired and then
  6423. the intensity can be limited if needed to avoid washing-out. The value
  6424. must be a float number in the range [0,1] and defaults to 0.210.
  6425. @item antibanding
  6426. Set the antibanding level. If enabled the filter will randomly vary
  6427. the luminance of output pixels by a small amount to avoid banding of
  6428. the histogram. Possible values are @code{none}, @code{weak} or
  6429. @code{strong}. It defaults to @code{none}.
  6430. @end table
  6431. @section histogram
  6432. Compute and draw a color distribution histogram for the input video.
  6433. The computed histogram is a representation of the color component
  6434. distribution in an image.
  6435. Standard histogram displays the color components distribution in an image.
  6436. Displays color graph for each color component. Shows distribution of
  6437. the Y, U, V, A or R, G, B components, depending on input format, in the
  6438. current frame. Below each graph a color component scale meter is shown.
  6439. The filter accepts the following options:
  6440. @table @option
  6441. @item level_height
  6442. Set height of level. Default value is @code{200}.
  6443. Allowed range is [50, 2048].
  6444. @item scale_height
  6445. Set height of color scale. Default value is @code{12}.
  6446. Allowed range is [0, 40].
  6447. @item display_mode
  6448. Set display mode.
  6449. It accepts the following values:
  6450. @table @samp
  6451. @item parade
  6452. Per color component graphs are placed below each other.
  6453. @item overlay
  6454. Presents information identical to that in the @code{parade}, except
  6455. that the graphs representing color components are superimposed directly
  6456. over one another.
  6457. @end table
  6458. Default is @code{parade}.
  6459. @item levels_mode
  6460. Set mode. Can be either @code{linear}, or @code{logarithmic}.
  6461. Default is @code{linear}.
  6462. @item components
  6463. Set what color components to display.
  6464. Default is @code{7}.
  6465. @end table
  6466. @subsection Examples
  6467. @itemize
  6468. @item
  6469. Calculate and draw histogram:
  6470. @example
  6471. ffplay -i input -vf histogram
  6472. @end example
  6473. @end itemize
  6474. @anchor{hqdn3d}
  6475. @section hqdn3d
  6476. This is a high precision/quality 3d denoise filter. It aims to reduce
  6477. image noise, producing smooth images and making still images really
  6478. still. It should enhance compressibility.
  6479. It accepts the following optional parameters:
  6480. @table @option
  6481. @item luma_spatial
  6482. A non-negative floating point number which specifies spatial luma strength.
  6483. It defaults to 4.0.
  6484. @item chroma_spatial
  6485. A non-negative floating point number which specifies spatial chroma strength.
  6486. It defaults to 3.0*@var{luma_spatial}/4.0.
  6487. @item luma_tmp
  6488. A floating point number which specifies luma temporal strength. It defaults to
  6489. 6.0*@var{luma_spatial}/4.0.
  6490. @item chroma_tmp
  6491. A floating point number which specifies chroma temporal strength. It defaults to
  6492. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
  6493. @end table
  6494. @anchor{hwupload_cuda}
  6495. @section hwupload_cuda
  6496. Upload system memory frames to a CUDA device.
  6497. It accepts the following optional parameters:
  6498. @table @option
  6499. @item device
  6500. The number of the CUDA device to use
  6501. @end table
  6502. @section hqx
  6503. Apply a high-quality magnification filter designed for pixel art. This filter
  6504. was originally created by Maxim Stepin.
  6505. It accepts the following option:
  6506. @table @option
  6507. @item n
  6508. Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
  6509. @code{hq3x} and @code{4} for @code{hq4x}.
  6510. Default is @code{3}.
  6511. @end table
  6512. @section hstack
  6513. Stack input videos horizontally.
  6514. All streams must be of same pixel format and of same height.
  6515. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  6516. to create same output.
  6517. The filter accept the following option:
  6518. @table @option
  6519. @item inputs
  6520. Set number of input streams. Default is 2.
  6521. @item shortest
  6522. If set to 1, force the output to terminate when the shortest input
  6523. terminates. Default value is 0.
  6524. @end table
  6525. @section hue
  6526. Modify the hue and/or the saturation of the input.
  6527. It accepts the following parameters:
  6528. @table @option
  6529. @item h
  6530. Specify the hue angle as a number of degrees. It accepts an expression,
  6531. and defaults to "0".
  6532. @item s
  6533. Specify the saturation in the [-10,10] range. It accepts an expression and
  6534. defaults to "1".
  6535. @item H
  6536. Specify the hue angle as a number of radians. It accepts an
  6537. expression, and defaults to "0".
  6538. @item b
  6539. Specify the brightness in the [-10,10] range. It accepts an expression and
  6540. defaults to "0".
  6541. @end table
  6542. @option{h} and @option{H} are mutually exclusive, and can't be
  6543. specified at the same time.
  6544. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  6545. expressions containing the following constants:
  6546. @table @option
  6547. @item n
  6548. frame count of the input frame starting from 0
  6549. @item pts
  6550. presentation timestamp of the input frame expressed in time base units
  6551. @item r
  6552. frame rate of the input video, NAN if the input frame rate is unknown
  6553. @item t
  6554. timestamp expressed in seconds, NAN if the input timestamp is unknown
  6555. @item tb
  6556. time base of the input video
  6557. @end table
  6558. @subsection Examples
  6559. @itemize
  6560. @item
  6561. Set the hue to 90 degrees and the saturation to 1.0:
  6562. @example
  6563. hue=h=90:s=1
  6564. @end example
  6565. @item
  6566. Same command but expressing the hue in radians:
  6567. @example
  6568. hue=H=PI/2:s=1
  6569. @end example
  6570. @item
  6571. Rotate hue and make the saturation swing between 0
  6572. and 2 over a period of 1 second:
  6573. @example
  6574. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  6575. @end example
  6576. @item
  6577. Apply a 3 seconds saturation fade-in effect starting at 0:
  6578. @example
  6579. hue="s=min(t/3\,1)"
  6580. @end example
  6581. The general fade-in expression can be written as:
  6582. @example
  6583. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  6584. @end example
  6585. @item
  6586. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  6587. @example
  6588. hue="s=max(0\, min(1\, (8-t)/3))"
  6589. @end example
  6590. The general fade-out expression can be written as:
  6591. @example
  6592. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  6593. @end example
  6594. @end itemize
  6595. @subsection Commands
  6596. This filter supports the following commands:
  6597. @table @option
  6598. @item b
  6599. @item s
  6600. @item h
  6601. @item H
  6602. Modify the hue and/or the saturation and/or brightness of the input video.
  6603. The command accepts the same syntax of the corresponding option.
  6604. If the specified expression is not valid, it is kept at its current
  6605. value.
  6606. @end table
  6607. @section idet
  6608. Detect video interlacing type.
  6609. This filter tries to detect if the input frames as interlaced, progressive,
  6610. top or bottom field first. It will also try and detect fields that are
  6611. repeated between adjacent frames (a sign of telecine).
  6612. Single frame detection considers only immediately adjacent frames when classifying each frame.
  6613. Multiple frame detection incorporates the classification history of previous frames.
  6614. The filter will log these metadata values:
  6615. @table @option
  6616. @item single.current_frame
  6617. Detected type of current frame using single-frame detection. One of:
  6618. ``tff'' (top field first), ``bff'' (bottom field first),
  6619. ``progressive'', or ``undetermined''
  6620. @item single.tff
  6621. Cumulative number of frames detected as top field first using single-frame detection.
  6622. @item multiple.tff
  6623. Cumulative number of frames detected as top field first using multiple-frame detection.
  6624. @item single.bff
  6625. Cumulative number of frames detected as bottom field first using single-frame detection.
  6626. @item multiple.current_frame
  6627. Detected type of current frame using multiple-frame detection. One of:
  6628. ``tff'' (top field first), ``bff'' (bottom field first),
  6629. ``progressive'', or ``undetermined''
  6630. @item multiple.bff
  6631. Cumulative number of frames detected as bottom field first using multiple-frame detection.
  6632. @item single.progressive
  6633. Cumulative number of frames detected as progressive using single-frame detection.
  6634. @item multiple.progressive
  6635. Cumulative number of frames detected as progressive using multiple-frame detection.
  6636. @item single.undetermined
  6637. Cumulative number of frames that could not be classified using single-frame detection.
  6638. @item multiple.undetermined
  6639. Cumulative number of frames that could not be classified using multiple-frame detection.
  6640. @item repeated.current_frame
  6641. Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
  6642. @item repeated.neither
  6643. Cumulative number of frames with no repeated field.
  6644. @item repeated.top
  6645. Cumulative number of frames with the top field repeated from the previous frame's top field.
  6646. @item repeated.bottom
  6647. Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
  6648. @end table
  6649. The filter accepts the following options:
  6650. @table @option
  6651. @item intl_thres
  6652. Set interlacing threshold.
  6653. @item prog_thres
  6654. Set progressive threshold.
  6655. @item rep_thres
  6656. Threshold for repeated field detection.
  6657. @item half_life
  6658. Number of frames after which a given frame's contribution to the
  6659. statistics is halved (i.e., it contributes only 0.5 to it's
  6660. classification). The default of 0 means that all frames seen are given
  6661. full weight of 1.0 forever.
  6662. @item analyze_interlaced_flag
  6663. When this is not 0 then idet will use the specified number of frames to determine
  6664. if the interlaced flag is accurate, it will not count undetermined frames.
  6665. If the flag is found to be accurate it will be used without any further
  6666. computations, if it is found to be inaccurate it will be cleared without any
  6667. further computations. This allows inserting the idet filter as a low computational
  6668. method to clean up the interlaced flag
  6669. @end table
  6670. @section il
  6671. Deinterleave or interleave fields.
  6672. This filter allows one to process interlaced images fields without
  6673. deinterlacing them. Deinterleaving splits the input frame into 2
  6674. fields (so called half pictures). Odd lines are moved to the top
  6675. half of the output image, even lines to the bottom half.
  6676. You can process (filter) them independently and then re-interleave them.
  6677. The filter accepts the following options:
  6678. @table @option
  6679. @item luma_mode, l
  6680. @item chroma_mode, c
  6681. @item alpha_mode, a
  6682. Available values for @var{luma_mode}, @var{chroma_mode} and
  6683. @var{alpha_mode} are:
  6684. @table @samp
  6685. @item none
  6686. Do nothing.
  6687. @item deinterleave, d
  6688. Deinterleave fields, placing one above the other.
  6689. @item interleave, i
  6690. Interleave fields. Reverse the effect of deinterleaving.
  6691. @end table
  6692. Default value is @code{none}.
  6693. @item luma_swap, ls
  6694. @item chroma_swap, cs
  6695. @item alpha_swap, as
  6696. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  6697. @end table
  6698. @section inflate
  6699. Apply inflate effect to the video.
  6700. This filter replaces the pixel by the local(3x3) average by taking into account
  6701. only values higher than the pixel.
  6702. It accepts the following options:
  6703. @table @option
  6704. @item threshold0
  6705. @item threshold1
  6706. @item threshold2
  6707. @item threshold3
  6708. Limit the maximum change for each plane, default is 65535.
  6709. If 0, plane will remain unchanged.
  6710. @end table
  6711. @section interlace
  6712. Simple interlacing filter from progressive contents. This interleaves upper (or
  6713. lower) lines from odd frames with lower (or upper) lines from even frames,
  6714. halving the frame rate and preserving image height.
  6715. @example
  6716. Original Original New Frame
  6717. Frame 'j' Frame 'j+1' (tff)
  6718. ========== =========== ==================
  6719. Line 0 --------------------> Frame 'j' Line 0
  6720. Line 1 Line 1 ----> Frame 'j+1' Line 1
  6721. Line 2 ---------------------> Frame 'j' Line 2
  6722. Line 3 Line 3 ----> Frame 'j+1' Line 3
  6723. ... ... ...
  6724. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  6725. @end example
  6726. It accepts the following optional parameters:
  6727. @table @option
  6728. @item scan
  6729. This determines whether the interlaced frame is taken from the even
  6730. (tff - default) or odd (bff) lines of the progressive frame.
  6731. @item lowpass
  6732. Enable (default) or disable the vertical lowpass filter to avoid twitter
  6733. interlacing and reduce moire patterns.
  6734. @end table
  6735. @section kerndeint
  6736. Deinterlace input video by applying Donald Graft's adaptive kernel
  6737. deinterling. Work on interlaced parts of a video to produce
  6738. progressive frames.
  6739. The description of the accepted parameters follows.
  6740. @table @option
  6741. @item thresh
  6742. Set the threshold which affects the filter's tolerance when
  6743. determining if a pixel line must be processed. It must be an integer
  6744. in the range [0,255] and defaults to 10. A value of 0 will result in
  6745. applying the process on every pixels.
  6746. @item map
  6747. Paint pixels exceeding the threshold value to white if set to 1.
  6748. Default is 0.
  6749. @item order
  6750. Set the fields order. Swap fields if set to 1, leave fields alone if
  6751. 0. Default is 0.
  6752. @item sharp
  6753. Enable additional sharpening if set to 1. Default is 0.
  6754. @item twoway
  6755. Enable twoway sharpening if set to 1. Default is 0.
  6756. @end table
  6757. @subsection Examples
  6758. @itemize
  6759. @item
  6760. Apply default values:
  6761. @example
  6762. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  6763. @end example
  6764. @item
  6765. Enable additional sharpening:
  6766. @example
  6767. kerndeint=sharp=1
  6768. @end example
  6769. @item
  6770. Paint processed pixels in white:
  6771. @example
  6772. kerndeint=map=1
  6773. @end example
  6774. @end itemize
  6775. @section lenscorrection
  6776. Correct radial lens distortion
  6777. This filter can be used to correct for radial distortion as can result from the use
  6778. of wide angle lenses, and thereby re-rectify the image. To find the right parameters
  6779. one can use tools available for example as part of opencv or simply trial-and-error.
  6780. To use opencv use the calibration sample (under samples/cpp) from the opencv sources
  6781. and extract the k1 and k2 coefficients from the resulting matrix.
  6782. Note that effectively the same filter is available in the open-source tools Krita and
  6783. Digikam from the KDE project.
  6784. In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
  6785. this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
  6786. brightness distribution, so you may want to use both filters together in certain
  6787. cases, though you will have to take care of ordering, i.e. whether vignetting should
  6788. be applied before or after lens correction.
  6789. @subsection Options
  6790. The filter accepts the following options:
  6791. @table @option
  6792. @item cx
  6793. Relative x-coordinate of the focal point of the image, and thereby the center of the
  6794. distortion. This value has a range [0,1] and is expressed as fractions of the image
  6795. width.
  6796. @item cy
  6797. Relative y-coordinate of the focal point of the image, and thereby the center of the
  6798. distortion. This value has a range [0,1] and is expressed as fractions of the image
  6799. height.
  6800. @item k1
  6801. Coefficient of the quadratic correction term. 0.5 means no correction.
  6802. @item k2
  6803. Coefficient of the double quadratic correction term. 0.5 means no correction.
  6804. @end table
  6805. The formula that generates the correction is:
  6806. @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)
  6807. where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
  6808. distances from the focal point in the source and target images, respectively.
  6809. @section loop, aloop
  6810. Loop video frames or audio samples.
  6811. Those filters accepts the following options:
  6812. @table @option
  6813. @item loop
  6814. Set the number of loops.
  6815. @item size
  6816. Set maximal size in number of frames for @code{loop} filter or maximal number
  6817. of samples in case of @code{aloop} filter.
  6818. @item start
  6819. Set first frame of loop for @code{loop} filter or first sample of loop in case
  6820. of @code{aloop} filter.
  6821. @end table
  6822. @anchor{lut3d}
  6823. @section lut3d
  6824. Apply a 3D LUT to an input video.
  6825. The filter accepts the following options:
  6826. @table @option
  6827. @item file
  6828. Set the 3D LUT file name.
  6829. Currently supported formats:
  6830. @table @samp
  6831. @item 3dl
  6832. AfterEffects
  6833. @item cube
  6834. Iridas
  6835. @item dat
  6836. DaVinci
  6837. @item m3d
  6838. Pandora
  6839. @end table
  6840. @item interp
  6841. Select interpolation mode.
  6842. Available values are:
  6843. @table @samp
  6844. @item nearest
  6845. Use values from the nearest defined point.
  6846. @item trilinear
  6847. Interpolate values using the 8 points defining a cube.
  6848. @item tetrahedral
  6849. Interpolate values using a tetrahedron.
  6850. @end table
  6851. @end table
  6852. @section lut, lutrgb, lutyuv
  6853. Compute a look-up table for binding each pixel component input value
  6854. to an output value, and apply it to the input video.
  6855. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  6856. to an RGB input video.
  6857. These filters accept the following parameters:
  6858. @table @option
  6859. @item c0
  6860. set first pixel component expression
  6861. @item c1
  6862. set second pixel component expression
  6863. @item c2
  6864. set third pixel component expression
  6865. @item c3
  6866. set fourth pixel component expression, corresponds to the alpha component
  6867. @item r
  6868. set red component expression
  6869. @item g
  6870. set green component expression
  6871. @item b
  6872. set blue component expression
  6873. @item a
  6874. alpha component expression
  6875. @item y
  6876. set Y/luminance component expression
  6877. @item u
  6878. set U/Cb component expression
  6879. @item v
  6880. set V/Cr component expression
  6881. @end table
  6882. Each of them specifies the expression to use for computing the lookup table for
  6883. the corresponding pixel component values.
  6884. The exact component associated to each of the @var{c*} options depends on the
  6885. format in input.
  6886. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  6887. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  6888. The expressions can contain the following constants and functions:
  6889. @table @option
  6890. @item w
  6891. @item h
  6892. The input width and height.
  6893. @item val
  6894. The input value for the pixel component.
  6895. @item clipval
  6896. The input value, clipped to the @var{minval}-@var{maxval} range.
  6897. @item maxval
  6898. The maximum value for the pixel component.
  6899. @item minval
  6900. The minimum value for the pixel component.
  6901. @item negval
  6902. The negated value for the pixel component value, clipped to the
  6903. @var{minval}-@var{maxval} range; it corresponds to the expression
  6904. "maxval-clipval+minval".
  6905. @item clip(val)
  6906. The computed value in @var{val}, clipped to the
  6907. @var{minval}-@var{maxval} range.
  6908. @item gammaval(gamma)
  6909. The computed gamma correction value of the pixel component value,
  6910. clipped to the @var{minval}-@var{maxval} range. It corresponds to the
  6911. expression
  6912. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  6913. @end table
  6914. All expressions default to "val".
  6915. @subsection Examples
  6916. @itemize
  6917. @item
  6918. Negate input video:
  6919. @example
  6920. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  6921. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  6922. @end example
  6923. The above is the same as:
  6924. @example
  6925. lutrgb="r=negval:g=negval:b=negval"
  6926. lutyuv="y=negval:u=negval:v=negval"
  6927. @end example
  6928. @item
  6929. Negate luminance:
  6930. @example
  6931. lutyuv=y=negval
  6932. @end example
  6933. @item
  6934. Remove chroma components, turning the video into a graytone image:
  6935. @example
  6936. lutyuv="u=128:v=128"
  6937. @end example
  6938. @item
  6939. Apply a luma burning effect:
  6940. @example
  6941. lutyuv="y=2*val"
  6942. @end example
  6943. @item
  6944. Remove green and blue components:
  6945. @example
  6946. lutrgb="g=0:b=0"
  6947. @end example
  6948. @item
  6949. Set a constant alpha channel value on input:
  6950. @example
  6951. format=rgba,lutrgb=a="maxval-minval/2"
  6952. @end example
  6953. @item
  6954. Correct luminance gamma by a factor of 0.5:
  6955. @example
  6956. lutyuv=y=gammaval(0.5)
  6957. @end example
  6958. @item
  6959. Discard least significant bits of luma:
  6960. @example
  6961. lutyuv=y='bitand(val, 128+64+32)'
  6962. @end example
  6963. @end itemize
  6964. @section maskedmerge
  6965. Merge the first input stream with the second input stream using per pixel
  6966. weights in the third input stream.
  6967. A value of 0 in the third stream pixel component means that pixel component
  6968. from first stream is returned unchanged, while maximum value (eg. 255 for
  6969. 8-bit videos) means that pixel component from second stream is returned
  6970. unchanged. Intermediate values define the amount of merging between both
  6971. input stream's pixel components.
  6972. This filter accepts the following options:
  6973. @table @option
  6974. @item planes
  6975. Set which planes will be processed as bitmap, unprocessed planes will be
  6976. copied from first stream.
  6977. By default value 0xf, all planes will be processed.
  6978. @end table
  6979. @section mcdeint
  6980. Apply motion-compensation deinterlacing.
  6981. It needs one field per frame as input and must thus be used together
  6982. with yadif=1/3 or equivalent.
  6983. This filter accepts the following options:
  6984. @table @option
  6985. @item mode
  6986. Set the deinterlacing mode.
  6987. It accepts one of the following values:
  6988. @table @samp
  6989. @item fast
  6990. @item medium
  6991. @item slow
  6992. use iterative motion estimation
  6993. @item extra_slow
  6994. like @samp{slow}, but use multiple reference frames.
  6995. @end table
  6996. Default value is @samp{fast}.
  6997. @item parity
  6998. Set the picture field parity assumed for the input video. It must be
  6999. one of the following values:
  7000. @table @samp
  7001. @item 0, tff
  7002. assume top field first
  7003. @item 1, bff
  7004. assume bottom field first
  7005. @end table
  7006. Default value is @samp{bff}.
  7007. @item qp
  7008. Set per-block quantization parameter (QP) used by the internal
  7009. encoder.
  7010. Higher values should result in a smoother motion vector field but less
  7011. optimal individual vectors. Default value is 1.
  7012. @end table
  7013. @section mergeplanes
  7014. Merge color channel components from several video streams.
  7015. The filter accepts up to 4 input streams, and merge selected input
  7016. planes to the output video.
  7017. This filter accepts the following options:
  7018. @table @option
  7019. @item mapping
  7020. Set input to output plane mapping. Default is @code{0}.
  7021. The mappings is specified as a bitmap. It should be specified as a
  7022. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  7023. mapping for the first plane of the output stream. 'A' sets the number of
  7024. the input stream to use (from 0 to 3), and 'a' the plane number of the
  7025. corresponding input to use (from 0 to 3). The rest of the mappings is
  7026. similar, 'Bb' describes the mapping for the output stream second
  7027. plane, 'Cc' describes the mapping for the output stream third plane and
  7028. 'Dd' describes the mapping for the output stream fourth plane.
  7029. @item format
  7030. Set output pixel format. Default is @code{yuva444p}.
  7031. @end table
  7032. @subsection Examples
  7033. @itemize
  7034. @item
  7035. Merge three gray video streams of same width and height into single video stream:
  7036. @example
  7037. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  7038. @end example
  7039. @item
  7040. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  7041. @example
  7042. [a0][a1]mergeplanes=0x00010210:yuva444p
  7043. @end example
  7044. @item
  7045. Swap Y and A plane in yuva444p stream:
  7046. @example
  7047. format=yuva444p,mergeplanes=0x03010200:yuva444p
  7048. @end example
  7049. @item
  7050. Swap U and V plane in yuv420p stream:
  7051. @example
  7052. format=yuv420p,mergeplanes=0x000201:yuv420p
  7053. @end example
  7054. @item
  7055. Cast a rgb24 clip to yuv444p:
  7056. @example
  7057. format=rgb24,mergeplanes=0x000102:yuv444p
  7058. @end example
  7059. @end itemize
  7060. @section metadata, ametadata
  7061. Manipulate frame metadata.
  7062. This filter accepts the following options:
  7063. @table @option
  7064. @item mode
  7065. Set mode of operation of the filter.
  7066. Can be one of the following:
  7067. @table @samp
  7068. @item select
  7069. If both @code{value} and @code{key} is set, select frames
  7070. which have such metadata. If only @code{key} is set, select
  7071. every frame that has such key in metadata.
  7072. @item add
  7073. Add new metadata @code{key} and @code{value}. If key is already available
  7074. do nothing.
  7075. @item modify
  7076. Modify value of already present key.
  7077. @item delete
  7078. If @code{value} is set, delete only keys that have such value.
  7079. Otherwise, delete key.
  7080. @item print
  7081. Print key and its value if metadata was found. If @code{key} is not set print all
  7082. metadata values available in frame.
  7083. @end table
  7084. @item key
  7085. Set key used with all modes. Must be set for all modes except @code{print}.
  7086. @item value
  7087. Set metadata value which will be used. This option is mandatory for
  7088. @code{modify} and @code{add} mode.
  7089. @item function
  7090. Which function to use when comparing metadata value and @code{value}.
  7091. Can be one of following:
  7092. @table @samp
  7093. @item same_str
  7094. Values are interpreted as strings, returns true if metadata value is same as @code{value}.
  7095. @item starts_with
  7096. Values are interpreted as strings, returns true if metadata value starts with
  7097. the @code{value} option string.
  7098. @item less
  7099. Values are interpreted as floats, returns true if metadata value is less than @code{value}.
  7100. @item equal
  7101. Values are interpreted as floats, returns true if @code{value} is equal with metadata value.
  7102. @item greater
  7103. Values are interpreted as floats, returns true if metadata value is greater than @code{value}.
  7104. @item expr
  7105. Values are interpreted as floats, returns true if expression from option @code{expr}
  7106. evaluates to true.
  7107. @end table
  7108. @item expr
  7109. Set expression which is used when @code{function} is set to @code{expr}.
  7110. The expression is evaluated through the eval API and can contain the following
  7111. constants:
  7112. @table @option
  7113. @item VALUE1
  7114. Float representation of @code{value} from metadata key.
  7115. @item VALUE2
  7116. Float representation of @code{value} as supplied by user in @code{value} option.
  7117. @end table
  7118. @item file
  7119. If specified in @code{print} mode, output is written to the named file. When
  7120. filename equals "-" data is written to standard output.
  7121. If @code{file} option is not set, output is written to the log with AV_LOG_INFO
  7122. loglevel.
  7123. @end table
  7124. @subsection Examples
  7125. @itemize
  7126. @item
  7127. Print all metadata values for frames with key @code{lavfi.singnalstats.YDIF} with values
  7128. between 0 and 1.
  7129. @example
  7130. @end example
  7131. signalstats,metadata=print:key=lavfi.signalstats.YDIF:value=0:function=expr:expr='between(VALUE1,0,1)'
  7132. @end itemize
  7133. @section mpdecimate
  7134. Drop frames that do not differ greatly from the previous frame in
  7135. order to reduce frame rate.
  7136. The main use of this filter is for very-low-bitrate encoding
  7137. (e.g. streaming over dialup modem), but it could in theory be used for
  7138. fixing movies that were inverse-telecined incorrectly.
  7139. A description of the accepted options follows.
  7140. @table @option
  7141. @item max
  7142. Set the maximum number of consecutive frames which can be dropped (if
  7143. positive), or the minimum interval between dropped frames (if
  7144. negative). If the value is 0, the frame is dropped unregarding the
  7145. number of previous sequentially dropped frames.
  7146. Default value is 0.
  7147. @item hi
  7148. @item lo
  7149. @item frac
  7150. Set the dropping threshold values.
  7151. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  7152. represent actual pixel value differences, so a threshold of 64
  7153. corresponds to 1 unit of difference for each pixel, or the same spread
  7154. out differently over the block.
  7155. A frame is a candidate for dropping if no 8x8 blocks differ by more
  7156. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  7157. meaning the whole image) differ by more than a threshold of @option{lo}.
  7158. Default value for @option{hi} is 64*12, default value for @option{lo} is
  7159. 64*5, and default value for @option{frac} is 0.33.
  7160. @end table
  7161. @section negate
  7162. Negate input video.
  7163. It accepts an integer in input; if non-zero it negates the
  7164. alpha component (if available). The default value in input is 0.
  7165. @section nnedi
  7166. Deinterlace video using neural network edge directed interpolation.
  7167. This filter accepts the following options:
  7168. @table @option
  7169. @item weights
  7170. Mandatory option, without binary file filter can not work.
  7171. Currently file can be found here:
  7172. https://github.com/dubhater/vapoursynth-nnedi3/blob/master/src/nnedi3_weights.bin
  7173. @item deint
  7174. Set which frames to deinterlace, by default it is @code{all}.
  7175. Can be @code{all} or @code{interlaced}.
  7176. @item field
  7177. Set mode of operation.
  7178. Can be one of the following:
  7179. @table @samp
  7180. @item af
  7181. Use frame flags, both fields.
  7182. @item a
  7183. Use frame flags, single field.
  7184. @item t
  7185. Use top field only.
  7186. @item b
  7187. Use bottom field only.
  7188. @item tf
  7189. Use both fields, top first.
  7190. @item bf
  7191. Use both fields, bottom first.
  7192. @end table
  7193. @item planes
  7194. Set which planes to process, by default filter process all frames.
  7195. @item nsize
  7196. Set size of local neighborhood around each pixel, used by the predictor neural
  7197. network.
  7198. Can be one of the following:
  7199. @table @samp
  7200. @item s8x6
  7201. @item s16x6
  7202. @item s32x6
  7203. @item s48x6
  7204. @item s8x4
  7205. @item s16x4
  7206. @item s32x4
  7207. @end table
  7208. @item nns
  7209. Set the number of neurons in predicctor neural network.
  7210. Can be one of the following:
  7211. @table @samp
  7212. @item n16
  7213. @item n32
  7214. @item n64
  7215. @item n128
  7216. @item n256
  7217. @end table
  7218. @item qual
  7219. Controls the number of different neural network predictions that are blended
  7220. together to compute the final output value. Can be @code{fast}, default or
  7221. @code{slow}.
  7222. @item etype
  7223. Set which set of weights to use in the predictor.
  7224. Can be one of the following:
  7225. @table @samp
  7226. @item a
  7227. weights trained to minimize absolute error
  7228. @item s
  7229. weights trained to minimize squared error
  7230. @end table
  7231. @item pscrn
  7232. Controls whether or not the prescreener neural network is used to decide
  7233. which pixels should be processed by the predictor neural network and which
  7234. can be handled by simple cubic interpolation.
  7235. The prescreener is trained to know whether cubic interpolation will be
  7236. sufficient for a pixel or whether it should be predicted by the predictor nn.
  7237. The computational complexity of the prescreener nn is much less than that of
  7238. the predictor nn. Since most pixels can be handled by cubic interpolation,
  7239. using the prescreener generally results in much faster processing.
  7240. The prescreener is pretty accurate, so the difference between using it and not
  7241. using it is almost always unnoticeable.
  7242. Can be one of the following:
  7243. @table @samp
  7244. @item none
  7245. @item original
  7246. @item new
  7247. @end table
  7248. Default is @code{new}.
  7249. @item fapprox
  7250. Set various debugging flags.
  7251. @end table
  7252. @section noformat
  7253. Force libavfilter not to use any of the specified pixel formats for the
  7254. input to the next filter.
  7255. It accepts the following parameters:
  7256. @table @option
  7257. @item pix_fmts
  7258. A '|'-separated list of pixel format names, such as
  7259. apix_fmts=yuv420p|monow|rgb24".
  7260. @end table
  7261. @subsection Examples
  7262. @itemize
  7263. @item
  7264. Force libavfilter to use a format different from @var{yuv420p} for the
  7265. input to the vflip filter:
  7266. @example
  7267. noformat=pix_fmts=yuv420p,vflip
  7268. @end example
  7269. @item
  7270. Convert the input video to any of the formats not contained in the list:
  7271. @example
  7272. noformat=yuv420p|yuv444p|yuv410p
  7273. @end example
  7274. @end itemize
  7275. @section noise
  7276. Add noise on video input frame.
  7277. The filter accepts the following options:
  7278. @table @option
  7279. @item all_seed
  7280. @item c0_seed
  7281. @item c1_seed
  7282. @item c2_seed
  7283. @item c3_seed
  7284. Set noise seed for specific pixel component or all pixel components in case
  7285. of @var{all_seed}. Default value is @code{123457}.
  7286. @item all_strength, alls
  7287. @item c0_strength, c0s
  7288. @item c1_strength, c1s
  7289. @item c2_strength, c2s
  7290. @item c3_strength, c3s
  7291. Set noise strength for specific pixel component or all pixel components in case
  7292. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  7293. @item all_flags, allf
  7294. @item c0_flags, c0f
  7295. @item c1_flags, c1f
  7296. @item c2_flags, c2f
  7297. @item c3_flags, c3f
  7298. Set pixel component flags or set flags for all components if @var{all_flags}.
  7299. Available values for component flags are:
  7300. @table @samp
  7301. @item a
  7302. averaged temporal noise (smoother)
  7303. @item p
  7304. mix random noise with a (semi)regular pattern
  7305. @item t
  7306. temporal noise (noise pattern changes between frames)
  7307. @item u
  7308. uniform noise (gaussian otherwise)
  7309. @end table
  7310. @end table
  7311. @subsection Examples
  7312. Add temporal and uniform noise to input video:
  7313. @example
  7314. noise=alls=20:allf=t+u
  7315. @end example
  7316. @section null
  7317. Pass the video source unchanged to the output.
  7318. @section ocr
  7319. Optical Character Recognition
  7320. This filter uses Tesseract for optical character recognition.
  7321. It accepts the following options:
  7322. @table @option
  7323. @item datapath
  7324. Set datapath to tesseract data. Default is to use whatever was
  7325. set at installation.
  7326. @item language
  7327. Set language, default is "eng".
  7328. @item whitelist
  7329. Set character whitelist.
  7330. @item blacklist
  7331. Set character blacklist.
  7332. @end table
  7333. The filter exports recognized text as the frame metadata @code{lavfi.ocr.text}.
  7334. @section ocv
  7335. Apply a video transform using libopencv.
  7336. To enable this filter, install the libopencv library and headers and
  7337. configure FFmpeg with @code{--enable-libopencv}.
  7338. It accepts the following parameters:
  7339. @table @option
  7340. @item filter_name
  7341. The name of the libopencv filter to apply.
  7342. @item filter_params
  7343. The parameters to pass to the libopencv filter. If not specified, the default
  7344. values are assumed.
  7345. @end table
  7346. Refer to the official libopencv documentation for more precise
  7347. information:
  7348. @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
  7349. Several libopencv filters are supported; see the following subsections.
  7350. @anchor{dilate}
  7351. @subsection dilate
  7352. Dilate an image by using a specific structuring element.
  7353. It corresponds to the libopencv function @code{cvDilate}.
  7354. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  7355. @var{struct_el} represents a structuring element, and has the syntax:
  7356. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  7357. @var{cols} and @var{rows} represent the number of columns and rows of
  7358. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  7359. point, and @var{shape} the shape for the structuring element. @var{shape}
  7360. must be "rect", "cross", "ellipse", or "custom".
  7361. If the value for @var{shape} is "custom", it must be followed by a
  7362. string of the form "=@var{filename}". The file with name
  7363. @var{filename} is assumed to represent a binary image, with each
  7364. printable character corresponding to a bright pixel. When a custom
  7365. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  7366. or columns and rows of the read file are assumed instead.
  7367. The default value for @var{struct_el} is "3x3+0x0/rect".
  7368. @var{nb_iterations} specifies the number of times the transform is
  7369. applied to the image, and defaults to 1.
  7370. Some examples:
  7371. @example
  7372. # Use the default values
  7373. ocv=dilate
  7374. # Dilate using a structuring element with a 5x5 cross, iterating two times
  7375. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  7376. # Read the shape from the file diamond.shape, iterating two times.
  7377. # The file diamond.shape may contain a pattern of characters like this
  7378. # *
  7379. # ***
  7380. # *****
  7381. # ***
  7382. # *
  7383. # The specified columns and rows are ignored
  7384. # but the anchor point coordinates are not
  7385. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  7386. @end example
  7387. @subsection erode
  7388. Erode an image by using a specific structuring element.
  7389. It corresponds to the libopencv function @code{cvErode}.
  7390. It accepts the parameters: @var{struct_el}:@var{nb_iterations},
  7391. with the same syntax and semantics as the @ref{dilate} filter.
  7392. @subsection smooth
  7393. Smooth the input video.
  7394. The filter takes the following parameters:
  7395. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  7396. @var{type} is the type of smooth filter to apply, and must be one of
  7397. the following values: "blur", "blur_no_scale", "median", "gaussian",
  7398. or "bilateral". The default value is "gaussian".
  7399. The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
  7400. depend on the smooth type. @var{param1} and
  7401. @var{param2} accept integer positive values or 0. @var{param3} and
  7402. @var{param4} accept floating point values.
  7403. The default value for @var{param1} is 3. The default value for the
  7404. other parameters is 0.
  7405. These parameters correspond to the parameters assigned to the
  7406. libopencv function @code{cvSmooth}.
  7407. @anchor{overlay}
  7408. @section overlay
  7409. Overlay one video on top of another.
  7410. It takes two inputs and has one output. The first input is the "main"
  7411. video on which the second input is overlaid.
  7412. It accepts the following parameters:
  7413. A description of the accepted options follows.
  7414. @table @option
  7415. @item x
  7416. @item y
  7417. Set the expression for the x and y coordinates of the overlaid video
  7418. on the main video. Default value is "0" for both expressions. In case
  7419. the expression is invalid, it is set to a huge value (meaning that the
  7420. overlay will not be displayed within the output visible area).
  7421. @item eof_action
  7422. The action to take when EOF is encountered on the secondary input; it accepts
  7423. one of the following values:
  7424. @table @option
  7425. @item repeat
  7426. Repeat the last frame (the default).
  7427. @item endall
  7428. End both streams.
  7429. @item pass
  7430. Pass the main input through.
  7431. @end table
  7432. @item eval
  7433. Set when the expressions for @option{x}, and @option{y} are evaluated.
  7434. It accepts the following values:
  7435. @table @samp
  7436. @item init
  7437. only evaluate expressions once during the filter initialization or
  7438. when a command is processed
  7439. @item frame
  7440. evaluate expressions for each incoming frame
  7441. @end table
  7442. Default value is @samp{frame}.
  7443. @item shortest
  7444. If set to 1, force the output to terminate when the shortest input
  7445. terminates. Default value is 0.
  7446. @item format
  7447. Set the format for the output video.
  7448. It accepts the following values:
  7449. @table @samp
  7450. @item yuv420
  7451. force YUV420 output
  7452. @item yuv422
  7453. force YUV422 output
  7454. @item yuv444
  7455. force YUV444 output
  7456. @item rgb
  7457. force RGB output
  7458. @end table
  7459. Default value is @samp{yuv420}.
  7460. @item rgb @emph{(deprecated)}
  7461. If set to 1, force the filter to accept inputs in the RGB
  7462. color space. Default value is 0. This option is deprecated, use
  7463. @option{format} instead.
  7464. @item repeatlast
  7465. If set to 1, force the filter to draw the last overlay frame over the
  7466. main input until the end of the stream. A value of 0 disables this
  7467. behavior. Default value is 1.
  7468. @end table
  7469. The @option{x}, and @option{y} expressions can contain the following
  7470. parameters.
  7471. @table @option
  7472. @item main_w, W
  7473. @item main_h, H
  7474. The main input width and height.
  7475. @item overlay_w, w
  7476. @item overlay_h, h
  7477. The overlay input width and height.
  7478. @item x
  7479. @item y
  7480. The computed values for @var{x} and @var{y}. They are evaluated for
  7481. each new frame.
  7482. @item hsub
  7483. @item vsub
  7484. horizontal and vertical chroma subsample values of the output
  7485. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  7486. @var{vsub} is 1.
  7487. @item n
  7488. the number of input frame, starting from 0
  7489. @item pos
  7490. the position in the file of the input frame, NAN if unknown
  7491. @item t
  7492. The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
  7493. @end table
  7494. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  7495. when evaluation is done @emph{per frame}, and will evaluate to NAN
  7496. when @option{eval} is set to @samp{init}.
  7497. Be aware that frames are taken from each input video in timestamp
  7498. order, hence, if their initial timestamps differ, it is a good idea
  7499. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  7500. have them begin in the same zero timestamp, as the example for
  7501. the @var{movie} filter does.
  7502. You can chain together more overlays but you should test the
  7503. efficiency of such approach.
  7504. @subsection Commands
  7505. This filter supports the following commands:
  7506. @table @option
  7507. @item x
  7508. @item y
  7509. Modify the x and y of the overlay input.
  7510. The command accepts the same syntax of the corresponding option.
  7511. If the specified expression is not valid, it is kept at its current
  7512. value.
  7513. @end table
  7514. @subsection Examples
  7515. @itemize
  7516. @item
  7517. Draw the overlay at 10 pixels from the bottom right corner of the main
  7518. video:
  7519. @example
  7520. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  7521. @end example
  7522. Using named options the example above becomes:
  7523. @example
  7524. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  7525. @end example
  7526. @item
  7527. Insert a transparent PNG logo in the bottom left corner of the input,
  7528. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  7529. @example
  7530. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  7531. @end example
  7532. @item
  7533. Insert 2 different transparent PNG logos (second logo on bottom
  7534. right corner) using the @command{ffmpeg} tool:
  7535. @example
  7536. 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
  7537. @end example
  7538. @item
  7539. Add a transparent color layer on top of the main video; @code{WxH}
  7540. must specify the size of the main input to the overlay filter:
  7541. @example
  7542. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  7543. @end example
  7544. @item
  7545. Play an original video and a filtered version (here with the deshake
  7546. filter) side by side using the @command{ffplay} tool:
  7547. @example
  7548. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  7549. @end example
  7550. The above command is the same as:
  7551. @example
  7552. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  7553. @end example
  7554. @item
  7555. Make a sliding overlay appearing from the left to the right top part of the
  7556. screen starting since time 2:
  7557. @example
  7558. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  7559. @end example
  7560. @item
  7561. Compose output by putting two input videos side to side:
  7562. @example
  7563. ffmpeg -i left.avi -i right.avi -filter_complex "
  7564. nullsrc=size=200x100 [background];
  7565. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  7566. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  7567. [background][left] overlay=shortest=1 [background+left];
  7568. [background+left][right] overlay=shortest=1:x=100 [left+right]
  7569. "
  7570. @end example
  7571. @item
  7572. Mask 10-20 seconds of a video by applying the delogo filter to a section
  7573. @example
  7574. ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
  7575. -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]'
  7576. masked.avi
  7577. @end example
  7578. @item
  7579. Chain several overlays in cascade:
  7580. @example
  7581. nullsrc=s=200x200 [bg];
  7582. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  7583. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  7584. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  7585. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  7586. [in3] null, [mid2] overlay=100:100 [out0]
  7587. @end example
  7588. @end itemize
  7589. @section owdenoise
  7590. Apply Overcomplete Wavelet denoiser.
  7591. The filter accepts the following options:
  7592. @table @option
  7593. @item depth
  7594. Set depth.
  7595. Larger depth values will denoise lower frequency components more, but
  7596. slow down filtering.
  7597. Must be an int in the range 8-16, default is @code{8}.
  7598. @item luma_strength, ls
  7599. Set luma strength.
  7600. Must be a double value in the range 0-1000, default is @code{1.0}.
  7601. @item chroma_strength, cs
  7602. Set chroma strength.
  7603. Must be a double value in the range 0-1000, default is @code{1.0}.
  7604. @end table
  7605. @anchor{pad}
  7606. @section pad
  7607. Add paddings to the input image, and place the original input at the
  7608. provided @var{x}, @var{y} coordinates.
  7609. It accepts the following parameters:
  7610. @table @option
  7611. @item width, w
  7612. @item height, h
  7613. Specify an expression for the size of the output image with the
  7614. paddings added. If the value for @var{width} or @var{height} is 0, the
  7615. corresponding input size is used for the output.
  7616. The @var{width} expression can reference the value set by the
  7617. @var{height} expression, and vice versa.
  7618. The default value of @var{width} and @var{height} is 0.
  7619. @item x
  7620. @item y
  7621. Specify the offsets to place the input image at within the padded area,
  7622. with respect to the top/left border of the output image.
  7623. The @var{x} expression can reference the value set by the @var{y}
  7624. expression, and vice versa.
  7625. The default value of @var{x} and @var{y} is 0.
  7626. @item color
  7627. Specify the color of the padded area. For the syntax of this option,
  7628. check the "Color" section in the ffmpeg-utils manual.
  7629. The default value of @var{color} is "black".
  7630. @end table
  7631. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  7632. options are expressions containing the following constants:
  7633. @table @option
  7634. @item in_w
  7635. @item in_h
  7636. The input video width and height.
  7637. @item iw
  7638. @item ih
  7639. These are the same as @var{in_w} and @var{in_h}.
  7640. @item out_w
  7641. @item out_h
  7642. The output width and height (the size of the padded area), as
  7643. specified by the @var{width} and @var{height} expressions.
  7644. @item ow
  7645. @item oh
  7646. These are the same as @var{out_w} and @var{out_h}.
  7647. @item x
  7648. @item y
  7649. The x and y offsets as specified by the @var{x} and @var{y}
  7650. expressions, or NAN if not yet specified.
  7651. @item a
  7652. same as @var{iw} / @var{ih}
  7653. @item sar
  7654. input sample aspect ratio
  7655. @item dar
  7656. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  7657. @item hsub
  7658. @item vsub
  7659. The horizontal and vertical chroma subsample values. For example for the
  7660. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7661. @end table
  7662. @subsection Examples
  7663. @itemize
  7664. @item
  7665. Add paddings with the color "violet" to the input video. The output video
  7666. size is 640x480, and the top-left corner of the input video is placed at
  7667. column 0, row 40
  7668. @example
  7669. pad=640:480:0:40:violet
  7670. @end example
  7671. The example above is equivalent to the following command:
  7672. @example
  7673. pad=width=640:height=480:x=0:y=40:color=violet
  7674. @end example
  7675. @item
  7676. Pad the input to get an output with dimensions increased by 3/2,
  7677. and put the input video at the center of the padded area:
  7678. @example
  7679. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  7680. @end example
  7681. @item
  7682. Pad the input to get a squared output with size equal to the maximum
  7683. value between the input width and height, and put the input video at
  7684. the center of the padded area:
  7685. @example
  7686. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  7687. @end example
  7688. @item
  7689. Pad the input to get a final w/h ratio of 16:9:
  7690. @example
  7691. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  7692. @end example
  7693. @item
  7694. In case of anamorphic video, in order to set the output display aspect
  7695. correctly, it is necessary to use @var{sar} in the expression,
  7696. according to the relation:
  7697. @example
  7698. (ih * X / ih) * sar = output_dar
  7699. X = output_dar / sar
  7700. @end example
  7701. Thus the previous example needs to be modified to:
  7702. @example
  7703. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  7704. @end example
  7705. @item
  7706. Double the output size and put the input video in the bottom-right
  7707. corner of the output padded area:
  7708. @example
  7709. pad="2*iw:2*ih:ow-iw:oh-ih"
  7710. @end example
  7711. @end itemize
  7712. @anchor{palettegen}
  7713. @section palettegen
  7714. Generate one palette for a whole video stream.
  7715. It accepts the following options:
  7716. @table @option
  7717. @item max_colors
  7718. Set the maximum number of colors to quantize in the palette.
  7719. Note: the palette will still contain 256 colors; the unused palette entries
  7720. will be black.
  7721. @item reserve_transparent
  7722. Create a palette of 255 colors maximum and reserve the last one for
  7723. transparency. Reserving the transparency color is useful for GIF optimization.
  7724. If not set, the maximum of colors in the palette will be 256. You probably want
  7725. to disable this option for a standalone image.
  7726. Set by default.
  7727. @item stats_mode
  7728. Set statistics mode.
  7729. It accepts the following values:
  7730. @table @samp
  7731. @item full
  7732. Compute full frame histograms.
  7733. @item diff
  7734. Compute histograms only for the part that differs from previous frame. This
  7735. might be relevant to give more importance to the moving part of your input if
  7736. the background is static.
  7737. @end table
  7738. Default value is @var{full}.
  7739. @end table
  7740. The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
  7741. (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
  7742. color quantization of the palette. This information is also visible at
  7743. @var{info} logging level.
  7744. @subsection Examples
  7745. @itemize
  7746. @item
  7747. Generate a representative palette of a given video using @command{ffmpeg}:
  7748. @example
  7749. ffmpeg -i input.mkv -vf palettegen palette.png
  7750. @end example
  7751. @end itemize
  7752. @section paletteuse
  7753. Use a palette to downsample an input video stream.
  7754. The filter takes two inputs: one video stream and a palette. The palette must
  7755. be a 256 pixels image.
  7756. It accepts the following options:
  7757. @table @option
  7758. @item dither
  7759. Select dithering mode. Available algorithms are:
  7760. @table @samp
  7761. @item bayer
  7762. Ordered 8x8 bayer dithering (deterministic)
  7763. @item heckbert
  7764. Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
  7765. Note: this dithering is sometimes considered "wrong" and is included as a
  7766. reference.
  7767. @item floyd_steinberg
  7768. Floyd and Steingberg dithering (error diffusion)
  7769. @item sierra2
  7770. Frankie Sierra dithering v2 (error diffusion)
  7771. @item sierra2_4a
  7772. Frankie Sierra dithering v2 "Lite" (error diffusion)
  7773. @end table
  7774. Default is @var{sierra2_4a}.
  7775. @item bayer_scale
  7776. When @var{bayer} dithering is selected, this option defines the scale of the
  7777. pattern (how much the crosshatch pattern is visible). A low value means more
  7778. visible pattern for less banding, and higher value means less visible pattern
  7779. at the cost of more banding.
  7780. The option must be an integer value in the range [0,5]. Default is @var{2}.
  7781. @item diff_mode
  7782. If set, define the zone to process
  7783. @table @samp
  7784. @item rectangle
  7785. Only the changing rectangle will be reprocessed. This is similar to GIF
  7786. cropping/offsetting compression mechanism. This option can be useful for speed
  7787. if only a part of the image is changing, and has use cases such as limiting the
  7788. scope of the error diffusal @option{dither} to the rectangle that bounds the
  7789. moving scene (it leads to more deterministic output if the scene doesn't change
  7790. much, and as a result less moving noise and better GIF compression).
  7791. @end table
  7792. Default is @var{none}.
  7793. @end table
  7794. @subsection Examples
  7795. @itemize
  7796. @item
  7797. Use a palette (generated for example with @ref{palettegen}) to encode a GIF
  7798. using @command{ffmpeg}:
  7799. @example
  7800. ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
  7801. @end example
  7802. @end itemize
  7803. @section perspective
  7804. Correct perspective of video not recorded perpendicular to the screen.
  7805. A description of the accepted parameters follows.
  7806. @table @option
  7807. @item x0
  7808. @item y0
  7809. @item x1
  7810. @item y1
  7811. @item x2
  7812. @item y2
  7813. @item x3
  7814. @item y3
  7815. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  7816. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  7817. If the @code{sense} option is set to @code{source}, then the specified points will be sent
  7818. to the corners of the destination. If the @code{sense} option is set to @code{destination},
  7819. then the corners of the source will be sent to the specified coordinates.
  7820. The expressions can use the following variables:
  7821. @table @option
  7822. @item W
  7823. @item H
  7824. the width and height of video frame.
  7825. @item in
  7826. Input frame count.
  7827. @item on
  7828. Output frame count.
  7829. @end table
  7830. @item interpolation
  7831. Set interpolation for perspective correction.
  7832. It accepts the following values:
  7833. @table @samp
  7834. @item linear
  7835. @item cubic
  7836. @end table
  7837. Default value is @samp{linear}.
  7838. @item sense
  7839. Set interpretation of coordinate options.
  7840. It accepts the following values:
  7841. @table @samp
  7842. @item 0, source
  7843. Send point in the source specified by the given coordinates to
  7844. the corners of the destination.
  7845. @item 1, destination
  7846. Send the corners of the source to the point in the destination specified
  7847. by the given coordinates.
  7848. Default value is @samp{source}.
  7849. @end table
  7850. @item eval
  7851. Set when the expressions for coordinates @option{x0,y0,...x3,y3} are evaluated.
  7852. It accepts the following values:
  7853. @table @samp
  7854. @item init
  7855. only evaluate expressions once during the filter initialization or
  7856. when a command is processed
  7857. @item frame
  7858. evaluate expressions for each incoming frame
  7859. @end table
  7860. Default value is @samp{init}.
  7861. @end table
  7862. @section phase
  7863. Delay interlaced video by one field time so that the field order changes.
  7864. The intended use is to fix PAL movies that have been captured with the
  7865. opposite field order to the film-to-video transfer.
  7866. A description of the accepted parameters follows.
  7867. @table @option
  7868. @item mode
  7869. Set phase mode.
  7870. It accepts the following values:
  7871. @table @samp
  7872. @item t
  7873. Capture field order top-first, transfer bottom-first.
  7874. Filter will delay the bottom field.
  7875. @item b
  7876. Capture field order bottom-first, transfer top-first.
  7877. Filter will delay the top field.
  7878. @item p
  7879. Capture and transfer with the same field order. This mode only exists
  7880. for the documentation of the other options to refer to, but if you
  7881. actually select it, the filter will faithfully do nothing.
  7882. @item a
  7883. Capture field order determined automatically by field flags, transfer
  7884. opposite.
  7885. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  7886. basis using field flags. If no field information is available,
  7887. then this works just like @samp{u}.
  7888. @item u
  7889. Capture unknown or varying, transfer opposite.
  7890. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  7891. analyzing the images and selecting the alternative that produces best
  7892. match between the fields.
  7893. @item T
  7894. Capture top-first, transfer unknown or varying.
  7895. Filter selects among @samp{t} and @samp{p} using image analysis.
  7896. @item B
  7897. Capture bottom-first, transfer unknown or varying.
  7898. Filter selects among @samp{b} and @samp{p} using image analysis.
  7899. @item A
  7900. Capture determined by field flags, transfer unknown or varying.
  7901. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  7902. image analysis. If no field information is available, then this works just
  7903. like @samp{U}. This is the default mode.
  7904. @item U
  7905. Both capture and transfer unknown or varying.
  7906. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  7907. @end table
  7908. @end table
  7909. @section pixdesctest
  7910. Pixel format descriptor test filter, mainly useful for internal
  7911. testing. The output video should be equal to the input video.
  7912. For example:
  7913. @example
  7914. format=monow, pixdesctest
  7915. @end example
  7916. can be used to test the monowhite pixel format descriptor definition.
  7917. @section pp
  7918. Enable the specified chain of postprocessing subfilters using libpostproc. This
  7919. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  7920. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  7921. Each subfilter and some options have a short and a long name that can be used
  7922. interchangeably, i.e. dr/dering are the same.
  7923. The filters accept the following options:
  7924. @table @option
  7925. @item subfilters
  7926. Set postprocessing subfilters string.
  7927. @end table
  7928. All subfilters share common options to determine their scope:
  7929. @table @option
  7930. @item a/autoq
  7931. Honor the quality commands for this subfilter.
  7932. @item c/chrom
  7933. Do chrominance filtering, too (default).
  7934. @item y/nochrom
  7935. Do luminance filtering only (no chrominance).
  7936. @item n/noluma
  7937. Do chrominance filtering only (no luminance).
  7938. @end table
  7939. These options can be appended after the subfilter name, separated by a '|'.
  7940. Available subfilters are:
  7941. @table @option
  7942. @item hb/hdeblock[|difference[|flatness]]
  7943. Horizontal deblocking filter
  7944. @table @option
  7945. @item difference
  7946. Difference factor where higher values mean more deblocking (default: @code{32}).
  7947. @item flatness
  7948. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7949. @end table
  7950. @item vb/vdeblock[|difference[|flatness]]
  7951. Vertical deblocking filter
  7952. @table @option
  7953. @item difference
  7954. Difference factor where higher values mean more deblocking (default: @code{32}).
  7955. @item flatness
  7956. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7957. @end table
  7958. @item ha/hadeblock[|difference[|flatness]]
  7959. Accurate horizontal deblocking filter
  7960. @table @option
  7961. @item difference
  7962. Difference factor where higher values mean more deblocking (default: @code{32}).
  7963. @item flatness
  7964. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7965. @end table
  7966. @item va/vadeblock[|difference[|flatness]]
  7967. Accurate vertical deblocking filter
  7968. @table @option
  7969. @item difference
  7970. Difference factor where higher values mean more deblocking (default: @code{32}).
  7971. @item flatness
  7972. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7973. @end table
  7974. @end table
  7975. The horizontal and vertical deblocking filters share the difference and
  7976. flatness values so you cannot set different horizontal and vertical
  7977. thresholds.
  7978. @table @option
  7979. @item h1/x1hdeblock
  7980. Experimental horizontal deblocking filter
  7981. @item v1/x1vdeblock
  7982. Experimental vertical deblocking filter
  7983. @item dr/dering
  7984. Deringing filter
  7985. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  7986. @table @option
  7987. @item threshold1
  7988. larger -> stronger filtering
  7989. @item threshold2
  7990. larger -> stronger filtering
  7991. @item threshold3
  7992. larger -> stronger filtering
  7993. @end table
  7994. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  7995. @table @option
  7996. @item f/fullyrange
  7997. Stretch luminance to @code{0-255}.
  7998. @end table
  7999. @item lb/linblenddeint
  8000. Linear blend deinterlacing filter that deinterlaces the given block by
  8001. filtering all lines with a @code{(1 2 1)} filter.
  8002. @item li/linipoldeint
  8003. Linear interpolating deinterlacing filter that deinterlaces the given block by
  8004. linearly interpolating every second line.
  8005. @item ci/cubicipoldeint
  8006. Cubic interpolating deinterlacing filter deinterlaces the given block by
  8007. cubically interpolating every second line.
  8008. @item md/mediandeint
  8009. Median deinterlacing filter that deinterlaces the given block by applying a
  8010. median filter to every second line.
  8011. @item fd/ffmpegdeint
  8012. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  8013. second line with a @code{(-1 4 2 4 -1)} filter.
  8014. @item l5/lowpass5
  8015. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  8016. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  8017. @item fq/forceQuant[|quantizer]
  8018. Overrides the quantizer table from the input with the constant quantizer you
  8019. specify.
  8020. @table @option
  8021. @item quantizer
  8022. Quantizer to use
  8023. @end table
  8024. @item de/default
  8025. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  8026. @item fa/fast
  8027. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  8028. @item ac
  8029. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  8030. @end table
  8031. @subsection Examples
  8032. @itemize
  8033. @item
  8034. Apply horizontal and vertical deblocking, deringing and automatic
  8035. brightness/contrast:
  8036. @example
  8037. pp=hb/vb/dr/al
  8038. @end example
  8039. @item
  8040. Apply default filters without brightness/contrast correction:
  8041. @example
  8042. pp=de/-al
  8043. @end example
  8044. @item
  8045. Apply default filters and temporal denoiser:
  8046. @example
  8047. pp=default/tmpnoise|1|2|3
  8048. @end example
  8049. @item
  8050. Apply deblocking on luminance only, and switch vertical deblocking on or off
  8051. automatically depending on available CPU time:
  8052. @example
  8053. pp=hb|y/vb|a
  8054. @end example
  8055. @end itemize
  8056. @section pp7
  8057. Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
  8058. similar to spp = 6 with 7 point DCT, where only the center sample is
  8059. used after IDCT.
  8060. The filter accepts the following options:
  8061. @table @option
  8062. @item qp
  8063. Force a constant quantization parameter. It accepts an integer in range
  8064. 0 to 63. If not set, the filter will use the QP from the video stream
  8065. (if available).
  8066. @item mode
  8067. Set thresholding mode. Available modes are:
  8068. @table @samp
  8069. @item hard
  8070. Set hard thresholding.
  8071. @item soft
  8072. Set soft thresholding (better de-ringing effect, but likely blurrier).
  8073. @item medium
  8074. Set medium thresholding (good results, default).
  8075. @end table
  8076. @end table
  8077. @section psnr
  8078. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  8079. Ratio) between two input videos.
  8080. This filter takes in input two input videos, the first input is
  8081. considered the "main" source and is passed unchanged to the
  8082. output. The second input is used as a "reference" video for computing
  8083. the PSNR.
  8084. Both video inputs must have the same resolution and pixel format for
  8085. this filter to work correctly. Also it assumes that both inputs
  8086. have the same number of frames, which are compared one by one.
  8087. The obtained average PSNR is printed through the logging system.
  8088. The filter stores the accumulated MSE (mean squared error) of each
  8089. frame, and at the end of the processing it is averaged across all frames
  8090. equally, and the following formula is applied to obtain the PSNR:
  8091. @example
  8092. PSNR = 10*log10(MAX^2/MSE)
  8093. @end example
  8094. Where MAX is the average of the maximum values of each component of the
  8095. image.
  8096. The description of the accepted parameters follows.
  8097. @table @option
  8098. @item stats_file, f
  8099. If specified the filter will use the named file to save the PSNR of
  8100. each individual frame. When filename equals "-" the data is sent to
  8101. standard output.
  8102. @end table
  8103. The file printed if @var{stats_file} is selected, contains a sequence of
  8104. key/value pairs of the form @var{key}:@var{value} for each compared
  8105. couple of frames.
  8106. A description of each shown parameter follows:
  8107. @table @option
  8108. @item n
  8109. sequential number of the input frame, starting from 1
  8110. @item mse_avg
  8111. Mean Square Error pixel-by-pixel average difference of the compared
  8112. frames, averaged over all the image components.
  8113. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  8114. Mean Square Error pixel-by-pixel average difference of the compared
  8115. frames for the component specified by the suffix.
  8116. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  8117. Peak Signal to Noise ratio of the compared frames for the component
  8118. specified by the suffix.
  8119. @end table
  8120. For example:
  8121. @example
  8122. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  8123. [main][ref] psnr="stats_file=stats.log" [out]
  8124. @end example
  8125. On this example the input file being processed is compared with the
  8126. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  8127. is stored in @file{stats.log}.
  8128. @anchor{pullup}
  8129. @section pullup
  8130. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  8131. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  8132. content.
  8133. The pullup filter is designed to take advantage of future context in making
  8134. its decisions. This filter is stateless in the sense that it does not lock
  8135. onto a pattern to follow, but it instead looks forward to the following
  8136. fields in order to identify matches and rebuild progressive frames.
  8137. To produce content with an even framerate, insert the fps filter after
  8138. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  8139. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  8140. The filter accepts the following options:
  8141. @table @option
  8142. @item jl
  8143. @item jr
  8144. @item jt
  8145. @item jb
  8146. These options set the amount of "junk" to ignore at the left, right, top, and
  8147. bottom of the image, respectively. Left and right are in units of 8 pixels,
  8148. while top and bottom are in units of 2 lines.
  8149. The default is 8 pixels on each side.
  8150. @item sb
  8151. Set the strict breaks. Setting this option to 1 will reduce the chances of
  8152. filter generating an occasional mismatched frame, but it may also cause an
  8153. excessive number of frames to be dropped during high motion sequences.
  8154. Conversely, setting it to -1 will make filter match fields more easily.
  8155. This may help processing of video where there is slight blurring between
  8156. the fields, but may also cause there to be interlaced frames in the output.
  8157. Default value is @code{0}.
  8158. @item mp
  8159. Set the metric plane to use. It accepts the following values:
  8160. @table @samp
  8161. @item l
  8162. Use luma plane.
  8163. @item u
  8164. Use chroma blue plane.
  8165. @item v
  8166. Use chroma red plane.
  8167. @end table
  8168. This option may be set to use chroma plane instead of the default luma plane
  8169. for doing filter's computations. This may improve accuracy on very clean
  8170. source material, but more likely will decrease accuracy, especially if there
  8171. is chroma noise (rainbow effect) or any grayscale video.
  8172. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  8173. load and make pullup usable in realtime on slow machines.
  8174. @end table
  8175. For best results (without duplicated frames in the output file) it is
  8176. necessary to change the output frame rate. For example, to inverse
  8177. telecine NTSC input:
  8178. @example
  8179. ffmpeg -i input -vf pullup -r 24000/1001 ...
  8180. @end example
  8181. @section qp
  8182. Change video quantization parameters (QP).
  8183. The filter accepts the following option:
  8184. @table @option
  8185. @item qp
  8186. Set expression for quantization parameter.
  8187. @end table
  8188. The expression is evaluated through the eval API and can contain, among others,
  8189. the following constants:
  8190. @table @var
  8191. @item known
  8192. 1 if index is not 129, 0 otherwise.
  8193. @item qp
  8194. Sequentional index starting from -129 to 128.
  8195. @end table
  8196. @subsection Examples
  8197. @itemize
  8198. @item
  8199. Some equation like:
  8200. @example
  8201. qp=2+2*sin(PI*qp)
  8202. @end example
  8203. @end itemize
  8204. @section random
  8205. Flush video frames from internal cache of frames into a random order.
  8206. No frame is discarded.
  8207. Inspired by @ref{frei0r} nervous filter.
  8208. @table @option
  8209. @item frames
  8210. Set size in number of frames of internal cache, in range from @code{2} to
  8211. @code{512}. Default is @code{30}.
  8212. @item seed
  8213. Set seed for random number generator, must be an integer included between
  8214. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  8215. less than @code{0}, the filter will try to use a good random seed on a
  8216. best effort basis.
  8217. @end table
  8218. @section readvitc
  8219. Read vertical interval timecode (VITC) information from the top lines of a
  8220. video frame.
  8221. The filter adds frame metadata key @code{lavfi.readvitc.tc_str} with the
  8222. timecode value, if a valid timecode has been detected. Further metadata key
  8223. @code{lavfi.readvitc.found} is set to 0/1 depending on whether
  8224. timecode data has been found or not.
  8225. This filter accepts the following options:
  8226. @table @option
  8227. @item scan_max
  8228. Set the maximum number of lines to scan for VITC data. If the value is set to
  8229. @code{-1} the full video frame is scanned. Default is @code{45}.
  8230. @item thr_b
  8231. Set the luma threshold for black. Accepts float numbers in the range [0.0,1.0],
  8232. default value is @code{0.2}. The value must be equal or less than @code{thr_w}.
  8233. @item thr_w
  8234. Set the luma threshold for white. Accepts float numbers in the range [0.0,1.0],
  8235. default value is @code{0.6}. The value must be equal or greater than @code{thr_b}.
  8236. @end table
  8237. @subsection Examples
  8238. @itemize
  8239. @item
  8240. Detect and draw VITC data onto the video frame; if no valid VITC is detected,
  8241. draw @code{--:--:--:--} as a placeholder:
  8242. @example
  8243. ffmpeg -i input.avi -filter:v 'readvitc,drawtext=fontfile=FreeMono.ttf:text=%@{metadata\\:lavfi.readvitc.tc_str\\:--\\\\\\:--\\\\\\:--\\\\\\:--@}:x=(w-tw)/2:y=400-ascent'
  8244. @end example
  8245. @end itemize
  8246. @section remap
  8247. Remap pixels using 2nd: Xmap and 3rd: Ymap input video stream.
  8248. Destination pixel at position (X, Y) will be picked from source (x, y) position
  8249. where x = Xmap(X, Y) and y = Ymap(X, Y). If mapping values are out of range, zero
  8250. value for pixel will be used for destination pixel.
  8251. Xmap and Ymap input video streams must be of same dimensions. Output video stream
  8252. will have Xmap/Ymap video stream dimensions.
  8253. Xmap and Ymap input video streams are 16bit depth, single channel.
  8254. @section removegrain
  8255. The removegrain filter is a spatial denoiser for progressive video.
  8256. @table @option
  8257. @item m0
  8258. Set mode for the first plane.
  8259. @item m1
  8260. Set mode for the second plane.
  8261. @item m2
  8262. Set mode for the third plane.
  8263. @item m3
  8264. Set mode for the fourth plane.
  8265. @end table
  8266. Range of mode is from 0 to 24. Description of each mode follows:
  8267. @table @var
  8268. @item 0
  8269. Leave input plane unchanged. Default.
  8270. @item 1
  8271. Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
  8272. @item 2
  8273. Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
  8274. @item 3
  8275. Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
  8276. @item 4
  8277. Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
  8278. This is equivalent to a median filter.
  8279. @item 5
  8280. Line-sensitive clipping giving the minimal change.
  8281. @item 6
  8282. Line-sensitive clipping, intermediate.
  8283. @item 7
  8284. Line-sensitive clipping, intermediate.
  8285. @item 8
  8286. Line-sensitive clipping, intermediate.
  8287. @item 9
  8288. Line-sensitive clipping on a line where the neighbours pixels are the closest.
  8289. @item 10
  8290. Replaces the target pixel with the closest neighbour.
  8291. @item 11
  8292. [1 2 1] horizontal and vertical kernel blur.
  8293. @item 12
  8294. Same as mode 11.
  8295. @item 13
  8296. Bob mode, interpolates top field from the line where the neighbours
  8297. pixels are the closest.
  8298. @item 14
  8299. Bob mode, interpolates bottom field from the line where the neighbours
  8300. pixels are the closest.
  8301. @item 15
  8302. Bob mode, interpolates top field. Same as 13 but with a more complicated
  8303. interpolation formula.
  8304. @item 16
  8305. Bob mode, interpolates bottom field. Same as 14 but with a more complicated
  8306. interpolation formula.
  8307. @item 17
  8308. Clips the pixel with the minimum and maximum of respectively the maximum and
  8309. minimum of each pair of opposite neighbour pixels.
  8310. @item 18
  8311. Line-sensitive clipping using opposite neighbours whose greatest distance from
  8312. the current pixel is minimal.
  8313. @item 19
  8314. Replaces the pixel with the average of its 8 neighbours.
  8315. @item 20
  8316. Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
  8317. @item 21
  8318. Clips pixels using the averages of opposite neighbour.
  8319. @item 22
  8320. Same as mode 21 but simpler and faster.
  8321. @item 23
  8322. Small edge and halo removal, but reputed useless.
  8323. @item 24
  8324. Similar as 23.
  8325. @end table
  8326. @section removelogo
  8327. Suppress a TV station logo, using an image file to determine which
  8328. pixels comprise the logo. It works by filling in the pixels that
  8329. comprise the logo with neighboring pixels.
  8330. The filter accepts the following options:
  8331. @table @option
  8332. @item filename, f
  8333. Set the filter bitmap file, which can be any image format supported by
  8334. libavformat. The width and height of the image file must match those of the
  8335. video stream being processed.
  8336. @end table
  8337. Pixels in the provided bitmap image with a value of zero are not
  8338. considered part of the logo, non-zero pixels are considered part of
  8339. the logo. If you use white (255) for the logo and black (0) for the
  8340. rest, you will be safe. For making the filter bitmap, it is
  8341. recommended to take a screen capture of a black frame with the logo
  8342. visible, and then using a threshold filter followed by the erode
  8343. filter once or twice.
  8344. If needed, little splotches can be fixed manually. Remember that if
  8345. logo pixels are not covered, the filter quality will be much
  8346. reduced. Marking too many pixels as part of the logo does not hurt as
  8347. much, but it will increase the amount of blurring needed to cover over
  8348. the image and will destroy more information than necessary, and extra
  8349. pixels will slow things down on a large logo.
  8350. @section repeatfields
  8351. This filter uses the repeat_field flag from the Video ES headers and hard repeats
  8352. fields based on its value.
  8353. @section reverse, areverse
  8354. Reverse a clip.
  8355. Warning: This filter requires memory to buffer the entire clip, so trimming
  8356. is suggested.
  8357. @subsection Examples
  8358. @itemize
  8359. @item
  8360. Take the first 5 seconds of a clip, and reverse it.
  8361. @example
  8362. trim=end=5,reverse
  8363. @end example
  8364. @end itemize
  8365. @section rotate
  8366. Rotate video by an arbitrary angle expressed in radians.
  8367. The filter accepts the following options:
  8368. A description of the optional parameters follows.
  8369. @table @option
  8370. @item angle, a
  8371. Set an expression for the angle by which to rotate the input video
  8372. clockwise, expressed as a number of radians. A negative value will
  8373. result in a counter-clockwise rotation. By default it is set to "0".
  8374. This expression is evaluated for each frame.
  8375. @item out_w, ow
  8376. Set the output width expression, default value is "iw".
  8377. This expression is evaluated just once during configuration.
  8378. @item out_h, oh
  8379. Set the output height expression, default value is "ih".
  8380. This expression is evaluated just once during configuration.
  8381. @item bilinear
  8382. Enable bilinear interpolation if set to 1, a value of 0 disables
  8383. it. Default value is 1.
  8384. @item fillcolor, c
  8385. Set the color used to fill the output area not covered by the rotated
  8386. image. For the general syntax of this option, check the "Color" section in the
  8387. ffmpeg-utils manual. If the special value "none" is selected then no
  8388. background is printed (useful for example if the background is never shown).
  8389. Default value is "black".
  8390. @end table
  8391. The expressions for the angle and the output size can contain the
  8392. following constants and functions:
  8393. @table @option
  8394. @item n
  8395. sequential number of the input frame, starting from 0. It is always NAN
  8396. before the first frame is filtered.
  8397. @item t
  8398. time in seconds of the input frame, it is set to 0 when the filter is
  8399. configured. It is always NAN before the first frame is filtered.
  8400. @item hsub
  8401. @item vsub
  8402. horizontal and vertical chroma subsample values. For example for the
  8403. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  8404. @item in_w, iw
  8405. @item in_h, ih
  8406. the input video width and height
  8407. @item out_w, ow
  8408. @item out_h, oh
  8409. the output width and height, that is the size of the padded area as
  8410. specified by the @var{width} and @var{height} expressions
  8411. @item rotw(a)
  8412. @item roth(a)
  8413. the minimal width/height required for completely containing the input
  8414. video rotated by @var{a} radians.
  8415. These are only available when computing the @option{out_w} and
  8416. @option{out_h} expressions.
  8417. @end table
  8418. @subsection Examples
  8419. @itemize
  8420. @item
  8421. Rotate the input by PI/6 radians clockwise:
  8422. @example
  8423. rotate=PI/6
  8424. @end example
  8425. @item
  8426. Rotate the input by PI/6 radians counter-clockwise:
  8427. @example
  8428. rotate=-PI/6
  8429. @end example
  8430. @item
  8431. Rotate the input by 45 degrees clockwise:
  8432. @example
  8433. rotate=45*PI/180
  8434. @end example
  8435. @item
  8436. Apply a constant rotation with period T, starting from an angle of PI/3:
  8437. @example
  8438. rotate=PI/3+2*PI*t/T
  8439. @end example
  8440. @item
  8441. Make the input video rotation oscillating with a period of T
  8442. seconds and an amplitude of A radians:
  8443. @example
  8444. rotate=A*sin(2*PI/T*t)
  8445. @end example
  8446. @item
  8447. Rotate the video, output size is chosen so that the whole rotating
  8448. input video is always completely contained in the output:
  8449. @example
  8450. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  8451. @end example
  8452. @item
  8453. Rotate the video, reduce the output size so that no background is ever
  8454. shown:
  8455. @example
  8456. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  8457. @end example
  8458. @end itemize
  8459. @subsection Commands
  8460. The filter supports the following commands:
  8461. @table @option
  8462. @item a, angle
  8463. Set the angle expression.
  8464. The command accepts the same syntax of the corresponding option.
  8465. If the specified expression is not valid, it is kept at its current
  8466. value.
  8467. @end table
  8468. @section sab
  8469. Apply Shape Adaptive Blur.
  8470. The filter accepts the following options:
  8471. @table @option
  8472. @item luma_radius, lr
  8473. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  8474. value is 1.0. A greater value will result in a more blurred image, and
  8475. in slower processing.
  8476. @item luma_pre_filter_radius, lpfr
  8477. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  8478. value is 1.0.
  8479. @item luma_strength, ls
  8480. Set luma maximum difference between pixels to still be considered, must
  8481. be a value in the 0.1-100.0 range, default value is 1.0.
  8482. @item chroma_radius, cr
  8483. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  8484. greater value will result in a more blurred image, and in slower
  8485. processing.
  8486. @item chroma_pre_filter_radius, cpfr
  8487. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  8488. @item chroma_strength, cs
  8489. Set chroma maximum difference between pixels to still be considered,
  8490. must be a value in the 0.1-100.0 range.
  8491. @end table
  8492. Each chroma option value, if not explicitly specified, is set to the
  8493. corresponding luma option value.
  8494. @anchor{scale}
  8495. @section scale
  8496. Scale (resize) the input video, using the libswscale library.
  8497. The scale filter forces the output display aspect ratio to be the same
  8498. of the input, by changing the output sample aspect ratio.
  8499. If the input image format is different from the format requested by
  8500. the next filter, the scale filter will convert the input to the
  8501. requested format.
  8502. @subsection Options
  8503. The filter accepts the following options, or any of the options
  8504. supported by the libswscale scaler.
  8505. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  8506. the complete list of scaler options.
  8507. @table @option
  8508. @item width, w
  8509. @item height, h
  8510. Set the output video dimension expression. Default value is the input
  8511. dimension.
  8512. If the value is 0, the input width is used for the output.
  8513. If one of the values is -1, the scale filter will use a value that
  8514. maintains the aspect ratio of the input image, calculated from the
  8515. other specified dimension. If both of them are -1, the input size is
  8516. used
  8517. If one of the values is -n with n > 1, the scale filter will also use a value
  8518. that maintains the aspect ratio of the input image, calculated from the other
  8519. specified dimension. After that it will, however, make sure that the calculated
  8520. dimension is divisible by n and adjust the value if necessary.
  8521. See below for the list of accepted constants for use in the dimension
  8522. expression.
  8523. @item eval
  8524. Specify when to evaluate @var{width} and @var{height} expression. It accepts the following values:
  8525. @table @samp
  8526. @item init
  8527. Only evaluate expressions once during the filter initialization or when a command is processed.
  8528. @item frame
  8529. Evaluate expressions for each incoming frame.
  8530. @end table
  8531. Default value is @samp{init}.
  8532. @item interl
  8533. Set the interlacing mode. It accepts the following values:
  8534. @table @samp
  8535. @item 1
  8536. Force interlaced aware scaling.
  8537. @item 0
  8538. Do not apply interlaced scaling.
  8539. @item -1
  8540. Select interlaced aware scaling depending on whether the source frames
  8541. are flagged as interlaced or not.
  8542. @end table
  8543. Default value is @samp{0}.
  8544. @item flags
  8545. Set libswscale scaling flags. See
  8546. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  8547. complete list of values. If not explicitly specified the filter applies
  8548. the default flags.
  8549. @item param0, param1
  8550. Set libswscale input parameters for scaling algorithms that need them. See
  8551. @ref{sws_params,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  8552. complete documentation. If not explicitly specified the filter applies
  8553. empty parameters.
  8554. @item size, s
  8555. Set the video size. For the syntax of this option, check the
  8556. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8557. @item in_color_matrix
  8558. @item out_color_matrix
  8559. Set in/output YCbCr color space type.
  8560. This allows the autodetected value to be overridden as well as allows forcing
  8561. a specific value used for the output and encoder.
  8562. If not specified, the color space type depends on the pixel format.
  8563. Possible values:
  8564. @table @samp
  8565. @item auto
  8566. Choose automatically.
  8567. @item bt709
  8568. Format conforming to International Telecommunication Union (ITU)
  8569. Recommendation BT.709.
  8570. @item fcc
  8571. Set color space conforming to the United States Federal Communications
  8572. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  8573. @item bt601
  8574. Set color space conforming to:
  8575. @itemize
  8576. @item
  8577. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  8578. @item
  8579. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  8580. @item
  8581. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  8582. @end itemize
  8583. @item smpte240m
  8584. Set color space conforming to SMPTE ST 240:1999.
  8585. @end table
  8586. @item in_range
  8587. @item out_range
  8588. Set in/output YCbCr sample range.
  8589. This allows the autodetected value to be overridden as well as allows forcing
  8590. a specific value used for the output and encoder. If not specified, the
  8591. range depends on the pixel format. Possible values:
  8592. @table @samp
  8593. @item auto
  8594. Choose automatically.
  8595. @item jpeg/full/pc
  8596. Set full range (0-255 in case of 8-bit luma).
  8597. @item mpeg/tv
  8598. Set "MPEG" range (16-235 in case of 8-bit luma).
  8599. @end table
  8600. @item force_original_aspect_ratio
  8601. Enable decreasing or increasing output video width or height if necessary to
  8602. keep the original aspect ratio. Possible values:
  8603. @table @samp
  8604. @item disable
  8605. Scale the video as specified and disable this feature.
  8606. @item decrease
  8607. The output video dimensions will automatically be decreased if needed.
  8608. @item increase
  8609. The output video dimensions will automatically be increased if needed.
  8610. @end table
  8611. One useful instance of this option is that when you know a specific device's
  8612. maximum allowed resolution, you can use this to limit the output video to
  8613. that, while retaining the aspect ratio. For example, device A allows
  8614. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  8615. decrease) and specifying 1280x720 to the command line makes the output
  8616. 1280x533.
  8617. Please note that this is a different thing than specifying -1 for @option{w}
  8618. or @option{h}, you still need to specify the output resolution for this option
  8619. to work.
  8620. @end table
  8621. The values of the @option{w} and @option{h} options are expressions
  8622. containing the following constants:
  8623. @table @var
  8624. @item in_w
  8625. @item in_h
  8626. The input width and height
  8627. @item iw
  8628. @item ih
  8629. These are the same as @var{in_w} and @var{in_h}.
  8630. @item out_w
  8631. @item out_h
  8632. The output (scaled) width and height
  8633. @item ow
  8634. @item oh
  8635. These are the same as @var{out_w} and @var{out_h}
  8636. @item a
  8637. The same as @var{iw} / @var{ih}
  8638. @item sar
  8639. input sample aspect ratio
  8640. @item dar
  8641. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  8642. @item hsub
  8643. @item vsub
  8644. horizontal and vertical input chroma subsample values. For example for the
  8645. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  8646. @item ohsub
  8647. @item ovsub
  8648. horizontal and vertical output chroma subsample values. For example for the
  8649. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  8650. @end table
  8651. @subsection Examples
  8652. @itemize
  8653. @item
  8654. Scale the input video to a size of 200x100
  8655. @example
  8656. scale=w=200:h=100
  8657. @end example
  8658. This is equivalent to:
  8659. @example
  8660. scale=200:100
  8661. @end example
  8662. or:
  8663. @example
  8664. scale=200x100
  8665. @end example
  8666. @item
  8667. Specify a size abbreviation for the output size:
  8668. @example
  8669. scale=qcif
  8670. @end example
  8671. which can also be written as:
  8672. @example
  8673. scale=size=qcif
  8674. @end example
  8675. @item
  8676. Scale the input to 2x:
  8677. @example
  8678. scale=w=2*iw:h=2*ih
  8679. @end example
  8680. @item
  8681. The above is the same as:
  8682. @example
  8683. scale=2*in_w:2*in_h
  8684. @end example
  8685. @item
  8686. Scale the input to 2x with forced interlaced scaling:
  8687. @example
  8688. scale=2*iw:2*ih:interl=1
  8689. @end example
  8690. @item
  8691. Scale the input to half size:
  8692. @example
  8693. scale=w=iw/2:h=ih/2
  8694. @end example
  8695. @item
  8696. Increase the width, and set the height to the same size:
  8697. @example
  8698. scale=3/2*iw:ow
  8699. @end example
  8700. @item
  8701. Seek Greek harmony:
  8702. @example
  8703. scale=iw:1/PHI*iw
  8704. scale=ih*PHI:ih
  8705. @end example
  8706. @item
  8707. Increase the height, and set the width to 3/2 of the height:
  8708. @example
  8709. scale=w=3/2*oh:h=3/5*ih
  8710. @end example
  8711. @item
  8712. Increase the size, making the size a multiple of the chroma
  8713. subsample values:
  8714. @example
  8715. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  8716. @end example
  8717. @item
  8718. Increase the width to a maximum of 500 pixels,
  8719. keeping the same aspect ratio as the input:
  8720. @example
  8721. scale=w='min(500\, iw*3/2):h=-1'
  8722. @end example
  8723. @end itemize
  8724. @subsection Commands
  8725. This filter supports the following commands:
  8726. @table @option
  8727. @item width, w
  8728. @item height, h
  8729. Set the output video dimension expression.
  8730. The command accepts the same syntax of the corresponding option.
  8731. If the specified expression is not valid, it is kept at its current
  8732. value.
  8733. @end table
  8734. @section scale2ref
  8735. Scale (resize) the input video, based on a reference video.
  8736. See the scale filter for available options, scale2ref supports the same but
  8737. uses the reference video instead of the main input as basis.
  8738. @subsection Examples
  8739. @itemize
  8740. @item
  8741. Scale a subtitle stream to match the main video in size before overlaying
  8742. @example
  8743. 'scale2ref[b][a];[a][b]overlay'
  8744. @end example
  8745. @end itemize
  8746. @anchor{selectivecolor}
  8747. @section selectivecolor
  8748. Adjust cyan, magenta, yellow and black (CMYK) to certain ranges of colors (such
  8749. as "reds", "yellows", "greens", "cyans", ...). The adjustment range is defined
  8750. by the "purity" of the color (that is, how saturated it already is).
  8751. This filter is similar to the Adobe Photoshop Selective Color tool.
  8752. The filter accepts the following options:
  8753. @table @option
  8754. @item correction_method
  8755. Select color correction method.
  8756. Available values are:
  8757. @table @samp
  8758. @item absolute
  8759. Specified adjustments are applied "as-is" (added/subtracted to original pixel
  8760. component value).
  8761. @item relative
  8762. Specified adjustments are relative to the original component value.
  8763. @end table
  8764. Default is @code{absolute}.
  8765. @item reds
  8766. Adjustments for red pixels (pixels where the red component is the maximum)
  8767. @item yellows
  8768. Adjustments for yellow pixels (pixels where the blue component is the minimum)
  8769. @item greens
  8770. Adjustments for green pixels (pixels where the green component is the maximum)
  8771. @item cyans
  8772. Adjustments for cyan pixels (pixels where the red component is the minimum)
  8773. @item blues
  8774. Adjustments for blue pixels (pixels where the blue component is the maximum)
  8775. @item magentas
  8776. Adjustments for magenta pixels (pixels where the green component is the minimum)
  8777. @item whites
  8778. Adjustments for white pixels (pixels where all components are greater than 128)
  8779. @item neutrals
  8780. Adjustments for all pixels except pure black and pure white
  8781. @item blacks
  8782. Adjustments for black pixels (pixels where all components are lesser than 128)
  8783. @item psfile
  8784. Specify a Photoshop selective color file (@code{.asv}) to import the settings from.
  8785. @end table
  8786. All the adjustment settings (@option{reds}, @option{yellows}, ...) accept up to
  8787. 4 space separated floating point adjustment values in the [-1,1] range,
  8788. respectively to adjust the amount of cyan, magenta, yellow and black for the
  8789. pixels of its range.
  8790. @subsection Examples
  8791. @itemize
  8792. @item
  8793. Increase cyan by 50% and reduce yellow by 33% in every green areas, and
  8794. increase magenta by 27% in blue areas:
  8795. @example
  8796. selectivecolor=greens=.5 0 -.33 0:blues=0 .27
  8797. @end example
  8798. @item
  8799. Use a Photoshop selective color preset:
  8800. @example
  8801. selectivecolor=psfile=MySelectiveColorPresets/Misty.asv
  8802. @end example
  8803. @end itemize
  8804. @section separatefields
  8805. The @code{separatefields} takes a frame-based video input and splits
  8806. each frame into its components fields, producing a new half height clip
  8807. with twice the frame rate and twice the frame count.
  8808. This filter use field-dominance information in frame to decide which
  8809. of each pair of fields to place first in the output.
  8810. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  8811. @section setdar, setsar
  8812. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  8813. output video.
  8814. This is done by changing the specified Sample (aka Pixel) Aspect
  8815. Ratio, according to the following equation:
  8816. @example
  8817. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  8818. @end example
  8819. Keep in mind that the @code{setdar} filter does not modify the pixel
  8820. dimensions of the video frame. Also, the display aspect ratio set by
  8821. this filter may be changed by later filters in the filterchain,
  8822. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  8823. applied.
  8824. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  8825. the filter output video.
  8826. Note that as a consequence of the application of this filter, the
  8827. output display aspect ratio will change according to the equation
  8828. above.
  8829. Keep in mind that the sample aspect ratio set by the @code{setsar}
  8830. filter may be changed by later filters in the filterchain, e.g. if
  8831. another "setsar" or a "setdar" filter is applied.
  8832. It accepts the following parameters:
  8833. @table @option
  8834. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  8835. Set the aspect ratio used by the filter.
  8836. The parameter can be a floating point number string, an expression, or
  8837. a string of the form @var{num}:@var{den}, where @var{num} and
  8838. @var{den} are the numerator and denominator of the aspect ratio. If
  8839. the parameter is not specified, it is assumed the value "0".
  8840. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  8841. should be escaped.
  8842. @item max
  8843. Set the maximum integer value to use for expressing numerator and
  8844. denominator when reducing the expressed aspect ratio to a rational.
  8845. Default value is @code{100}.
  8846. @end table
  8847. The parameter @var{sar} is an expression containing
  8848. the following constants:
  8849. @table @option
  8850. @item E, PI, PHI
  8851. These are approximated values for the mathematical constants e
  8852. (Euler's number), pi (Greek pi), and phi (the golden ratio).
  8853. @item w, h
  8854. The input width and height.
  8855. @item a
  8856. These are the same as @var{w} / @var{h}.
  8857. @item sar
  8858. The input sample aspect ratio.
  8859. @item dar
  8860. The input display aspect ratio. It is the same as
  8861. (@var{w} / @var{h}) * @var{sar}.
  8862. @item hsub, vsub
  8863. Horizontal and vertical chroma subsample values. For example, for the
  8864. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  8865. @end table
  8866. @subsection Examples
  8867. @itemize
  8868. @item
  8869. To change the display aspect ratio to 16:9, specify one of the following:
  8870. @example
  8871. setdar=dar=1.77777
  8872. setdar=dar=16/9
  8873. setdar=dar=1.77777
  8874. @end example
  8875. @item
  8876. To change the sample aspect ratio to 10:11, specify:
  8877. @example
  8878. setsar=sar=10/11
  8879. @end example
  8880. @item
  8881. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  8882. 1000 in the aspect ratio reduction, use the command:
  8883. @example
  8884. setdar=ratio=16/9:max=1000
  8885. @end example
  8886. @end itemize
  8887. @anchor{setfield}
  8888. @section setfield
  8889. Force field for the output video frame.
  8890. The @code{setfield} filter marks the interlace type field for the
  8891. output frames. It does not change the input frame, but only sets the
  8892. corresponding property, which affects how the frame is treated by
  8893. following filters (e.g. @code{fieldorder} or @code{yadif}).
  8894. The filter accepts the following options:
  8895. @table @option
  8896. @item mode
  8897. Available values are:
  8898. @table @samp
  8899. @item auto
  8900. Keep the same field property.
  8901. @item bff
  8902. Mark the frame as bottom-field-first.
  8903. @item tff
  8904. Mark the frame as top-field-first.
  8905. @item prog
  8906. Mark the frame as progressive.
  8907. @end table
  8908. @end table
  8909. @section showinfo
  8910. Show a line containing various information for each input video frame.
  8911. The input video is not modified.
  8912. The shown line contains a sequence of key/value pairs of the form
  8913. @var{key}:@var{value}.
  8914. The following values are shown in the output:
  8915. @table @option
  8916. @item n
  8917. The (sequential) number of the input frame, starting from 0.
  8918. @item pts
  8919. The Presentation TimeStamp of the input frame, expressed as a number of
  8920. time base units. The time base unit depends on the filter input pad.
  8921. @item pts_time
  8922. The Presentation TimeStamp of the input frame, expressed as a number of
  8923. seconds.
  8924. @item pos
  8925. The position of the frame in the input stream, or -1 if this information is
  8926. unavailable and/or meaningless (for example in case of synthetic video).
  8927. @item fmt
  8928. The pixel format name.
  8929. @item sar
  8930. The sample aspect ratio of the input frame, expressed in the form
  8931. @var{num}/@var{den}.
  8932. @item s
  8933. The size of the input frame. For the syntax of this option, check the
  8934. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8935. @item i
  8936. The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
  8937. for bottom field first).
  8938. @item iskey
  8939. This is 1 if the frame is a key frame, 0 otherwise.
  8940. @item type
  8941. The picture type of the input frame ("I" for an I-frame, "P" for a
  8942. P-frame, "B" for a B-frame, or "?" for an unknown type).
  8943. Also refer to the documentation of the @code{AVPictureType} enum and of
  8944. the @code{av_get_picture_type_char} function defined in
  8945. @file{libavutil/avutil.h}.
  8946. @item checksum
  8947. The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
  8948. @item plane_checksum
  8949. The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  8950. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
  8951. @end table
  8952. @section showpalette
  8953. Displays the 256 colors palette of each frame. This filter is only relevant for
  8954. @var{pal8} pixel format frames.
  8955. It accepts the following option:
  8956. @table @option
  8957. @item s
  8958. Set the size of the box used to represent one palette color entry. Default is
  8959. @code{30} (for a @code{30x30} pixel box).
  8960. @end table
  8961. @section shuffleframes
  8962. Reorder and/or duplicate video frames.
  8963. It accepts the following parameters:
  8964. @table @option
  8965. @item mapping
  8966. Set the destination indexes of input frames.
  8967. This is space or '|' separated list of indexes that maps input frames to output
  8968. frames. Number of indexes also sets maximal value that each index may have.
  8969. @end table
  8970. The first frame has the index 0. The default is to keep the input unchanged.
  8971. Swap second and third frame of every three frames of the input:
  8972. @example
  8973. ffmpeg -i INPUT -vf "shuffleframes=0 2 1" OUTPUT
  8974. @end example
  8975. @section shuffleplanes
  8976. Reorder and/or duplicate video planes.
  8977. It accepts the following parameters:
  8978. @table @option
  8979. @item map0
  8980. The index of the input plane to be used as the first output plane.
  8981. @item map1
  8982. The index of the input plane to be used as the second output plane.
  8983. @item map2
  8984. The index of the input plane to be used as the third output plane.
  8985. @item map3
  8986. The index of the input plane to be used as the fourth output plane.
  8987. @end table
  8988. The first plane has the index 0. The default is to keep the input unchanged.
  8989. Swap the second and third planes of the input:
  8990. @example
  8991. ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
  8992. @end example
  8993. @anchor{signalstats}
  8994. @section signalstats
  8995. Evaluate various visual metrics that assist in determining issues associated
  8996. with the digitization of analog video media.
  8997. By default the filter will log these metadata values:
  8998. @table @option
  8999. @item YMIN
  9000. Display the minimal Y value contained within the input frame. Expressed in
  9001. range of [0-255].
  9002. @item YLOW
  9003. Display the Y value at the 10% percentile within the input frame. Expressed in
  9004. range of [0-255].
  9005. @item YAVG
  9006. Display the average Y value within the input frame. Expressed in range of
  9007. [0-255].
  9008. @item YHIGH
  9009. Display the Y value at the 90% percentile within the input frame. Expressed in
  9010. range of [0-255].
  9011. @item YMAX
  9012. Display the maximum Y value contained within the input frame. Expressed in
  9013. range of [0-255].
  9014. @item UMIN
  9015. Display the minimal U value contained within the input frame. Expressed in
  9016. range of [0-255].
  9017. @item ULOW
  9018. Display the U value at the 10% percentile within the input frame. Expressed in
  9019. range of [0-255].
  9020. @item UAVG
  9021. Display the average U value within the input frame. Expressed in range of
  9022. [0-255].
  9023. @item UHIGH
  9024. Display the U value at the 90% percentile within the input frame. Expressed in
  9025. range of [0-255].
  9026. @item UMAX
  9027. Display the maximum U value contained within the input frame. Expressed in
  9028. range of [0-255].
  9029. @item VMIN
  9030. Display the minimal V value contained within the input frame. Expressed in
  9031. range of [0-255].
  9032. @item VLOW
  9033. Display the V value at the 10% percentile within the input frame. Expressed in
  9034. range of [0-255].
  9035. @item VAVG
  9036. Display the average V value within the input frame. Expressed in range of
  9037. [0-255].
  9038. @item VHIGH
  9039. Display the V value at the 90% percentile within the input frame. Expressed in
  9040. range of [0-255].
  9041. @item VMAX
  9042. Display the maximum V value contained within the input frame. Expressed in
  9043. range of [0-255].
  9044. @item SATMIN
  9045. Display the minimal saturation value contained within the input frame.
  9046. Expressed in range of [0-~181.02].
  9047. @item SATLOW
  9048. Display the saturation value at the 10% percentile within the input frame.
  9049. Expressed in range of [0-~181.02].
  9050. @item SATAVG
  9051. Display the average saturation value within the input frame. Expressed in range
  9052. of [0-~181.02].
  9053. @item SATHIGH
  9054. Display the saturation value at the 90% percentile within the input frame.
  9055. Expressed in range of [0-~181.02].
  9056. @item SATMAX
  9057. Display the maximum saturation value contained within the input frame.
  9058. Expressed in range of [0-~181.02].
  9059. @item HUEMED
  9060. Display the median value for hue within the input frame. Expressed in range of
  9061. [0-360].
  9062. @item HUEAVG
  9063. Display the average value for hue within the input frame. Expressed in range of
  9064. [0-360].
  9065. @item YDIF
  9066. Display the average of sample value difference between all values of the Y
  9067. plane in the current frame and corresponding values of the previous input frame.
  9068. Expressed in range of [0-255].
  9069. @item UDIF
  9070. Display the average of sample value difference between all values of the U
  9071. plane in the current frame and corresponding values of the previous input frame.
  9072. Expressed in range of [0-255].
  9073. @item VDIF
  9074. Display the average of sample value difference between all values of the V
  9075. plane in the current frame and corresponding values of the previous input frame.
  9076. Expressed in range of [0-255].
  9077. @end table
  9078. The filter accepts the following options:
  9079. @table @option
  9080. @item stat
  9081. @item out
  9082. @option{stat} specify an additional form of image analysis.
  9083. @option{out} output video with the specified type of pixel highlighted.
  9084. Both options accept the following values:
  9085. @table @samp
  9086. @item tout
  9087. Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
  9088. unlike the neighboring pixels of the same field. Examples of temporal outliers
  9089. include the results of video dropouts, head clogs, or tape tracking issues.
  9090. @item vrep
  9091. Identify @var{vertical line repetition}. Vertical line repetition includes
  9092. similar rows of pixels within a frame. In born-digital video vertical line
  9093. repetition is common, but this pattern is uncommon in video digitized from an
  9094. analog source. When it occurs in video that results from the digitization of an
  9095. analog source it can indicate concealment from a dropout compensator.
  9096. @item brng
  9097. Identify pixels that fall outside of legal broadcast range.
  9098. @end table
  9099. @item color, c
  9100. Set the highlight color for the @option{out} option. The default color is
  9101. yellow.
  9102. @end table
  9103. @subsection Examples
  9104. @itemize
  9105. @item
  9106. Output data of various video metrics:
  9107. @example
  9108. ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
  9109. @end example
  9110. @item
  9111. Output specific data about the minimum and maximum values of the Y plane per frame:
  9112. @example
  9113. ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
  9114. @end example
  9115. @item
  9116. Playback video while highlighting pixels that are outside of broadcast range in red.
  9117. @example
  9118. ffplay example.mov -vf signalstats="out=brng:color=red"
  9119. @end example
  9120. @item
  9121. Playback video with signalstats metadata drawn over the frame.
  9122. @example
  9123. ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
  9124. @end example
  9125. The contents of signalstat_drawtext.txt used in the command are:
  9126. @example
  9127. time %@{pts:hms@}
  9128. Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
  9129. U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
  9130. V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
  9131. saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
  9132. @end example
  9133. @end itemize
  9134. @anchor{smartblur}
  9135. @section smartblur
  9136. Blur the input video without impacting the outlines.
  9137. It accepts the following options:
  9138. @table @option
  9139. @item luma_radius, lr
  9140. Set the luma radius. The option value must be a float number in
  9141. the range [0.1,5.0] that specifies the variance of the gaussian filter
  9142. used to blur the image (slower if larger). Default value is 1.0.
  9143. @item luma_strength, ls
  9144. Set the luma strength. The option value must be a float number
  9145. in the range [-1.0,1.0] that configures the blurring. A value included
  9146. in [0.0,1.0] will blur the image whereas a value included in
  9147. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  9148. @item luma_threshold, lt
  9149. Set the luma threshold used as a coefficient to determine
  9150. whether a pixel should be blurred or not. The option value must be an
  9151. integer in the range [-30,30]. A value of 0 will filter all the image,
  9152. a value included in [0,30] will filter flat areas and a value included
  9153. in [-30,0] will filter edges. Default value is 0.
  9154. @item chroma_radius, cr
  9155. Set the chroma radius. The option value must be a float number in
  9156. the range [0.1,5.0] that specifies the variance of the gaussian filter
  9157. used to blur the image (slower if larger). Default value is 1.0.
  9158. @item chroma_strength, cs
  9159. Set the chroma strength. The option value must be a float number
  9160. in the range [-1.0,1.0] that configures the blurring. A value included
  9161. in [0.0,1.0] will blur the image whereas a value included in
  9162. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  9163. @item chroma_threshold, ct
  9164. Set the chroma threshold used as a coefficient to determine
  9165. whether a pixel should be blurred or not. The option value must be an
  9166. integer in the range [-30,30]. A value of 0 will filter all the image,
  9167. a value included in [0,30] will filter flat areas and a value included
  9168. in [-30,0] will filter edges. Default value is 0.
  9169. @end table
  9170. If a chroma option is not explicitly set, the corresponding luma value
  9171. is set.
  9172. @section ssim
  9173. Obtain the SSIM (Structural SImilarity Metric) between two input videos.
  9174. This filter takes in input two input videos, the first input is
  9175. considered the "main" source and is passed unchanged to the
  9176. output. The second input is used as a "reference" video for computing
  9177. the SSIM.
  9178. Both video inputs must have the same resolution and pixel format for
  9179. this filter to work correctly. Also it assumes that both inputs
  9180. have the same number of frames, which are compared one by one.
  9181. The filter stores the calculated SSIM of each frame.
  9182. The description of the accepted parameters follows.
  9183. @table @option
  9184. @item stats_file, f
  9185. If specified the filter will use the named file to save the SSIM of
  9186. each individual frame. When filename equals "-" the data is sent to
  9187. standard output.
  9188. @end table
  9189. The file printed if @var{stats_file} is selected, contains a sequence of
  9190. key/value pairs of the form @var{key}:@var{value} for each compared
  9191. couple of frames.
  9192. A description of each shown parameter follows:
  9193. @table @option
  9194. @item n
  9195. sequential number of the input frame, starting from 1
  9196. @item Y, U, V, R, G, B
  9197. SSIM of the compared frames for the component specified by the suffix.
  9198. @item All
  9199. SSIM of the compared frames for the whole frame.
  9200. @item dB
  9201. Same as above but in dB representation.
  9202. @end table
  9203. For example:
  9204. @example
  9205. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  9206. [main][ref] ssim="stats_file=stats.log" [out]
  9207. @end example
  9208. On this example the input file being processed is compared with the
  9209. reference file @file{ref_movie.mpg}. The SSIM of each individual frame
  9210. is stored in @file{stats.log}.
  9211. Another example with both psnr and ssim at same time:
  9212. @example
  9213. ffmpeg -i main.mpg -i ref.mpg -lavfi "ssim;[0:v][1:v]psnr" -f null -
  9214. @end example
  9215. @section stereo3d
  9216. Convert between different stereoscopic image formats.
  9217. The filters accept the following options:
  9218. @table @option
  9219. @item in
  9220. Set stereoscopic image format of input.
  9221. Available values for input image formats are:
  9222. @table @samp
  9223. @item sbsl
  9224. side by side parallel (left eye left, right eye right)
  9225. @item sbsr
  9226. side by side crosseye (right eye left, left eye right)
  9227. @item sbs2l
  9228. side by side parallel with half width resolution
  9229. (left eye left, right eye right)
  9230. @item sbs2r
  9231. side by side crosseye with half width resolution
  9232. (right eye left, left eye right)
  9233. @item abl
  9234. above-below (left eye above, right eye below)
  9235. @item abr
  9236. above-below (right eye above, left eye below)
  9237. @item ab2l
  9238. above-below with half height resolution
  9239. (left eye above, right eye below)
  9240. @item ab2r
  9241. above-below with half height resolution
  9242. (right eye above, left eye below)
  9243. @item al
  9244. alternating frames (left eye first, right eye second)
  9245. @item ar
  9246. alternating frames (right eye first, left eye second)
  9247. @item irl
  9248. interleaved rows (left eye has top row, right eye starts on next row)
  9249. @item irr
  9250. interleaved rows (right eye has top row, left eye starts on next row)
  9251. @item icl
  9252. interleaved columns, left eye first
  9253. @item icr
  9254. interleaved columns, right eye first
  9255. Default value is @samp{sbsl}.
  9256. @end table
  9257. @item out
  9258. Set stereoscopic image format of output.
  9259. @table @samp
  9260. @item sbsl
  9261. side by side parallel (left eye left, right eye right)
  9262. @item sbsr
  9263. side by side crosseye (right eye left, left eye right)
  9264. @item sbs2l
  9265. side by side parallel with half width resolution
  9266. (left eye left, right eye right)
  9267. @item sbs2r
  9268. side by side crosseye with half width resolution
  9269. (right eye left, left eye right)
  9270. @item abl
  9271. above-below (left eye above, right eye below)
  9272. @item abr
  9273. above-below (right eye above, left eye below)
  9274. @item ab2l
  9275. above-below with half height resolution
  9276. (left eye above, right eye below)
  9277. @item ab2r
  9278. above-below with half height resolution
  9279. (right eye above, left eye below)
  9280. @item al
  9281. alternating frames (left eye first, right eye second)
  9282. @item ar
  9283. alternating frames (right eye first, left eye second)
  9284. @item irl
  9285. interleaved rows (left eye has top row, right eye starts on next row)
  9286. @item irr
  9287. interleaved rows (right eye has top row, left eye starts on next row)
  9288. @item arbg
  9289. anaglyph red/blue gray
  9290. (red filter on left eye, blue filter on right eye)
  9291. @item argg
  9292. anaglyph red/green gray
  9293. (red filter on left eye, green filter on right eye)
  9294. @item arcg
  9295. anaglyph red/cyan gray
  9296. (red filter on left eye, cyan filter on right eye)
  9297. @item arch
  9298. anaglyph red/cyan half colored
  9299. (red filter on left eye, cyan filter on right eye)
  9300. @item arcc
  9301. anaglyph red/cyan color
  9302. (red filter on left eye, cyan filter on right eye)
  9303. @item arcd
  9304. anaglyph red/cyan color optimized with the least squares projection of dubois
  9305. (red filter on left eye, cyan filter on right eye)
  9306. @item agmg
  9307. anaglyph green/magenta gray
  9308. (green filter on left eye, magenta filter on right eye)
  9309. @item agmh
  9310. anaglyph green/magenta half colored
  9311. (green filter on left eye, magenta filter on right eye)
  9312. @item agmc
  9313. anaglyph green/magenta colored
  9314. (green filter on left eye, magenta filter on right eye)
  9315. @item agmd
  9316. anaglyph green/magenta color optimized with the least squares projection of dubois
  9317. (green filter on left eye, magenta filter on right eye)
  9318. @item aybg
  9319. anaglyph yellow/blue gray
  9320. (yellow filter on left eye, blue filter on right eye)
  9321. @item aybh
  9322. anaglyph yellow/blue half colored
  9323. (yellow filter on left eye, blue filter on right eye)
  9324. @item aybc
  9325. anaglyph yellow/blue colored
  9326. (yellow filter on left eye, blue filter on right eye)
  9327. @item aybd
  9328. anaglyph yellow/blue color optimized with the least squares projection of dubois
  9329. (yellow filter on left eye, blue filter on right eye)
  9330. @item ml
  9331. mono output (left eye only)
  9332. @item mr
  9333. mono output (right eye only)
  9334. @item chl
  9335. checkerboard, left eye first
  9336. @item chr
  9337. checkerboard, right eye first
  9338. @item icl
  9339. interleaved columns, left eye first
  9340. @item icr
  9341. interleaved columns, right eye first
  9342. @end table
  9343. Default value is @samp{arcd}.
  9344. @end table
  9345. @subsection Examples
  9346. @itemize
  9347. @item
  9348. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  9349. @example
  9350. stereo3d=sbsl:aybd
  9351. @end example
  9352. @item
  9353. Convert input video from above below (left eye above, right eye below) to side by side crosseye.
  9354. @example
  9355. stereo3d=abl:sbsr
  9356. @end example
  9357. @end itemize
  9358. @section streamselect, astreamselect
  9359. Select video or audio streams.
  9360. The filter accepts the following options:
  9361. @table @option
  9362. @item inputs
  9363. Set number of inputs. Default is 2.
  9364. @item map
  9365. Set input indexes to remap to outputs.
  9366. @end table
  9367. @subsection Commands
  9368. The @code{streamselect} and @code{astreamselect} filter supports the following
  9369. commands:
  9370. @table @option
  9371. @item map
  9372. Set input indexes to remap to outputs.
  9373. @end table
  9374. @subsection Examples
  9375. @itemize
  9376. @item
  9377. Select first 5 seconds 1st stream and rest of time 2nd stream:
  9378. @example
  9379. sendcmd='5.0 streamselect map 1',streamselect=inputs=2:map=0
  9380. @end example
  9381. @item
  9382. Same as above, but for audio:
  9383. @example
  9384. asendcmd='5.0 astreamselect map 1',astreamselect=inputs=2:map=0
  9385. @end example
  9386. @end itemize
  9387. @anchor{spp}
  9388. @section spp
  9389. Apply a simple postprocessing filter that compresses and decompresses the image
  9390. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  9391. and average the results.
  9392. The filter accepts the following options:
  9393. @table @option
  9394. @item quality
  9395. Set quality. This option defines the number of levels for averaging. It accepts
  9396. an integer in the range 0-6. If set to @code{0}, the filter will have no
  9397. effect. A value of @code{6} means the higher quality. For each increment of
  9398. that value the speed drops by a factor of approximately 2. Default value is
  9399. @code{3}.
  9400. @item qp
  9401. Force a constant quantization parameter. If not set, the filter will use the QP
  9402. from the video stream (if available).
  9403. @item mode
  9404. Set thresholding mode. Available modes are:
  9405. @table @samp
  9406. @item hard
  9407. Set hard thresholding (default).
  9408. @item soft
  9409. Set soft thresholding (better de-ringing effect, but likely blurrier).
  9410. @end table
  9411. @item use_bframe_qp
  9412. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  9413. option may cause flicker since the B-Frames have often larger QP. Default is
  9414. @code{0} (not enabled).
  9415. @end table
  9416. @anchor{subtitles}
  9417. @section subtitles
  9418. Draw subtitles on top of input video using the libass library.
  9419. To enable compilation of this filter you need to configure FFmpeg with
  9420. @code{--enable-libass}. This filter also requires a build with libavcodec and
  9421. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  9422. Alpha) subtitles format.
  9423. The filter accepts the following options:
  9424. @table @option
  9425. @item filename, f
  9426. Set the filename of the subtitle file to read. It must be specified.
  9427. @item original_size
  9428. Specify the size of the original video, the video for which the ASS file
  9429. was composed. For the syntax of this option, check the
  9430. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9431. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
  9432. correctly scale the fonts if the aspect ratio has been changed.
  9433. @item fontsdir
  9434. Set a directory path containing fonts that can be used by the filter.
  9435. These fonts will be used in addition to whatever the font provider uses.
  9436. @item charenc
  9437. Set subtitles input character encoding. @code{subtitles} filter only. Only
  9438. useful if not UTF-8.
  9439. @item stream_index, si
  9440. Set subtitles stream index. @code{subtitles} filter only.
  9441. @item force_style
  9442. Override default style or script info parameters of the subtitles. It accepts a
  9443. string containing ASS style format @code{KEY=VALUE} couples separated by ",".
  9444. @end table
  9445. If the first key is not specified, it is assumed that the first value
  9446. specifies the @option{filename}.
  9447. For example, to render the file @file{sub.srt} on top of the input
  9448. video, use the command:
  9449. @example
  9450. subtitles=sub.srt
  9451. @end example
  9452. which is equivalent to:
  9453. @example
  9454. subtitles=filename=sub.srt
  9455. @end example
  9456. To render the default subtitles stream from file @file{video.mkv}, use:
  9457. @example
  9458. subtitles=video.mkv
  9459. @end example
  9460. To render the second subtitles stream from that file, use:
  9461. @example
  9462. subtitles=video.mkv:si=1
  9463. @end example
  9464. To make the subtitles stream from @file{sub.srt} appear in transparent green
  9465. @code{DejaVu Serif}, use:
  9466. @example
  9467. subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
  9468. @end example
  9469. @section super2xsai
  9470. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  9471. Interpolate) pixel art scaling algorithm.
  9472. Useful for enlarging pixel art images without reducing sharpness.
  9473. @section swaprect
  9474. Swap two rectangular objects in video.
  9475. This filter accepts the following options:
  9476. @table @option
  9477. @item w
  9478. Set object width.
  9479. @item h
  9480. Set object height.
  9481. @item x1
  9482. Set 1st rect x coordinate.
  9483. @item y1
  9484. Set 1st rect y coordinate.
  9485. @item x2
  9486. Set 2nd rect x coordinate.
  9487. @item y2
  9488. Set 2nd rect y coordinate.
  9489. All expressions are evaluated once for each frame.
  9490. @end table
  9491. The all options are expressions containing the following constants:
  9492. @table @option
  9493. @item w
  9494. @item h
  9495. The input width and height.
  9496. @item a
  9497. same as @var{w} / @var{h}
  9498. @item sar
  9499. input sample aspect ratio
  9500. @item dar
  9501. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  9502. @item n
  9503. The number of the input frame, starting from 0.
  9504. @item t
  9505. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  9506. @item pos
  9507. the position in the file of the input frame, NAN if unknown
  9508. @end table
  9509. @section swapuv
  9510. Swap U & V plane.
  9511. @section telecine
  9512. Apply telecine process to the video.
  9513. This filter accepts the following options:
  9514. @table @option
  9515. @item first_field
  9516. @table @samp
  9517. @item top, t
  9518. top field first
  9519. @item bottom, b
  9520. bottom field first
  9521. The default value is @code{top}.
  9522. @end table
  9523. @item pattern
  9524. A string of numbers representing the pulldown pattern you wish to apply.
  9525. The default value is @code{23}.
  9526. @end table
  9527. @example
  9528. Some typical patterns:
  9529. NTSC output (30i):
  9530. 27.5p: 32222
  9531. 24p: 23 (classic)
  9532. 24p: 2332 (preferred)
  9533. 20p: 33
  9534. 18p: 334
  9535. 16p: 3444
  9536. PAL output (25i):
  9537. 27.5p: 12222
  9538. 24p: 222222222223 ("Euro pulldown")
  9539. 16.67p: 33
  9540. 16p: 33333334
  9541. @end example
  9542. @section thumbnail
  9543. Select the most representative frame in a given sequence of consecutive frames.
  9544. The filter accepts the following options:
  9545. @table @option
  9546. @item n
  9547. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  9548. will pick one of them, and then handle the next batch of @var{n} frames until
  9549. the end. Default is @code{100}.
  9550. @end table
  9551. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  9552. value will result in a higher memory usage, so a high value is not recommended.
  9553. @subsection Examples
  9554. @itemize
  9555. @item
  9556. Extract one picture each 50 frames:
  9557. @example
  9558. thumbnail=50
  9559. @end example
  9560. @item
  9561. Complete example of a thumbnail creation with @command{ffmpeg}:
  9562. @example
  9563. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  9564. @end example
  9565. @end itemize
  9566. @section tile
  9567. Tile several successive frames together.
  9568. The filter accepts the following options:
  9569. @table @option
  9570. @item layout
  9571. Set the grid size (i.e. the number of lines and columns). For the syntax of
  9572. this option, check the
  9573. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9574. @item nb_frames
  9575. Set the maximum number of frames to render in the given area. It must be less
  9576. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  9577. the area will be used.
  9578. @item margin
  9579. Set the outer border margin in pixels.
  9580. @item padding
  9581. Set the inner border thickness (i.e. the number of pixels between frames). For
  9582. more advanced padding options (such as having different values for the edges),
  9583. refer to the pad video filter.
  9584. @item color
  9585. Specify the color of the unused area. For the syntax of this option, check the
  9586. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  9587. is "black".
  9588. @end table
  9589. @subsection Examples
  9590. @itemize
  9591. @item
  9592. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  9593. @example
  9594. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  9595. @end example
  9596. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  9597. duplicating each output frame to accommodate the originally detected frame
  9598. rate.
  9599. @item
  9600. Display @code{5} pictures in an area of @code{3x2} frames,
  9601. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  9602. mixed flat and named options:
  9603. @example
  9604. tile=3x2:nb_frames=5:padding=7:margin=2
  9605. @end example
  9606. @end itemize
  9607. @section tinterlace
  9608. Perform various types of temporal field interlacing.
  9609. Frames are counted starting from 1, so the first input frame is
  9610. considered odd.
  9611. The filter accepts the following options:
  9612. @table @option
  9613. @item mode
  9614. Specify the mode of the interlacing. This option can also be specified
  9615. as a value alone. See below for a list of values for this option.
  9616. Available values are:
  9617. @table @samp
  9618. @item merge, 0
  9619. Move odd frames into the upper field, even into the lower field,
  9620. generating a double height frame at half frame rate.
  9621. @example
  9622. ------> time
  9623. Input:
  9624. Frame 1 Frame 2 Frame 3 Frame 4
  9625. 11111 22222 33333 44444
  9626. 11111 22222 33333 44444
  9627. 11111 22222 33333 44444
  9628. 11111 22222 33333 44444
  9629. Output:
  9630. 11111 33333
  9631. 22222 44444
  9632. 11111 33333
  9633. 22222 44444
  9634. 11111 33333
  9635. 22222 44444
  9636. 11111 33333
  9637. 22222 44444
  9638. @end example
  9639. @item drop_odd, 1
  9640. Only output even frames, odd frames are dropped, generating a frame with
  9641. unchanged height at half frame rate.
  9642. @example
  9643. ------> time
  9644. Input:
  9645. Frame 1 Frame 2 Frame 3 Frame 4
  9646. 11111 22222 33333 44444
  9647. 11111 22222 33333 44444
  9648. 11111 22222 33333 44444
  9649. 11111 22222 33333 44444
  9650. Output:
  9651. 22222 44444
  9652. 22222 44444
  9653. 22222 44444
  9654. 22222 44444
  9655. @end example
  9656. @item drop_even, 2
  9657. Only output odd frames, even frames are dropped, generating a frame with
  9658. unchanged height at half frame rate.
  9659. @example
  9660. ------> time
  9661. Input:
  9662. Frame 1 Frame 2 Frame 3 Frame 4
  9663. 11111 22222 33333 44444
  9664. 11111 22222 33333 44444
  9665. 11111 22222 33333 44444
  9666. 11111 22222 33333 44444
  9667. Output:
  9668. 11111 33333
  9669. 11111 33333
  9670. 11111 33333
  9671. 11111 33333
  9672. @end example
  9673. @item pad, 3
  9674. Expand each frame to full height, but pad alternate lines with black,
  9675. generating a frame with double height at the same input frame rate.
  9676. @example
  9677. ------> time
  9678. Input:
  9679. Frame 1 Frame 2 Frame 3 Frame 4
  9680. 11111 22222 33333 44444
  9681. 11111 22222 33333 44444
  9682. 11111 22222 33333 44444
  9683. 11111 22222 33333 44444
  9684. Output:
  9685. 11111 ..... 33333 .....
  9686. ..... 22222 ..... 44444
  9687. 11111 ..... 33333 .....
  9688. ..... 22222 ..... 44444
  9689. 11111 ..... 33333 .....
  9690. ..... 22222 ..... 44444
  9691. 11111 ..... 33333 .....
  9692. ..... 22222 ..... 44444
  9693. @end example
  9694. @item interleave_top, 4
  9695. Interleave the upper field from odd frames with the lower field from
  9696. even frames, generating a frame with unchanged height at half frame rate.
  9697. @example
  9698. ------> time
  9699. Input:
  9700. Frame 1 Frame 2 Frame 3 Frame 4
  9701. 11111<- 22222 33333<- 44444
  9702. 11111 22222<- 33333 44444<-
  9703. 11111<- 22222 33333<- 44444
  9704. 11111 22222<- 33333 44444<-
  9705. Output:
  9706. 11111 33333
  9707. 22222 44444
  9708. 11111 33333
  9709. 22222 44444
  9710. @end example
  9711. @item interleave_bottom, 5
  9712. Interleave the lower field from odd frames with the upper field from
  9713. even frames, generating a frame with unchanged height at half frame rate.
  9714. @example
  9715. ------> time
  9716. Input:
  9717. Frame 1 Frame 2 Frame 3 Frame 4
  9718. 11111 22222<- 33333 44444<-
  9719. 11111<- 22222 33333<- 44444
  9720. 11111 22222<- 33333 44444<-
  9721. 11111<- 22222 33333<- 44444
  9722. Output:
  9723. 22222 44444
  9724. 11111 33333
  9725. 22222 44444
  9726. 11111 33333
  9727. @end example
  9728. @item interlacex2, 6
  9729. Double frame rate with unchanged height. Frames are inserted each
  9730. containing the second temporal field from the previous input frame and
  9731. the first temporal field from the next input frame. This mode relies on
  9732. the top_field_first flag. Useful for interlaced video displays with no
  9733. field synchronisation.
  9734. @example
  9735. ------> time
  9736. Input:
  9737. Frame 1 Frame 2 Frame 3 Frame 4
  9738. 11111 22222 33333 44444
  9739. 11111 22222 33333 44444
  9740. 11111 22222 33333 44444
  9741. 11111 22222 33333 44444
  9742. Output:
  9743. 11111 22222 22222 33333 33333 44444 44444
  9744. 11111 11111 22222 22222 33333 33333 44444
  9745. 11111 22222 22222 33333 33333 44444 44444
  9746. 11111 11111 22222 22222 33333 33333 44444
  9747. @end example
  9748. @item mergex2, 7
  9749. Move odd frames into the upper field, even into the lower field,
  9750. generating a double height frame at same frame rate.
  9751. @example
  9752. ------> time
  9753. Input:
  9754. Frame 1 Frame 2 Frame 3 Frame 4
  9755. 11111 22222 33333 44444
  9756. 11111 22222 33333 44444
  9757. 11111 22222 33333 44444
  9758. 11111 22222 33333 44444
  9759. Output:
  9760. 11111 33333 33333 55555
  9761. 22222 22222 44444 44444
  9762. 11111 33333 33333 55555
  9763. 22222 22222 44444 44444
  9764. 11111 33333 33333 55555
  9765. 22222 22222 44444 44444
  9766. 11111 33333 33333 55555
  9767. 22222 22222 44444 44444
  9768. @end example
  9769. @end table
  9770. Numeric values are deprecated but are accepted for backward
  9771. compatibility reasons.
  9772. Default mode is @code{merge}.
  9773. @item flags
  9774. Specify flags influencing the filter process.
  9775. Available value for @var{flags} is:
  9776. @table @option
  9777. @item low_pass_filter, vlfp
  9778. Enable vertical low-pass filtering in the filter.
  9779. Vertical low-pass filtering is required when creating an interlaced
  9780. destination from a progressive source which contains high-frequency
  9781. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  9782. patterning.
  9783. Vertical low-pass filtering can only be enabled for @option{mode}
  9784. @var{interleave_top} and @var{interleave_bottom}.
  9785. @end table
  9786. @end table
  9787. @section transpose
  9788. Transpose rows with columns in the input video and optionally flip it.
  9789. It accepts the following parameters:
  9790. @table @option
  9791. @item dir
  9792. Specify the transposition direction.
  9793. Can assume the following values:
  9794. @table @samp
  9795. @item 0, 4, cclock_flip
  9796. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  9797. @example
  9798. L.R L.l
  9799. . . -> . .
  9800. l.r R.r
  9801. @end example
  9802. @item 1, 5, clock
  9803. Rotate by 90 degrees clockwise, that is:
  9804. @example
  9805. L.R l.L
  9806. . . -> . .
  9807. l.r r.R
  9808. @end example
  9809. @item 2, 6, cclock
  9810. Rotate by 90 degrees counterclockwise, that is:
  9811. @example
  9812. L.R R.r
  9813. . . -> . .
  9814. l.r L.l
  9815. @end example
  9816. @item 3, 7, clock_flip
  9817. Rotate by 90 degrees clockwise and vertically flip, that is:
  9818. @example
  9819. L.R r.R
  9820. . . -> . .
  9821. l.r l.L
  9822. @end example
  9823. @end table
  9824. For values between 4-7, the transposition is only done if the input
  9825. video geometry is portrait and not landscape. These values are
  9826. deprecated, the @code{passthrough} option should be used instead.
  9827. Numerical values are deprecated, and should be dropped in favor of
  9828. symbolic constants.
  9829. @item passthrough
  9830. Do not apply the transposition if the input geometry matches the one
  9831. specified by the specified value. It accepts the following values:
  9832. @table @samp
  9833. @item none
  9834. Always apply transposition.
  9835. @item portrait
  9836. Preserve portrait geometry (when @var{height} >= @var{width}).
  9837. @item landscape
  9838. Preserve landscape geometry (when @var{width} >= @var{height}).
  9839. @end table
  9840. Default value is @code{none}.
  9841. @end table
  9842. For example to rotate by 90 degrees clockwise and preserve portrait
  9843. layout:
  9844. @example
  9845. transpose=dir=1:passthrough=portrait
  9846. @end example
  9847. The command above can also be specified as:
  9848. @example
  9849. transpose=1:portrait
  9850. @end example
  9851. @section trim
  9852. Trim the input so that the output contains one continuous subpart of the input.
  9853. It accepts the following parameters:
  9854. @table @option
  9855. @item start
  9856. Specify the time of the start of the kept section, i.e. the frame with the
  9857. timestamp @var{start} will be the first frame in the output.
  9858. @item end
  9859. Specify the time of the first frame that will be dropped, i.e. the frame
  9860. immediately preceding the one with the timestamp @var{end} will be the last
  9861. frame in the output.
  9862. @item start_pts
  9863. This is the same as @var{start}, except this option sets the start timestamp
  9864. in timebase units instead of seconds.
  9865. @item end_pts
  9866. This is the same as @var{end}, except this option sets the end timestamp
  9867. in timebase units instead of seconds.
  9868. @item duration
  9869. The maximum duration of the output in seconds.
  9870. @item start_frame
  9871. The number of the first frame that should be passed to the output.
  9872. @item end_frame
  9873. The number of the first frame that should be dropped.
  9874. @end table
  9875. @option{start}, @option{end}, and @option{duration} are expressed as time
  9876. duration specifications; see
  9877. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  9878. for the accepted syntax.
  9879. Note that the first two sets of the start/end options and the @option{duration}
  9880. option look at the frame timestamp, while the _frame variants simply count the
  9881. frames that pass through the filter. Also note that this filter does not modify
  9882. the timestamps. If you wish for the output timestamps to start at zero, insert a
  9883. setpts filter after the trim filter.
  9884. If multiple start or end options are set, this filter tries to be greedy and
  9885. keep all the frames that match at least one of the specified constraints. To keep
  9886. only the part that matches all the constraints at once, chain multiple trim
  9887. filters.
  9888. The defaults are such that all the input is kept. So it is possible to set e.g.
  9889. just the end values to keep everything before the specified time.
  9890. Examples:
  9891. @itemize
  9892. @item
  9893. Drop everything except the second minute of input:
  9894. @example
  9895. ffmpeg -i INPUT -vf trim=60:120
  9896. @end example
  9897. @item
  9898. Keep only the first second:
  9899. @example
  9900. ffmpeg -i INPUT -vf trim=duration=1
  9901. @end example
  9902. @end itemize
  9903. @anchor{unsharp}
  9904. @section unsharp
  9905. Sharpen or blur the input video.
  9906. It accepts the following parameters:
  9907. @table @option
  9908. @item luma_msize_x, lx
  9909. Set the luma matrix horizontal size. It must be an odd integer between
  9910. 3 and 63. The default value is 5.
  9911. @item luma_msize_y, ly
  9912. Set the luma matrix vertical size. It must be an odd integer between 3
  9913. and 63. The default value is 5.
  9914. @item luma_amount, la
  9915. Set the luma effect strength. It must be a floating point number, reasonable
  9916. values lay between -1.5 and 1.5.
  9917. Negative values will blur the input video, while positive values will
  9918. sharpen it, a value of zero will disable the effect.
  9919. Default value is 1.0.
  9920. @item chroma_msize_x, cx
  9921. Set the chroma matrix horizontal size. It must be an odd integer
  9922. between 3 and 63. The default value is 5.
  9923. @item chroma_msize_y, cy
  9924. Set the chroma matrix vertical size. It must be an odd integer
  9925. between 3 and 63. The default value is 5.
  9926. @item chroma_amount, ca
  9927. Set the chroma effect strength. It must be a floating point number, reasonable
  9928. values lay between -1.5 and 1.5.
  9929. Negative values will blur the input video, while positive values will
  9930. sharpen it, a value of zero will disable the effect.
  9931. Default value is 0.0.
  9932. @item opencl
  9933. If set to 1, specify using OpenCL capabilities, only available if
  9934. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  9935. @end table
  9936. All parameters are optional and default to the equivalent of the
  9937. string '5:5:1.0:5:5:0.0'.
  9938. @subsection Examples
  9939. @itemize
  9940. @item
  9941. Apply strong luma sharpen effect:
  9942. @example
  9943. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  9944. @end example
  9945. @item
  9946. Apply a strong blur of both luma and chroma parameters:
  9947. @example
  9948. unsharp=7:7:-2:7:7:-2
  9949. @end example
  9950. @end itemize
  9951. @section uspp
  9952. Apply ultra slow/simple postprocessing filter that compresses and decompresses
  9953. the image at several (or - in the case of @option{quality} level @code{8} - all)
  9954. shifts and average the results.
  9955. The way this differs from the behavior of spp is that uspp actually encodes &
  9956. decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
  9957. DCT similar to MJPEG.
  9958. The filter accepts the following options:
  9959. @table @option
  9960. @item quality
  9961. Set quality. This option defines the number of levels for averaging. It accepts
  9962. an integer in the range 0-8. If set to @code{0}, the filter will have no
  9963. effect. A value of @code{8} means the higher quality. For each increment of
  9964. that value the speed drops by a factor of approximately 2. Default value is
  9965. @code{3}.
  9966. @item qp
  9967. Force a constant quantization parameter. If not set, the filter will use the QP
  9968. from the video stream (if available).
  9969. @end table
  9970. @section vectorscope
  9971. Display 2 color component values in the two dimensional graph (which is called
  9972. a vectorscope).
  9973. This filter accepts the following options:
  9974. @table @option
  9975. @item mode, m
  9976. Set vectorscope mode.
  9977. It accepts the following values:
  9978. @table @samp
  9979. @item gray
  9980. Gray values are displayed on graph, higher brightness means more pixels have
  9981. same component color value on location in graph. This is the default mode.
  9982. @item color
  9983. Gray values are displayed on graph. Surrounding pixels values which are not
  9984. present in video frame are drawn in gradient of 2 color components which are
  9985. set by option @code{x} and @code{y}. The 3rd color component is static.
  9986. @item color2
  9987. Actual color components values present in video frame are displayed on graph.
  9988. @item color3
  9989. Similar as color2 but higher frequency of same values @code{x} and @code{y}
  9990. on graph increases value of another color component, which is luminance by
  9991. default values of @code{x} and @code{y}.
  9992. @item color4
  9993. Actual colors present in video frame are displayed on graph. If two different
  9994. colors map to same position on graph then color with higher value of component
  9995. not present in graph is picked.
  9996. @item color5
  9997. Gray values are displayed on graph. Similar to @code{color} but with 3rd color
  9998. component picked from radial gradient.
  9999. @end table
  10000. @item x
  10001. Set which color component will be represented on X-axis. Default is @code{1}.
  10002. @item y
  10003. Set which color component will be represented on Y-axis. Default is @code{2}.
  10004. @item intensity, i
  10005. Set intensity, used by modes: gray, color, color3 and color5 for increasing brightness
  10006. of color component which represents frequency of (X, Y) location in graph.
  10007. @item envelope, e
  10008. @table @samp
  10009. @item none
  10010. No envelope, this is default.
  10011. @item instant
  10012. Instant envelope, even darkest single pixel will be clearly highlighted.
  10013. @item peak
  10014. Hold maximum and minimum values presented in graph over time. This way you
  10015. can still spot out of range values without constantly looking at vectorscope.
  10016. @item peak+instant
  10017. Peak and instant envelope combined together.
  10018. @end table
  10019. @item graticule, g
  10020. Set what kind of graticule to draw.
  10021. @table @samp
  10022. @item none
  10023. @item green
  10024. @item color
  10025. @end table
  10026. @item opacity, o
  10027. Set graticule opacity.
  10028. @item flags, f
  10029. Set graticule flags.
  10030. @table @samp
  10031. @item white
  10032. Draw graticule for white point.
  10033. @item black
  10034. Draw graticule for black point.
  10035. @item name
  10036. Draw color points short names.
  10037. @end table
  10038. @item bgopacity, b
  10039. Set background opacity.
  10040. @item lthreshold, l
  10041. Set low threshold for color component not represented on X or Y axis.
  10042. Values lower than this value will be ignored. Default is 0.
  10043. Note this value is multiplied with actual max possible value one pixel component
  10044. can have. So for 8-bit input and low threshold value of 0.1 actual threshold
  10045. is 0.1 * 255 = 25.
  10046. @item hthreshold, h
  10047. Set high threshold for color component not represented on X or Y axis.
  10048. Values higher than this value will be ignored. Default is 1.
  10049. Note this value is multiplied with actual max possible value one pixel component
  10050. can have. So for 8-bit input and high threshold value of 0.9 actual threshold
  10051. is 0.9 * 255 = 230.
  10052. @item colorspace, c
  10053. Set what kind of colorspace to use when drawing graticule.
  10054. @table @samp
  10055. @item auto
  10056. @item 601
  10057. @item 709
  10058. @end table
  10059. Default is auto.
  10060. @end table
  10061. @anchor{vidstabdetect}
  10062. @section vidstabdetect
  10063. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  10064. @ref{vidstabtransform} for pass 2.
  10065. This filter generates a file with relative translation and rotation
  10066. transform information about subsequent frames, which is then used by
  10067. the @ref{vidstabtransform} filter.
  10068. To enable compilation of this filter you need to configure FFmpeg with
  10069. @code{--enable-libvidstab}.
  10070. This filter accepts the following options:
  10071. @table @option
  10072. @item result
  10073. Set the path to the file used to write the transforms information.
  10074. Default value is @file{transforms.trf}.
  10075. @item shakiness
  10076. Set how shaky the video is and how quick the camera is. It accepts an
  10077. integer in the range 1-10, a value of 1 means little shakiness, a
  10078. value of 10 means strong shakiness. Default value is 5.
  10079. @item accuracy
  10080. Set the accuracy of the detection process. It must be a value in the
  10081. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  10082. accuracy. Default value is 15.
  10083. @item stepsize
  10084. Set stepsize of the search process. The region around minimum is
  10085. scanned with 1 pixel resolution. Default value is 6.
  10086. @item mincontrast
  10087. Set minimum contrast. Below this value a local measurement field is
  10088. discarded. Must be a floating point value in the range 0-1. Default
  10089. value is 0.3.
  10090. @item tripod
  10091. Set reference frame number for tripod mode.
  10092. If enabled, the motion of the frames is compared to a reference frame
  10093. in the filtered stream, identified by the specified number. The idea
  10094. is to compensate all movements in a more-or-less static scene and keep
  10095. the camera view absolutely still.
  10096. If set to 0, it is disabled. The frames are counted starting from 1.
  10097. @item show
  10098. Show fields and transforms in the resulting frames. It accepts an
  10099. integer in the range 0-2. Default value is 0, which disables any
  10100. visualization.
  10101. @end table
  10102. @subsection Examples
  10103. @itemize
  10104. @item
  10105. Use default values:
  10106. @example
  10107. vidstabdetect
  10108. @end example
  10109. @item
  10110. Analyze strongly shaky movie and put the results in file
  10111. @file{mytransforms.trf}:
  10112. @example
  10113. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  10114. @end example
  10115. @item
  10116. Visualize the result of internal transformations in the resulting
  10117. video:
  10118. @example
  10119. vidstabdetect=show=1
  10120. @end example
  10121. @item
  10122. Analyze a video with medium shakiness using @command{ffmpeg}:
  10123. @example
  10124. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  10125. @end example
  10126. @end itemize
  10127. @anchor{vidstabtransform}
  10128. @section vidstabtransform
  10129. Video stabilization/deshaking: pass 2 of 2,
  10130. see @ref{vidstabdetect} for pass 1.
  10131. Read a file with transform information for each frame and
  10132. apply/compensate them. Together with the @ref{vidstabdetect}
  10133. filter this can be used to deshake videos. See also
  10134. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  10135. the @ref{unsharp} filter, see below.
  10136. To enable compilation of this filter you need to configure FFmpeg with
  10137. @code{--enable-libvidstab}.
  10138. @subsection Options
  10139. @table @option
  10140. @item input
  10141. Set path to the file used to read the transforms. Default value is
  10142. @file{transforms.trf}.
  10143. @item smoothing
  10144. Set the number of frames (value*2 + 1) used for lowpass filtering the
  10145. camera movements. Default value is 10.
  10146. For example a number of 10 means that 21 frames are used (10 in the
  10147. past and 10 in the future) to smoothen the motion in the video. A
  10148. larger value leads to a smoother video, but limits the acceleration of
  10149. the camera (pan/tilt movements). 0 is a special case where a static
  10150. camera is simulated.
  10151. @item optalgo
  10152. Set the camera path optimization algorithm.
  10153. Accepted values are:
  10154. @table @samp
  10155. @item gauss
  10156. gaussian kernel low-pass filter on camera motion (default)
  10157. @item avg
  10158. averaging on transformations
  10159. @end table
  10160. @item maxshift
  10161. Set maximal number of pixels to translate frames. Default value is -1,
  10162. meaning no limit.
  10163. @item maxangle
  10164. Set maximal angle in radians (degree*PI/180) to rotate frames. Default
  10165. value is -1, meaning no limit.
  10166. @item crop
  10167. Specify how to deal with borders that may be visible due to movement
  10168. compensation.
  10169. Available values are:
  10170. @table @samp
  10171. @item keep
  10172. keep image information from previous frame (default)
  10173. @item black
  10174. fill the border black
  10175. @end table
  10176. @item invert
  10177. Invert transforms if set to 1. Default value is 0.
  10178. @item relative
  10179. Consider transforms as relative to previous frame if set to 1,
  10180. absolute if set to 0. Default value is 0.
  10181. @item zoom
  10182. Set percentage to zoom. A positive value will result in a zoom-in
  10183. effect, a negative value in a zoom-out effect. Default value is 0 (no
  10184. zoom).
  10185. @item optzoom
  10186. Set optimal zooming to avoid borders.
  10187. Accepted values are:
  10188. @table @samp
  10189. @item 0
  10190. disabled
  10191. @item 1
  10192. optimal static zoom value is determined (only very strong movements
  10193. will lead to visible borders) (default)
  10194. @item 2
  10195. optimal adaptive zoom value is determined (no borders will be
  10196. visible), see @option{zoomspeed}
  10197. @end table
  10198. Note that the value given at zoom is added to the one calculated here.
  10199. @item zoomspeed
  10200. Set percent to zoom maximally each frame (enabled when
  10201. @option{optzoom} is set to 2). Range is from 0 to 5, default value is
  10202. 0.25.
  10203. @item interpol
  10204. Specify type of interpolation.
  10205. Available values are:
  10206. @table @samp
  10207. @item no
  10208. no interpolation
  10209. @item linear
  10210. linear only horizontal
  10211. @item bilinear
  10212. linear in both directions (default)
  10213. @item bicubic
  10214. cubic in both directions (slow)
  10215. @end table
  10216. @item tripod
  10217. Enable virtual tripod mode if set to 1, which is equivalent to
  10218. @code{relative=0:smoothing=0}. Default value is 0.
  10219. Use also @code{tripod} option of @ref{vidstabdetect}.
  10220. @item debug
  10221. Increase log verbosity if set to 1. Also the detected global motions
  10222. are written to the temporary file @file{global_motions.trf}. Default
  10223. value is 0.
  10224. @end table
  10225. @subsection Examples
  10226. @itemize
  10227. @item
  10228. Use @command{ffmpeg} for a typical stabilization with default values:
  10229. @example
  10230. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  10231. @end example
  10232. Note the use of the @ref{unsharp} filter which is always recommended.
  10233. @item
  10234. Zoom in a bit more and load transform data from a given file:
  10235. @example
  10236. vidstabtransform=zoom=5:input="mytransforms.trf"
  10237. @end example
  10238. @item
  10239. Smoothen the video even more:
  10240. @example
  10241. vidstabtransform=smoothing=30
  10242. @end example
  10243. @end itemize
  10244. @section vflip
  10245. Flip the input video vertically.
  10246. For example, to vertically flip a video with @command{ffmpeg}:
  10247. @example
  10248. ffmpeg -i in.avi -vf "vflip" out.avi
  10249. @end example
  10250. @anchor{vignette}
  10251. @section vignette
  10252. Make or reverse a natural vignetting effect.
  10253. The filter accepts the following options:
  10254. @table @option
  10255. @item angle, a
  10256. Set lens angle expression as a number of radians.
  10257. The value is clipped in the @code{[0,PI/2]} range.
  10258. Default value: @code{"PI/5"}
  10259. @item x0
  10260. @item y0
  10261. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  10262. by default.
  10263. @item mode
  10264. Set forward/backward mode.
  10265. Available modes are:
  10266. @table @samp
  10267. @item forward
  10268. The larger the distance from the central point, the darker the image becomes.
  10269. @item backward
  10270. The larger the distance from the central point, the brighter the image becomes.
  10271. This can be used to reverse a vignette effect, though there is no automatic
  10272. detection to extract the lens @option{angle} and other settings (yet). It can
  10273. also be used to create a burning effect.
  10274. @end table
  10275. Default value is @samp{forward}.
  10276. @item eval
  10277. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  10278. It accepts the following values:
  10279. @table @samp
  10280. @item init
  10281. Evaluate expressions only once during the filter initialization.
  10282. @item frame
  10283. Evaluate expressions for each incoming frame. This is way slower than the
  10284. @samp{init} mode since it requires all the scalers to be re-computed, but it
  10285. allows advanced dynamic expressions.
  10286. @end table
  10287. Default value is @samp{init}.
  10288. @item dither
  10289. Set dithering to reduce the circular banding effects. Default is @code{1}
  10290. (enabled).
  10291. @item aspect
  10292. Set vignette aspect. This setting allows one to adjust the shape of the vignette.
  10293. Setting this value to the SAR of the input will make a rectangular vignetting
  10294. following the dimensions of the video.
  10295. Default is @code{1/1}.
  10296. @end table
  10297. @subsection Expressions
  10298. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  10299. following parameters.
  10300. @table @option
  10301. @item w
  10302. @item h
  10303. input width and height
  10304. @item n
  10305. the number of input frame, starting from 0
  10306. @item pts
  10307. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  10308. @var{TB} units, NAN if undefined
  10309. @item r
  10310. frame rate of the input video, NAN if the input frame rate is unknown
  10311. @item t
  10312. the PTS (Presentation TimeStamp) of the filtered video frame,
  10313. expressed in seconds, NAN if undefined
  10314. @item tb
  10315. time base of the input video
  10316. @end table
  10317. @subsection Examples
  10318. @itemize
  10319. @item
  10320. Apply simple strong vignetting effect:
  10321. @example
  10322. vignette=PI/4
  10323. @end example
  10324. @item
  10325. Make a flickering vignetting:
  10326. @example
  10327. vignette='PI/4+random(1)*PI/50':eval=frame
  10328. @end example
  10329. @end itemize
  10330. @section vstack
  10331. Stack input videos vertically.
  10332. All streams must be of same pixel format and of same width.
  10333. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  10334. to create same output.
  10335. The filter accept the following option:
  10336. @table @option
  10337. @item inputs
  10338. Set number of input streams. Default is 2.
  10339. @item shortest
  10340. If set to 1, force the output to terminate when the shortest input
  10341. terminates. Default value is 0.
  10342. @end table
  10343. @section w3fdif
  10344. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  10345. Deinterlacing Filter").
  10346. Based on the process described by Martin Weston for BBC R&D, and
  10347. implemented based on the de-interlace algorithm written by Jim
  10348. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  10349. uses filter coefficients calculated by BBC R&D.
  10350. There are two sets of filter coefficients, so called "simple":
  10351. and "complex". Which set of filter coefficients is used can
  10352. be set by passing an optional parameter:
  10353. @table @option
  10354. @item filter
  10355. Set the interlacing filter coefficients. Accepts one of the following values:
  10356. @table @samp
  10357. @item simple
  10358. Simple filter coefficient set.
  10359. @item complex
  10360. More-complex filter coefficient set.
  10361. @end table
  10362. Default value is @samp{complex}.
  10363. @item deint
  10364. Specify which frames to deinterlace. Accept one of the following values:
  10365. @table @samp
  10366. @item all
  10367. Deinterlace all frames,
  10368. @item interlaced
  10369. Only deinterlace frames marked as interlaced.
  10370. @end table
  10371. Default value is @samp{all}.
  10372. @end table
  10373. @section waveform
  10374. Video waveform monitor.
  10375. The waveform monitor plots color component intensity. By default luminance
  10376. only. Each column of the waveform corresponds to a column of pixels in the
  10377. source video.
  10378. It accepts the following options:
  10379. @table @option
  10380. @item mode, m
  10381. Can be either @code{row}, or @code{column}. Default is @code{column}.
  10382. In row mode, the graph on the left side represents color component value 0 and
  10383. the right side represents value = 255. In column mode, the top side represents
  10384. color component value = 0 and bottom side represents value = 255.
  10385. @item intensity, i
  10386. Set intensity. Smaller values are useful to find out how many values of the same
  10387. luminance are distributed across input rows/columns.
  10388. Default value is @code{0.04}. Allowed range is [0, 1].
  10389. @item mirror, r
  10390. Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored.
  10391. In mirrored mode, higher values will be represented on the left
  10392. side for @code{row} mode and at the top for @code{column} mode. Default is
  10393. @code{1} (mirrored).
  10394. @item display, d
  10395. Set display mode.
  10396. It accepts the following values:
  10397. @table @samp
  10398. @item overlay
  10399. Presents information identical to that in the @code{parade}, except
  10400. that the graphs representing color components are superimposed directly
  10401. over one another.
  10402. This display mode makes it easier to spot relative differences or similarities
  10403. in overlapping areas of the color components that are supposed to be identical,
  10404. such as neutral whites, grays, or blacks.
  10405. @item stack
  10406. Display separate graph for the color components side by side in
  10407. @code{row} mode or one below the other in @code{column} mode.
  10408. @item parade
  10409. Display separate graph for the color components side by side in
  10410. @code{column} mode or one below the other in @code{row} mode.
  10411. Using this display mode makes it easy to spot color casts in the highlights
  10412. and shadows of an image, by comparing the contours of the top and the bottom
  10413. graphs of each waveform. Since whites, grays, and blacks are characterized
  10414. by exactly equal amounts of red, green, and blue, neutral areas of the picture
  10415. should display three waveforms of roughly equal width/height. If not, the
  10416. correction is easy to perform by making level adjustments the three waveforms.
  10417. @end table
  10418. Default is @code{stack}.
  10419. @item components, c
  10420. Set which color components to display. Default is 1, which means only luminance
  10421. or red color component if input is in RGB colorspace. If is set for example to
  10422. 7 it will display all 3 (if) available color components.
  10423. @item envelope, e
  10424. @table @samp
  10425. @item none
  10426. No envelope, this is default.
  10427. @item instant
  10428. Instant envelope, minimum and maximum values presented in graph will be easily
  10429. visible even with small @code{step} value.
  10430. @item peak
  10431. Hold minimum and maximum values presented in graph across time. This way you
  10432. can still spot out of range values without constantly looking at waveforms.
  10433. @item peak+instant
  10434. Peak and instant envelope combined together.
  10435. @end table
  10436. @item filter, f
  10437. @table @samp
  10438. @item lowpass
  10439. No filtering, this is default.
  10440. @item flat
  10441. Luma and chroma combined together.
  10442. @item aflat
  10443. Similar as above, but shows difference between blue and red chroma.
  10444. @item chroma
  10445. Displays only chroma.
  10446. @item color
  10447. Displays actual color value on waveform.
  10448. @item acolor
  10449. Similar as above, but with luma showing frequency of chroma values.
  10450. @end table
  10451. @item graticule, g
  10452. Set which graticule to display.
  10453. @table @samp
  10454. @item none
  10455. Do not display graticule.
  10456. @item green
  10457. Display green graticule showing legal broadcast ranges.
  10458. @end table
  10459. @item opacity, o
  10460. Set graticule opacity.
  10461. @item flags, fl
  10462. Set graticule flags.
  10463. @table @samp
  10464. @item numbers
  10465. Draw numbers above lines. By default enabled.
  10466. @item dots
  10467. Draw dots instead of lines.
  10468. @end table
  10469. @item scale, s
  10470. Set scale used for displaying graticule.
  10471. @table @samp
  10472. @item digital
  10473. @item millivolts
  10474. @item ire
  10475. @end table
  10476. Default is digital.
  10477. @end table
  10478. @section xbr
  10479. Apply the xBR high-quality magnification filter which is designed for pixel
  10480. art. It follows a set of edge-detection rules, see
  10481. @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
  10482. It accepts the following option:
  10483. @table @option
  10484. @item n
  10485. Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
  10486. @code{3xBR} and @code{4} for @code{4xBR}.
  10487. Default is @code{3}.
  10488. @end table
  10489. @anchor{yadif}
  10490. @section yadif
  10491. Deinterlace the input video ("yadif" means "yet another deinterlacing
  10492. filter").
  10493. It accepts the following parameters:
  10494. @table @option
  10495. @item mode
  10496. The interlacing mode to adopt. It accepts one of the following values:
  10497. @table @option
  10498. @item 0, send_frame
  10499. Output one frame for each frame.
  10500. @item 1, send_field
  10501. Output one frame for each field.
  10502. @item 2, send_frame_nospatial
  10503. Like @code{send_frame}, but it skips the spatial interlacing check.
  10504. @item 3, send_field_nospatial
  10505. Like @code{send_field}, but it skips the spatial interlacing check.
  10506. @end table
  10507. The default value is @code{send_frame}.
  10508. @item parity
  10509. The picture field parity assumed for the input interlaced video. It accepts one
  10510. of the following values:
  10511. @table @option
  10512. @item 0, tff
  10513. Assume the top field is first.
  10514. @item 1, bff
  10515. Assume the bottom field is first.
  10516. @item -1, auto
  10517. Enable automatic detection of field parity.
  10518. @end table
  10519. The default value is @code{auto}.
  10520. If the interlacing is unknown or the decoder does not export this information,
  10521. top field first will be assumed.
  10522. @item deint
  10523. Specify which frames to deinterlace. Accept one of the following
  10524. values:
  10525. @table @option
  10526. @item 0, all
  10527. Deinterlace all frames.
  10528. @item 1, interlaced
  10529. Only deinterlace frames marked as interlaced.
  10530. @end table
  10531. The default value is @code{all}.
  10532. @end table
  10533. @section zoompan
  10534. Apply Zoom & Pan effect.
  10535. This filter accepts the following options:
  10536. @table @option
  10537. @item zoom, z
  10538. Set the zoom expression. Default is 1.
  10539. @item x
  10540. @item y
  10541. Set the x and y expression. Default is 0.
  10542. @item d
  10543. Set the duration expression in number of frames.
  10544. This sets for how many number of frames effect will last for
  10545. single input image.
  10546. @item s
  10547. Set the output image size, default is 'hd720'.
  10548. @item fps
  10549. Set the output frame rate, default is '25'.
  10550. @end table
  10551. Each expression can contain the following constants:
  10552. @table @option
  10553. @item in_w, iw
  10554. Input width.
  10555. @item in_h, ih
  10556. Input height.
  10557. @item out_w, ow
  10558. Output width.
  10559. @item out_h, oh
  10560. Output height.
  10561. @item in
  10562. Input frame count.
  10563. @item on
  10564. Output frame count.
  10565. @item x
  10566. @item y
  10567. Last calculated 'x' and 'y' position from 'x' and 'y' expression
  10568. for current input frame.
  10569. @item px
  10570. @item py
  10571. 'x' and 'y' of last output frame of previous input frame or 0 when there was
  10572. not yet such frame (first input frame).
  10573. @item zoom
  10574. Last calculated zoom from 'z' expression for current input frame.
  10575. @item pzoom
  10576. Last calculated zoom of last output frame of previous input frame.
  10577. @item duration
  10578. Number of output frames for current input frame. Calculated from 'd' expression
  10579. for each input frame.
  10580. @item pduration
  10581. number of output frames created for previous input frame
  10582. @item a
  10583. Rational number: input width / input height
  10584. @item sar
  10585. sample aspect ratio
  10586. @item dar
  10587. display aspect ratio
  10588. @end table
  10589. @subsection Examples
  10590. @itemize
  10591. @item
  10592. Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
  10593. @example
  10594. 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
  10595. @end example
  10596. @item
  10597. Zoom-in up to 1.5 and pan always at center of picture:
  10598. @example
  10599. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
  10600. @end example
  10601. @end itemize
  10602. @section zscale
  10603. Scale (resize) the input video, using the z.lib library:
  10604. https://github.com/sekrit-twc/zimg.
  10605. The zscale filter forces the output display aspect ratio to be the same
  10606. as the input, by changing the output sample aspect ratio.
  10607. If the input image format is different from the format requested by
  10608. the next filter, the zscale filter will convert the input to the
  10609. requested format.
  10610. @subsection Options
  10611. The filter accepts the following options.
  10612. @table @option
  10613. @item width, w
  10614. @item height, h
  10615. Set the output video dimension expression. Default value is the input
  10616. dimension.
  10617. If the @var{width} or @var{w} is 0, the input width is used for the output.
  10618. If the @var{height} or @var{h} is 0, the input height is used for the output.
  10619. If one of the values is -1, the zscale filter will use a value that
  10620. maintains the aspect ratio of the input image, calculated from the
  10621. other specified dimension. If both of them are -1, the input size is
  10622. used
  10623. If one of the values is -n with n > 1, the zscale filter will also use a value
  10624. that maintains the aspect ratio of the input image, calculated from the other
  10625. specified dimension. After that it will, however, make sure that the calculated
  10626. dimension is divisible by n and adjust the value if necessary.
  10627. See below for the list of accepted constants for use in the dimension
  10628. expression.
  10629. @item size, s
  10630. Set the video size. For the syntax of this option, check the
  10631. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10632. @item dither, d
  10633. Set the dither type.
  10634. Possible values are:
  10635. @table @var
  10636. @item none
  10637. @item ordered
  10638. @item random
  10639. @item error_diffusion
  10640. @end table
  10641. Default is none.
  10642. @item filter, f
  10643. Set the resize filter type.
  10644. Possible values are:
  10645. @table @var
  10646. @item point
  10647. @item bilinear
  10648. @item bicubic
  10649. @item spline16
  10650. @item spline36
  10651. @item lanczos
  10652. @end table
  10653. Default is bilinear.
  10654. @item range, r
  10655. Set the color range.
  10656. Possible values are:
  10657. @table @var
  10658. @item input
  10659. @item limited
  10660. @item full
  10661. @end table
  10662. Default is same as input.
  10663. @item primaries, p
  10664. Set the color primaries.
  10665. Possible values are:
  10666. @table @var
  10667. @item input
  10668. @item 709
  10669. @item unspecified
  10670. @item 170m
  10671. @item 240m
  10672. @item 2020
  10673. @end table
  10674. Default is same as input.
  10675. @item transfer, t
  10676. Set the transfer characteristics.
  10677. Possible values are:
  10678. @table @var
  10679. @item input
  10680. @item 709
  10681. @item unspecified
  10682. @item 601
  10683. @item linear
  10684. @item 2020_10
  10685. @item 2020_12
  10686. @end table
  10687. Default is same as input.
  10688. @item matrix, m
  10689. Set the colorspace matrix.
  10690. Possible value are:
  10691. @table @var
  10692. @item input
  10693. @item 709
  10694. @item unspecified
  10695. @item 470bg
  10696. @item 170m
  10697. @item 2020_ncl
  10698. @item 2020_cl
  10699. @end table
  10700. Default is same as input.
  10701. @item rangein, rin
  10702. Set the input color range.
  10703. Possible values are:
  10704. @table @var
  10705. @item input
  10706. @item limited
  10707. @item full
  10708. @end table
  10709. Default is same as input.
  10710. @item primariesin, pin
  10711. Set the input color primaries.
  10712. Possible values are:
  10713. @table @var
  10714. @item input
  10715. @item 709
  10716. @item unspecified
  10717. @item 170m
  10718. @item 240m
  10719. @item 2020
  10720. @end table
  10721. Default is same as input.
  10722. @item transferin, tin
  10723. Set the input transfer characteristics.
  10724. Possible values are:
  10725. @table @var
  10726. @item input
  10727. @item 709
  10728. @item unspecified
  10729. @item 601
  10730. @item linear
  10731. @item 2020_10
  10732. @item 2020_12
  10733. @end table
  10734. Default is same as input.
  10735. @item matrixin, min
  10736. Set the input colorspace matrix.
  10737. Possible value are:
  10738. @table @var
  10739. @item input
  10740. @item 709
  10741. @item unspecified
  10742. @item 470bg
  10743. @item 170m
  10744. @item 2020_ncl
  10745. @item 2020_cl
  10746. @end table
  10747. @end table
  10748. The values of the @option{w} and @option{h} options are expressions
  10749. containing the following constants:
  10750. @table @var
  10751. @item in_w
  10752. @item in_h
  10753. The input width and height
  10754. @item iw
  10755. @item ih
  10756. These are the same as @var{in_w} and @var{in_h}.
  10757. @item out_w
  10758. @item out_h
  10759. The output (scaled) width and height
  10760. @item ow
  10761. @item oh
  10762. These are the same as @var{out_w} and @var{out_h}
  10763. @item a
  10764. The same as @var{iw} / @var{ih}
  10765. @item sar
  10766. input sample aspect ratio
  10767. @item dar
  10768. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  10769. @item hsub
  10770. @item vsub
  10771. horizontal and vertical input chroma subsample values. For example for the
  10772. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  10773. @item ohsub
  10774. @item ovsub
  10775. horizontal and vertical output chroma subsample values. For example for the
  10776. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  10777. @end table
  10778. @table @option
  10779. @end table
  10780. @c man end VIDEO FILTERS
  10781. @chapter Video Sources
  10782. @c man begin VIDEO SOURCES
  10783. Below is a description of the currently available video sources.
  10784. @section buffer
  10785. Buffer video frames, and make them available to the filter chain.
  10786. This source is mainly intended for a programmatic use, in particular
  10787. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  10788. It accepts the following parameters:
  10789. @table @option
  10790. @item video_size
  10791. Specify the size (width and height) of the buffered video frames. For the
  10792. syntax of this option, check the
  10793. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10794. @item width
  10795. The input video width.
  10796. @item height
  10797. The input video height.
  10798. @item pix_fmt
  10799. A string representing the pixel format of the buffered video frames.
  10800. It may be a number corresponding to a pixel format, or a pixel format
  10801. name.
  10802. @item time_base
  10803. Specify the timebase assumed by the timestamps of the buffered frames.
  10804. @item frame_rate
  10805. Specify the frame rate expected for the video stream.
  10806. @item pixel_aspect, sar
  10807. The sample (pixel) aspect ratio of the input video.
  10808. @item sws_param
  10809. Specify the optional parameters to be used for the scale filter which
  10810. is automatically inserted when an input change is detected in the
  10811. input size or format.
  10812. @item hw_frames_ctx
  10813. When using a hardware pixel format, this should be a reference to an
  10814. AVHWFramesContext describing input frames.
  10815. @end table
  10816. For example:
  10817. @example
  10818. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  10819. @end example
  10820. will instruct the source to accept video frames with size 320x240 and
  10821. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  10822. square pixels (1:1 sample aspect ratio).
  10823. Since the pixel format with name "yuv410p" corresponds to the number 6
  10824. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  10825. this example corresponds to:
  10826. @example
  10827. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  10828. @end example
  10829. Alternatively, the options can be specified as a flat string, but this
  10830. syntax is deprecated:
  10831. @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}]
  10832. @section cellauto
  10833. Create a pattern generated by an elementary cellular automaton.
  10834. The initial state of the cellular automaton can be defined through the
  10835. @option{filename}, and @option{pattern} options. If such options are
  10836. not specified an initial state is created randomly.
  10837. At each new frame a new row in the video is filled with the result of
  10838. the cellular automaton next generation. The behavior when the whole
  10839. frame is filled is defined by the @option{scroll} option.
  10840. This source accepts the following options:
  10841. @table @option
  10842. @item filename, f
  10843. Read the initial cellular automaton state, i.e. the starting row, from
  10844. the specified file.
  10845. In the file, each non-whitespace character is considered an alive
  10846. cell, a newline will terminate the row, and further characters in the
  10847. file will be ignored.
  10848. @item pattern, p
  10849. Read the initial cellular automaton state, i.e. the starting row, from
  10850. the specified string.
  10851. Each non-whitespace character in the string is considered an alive
  10852. cell, a newline will terminate the row, and further characters in the
  10853. string will be ignored.
  10854. @item rate, r
  10855. Set the video rate, that is the number of frames generated per second.
  10856. Default is 25.
  10857. @item random_fill_ratio, ratio
  10858. Set the random fill ratio for the initial cellular automaton row. It
  10859. is a floating point number value ranging from 0 to 1, defaults to
  10860. 1/PHI.
  10861. This option is ignored when a file or a pattern is specified.
  10862. @item random_seed, seed
  10863. Set the seed for filling randomly the initial row, must be an integer
  10864. included between 0 and UINT32_MAX. If not specified, or if explicitly
  10865. set to -1, the filter will try to use a good random seed on a best
  10866. effort basis.
  10867. @item rule
  10868. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  10869. Default value is 110.
  10870. @item size, s
  10871. Set the size of the output video. For the syntax of this option, check the
  10872. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10873. If @option{filename} or @option{pattern} is specified, the size is set
  10874. by default to the width of the specified initial state row, and the
  10875. height is set to @var{width} * PHI.
  10876. If @option{size} is set, it must contain the width of the specified
  10877. pattern string, and the specified pattern will be centered in the
  10878. larger row.
  10879. If a filename or a pattern string is not specified, the size value
  10880. defaults to "320x518" (used for a randomly generated initial state).
  10881. @item scroll
  10882. If set to 1, scroll the output upward when all the rows in the output
  10883. have been already filled. If set to 0, the new generated row will be
  10884. written over the top row just after the bottom row is filled.
  10885. Defaults to 1.
  10886. @item start_full, full
  10887. If set to 1, completely fill the output with generated rows before
  10888. outputting the first frame.
  10889. This is the default behavior, for disabling set the value to 0.
  10890. @item stitch
  10891. If set to 1, stitch the left and right row edges together.
  10892. This is the default behavior, for disabling set the value to 0.
  10893. @end table
  10894. @subsection Examples
  10895. @itemize
  10896. @item
  10897. Read the initial state from @file{pattern}, and specify an output of
  10898. size 200x400.
  10899. @example
  10900. cellauto=f=pattern:s=200x400
  10901. @end example
  10902. @item
  10903. Generate a random initial row with a width of 200 cells, with a fill
  10904. ratio of 2/3:
  10905. @example
  10906. cellauto=ratio=2/3:s=200x200
  10907. @end example
  10908. @item
  10909. Create a pattern generated by rule 18 starting by a single alive cell
  10910. centered on an initial row with width 100:
  10911. @example
  10912. cellauto=p=@@:s=100x400:full=0:rule=18
  10913. @end example
  10914. @item
  10915. Specify a more elaborated initial pattern:
  10916. @example
  10917. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  10918. @end example
  10919. @end itemize
  10920. @anchor{coreimagesrc}
  10921. @section coreimagesrc
  10922. Video source generated on GPU using Apple's CoreImage API on OSX.
  10923. This video source is a specialized version of the @ref{coreimage} video filter.
  10924. Use a core image generator at the beginning of the applied filterchain to
  10925. generate the content.
  10926. The coreimagesrc video source accepts the following options:
  10927. @table @option
  10928. @item list_generators
  10929. List all available generators along with all their respective options as well as
  10930. possible minimum and maximum values along with the default values.
  10931. @example
  10932. list_generators=true
  10933. @end example
  10934. @item size, s
  10935. Specify the size of the sourced video. For the syntax of this option, check the
  10936. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10937. The default value is @code{320x240}.
  10938. @item rate, r
  10939. Specify the frame rate of the sourced video, as the number of frames
  10940. generated per second. It has to be a string in the format
  10941. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  10942. number or a valid video frame rate abbreviation. The default value is
  10943. "25".
  10944. @item sar
  10945. Set the sample aspect ratio of the sourced video.
  10946. @item duration, d
  10947. Set the duration of the sourced video. See
  10948. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  10949. for the accepted syntax.
  10950. If not specified, or the expressed duration is negative, the video is
  10951. supposed to be generated forever.
  10952. @end table
  10953. Additionally, all options of the @ref{coreimage} video filter are accepted.
  10954. A complete filterchain can be used for further processing of the
  10955. generated input without CPU-HOST transfer. See @ref{coreimage} documentation
  10956. and examples for details.
  10957. @subsection Examples
  10958. @itemize
  10959. @item
  10960. Use CIQRCodeGenerator to create a QR code for the FFmpeg homepage,
  10961. given as complete and escaped command-line for Apple's standard bash shell:
  10962. @example
  10963. ffmpeg -f lavfi -i coreimagesrc=s=100x100:filter=CIQRCodeGenerator@@inputMessage=https\\\\\://FFmpeg.org/@@inputCorrectionLevel=H -frames:v 1 QRCode.png
  10964. @end example
  10965. This example is equivalent to the QRCode example of @ref{coreimage} without the
  10966. need for a nullsrc video source.
  10967. @end itemize
  10968. @section mandelbrot
  10969. Generate a Mandelbrot set fractal, and progressively zoom towards the
  10970. point specified with @var{start_x} and @var{start_y}.
  10971. This source accepts the following options:
  10972. @table @option
  10973. @item end_pts
  10974. Set the terminal pts value. Default value is 400.
  10975. @item end_scale
  10976. Set the terminal scale value.
  10977. Must be a floating point value. Default value is 0.3.
  10978. @item inner
  10979. Set the inner coloring mode, that is the algorithm used to draw the
  10980. Mandelbrot fractal internal region.
  10981. It shall assume one of the following values:
  10982. @table @option
  10983. @item black
  10984. Set black mode.
  10985. @item convergence
  10986. Show time until convergence.
  10987. @item mincol
  10988. Set color based on point closest to the origin of the iterations.
  10989. @item period
  10990. Set period mode.
  10991. @end table
  10992. Default value is @var{mincol}.
  10993. @item bailout
  10994. Set the bailout value. Default value is 10.0.
  10995. @item maxiter
  10996. Set the maximum of iterations performed by the rendering
  10997. algorithm. Default value is 7189.
  10998. @item outer
  10999. Set outer coloring mode.
  11000. It shall assume one of following values:
  11001. @table @option
  11002. @item iteration_count
  11003. Set iteration cound mode.
  11004. @item normalized_iteration_count
  11005. set normalized iteration count mode.
  11006. @end table
  11007. Default value is @var{normalized_iteration_count}.
  11008. @item rate, r
  11009. Set frame rate, expressed as number of frames per second. Default
  11010. value is "25".
  11011. @item size, s
  11012. Set frame size. For the syntax of this option, check the "Video
  11013. size" section in the ffmpeg-utils manual. Default value is "640x480".
  11014. @item start_scale
  11015. Set the initial scale value. Default value is 3.0.
  11016. @item start_x
  11017. Set the initial x position. Must be a floating point value between
  11018. -100 and 100. Default value is -0.743643887037158704752191506114774.
  11019. @item start_y
  11020. Set the initial y position. Must be a floating point value between
  11021. -100 and 100. Default value is -0.131825904205311970493132056385139.
  11022. @end table
  11023. @section mptestsrc
  11024. Generate various test patterns, as generated by the MPlayer test filter.
  11025. The size of the generated video is fixed, and is 256x256.
  11026. This source is useful in particular for testing encoding features.
  11027. This source accepts the following options:
  11028. @table @option
  11029. @item rate, r
  11030. Specify the frame rate of the sourced video, as the number of frames
  11031. generated per second. It has to be a string in the format
  11032. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  11033. number or a valid video frame rate abbreviation. The default value is
  11034. "25".
  11035. @item duration, d
  11036. Set the duration of the sourced video. See
  11037. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  11038. for the accepted syntax.
  11039. If not specified, or the expressed duration is negative, the video is
  11040. supposed to be generated forever.
  11041. @item test, t
  11042. Set the number or the name of the test to perform. Supported tests are:
  11043. @table @option
  11044. @item dc_luma
  11045. @item dc_chroma
  11046. @item freq_luma
  11047. @item freq_chroma
  11048. @item amp_luma
  11049. @item amp_chroma
  11050. @item cbp
  11051. @item mv
  11052. @item ring1
  11053. @item ring2
  11054. @item all
  11055. @end table
  11056. Default value is "all", which will cycle through the list of all tests.
  11057. @end table
  11058. Some examples:
  11059. @example
  11060. mptestsrc=t=dc_luma
  11061. @end example
  11062. will generate a "dc_luma" test pattern.
  11063. @section frei0r_src
  11064. Provide a frei0r source.
  11065. To enable compilation of this filter you need to install the frei0r
  11066. header and configure FFmpeg with @code{--enable-frei0r}.
  11067. This source accepts the following parameters:
  11068. @table @option
  11069. @item size
  11070. The size of the video to generate. For the syntax of this option, check the
  11071. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11072. @item framerate
  11073. The framerate of the generated video. It may be a string of the form
  11074. @var{num}/@var{den} or a frame rate abbreviation.
  11075. @item filter_name
  11076. The name to the frei0r source to load. For more information regarding frei0r and
  11077. how to set the parameters, read the @ref{frei0r} section in the video filters
  11078. documentation.
  11079. @item filter_params
  11080. A '|'-separated list of parameters to pass to the frei0r source.
  11081. @end table
  11082. For example, to generate a frei0r partik0l source with size 200x200
  11083. and frame rate 10 which is overlaid on the overlay filter main input:
  11084. @example
  11085. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  11086. @end example
  11087. @section life
  11088. Generate a life pattern.
  11089. This source is based on a generalization of John Conway's life game.
  11090. The sourced input represents a life grid, each pixel represents a cell
  11091. which can be in one of two possible states, alive or dead. Every cell
  11092. interacts with its eight neighbours, which are the cells that are
  11093. horizontally, vertically, or diagonally adjacent.
  11094. At each interaction the grid evolves according to the adopted rule,
  11095. which specifies the number of neighbor alive cells which will make a
  11096. cell stay alive or born. The @option{rule} option allows one to specify
  11097. the rule to adopt.
  11098. This source accepts the following options:
  11099. @table @option
  11100. @item filename, f
  11101. Set the file from which to read the initial grid state. In the file,
  11102. each non-whitespace character is considered an alive cell, and newline
  11103. is used to delimit the end of each row.
  11104. If this option is not specified, the initial grid is generated
  11105. randomly.
  11106. @item rate, r
  11107. Set the video rate, that is the number of frames generated per second.
  11108. Default is 25.
  11109. @item random_fill_ratio, ratio
  11110. Set the random fill ratio for the initial random grid. It is a
  11111. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  11112. It is ignored when a file is specified.
  11113. @item random_seed, seed
  11114. Set the seed for filling the initial random grid, must be an integer
  11115. included between 0 and UINT32_MAX. If not specified, or if explicitly
  11116. set to -1, the filter will try to use a good random seed on a best
  11117. effort basis.
  11118. @item rule
  11119. Set the life rule.
  11120. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  11121. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  11122. @var{NS} specifies the number of alive neighbor cells which make a
  11123. live cell stay alive, and @var{NB} the number of alive neighbor cells
  11124. which make a dead cell to become alive (i.e. to "born").
  11125. "s" and "b" can be used in place of "S" and "B", respectively.
  11126. Alternatively a rule can be specified by an 18-bits integer. The 9
  11127. high order bits are used to encode the next cell state if it is alive
  11128. for each number of neighbor alive cells, the low order bits specify
  11129. the rule for "borning" new cells. Higher order bits encode for an
  11130. higher number of neighbor cells.
  11131. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  11132. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  11133. Default value is "S23/B3", which is the original Conway's game of life
  11134. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  11135. cells, and will born a new cell if there are three alive cells around
  11136. a dead cell.
  11137. @item size, s
  11138. Set the size of the output video. For the syntax of this option, check the
  11139. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11140. If @option{filename} is specified, the size is set by default to the
  11141. same size of the input file. If @option{size} is set, it must contain
  11142. the size specified in the input file, and the initial grid defined in
  11143. that file is centered in the larger resulting area.
  11144. If a filename is not specified, the size value defaults to "320x240"
  11145. (used for a randomly generated initial grid).
  11146. @item stitch
  11147. If set to 1, stitch the left and right grid edges together, and the
  11148. top and bottom edges also. Defaults to 1.
  11149. @item mold
  11150. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  11151. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  11152. value from 0 to 255.
  11153. @item life_color
  11154. Set the color of living (or new born) cells.
  11155. @item death_color
  11156. Set the color of dead cells. If @option{mold} is set, this is the first color
  11157. used to represent a dead cell.
  11158. @item mold_color
  11159. Set mold color, for definitely dead and moldy cells.
  11160. For the syntax of these 3 color options, check the "Color" section in the
  11161. ffmpeg-utils manual.
  11162. @end table
  11163. @subsection Examples
  11164. @itemize
  11165. @item
  11166. Read a grid from @file{pattern}, and center it on a grid of size
  11167. 300x300 pixels:
  11168. @example
  11169. life=f=pattern:s=300x300
  11170. @end example
  11171. @item
  11172. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  11173. @example
  11174. life=ratio=2/3:s=200x200
  11175. @end example
  11176. @item
  11177. Specify a custom rule for evolving a randomly generated grid:
  11178. @example
  11179. life=rule=S14/B34
  11180. @end example
  11181. @item
  11182. Full example with slow death effect (mold) using @command{ffplay}:
  11183. @example
  11184. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  11185. @end example
  11186. @end itemize
  11187. @anchor{allrgb}
  11188. @anchor{allyuv}
  11189. @anchor{color}
  11190. @anchor{haldclutsrc}
  11191. @anchor{nullsrc}
  11192. @anchor{rgbtestsrc}
  11193. @anchor{smptebars}
  11194. @anchor{smptehdbars}
  11195. @anchor{testsrc}
  11196. @anchor{testsrc2}
  11197. @section allrgb, allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc, testsrc2
  11198. The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
  11199. The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
  11200. The @code{color} source provides an uniformly colored input.
  11201. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  11202. @ref{haldclut} filter.
  11203. The @code{nullsrc} source returns unprocessed video frames. It is
  11204. mainly useful to be employed in analysis / debugging tools, or as the
  11205. source for filters which ignore the input data.
  11206. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  11207. detecting RGB vs BGR issues. You should see a red, green and blue
  11208. stripe from top to bottom.
  11209. The @code{smptebars} source generates a color bars pattern, based on
  11210. the SMPTE Engineering Guideline EG 1-1990.
  11211. The @code{smptehdbars} source generates a color bars pattern, based on
  11212. the SMPTE RP 219-2002.
  11213. The @code{testsrc} source generates a test video pattern, showing a
  11214. color pattern, a scrolling gradient and a timestamp. This is mainly
  11215. intended for testing purposes.
  11216. The @code{testsrc2} source is similar to testsrc, but supports more
  11217. pixel formats instead of just @code{rgb24}. This allows using it as an
  11218. input for other tests without requiring a format conversion.
  11219. The sources accept the following parameters:
  11220. @table @option
  11221. @item color, c
  11222. Specify the color of the source, only available in the @code{color}
  11223. source. For the syntax of this option, check the "Color" section in the
  11224. ffmpeg-utils manual.
  11225. @item level
  11226. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  11227. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  11228. pixels to be used as identity matrix for 3D lookup tables. Each component is
  11229. coded on a @code{1/(N*N)} scale.
  11230. @item size, s
  11231. Specify the size of the sourced video. For the syntax of this option, check the
  11232. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11233. The default value is @code{320x240}.
  11234. This option is not available with the @code{haldclutsrc} filter.
  11235. @item rate, r
  11236. Specify the frame rate of the sourced video, as the number of frames
  11237. generated per second. It has to be a string in the format
  11238. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  11239. number or a valid video frame rate abbreviation. The default value is
  11240. "25".
  11241. @item sar
  11242. Set the sample aspect ratio of the sourced video.
  11243. @item duration, d
  11244. Set the duration of the sourced video. See
  11245. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  11246. for the accepted syntax.
  11247. If not specified, or the expressed duration is negative, the video is
  11248. supposed to be generated forever.
  11249. @item decimals, n
  11250. Set the number of decimals to show in the timestamp, only available in the
  11251. @code{testsrc} source.
  11252. The displayed timestamp value will correspond to the original
  11253. timestamp value multiplied by the power of 10 of the specified
  11254. value. Default value is 0.
  11255. @end table
  11256. For example the following:
  11257. @example
  11258. testsrc=duration=5.3:size=qcif:rate=10
  11259. @end example
  11260. will generate a video with a duration of 5.3 seconds, with size
  11261. 176x144 and a frame rate of 10 frames per second.
  11262. The following graph description will generate a red source
  11263. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  11264. frames per second.
  11265. @example
  11266. color=c=red@@0.2:s=qcif:r=10
  11267. @end example
  11268. If the input content is to be ignored, @code{nullsrc} can be used. The
  11269. following command generates noise in the luminance plane by employing
  11270. the @code{geq} filter:
  11271. @example
  11272. nullsrc=s=256x256, geq=random(1)*255:128:128
  11273. @end example
  11274. @subsection Commands
  11275. The @code{color} source supports the following commands:
  11276. @table @option
  11277. @item c, color
  11278. Set the color of the created image. Accepts the same syntax of the
  11279. corresponding @option{color} option.
  11280. @end table
  11281. @c man end VIDEO SOURCES
  11282. @chapter Video Sinks
  11283. @c man begin VIDEO SINKS
  11284. Below is a description of the currently available video sinks.
  11285. @section buffersink
  11286. Buffer video frames, and make them available to the end of the filter
  11287. graph.
  11288. This sink is mainly intended for programmatic use, in particular
  11289. through the interface defined in @file{libavfilter/buffersink.h}
  11290. or the options system.
  11291. It accepts a pointer to an AVBufferSinkContext structure, which
  11292. defines the incoming buffers' formats, to be passed as the opaque
  11293. parameter to @code{avfilter_init_filter} for initialization.
  11294. @section nullsink
  11295. Null video sink: do absolutely nothing with the input video. It is
  11296. mainly useful as a template and for use in analysis / debugging
  11297. tools.
  11298. @c man end VIDEO SINKS
  11299. @chapter Multimedia Filters
  11300. @c man begin MULTIMEDIA FILTERS
  11301. Below is a description of the currently available multimedia filters.
  11302. @section ahistogram
  11303. Convert input audio to a video output, displaying the volume histogram.
  11304. The filter accepts the following options:
  11305. @table @option
  11306. @item dmode
  11307. Specify how histogram is calculated.
  11308. It accepts the following values:
  11309. @table @samp
  11310. @item single
  11311. Use single histogram for all channels.
  11312. @item separate
  11313. Use separate histogram for each channel.
  11314. @end table
  11315. Default is @code{single}.
  11316. @item rate, r
  11317. Set frame rate, expressed as number of frames per second. Default
  11318. value is "25".
  11319. @item size, s
  11320. Specify the video size for the output. For the syntax of this option, check the
  11321. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11322. Default value is @code{hd720}.
  11323. @item scale
  11324. Set display scale.
  11325. It accepts the following values:
  11326. @table @samp
  11327. @item log
  11328. logarithmic
  11329. @item sqrt
  11330. square root
  11331. @item cbrt
  11332. cubic root
  11333. @item lin
  11334. linear
  11335. @item rlog
  11336. reverse logarithmic
  11337. @end table
  11338. Default is @code{log}.
  11339. @item ascale
  11340. Set amplitude scale.
  11341. It accepts the following values:
  11342. @table @samp
  11343. @item log
  11344. logarithmic
  11345. @item lin
  11346. linear
  11347. @end table
  11348. Default is @code{log}.
  11349. @item acount
  11350. Set how much frames to accumulate in histogram.
  11351. Defauls is 1. Setting this to -1 accumulates all frames.
  11352. @item rheight
  11353. Set histogram ratio of window height.
  11354. @item slide
  11355. Set sonogram sliding.
  11356. It accepts the following values:
  11357. @table @samp
  11358. @item replace
  11359. replace old rows with new ones.
  11360. @item scroll
  11361. scroll from top to bottom.
  11362. @end table
  11363. Default is @code{replace}.
  11364. @end table
  11365. @section aphasemeter
  11366. Convert input audio to a video output, displaying the audio phase.
  11367. The filter accepts the following options:
  11368. @table @option
  11369. @item rate, r
  11370. Set the output frame rate. Default value is @code{25}.
  11371. @item size, s
  11372. Set the video size for the output. For the syntax of this option, check the
  11373. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11374. Default value is @code{800x400}.
  11375. @item rc
  11376. @item gc
  11377. @item bc
  11378. Specify the red, green, blue contrast. Default values are @code{2},
  11379. @code{7} and @code{1}.
  11380. Allowed range is @code{[0, 255]}.
  11381. @item mpc
  11382. Set color which will be used for drawing median phase. If color is
  11383. @code{none} which is default, no median phase value will be drawn.
  11384. @end table
  11385. The filter also exports the frame metadata @code{lavfi.aphasemeter.phase} which
  11386. represents mean phase of current audio frame. Value is in range @code{[-1, 1]}.
  11387. The @code{-1} means left and right channels are completely out of phase and
  11388. @code{1} means channels are in phase.
  11389. @section avectorscope
  11390. Convert input audio to a video output, representing the audio vector
  11391. scope.
  11392. The filter is used to measure the difference between channels of stereo
  11393. audio stream. A monoaural signal, consisting of identical left and right
  11394. signal, results in straight vertical line. Any stereo separation is visible
  11395. as a deviation from this line, creating a Lissajous figure.
  11396. If the straight (or deviation from it) but horizontal line appears this
  11397. indicates that the left and right channels are out of phase.
  11398. The filter accepts the following options:
  11399. @table @option
  11400. @item mode, m
  11401. Set the vectorscope mode.
  11402. Available values are:
  11403. @table @samp
  11404. @item lissajous
  11405. Lissajous rotated by 45 degrees.
  11406. @item lissajous_xy
  11407. Same as above but not rotated.
  11408. @item polar
  11409. Shape resembling half of circle.
  11410. @end table
  11411. Default value is @samp{lissajous}.
  11412. @item size, s
  11413. Set the video size for the output. For the syntax of this option, check the
  11414. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11415. Default value is @code{400x400}.
  11416. @item rate, r
  11417. Set the output frame rate. Default value is @code{25}.
  11418. @item rc
  11419. @item gc
  11420. @item bc
  11421. @item ac
  11422. Specify the red, green, blue and alpha contrast. Default values are @code{40},
  11423. @code{160}, @code{80} and @code{255}.
  11424. Allowed range is @code{[0, 255]}.
  11425. @item rf
  11426. @item gf
  11427. @item bf
  11428. @item af
  11429. Specify the red, green, blue and alpha fade. Default values are @code{15},
  11430. @code{10}, @code{5} and @code{5}.
  11431. Allowed range is @code{[0, 255]}.
  11432. @item zoom
  11433. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  11434. @item draw
  11435. Set the vectorscope drawing mode.
  11436. Available values are:
  11437. @table @samp
  11438. @item dot
  11439. Draw dot for each sample.
  11440. @item line
  11441. Draw line between previous and current sample.
  11442. @end table
  11443. Default value is @samp{dot}.
  11444. @end table
  11445. @subsection Examples
  11446. @itemize
  11447. @item
  11448. Complete example using @command{ffplay}:
  11449. @example
  11450. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  11451. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  11452. @end example
  11453. @end itemize
  11454. @section bench, abench
  11455. Benchmark part of a filtergraph.
  11456. The filter accepts the following options:
  11457. @table @option
  11458. @item action
  11459. Start or stop a timer.
  11460. Available values are:
  11461. @table @samp
  11462. @item start
  11463. Get the current time, set it as frame metadata (using the key
  11464. @code{lavfi.bench.start_time}), and forward the frame to the next filter.
  11465. @item stop
  11466. Get the current time and fetch the @code{lavfi.bench.start_time} metadata from
  11467. the input frame metadata to get the time difference. Time difference, average,
  11468. maximum and minimum time (respectively @code{t}, @code{avg}, @code{max} and
  11469. @code{min}) are then printed. The timestamps are expressed in seconds.
  11470. @end table
  11471. @end table
  11472. @subsection Examples
  11473. @itemize
  11474. @item
  11475. Benchmark @ref{selectivecolor} filter:
  11476. @example
  11477. bench=start,selectivecolor=reds=-.2 .12 -.49,bench=stop
  11478. @end example
  11479. @end itemize
  11480. @section concat
  11481. Concatenate audio and video streams, joining them together one after the
  11482. other.
  11483. The filter works on segments of synchronized video and audio streams. All
  11484. segments must have the same number of streams of each type, and that will
  11485. also be the number of streams at output.
  11486. The filter accepts the following options:
  11487. @table @option
  11488. @item n
  11489. Set the number of segments. Default is 2.
  11490. @item v
  11491. Set the number of output video streams, that is also the number of video
  11492. streams in each segment. Default is 1.
  11493. @item a
  11494. Set the number of output audio streams, that is also the number of audio
  11495. streams in each segment. Default is 0.
  11496. @item unsafe
  11497. Activate unsafe mode: do not fail if segments have a different format.
  11498. @end table
  11499. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  11500. @var{a} audio outputs.
  11501. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  11502. segment, in the same order as the outputs, then the inputs for the second
  11503. segment, etc.
  11504. Related streams do not always have exactly the same duration, for various
  11505. reasons including codec frame size or sloppy authoring. For that reason,
  11506. related synchronized streams (e.g. a video and its audio track) should be
  11507. concatenated at once. The concat filter will use the duration of the longest
  11508. stream in each segment (except the last one), and if necessary pad shorter
  11509. audio streams with silence.
  11510. For this filter to work correctly, all segments must start at timestamp 0.
  11511. All corresponding streams must have the same parameters in all segments; the
  11512. filtering system will automatically select a common pixel format for video
  11513. streams, and a common sample format, sample rate and channel layout for
  11514. audio streams, but other settings, such as resolution, must be converted
  11515. explicitly by the user.
  11516. Different frame rates are acceptable but will result in variable frame rate
  11517. at output; be sure to configure the output file to handle it.
  11518. @subsection Examples
  11519. @itemize
  11520. @item
  11521. Concatenate an opening, an episode and an ending, all in bilingual version
  11522. (video in stream 0, audio in streams 1 and 2):
  11523. @example
  11524. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  11525. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  11526. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  11527. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  11528. @end example
  11529. @item
  11530. Concatenate two parts, handling audio and video separately, using the
  11531. (a)movie sources, and adjusting the resolution:
  11532. @example
  11533. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  11534. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  11535. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  11536. @end example
  11537. Note that a desync will happen at the stitch if the audio and video streams
  11538. do not have exactly the same duration in the first file.
  11539. @end itemize
  11540. @anchor{ebur128}
  11541. @section ebur128
  11542. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  11543. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  11544. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  11545. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  11546. The filter also has a video output (see the @var{video} option) with a real
  11547. time graph to observe the loudness evolution. The graphic contains the logged
  11548. message mentioned above, so it is not printed anymore when this option is set,
  11549. unless the verbose logging is set. The main graphing area contains the
  11550. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  11551. the momentary loudness (400 milliseconds).
  11552. More information about the Loudness Recommendation EBU R128 on
  11553. @url{http://tech.ebu.ch/loudness}.
  11554. The filter accepts the following options:
  11555. @table @option
  11556. @item video
  11557. Activate the video output. The audio stream is passed unchanged whether this
  11558. option is set or no. The video stream will be the first output stream if
  11559. activated. Default is @code{0}.
  11560. @item size
  11561. Set the video size. This option is for video only. For the syntax of this
  11562. option, check the
  11563. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11564. Default and minimum resolution is @code{640x480}.
  11565. @item meter
  11566. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  11567. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  11568. other integer value between this range is allowed.
  11569. @item metadata
  11570. Set metadata injection. If set to @code{1}, the audio input will be segmented
  11571. into 100ms output frames, each of them containing various loudness information
  11572. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  11573. Default is @code{0}.
  11574. @item framelog
  11575. Force the frame logging level.
  11576. Available values are:
  11577. @table @samp
  11578. @item info
  11579. information logging level
  11580. @item verbose
  11581. verbose logging level
  11582. @end table
  11583. By default, the logging level is set to @var{info}. If the @option{video} or
  11584. the @option{metadata} options are set, it switches to @var{verbose}.
  11585. @item peak
  11586. Set peak mode(s).
  11587. Available modes can be cumulated (the option is a @code{flag} type). Possible
  11588. values are:
  11589. @table @samp
  11590. @item none
  11591. Disable any peak mode (default).
  11592. @item sample
  11593. Enable sample-peak mode.
  11594. Simple peak mode looking for the higher sample value. It logs a message
  11595. for sample-peak (identified by @code{SPK}).
  11596. @item true
  11597. Enable true-peak mode.
  11598. If enabled, the peak lookup is done on an over-sampled version of the input
  11599. stream for better peak accuracy. It logs a message for true-peak.
  11600. (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
  11601. This mode requires a build with @code{libswresample}.
  11602. @end table
  11603. @item dualmono
  11604. Treat mono input files as "dual mono". If a mono file is intended for playback
  11605. on a stereo system, its EBU R128 measurement will be perceptually incorrect.
  11606. If set to @code{true}, this option will compensate for this effect.
  11607. Multi-channel input files are not affected by this option.
  11608. @item panlaw
  11609. Set a specific pan law to be used for the measurement of dual mono files.
  11610. This parameter is optional, and has a default value of -3.01dB.
  11611. @end table
  11612. @subsection Examples
  11613. @itemize
  11614. @item
  11615. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  11616. @example
  11617. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  11618. @end example
  11619. @item
  11620. Run an analysis with @command{ffmpeg}:
  11621. @example
  11622. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  11623. @end example
  11624. @end itemize
  11625. @section interleave, ainterleave
  11626. Temporally interleave frames from several inputs.
  11627. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  11628. These filters read frames from several inputs and send the oldest
  11629. queued frame to the output.
  11630. Input streams must have a well defined, monotonically increasing frame
  11631. timestamp values.
  11632. In order to submit one frame to output, these filters need to enqueue
  11633. at least one frame for each input, so they cannot work in case one
  11634. input is not yet terminated and will not receive incoming frames.
  11635. For example consider the case when one input is a @code{select} filter
  11636. which always drop input frames. The @code{interleave} filter will keep
  11637. reading from that input, but it will never be able to send new frames
  11638. to output until the input will send an end-of-stream signal.
  11639. Also, depending on inputs synchronization, the filters will drop
  11640. frames in case one input receives more frames than the other ones, and
  11641. the queue is already filled.
  11642. These filters accept the following options:
  11643. @table @option
  11644. @item nb_inputs, n
  11645. Set the number of different inputs, it is 2 by default.
  11646. @end table
  11647. @subsection Examples
  11648. @itemize
  11649. @item
  11650. Interleave frames belonging to different streams using @command{ffmpeg}:
  11651. @example
  11652. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  11653. @end example
  11654. @item
  11655. Add flickering blur effect:
  11656. @example
  11657. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  11658. @end example
  11659. @end itemize
  11660. @section perms, aperms
  11661. Set read/write permissions for the output frames.
  11662. These filters are mainly aimed at developers to test direct path in the
  11663. following filter in the filtergraph.
  11664. The filters accept the following options:
  11665. @table @option
  11666. @item mode
  11667. Select the permissions mode.
  11668. It accepts the following values:
  11669. @table @samp
  11670. @item none
  11671. Do nothing. This is the default.
  11672. @item ro
  11673. Set all the output frames read-only.
  11674. @item rw
  11675. Set all the output frames directly writable.
  11676. @item toggle
  11677. Make the frame read-only if writable, and writable if read-only.
  11678. @item random
  11679. Set each output frame read-only or writable randomly.
  11680. @end table
  11681. @item seed
  11682. Set the seed for the @var{random} mode, must be an integer included between
  11683. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  11684. @code{-1}, the filter will try to use a good random seed on a best effort
  11685. basis.
  11686. @end table
  11687. Note: in case of auto-inserted filter between the permission filter and the
  11688. following one, the permission might not be received as expected in that
  11689. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  11690. perms/aperms filter can avoid this problem.
  11691. @section realtime, arealtime
  11692. Slow down filtering to match real time approximatively.
  11693. These filters will pause the filtering for a variable amount of time to
  11694. match the output rate with the input timestamps.
  11695. They are similar to the @option{re} option to @code{ffmpeg}.
  11696. They accept the following options:
  11697. @table @option
  11698. @item limit
  11699. Time limit for the pauses. Any pause longer than that will be considered
  11700. a timestamp discontinuity and reset the timer. Default is 2 seconds.
  11701. @end table
  11702. @section select, aselect
  11703. Select frames to pass in output.
  11704. This filter accepts the following options:
  11705. @table @option
  11706. @item expr, e
  11707. Set expression, which is evaluated for each input frame.
  11708. If the expression is evaluated to zero, the frame is discarded.
  11709. If the evaluation result is negative or NaN, the frame is sent to the
  11710. first output; otherwise it is sent to the output with index
  11711. @code{ceil(val)-1}, assuming that the input index starts from 0.
  11712. For example a value of @code{1.2} corresponds to the output with index
  11713. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  11714. @item outputs, n
  11715. Set the number of outputs. The output to which to send the selected
  11716. frame is based on the result of the evaluation. Default value is 1.
  11717. @end table
  11718. The expression can contain the following constants:
  11719. @table @option
  11720. @item n
  11721. The (sequential) number of the filtered frame, starting from 0.
  11722. @item selected_n
  11723. The (sequential) number of the selected frame, starting from 0.
  11724. @item prev_selected_n
  11725. The sequential number of the last selected frame. It's NAN if undefined.
  11726. @item TB
  11727. The timebase of the input timestamps.
  11728. @item pts
  11729. The PTS (Presentation TimeStamp) of the filtered video frame,
  11730. expressed in @var{TB} units. It's NAN if undefined.
  11731. @item t
  11732. The PTS of the filtered video frame,
  11733. expressed in seconds. It's NAN if undefined.
  11734. @item prev_pts
  11735. The PTS of the previously filtered video frame. It's NAN if undefined.
  11736. @item prev_selected_pts
  11737. The PTS of the last previously filtered video frame. It's NAN if undefined.
  11738. @item prev_selected_t
  11739. The PTS of the last previously selected video frame. It's NAN if undefined.
  11740. @item start_pts
  11741. The PTS of the first video frame in the video. It's NAN if undefined.
  11742. @item start_t
  11743. The time of the first video frame in the video. It's NAN if undefined.
  11744. @item pict_type @emph{(video only)}
  11745. The type of the filtered frame. It can assume one of the following
  11746. values:
  11747. @table @option
  11748. @item I
  11749. @item P
  11750. @item B
  11751. @item S
  11752. @item SI
  11753. @item SP
  11754. @item BI
  11755. @end table
  11756. @item interlace_type @emph{(video only)}
  11757. The frame interlace type. It can assume one of the following values:
  11758. @table @option
  11759. @item PROGRESSIVE
  11760. The frame is progressive (not interlaced).
  11761. @item TOPFIRST
  11762. The frame is top-field-first.
  11763. @item BOTTOMFIRST
  11764. The frame is bottom-field-first.
  11765. @end table
  11766. @item consumed_sample_n @emph{(audio only)}
  11767. the number of selected samples before the current frame
  11768. @item samples_n @emph{(audio only)}
  11769. the number of samples in the current frame
  11770. @item sample_rate @emph{(audio only)}
  11771. the input sample rate
  11772. @item key
  11773. This is 1 if the filtered frame is a key-frame, 0 otherwise.
  11774. @item pos
  11775. the position in the file of the filtered frame, -1 if the information
  11776. is not available (e.g. for synthetic video)
  11777. @item scene @emph{(video only)}
  11778. value between 0 and 1 to indicate a new scene; a low value reflects a low
  11779. probability for the current frame to introduce a new scene, while a higher
  11780. value means the current frame is more likely to be one (see the example below)
  11781. @item concatdec_select
  11782. The concat demuxer can select only part of a concat input file by setting an
  11783. inpoint and an outpoint, but the output packets may not be entirely contained
  11784. in the selected interval. By using this variable, it is possible to skip frames
  11785. generated by the concat demuxer which are not exactly contained in the selected
  11786. interval.
  11787. This works by comparing the frame pts against the @var{lavf.concat.start_time}
  11788. and the @var{lavf.concat.duration} packet metadata values which are also
  11789. present in the decoded frames.
  11790. The @var{concatdec_select} variable is -1 if the frame pts is at least
  11791. start_time and either the duration metadata is missing or the frame pts is less
  11792. than start_time + duration, 0 otherwise, and NaN if the start_time metadata is
  11793. missing.
  11794. That basically means that an input frame is selected if its pts is within the
  11795. interval set by the concat demuxer.
  11796. @end table
  11797. The default value of the select expression is "1".
  11798. @subsection Examples
  11799. @itemize
  11800. @item
  11801. Select all frames in input:
  11802. @example
  11803. select
  11804. @end example
  11805. The example above is the same as:
  11806. @example
  11807. select=1
  11808. @end example
  11809. @item
  11810. Skip all frames:
  11811. @example
  11812. select=0
  11813. @end example
  11814. @item
  11815. Select only I-frames:
  11816. @example
  11817. select='eq(pict_type\,I)'
  11818. @end example
  11819. @item
  11820. Select one frame every 100:
  11821. @example
  11822. select='not(mod(n\,100))'
  11823. @end example
  11824. @item
  11825. Select only frames contained in the 10-20 time interval:
  11826. @example
  11827. select=between(t\,10\,20)
  11828. @end example
  11829. @item
  11830. Select only I frames contained in the 10-20 time interval:
  11831. @example
  11832. select=between(t\,10\,20)*eq(pict_type\,I)
  11833. @end example
  11834. @item
  11835. Select frames with a minimum distance of 10 seconds:
  11836. @example
  11837. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  11838. @end example
  11839. @item
  11840. Use aselect to select only audio frames with samples number > 100:
  11841. @example
  11842. aselect='gt(samples_n\,100)'
  11843. @end example
  11844. @item
  11845. Create a mosaic of the first scenes:
  11846. @example
  11847. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  11848. @end example
  11849. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  11850. choice.
  11851. @item
  11852. Send even and odd frames to separate outputs, and compose them:
  11853. @example
  11854. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  11855. @end example
  11856. @item
  11857. Select useful frames from an ffconcat file which is using inpoints and
  11858. outpoints but where the source files are not intra frame only.
  11859. @example
  11860. ffmpeg -copyts -vsync 0 -segment_time_metadata 1 -i input.ffconcat -vf select=concatdec_select -af aselect=concatdec_select output.avi
  11861. @end example
  11862. @end itemize
  11863. @section sendcmd, asendcmd
  11864. Send commands to filters in the filtergraph.
  11865. These filters read commands to be sent to other filters in the
  11866. filtergraph.
  11867. @code{sendcmd} must be inserted between two video filters,
  11868. @code{asendcmd} must be inserted between two audio filters, but apart
  11869. from that they act the same way.
  11870. The specification of commands can be provided in the filter arguments
  11871. with the @var{commands} option, or in a file specified by the
  11872. @var{filename} option.
  11873. These filters accept the following options:
  11874. @table @option
  11875. @item commands, c
  11876. Set the commands to be read and sent to the other filters.
  11877. @item filename, f
  11878. Set the filename of the commands to be read and sent to the other
  11879. filters.
  11880. @end table
  11881. @subsection Commands syntax
  11882. A commands description consists of a sequence of interval
  11883. specifications, comprising a list of commands to be executed when a
  11884. particular event related to that interval occurs. The occurring event
  11885. is typically the current frame time entering or leaving a given time
  11886. interval.
  11887. An interval is specified by the following syntax:
  11888. @example
  11889. @var{START}[-@var{END}] @var{COMMANDS};
  11890. @end example
  11891. The time interval is specified by the @var{START} and @var{END} times.
  11892. @var{END} is optional and defaults to the maximum time.
  11893. The current frame time is considered within the specified interval if
  11894. it is included in the interval [@var{START}, @var{END}), that is when
  11895. the time is greater or equal to @var{START} and is lesser than
  11896. @var{END}.
  11897. @var{COMMANDS} consists of a sequence of one or more command
  11898. specifications, separated by ",", relating to that interval. The
  11899. syntax of a command specification is given by:
  11900. @example
  11901. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  11902. @end example
  11903. @var{FLAGS} is optional and specifies the type of events relating to
  11904. the time interval which enable sending the specified command, and must
  11905. be a non-null sequence of identifier flags separated by "+" or "|" and
  11906. enclosed between "[" and "]".
  11907. The following flags are recognized:
  11908. @table @option
  11909. @item enter
  11910. The command is sent when the current frame timestamp enters the
  11911. specified interval. In other words, the command is sent when the
  11912. previous frame timestamp was not in the given interval, and the
  11913. current is.
  11914. @item leave
  11915. The command is sent when the current frame timestamp leaves the
  11916. specified interval. In other words, the command is sent when the
  11917. previous frame timestamp was in the given interval, and the
  11918. current is not.
  11919. @end table
  11920. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  11921. assumed.
  11922. @var{TARGET} specifies the target of the command, usually the name of
  11923. the filter class or a specific filter instance name.
  11924. @var{COMMAND} specifies the name of the command for the target filter.
  11925. @var{ARG} is optional and specifies the optional list of argument for
  11926. the given @var{COMMAND}.
  11927. Between one interval specification and another, whitespaces, or
  11928. sequences of characters starting with @code{#} until the end of line,
  11929. are ignored and can be used to annotate comments.
  11930. A simplified BNF description of the commands specification syntax
  11931. follows:
  11932. @example
  11933. @var{COMMAND_FLAG} ::= "enter" | "leave"
  11934. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  11935. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  11936. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  11937. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  11938. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  11939. @end example
  11940. @subsection Examples
  11941. @itemize
  11942. @item
  11943. Specify audio tempo change at second 4:
  11944. @example
  11945. asendcmd=c='4.0 atempo tempo 1.5',atempo
  11946. @end example
  11947. @item
  11948. Specify a list of drawtext and hue commands in a file.
  11949. @example
  11950. # show text in the interval 5-10
  11951. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  11952. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  11953. # desaturate the image in the interval 15-20
  11954. 15.0-20.0 [enter] hue s 0,
  11955. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  11956. [leave] hue s 1,
  11957. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  11958. # apply an exponential saturation fade-out effect, starting from time 25
  11959. 25 [enter] hue s exp(25-t)
  11960. @end example
  11961. A filtergraph allowing to read and process the above command list
  11962. stored in a file @file{test.cmd}, can be specified with:
  11963. @example
  11964. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  11965. @end example
  11966. @end itemize
  11967. @anchor{setpts}
  11968. @section setpts, asetpts
  11969. Change the PTS (presentation timestamp) of the input frames.
  11970. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  11971. This filter accepts the following options:
  11972. @table @option
  11973. @item expr
  11974. The expression which is evaluated for each frame to construct its timestamp.
  11975. @end table
  11976. The expression is evaluated through the eval API and can contain the following
  11977. constants:
  11978. @table @option
  11979. @item FRAME_RATE
  11980. frame rate, only defined for constant frame-rate video
  11981. @item PTS
  11982. The presentation timestamp in input
  11983. @item N
  11984. The count of the input frame for video or the number of consumed samples,
  11985. not including the current frame for audio, starting from 0.
  11986. @item NB_CONSUMED_SAMPLES
  11987. The number of consumed samples, not including the current frame (only
  11988. audio)
  11989. @item NB_SAMPLES, S
  11990. The number of samples in the current frame (only audio)
  11991. @item SAMPLE_RATE, SR
  11992. The audio sample rate.
  11993. @item STARTPTS
  11994. The PTS of the first frame.
  11995. @item STARTT
  11996. the time in seconds of the first frame
  11997. @item INTERLACED
  11998. State whether the current frame is interlaced.
  11999. @item T
  12000. the time in seconds of the current frame
  12001. @item POS
  12002. original position in the file of the frame, or undefined if undefined
  12003. for the current frame
  12004. @item PREV_INPTS
  12005. The previous input PTS.
  12006. @item PREV_INT
  12007. previous input time in seconds
  12008. @item PREV_OUTPTS
  12009. The previous output PTS.
  12010. @item PREV_OUTT
  12011. previous output time in seconds
  12012. @item RTCTIME
  12013. The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  12014. instead.
  12015. @item RTCSTART
  12016. The wallclock (RTC) time at the start of the movie in microseconds.
  12017. @item TB
  12018. The timebase of the input timestamps.
  12019. @end table
  12020. @subsection Examples
  12021. @itemize
  12022. @item
  12023. Start counting PTS from zero
  12024. @example
  12025. setpts=PTS-STARTPTS
  12026. @end example
  12027. @item
  12028. Apply fast motion effect:
  12029. @example
  12030. setpts=0.5*PTS
  12031. @end example
  12032. @item
  12033. Apply slow motion effect:
  12034. @example
  12035. setpts=2.0*PTS
  12036. @end example
  12037. @item
  12038. Set fixed rate of 25 frames per second:
  12039. @example
  12040. setpts=N/(25*TB)
  12041. @end example
  12042. @item
  12043. Set fixed rate 25 fps with some jitter:
  12044. @example
  12045. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  12046. @end example
  12047. @item
  12048. Apply an offset of 10 seconds to the input PTS:
  12049. @example
  12050. setpts=PTS+10/TB
  12051. @end example
  12052. @item
  12053. Generate timestamps from a "live source" and rebase onto the current timebase:
  12054. @example
  12055. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  12056. @end example
  12057. @item
  12058. Generate timestamps by counting samples:
  12059. @example
  12060. asetpts=N/SR/TB
  12061. @end example
  12062. @end itemize
  12063. @section settb, asettb
  12064. Set the timebase to use for the output frames timestamps.
  12065. It is mainly useful for testing timebase configuration.
  12066. It accepts the following parameters:
  12067. @table @option
  12068. @item expr, tb
  12069. The expression which is evaluated into the output timebase.
  12070. @end table
  12071. The value for @option{tb} is an arithmetic expression representing a
  12072. rational. The expression can contain the constants "AVTB" (the default
  12073. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  12074. audio only). Default value is "intb".
  12075. @subsection Examples
  12076. @itemize
  12077. @item
  12078. Set the timebase to 1/25:
  12079. @example
  12080. settb=expr=1/25
  12081. @end example
  12082. @item
  12083. Set the timebase to 1/10:
  12084. @example
  12085. settb=expr=0.1
  12086. @end example
  12087. @item
  12088. Set the timebase to 1001/1000:
  12089. @example
  12090. settb=1+0.001
  12091. @end example
  12092. @item
  12093. Set the timebase to 2*intb:
  12094. @example
  12095. settb=2*intb
  12096. @end example
  12097. @item
  12098. Set the default timebase value:
  12099. @example
  12100. settb=AVTB
  12101. @end example
  12102. @end itemize
  12103. @section showcqt
  12104. Convert input audio to a video output representing frequency spectrum
  12105. logarithmically using Brown-Puckette constant Q transform algorithm with
  12106. direct frequency domain coefficient calculation (but the transform itself
  12107. is not really constant Q, instead the Q factor is actually variable/clamped),
  12108. with musical tone scale, from E0 to D#10.
  12109. The filter accepts the following options:
  12110. @table @option
  12111. @item size, s
  12112. Specify the video size for the output. It must be even. For the syntax of this option,
  12113. check the @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12114. Default value is @code{1920x1080}.
  12115. @item fps, rate, r
  12116. Set the output frame rate. Default value is @code{25}.
  12117. @item bar_h
  12118. Set the bargraph height. It must be even. Default value is @code{-1} which
  12119. computes the bargraph height automatically.
  12120. @item axis_h
  12121. Set the axis height. It must be even. Default value is @code{-1} which computes
  12122. the axis height automatically.
  12123. @item sono_h
  12124. Set the sonogram height. It must be even. Default value is @code{-1} which
  12125. computes the sonogram height automatically.
  12126. @item fullhd
  12127. Set the fullhd resolution. This option is deprecated, use @var{size}, @var{s}
  12128. instead. Default value is @code{1}.
  12129. @item sono_v, volume
  12130. Specify the sonogram volume expression. It can contain variables:
  12131. @table @option
  12132. @item bar_v
  12133. the @var{bar_v} evaluated expression
  12134. @item frequency, freq, f
  12135. the frequency where it is evaluated
  12136. @item timeclamp, tc
  12137. the value of @var{timeclamp} option
  12138. @end table
  12139. and functions:
  12140. @table @option
  12141. @item a_weighting(f)
  12142. A-weighting of equal loudness
  12143. @item b_weighting(f)
  12144. B-weighting of equal loudness
  12145. @item c_weighting(f)
  12146. C-weighting of equal loudness.
  12147. @end table
  12148. Default value is @code{16}.
  12149. @item bar_v, volume2
  12150. Specify the bargraph volume expression. It can contain variables:
  12151. @table @option
  12152. @item sono_v
  12153. the @var{sono_v} evaluated expression
  12154. @item frequency, freq, f
  12155. the frequency where it is evaluated
  12156. @item timeclamp, tc
  12157. the value of @var{timeclamp} option
  12158. @end table
  12159. and functions:
  12160. @table @option
  12161. @item a_weighting(f)
  12162. A-weighting of equal loudness
  12163. @item b_weighting(f)
  12164. B-weighting of equal loudness
  12165. @item c_weighting(f)
  12166. C-weighting of equal loudness.
  12167. @end table
  12168. Default value is @code{sono_v}.
  12169. @item sono_g, gamma
  12170. Specify the sonogram gamma. Lower gamma makes the spectrum more contrast,
  12171. higher gamma makes the spectrum having more range. Default value is @code{3}.
  12172. Acceptable range is @code{[1, 7]}.
  12173. @item bar_g, gamma2
  12174. Specify the bargraph gamma. Default value is @code{1}. Acceptable range is
  12175. @code{[1, 7]}.
  12176. @item timeclamp, tc
  12177. Specify the transform timeclamp. At low frequency, there is trade-off between
  12178. accuracy in time domain and frequency domain. If timeclamp is lower,
  12179. event in time domain is represented more accurately (such as fast bass drum),
  12180. otherwise event in frequency domain is represented more accurately
  12181. (such as bass guitar). Acceptable range is @code{[0.1, 1]}. Default value is @code{0.17}.
  12182. @item basefreq
  12183. Specify the transform base frequency. Default value is @code{20.01523126408007475},
  12184. which is frequency 50 cents below E0. Acceptable range is @code{[10, 100000]}.
  12185. @item endfreq
  12186. Specify the transform end frequency. Default value is @code{20495.59681441799654},
  12187. which is frequency 50 cents above D#10. Acceptable range is @code{[10, 100000]}.
  12188. @item coeffclamp
  12189. This option is deprecated and ignored.
  12190. @item tlength
  12191. Specify the transform length in time domain. Use this option to control accuracy
  12192. trade-off between time domain and frequency domain at every frequency sample.
  12193. It can contain variables:
  12194. @table @option
  12195. @item frequency, freq, f
  12196. the frequency where it is evaluated
  12197. @item timeclamp, tc
  12198. the value of @var{timeclamp} option.
  12199. @end table
  12200. Default value is @code{384*tc/(384+tc*f)}.
  12201. @item count
  12202. Specify the transform count for every video frame. Default value is @code{6}.
  12203. Acceptable range is @code{[1, 30]}.
  12204. @item fcount
  12205. Specify the transform count for every single pixel. Default value is @code{0},
  12206. which makes it computed automatically. Acceptable range is @code{[0, 10]}.
  12207. @item fontfile
  12208. Specify font file for use with freetype to draw the axis. If not specified,
  12209. use embedded font. Note that drawing with font file or embedded font is not
  12210. implemented with custom @var{basefreq} and @var{endfreq}, use @var{axisfile}
  12211. option instead.
  12212. @item fontcolor
  12213. Specify font color expression. This is arithmetic expression that should return
  12214. integer value 0xRRGGBB. It can contain variables:
  12215. @table @option
  12216. @item frequency, freq, f
  12217. the frequency where it is evaluated
  12218. @item timeclamp, tc
  12219. the value of @var{timeclamp} option
  12220. @end table
  12221. and functions:
  12222. @table @option
  12223. @item midi(f)
  12224. midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
  12225. @item r(x), g(x), b(x)
  12226. red, green, and blue value of intensity x.
  12227. @end table
  12228. Default value is @code{st(0, (midi(f)-59.5)/12);
  12229. st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
  12230. r(1-ld(1)) + b(ld(1))}.
  12231. @item axisfile
  12232. Specify image file to draw the axis. This option override @var{fontfile} and
  12233. @var{fontcolor} option.
  12234. @item axis, text
  12235. Enable/disable drawing text to the axis. If it is set to @code{0}, drawing to
  12236. the axis is disabled, ignoring @var{fontfile} and @var{axisfile} option.
  12237. Default value is @code{1}.
  12238. @end table
  12239. @subsection Examples
  12240. @itemize
  12241. @item
  12242. Playing audio while showing the spectrum:
  12243. @example
  12244. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
  12245. @end example
  12246. @item
  12247. Same as above, but with frame rate 30 fps:
  12248. @example
  12249. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
  12250. @end example
  12251. @item
  12252. Playing at 1280x720:
  12253. @example
  12254. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=s=1280x720:count=4 [out0]'
  12255. @end example
  12256. @item
  12257. Disable sonogram display:
  12258. @example
  12259. sono_h=0
  12260. @end example
  12261. @item
  12262. A1 and its harmonics: A1, A2, (near)E3, A3:
  12263. @example
  12264. 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),
  12265. asplit[a][out1]; [a] showcqt [out0]'
  12266. @end example
  12267. @item
  12268. Same as above, but with more accuracy in frequency domain:
  12269. @example
  12270. 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),
  12271. asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
  12272. @end example
  12273. @item
  12274. Custom volume:
  12275. @example
  12276. bar_v=10:sono_v=bar_v*a_weighting(f)
  12277. @end example
  12278. @item
  12279. Custom gamma, now spectrum is linear to the amplitude.
  12280. @example
  12281. bar_g=2:sono_g=2
  12282. @end example
  12283. @item
  12284. Custom tlength equation:
  12285. @example
  12286. 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)))'
  12287. @end example
  12288. @item
  12289. Custom fontcolor and fontfile, C-note is colored green, others are colored blue:
  12290. @example
  12291. fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))':fontfile=myfont.ttf
  12292. @end example
  12293. @item
  12294. Custom frequency range with custom axis using image file:
  12295. @example
  12296. axisfile=myaxis.png:basefreq=40:endfreq=10000
  12297. @end example
  12298. @end itemize
  12299. @section showfreqs
  12300. Convert input audio to video output representing the audio power spectrum.
  12301. Audio amplitude is on Y-axis while frequency is on X-axis.
  12302. The filter accepts the following options:
  12303. @table @option
  12304. @item size, s
  12305. Specify size of video. For the syntax of this option, check the
  12306. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12307. Default is @code{1024x512}.
  12308. @item mode
  12309. Set display mode.
  12310. This set how each frequency bin will be represented.
  12311. It accepts the following values:
  12312. @table @samp
  12313. @item line
  12314. @item bar
  12315. @item dot
  12316. @end table
  12317. Default is @code{bar}.
  12318. @item ascale
  12319. Set amplitude scale.
  12320. It accepts the following values:
  12321. @table @samp
  12322. @item lin
  12323. Linear scale.
  12324. @item sqrt
  12325. Square root scale.
  12326. @item cbrt
  12327. Cubic root scale.
  12328. @item log
  12329. Logarithmic scale.
  12330. @end table
  12331. Default is @code{log}.
  12332. @item fscale
  12333. Set frequency scale.
  12334. It accepts the following values:
  12335. @table @samp
  12336. @item lin
  12337. Linear scale.
  12338. @item log
  12339. Logarithmic scale.
  12340. @item rlog
  12341. Reverse logarithmic scale.
  12342. @end table
  12343. Default is @code{lin}.
  12344. @item win_size
  12345. Set window size.
  12346. It accepts the following values:
  12347. @table @samp
  12348. @item w16
  12349. @item w32
  12350. @item w64
  12351. @item w128
  12352. @item w256
  12353. @item w512
  12354. @item w1024
  12355. @item w2048
  12356. @item w4096
  12357. @item w8192
  12358. @item w16384
  12359. @item w32768
  12360. @item w65536
  12361. @end table
  12362. Default is @code{w2048}
  12363. @item win_func
  12364. Set windowing function.
  12365. It accepts the following values:
  12366. @table @samp
  12367. @item rect
  12368. @item bartlett
  12369. @item hanning
  12370. @item hamming
  12371. @item blackman
  12372. @item welch
  12373. @item flattop
  12374. @item bharris
  12375. @item bnuttall
  12376. @item bhann
  12377. @item sine
  12378. @item nuttall
  12379. @item lanczos
  12380. @item gauss
  12381. @item tukey
  12382. @end table
  12383. Default is @code{hanning}.
  12384. @item overlap
  12385. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  12386. which means optimal overlap for selected window function will be picked.
  12387. @item averaging
  12388. Set time averaging. Setting this to 0 will display current maximal peaks.
  12389. Default is @code{1}, which means time averaging is disabled.
  12390. @item colors
  12391. Specify list of colors separated by space or by '|' which will be used to
  12392. draw channel frequencies. Unrecognized or missing colors will be replaced
  12393. by white color.
  12394. @item cmode
  12395. Set channel display mode.
  12396. It accepts the following values:
  12397. @table @samp
  12398. @item combined
  12399. @item separate
  12400. @end table
  12401. Default is @code{combined}.
  12402. @end table
  12403. @anchor{showspectrum}
  12404. @section showspectrum
  12405. Convert input audio to a video output, representing the audio frequency
  12406. spectrum.
  12407. The filter accepts the following options:
  12408. @table @option
  12409. @item size, s
  12410. Specify the video size for the output. For the syntax of this option, check the
  12411. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12412. Default value is @code{640x512}.
  12413. @item slide
  12414. Specify how the spectrum should slide along the window.
  12415. It accepts the following values:
  12416. @table @samp
  12417. @item replace
  12418. the samples start again on the left when they reach the right
  12419. @item scroll
  12420. the samples scroll from right to left
  12421. @item rscroll
  12422. the samples scroll from left to right
  12423. @item fullframe
  12424. frames are only produced when the samples reach the right
  12425. @end table
  12426. Default value is @code{replace}.
  12427. @item mode
  12428. Specify display mode.
  12429. It accepts the following values:
  12430. @table @samp
  12431. @item combined
  12432. all channels are displayed in the same row
  12433. @item separate
  12434. all channels are displayed in separate rows
  12435. @end table
  12436. Default value is @samp{combined}.
  12437. @item color
  12438. Specify display color mode.
  12439. It accepts the following values:
  12440. @table @samp
  12441. @item channel
  12442. each channel is displayed in a separate color
  12443. @item intensity
  12444. each channel is displayed using the same color scheme
  12445. @item rainbow
  12446. each channel is displayed using the rainbow color scheme
  12447. @item moreland
  12448. each channel is displayed using the moreland color scheme
  12449. @item nebulae
  12450. each channel is displayed using the nebulae color scheme
  12451. @item fire
  12452. each channel is displayed using the fire color scheme
  12453. @item fiery
  12454. each channel is displayed using the fiery color scheme
  12455. @item fruit
  12456. each channel is displayed using the fruit color scheme
  12457. @item cool
  12458. each channel is displayed using the cool color scheme
  12459. @end table
  12460. Default value is @samp{channel}.
  12461. @item scale
  12462. Specify scale used for calculating intensity color values.
  12463. It accepts the following values:
  12464. @table @samp
  12465. @item lin
  12466. linear
  12467. @item sqrt
  12468. square root, default
  12469. @item cbrt
  12470. cubic root
  12471. @item 4thrt
  12472. 4th root
  12473. @item 5thrt
  12474. 5th root
  12475. @item log
  12476. logarithmic
  12477. @end table
  12478. Default value is @samp{sqrt}.
  12479. @item saturation
  12480. Set saturation modifier for displayed colors. Negative values provide
  12481. alternative color scheme. @code{0} is no saturation at all.
  12482. Saturation must be in [-10.0, 10.0] range.
  12483. Default value is @code{1}.
  12484. @item win_func
  12485. Set window function.
  12486. It accepts the following values:
  12487. @table @samp
  12488. @item rect
  12489. @item bartlett
  12490. @item hann
  12491. @item hanning
  12492. @item hamming
  12493. @item blackman
  12494. @item welch
  12495. @item flattop
  12496. @item bharris
  12497. @item bnuttall
  12498. @item bhann
  12499. @item sine
  12500. @item nuttall
  12501. @item lanczos
  12502. @item gauss
  12503. @item tukey
  12504. @end table
  12505. Default value is @code{hann}.
  12506. @item orientation
  12507. Set orientation of time vs frequency axis. Can be @code{vertical} or
  12508. @code{horizontal}. Default is @code{vertical}.
  12509. @item overlap
  12510. Set ratio of overlap window. Default value is @code{0}.
  12511. When value is @code{1} overlap is set to recommended size for specific
  12512. window function currently used.
  12513. @item gain
  12514. Set scale gain for calculating intensity color values.
  12515. Default value is @code{1}.
  12516. @item data
  12517. Set which data to display. Can be @code{magnitude}, default or @code{phase}.
  12518. @end table
  12519. The usage is very similar to the showwaves filter; see the examples in that
  12520. section.
  12521. @subsection Examples
  12522. @itemize
  12523. @item
  12524. Large window with logarithmic color scaling:
  12525. @example
  12526. showspectrum=s=1280x480:scale=log
  12527. @end example
  12528. @item
  12529. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  12530. @example
  12531. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  12532. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  12533. @end example
  12534. @end itemize
  12535. @section showspectrumpic
  12536. Convert input audio to a single video frame, representing the audio frequency
  12537. spectrum.
  12538. The filter accepts the following options:
  12539. @table @option
  12540. @item size, s
  12541. Specify the video size for the output. For the syntax of this option, check the
  12542. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12543. Default value is @code{4096x2048}.
  12544. @item mode
  12545. Specify display mode.
  12546. It accepts the following values:
  12547. @table @samp
  12548. @item combined
  12549. all channels are displayed in the same row
  12550. @item separate
  12551. all channels are displayed in separate rows
  12552. @end table
  12553. Default value is @samp{combined}.
  12554. @item color
  12555. Specify display color mode.
  12556. It accepts the following values:
  12557. @table @samp
  12558. @item channel
  12559. each channel is displayed in a separate color
  12560. @item intensity
  12561. each channel is displayed using the same color scheme
  12562. @item rainbow
  12563. each channel is displayed using the rainbow color scheme
  12564. @item moreland
  12565. each channel is displayed using the moreland color scheme
  12566. @item nebulae
  12567. each channel is displayed using the nebulae color scheme
  12568. @item fire
  12569. each channel is displayed using the fire color scheme
  12570. @item fiery
  12571. each channel is displayed using the fiery color scheme
  12572. @item fruit
  12573. each channel is displayed using the fruit color scheme
  12574. @item cool
  12575. each channel is displayed using the cool color scheme
  12576. @end table
  12577. Default value is @samp{intensity}.
  12578. @item scale
  12579. Specify scale used for calculating intensity color values.
  12580. It accepts the following values:
  12581. @table @samp
  12582. @item lin
  12583. linear
  12584. @item sqrt
  12585. square root, default
  12586. @item cbrt
  12587. cubic root
  12588. @item 4thrt
  12589. 4th root
  12590. @item 5thrt
  12591. 5th root
  12592. @item log
  12593. logarithmic
  12594. @end table
  12595. Default value is @samp{log}.
  12596. @item saturation
  12597. Set saturation modifier for displayed colors. Negative values provide
  12598. alternative color scheme. @code{0} is no saturation at all.
  12599. Saturation must be in [-10.0, 10.0] range.
  12600. Default value is @code{1}.
  12601. @item win_func
  12602. Set window function.
  12603. It accepts the following values:
  12604. @table @samp
  12605. @item rect
  12606. @item bartlett
  12607. @item hann
  12608. @item hanning
  12609. @item hamming
  12610. @item blackman
  12611. @item welch
  12612. @item flattop
  12613. @item bharris
  12614. @item bnuttall
  12615. @item bhann
  12616. @item sine
  12617. @item nuttall
  12618. @item lanczos
  12619. @item gauss
  12620. @item tukey
  12621. @end table
  12622. Default value is @code{hann}.
  12623. @item orientation
  12624. Set orientation of time vs frequency axis. Can be @code{vertical} or
  12625. @code{horizontal}. Default is @code{vertical}.
  12626. @item gain
  12627. Set scale gain for calculating intensity color values.
  12628. Default value is @code{1}.
  12629. @item legend
  12630. Draw time and frequency axes and legends. Default is enabled.
  12631. @end table
  12632. @subsection Examples
  12633. @itemize
  12634. @item
  12635. Extract an audio spectrogram of a whole audio track
  12636. in a 1024x1024 picture using @command{ffmpeg}:
  12637. @example
  12638. ffmpeg -i audio.flac -lavfi showspectrumpic=s=1024x1024 spectrogram.png
  12639. @end example
  12640. @end itemize
  12641. @section showvolume
  12642. Convert input audio volume to a video output.
  12643. The filter accepts the following options:
  12644. @table @option
  12645. @item rate, r
  12646. Set video rate.
  12647. @item b
  12648. Set border width, allowed range is [0, 5]. Default is 1.
  12649. @item w
  12650. Set channel width, allowed range is [80, 8192]. Default is 400.
  12651. @item h
  12652. Set channel height, allowed range is [1, 900]. Default is 20.
  12653. @item f
  12654. Set fade, allowed range is [0.001, 1]. Default is 0.95.
  12655. @item c
  12656. Set volume color expression.
  12657. The expression can use the following variables:
  12658. @table @option
  12659. @item VOLUME
  12660. Current max volume of channel in dB.
  12661. @item CHANNEL
  12662. Current channel number, starting from 0.
  12663. @end table
  12664. @item t
  12665. If set, displays channel names. Default is enabled.
  12666. @item v
  12667. If set, displays volume values. Default is enabled.
  12668. @item o
  12669. Set orientation, can be @code{horizontal} or @code{vertical},
  12670. default is @code{horizontal}.
  12671. @item s
  12672. Set step size, allowed range s [0, 5]. Default is 0, which means
  12673. step is disabled.
  12674. @end table
  12675. @section showwaves
  12676. Convert input audio to a video output, representing the samples waves.
  12677. The filter accepts the following options:
  12678. @table @option
  12679. @item size, s
  12680. Specify the video size for the output. For the syntax of this option, check the
  12681. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12682. Default value is @code{600x240}.
  12683. @item mode
  12684. Set display mode.
  12685. Available values are:
  12686. @table @samp
  12687. @item point
  12688. Draw a point for each sample.
  12689. @item line
  12690. Draw a vertical line for each sample.
  12691. @item p2p
  12692. Draw a point for each sample and a line between them.
  12693. @item cline
  12694. Draw a centered vertical line for each sample.
  12695. @end table
  12696. Default value is @code{point}.
  12697. @item n
  12698. Set the number of samples which are printed on the same column. A
  12699. larger value will decrease the frame rate. Must be a positive
  12700. integer. This option can be set only if the value for @var{rate}
  12701. is not explicitly specified.
  12702. @item rate, r
  12703. Set the (approximate) output frame rate. This is done by setting the
  12704. option @var{n}. Default value is "25".
  12705. @item split_channels
  12706. Set if channels should be drawn separately or overlap. Default value is 0.
  12707. @item colors
  12708. Set colors separated by '|' which are going to be used for drawing of each channel.
  12709. @item scale
  12710. Set amplitude scale. Can be linear @code{lin} or logarithmic @code{log}.
  12711. Default is linear.
  12712. @end table
  12713. @subsection Examples
  12714. @itemize
  12715. @item
  12716. Output the input file audio and the corresponding video representation
  12717. at the same time:
  12718. @example
  12719. amovie=a.mp3,asplit[out0],showwaves[out1]
  12720. @end example
  12721. @item
  12722. Create a synthetic signal and show it with showwaves, forcing a
  12723. frame rate of 30 frames per second:
  12724. @example
  12725. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  12726. @end example
  12727. @end itemize
  12728. @section showwavespic
  12729. Convert input audio to a single video frame, representing the samples waves.
  12730. The filter accepts the following options:
  12731. @table @option
  12732. @item size, s
  12733. Specify the video size for the output. For the syntax of this option, check the
  12734. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12735. Default value is @code{600x240}.
  12736. @item split_channels
  12737. Set if channels should be drawn separately or overlap. Default value is 0.
  12738. @item colors
  12739. Set colors separated by '|' which are going to be used for drawing of each channel.
  12740. @item scale
  12741. Set amplitude scale. Can be linear @code{lin} or logarithmic @code{log}.
  12742. Default is linear.
  12743. @end table
  12744. @subsection Examples
  12745. @itemize
  12746. @item
  12747. Extract a channel split representation of the wave form of a whole audio track
  12748. in a 1024x800 picture using @command{ffmpeg}:
  12749. @example
  12750. ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
  12751. @end example
  12752. @item
  12753. Colorize the waveform with colorchannelmixer. This example will make
  12754. the waveform a green color approximately RGB(66,217,150). Additional
  12755. channels will be shades of this color.
  12756. @example
  12757. ffmpeg -i audio.mp3 -filter_complex "showwavespic,colorchannelmixer=rr=66/255:gg=217/255:bb=150/255" waveform.png
  12758. @end example
  12759. @end itemize
  12760. @section spectrumsynth
  12761. Sythesize audio from 2 input video spectrums, first input stream represents
  12762. magnitude across time and second represents phase across time.
  12763. The filter will transform from frequency domain as displayed in videos back
  12764. to time domain as presented in audio output.
  12765. This filter is primarly created for reversing processed @ref{showspectrum}
  12766. filter outputs, but can synthesize sound from other spectrograms too.
  12767. But in such case results are going to be poor if the phase data is not
  12768. available, because in such cases phase data need to be recreated, usually
  12769. its just recreated from random noise.
  12770. For best results use gray only output (@code{channel} color mode in
  12771. @ref{showspectrum} filter) and @code{log} scale for magnitude video and
  12772. @code{lin} scale for phase video. To produce phase, for 2nd video, use
  12773. @code{data} option. Inputs videos should generally use @code{fullframe}
  12774. slide mode as that saves resources needed for decoding video.
  12775. The filter accepts the following options:
  12776. @table @option
  12777. @item sample_rate
  12778. Specify sample rate of output audio, the sample rate of audio from which
  12779. spectrum was generated may differ.
  12780. @item channels
  12781. Set number of channels represented in input video spectrums.
  12782. @item scale
  12783. Set scale which was used when generating magnitude input spectrum.
  12784. Can be @code{lin} or @code{log}. Default is @code{log}.
  12785. @item slide
  12786. Set slide which was used when generating inputs spectrums.
  12787. Can be @code{replace}, @code{scroll}, @code{fullframe} or @code{rscroll}.
  12788. Default is @code{fullframe}.
  12789. @item win_func
  12790. Set window function used for resynthesis.
  12791. @item overlap
  12792. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  12793. which means optimal overlap for selected window function will be picked.
  12794. @item orientation
  12795. Set orientation of input videos. Can be @code{vertical} or @code{horizontal}.
  12796. Default is @code{vertical}.
  12797. @end table
  12798. @subsection Examples
  12799. @itemize
  12800. @item
  12801. First create magnitude and phase videos from audio, assuming audio is stereo with 44100 sample rate,
  12802. then resynthesize videos back to audio with spectrumsynth:
  12803. @example
  12804. ffmpeg -i input.flac -lavfi showspectrum=mode=separate:scale=log:overlap=0.875:color=channel:slide=fullframe:data=magnitude -an -c:v rawvideo magnitude.nut
  12805. ffmpeg -i input.flac -lavfi showspectrum=mode=separate:scale=lin:overlap=0.875:color=channel:slide=fullframe:data=phase -an -c:v rawvideo phase.nut
  12806. ffmpeg -i magnitude.nut -i phase.nut -lavfi spectrumsynth=channels=2:sample_rate=44100:win_func=hann:overlap=0.875:slide=fullframe output.flac
  12807. @end example
  12808. @end itemize
  12809. @section split, asplit
  12810. Split input into several identical outputs.
  12811. @code{asplit} works with audio input, @code{split} with video.
  12812. The filter accepts a single parameter which specifies the number of outputs. If
  12813. unspecified, it defaults to 2.
  12814. @subsection Examples
  12815. @itemize
  12816. @item
  12817. Create two separate outputs from the same input:
  12818. @example
  12819. [in] split [out0][out1]
  12820. @end example
  12821. @item
  12822. To create 3 or more outputs, you need to specify the number of
  12823. outputs, like in:
  12824. @example
  12825. [in] asplit=3 [out0][out1][out2]
  12826. @end example
  12827. @item
  12828. Create two separate outputs from the same input, one cropped and
  12829. one padded:
  12830. @example
  12831. [in] split [splitout1][splitout2];
  12832. [splitout1] crop=100:100:0:0 [cropout];
  12833. [splitout2] pad=200:200:100:100 [padout];
  12834. @end example
  12835. @item
  12836. Create 5 copies of the input audio with @command{ffmpeg}:
  12837. @example
  12838. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  12839. @end example
  12840. @end itemize
  12841. @section zmq, azmq
  12842. Receive commands sent through a libzmq client, and forward them to
  12843. filters in the filtergraph.
  12844. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  12845. must be inserted between two video filters, @code{azmq} between two
  12846. audio filters.
  12847. To enable these filters you need to install the libzmq library and
  12848. headers and configure FFmpeg with @code{--enable-libzmq}.
  12849. For more information about libzmq see:
  12850. @url{http://www.zeromq.org/}
  12851. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  12852. receives messages sent through a network interface defined by the
  12853. @option{bind_address} option.
  12854. The received message must be in the form:
  12855. @example
  12856. @var{TARGET} @var{COMMAND} [@var{ARG}]
  12857. @end example
  12858. @var{TARGET} specifies the target of the command, usually the name of
  12859. the filter class or a specific filter instance name.
  12860. @var{COMMAND} specifies the name of the command for the target filter.
  12861. @var{ARG} is optional and specifies the optional argument list for the
  12862. given @var{COMMAND}.
  12863. Upon reception, the message is processed and the corresponding command
  12864. is injected into the filtergraph. Depending on the result, the filter
  12865. will send a reply to the client, adopting the format:
  12866. @example
  12867. @var{ERROR_CODE} @var{ERROR_REASON}
  12868. @var{MESSAGE}
  12869. @end example
  12870. @var{MESSAGE} is optional.
  12871. @subsection Examples
  12872. Look at @file{tools/zmqsend} for an example of a zmq client which can
  12873. be used to send commands processed by these filters.
  12874. Consider the following filtergraph generated by @command{ffplay}
  12875. @example
  12876. ffplay -dumpgraph 1 -f lavfi "
  12877. color=s=100x100:c=red [l];
  12878. color=s=100x100:c=blue [r];
  12879. nullsrc=s=200x100, zmq [bg];
  12880. [bg][l] overlay [bg+l];
  12881. [bg+l][r] overlay=x=100 "
  12882. @end example
  12883. To change the color of the left side of the video, the following
  12884. command can be used:
  12885. @example
  12886. echo Parsed_color_0 c yellow | tools/zmqsend
  12887. @end example
  12888. To change the right side:
  12889. @example
  12890. echo Parsed_color_1 c pink | tools/zmqsend
  12891. @end example
  12892. @c man end MULTIMEDIA FILTERS
  12893. @chapter Multimedia Sources
  12894. @c man begin MULTIMEDIA SOURCES
  12895. Below is a description of the currently available multimedia sources.
  12896. @section amovie
  12897. This is the same as @ref{movie} source, except it selects an audio
  12898. stream by default.
  12899. @anchor{movie}
  12900. @section movie
  12901. Read audio and/or video stream(s) from a movie container.
  12902. It accepts the following parameters:
  12903. @table @option
  12904. @item filename
  12905. The name of the resource to read (not necessarily a file; it can also be a
  12906. device or a stream accessed through some protocol).
  12907. @item format_name, f
  12908. Specifies the format assumed for the movie to read, and can be either
  12909. the name of a container or an input device. If not specified, the
  12910. format is guessed from @var{movie_name} or by probing.
  12911. @item seek_point, sp
  12912. Specifies the seek point in seconds. The frames will be output
  12913. starting from this seek point. The parameter is evaluated with
  12914. @code{av_strtod}, so the numerical value may be suffixed by an IS
  12915. postfix. The default value is "0".
  12916. @item streams, s
  12917. Specifies the streams to read. Several streams can be specified,
  12918. separated by "+". The source will then have as many outputs, in the
  12919. same order. The syntax is explained in the ``Stream specifiers''
  12920. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  12921. respectively the default (best suited) video and audio stream. Default
  12922. is "dv", or "da" if the filter is called as "amovie".
  12923. @item stream_index, si
  12924. Specifies the index of the video stream to read. If the value is -1,
  12925. the most suitable video stream will be automatically selected. The default
  12926. value is "-1". Deprecated. If the filter is called "amovie", it will select
  12927. audio instead of video.
  12928. @item loop
  12929. Specifies how many times to read the stream in sequence.
  12930. If the value is less than 1, the stream will be read again and again.
  12931. Default value is "1".
  12932. Note that when the movie is looped the source timestamps are not
  12933. changed, so it will generate non monotonically increasing timestamps.
  12934. @end table
  12935. It allows overlaying a second video on top of the main input of
  12936. a filtergraph, as shown in this graph:
  12937. @example
  12938. input -----------> deltapts0 --> overlay --> output
  12939. ^
  12940. |
  12941. movie --> scale--> deltapts1 -------+
  12942. @end example
  12943. @subsection Examples
  12944. @itemize
  12945. @item
  12946. Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
  12947. on top of the input labelled "in":
  12948. @example
  12949. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  12950. [in] setpts=PTS-STARTPTS [main];
  12951. [main][over] overlay=16:16 [out]
  12952. @end example
  12953. @item
  12954. Read from a video4linux2 device, and overlay it on top of the input
  12955. labelled "in":
  12956. @example
  12957. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  12958. [in] setpts=PTS-STARTPTS [main];
  12959. [main][over] overlay=16:16 [out]
  12960. @end example
  12961. @item
  12962. Read the first video stream and the audio stream with id 0x81 from
  12963. dvd.vob; the video is connected to the pad named "video" and the audio is
  12964. connected to the pad named "audio":
  12965. @example
  12966. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  12967. @end example
  12968. @end itemize
  12969. @c man end MULTIMEDIA SOURCES