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.

16923 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. @item dither
  3987. Specify dithering mode.
  3988. The accepted values are:
  3989. @table @samp
  3990. @item none
  3991. No dithering
  3992. @item fsb
  3993. Floyd-Steinberg dithering
  3994. @end table
  3995. @item wpadapt
  3996. Whitepoint adaptation mode.
  3997. The accepted values are:
  3998. @table @samp
  3999. @item bradford
  4000. Bradford whitepoint adaptation
  4001. @item vonkries
  4002. von Kries whitepoint adaptation
  4003. @item identity
  4004. identity whitepoint adaptation (i.e. no whitepoint adaptation)
  4005. @end table
  4006. @end table
  4007. The filter converts the transfer characteristics, color space and color
  4008. primaries to the specified user values. The output value, if not specified,
  4009. is set to a default value based on the "all" property. If that property is
  4010. also not specified, the filter will log an error. The output color range and
  4011. format default to the same value as the input color range and format. The
  4012. input transfer characteristics, color space, color primaries and color range
  4013. should be set on the input data. If any of these are missing, the filter will
  4014. log an error and no conversion will take place.
  4015. For example to convert the input to SMPTE-240M, use the command:
  4016. @example
  4017. colorspace=smpte240m
  4018. @end example
  4019. @section convolution
  4020. Apply convolution 3x3 or 5x5 filter.
  4021. The filter accepts the following options:
  4022. @table @option
  4023. @item 0m
  4024. @item 1m
  4025. @item 2m
  4026. @item 3m
  4027. Set matrix for each plane.
  4028. Matrix is sequence of 9 or 25 signed integers.
  4029. @item 0rdiv
  4030. @item 1rdiv
  4031. @item 2rdiv
  4032. @item 3rdiv
  4033. Set multiplier for calculated value for each plane.
  4034. @item 0bias
  4035. @item 1bias
  4036. @item 2bias
  4037. @item 3bias
  4038. Set bias for each plane. This value is added to the result of the multiplication.
  4039. Useful for making the overall image brighter or darker. Default is 0.0.
  4040. @end table
  4041. @subsection Examples
  4042. @itemize
  4043. @item
  4044. Apply sharpen:
  4045. @example
  4046. 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"
  4047. @end example
  4048. @item
  4049. Apply blur:
  4050. @example
  4051. 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"
  4052. @end example
  4053. @item
  4054. Apply edge enhance:
  4055. @example
  4056. 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"
  4057. @end example
  4058. @item
  4059. Apply edge detect:
  4060. @example
  4061. 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"
  4062. @end example
  4063. @item
  4064. Apply emboss:
  4065. @example
  4066. 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"
  4067. @end example
  4068. @end itemize
  4069. @section copy
  4070. Copy the input source unchanged to the output. This is mainly useful for
  4071. testing purposes.
  4072. @anchor{coreimage}
  4073. @section coreimage
  4074. Video filtering on GPU using Apple's CoreImage API on OSX.
  4075. Hardware acceleration is based on an OpenGL context. Usually, this means it is
  4076. processed by video hardware. However, software-based OpenGL implementations
  4077. exist which means there is no guarantee for hardware processing. It depends on
  4078. the respective OSX.
  4079. There are many filters and image generators provided by Apple that come with a
  4080. large variety of options. The filter has to be referenced by its name along
  4081. with its options.
  4082. The coreimage filter accepts the following options:
  4083. @table @option
  4084. @item list_filters
  4085. List all available filters and generators along with all their respective
  4086. options as well as possible minimum and maximum values along with the default
  4087. values.
  4088. @example
  4089. list_filters=true
  4090. @end example
  4091. @item filter
  4092. Specify all filters by their respective name and options.
  4093. Use @var{list_filters} to determine all valid filter names and options.
  4094. Numerical options are specified by a float value and are automatically clamped
  4095. to their respective value range. Vector and color options have to be specified
  4096. by a list of space separated float values. Character escaping has to be done.
  4097. A special option name @code{default} is available to use default options for a
  4098. filter.
  4099. It is required to specify either @code{default} or at least one of the filter options.
  4100. All omitted options are used with their default values.
  4101. The syntax of the filter string is as follows:
  4102. @example
  4103. filter=<NAME>@@<OPTION>=<VALUE>[@@<OPTION>=<VALUE>][@@...][#<NAME>@@<OPTION>=<VALUE>[@@<OPTION>=<VALUE>][@@...]][#...]
  4104. @end example
  4105. @item output_rect
  4106. Specify a rectangle where the output of the filter chain is copied into the
  4107. input image. It is given by a list of space separated float values:
  4108. @example
  4109. output_rect=x\ y\ width\ height
  4110. @end example
  4111. If not given, the output rectangle equals the dimensions of the input image.
  4112. The output rectangle is automatically cropped at the borders of the input
  4113. image. Negative values are valid for each component.
  4114. @example
  4115. output_rect=25\ 25\ 100\ 100
  4116. @end example
  4117. @end table
  4118. Several filters can be chained for successive processing without GPU-HOST
  4119. transfers allowing for fast processing of complex filter chains.
  4120. Currently, only filters with zero (generators) or exactly one (filters) input
  4121. image and one output image are supported. Also, transition filters are not yet
  4122. usable as intended.
  4123. Some filters generate output images with additional padding depending on the
  4124. respective filter kernel. The padding is automatically removed to ensure the
  4125. filter output has the same size as the input image.
  4126. For image generators, the size of the output image is determined by the
  4127. previous output image of the filter chain or the input image of the whole
  4128. filterchain, respectively. The generators do not use the pixel information of
  4129. this image to generate their output. However, the generated output is
  4130. blended onto this image, resulting in partial or complete coverage of the
  4131. output image.
  4132. The @ref{coreimagesrc} video source can be used for generating input images
  4133. which are directly fed into the filter chain. By using it, providing input
  4134. images by another video source or an input video is not required.
  4135. @subsection Examples
  4136. @itemize
  4137. @item
  4138. List all filters available:
  4139. @example
  4140. coreimage=list_filters=true
  4141. @end example
  4142. @item
  4143. Use the CIBoxBlur filter with default options to blur an image:
  4144. @example
  4145. coreimage=filter=CIBoxBlur@@default
  4146. @end example
  4147. @item
  4148. Use a filter chain with CISepiaTone at default values and CIVignetteEffect with
  4149. its center at 100x100 and a radius of 50 pixels:
  4150. @example
  4151. coreimage=filter=CIBoxBlur@@default#CIVignetteEffect@@inputCenter=100\ 100@@inputRadius=50
  4152. @end example
  4153. @item
  4154. Use nullsrc and CIQRCodeGenerator to create a QR code for the FFmpeg homepage,
  4155. given as complete and escaped command-line for Apple's standard bash shell:
  4156. @example
  4157. ffmpeg -f lavfi -i nullsrc=s=100x100,coreimage=filter=CIQRCodeGenerator@@inputMessage=https\\\\\://FFmpeg.org/@@inputCorrectionLevel=H -frames:v 1 QRCode.png
  4158. @end example
  4159. @end itemize
  4160. @section crop
  4161. Crop the input video to given dimensions.
  4162. It accepts the following parameters:
  4163. @table @option
  4164. @item w, out_w
  4165. The width of the output video. It defaults to @code{iw}.
  4166. This expression is evaluated only once during the filter
  4167. configuration, or when the @samp{w} or @samp{out_w} command is sent.
  4168. @item h, out_h
  4169. The height of the output video. It defaults to @code{ih}.
  4170. This expression is evaluated only once during the filter
  4171. configuration, or when the @samp{h} or @samp{out_h} command is sent.
  4172. @item x
  4173. The horizontal position, in the input video, of the left edge of the output
  4174. video. It defaults to @code{(in_w-out_w)/2}.
  4175. This expression is evaluated per-frame.
  4176. @item y
  4177. The vertical position, in the input video, of the top edge of the output video.
  4178. It defaults to @code{(in_h-out_h)/2}.
  4179. This expression is evaluated per-frame.
  4180. @item keep_aspect
  4181. If set to 1 will force the output display aspect ratio
  4182. to be the same of the input, by changing the output sample aspect
  4183. ratio. It defaults to 0.
  4184. @end table
  4185. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  4186. expressions containing the following constants:
  4187. @table @option
  4188. @item x
  4189. @item y
  4190. The computed values for @var{x} and @var{y}. They are evaluated for
  4191. each new frame.
  4192. @item in_w
  4193. @item in_h
  4194. The input width and height.
  4195. @item iw
  4196. @item ih
  4197. These are the same as @var{in_w} and @var{in_h}.
  4198. @item out_w
  4199. @item out_h
  4200. The output (cropped) width and height.
  4201. @item ow
  4202. @item oh
  4203. These are the same as @var{out_w} and @var{out_h}.
  4204. @item a
  4205. same as @var{iw} / @var{ih}
  4206. @item sar
  4207. input sample aspect ratio
  4208. @item dar
  4209. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  4210. @item hsub
  4211. @item vsub
  4212. horizontal and vertical chroma subsample values. For example for the
  4213. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4214. @item n
  4215. The number of the input frame, starting from 0.
  4216. @item pos
  4217. the position in the file of the input frame, NAN if unknown
  4218. @item t
  4219. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  4220. @end table
  4221. The expression for @var{out_w} may depend on the value of @var{out_h},
  4222. and the expression for @var{out_h} may depend on @var{out_w}, but they
  4223. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  4224. evaluated after @var{out_w} and @var{out_h}.
  4225. The @var{x} and @var{y} parameters specify the expressions for the
  4226. position of the top-left corner of the output (non-cropped) area. They
  4227. are evaluated for each frame. If the evaluated value is not valid, it
  4228. is approximated to the nearest valid value.
  4229. The expression for @var{x} may depend on @var{y}, and the expression
  4230. for @var{y} may depend on @var{x}.
  4231. @subsection Examples
  4232. @itemize
  4233. @item
  4234. Crop area with size 100x100 at position (12,34).
  4235. @example
  4236. crop=100:100:12:34
  4237. @end example
  4238. Using named options, the example above becomes:
  4239. @example
  4240. crop=w=100:h=100:x=12:y=34
  4241. @end example
  4242. @item
  4243. Crop the central input area with size 100x100:
  4244. @example
  4245. crop=100:100
  4246. @end example
  4247. @item
  4248. Crop the central input area with size 2/3 of the input video:
  4249. @example
  4250. crop=2/3*in_w:2/3*in_h
  4251. @end example
  4252. @item
  4253. Crop the input video central square:
  4254. @example
  4255. crop=out_w=in_h
  4256. crop=in_h
  4257. @end example
  4258. @item
  4259. Delimit the rectangle with the top-left corner placed at position
  4260. 100:100 and the right-bottom corner corresponding to the right-bottom
  4261. corner of the input image.
  4262. @example
  4263. crop=in_w-100:in_h-100:100:100
  4264. @end example
  4265. @item
  4266. Crop 10 pixels from the left and right borders, and 20 pixels from
  4267. the top and bottom borders
  4268. @example
  4269. crop=in_w-2*10:in_h-2*20
  4270. @end example
  4271. @item
  4272. Keep only the bottom right quarter of the input image:
  4273. @example
  4274. crop=in_w/2:in_h/2:in_w/2:in_h/2
  4275. @end example
  4276. @item
  4277. Crop height for getting Greek harmony:
  4278. @example
  4279. crop=in_w:1/PHI*in_w
  4280. @end example
  4281. @item
  4282. Apply trembling effect:
  4283. @example
  4284. 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)
  4285. @end example
  4286. @item
  4287. Apply erratic camera effect depending on timestamp:
  4288. @example
  4289. 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)"
  4290. @end example
  4291. @item
  4292. Set x depending on the value of y:
  4293. @example
  4294. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  4295. @end example
  4296. @end itemize
  4297. @subsection Commands
  4298. This filter supports the following commands:
  4299. @table @option
  4300. @item w, out_w
  4301. @item h, out_h
  4302. @item x
  4303. @item y
  4304. Set width/height of the output video and the horizontal/vertical position
  4305. in the input video.
  4306. The command accepts the same syntax of the corresponding option.
  4307. If the specified expression is not valid, it is kept at its current
  4308. value.
  4309. @end table
  4310. @section cropdetect
  4311. Auto-detect the crop size.
  4312. It calculates the necessary cropping parameters and prints the
  4313. recommended parameters via the logging system. The detected dimensions
  4314. correspond to the non-black area of the input video.
  4315. It accepts the following parameters:
  4316. @table @option
  4317. @item limit
  4318. Set higher black value threshold, which can be optionally specified
  4319. from nothing (0) to everything (255 for 8bit based formats). An intensity
  4320. value greater to the set value is considered non-black. It defaults to 24.
  4321. You can also specify a value between 0.0 and 1.0 which will be scaled depending
  4322. on the bitdepth of the pixel format.
  4323. @item round
  4324. The value which the width/height should be divisible by. It defaults to
  4325. 16. The offset is automatically adjusted to center the video. Use 2 to
  4326. get only even dimensions (needed for 4:2:2 video). 16 is best when
  4327. encoding to most video codecs.
  4328. @item reset_count, reset
  4329. Set the counter that determines after how many frames cropdetect will
  4330. reset the previously detected largest video area and start over to
  4331. detect the current optimal crop area. Default value is 0.
  4332. This can be useful when channel logos distort the video area. 0
  4333. indicates 'never reset', and returns the largest area encountered during
  4334. playback.
  4335. @end table
  4336. @anchor{curves}
  4337. @section curves
  4338. Apply color adjustments using curves.
  4339. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  4340. component (red, green and blue) has its values defined by @var{N} key points
  4341. tied from each other using a smooth curve. The x-axis represents the pixel
  4342. values from the input frame, and the y-axis the new pixel values to be set for
  4343. the output frame.
  4344. By default, a component curve is defined by the two points @var{(0;0)} and
  4345. @var{(1;1)}. This creates a straight line where each original pixel value is
  4346. "adjusted" to its own value, which means no change to the image.
  4347. The filter allows you to redefine these two points and add some more. A new
  4348. curve (using a natural cubic spline interpolation) will be define to pass
  4349. smoothly through all these new coordinates. The new defined points needs to be
  4350. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  4351. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  4352. the vector spaces, the values will be clipped accordingly.
  4353. If there is no key point defined in @code{x=0}, the filter will automatically
  4354. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  4355. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  4356. The filter accepts the following options:
  4357. @table @option
  4358. @item preset
  4359. Select one of the available color presets. This option can be used in addition
  4360. to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
  4361. options takes priority on the preset values.
  4362. Available presets are:
  4363. @table @samp
  4364. @item none
  4365. @item color_negative
  4366. @item cross_process
  4367. @item darker
  4368. @item increase_contrast
  4369. @item lighter
  4370. @item linear_contrast
  4371. @item medium_contrast
  4372. @item negative
  4373. @item strong_contrast
  4374. @item vintage
  4375. @end table
  4376. Default is @code{none}.
  4377. @item master, m
  4378. Set the master key points. These points will define a second pass mapping. It
  4379. is sometimes called a "luminance" or "value" mapping. It can be used with
  4380. @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
  4381. post-processing LUT.
  4382. @item red, r
  4383. Set the key points for the red component.
  4384. @item green, g
  4385. Set the key points for the green component.
  4386. @item blue, b
  4387. Set the key points for the blue component.
  4388. @item all
  4389. Set the key points for all components (not including master).
  4390. Can be used in addition to the other key points component
  4391. options. In this case, the unset component(s) will fallback on this
  4392. @option{all} setting.
  4393. @item psfile
  4394. Specify a Photoshop curves file (@code{.acv}) to import the settings from.
  4395. @end table
  4396. To avoid some filtergraph syntax conflicts, each key points list need to be
  4397. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  4398. @subsection Examples
  4399. @itemize
  4400. @item
  4401. Increase slightly the middle level of blue:
  4402. @example
  4403. curves=blue='0.5/0.58'
  4404. @end example
  4405. @item
  4406. Vintage effect:
  4407. @example
  4408. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  4409. @end example
  4410. Here we obtain the following coordinates for each components:
  4411. @table @var
  4412. @item red
  4413. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  4414. @item green
  4415. @code{(0;0) (0.50;0.48) (1;1)}
  4416. @item blue
  4417. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  4418. @end table
  4419. @item
  4420. The previous example can also be achieved with the associated built-in preset:
  4421. @example
  4422. curves=preset=vintage
  4423. @end example
  4424. @item
  4425. Or simply:
  4426. @example
  4427. curves=vintage
  4428. @end example
  4429. @item
  4430. Use a Photoshop preset and redefine the points of the green component:
  4431. @example
  4432. curves=psfile='MyCurvesPresets/purple.acv':green='0.45/0.53'
  4433. @end example
  4434. @end itemize
  4435. @section datascope
  4436. Video data analysis filter.
  4437. This filter shows hexadecimal pixel values of part of video.
  4438. The filter accepts the following options:
  4439. @table @option
  4440. @item size, s
  4441. Set output video size.
  4442. @item x
  4443. Set x offset from where to pick pixels.
  4444. @item y
  4445. Set y offset from where to pick pixels.
  4446. @item mode
  4447. Set scope mode, can be one of the following:
  4448. @table @samp
  4449. @item mono
  4450. Draw hexadecimal pixel values with white color on black background.
  4451. @item color
  4452. Draw hexadecimal pixel values with input video pixel color on black
  4453. background.
  4454. @item color2
  4455. Draw hexadecimal pixel values on color background picked from input video,
  4456. the text color is picked in such way so its always visible.
  4457. @end table
  4458. @item axis
  4459. Draw rows and columns numbers on left and top of video.
  4460. @end table
  4461. @section dctdnoiz
  4462. Denoise frames using 2D DCT (frequency domain filtering).
  4463. This filter is not designed for real time.
  4464. The filter accepts the following options:
  4465. @table @option
  4466. @item sigma, s
  4467. Set the noise sigma constant.
  4468. This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
  4469. coefficient (absolute value) below this threshold with be dropped.
  4470. If you need a more advanced filtering, see @option{expr}.
  4471. Default is @code{0}.
  4472. @item overlap
  4473. Set number overlapping pixels for each block. Since the filter can be slow, you
  4474. may want to reduce this value, at the cost of a less effective filter and the
  4475. risk of various artefacts.
  4476. If the overlapping value doesn't permit processing the whole input width or
  4477. height, a warning will be displayed and according borders won't be denoised.
  4478. Default value is @var{blocksize}-1, which is the best possible setting.
  4479. @item expr, e
  4480. Set the coefficient factor expression.
  4481. For each coefficient of a DCT block, this expression will be evaluated as a
  4482. multiplier value for the coefficient.
  4483. If this is option is set, the @option{sigma} option will be ignored.
  4484. The absolute value of the coefficient can be accessed through the @var{c}
  4485. variable.
  4486. @item n
  4487. Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
  4488. @var{blocksize}, which is the width and height of the processed blocks.
  4489. The default value is @var{3} (8x8) and can be raised to @var{4} for a
  4490. @var{blocksize} of 16x16. Note that changing this setting has huge consequences
  4491. on the speed processing. Also, a larger block size does not necessarily means a
  4492. better de-noising.
  4493. @end table
  4494. @subsection Examples
  4495. Apply a denoise with a @option{sigma} of @code{4.5}:
  4496. @example
  4497. dctdnoiz=4.5
  4498. @end example
  4499. The same operation can be achieved using the expression system:
  4500. @example
  4501. dctdnoiz=e='gte(c, 4.5*3)'
  4502. @end example
  4503. Violent denoise using a block size of @code{16x16}:
  4504. @example
  4505. dctdnoiz=15:n=4
  4506. @end example
  4507. @section deband
  4508. Remove banding artifacts from input video.
  4509. It works by replacing banded pixels with average value of referenced pixels.
  4510. The filter accepts the following options:
  4511. @table @option
  4512. @item 1thr
  4513. @item 2thr
  4514. @item 3thr
  4515. @item 4thr
  4516. Set banding detection threshold for each plane. Default is 0.02.
  4517. Valid range is 0.00003 to 0.5.
  4518. If difference between current pixel and reference pixel is less than threshold,
  4519. it will be considered as banded.
  4520. @item range, r
  4521. Banding detection range in pixels. Default is 16. If positive, random number
  4522. in range 0 to set value will be used. If negative, exact absolute value
  4523. will be used.
  4524. The range defines square of four pixels around current pixel.
  4525. @item direction, d
  4526. Set direction in radians from which four pixel will be compared. If positive,
  4527. random direction from 0 to set direction will be picked. If negative, exact of
  4528. absolute value will be picked. For example direction 0, -PI or -2*PI radians
  4529. will pick only pixels on same row and -PI/2 will pick only pixels on same
  4530. column.
  4531. @item blur
  4532. If enabled, current pixel is compared with average value of all four
  4533. surrounding pixels. The default is enabled. If disabled current pixel is
  4534. compared with all four surrounding pixels. The pixel is considered banded
  4535. if only all four differences with surrounding pixels are less than threshold.
  4536. @end table
  4537. @anchor{decimate}
  4538. @section decimate
  4539. Drop duplicated frames at regular intervals.
  4540. The filter accepts the following options:
  4541. @table @option
  4542. @item cycle
  4543. Set the number of frames from which one will be dropped. Setting this to
  4544. @var{N} means one frame in every batch of @var{N} frames will be dropped.
  4545. Default is @code{5}.
  4546. @item dupthresh
  4547. Set the threshold for duplicate detection. If the difference metric for a frame
  4548. is less than or equal to this value, then it is declared as duplicate. Default
  4549. is @code{1.1}
  4550. @item scthresh
  4551. Set scene change threshold. Default is @code{15}.
  4552. @item blockx
  4553. @item blocky
  4554. Set the size of the x and y-axis blocks used during metric calculations.
  4555. Larger blocks give better noise suppression, but also give worse detection of
  4556. small movements. Must be a power of two. Default is @code{32}.
  4557. @item ppsrc
  4558. Mark main input as a pre-processed input and activate clean source input
  4559. stream. This allows the input to be pre-processed with various filters to help
  4560. the metrics calculation while keeping the frame selection lossless. When set to
  4561. @code{1}, the first stream is for the pre-processed input, and the second
  4562. stream is the clean source from where the kept frames are chosen. Default is
  4563. @code{0}.
  4564. @item chroma
  4565. Set whether or not chroma is considered in the metric calculations. Default is
  4566. @code{1}.
  4567. @end table
  4568. @section deflate
  4569. Apply deflate effect to the video.
  4570. This filter replaces the pixel by the local(3x3) average by taking into account
  4571. only values lower than the pixel.
  4572. It accepts the following options:
  4573. @table @option
  4574. @item threshold0
  4575. @item threshold1
  4576. @item threshold2
  4577. @item threshold3
  4578. Limit the maximum change for each plane, default is 65535.
  4579. If 0, plane will remain unchanged.
  4580. @end table
  4581. @section dejudder
  4582. Remove judder produced by partially interlaced telecined content.
  4583. Judder can be introduced, for instance, by @ref{pullup} filter. If the original
  4584. source was partially telecined content then the output of @code{pullup,dejudder}
  4585. will have a variable frame rate. May change the recorded frame rate of the
  4586. container. Aside from that change, this filter will not affect constant frame
  4587. rate video.
  4588. The option available in this filter is:
  4589. @table @option
  4590. @item cycle
  4591. Specify the length of the window over which the judder repeats.
  4592. Accepts any integer greater than 1. Useful values are:
  4593. @table @samp
  4594. @item 4
  4595. If the original was telecined from 24 to 30 fps (Film to NTSC).
  4596. @item 5
  4597. If the original was telecined from 25 to 30 fps (PAL to NTSC).
  4598. @item 20
  4599. If a mixture of the two.
  4600. @end table
  4601. The default is @samp{4}.
  4602. @end table
  4603. @section delogo
  4604. Suppress a TV station logo by a simple interpolation of the surrounding
  4605. pixels. Just set a rectangle covering the logo and watch it disappear
  4606. (and sometimes something even uglier appear - your mileage may vary).
  4607. It accepts the following parameters:
  4608. @table @option
  4609. @item x
  4610. @item y
  4611. Specify the top left corner coordinates of the logo. They must be
  4612. specified.
  4613. @item w
  4614. @item h
  4615. Specify the width and height of the logo to clear. They must be
  4616. specified.
  4617. @item band, t
  4618. Specify the thickness of the fuzzy edge of the rectangle (added to
  4619. @var{w} and @var{h}). The default value is 1. This option is
  4620. deprecated, setting higher values should no longer be necessary and
  4621. is not recommended.
  4622. @item show
  4623. When set to 1, a green rectangle is drawn on the screen to simplify
  4624. finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
  4625. The default value is 0.
  4626. The rectangle is drawn on the outermost pixels which will be (partly)
  4627. replaced with interpolated values. The values of the next pixels
  4628. immediately outside this rectangle in each direction will be used to
  4629. compute the interpolated pixel values inside the rectangle.
  4630. @end table
  4631. @subsection Examples
  4632. @itemize
  4633. @item
  4634. Set a rectangle covering the area with top left corner coordinates 0,0
  4635. and size 100x77, and a band of size 10:
  4636. @example
  4637. delogo=x=0:y=0:w=100:h=77:band=10
  4638. @end example
  4639. @end itemize
  4640. @section deshake
  4641. Attempt to fix small changes in horizontal and/or vertical shift. This
  4642. filter helps remove camera shake from hand-holding a camera, bumping a
  4643. tripod, moving on a vehicle, etc.
  4644. The filter accepts the following options:
  4645. @table @option
  4646. @item x
  4647. @item y
  4648. @item w
  4649. @item h
  4650. Specify a rectangular area where to limit the search for motion
  4651. vectors.
  4652. If desired the search for motion vectors can be limited to a
  4653. rectangular area of the frame defined by its top left corner, width
  4654. and height. These parameters have the same meaning as the drawbox
  4655. filter which can be used to visualise the position of the bounding
  4656. box.
  4657. This is useful when simultaneous movement of subjects within the frame
  4658. might be confused for camera motion by the motion vector search.
  4659. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  4660. then the full frame is used. This allows later options to be set
  4661. without specifying the bounding box for the motion vector search.
  4662. Default - search the whole frame.
  4663. @item rx
  4664. @item ry
  4665. Specify the maximum extent of movement in x and y directions in the
  4666. range 0-64 pixels. Default 16.
  4667. @item edge
  4668. Specify how to generate pixels to fill blanks at the edge of the
  4669. frame. Available values are:
  4670. @table @samp
  4671. @item blank, 0
  4672. Fill zeroes at blank locations
  4673. @item original, 1
  4674. Original image at blank locations
  4675. @item clamp, 2
  4676. Extruded edge value at blank locations
  4677. @item mirror, 3
  4678. Mirrored edge at blank locations
  4679. @end table
  4680. Default value is @samp{mirror}.
  4681. @item blocksize
  4682. Specify the blocksize to use for motion search. Range 4-128 pixels,
  4683. default 8.
  4684. @item contrast
  4685. Specify the contrast threshold for blocks. Only blocks with more than
  4686. the specified contrast (difference between darkest and lightest
  4687. pixels) will be considered. Range 1-255, default 125.
  4688. @item search
  4689. Specify the search strategy. Available values are:
  4690. @table @samp
  4691. @item exhaustive, 0
  4692. Set exhaustive search
  4693. @item less, 1
  4694. Set less exhaustive search.
  4695. @end table
  4696. Default value is @samp{exhaustive}.
  4697. @item filename
  4698. If set then a detailed log of the motion search is written to the
  4699. specified file.
  4700. @item opencl
  4701. If set to 1, specify using OpenCL capabilities, only available if
  4702. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  4703. @end table
  4704. @section detelecine
  4705. Apply an exact inverse of the telecine operation. It requires a predefined
  4706. pattern specified using the pattern option which must be the same as that passed
  4707. to the telecine filter.
  4708. This filter accepts the following options:
  4709. @table @option
  4710. @item first_field
  4711. @table @samp
  4712. @item top, t
  4713. top field first
  4714. @item bottom, b
  4715. bottom field first
  4716. The default value is @code{top}.
  4717. @end table
  4718. @item pattern
  4719. A string of numbers representing the pulldown pattern you wish to apply.
  4720. The default value is @code{23}.
  4721. @item start_frame
  4722. A number representing position of the first frame with respect to the telecine
  4723. pattern. This is to be used if the stream is cut. The default value is @code{0}.
  4724. @end table
  4725. @section dilation
  4726. Apply dilation effect to the video.
  4727. This filter replaces the pixel by the local(3x3) maximum.
  4728. It accepts the following options:
  4729. @table @option
  4730. @item threshold0
  4731. @item threshold1
  4732. @item threshold2
  4733. @item threshold3
  4734. Limit the maximum change for each plane, default is 65535.
  4735. If 0, plane will remain unchanged.
  4736. @item coordinates
  4737. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  4738. pixels are used.
  4739. Flags to local 3x3 coordinates maps like this:
  4740. 1 2 3
  4741. 4 5
  4742. 6 7 8
  4743. @end table
  4744. @section displace
  4745. Displace pixels as indicated by second and third input stream.
  4746. It takes three input streams and outputs one stream, the first input is the
  4747. source, and second and third input are displacement maps.
  4748. The second input specifies how much to displace pixels along the
  4749. x-axis, while the third input specifies how much to displace pixels
  4750. along the y-axis.
  4751. If one of displacement map streams terminates, last frame from that
  4752. displacement map will be used.
  4753. Note that once generated, displacements maps can be reused over and over again.
  4754. A description of the accepted options follows.
  4755. @table @option
  4756. @item edge
  4757. Set displace behavior for pixels that are out of range.
  4758. Available values are:
  4759. @table @samp
  4760. @item blank
  4761. Missing pixels are replaced by black pixels.
  4762. @item smear
  4763. Adjacent pixels will spread out to replace missing pixels.
  4764. @item wrap
  4765. Out of range pixels are wrapped so they point to pixels of other side.
  4766. @end table
  4767. Default is @samp{smear}.
  4768. @end table
  4769. @subsection Examples
  4770. @itemize
  4771. @item
  4772. Add ripple effect to rgb input of video size hd720:
  4773. @example
  4774. 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
  4775. @end example
  4776. @item
  4777. Add wave effect to rgb input of video size hd720:
  4778. @example
  4779. 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
  4780. @end example
  4781. @end itemize
  4782. @section drawbox
  4783. Draw a colored box on the input image.
  4784. It accepts the following parameters:
  4785. @table @option
  4786. @item x
  4787. @item y
  4788. The expressions which specify the top left corner coordinates of the box. It defaults to 0.
  4789. @item width, w
  4790. @item height, h
  4791. The expressions which specify the width and height of the box; if 0 they are interpreted as
  4792. the input width and height. It defaults to 0.
  4793. @item color, c
  4794. Specify the color of the box to write. For the general syntax of this option,
  4795. check the "Color" section in the ffmpeg-utils manual. If the special
  4796. value @code{invert} is used, the box edge color is the same as the
  4797. video with inverted luma.
  4798. @item thickness, t
  4799. The expression which sets the thickness of the box edge. Default value is @code{3}.
  4800. See below for the list of accepted constants.
  4801. @end table
  4802. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  4803. following constants:
  4804. @table @option
  4805. @item dar
  4806. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  4807. @item hsub
  4808. @item vsub
  4809. horizontal and vertical chroma subsample values. For example for the
  4810. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4811. @item in_h, ih
  4812. @item in_w, iw
  4813. The input width and height.
  4814. @item sar
  4815. The input sample aspect ratio.
  4816. @item x
  4817. @item y
  4818. The x and y offset coordinates where the box is drawn.
  4819. @item w
  4820. @item h
  4821. The width and height of the drawn box.
  4822. @item t
  4823. The thickness of the drawn box.
  4824. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  4825. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  4826. @end table
  4827. @subsection Examples
  4828. @itemize
  4829. @item
  4830. Draw a black box around the edge of the input image:
  4831. @example
  4832. drawbox
  4833. @end example
  4834. @item
  4835. Draw a box with color red and an opacity of 50%:
  4836. @example
  4837. drawbox=10:20:200:60:red@@0.5
  4838. @end example
  4839. The previous example can be specified as:
  4840. @example
  4841. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  4842. @end example
  4843. @item
  4844. Fill the box with pink color:
  4845. @example
  4846. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  4847. @end example
  4848. @item
  4849. Draw a 2-pixel red 2.40:1 mask:
  4850. @example
  4851. 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
  4852. @end example
  4853. @end itemize
  4854. @section drawgraph, adrawgraph
  4855. Draw a graph using input video or audio metadata.
  4856. It accepts the following parameters:
  4857. @table @option
  4858. @item m1
  4859. Set 1st frame metadata key from which metadata values will be used to draw a graph.
  4860. @item fg1
  4861. Set 1st foreground color expression.
  4862. @item m2
  4863. Set 2nd frame metadata key from which metadata values will be used to draw a graph.
  4864. @item fg2
  4865. Set 2nd foreground color expression.
  4866. @item m3
  4867. Set 3rd frame metadata key from which metadata values will be used to draw a graph.
  4868. @item fg3
  4869. Set 3rd foreground color expression.
  4870. @item m4
  4871. Set 4th frame metadata key from which metadata values will be used to draw a graph.
  4872. @item fg4
  4873. Set 4th foreground color expression.
  4874. @item min
  4875. Set minimal value of metadata value.
  4876. @item max
  4877. Set maximal value of metadata value.
  4878. @item bg
  4879. Set graph background color. Default is white.
  4880. @item mode
  4881. Set graph mode.
  4882. Available values for mode is:
  4883. @table @samp
  4884. @item bar
  4885. @item dot
  4886. @item line
  4887. @end table
  4888. Default is @code{line}.
  4889. @item slide
  4890. Set slide mode.
  4891. Available values for slide is:
  4892. @table @samp
  4893. @item frame
  4894. Draw new frame when right border is reached.
  4895. @item replace
  4896. Replace old columns with new ones.
  4897. @item scroll
  4898. Scroll from right to left.
  4899. @item rscroll
  4900. Scroll from left to right.
  4901. @end table
  4902. Default is @code{frame}.
  4903. @item size
  4904. Set size of graph video. For the syntax of this option, check the
  4905. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  4906. The default value is @code{900x256}.
  4907. The foreground color expressions can use the following variables:
  4908. @table @option
  4909. @item MIN
  4910. Minimal value of metadata value.
  4911. @item MAX
  4912. Maximal value of metadata value.
  4913. @item VAL
  4914. Current metadata key value.
  4915. @end table
  4916. The color is defined as 0xAABBGGRR.
  4917. @end table
  4918. Example using metadata from @ref{signalstats} filter:
  4919. @example
  4920. signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255
  4921. @end example
  4922. Example using metadata from @ref{ebur128} filter:
  4923. @example
  4924. ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5
  4925. @end example
  4926. @section drawgrid
  4927. Draw a grid on the input image.
  4928. It accepts the following parameters:
  4929. @table @option
  4930. @item x
  4931. @item y
  4932. The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
  4933. @item width, w
  4934. @item height, h
  4935. The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
  4936. input width and height, respectively, minus @code{thickness}, so image gets
  4937. framed. Default to 0.
  4938. @item color, c
  4939. Specify the color of the grid. For the general syntax of this option,
  4940. check the "Color" section in the ffmpeg-utils manual. If the special
  4941. value @code{invert} is used, the grid color is the same as the
  4942. video with inverted luma.
  4943. @item thickness, t
  4944. The expression which sets the thickness of the grid line. Default value is @code{1}.
  4945. See below for the list of accepted constants.
  4946. @end table
  4947. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  4948. following constants:
  4949. @table @option
  4950. @item dar
  4951. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  4952. @item hsub
  4953. @item vsub
  4954. horizontal and vertical chroma subsample values. For example for the
  4955. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4956. @item in_h, ih
  4957. @item in_w, iw
  4958. The input grid cell width and height.
  4959. @item sar
  4960. The input sample aspect ratio.
  4961. @item x
  4962. @item y
  4963. The x and y coordinates of some point of grid intersection (meant to configure offset).
  4964. @item w
  4965. @item h
  4966. The width and height of the drawn cell.
  4967. @item t
  4968. The thickness of the drawn cell.
  4969. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  4970. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  4971. @end table
  4972. @subsection Examples
  4973. @itemize
  4974. @item
  4975. Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
  4976. @example
  4977. drawgrid=width=100:height=100:thickness=2:color=red@@0.5
  4978. @end example
  4979. @item
  4980. Draw a white 3x3 grid with an opacity of 50%:
  4981. @example
  4982. drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
  4983. @end example
  4984. @end itemize
  4985. @anchor{drawtext}
  4986. @section drawtext
  4987. Draw a text string or text from a specified file on top of a video, using the
  4988. libfreetype library.
  4989. To enable compilation of this filter, you need to configure FFmpeg with
  4990. @code{--enable-libfreetype}.
  4991. To enable default font fallback and the @var{font} option you need to
  4992. configure FFmpeg with @code{--enable-libfontconfig}.
  4993. To enable the @var{text_shaping} option, you need to configure FFmpeg with
  4994. @code{--enable-libfribidi}.
  4995. @subsection Syntax
  4996. It accepts the following parameters:
  4997. @table @option
  4998. @item box
  4999. Used to draw a box around text using the background color.
  5000. The value must be either 1 (enable) or 0 (disable).
  5001. The default value of @var{box} is 0.
  5002. @item boxborderw
  5003. Set the width of the border to be drawn around the box using @var{boxcolor}.
  5004. The default value of @var{boxborderw} is 0.
  5005. @item boxcolor
  5006. The color to be used for drawing box around text. For the syntax of this
  5007. option, check the "Color" section in the ffmpeg-utils manual.
  5008. The default value of @var{boxcolor} is "white".
  5009. @item borderw
  5010. Set the width of the border to be drawn around the text using @var{bordercolor}.
  5011. The default value of @var{borderw} is 0.
  5012. @item bordercolor
  5013. Set the color to be used for drawing border around text. For the syntax of this
  5014. option, check the "Color" section in the ffmpeg-utils manual.
  5015. The default value of @var{bordercolor} is "black".
  5016. @item expansion
  5017. Select how the @var{text} is expanded. Can be either @code{none},
  5018. @code{strftime} (deprecated) or
  5019. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  5020. below for details.
  5021. @item fix_bounds
  5022. If true, check and fix text coords to avoid clipping.
  5023. @item fontcolor
  5024. The color to be used for drawing fonts. For the syntax of this option, check
  5025. the "Color" section in the ffmpeg-utils manual.
  5026. The default value of @var{fontcolor} is "black".
  5027. @item fontcolor_expr
  5028. String which is expanded the same way as @var{text} to obtain dynamic
  5029. @var{fontcolor} value. By default this option has empty value and is not
  5030. processed. When this option is set, it overrides @var{fontcolor} option.
  5031. @item font
  5032. The font family to be used for drawing text. By default Sans.
  5033. @item fontfile
  5034. The font file to be used for drawing text. The path must be included.
  5035. This parameter is mandatory if the fontconfig support is disabled.
  5036. @item draw
  5037. This option does not exist, please see the timeline system
  5038. @item alpha
  5039. Draw the text applying alpha blending. The value can
  5040. be either a number between 0.0 and 1.0
  5041. The expression accepts the same variables @var{x, y} do.
  5042. The default value is 1.
  5043. Please see fontcolor_expr
  5044. @item fontsize
  5045. The font size to be used for drawing text.
  5046. The default value of @var{fontsize} is 16.
  5047. @item text_shaping
  5048. If set to 1, attempt to shape the text (for example, reverse the order of
  5049. right-to-left text and join Arabic characters) before drawing it.
  5050. Otherwise, just draw the text exactly as given.
  5051. By default 1 (if supported).
  5052. @item ft_load_flags
  5053. The flags to be used for loading the fonts.
  5054. The flags map the corresponding flags supported by libfreetype, and are
  5055. a combination of the following values:
  5056. @table @var
  5057. @item default
  5058. @item no_scale
  5059. @item no_hinting
  5060. @item render
  5061. @item no_bitmap
  5062. @item vertical_layout
  5063. @item force_autohint
  5064. @item crop_bitmap
  5065. @item pedantic
  5066. @item ignore_global_advance_width
  5067. @item no_recurse
  5068. @item ignore_transform
  5069. @item monochrome
  5070. @item linear_design
  5071. @item no_autohint
  5072. @end table
  5073. Default value is "default".
  5074. For more information consult the documentation for the FT_LOAD_*
  5075. libfreetype flags.
  5076. @item shadowcolor
  5077. The color to be used for drawing a shadow behind the drawn text. For the
  5078. syntax of this option, check the "Color" section in the ffmpeg-utils manual.
  5079. The default value of @var{shadowcolor} is "black".
  5080. @item shadowx
  5081. @item shadowy
  5082. The x and y offsets for the text shadow position with respect to the
  5083. position of the text. They can be either positive or negative
  5084. values. The default value for both is "0".
  5085. @item start_number
  5086. The starting frame number for the n/frame_num variable. The default value
  5087. is "0".
  5088. @item tabsize
  5089. The size in number of spaces to use for rendering the tab.
  5090. Default value is 4.
  5091. @item timecode
  5092. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  5093. format. It can be used with or without text parameter. @var{timecode_rate}
  5094. option must be specified.
  5095. @item timecode_rate, rate, r
  5096. Set the timecode frame rate (timecode only).
  5097. @item text
  5098. The text string to be drawn. The text must be a sequence of UTF-8
  5099. encoded characters.
  5100. This parameter is mandatory if no file is specified with the parameter
  5101. @var{textfile}.
  5102. @item textfile
  5103. A text file containing text to be drawn. The text must be a sequence
  5104. of UTF-8 encoded characters.
  5105. This parameter is mandatory if no text string is specified with the
  5106. parameter @var{text}.
  5107. If both @var{text} and @var{textfile} are specified, an error is thrown.
  5108. @item reload
  5109. If set to 1, the @var{textfile} will be reloaded before each frame.
  5110. Be sure to update it atomically, or it may be read partially, or even fail.
  5111. @item x
  5112. @item y
  5113. The expressions which specify the offsets where text will be drawn
  5114. within the video frame. They are relative to the top/left border of the
  5115. output image.
  5116. The default value of @var{x} and @var{y} is "0".
  5117. See below for the list of accepted constants and functions.
  5118. @end table
  5119. The parameters for @var{x} and @var{y} are expressions containing the
  5120. following constants and functions:
  5121. @table @option
  5122. @item dar
  5123. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  5124. @item hsub
  5125. @item vsub
  5126. horizontal and vertical chroma subsample values. For example for the
  5127. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  5128. @item line_h, lh
  5129. the height of each text line
  5130. @item main_h, h, H
  5131. the input height
  5132. @item main_w, w, W
  5133. the input width
  5134. @item max_glyph_a, ascent
  5135. the maximum distance from the baseline to the highest/upper grid
  5136. coordinate used to place a glyph outline point, for all the rendered
  5137. glyphs.
  5138. It is a positive value, due to the grid's orientation with the Y axis
  5139. upwards.
  5140. @item max_glyph_d, descent
  5141. the maximum distance from the baseline to the lowest grid coordinate
  5142. used to place a glyph outline point, for all the rendered glyphs.
  5143. This is a negative value, due to the grid's orientation, with the Y axis
  5144. upwards.
  5145. @item max_glyph_h
  5146. maximum glyph height, that is the maximum height for all the glyphs
  5147. contained in the rendered text, it is equivalent to @var{ascent} -
  5148. @var{descent}.
  5149. @item max_glyph_w
  5150. maximum glyph width, that is the maximum width for all the glyphs
  5151. contained in the rendered text
  5152. @item n
  5153. the number of input frame, starting from 0
  5154. @item rand(min, max)
  5155. return a random number included between @var{min} and @var{max}
  5156. @item sar
  5157. The input sample aspect ratio.
  5158. @item t
  5159. timestamp expressed in seconds, NAN if the input timestamp is unknown
  5160. @item text_h, th
  5161. the height of the rendered text
  5162. @item text_w, tw
  5163. the width of the rendered text
  5164. @item x
  5165. @item y
  5166. the x and y offset coordinates where the text is drawn.
  5167. These parameters allow the @var{x} and @var{y} expressions to refer
  5168. each other, so you can for example specify @code{y=x/dar}.
  5169. @end table
  5170. @anchor{drawtext_expansion}
  5171. @subsection Text expansion
  5172. If @option{expansion} is set to @code{strftime},
  5173. the filter recognizes strftime() sequences in the provided text and
  5174. expands them accordingly. Check the documentation of strftime(). This
  5175. feature is deprecated.
  5176. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  5177. If @option{expansion} is set to @code{normal} (which is the default),
  5178. the following expansion mechanism is used.
  5179. The backslash character @samp{\}, followed by any character, always expands to
  5180. the second character.
  5181. Sequence of the form @code{%@{...@}} are expanded. The text between the
  5182. braces is a function name, possibly followed by arguments separated by ':'.
  5183. If the arguments contain special characters or delimiters (':' or '@}'),
  5184. they should be escaped.
  5185. Note that they probably must also be escaped as the value for the
  5186. @option{text} option in the filter argument string and as the filter
  5187. argument in the filtergraph description, and possibly also for the shell,
  5188. that makes up to four levels of escaping; using a text file avoids these
  5189. problems.
  5190. The following functions are available:
  5191. @table @command
  5192. @item expr, e
  5193. The expression evaluation result.
  5194. It must take one argument specifying the expression to be evaluated,
  5195. which accepts the same constants and functions as the @var{x} and
  5196. @var{y} values. Note that not all constants should be used, for
  5197. example the text size is not known when evaluating the expression, so
  5198. the constants @var{text_w} and @var{text_h} will have an undefined
  5199. value.
  5200. @item expr_int_format, eif
  5201. Evaluate the expression's value and output as formatted integer.
  5202. The first argument is the expression to be evaluated, just as for the @var{expr} function.
  5203. The second argument specifies the output format. Allowed values are @samp{x},
  5204. @samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
  5205. @code{printf} function.
  5206. The third parameter is optional and sets the number of positions taken by the output.
  5207. It can be used to add padding with zeros from the left.
  5208. @item gmtime
  5209. The time at which the filter is running, expressed in UTC.
  5210. It can accept an argument: a strftime() format string.
  5211. @item localtime
  5212. The time at which the filter is running, expressed in the local time zone.
  5213. It can accept an argument: a strftime() format string.
  5214. @item metadata
  5215. Frame metadata. Takes one or two arguments.
  5216. The first argument is mandatory and specifies the metadata key.
  5217. The second argument is optional and specifies a default value, used when the
  5218. metadata key is not found or empty.
  5219. @item n, frame_num
  5220. The frame number, starting from 0.
  5221. @item pict_type
  5222. A 1 character description of the current picture type.
  5223. @item pts
  5224. The timestamp of the current frame.
  5225. It can take up to three arguments.
  5226. The first argument is the format of the timestamp; it defaults to @code{flt}
  5227. for seconds as a decimal number with microsecond accuracy; @code{hms} stands
  5228. for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
  5229. @code{gmtime} stands for the timestamp of the frame formatted as UTC time;
  5230. @code{localtime} stands for the timestamp of the frame formatted as
  5231. local time zone time.
  5232. The second argument is an offset added to the timestamp.
  5233. If the format is set to @code{localtime} or @code{gmtime},
  5234. a third argument may be supplied: a strftime() format string.
  5235. By default, @var{YYYY-MM-DD HH:MM:SS} format will be used.
  5236. @end table
  5237. @subsection Examples
  5238. @itemize
  5239. @item
  5240. Draw "Test Text" with font FreeSerif, using the default values for the
  5241. optional parameters.
  5242. @example
  5243. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  5244. @end example
  5245. @item
  5246. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  5247. and y=50 (counting from the top-left corner of the screen), text is
  5248. yellow with a red box around it. Both the text and the box have an
  5249. opacity of 20%.
  5250. @example
  5251. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  5252. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  5253. @end example
  5254. Note that the double quotes are not necessary if spaces are not used
  5255. within the parameter list.
  5256. @item
  5257. Show the text at the center of the video frame:
  5258. @example
  5259. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2"
  5260. @end example
  5261. @item
  5262. Show the text at a random position, switching to a new position every 30 seconds:
  5263. @example
  5264. 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)"
  5265. @end example
  5266. @item
  5267. Show a text line sliding from right to left in the last row of the video
  5268. frame. The file @file{LONG_LINE} is assumed to contain a single line
  5269. with no newlines.
  5270. @example
  5271. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  5272. @end example
  5273. @item
  5274. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  5275. @example
  5276. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  5277. @end example
  5278. @item
  5279. Draw a single green letter "g", at the center of the input video.
  5280. The glyph baseline is placed at half screen height.
  5281. @example
  5282. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  5283. @end example
  5284. @item
  5285. Show text for 1 second every 3 seconds:
  5286. @example
  5287. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  5288. @end example
  5289. @item
  5290. Use fontconfig to set the font. Note that the colons need to be escaped.
  5291. @example
  5292. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  5293. @end example
  5294. @item
  5295. Print the date of a real-time encoding (see strftime(3)):
  5296. @example
  5297. drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
  5298. @end example
  5299. @item
  5300. Show text fading in and out (appearing/disappearing):
  5301. @example
  5302. #!/bin/sh
  5303. DS=1.0 # display start
  5304. DE=10.0 # display end
  5305. FID=1.5 # fade in duration
  5306. FOD=5 # fade out duration
  5307. 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 @}"
  5308. @end example
  5309. @end itemize
  5310. For more information about libfreetype, check:
  5311. @url{http://www.freetype.org/}.
  5312. For more information about fontconfig, check:
  5313. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  5314. For more information about libfribidi, check:
  5315. @url{http://fribidi.org/}.
  5316. @section edgedetect
  5317. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  5318. The filter accepts the following options:
  5319. @table @option
  5320. @item low
  5321. @item high
  5322. Set low and high threshold values used by the Canny thresholding
  5323. algorithm.
  5324. The high threshold selects the "strong" edge pixels, which are then
  5325. connected through 8-connectivity with the "weak" edge pixels selected
  5326. by the low threshold.
  5327. @var{low} and @var{high} threshold values must be chosen in the range
  5328. [0,1], and @var{low} should be lesser or equal to @var{high}.
  5329. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  5330. is @code{50/255}.
  5331. @item mode
  5332. Define the drawing mode.
  5333. @table @samp
  5334. @item wires
  5335. Draw white/gray wires on black background.
  5336. @item colormix
  5337. Mix the colors to create a paint/cartoon effect.
  5338. @end table
  5339. Default value is @var{wires}.
  5340. @end table
  5341. @subsection Examples
  5342. @itemize
  5343. @item
  5344. Standard edge detection with custom values for the hysteresis thresholding:
  5345. @example
  5346. edgedetect=low=0.1:high=0.4
  5347. @end example
  5348. @item
  5349. Painting effect without thresholding:
  5350. @example
  5351. edgedetect=mode=colormix:high=0
  5352. @end example
  5353. @end itemize
  5354. @section eq
  5355. Set brightness, contrast, saturation and approximate gamma adjustment.
  5356. The filter accepts the following options:
  5357. @table @option
  5358. @item contrast
  5359. Set the contrast expression. The value must be a float value in range
  5360. @code{-2.0} to @code{2.0}. The default value is "1".
  5361. @item brightness
  5362. Set the brightness expression. The value must be a float value in
  5363. range @code{-1.0} to @code{1.0}. The default value is "0".
  5364. @item saturation
  5365. Set the saturation expression. The value must be a float in
  5366. range @code{0.0} to @code{3.0}. The default value is "1".
  5367. @item gamma
  5368. Set the gamma expression. The value must be a float in range
  5369. @code{0.1} to @code{10.0}. The default value is "1".
  5370. @item gamma_r
  5371. Set the gamma expression for red. The value must be a float in
  5372. range @code{0.1} to @code{10.0}. The default value is "1".
  5373. @item gamma_g
  5374. Set the gamma expression for green. The value must be a float in range
  5375. @code{0.1} to @code{10.0}. The default value is "1".
  5376. @item gamma_b
  5377. Set the gamma expression for blue. The value must be a float in range
  5378. @code{0.1} to @code{10.0}. The default value is "1".
  5379. @item gamma_weight
  5380. Set the gamma weight expression. It can be used to reduce the effect
  5381. of a high gamma value on bright image areas, e.g. keep them from
  5382. getting overamplified and just plain white. The value must be a float
  5383. in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
  5384. gamma correction all the way down while @code{1.0} leaves it at its
  5385. full strength. Default is "1".
  5386. @item eval
  5387. Set when the expressions for brightness, contrast, saturation and
  5388. gamma expressions are evaluated.
  5389. It accepts the following values:
  5390. @table @samp
  5391. @item init
  5392. only evaluate expressions once during the filter initialization or
  5393. when a command is processed
  5394. @item frame
  5395. evaluate expressions for each incoming frame
  5396. @end table
  5397. Default value is @samp{init}.
  5398. @end table
  5399. The expressions accept the following parameters:
  5400. @table @option
  5401. @item n
  5402. frame count of the input frame starting from 0
  5403. @item pos
  5404. byte position of the corresponding packet in the input file, NAN if
  5405. unspecified
  5406. @item r
  5407. frame rate of the input video, NAN if the input frame rate is unknown
  5408. @item t
  5409. timestamp expressed in seconds, NAN if the input timestamp is unknown
  5410. @end table
  5411. @subsection Commands
  5412. The filter supports the following commands:
  5413. @table @option
  5414. @item contrast
  5415. Set the contrast expression.
  5416. @item brightness
  5417. Set the brightness expression.
  5418. @item saturation
  5419. Set the saturation expression.
  5420. @item gamma
  5421. Set the gamma expression.
  5422. @item gamma_r
  5423. Set the gamma_r expression.
  5424. @item gamma_g
  5425. Set gamma_g expression.
  5426. @item gamma_b
  5427. Set gamma_b expression.
  5428. @item gamma_weight
  5429. Set gamma_weight expression.
  5430. The command accepts the same syntax of the corresponding option.
  5431. If the specified expression is not valid, it is kept at its current
  5432. value.
  5433. @end table
  5434. @section erosion
  5435. Apply erosion effect to the video.
  5436. This filter replaces the pixel by the local(3x3) minimum.
  5437. It accepts the following options:
  5438. @table @option
  5439. @item threshold0
  5440. @item threshold1
  5441. @item threshold2
  5442. @item threshold3
  5443. Limit the maximum change for each plane, default is 65535.
  5444. If 0, plane will remain unchanged.
  5445. @item coordinates
  5446. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  5447. pixels are used.
  5448. Flags to local 3x3 coordinates maps like this:
  5449. 1 2 3
  5450. 4 5
  5451. 6 7 8
  5452. @end table
  5453. @section extractplanes
  5454. Extract color channel components from input video stream into
  5455. separate grayscale video streams.
  5456. The filter accepts the following option:
  5457. @table @option
  5458. @item planes
  5459. Set plane(s) to extract.
  5460. Available values for planes are:
  5461. @table @samp
  5462. @item y
  5463. @item u
  5464. @item v
  5465. @item a
  5466. @item r
  5467. @item g
  5468. @item b
  5469. @end table
  5470. Choosing planes not available in the input will result in an error.
  5471. That means you cannot select @code{r}, @code{g}, @code{b} planes
  5472. with @code{y}, @code{u}, @code{v} planes at same time.
  5473. @end table
  5474. @subsection Examples
  5475. @itemize
  5476. @item
  5477. Extract luma, u and v color channel component from input video frame
  5478. into 3 grayscale outputs:
  5479. @example
  5480. 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
  5481. @end example
  5482. @end itemize
  5483. @section elbg
  5484. Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
  5485. For each input image, the filter will compute the optimal mapping from
  5486. the input to the output given the codebook length, that is the number
  5487. of distinct output colors.
  5488. This filter accepts the following options.
  5489. @table @option
  5490. @item codebook_length, l
  5491. Set codebook length. The value must be a positive integer, and
  5492. represents the number of distinct output colors. Default value is 256.
  5493. @item nb_steps, n
  5494. Set the maximum number of iterations to apply for computing the optimal
  5495. mapping. The higher the value the better the result and the higher the
  5496. computation time. Default value is 1.
  5497. @item seed, s
  5498. Set a random seed, must be an integer included between 0 and
  5499. UINT32_MAX. If not specified, or if explicitly set to -1, the filter
  5500. will try to use a good random seed on a best effort basis.
  5501. @item pal8
  5502. Set pal8 output pixel format. This option does not work with codebook
  5503. length greater than 256.
  5504. @end table
  5505. @section fade
  5506. Apply a fade-in/out effect to the input video.
  5507. It accepts the following parameters:
  5508. @table @option
  5509. @item type, t
  5510. The effect type can be either "in" for a fade-in, or "out" for a fade-out
  5511. effect.
  5512. Default is @code{in}.
  5513. @item start_frame, s
  5514. Specify the number of the frame to start applying the fade
  5515. effect at. Default is 0.
  5516. @item nb_frames, n
  5517. The number of frames that the fade effect lasts. At the end of the
  5518. fade-in effect, the output video will have the same intensity as the input video.
  5519. At the end of the fade-out transition, the output video will be filled with the
  5520. selected @option{color}.
  5521. Default is 25.
  5522. @item alpha
  5523. If set to 1, fade only alpha channel, if one exists on the input.
  5524. Default value is 0.
  5525. @item start_time, st
  5526. Specify the timestamp (in seconds) of the frame to start to apply the fade
  5527. effect. If both start_frame and start_time are specified, the fade will start at
  5528. whichever comes last. Default is 0.
  5529. @item duration, d
  5530. The number of seconds for which the fade effect has to last. At the end of the
  5531. fade-in effect the output video will have the same intensity as the input video,
  5532. at the end of the fade-out transition the output video will be filled with the
  5533. selected @option{color}.
  5534. If both duration and nb_frames are specified, duration is used. Default is 0
  5535. (nb_frames is used by default).
  5536. @item color, c
  5537. Specify the color of the fade. Default is "black".
  5538. @end table
  5539. @subsection Examples
  5540. @itemize
  5541. @item
  5542. Fade in the first 30 frames of video:
  5543. @example
  5544. fade=in:0:30
  5545. @end example
  5546. The command above is equivalent to:
  5547. @example
  5548. fade=t=in:s=0:n=30
  5549. @end example
  5550. @item
  5551. Fade out the last 45 frames of a 200-frame video:
  5552. @example
  5553. fade=out:155:45
  5554. fade=type=out:start_frame=155:nb_frames=45
  5555. @end example
  5556. @item
  5557. Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
  5558. @example
  5559. fade=in:0:25, fade=out:975:25
  5560. @end example
  5561. @item
  5562. Make the first 5 frames yellow, then fade in from frame 5-24:
  5563. @example
  5564. fade=in:5:20:color=yellow
  5565. @end example
  5566. @item
  5567. Fade in alpha over first 25 frames of video:
  5568. @example
  5569. fade=in:0:25:alpha=1
  5570. @end example
  5571. @item
  5572. Make the first 5.5 seconds black, then fade in for 0.5 seconds:
  5573. @example
  5574. fade=t=in:st=5.5:d=0.5
  5575. @end example
  5576. @end itemize
  5577. @section fftfilt
  5578. Apply arbitrary expressions to samples in frequency domain
  5579. @table @option
  5580. @item dc_Y
  5581. Adjust the dc value (gain) of the luma plane of the image. The filter
  5582. accepts an integer value in range @code{0} to @code{1000}. The default
  5583. value is set to @code{0}.
  5584. @item dc_U
  5585. Adjust the dc value (gain) of the 1st chroma plane of the image. The
  5586. filter accepts an integer value in range @code{0} to @code{1000}. The
  5587. default value is set to @code{0}.
  5588. @item dc_V
  5589. Adjust the dc value (gain) of the 2nd chroma plane of the image. The
  5590. filter accepts an integer value in range @code{0} to @code{1000}. The
  5591. default value is set to @code{0}.
  5592. @item weight_Y
  5593. Set the frequency domain weight expression for the luma plane.
  5594. @item weight_U
  5595. Set the frequency domain weight expression for the 1st chroma plane.
  5596. @item weight_V
  5597. Set the frequency domain weight expression for the 2nd chroma plane.
  5598. The filter accepts the following variables:
  5599. @item X
  5600. @item Y
  5601. The coordinates of the current sample.
  5602. @item W
  5603. @item H
  5604. The width and height of the image.
  5605. @end table
  5606. @subsection Examples
  5607. @itemize
  5608. @item
  5609. High-pass:
  5610. @example
  5611. fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
  5612. @end example
  5613. @item
  5614. Low-pass:
  5615. @example
  5616. fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
  5617. @end example
  5618. @item
  5619. Sharpen:
  5620. @example
  5621. fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
  5622. @end example
  5623. @item
  5624. Blur:
  5625. @example
  5626. fftfilt=dc_Y=0:weight_Y='exp(-4 * ((Y+X)/(W+H)))'
  5627. @end example
  5628. @end itemize
  5629. @section field
  5630. Extract a single field from an interlaced image using stride
  5631. arithmetic to avoid wasting CPU time. The output frames are marked as
  5632. non-interlaced.
  5633. The filter accepts the following options:
  5634. @table @option
  5635. @item type
  5636. Specify whether to extract the top (if the value is @code{0} or
  5637. @code{top}) or the bottom field (if the value is @code{1} or
  5638. @code{bottom}).
  5639. @end table
  5640. @section fieldhint
  5641. Create new frames by copying the top and bottom fields from surrounding frames
  5642. supplied as numbers by the hint file.
  5643. @table @option
  5644. @item hint
  5645. Set file containing hints: absolute/relative frame numbers.
  5646. There must be one line for each frame in a clip. Each line must contain two
  5647. numbers separated by the comma, optionally followed by @code{-} or @code{+}.
  5648. Numbers supplied on each line of file can not be out of [N-1,N+1] where N
  5649. is current frame number for @code{absolute} mode or out of [-1, 1] range
  5650. for @code{relative} mode. First number tells from which frame to pick up top
  5651. field and second number tells from which frame to pick up bottom field.
  5652. If optionally followed by @code{+} output frame will be marked as interlaced,
  5653. else if followed by @code{-} output frame will be marked as progressive, else
  5654. it will be marked same as input frame.
  5655. If line starts with @code{#} or @code{;} that line is skipped.
  5656. @item mode
  5657. Can be item @code{absolute} or @code{relative}. Default is @code{absolute}.
  5658. @end table
  5659. Example of first several lines of @code{hint} file for @code{relative} mode:
  5660. @example
  5661. 0,0 - # first frame
  5662. 1,0 - # second frame, use third's frame top field and second's frame bottom field
  5663. 1,0 - # third frame, use fourth's frame top field and third's frame bottom field
  5664. 1,0 -
  5665. 0,0 -
  5666. 0,0 -
  5667. 1,0 -
  5668. 1,0 -
  5669. 1,0 -
  5670. 0,0 -
  5671. 0,0 -
  5672. 1,0 -
  5673. 1,0 -
  5674. 1,0 -
  5675. 0,0 -
  5676. @end example
  5677. @section fieldmatch
  5678. Field matching filter for inverse telecine. It is meant to reconstruct the
  5679. progressive frames from a telecined stream. The filter does not drop duplicated
  5680. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  5681. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  5682. The separation of the field matching and the decimation is notably motivated by
  5683. the possibility of inserting a de-interlacing filter fallback between the two.
  5684. If the source has mixed telecined and real interlaced content,
  5685. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  5686. But these remaining combed frames will be marked as interlaced, and thus can be
  5687. de-interlaced by a later filter such as @ref{yadif} before decimation.
  5688. In addition to the various configuration options, @code{fieldmatch} can take an
  5689. optional second stream, activated through the @option{ppsrc} option. If
  5690. enabled, the frames reconstruction will be based on the fields and frames from
  5691. this second stream. This allows the first input to be pre-processed in order to
  5692. help the various algorithms of the filter, while keeping the output lossless
  5693. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  5694. or brightness/contrast adjustments can help.
  5695. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  5696. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  5697. which @code{fieldmatch} is based on. While the semantic and usage are very
  5698. close, some behaviour and options names can differ.
  5699. The @ref{decimate} filter currently only works for constant frame rate input.
  5700. If your input has mixed telecined (30fps) and progressive content with a lower
  5701. framerate like 24fps use the following filterchain to produce the necessary cfr
  5702. stream: @code{dejudder,fps=30000/1001,fieldmatch,decimate}.
  5703. The filter accepts the following options:
  5704. @table @option
  5705. @item order
  5706. Specify the assumed field order of the input stream. Available values are:
  5707. @table @samp
  5708. @item auto
  5709. Auto detect parity (use FFmpeg's internal parity value).
  5710. @item bff
  5711. Assume bottom field first.
  5712. @item tff
  5713. Assume top field first.
  5714. @end table
  5715. Note that it is sometimes recommended not to trust the parity announced by the
  5716. stream.
  5717. Default value is @var{auto}.
  5718. @item mode
  5719. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  5720. sense that it won't risk creating jerkiness due to duplicate frames when
  5721. possible, but if there are bad edits or blended fields it will end up
  5722. outputting combed frames when a good match might actually exist. On the other
  5723. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  5724. but will almost always find a good frame if there is one. The other values are
  5725. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  5726. jerkiness and creating duplicate frames versus finding good matches in sections
  5727. with bad edits, orphaned fields, blended fields, etc.
  5728. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  5729. Available values are:
  5730. @table @samp
  5731. @item pc
  5732. 2-way matching (p/c)
  5733. @item pc_n
  5734. 2-way matching, and trying 3rd match if still combed (p/c + n)
  5735. @item pc_u
  5736. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  5737. @item pc_n_ub
  5738. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  5739. still combed (p/c + n + u/b)
  5740. @item pcn
  5741. 3-way matching (p/c/n)
  5742. @item pcn_ub
  5743. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  5744. detected as combed (p/c/n + u/b)
  5745. @end table
  5746. The parenthesis at the end indicate the matches that would be used for that
  5747. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  5748. @var{top}).
  5749. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  5750. the slowest.
  5751. Default value is @var{pc_n}.
  5752. @item ppsrc
  5753. Mark the main input stream as a pre-processed input, and enable the secondary
  5754. input stream as the clean source to pick the fields from. See the filter
  5755. introduction for more details. It is similar to the @option{clip2} feature from
  5756. VFM/TFM.
  5757. Default value is @code{0} (disabled).
  5758. @item field
  5759. Set the field to match from. It is recommended to set this to the same value as
  5760. @option{order} unless you experience matching failures with that setting. In
  5761. certain circumstances changing the field that is used to match from can have a
  5762. large impact on matching performance. Available values are:
  5763. @table @samp
  5764. @item auto
  5765. Automatic (same value as @option{order}).
  5766. @item bottom
  5767. Match from the bottom field.
  5768. @item top
  5769. Match from the top field.
  5770. @end table
  5771. Default value is @var{auto}.
  5772. @item mchroma
  5773. Set whether or not chroma is included during the match comparisons. In most
  5774. cases it is recommended to leave this enabled. You should set this to @code{0}
  5775. only if your clip has bad chroma problems such as heavy rainbowing or other
  5776. artifacts. Setting this to @code{0} could also be used to speed things up at
  5777. the cost of some accuracy.
  5778. Default value is @code{1}.
  5779. @item y0
  5780. @item y1
  5781. These define an exclusion band which excludes the lines between @option{y0} and
  5782. @option{y1} from being included in the field matching decision. An exclusion
  5783. band can be used to ignore subtitles, a logo, or other things that may
  5784. interfere with the matching. @option{y0} sets the starting scan line and
  5785. @option{y1} sets the ending line; all lines in between @option{y0} and
  5786. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  5787. @option{y0} and @option{y1} to the same value will disable the feature.
  5788. @option{y0} and @option{y1} defaults to @code{0}.
  5789. @item scthresh
  5790. Set the scene change detection threshold as a percentage of maximum change on
  5791. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  5792. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  5793. @option{scthresh} is @code{[0.0, 100.0]}.
  5794. Default value is @code{12.0}.
  5795. @item combmatch
  5796. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  5797. account the combed scores of matches when deciding what match to use as the
  5798. final match. Available values are:
  5799. @table @samp
  5800. @item none
  5801. No final matching based on combed scores.
  5802. @item sc
  5803. Combed scores are only used when a scene change is detected.
  5804. @item full
  5805. Use combed scores all the time.
  5806. @end table
  5807. Default is @var{sc}.
  5808. @item combdbg
  5809. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  5810. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  5811. Available values are:
  5812. @table @samp
  5813. @item none
  5814. No forced calculation.
  5815. @item pcn
  5816. Force p/c/n calculations.
  5817. @item pcnub
  5818. Force p/c/n/u/b calculations.
  5819. @end table
  5820. Default value is @var{none}.
  5821. @item cthresh
  5822. This is the area combing threshold used for combed frame detection. This
  5823. essentially controls how "strong" or "visible" combing must be to be detected.
  5824. Larger values mean combing must be more visible and smaller values mean combing
  5825. can be less visible or strong and still be detected. Valid settings are from
  5826. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  5827. be detected as combed). This is basically a pixel difference value. A good
  5828. range is @code{[8, 12]}.
  5829. Default value is @code{9}.
  5830. @item chroma
  5831. Sets whether or not chroma is considered in the combed frame decision. Only
  5832. disable this if your source has chroma problems (rainbowing, etc.) that are
  5833. causing problems for the combed frame detection with chroma enabled. Actually,
  5834. using @option{chroma}=@var{0} is usually more reliable, except for the case
  5835. where there is chroma only combing in the source.
  5836. Default value is @code{0}.
  5837. @item blockx
  5838. @item blocky
  5839. Respectively set the x-axis and y-axis size of the window used during combed
  5840. frame detection. This has to do with the size of the area in which
  5841. @option{combpel} pixels are required to be detected as combed for a frame to be
  5842. declared combed. See the @option{combpel} parameter description for more info.
  5843. Possible values are any number that is a power of 2 starting at 4 and going up
  5844. to 512.
  5845. Default value is @code{16}.
  5846. @item combpel
  5847. The number of combed pixels inside any of the @option{blocky} by
  5848. @option{blockx} size blocks on the frame for the frame to be detected as
  5849. combed. While @option{cthresh} controls how "visible" the combing must be, this
  5850. setting controls "how much" combing there must be in any localized area (a
  5851. window defined by the @option{blockx} and @option{blocky} settings) on the
  5852. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  5853. which point no frames will ever be detected as combed). This setting is known
  5854. as @option{MI} in TFM/VFM vocabulary.
  5855. Default value is @code{80}.
  5856. @end table
  5857. @anchor{p/c/n/u/b meaning}
  5858. @subsection p/c/n/u/b meaning
  5859. @subsubsection p/c/n
  5860. We assume the following telecined stream:
  5861. @example
  5862. Top fields: 1 2 2 3 4
  5863. Bottom fields: 1 2 3 4 4
  5864. @end example
  5865. The numbers correspond to the progressive frame the fields relate to. Here, the
  5866. first two frames are progressive, the 3rd and 4th are combed, and so on.
  5867. When @code{fieldmatch} is configured to run a matching from bottom
  5868. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  5869. @example
  5870. Input stream:
  5871. T 1 2 2 3 4
  5872. B 1 2 3 4 4 <-- matching reference
  5873. Matches: c c n n c
  5874. Output stream:
  5875. T 1 2 3 4 4
  5876. B 1 2 3 4 4
  5877. @end example
  5878. As a result of the field matching, we can see that some frames get duplicated.
  5879. To perform a complete inverse telecine, you need to rely on a decimation filter
  5880. after this operation. See for instance the @ref{decimate} filter.
  5881. The same operation now matching from top fields (@option{field}=@var{top})
  5882. looks like this:
  5883. @example
  5884. Input stream:
  5885. T 1 2 2 3 4 <-- matching reference
  5886. B 1 2 3 4 4
  5887. Matches: c c p p c
  5888. Output stream:
  5889. T 1 2 2 3 4
  5890. B 1 2 2 3 4
  5891. @end example
  5892. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  5893. basically, they refer to the frame and field of the opposite parity:
  5894. @itemize
  5895. @item @var{p} matches the field of the opposite parity in the previous frame
  5896. @item @var{c} matches the field of the opposite parity in the current frame
  5897. @item @var{n} matches the field of the opposite parity in the next frame
  5898. @end itemize
  5899. @subsubsection u/b
  5900. The @var{u} and @var{b} matching are a bit special in the sense that they match
  5901. from the opposite parity flag. In the following examples, we assume that we are
  5902. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  5903. 'x' is placed above and below each matched fields.
  5904. With bottom matching (@option{field}=@var{bottom}):
  5905. @example
  5906. Match: c p n b u
  5907. x x x x x
  5908. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  5909. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  5910. x x x x x
  5911. Output frames:
  5912. 2 1 2 2 2
  5913. 2 2 2 1 3
  5914. @end example
  5915. With top matching (@option{field}=@var{top}):
  5916. @example
  5917. Match: c p n b u
  5918. x x x x x
  5919. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  5920. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  5921. x x x x x
  5922. Output frames:
  5923. 2 2 2 1 2
  5924. 2 1 3 2 2
  5925. @end example
  5926. @subsection Examples
  5927. Simple IVTC of a top field first telecined stream:
  5928. @example
  5929. fieldmatch=order=tff:combmatch=none, decimate
  5930. @end example
  5931. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  5932. @example
  5933. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  5934. @end example
  5935. @section fieldorder
  5936. Transform the field order of the input video.
  5937. It accepts the following parameters:
  5938. @table @option
  5939. @item order
  5940. The output field order. Valid values are @var{tff} for top field first or @var{bff}
  5941. for bottom field first.
  5942. @end table
  5943. The default value is @samp{tff}.
  5944. The transformation is done by shifting the picture content up or down
  5945. by one line, and filling the remaining line with appropriate picture content.
  5946. This method is consistent with most broadcast field order converters.
  5947. If the input video is not flagged as being interlaced, or it is already
  5948. flagged as being of the required output field order, then this filter does
  5949. not alter the incoming video.
  5950. It is very useful when converting to or from PAL DV material,
  5951. which is bottom field first.
  5952. For example:
  5953. @example
  5954. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  5955. @end example
  5956. @section fifo, afifo
  5957. Buffer input images and send them when they are requested.
  5958. It is mainly useful when auto-inserted by the libavfilter
  5959. framework.
  5960. It does not take parameters.
  5961. @section find_rect
  5962. Find a rectangular object
  5963. It accepts the following options:
  5964. @table @option
  5965. @item object
  5966. Filepath of the object image, needs to be in gray8.
  5967. @item threshold
  5968. Detection threshold, default is 0.5.
  5969. @item mipmaps
  5970. Number of mipmaps, default is 3.
  5971. @item xmin, ymin, xmax, ymax
  5972. Specifies the rectangle in which to search.
  5973. @end table
  5974. @subsection Examples
  5975. @itemize
  5976. @item
  5977. Generate a representative palette of a given video using @command{ffmpeg}:
  5978. @example
  5979. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  5980. @end example
  5981. @end itemize
  5982. @section cover_rect
  5983. Cover a rectangular object
  5984. It accepts the following options:
  5985. @table @option
  5986. @item cover
  5987. Filepath of the optional cover image, needs to be in yuv420.
  5988. @item mode
  5989. Set covering mode.
  5990. It accepts the following values:
  5991. @table @samp
  5992. @item cover
  5993. cover it by the supplied image
  5994. @item blur
  5995. cover it by interpolating the surrounding pixels
  5996. @end table
  5997. Default value is @var{blur}.
  5998. @end table
  5999. @subsection Examples
  6000. @itemize
  6001. @item
  6002. Generate a representative palette of a given video using @command{ffmpeg}:
  6003. @example
  6004. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  6005. @end example
  6006. @end itemize
  6007. @anchor{format}
  6008. @section format
  6009. Convert the input video to one of the specified pixel formats.
  6010. Libavfilter will try to pick one that is suitable as input to
  6011. the next filter.
  6012. It accepts the following parameters:
  6013. @table @option
  6014. @item pix_fmts
  6015. A '|'-separated list of pixel format names, such as
  6016. "pix_fmts=yuv420p|monow|rgb24".
  6017. @end table
  6018. @subsection Examples
  6019. @itemize
  6020. @item
  6021. Convert the input video to the @var{yuv420p} format
  6022. @example
  6023. format=pix_fmts=yuv420p
  6024. @end example
  6025. Convert the input video to any of the formats in the list
  6026. @example
  6027. format=pix_fmts=yuv420p|yuv444p|yuv410p
  6028. @end example
  6029. @end itemize
  6030. @anchor{fps}
  6031. @section fps
  6032. Convert the video to specified constant frame rate by duplicating or dropping
  6033. frames as necessary.
  6034. It accepts the following parameters:
  6035. @table @option
  6036. @item fps
  6037. The desired output frame rate. The default is @code{25}.
  6038. @item round
  6039. Rounding method.
  6040. Possible values are:
  6041. @table @option
  6042. @item zero
  6043. zero round towards 0
  6044. @item inf
  6045. round away from 0
  6046. @item down
  6047. round towards -infinity
  6048. @item up
  6049. round towards +infinity
  6050. @item near
  6051. round to nearest
  6052. @end table
  6053. The default is @code{near}.
  6054. @item start_time
  6055. Assume the first PTS should be the given value, in seconds. This allows for
  6056. padding/trimming at the start of stream. By default, no assumption is made
  6057. about the first frame's expected PTS, so no padding or trimming is done.
  6058. For example, this could be set to 0 to pad the beginning with duplicates of
  6059. the first frame if a video stream starts after the audio stream or to trim any
  6060. frames with a negative PTS.
  6061. @end table
  6062. Alternatively, the options can be specified as a flat string:
  6063. @var{fps}[:@var{round}].
  6064. See also the @ref{setpts} filter.
  6065. @subsection Examples
  6066. @itemize
  6067. @item
  6068. A typical usage in order to set the fps to 25:
  6069. @example
  6070. fps=fps=25
  6071. @end example
  6072. @item
  6073. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  6074. @example
  6075. fps=fps=film:round=near
  6076. @end example
  6077. @end itemize
  6078. @section framepack
  6079. Pack two different video streams into a stereoscopic video, setting proper
  6080. metadata on supported codecs. The two views should have the same size and
  6081. framerate and processing will stop when the shorter video ends. Please note
  6082. that you may conveniently adjust view properties with the @ref{scale} and
  6083. @ref{fps} filters.
  6084. It accepts the following parameters:
  6085. @table @option
  6086. @item format
  6087. The desired packing format. Supported values are:
  6088. @table @option
  6089. @item sbs
  6090. The views are next to each other (default).
  6091. @item tab
  6092. The views are on top of each other.
  6093. @item lines
  6094. The views are packed by line.
  6095. @item columns
  6096. The views are packed by column.
  6097. @item frameseq
  6098. The views are temporally interleaved.
  6099. @end table
  6100. @end table
  6101. Some examples:
  6102. @example
  6103. # Convert left and right views into a frame-sequential video
  6104. ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
  6105. # Convert views into a side-by-side video with the same output resolution as the input
  6106. 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
  6107. @end example
  6108. @section framerate
  6109. Change the frame rate by interpolating new video output frames from the source
  6110. frames.
  6111. This filter is not designed to function correctly with interlaced media. If
  6112. you wish to change the frame rate of interlaced media then you are required
  6113. to deinterlace before this filter and re-interlace after this filter.
  6114. A description of the accepted options follows.
  6115. @table @option
  6116. @item fps
  6117. Specify the output frames per second. This option can also be specified
  6118. as a value alone. The default is @code{50}.
  6119. @item interp_start
  6120. Specify the start of a range where the output frame will be created as a
  6121. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  6122. the default is @code{15}.
  6123. @item interp_end
  6124. Specify the end of a range where the output frame will be created as a
  6125. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  6126. the default is @code{240}.
  6127. @item scene
  6128. Specify the level at which a scene change is detected as a value between
  6129. 0 and 100 to indicate a new scene; a low value reflects a low
  6130. probability for the current frame to introduce a new scene, while a higher
  6131. value means the current frame is more likely to be one.
  6132. The default is @code{7}.
  6133. @item flags
  6134. Specify flags influencing the filter process.
  6135. Available value for @var{flags} is:
  6136. @table @option
  6137. @item scene_change_detect, scd
  6138. Enable scene change detection using the value of the option @var{scene}.
  6139. This flag is enabled by default.
  6140. @end table
  6141. @end table
  6142. @section framestep
  6143. Select one frame every N-th frame.
  6144. This filter accepts the following option:
  6145. @table @option
  6146. @item step
  6147. Select frame after every @code{step} frames.
  6148. Allowed values are positive integers higher than 0. Default value is @code{1}.
  6149. @end table
  6150. @anchor{frei0r}
  6151. @section frei0r
  6152. Apply a frei0r effect to the input video.
  6153. To enable the compilation of this filter, you need to install the frei0r
  6154. header and configure FFmpeg with @code{--enable-frei0r}.
  6155. It accepts the following parameters:
  6156. @table @option
  6157. @item filter_name
  6158. The name of the frei0r effect to load. If the environment variable
  6159. @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
  6160. directories specified by the colon-separated list in @env{FREIOR_PATH}.
  6161. Otherwise, the standard frei0r paths are searched, in this order:
  6162. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  6163. @file{/usr/lib/frei0r-1/}.
  6164. @item filter_params
  6165. A '|'-separated list of parameters to pass to the frei0r effect.
  6166. @end table
  6167. A frei0r effect parameter can be a boolean (its value is either
  6168. "y" or "n"), a double, a color (specified as
  6169. @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
  6170. numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
  6171. section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
  6172. @var{X} and @var{Y} are floating point numbers) and/or a string.
  6173. The number and types of parameters depend on the loaded effect. If an
  6174. effect parameter is not specified, the default value is set.
  6175. @subsection Examples
  6176. @itemize
  6177. @item
  6178. Apply the distort0r effect, setting the first two double parameters:
  6179. @example
  6180. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  6181. @end example
  6182. @item
  6183. Apply the colordistance effect, taking a color as the first parameter:
  6184. @example
  6185. frei0r=colordistance:0.2/0.3/0.4
  6186. frei0r=colordistance:violet
  6187. frei0r=colordistance:0x112233
  6188. @end example
  6189. @item
  6190. Apply the perspective effect, specifying the top left and top right image
  6191. positions:
  6192. @example
  6193. frei0r=perspective:0.2/0.2|0.8/0.2
  6194. @end example
  6195. @end itemize
  6196. For more information, see
  6197. @url{http://frei0r.dyne.org}
  6198. @section fspp
  6199. Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
  6200. It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
  6201. processing filter, one of them is performed once per block, not per pixel.
  6202. This allows for much higher speed.
  6203. The filter accepts the following options:
  6204. @table @option
  6205. @item quality
  6206. Set quality. This option defines the number of levels for averaging. It accepts
  6207. an integer in the range 4-5. Default value is @code{4}.
  6208. @item qp
  6209. Force a constant quantization parameter. It accepts an integer in range 0-63.
  6210. If not set, the filter will use the QP from the video stream (if available).
  6211. @item strength
  6212. Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
  6213. more details but also more artifacts, while higher values make the image smoother
  6214. but also blurrier. Default value is @code{0} − PSNR optimal.
  6215. @item use_bframe_qp
  6216. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  6217. option may cause flicker since the B-Frames have often larger QP. Default is
  6218. @code{0} (not enabled).
  6219. @end table
  6220. @section geq
  6221. The filter accepts the following options:
  6222. @table @option
  6223. @item lum_expr, lum
  6224. Set the luminance expression.
  6225. @item cb_expr, cb
  6226. Set the chrominance blue expression.
  6227. @item cr_expr, cr
  6228. Set the chrominance red expression.
  6229. @item alpha_expr, a
  6230. Set the alpha expression.
  6231. @item red_expr, r
  6232. Set the red expression.
  6233. @item green_expr, g
  6234. Set the green expression.
  6235. @item blue_expr, b
  6236. Set the blue expression.
  6237. @end table
  6238. The colorspace is selected according to the specified options. If one
  6239. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  6240. options is specified, the filter will automatically select a YCbCr
  6241. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  6242. @option{blue_expr} options is specified, it will select an RGB
  6243. colorspace.
  6244. If one of the chrominance expression is not defined, it falls back on the other
  6245. one. If no alpha expression is specified it will evaluate to opaque value.
  6246. If none of chrominance expressions are specified, they will evaluate
  6247. to the luminance expression.
  6248. The expressions can use the following variables and functions:
  6249. @table @option
  6250. @item N
  6251. The sequential number of the filtered frame, starting from @code{0}.
  6252. @item X
  6253. @item Y
  6254. The coordinates of the current sample.
  6255. @item W
  6256. @item H
  6257. The width and height of the image.
  6258. @item SW
  6259. @item SH
  6260. Width and height scale depending on the currently filtered plane. It is the
  6261. ratio between the corresponding luma plane number of pixels and the current
  6262. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  6263. @code{0.5,0.5} for chroma planes.
  6264. @item T
  6265. Time of the current frame, expressed in seconds.
  6266. @item p(x, y)
  6267. Return the value of the pixel at location (@var{x},@var{y}) of the current
  6268. plane.
  6269. @item lum(x, y)
  6270. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  6271. plane.
  6272. @item cb(x, y)
  6273. Return the value of the pixel at location (@var{x},@var{y}) of the
  6274. blue-difference chroma plane. Return 0 if there is no such plane.
  6275. @item cr(x, y)
  6276. Return the value of the pixel at location (@var{x},@var{y}) of the
  6277. red-difference chroma plane. Return 0 if there is no such plane.
  6278. @item r(x, y)
  6279. @item g(x, y)
  6280. @item b(x, y)
  6281. Return the value of the pixel at location (@var{x},@var{y}) of the
  6282. red/green/blue component. Return 0 if there is no such component.
  6283. @item alpha(x, y)
  6284. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  6285. plane. Return 0 if there is no such plane.
  6286. @end table
  6287. For functions, if @var{x} and @var{y} are outside the area, the value will be
  6288. automatically clipped to the closer edge.
  6289. @subsection Examples
  6290. @itemize
  6291. @item
  6292. Flip the image horizontally:
  6293. @example
  6294. geq=p(W-X\,Y)
  6295. @end example
  6296. @item
  6297. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  6298. wavelength of 100 pixels:
  6299. @example
  6300. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  6301. @end example
  6302. @item
  6303. Generate a fancy enigmatic moving light:
  6304. @example
  6305. 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
  6306. @end example
  6307. @item
  6308. Generate a quick emboss effect:
  6309. @example
  6310. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  6311. @end example
  6312. @item
  6313. Modify RGB components depending on pixel position:
  6314. @example
  6315. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  6316. @end example
  6317. @item
  6318. Create a radial gradient that is the same size as the input (also see
  6319. the @ref{vignette} filter):
  6320. @example
  6321. geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
  6322. @end example
  6323. @end itemize
  6324. @section gradfun
  6325. Fix the banding artifacts that are sometimes introduced into nearly flat
  6326. regions by truncation to 8bit color depth.
  6327. Interpolate the gradients that should go where the bands are, and
  6328. dither them.
  6329. It is designed for playback only. Do not use it prior to
  6330. lossy compression, because compression tends to lose the dither and
  6331. bring back the bands.
  6332. It accepts the following parameters:
  6333. @table @option
  6334. @item strength
  6335. The maximum amount by which the filter will change any one pixel. This is also
  6336. the threshold for detecting nearly flat regions. Acceptable values range from
  6337. .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
  6338. valid range.
  6339. @item radius
  6340. The neighborhood to fit the gradient to. A larger radius makes for smoother
  6341. gradients, but also prevents the filter from modifying the pixels near detailed
  6342. regions. Acceptable values are 8-32; the default value is 16. Out-of-range
  6343. values will be clipped to the valid range.
  6344. @end table
  6345. Alternatively, the options can be specified as a flat string:
  6346. @var{strength}[:@var{radius}]
  6347. @subsection Examples
  6348. @itemize
  6349. @item
  6350. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  6351. @example
  6352. gradfun=3.5:8
  6353. @end example
  6354. @item
  6355. Specify radius, omitting the strength (which will fall-back to the default
  6356. value):
  6357. @example
  6358. gradfun=radius=8
  6359. @end example
  6360. @end itemize
  6361. @anchor{haldclut}
  6362. @section haldclut
  6363. Apply a Hald CLUT to a video stream.
  6364. First input is the video stream to process, and second one is the Hald CLUT.
  6365. The Hald CLUT input can be a simple picture or a complete video stream.
  6366. The filter accepts the following options:
  6367. @table @option
  6368. @item shortest
  6369. Force termination when the shortest input terminates. Default is @code{0}.
  6370. @item repeatlast
  6371. Continue applying the last CLUT after the end of the stream. A value of
  6372. @code{0} disable the filter after the last frame of the CLUT is reached.
  6373. Default is @code{1}.
  6374. @end table
  6375. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  6376. filters share the same internals).
  6377. More information about the Hald CLUT can be found on Eskil Steenberg's website
  6378. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  6379. @subsection Workflow examples
  6380. @subsubsection Hald CLUT video stream
  6381. Generate an identity Hald CLUT stream altered with various effects:
  6382. @example
  6383. 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
  6384. @end example
  6385. Note: make sure you use a lossless codec.
  6386. Then use it with @code{haldclut} to apply it on some random stream:
  6387. @example
  6388. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  6389. @end example
  6390. The Hald CLUT will be applied to the 10 first seconds (duration of
  6391. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  6392. to the remaining frames of the @code{mandelbrot} stream.
  6393. @subsubsection Hald CLUT with preview
  6394. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  6395. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  6396. biggest possible square starting at the top left of the picture. The remaining
  6397. padding pixels (bottom or right) will be ignored. This area can be used to add
  6398. a preview of the Hald CLUT.
  6399. Typically, the following generated Hald CLUT will be supported by the
  6400. @code{haldclut} filter:
  6401. @example
  6402. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  6403. pad=iw+320 [padded_clut];
  6404. smptebars=s=320x256, split [a][b];
  6405. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  6406. [main][b] overlay=W-320" -frames:v 1 clut.png
  6407. @end example
  6408. It contains the original and a preview of the effect of the CLUT: SMPTE color
  6409. bars are displayed on the right-top, and below the same color bars processed by
  6410. the color changes.
  6411. Then, the effect of this Hald CLUT can be visualized with:
  6412. @example
  6413. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  6414. @end example
  6415. @section hdcd
  6416. Decodes high definition audio cd data. 16-Bit PCM stream containing hdcd flags
  6417. is converted to 20-bit PCM stream.
  6418. @section hflip
  6419. Flip the input video horizontally.
  6420. For example, to horizontally flip the input video with @command{ffmpeg}:
  6421. @example
  6422. ffmpeg -i in.avi -vf "hflip" out.avi
  6423. @end example
  6424. @section histeq
  6425. This filter applies a global color histogram equalization on a
  6426. per-frame basis.
  6427. It can be used to correct video that has a compressed range of pixel
  6428. intensities. The filter redistributes the pixel intensities to
  6429. equalize their distribution across the intensity range. It may be
  6430. viewed as an "automatically adjusting contrast filter". This filter is
  6431. useful only for correcting degraded or poorly captured source
  6432. video.
  6433. The filter accepts the following options:
  6434. @table @option
  6435. @item strength
  6436. Determine the amount of equalization to be applied. As the strength
  6437. is reduced, the distribution of pixel intensities more-and-more
  6438. approaches that of the input frame. The value must be a float number
  6439. in the range [0,1] and defaults to 0.200.
  6440. @item intensity
  6441. Set the maximum intensity that can generated and scale the output
  6442. values appropriately. The strength should be set as desired and then
  6443. the intensity can be limited if needed to avoid washing-out. The value
  6444. must be a float number in the range [0,1] and defaults to 0.210.
  6445. @item antibanding
  6446. Set the antibanding level. If enabled the filter will randomly vary
  6447. the luminance of output pixels by a small amount to avoid banding of
  6448. the histogram. Possible values are @code{none}, @code{weak} or
  6449. @code{strong}. It defaults to @code{none}.
  6450. @end table
  6451. @section histogram
  6452. Compute and draw a color distribution histogram for the input video.
  6453. The computed histogram is a representation of the color component
  6454. distribution in an image.
  6455. Standard histogram displays the color components distribution in an image.
  6456. Displays color graph for each color component. Shows distribution of
  6457. the Y, U, V, A or R, G, B components, depending on input format, in the
  6458. current frame. Below each graph a color component scale meter is shown.
  6459. The filter accepts the following options:
  6460. @table @option
  6461. @item level_height
  6462. Set height of level. Default value is @code{200}.
  6463. Allowed range is [50, 2048].
  6464. @item scale_height
  6465. Set height of color scale. Default value is @code{12}.
  6466. Allowed range is [0, 40].
  6467. @item display_mode
  6468. Set display mode.
  6469. It accepts the following values:
  6470. @table @samp
  6471. @item parade
  6472. Per color component graphs are placed below each other.
  6473. @item overlay
  6474. Presents information identical to that in the @code{parade}, except
  6475. that the graphs representing color components are superimposed directly
  6476. over one another.
  6477. @end table
  6478. Default is @code{parade}.
  6479. @item levels_mode
  6480. Set mode. Can be either @code{linear}, or @code{logarithmic}.
  6481. Default is @code{linear}.
  6482. @item components
  6483. Set what color components to display.
  6484. Default is @code{7}.
  6485. @end table
  6486. @subsection Examples
  6487. @itemize
  6488. @item
  6489. Calculate and draw histogram:
  6490. @example
  6491. ffplay -i input -vf histogram
  6492. @end example
  6493. @end itemize
  6494. @anchor{hqdn3d}
  6495. @section hqdn3d
  6496. This is a high precision/quality 3d denoise filter. It aims to reduce
  6497. image noise, producing smooth images and making still images really
  6498. still. It should enhance compressibility.
  6499. It accepts the following optional parameters:
  6500. @table @option
  6501. @item luma_spatial
  6502. A non-negative floating point number which specifies spatial luma strength.
  6503. It defaults to 4.0.
  6504. @item chroma_spatial
  6505. A non-negative floating point number which specifies spatial chroma strength.
  6506. It defaults to 3.0*@var{luma_spatial}/4.0.
  6507. @item luma_tmp
  6508. A floating point number which specifies luma temporal strength. It defaults to
  6509. 6.0*@var{luma_spatial}/4.0.
  6510. @item chroma_tmp
  6511. A floating point number which specifies chroma temporal strength. It defaults to
  6512. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
  6513. @end table
  6514. @anchor{hwupload_cuda}
  6515. @section hwupload_cuda
  6516. Upload system memory frames to a CUDA device.
  6517. It accepts the following optional parameters:
  6518. @table @option
  6519. @item device
  6520. The number of the CUDA device to use
  6521. @end table
  6522. @section hqx
  6523. Apply a high-quality magnification filter designed for pixel art. This filter
  6524. was originally created by Maxim Stepin.
  6525. It accepts the following option:
  6526. @table @option
  6527. @item n
  6528. Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
  6529. @code{hq3x} and @code{4} for @code{hq4x}.
  6530. Default is @code{3}.
  6531. @end table
  6532. @section hstack
  6533. Stack input videos horizontally.
  6534. All streams must be of same pixel format and of same height.
  6535. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  6536. to create same output.
  6537. The filter accept the following option:
  6538. @table @option
  6539. @item inputs
  6540. Set number of input streams. Default is 2.
  6541. @item shortest
  6542. If set to 1, force the output to terminate when the shortest input
  6543. terminates. Default value is 0.
  6544. @end table
  6545. @section hue
  6546. Modify the hue and/or the saturation of the input.
  6547. It accepts the following parameters:
  6548. @table @option
  6549. @item h
  6550. Specify the hue angle as a number of degrees. It accepts an expression,
  6551. and defaults to "0".
  6552. @item s
  6553. Specify the saturation in the [-10,10] range. It accepts an expression and
  6554. defaults to "1".
  6555. @item H
  6556. Specify the hue angle as a number of radians. It accepts an
  6557. expression, and defaults to "0".
  6558. @item b
  6559. Specify the brightness in the [-10,10] range. It accepts an expression and
  6560. defaults to "0".
  6561. @end table
  6562. @option{h} and @option{H} are mutually exclusive, and can't be
  6563. specified at the same time.
  6564. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  6565. expressions containing the following constants:
  6566. @table @option
  6567. @item n
  6568. frame count of the input frame starting from 0
  6569. @item pts
  6570. presentation timestamp of the input frame expressed in time base units
  6571. @item r
  6572. frame rate of the input video, NAN if the input frame rate is unknown
  6573. @item t
  6574. timestamp expressed in seconds, NAN if the input timestamp is unknown
  6575. @item tb
  6576. time base of the input video
  6577. @end table
  6578. @subsection Examples
  6579. @itemize
  6580. @item
  6581. Set the hue to 90 degrees and the saturation to 1.0:
  6582. @example
  6583. hue=h=90:s=1
  6584. @end example
  6585. @item
  6586. Same command but expressing the hue in radians:
  6587. @example
  6588. hue=H=PI/2:s=1
  6589. @end example
  6590. @item
  6591. Rotate hue and make the saturation swing between 0
  6592. and 2 over a period of 1 second:
  6593. @example
  6594. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  6595. @end example
  6596. @item
  6597. Apply a 3 seconds saturation fade-in effect starting at 0:
  6598. @example
  6599. hue="s=min(t/3\,1)"
  6600. @end example
  6601. The general fade-in expression can be written as:
  6602. @example
  6603. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  6604. @end example
  6605. @item
  6606. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  6607. @example
  6608. hue="s=max(0\, min(1\, (8-t)/3))"
  6609. @end example
  6610. The general fade-out expression can be written as:
  6611. @example
  6612. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  6613. @end example
  6614. @end itemize
  6615. @subsection Commands
  6616. This filter supports the following commands:
  6617. @table @option
  6618. @item b
  6619. @item s
  6620. @item h
  6621. @item H
  6622. Modify the hue and/or the saturation and/or brightness of the input video.
  6623. The command accepts the same syntax of the corresponding option.
  6624. If the specified expression is not valid, it is kept at its current
  6625. value.
  6626. @end table
  6627. @section idet
  6628. Detect video interlacing type.
  6629. This filter tries to detect if the input frames as interlaced, progressive,
  6630. top or bottom field first. It will also try and detect fields that are
  6631. repeated between adjacent frames (a sign of telecine).
  6632. Single frame detection considers only immediately adjacent frames when classifying each frame.
  6633. Multiple frame detection incorporates the classification history of previous frames.
  6634. The filter will log these metadata values:
  6635. @table @option
  6636. @item single.current_frame
  6637. Detected type of current frame using single-frame detection. One of:
  6638. ``tff'' (top field first), ``bff'' (bottom field first),
  6639. ``progressive'', or ``undetermined''
  6640. @item single.tff
  6641. Cumulative number of frames detected as top field first using single-frame detection.
  6642. @item multiple.tff
  6643. Cumulative number of frames detected as top field first using multiple-frame detection.
  6644. @item single.bff
  6645. Cumulative number of frames detected as bottom field first using single-frame detection.
  6646. @item multiple.current_frame
  6647. Detected type of current frame using multiple-frame detection. One of:
  6648. ``tff'' (top field first), ``bff'' (bottom field first),
  6649. ``progressive'', or ``undetermined''
  6650. @item multiple.bff
  6651. Cumulative number of frames detected as bottom field first using multiple-frame detection.
  6652. @item single.progressive
  6653. Cumulative number of frames detected as progressive using single-frame detection.
  6654. @item multiple.progressive
  6655. Cumulative number of frames detected as progressive using multiple-frame detection.
  6656. @item single.undetermined
  6657. Cumulative number of frames that could not be classified using single-frame detection.
  6658. @item multiple.undetermined
  6659. Cumulative number of frames that could not be classified using multiple-frame detection.
  6660. @item repeated.current_frame
  6661. Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
  6662. @item repeated.neither
  6663. Cumulative number of frames with no repeated field.
  6664. @item repeated.top
  6665. Cumulative number of frames with the top field repeated from the previous frame's top field.
  6666. @item repeated.bottom
  6667. Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
  6668. @end table
  6669. The filter accepts the following options:
  6670. @table @option
  6671. @item intl_thres
  6672. Set interlacing threshold.
  6673. @item prog_thres
  6674. Set progressive threshold.
  6675. @item rep_thres
  6676. Threshold for repeated field detection.
  6677. @item half_life
  6678. Number of frames after which a given frame's contribution to the
  6679. statistics is halved (i.e., it contributes only 0.5 to it's
  6680. classification). The default of 0 means that all frames seen are given
  6681. full weight of 1.0 forever.
  6682. @item analyze_interlaced_flag
  6683. When this is not 0 then idet will use the specified number of frames to determine
  6684. if the interlaced flag is accurate, it will not count undetermined frames.
  6685. If the flag is found to be accurate it will be used without any further
  6686. computations, if it is found to be inaccurate it will be cleared without any
  6687. further computations. This allows inserting the idet filter as a low computational
  6688. method to clean up the interlaced flag
  6689. @end table
  6690. @section il
  6691. Deinterleave or interleave fields.
  6692. This filter allows one to process interlaced images fields without
  6693. deinterlacing them. Deinterleaving splits the input frame into 2
  6694. fields (so called half pictures). Odd lines are moved to the top
  6695. half of the output image, even lines to the bottom half.
  6696. You can process (filter) them independently and then re-interleave them.
  6697. The filter accepts the following options:
  6698. @table @option
  6699. @item luma_mode, l
  6700. @item chroma_mode, c
  6701. @item alpha_mode, a
  6702. Available values for @var{luma_mode}, @var{chroma_mode} and
  6703. @var{alpha_mode} are:
  6704. @table @samp
  6705. @item none
  6706. Do nothing.
  6707. @item deinterleave, d
  6708. Deinterleave fields, placing one above the other.
  6709. @item interleave, i
  6710. Interleave fields. Reverse the effect of deinterleaving.
  6711. @end table
  6712. Default value is @code{none}.
  6713. @item luma_swap, ls
  6714. @item chroma_swap, cs
  6715. @item alpha_swap, as
  6716. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  6717. @end table
  6718. @section inflate
  6719. Apply inflate effect to the video.
  6720. This filter replaces the pixel by the local(3x3) average by taking into account
  6721. only values higher than the pixel.
  6722. It accepts the following options:
  6723. @table @option
  6724. @item threshold0
  6725. @item threshold1
  6726. @item threshold2
  6727. @item threshold3
  6728. Limit the maximum change for each plane, default is 65535.
  6729. If 0, plane will remain unchanged.
  6730. @end table
  6731. @section interlace
  6732. Simple interlacing filter from progressive contents. This interleaves upper (or
  6733. lower) lines from odd frames with lower (or upper) lines from even frames,
  6734. halving the frame rate and preserving image height.
  6735. @example
  6736. Original Original New Frame
  6737. Frame 'j' Frame 'j+1' (tff)
  6738. ========== =========== ==================
  6739. Line 0 --------------------> Frame 'j' Line 0
  6740. Line 1 Line 1 ----> Frame 'j+1' Line 1
  6741. Line 2 ---------------------> Frame 'j' Line 2
  6742. Line 3 Line 3 ----> Frame 'j+1' Line 3
  6743. ... ... ...
  6744. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  6745. @end example
  6746. It accepts the following optional parameters:
  6747. @table @option
  6748. @item scan
  6749. This determines whether the interlaced frame is taken from the even
  6750. (tff - default) or odd (bff) lines of the progressive frame.
  6751. @item lowpass
  6752. Enable (default) or disable the vertical lowpass filter to avoid twitter
  6753. interlacing and reduce moire patterns.
  6754. @end table
  6755. @section kerndeint
  6756. Deinterlace input video by applying Donald Graft's adaptive kernel
  6757. deinterling. Work on interlaced parts of a video to produce
  6758. progressive frames.
  6759. The description of the accepted parameters follows.
  6760. @table @option
  6761. @item thresh
  6762. Set the threshold which affects the filter's tolerance when
  6763. determining if a pixel line must be processed. It must be an integer
  6764. in the range [0,255] and defaults to 10. A value of 0 will result in
  6765. applying the process on every pixels.
  6766. @item map
  6767. Paint pixels exceeding the threshold value to white if set to 1.
  6768. Default is 0.
  6769. @item order
  6770. Set the fields order. Swap fields if set to 1, leave fields alone if
  6771. 0. Default is 0.
  6772. @item sharp
  6773. Enable additional sharpening if set to 1. Default is 0.
  6774. @item twoway
  6775. Enable twoway sharpening if set to 1. Default is 0.
  6776. @end table
  6777. @subsection Examples
  6778. @itemize
  6779. @item
  6780. Apply default values:
  6781. @example
  6782. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  6783. @end example
  6784. @item
  6785. Enable additional sharpening:
  6786. @example
  6787. kerndeint=sharp=1
  6788. @end example
  6789. @item
  6790. Paint processed pixels in white:
  6791. @example
  6792. kerndeint=map=1
  6793. @end example
  6794. @end itemize
  6795. @section lenscorrection
  6796. Correct radial lens distortion
  6797. This filter can be used to correct for radial distortion as can result from the use
  6798. of wide angle lenses, and thereby re-rectify the image. To find the right parameters
  6799. one can use tools available for example as part of opencv or simply trial-and-error.
  6800. To use opencv use the calibration sample (under samples/cpp) from the opencv sources
  6801. and extract the k1 and k2 coefficients from the resulting matrix.
  6802. Note that effectively the same filter is available in the open-source tools Krita and
  6803. Digikam from the KDE project.
  6804. In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
  6805. this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
  6806. brightness distribution, so you may want to use both filters together in certain
  6807. cases, though you will have to take care of ordering, i.e. whether vignetting should
  6808. be applied before or after lens correction.
  6809. @subsection Options
  6810. The filter accepts the following options:
  6811. @table @option
  6812. @item cx
  6813. Relative x-coordinate of the focal point of the image, and thereby the center of the
  6814. distortion. This value has a range [0,1] and is expressed as fractions of the image
  6815. width.
  6816. @item cy
  6817. Relative y-coordinate of the focal point of the image, and thereby the center of the
  6818. distortion. This value has a range [0,1] and is expressed as fractions of the image
  6819. height.
  6820. @item k1
  6821. Coefficient of the quadratic correction term. 0.5 means no correction.
  6822. @item k2
  6823. Coefficient of the double quadratic correction term. 0.5 means no correction.
  6824. @end table
  6825. The formula that generates the correction is:
  6826. @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)
  6827. where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
  6828. distances from the focal point in the source and target images, respectively.
  6829. @section loop, aloop
  6830. Loop video frames or audio samples.
  6831. Those filters accepts the following options:
  6832. @table @option
  6833. @item loop
  6834. Set the number of loops.
  6835. @item size
  6836. Set maximal size in number of frames for @code{loop} filter or maximal number
  6837. of samples in case of @code{aloop} filter.
  6838. @item start
  6839. Set first frame of loop for @code{loop} filter or first sample of loop in case
  6840. of @code{aloop} filter.
  6841. @end table
  6842. @anchor{lut3d}
  6843. @section lut3d
  6844. Apply a 3D LUT to an input video.
  6845. The filter accepts the following options:
  6846. @table @option
  6847. @item file
  6848. Set the 3D LUT file name.
  6849. Currently supported formats:
  6850. @table @samp
  6851. @item 3dl
  6852. AfterEffects
  6853. @item cube
  6854. Iridas
  6855. @item dat
  6856. DaVinci
  6857. @item m3d
  6858. Pandora
  6859. @end table
  6860. @item interp
  6861. Select interpolation mode.
  6862. Available values are:
  6863. @table @samp
  6864. @item nearest
  6865. Use values from the nearest defined point.
  6866. @item trilinear
  6867. Interpolate values using the 8 points defining a cube.
  6868. @item tetrahedral
  6869. Interpolate values using a tetrahedron.
  6870. @end table
  6871. @end table
  6872. @section lut, lutrgb, lutyuv
  6873. Compute a look-up table for binding each pixel component input value
  6874. to an output value, and apply it to the input video.
  6875. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  6876. to an RGB input video.
  6877. These filters accept the following parameters:
  6878. @table @option
  6879. @item c0
  6880. set first pixel component expression
  6881. @item c1
  6882. set second pixel component expression
  6883. @item c2
  6884. set third pixel component expression
  6885. @item c3
  6886. set fourth pixel component expression, corresponds to the alpha component
  6887. @item r
  6888. set red component expression
  6889. @item g
  6890. set green component expression
  6891. @item b
  6892. set blue component expression
  6893. @item a
  6894. alpha component expression
  6895. @item y
  6896. set Y/luminance component expression
  6897. @item u
  6898. set U/Cb component expression
  6899. @item v
  6900. set V/Cr component expression
  6901. @end table
  6902. Each of them specifies the expression to use for computing the lookup table for
  6903. the corresponding pixel component values.
  6904. The exact component associated to each of the @var{c*} options depends on the
  6905. format in input.
  6906. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  6907. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  6908. The expressions can contain the following constants and functions:
  6909. @table @option
  6910. @item w
  6911. @item h
  6912. The input width and height.
  6913. @item val
  6914. The input value for the pixel component.
  6915. @item clipval
  6916. The input value, clipped to the @var{minval}-@var{maxval} range.
  6917. @item maxval
  6918. The maximum value for the pixel component.
  6919. @item minval
  6920. The minimum value for the pixel component.
  6921. @item negval
  6922. The negated value for the pixel component value, clipped to the
  6923. @var{minval}-@var{maxval} range; it corresponds to the expression
  6924. "maxval-clipval+minval".
  6925. @item clip(val)
  6926. The computed value in @var{val}, clipped to the
  6927. @var{minval}-@var{maxval} range.
  6928. @item gammaval(gamma)
  6929. The computed gamma correction value of the pixel component value,
  6930. clipped to the @var{minval}-@var{maxval} range. It corresponds to the
  6931. expression
  6932. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  6933. @end table
  6934. All expressions default to "val".
  6935. @subsection Examples
  6936. @itemize
  6937. @item
  6938. Negate input video:
  6939. @example
  6940. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  6941. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  6942. @end example
  6943. The above is the same as:
  6944. @example
  6945. lutrgb="r=negval:g=negval:b=negval"
  6946. lutyuv="y=negval:u=negval:v=negval"
  6947. @end example
  6948. @item
  6949. Negate luminance:
  6950. @example
  6951. lutyuv=y=negval
  6952. @end example
  6953. @item
  6954. Remove chroma components, turning the video into a graytone image:
  6955. @example
  6956. lutyuv="u=128:v=128"
  6957. @end example
  6958. @item
  6959. Apply a luma burning effect:
  6960. @example
  6961. lutyuv="y=2*val"
  6962. @end example
  6963. @item
  6964. Remove green and blue components:
  6965. @example
  6966. lutrgb="g=0:b=0"
  6967. @end example
  6968. @item
  6969. Set a constant alpha channel value on input:
  6970. @example
  6971. format=rgba,lutrgb=a="maxval-minval/2"
  6972. @end example
  6973. @item
  6974. Correct luminance gamma by a factor of 0.5:
  6975. @example
  6976. lutyuv=y=gammaval(0.5)
  6977. @end example
  6978. @item
  6979. Discard least significant bits of luma:
  6980. @example
  6981. lutyuv=y='bitand(val, 128+64+32)'
  6982. @end example
  6983. @end itemize
  6984. @section maskedmerge
  6985. Merge the first input stream with the second input stream using per pixel
  6986. weights in the third input stream.
  6987. A value of 0 in the third stream pixel component means that pixel component
  6988. from first stream is returned unchanged, while maximum value (eg. 255 for
  6989. 8-bit videos) means that pixel component from second stream is returned
  6990. unchanged. Intermediate values define the amount of merging between both
  6991. input stream's pixel components.
  6992. This filter accepts the following options:
  6993. @table @option
  6994. @item planes
  6995. Set which planes will be processed as bitmap, unprocessed planes will be
  6996. copied from first stream.
  6997. By default value 0xf, all planes will be processed.
  6998. @end table
  6999. @section mcdeint
  7000. Apply motion-compensation deinterlacing.
  7001. It needs one field per frame as input and must thus be used together
  7002. with yadif=1/3 or equivalent.
  7003. This filter accepts the following options:
  7004. @table @option
  7005. @item mode
  7006. Set the deinterlacing mode.
  7007. It accepts one of the following values:
  7008. @table @samp
  7009. @item fast
  7010. @item medium
  7011. @item slow
  7012. use iterative motion estimation
  7013. @item extra_slow
  7014. like @samp{slow}, but use multiple reference frames.
  7015. @end table
  7016. Default value is @samp{fast}.
  7017. @item parity
  7018. Set the picture field parity assumed for the input video. It must be
  7019. one of the following values:
  7020. @table @samp
  7021. @item 0, tff
  7022. assume top field first
  7023. @item 1, bff
  7024. assume bottom field first
  7025. @end table
  7026. Default value is @samp{bff}.
  7027. @item qp
  7028. Set per-block quantization parameter (QP) used by the internal
  7029. encoder.
  7030. Higher values should result in a smoother motion vector field but less
  7031. optimal individual vectors. Default value is 1.
  7032. @end table
  7033. @section mergeplanes
  7034. Merge color channel components from several video streams.
  7035. The filter accepts up to 4 input streams, and merge selected input
  7036. planes to the output video.
  7037. This filter accepts the following options:
  7038. @table @option
  7039. @item mapping
  7040. Set input to output plane mapping. Default is @code{0}.
  7041. The mappings is specified as a bitmap. It should be specified as a
  7042. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  7043. mapping for the first plane of the output stream. 'A' sets the number of
  7044. the input stream to use (from 0 to 3), and 'a' the plane number of the
  7045. corresponding input to use (from 0 to 3). The rest of the mappings is
  7046. similar, 'Bb' describes the mapping for the output stream second
  7047. plane, 'Cc' describes the mapping for the output stream third plane and
  7048. 'Dd' describes the mapping for the output stream fourth plane.
  7049. @item format
  7050. Set output pixel format. Default is @code{yuva444p}.
  7051. @end table
  7052. @subsection Examples
  7053. @itemize
  7054. @item
  7055. Merge three gray video streams of same width and height into single video stream:
  7056. @example
  7057. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  7058. @end example
  7059. @item
  7060. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  7061. @example
  7062. [a0][a1]mergeplanes=0x00010210:yuva444p
  7063. @end example
  7064. @item
  7065. Swap Y and A plane in yuva444p stream:
  7066. @example
  7067. format=yuva444p,mergeplanes=0x03010200:yuva444p
  7068. @end example
  7069. @item
  7070. Swap U and V plane in yuv420p stream:
  7071. @example
  7072. format=yuv420p,mergeplanes=0x000201:yuv420p
  7073. @end example
  7074. @item
  7075. Cast a rgb24 clip to yuv444p:
  7076. @example
  7077. format=rgb24,mergeplanes=0x000102:yuv444p
  7078. @end example
  7079. @end itemize
  7080. @section metadata, ametadata
  7081. Manipulate frame metadata.
  7082. This filter accepts the following options:
  7083. @table @option
  7084. @item mode
  7085. Set mode of operation of the filter.
  7086. Can be one of the following:
  7087. @table @samp
  7088. @item select
  7089. If both @code{value} and @code{key} is set, select frames
  7090. which have such metadata. If only @code{key} is set, select
  7091. every frame that has such key in metadata.
  7092. @item add
  7093. Add new metadata @code{key} and @code{value}. If key is already available
  7094. do nothing.
  7095. @item modify
  7096. Modify value of already present key.
  7097. @item delete
  7098. If @code{value} is set, delete only keys that have such value.
  7099. Otherwise, delete key.
  7100. @item print
  7101. Print key and its value if metadata was found. If @code{key} is not set print all
  7102. metadata values available in frame.
  7103. @end table
  7104. @item key
  7105. Set key used with all modes. Must be set for all modes except @code{print}.
  7106. @item value
  7107. Set metadata value which will be used. This option is mandatory for
  7108. @code{modify} and @code{add} mode.
  7109. @item function
  7110. Which function to use when comparing metadata value and @code{value}.
  7111. Can be one of following:
  7112. @table @samp
  7113. @item same_str
  7114. Values are interpreted as strings, returns true if metadata value is same as @code{value}.
  7115. @item starts_with
  7116. Values are interpreted as strings, returns true if metadata value starts with
  7117. the @code{value} option string.
  7118. @item less
  7119. Values are interpreted as floats, returns true if metadata value is less than @code{value}.
  7120. @item equal
  7121. Values are interpreted as floats, returns true if @code{value} is equal with metadata value.
  7122. @item greater
  7123. Values are interpreted as floats, returns true if metadata value is greater than @code{value}.
  7124. @item expr
  7125. Values are interpreted as floats, returns true if expression from option @code{expr}
  7126. evaluates to true.
  7127. @end table
  7128. @item expr
  7129. Set expression which is used when @code{function} is set to @code{expr}.
  7130. The expression is evaluated through the eval API and can contain the following
  7131. constants:
  7132. @table @option
  7133. @item VALUE1
  7134. Float representation of @code{value} from metadata key.
  7135. @item VALUE2
  7136. Float representation of @code{value} as supplied by user in @code{value} option.
  7137. @end table
  7138. @item file
  7139. If specified in @code{print} mode, output is written to the named file. When
  7140. filename equals "-" data is written to standard output.
  7141. If @code{file} option is not set, output is written to the log with AV_LOG_INFO
  7142. loglevel.
  7143. @end table
  7144. @subsection Examples
  7145. @itemize
  7146. @item
  7147. Print all metadata values for frames with key @code{lavfi.singnalstats.YDIF} with values
  7148. between 0 and 1.
  7149. @example
  7150. @end example
  7151. signalstats,metadata=print:key=lavfi.signalstats.YDIF:value=0:function=expr:expr='between(VALUE1,0,1)'
  7152. @end itemize
  7153. @section mpdecimate
  7154. Drop frames that do not differ greatly from the previous frame in
  7155. order to reduce frame rate.
  7156. The main use of this filter is for very-low-bitrate encoding
  7157. (e.g. streaming over dialup modem), but it could in theory be used for
  7158. fixing movies that were inverse-telecined incorrectly.
  7159. A description of the accepted options follows.
  7160. @table @option
  7161. @item max
  7162. Set the maximum number of consecutive frames which can be dropped (if
  7163. positive), or the minimum interval between dropped frames (if
  7164. negative). If the value is 0, the frame is dropped unregarding the
  7165. number of previous sequentially dropped frames.
  7166. Default value is 0.
  7167. @item hi
  7168. @item lo
  7169. @item frac
  7170. Set the dropping threshold values.
  7171. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  7172. represent actual pixel value differences, so a threshold of 64
  7173. corresponds to 1 unit of difference for each pixel, or the same spread
  7174. out differently over the block.
  7175. A frame is a candidate for dropping if no 8x8 blocks differ by more
  7176. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  7177. meaning the whole image) differ by more than a threshold of @option{lo}.
  7178. Default value for @option{hi} is 64*12, default value for @option{lo} is
  7179. 64*5, and default value for @option{frac} is 0.33.
  7180. @end table
  7181. @section negate
  7182. Negate input video.
  7183. It accepts an integer in input; if non-zero it negates the
  7184. alpha component (if available). The default value in input is 0.
  7185. @section nnedi
  7186. Deinterlace video using neural network edge directed interpolation.
  7187. This filter accepts the following options:
  7188. @table @option
  7189. @item weights
  7190. Mandatory option, without binary file filter can not work.
  7191. Currently file can be found here:
  7192. https://github.com/dubhater/vapoursynth-nnedi3/blob/master/src/nnedi3_weights.bin
  7193. @item deint
  7194. Set which frames to deinterlace, by default it is @code{all}.
  7195. Can be @code{all} or @code{interlaced}.
  7196. @item field
  7197. Set mode of operation.
  7198. Can be one of the following:
  7199. @table @samp
  7200. @item af
  7201. Use frame flags, both fields.
  7202. @item a
  7203. Use frame flags, single field.
  7204. @item t
  7205. Use top field only.
  7206. @item b
  7207. Use bottom field only.
  7208. @item tf
  7209. Use both fields, top first.
  7210. @item bf
  7211. Use both fields, bottom first.
  7212. @end table
  7213. @item planes
  7214. Set which planes to process, by default filter process all frames.
  7215. @item nsize
  7216. Set size of local neighborhood around each pixel, used by the predictor neural
  7217. network.
  7218. Can be one of the following:
  7219. @table @samp
  7220. @item s8x6
  7221. @item s16x6
  7222. @item s32x6
  7223. @item s48x6
  7224. @item s8x4
  7225. @item s16x4
  7226. @item s32x4
  7227. @end table
  7228. @item nns
  7229. Set the number of neurons in predicctor neural network.
  7230. Can be one of the following:
  7231. @table @samp
  7232. @item n16
  7233. @item n32
  7234. @item n64
  7235. @item n128
  7236. @item n256
  7237. @end table
  7238. @item qual
  7239. Controls the number of different neural network predictions that are blended
  7240. together to compute the final output value. Can be @code{fast}, default or
  7241. @code{slow}.
  7242. @item etype
  7243. Set which set of weights to use in the predictor.
  7244. Can be one of the following:
  7245. @table @samp
  7246. @item a
  7247. weights trained to minimize absolute error
  7248. @item s
  7249. weights trained to minimize squared error
  7250. @end table
  7251. @item pscrn
  7252. Controls whether or not the prescreener neural network is used to decide
  7253. which pixels should be processed by the predictor neural network and which
  7254. can be handled by simple cubic interpolation.
  7255. The prescreener is trained to know whether cubic interpolation will be
  7256. sufficient for a pixel or whether it should be predicted by the predictor nn.
  7257. The computational complexity of the prescreener nn is much less than that of
  7258. the predictor nn. Since most pixels can be handled by cubic interpolation,
  7259. using the prescreener generally results in much faster processing.
  7260. The prescreener is pretty accurate, so the difference between using it and not
  7261. using it is almost always unnoticeable.
  7262. Can be one of the following:
  7263. @table @samp
  7264. @item none
  7265. @item original
  7266. @item new
  7267. @end table
  7268. Default is @code{new}.
  7269. @item fapprox
  7270. Set various debugging flags.
  7271. @end table
  7272. @section noformat
  7273. Force libavfilter not to use any of the specified pixel formats for the
  7274. input to the next filter.
  7275. It accepts the following parameters:
  7276. @table @option
  7277. @item pix_fmts
  7278. A '|'-separated list of pixel format names, such as
  7279. apix_fmts=yuv420p|monow|rgb24".
  7280. @end table
  7281. @subsection Examples
  7282. @itemize
  7283. @item
  7284. Force libavfilter to use a format different from @var{yuv420p} for the
  7285. input to the vflip filter:
  7286. @example
  7287. noformat=pix_fmts=yuv420p,vflip
  7288. @end example
  7289. @item
  7290. Convert the input video to any of the formats not contained in the list:
  7291. @example
  7292. noformat=yuv420p|yuv444p|yuv410p
  7293. @end example
  7294. @end itemize
  7295. @section noise
  7296. Add noise on video input frame.
  7297. The filter accepts the following options:
  7298. @table @option
  7299. @item all_seed
  7300. @item c0_seed
  7301. @item c1_seed
  7302. @item c2_seed
  7303. @item c3_seed
  7304. Set noise seed for specific pixel component or all pixel components in case
  7305. of @var{all_seed}. Default value is @code{123457}.
  7306. @item all_strength, alls
  7307. @item c0_strength, c0s
  7308. @item c1_strength, c1s
  7309. @item c2_strength, c2s
  7310. @item c3_strength, c3s
  7311. Set noise strength for specific pixel component or all pixel components in case
  7312. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  7313. @item all_flags, allf
  7314. @item c0_flags, c0f
  7315. @item c1_flags, c1f
  7316. @item c2_flags, c2f
  7317. @item c3_flags, c3f
  7318. Set pixel component flags or set flags for all components if @var{all_flags}.
  7319. Available values for component flags are:
  7320. @table @samp
  7321. @item a
  7322. averaged temporal noise (smoother)
  7323. @item p
  7324. mix random noise with a (semi)regular pattern
  7325. @item t
  7326. temporal noise (noise pattern changes between frames)
  7327. @item u
  7328. uniform noise (gaussian otherwise)
  7329. @end table
  7330. @end table
  7331. @subsection Examples
  7332. Add temporal and uniform noise to input video:
  7333. @example
  7334. noise=alls=20:allf=t+u
  7335. @end example
  7336. @section null
  7337. Pass the video source unchanged to the output.
  7338. @section ocr
  7339. Optical Character Recognition
  7340. This filter uses Tesseract for optical character recognition.
  7341. It accepts the following options:
  7342. @table @option
  7343. @item datapath
  7344. Set datapath to tesseract data. Default is to use whatever was
  7345. set at installation.
  7346. @item language
  7347. Set language, default is "eng".
  7348. @item whitelist
  7349. Set character whitelist.
  7350. @item blacklist
  7351. Set character blacklist.
  7352. @end table
  7353. The filter exports recognized text as the frame metadata @code{lavfi.ocr.text}.
  7354. @section ocv
  7355. Apply a video transform using libopencv.
  7356. To enable this filter, install the libopencv library and headers and
  7357. configure FFmpeg with @code{--enable-libopencv}.
  7358. It accepts the following parameters:
  7359. @table @option
  7360. @item filter_name
  7361. The name of the libopencv filter to apply.
  7362. @item filter_params
  7363. The parameters to pass to the libopencv filter. If not specified, the default
  7364. values are assumed.
  7365. @end table
  7366. Refer to the official libopencv documentation for more precise
  7367. information:
  7368. @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
  7369. Several libopencv filters are supported; see the following subsections.
  7370. @anchor{dilate}
  7371. @subsection dilate
  7372. Dilate an image by using a specific structuring element.
  7373. It corresponds to the libopencv function @code{cvDilate}.
  7374. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  7375. @var{struct_el} represents a structuring element, and has the syntax:
  7376. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  7377. @var{cols} and @var{rows} represent the number of columns and rows of
  7378. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  7379. point, and @var{shape} the shape for the structuring element. @var{shape}
  7380. must be "rect", "cross", "ellipse", or "custom".
  7381. If the value for @var{shape} is "custom", it must be followed by a
  7382. string of the form "=@var{filename}". The file with name
  7383. @var{filename} is assumed to represent a binary image, with each
  7384. printable character corresponding to a bright pixel. When a custom
  7385. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  7386. or columns and rows of the read file are assumed instead.
  7387. The default value for @var{struct_el} is "3x3+0x0/rect".
  7388. @var{nb_iterations} specifies the number of times the transform is
  7389. applied to the image, and defaults to 1.
  7390. Some examples:
  7391. @example
  7392. # Use the default values
  7393. ocv=dilate
  7394. # Dilate using a structuring element with a 5x5 cross, iterating two times
  7395. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  7396. # Read the shape from the file diamond.shape, iterating two times.
  7397. # The file diamond.shape may contain a pattern of characters like this
  7398. # *
  7399. # ***
  7400. # *****
  7401. # ***
  7402. # *
  7403. # The specified columns and rows are ignored
  7404. # but the anchor point coordinates are not
  7405. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  7406. @end example
  7407. @subsection erode
  7408. Erode an image by using a specific structuring element.
  7409. It corresponds to the libopencv function @code{cvErode}.
  7410. It accepts the parameters: @var{struct_el}:@var{nb_iterations},
  7411. with the same syntax and semantics as the @ref{dilate} filter.
  7412. @subsection smooth
  7413. Smooth the input video.
  7414. The filter takes the following parameters:
  7415. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  7416. @var{type} is the type of smooth filter to apply, and must be one of
  7417. the following values: "blur", "blur_no_scale", "median", "gaussian",
  7418. or "bilateral". The default value is "gaussian".
  7419. The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
  7420. depend on the smooth type. @var{param1} and
  7421. @var{param2} accept integer positive values or 0. @var{param3} and
  7422. @var{param4} accept floating point values.
  7423. The default value for @var{param1} is 3. The default value for the
  7424. other parameters is 0.
  7425. These parameters correspond to the parameters assigned to the
  7426. libopencv function @code{cvSmooth}.
  7427. @anchor{overlay}
  7428. @section overlay
  7429. Overlay one video on top of another.
  7430. It takes two inputs and has one output. The first input is the "main"
  7431. video on which the second input is overlaid.
  7432. It accepts the following parameters:
  7433. A description of the accepted options follows.
  7434. @table @option
  7435. @item x
  7436. @item y
  7437. Set the expression for the x and y coordinates of the overlaid video
  7438. on the main video. Default value is "0" for both expressions. In case
  7439. the expression is invalid, it is set to a huge value (meaning that the
  7440. overlay will not be displayed within the output visible area).
  7441. @item eof_action
  7442. The action to take when EOF is encountered on the secondary input; it accepts
  7443. one of the following values:
  7444. @table @option
  7445. @item repeat
  7446. Repeat the last frame (the default).
  7447. @item endall
  7448. End both streams.
  7449. @item pass
  7450. Pass the main input through.
  7451. @end table
  7452. @item eval
  7453. Set when the expressions for @option{x}, and @option{y} are evaluated.
  7454. It accepts the following values:
  7455. @table @samp
  7456. @item init
  7457. only evaluate expressions once during the filter initialization or
  7458. when a command is processed
  7459. @item frame
  7460. evaluate expressions for each incoming frame
  7461. @end table
  7462. Default value is @samp{frame}.
  7463. @item shortest
  7464. If set to 1, force the output to terminate when the shortest input
  7465. terminates. Default value is 0.
  7466. @item format
  7467. Set the format for the output video.
  7468. It accepts the following values:
  7469. @table @samp
  7470. @item yuv420
  7471. force YUV420 output
  7472. @item yuv422
  7473. force YUV422 output
  7474. @item yuv444
  7475. force YUV444 output
  7476. @item rgb
  7477. force RGB output
  7478. @end table
  7479. Default value is @samp{yuv420}.
  7480. @item rgb @emph{(deprecated)}
  7481. If set to 1, force the filter to accept inputs in the RGB
  7482. color space. Default value is 0. This option is deprecated, use
  7483. @option{format} instead.
  7484. @item repeatlast
  7485. If set to 1, force the filter to draw the last overlay frame over the
  7486. main input until the end of the stream. A value of 0 disables this
  7487. behavior. Default value is 1.
  7488. @end table
  7489. The @option{x}, and @option{y} expressions can contain the following
  7490. parameters.
  7491. @table @option
  7492. @item main_w, W
  7493. @item main_h, H
  7494. The main input width and height.
  7495. @item overlay_w, w
  7496. @item overlay_h, h
  7497. The overlay input width and height.
  7498. @item x
  7499. @item y
  7500. The computed values for @var{x} and @var{y}. They are evaluated for
  7501. each new frame.
  7502. @item hsub
  7503. @item vsub
  7504. horizontal and vertical chroma subsample values of the output
  7505. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  7506. @var{vsub} is 1.
  7507. @item n
  7508. the number of input frame, starting from 0
  7509. @item pos
  7510. the position in the file of the input frame, NAN if unknown
  7511. @item t
  7512. The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
  7513. @end table
  7514. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  7515. when evaluation is done @emph{per frame}, and will evaluate to NAN
  7516. when @option{eval} is set to @samp{init}.
  7517. Be aware that frames are taken from each input video in timestamp
  7518. order, hence, if their initial timestamps differ, it is a good idea
  7519. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  7520. have them begin in the same zero timestamp, as the example for
  7521. the @var{movie} filter does.
  7522. You can chain together more overlays but you should test the
  7523. efficiency of such approach.
  7524. @subsection Commands
  7525. This filter supports the following commands:
  7526. @table @option
  7527. @item x
  7528. @item y
  7529. Modify the x and y of the overlay input.
  7530. The command accepts the same syntax of the corresponding option.
  7531. If the specified expression is not valid, it is kept at its current
  7532. value.
  7533. @end table
  7534. @subsection Examples
  7535. @itemize
  7536. @item
  7537. Draw the overlay at 10 pixels from the bottom right corner of the main
  7538. video:
  7539. @example
  7540. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  7541. @end example
  7542. Using named options the example above becomes:
  7543. @example
  7544. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  7545. @end example
  7546. @item
  7547. Insert a transparent PNG logo in the bottom left corner of the input,
  7548. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  7549. @example
  7550. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  7551. @end example
  7552. @item
  7553. Insert 2 different transparent PNG logos (second logo on bottom
  7554. right corner) using the @command{ffmpeg} tool:
  7555. @example
  7556. 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
  7557. @end example
  7558. @item
  7559. Add a transparent color layer on top of the main video; @code{WxH}
  7560. must specify the size of the main input to the overlay filter:
  7561. @example
  7562. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  7563. @end example
  7564. @item
  7565. Play an original video and a filtered version (here with the deshake
  7566. filter) side by side using the @command{ffplay} tool:
  7567. @example
  7568. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  7569. @end example
  7570. The above command is the same as:
  7571. @example
  7572. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  7573. @end example
  7574. @item
  7575. Make a sliding overlay appearing from the left to the right top part of the
  7576. screen starting since time 2:
  7577. @example
  7578. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  7579. @end example
  7580. @item
  7581. Compose output by putting two input videos side to side:
  7582. @example
  7583. ffmpeg -i left.avi -i right.avi -filter_complex "
  7584. nullsrc=size=200x100 [background];
  7585. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  7586. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  7587. [background][left] overlay=shortest=1 [background+left];
  7588. [background+left][right] overlay=shortest=1:x=100 [left+right]
  7589. "
  7590. @end example
  7591. @item
  7592. Mask 10-20 seconds of a video by applying the delogo filter to a section
  7593. @example
  7594. ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
  7595. -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]'
  7596. masked.avi
  7597. @end example
  7598. @item
  7599. Chain several overlays in cascade:
  7600. @example
  7601. nullsrc=s=200x200 [bg];
  7602. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  7603. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  7604. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  7605. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  7606. [in3] null, [mid2] overlay=100:100 [out0]
  7607. @end example
  7608. @end itemize
  7609. @section owdenoise
  7610. Apply Overcomplete Wavelet denoiser.
  7611. The filter accepts the following options:
  7612. @table @option
  7613. @item depth
  7614. Set depth.
  7615. Larger depth values will denoise lower frequency components more, but
  7616. slow down filtering.
  7617. Must be an int in the range 8-16, default is @code{8}.
  7618. @item luma_strength, ls
  7619. Set luma strength.
  7620. Must be a double value in the range 0-1000, default is @code{1.0}.
  7621. @item chroma_strength, cs
  7622. Set chroma strength.
  7623. Must be a double value in the range 0-1000, default is @code{1.0}.
  7624. @end table
  7625. @anchor{pad}
  7626. @section pad
  7627. Add paddings to the input image, and place the original input at the
  7628. provided @var{x}, @var{y} coordinates.
  7629. It accepts the following parameters:
  7630. @table @option
  7631. @item width, w
  7632. @item height, h
  7633. Specify an expression for the size of the output image with the
  7634. paddings added. If the value for @var{width} or @var{height} is 0, the
  7635. corresponding input size is used for the output.
  7636. The @var{width} expression can reference the value set by the
  7637. @var{height} expression, and vice versa.
  7638. The default value of @var{width} and @var{height} is 0.
  7639. @item x
  7640. @item y
  7641. Specify the offsets to place the input image at within the padded area,
  7642. with respect to the top/left border of the output image.
  7643. The @var{x} expression can reference the value set by the @var{y}
  7644. expression, and vice versa.
  7645. The default value of @var{x} and @var{y} is 0.
  7646. @item color
  7647. Specify the color of the padded area. For the syntax of this option,
  7648. check the "Color" section in the ffmpeg-utils manual.
  7649. The default value of @var{color} is "black".
  7650. @end table
  7651. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  7652. options are expressions containing the following constants:
  7653. @table @option
  7654. @item in_w
  7655. @item in_h
  7656. The input video width and height.
  7657. @item iw
  7658. @item ih
  7659. These are the same as @var{in_w} and @var{in_h}.
  7660. @item out_w
  7661. @item out_h
  7662. The output width and height (the size of the padded area), as
  7663. specified by the @var{width} and @var{height} expressions.
  7664. @item ow
  7665. @item oh
  7666. These are the same as @var{out_w} and @var{out_h}.
  7667. @item x
  7668. @item y
  7669. The x and y offsets as specified by the @var{x} and @var{y}
  7670. expressions, or NAN if not yet specified.
  7671. @item a
  7672. same as @var{iw} / @var{ih}
  7673. @item sar
  7674. input sample aspect ratio
  7675. @item dar
  7676. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  7677. @item hsub
  7678. @item vsub
  7679. The horizontal and vertical chroma subsample values. For example for the
  7680. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7681. @end table
  7682. @subsection Examples
  7683. @itemize
  7684. @item
  7685. Add paddings with the color "violet" to the input video. The output video
  7686. size is 640x480, and the top-left corner of the input video is placed at
  7687. column 0, row 40
  7688. @example
  7689. pad=640:480:0:40:violet
  7690. @end example
  7691. The example above is equivalent to the following command:
  7692. @example
  7693. pad=width=640:height=480:x=0:y=40:color=violet
  7694. @end example
  7695. @item
  7696. Pad the input to get an output with dimensions increased by 3/2,
  7697. and put the input video at the center of the padded area:
  7698. @example
  7699. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  7700. @end example
  7701. @item
  7702. Pad the input to get a squared output with size equal to the maximum
  7703. value between the input width and height, and put the input video at
  7704. the center of the padded area:
  7705. @example
  7706. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  7707. @end example
  7708. @item
  7709. Pad the input to get a final w/h ratio of 16:9:
  7710. @example
  7711. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  7712. @end example
  7713. @item
  7714. In case of anamorphic video, in order to set the output display aspect
  7715. correctly, it is necessary to use @var{sar} in the expression,
  7716. according to the relation:
  7717. @example
  7718. (ih * X / ih) * sar = output_dar
  7719. X = output_dar / sar
  7720. @end example
  7721. Thus the previous example needs to be modified to:
  7722. @example
  7723. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  7724. @end example
  7725. @item
  7726. Double the output size and put the input video in the bottom-right
  7727. corner of the output padded area:
  7728. @example
  7729. pad="2*iw:2*ih:ow-iw:oh-ih"
  7730. @end example
  7731. @end itemize
  7732. @anchor{palettegen}
  7733. @section palettegen
  7734. Generate one palette for a whole video stream.
  7735. It accepts the following options:
  7736. @table @option
  7737. @item max_colors
  7738. Set the maximum number of colors to quantize in the palette.
  7739. Note: the palette will still contain 256 colors; the unused palette entries
  7740. will be black.
  7741. @item reserve_transparent
  7742. Create a palette of 255 colors maximum and reserve the last one for
  7743. transparency. Reserving the transparency color is useful for GIF optimization.
  7744. If not set, the maximum of colors in the palette will be 256. You probably want
  7745. to disable this option for a standalone image.
  7746. Set by default.
  7747. @item stats_mode
  7748. Set statistics mode.
  7749. It accepts the following values:
  7750. @table @samp
  7751. @item full
  7752. Compute full frame histograms.
  7753. @item diff
  7754. Compute histograms only for the part that differs from previous frame. This
  7755. might be relevant to give more importance to the moving part of your input if
  7756. the background is static.
  7757. @end table
  7758. Default value is @var{full}.
  7759. @end table
  7760. The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
  7761. (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
  7762. color quantization of the palette. This information is also visible at
  7763. @var{info} logging level.
  7764. @subsection Examples
  7765. @itemize
  7766. @item
  7767. Generate a representative palette of a given video using @command{ffmpeg}:
  7768. @example
  7769. ffmpeg -i input.mkv -vf palettegen palette.png
  7770. @end example
  7771. @end itemize
  7772. @section paletteuse
  7773. Use a palette to downsample an input video stream.
  7774. The filter takes two inputs: one video stream and a palette. The palette must
  7775. be a 256 pixels image.
  7776. It accepts the following options:
  7777. @table @option
  7778. @item dither
  7779. Select dithering mode. Available algorithms are:
  7780. @table @samp
  7781. @item bayer
  7782. Ordered 8x8 bayer dithering (deterministic)
  7783. @item heckbert
  7784. Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
  7785. Note: this dithering is sometimes considered "wrong" and is included as a
  7786. reference.
  7787. @item floyd_steinberg
  7788. Floyd and Steingberg dithering (error diffusion)
  7789. @item sierra2
  7790. Frankie Sierra dithering v2 (error diffusion)
  7791. @item sierra2_4a
  7792. Frankie Sierra dithering v2 "Lite" (error diffusion)
  7793. @end table
  7794. Default is @var{sierra2_4a}.
  7795. @item bayer_scale
  7796. When @var{bayer} dithering is selected, this option defines the scale of the
  7797. pattern (how much the crosshatch pattern is visible). A low value means more
  7798. visible pattern for less banding, and higher value means less visible pattern
  7799. at the cost of more banding.
  7800. The option must be an integer value in the range [0,5]. Default is @var{2}.
  7801. @item diff_mode
  7802. If set, define the zone to process
  7803. @table @samp
  7804. @item rectangle
  7805. Only the changing rectangle will be reprocessed. This is similar to GIF
  7806. cropping/offsetting compression mechanism. This option can be useful for speed
  7807. if only a part of the image is changing, and has use cases such as limiting the
  7808. scope of the error diffusal @option{dither} to the rectangle that bounds the
  7809. moving scene (it leads to more deterministic output if the scene doesn't change
  7810. much, and as a result less moving noise and better GIF compression).
  7811. @end table
  7812. Default is @var{none}.
  7813. @end table
  7814. @subsection Examples
  7815. @itemize
  7816. @item
  7817. Use a palette (generated for example with @ref{palettegen}) to encode a GIF
  7818. using @command{ffmpeg}:
  7819. @example
  7820. ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
  7821. @end example
  7822. @end itemize
  7823. @section perspective
  7824. Correct perspective of video not recorded perpendicular to the screen.
  7825. A description of the accepted parameters follows.
  7826. @table @option
  7827. @item x0
  7828. @item y0
  7829. @item x1
  7830. @item y1
  7831. @item x2
  7832. @item y2
  7833. @item x3
  7834. @item y3
  7835. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  7836. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  7837. If the @code{sense} option is set to @code{source}, then the specified points will be sent
  7838. to the corners of the destination. If the @code{sense} option is set to @code{destination},
  7839. then the corners of the source will be sent to the specified coordinates.
  7840. The expressions can use the following variables:
  7841. @table @option
  7842. @item W
  7843. @item H
  7844. the width and height of video frame.
  7845. @item in
  7846. Input frame count.
  7847. @item on
  7848. Output frame count.
  7849. @end table
  7850. @item interpolation
  7851. Set interpolation for perspective correction.
  7852. It accepts the following values:
  7853. @table @samp
  7854. @item linear
  7855. @item cubic
  7856. @end table
  7857. Default value is @samp{linear}.
  7858. @item sense
  7859. Set interpretation of coordinate options.
  7860. It accepts the following values:
  7861. @table @samp
  7862. @item 0, source
  7863. Send point in the source specified by the given coordinates to
  7864. the corners of the destination.
  7865. @item 1, destination
  7866. Send the corners of the source to the point in the destination specified
  7867. by the given coordinates.
  7868. Default value is @samp{source}.
  7869. @end table
  7870. @item eval
  7871. Set when the expressions for coordinates @option{x0,y0,...x3,y3} are evaluated.
  7872. It accepts the following values:
  7873. @table @samp
  7874. @item init
  7875. only evaluate expressions once during the filter initialization or
  7876. when a command is processed
  7877. @item frame
  7878. evaluate expressions for each incoming frame
  7879. @end table
  7880. Default value is @samp{init}.
  7881. @end table
  7882. @section phase
  7883. Delay interlaced video by one field time so that the field order changes.
  7884. The intended use is to fix PAL movies that have been captured with the
  7885. opposite field order to the film-to-video transfer.
  7886. A description of the accepted parameters follows.
  7887. @table @option
  7888. @item mode
  7889. Set phase mode.
  7890. It accepts the following values:
  7891. @table @samp
  7892. @item t
  7893. Capture field order top-first, transfer bottom-first.
  7894. Filter will delay the bottom field.
  7895. @item b
  7896. Capture field order bottom-first, transfer top-first.
  7897. Filter will delay the top field.
  7898. @item p
  7899. Capture and transfer with the same field order. This mode only exists
  7900. for the documentation of the other options to refer to, but if you
  7901. actually select it, the filter will faithfully do nothing.
  7902. @item a
  7903. Capture field order determined automatically by field flags, transfer
  7904. opposite.
  7905. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  7906. basis using field flags. If no field information is available,
  7907. then this works just like @samp{u}.
  7908. @item u
  7909. Capture unknown or varying, transfer opposite.
  7910. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  7911. analyzing the images and selecting the alternative that produces best
  7912. match between the fields.
  7913. @item T
  7914. Capture top-first, transfer unknown or varying.
  7915. Filter selects among @samp{t} and @samp{p} using image analysis.
  7916. @item B
  7917. Capture bottom-first, transfer unknown or varying.
  7918. Filter selects among @samp{b} and @samp{p} using image analysis.
  7919. @item A
  7920. Capture determined by field flags, transfer unknown or varying.
  7921. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  7922. image analysis. If no field information is available, then this works just
  7923. like @samp{U}. This is the default mode.
  7924. @item U
  7925. Both capture and transfer unknown or varying.
  7926. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  7927. @end table
  7928. @end table
  7929. @section pixdesctest
  7930. Pixel format descriptor test filter, mainly useful for internal
  7931. testing. The output video should be equal to the input video.
  7932. For example:
  7933. @example
  7934. format=monow, pixdesctest
  7935. @end example
  7936. can be used to test the monowhite pixel format descriptor definition.
  7937. @section pp
  7938. Enable the specified chain of postprocessing subfilters using libpostproc. This
  7939. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  7940. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  7941. Each subfilter and some options have a short and a long name that can be used
  7942. interchangeably, i.e. dr/dering are the same.
  7943. The filters accept the following options:
  7944. @table @option
  7945. @item subfilters
  7946. Set postprocessing subfilters string.
  7947. @end table
  7948. All subfilters share common options to determine their scope:
  7949. @table @option
  7950. @item a/autoq
  7951. Honor the quality commands for this subfilter.
  7952. @item c/chrom
  7953. Do chrominance filtering, too (default).
  7954. @item y/nochrom
  7955. Do luminance filtering only (no chrominance).
  7956. @item n/noluma
  7957. Do chrominance filtering only (no luminance).
  7958. @end table
  7959. These options can be appended after the subfilter name, separated by a '|'.
  7960. Available subfilters are:
  7961. @table @option
  7962. @item hb/hdeblock[|difference[|flatness]]
  7963. Horizontal deblocking filter
  7964. @table @option
  7965. @item difference
  7966. Difference factor where higher values mean more deblocking (default: @code{32}).
  7967. @item flatness
  7968. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7969. @end table
  7970. @item vb/vdeblock[|difference[|flatness]]
  7971. Vertical deblocking filter
  7972. @table @option
  7973. @item difference
  7974. Difference factor where higher values mean more deblocking (default: @code{32}).
  7975. @item flatness
  7976. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7977. @end table
  7978. @item ha/hadeblock[|difference[|flatness]]
  7979. Accurate horizontal deblocking filter
  7980. @table @option
  7981. @item difference
  7982. Difference factor where higher values mean more deblocking (default: @code{32}).
  7983. @item flatness
  7984. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7985. @end table
  7986. @item va/vadeblock[|difference[|flatness]]
  7987. Accurate vertical deblocking filter
  7988. @table @option
  7989. @item difference
  7990. Difference factor where higher values mean more deblocking (default: @code{32}).
  7991. @item flatness
  7992. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  7993. @end table
  7994. @end table
  7995. The horizontal and vertical deblocking filters share the difference and
  7996. flatness values so you cannot set different horizontal and vertical
  7997. thresholds.
  7998. @table @option
  7999. @item h1/x1hdeblock
  8000. Experimental horizontal deblocking filter
  8001. @item v1/x1vdeblock
  8002. Experimental vertical deblocking filter
  8003. @item dr/dering
  8004. Deringing filter
  8005. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  8006. @table @option
  8007. @item threshold1
  8008. larger -> stronger filtering
  8009. @item threshold2
  8010. larger -> stronger filtering
  8011. @item threshold3
  8012. larger -> stronger filtering
  8013. @end table
  8014. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  8015. @table @option
  8016. @item f/fullyrange
  8017. Stretch luminance to @code{0-255}.
  8018. @end table
  8019. @item lb/linblenddeint
  8020. Linear blend deinterlacing filter that deinterlaces the given block by
  8021. filtering all lines with a @code{(1 2 1)} filter.
  8022. @item li/linipoldeint
  8023. Linear interpolating deinterlacing filter that deinterlaces the given block by
  8024. linearly interpolating every second line.
  8025. @item ci/cubicipoldeint
  8026. Cubic interpolating deinterlacing filter deinterlaces the given block by
  8027. cubically interpolating every second line.
  8028. @item md/mediandeint
  8029. Median deinterlacing filter that deinterlaces the given block by applying a
  8030. median filter to every second line.
  8031. @item fd/ffmpegdeint
  8032. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  8033. second line with a @code{(-1 4 2 4 -1)} filter.
  8034. @item l5/lowpass5
  8035. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  8036. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  8037. @item fq/forceQuant[|quantizer]
  8038. Overrides the quantizer table from the input with the constant quantizer you
  8039. specify.
  8040. @table @option
  8041. @item quantizer
  8042. Quantizer to use
  8043. @end table
  8044. @item de/default
  8045. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  8046. @item fa/fast
  8047. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  8048. @item ac
  8049. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  8050. @end table
  8051. @subsection Examples
  8052. @itemize
  8053. @item
  8054. Apply horizontal and vertical deblocking, deringing and automatic
  8055. brightness/contrast:
  8056. @example
  8057. pp=hb/vb/dr/al
  8058. @end example
  8059. @item
  8060. Apply default filters without brightness/contrast correction:
  8061. @example
  8062. pp=de/-al
  8063. @end example
  8064. @item
  8065. Apply default filters and temporal denoiser:
  8066. @example
  8067. pp=default/tmpnoise|1|2|3
  8068. @end example
  8069. @item
  8070. Apply deblocking on luminance only, and switch vertical deblocking on or off
  8071. automatically depending on available CPU time:
  8072. @example
  8073. pp=hb|y/vb|a
  8074. @end example
  8075. @end itemize
  8076. @section pp7
  8077. Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
  8078. similar to spp = 6 with 7 point DCT, where only the center sample is
  8079. used after IDCT.
  8080. The filter accepts the following options:
  8081. @table @option
  8082. @item qp
  8083. Force a constant quantization parameter. It accepts an integer in range
  8084. 0 to 63. If not set, the filter will use the QP from the video stream
  8085. (if available).
  8086. @item mode
  8087. Set thresholding mode. Available modes are:
  8088. @table @samp
  8089. @item hard
  8090. Set hard thresholding.
  8091. @item soft
  8092. Set soft thresholding (better de-ringing effect, but likely blurrier).
  8093. @item medium
  8094. Set medium thresholding (good results, default).
  8095. @end table
  8096. @end table
  8097. @section psnr
  8098. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  8099. Ratio) between two input videos.
  8100. This filter takes in input two input videos, the first input is
  8101. considered the "main" source and is passed unchanged to the
  8102. output. The second input is used as a "reference" video for computing
  8103. the PSNR.
  8104. Both video inputs must have the same resolution and pixel format for
  8105. this filter to work correctly. Also it assumes that both inputs
  8106. have the same number of frames, which are compared one by one.
  8107. The obtained average PSNR is printed through the logging system.
  8108. The filter stores the accumulated MSE (mean squared error) of each
  8109. frame, and at the end of the processing it is averaged across all frames
  8110. equally, and the following formula is applied to obtain the PSNR:
  8111. @example
  8112. PSNR = 10*log10(MAX^2/MSE)
  8113. @end example
  8114. Where MAX is the average of the maximum values of each component of the
  8115. image.
  8116. The description of the accepted parameters follows.
  8117. @table @option
  8118. @item stats_file, f
  8119. If specified the filter will use the named file to save the PSNR of
  8120. each individual frame. When filename equals "-" the data is sent to
  8121. standard output.
  8122. @end table
  8123. The file printed if @var{stats_file} is selected, contains a sequence of
  8124. key/value pairs of the form @var{key}:@var{value} for each compared
  8125. couple of frames.
  8126. A description of each shown parameter follows:
  8127. @table @option
  8128. @item n
  8129. sequential number of the input frame, starting from 1
  8130. @item mse_avg
  8131. Mean Square Error pixel-by-pixel average difference of the compared
  8132. frames, averaged over all the image components.
  8133. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  8134. Mean Square Error pixel-by-pixel average difference of the compared
  8135. frames for the component specified by the suffix.
  8136. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  8137. Peak Signal to Noise ratio of the compared frames for the component
  8138. specified by the suffix.
  8139. @end table
  8140. For example:
  8141. @example
  8142. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  8143. [main][ref] psnr="stats_file=stats.log" [out]
  8144. @end example
  8145. On this example the input file being processed is compared with the
  8146. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  8147. is stored in @file{stats.log}.
  8148. @anchor{pullup}
  8149. @section pullup
  8150. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  8151. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  8152. content.
  8153. The pullup filter is designed to take advantage of future context in making
  8154. its decisions. This filter is stateless in the sense that it does not lock
  8155. onto a pattern to follow, but it instead looks forward to the following
  8156. fields in order to identify matches and rebuild progressive frames.
  8157. To produce content with an even framerate, insert the fps filter after
  8158. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  8159. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  8160. The filter accepts the following options:
  8161. @table @option
  8162. @item jl
  8163. @item jr
  8164. @item jt
  8165. @item jb
  8166. These options set the amount of "junk" to ignore at the left, right, top, and
  8167. bottom of the image, respectively. Left and right are in units of 8 pixels,
  8168. while top and bottom are in units of 2 lines.
  8169. The default is 8 pixels on each side.
  8170. @item sb
  8171. Set the strict breaks. Setting this option to 1 will reduce the chances of
  8172. filter generating an occasional mismatched frame, but it may also cause an
  8173. excessive number of frames to be dropped during high motion sequences.
  8174. Conversely, setting it to -1 will make filter match fields more easily.
  8175. This may help processing of video where there is slight blurring between
  8176. the fields, but may also cause there to be interlaced frames in the output.
  8177. Default value is @code{0}.
  8178. @item mp
  8179. Set the metric plane to use. It accepts the following values:
  8180. @table @samp
  8181. @item l
  8182. Use luma plane.
  8183. @item u
  8184. Use chroma blue plane.
  8185. @item v
  8186. Use chroma red plane.
  8187. @end table
  8188. This option may be set to use chroma plane instead of the default luma plane
  8189. for doing filter's computations. This may improve accuracy on very clean
  8190. source material, but more likely will decrease accuracy, especially if there
  8191. is chroma noise (rainbow effect) or any grayscale video.
  8192. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  8193. load and make pullup usable in realtime on slow machines.
  8194. @end table
  8195. For best results (without duplicated frames in the output file) it is
  8196. necessary to change the output frame rate. For example, to inverse
  8197. telecine NTSC input:
  8198. @example
  8199. ffmpeg -i input -vf pullup -r 24000/1001 ...
  8200. @end example
  8201. @section qp
  8202. Change video quantization parameters (QP).
  8203. The filter accepts the following option:
  8204. @table @option
  8205. @item qp
  8206. Set expression for quantization parameter.
  8207. @end table
  8208. The expression is evaluated through the eval API and can contain, among others,
  8209. the following constants:
  8210. @table @var
  8211. @item known
  8212. 1 if index is not 129, 0 otherwise.
  8213. @item qp
  8214. Sequentional index starting from -129 to 128.
  8215. @end table
  8216. @subsection Examples
  8217. @itemize
  8218. @item
  8219. Some equation like:
  8220. @example
  8221. qp=2+2*sin(PI*qp)
  8222. @end example
  8223. @end itemize
  8224. @section random
  8225. Flush video frames from internal cache of frames into a random order.
  8226. No frame is discarded.
  8227. Inspired by @ref{frei0r} nervous filter.
  8228. @table @option
  8229. @item frames
  8230. Set size in number of frames of internal cache, in range from @code{2} to
  8231. @code{512}. Default is @code{30}.
  8232. @item seed
  8233. Set seed for random number generator, must be an integer included between
  8234. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  8235. less than @code{0}, the filter will try to use a good random seed on a
  8236. best effort basis.
  8237. @end table
  8238. @section readvitc
  8239. Read vertical interval timecode (VITC) information from the top lines of a
  8240. video frame.
  8241. The filter adds frame metadata key @code{lavfi.readvitc.tc_str} with the
  8242. timecode value, if a valid timecode has been detected. Further metadata key
  8243. @code{lavfi.readvitc.found} is set to 0/1 depending on whether
  8244. timecode data has been found or not.
  8245. This filter accepts the following options:
  8246. @table @option
  8247. @item scan_max
  8248. Set the maximum number of lines to scan for VITC data. If the value is set to
  8249. @code{-1} the full video frame is scanned. Default is @code{45}.
  8250. @item thr_b
  8251. Set the luma threshold for black. Accepts float numbers in the range [0.0,1.0],
  8252. default value is @code{0.2}. The value must be equal or less than @code{thr_w}.
  8253. @item thr_w
  8254. Set the luma threshold for white. Accepts float numbers in the range [0.0,1.0],
  8255. default value is @code{0.6}. The value must be equal or greater than @code{thr_b}.
  8256. @end table
  8257. @subsection Examples
  8258. @itemize
  8259. @item
  8260. Detect and draw VITC data onto the video frame; if no valid VITC is detected,
  8261. draw @code{--:--:--:--} as a placeholder:
  8262. @example
  8263. ffmpeg -i input.avi -filter:v 'readvitc,drawtext=fontfile=FreeMono.ttf:text=%@{metadata\\:lavfi.readvitc.tc_str\\:--\\\\\\:--\\\\\\:--\\\\\\:--@}:x=(w-tw)/2:y=400-ascent'
  8264. @end example
  8265. @end itemize
  8266. @section remap
  8267. Remap pixels using 2nd: Xmap and 3rd: Ymap input video stream.
  8268. Destination pixel at position (X, Y) will be picked from source (x, y) position
  8269. where x = Xmap(X, Y) and y = Ymap(X, Y). If mapping values are out of range, zero
  8270. value for pixel will be used for destination pixel.
  8271. Xmap and Ymap input video streams must be of same dimensions. Output video stream
  8272. will have Xmap/Ymap video stream dimensions.
  8273. Xmap and Ymap input video streams are 16bit depth, single channel.
  8274. @section removegrain
  8275. The removegrain filter is a spatial denoiser for progressive video.
  8276. @table @option
  8277. @item m0
  8278. Set mode for the first plane.
  8279. @item m1
  8280. Set mode for the second plane.
  8281. @item m2
  8282. Set mode for the third plane.
  8283. @item m3
  8284. Set mode for the fourth plane.
  8285. @end table
  8286. Range of mode is from 0 to 24. Description of each mode follows:
  8287. @table @var
  8288. @item 0
  8289. Leave input plane unchanged. Default.
  8290. @item 1
  8291. Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
  8292. @item 2
  8293. Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
  8294. @item 3
  8295. Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
  8296. @item 4
  8297. Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
  8298. This is equivalent to a median filter.
  8299. @item 5
  8300. Line-sensitive clipping giving the minimal change.
  8301. @item 6
  8302. Line-sensitive clipping, intermediate.
  8303. @item 7
  8304. Line-sensitive clipping, intermediate.
  8305. @item 8
  8306. Line-sensitive clipping, intermediate.
  8307. @item 9
  8308. Line-sensitive clipping on a line where the neighbours pixels are the closest.
  8309. @item 10
  8310. Replaces the target pixel with the closest neighbour.
  8311. @item 11
  8312. [1 2 1] horizontal and vertical kernel blur.
  8313. @item 12
  8314. Same as mode 11.
  8315. @item 13
  8316. Bob mode, interpolates top field from the line where the neighbours
  8317. pixels are the closest.
  8318. @item 14
  8319. Bob mode, interpolates bottom field from the line where the neighbours
  8320. pixels are the closest.
  8321. @item 15
  8322. Bob mode, interpolates top field. Same as 13 but with a more complicated
  8323. interpolation formula.
  8324. @item 16
  8325. Bob mode, interpolates bottom field. Same as 14 but with a more complicated
  8326. interpolation formula.
  8327. @item 17
  8328. Clips the pixel with the minimum and maximum of respectively the maximum and
  8329. minimum of each pair of opposite neighbour pixels.
  8330. @item 18
  8331. Line-sensitive clipping using opposite neighbours whose greatest distance from
  8332. the current pixel is minimal.
  8333. @item 19
  8334. Replaces the pixel with the average of its 8 neighbours.
  8335. @item 20
  8336. Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
  8337. @item 21
  8338. Clips pixels using the averages of opposite neighbour.
  8339. @item 22
  8340. Same as mode 21 but simpler and faster.
  8341. @item 23
  8342. Small edge and halo removal, but reputed useless.
  8343. @item 24
  8344. Similar as 23.
  8345. @end table
  8346. @section removelogo
  8347. Suppress a TV station logo, using an image file to determine which
  8348. pixels comprise the logo. It works by filling in the pixels that
  8349. comprise the logo with neighboring pixels.
  8350. The filter accepts the following options:
  8351. @table @option
  8352. @item filename, f
  8353. Set the filter bitmap file, which can be any image format supported by
  8354. libavformat. The width and height of the image file must match those of the
  8355. video stream being processed.
  8356. @end table
  8357. Pixels in the provided bitmap image with a value of zero are not
  8358. considered part of the logo, non-zero pixels are considered part of
  8359. the logo. If you use white (255) for the logo and black (0) for the
  8360. rest, you will be safe. For making the filter bitmap, it is
  8361. recommended to take a screen capture of a black frame with the logo
  8362. visible, and then using a threshold filter followed by the erode
  8363. filter once or twice.
  8364. If needed, little splotches can be fixed manually. Remember that if
  8365. logo pixels are not covered, the filter quality will be much
  8366. reduced. Marking too many pixels as part of the logo does not hurt as
  8367. much, but it will increase the amount of blurring needed to cover over
  8368. the image and will destroy more information than necessary, and extra
  8369. pixels will slow things down on a large logo.
  8370. @section repeatfields
  8371. This filter uses the repeat_field flag from the Video ES headers and hard repeats
  8372. fields based on its value.
  8373. @section reverse, areverse
  8374. Reverse a clip.
  8375. Warning: This filter requires memory to buffer the entire clip, so trimming
  8376. is suggested.
  8377. @subsection Examples
  8378. @itemize
  8379. @item
  8380. Take the first 5 seconds of a clip, and reverse it.
  8381. @example
  8382. trim=end=5,reverse
  8383. @end example
  8384. @end itemize
  8385. @section rotate
  8386. Rotate video by an arbitrary angle expressed in radians.
  8387. The filter accepts the following options:
  8388. A description of the optional parameters follows.
  8389. @table @option
  8390. @item angle, a
  8391. Set an expression for the angle by which to rotate the input video
  8392. clockwise, expressed as a number of radians. A negative value will
  8393. result in a counter-clockwise rotation. By default it is set to "0".
  8394. This expression is evaluated for each frame.
  8395. @item out_w, ow
  8396. Set the output width expression, default value is "iw".
  8397. This expression is evaluated just once during configuration.
  8398. @item out_h, oh
  8399. Set the output height expression, default value is "ih".
  8400. This expression is evaluated just once during configuration.
  8401. @item bilinear
  8402. Enable bilinear interpolation if set to 1, a value of 0 disables
  8403. it. Default value is 1.
  8404. @item fillcolor, c
  8405. Set the color used to fill the output area not covered by the rotated
  8406. image. For the general syntax of this option, check the "Color" section in the
  8407. ffmpeg-utils manual. If the special value "none" is selected then no
  8408. background is printed (useful for example if the background is never shown).
  8409. Default value is "black".
  8410. @end table
  8411. The expressions for the angle and the output size can contain the
  8412. following constants and functions:
  8413. @table @option
  8414. @item n
  8415. sequential number of the input frame, starting from 0. It is always NAN
  8416. before the first frame is filtered.
  8417. @item t
  8418. time in seconds of the input frame, it is set to 0 when the filter is
  8419. configured. It is always NAN before the first frame is filtered.
  8420. @item hsub
  8421. @item vsub
  8422. horizontal and vertical chroma subsample values. For example for the
  8423. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  8424. @item in_w, iw
  8425. @item in_h, ih
  8426. the input video width and height
  8427. @item out_w, ow
  8428. @item out_h, oh
  8429. the output width and height, that is the size of the padded area as
  8430. specified by the @var{width} and @var{height} expressions
  8431. @item rotw(a)
  8432. @item roth(a)
  8433. the minimal width/height required for completely containing the input
  8434. video rotated by @var{a} radians.
  8435. These are only available when computing the @option{out_w} and
  8436. @option{out_h} expressions.
  8437. @end table
  8438. @subsection Examples
  8439. @itemize
  8440. @item
  8441. Rotate the input by PI/6 radians clockwise:
  8442. @example
  8443. rotate=PI/6
  8444. @end example
  8445. @item
  8446. Rotate the input by PI/6 radians counter-clockwise:
  8447. @example
  8448. rotate=-PI/6
  8449. @end example
  8450. @item
  8451. Rotate the input by 45 degrees clockwise:
  8452. @example
  8453. rotate=45*PI/180
  8454. @end example
  8455. @item
  8456. Apply a constant rotation with period T, starting from an angle of PI/3:
  8457. @example
  8458. rotate=PI/3+2*PI*t/T
  8459. @end example
  8460. @item
  8461. Make the input video rotation oscillating with a period of T
  8462. seconds and an amplitude of A radians:
  8463. @example
  8464. rotate=A*sin(2*PI/T*t)
  8465. @end example
  8466. @item
  8467. Rotate the video, output size is chosen so that the whole rotating
  8468. input video is always completely contained in the output:
  8469. @example
  8470. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  8471. @end example
  8472. @item
  8473. Rotate the video, reduce the output size so that no background is ever
  8474. shown:
  8475. @example
  8476. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  8477. @end example
  8478. @end itemize
  8479. @subsection Commands
  8480. The filter supports the following commands:
  8481. @table @option
  8482. @item a, angle
  8483. Set the angle expression.
  8484. The command accepts the same syntax of the corresponding option.
  8485. If the specified expression is not valid, it is kept at its current
  8486. value.
  8487. @end table
  8488. @section sab
  8489. Apply Shape Adaptive Blur.
  8490. The filter accepts the following options:
  8491. @table @option
  8492. @item luma_radius, lr
  8493. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  8494. value is 1.0. A greater value will result in a more blurred image, and
  8495. in slower processing.
  8496. @item luma_pre_filter_radius, lpfr
  8497. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  8498. value is 1.0.
  8499. @item luma_strength, ls
  8500. Set luma maximum difference between pixels to still be considered, must
  8501. be a value in the 0.1-100.0 range, default value is 1.0.
  8502. @item chroma_radius, cr
  8503. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  8504. greater value will result in a more blurred image, and in slower
  8505. processing.
  8506. @item chroma_pre_filter_radius, cpfr
  8507. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  8508. @item chroma_strength, cs
  8509. Set chroma maximum difference between pixels to still be considered,
  8510. must be a value in the 0.1-100.0 range.
  8511. @end table
  8512. Each chroma option value, if not explicitly specified, is set to the
  8513. corresponding luma option value.
  8514. @anchor{scale}
  8515. @section scale
  8516. Scale (resize) the input video, using the libswscale library.
  8517. The scale filter forces the output display aspect ratio to be the same
  8518. of the input, by changing the output sample aspect ratio.
  8519. If the input image format is different from the format requested by
  8520. the next filter, the scale filter will convert the input to the
  8521. requested format.
  8522. @subsection Options
  8523. The filter accepts the following options, or any of the options
  8524. supported by the libswscale scaler.
  8525. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  8526. the complete list of scaler options.
  8527. @table @option
  8528. @item width, w
  8529. @item height, h
  8530. Set the output video dimension expression. Default value is the input
  8531. dimension.
  8532. If the value is 0, the input width is used for the output.
  8533. If one of the values is -1, the scale filter will use a value that
  8534. maintains the aspect ratio of the input image, calculated from the
  8535. other specified dimension. If both of them are -1, the input size is
  8536. used
  8537. If one of the values is -n with n > 1, the scale filter will also use a value
  8538. that maintains the aspect ratio of the input image, calculated from the other
  8539. specified dimension. After that it will, however, make sure that the calculated
  8540. dimension is divisible by n and adjust the value if necessary.
  8541. See below for the list of accepted constants for use in the dimension
  8542. expression.
  8543. @item eval
  8544. Specify when to evaluate @var{width} and @var{height} expression. It accepts the following values:
  8545. @table @samp
  8546. @item init
  8547. Only evaluate expressions once during the filter initialization or when a command is processed.
  8548. @item frame
  8549. Evaluate expressions for each incoming frame.
  8550. @end table
  8551. Default value is @samp{init}.
  8552. @item interl
  8553. Set the interlacing mode. It accepts the following values:
  8554. @table @samp
  8555. @item 1
  8556. Force interlaced aware scaling.
  8557. @item 0
  8558. Do not apply interlaced scaling.
  8559. @item -1
  8560. Select interlaced aware scaling depending on whether the source frames
  8561. are flagged as interlaced or not.
  8562. @end table
  8563. Default value is @samp{0}.
  8564. @item flags
  8565. Set libswscale scaling flags. See
  8566. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  8567. complete list of values. If not explicitly specified the filter applies
  8568. the default flags.
  8569. @item param0, param1
  8570. Set libswscale input parameters for scaling algorithms that need them. See
  8571. @ref{sws_params,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  8572. complete documentation. If not explicitly specified the filter applies
  8573. empty parameters.
  8574. @item size, s
  8575. Set the video size. For the syntax of this option, check the
  8576. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8577. @item in_color_matrix
  8578. @item out_color_matrix
  8579. Set in/output YCbCr color space type.
  8580. This allows the autodetected value to be overridden as well as allows forcing
  8581. a specific value used for the output and encoder.
  8582. If not specified, the color space type depends on the pixel format.
  8583. Possible values:
  8584. @table @samp
  8585. @item auto
  8586. Choose automatically.
  8587. @item bt709
  8588. Format conforming to International Telecommunication Union (ITU)
  8589. Recommendation BT.709.
  8590. @item fcc
  8591. Set color space conforming to the United States Federal Communications
  8592. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  8593. @item bt601
  8594. Set color space conforming to:
  8595. @itemize
  8596. @item
  8597. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  8598. @item
  8599. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  8600. @item
  8601. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  8602. @end itemize
  8603. @item smpte240m
  8604. Set color space conforming to SMPTE ST 240:1999.
  8605. @end table
  8606. @item in_range
  8607. @item out_range
  8608. Set in/output YCbCr sample range.
  8609. This allows the autodetected value to be overridden as well as allows forcing
  8610. a specific value used for the output and encoder. If not specified, the
  8611. range depends on the pixel format. Possible values:
  8612. @table @samp
  8613. @item auto
  8614. Choose automatically.
  8615. @item jpeg/full/pc
  8616. Set full range (0-255 in case of 8-bit luma).
  8617. @item mpeg/tv
  8618. Set "MPEG" range (16-235 in case of 8-bit luma).
  8619. @end table
  8620. @item force_original_aspect_ratio
  8621. Enable decreasing or increasing output video width or height if necessary to
  8622. keep the original aspect ratio. Possible values:
  8623. @table @samp
  8624. @item disable
  8625. Scale the video as specified and disable this feature.
  8626. @item decrease
  8627. The output video dimensions will automatically be decreased if needed.
  8628. @item increase
  8629. The output video dimensions will automatically be increased if needed.
  8630. @end table
  8631. One useful instance of this option is that when you know a specific device's
  8632. maximum allowed resolution, you can use this to limit the output video to
  8633. that, while retaining the aspect ratio. For example, device A allows
  8634. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  8635. decrease) and specifying 1280x720 to the command line makes the output
  8636. 1280x533.
  8637. Please note that this is a different thing than specifying -1 for @option{w}
  8638. or @option{h}, you still need to specify the output resolution for this option
  8639. to work.
  8640. @end table
  8641. The values of the @option{w} and @option{h} options are expressions
  8642. containing the following constants:
  8643. @table @var
  8644. @item in_w
  8645. @item in_h
  8646. The input width and height
  8647. @item iw
  8648. @item ih
  8649. These are the same as @var{in_w} and @var{in_h}.
  8650. @item out_w
  8651. @item out_h
  8652. The output (scaled) width and height
  8653. @item ow
  8654. @item oh
  8655. These are the same as @var{out_w} and @var{out_h}
  8656. @item a
  8657. The same as @var{iw} / @var{ih}
  8658. @item sar
  8659. input sample aspect ratio
  8660. @item dar
  8661. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  8662. @item hsub
  8663. @item vsub
  8664. horizontal and vertical input chroma subsample values. For example for the
  8665. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  8666. @item ohsub
  8667. @item ovsub
  8668. horizontal and vertical output chroma subsample values. For example for the
  8669. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  8670. @end table
  8671. @subsection Examples
  8672. @itemize
  8673. @item
  8674. Scale the input video to a size of 200x100
  8675. @example
  8676. scale=w=200:h=100
  8677. @end example
  8678. This is equivalent to:
  8679. @example
  8680. scale=200:100
  8681. @end example
  8682. or:
  8683. @example
  8684. scale=200x100
  8685. @end example
  8686. @item
  8687. Specify a size abbreviation for the output size:
  8688. @example
  8689. scale=qcif
  8690. @end example
  8691. which can also be written as:
  8692. @example
  8693. scale=size=qcif
  8694. @end example
  8695. @item
  8696. Scale the input to 2x:
  8697. @example
  8698. scale=w=2*iw:h=2*ih
  8699. @end example
  8700. @item
  8701. The above is the same as:
  8702. @example
  8703. scale=2*in_w:2*in_h
  8704. @end example
  8705. @item
  8706. Scale the input to 2x with forced interlaced scaling:
  8707. @example
  8708. scale=2*iw:2*ih:interl=1
  8709. @end example
  8710. @item
  8711. Scale the input to half size:
  8712. @example
  8713. scale=w=iw/2:h=ih/2
  8714. @end example
  8715. @item
  8716. Increase the width, and set the height to the same size:
  8717. @example
  8718. scale=3/2*iw:ow
  8719. @end example
  8720. @item
  8721. Seek Greek harmony:
  8722. @example
  8723. scale=iw:1/PHI*iw
  8724. scale=ih*PHI:ih
  8725. @end example
  8726. @item
  8727. Increase the height, and set the width to 3/2 of the height:
  8728. @example
  8729. scale=w=3/2*oh:h=3/5*ih
  8730. @end example
  8731. @item
  8732. Increase the size, making the size a multiple of the chroma
  8733. subsample values:
  8734. @example
  8735. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  8736. @end example
  8737. @item
  8738. Increase the width to a maximum of 500 pixels,
  8739. keeping the same aspect ratio as the input:
  8740. @example
  8741. scale=w='min(500\, iw*3/2):h=-1'
  8742. @end example
  8743. @end itemize
  8744. @subsection Commands
  8745. This filter supports the following commands:
  8746. @table @option
  8747. @item width, w
  8748. @item height, h
  8749. Set the output video dimension expression.
  8750. The command accepts the same syntax of the corresponding option.
  8751. If the specified expression is not valid, it is kept at its current
  8752. value.
  8753. @end table
  8754. @section scale2ref
  8755. Scale (resize) the input video, based on a reference video.
  8756. See the scale filter for available options, scale2ref supports the same but
  8757. uses the reference video instead of the main input as basis.
  8758. @subsection Examples
  8759. @itemize
  8760. @item
  8761. Scale a subtitle stream to match the main video in size before overlaying
  8762. @example
  8763. 'scale2ref[b][a];[a][b]overlay'
  8764. @end example
  8765. @end itemize
  8766. @anchor{selectivecolor}
  8767. @section selectivecolor
  8768. Adjust cyan, magenta, yellow and black (CMYK) to certain ranges of colors (such
  8769. as "reds", "yellows", "greens", "cyans", ...). The adjustment range is defined
  8770. by the "purity" of the color (that is, how saturated it already is).
  8771. This filter is similar to the Adobe Photoshop Selective Color tool.
  8772. The filter accepts the following options:
  8773. @table @option
  8774. @item correction_method
  8775. Select color correction method.
  8776. Available values are:
  8777. @table @samp
  8778. @item absolute
  8779. Specified adjustments are applied "as-is" (added/subtracted to original pixel
  8780. component value).
  8781. @item relative
  8782. Specified adjustments are relative to the original component value.
  8783. @end table
  8784. Default is @code{absolute}.
  8785. @item reds
  8786. Adjustments for red pixels (pixels where the red component is the maximum)
  8787. @item yellows
  8788. Adjustments for yellow pixels (pixels where the blue component is the minimum)
  8789. @item greens
  8790. Adjustments for green pixels (pixels where the green component is the maximum)
  8791. @item cyans
  8792. Adjustments for cyan pixels (pixels where the red component is the minimum)
  8793. @item blues
  8794. Adjustments for blue pixels (pixels where the blue component is the maximum)
  8795. @item magentas
  8796. Adjustments for magenta pixels (pixels where the green component is the minimum)
  8797. @item whites
  8798. Adjustments for white pixels (pixels where all components are greater than 128)
  8799. @item neutrals
  8800. Adjustments for all pixels except pure black and pure white
  8801. @item blacks
  8802. Adjustments for black pixels (pixels where all components are lesser than 128)
  8803. @item psfile
  8804. Specify a Photoshop selective color file (@code{.asv}) to import the settings from.
  8805. @end table
  8806. All the adjustment settings (@option{reds}, @option{yellows}, ...) accept up to
  8807. 4 space separated floating point adjustment values in the [-1,1] range,
  8808. respectively to adjust the amount of cyan, magenta, yellow and black for the
  8809. pixels of its range.
  8810. @subsection Examples
  8811. @itemize
  8812. @item
  8813. Increase cyan by 50% and reduce yellow by 33% in every green areas, and
  8814. increase magenta by 27% in blue areas:
  8815. @example
  8816. selectivecolor=greens=.5 0 -.33 0:blues=0 .27
  8817. @end example
  8818. @item
  8819. Use a Photoshop selective color preset:
  8820. @example
  8821. selectivecolor=psfile=MySelectiveColorPresets/Misty.asv
  8822. @end example
  8823. @end itemize
  8824. @section separatefields
  8825. The @code{separatefields} takes a frame-based video input and splits
  8826. each frame into its components fields, producing a new half height clip
  8827. with twice the frame rate and twice the frame count.
  8828. This filter use field-dominance information in frame to decide which
  8829. of each pair of fields to place first in the output.
  8830. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  8831. @section setdar, setsar
  8832. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  8833. output video.
  8834. This is done by changing the specified Sample (aka Pixel) Aspect
  8835. Ratio, according to the following equation:
  8836. @example
  8837. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  8838. @end example
  8839. Keep in mind that the @code{setdar} filter does not modify the pixel
  8840. dimensions of the video frame. Also, the display aspect ratio set by
  8841. this filter may be changed by later filters in the filterchain,
  8842. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  8843. applied.
  8844. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  8845. the filter output video.
  8846. Note that as a consequence of the application of this filter, the
  8847. output display aspect ratio will change according to the equation
  8848. above.
  8849. Keep in mind that the sample aspect ratio set by the @code{setsar}
  8850. filter may be changed by later filters in the filterchain, e.g. if
  8851. another "setsar" or a "setdar" filter is applied.
  8852. It accepts the following parameters:
  8853. @table @option
  8854. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  8855. Set the aspect ratio used by the filter.
  8856. The parameter can be a floating point number string, an expression, or
  8857. a string of the form @var{num}:@var{den}, where @var{num} and
  8858. @var{den} are the numerator and denominator of the aspect ratio. If
  8859. the parameter is not specified, it is assumed the value "0".
  8860. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  8861. should be escaped.
  8862. @item max
  8863. Set the maximum integer value to use for expressing numerator and
  8864. denominator when reducing the expressed aspect ratio to a rational.
  8865. Default value is @code{100}.
  8866. @end table
  8867. The parameter @var{sar} is an expression containing
  8868. the following constants:
  8869. @table @option
  8870. @item E, PI, PHI
  8871. These are approximated values for the mathematical constants e
  8872. (Euler's number), pi (Greek pi), and phi (the golden ratio).
  8873. @item w, h
  8874. The input width and height.
  8875. @item a
  8876. These are the same as @var{w} / @var{h}.
  8877. @item sar
  8878. The input sample aspect ratio.
  8879. @item dar
  8880. The input display aspect ratio. It is the same as
  8881. (@var{w} / @var{h}) * @var{sar}.
  8882. @item hsub, vsub
  8883. Horizontal and vertical chroma subsample values. For example, for the
  8884. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  8885. @end table
  8886. @subsection Examples
  8887. @itemize
  8888. @item
  8889. To change the display aspect ratio to 16:9, specify one of the following:
  8890. @example
  8891. setdar=dar=1.77777
  8892. setdar=dar=16/9
  8893. setdar=dar=1.77777
  8894. @end example
  8895. @item
  8896. To change the sample aspect ratio to 10:11, specify:
  8897. @example
  8898. setsar=sar=10/11
  8899. @end example
  8900. @item
  8901. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  8902. 1000 in the aspect ratio reduction, use the command:
  8903. @example
  8904. setdar=ratio=16/9:max=1000
  8905. @end example
  8906. @end itemize
  8907. @anchor{setfield}
  8908. @section setfield
  8909. Force field for the output video frame.
  8910. The @code{setfield} filter marks the interlace type field for the
  8911. output frames. It does not change the input frame, but only sets the
  8912. corresponding property, which affects how the frame is treated by
  8913. following filters (e.g. @code{fieldorder} or @code{yadif}).
  8914. The filter accepts the following options:
  8915. @table @option
  8916. @item mode
  8917. Available values are:
  8918. @table @samp
  8919. @item auto
  8920. Keep the same field property.
  8921. @item bff
  8922. Mark the frame as bottom-field-first.
  8923. @item tff
  8924. Mark the frame as top-field-first.
  8925. @item prog
  8926. Mark the frame as progressive.
  8927. @end table
  8928. @end table
  8929. @section showinfo
  8930. Show a line containing various information for each input video frame.
  8931. The input video is not modified.
  8932. The shown line contains a sequence of key/value pairs of the form
  8933. @var{key}:@var{value}.
  8934. The following values are shown in the output:
  8935. @table @option
  8936. @item n
  8937. The (sequential) number of the input frame, starting from 0.
  8938. @item pts
  8939. The Presentation TimeStamp of the input frame, expressed as a number of
  8940. time base units. The time base unit depends on the filter input pad.
  8941. @item pts_time
  8942. The Presentation TimeStamp of the input frame, expressed as a number of
  8943. seconds.
  8944. @item pos
  8945. The position of the frame in the input stream, or -1 if this information is
  8946. unavailable and/or meaningless (for example in case of synthetic video).
  8947. @item fmt
  8948. The pixel format name.
  8949. @item sar
  8950. The sample aspect ratio of the input frame, expressed in the form
  8951. @var{num}/@var{den}.
  8952. @item s
  8953. The size of the input frame. For the syntax of this option, check the
  8954. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8955. @item i
  8956. The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
  8957. for bottom field first).
  8958. @item iskey
  8959. This is 1 if the frame is a key frame, 0 otherwise.
  8960. @item type
  8961. The picture type of the input frame ("I" for an I-frame, "P" for a
  8962. P-frame, "B" for a B-frame, or "?" for an unknown type).
  8963. Also refer to the documentation of the @code{AVPictureType} enum and of
  8964. the @code{av_get_picture_type_char} function defined in
  8965. @file{libavutil/avutil.h}.
  8966. @item checksum
  8967. The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
  8968. @item plane_checksum
  8969. The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  8970. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
  8971. @end table
  8972. @section showpalette
  8973. Displays the 256 colors palette of each frame. This filter is only relevant for
  8974. @var{pal8} pixel format frames.
  8975. It accepts the following option:
  8976. @table @option
  8977. @item s
  8978. Set the size of the box used to represent one palette color entry. Default is
  8979. @code{30} (for a @code{30x30} pixel box).
  8980. @end table
  8981. @section shuffleframes
  8982. Reorder and/or duplicate video frames.
  8983. It accepts the following parameters:
  8984. @table @option
  8985. @item mapping
  8986. Set the destination indexes of input frames.
  8987. This is space or '|' separated list of indexes that maps input frames to output
  8988. frames. Number of indexes also sets maximal value that each index may have.
  8989. @end table
  8990. The first frame has the index 0. The default is to keep the input unchanged.
  8991. Swap second and third frame of every three frames of the input:
  8992. @example
  8993. ffmpeg -i INPUT -vf "shuffleframes=0 2 1" OUTPUT
  8994. @end example
  8995. @section shuffleplanes
  8996. Reorder and/or duplicate video planes.
  8997. It accepts the following parameters:
  8998. @table @option
  8999. @item map0
  9000. The index of the input plane to be used as the first output plane.
  9001. @item map1
  9002. The index of the input plane to be used as the second output plane.
  9003. @item map2
  9004. The index of the input plane to be used as the third output plane.
  9005. @item map3
  9006. The index of the input plane to be used as the fourth output plane.
  9007. @end table
  9008. The first plane has the index 0. The default is to keep the input unchanged.
  9009. Swap the second and third planes of the input:
  9010. @example
  9011. ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
  9012. @end example
  9013. @anchor{signalstats}
  9014. @section signalstats
  9015. Evaluate various visual metrics that assist in determining issues associated
  9016. with the digitization of analog video media.
  9017. By default the filter will log these metadata values:
  9018. @table @option
  9019. @item YMIN
  9020. Display the minimal Y value contained within the input frame. Expressed in
  9021. range of [0-255].
  9022. @item YLOW
  9023. Display the Y value at the 10% percentile within the input frame. Expressed in
  9024. range of [0-255].
  9025. @item YAVG
  9026. Display the average Y value within the input frame. Expressed in range of
  9027. [0-255].
  9028. @item YHIGH
  9029. Display the Y value at the 90% percentile within the input frame. Expressed in
  9030. range of [0-255].
  9031. @item YMAX
  9032. Display the maximum Y value contained within the input frame. Expressed in
  9033. range of [0-255].
  9034. @item UMIN
  9035. Display the minimal U value contained within the input frame. Expressed in
  9036. range of [0-255].
  9037. @item ULOW
  9038. Display the U value at the 10% percentile within the input frame. Expressed in
  9039. range of [0-255].
  9040. @item UAVG
  9041. Display the average U value within the input frame. Expressed in range of
  9042. [0-255].
  9043. @item UHIGH
  9044. Display the U value at the 90% percentile within the input frame. Expressed in
  9045. range of [0-255].
  9046. @item UMAX
  9047. Display the maximum U value contained within the input frame. Expressed in
  9048. range of [0-255].
  9049. @item VMIN
  9050. Display the minimal V value contained within the input frame. Expressed in
  9051. range of [0-255].
  9052. @item VLOW
  9053. Display the V value at the 10% percentile within the input frame. Expressed in
  9054. range of [0-255].
  9055. @item VAVG
  9056. Display the average V value within the input frame. Expressed in range of
  9057. [0-255].
  9058. @item VHIGH
  9059. Display the V value at the 90% percentile within the input frame. Expressed in
  9060. range of [0-255].
  9061. @item VMAX
  9062. Display the maximum V value contained within the input frame. Expressed in
  9063. range of [0-255].
  9064. @item SATMIN
  9065. Display the minimal saturation value contained within the input frame.
  9066. Expressed in range of [0-~181.02].
  9067. @item SATLOW
  9068. Display the saturation value at the 10% percentile within the input frame.
  9069. Expressed in range of [0-~181.02].
  9070. @item SATAVG
  9071. Display the average saturation value within the input frame. Expressed in range
  9072. of [0-~181.02].
  9073. @item SATHIGH
  9074. Display the saturation value at the 90% percentile within the input frame.
  9075. Expressed in range of [0-~181.02].
  9076. @item SATMAX
  9077. Display the maximum saturation value contained within the input frame.
  9078. Expressed in range of [0-~181.02].
  9079. @item HUEMED
  9080. Display the median value for hue within the input frame. Expressed in range of
  9081. [0-360].
  9082. @item HUEAVG
  9083. Display the average value for hue within the input frame. Expressed in range of
  9084. [0-360].
  9085. @item YDIF
  9086. Display the average of sample value difference between all values of the Y
  9087. plane in the current frame and corresponding values of the previous input frame.
  9088. Expressed in range of [0-255].
  9089. @item UDIF
  9090. Display the average of sample value difference between all values of the U
  9091. plane in the current frame and corresponding values of the previous input frame.
  9092. Expressed in range of [0-255].
  9093. @item VDIF
  9094. Display the average of sample value difference between all values of the V
  9095. plane in the current frame and corresponding values of the previous input frame.
  9096. Expressed in range of [0-255].
  9097. @end table
  9098. The filter accepts the following options:
  9099. @table @option
  9100. @item stat
  9101. @item out
  9102. @option{stat} specify an additional form of image analysis.
  9103. @option{out} output video with the specified type of pixel highlighted.
  9104. Both options accept the following values:
  9105. @table @samp
  9106. @item tout
  9107. Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
  9108. unlike the neighboring pixels of the same field. Examples of temporal outliers
  9109. include the results of video dropouts, head clogs, or tape tracking issues.
  9110. @item vrep
  9111. Identify @var{vertical line repetition}. Vertical line repetition includes
  9112. similar rows of pixels within a frame. In born-digital video vertical line
  9113. repetition is common, but this pattern is uncommon in video digitized from an
  9114. analog source. When it occurs in video that results from the digitization of an
  9115. analog source it can indicate concealment from a dropout compensator.
  9116. @item brng
  9117. Identify pixels that fall outside of legal broadcast range.
  9118. @end table
  9119. @item color, c
  9120. Set the highlight color for the @option{out} option. The default color is
  9121. yellow.
  9122. @end table
  9123. @subsection Examples
  9124. @itemize
  9125. @item
  9126. Output data of various video metrics:
  9127. @example
  9128. ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
  9129. @end example
  9130. @item
  9131. Output specific data about the minimum and maximum values of the Y plane per frame:
  9132. @example
  9133. ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
  9134. @end example
  9135. @item
  9136. Playback video while highlighting pixels that are outside of broadcast range in red.
  9137. @example
  9138. ffplay example.mov -vf signalstats="out=brng:color=red"
  9139. @end example
  9140. @item
  9141. Playback video with signalstats metadata drawn over the frame.
  9142. @example
  9143. ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
  9144. @end example
  9145. The contents of signalstat_drawtext.txt used in the command are:
  9146. @example
  9147. time %@{pts:hms@}
  9148. Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
  9149. U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
  9150. V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
  9151. saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
  9152. @end example
  9153. @end itemize
  9154. @anchor{smartblur}
  9155. @section smartblur
  9156. Blur the input video without impacting the outlines.
  9157. It accepts the following options:
  9158. @table @option
  9159. @item luma_radius, lr
  9160. Set the luma radius. The option value must be a float number in
  9161. the range [0.1,5.0] that specifies the variance of the gaussian filter
  9162. used to blur the image (slower if larger). Default value is 1.0.
  9163. @item luma_strength, ls
  9164. Set the luma strength. The option value must be a float number
  9165. in the range [-1.0,1.0] that configures the blurring. A value included
  9166. in [0.0,1.0] will blur the image whereas a value included in
  9167. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  9168. @item luma_threshold, lt
  9169. Set the luma threshold used as a coefficient to determine
  9170. whether a pixel should be blurred or not. The option value must be an
  9171. integer in the range [-30,30]. A value of 0 will filter all the image,
  9172. a value included in [0,30] will filter flat areas and a value included
  9173. in [-30,0] will filter edges. Default value is 0.
  9174. @item chroma_radius, cr
  9175. Set the chroma radius. The option value must be a float number in
  9176. the range [0.1,5.0] that specifies the variance of the gaussian filter
  9177. used to blur the image (slower if larger). Default value is 1.0.
  9178. @item chroma_strength, cs
  9179. Set the chroma strength. The option value must be a float number
  9180. in the range [-1.0,1.0] that configures the blurring. A value included
  9181. in [0.0,1.0] will blur the image whereas a value included in
  9182. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  9183. @item chroma_threshold, ct
  9184. Set the chroma threshold used as a coefficient to determine
  9185. whether a pixel should be blurred or not. The option value must be an
  9186. integer in the range [-30,30]. A value of 0 will filter all the image,
  9187. a value included in [0,30] will filter flat areas and a value included
  9188. in [-30,0] will filter edges. Default value is 0.
  9189. @end table
  9190. If a chroma option is not explicitly set, the corresponding luma value
  9191. is set.
  9192. @section ssim
  9193. Obtain the SSIM (Structural SImilarity Metric) between two input videos.
  9194. This filter takes in input two input videos, the first input is
  9195. considered the "main" source and is passed unchanged to the
  9196. output. The second input is used as a "reference" video for computing
  9197. the SSIM.
  9198. Both video inputs must have the same resolution and pixel format for
  9199. this filter to work correctly. Also it assumes that both inputs
  9200. have the same number of frames, which are compared one by one.
  9201. The filter stores the calculated SSIM of each frame.
  9202. The description of the accepted parameters follows.
  9203. @table @option
  9204. @item stats_file, f
  9205. If specified the filter will use the named file to save the SSIM of
  9206. each individual frame. When filename equals "-" the data is sent to
  9207. standard output.
  9208. @end table
  9209. The file printed if @var{stats_file} is selected, contains a sequence of
  9210. key/value pairs of the form @var{key}:@var{value} for each compared
  9211. couple of frames.
  9212. A description of each shown parameter follows:
  9213. @table @option
  9214. @item n
  9215. sequential number of the input frame, starting from 1
  9216. @item Y, U, V, R, G, B
  9217. SSIM of the compared frames for the component specified by the suffix.
  9218. @item All
  9219. SSIM of the compared frames for the whole frame.
  9220. @item dB
  9221. Same as above but in dB representation.
  9222. @end table
  9223. For example:
  9224. @example
  9225. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  9226. [main][ref] ssim="stats_file=stats.log" [out]
  9227. @end example
  9228. On this example the input file being processed is compared with the
  9229. reference file @file{ref_movie.mpg}. The SSIM of each individual frame
  9230. is stored in @file{stats.log}.
  9231. Another example with both psnr and ssim at same time:
  9232. @example
  9233. ffmpeg -i main.mpg -i ref.mpg -lavfi "ssim;[0:v][1:v]psnr" -f null -
  9234. @end example
  9235. @section stereo3d
  9236. Convert between different stereoscopic image formats.
  9237. The filters accept the following options:
  9238. @table @option
  9239. @item in
  9240. Set stereoscopic image format of input.
  9241. Available values for input image formats are:
  9242. @table @samp
  9243. @item sbsl
  9244. side by side parallel (left eye left, right eye right)
  9245. @item sbsr
  9246. side by side crosseye (right eye left, left eye right)
  9247. @item sbs2l
  9248. side by side parallel with half width resolution
  9249. (left eye left, right eye right)
  9250. @item sbs2r
  9251. side by side crosseye with half width resolution
  9252. (right eye left, left eye right)
  9253. @item abl
  9254. above-below (left eye above, right eye below)
  9255. @item abr
  9256. above-below (right eye above, left eye below)
  9257. @item ab2l
  9258. above-below with half height resolution
  9259. (left eye above, right eye below)
  9260. @item ab2r
  9261. above-below with half height resolution
  9262. (right eye above, left eye below)
  9263. @item al
  9264. alternating frames (left eye first, right eye second)
  9265. @item ar
  9266. alternating frames (right eye first, left eye second)
  9267. @item irl
  9268. interleaved rows (left eye has top row, right eye starts on next row)
  9269. @item irr
  9270. interleaved rows (right eye has top row, left eye starts on next row)
  9271. @item icl
  9272. interleaved columns, left eye first
  9273. @item icr
  9274. interleaved columns, right eye first
  9275. Default value is @samp{sbsl}.
  9276. @end table
  9277. @item out
  9278. Set stereoscopic image format of output.
  9279. @table @samp
  9280. @item sbsl
  9281. side by side parallel (left eye left, right eye right)
  9282. @item sbsr
  9283. side by side crosseye (right eye left, left eye right)
  9284. @item sbs2l
  9285. side by side parallel with half width resolution
  9286. (left eye left, right eye right)
  9287. @item sbs2r
  9288. side by side crosseye with half width resolution
  9289. (right eye left, left eye right)
  9290. @item abl
  9291. above-below (left eye above, right eye below)
  9292. @item abr
  9293. above-below (right eye above, left eye below)
  9294. @item ab2l
  9295. above-below with half height resolution
  9296. (left eye above, right eye below)
  9297. @item ab2r
  9298. above-below with half height resolution
  9299. (right eye above, left eye below)
  9300. @item al
  9301. alternating frames (left eye first, right eye second)
  9302. @item ar
  9303. alternating frames (right eye first, left eye second)
  9304. @item irl
  9305. interleaved rows (left eye has top row, right eye starts on next row)
  9306. @item irr
  9307. interleaved rows (right eye has top row, left eye starts on next row)
  9308. @item arbg
  9309. anaglyph red/blue gray
  9310. (red filter on left eye, blue filter on right eye)
  9311. @item argg
  9312. anaglyph red/green gray
  9313. (red filter on left eye, green filter on right eye)
  9314. @item arcg
  9315. anaglyph red/cyan gray
  9316. (red filter on left eye, cyan filter on right eye)
  9317. @item arch
  9318. anaglyph red/cyan half colored
  9319. (red filter on left eye, cyan filter on right eye)
  9320. @item arcc
  9321. anaglyph red/cyan color
  9322. (red filter on left eye, cyan filter on right eye)
  9323. @item arcd
  9324. anaglyph red/cyan color optimized with the least squares projection of dubois
  9325. (red filter on left eye, cyan filter on right eye)
  9326. @item agmg
  9327. anaglyph green/magenta gray
  9328. (green filter on left eye, magenta filter on right eye)
  9329. @item agmh
  9330. anaglyph green/magenta half colored
  9331. (green filter on left eye, magenta filter on right eye)
  9332. @item agmc
  9333. anaglyph green/magenta colored
  9334. (green filter on left eye, magenta filter on right eye)
  9335. @item agmd
  9336. anaglyph green/magenta color optimized with the least squares projection of dubois
  9337. (green filter on left eye, magenta filter on right eye)
  9338. @item aybg
  9339. anaglyph yellow/blue gray
  9340. (yellow filter on left eye, blue filter on right eye)
  9341. @item aybh
  9342. anaglyph yellow/blue half colored
  9343. (yellow filter on left eye, blue filter on right eye)
  9344. @item aybc
  9345. anaglyph yellow/blue colored
  9346. (yellow filter on left eye, blue filter on right eye)
  9347. @item aybd
  9348. anaglyph yellow/blue color optimized with the least squares projection of dubois
  9349. (yellow filter on left eye, blue filter on right eye)
  9350. @item ml
  9351. mono output (left eye only)
  9352. @item mr
  9353. mono output (right eye only)
  9354. @item chl
  9355. checkerboard, left eye first
  9356. @item chr
  9357. checkerboard, right eye first
  9358. @item icl
  9359. interleaved columns, left eye first
  9360. @item icr
  9361. interleaved columns, right eye first
  9362. @end table
  9363. Default value is @samp{arcd}.
  9364. @end table
  9365. @subsection Examples
  9366. @itemize
  9367. @item
  9368. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  9369. @example
  9370. stereo3d=sbsl:aybd
  9371. @end example
  9372. @item
  9373. Convert input video from above below (left eye above, right eye below) to side by side crosseye.
  9374. @example
  9375. stereo3d=abl:sbsr
  9376. @end example
  9377. @end itemize
  9378. @section streamselect, astreamselect
  9379. Select video or audio streams.
  9380. The filter accepts the following options:
  9381. @table @option
  9382. @item inputs
  9383. Set number of inputs. Default is 2.
  9384. @item map
  9385. Set input indexes to remap to outputs.
  9386. @end table
  9387. @subsection Commands
  9388. The @code{streamselect} and @code{astreamselect} filter supports the following
  9389. commands:
  9390. @table @option
  9391. @item map
  9392. Set input indexes to remap to outputs.
  9393. @end table
  9394. @subsection Examples
  9395. @itemize
  9396. @item
  9397. Select first 5 seconds 1st stream and rest of time 2nd stream:
  9398. @example
  9399. sendcmd='5.0 streamselect map 1',streamselect=inputs=2:map=0
  9400. @end example
  9401. @item
  9402. Same as above, but for audio:
  9403. @example
  9404. asendcmd='5.0 astreamselect map 1',astreamselect=inputs=2:map=0
  9405. @end example
  9406. @end itemize
  9407. @anchor{spp}
  9408. @section spp
  9409. Apply a simple postprocessing filter that compresses and decompresses the image
  9410. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  9411. and average the results.
  9412. The filter accepts the following options:
  9413. @table @option
  9414. @item quality
  9415. Set quality. This option defines the number of levels for averaging. It accepts
  9416. an integer in the range 0-6. If set to @code{0}, the filter will have no
  9417. effect. A value of @code{6} means the higher quality. For each increment of
  9418. that value the speed drops by a factor of approximately 2. Default value is
  9419. @code{3}.
  9420. @item qp
  9421. Force a constant quantization parameter. If not set, the filter will use the QP
  9422. from the video stream (if available).
  9423. @item mode
  9424. Set thresholding mode. Available modes are:
  9425. @table @samp
  9426. @item hard
  9427. Set hard thresholding (default).
  9428. @item soft
  9429. Set soft thresholding (better de-ringing effect, but likely blurrier).
  9430. @end table
  9431. @item use_bframe_qp
  9432. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  9433. option may cause flicker since the B-Frames have often larger QP. Default is
  9434. @code{0} (not enabled).
  9435. @end table
  9436. @anchor{subtitles}
  9437. @section subtitles
  9438. Draw subtitles on top of input video using the libass library.
  9439. To enable compilation of this filter you need to configure FFmpeg with
  9440. @code{--enable-libass}. This filter also requires a build with libavcodec and
  9441. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  9442. Alpha) subtitles format.
  9443. The filter accepts the following options:
  9444. @table @option
  9445. @item filename, f
  9446. Set the filename of the subtitle file to read. It must be specified.
  9447. @item original_size
  9448. Specify the size of the original video, the video for which the ASS file
  9449. was composed. For the syntax of this option, check the
  9450. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9451. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
  9452. correctly scale the fonts if the aspect ratio has been changed.
  9453. @item fontsdir
  9454. Set a directory path containing fonts that can be used by the filter.
  9455. These fonts will be used in addition to whatever the font provider uses.
  9456. @item charenc
  9457. Set subtitles input character encoding. @code{subtitles} filter only. Only
  9458. useful if not UTF-8.
  9459. @item stream_index, si
  9460. Set subtitles stream index. @code{subtitles} filter only.
  9461. @item force_style
  9462. Override default style or script info parameters of the subtitles. It accepts a
  9463. string containing ASS style format @code{KEY=VALUE} couples separated by ",".
  9464. @end table
  9465. If the first key is not specified, it is assumed that the first value
  9466. specifies the @option{filename}.
  9467. For example, to render the file @file{sub.srt} on top of the input
  9468. video, use the command:
  9469. @example
  9470. subtitles=sub.srt
  9471. @end example
  9472. which is equivalent to:
  9473. @example
  9474. subtitles=filename=sub.srt
  9475. @end example
  9476. To render the default subtitles stream from file @file{video.mkv}, use:
  9477. @example
  9478. subtitles=video.mkv
  9479. @end example
  9480. To render the second subtitles stream from that file, use:
  9481. @example
  9482. subtitles=video.mkv:si=1
  9483. @end example
  9484. To make the subtitles stream from @file{sub.srt} appear in transparent green
  9485. @code{DejaVu Serif}, use:
  9486. @example
  9487. subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
  9488. @end example
  9489. @section super2xsai
  9490. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  9491. Interpolate) pixel art scaling algorithm.
  9492. Useful for enlarging pixel art images without reducing sharpness.
  9493. @section swaprect
  9494. Swap two rectangular objects in video.
  9495. This filter accepts the following options:
  9496. @table @option
  9497. @item w
  9498. Set object width.
  9499. @item h
  9500. Set object height.
  9501. @item x1
  9502. Set 1st rect x coordinate.
  9503. @item y1
  9504. Set 1st rect y coordinate.
  9505. @item x2
  9506. Set 2nd rect x coordinate.
  9507. @item y2
  9508. Set 2nd rect y coordinate.
  9509. All expressions are evaluated once for each frame.
  9510. @end table
  9511. The all options are expressions containing the following constants:
  9512. @table @option
  9513. @item w
  9514. @item h
  9515. The input width and height.
  9516. @item a
  9517. same as @var{w} / @var{h}
  9518. @item sar
  9519. input sample aspect ratio
  9520. @item dar
  9521. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  9522. @item n
  9523. The number of the input frame, starting from 0.
  9524. @item t
  9525. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  9526. @item pos
  9527. the position in the file of the input frame, NAN if unknown
  9528. @end table
  9529. @section swapuv
  9530. Swap U & V plane.
  9531. @section telecine
  9532. Apply telecine process to the video.
  9533. This filter accepts the following options:
  9534. @table @option
  9535. @item first_field
  9536. @table @samp
  9537. @item top, t
  9538. top field first
  9539. @item bottom, b
  9540. bottom field first
  9541. The default value is @code{top}.
  9542. @end table
  9543. @item pattern
  9544. A string of numbers representing the pulldown pattern you wish to apply.
  9545. The default value is @code{23}.
  9546. @end table
  9547. @example
  9548. Some typical patterns:
  9549. NTSC output (30i):
  9550. 27.5p: 32222
  9551. 24p: 23 (classic)
  9552. 24p: 2332 (preferred)
  9553. 20p: 33
  9554. 18p: 334
  9555. 16p: 3444
  9556. PAL output (25i):
  9557. 27.5p: 12222
  9558. 24p: 222222222223 ("Euro pulldown")
  9559. 16.67p: 33
  9560. 16p: 33333334
  9561. @end example
  9562. @section thumbnail
  9563. Select the most representative frame in a given sequence of consecutive frames.
  9564. The filter accepts the following options:
  9565. @table @option
  9566. @item n
  9567. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  9568. will pick one of them, and then handle the next batch of @var{n} frames until
  9569. the end. Default is @code{100}.
  9570. @end table
  9571. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  9572. value will result in a higher memory usage, so a high value is not recommended.
  9573. @subsection Examples
  9574. @itemize
  9575. @item
  9576. Extract one picture each 50 frames:
  9577. @example
  9578. thumbnail=50
  9579. @end example
  9580. @item
  9581. Complete example of a thumbnail creation with @command{ffmpeg}:
  9582. @example
  9583. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  9584. @end example
  9585. @end itemize
  9586. @section tile
  9587. Tile several successive frames together.
  9588. The filter accepts the following options:
  9589. @table @option
  9590. @item layout
  9591. Set the grid size (i.e. the number of lines and columns). For the syntax of
  9592. this option, check the
  9593. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9594. @item nb_frames
  9595. Set the maximum number of frames to render in the given area. It must be less
  9596. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  9597. the area will be used.
  9598. @item margin
  9599. Set the outer border margin in pixels.
  9600. @item padding
  9601. Set the inner border thickness (i.e. the number of pixels between frames). For
  9602. more advanced padding options (such as having different values for the edges),
  9603. refer to the pad video filter.
  9604. @item color
  9605. Specify the color of the unused area. For the syntax of this option, check the
  9606. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  9607. is "black".
  9608. @end table
  9609. @subsection Examples
  9610. @itemize
  9611. @item
  9612. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  9613. @example
  9614. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  9615. @end example
  9616. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  9617. duplicating each output frame to accommodate the originally detected frame
  9618. rate.
  9619. @item
  9620. Display @code{5} pictures in an area of @code{3x2} frames,
  9621. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  9622. mixed flat and named options:
  9623. @example
  9624. tile=3x2:nb_frames=5:padding=7:margin=2
  9625. @end example
  9626. @end itemize
  9627. @section tinterlace
  9628. Perform various types of temporal field interlacing.
  9629. Frames are counted starting from 1, so the first input frame is
  9630. considered odd.
  9631. The filter accepts the following options:
  9632. @table @option
  9633. @item mode
  9634. Specify the mode of the interlacing. This option can also be specified
  9635. as a value alone. See below for a list of values for this option.
  9636. Available values are:
  9637. @table @samp
  9638. @item merge, 0
  9639. Move odd frames into the upper field, even into the lower field,
  9640. generating a double height frame at half frame rate.
  9641. @example
  9642. ------> time
  9643. Input:
  9644. Frame 1 Frame 2 Frame 3 Frame 4
  9645. 11111 22222 33333 44444
  9646. 11111 22222 33333 44444
  9647. 11111 22222 33333 44444
  9648. 11111 22222 33333 44444
  9649. Output:
  9650. 11111 33333
  9651. 22222 44444
  9652. 11111 33333
  9653. 22222 44444
  9654. 11111 33333
  9655. 22222 44444
  9656. 11111 33333
  9657. 22222 44444
  9658. @end example
  9659. @item drop_odd, 1
  9660. Only output even frames, odd frames are dropped, generating a frame with
  9661. unchanged height at half frame rate.
  9662. @example
  9663. ------> time
  9664. Input:
  9665. Frame 1 Frame 2 Frame 3 Frame 4
  9666. 11111 22222 33333 44444
  9667. 11111 22222 33333 44444
  9668. 11111 22222 33333 44444
  9669. 11111 22222 33333 44444
  9670. Output:
  9671. 22222 44444
  9672. 22222 44444
  9673. 22222 44444
  9674. 22222 44444
  9675. @end example
  9676. @item drop_even, 2
  9677. Only output odd frames, even frames are dropped, generating a frame with
  9678. unchanged height at half frame rate.
  9679. @example
  9680. ------> time
  9681. Input:
  9682. Frame 1 Frame 2 Frame 3 Frame 4
  9683. 11111 22222 33333 44444
  9684. 11111 22222 33333 44444
  9685. 11111 22222 33333 44444
  9686. 11111 22222 33333 44444
  9687. Output:
  9688. 11111 33333
  9689. 11111 33333
  9690. 11111 33333
  9691. 11111 33333
  9692. @end example
  9693. @item pad, 3
  9694. Expand each frame to full height, but pad alternate lines with black,
  9695. generating a frame with double height at the same input frame rate.
  9696. @example
  9697. ------> time
  9698. Input:
  9699. Frame 1 Frame 2 Frame 3 Frame 4
  9700. 11111 22222 33333 44444
  9701. 11111 22222 33333 44444
  9702. 11111 22222 33333 44444
  9703. 11111 22222 33333 44444
  9704. Output:
  9705. 11111 ..... 33333 .....
  9706. ..... 22222 ..... 44444
  9707. 11111 ..... 33333 .....
  9708. ..... 22222 ..... 44444
  9709. 11111 ..... 33333 .....
  9710. ..... 22222 ..... 44444
  9711. 11111 ..... 33333 .....
  9712. ..... 22222 ..... 44444
  9713. @end example
  9714. @item interleave_top, 4
  9715. Interleave the upper field from odd frames with the lower field from
  9716. even frames, generating a frame with unchanged height at half frame rate.
  9717. @example
  9718. ------> time
  9719. Input:
  9720. Frame 1 Frame 2 Frame 3 Frame 4
  9721. 11111<- 22222 33333<- 44444
  9722. 11111 22222<- 33333 44444<-
  9723. 11111<- 22222 33333<- 44444
  9724. 11111 22222<- 33333 44444<-
  9725. Output:
  9726. 11111 33333
  9727. 22222 44444
  9728. 11111 33333
  9729. 22222 44444
  9730. @end example
  9731. @item interleave_bottom, 5
  9732. Interleave the lower field from odd frames with the upper field from
  9733. even frames, generating a frame with unchanged height at half frame rate.
  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. 22222 44444
  9744. 11111 33333
  9745. 22222 44444
  9746. 11111 33333
  9747. @end example
  9748. @item interlacex2, 6
  9749. Double frame rate with unchanged height. Frames are inserted each
  9750. containing the second temporal field from the previous input frame and
  9751. the first temporal field from the next input frame. This mode relies on
  9752. the top_field_first flag. Useful for interlaced video displays with no
  9753. field synchronisation.
  9754. @example
  9755. ------> time
  9756. Input:
  9757. Frame 1 Frame 2 Frame 3 Frame 4
  9758. 11111 22222 33333 44444
  9759. 11111 22222 33333 44444
  9760. 11111 22222 33333 44444
  9761. 11111 22222 33333 44444
  9762. Output:
  9763. 11111 22222 22222 33333 33333 44444 44444
  9764. 11111 11111 22222 22222 33333 33333 44444
  9765. 11111 22222 22222 33333 33333 44444 44444
  9766. 11111 11111 22222 22222 33333 33333 44444
  9767. @end example
  9768. @item mergex2, 7
  9769. Move odd frames into the upper field, even into the lower field,
  9770. generating a double height frame at same frame rate.
  9771. @example
  9772. ------> time
  9773. Input:
  9774. Frame 1 Frame 2 Frame 3 Frame 4
  9775. 11111 22222 33333 44444
  9776. 11111 22222 33333 44444
  9777. 11111 22222 33333 44444
  9778. 11111 22222 33333 44444
  9779. Output:
  9780. 11111 33333 33333 55555
  9781. 22222 22222 44444 44444
  9782. 11111 33333 33333 55555
  9783. 22222 22222 44444 44444
  9784. 11111 33333 33333 55555
  9785. 22222 22222 44444 44444
  9786. 11111 33333 33333 55555
  9787. 22222 22222 44444 44444
  9788. @end example
  9789. @end table
  9790. Numeric values are deprecated but are accepted for backward
  9791. compatibility reasons.
  9792. Default mode is @code{merge}.
  9793. @item flags
  9794. Specify flags influencing the filter process.
  9795. Available value for @var{flags} is:
  9796. @table @option
  9797. @item low_pass_filter, vlfp
  9798. Enable vertical low-pass filtering in the filter.
  9799. Vertical low-pass filtering is required when creating an interlaced
  9800. destination from a progressive source which contains high-frequency
  9801. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  9802. patterning.
  9803. Vertical low-pass filtering can only be enabled for @option{mode}
  9804. @var{interleave_top} and @var{interleave_bottom}.
  9805. @end table
  9806. @end table
  9807. @section transpose
  9808. Transpose rows with columns in the input video and optionally flip it.
  9809. It accepts the following parameters:
  9810. @table @option
  9811. @item dir
  9812. Specify the transposition direction.
  9813. Can assume the following values:
  9814. @table @samp
  9815. @item 0, 4, cclock_flip
  9816. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  9817. @example
  9818. L.R L.l
  9819. . . -> . .
  9820. l.r R.r
  9821. @end example
  9822. @item 1, 5, clock
  9823. Rotate by 90 degrees clockwise, that is:
  9824. @example
  9825. L.R l.L
  9826. . . -> . .
  9827. l.r r.R
  9828. @end example
  9829. @item 2, 6, cclock
  9830. Rotate by 90 degrees counterclockwise, that is:
  9831. @example
  9832. L.R R.r
  9833. . . -> . .
  9834. l.r L.l
  9835. @end example
  9836. @item 3, 7, clock_flip
  9837. Rotate by 90 degrees clockwise and vertically flip, that is:
  9838. @example
  9839. L.R r.R
  9840. . . -> . .
  9841. l.r l.L
  9842. @end example
  9843. @end table
  9844. For values between 4-7, the transposition is only done if the input
  9845. video geometry is portrait and not landscape. These values are
  9846. deprecated, the @code{passthrough} option should be used instead.
  9847. Numerical values are deprecated, and should be dropped in favor of
  9848. symbolic constants.
  9849. @item passthrough
  9850. Do not apply the transposition if the input geometry matches the one
  9851. specified by the specified value. It accepts the following values:
  9852. @table @samp
  9853. @item none
  9854. Always apply transposition.
  9855. @item portrait
  9856. Preserve portrait geometry (when @var{height} >= @var{width}).
  9857. @item landscape
  9858. Preserve landscape geometry (when @var{width} >= @var{height}).
  9859. @end table
  9860. Default value is @code{none}.
  9861. @end table
  9862. For example to rotate by 90 degrees clockwise and preserve portrait
  9863. layout:
  9864. @example
  9865. transpose=dir=1:passthrough=portrait
  9866. @end example
  9867. The command above can also be specified as:
  9868. @example
  9869. transpose=1:portrait
  9870. @end example
  9871. @section trim
  9872. Trim the input so that the output contains one continuous subpart of the input.
  9873. It accepts the following parameters:
  9874. @table @option
  9875. @item start
  9876. Specify the time of the start of the kept section, i.e. the frame with the
  9877. timestamp @var{start} will be the first frame in the output.
  9878. @item end
  9879. Specify the time of the first frame that will be dropped, i.e. the frame
  9880. immediately preceding the one with the timestamp @var{end} will be the last
  9881. frame in the output.
  9882. @item start_pts
  9883. This is the same as @var{start}, except this option sets the start timestamp
  9884. in timebase units instead of seconds.
  9885. @item end_pts
  9886. This is the same as @var{end}, except this option sets the end timestamp
  9887. in timebase units instead of seconds.
  9888. @item duration
  9889. The maximum duration of the output in seconds.
  9890. @item start_frame
  9891. The number of the first frame that should be passed to the output.
  9892. @item end_frame
  9893. The number of the first frame that should be dropped.
  9894. @end table
  9895. @option{start}, @option{end}, and @option{duration} are expressed as time
  9896. duration specifications; see
  9897. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  9898. for the accepted syntax.
  9899. Note that the first two sets of the start/end options and the @option{duration}
  9900. option look at the frame timestamp, while the _frame variants simply count the
  9901. frames that pass through the filter. Also note that this filter does not modify
  9902. the timestamps. If you wish for the output timestamps to start at zero, insert a
  9903. setpts filter after the trim filter.
  9904. If multiple start or end options are set, this filter tries to be greedy and
  9905. keep all the frames that match at least one of the specified constraints. To keep
  9906. only the part that matches all the constraints at once, chain multiple trim
  9907. filters.
  9908. The defaults are such that all the input is kept. So it is possible to set e.g.
  9909. just the end values to keep everything before the specified time.
  9910. Examples:
  9911. @itemize
  9912. @item
  9913. Drop everything except the second minute of input:
  9914. @example
  9915. ffmpeg -i INPUT -vf trim=60:120
  9916. @end example
  9917. @item
  9918. Keep only the first second:
  9919. @example
  9920. ffmpeg -i INPUT -vf trim=duration=1
  9921. @end example
  9922. @end itemize
  9923. @anchor{unsharp}
  9924. @section unsharp
  9925. Sharpen or blur the input video.
  9926. It accepts the following parameters:
  9927. @table @option
  9928. @item luma_msize_x, lx
  9929. Set the luma matrix horizontal size. It must be an odd integer between
  9930. 3 and 63. The default value is 5.
  9931. @item luma_msize_y, ly
  9932. Set the luma matrix vertical size. It must be an odd integer between 3
  9933. and 63. The default value is 5.
  9934. @item luma_amount, la
  9935. Set the luma effect strength. It must be a floating point number, reasonable
  9936. values lay between -1.5 and 1.5.
  9937. Negative values will blur the input video, while positive values will
  9938. sharpen it, a value of zero will disable the effect.
  9939. Default value is 1.0.
  9940. @item chroma_msize_x, cx
  9941. Set the chroma matrix horizontal size. It must be an odd integer
  9942. between 3 and 63. The default value is 5.
  9943. @item chroma_msize_y, cy
  9944. Set the chroma matrix vertical size. It must be an odd integer
  9945. between 3 and 63. The default value is 5.
  9946. @item chroma_amount, ca
  9947. Set the chroma effect strength. It must be a floating point number, reasonable
  9948. values lay between -1.5 and 1.5.
  9949. Negative values will blur the input video, while positive values will
  9950. sharpen it, a value of zero will disable the effect.
  9951. Default value is 0.0.
  9952. @item opencl
  9953. If set to 1, specify using OpenCL capabilities, only available if
  9954. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  9955. @end table
  9956. All parameters are optional and default to the equivalent of the
  9957. string '5:5:1.0:5:5:0.0'.
  9958. @subsection Examples
  9959. @itemize
  9960. @item
  9961. Apply strong luma sharpen effect:
  9962. @example
  9963. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  9964. @end example
  9965. @item
  9966. Apply a strong blur of both luma and chroma parameters:
  9967. @example
  9968. unsharp=7:7:-2:7:7:-2
  9969. @end example
  9970. @end itemize
  9971. @section uspp
  9972. Apply ultra slow/simple postprocessing filter that compresses and decompresses
  9973. the image at several (or - in the case of @option{quality} level @code{8} - all)
  9974. shifts and average the results.
  9975. The way this differs from the behavior of spp is that uspp actually encodes &
  9976. decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
  9977. DCT similar to MJPEG.
  9978. The filter accepts the following options:
  9979. @table @option
  9980. @item quality
  9981. Set quality. This option defines the number of levels for averaging. It accepts
  9982. an integer in the range 0-8. If set to @code{0}, the filter will have no
  9983. effect. A value of @code{8} means the higher quality. For each increment of
  9984. that value the speed drops by a factor of approximately 2. Default value is
  9985. @code{3}.
  9986. @item qp
  9987. Force a constant quantization parameter. If not set, the filter will use the QP
  9988. from the video stream (if available).
  9989. @end table
  9990. @section vectorscope
  9991. Display 2 color component values in the two dimensional graph (which is called
  9992. a vectorscope).
  9993. This filter accepts the following options:
  9994. @table @option
  9995. @item mode, m
  9996. Set vectorscope mode.
  9997. It accepts the following values:
  9998. @table @samp
  9999. @item gray
  10000. Gray values are displayed on graph, higher brightness means more pixels have
  10001. same component color value on location in graph. This is the default mode.
  10002. @item color
  10003. Gray values are displayed on graph. Surrounding pixels values which are not
  10004. present in video frame are drawn in gradient of 2 color components which are
  10005. set by option @code{x} and @code{y}. The 3rd color component is static.
  10006. @item color2
  10007. Actual color components values present in video frame are displayed on graph.
  10008. @item color3
  10009. Similar as color2 but higher frequency of same values @code{x} and @code{y}
  10010. on graph increases value of another color component, which is luminance by
  10011. default values of @code{x} and @code{y}.
  10012. @item color4
  10013. Actual colors present in video frame are displayed on graph. If two different
  10014. colors map to same position on graph then color with higher value of component
  10015. not present in graph is picked.
  10016. @item color5
  10017. Gray values are displayed on graph. Similar to @code{color} but with 3rd color
  10018. component picked from radial gradient.
  10019. @end table
  10020. @item x
  10021. Set which color component will be represented on X-axis. Default is @code{1}.
  10022. @item y
  10023. Set which color component will be represented on Y-axis. Default is @code{2}.
  10024. @item intensity, i
  10025. Set intensity, used by modes: gray, color, color3 and color5 for increasing brightness
  10026. of color component which represents frequency of (X, Y) location in graph.
  10027. @item envelope, e
  10028. @table @samp
  10029. @item none
  10030. No envelope, this is default.
  10031. @item instant
  10032. Instant envelope, even darkest single pixel will be clearly highlighted.
  10033. @item peak
  10034. Hold maximum and minimum values presented in graph over time. This way you
  10035. can still spot out of range values without constantly looking at vectorscope.
  10036. @item peak+instant
  10037. Peak and instant envelope combined together.
  10038. @end table
  10039. @item graticule, g
  10040. Set what kind of graticule to draw.
  10041. @table @samp
  10042. @item none
  10043. @item green
  10044. @item color
  10045. @end table
  10046. @item opacity, o
  10047. Set graticule opacity.
  10048. @item flags, f
  10049. Set graticule flags.
  10050. @table @samp
  10051. @item white
  10052. Draw graticule for white point.
  10053. @item black
  10054. Draw graticule for black point.
  10055. @item name
  10056. Draw color points short names.
  10057. @end table
  10058. @item bgopacity, b
  10059. Set background opacity.
  10060. @item lthreshold, l
  10061. Set low threshold for color component not represented on X or Y axis.
  10062. Values lower than this value will be ignored. Default is 0.
  10063. Note this value is multiplied with actual max possible value one pixel component
  10064. can have. So for 8-bit input and low threshold value of 0.1 actual threshold
  10065. is 0.1 * 255 = 25.
  10066. @item hthreshold, h
  10067. Set high threshold for color component not represented on X or Y axis.
  10068. Values higher than this value will be ignored. Default is 1.
  10069. Note this value is multiplied with actual max possible value one pixel component
  10070. can have. So for 8-bit input and high threshold value of 0.9 actual threshold
  10071. is 0.9 * 255 = 230.
  10072. @item colorspace, c
  10073. Set what kind of colorspace to use when drawing graticule.
  10074. @table @samp
  10075. @item auto
  10076. @item 601
  10077. @item 709
  10078. @end table
  10079. Default is auto.
  10080. @end table
  10081. @anchor{vidstabdetect}
  10082. @section vidstabdetect
  10083. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  10084. @ref{vidstabtransform} for pass 2.
  10085. This filter generates a file with relative translation and rotation
  10086. transform information about subsequent frames, which is then used by
  10087. the @ref{vidstabtransform} filter.
  10088. To enable compilation of this filter you need to configure FFmpeg with
  10089. @code{--enable-libvidstab}.
  10090. This filter accepts the following options:
  10091. @table @option
  10092. @item result
  10093. Set the path to the file used to write the transforms information.
  10094. Default value is @file{transforms.trf}.
  10095. @item shakiness
  10096. Set how shaky the video is and how quick the camera is. It accepts an
  10097. integer in the range 1-10, a value of 1 means little shakiness, a
  10098. value of 10 means strong shakiness. Default value is 5.
  10099. @item accuracy
  10100. Set the accuracy of the detection process. It must be a value in the
  10101. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  10102. accuracy. Default value is 15.
  10103. @item stepsize
  10104. Set stepsize of the search process. The region around minimum is
  10105. scanned with 1 pixel resolution. Default value is 6.
  10106. @item mincontrast
  10107. Set minimum contrast. Below this value a local measurement field is
  10108. discarded. Must be a floating point value in the range 0-1. Default
  10109. value is 0.3.
  10110. @item tripod
  10111. Set reference frame number for tripod mode.
  10112. If enabled, the motion of the frames is compared to a reference frame
  10113. in the filtered stream, identified by the specified number. The idea
  10114. is to compensate all movements in a more-or-less static scene and keep
  10115. the camera view absolutely still.
  10116. If set to 0, it is disabled. The frames are counted starting from 1.
  10117. @item show
  10118. Show fields and transforms in the resulting frames. It accepts an
  10119. integer in the range 0-2. Default value is 0, which disables any
  10120. visualization.
  10121. @end table
  10122. @subsection Examples
  10123. @itemize
  10124. @item
  10125. Use default values:
  10126. @example
  10127. vidstabdetect
  10128. @end example
  10129. @item
  10130. Analyze strongly shaky movie and put the results in file
  10131. @file{mytransforms.trf}:
  10132. @example
  10133. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  10134. @end example
  10135. @item
  10136. Visualize the result of internal transformations in the resulting
  10137. video:
  10138. @example
  10139. vidstabdetect=show=1
  10140. @end example
  10141. @item
  10142. Analyze a video with medium shakiness using @command{ffmpeg}:
  10143. @example
  10144. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  10145. @end example
  10146. @end itemize
  10147. @anchor{vidstabtransform}
  10148. @section vidstabtransform
  10149. Video stabilization/deshaking: pass 2 of 2,
  10150. see @ref{vidstabdetect} for pass 1.
  10151. Read a file with transform information for each frame and
  10152. apply/compensate them. Together with the @ref{vidstabdetect}
  10153. filter this can be used to deshake videos. See also
  10154. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  10155. the @ref{unsharp} filter, see below.
  10156. To enable compilation of this filter you need to configure FFmpeg with
  10157. @code{--enable-libvidstab}.
  10158. @subsection Options
  10159. @table @option
  10160. @item input
  10161. Set path to the file used to read the transforms. Default value is
  10162. @file{transforms.trf}.
  10163. @item smoothing
  10164. Set the number of frames (value*2 + 1) used for lowpass filtering the
  10165. camera movements. Default value is 10.
  10166. For example a number of 10 means that 21 frames are used (10 in the
  10167. past and 10 in the future) to smoothen the motion in the video. A
  10168. larger value leads to a smoother video, but limits the acceleration of
  10169. the camera (pan/tilt movements). 0 is a special case where a static
  10170. camera is simulated.
  10171. @item optalgo
  10172. Set the camera path optimization algorithm.
  10173. Accepted values are:
  10174. @table @samp
  10175. @item gauss
  10176. gaussian kernel low-pass filter on camera motion (default)
  10177. @item avg
  10178. averaging on transformations
  10179. @end table
  10180. @item maxshift
  10181. Set maximal number of pixels to translate frames. Default value is -1,
  10182. meaning no limit.
  10183. @item maxangle
  10184. Set maximal angle in radians (degree*PI/180) to rotate frames. Default
  10185. value is -1, meaning no limit.
  10186. @item crop
  10187. Specify how to deal with borders that may be visible due to movement
  10188. compensation.
  10189. Available values are:
  10190. @table @samp
  10191. @item keep
  10192. keep image information from previous frame (default)
  10193. @item black
  10194. fill the border black
  10195. @end table
  10196. @item invert
  10197. Invert transforms if set to 1. Default value is 0.
  10198. @item relative
  10199. Consider transforms as relative to previous frame if set to 1,
  10200. absolute if set to 0. Default value is 0.
  10201. @item zoom
  10202. Set percentage to zoom. A positive value will result in a zoom-in
  10203. effect, a negative value in a zoom-out effect. Default value is 0 (no
  10204. zoom).
  10205. @item optzoom
  10206. Set optimal zooming to avoid borders.
  10207. Accepted values are:
  10208. @table @samp
  10209. @item 0
  10210. disabled
  10211. @item 1
  10212. optimal static zoom value is determined (only very strong movements
  10213. will lead to visible borders) (default)
  10214. @item 2
  10215. optimal adaptive zoom value is determined (no borders will be
  10216. visible), see @option{zoomspeed}
  10217. @end table
  10218. Note that the value given at zoom is added to the one calculated here.
  10219. @item zoomspeed
  10220. Set percent to zoom maximally each frame (enabled when
  10221. @option{optzoom} is set to 2). Range is from 0 to 5, default value is
  10222. 0.25.
  10223. @item interpol
  10224. Specify type of interpolation.
  10225. Available values are:
  10226. @table @samp
  10227. @item no
  10228. no interpolation
  10229. @item linear
  10230. linear only horizontal
  10231. @item bilinear
  10232. linear in both directions (default)
  10233. @item bicubic
  10234. cubic in both directions (slow)
  10235. @end table
  10236. @item tripod
  10237. Enable virtual tripod mode if set to 1, which is equivalent to
  10238. @code{relative=0:smoothing=0}. Default value is 0.
  10239. Use also @code{tripod} option of @ref{vidstabdetect}.
  10240. @item debug
  10241. Increase log verbosity if set to 1. Also the detected global motions
  10242. are written to the temporary file @file{global_motions.trf}. Default
  10243. value is 0.
  10244. @end table
  10245. @subsection Examples
  10246. @itemize
  10247. @item
  10248. Use @command{ffmpeg} for a typical stabilization with default values:
  10249. @example
  10250. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  10251. @end example
  10252. Note the use of the @ref{unsharp} filter which is always recommended.
  10253. @item
  10254. Zoom in a bit more and load transform data from a given file:
  10255. @example
  10256. vidstabtransform=zoom=5:input="mytransforms.trf"
  10257. @end example
  10258. @item
  10259. Smoothen the video even more:
  10260. @example
  10261. vidstabtransform=smoothing=30
  10262. @end example
  10263. @end itemize
  10264. @section vflip
  10265. Flip the input video vertically.
  10266. For example, to vertically flip a video with @command{ffmpeg}:
  10267. @example
  10268. ffmpeg -i in.avi -vf "vflip" out.avi
  10269. @end example
  10270. @anchor{vignette}
  10271. @section vignette
  10272. Make or reverse a natural vignetting effect.
  10273. The filter accepts the following options:
  10274. @table @option
  10275. @item angle, a
  10276. Set lens angle expression as a number of radians.
  10277. The value is clipped in the @code{[0,PI/2]} range.
  10278. Default value: @code{"PI/5"}
  10279. @item x0
  10280. @item y0
  10281. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  10282. by default.
  10283. @item mode
  10284. Set forward/backward mode.
  10285. Available modes are:
  10286. @table @samp
  10287. @item forward
  10288. The larger the distance from the central point, the darker the image becomes.
  10289. @item backward
  10290. The larger the distance from the central point, the brighter the image becomes.
  10291. This can be used to reverse a vignette effect, though there is no automatic
  10292. detection to extract the lens @option{angle} and other settings (yet). It can
  10293. also be used to create a burning effect.
  10294. @end table
  10295. Default value is @samp{forward}.
  10296. @item eval
  10297. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  10298. It accepts the following values:
  10299. @table @samp
  10300. @item init
  10301. Evaluate expressions only once during the filter initialization.
  10302. @item frame
  10303. Evaluate expressions for each incoming frame. This is way slower than the
  10304. @samp{init} mode since it requires all the scalers to be re-computed, but it
  10305. allows advanced dynamic expressions.
  10306. @end table
  10307. Default value is @samp{init}.
  10308. @item dither
  10309. Set dithering to reduce the circular banding effects. Default is @code{1}
  10310. (enabled).
  10311. @item aspect
  10312. Set vignette aspect. This setting allows one to adjust the shape of the vignette.
  10313. Setting this value to the SAR of the input will make a rectangular vignetting
  10314. following the dimensions of the video.
  10315. Default is @code{1/1}.
  10316. @end table
  10317. @subsection Expressions
  10318. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  10319. following parameters.
  10320. @table @option
  10321. @item w
  10322. @item h
  10323. input width and height
  10324. @item n
  10325. the number of input frame, starting from 0
  10326. @item pts
  10327. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  10328. @var{TB} units, NAN if undefined
  10329. @item r
  10330. frame rate of the input video, NAN if the input frame rate is unknown
  10331. @item t
  10332. the PTS (Presentation TimeStamp) of the filtered video frame,
  10333. expressed in seconds, NAN if undefined
  10334. @item tb
  10335. time base of the input video
  10336. @end table
  10337. @subsection Examples
  10338. @itemize
  10339. @item
  10340. Apply simple strong vignetting effect:
  10341. @example
  10342. vignette=PI/4
  10343. @end example
  10344. @item
  10345. Make a flickering vignetting:
  10346. @example
  10347. vignette='PI/4+random(1)*PI/50':eval=frame
  10348. @end example
  10349. @end itemize
  10350. @section vstack
  10351. Stack input videos vertically.
  10352. All streams must be of same pixel format and of same width.
  10353. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  10354. to create same output.
  10355. The filter accept the following option:
  10356. @table @option
  10357. @item inputs
  10358. Set number of input streams. Default is 2.
  10359. @item shortest
  10360. If set to 1, force the output to terminate when the shortest input
  10361. terminates. Default value is 0.
  10362. @end table
  10363. @section w3fdif
  10364. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  10365. Deinterlacing Filter").
  10366. Based on the process described by Martin Weston for BBC R&D, and
  10367. implemented based on the de-interlace algorithm written by Jim
  10368. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  10369. uses filter coefficients calculated by BBC R&D.
  10370. There are two sets of filter coefficients, so called "simple":
  10371. and "complex". Which set of filter coefficients is used can
  10372. be set by passing an optional parameter:
  10373. @table @option
  10374. @item filter
  10375. Set the interlacing filter coefficients. Accepts one of the following values:
  10376. @table @samp
  10377. @item simple
  10378. Simple filter coefficient set.
  10379. @item complex
  10380. More-complex filter coefficient set.
  10381. @end table
  10382. Default value is @samp{complex}.
  10383. @item deint
  10384. Specify which frames to deinterlace. Accept one of the following values:
  10385. @table @samp
  10386. @item all
  10387. Deinterlace all frames,
  10388. @item interlaced
  10389. Only deinterlace frames marked as interlaced.
  10390. @end table
  10391. Default value is @samp{all}.
  10392. @end table
  10393. @section waveform
  10394. Video waveform monitor.
  10395. The waveform monitor plots color component intensity. By default luminance
  10396. only. Each column of the waveform corresponds to a column of pixels in the
  10397. source video.
  10398. It accepts the following options:
  10399. @table @option
  10400. @item mode, m
  10401. Can be either @code{row}, or @code{column}. Default is @code{column}.
  10402. In row mode, the graph on the left side represents color component value 0 and
  10403. the right side represents value = 255. In column mode, the top side represents
  10404. color component value = 0 and bottom side represents value = 255.
  10405. @item intensity, i
  10406. Set intensity. Smaller values are useful to find out how many values of the same
  10407. luminance are distributed across input rows/columns.
  10408. Default value is @code{0.04}. Allowed range is [0, 1].
  10409. @item mirror, r
  10410. Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored.
  10411. In mirrored mode, higher values will be represented on the left
  10412. side for @code{row} mode and at the top for @code{column} mode. Default is
  10413. @code{1} (mirrored).
  10414. @item display, d
  10415. Set display mode.
  10416. It accepts the following values:
  10417. @table @samp
  10418. @item overlay
  10419. Presents information identical to that in the @code{parade}, except
  10420. that the graphs representing color components are superimposed directly
  10421. over one another.
  10422. This display mode makes it easier to spot relative differences or similarities
  10423. in overlapping areas of the color components that are supposed to be identical,
  10424. such as neutral whites, grays, or blacks.
  10425. @item stack
  10426. Display separate graph for the color components side by side in
  10427. @code{row} mode or one below the other in @code{column} mode.
  10428. @item parade
  10429. Display separate graph for the color components side by side in
  10430. @code{column} mode or one below the other in @code{row} mode.
  10431. Using this display mode makes it easy to spot color casts in the highlights
  10432. and shadows of an image, by comparing the contours of the top and the bottom
  10433. graphs of each waveform. Since whites, grays, and blacks are characterized
  10434. by exactly equal amounts of red, green, and blue, neutral areas of the picture
  10435. should display three waveforms of roughly equal width/height. If not, the
  10436. correction is easy to perform by making level adjustments the three waveforms.
  10437. @end table
  10438. Default is @code{stack}.
  10439. @item components, c
  10440. Set which color components to display. Default is 1, which means only luminance
  10441. or red color component if input is in RGB colorspace. If is set for example to
  10442. 7 it will display all 3 (if) available color components.
  10443. @item envelope, e
  10444. @table @samp
  10445. @item none
  10446. No envelope, this is default.
  10447. @item instant
  10448. Instant envelope, minimum and maximum values presented in graph will be easily
  10449. visible even with small @code{step} value.
  10450. @item peak
  10451. Hold minimum and maximum values presented in graph across time. This way you
  10452. can still spot out of range values without constantly looking at waveforms.
  10453. @item peak+instant
  10454. Peak and instant envelope combined together.
  10455. @end table
  10456. @item filter, f
  10457. @table @samp
  10458. @item lowpass
  10459. No filtering, this is default.
  10460. @item flat
  10461. Luma and chroma combined together.
  10462. @item aflat
  10463. Similar as above, but shows difference between blue and red chroma.
  10464. @item chroma
  10465. Displays only chroma.
  10466. @item color
  10467. Displays actual color value on waveform.
  10468. @item acolor
  10469. Similar as above, but with luma showing frequency of chroma values.
  10470. @end table
  10471. @item graticule, g
  10472. Set which graticule to display.
  10473. @table @samp
  10474. @item none
  10475. Do not display graticule.
  10476. @item green
  10477. Display green graticule showing legal broadcast ranges.
  10478. @end table
  10479. @item opacity, o
  10480. Set graticule opacity.
  10481. @item flags, fl
  10482. Set graticule flags.
  10483. @table @samp
  10484. @item numbers
  10485. Draw numbers above lines. By default enabled.
  10486. @item dots
  10487. Draw dots instead of lines.
  10488. @end table
  10489. @item scale, s
  10490. Set scale used for displaying graticule.
  10491. @table @samp
  10492. @item digital
  10493. @item millivolts
  10494. @item ire
  10495. @end table
  10496. Default is digital.
  10497. @end table
  10498. @section xbr
  10499. Apply the xBR high-quality magnification filter which is designed for pixel
  10500. art. It follows a set of edge-detection rules, see
  10501. @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
  10502. It accepts the following option:
  10503. @table @option
  10504. @item n
  10505. Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
  10506. @code{3xBR} and @code{4} for @code{4xBR}.
  10507. Default is @code{3}.
  10508. @end table
  10509. @anchor{yadif}
  10510. @section yadif
  10511. Deinterlace the input video ("yadif" means "yet another deinterlacing
  10512. filter").
  10513. It accepts the following parameters:
  10514. @table @option
  10515. @item mode
  10516. The interlacing mode to adopt. It accepts one of the following values:
  10517. @table @option
  10518. @item 0, send_frame
  10519. Output one frame for each frame.
  10520. @item 1, send_field
  10521. Output one frame for each field.
  10522. @item 2, send_frame_nospatial
  10523. Like @code{send_frame}, but it skips the spatial interlacing check.
  10524. @item 3, send_field_nospatial
  10525. Like @code{send_field}, but it skips the spatial interlacing check.
  10526. @end table
  10527. The default value is @code{send_frame}.
  10528. @item parity
  10529. The picture field parity assumed for the input interlaced video. It accepts one
  10530. of the following values:
  10531. @table @option
  10532. @item 0, tff
  10533. Assume the top field is first.
  10534. @item 1, bff
  10535. Assume the bottom field is first.
  10536. @item -1, auto
  10537. Enable automatic detection of field parity.
  10538. @end table
  10539. The default value is @code{auto}.
  10540. If the interlacing is unknown or the decoder does not export this information,
  10541. top field first will be assumed.
  10542. @item deint
  10543. Specify which frames to deinterlace. Accept one of the following
  10544. values:
  10545. @table @option
  10546. @item 0, all
  10547. Deinterlace all frames.
  10548. @item 1, interlaced
  10549. Only deinterlace frames marked as interlaced.
  10550. @end table
  10551. The default value is @code{all}.
  10552. @end table
  10553. @section zoompan
  10554. Apply Zoom & Pan effect.
  10555. This filter accepts the following options:
  10556. @table @option
  10557. @item zoom, z
  10558. Set the zoom expression. Default is 1.
  10559. @item x
  10560. @item y
  10561. Set the x and y expression. Default is 0.
  10562. @item d
  10563. Set the duration expression in number of frames.
  10564. This sets for how many number of frames effect will last for
  10565. single input image.
  10566. @item s
  10567. Set the output image size, default is 'hd720'.
  10568. @item fps
  10569. Set the output frame rate, default is '25'.
  10570. @end table
  10571. Each expression can contain the following constants:
  10572. @table @option
  10573. @item in_w, iw
  10574. Input width.
  10575. @item in_h, ih
  10576. Input height.
  10577. @item out_w, ow
  10578. Output width.
  10579. @item out_h, oh
  10580. Output height.
  10581. @item in
  10582. Input frame count.
  10583. @item on
  10584. Output frame count.
  10585. @item x
  10586. @item y
  10587. Last calculated 'x' and 'y' position from 'x' and 'y' expression
  10588. for current input frame.
  10589. @item px
  10590. @item py
  10591. 'x' and 'y' of last output frame of previous input frame or 0 when there was
  10592. not yet such frame (first input frame).
  10593. @item zoom
  10594. Last calculated zoom from 'z' expression for current input frame.
  10595. @item pzoom
  10596. Last calculated zoom of last output frame of previous input frame.
  10597. @item duration
  10598. Number of output frames for current input frame. Calculated from 'd' expression
  10599. for each input frame.
  10600. @item pduration
  10601. number of output frames created for previous input frame
  10602. @item a
  10603. Rational number: input width / input height
  10604. @item sar
  10605. sample aspect ratio
  10606. @item dar
  10607. display aspect ratio
  10608. @end table
  10609. @subsection Examples
  10610. @itemize
  10611. @item
  10612. Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
  10613. @example
  10614. 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
  10615. @end example
  10616. @item
  10617. Zoom-in up to 1.5 and pan always at center of picture:
  10618. @example
  10619. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
  10620. @end example
  10621. @end itemize
  10622. @section zscale
  10623. Scale (resize) the input video, using the z.lib library:
  10624. https://github.com/sekrit-twc/zimg.
  10625. The zscale filter forces the output display aspect ratio to be the same
  10626. as the input, by changing the output sample aspect ratio.
  10627. If the input image format is different from the format requested by
  10628. the next filter, the zscale filter will convert the input to the
  10629. requested format.
  10630. @subsection Options
  10631. The filter accepts the following options.
  10632. @table @option
  10633. @item width, w
  10634. @item height, h
  10635. Set the output video dimension expression. Default value is the input
  10636. dimension.
  10637. If the @var{width} or @var{w} is 0, the input width is used for the output.
  10638. If the @var{height} or @var{h} is 0, the input height is used for the output.
  10639. If one of the values is -1, the zscale filter will use a value that
  10640. maintains the aspect ratio of the input image, calculated from the
  10641. other specified dimension. If both of them are -1, the input size is
  10642. used
  10643. If one of the values is -n with n > 1, the zscale filter will also use a value
  10644. that maintains the aspect ratio of the input image, calculated from the other
  10645. specified dimension. After that it will, however, make sure that the calculated
  10646. dimension is divisible by n and adjust the value if necessary.
  10647. See below for the list of accepted constants for use in the dimension
  10648. expression.
  10649. @item size, s
  10650. Set the video size. For the syntax of this option, check the
  10651. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10652. @item dither, d
  10653. Set the dither type.
  10654. Possible values are:
  10655. @table @var
  10656. @item none
  10657. @item ordered
  10658. @item random
  10659. @item error_diffusion
  10660. @end table
  10661. Default is none.
  10662. @item filter, f
  10663. Set the resize filter type.
  10664. Possible values are:
  10665. @table @var
  10666. @item point
  10667. @item bilinear
  10668. @item bicubic
  10669. @item spline16
  10670. @item spline36
  10671. @item lanczos
  10672. @end table
  10673. Default is bilinear.
  10674. @item range, r
  10675. Set the color range.
  10676. Possible values are:
  10677. @table @var
  10678. @item input
  10679. @item limited
  10680. @item full
  10681. @end table
  10682. Default is same as input.
  10683. @item primaries, p
  10684. Set the color primaries.
  10685. Possible values are:
  10686. @table @var
  10687. @item input
  10688. @item 709
  10689. @item unspecified
  10690. @item 170m
  10691. @item 240m
  10692. @item 2020
  10693. @end table
  10694. Default is same as input.
  10695. @item transfer, t
  10696. Set the transfer characteristics.
  10697. Possible values are:
  10698. @table @var
  10699. @item input
  10700. @item 709
  10701. @item unspecified
  10702. @item 601
  10703. @item linear
  10704. @item 2020_10
  10705. @item 2020_12
  10706. @end table
  10707. Default is same as input.
  10708. @item matrix, m
  10709. Set the colorspace matrix.
  10710. Possible value are:
  10711. @table @var
  10712. @item input
  10713. @item 709
  10714. @item unspecified
  10715. @item 470bg
  10716. @item 170m
  10717. @item 2020_ncl
  10718. @item 2020_cl
  10719. @end table
  10720. Default is same as input.
  10721. @item rangein, rin
  10722. Set the input color range.
  10723. Possible values are:
  10724. @table @var
  10725. @item input
  10726. @item limited
  10727. @item full
  10728. @end table
  10729. Default is same as input.
  10730. @item primariesin, pin
  10731. Set the input color primaries.
  10732. Possible values are:
  10733. @table @var
  10734. @item input
  10735. @item 709
  10736. @item unspecified
  10737. @item 170m
  10738. @item 240m
  10739. @item 2020
  10740. @end table
  10741. Default is same as input.
  10742. @item transferin, tin
  10743. Set the input transfer characteristics.
  10744. Possible values are:
  10745. @table @var
  10746. @item input
  10747. @item 709
  10748. @item unspecified
  10749. @item 601
  10750. @item linear
  10751. @item 2020_10
  10752. @item 2020_12
  10753. @end table
  10754. Default is same as input.
  10755. @item matrixin, min
  10756. Set the input colorspace matrix.
  10757. Possible value are:
  10758. @table @var
  10759. @item input
  10760. @item 709
  10761. @item unspecified
  10762. @item 470bg
  10763. @item 170m
  10764. @item 2020_ncl
  10765. @item 2020_cl
  10766. @end table
  10767. @end table
  10768. The values of the @option{w} and @option{h} options are expressions
  10769. containing the following constants:
  10770. @table @var
  10771. @item in_w
  10772. @item in_h
  10773. The input width and height
  10774. @item iw
  10775. @item ih
  10776. These are the same as @var{in_w} and @var{in_h}.
  10777. @item out_w
  10778. @item out_h
  10779. The output (scaled) width and height
  10780. @item ow
  10781. @item oh
  10782. These are the same as @var{out_w} and @var{out_h}
  10783. @item a
  10784. The same as @var{iw} / @var{ih}
  10785. @item sar
  10786. input sample aspect ratio
  10787. @item dar
  10788. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  10789. @item hsub
  10790. @item vsub
  10791. horizontal and vertical input chroma subsample values. For example for the
  10792. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  10793. @item ohsub
  10794. @item ovsub
  10795. horizontal and vertical output chroma subsample values. For example for the
  10796. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  10797. @end table
  10798. @table @option
  10799. @end table
  10800. @c man end VIDEO FILTERS
  10801. @chapter Video Sources
  10802. @c man begin VIDEO SOURCES
  10803. Below is a description of the currently available video sources.
  10804. @section buffer
  10805. Buffer video frames, and make them available to the filter chain.
  10806. This source is mainly intended for a programmatic use, in particular
  10807. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  10808. It accepts the following parameters:
  10809. @table @option
  10810. @item video_size
  10811. Specify the size (width and height) of the buffered video frames. For the
  10812. syntax of this option, check the
  10813. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10814. @item width
  10815. The input video width.
  10816. @item height
  10817. The input video height.
  10818. @item pix_fmt
  10819. A string representing the pixel format of the buffered video frames.
  10820. It may be a number corresponding to a pixel format, or a pixel format
  10821. name.
  10822. @item time_base
  10823. Specify the timebase assumed by the timestamps of the buffered frames.
  10824. @item frame_rate
  10825. Specify the frame rate expected for the video stream.
  10826. @item pixel_aspect, sar
  10827. The sample (pixel) aspect ratio of the input video.
  10828. @item sws_param
  10829. Specify the optional parameters to be used for the scale filter which
  10830. is automatically inserted when an input change is detected in the
  10831. input size or format.
  10832. @item hw_frames_ctx
  10833. When using a hardware pixel format, this should be a reference to an
  10834. AVHWFramesContext describing input frames.
  10835. @end table
  10836. For example:
  10837. @example
  10838. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  10839. @end example
  10840. will instruct the source to accept video frames with size 320x240 and
  10841. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  10842. square pixels (1:1 sample aspect ratio).
  10843. Since the pixel format with name "yuv410p" corresponds to the number 6
  10844. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  10845. this example corresponds to:
  10846. @example
  10847. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  10848. @end example
  10849. Alternatively, the options can be specified as a flat string, but this
  10850. syntax is deprecated:
  10851. @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}]
  10852. @section cellauto
  10853. Create a pattern generated by an elementary cellular automaton.
  10854. The initial state of the cellular automaton can be defined through the
  10855. @option{filename}, and @option{pattern} options. If such options are
  10856. not specified an initial state is created randomly.
  10857. At each new frame a new row in the video is filled with the result of
  10858. the cellular automaton next generation. The behavior when the whole
  10859. frame is filled is defined by the @option{scroll} option.
  10860. This source accepts the following options:
  10861. @table @option
  10862. @item filename, f
  10863. Read the initial cellular automaton state, i.e. the starting row, from
  10864. the specified file.
  10865. In the file, each non-whitespace character is considered an alive
  10866. cell, a newline will terminate the row, and further characters in the
  10867. file will be ignored.
  10868. @item pattern, p
  10869. Read the initial cellular automaton state, i.e. the starting row, from
  10870. the specified string.
  10871. Each non-whitespace character in the string is considered an alive
  10872. cell, a newline will terminate the row, and further characters in the
  10873. string will be ignored.
  10874. @item rate, r
  10875. Set the video rate, that is the number of frames generated per second.
  10876. Default is 25.
  10877. @item random_fill_ratio, ratio
  10878. Set the random fill ratio for the initial cellular automaton row. It
  10879. is a floating point number value ranging from 0 to 1, defaults to
  10880. 1/PHI.
  10881. This option is ignored when a file or a pattern is specified.
  10882. @item random_seed, seed
  10883. Set the seed for filling randomly the initial row, must be an integer
  10884. included between 0 and UINT32_MAX. If not specified, or if explicitly
  10885. set to -1, the filter will try to use a good random seed on a best
  10886. effort basis.
  10887. @item rule
  10888. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  10889. Default value is 110.
  10890. @item size, s
  10891. Set the size of the output video. For the syntax of this option, check the
  10892. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10893. If @option{filename} or @option{pattern} is specified, the size is set
  10894. by default to the width of the specified initial state row, and the
  10895. height is set to @var{width} * PHI.
  10896. If @option{size} is set, it must contain the width of the specified
  10897. pattern string, and the specified pattern will be centered in the
  10898. larger row.
  10899. If a filename or a pattern string is not specified, the size value
  10900. defaults to "320x518" (used for a randomly generated initial state).
  10901. @item scroll
  10902. If set to 1, scroll the output upward when all the rows in the output
  10903. have been already filled. If set to 0, the new generated row will be
  10904. written over the top row just after the bottom row is filled.
  10905. Defaults to 1.
  10906. @item start_full, full
  10907. If set to 1, completely fill the output with generated rows before
  10908. outputting the first frame.
  10909. This is the default behavior, for disabling set the value to 0.
  10910. @item stitch
  10911. If set to 1, stitch the left and right row edges together.
  10912. This is the default behavior, for disabling set the value to 0.
  10913. @end table
  10914. @subsection Examples
  10915. @itemize
  10916. @item
  10917. Read the initial state from @file{pattern}, and specify an output of
  10918. size 200x400.
  10919. @example
  10920. cellauto=f=pattern:s=200x400
  10921. @end example
  10922. @item
  10923. Generate a random initial row with a width of 200 cells, with a fill
  10924. ratio of 2/3:
  10925. @example
  10926. cellauto=ratio=2/3:s=200x200
  10927. @end example
  10928. @item
  10929. Create a pattern generated by rule 18 starting by a single alive cell
  10930. centered on an initial row with width 100:
  10931. @example
  10932. cellauto=p=@@:s=100x400:full=0:rule=18
  10933. @end example
  10934. @item
  10935. Specify a more elaborated initial pattern:
  10936. @example
  10937. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  10938. @end example
  10939. @end itemize
  10940. @anchor{coreimagesrc}
  10941. @section coreimagesrc
  10942. Video source generated on GPU using Apple's CoreImage API on OSX.
  10943. This video source is a specialized version of the @ref{coreimage} video filter.
  10944. Use a core image generator at the beginning of the applied filterchain to
  10945. generate the content.
  10946. The coreimagesrc video source accepts the following options:
  10947. @table @option
  10948. @item list_generators
  10949. List all available generators along with all their respective options as well as
  10950. possible minimum and maximum values along with the default values.
  10951. @example
  10952. list_generators=true
  10953. @end example
  10954. @item size, s
  10955. Specify the size of the sourced video. For the syntax of this option, check the
  10956. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10957. The default value is @code{320x240}.
  10958. @item rate, r
  10959. Specify the frame rate of the sourced video, as the number of frames
  10960. generated per second. It has to be a string in the format
  10961. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  10962. number or a valid video frame rate abbreviation. The default value is
  10963. "25".
  10964. @item sar
  10965. Set the sample aspect ratio of the sourced video.
  10966. @item duration, d
  10967. Set the duration of the sourced video. See
  10968. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  10969. for the accepted syntax.
  10970. If not specified, or the expressed duration is negative, the video is
  10971. supposed to be generated forever.
  10972. @end table
  10973. Additionally, all options of the @ref{coreimage} video filter are accepted.
  10974. A complete filterchain can be used for further processing of the
  10975. generated input without CPU-HOST transfer. See @ref{coreimage} documentation
  10976. and examples for details.
  10977. @subsection Examples
  10978. @itemize
  10979. @item
  10980. Use CIQRCodeGenerator to create a QR code for the FFmpeg homepage,
  10981. given as complete and escaped command-line for Apple's standard bash shell:
  10982. @example
  10983. ffmpeg -f lavfi -i coreimagesrc=s=100x100:filter=CIQRCodeGenerator@@inputMessage=https\\\\\://FFmpeg.org/@@inputCorrectionLevel=H -frames:v 1 QRCode.png
  10984. @end example
  10985. This example is equivalent to the QRCode example of @ref{coreimage} without the
  10986. need for a nullsrc video source.
  10987. @end itemize
  10988. @section mandelbrot
  10989. Generate a Mandelbrot set fractal, and progressively zoom towards the
  10990. point specified with @var{start_x} and @var{start_y}.
  10991. This source accepts the following options:
  10992. @table @option
  10993. @item end_pts
  10994. Set the terminal pts value. Default value is 400.
  10995. @item end_scale
  10996. Set the terminal scale value.
  10997. Must be a floating point value. Default value is 0.3.
  10998. @item inner
  10999. Set the inner coloring mode, that is the algorithm used to draw the
  11000. Mandelbrot fractal internal region.
  11001. It shall assume one of the following values:
  11002. @table @option
  11003. @item black
  11004. Set black mode.
  11005. @item convergence
  11006. Show time until convergence.
  11007. @item mincol
  11008. Set color based on point closest to the origin of the iterations.
  11009. @item period
  11010. Set period mode.
  11011. @end table
  11012. Default value is @var{mincol}.
  11013. @item bailout
  11014. Set the bailout value. Default value is 10.0.
  11015. @item maxiter
  11016. Set the maximum of iterations performed by the rendering
  11017. algorithm. Default value is 7189.
  11018. @item outer
  11019. Set outer coloring mode.
  11020. It shall assume one of following values:
  11021. @table @option
  11022. @item iteration_count
  11023. Set iteration cound mode.
  11024. @item normalized_iteration_count
  11025. set normalized iteration count mode.
  11026. @end table
  11027. Default value is @var{normalized_iteration_count}.
  11028. @item rate, r
  11029. Set frame rate, expressed as number of frames per second. Default
  11030. value is "25".
  11031. @item size, s
  11032. Set frame size. For the syntax of this option, check the "Video
  11033. size" section in the ffmpeg-utils manual. Default value is "640x480".
  11034. @item start_scale
  11035. Set the initial scale value. Default value is 3.0.
  11036. @item start_x
  11037. Set the initial x position. Must be a floating point value between
  11038. -100 and 100. Default value is -0.743643887037158704752191506114774.
  11039. @item start_y
  11040. Set the initial y position. Must be a floating point value between
  11041. -100 and 100. Default value is -0.131825904205311970493132056385139.
  11042. @end table
  11043. @section mptestsrc
  11044. Generate various test patterns, as generated by the MPlayer test filter.
  11045. The size of the generated video is fixed, and is 256x256.
  11046. This source is useful in particular for testing encoding features.
  11047. This source accepts the following options:
  11048. @table @option
  11049. @item rate, r
  11050. Specify the frame rate of the sourced video, as the number of frames
  11051. generated per second. It has to be a string in the format
  11052. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  11053. number or a valid video frame rate abbreviation. The default value is
  11054. "25".
  11055. @item duration, d
  11056. Set the duration of the sourced video. See
  11057. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  11058. for the accepted syntax.
  11059. If not specified, or the expressed duration is negative, the video is
  11060. supposed to be generated forever.
  11061. @item test, t
  11062. Set the number or the name of the test to perform. Supported tests are:
  11063. @table @option
  11064. @item dc_luma
  11065. @item dc_chroma
  11066. @item freq_luma
  11067. @item freq_chroma
  11068. @item amp_luma
  11069. @item amp_chroma
  11070. @item cbp
  11071. @item mv
  11072. @item ring1
  11073. @item ring2
  11074. @item all
  11075. @end table
  11076. Default value is "all", which will cycle through the list of all tests.
  11077. @end table
  11078. Some examples:
  11079. @example
  11080. mptestsrc=t=dc_luma
  11081. @end example
  11082. will generate a "dc_luma" test pattern.
  11083. @section frei0r_src
  11084. Provide a frei0r source.
  11085. To enable compilation of this filter you need to install the frei0r
  11086. header and configure FFmpeg with @code{--enable-frei0r}.
  11087. This source accepts the following parameters:
  11088. @table @option
  11089. @item size
  11090. The size of the video to generate. For the syntax of this option, check the
  11091. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11092. @item framerate
  11093. The framerate of the generated video. It may be a string of the form
  11094. @var{num}/@var{den} or a frame rate abbreviation.
  11095. @item filter_name
  11096. The name to the frei0r source to load. For more information regarding frei0r and
  11097. how to set the parameters, read the @ref{frei0r} section in the video filters
  11098. documentation.
  11099. @item filter_params
  11100. A '|'-separated list of parameters to pass to the frei0r source.
  11101. @end table
  11102. For example, to generate a frei0r partik0l source with size 200x200
  11103. and frame rate 10 which is overlaid on the overlay filter main input:
  11104. @example
  11105. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  11106. @end example
  11107. @section life
  11108. Generate a life pattern.
  11109. This source is based on a generalization of John Conway's life game.
  11110. The sourced input represents a life grid, each pixel represents a cell
  11111. which can be in one of two possible states, alive or dead. Every cell
  11112. interacts with its eight neighbours, which are the cells that are
  11113. horizontally, vertically, or diagonally adjacent.
  11114. At each interaction the grid evolves according to the adopted rule,
  11115. which specifies the number of neighbor alive cells which will make a
  11116. cell stay alive or born. The @option{rule} option allows one to specify
  11117. the rule to adopt.
  11118. This source accepts the following options:
  11119. @table @option
  11120. @item filename, f
  11121. Set the file from which to read the initial grid state. In the file,
  11122. each non-whitespace character is considered an alive cell, and newline
  11123. is used to delimit the end of each row.
  11124. If this option is not specified, the initial grid is generated
  11125. randomly.
  11126. @item rate, r
  11127. Set the video rate, that is the number of frames generated per second.
  11128. Default is 25.
  11129. @item random_fill_ratio, ratio
  11130. Set the random fill ratio for the initial random grid. It is a
  11131. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  11132. It is ignored when a file is specified.
  11133. @item random_seed, seed
  11134. Set the seed for filling the initial random grid, must be an integer
  11135. included between 0 and UINT32_MAX. If not specified, or if explicitly
  11136. set to -1, the filter will try to use a good random seed on a best
  11137. effort basis.
  11138. @item rule
  11139. Set the life rule.
  11140. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  11141. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  11142. @var{NS} specifies the number of alive neighbor cells which make a
  11143. live cell stay alive, and @var{NB} the number of alive neighbor cells
  11144. which make a dead cell to become alive (i.e. to "born").
  11145. "s" and "b" can be used in place of "S" and "B", respectively.
  11146. Alternatively a rule can be specified by an 18-bits integer. The 9
  11147. high order bits are used to encode the next cell state if it is alive
  11148. for each number of neighbor alive cells, the low order bits specify
  11149. the rule for "borning" new cells. Higher order bits encode for an
  11150. higher number of neighbor cells.
  11151. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  11152. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  11153. Default value is "S23/B3", which is the original Conway's game of life
  11154. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  11155. cells, and will born a new cell if there are three alive cells around
  11156. a dead cell.
  11157. @item size, s
  11158. Set the size of the output video. For the syntax of this option, check the
  11159. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11160. If @option{filename} is specified, the size is set by default to the
  11161. same size of the input file. If @option{size} is set, it must contain
  11162. the size specified in the input file, and the initial grid defined in
  11163. that file is centered in the larger resulting area.
  11164. If a filename is not specified, the size value defaults to "320x240"
  11165. (used for a randomly generated initial grid).
  11166. @item stitch
  11167. If set to 1, stitch the left and right grid edges together, and the
  11168. top and bottom edges also. Defaults to 1.
  11169. @item mold
  11170. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  11171. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  11172. value from 0 to 255.
  11173. @item life_color
  11174. Set the color of living (or new born) cells.
  11175. @item death_color
  11176. Set the color of dead cells. If @option{mold} is set, this is the first color
  11177. used to represent a dead cell.
  11178. @item mold_color
  11179. Set mold color, for definitely dead and moldy cells.
  11180. For the syntax of these 3 color options, check the "Color" section in the
  11181. ffmpeg-utils manual.
  11182. @end table
  11183. @subsection Examples
  11184. @itemize
  11185. @item
  11186. Read a grid from @file{pattern}, and center it on a grid of size
  11187. 300x300 pixels:
  11188. @example
  11189. life=f=pattern:s=300x300
  11190. @end example
  11191. @item
  11192. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  11193. @example
  11194. life=ratio=2/3:s=200x200
  11195. @end example
  11196. @item
  11197. Specify a custom rule for evolving a randomly generated grid:
  11198. @example
  11199. life=rule=S14/B34
  11200. @end example
  11201. @item
  11202. Full example with slow death effect (mold) using @command{ffplay}:
  11203. @example
  11204. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  11205. @end example
  11206. @end itemize
  11207. @anchor{allrgb}
  11208. @anchor{allyuv}
  11209. @anchor{color}
  11210. @anchor{haldclutsrc}
  11211. @anchor{nullsrc}
  11212. @anchor{rgbtestsrc}
  11213. @anchor{smptebars}
  11214. @anchor{smptehdbars}
  11215. @anchor{testsrc}
  11216. @anchor{testsrc2}
  11217. @section allrgb, allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc, testsrc2
  11218. The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
  11219. The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
  11220. The @code{color} source provides an uniformly colored input.
  11221. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  11222. @ref{haldclut} filter.
  11223. The @code{nullsrc} source returns unprocessed video frames. It is
  11224. mainly useful to be employed in analysis / debugging tools, or as the
  11225. source for filters which ignore the input data.
  11226. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  11227. detecting RGB vs BGR issues. You should see a red, green and blue
  11228. stripe from top to bottom.
  11229. The @code{smptebars} source generates a color bars pattern, based on
  11230. the SMPTE Engineering Guideline EG 1-1990.
  11231. The @code{smptehdbars} source generates a color bars pattern, based on
  11232. the SMPTE RP 219-2002.
  11233. The @code{testsrc} source generates a test video pattern, showing a
  11234. color pattern, a scrolling gradient and a timestamp. This is mainly
  11235. intended for testing purposes.
  11236. The @code{testsrc2} source is similar to testsrc, but supports more
  11237. pixel formats instead of just @code{rgb24}. This allows using it as an
  11238. input for other tests without requiring a format conversion.
  11239. The sources accept the following parameters:
  11240. @table @option
  11241. @item color, c
  11242. Specify the color of the source, only available in the @code{color}
  11243. source. For the syntax of this option, check the "Color" section in the
  11244. ffmpeg-utils manual.
  11245. @item level
  11246. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  11247. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  11248. pixels to be used as identity matrix for 3D lookup tables. Each component is
  11249. coded on a @code{1/(N*N)} scale.
  11250. @item size, s
  11251. Specify the size of the sourced video. For the syntax of this option, check the
  11252. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11253. The default value is @code{320x240}.
  11254. This option is not available with the @code{haldclutsrc} filter.
  11255. @item rate, r
  11256. Specify the frame rate of the sourced video, as the number of frames
  11257. generated per second. It has to be a string in the format
  11258. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  11259. number or a valid video frame rate abbreviation. The default value is
  11260. "25".
  11261. @item sar
  11262. Set the sample aspect ratio of the sourced video.
  11263. @item duration, d
  11264. Set the duration of the sourced video. See
  11265. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  11266. for the accepted syntax.
  11267. If not specified, or the expressed duration is negative, the video is
  11268. supposed to be generated forever.
  11269. @item decimals, n
  11270. Set the number of decimals to show in the timestamp, only available in the
  11271. @code{testsrc} source.
  11272. The displayed timestamp value will correspond to the original
  11273. timestamp value multiplied by the power of 10 of the specified
  11274. value. Default value is 0.
  11275. @end table
  11276. For example the following:
  11277. @example
  11278. testsrc=duration=5.3:size=qcif:rate=10
  11279. @end example
  11280. will generate a video with a duration of 5.3 seconds, with size
  11281. 176x144 and a frame rate of 10 frames per second.
  11282. The following graph description will generate a red source
  11283. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  11284. frames per second.
  11285. @example
  11286. color=c=red@@0.2:s=qcif:r=10
  11287. @end example
  11288. If the input content is to be ignored, @code{nullsrc} can be used. The
  11289. following command generates noise in the luminance plane by employing
  11290. the @code{geq} filter:
  11291. @example
  11292. nullsrc=s=256x256, geq=random(1)*255:128:128
  11293. @end example
  11294. @subsection Commands
  11295. The @code{color} source supports the following commands:
  11296. @table @option
  11297. @item c, color
  11298. Set the color of the created image. Accepts the same syntax of the
  11299. corresponding @option{color} option.
  11300. @end table
  11301. @c man end VIDEO SOURCES
  11302. @chapter Video Sinks
  11303. @c man begin VIDEO SINKS
  11304. Below is a description of the currently available video sinks.
  11305. @section buffersink
  11306. Buffer video frames, and make them available to the end of the filter
  11307. graph.
  11308. This sink is mainly intended for programmatic use, in particular
  11309. through the interface defined in @file{libavfilter/buffersink.h}
  11310. or the options system.
  11311. It accepts a pointer to an AVBufferSinkContext structure, which
  11312. defines the incoming buffers' formats, to be passed as the opaque
  11313. parameter to @code{avfilter_init_filter} for initialization.
  11314. @section nullsink
  11315. Null video sink: do absolutely nothing with the input video. It is
  11316. mainly useful as a template and for use in analysis / debugging
  11317. tools.
  11318. @c man end VIDEO SINKS
  11319. @chapter Multimedia Filters
  11320. @c man begin MULTIMEDIA FILTERS
  11321. Below is a description of the currently available multimedia filters.
  11322. @section ahistogram
  11323. Convert input audio to a video output, displaying the volume histogram.
  11324. The filter accepts the following options:
  11325. @table @option
  11326. @item dmode
  11327. Specify how histogram is calculated.
  11328. It accepts the following values:
  11329. @table @samp
  11330. @item single
  11331. Use single histogram for all channels.
  11332. @item separate
  11333. Use separate histogram for each channel.
  11334. @end table
  11335. Default is @code{single}.
  11336. @item rate, r
  11337. Set frame rate, expressed as number of frames per second. Default
  11338. value is "25".
  11339. @item size, s
  11340. Specify the video size for the output. For the syntax of this option, check the
  11341. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11342. Default value is @code{hd720}.
  11343. @item scale
  11344. Set display scale.
  11345. It accepts the following values:
  11346. @table @samp
  11347. @item log
  11348. logarithmic
  11349. @item sqrt
  11350. square root
  11351. @item cbrt
  11352. cubic root
  11353. @item lin
  11354. linear
  11355. @item rlog
  11356. reverse logarithmic
  11357. @end table
  11358. Default is @code{log}.
  11359. @item ascale
  11360. Set amplitude scale.
  11361. It accepts the following values:
  11362. @table @samp
  11363. @item log
  11364. logarithmic
  11365. @item lin
  11366. linear
  11367. @end table
  11368. Default is @code{log}.
  11369. @item acount
  11370. Set how much frames to accumulate in histogram.
  11371. Defauls is 1. Setting this to -1 accumulates all frames.
  11372. @item rheight
  11373. Set histogram ratio of window height.
  11374. @item slide
  11375. Set sonogram sliding.
  11376. It accepts the following values:
  11377. @table @samp
  11378. @item replace
  11379. replace old rows with new ones.
  11380. @item scroll
  11381. scroll from top to bottom.
  11382. @end table
  11383. Default is @code{replace}.
  11384. @end table
  11385. @section aphasemeter
  11386. Convert input audio to a video output, displaying the audio phase.
  11387. The filter accepts the following options:
  11388. @table @option
  11389. @item rate, r
  11390. Set the output frame rate. Default value is @code{25}.
  11391. @item size, s
  11392. Set the video size for the output. For the syntax of this option, check the
  11393. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11394. Default value is @code{800x400}.
  11395. @item rc
  11396. @item gc
  11397. @item bc
  11398. Specify the red, green, blue contrast. Default values are @code{2},
  11399. @code{7} and @code{1}.
  11400. Allowed range is @code{[0, 255]}.
  11401. @item mpc
  11402. Set color which will be used for drawing median phase. If color is
  11403. @code{none} which is default, no median phase value will be drawn.
  11404. @end table
  11405. The filter also exports the frame metadata @code{lavfi.aphasemeter.phase} which
  11406. represents mean phase of current audio frame. Value is in range @code{[-1, 1]}.
  11407. The @code{-1} means left and right channels are completely out of phase and
  11408. @code{1} means channels are in phase.
  11409. @section avectorscope
  11410. Convert input audio to a video output, representing the audio vector
  11411. scope.
  11412. The filter is used to measure the difference between channels of stereo
  11413. audio stream. A monoaural signal, consisting of identical left and right
  11414. signal, results in straight vertical line. Any stereo separation is visible
  11415. as a deviation from this line, creating a Lissajous figure.
  11416. If the straight (or deviation from it) but horizontal line appears this
  11417. indicates that the left and right channels are out of phase.
  11418. The filter accepts the following options:
  11419. @table @option
  11420. @item mode, m
  11421. Set the vectorscope mode.
  11422. Available values are:
  11423. @table @samp
  11424. @item lissajous
  11425. Lissajous rotated by 45 degrees.
  11426. @item lissajous_xy
  11427. Same as above but not rotated.
  11428. @item polar
  11429. Shape resembling half of circle.
  11430. @end table
  11431. Default value is @samp{lissajous}.
  11432. @item size, s
  11433. Set the video size for the output. For the syntax of this option, check the
  11434. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11435. Default value is @code{400x400}.
  11436. @item rate, r
  11437. Set the output frame rate. Default value is @code{25}.
  11438. @item rc
  11439. @item gc
  11440. @item bc
  11441. @item ac
  11442. Specify the red, green, blue and alpha contrast. Default values are @code{40},
  11443. @code{160}, @code{80} and @code{255}.
  11444. Allowed range is @code{[0, 255]}.
  11445. @item rf
  11446. @item gf
  11447. @item bf
  11448. @item af
  11449. Specify the red, green, blue and alpha fade. Default values are @code{15},
  11450. @code{10}, @code{5} and @code{5}.
  11451. Allowed range is @code{[0, 255]}.
  11452. @item zoom
  11453. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  11454. @item draw
  11455. Set the vectorscope drawing mode.
  11456. Available values are:
  11457. @table @samp
  11458. @item dot
  11459. Draw dot for each sample.
  11460. @item line
  11461. Draw line between previous and current sample.
  11462. @end table
  11463. Default value is @samp{dot}.
  11464. @end table
  11465. @subsection Examples
  11466. @itemize
  11467. @item
  11468. Complete example using @command{ffplay}:
  11469. @example
  11470. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  11471. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  11472. @end example
  11473. @end itemize
  11474. @section bench, abench
  11475. Benchmark part of a filtergraph.
  11476. The filter accepts the following options:
  11477. @table @option
  11478. @item action
  11479. Start or stop a timer.
  11480. Available values are:
  11481. @table @samp
  11482. @item start
  11483. Get the current time, set it as frame metadata (using the key
  11484. @code{lavfi.bench.start_time}), and forward the frame to the next filter.
  11485. @item stop
  11486. Get the current time and fetch the @code{lavfi.bench.start_time} metadata from
  11487. the input frame metadata to get the time difference. Time difference, average,
  11488. maximum and minimum time (respectively @code{t}, @code{avg}, @code{max} and
  11489. @code{min}) are then printed. The timestamps are expressed in seconds.
  11490. @end table
  11491. @end table
  11492. @subsection Examples
  11493. @itemize
  11494. @item
  11495. Benchmark @ref{selectivecolor} filter:
  11496. @example
  11497. bench=start,selectivecolor=reds=-.2 .12 -.49,bench=stop
  11498. @end example
  11499. @end itemize
  11500. @section concat
  11501. Concatenate audio and video streams, joining them together one after the
  11502. other.
  11503. The filter works on segments of synchronized video and audio streams. All
  11504. segments must have the same number of streams of each type, and that will
  11505. also be the number of streams at output.
  11506. The filter accepts the following options:
  11507. @table @option
  11508. @item n
  11509. Set the number of segments. Default is 2.
  11510. @item v
  11511. Set the number of output video streams, that is also the number of video
  11512. streams in each segment. Default is 1.
  11513. @item a
  11514. Set the number of output audio streams, that is also the number of audio
  11515. streams in each segment. Default is 0.
  11516. @item unsafe
  11517. Activate unsafe mode: do not fail if segments have a different format.
  11518. @end table
  11519. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  11520. @var{a} audio outputs.
  11521. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  11522. segment, in the same order as the outputs, then the inputs for the second
  11523. segment, etc.
  11524. Related streams do not always have exactly the same duration, for various
  11525. reasons including codec frame size or sloppy authoring. For that reason,
  11526. related synchronized streams (e.g. a video and its audio track) should be
  11527. concatenated at once. The concat filter will use the duration of the longest
  11528. stream in each segment (except the last one), and if necessary pad shorter
  11529. audio streams with silence.
  11530. For this filter to work correctly, all segments must start at timestamp 0.
  11531. All corresponding streams must have the same parameters in all segments; the
  11532. filtering system will automatically select a common pixel format for video
  11533. streams, and a common sample format, sample rate and channel layout for
  11534. audio streams, but other settings, such as resolution, must be converted
  11535. explicitly by the user.
  11536. Different frame rates are acceptable but will result in variable frame rate
  11537. at output; be sure to configure the output file to handle it.
  11538. @subsection Examples
  11539. @itemize
  11540. @item
  11541. Concatenate an opening, an episode and an ending, all in bilingual version
  11542. (video in stream 0, audio in streams 1 and 2):
  11543. @example
  11544. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  11545. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  11546. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  11547. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  11548. @end example
  11549. @item
  11550. Concatenate two parts, handling audio and video separately, using the
  11551. (a)movie sources, and adjusting the resolution:
  11552. @example
  11553. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  11554. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  11555. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  11556. @end example
  11557. Note that a desync will happen at the stitch if the audio and video streams
  11558. do not have exactly the same duration in the first file.
  11559. @end itemize
  11560. @anchor{ebur128}
  11561. @section ebur128
  11562. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  11563. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  11564. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  11565. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  11566. The filter also has a video output (see the @var{video} option) with a real
  11567. time graph to observe the loudness evolution. The graphic contains the logged
  11568. message mentioned above, so it is not printed anymore when this option is set,
  11569. unless the verbose logging is set. The main graphing area contains the
  11570. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  11571. the momentary loudness (400 milliseconds).
  11572. More information about the Loudness Recommendation EBU R128 on
  11573. @url{http://tech.ebu.ch/loudness}.
  11574. The filter accepts the following options:
  11575. @table @option
  11576. @item video
  11577. Activate the video output. The audio stream is passed unchanged whether this
  11578. option is set or no. The video stream will be the first output stream if
  11579. activated. Default is @code{0}.
  11580. @item size
  11581. Set the video size. This option is for video only. For the syntax of this
  11582. option, check the
  11583. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  11584. Default and minimum resolution is @code{640x480}.
  11585. @item meter
  11586. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  11587. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  11588. other integer value between this range is allowed.
  11589. @item metadata
  11590. Set metadata injection. If set to @code{1}, the audio input will be segmented
  11591. into 100ms output frames, each of them containing various loudness information
  11592. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  11593. Default is @code{0}.
  11594. @item framelog
  11595. Force the frame logging level.
  11596. Available values are:
  11597. @table @samp
  11598. @item info
  11599. information logging level
  11600. @item verbose
  11601. verbose logging level
  11602. @end table
  11603. By default, the logging level is set to @var{info}. If the @option{video} or
  11604. the @option{metadata} options are set, it switches to @var{verbose}.
  11605. @item peak
  11606. Set peak mode(s).
  11607. Available modes can be cumulated (the option is a @code{flag} type). Possible
  11608. values are:
  11609. @table @samp
  11610. @item none
  11611. Disable any peak mode (default).
  11612. @item sample
  11613. Enable sample-peak mode.
  11614. Simple peak mode looking for the higher sample value. It logs a message
  11615. for sample-peak (identified by @code{SPK}).
  11616. @item true
  11617. Enable true-peak mode.
  11618. If enabled, the peak lookup is done on an over-sampled version of the input
  11619. stream for better peak accuracy. It logs a message for true-peak.
  11620. (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
  11621. This mode requires a build with @code{libswresample}.
  11622. @end table
  11623. @item dualmono
  11624. Treat mono input files as "dual mono". If a mono file is intended for playback
  11625. on a stereo system, its EBU R128 measurement will be perceptually incorrect.
  11626. If set to @code{true}, this option will compensate for this effect.
  11627. Multi-channel input files are not affected by this option.
  11628. @item panlaw
  11629. Set a specific pan law to be used for the measurement of dual mono files.
  11630. This parameter is optional, and has a default value of -3.01dB.
  11631. @end table
  11632. @subsection Examples
  11633. @itemize
  11634. @item
  11635. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  11636. @example
  11637. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  11638. @end example
  11639. @item
  11640. Run an analysis with @command{ffmpeg}:
  11641. @example
  11642. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  11643. @end example
  11644. @end itemize
  11645. @section interleave, ainterleave
  11646. Temporally interleave frames from several inputs.
  11647. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  11648. These filters read frames from several inputs and send the oldest
  11649. queued frame to the output.
  11650. Input streams must have a well defined, monotonically increasing frame
  11651. timestamp values.
  11652. In order to submit one frame to output, these filters need to enqueue
  11653. at least one frame for each input, so they cannot work in case one
  11654. input is not yet terminated and will not receive incoming frames.
  11655. For example consider the case when one input is a @code{select} filter
  11656. which always drop input frames. The @code{interleave} filter will keep
  11657. reading from that input, but it will never be able to send new frames
  11658. to output until the input will send an end-of-stream signal.
  11659. Also, depending on inputs synchronization, the filters will drop
  11660. frames in case one input receives more frames than the other ones, and
  11661. the queue is already filled.
  11662. These filters accept the following options:
  11663. @table @option
  11664. @item nb_inputs, n
  11665. Set the number of different inputs, it is 2 by default.
  11666. @end table
  11667. @subsection Examples
  11668. @itemize
  11669. @item
  11670. Interleave frames belonging to different streams using @command{ffmpeg}:
  11671. @example
  11672. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  11673. @end example
  11674. @item
  11675. Add flickering blur effect:
  11676. @example
  11677. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  11678. @end example
  11679. @end itemize
  11680. @section perms, aperms
  11681. Set read/write permissions for the output frames.
  11682. These filters are mainly aimed at developers to test direct path in the
  11683. following filter in the filtergraph.
  11684. The filters accept the following options:
  11685. @table @option
  11686. @item mode
  11687. Select the permissions mode.
  11688. It accepts the following values:
  11689. @table @samp
  11690. @item none
  11691. Do nothing. This is the default.
  11692. @item ro
  11693. Set all the output frames read-only.
  11694. @item rw
  11695. Set all the output frames directly writable.
  11696. @item toggle
  11697. Make the frame read-only if writable, and writable if read-only.
  11698. @item random
  11699. Set each output frame read-only or writable randomly.
  11700. @end table
  11701. @item seed
  11702. Set the seed for the @var{random} mode, must be an integer included between
  11703. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  11704. @code{-1}, the filter will try to use a good random seed on a best effort
  11705. basis.
  11706. @end table
  11707. Note: in case of auto-inserted filter between the permission filter and the
  11708. following one, the permission might not be received as expected in that
  11709. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  11710. perms/aperms filter can avoid this problem.
  11711. @section realtime, arealtime
  11712. Slow down filtering to match real time approximatively.
  11713. These filters will pause the filtering for a variable amount of time to
  11714. match the output rate with the input timestamps.
  11715. They are similar to the @option{re} option to @code{ffmpeg}.
  11716. They accept the following options:
  11717. @table @option
  11718. @item limit
  11719. Time limit for the pauses. Any pause longer than that will be considered
  11720. a timestamp discontinuity and reset the timer. Default is 2 seconds.
  11721. @end table
  11722. @section select, aselect
  11723. Select frames to pass in output.
  11724. This filter accepts the following options:
  11725. @table @option
  11726. @item expr, e
  11727. Set expression, which is evaluated for each input frame.
  11728. If the expression is evaluated to zero, the frame is discarded.
  11729. If the evaluation result is negative or NaN, the frame is sent to the
  11730. first output; otherwise it is sent to the output with index
  11731. @code{ceil(val)-1}, assuming that the input index starts from 0.
  11732. For example a value of @code{1.2} corresponds to the output with index
  11733. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  11734. @item outputs, n
  11735. Set the number of outputs. The output to which to send the selected
  11736. frame is based on the result of the evaluation. Default value is 1.
  11737. @end table
  11738. The expression can contain the following constants:
  11739. @table @option
  11740. @item n
  11741. The (sequential) number of the filtered frame, starting from 0.
  11742. @item selected_n
  11743. The (sequential) number of the selected frame, starting from 0.
  11744. @item prev_selected_n
  11745. The sequential number of the last selected frame. It's NAN if undefined.
  11746. @item TB
  11747. The timebase of the input timestamps.
  11748. @item pts
  11749. The PTS (Presentation TimeStamp) of the filtered video frame,
  11750. expressed in @var{TB} units. It's NAN if undefined.
  11751. @item t
  11752. The PTS of the filtered video frame,
  11753. expressed in seconds. It's NAN if undefined.
  11754. @item prev_pts
  11755. The PTS of the previously filtered video frame. It's NAN if undefined.
  11756. @item prev_selected_pts
  11757. The PTS of the last previously filtered video frame. It's NAN if undefined.
  11758. @item prev_selected_t
  11759. The PTS of the last previously selected video frame. It's NAN if undefined.
  11760. @item start_pts
  11761. The PTS of the first video frame in the video. It's NAN if undefined.
  11762. @item start_t
  11763. The time of the first video frame in the video. It's NAN if undefined.
  11764. @item pict_type @emph{(video only)}
  11765. The type of the filtered frame. It can assume one of the following
  11766. values:
  11767. @table @option
  11768. @item I
  11769. @item P
  11770. @item B
  11771. @item S
  11772. @item SI
  11773. @item SP
  11774. @item BI
  11775. @end table
  11776. @item interlace_type @emph{(video only)}
  11777. The frame interlace type. It can assume one of the following values:
  11778. @table @option
  11779. @item PROGRESSIVE
  11780. The frame is progressive (not interlaced).
  11781. @item TOPFIRST
  11782. The frame is top-field-first.
  11783. @item BOTTOMFIRST
  11784. The frame is bottom-field-first.
  11785. @end table
  11786. @item consumed_sample_n @emph{(audio only)}
  11787. the number of selected samples before the current frame
  11788. @item samples_n @emph{(audio only)}
  11789. the number of samples in the current frame
  11790. @item sample_rate @emph{(audio only)}
  11791. the input sample rate
  11792. @item key
  11793. This is 1 if the filtered frame is a key-frame, 0 otherwise.
  11794. @item pos
  11795. the position in the file of the filtered frame, -1 if the information
  11796. is not available (e.g. for synthetic video)
  11797. @item scene @emph{(video only)}
  11798. value between 0 and 1 to indicate a new scene; a low value reflects a low
  11799. probability for the current frame to introduce a new scene, while a higher
  11800. value means the current frame is more likely to be one (see the example below)
  11801. @item concatdec_select
  11802. The concat demuxer can select only part of a concat input file by setting an
  11803. inpoint and an outpoint, but the output packets may not be entirely contained
  11804. in the selected interval. By using this variable, it is possible to skip frames
  11805. generated by the concat demuxer which are not exactly contained in the selected
  11806. interval.
  11807. This works by comparing the frame pts against the @var{lavf.concat.start_time}
  11808. and the @var{lavf.concat.duration} packet metadata values which are also
  11809. present in the decoded frames.
  11810. The @var{concatdec_select} variable is -1 if the frame pts is at least
  11811. start_time and either the duration metadata is missing or the frame pts is less
  11812. than start_time + duration, 0 otherwise, and NaN if the start_time metadata is
  11813. missing.
  11814. That basically means that an input frame is selected if its pts is within the
  11815. interval set by the concat demuxer.
  11816. @end table
  11817. The default value of the select expression is "1".
  11818. @subsection Examples
  11819. @itemize
  11820. @item
  11821. Select all frames in input:
  11822. @example
  11823. select
  11824. @end example
  11825. The example above is the same as:
  11826. @example
  11827. select=1
  11828. @end example
  11829. @item
  11830. Skip all frames:
  11831. @example
  11832. select=0
  11833. @end example
  11834. @item
  11835. Select only I-frames:
  11836. @example
  11837. select='eq(pict_type\,I)'
  11838. @end example
  11839. @item
  11840. Select one frame every 100:
  11841. @example
  11842. select='not(mod(n\,100))'
  11843. @end example
  11844. @item
  11845. Select only frames contained in the 10-20 time interval:
  11846. @example
  11847. select=between(t\,10\,20)
  11848. @end example
  11849. @item
  11850. Select only I frames contained in the 10-20 time interval:
  11851. @example
  11852. select=between(t\,10\,20)*eq(pict_type\,I)
  11853. @end example
  11854. @item
  11855. Select frames with a minimum distance of 10 seconds:
  11856. @example
  11857. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  11858. @end example
  11859. @item
  11860. Use aselect to select only audio frames with samples number > 100:
  11861. @example
  11862. aselect='gt(samples_n\,100)'
  11863. @end example
  11864. @item
  11865. Create a mosaic of the first scenes:
  11866. @example
  11867. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  11868. @end example
  11869. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  11870. choice.
  11871. @item
  11872. Send even and odd frames to separate outputs, and compose them:
  11873. @example
  11874. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  11875. @end example
  11876. @item
  11877. Select useful frames from an ffconcat file which is using inpoints and
  11878. outpoints but where the source files are not intra frame only.
  11879. @example
  11880. ffmpeg -copyts -vsync 0 -segment_time_metadata 1 -i input.ffconcat -vf select=concatdec_select -af aselect=concatdec_select output.avi
  11881. @end example
  11882. @end itemize
  11883. @section sendcmd, asendcmd
  11884. Send commands to filters in the filtergraph.
  11885. These filters read commands to be sent to other filters in the
  11886. filtergraph.
  11887. @code{sendcmd} must be inserted between two video filters,
  11888. @code{asendcmd} must be inserted between two audio filters, but apart
  11889. from that they act the same way.
  11890. The specification of commands can be provided in the filter arguments
  11891. with the @var{commands} option, or in a file specified by the
  11892. @var{filename} option.
  11893. These filters accept the following options:
  11894. @table @option
  11895. @item commands, c
  11896. Set the commands to be read and sent to the other filters.
  11897. @item filename, f
  11898. Set the filename of the commands to be read and sent to the other
  11899. filters.
  11900. @end table
  11901. @subsection Commands syntax
  11902. A commands description consists of a sequence of interval
  11903. specifications, comprising a list of commands to be executed when a
  11904. particular event related to that interval occurs. The occurring event
  11905. is typically the current frame time entering or leaving a given time
  11906. interval.
  11907. An interval is specified by the following syntax:
  11908. @example
  11909. @var{START}[-@var{END}] @var{COMMANDS};
  11910. @end example
  11911. The time interval is specified by the @var{START} and @var{END} times.
  11912. @var{END} is optional and defaults to the maximum time.
  11913. The current frame time is considered within the specified interval if
  11914. it is included in the interval [@var{START}, @var{END}), that is when
  11915. the time is greater or equal to @var{START} and is lesser than
  11916. @var{END}.
  11917. @var{COMMANDS} consists of a sequence of one or more command
  11918. specifications, separated by ",", relating to that interval. The
  11919. syntax of a command specification is given by:
  11920. @example
  11921. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  11922. @end example
  11923. @var{FLAGS} is optional and specifies the type of events relating to
  11924. the time interval which enable sending the specified command, and must
  11925. be a non-null sequence of identifier flags separated by "+" or "|" and
  11926. enclosed between "[" and "]".
  11927. The following flags are recognized:
  11928. @table @option
  11929. @item enter
  11930. The command is sent when the current frame timestamp enters the
  11931. specified interval. In other words, the command is sent when the
  11932. previous frame timestamp was not in the given interval, and the
  11933. current is.
  11934. @item leave
  11935. The command is sent when the current frame timestamp leaves the
  11936. specified interval. In other words, the command is sent when the
  11937. previous frame timestamp was in the given interval, and the
  11938. current is not.
  11939. @end table
  11940. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  11941. assumed.
  11942. @var{TARGET} specifies the target of the command, usually the name of
  11943. the filter class or a specific filter instance name.
  11944. @var{COMMAND} specifies the name of the command for the target filter.
  11945. @var{ARG} is optional and specifies the optional list of argument for
  11946. the given @var{COMMAND}.
  11947. Between one interval specification and another, whitespaces, or
  11948. sequences of characters starting with @code{#} until the end of line,
  11949. are ignored and can be used to annotate comments.
  11950. A simplified BNF description of the commands specification syntax
  11951. follows:
  11952. @example
  11953. @var{COMMAND_FLAG} ::= "enter" | "leave"
  11954. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  11955. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  11956. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  11957. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  11958. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  11959. @end example
  11960. @subsection Examples
  11961. @itemize
  11962. @item
  11963. Specify audio tempo change at second 4:
  11964. @example
  11965. asendcmd=c='4.0 atempo tempo 1.5',atempo
  11966. @end example
  11967. @item
  11968. Specify a list of drawtext and hue commands in a file.
  11969. @example
  11970. # show text in the interval 5-10
  11971. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  11972. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  11973. # desaturate the image in the interval 15-20
  11974. 15.0-20.0 [enter] hue s 0,
  11975. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  11976. [leave] hue s 1,
  11977. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  11978. # apply an exponential saturation fade-out effect, starting from time 25
  11979. 25 [enter] hue s exp(25-t)
  11980. @end example
  11981. A filtergraph allowing to read and process the above command list
  11982. stored in a file @file{test.cmd}, can be specified with:
  11983. @example
  11984. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  11985. @end example
  11986. @end itemize
  11987. @anchor{setpts}
  11988. @section setpts, asetpts
  11989. Change the PTS (presentation timestamp) of the input frames.
  11990. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  11991. This filter accepts the following options:
  11992. @table @option
  11993. @item expr
  11994. The expression which is evaluated for each frame to construct its timestamp.
  11995. @end table
  11996. The expression is evaluated through the eval API and can contain the following
  11997. constants:
  11998. @table @option
  11999. @item FRAME_RATE
  12000. frame rate, only defined for constant frame-rate video
  12001. @item PTS
  12002. The presentation timestamp in input
  12003. @item N
  12004. The count of the input frame for video or the number of consumed samples,
  12005. not including the current frame for audio, starting from 0.
  12006. @item NB_CONSUMED_SAMPLES
  12007. The number of consumed samples, not including the current frame (only
  12008. audio)
  12009. @item NB_SAMPLES, S
  12010. The number of samples in the current frame (only audio)
  12011. @item SAMPLE_RATE, SR
  12012. The audio sample rate.
  12013. @item STARTPTS
  12014. The PTS of the first frame.
  12015. @item STARTT
  12016. the time in seconds of the first frame
  12017. @item INTERLACED
  12018. State whether the current frame is interlaced.
  12019. @item T
  12020. the time in seconds of the current frame
  12021. @item POS
  12022. original position in the file of the frame, or undefined if undefined
  12023. for the current frame
  12024. @item PREV_INPTS
  12025. The previous input PTS.
  12026. @item PREV_INT
  12027. previous input time in seconds
  12028. @item PREV_OUTPTS
  12029. The previous output PTS.
  12030. @item PREV_OUTT
  12031. previous output time in seconds
  12032. @item RTCTIME
  12033. The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  12034. instead.
  12035. @item RTCSTART
  12036. The wallclock (RTC) time at the start of the movie in microseconds.
  12037. @item TB
  12038. The timebase of the input timestamps.
  12039. @end table
  12040. @subsection Examples
  12041. @itemize
  12042. @item
  12043. Start counting PTS from zero
  12044. @example
  12045. setpts=PTS-STARTPTS
  12046. @end example
  12047. @item
  12048. Apply fast motion effect:
  12049. @example
  12050. setpts=0.5*PTS
  12051. @end example
  12052. @item
  12053. Apply slow motion effect:
  12054. @example
  12055. setpts=2.0*PTS
  12056. @end example
  12057. @item
  12058. Set fixed rate of 25 frames per second:
  12059. @example
  12060. setpts=N/(25*TB)
  12061. @end example
  12062. @item
  12063. Set fixed rate 25 fps with some jitter:
  12064. @example
  12065. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  12066. @end example
  12067. @item
  12068. Apply an offset of 10 seconds to the input PTS:
  12069. @example
  12070. setpts=PTS+10/TB
  12071. @end example
  12072. @item
  12073. Generate timestamps from a "live source" and rebase onto the current timebase:
  12074. @example
  12075. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  12076. @end example
  12077. @item
  12078. Generate timestamps by counting samples:
  12079. @example
  12080. asetpts=N/SR/TB
  12081. @end example
  12082. @end itemize
  12083. @section settb, asettb
  12084. Set the timebase to use for the output frames timestamps.
  12085. It is mainly useful for testing timebase configuration.
  12086. It accepts the following parameters:
  12087. @table @option
  12088. @item expr, tb
  12089. The expression which is evaluated into the output timebase.
  12090. @end table
  12091. The value for @option{tb} is an arithmetic expression representing a
  12092. rational. The expression can contain the constants "AVTB" (the default
  12093. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  12094. audio only). Default value is "intb".
  12095. @subsection Examples
  12096. @itemize
  12097. @item
  12098. Set the timebase to 1/25:
  12099. @example
  12100. settb=expr=1/25
  12101. @end example
  12102. @item
  12103. Set the timebase to 1/10:
  12104. @example
  12105. settb=expr=0.1
  12106. @end example
  12107. @item
  12108. Set the timebase to 1001/1000:
  12109. @example
  12110. settb=1+0.001
  12111. @end example
  12112. @item
  12113. Set the timebase to 2*intb:
  12114. @example
  12115. settb=2*intb
  12116. @end example
  12117. @item
  12118. Set the default timebase value:
  12119. @example
  12120. settb=AVTB
  12121. @end example
  12122. @end itemize
  12123. @section showcqt
  12124. Convert input audio to a video output representing frequency spectrum
  12125. logarithmically using Brown-Puckette constant Q transform algorithm with
  12126. direct frequency domain coefficient calculation (but the transform itself
  12127. is not really constant Q, instead the Q factor is actually variable/clamped),
  12128. with musical tone scale, from E0 to D#10.
  12129. The filter accepts the following options:
  12130. @table @option
  12131. @item size, s
  12132. Specify the video size for the output. It must be even. For the syntax of this option,
  12133. check the @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12134. Default value is @code{1920x1080}.
  12135. @item fps, rate, r
  12136. Set the output frame rate. Default value is @code{25}.
  12137. @item bar_h
  12138. Set the bargraph height. It must be even. Default value is @code{-1} which
  12139. computes the bargraph height automatically.
  12140. @item axis_h
  12141. Set the axis height. It must be even. Default value is @code{-1} which computes
  12142. the axis height automatically.
  12143. @item sono_h
  12144. Set the sonogram height. It must be even. Default value is @code{-1} which
  12145. computes the sonogram height automatically.
  12146. @item fullhd
  12147. Set the fullhd resolution. This option is deprecated, use @var{size}, @var{s}
  12148. instead. Default value is @code{1}.
  12149. @item sono_v, volume
  12150. Specify the sonogram volume expression. It can contain variables:
  12151. @table @option
  12152. @item bar_v
  12153. the @var{bar_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{16}.
  12169. @item bar_v, volume2
  12170. Specify the bargraph volume expression. It can contain variables:
  12171. @table @option
  12172. @item sono_v
  12173. the @var{sono_v} evaluated expression
  12174. @item frequency, freq, f
  12175. the frequency where it is evaluated
  12176. @item timeclamp, tc
  12177. the value of @var{timeclamp} option
  12178. @end table
  12179. and functions:
  12180. @table @option
  12181. @item a_weighting(f)
  12182. A-weighting of equal loudness
  12183. @item b_weighting(f)
  12184. B-weighting of equal loudness
  12185. @item c_weighting(f)
  12186. C-weighting of equal loudness.
  12187. @end table
  12188. Default value is @code{sono_v}.
  12189. @item sono_g, gamma
  12190. Specify the sonogram gamma. Lower gamma makes the spectrum more contrast,
  12191. higher gamma makes the spectrum having more range. Default value is @code{3}.
  12192. Acceptable range is @code{[1, 7]}.
  12193. @item bar_g, gamma2
  12194. Specify the bargraph gamma. Default value is @code{1}. Acceptable range is
  12195. @code{[1, 7]}.
  12196. @item timeclamp, tc
  12197. Specify the transform timeclamp. At low frequency, there is trade-off between
  12198. accuracy in time domain and frequency domain. If timeclamp is lower,
  12199. event in time domain is represented more accurately (such as fast bass drum),
  12200. otherwise event in frequency domain is represented more accurately
  12201. (such as bass guitar). Acceptable range is @code{[0.1, 1]}. Default value is @code{0.17}.
  12202. @item basefreq
  12203. Specify the transform base frequency. Default value is @code{20.01523126408007475},
  12204. which is frequency 50 cents below E0. Acceptable range is @code{[10, 100000]}.
  12205. @item endfreq
  12206. Specify the transform end frequency. Default value is @code{20495.59681441799654},
  12207. which is frequency 50 cents above D#10. Acceptable range is @code{[10, 100000]}.
  12208. @item coeffclamp
  12209. This option is deprecated and ignored.
  12210. @item tlength
  12211. Specify the transform length in time domain. Use this option to control accuracy
  12212. trade-off between time domain and frequency domain at every frequency sample.
  12213. It can contain variables:
  12214. @table @option
  12215. @item frequency, freq, f
  12216. the frequency where it is evaluated
  12217. @item timeclamp, tc
  12218. the value of @var{timeclamp} option.
  12219. @end table
  12220. Default value is @code{384*tc/(384+tc*f)}.
  12221. @item count
  12222. Specify the transform count for every video frame. Default value is @code{6}.
  12223. Acceptable range is @code{[1, 30]}.
  12224. @item fcount
  12225. Specify the transform count for every single pixel. Default value is @code{0},
  12226. which makes it computed automatically. Acceptable range is @code{[0, 10]}.
  12227. @item fontfile
  12228. Specify font file for use with freetype to draw the axis. If not specified,
  12229. use embedded font. Note that drawing with font file or embedded font is not
  12230. implemented with custom @var{basefreq} and @var{endfreq}, use @var{axisfile}
  12231. option instead.
  12232. @item fontcolor
  12233. Specify font color expression. This is arithmetic expression that should return
  12234. integer value 0xRRGGBB. It can contain variables:
  12235. @table @option
  12236. @item frequency, freq, f
  12237. the frequency where it is evaluated
  12238. @item timeclamp, tc
  12239. the value of @var{timeclamp} option
  12240. @end table
  12241. and functions:
  12242. @table @option
  12243. @item midi(f)
  12244. midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
  12245. @item r(x), g(x), b(x)
  12246. red, green, and blue value of intensity x.
  12247. @end table
  12248. Default value is @code{st(0, (midi(f)-59.5)/12);
  12249. st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
  12250. r(1-ld(1)) + b(ld(1))}.
  12251. @item axisfile
  12252. Specify image file to draw the axis. This option override @var{fontfile} and
  12253. @var{fontcolor} option.
  12254. @item axis, text
  12255. Enable/disable drawing text to the axis. If it is set to @code{0}, drawing to
  12256. the axis is disabled, ignoring @var{fontfile} and @var{axisfile} option.
  12257. Default value is @code{1}.
  12258. @end table
  12259. @subsection Examples
  12260. @itemize
  12261. @item
  12262. Playing audio while showing the spectrum:
  12263. @example
  12264. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
  12265. @end example
  12266. @item
  12267. Same as above, but with frame rate 30 fps:
  12268. @example
  12269. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
  12270. @end example
  12271. @item
  12272. Playing at 1280x720:
  12273. @example
  12274. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=s=1280x720:count=4 [out0]'
  12275. @end example
  12276. @item
  12277. Disable sonogram display:
  12278. @example
  12279. sono_h=0
  12280. @end example
  12281. @item
  12282. A1 and its harmonics: A1, A2, (near)E3, A3:
  12283. @example
  12284. 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),
  12285. asplit[a][out1]; [a] showcqt [out0]'
  12286. @end example
  12287. @item
  12288. Same as above, but with more accuracy in frequency domain:
  12289. @example
  12290. 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),
  12291. asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
  12292. @end example
  12293. @item
  12294. Custom volume:
  12295. @example
  12296. bar_v=10:sono_v=bar_v*a_weighting(f)
  12297. @end example
  12298. @item
  12299. Custom gamma, now spectrum is linear to the amplitude.
  12300. @example
  12301. bar_g=2:sono_g=2
  12302. @end example
  12303. @item
  12304. Custom tlength equation:
  12305. @example
  12306. 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)))'
  12307. @end example
  12308. @item
  12309. Custom fontcolor and fontfile, C-note is colored green, others are colored blue:
  12310. @example
  12311. fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))':fontfile=myfont.ttf
  12312. @end example
  12313. @item
  12314. Custom frequency range with custom axis using image file:
  12315. @example
  12316. axisfile=myaxis.png:basefreq=40:endfreq=10000
  12317. @end example
  12318. @end itemize
  12319. @section showfreqs
  12320. Convert input audio to video output representing the audio power spectrum.
  12321. Audio amplitude is on Y-axis while frequency is on X-axis.
  12322. The filter accepts the following options:
  12323. @table @option
  12324. @item size, s
  12325. Specify size of video. For the syntax of this option, check the
  12326. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12327. Default is @code{1024x512}.
  12328. @item mode
  12329. Set display mode.
  12330. This set how each frequency bin will be represented.
  12331. It accepts the following values:
  12332. @table @samp
  12333. @item line
  12334. @item bar
  12335. @item dot
  12336. @end table
  12337. Default is @code{bar}.
  12338. @item ascale
  12339. Set amplitude scale.
  12340. It accepts the following values:
  12341. @table @samp
  12342. @item lin
  12343. Linear scale.
  12344. @item sqrt
  12345. Square root scale.
  12346. @item cbrt
  12347. Cubic root scale.
  12348. @item log
  12349. Logarithmic scale.
  12350. @end table
  12351. Default is @code{log}.
  12352. @item fscale
  12353. Set frequency scale.
  12354. It accepts the following values:
  12355. @table @samp
  12356. @item lin
  12357. Linear scale.
  12358. @item log
  12359. Logarithmic scale.
  12360. @item rlog
  12361. Reverse logarithmic scale.
  12362. @end table
  12363. Default is @code{lin}.
  12364. @item win_size
  12365. Set window size.
  12366. It accepts the following values:
  12367. @table @samp
  12368. @item w16
  12369. @item w32
  12370. @item w64
  12371. @item w128
  12372. @item w256
  12373. @item w512
  12374. @item w1024
  12375. @item w2048
  12376. @item w4096
  12377. @item w8192
  12378. @item w16384
  12379. @item w32768
  12380. @item w65536
  12381. @end table
  12382. Default is @code{w2048}
  12383. @item win_func
  12384. Set windowing function.
  12385. It accepts the following values:
  12386. @table @samp
  12387. @item rect
  12388. @item bartlett
  12389. @item hanning
  12390. @item hamming
  12391. @item blackman
  12392. @item welch
  12393. @item flattop
  12394. @item bharris
  12395. @item bnuttall
  12396. @item bhann
  12397. @item sine
  12398. @item nuttall
  12399. @item lanczos
  12400. @item gauss
  12401. @item tukey
  12402. @end table
  12403. Default is @code{hanning}.
  12404. @item overlap
  12405. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  12406. which means optimal overlap for selected window function will be picked.
  12407. @item averaging
  12408. Set time averaging. Setting this to 0 will display current maximal peaks.
  12409. Default is @code{1}, which means time averaging is disabled.
  12410. @item colors
  12411. Specify list of colors separated by space or by '|' which will be used to
  12412. draw channel frequencies. Unrecognized or missing colors will be replaced
  12413. by white color.
  12414. @item cmode
  12415. Set channel display mode.
  12416. It accepts the following values:
  12417. @table @samp
  12418. @item combined
  12419. @item separate
  12420. @end table
  12421. Default is @code{combined}.
  12422. @end table
  12423. @anchor{showspectrum}
  12424. @section showspectrum
  12425. Convert input audio to a video output, representing the audio frequency
  12426. spectrum.
  12427. The filter accepts the following options:
  12428. @table @option
  12429. @item size, s
  12430. Specify the video size for the output. For the syntax of this option, check the
  12431. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12432. Default value is @code{640x512}.
  12433. @item slide
  12434. Specify how the spectrum should slide along the window.
  12435. It accepts the following values:
  12436. @table @samp
  12437. @item replace
  12438. the samples start again on the left when they reach the right
  12439. @item scroll
  12440. the samples scroll from right to left
  12441. @item rscroll
  12442. the samples scroll from left to right
  12443. @item fullframe
  12444. frames are only produced when the samples reach the right
  12445. @end table
  12446. Default value is @code{replace}.
  12447. @item mode
  12448. Specify display mode.
  12449. It accepts the following values:
  12450. @table @samp
  12451. @item combined
  12452. all channels are displayed in the same row
  12453. @item separate
  12454. all channels are displayed in separate rows
  12455. @end table
  12456. Default value is @samp{combined}.
  12457. @item color
  12458. Specify display color mode.
  12459. It accepts the following values:
  12460. @table @samp
  12461. @item channel
  12462. each channel is displayed in a separate color
  12463. @item intensity
  12464. each channel is displayed using the same color scheme
  12465. @item rainbow
  12466. each channel is displayed using the rainbow color scheme
  12467. @item moreland
  12468. each channel is displayed using the moreland color scheme
  12469. @item nebulae
  12470. each channel is displayed using the nebulae color scheme
  12471. @item fire
  12472. each channel is displayed using the fire color scheme
  12473. @item fiery
  12474. each channel is displayed using the fiery color scheme
  12475. @item fruit
  12476. each channel is displayed using the fruit color scheme
  12477. @item cool
  12478. each channel is displayed using the cool color scheme
  12479. @end table
  12480. Default value is @samp{channel}.
  12481. @item scale
  12482. Specify scale used for calculating intensity color values.
  12483. It accepts the following values:
  12484. @table @samp
  12485. @item lin
  12486. linear
  12487. @item sqrt
  12488. square root, default
  12489. @item cbrt
  12490. cubic root
  12491. @item 4thrt
  12492. 4th root
  12493. @item 5thrt
  12494. 5th root
  12495. @item log
  12496. logarithmic
  12497. @end table
  12498. Default value is @samp{sqrt}.
  12499. @item saturation
  12500. Set saturation modifier for displayed colors. Negative values provide
  12501. alternative color scheme. @code{0} is no saturation at all.
  12502. Saturation must be in [-10.0, 10.0] range.
  12503. Default value is @code{1}.
  12504. @item win_func
  12505. Set window function.
  12506. It accepts the following values:
  12507. @table @samp
  12508. @item rect
  12509. @item bartlett
  12510. @item hann
  12511. @item hanning
  12512. @item hamming
  12513. @item blackman
  12514. @item welch
  12515. @item flattop
  12516. @item bharris
  12517. @item bnuttall
  12518. @item bhann
  12519. @item sine
  12520. @item nuttall
  12521. @item lanczos
  12522. @item gauss
  12523. @item tukey
  12524. @end table
  12525. Default value is @code{hann}.
  12526. @item orientation
  12527. Set orientation of time vs frequency axis. Can be @code{vertical} or
  12528. @code{horizontal}. Default is @code{vertical}.
  12529. @item overlap
  12530. Set ratio of overlap window. Default value is @code{0}.
  12531. When value is @code{1} overlap is set to recommended size for specific
  12532. window function currently used.
  12533. @item gain
  12534. Set scale gain for calculating intensity color values.
  12535. Default value is @code{1}.
  12536. @item data
  12537. Set which data to display. Can be @code{magnitude}, default or @code{phase}.
  12538. @end table
  12539. The usage is very similar to the showwaves filter; see the examples in that
  12540. section.
  12541. @subsection Examples
  12542. @itemize
  12543. @item
  12544. Large window with logarithmic color scaling:
  12545. @example
  12546. showspectrum=s=1280x480:scale=log
  12547. @end example
  12548. @item
  12549. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  12550. @example
  12551. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  12552. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  12553. @end example
  12554. @end itemize
  12555. @section showspectrumpic
  12556. Convert input audio to a single video frame, representing the audio frequency
  12557. spectrum.
  12558. The filter accepts the following options:
  12559. @table @option
  12560. @item size, s
  12561. Specify the video size for the output. For the syntax of this option, check the
  12562. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12563. Default value is @code{4096x2048}.
  12564. @item mode
  12565. Specify display mode.
  12566. It accepts the following values:
  12567. @table @samp
  12568. @item combined
  12569. all channels are displayed in the same row
  12570. @item separate
  12571. all channels are displayed in separate rows
  12572. @end table
  12573. Default value is @samp{combined}.
  12574. @item color
  12575. Specify display color mode.
  12576. It accepts the following values:
  12577. @table @samp
  12578. @item channel
  12579. each channel is displayed in a separate color
  12580. @item intensity
  12581. each channel is displayed using the same color scheme
  12582. @item rainbow
  12583. each channel is displayed using the rainbow color scheme
  12584. @item moreland
  12585. each channel is displayed using the moreland color scheme
  12586. @item nebulae
  12587. each channel is displayed using the nebulae color scheme
  12588. @item fire
  12589. each channel is displayed using the fire color scheme
  12590. @item fiery
  12591. each channel is displayed using the fiery color scheme
  12592. @item fruit
  12593. each channel is displayed using the fruit color scheme
  12594. @item cool
  12595. each channel is displayed using the cool color scheme
  12596. @end table
  12597. Default value is @samp{intensity}.
  12598. @item scale
  12599. Specify scale used for calculating intensity color values.
  12600. It accepts the following values:
  12601. @table @samp
  12602. @item lin
  12603. linear
  12604. @item sqrt
  12605. square root, default
  12606. @item cbrt
  12607. cubic root
  12608. @item 4thrt
  12609. 4th root
  12610. @item 5thrt
  12611. 5th root
  12612. @item log
  12613. logarithmic
  12614. @end table
  12615. Default value is @samp{log}.
  12616. @item saturation
  12617. Set saturation modifier for displayed colors. Negative values provide
  12618. alternative color scheme. @code{0} is no saturation at all.
  12619. Saturation must be in [-10.0, 10.0] range.
  12620. Default value is @code{1}.
  12621. @item win_func
  12622. Set window function.
  12623. It accepts the following values:
  12624. @table @samp
  12625. @item rect
  12626. @item bartlett
  12627. @item hann
  12628. @item hanning
  12629. @item hamming
  12630. @item blackman
  12631. @item welch
  12632. @item flattop
  12633. @item bharris
  12634. @item bnuttall
  12635. @item bhann
  12636. @item sine
  12637. @item nuttall
  12638. @item lanczos
  12639. @item gauss
  12640. @item tukey
  12641. @end table
  12642. Default value is @code{hann}.
  12643. @item orientation
  12644. Set orientation of time vs frequency axis. Can be @code{vertical} or
  12645. @code{horizontal}. Default is @code{vertical}.
  12646. @item gain
  12647. Set scale gain for calculating intensity color values.
  12648. Default value is @code{1}.
  12649. @item legend
  12650. Draw time and frequency axes and legends. Default is enabled.
  12651. @end table
  12652. @subsection Examples
  12653. @itemize
  12654. @item
  12655. Extract an audio spectrogram of a whole audio track
  12656. in a 1024x1024 picture using @command{ffmpeg}:
  12657. @example
  12658. ffmpeg -i audio.flac -lavfi showspectrumpic=s=1024x1024 spectrogram.png
  12659. @end example
  12660. @end itemize
  12661. @section showvolume
  12662. Convert input audio volume to a video output.
  12663. The filter accepts the following options:
  12664. @table @option
  12665. @item rate, r
  12666. Set video rate.
  12667. @item b
  12668. Set border width, allowed range is [0, 5]. Default is 1.
  12669. @item w
  12670. Set channel width, allowed range is [80, 8192]. Default is 400.
  12671. @item h
  12672. Set channel height, allowed range is [1, 900]. Default is 20.
  12673. @item f
  12674. Set fade, allowed range is [0.001, 1]. Default is 0.95.
  12675. @item c
  12676. Set volume color expression.
  12677. The expression can use the following variables:
  12678. @table @option
  12679. @item VOLUME
  12680. Current max volume of channel in dB.
  12681. @item CHANNEL
  12682. Current channel number, starting from 0.
  12683. @end table
  12684. @item t
  12685. If set, displays channel names. Default is enabled.
  12686. @item v
  12687. If set, displays volume values. Default is enabled.
  12688. @item o
  12689. Set orientation, can be @code{horizontal} or @code{vertical},
  12690. default is @code{horizontal}.
  12691. @item s
  12692. Set step size, allowed range s [0, 5]. Default is 0, which means
  12693. step is disabled.
  12694. @end table
  12695. @section showwaves
  12696. Convert input audio to a video output, representing the samples waves.
  12697. The filter accepts the following options:
  12698. @table @option
  12699. @item size, s
  12700. Specify the video size for the output. For the syntax of this option, check the
  12701. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12702. Default value is @code{600x240}.
  12703. @item mode
  12704. Set display mode.
  12705. Available values are:
  12706. @table @samp
  12707. @item point
  12708. Draw a point for each sample.
  12709. @item line
  12710. Draw a vertical line for each sample.
  12711. @item p2p
  12712. Draw a point for each sample and a line between them.
  12713. @item cline
  12714. Draw a centered vertical line for each sample.
  12715. @end table
  12716. Default value is @code{point}.
  12717. @item n
  12718. Set the number of samples which are printed on the same column. A
  12719. larger value will decrease the frame rate. Must be a positive
  12720. integer. This option can be set only if the value for @var{rate}
  12721. is not explicitly specified.
  12722. @item rate, r
  12723. Set the (approximate) output frame rate. This is done by setting the
  12724. option @var{n}. Default value is "25".
  12725. @item split_channels
  12726. Set if channels should be drawn separately or overlap. Default value is 0.
  12727. @item colors
  12728. Set colors separated by '|' which are going to be used for drawing of each channel.
  12729. @item scale
  12730. Set amplitude scale. Can be linear @code{lin} or logarithmic @code{log}.
  12731. Default is linear.
  12732. @end table
  12733. @subsection Examples
  12734. @itemize
  12735. @item
  12736. Output the input file audio and the corresponding video representation
  12737. at the same time:
  12738. @example
  12739. amovie=a.mp3,asplit[out0],showwaves[out1]
  12740. @end example
  12741. @item
  12742. Create a synthetic signal and show it with showwaves, forcing a
  12743. frame rate of 30 frames per second:
  12744. @example
  12745. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  12746. @end example
  12747. @end itemize
  12748. @section showwavespic
  12749. Convert input audio to a single video frame, representing the samples waves.
  12750. The filter accepts the following options:
  12751. @table @option
  12752. @item size, s
  12753. Specify the video size for the output. For the syntax of this option, check the
  12754. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  12755. Default value is @code{600x240}.
  12756. @item split_channels
  12757. Set if channels should be drawn separately or overlap. Default value is 0.
  12758. @item colors
  12759. Set colors separated by '|' which are going to be used for drawing of each channel.
  12760. @item scale
  12761. Set amplitude scale. Can be linear @code{lin} or logarithmic @code{log}.
  12762. Default is linear.
  12763. @end table
  12764. @subsection Examples
  12765. @itemize
  12766. @item
  12767. Extract a channel split representation of the wave form of a whole audio track
  12768. in a 1024x800 picture using @command{ffmpeg}:
  12769. @example
  12770. ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
  12771. @end example
  12772. @item
  12773. Colorize the waveform with colorchannelmixer. This example will make
  12774. the waveform a green color approximately RGB(66,217,150). Additional
  12775. channels will be shades of this color.
  12776. @example
  12777. ffmpeg -i audio.mp3 -filter_complex "showwavespic,colorchannelmixer=rr=66/255:gg=217/255:bb=150/255" waveform.png
  12778. @end example
  12779. @end itemize
  12780. @section spectrumsynth
  12781. Sythesize audio from 2 input video spectrums, first input stream represents
  12782. magnitude across time and second represents phase across time.
  12783. The filter will transform from frequency domain as displayed in videos back
  12784. to time domain as presented in audio output.
  12785. This filter is primarly created for reversing processed @ref{showspectrum}
  12786. filter outputs, but can synthesize sound from other spectrograms too.
  12787. But in such case results are going to be poor if the phase data is not
  12788. available, because in such cases phase data need to be recreated, usually
  12789. its just recreated from random noise.
  12790. For best results use gray only output (@code{channel} color mode in
  12791. @ref{showspectrum} filter) and @code{log} scale for magnitude video and
  12792. @code{lin} scale for phase video. To produce phase, for 2nd video, use
  12793. @code{data} option. Inputs videos should generally use @code{fullframe}
  12794. slide mode as that saves resources needed for decoding video.
  12795. The filter accepts the following options:
  12796. @table @option
  12797. @item sample_rate
  12798. Specify sample rate of output audio, the sample rate of audio from which
  12799. spectrum was generated may differ.
  12800. @item channels
  12801. Set number of channels represented in input video spectrums.
  12802. @item scale
  12803. Set scale which was used when generating magnitude input spectrum.
  12804. Can be @code{lin} or @code{log}. Default is @code{log}.
  12805. @item slide
  12806. Set slide which was used when generating inputs spectrums.
  12807. Can be @code{replace}, @code{scroll}, @code{fullframe} or @code{rscroll}.
  12808. Default is @code{fullframe}.
  12809. @item win_func
  12810. Set window function used for resynthesis.
  12811. @item overlap
  12812. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  12813. which means optimal overlap for selected window function will be picked.
  12814. @item orientation
  12815. Set orientation of input videos. Can be @code{vertical} or @code{horizontal}.
  12816. Default is @code{vertical}.
  12817. @end table
  12818. @subsection Examples
  12819. @itemize
  12820. @item
  12821. First create magnitude and phase videos from audio, assuming audio is stereo with 44100 sample rate,
  12822. then resynthesize videos back to audio with spectrumsynth:
  12823. @example
  12824. 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
  12825. 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
  12826. ffmpeg -i magnitude.nut -i phase.nut -lavfi spectrumsynth=channels=2:sample_rate=44100:win_func=hann:overlap=0.875:slide=fullframe output.flac
  12827. @end example
  12828. @end itemize
  12829. @section split, asplit
  12830. Split input into several identical outputs.
  12831. @code{asplit} works with audio input, @code{split} with video.
  12832. The filter accepts a single parameter which specifies the number of outputs. If
  12833. unspecified, it defaults to 2.
  12834. @subsection Examples
  12835. @itemize
  12836. @item
  12837. Create two separate outputs from the same input:
  12838. @example
  12839. [in] split [out0][out1]
  12840. @end example
  12841. @item
  12842. To create 3 or more outputs, you need to specify the number of
  12843. outputs, like in:
  12844. @example
  12845. [in] asplit=3 [out0][out1][out2]
  12846. @end example
  12847. @item
  12848. Create two separate outputs from the same input, one cropped and
  12849. one padded:
  12850. @example
  12851. [in] split [splitout1][splitout2];
  12852. [splitout1] crop=100:100:0:0 [cropout];
  12853. [splitout2] pad=200:200:100:100 [padout];
  12854. @end example
  12855. @item
  12856. Create 5 copies of the input audio with @command{ffmpeg}:
  12857. @example
  12858. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  12859. @end example
  12860. @end itemize
  12861. @section zmq, azmq
  12862. Receive commands sent through a libzmq client, and forward them to
  12863. filters in the filtergraph.
  12864. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  12865. must be inserted between two video filters, @code{azmq} between two
  12866. audio filters.
  12867. To enable these filters you need to install the libzmq library and
  12868. headers and configure FFmpeg with @code{--enable-libzmq}.
  12869. For more information about libzmq see:
  12870. @url{http://www.zeromq.org/}
  12871. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  12872. receives messages sent through a network interface defined by the
  12873. @option{bind_address} option.
  12874. The received message must be in the form:
  12875. @example
  12876. @var{TARGET} @var{COMMAND} [@var{ARG}]
  12877. @end example
  12878. @var{TARGET} specifies the target of the command, usually the name of
  12879. the filter class or a specific filter instance name.
  12880. @var{COMMAND} specifies the name of the command for the target filter.
  12881. @var{ARG} is optional and specifies the optional argument list for the
  12882. given @var{COMMAND}.
  12883. Upon reception, the message is processed and the corresponding command
  12884. is injected into the filtergraph. Depending on the result, the filter
  12885. will send a reply to the client, adopting the format:
  12886. @example
  12887. @var{ERROR_CODE} @var{ERROR_REASON}
  12888. @var{MESSAGE}
  12889. @end example
  12890. @var{MESSAGE} is optional.
  12891. @subsection Examples
  12892. Look at @file{tools/zmqsend} for an example of a zmq client which can
  12893. be used to send commands processed by these filters.
  12894. Consider the following filtergraph generated by @command{ffplay}
  12895. @example
  12896. ffplay -dumpgraph 1 -f lavfi "
  12897. color=s=100x100:c=red [l];
  12898. color=s=100x100:c=blue [r];
  12899. nullsrc=s=200x100, zmq [bg];
  12900. [bg][l] overlay [bg+l];
  12901. [bg+l][r] overlay=x=100 "
  12902. @end example
  12903. To change the color of the left side of the video, the following
  12904. command can be used:
  12905. @example
  12906. echo Parsed_color_0 c yellow | tools/zmqsend
  12907. @end example
  12908. To change the right side:
  12909. @example
  12910. echo Parsed_color_1 c pink | tools/zmqsend
  12911. @end example
  12912. @c man end MULTIMEDIA FILTERS
  12913. @chapter Multimedia Sources
  12914. @c man begin MULTIMEDIA SOURCES
  12915. Below is a description of the currently available multimedia sources.
  12916. @section amovie
  12917. This is the same as @ref{movie} source, except it selects an audio
  12918. stream by default.
  12919. @anchor{movie}
  12920. @section movie
  12921. Read audio and/or video stream(s) from a movie container.
  12922. It accepts the following parameters:
  12923. @table @option
  12924. @item filename
  12925. The name of the resource to read (not necessarily a file; it can also be a
  12926. device or a stream accessed through some protocol).
  12927. @item format_name, f
  12928. Specifies the format assumed for the movie to read, and can be either
  12929. the name of a container or an input device. If not specified, the
  12930. format is guessed from @var{movie_name} or by probing.
  12931. @item seek_point, sp
  12932. Specifies the seek point in seconds. The frames will be output
  12933. starting from this seek point. The parameter is evaluated with
  12934. @code{av_strtod}, so the numerical value may be suffixed by an IS
  12935. postfix. The default value is "0".
  12936. @item streams, s
  12937. Specifies the streams to read. Several streams can be specified,
  12938. separated by "+". The source will then have as many outputs, in the
  12939. same order. The syntax is explained in the ``Stream specifiers''
  12940. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  12941. respectively the default (best suited) video and audio stream. Default
  12942. is "dv", or "da" if the filter is called as "amovie".
  12943. @item stream_index, si
  12944. Specifies the index of the video stream to read. If the value is -1,
  12945. the most suitable video stream will be automatically selected. The default
  12946. value is "-1". Deprecated. If the filter is called "amovie", it will select
  12947. audio instead of video.
  12948. @item loop
  12949. Specifies how many times to read the stream in sequence.
  12950. If the value is less than 1, the stream will be read again and again.
  12951. Default value is "1".
  12952. Note that when the movie is looped the source timestamps are not
  12953. changed, so it will generate non monotonically increasing timestamps.
  12954. @end table
  12955. It allows overlaying a second video on top of the main input of
  12956. a filtergraph, as shown in this graph:
  12957. @example
  12958. input -----------> deltapts0 --> overlay --> output
  12959. ^
  12960. |
  12961. movie --> scale--> deltapts1 -------+
  12962. @end example
  12963. @subsection Examples
  12964. @itemize
  12965. @item
  12966. Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
  12967. on top of the input labelled "in":
  12968. @example
  12969. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  12970. [in] setpts=PTS-STARTPTS [main];
  12971. [main][over] overlay=16:16 [out]
  12972. @end example
  12973. @item
  12974. Read from a video4linux2 device, and overlay it on top of the input
  12975. labelled "in":
  12976. @example
  12977. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  12978. [in] setpts=PTS-STARTPTS [main];
  12979. [main][over] overlay=16:16 [out]
  12980. @end example
  12981. @item
  12982. Read the first video stream and the audio stream with id 0x81 from
  12983. dvd.vob; the video is connected to the pad named "video" and the audio is
  12984. connected to the pad named "audio":
  12985. @example
  12986. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  12987. @end example
  12988. @end itemize
  12989. @c man end MULTIMEDIA SOURCES