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.

14156 lines
387KB

  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 acrossfade
  256. Apply cross fade from one input audio stream to another input audio stream.
  257. The cross fade is applied for specified duration near the end of first stream.
  258. The filter accepts the following options:
  259. @table @option
  260. @item nb_samples, ns
  261. Specify the number of samples for which the cross fade effect has to last.
  262. At the end of the cross fade effect the first input audio will be completely
  263. silent. Default is 44100.
  264. @item duration, d
  265. Specify the duration of the cross fade effect. See
  266. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  267. for the accepted syntax.
  268. By default the duration is determined by @var{nb_samples}.
  269. If set this option is used instead of @var{nb_samples}.
  270. @item overlap, o
  271. Should first stream end overlap with second stream start. Default is enabled.
  272. @item curve1
  273. Set curve for cross fade transition for first stream.
  274. @item curve2
  275. Set curve for cross fade transition for second stream.
  276. For description of available curve types see @ref{afade} filter description.
  277. @end table
  278. @subsection Examples
  279. @itemize
  280. @item
  281. Cross fade from one input to another:
  282. @example
  283. ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:c1=exp:c2=exp output.flac
  284. @end example
  285. @item
  286. Cross fade from one input to another but without overlapping:
  287. @example
  288. ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:o=0:c1=exp:c2=exp output.flac
  289. @end example
  290. @end itemize
  291. @section adelay
  292. Delay one or more audio channels.
  293. Samples in delayed channel are filled with silence.
  294. The filter accepts the following option:
  295. @table @option
  296. @item delays
  297. Set list of delays in milliseconds for each channel separated by '|'.
  298. At least one delay greater than 0 should be provided.
  299. Unused delays will be silently ignored. If number of given delays is
  300. smaller than number of channels all remaining channels will not be delayed.
  301. @end table
  302. @subsection Examples
  303. @itemize
  304. @item
  305. Delay first channel by 1.5 seconds, the third channel by 0.5 seconds and leave
  306. the second channel (and any other channels that may be present) unchanged.
  307. @example
  308. adelay=1500|0|500
  309. @end example
  310. @end itemize
  311. @section aecho
  312. Apply echoing to the input audio.
  313. Echoes are reflected sound and can occur naturally amongst mountains
  314. (and sometimes large buildings) when talking or shouting; digital echo
  315. effects emulate this behaviour and are often used to help fill out the
  316. sound of a single instrument or vocal. The time difference between the
  317. original signal and the reflection is the @code{delay}, and the
  318. loudness of the reflected signal is the @code{decay}.
  319. Multiple echoes can have different delays and decays.
  320. A description of the accepted parameters follows.
  321. @table @option
  322. @item in_gain
  323. Set input gain of reflected signal. Default is @code{0.6}.
  324. @item out_gain
  325. Set output gain of reflected signal. Default is @code{0.3}.
  326. @item delays
  327. Set list of time intervals in milliseconds between original signal and reflections
  328. separated by '|'. Allowed range for each @code{delay} is @code{(0 - 90000.0]}.
  329. Default is @code{1000}.
  330. @item decays
  331. Set list of loudnesses of reflected signals separated by '|'.
  332. Allowed range for each @code{decay} is @code{(0 - 1.0]}.
  333. Default is @code{0.5}.
  334. @end table
  335. @subsection Examples
  336. @itemize
  337. @item
  338. Make it sound as if there are twice as many instruments as are actually playing:
  339. @example
  340. aecho=0.8:0.88:60:0.4
  341. @end example
  342. @item
  343. If delay is very short, then it sound like a (metallic) robot playing music:
  344. @example
  345. aecho=0.8:0.88:6:0.4
  346. @end example
  347. @item
  348. A longer delay will sound like an open air concert in the mountains:
  349. @example
  350. aecho=0.8:0.9:1000:0.3
  351. @end example
  352. @item
  353. Same as above but with one more mountain:
  354. @example
  355. aecho=0.8:0.9:1000|1800:0.3|0.25
  356. @end example
  357. @end itemize
  358. @section aeval
  359. Modify an audio signal according to the specified expressions.
  360. This filter accepts one or more expressions (one for each channel),
  361. which are evaluated and used to modify a corresponding audio signal.
  362. It accepts the following parameters:
  363. @table @option
  364. @item exprs
  365. Set the '|'-separated expressions list for each separate channel. If
  366. the number of input channels is greater than the number of
  367. expressions, the last specified expression is used for the remaining
  368. output channels.
  369. @item channel_layout, c
  370. Set output channel layout. If not specified, the channel layout is
  371. specified by the number of expressions. If set to @samp{same}, it will
  372. use by default the same input channel layout.
  373. @end table
  374. Each expression in @var{exprs} can contain the following constants and functions:
  375. @table @option
  376. @item ch
  377. channel number of the current expression
  378. @item n
  379. number of the evaluated sample, starting from 0
  380. @item s
  381. sample rate
  382. @item t
  383. time of the evaluated sample expressed in seconds
  384. @item nb_in_channels
  385. @item nb_out_channels
  386. input and output number of channels
  387. @item val(CH)
  388. the value of input channel with number @var{CH}
  389. @end table
  390. Note: this filter is slow. For faster processing you should use a
  391. dedicated filter.
  392. @subsection Examples
  393. @itemize
  394. @item
  395. Half volume:
  396. @example
  397. aeval=val(ch)/2:c=same
  398. @end example
  399. @item
  400. Invert phase of the second channel:
  401. @example
  402. aeval=val(0)|-val(1)
  403. @end example
  404. @end itemize
  405. @anchor{afade}
  406. @section afade
  407. Apply fade-in/out effect to input audio.
  408. A description of the accepted parameters follows.
  409. @table @option
  410. @item type, t
  411. Specify the effect type, can be either @code{in} for fade-in, or
  412. @code{out} for a fade-out effect. Default is @code{in}.
  413. @item start_sample, ss
  414. Specify the number of the start sample for starting to apply the fade
  415. effect. Default is 0.
  416. @item nb_samples, ns
  417. Specify the number of samples for which the fade effect has to last. At
  418. the end of the fade-in effect the output audio will have the same
  419. volume as the input audio, at the end of the fade-out transition
  420. the output audio will be silence. Default is 44100.
  421. @item start_time, st
  422. Specify the start time of the fade effect. Default is 0.
  423. The value must be specified as a time duration; see
  424. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  425. for the accepted syntax.
  426. If set this option is used instead of @var{start_sample}.
  427. @item duration, d
  428. Specify the duration of the fade effect. See
  429. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  430. for the accepted syntax.
  431. At the end of the fade-in effect the output audio will have the same
  432. volume as the input audio, at the end of the fade-out transition
  433. the output audio will be silence.
  434. By default the duration is determined by @var{nb_samples}.
  435. If set this option is used instead of @var{nb_samples}.
  436. @item curve
  437. Set curve for fade transition.
  438. It accepts the following values:
  439. @table @option
  440. @item tri
  441. select triangular, linear slope (default)
  442. @item qsin
  443. select quarter of sine wave
  444. @item hsin
  445. select half of sine wave
  446. @item esin
  447. select exponential sine wave
  448. @item log
  449. select logarithmic
  450. @item ipar
  451. select inverted parabola
  452. @item qua
  453. select quadratic
  454. @item cub
  455. select cubic
  456. @item squ
  457. select square root
  458. @item cbr
  459. select cubic root
  460. @item par
  461. select parabola
  462. @item exp
  463. select exponential
  464. @item iqsin
  465. select inverted quarter of sine wave
  466. @item ihsin
  467. select inverted half of sine wave
  468. @item dese
  469. select double-exponential seat
  470. @item desi
  471. select double-exponential sigmoid
  472. @end table
  473. @end table
  474. @subsection Examples
  475. @itemize
  476. @item
  477. Fade in first 15 seconds of audio:
  478. @example
  479. afade=t=in:ss=0:d=15
  480. @end example
  481. @item
  482. Fade out last 25 seconds of a 900 seconds audio:
  483. @example
  484. afade=t=out:st=875:d=25
  485. @end example
  486. @end itemize
  487. @anchor{aformat}
  488. @section aformat
  489. Set output format constraints for the input audio. The framework will
  490. negotiate the most appropriate format to minimize conversions.
  491. It accepts the following parameters:
  492. @table @option
  493. @item sample_fmts
  494. A '|'-separated list of requested sample formats.
  495. @item sample_rates
  496. A '|'-separated list of requested sample rates.
  497. @item channel_layouts
  498. A '|'-separated list of requested channel layouts.
  499. See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  500. for the required syntax.
  501. @end table
  502. If a parameter is omitted, all values are allowed.
  503. Force the output to either unsigned 8-bit or signed 16-bit stereo
  504. @example
  505. aformat=sample_fmts=u8|s16:channel_layouts=stereo
  506. @end example
  507. @section agate
  508. A gate is mainly used to reduce lower parts of a signal. This kind of signal
  509. processing reduces disturbing noise between useful signals.
  510. Gating is done by detecting the volume below a chosen level @var{threshold}
  511. and divide it by the factor set with @var{ratio}. The bottom of the noise
  512. floor is set via @var{range}. Because an exact manipulation of the signal
  513. would cause distortion of the waveform the reduction can be levelled over
  514. time. This is done by setting @var{attack} and @var{release}.
  515. @var{attack} determines how long the signal has to fall below the threshold
  516. before any reduction will occur and @var{release} sets the time the signal
  517. has to raise above the threshold to reduce the reduction again.
  518. Shorter signals than the chosen attack time will be left untouched.
  519. @table @option
  520. @item level_in
  521. Set input level before filtering.
  522. @item range
  523. Set the level of gain reduction when the signal is below the threshold.
  524. @item threshold
  525. If a signal rises above this level the gain reduction is released.
  526. @item ratio
  527. Set a ratio about which the signal is reduced.
  528. @item attack
  529. Amount of milliseconds the signal has to rise above the threshold before gain
  530. reduction stops.
  531. @item release
  532. Amount of milliseconds the signal has to fall below the threshold before the
  533. reduction is increased again.
  534. @item makeup
  535. Set amount of amplification of signal after processing.
  536. @item knee
  537. Curve the sharp knee around the threshold to enter gain reduction more softly.
  538. @item detection
  539. Choose if exact signal should be taken for detection or an RMS like one.
  540. @item link
  541. Choose if the average level between all channels or the louder channel affects
  542. the reduction.
  543. @end table
  544. @section alimiter
  545. The limiter prevents input signal from raising over a desired threshold.
  546. This limiter uses lookahead technology to prevent your signal from distorting.
  547. It means that there is a small delay after signal is processed. Keep in mind
  548. that the delay it produces is the attack time you set.
  549. The filter accepts the following options:
  550. @table @option
  551. @item limit
  552. Don't let signals above this level pass the limiter. The removed amplitude is
  553. added automatically. Default is 1.
  554. @item attack
  555. The limiter will reach its attenuation level in this amount of time in
  556. milliseconds. Default is 5 milliseconds.
  557. @item release
  558. Come back from limiting to attenuation 1.0 in this amount of milliseconds.
  559. Default is 50 milliseconds.
  560. @item asc
  561. When gain reduction is always needed ASC takes care of releasing to an
  562. average reduction level rather than reaching a reduction of 0 in the release
  563. time.
  564. @item asc_level
  565. Select how much the release time is affected by ASC, 0 means nearly no changes
  566. in release time while 1 produces higher release times.
  567. @end table
  568. Depending on picked setting it is recommended to upsample input 2x or 4x times
  569. with @ref{aresample} before applying this filter.
  570. @section allpass
  571. Apply a two-pole all-pass filter with central frequency (in Hz)
  572. @var{frequency}, and filter-width @var{width}.
  573. An all-pass filter changes the audio's frequency to phase relationship
  574. without changing its frequency to amplitude relationship.
  575. The filter accepts the following options:
  576. @table @option
  577. @item frequency, f
  578. Set frequency in Hz.
  579. @item width_type
  580. Set method to specify band-width of filter.
  581. @table @option
  582. @item h
  583. Hz
  584. @item q
  585. Q-Factor
  586. @item o
  587. octave
  588. @item s
  589. slope
  590. @end table
  591. @item width, w
  592. Specify the band-width of a filter in width_type units.
  593. @end table
  594. @anchor{amerge}
  595. @section amerge
  596. Merge two or more audio streams into a single multi-channel stream.
  597. The filter accepts the following options:
  598. @table @option
  599. @item inputs
  600. Set the number of inputs. Default is 2.
  601. @end table
  602. If the channel layouts of the inputs are disjoint, and therefore compatible,
  603. the channel layout of the output will be set accordingly and the channels
  604. will be reordered as necessary. If the channel layouts of the inputs are not
  605. disjoint, the output will have all the channels of the first input then all
  606. the channels of the second input, in that order, and the channel layout of
  607. the output will be the default value corresponding to the total number of
  608. channels.
  609. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  610. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  611. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  612. first input, b1 is the first channel of the second input).
  613. On the other hand, if both input are in stereo, the output channels will be
  614. in the default order: a1, a2, b1, b2, and the channel layout will be
  615. arbitrarily set to 4.0, which may or may not be the expected value.
  616. All inputs must have the same sample rate, and format.
  617. If inputs do not have the same duration, the output will stop with the
  618. shortest.
  619. @subsection Examples
  620. @itemize
  621. @item
  622. Merge two mono files into a stereo stream:
  623. @example
  624. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  625. @end example
  626. @item
  627. Multiple merges assuming 1 video stream and 6 audio streams in @file{input.mkv}:
  628. @example
  629. 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
  630. @end example
  631. @end itemize
  632. @section amix
  633. Mixes multiple audio inputs into a single output.
  634. Note that this filter only supports float samples (the @var{amerge}
  635. and @var{pan} audio filters support many formats). If the @var{amix}
  636. input has integer samples then @ref{aresample} will be automatically
  637. inserted to perform the conversion to float samples.
  638. For example
  639. @example
  640. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  641. @end example
  642. will mix 3 input audio streams to a single output with the same duration as the
  643. first input and a dropout transition time of 3 seconds.
  644. It accepts the following parameters:
  645. @table @option
  646. @item inputs
  647. The number of inputs. If unspecified, it defaults to 2.
  648. @item duration
  649. How to determine the end-of-stream.
  650. @table @option
  651. @item longest
  652. The duration of the longest input. (default)
  653. @item shortest
  654. The duration of the shortest input.
  655. @item first
  656. The duration of the first input.
  657. @end table
  658. @item dropout_transition
  659. The transition time, in seconds, for volume renormalization when an input
  660. stream ends. The default value is 2 seconds.
  661. @end table
  662. @section anull
  663. Pass the audio source unchanged to the output.
  664. @section apad
  665. Pad the end of an audio stream with silence.
  666. This can be used together with @command{ffmpeg} @option{-shortest} to
  667. extend audio streams to the same length as the video stream.
  668. A description of the accepted options follows.
  669. @table @option
  670. @item packet_size
  671. Set silence packet size. Default value is 4096.
  672. @item pad_len
  673. Set the number of samples of silence to add to the end. After the
  674. value is reached, the stream is terminated. This option is mutually
  675. exclusive with @option{whole_len}.
  676. @item whole_len
  677. Set the minimum total number of samples in the output audio stream. If
  678. the value is longer than the input audio length, silence is added to
  679. the end, until the value is reached. This option is mutually exclusive
  680. with @option{pad_len}.
  681. @end table
  682. If neither the @option{pad_len} nor the @option{whole_len} option is
  683. set, the filter will add silence to the end of the input stream
  684. indefinitely.
  685. @subsection Examples
  686. @itemize
  687. @item
  688. Add 1024 samples of silence to the end of the input:
  689. @example
  690. apad=pad_len=1024
  691. @end example
  692. @item
  693. Make sure the audio output will contain at least 10000 samples, pad
  694. the input with silence if required:
  695. @example
  696. apad=whole_len=10000
  697. @end example
  698. @item
  699. Use @command{ffmpeg} to pad the audio input with silence, so that the
  700. video stream will always result the shortest and will be converted
  701. until the end in the output file when using the @option{shortest}
  702. option:
  703. @example
  704. ffmpeg -i VIDEO -i AUDIO -filter_complex "[1:0]apad" -shortest OUTPUT
  705. @end example
  706. @end itemize
  707. @section aphaser
  708. Add a phasing effect to the input audio.
  709. A phaser filter creates series of peaks and troughs in the frequency spectrum.
  710. The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
  711. A description of the accepted parameters follows.
  712. @table @option
  713. @item in_gain
  714. Set input gain. Default is 0.4.
  715. @item out_gain
  716. Set output gain. Default is 0.74
  717. @item delay
  718. Set delay in milliseconds. Default is 3.0.
  719. @item decay
  720. Set decay. Default is 0.4.
  721. @item speed
  722. Set modulation speed in Hz. Default is 0.5.
  723. @item type
  724. Set modulation type. Default is triangular.
  725. It accepts the following values:
  726. @table @samp
  727. @item triangular, t
  728. @item sinusoidal, s
  729. @end table
  730. @end table
  731. @anchor{aresample}
  732. @section aresample
  733. Resample the input audio to the specified parameters, using the
  734. libswresample library. If none are specified then the filter will
  735. automatically convert between its input and output.
  736. This filter is also able to stretch/squeeze the audio data to make it match
  737. the timestamps or to inject silence / cut out audio to make it match the
  738. timestamps, do a combination of both or do neither.
  739. The filter accepts the syntax
  740. [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
  741. expresses a sample rate and @var{resampler_options} is a list of
  742. @var{key}=@var{value} pairs, separated by ":". See the
  743. ffmpeg-resampler manual for the complete list of supported options.
  744. @subsection Examples
  745. @itemize
  746. @item
  747. Resample the input audio to 44100Hz:
  748. @example
  749. aresample=44100
  750. @end example
  751. @item
  752. Stretch/squeeze samples to the given timestamps, with a maximum of 1000
  753. samples per second compensation:
  754. @example
  755. aresample=async=1000
  756. @end example
  757. @end itemize
  758. @section asetnsamples
  759. Set the number of samples per each output audio frame.
  760. The last output packet may contain a different number of samples, as
  761. the filter will flush all the remaining samples when the input audio
  762. signal its end.
  763. The filter accepts the following options:
  764. @table @option
  765. @item nb_out_samples, n
  766. Set the number of frames per each output audio frame. The number is
  767. intended as the number of samples @emph{per each channel}.
  768. Default value is 1024.
  769. @item pad, p
  770. If set to 1, the filter will pad the last audio frame with zeroes, so
  771. that the last frame will contain the same number of samples as the
  772. previous ones. Default value is 1.
  773. @end table
  774. For example, to set the number of per-frame samples to 1234 and
  775. disable padding for the last frame, use:
  776. @example
  777. asetnsamples=n=1234:p=0
  778. @end example
  779. @section asetrate
  780. Set the sample rate without altering the PCM data.
  781. This will result in a change of speed and pitch.
  782. The filter accepts the following options:
  783. @table @option
  784. @item sample_rate, r
  785. Set the output sample rate. Default is 44100 Hz.
  786. @end table
  787. @section ashowinfo
  788. Show a line containing various information for each input audio frame.
  789. The input audio is not modified.
  790. The shown line contains a sequence of key/value pairs of the form
  791. @var{key}:@var{value}.
  792. The following values are shown in the output:
  793. @table @option
  794. @item n
  795. The (sequential) number of the input frame, starting from 0.
  796. @item pts
  797. The presentation timestamp of the input frame, in time base units; the time base
  798. depends on the filter input pad, and is usually 1/@var{sample_rate}.
  799. @item pts_time
  800. The presentation timestamp of the input frame in seconds.
  801. @item pos
  802. position of the frame in the input stream, -1 if this information in
  803. unavailable and/or meaningless (for example in case of synthetic audio)
  804. @item fmt
  805. The sample format.
  806. @item chlayout
  807. The channel layout.
  808. @item rate
  809. The sample rate for the audio frame.
  810. @item nb_samples
  811. The number of samples (per channel) in the frame.
  812. @item checksum
  813. The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
  814. audio, the data is treated as if all the planes were concatenated.
  815. @item plane_checksums
  816. A list of Adler-32 checksums for each data plane.
  817. @end table
  818. @anchor{astats}
  819. @section astats
  820. Display time domain statistical information about the audio channels.
  821. Statistics are calculated and displayed for each audio channel and,
  822. where applicable, an overall figure is also given.
  823. It accepts the following option:
  824. @table @option
  825. @item length
  826. Short window length in seconds, used for peak and trough RMS measurement.
  827. Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.1 - 10]}.
  828. @item metadata
  829. Set metadata injection. All the metadata keys are prefixed with @code{lavfi.astats.X},
  830. where @code{X} is channel number starting from 1 or string @code{Overall}. Default is
  831. disabled.
  832. Available keys for each channel are:
  833. DC_offset
  834. Min_level
  835. Max_level
  836. Min_difference
  837. Max_difference
  838. Mean_difference
  839. Peak_level
  840. RMS_peak
  841. RMS_trough
  842. Crest_factor
  843. Flat_factor
  844. Peak_count
  845. Bit_depth
  846. and for Overall:
  847. DC_offset
  848. Min_level
  849. Max_level
  850. Min_difference
  851. Max_difference
  852. Mean_difference
  853. Peak_level
  854. RMS_level
  855. RMS_peak
  856. RMS_trough
  857. Flat_factor
  858. Peak_count
  859. Bit_depth
  860. Number_of_samples
  861. For example full key look like this @code{lavfi.astats.1.DC_offset} or
  862. this @code{lavfi.astats.Overall.Peak_count}.
  863. For description what each key means read below.
  864. @item reset
  865. Set number of frame after which stats are going to be recalculated.
  866. Default is disabled.
  867. @end table
  868. A description of each shown parameter follows:
  869. @table @option
  870. @item DC offset
  871. Mean amplitude displacement from zero.
  872. @item Min level
  873. Minimal sample level.
  874. @item Max level
  875. Maximal sample level.
  876. @item Min difference
  877. Minimal difference between two consecutive samples.
  878. @item Max difference
  879. Maximal difference between two consecutive samples.
  880. @item Mean difference
  881. Mean difference between two consecutive samples.
  882. The average of each difference between two consecutive samples.
  883. @item Peak level dB
  884. @item RMS level dB
  885. Standard peak and RMS level measured in dBFS.
  886. @item RMS peak dB
  887. @item RMS trough dB
  888. Peak and trough values for RMS level measured over a short window.
  889. @item Crest factor
  890. Standard ratio of peak to RMS level (note: not in dB).
  891. @item Flat factor
  892. Flatness (i.e. consecutive samples with the same value) of the signal at its peak levels
  893. (i.e. either @var{Min level} or @var{Max level}).
  894. @item Peak count
  895. Number of occasions (not the number of samples) that the signal attained either
  896. @var{Min level} or @var{Max level}.
  897. @item Bit depth
  898. Overall bit depth of audio. Number of bits used for each sample.
  899. @end table
  900. @section astreamsync
  901. Forward two audio streams and control the order the buffers are forwarded.
  902. The filter accepts the following options:
  903. @table @option
  904. @item expr, e
  905. Set the expression deciding which stream should be
  906. forwarded next: if the result is negative, the first stream is forwarded; if
  907. the result is positive or zero, the second stream is forwarded. It can use
  908. the following variables:
  909. @table @var
  910. @item b1 b2
  911. number of buffers forwarded so far on each stream
  912. @item s1 s2
  913. number of samples forwarded so far on each stream
  914. @item t1 t2
  915. current timestamp of each stream
  916. @end table
  917. The default value is @code{t1-t2}, which means to always forward the stream
  918. that has a smaller timestamp.
  919. @end table
  920. @subsection Examples
  921. Stress-test @code{amerge} by randomly sending buffers on the wrong
  922. input, while avoiding too much of a desynchronization:
  923. @example
  924. amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
  925. [a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
  926. [a2] [b2] amerge
  927. @end example
  928. @section asyncts
  929. Synchronize audio data with timestamps by squeezing/stretching it and/or
  930. dropping samples/adding silence when needed.
  931. This filter is not built by default, please use @ref{aresample} to do squeezing/stretching.
  932. It accepts the following parameters:
  933. @table @option
  934. @item compensate
  935. Enable stretching/squeezing the data to make it match the timestamps. Disabled
  936. by default. When disabled, time gaps are covered with silence.
  937. @item min_delta
  938. The minimum difference between timestamps and audio data (in seconds) to trigger
  939. adding/dropping samples. The default value is 0.1. If you get an imperfect
  940. sync with this filter, try setting this parameter to 0.
  941. @item max_comp
  942. The maximum compensation in samples per second. Only relevant with compensate=1.
  943. The default value is 500.
  944. @item first_pts
  945. Assume that the first PTS should be this value. The time base is 1 / sample
  946. rate. This allows for padding/trimming at the start of the stream. By default,
  947. no assumption is made about the first frame's expected PTS, so no padding or
  948. trimming is done. For example, this could be set to 0 to pad the beginning with
  949. silence if an audio stream starts after the video stream or to trim any samples
  950. with a negative PTS due to encoder delay.
  951. @end table
  952. @section atempo
  953. Adjust audio tempo.
  954. The filter accepts exactly one parameter, the audio tempo. If not
  955. specified then the filter will assume nominal 1.0 tempo. Tempo must
  956. be in the [0.5, 2.0] range.
  957. @subsection Examples
  958. @itemize
  959. @item
  960. Slow down audio to 80% tempo:
  961. @example
  962. atempo=0.8
  963. @end example
  964. @item
  965. To speed up audio to 125% tempo:
  966. @example
  967. atempo=1.25
  968. @end example
  969. @end itemize
  970. @section atrim
  971. Trim the input so that the output contains one continuous subpart of the input.
  972. It accepts the following parameters:
  973. @table @option
  974. @item start
  975. Timestamp (in seconds) of the start of the section to keep. I.e. the audio
  976. sample with the timestamp @var{start} will be the first sample in the output.
  977. @item end
  978. Specify time of the first audio sample that will be dropped, i.e. the
  979. audio sample immediately preceding the one with the timestamp @var{end} will be
  980. the last sample in the output.
  981. @item start_pts
  982. Same as @var{start}, except this option sets the start timestamp in samples
  983. instead of seconds.
  984. @item end_pts
  985. Same as @var{end}, except this option sets the end timestamp in samples instead
  986. of seconds.
  987. @item duration
  988. The maximum duration of the output in seconds.
  989. @item start_sample
  990. The number of the first sample that should be output.
  991. @item end_sample
  992. The number of the first sample that should be dropped.
  993. @end table
  994. @option{start}, @option{end}, and @option{duration} are expressed as time
  995. duration specifications; see
  996. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  997. Note that the first two sets of the start/end options and the @option{duration}
  998. option look at the frame timestamp, while the _sample options simply count the
  999. samples that pass through the filter. So start/end_pts and start/end_sample will
  1000. give different results when the timestamps are wrong, inexact or do not start at
  1001. zero. Also note that this filter does not modify the timestamps. If you wish
  1002. to have the output timestamps start at zero, insert the asetpts filter after the
  1003. atrim filter.
  1004. If multiple start or end options are set, this filter tries to be greedy and
  1005. keep all samples that match at least one of the specified constraints. To keep
  1006. only the part that matches all the constraints at once, chain multiple atrim
  1007. filters.
  1008. The defaults are such that all the input is kept. So it is possible to set e.g.
  1009. just the end values to keep everything before the specified time.
  1010. Examples:
  1011. @itemize
  1012. @item
  1013. Drop everything except the second minute of input:
  1014. @example
  1015. ffmpeg -i INPUT -af atrim=60:120
  1016. @end example
  1017. @item
  1018. Keep only the first 1000 samples:
  1019. @example
  1020. ffmpeg -i INPUT -af atrim=end_sample=1000
  1021. @end example
  1022. @end itemize
  1023. @section bandpass
  1024. Apply a two-pole Butterworth band-pass filter with central
  1025. frequency @var{frequency}, and (3dB-point) band-width width.
  1026. The @var{csg} option selects a constant skirt gain (peak gain = Q)
  1027. instead of the default: constant 0dB peak gain.
  1028. The filter roll off at 6dB per octave (20dB per decade).
  1029. The filter accepts the following options:
  1030. @table @option
  1031. @item frequency, f
  1032. Set the filter's central frequency. Default is @code{3000}.
  1033. @item csg
  1034. Constant skirt gain if set to 1. Defaults to 0.
  1035. @item width_type
  1036. Set method to specify band-width of filter.
  1037. @table @option
  1038. @item h
  1039. Hz
  1040. @item q
  1041. Q-Factor
  1042. @item o
  1043. octave
  1044. @item s
  1045. slope
  1046. @end table
  1047. @item width, w
  1048. Specify the band-width of a filter in width_type units.
  1049. @end table
  1050. @section bandreject
  1051. Apply a two-pole Butterworth band-reject filter with central
  1052. frequency @var{frequency}, and (3dB-point) band-width @var{width}.
  1053. The filter roll off at 6dB per octave (20dB per decade).
  1054. The filter accepts the following options:
  1055. @table @option
  1056. @item frequency, f
  1057. Set the filter's central frequency. Default is @code{3000}.
  1058. @item width_type
  1059. Set method to specify band-width of filter.
  1060. @table @option
  1061. @item h
  1062. Hz
  1063. @item q
  1064. Q-Factor
  1065. @item o
  1066. octave
  1067. @item s
  1068. slope
  1069. @end table
  1070. @item width, w
  1071. Specify the band-width of a filter in width_type units.
  1072. @end table
  1073. @section bass
  1074. Boost or cut the bass (lower) frequencies of the audio using a two-pole
  1075. shelving filter with a response similar to that of a standard
  1076. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  1077. The filter accepts the following options:
  1078. @table @option
  1079. @item gain, g
  1080. Give the gain at 0 Hz. Its useful range is about -20
  1081. (for a large cut) to +20 (for a large boost).
  1082. Beware of clipping when using a positive gain.
  1083. @item frequency, f
  1084. Set the filter's central frequency and so can be used
  1085. to extend or reduce the frequency range to be boosted or cut.
  1086. The default value is @code{100} Hz.
  1087. @item width_type
  1088. Set method to specify band-width of filter.
  1089. @table @option
  1090. @item h
  1091. Hz
  1092. @item q
  1093. Q-Factor
  1094. @item o
  1095. octave
  1096. @item s
  1097. slope
  1098. @end table
  1099. @item width, w
  1100. Determine how steep is the filter's shelf transition.
  1101. @end table
  1102. @section biquad
  1103. Apply a biquad IIR filter with the given coefficients.
  1104. Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
  1105. are the numerator and denominator coefficients respectively.
  1106. @section bs2b
  1107. Bauer stereo to binaural transformation, which improves headphone listening of
  1108. stereo audio records.
  1109. It accepts the following parameters:
  1110. @table @option
  1111. @item profile
  1112. Pre-defined crossfeed level.
  1113. @table @option
  1114. @item default
  1115. Default level (fcut=700, feed=50).
  1116. @item cmoy
  1117. Chu Moy circuit (fcut=700, feed=60).
  1118. @item jmeier
  1119. Jan Meier circuit (fcut=650, feed=95).
  1120. @end table
  1121. @item fcut
  1122. Cut frequency (in Hz).
  1123. @item feed
  1124. Feed level (in Hz).
  1125. @end table
  1126. @section channelmap
  1127. Remap input channels to new locations.
  1128. It accepts the following parameters:
  1129. @table @option
  1130. @item channel_layout
  1131. The channel layout of the output stream.
  1132. @item map
  1133. Map channels from input to output. The argument is a '|'-separated list of
  1134. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  1135. @var{in_channel} form. @var{in_channel} can be either the name of the input
  1136. channel (e.g. FL for front left) or its index in the input channel layout.
  1137. @var{out_channel} is the name of the output channel or its index in the output
  1138. channel layout. If @var{out_channel} is not given then it is implicitly an
  1139. index, starting with zero and increasing by one for each mapping.
  1140. @end table
  1141. If no mapping is present, the filter will implicitly map input channels to
  1142. output channels, preserving indices.
  1143. For example, assuming a 5.1+downmix input MOV file,
  1144. @example
  1145. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
  1146. @end example
  1147. will create an output WAV file tagged as stereo from the downmix channels of
  1148. the input.
  1149. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  1150. @example
  1151. ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:5.1' out.wav
  1152. @end example
  1153. @section channelsplit
  1154. Split each channel from an input audio stream into a separate output stream.
  1155. It accepts the following parameters:
  1156. @table @option
  1157. @item channel_layout
  1158. The channel layout of the input stream. The default is "stereo".
  1159. @end table
  1160. For example, assuming a stereo input MP3 file,
  1161. @example
  1162. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  1163. @end example
  1164. will create an output Matroska file with two audio streams, one containing only
  1165. the left channel and the other the right channel.
  1166. Split a 5.1 WAV file into per-channel files:
  1167. @example
  1168. ffmpeg -i in.wav -filter_complex
  1169. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  1170. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  1171. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  1172. side_right.wav
  1173. @end example
  1174. @section chorus
  1175. Add a chorus effect to the audio.
  1176. Can make a single vocal sound like a chorus, but can also be applied to instrumentation.
  1177. Chorus resembles an echo effect with a short delay, but whereas with echo the delay is
  1178. constant, with chorus, it is varied using using sinusoidal or triangular modulation.
  1179. The modulation depth defines the range the modulated delay is played before or after
  1180. the delay. Hence the delayed sound will sound slower or faster, that is the delayed
  1181. sound tuned around the original one, like in a chorus where some vocals are slightly
  1182. off key.
  1183. It accepts the following parameters:
  1184. @table @option
  1185. @item in_gain
  1186. Set input gain. Default is 0.4.
  1187. @item out_gain
  1188. Set output gain. Default is 0.4.
  1189. @item delays
  1190. Set delays. A typical delay is around 40ms to 60ms.
  1191. @item decays
  1192. Set decays.
  1193. @item speeds
  1194. Set speeds.
  1195. @item depths
  1196. Set depths.
  1197. @end table
  1198. @subsection Examples
  1199. @itemize
  1200. @item
  1201. A single delay:
  1202. @example
  1203. chorus=0.7:0.9:55:0.4:0.25:2
  1204. @end example
  1205. @item
  1206. Two delays:
  1207. @example
  1208. chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3
  1209. @end example
  1210. @item
  1211. Fuller sounding chorus with three delays:
  1212. @example
  1213. 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
  1214. @end example
  1215. @end itemize
  1216. @section compand
  1217. Compress or expand the audio's dynamic range.
  1218. It accepts the following parameters:
  1219. @table @option
  1220. @item attacks
  1221. @item decays
  1222. A list of times in seconds for each channel over which the instantaneous level
  1223. of the input signal is averaged to determine its volume. @var{attacks} refers to
  1224. increase of volume and @var{decays} refers to decrease of volume. For most
  1225. situations, the attack time (response to the audio getting louder) should be
  1226. shorter than the decay time, because the human ear is more sensitive to sudden
  1227. loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
  1228. a typical value for decay is 0.8 seconds.
  1229. If specified number of attacks & decays is lower than number of channels, the last
  1230. set attack/decay will be used for all remaining channels.
  1231. @item points
  1232. A list of points for the transfer function, specified in dB relative to the
  1233. maximum possible signal amplitude. Each key points list must be defined using
  1234. the following syntax: @code{x0/y0|x1/y1|x2/y2|....} or
  1235. @code{x0/y0 x1/y1 x2/y2 ....}
  1236. The input values must be in strictly increasing order but the transfer function
  1237. does not have to be monotonically rising. The point @code{0/0} is assumed but
  1238. may be overridden (by @code{0/out-dBn}). Typical values for the transfer
  1239. function are @code{-70/-70|-60/-20}.
  1240. @item soft-knee
  1241. Set the curve radius in dB for all joints. It defaults to 0.01.
  1242. @item gain
  1243. Set the additional gain in dB to be applied at all points on the transfer
  1244. function. This allows for easy adjustment of the overall gain.
  1245. It defaults to 0.
  1246. @item volume
  1247. Set an initial volume, in dB, to be assumed for each channel when filtering
  1248. starts. This permits the user to supply a nominal level initially, so that, for
  1249. example, a very large gain is not applied to initial signal levels before the
  1250. companding has begun to operate. A typical value for audio which is initially
  1251. quiet is -90 dB. It defaults to 0.
  1252. @item delay
  1253. Set a delay, in seconds. The input audio is analyzed immediately, but audio is
  1254. delayed before being fed to the volume adjuster. Specifying a delay
  1255. approximately equal to the attack/decay times allows the filter to effectively
  1256. operate in predictive rather than reactive mode. It defaults to 0.
  1257. @end table
  1258. @subsection Examples
  1259. @itemize
  1260. @item
  1261. Make music with both quiet and loud passages suitable for listening to in a
  1262. noisy environment:
  1263. @example
  1264. compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
  1265. @end example
  1266. Another example for audio with whisper and explosion parts:
  1267. @example
  1268. compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0
  1269. @end example
  1270. @item
  1271. A noise gate for when the noise is at a lower level than the signal:
  1272. @example
  1273. compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
  1274. @end example
  1275. @item
  1276. Here is another noise gate, this time for when the noise is at a higher level
  1277. than the signal (making it, in some ways, similar to squelch):
  1278. @example
  1279. compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
  1280. @end example
  1281. @end itemize
  1282. @section dcshift
  1283. Apply a DC shift to the audio.
  1284. This can be useful to remove a DC offset (caused perhaps by a hardware problem
  1285. in the recording chain) from the audio. The effect of a DC offset is reduced
  1286. headroom and hence volume. The @ref{astats} filter can be used to determine if
  1287. a signal has a DC offset.
  1288. @table @option
  1289. @item shift
  1290. Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift
  1291. the audio.
  1292. @item limitergain
  1293. Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
  1294. used to prevent clipping.
  1295. @end table
  1296. @section dynaudnorm
  1297. Dynamic Audio Normalizer.
  1298. This filter applies a certain amount of gain to the input audio in order
  1299. to bring its peak magnitude to a target level (e.g. 0 dBFS). However, in
  1300. contrast to more "simple" normalization algorithms, the Dynamic Audio
  1301. Normalizer *dynamically* re-adjusts the gain factor to the input audio.
  1302. This allows for applying extra gain to the "quiet" sections of the audio
  1303. while avoiding distortions or clipping the "loud" sections. In other words:
  1304. The Dynamic Audio Normalizer will "even out" the volume of quiet and loud
  1305. sections, in the sense that the volume of each section is brought to the
  1306. same target level. Note, however, that the Dynamic Audio Normalizer achieves
  1307. this goal *without* applying "dynamic range compressing". It will retain 100%
  1308. of the dynamic range *within* each section of the audio file.
  1309. @table @option
  1310. @item f
  1311. Set the frame length in milliseconds. In range from 10 to 8000 milliseconds.
  1312. Default is 500 milliseconds.
  1313. The Dynamic Audio Normalizer processes the input audio in small chunks,
  1314. referred to as frames. This is required, because a peak magnitude has no
  1315. meaning for just a single sample value. Instead, we need to determine the
  1316. peak magnitude for a contiguous sequence of sample values. While a "standard"
  1317. normalizer would simply use the peak magnitude of the complete file, the
  1318. Dynamic Audio Normalizer determines the peak magnitude individually for each
  1319. frame. The length of a frame is specified in milliseconds. By default, the
  1320. Dynamic Audio Normalizer uses a frame length of 500 milliseconds, which has
  1321. been found to give good results with most files.
  1322. Note that the exact frame length, in number of samples, will be determined
  1323. automatically, based on the sampling rate of the individual input audio file.
  1324. @item g
  1325. Set the Gaussian filter window size. In range from 3 to 301, must be odd
  1326. number. Default is 31.
  1327. Probably the most important parameter of the Dynamic Audio Normalizer is the
  1328. @code{window size} of the Gaussian smoothing filter. The filter's window size
  1329. is specified in frames, centered around the current frame. For the sake of
  1330. simplicity, this must be an odd number. Consequently, the default value of 31
  1331. takes into account the current frame, as well as the 15 preceding frames and
  1332. the 15 subsequent frames. Using a larger window results in a stronger
  1333. smoothing effect and thus in less gain variation, i.e. slower gain
  1334. adaptation. Conversely, using a smaller window results in a weaker smoothing
  1335. effect and thus in more gain variation, i.e. faster gain adaptation.
  1336. In other words, the more you increase this value, the more the Dynamic Audio
  1337. Normalizer will behave like a "traditional" normalization filter. On the
  1338. contrary, the more you decrease this value, the more the Dynamic Audio
  1339. Normalizer will behave like a dynamic range compressor.
  1340. @item p
  1341. Set the target peak value. This specifies the highest permissible magnitude
  1342. level for the normalized audio input. This filter will try to approach the
  1343. target peak magnitude as closely as possible, but at the same time it also
  1344. makes sure that the normalized signal will never exceed the peak magnitude.
  1345. A frame's maximum local gain factor is imposed directly by the target peak
  1346. magnitude. The default value is 0.95 and thus leaves a headroom of 5%*.
  1347. It is not recommended to go above this value.
  1348. @item m
  1349. Set the maximum gain factor. In range from 1.0 to 100.0. Default is 10.0.
  1350. The Dynamic Audio Normalizer determines the maximum possible (local) gain
  1351. factor for each input frame, i.e. the maximum gain factor that does not
  1352. result in clipping or distortion. The maximum gain factor is determined by
  1353. the frame's highest magnitude sample. However, the Dynamic Audio Normalizer
  1354. additionally bounds the frame's maximum gain factor by a predetermined
  1355. (global) maximum gain factor. This is done in order to avoid excessive gain
  1356. factors in "silent" or almost silent frames. By default, the maximum gain
  1357. factor is 10.0, For most inputs the default value should be sufficient and
  1358. it usually is not recommended to increase this value. Though, for input
  1359. with an extremely low overall volume level, it may be necessary to allow even
  1360. higher gain factors. Note, however, that the Dynamic Audio Normalizer does
  1361. not simply apply a "hard" threshold (i.e. cut off values above the threshold).
  1362. Instead, a "sigmoid" threshold function will be applied. This way, the
  1363. gain factors will smoothly approach the threshold value, but never exceed that
  1364. value.
  1365. @item r
  1366. Set the target RMS. In range from 0.0 to 1.0. Default is 0.0 - disabled.
  1367. By default, the Dynamic Audio Normalizer performs "peak" normalization.
  1368. This means that the maximum local gain factor for each frame is defined
  1369. (only) by the frame's highest magnitude sample. This way, the samples can
  1370. be amplified as much as possible without exceeding the maximum signal
  1371. level, i.e. without clipping. Optionally, however, the Dynamic Audio
  1372. Normalizer can also take into account the frame's root mean square,
  1373. abbreviated RMS. In electrical engineering, the RMS is commonly used to
  1374. determine the power of a time-varying signal. It is therefore considered
  1375. that the RMS is a better approximation of the "perceived loudness" than
  1376. just looking at the signal's peak magnitude. Consequently, by adjusting all
  1377. frames to a constant RMS value, a uniform "perceived loudness" can be
  1378. established. If a target RMS value has been specified, a frame's local gain
  1379. factor is defined as the factor that would result in exactly that RMS value.
  1380. Note, however, that the maximum local gain factor is still restricted by the
  1381. frame's highest magnitude sample, in order to prevent clipping.
  1382. @item n
  1383. Enable channels coupling. By default is enabled.
  1384. By default, the Dynamic Audio Normalizer will amplify all channels by the same
  1385. amount. This means the same gain factor will be applied to all channels, i.e.
  1386. the maximum possible gain factor is determined by the "loudest" channel.
  1387. However, in some recordings, it may happen that the volume of the different
  1388. channels is uneven, e.g. one channel may be "quieter" than the other one(s).
  1389. In this case, this option can be used to disable the channel coupling. This way,
  1390. the gain factor will be determined independently for each channel, depending
  1391. only on the individual channel's highest magnitude sample. This allows for
  1392. harmonizing the volume of the different channels.
  1393. @item c
  1394. Enable DC bias correction. By default is disabled.
  1395. An audio signal (in the time domain) is a sequence of sample values.
  1396. In the Dynamic Audio Normalizer these sample values are represented in the
  1397. -1.0 to 1.0 range, regardless of the original input format. Normally, the
  1398. audio signal, or "waveform", should be centered around the zero point.
  1399. That means if we calculate the mean value of all samples in a file, or in a
  1400. single frame, then the result should be 0.0 or at least very close to that
  1401. value. If, however, there is a significant deviation of the mean value from
  1402. 0.0, in either positive or negative direction, this is referred to as a
  1403. DC bias or DC offset. Since a DC bias is clearly undesirable, the Dynamic
  1404. Audio Normalizer provides optional DC bias correction.
  1405. With DC bias correction enabled, the Dynamic Audio Normalizer will determine
  1406. the mean value, or "DC correction" offset, of each input frame and subtract
  1407. that value from all of the frame's sample values which ensures those samples
  1408. are centered around 0.0 again. Also, in order to avoid "gaps" at the frame
  1409. boundaries, the DC correction offset values will be interpolated smoothly
  1410. between neighbouring frames.
  1411. @item b
  1412. Enable alternative boundary mode. By default is disabled.
  1413. The Dynamic Audio Normalizer takes into account a certain neighbourhood
  1414. around each frame. This includes the preceding frames as well as the
  1415. subsequent frames. However, for the "boundary" frames, located at the very
  1416. beginning and at the very end of the audio file, not all neighbouring
  1417. frames are available. In particular, for the first few frames in the audio
  1418. file, the preceding frames are not known. And, similarly, for the last few
  1419. frames in the audio file, the subsequent frames are not known. Thus, the
  1420. question arises which gain factors should be assumed for the missing frames
  1421. in the "boundary" region. The Dynamic Audio Normalizer implements two modes
  1422. to deal with this situation. The default boundary mode assumes a gain factor
  1423. of exactly 1.0 for the missing frames, resulting in a smooth "fade in" and
  1424. "fade out" at the beginning and at the end of the input, respectively.
  1425. @item s
  1426. Set the compress factor. In range from 0.0 to 30.0. Default is 0.0.
  1427. By default, the Dynamic Audio Normalizer does not apply "traditional"
  1428. compression. This means that signal peaks will not be pruned and thus the
  1429. full dynamic range will be retained within each local neighbourhood. However,
  1430. in some cases it may be desirable to combine the Dynamic Audio Normalizer's
  1431. normalization algorithm with a more "traditional" compression.
  1432. For this purpose, the Dynamic Audio Normalizer provides an optional compression
  1433. (thresholding) function. If (and only if) the compression feature is enabled,
  1434. all input frames will be processed by a soft knee thresholding function prior
  1435. to the actual normalization process. Put simply, the thresholding function is
  1436. going to prune all samples whose magnitude exceeds a certain threshold value.
  1437. However, the Dynamic Audio Normalizer does not simply apply a fixed threshold
  1438. value. Instead, the threshold value will be adjusted for each individual
  1439. frame.
  1440. In general, smaller parameters result in stronger compression, and vice versa.
  1441. Values below 3.0 are not recommended, because audible distortion may appear.
  1442. @end table
  1443. @section earwax
  1444. Make audio easier to listen to on headphones.
  1445. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  1446. so that when listened to on headphones the stereo image is moved from
  1447. inside your head (standard for headphones) to outside and in front of
  1448. the listener (standard for speakers).
  1449. Ported from SoX.
  1450. @section equalizer
  1451. Apply a two-pole peaking equalisation (EQ) filter. With this
  1452. filter, the signal-level at and around a selected frequency can
  1453. be increased or decreased, whilst (unlike bandpass and bandreject
  1454. filters) that at all other frequencies is unchanged.
  1455. In order to produce complex equalisation curves, this filter can
  1456. be given several times, each with a different central frequency.
  1457. The filter accepts the following options:
  1458. @table @option
  1459. @item frequency, f
  1460. Set the filter's central frequency in Hz.
  1461. @item width_type
  1462. Set method to specify band-width of filter.
  1463. @table @option
  1464. @item h
  1465. Hz
  1466. @item q
  1467. Q-Factor
  1468. @item o
  1469. octave
  1470. @item s
  1471. slope
  1472. @end table
  1473. @item width, w
  1474. Specify the band-width of a filter in width_type units.
  1475. @item gain, g
  1476. Set the required gain or attenuation in dB.
  1477. Beware of clipping when using a positive gain.
  1478. @end table
  1479. @subsection Examples
  1480. @itemize
  1481. @item
  1482. Attenuate 10 dB at 1000 Hz, with a bandwidth of 200 Hz:
  1483. @example
  1484. equalizer=f=1000:width_type=h:width=200:g=-10
  1485. @end example
  1486. @item
  1487. Apply 2 dB gain at 1000 Hz with Q 1 and attenuate 5 dB at 100 Hz with Q 2:
  1488. @example
  1489. equalizer=f=1000:width_type=q:width=1:g=2,equalizer=f=100:width_type=q:width=2:g=-5
  1490. @end example
  1491. @end itemize
  1492. @section extrastereo
  1493. Linearly increases the difference between left and right channels which
  1494. adds some sort of "live" effect to playback.
  1495. The filter accepts the following option:
  1496. @table @option
  1497. @item m
  1498. Sets the difference coefficient (default: 2.5). 0.0 means mono sound
  1499. (average of both channels), with 1.0 sound will be unchanged, with
  1500. -1.0 left and right channels will be swapped.
  1501. @item c
  1502. Enable clipping. By default is enabled.
  1503. @end table
  1504. @section flanger
  1505. Apply a flanging effect to the audio.
  1506. The filter accepts the following options:
  1507. @table @option
  1508. @item delay
  1509. Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
  1510. @item depth
  1511. Set added swep delay in milliseconds. Range from 0 to 10. Default value is 2.
  1512. @item regen
  1513. Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
  1514. Default value is 0.
  1515. @item width
  1516. Set percentage of delayed signal mixed with original. Range from 0 to 100.
  1517. Default value is 71.
  1518. @item speed
  1519. Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
  1520. @item shape
  1521. Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
  1522. Default value is @var{sinusoidal}.
  1523. @item phase
  1524. Set swept wave percentage-shift for multi channel. Range from 0 to 100.
  1525. Default value is 25.
  1526. @item interp
  1527. Set delay-line interpolation, @var{linear} or @var{quadratic}.
  1528. Default is @var{linear}.
  1529. @end table
  1530. @section highpass
  1531. Apply a high-pass filter with 3dB point frequency.
  1532. The filter can be either single-pole, or double-pole (the default).
  1533. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1534. The filter accepts the following options:
  1535. @table @option
  1536. @item frequency, f
  1537. Set frequency in Hz. Default is 3000.
  1538. @item poles, p
  1539. Set number of poles. Default is 2.
  1540. @item width_type
  1541. Set method to specify band-width of filter.
  1542. @table @option
  1543. @item h
  1544. Hz
  1545. @item q
  1546. Q-Factor
  1547. @item o
  1548. octave
  1549. @item s
  1550. slope
  1551. @end table
  1552. @item width, w
  1553. Specify the band-width of a filter in width_type units.
  1554. Applies only to double-pole filter.
  1555. The default is 0.707q and gives a Butterworth response.
  1556. @end table
  1557. @section join
  1558. Join multiple input streams into one multi-channel stream.
  1559. It accepts the following parameters:
  1560. @table @option
  1561. @item inputs
  1562. The number of input streams. It defaults to 2.
  1563. @item channel_layout
  1564. The desired output channel layout. It defaults to stereo.
  1565. @item map
  1566. Map channels from inputs to output. The argument is a '|'-separated list of
  1567. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  1568. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  1569. can be either the name of the input channel (e.g. FL for front left) or its
  1570. index in the specified input stream. @var{out_channel} is the name of the output
  1571. channel.
  1572. @end table
  1573. The filter will attempt to guess the mappings when they are not specified
  1574. explicitly. It does so by first trying to find an unused matching input channel
  1575. and if that fails it picks the first unused input channel.
  1576. Join 3 inputs (with properly set channel layouts):
  1577. @example
  1578. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  1579. @end example
  1580. Build a 5.1 output from 6 single-channel streams:
  1581. @example
  1582. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  1583. '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'
  1584. out
  1585. @end example
  1586. @section ladspa
  1587. Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
  1588. To enable compilation of this filter you need to configure FFmpeg with
  1589. @code{--enable-ladspa}.
  1590. @table @option
  1591. @item file, f
  1592. Specifies the name of LADSPA plugin library to load. If the environment
  1593. variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
  1594. each one of the directories specified by the colon separated list in
  1595. @env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
  1596. this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
  1597. @file{/usr/lib/ladspa/}.
  1598. @item plugin, p
  1599. Specifies the plugin within the library. Some libraries contain only
  1600. one plugin, but others contain many of them. If this is not set filter
  1601. will list all available plugins within the specified library.
  1602. @item controls, c
  1603. Set the '|' separated list of controls which are zero or more floating point
  1604. values that determine the behavior of the loaded plugin (for example delay,
  1605. threshold or gain).
  1606. Controls need to be defined using the following syntax:
  1607. c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
  1608. @var{valuei} is the value set on the @var{i}-th control.
  1609. Alternatively they can be also defined using the following syntax:
  1610. @var{value0}|@var{value1}|@var{value2}|..., where
  1611. @var{valuei} is the value set on the @var{i}-th control.
  1612. If @option{controls} is set to @code{help}, all available controls and
  1613. their valid ranges are printed.
  1614. @item sample_rate, s
  1615. Specify the sample rate, default to 44100. Only used if plugin have
  1616. zero inputs.
  1617. @item nb_samples, n
  1618. Set the number of samples per channel per each output frame, default
  1619. is 1024. Only used if plugin have zero inputs.
  1620. @item duration, d
  1621. Set the minimum duration of the sourced audio. See
  1622. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  1623. for the accepted syntax.
  1624. Note that the resulting duration may be greater than the specified duration,
  1625. as the generated audio is always cut at the end of a complete frame.
  1626. If not specified, or the expressed duration is negative, the audio is
  1627. supposed to be generated forever.
  1628. Only used if plugin have zero inputs.
  1629. @end table
  1630. @subsection Examples
  1631. @itemize
  1632. @item
  1633. List all available plugins within amp (LADSPA example plugin) library:
  1634. @example
  1635. ladspa=file=amp
  1636. @end example
  1637. @item
  1638. List all available controls and their valid ranges for @code{vcf_notch}
  1639. plugin from @code{VCF} library:
  1640. @example
  1641. ladspa=f=vcf:p=vcf_notch:c=help
  1642. @end example
  1643. @item
  1644. Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
  1645. plugin library:
  1646. @example
  1647. ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
  1648. @end example
  1649. @item
  1650. Add reverberation to the audio using TAP-plugins
  1651. (Tom's Audio Processing plugins):
  1652. @example
  1653. ladspa=file=tap_reverb:tap_reverb
  1654. @end example
  1655. @item
  1656. Generate white noise, with 0.2 amplitude:
  1657. @example
  1658. ladspa=file=cmt:noise_source_white:c=c0=.2
  1659. @end example
  1660. @item
  1661. Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
  1662. @code{C* Audio Plugin Suite} (CAPS) library:
  1663. @example
  1664. ladspa=file=caps:Click:c=c1=20'
  1665. @end example
  1666. @item
  1667. Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
  1668. @example
  1669. ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
  1670. @end example
  1671. @item
  1672. Increase volume by 20dB using fast lookahead limiter from Steve Harris
  1673. @code{SWH Plugins} collection:
  1674. @example
  1675. ladspa=fast_lookahead_limiter_1913:fastLookaheadLimiter:20|0|2
  1676. @end example
  1677. @item
  1678. Attenuate low frequencies using Multiband EQ from Steve Harris
  1679. @code{SWH Plugins} collection:
  1680. @example
  1681. ladspa=mbeq_1197:mbeq:-24|-24|-24|0|0|0|0|0|0|0|0|0|0|0|0
  1682. @end example
  1683. @end itemize
  1684. @subsection Commands
  1685. This filter supports the following commands:
  1686. @table @option
  1687. @item cN
  1688. Modify the @var{N}-th control value.
  1689. If the specified value is not valid, it is ignored and prior one is kept.
  1690. @end table
  1691. @section lowpass
  1692. Apply a low-pass filter with 3dB point frequency.
  1693. The filter can be either single-pole or double-pole (the default).
  1694. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1695. The filter accepts the following options:
  1696. @table @option
  1697. @item frequency, f
  1698. Set frequency in Hz. Default is 500.
  1699. @item poles, p
  1700. Set number of poles. Default is 2.
  1701. @item width_type
  1702. Set method to specify band-width of filter.
  1703. @table @option
  1704. @item h
  1705. Hz
  1706. @item q
  1707. Q-Factor
  1708. @item o
  1709. octave
  1710. @item s
  1711. slope
  1712. @end table
  1713. @item width, w
  1714. Specify the band-width of a filter in width_type units.
  1715. Applies only to double-pole filter.
  1716. The default is 0.707q and gives a Butterworth response.
  1717. @end table
  1718. @anchor{pan}
  1719. @section pan
  1720. Mix channels with specific gain levels. The filter accepts the output
  1721. channel layout followed by a set of channels definitions.
  1722. This filter is also designed to efficiently remap the channels of an audio
  1723. stream.
  1724. The filter accepts parameters of the form:
  1725. "@var{l}|@var{outdef}|@var{outdef}|..."
  1726. @table @option
  1727. @item l
  1728. output channel layout or number of channels
  1729. @item outdef
  1730. output channel specification, of the form:
  1731. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  1732. @item out_name
  1733. output channel to define, either a channel name (FL, FR, etc.) or a channel
  1734. number (c0, c1, etc.)
  1735. @item gain
  1736. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  1737. @item in_name
  1738. input channel to use, see out_name for details; it is not possible to mix
  1739. named and numbered input channels
  1740. @end table
  1741. If the `=' in a channel specification is replaced by `<', then the gains for
  1742. that specification will be renormalized so that the total is 1, thus
  1743. avoiding clipping noise.
  1744. @subsection Mixing examples
  1745. For example, if you want to down-mix from stereo to mono, but with a bigger
  1746. factor for the left channel:
  1747. @example
  1748. pan=1c|c0=0.9*c0+0.1*c1
  1749. @end example
  1750. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  1751. 7-channels surround:
  1752. @example
  1753. pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  1754. @end example
  1755. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  1756. that should be preferred (see "-ac" option) unless you have very specific
  1757. needs.
  1758. @subsection Remapping examples
  1759. The channel remapping will be effective if, and only if:
  1760. @itemize
  1761. @item gain coefficients are zeroes or ones,
  1762. @item only one input per channel output,
  1763. @end itemize
  1764. If all these conditions are satisfied, the filter will notify the user ("Pure
  1765. channel mapping detected"), and use an optimized and lossless method to do the
  1766. remapping.
  1767. For example, if you have a 5.1 source and want a stereo audio stream by
  1768. dropping the extra channels:
  1769. @example
  1770. pan="stereo| c0=FL | c1=FR"
  1771. @end example
  1772. Given the same source, you can also switch front left and front right channels
  1773. and keep the input channel layout:
  1774. @example
  1775. pan="5.1| c0=c1 | c1=c0 | c2=c2 | c3=c3 | c4=c4 | c5=c5"
  1776. @end example
  1777. If the input is a stereo audio stream, you can mute the front left channel (and
  1778. still keep the stereo channel layout) with:
  1779. @example
  1780. pan="stereo|c1=c1"
  1781. @end example
  1782. Still with a stereo audio stream input, you can copy the right channel in both
  1783. front left and right:
  1784. @example
  1785. pan="stereo| c0=FR | c1=FR"
  1786. @end example
  1787. @section replaygain
  1788. ReplayGain scanner filter. This filter takes an audio stream as an input and
  1789. outputs it unchanged.
  1790. At end of filtering it displays @code{track_gain} and @code{track_peak}.
  1791. @section resample
  1792. Convert the audio sample format, sample rate and channel layout. It is
  1793. not meant to be used directly.
  1794. @section rubberband
  1795. Apply time-stretching and pitch-shifting with librubberband.
  1796. The filter accepts the following options:
  1797. @table @option
  1798. @item tempo
  1799. Set tempo scale factor.
  1800. @item pitch
  1801. Set pitch scale factor.
  1802. @item transients
  1803. Set transients detector.
  1804. Possible values are:
  1805. @table @var
  1806. @item crisp
  1807. @item mixed
  1808. @item smooth
  1809. @end table
  1810. @item detector
  1811. Set detector.
  1812. Possible values are:
  1813. @table @var
  1814. @item compound
  1815. @item percussive
  1816. @item soft
  1817. @end table
  1818. @item phase
  1819. Set phase.
  1820. Possible values are:
  1821. @table @var
  1822. @item laminar
  1823. @item independent
  1824. @end table
  1825. @item window
  1826. Set processing window size.
  1827. Possible values are:
  1828. @table @var
  1829. @item standard
  1830. @item short
  1831. @item long
  1832. @end table
  1833. @item smoothing
  1834. Set smoothing.
  1835. Possible values are:
  1836. @table @var
  1837. @item off
  1838. @item on
  1839. @end table
  1840. @item formant
  1841. Enable formant preservation when shift pitching.
  1842. Possible values are:
  1843. @table @var
  1844. @item shifted
  1845. @item preserved
  1846. @end table
  1847. @item pitchq
  1848. Set pitch quality.
  1849. Possible values are:
  1850. @table @var
  1851. @item quality
  1852. @item speed
  1853. @item consistency
  1854. @end table
  1855. @item channels
  1856. Set channels.
  1857. Possible values are:
  1858. @table @var
  1859. @item apart
  1860. @item together
  1861. @end table
  1862. @end table
  1863. @section sidechaincompress
  1864. This filter acts like normal compressor but has the ability to compress
  1865. detected signal using second input signal.
  1866. It needs two input streams and returns one output stream.
  1867. First input stream will be processed depending on second stream signal.
  1868. The filtered signal then can be filtered with other filters in later stages of
  1869. processing. See @ref{pan} and @ref{amerge} filter.
  1870. The filter accepts the following options:
  1871. @table @option
  1872. @item threshold
  1873. If a signal of second stream raises above this level it will affect the gain
  1874. reduction of first stream.
  1875. By default is 0.125. Range is between 0.00097563 and 1.
  1876. @item ratio
  1877. Set a ratio about which the signal is reduced. 1:2 means that if the level
  1878. raised 4dB above the threshold, it will be only 2dB above after the reduction.
  1879. Default is 2. Range is between 1 and 20.
  1880. @item attack
  1881. Amount of milliseconds the signal has to rise above the threshold before gain
  1882. reduction starts. Default is 20. Range is between 0.01 and 2000.
  1883. @item release
  1884. Amount of milliseconds the signal has to fall below the threshold before
  1885. reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
  1886. @item makeup
  1887. Set the amount by how much signal will be amplified after processing.
  1888. Default is 2. Range is from 1 and 64.
  1889. @item knee
  1890. Curve the sharp knee around the threshold to enter gain reduction more softly.
  1891. Default is 2.82843. Range is between 1 and 8.
  1892. @item link
  1893. Choose if the @code{average} level between all channels of side-chain stream
  1894. or the louder(@code{maximum}) channel of side-chain stream affects the
  1895. reduction. Default is @code{average}.
  1896. @item detection
  1897. Should the exact signal be taken in case of @code{peak} or an RMS one in case
  1898. of @code{rms}. Default is @code{rms} which is mainly smoother.
  1899. @end table
  1900. @subsection Examples
  1901. @itemize
  1902. @item
  1903. Full ffmpeg example taking 2 audio inputs, 1st input to be compressed
  1904. depending on the signal of 2nd input and later compressed signal to be
  1905. merged with 2nd input:
  1906. @example
  1907. ffmpeg -i main.flac -i sidechain.flac -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge"
  1908. @end example
  1909. @end itemize
  1910. @section silencedetect
  1911. Detect silence in an audio stream.
  1912. This filter logs a message when it detects that the input audio volume is less
  1913. or equal to a noise tolerance value for a duration greater or equal to the
  1914. minimum detected noise duration.
  1915. The printed times and duration are expressed in seconds.
  1916. The filter accepts the following options:
  1917. @table @option
  1918. @item duration, d
  1919. Set silence duration until notification (default is 2 seconds).
  1920. @item noise, n
  1921. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  1922. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  1923. @end table
  1924. @subsection Examples
  1925. @itemize
  1926. @item
  1927. Detect 5 seconds of silence with -50dB noise tolerance:
  1928. @example
  1929. silencedetect=n=-50dB:d=5
  1930. @end example
  1931. @item
  1932. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  1933. tolerance in @file{silence.mp3}:
  1934. @example
  1935. ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
  1936. @end example
  1937. @end itemize
  1938. @section silenceremove
  1939. Remove silence from the beginning, middle or end of the audio.
  1940. The filter accepts the following options:
  1941. @table @option
  1942. @item start_periods
  1943. This value is used to indicate if audio should be trimmed at beginning of
  1944. the audio. A value of zero indicates no silence should be trimmed from the
  1945. beginning. When specifying a non-zero value, it trims audio up until it
  1946. finds non-silence. Normally, when trimming silence from beginning of audio
  1947. the @var{start_periods} will be @code{1} but it can be increased to higher
  1948. values to trim all audio up to specific count of non-silence periods.
  1949. Default value is @code{0}.
  1950. @item start_duration
  1951. Specify the amount of time that non-silence must be detected before it stops
  1952. trimming audio. By increasing the duration, bursts of noises can be treated
  1953. as silence and trimmed off. Default value is @code{0}.
  1954. @item start_threshold
  1955. This indicates what sample value should be treated as silence. For digital
  1956. audio, a value of @code{0} may be fine but for audio recorded from analog,
  1957. you may wish to increase the value to account for background noise.
  1958. Can be specified in dB (in case "dB" is appended to the specified value)
  1959. or amplitude ratio. Default value is @code{0}.
  1960. @item stop_periods
  1961. Set the count for trimming silence from the end of audio.
  1962. To remove silence from the middle of a file, specify a @var{stop_periods}
  1963. that is negative. This value is then treated as a positive value and is
  1964. used to indicate the effect should restart processing as specified by
  1965. @var{start_periods}, making it suitable for removing periods of silence
  1966. in the middle of the audio.
  1967. Default value is @code{0}.
  1968. @item stop_duration
  1969. Specify a duration of silence that must exist before audio is not copied any
  1970. more. By specifying a higher duration, silence that is wanted can be left in
  1971. the audio.
  1972. Default value is @code{0}.
  1973. @item stop_threshold
  1974. This is the same as @option{start_threshold} but for trimming silence from
  1975. the end of audio.
  1976. Can be specified in dB (in case "dB" is appended to the specified value)
  1977. or amplitude ratio. Default value is @code{0}.
  1978. @item leave_silence
  1979. This indicate that @var{stop_duration} length of audio should be left intact
  1980. at the beginning of each period of silence.
  1981. For example, if you want to remove long pauses between words but do not want
  1982. to remove the pauses completely. Default value is @code{0}.
  1983. @end table
  1984. @subsection Examples
  1985. @itemize
  1986. @item
  1987. The following example shows how this filter can be used to start a recording
  1988. that does not contain the delay at the start which usually occurs between
  1989. pressing the record button and the start of the performance:
  1990. @example
  1991. silenceremove=1:5:0.02
  1992. @end example
  1993. @end itemize
  1994. @section stereotools
  1995. This filter has some handy utilities to manage stereo signals, for converting
  1996. M/S stereo recordings to L/R signal while having control over the parameters
  1997. or spreading the stereo image of master track.
  1998. The filter accepts the following options:
  1999. @table @option
  2000. @item level_in
  2001. Set input level before filtering for both channels. Defaults is 1.
  2002. Allowed range is from 0.015625 to 64.
  2003. @item level_out
  2004. Set output level after filtering for both channels. Defaults is 1.
  2005. Allowed range is from 0.015625 to 64.
  2006. @item balance_in
  2007. Set input balance between both channels. Default is 0.
  2008. Allowed range is from -1 to 1.
  2009. @item balance_out
  2010. Set output balance between both channels. Default is 0.
  2011. Allowed range is from -1 to 1.
  2012. @item softclip
  2013. Enable softclipping. Results in analog distortion instead of harsh digital 0dB
  2014. clipping. Disabled by default.
  2015. @item mutel
  2016. Mute the left channel. Disabled by default.
  2017. @item muter
  2018. Mute the right channel. Disabled by default.
  2019. @item phasel
  2020. Change the phase of the left channel. Disabled by default.
  2021. @item phaser
  2022. Change the phase of the right channel. Disabled by default.
  2023. @item mode
  2024. Set stereo mode. Available values are:
  2025. @table @samp
  2026. @item lr>lr
  2027. Left/Right to Left/Right, this is default.
  2028. @item lr>ms
  2029. Left/Right to Mid/Side.
  2030. @item ms>lr
  2031. Mid/Side to Left/Right.
  2032. @item lr>ll
  2033. Left/Right to Left/Left.
  2034. @item lr>rr
  2035. Left/Right to Right/Right.
  2036. @item lr>l+r
  2037. Left/Right to Left + Right.
  2038. @item lr>rl
  2039. Left/Right to Right/Left.
  2040. @end table
  2041. @item slev
  2042. Set level of side signal. Default is 1.
  2043. Allowed range is from 0.015625 to 64.
  2044. @item sbal
  2045. Set balance of side signal. Default is 0.
  2046. Allowed range is from -1 to 1.
  2047. @item mlev
  2048. Set level of the middle signal. Default is 1.
  2049. Allowed range is from 0.015625 to 64.
  2050. @item mpan
  2051. Set middle signal pan. Default is 0. Allowed range is from -1 to 1.
  2052. @item base
  2053. Set stereo base between mono and inversed channels. Default is 0.
  2054. Allowed range is from -1 to 1.
  2055. @item delay
  2056. Set delay in milliseconds how much to delay left from right channel and
  2057. vice versa. Default is 0. Allowed range is from -20 to 20.
  2058. @item sclevel
  2059. Set S/C level. Default is 1. Allowed range is from 1 to 100.
  2060. @item phase
  2061. Set the stereo phase in degrees. Default is 0. Allowed range is from 0 to 360.
  2062. @end table
  2063. @section stereowiden
  2064. This filter enhance the stereo effect by suppressing signal common to both
  2065. channels and by delaying the signal of left into right and vice versa,
  2066. thereby widening the stereo effect.
  2067. The filter accepts the following options:
  2068. @table @option
  2069. @item delay
  2070. Time in milliseconds of the delay of left signal into right and vice versa.
  2071. Default is 20 milliseconds.
  2072. @item feedback
  2073. Amount of gain in delayed signal into right and vice versa. Gives a delay
  2074. effect of left signal in right output and vice versa which gives widening
  2075. effect. Default is 0.3.
  2076. @item crossfeed
  2077. Cross feed of left into right with inverted phase. This helps in suppressing
  2078. the mono. If the value is 1 it will cancel all the signal common to both
  2079. channels. Default is 0.3.
  2080. @item drymix
  2081. Set level of input signal of original channel. Default is 0.8.
  2082. @end table
  2083. @section treble
  2084. Boost or cut treble (upper) frequencies of the audio using a two-pole
  2085. shelving filter with a response similar to that of a standard
  2086. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  2087. The filter accepts the following options:
  2088. @table @option
  2089. @item gain, g
  2090. Give the gain at whichever is the lower of ~22 kHz and the
  2091. Nyquist frequency. Its useful range is about -20 (for a large cut)
  2092. to +20 (for a large boost). Beware of clipping when using a positive gain.
  2093. @item frequency, f
  2094. Set the filter's central frequency and so can be used
  2095. to extend or reduce the frequency range to be boosted or cut.
  2096. The default value is @code{3000} Hz.
  2097. @item width_type
  2098. Set method to specify band-width of filter.
  2099. @table @option
  2100. @item h
  2101. Hz
  2102. @item q
  2103. Q-Factor
  2104. @item o
  2105. octave
  2106. @item s
  2107. slope
  2108. @end table
  2109. @item width, w
  2110. Determine how steep is the filter's shelf transition.
  2111. @end table
  2112. @section tremolo
  2113. Sinusoidal amplitude modulation.
  2114. The filter accepts the following options:
  2115. @table @option
  2116. @item f
  2117. Modulation frequency in Hertz. Modulation frequencies in the subharmonic range
  2118. (20 Hz or lower) will result in a tremolo effect.
  2119. This filter may also be used as a ring modulator by specifying
  2120. a modulation frequency higher than 20 Hz.
  2121. Range is 0.1 - 20000.0. Default value is 5.0 Hz.
  2122. @item d
  2123. Depth of modulation as a percentage. Range is 0.0 - 1.0.
  2124. Default value is 0.5.
  2125. @end table
  2126. @section volume
  2127. Adjust the input audio volume.
  2128. It accepts the following parameters:
  2129. @table @option
  2130. @item volume
  2131. Set audio volume expression.
  2132. Output values are clipped to the maximum value.
  2133. The output audio volume is given by the relation:
  2134. @example
  2135. @var{output_volume} = @var{volume} * @var{input_volume}
  2136. @end example
  2137. The default value for @var{volume} is "1.0".
  2138. @item precision
  2139. This parameter represents the mathematical precision.
  2140. It determines which input sample formats will be allowed, which affects the
  2141. precision of the volume scaling.
  2142. @table @option
  2143. @item fixed
  2144. 8-bit fixed-point; this limits input sample format to U8, S16, and S32.
  2145. @item float
  2146. 32-bit floating-point; this limits input sample format to FLT. (default)
  2147. @item double
  2148. 64-bit floating-point; this limits input sample format to DBL.
  2149. @end table
  2150. @item replaygain
  2151. Choose the behaviour on encountering ReplayGain side data in input frames.
  2152. @table @option
  2153. @item drop
  2154. Remove ReplayGain side data, ignoring its contents (the default).
  2155. @item ignore
  2156. Ignore ReplayGain side data, but leave it in the frame.
  2157. @item track
  2158. Prefer the track gain, if present.
  2159. @item album
  2160. Prefer the album gain, if present.
  2161. @end table
  2162. @item replaygain_preamp
  2163. Pre-amplification gain in dB to apply to the selected replaygain gain.
  2164. Default value for @var{replaygain_preamp} is 0.0.
  2165. @item eval
  2166. Set when the volume expression is evaluated.
  2167. It accepts the following values:
  2168. @table @samp
  2169. @item once
  2170. only evaluate expression once during the filter initialization, or
  2171. when the @samp{volume} command is sent
  2172. @item frame
  2173. evaluate expression for each incoming frame
  2174. @end table
  2175. Default value is @samp{once}.
  2176. @end table
  2177. The volume expression can contain the following parameters.
  2178. @table @option
  2179. @item n
  2180. frame number (starting at zero)
  2181. @item nb_channels
  2182. number of channels
  2183. @item nb_consumed_samples
  2184. number of samples consumed by the filter
  2185. @item nb_samples
  2186. number of samples in the current frame
  2187. @item pos
  2188. original frame position in the file
  2189. @item pts
  2190. frame PTS
  2191. @item sample_rate
  2192. sample rate
  2193. @item startpts
  2194. PTS at start of stream
  2195. @item startt
  2196. time at start of stream
  2197. @item t
  2198. frame time
  2199. @item tb
  2200. timestamp timebase
  2201. @item volume
  2202. last set volume value
  2203. @end table
  2204. Note that when @option{eval} is set to @samp{once} only the
  2205. @var{sample_rate} and @var{tb} variables are available, all other
  2206. variables will evaluate to NAN.
  2207. @subsection Commands
  2208. This filter supports the following commands:
  2209. @table @option
  2210. @item volume
  2211. Modify the volume expression.
  2212. The command accepts the same syntax of the corresponding option.
  2213. If the specified expression is not valid, it is kept at its current
  2214. value.
  2215. @item replaygain_noclip
  2216. Prevent clipping by limiting the gain applied.
  2217. Default value for @var{replaygain_noclip} is 1.
  2218. @end table
  2219. @subsection Examples
  2220. @itemize
  2221. @item
  2222. Halve the input audio volume:
  2223. @example
  2224. volume=volume=0.5
  2225. volume=volume=1/2
  2226. volume=volume=-6.0206dB
  2227. @end example
  2228. In all the above example the named key for @option{volume} can be
  2229. omitted, for example like in:
  2230. @example
  2231. volume=0.5
  2232. @end example
  2233. @item
  2234. Increase input audio power by 6 decibels using fixed-point precision:
  2235. @example
  2236. volume=volume=6dB:precision=fixed
  2237. @end example
  2238. @item
  2239. Fade volume after time 10 with an annihilation period of 5 seconds:
  2240. @example
  2241. volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
  2242. @end example
  2243. @end itemize
  2244. @section volumedetect
  2245. Detect the volume of the input video.
  2246. The filter has no parameters. The input is not modified. Statistics about
  2247. the volume will be printed in the log when the input stream end is reached.
  2248. In particular it will show the mean volume (root mean square), maximum
  2249. volume (on a per-sample basis), and the beginning of a histogram of the
  2250. registered volume values (from the maximum value to a cumulated 1/1000 of
  2251. the samples).
  2252. All volumes are in decibels relative to the maximum PCM value.
  2253. @subsection Examples
  2254. Here is an excerpt of the output:
  2255. @example
  2256. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  2257. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  2258. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  2259. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  2260. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  2261. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  2262. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  2263. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  2264. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  2265. @end example
  2266. It means that:
  2267. @itemize
  2268. @item
  2269. The mean square energy is approximately -27 dB, or 10^-2.7.
  2270. @item
  2271. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  2272. @item
  2273. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  2274. @end itemize
  2275. In other words, raising the volume by +4 dB does not cause any clipping,
  2276. raising it by +5 dB causes clipping for 6 samples, etc.
  2277. @c man end AUDIO FILTERS
  2278. @chapter Audio Sources
  2279. @c man begin AUDIO SOURCES
  2280. Below is a description of the currently available audio sources.
  2281. @section abuffer
  2282. Buffer audio frames, and make them available to the filter chain.
  2283. This source is mainly intended for a programmatic use, in particular
  2284. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  2285. It accepts the following parameters:
  2286. @table @option
  2287. @item time_base
  2288. The timebase which will be used for timestamps of submitted frames. It must be
  2289. either a floating-point number or in @var{numerator}/@var{denominator} form.
  2290. @item sample_rate
  2291. The sample rate of the incoming audio buffers.
  2292. @item sample_fmt
  2293. The sample format of the incoming audio buffers.
  2294. Either a sample format name or its corresponding integer representation from
  2295. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  2296. @item channel_layout
  2297. The channel layout of the incoming audio buffers.
  2298. Either a channel layout name from channel_layout_map in
  2299. @file{libavutil/channel_layout.c} or its corresponding integer representation
  2300. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  2301. @item channels
  2302. The number of channels of the incoming audio buffers.
  2303. If both @var{channels} and @var{channel_layout} are specified, then they
  2304. must be consistent.
  2305. @end table
  2306. @subsection Examples
  2307. @example
  2308. abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
  2309. @end example
  2310. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  2311. Since the sample format with name "s16p" corresponds to the number
  2312. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  2313. equivalent to:
  2314. @example
  2315. abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
  2316. @end example
  2317. @section aevalsrc
  2318. Generate an audio signal specified by an expression.
  2319. This source accepts in input one or more expressions (one for each
  2320. channel), which are evaluated and used to generate a corresponding
  2321. audio signal.
  2322. This source accepts the following options:
  2323. @table @option
  2324. @item exprs
  2325. Set the '|'-separated expressions list for each separate channel. In case the
  2326. @option{channel_layout} option is not specified, the selected channel layout
  2327. depends on the number of provided expressions. Otherwise the last
  2328. specified expression is applied to the remaining output channels.
  2329. @item channel_layout, c
  2330. Set the channel layout. The number of channels in the specified layout
  2331. must be equal to the number of specified expressions.
  2332. @item duration, d
  2333. Set the minimum duration of the sourced audio. See
  2334. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  2335. for the accepted syntax.
  2336. Note that the resulting duration may be greater than the specified
  2337. duration, as the generated audio is always cut at the end of a
  2338. complete frame.
  2339. If not specified, or the expressed duration is negative, the audio is
  2340. supposed to be generated forever.
  2341. @item nb_samples, n
  2342. Set the number of samples per channel per each output frame,
  2343. default to 1024.
  2344. @item sample_rate, s
  2345. Specify the sample rate, default to 44100.
  2346. @end table
  2347. Each expression in @var{exprs} can contain the following constants:
  2348. @table @option
  2349. @item n
  2350. number of the evaluated sample, starting from 0
  2351. @item t
  2352. time of the evaluated sample expressed in seconds, starting from 0
  2353. @item s
  2354. sample rate
  2355. @end table
  2356. @subsection Examples
  2357. @itemize
  2358. @item
  2359. Generate silence:
  2360. @example
  2361. aevalsrc=0
  2362. @end example
  2363. @item
  2364. Generate a sin signal with frequency of 440 Hz, set sample rate to
  2365. 8000 Hz:
  2366. @example
  2367. aevalsrc="sin(440*2*PI*t):s=8000"
  2368. @end example
  2369. @item
  2370. Generate a two channels signal, specify the channel layout (Front
  2371. Center + Back Center) explicitly:
  2372. @example
  2373. aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
  2374. @end example
  2375. @item
  2376. Generate white noise:
  2377. @example
  2378. aevalsrc="-2+random(0)"
  2379. @end example
  2380. @item
  2381. Generate an amplitude modulated signal:
  2382. @example
  2383. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  2384. @end example
  2385. @item
  2386. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  2387. @example
  2388. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
  2389. @end example
  2390. @end itemize
  2391. @section anullsrc
  2392. The null audio source, return unprocessed audio frames. It is mainly useful
  2393. as a template and to be employed in analysis / debugging tools, or as
  2394. the source for filters which ignore the input data (for example the sox
  2395. synth filter).
  2396. This source accepts the following options:
  2397. @table @option
  2398. @item channel_layout, cl
  2399. Specifies the channel layout, and can be either an integer or a string
  2400. representing a channel layout. The default value of @var{channel_layout}
  2401. is "stereo".
  2402. Check the channel_layout_map definition in
  2403. @file{libavutil/channel_layout.c} for the mapping between strings and
  2404. channel layout values.
  2405. @item sample_rate, r
  2406. Specifies the sample rate, and defaults to 44100.
  2407. @item nb_samples, n
  2408. Set the number of samples per requested frames.
  2409. @end table
  2410. @subsection Examples
  2411. @itemize
  2412. @item
  2413. Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  2414. @example
  2415. anullsrc=r=48000:cl=4
  2416. @end example
  2417. @item
  2418. Do the same operation with a more obvious syntax:
  2419. @example
  2420. anullsrc=r=48000:cl=mono
  2421. @end example
  2422. @end itemize
  2423. All the parameters need to be explicitly defined.
  2424. @section flite
  2425. Synthesize a voice utterance using the libflite library.
  2426. To enable compilation of this filter you need to configure FFmpeg with
  2427. @code{--enable-libflite}.
  2428. Note that the flite library is not thread-safe.
  2429. The filter accepts the following options:
  2430. @table @option
  2431. @item list_voices
  2432. If set to 1, list the names of the available voices and exit
  2433. immediately. Default value is 0.
  2434. @item nb_samples, n
  2435. Set the maximum number of samples per frame. Default value is 512.
  2436. @item textfile
  2437. Set the filename containing the text to speak.
  2438. @item text
  2439. Set the text to speak.
  2440. @item voice, v
  2441. Set the voice to use for the speech synthesis. Default value is
  2442. @code{kal}. See also the @var{list_voices} option.
  2443. @end table
  2444. @subsection Examples
  2445. @itemize
  2446. @item
  2447. Read from file @file{speech.txt}, and synthesize the text using the
  2448. standard flite voice:
  2449. @example
  2450. flite=textfile=speech.txt
  2451. @end example
  2452. @item
  2453. Read the specified text selecting the @code{slt} voice:
  2454. @example
  2455. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2456. @end example
  2457. @item
  2458. Input text to ffmpeg:
  2459. @example
  2460. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2461. @end example
  2462. @item
  2463. Make @file{ffplay} speak the specified text, using @code{flite} and
  2464. the @code{lavfi} device:
  2465. @example
  2466. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  2467. @end example
  2468. @end itemize
  2469. For more information about libflite, check:
  2470. @url{http://www.speech.cs.cmu.edu/flite/}
  2471. @section sine
  2472. Generate an audio signal made of a sine wave with amplitude 1/8.
  2473. The audio signal is bit-exact.
  2474. The filter accepts the following options:
  2475. @table @option
  2476. @item frequency, f
  2477. Set the carrier frequency. Default is 440 Hz.
  2478. @item beep_factor, b
  2479. Enable a periodic beep every second with frequency @var{beep_factor} times
  2480. the carrier frequency. Default is 0, meaning the beep is disabled.
  2481. @item sample_rate, r
  2482. Specify the sample rate, default is 44100.
  2483. @item duration, d
  2484. Specify the duration of the generated audio stream.
  2485. @item samples_per_frame
  2486. Set the number of samples per output frame.
  2487. The expression can contain the following constants:
  2488. @table @option
  2489. @item n
  2490. The (sequential) number of the output audio frame, starting from 0.
  2491. @item pts
  2492. The PTS (Presentation TimeStamp) of the output audio frame,
  2493. expressed in @var{TB} units.
  2494. @item t
  2495. The PTS of the output audio frame, expressed in seconds.
  2496. @item TB
  2497. The timebase of the output audio frames.
  2498. @end table
  2499. Default is @code{1024}.
  2500. @end table
  2501. @subsection Examples
  2502. @itemize
  2503. @item
  2504. Generate a simple 440 Hz sine wave:
  2505. @example
  2506. sine
  2507. @end example
  2508. @item
  2509. Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
  2510. @example
  2511. sine=220:4:d=5
  2512. sine=f=220:b=4:d=5
  2513. sine=frequency=220:beep_factor=4:duration=5
  2514. @end example
  2515. @item
  2516. Generate a 1 kHz sine wave following @code{1602,1601,1602,1601,1602} NTSC
  2517. pattern:
  2518. @example
  2519. sine=1000:samples_per_frame='st(0,mod(n,5)); 1602-not(not(eq(ld(0),1)+eq(ld(0),3)))'
  2520. @end example
  2521. @end itemize
  2522. @c man end AUDIO SOURCES
  2523. @chapter Audio Sinks
  2524. @c man begin AUDIO SINKS
  2525. Below is a description of the currently available audio sinks.
  2526. @section abuffersink
  2527. Buffer audio frames, and make them available to the end of filter chain.
  2528. This sink is mainly intended for programmatic use, in particular
  2529. through the interface defined in @file{libavfilter/buffersink.h}
  2530. or the options system.
  2531. It accepts a pointer to an AVABufferSinkContext structure, which
  2532. defines the incoming buffers' formats, to be passed as the opaque
  2533. parameter to @code{avfilter_init_filter} for initialization.
  2534. @section anullsink
  2535. Null audio sink; do absolutely nothing with the input audio. It is
  2536. mainly useful as a template and for use in analysis / debugging
  2537. tools.
  2538. @c man end AUDIO SINKS
  2539. @chapter Video Filters
  2540. @c man begin VIDEO FILTERS
  2541. When you configure your FFmpeg build, you can disable any of the
  2542. existing filters using @code{--disable-filters}.
  2543. The configure output will show the video filters included in your
  2544. build.
  2545. Below is a description of the currently available video filters.
  2546. @section alphaextract
  2547. Extract the alpha component from the input as a grayscale video. This
  2548. is especially useful with the @var{alphamerge} filter.
  2549. @section alphamerge
  2550. Add or replace the alpha component of the primary input with the
  2551. grayscale value of a second input. This is intended for use with
  2552. @var{alphaextract} to allow the transmission or storage of frame
  2553. sequences that have alpha in a format that doesn't support an alpha
  2554. channel.
  2555. For example, to reconstruct full frames from a normal YUV-encoded video
  2556. and a separate video created with @var{alphaextract}, you might use:
  2557. @example
  2558. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  2559. @end example
  2560. Since this filter is designed for reconstruction, it operates on frame
  2561. sequences without considering timestamps, and terminates when either
  2562. input reaches end of stream. This will cause problems if your encoding
  2563. pipeline drops frames. If you're trying to apply an image as an
  2564. overlay to a video stream, consider the @var{overlay} filter instead.
  2565. @section ass
  2566. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  2567. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  2568. Substation Alpha) subtitles files.
  2569. This filter accepts the following option in addition to the common options from
  2570. the @ref{subtitles} filter:
  2571. @table @option
  2572. @item shaping
  2573. Set the shaping engine
  2574. Available values are:
  2575. @table @samp
  2576. @item auto
  2577. The default libass shaping engine, which is the best available.
  2578. @item simple
  2579. Fast, font-agnostic shaper that can do only substitutions
  2580. @item complex
  2581. Slower shaper using OpenType for substitutions and positioning
  2582. @end table
  2583. The default is @code{auto}.
  2584. @end table
  2585. @section atadenoise
  2586. Apply an Adaptive Temporal Averaging Denoiser to the video input.
  2587. The filter accepts the following options:
  2588. @table @option
  2589. @item 0a
  2590. Set threshold A for 1st plane. Default is 0.02.
  2591. Valid range is 0 to 0.3.
  2592. @item 0b
  2593. Set threshold B for 1st plane. Default is 0.04.
  2594. Valid range is 0 to 5.
  2595. @item 1a
  2596. Set threshold A for 2nd plane. Default is 0.02.
  2597. Valid range is 0 to 0.3.
  2598. @item 1b
  2599. Set threshold B for 2nd plane. Default is 0.04.
  2600. Valid range is 0 to 5.
  2601. @item 2a
  2602. Set threshold A for 3rd plane. Default is 0.02.
  2603. Valid range is 0 to 0.3.
  2604. @item 2b
  2605. Set threshold B for 3rd plane. Default is 0.04.
  2606. Valid range is 0 to 5.
  2607. Threshold A is designed to react on abrupt changes in the input signal and
  2608. threshold B is designed to react on continuous changes in the input signal.
  2609. @item s
  2610. Set number of frames filter will use for averaging. Default is 33. Must be odd
  2611. number in range [5, 129].
  2612. @end table
  2613. @section bbox
  2614. Compute the bounding box for the non-black pixels in the input frame
  2615. luminance plane.
  2616. This filter computes the bounding box containing all the pixels with a
  2617. luminance value greater than the minimum allowed value.
  2618. The parameters describing the bounding box are printed on the filter
  2619. log.
  2620. The filter accepts the following option:
  2621. @table @option
  2622. @item min_val
  2623. Set the minimal luminance value. Default is @code{16}.
  2624. @end table
  2625. @section blackdetect
  2626. Detect video intervals that are (almost) completely black. Can be
  2627. useful to detect chapter transitions, commercials, or invalid
  2628. recordings. Output lines contains the time for the start, end and
  2629. duration of the detected black interval expressed in seconds.
  2630. In order to display the output lines, you need to set the loglevel at
  2631. least to the AV_LOG_INFO value.
  2632. The filter accepts the following options:
  2633. @table @option
  2634. @item black_min_duration, d
  2635. Set the minimum detected black duration expressed in seconds. It must
  2636. be a non-negative floating point number.
  2637. Default value is 2.0.
  2638. @item picture_black_ratio_th, pic_th
  2639. Set the threshold for considering a picture "black".
  2640. Express the minimum value for the ratio:
  2641. @example
  2642. @var{nb_black_pixels} / @var{nb_pixels}
  2643. @end example
  2644. for which a picture is considered black.
  2645. Default value is 0.98.
  2646. @item pixel_black_th, pix_th
  2647. Set the threshold for considering a pixel "black".
  2648. The threshold expresses the maximum pixel luminance value for which a
  2649. pixel is considered "black". The provided value is scaled according to
  2650. the following equation:
  2651. @example
  2652. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  2653. @end example
  2654. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  2655. the input video format, the range is [0-255] for YUV full-range
  2656. formats and [16-235] for YUV non full-range formats.
  2657. Default value is 0.10.
  2658. @end table
  2659. The following example sets the maximum pixel threshold to the minimum
  2660. value, and detects only black intervals of 2 or more seconds:
  2661. @example
  2662. blackdetect=d=2:pix_th=0.00
  2663. @end example
  2664. @section blackframe
  2665. Detect frames that are (almost) completely black. Can be useful to
  2666. detect chapter transitions or commercials. Output lines consist of
  2667. the frame number of the detected frame, the percentage of blackness,
  2668. the position in the file if known or -1 and the timestamp in seconds.
  2669. In order to display the output lines, you need to set the loglevel at
  2670. least to the AV_LOG_INFO value.
  2671. It accepts the following parameters:
  2672. @table @option
  2673. @item amount
  2674. The percentage of the pixels that have to be below the threshold; it defaults to
  2675. @code{98}.
  2676. @item threshold, thresh
  2677. The threshold below which a pixel value is considered black; it defaults to
  2678. @code{32}.
  2679. @end table
  2680. @section blend, tblend
  2681. Blend two video frames into each other.
  2682. The @code{blend} filter takes two input streams and outputs one
  2683. stream, the first input is the "top" layer and second input is
  2684. "bottom" layer. Output terminates when shortest input terminates.
  2685. The @code{tblend} (time blend) filter takes two consecutive frames
  2686. from one single stream, and outputs the result obtained by blending
  2687. the new frame on top of the old frame.
  2688. A description of the accepted options follows.
  2689. @table @option
  2690. @item c0_mode
  2691. @item c1_mode
  2692. @item c2_mode
  2693. @item c3_mode
  2694. @item all_mode
  2695. Set blend mode for specific pixel component or all pixel components in case
  2696. of @var{all_mode}. Default value is @code{normal}.
  2697. Available values for component modes are:
  2698. @table @samp
  2699. @item addition
  2700. @item addition128
  2701. @item and
  2702. @item average
  2703. @item burn
  2704. @item darken
  2705. @item difference
  2706. @item difference128
  2707. @item divide
  2708. @item dodge
  2709. @item exclusion
  2710. @item glow
  2711. @item hardlight
  2712. @item hardmix
  2713. @item lighten
  2714. @item linearlight
  2715. @item multiply
  2716. @item negation
  2717. @item normal
  2718. @item or
  2719. @item overlay
  2720. @item phoenix
  2721. @item pinlight
  2722. @item reflect
  2723. @item screen
  2724. @item softlight
  2725. @item subtract
  2726. @item vividlight
  2727. @item xor
  2728. @end table
  2729. @item c0_opacity
  2730. @item c1_opacity
  2731. @item c2_opacity
  2732. @item c3_opacity
  2733. @item all_opacity
  2734. Set blend opacity for specific pixel component or all pixel components in case
  2735. of @var{all_opacity}. Only used in combination with pixel component blend modes.
  2736. @item c0_expr
  2737. @item c1_expr
  2738. @item c2_expr
  2739. @item c3_expr
  2740. @item all_expr
  2741. Set blend expression for specific pixel component or all pixel components in case
  2742. of @var{all_expr}. Note that related mode options will be ignored if those are set.
  2743. The expressions can use the following variables:
  2744. @table @option
  2745. @item N
  2746. The sequential number of the filtered frame, starting from @code{0}.
  2747. @item X
  2748. @item Y
  2749. the coordinates of the current sample
  2750. @item W
  2751. @item H
  2752. the width and height of currently filtered plane
  2753. @item SW
  2754. @item SH
  2755. Width and height scale depending on the currently filtered plane. It is the
  2756. ratio between the corresponding luma plane number of pixels and the current
  2757. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  2758. @code{0.5,0.5} for chroma planes.
  2759. @item T
  2760. Time of the current frame, expressed in seconds.
  2761. @item TOP, A
  2762. Value of pixel component at current location for first video frame (top layer).
  2763. @item BOTTOM, B
  2764. Value of pixel component at current location for second video frame (bottom layer).
  2765. @end table
  2766. @item shortest
  2767. Force termination when the shortest input terminates. Default is
  2768. @code{0}. This option is only defined for the @code{blend} filter.
  2769. @item repeatlast
  2770. Continue applying the last bottom frame after the end of the stream. A value of
  2771. @code{0} disable the filter after the last frame of the bottom layer is reached.
  2772. Default is @code{1}. This option is only defined for the @code{blend} filter.
  2773. @end table
  2774. @subsection Examples
  2775. @itemize
  2776. @item
  2777. Apply transition from bottom layer to top layer in first 10 seconds:
  2778. @example
  2779. blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
  2780. @end example
  2781. @item
  2782. Apply 1x1 checkerboard effect:
  2783. @example
  2784. blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
  2785. @end example
  2786. @item
  2787. Apply uncover left effect:
  2788. @example
  2789. blend=all_expr='if(gte(N*SW+X,W),A,B)'
  2790. @end example
  2791. @item
  2792. Apply uncover down effect:
  2793. @example
  2794. blend=all_expr='if(gte(Y-N*SH,0),A,B)'
  2795. @end example
  2796. @item
  2797. Apply uncover up-left effect:
  2798. @example
  2799. blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
  2800. @end example
  2801. @item
  2802. Display differences between the current and the previous frame:
  2803. @example
  2804. tblend=all_mode=difference128
  2805. @end example
  2806. @end itemize
  2807. @section boxblur
  2808. Apply a boxblur algorithm to the input video.
  2809. It accepts the following parameters:
  2810. @table @option
  2811. @item luma_radius, lr
  2812. @item luma_power, lp
  2813. @item chroma_radius, cr
  2814. @item chroma_power, cp
  2815. @item alpha_radius, ar
  2816. @item alpha_power, ap
  2817. @end table
  2818. A description of the accepted options follows.
  2819. @table @option
  2820. @item luma_radius, lr
  2821. @item chroma_radius, cr
  2822. @item alpha_radius, ar
  2823. Set an expression for the box radius in pixels used for blurring the
  2824. corresponding input plane.
  2825. The radius value must be a non-negative number, and must not be
  2826. greater than the value of the expression @code{min(w,h)/2} for the
  2827. luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
  2828. planes.
  2829. Default value for @option{luma_radius} is "2". If not specified,
  2830. @option{chroma_radius} and @option{alpha_radius} default to the
  2831. corresponding value set for @option{luma_radius}.
  2832. The expressions can contain the following constants:
  2833. @table @option
  2834. @item w
  2835. @item h
  2836. The input width and height in pixels.
  2837. @item cw
  2838. @item ch
  2839. The input chroma image width and height in pixels.
  2840. @item hsub
  2841. @item vsub
  2842. The horizontal and vertical chroma subsample values. For example, for the
  2843. pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
  2844. @end table
  2845. @item luma_power, lp
  2846. @item chroma_power, cp
  2847. @item alpha_power, ap
  2848. Specify how many times the boxblur filter is applied to the
  2849. corresponding plane.
  2850. Default value for @option{luma_power} is 2. If not specified,
  2851. @option{chroma_power} and @option{alpha_power} default to the
  2852. corresponding value set for @option{luma_power}.
  2853. A value of 0 will disable the effect.
  2854. @end table
  2855. @subsection Examples
  2856. @itemize
  2857. @item
  2858. Apply a boxblur filter with the luma, chroma, and alpha radii
  2859. set to 2:
  2860. @example
  2861. boxblur=luma_radius=2:luma_power=1
  2862. boxblur=2:1
  2863. @end example
  2864. @item
  2865. Set the luma radius to 2, and alpha and chroma radius to 0:
  2866. @example
  2867. boxblur=2:1:cr=0:ar=0
  2868. @end example
  2869. @item
  2870. Set the luma and chroma radii to a fraction of the video dimension:
  2871. @example
  2872. boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
  2873. @end example
  2874. @end itemize
  2875. @section chromakey
  2876. YUV colorspace color/chroma keying.
  2877. The filter accepts the following options:
  2878. @table @option
  2879. @item color
  2880. The color which will be replaced with transparency.
  2881. @item similarity
  2882. Similarity percentage with the key color.
  2883. 0.01 matches only the exact key color, while 1.0 matches everything.
  2884. @item blend
  2885. Blend percentage.
  2886. 0.0 makes pixels either fully transparent, or not transparent at all.
  2887. Higher values result in semi-transparent pixels, with a higher transparency
  2888. the more similar the pixels color is to the key color.
  2889. @item yuv
  2890. Signals that the color passed is already in YUV instead of RGB.
  2891. Litteral colors like "green" or "red" don't make sense with this enabled anymore.
  2892. This can be used to pass exact YUV values as hexadecimal numbers.
  2893. @end table
  2894. @subsection Examples
  2895. @itemize
  2896. @item
  2897. Make every green pixel in the input image transparent:
  2898. @example
  2899. ffmpeg -i input.png -vf chromakey=green out.png
  2900. @end example
  2901. @item
  2902. Overlay a greenscreen-video on top of a static black background.
  2903. @example
  2904. 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
  2905. @end example
  2906. @end itemize
  2907. @section codecview
  2908. Visualize information exported by some codecs.
  2909. Some codecs can export information through frames using side-data or other
  2910. means. For example, some MPEG based codecs export motion vectors through the
  2911. @var{export_mvs} flag in the codec @option{flags2} option.
  2912. The filter accepts the following option:
  2913. @table @option
  2914. @item mv
  2915. Set motion vectors to visualize.
  2916. Available flags for @var{mv} are:
  2917. @table @samp
  2918. @item pf
  2919. forward predicted MVs of P-frames
  2920. @item bf
  2921. forward predicted MVs of B-frames
  2922. @item bb
  2923. backward predicted MVs of B-frames
  2924. @end table
  2925. @end table
  2926. @subsection Examples
  2927. @itemize
  2928. @item
  2929. Visualizes multi-directionals MVs from P and B-Frames using @command{ffplay}:
  2930. @example
  2931. ffplay -flags2 +export_mvs input.mpg -vf codecview=mv=pf+bf+bb
  2932. @end example
  2933. @end itemize
  2934. @section colorbalance
  2935. Modify intensity of primary colors (red, green and blue) of input frames.
  2936. The filter allows an input frame to be adjusted in the shadows, midtones or highlights
  2937. regions for the red-cyan, green-magenta or blue-yellow balance.
  2938. A positive adjustment value shifts the balance towards the primary color, a negative
  2939. value towards the complementary color.
  2940. The filter accepts the following options:
  2941. @table @option
  2942. @item rs
  2943. @item gs
  2944. @item bs
  2945. Adjust red, green and blue shadows (darkest pixels).
  2946. @item rm
  2947. @item gm
  2948. @item bm
  2949. Adjust red, green and blue midtones (medium pixels).
  2950. @item rh
  2951. @item gh
  2952. @item bh
  2953. Adjust red, green and blue highlights (brightest pixels).
  2954. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  2955. @end table
  2956. @subsection Examples
  2957. @itemize
  2958. @item
  2959. Add red color cast to shadows:
  2960. @example
  2961. colorbalance=rs=.3
  2962. @end example
  2963. @end itemize
  2964. @section colorkey
  2965. RGB colorspace color keying.
  2966. The filter accepts the following options:
  2967. @table @option
  2968. @item color
  2969. The color which will be replaced with transparency.
  2970. @item similarity
  2971. Similarity percentage with the key color.
  2972. 0.01 matches only the exact key color, while 1.0 matches everything.
  2973. @item blend
  2974. Blend percentage.
  2975. 0.0 makes pixels either fully transparent, or not transparent at all.
  2976. Higher values result in semi-transparent pixels, with a higher transparency
  2977. the more similar the pixels color is to the key color.
  2978. @end table
  2979. @subsection Examples
  2980. @itemize
  2981. @item
  2982. Make every green pixel in the input image transparent:
  2983. @example
  2984. ffmpeg -i input.png -vf colorkey=green out.png
  2985. @end example
  2986. @item
  2987. Overlay a greenscreen-video on top of a static background image.
  2988. @example
  2989. 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
  2990. @end example
  2991. @end itemize
  2992. @section colorlevels
  2993. Adjust video input frames using levels.
  2994. The filter accepts the following options:
  2995. @table @option
  2996. @item rimin
  2997. @item gimin
  2998. @item bimin
  2999. @item aimin
  3000. Adjust red, green, blue and alpha input black point.
  3001. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  3002. @item rimax
  3003. @item gimax
  3004. @item bimax
  3005. @item aimax
  3006. Adjust red, green, blue and alpha input white point.
  3007. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
  3008. Input levels are used to lighten highlights (bright tones), darken shadows
  3009. (dark tones), change the balance of bright and dark tones.
  3010. @item romin
  3011. @item gomin
  3012. @item bomin
  3013. @item aomin
  3014. Adjust red, green, blue and alpha output black point.
  3015. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
  3016. @item romax
  3017. @item gomax
  3018. @item bomax
  3019. @item aomax
  3020. Adjust red, green, blue and alpha output white point.
  3021. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
  3022. Output levels allows manual selection of a constrained output level range.
  3023. @end table
  3024. @subsection Examples
  3025. @itemize
  3026. @item
  3027. Make video output darker:
  3028. @example
  3029. colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
  3030. @end example
  3031. @item
  3032. Increase contrast:
  3033. @example
  3034. colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
  3035. @end example
  3036. @item
  3037. Make video output lighter:
  3038. @example
  3039. colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
  3040. @end example
  3041. @item
  3042. Increase brightness:
  3043. @example
  3044. colorlevels=romin=0.5:gomin=0.5:bomin=0.5
  3045. @end example
  3046. @end itemize
  3047. @section colorchannelmixer
  3048. Adjust video input frames by re-mixing color channels.
  3049. This filter modifies a color channel by adding the values associated to
  3050. the other channels of the same pixels. For example if the value to
  3051. modify is red, the output value will be:
  3052. @example
  3053. @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
  3054. @end example
  3055. The filter accepts the following options:
  3056. @table @option
  3057. @item rr
  3058. @item rg
  3059. @item rb
  3060. @item ra
  3061. Adjust contribution of input red, green, blue and alpha channels for output red channel.
  3062. Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
  3063. @item gr
  3064. @item gg
  3065. @item gb
  3066. @item ga
  3067. Adjust contribution of input red, green, blue and alpha channels for output green channel.
  3068. Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
  3069. @item br
  3070. @item bg
  3071. @item bb
  3072. @item ba
  3073. Adjust contribution of input red, green, blue and alpha channels for output blue channel.
  3074. Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
  3075. @item ar
  3076. @item ag
  3077. @item ab
  3078. @item aa
  3079. Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
  3080. Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
  3081. Allowed ranges for options are @code{[-2.0, 2.0]}.
  3082. @end table
  3083. @subsection Examples
  3084. @itemize
  3085. @item
  3086. Convert source to grayscale:
  3087. @example
  3088. colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
  3089. @end example
  3090. @item
  3091. Simulate sepia tones:
  3092. @example
  3093. colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
  3094. @end example
  3095. @end itemize
  3096. @section colormatrix
  3097. Convert color matrix.
  3098. The filter accepts the following options:
  3099. @table @option
  3100. @item src
  3101. @item dst
  3102. Specify the source and destination color matrix. Both values must be
  3103. specified.
  3104. The accepted values are:
  3105. @table @samp
  3106. @item bt709
  3107. BT.709
  3108. @item bt601
  3109. BT.601
  3110. @item smpte240m
  3111. SMPTE-240M
  3112. @item fcc
  3113. FCC
  3114. @end table
  3115. @end table
  3116. For example to convert from BT.601 to SMPTE-240M, use the command:
  3117. @example
  3118. colormatrix=bt601:smpte240m
  3119. @end example
  3120. @section copy
  3121. Copy the input source unchanged to the output. This is mainly useful for
  3122. testing purposes.
  3123. @section crop
  3124. Crop the input video to given dimensions.
  3125. It accepts the following parameters:
  3126. @table @option
  3127. @item w, out_w
  3128. The width of the output video. It defaults to @code{iw}.
  3129. This expression is evaluated only once during the filter
  3130. configuration, or when the @samp{w} or @samp{out_w} command is sent.
  3131. @item h, out_h
  3132. The height of the output video. It defaults to @code{ih}.
  3133. This expression is evaluated only once during the filter
  3134. configuration, or when the @samp{h} or @samp{out_h} command is sent.
  3135. @item x
  3136. The horizontal position, in the input video, of the left edge of the output
  3137. video. It defaults to @code{(in_w-out_w)/2}.
  3138. This expression is evaluated per-frame.
  3139. @item y
  3140. The vertical position, in the input video, of the top edge of the output video.
  3141. It defaults to @code{(in_h-out_h)/2}.
  3142. This expression is evaluated per-frame.
  3143. @item keep_aspect
  3144. If set to 1 will force the output display aspect ratio
  3145. to be the same of the input, by changing the output sample aspect
  3146. ratio. It defaults to 0.
  3147. @end table
  3148. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  3149. expressions containing the following constants:
  3150. @table @option
  3151. @item x
  3152. @item y
  3153. The computed values for @var{x} and @var{y}. They are evaluated for
  3154. each new frame.
  3155. @item in_w
  3156. @item in_h
  3157. The input width and height.
  3158. @item iw
  3159. @item ih
  3160. These are the same as @var{in_w} and @var{in_h}.
  3161. @item out_w
  3162. @item out_h
  3163. The output (cropped) width and height.
  3164. @item ow
  3165. @item oh
  3166. These are the same as @var{out_w} and @var{out_h}.
  3167. @item a
  3168. same as @var{iw} / @var{ih}
  3169. @item sar
  3170. input sample aspect ratio
  3171. @item dar
  3172. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  3173. @item hsub
  3174. @item vsub
  3175. horizontal and vertical chroma subsample values. For example for the
  3176. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3177. @item n
  3178. The number of the input frame, starting from 0.
  3179. @item pos
  3180. the position in the file of the input frame, NAN if unknown
  3181. @item t
  3182. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  3183. @end table
  3184. The expression for @var{out_w} may depend on the value of @var{out_h},
  3185. and the expression for @var{out_h} may depend on @var{out_w}, but they
  3186. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  3187. evaluated after @var{out_w} and @var{out_h}.
  3188. The @var{x} and @var{y} parameters specify the expressions for the
  3189. position of the top-left corner of the output (non-cropped) area. They
  3190. are evaluated for each frame. If the evaluated value is not valid, it
  3191. is approximated to the nearest valid value.
  3192. The expression for @var{x} may depend on @var{y}, and the expression
  3193. for @var{y} may depend on @var{x}.
  3194. @subsection Examples
  3195. @itemize
  3196. @item
  3197. Crop area with size 100x100 at position (12,34).
  3198. @example
  3199. crop=100:100:12:34
  3200. @end example
  3201. Using named options, the example above becomes:
  3202. @example
  3203. crop=w=100:h=100:x=12:y=34
  3204. @end example
  3205. @item
  3206. Crop the central input area with size 100x100:
  3207. @example
  3208. crop=100:100
  3209. @end example
  3210. @item
  3211. Crop the central input area with size 2/3 of the input video:
  3212. @example
  3213. crop=2/3*in_w:2/3*in_h
  3214. @end example
  3215. @item
  3216. Crop the input video central square:
  3217. @example
  3218. crop=out_w=in_h
  3219. crop=in_h
  3220. @end example
  3221. @item
  3222. Delimit the rectangle with the top-left corner placed at position
  3223. 100:100 and the right-bottom corner corresponding to the right-bottom
  3224. corner of the input image.
  3225. @example
  3226. crop=in_w-100:in_h-100:100:100
  3227. @end example
  3228. @item
  3229. Crop 10 pixels from the left and right borders, and 20 pixels from
  3230. the top and bottom borders
  3231. @example
  3232. crop=in_w-2*10:in_h-2*20
  3233. @end example
  3234. @item
  3235. Keep only the bottom right quarter of the input image:
  3236. @example
  3237. crop=in_w/2:in_h/2:in_w/2:in_h/2
  3238. @end example
  3239. @item
  3240. Crop height for getting Greek harmony:
  3241. @example
  3242. crop=in_w:1/PHI*in_w
  3243. @end example
  3244. @item
  3245. Apply trembling effect:
  3246. @example
  3247. 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)
  3248. @end example
  3249. @item
  3250. Apply erratic camera effect depending on timestamp:
  3251. @example
  3252. 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)"
  3253. @end example
  3254. @item
  3255. Set x depending on the value of y:
  3256. @example
  3257. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  3258. @end example
  3259. @end itemize
  3260. @subsection Commands
  3261. This filter supports the following commands:
  3262. @table @option
  3263. @item w, out_w
  3264. @item h, out_h
  3265. @item x
  3266. @item y
  3267. Set width/height of the output video and the horizontal/vertical position
  3268. in the input video.
  3269. The command accepts the same syntax of the corresponding option.
  3270. If the specified expression is not valid, it is kept at its current
  3271. value.
  3272. @end table
  3273. @section cropdetect
  3274. Auto-detect the crop size.
  3275. It calculates the necessary cropping parameters and prints the
  3276. recommended parameters via the logging system. The detected dimensions
  3277. correspond to the non-black area of the input video.
  3278. It accepts the following parameters:
  3279. @table @option
  3280. @item limit
  3281. Set higher black value threshold, which can be optionally specified
  3282. from nothing (0) to everything (255 for 8bit based formats). An intensity
  3283. value greater to the set value is considered non-black. It defaults to 24.
  3284. You can also specify a value between 0.0 and 1.0 which will be scaled depending
  3285. on the bitdepth of the pixel format.
  3286. @item round
  3287. The value which the width/height should be divisible by. It defaults to
  3288. 16. The offset is automatically adjusted to center the video. Use 2 to
  3289. get only even dimensions (needed for 4:2:2 video). 16 is best when
  3290. encoding to most video codecs.
  3291. @item reset_count, reset
  3292. Set the counter that determines after how many frames cropdetect will
  3293. reset the previously detected largest video area and start over to
  3294. detect the current optimal crop area. Default value is 0.
  3295. This can be useful when channel logos distort the video area. 0
  3296. indicates 'never reset', and returns the largest area encountered during
  3297. playback.
  3298. @end table
  3299. @anchor{curves}
  3300. @section curves
  3301. Apply color adjustments using curves.
  3302. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  3303. component (red, green and blue) has its values defined by @var{N} key points
  3304. tied from each other using a smooth curve. The x-axis represents the pixel
  3305. values from the input frame, and the y-axis the new pixel values to be set for
  3306. the output frame.
  3307. By default, a component curve is defined by the two points @var{(0;0)} and
  3308. @var{(1;1)}. This creates a straight line where each original pixel value is
  3309. "adjusted" to its own value, which means no change to the image.
  3310. The filter allows you to redefine these two points and add some more. A new
  3311. curve (using a natural cubic spline interpolation) will be define to pass
  3312. smoothly through all these new coordinates. The new defined points needs to be
  3313. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  3314. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  3315. the vector spaces, the values will be clipped accordingly.
  3316. If there is no key point defined in @code{x=0}, the filter will automatically
  3317. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  3318. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  3319. The filter accepts the following options:
  3320. @table @option
  3321. @item preset
  3322. Select one of the available color presets. This option can be used in addition
  3323. to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
  3324. options takes priority on the preset values.
  3325. Available presets are:
  3326. @table @samp
  3327. @item none
  3328. @item color_negative
  3329. @item cross_process
  3330. @item darker
  3331. @item increase_contrast
  3332. @item lighter
  3333. @item linear_contrast
  3334. @item medium_contrast
  3335. @item negative
  3336. @item strong_contrast
  3337. @item vintage
  3338. @end table
  3339. Default is @code{none}.
  3340. @item master, m
  3341. Set the master key points. These points will define a second pass mapping. It
  3342. is sometimes called a "luminance" or "value" mapping. It can be used with
  3343. @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
  3344. post-processing LUT.
  3345. @item red, r
  3346. Set the key points for the red component.
  3347. @item green, g
  3348. Set the key points for the green component.
  3349. @item blue, b
  3350. Set the key points for the blue component.
  3351. @item all
  3352. Set the key points for all components (not including master).
  3353. Can be used in addition to the other key points component
  3354. options. In this case, the unset component(s) will fallback on this
  3355. @option{all} setting.
  3356. @item psfile
  3357. Specify a Photoshop curves file (@code{.acv}) to import the settings from.
  3358. @end table
  3359. To avoid some filtergraph syntax conflicts, each key points list need to be
  3360. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  3361. @subsection Examples
  3362. @itemize
  3363. @item
  3364. Increase slightly the middle level of blue:
  3365. @example
  3366. curves=blue='0.5/0.58'
  3367. @end example
  3368. @item
  3369. Vintage effect:
  3370. @example
  3371. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  3372. @end example
  3373. Here we obtain the following coordinates for each components:
  3374. @table @var
  3375. @item red
  3376. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  3377. @item green
  3378. @code{(0;0) (0.50;0.48) (1;1)}
  3379. @item blue
  3380. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  3381. @end table
  3382. @item
  3383. The previous example can also be achieved with the associated built-in preset:
  3384. @example
  3385. curves=preset=vintage
  3386. @end example
  3387. @item
  3388. Or simply:
  3389. @example
  3390. curves=vintage
  3391. @end example
  3392. @item
  3393. Use a Photoshop preset and redefine the points of the green component:
  3394. @example
  3395. curves=psfile='MyCurvesPresets/purple.acv':green='0.45/0.53'
  3396. @end example
  3397. @end itemize
  3398. @section dctdnoiz
  3399. Denoise frames using 2D DCT (frequency domain filtering).
  3400. This filter is not designed for real time.
  3401. The filter accepts the following options:
  3402. @table @option
  3403. @item sigma, s
  3404. Set the noise sigma constant.
  3405. This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
  3406. coefficient (absolute value) below this threshold with be dropped.
  3407. If you need a more advanced filtering, see @option{expr}.
  3408. Default is @code{0}.
  3409. @item overlap
  3410. Set number overlapping pixels for each block. Since the filter can be slow, you
  3411. may want to reduce this value, at the cost of a less effective filter and the
  3412. risk of various artefacts.
  3413. If the overlapping value doesn't permit processing the whole input width or
  3414. height, a warning will be displayed and according borders won't be denoised.
  3415. Default value is @var{blocksize}-1, which is the best possible setting.
  3416. @item expr, e
  3417. Set the coefficient factor expression.
  3418. For each coefficient of a DCT block, this expression will be evaluated as a
  3419. multiplier value for the coefficient.
  3420. If this is option is set, the @option{sigma} option will be ignored.
  3421. The absolute value of the coefficient can be accessed through the @var{c}
  3422. variable.
  3423. @item n
  3424. Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
  3425. @var{blocksize}, which is the width and height of the processed blocks.
  3426. The default value is @var{3} (8x8) and can be raised to @var{4} for a
  3427. @var{blocksize} of 16x16. Note that changing this setting has huge consequences
  3428. on the speed processing. Also, a larger block size does not necessarily means a
  3429. better de-noising.
  3430. @end table
  3431. @subsection Examples
  3432. Apply a denoise with a @option{sigma} of @code{4.5}:
  3433. @example
  3434. dctdnoiz=4.5
  3435. @end example
  3436. The same operation can be achieved using the expression system:
  3437. @example
  3438. dctdnoiz=e='gte(c, 4.5*3)'
  3439. @end example
  3440. Violent denoise using a block size of @code{16x16}:
  3441. @example
  3442. dctdnoiz=15:n=4
  3443. @end example
  3444. @section deband
  3445. Remove banding artifacts from input video.
  3446. It works by replacing banded pixels with average value of referenced pixels.
  3447. The filter accepts the following options:
  3448. @table @option
  3449. @item 1thr
  3450. @item 2thr
  3451. @item 3thr
  3452. @item 4thr
  3453. Set banding detection threshold for each plane. Default is 0.02.
  3454. Valid range is 0.00003 to 0.5.
  3455. If difference between current pixel and reference pixel is less than threshold,
  3456. it will be considered as banded.
  3457. @item range, r
  3458. Banding detection range in pixels. Default is 16. If positive, random number
  3459. in range 0 to set value will be used. If negative, exact absolute value
  3460. will be used.
  3461. The range defines square of four pixels around current pixel.
  3462. @item direction, d
  3463. Set direction in radians from which four pixel will be compared. If positive,
  3464. random direction from 0 to set direction will be picked. If negative, exact of
  3465. absolute value will be picked. For example direction 0, -PI or -2*PI radians
  3466. will pick only pixels on same row and -PI/2 will pick only pixels on same
  3467. column.
  3468. @item blur
  3469. If enabled, current pixel is compared with average value of all four
  3470. surrounding pixels. The default is enabled. If disabled current pixel is
  3471. compared with all four surrounding pixels. The pixel is considered banded
  3472. if only all four differences with surrounding pixels are less than threshold.
  3473. @end table
  3474. @anchor{decimate}
  3475. @section decimate
  3476. Drop duplicated frames at regular intervals.
  3477. The filter accepts the following options:
  3478. @table @option
  3479. @item cycle
  3480. Set the number of frames from which one will be dropped. Setting this to
  3481. @var{N} means one frame in every batch of @var{N} frames will be dropped.
  3482. Default is @code{5}.
  3483. @item dupthresh
  3484. Set the threshold for duplicate detection. If the difference metric for a frame
  3485. is less than or equal to this value, then it is declared as duplicate. Default
  3486. is @code{1.1}
  3487. @item scthresh
  3488. Set scene change threshold. Default is @code{15}.
  3489. @item blockx
  3490. @item blocky
  3491. Set the size of the x and y-axis blocks used during metric calculations.
  3492. Larger blocks give better noise suppression, but also give worse detection of
  3493. small movements. Must be a power of two. Default is @code{32}.
  3494. @item ppsrc
  3495. Mark main input as a pre-processed input and activate clean source input
  3496. stream. This allows the input to be pre-processed with various filters to help
  3497. the metrics calculation while keeping the frame selection lossless. When set to
  3498. @code{1}, the first stream is for the pre-processed input, and the second
  3499. stream is the clean source from where the kept frames are chosen. Default is
  3500. @code{0}.
  3501. @item chroma
  3502. Set whether or not chroma is considered in the metric calculations. Default is
  3503. @code{1}.
  3504. @end table
  3505. @section deflate
  3506. Apply deflate effect to the video.
  3507. This filter replaces the pixel by the local(3x3) average by taking into account
  3508. only values lower than the pixel.
  3509. It accepts the following options:
  3510. @table @option
  3511. @item threshold0
  3512. @item threshold1
  3513. @item threshold2
  3514. @item threshold3
  3515. Limit the maximum change for each plane, default is 65535.
  3516. If 0, plane will remain unchanged.
  3517. @end table
  3518. @section dejudder
  3519. Remove judder produced by partially interlaced telecined content.
  3520. Judder can be introduced, for instance, by @ref{pullup} filter. If the original
  3521. source was partially telecined content then the output of @code{pullup,dejudder}
  3522. will have a variable frame rate. May change the recorded frame rate of the
  3523. container. Aside from that change, this filter will not affect constant frame
  3524. rate video.
  3525. The option available in this filter is:
  3526. @table @option
  3527. @item cycle
  3528. Specify the length of the window over which the judder repeats.
  3529. Accepts any integer greater than 1. Useful values are:
  3530. @table @samp
  3531. @item 4
  3532. If the original was telecined from 24 to 30 fps (Film to NTSC).
  3533. @item 5
  3534. If the original was telecined from 25 to 30 fps (PAL to NTSC).
  3535. @item 20
  3536. If a mixture of the two.
  3537. @end table
  3538. The default is @samp{4}.
  3539. @end table
  3540. @section delogo
  3541. Suppress a TV station logo by a simple interpolation of the surrounding
  3542. pixels. Just set a rectangle covering the logo and watch it disappear
  3543. (and sometimes something even uglier appear - your mileage may vary).
  3544. It accepts the following parameters:
  3545. @table @option
  3546. @item x
  3547. @item y
  3548. Specify the top left corner coordinates of the logo. They must be
  3549. specified.
  3550. @item w
  3551. @item h
  3552. Specify the width and height of the logo to clear. They must be
  3553. specified.
  3554. @item band, t
  3555. Specify the thickness of the fuzzy edge of the rectangle (added to
  3556. @var{w} and @var{h}). The default value is 1. This option is
  3557. deprecated, setting higher values should no longer be necessary and
  3558. is not recommended.
  3559. @item show
  3560. When set to 1, a green rectangle is drawn on the screen to simplify
  3561. finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
  3562. The default value is 0.
  3563. The rectangle is drawn on the outermost pixels which will be (partly)
  3564. replaced with interpolated values. The values of the next pixels
  3565. immediately outside this rectangle in each direction will be used to
  3566. compute the interpolated pixel values inside the rectangle.
  3567. @end table
  3568. @subsection Examples
  3569. @itemize
  3570. @item
  3571. Set a rectangle covering the area with top left corner coordinates 0,0
  3572. and size 100x77, and a band of size 10:
  3573. @example
  3574. delogo=x=0:y=0:w=100:h=77:band=10
  3575. @end example
  3576. @end itemize
  3577. @section deshake
  3578. Attempt to fix small changes in horizontal and/or vertical shift. This
  3579. filter helps remove camera shake from hand-holding a camera, bumping a
  3580. tripod, moving on a vehicle, etc.
  3581. The filter accepts the following options:
  3582. @table @option
  3583. @item x
  3584. @item y
  3585. @item w
  3586. @item h
  3587. Specify a rectangular area where to limit the search for motion
  3588. vectors.
  3589. If desired the search for motion vectors can be limited to a
  3590. rectangular area of the frame defined by its top left corner, width
  3591. and height. These parameters have the same meaning as the drawbox
  3592. filter which can be used to visualise the position of the bounding
  3593. box.
  3594. This is useful when simultaneous movement of subjects within the frame
  3595. might be confused for camera motion by the motion vector search.
  3596. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  3597. then the full frame is used. This allows later options to be set
  3598. without specifying the bounding box for the motion vector search.
  3599. Default - search the whole frame.
  3600. @item rx
  3601. @item ry
  3602. Specify the maximum extent of movement in x and y directions in the
  3603. range 0-64 pixels. Default 16.
  3604. @item edge
  3605. Specify how to generate pixels to fill blanks at the edge of the
  3606. frame. Available values are:
  3607. @table @samp
  3608. @item blank, 0
  3609. Fill zeroes at blank locations
  3610. @item original, 1
  3611. Original image at blank locations
  3612. @item clamp, 2
  3613. Extruded edge value at blank locations
  3614. @item mirror, 3
  3615. Mirrored edge at blank locations
  3616. @end table
  3617. Default value is @samp{mirror}.
  3618. @item blocksize
  3619. Specify the blocksize to use for motion search. Range 4-128 pixels,
  3620. default 8.
  3621. @item contrast
  3622. Specify the contrast threshold for blocks. Only blocks with more than
  3623. the specified contrast (difference between darkest and lightest
  3624. pixels) will be considered. Range 1-255, default 125.
  3625. @item search
  3626. Specify the search strategy. Available values are:
  3627. @table @samp
  3628. @item exhaustive, 0
  3629. Set exhaustive search
  3630. @item less, 1
  3631. Set less exhaustive search.
  3632. @end table
  3633. Default value is @samp{exhaustive}.
  3634. @item filename
  3635. If set then a detailed log of the motion search is written to the
  3636. specified file.
  3637. @item opencl
  3638. If set to 1, specify using OpenCL capabilities, only available if
  3639. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  3640. @end table
  3641. @section detelecine
  3642. Apply an exact inverse of the telecine operation. It requires a predefined
  3643. pattern specified using the pattern option which must be the same as that passed
  3644. to the telecine filter.
  3645. This filter accepts the following options:
  3646. @table @option
  3647. @item first_field
  3648. @table @samp
  3649. @item top, t
  3650. top field first
  3651. @item bottom, b
  3652. bottom field first
  3653. The default value is @code{top}.
  3654. @end table
  3655. @item pattern
  3656. A string of numbers representing the pulldown pattern you wish to apply.
  3657. The default value is @code{23}.
  3658. @item start_frame
  3659. A number representing position of the first frame with respect to the telecine
  3660. pattern. This is to be used if the stream is cut. The default value is @code{0}.
  3661. @end table
  3662. @section dilation
  3663. Apply dilation effect to the video.
  3664. This filter replaces the pixel by the local(3x3) maximum.
  3665. It accepts the following options:
  3666. @table @option
  3667. @item threshold0
  3668. @item threshold1
  3669. @item threshold2
  3670. @item threshold3
  3671. Limit the maximum change for each plane, default is 65535.
  3672. If 0, plane will remain unchanged.
  3673. @item coordinates
  3674. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  3675. pixels are used.
  3676. Flags to local 3x3 coordinates maps like this:
  3677. 1 2 3
  3678. 4 5
  3679. 6 7 8
  3680. @end table
  3681. @section displace
  3682. Displace pixels as indicated by second and third input stream.
  3683. It takes three input streams and outputs one stream, the first input is the
  3684. source, and second and third input are displacement maps.
  3685. The second input specifies how much to displace pixels along the
  3686. x-axis, while the third input specifies how much to displace pixels
  3687. along the y-axis.
  3688. If one of displacement map streams terminates, last frame from that
  3689. displacement map will be used.
  3690. Note that once generated, displacements maps can be reused over and over again.
  3691. A description of the accepted options follows.
  3692. @table @option
  3693. @item edge
  3694. Set displace behavior for pixels that are out of range.
  3695. Available values are:
  3696. @table @samp
  3697. @item blank
  3698. Missing pixels are replaced by black pixels.
  3699. @item smear
  3700. Adjacent pixels will spread out to replace missing pixels.
  3701. @item wrap
  3702. Out of range pixels are wrapped so they point to pixels of other side.
  3703. @end table
  3704. Default is @samp{smear}.
  3705. @end table
  3706. @subsection Examples
  3707. @itemize
  3708. @item
  3709. Add ripple effect to rgb input of video size hd720:
  3710. @example
  3711. 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
  3712. @end example
  3713. @item
  3714. Add wave effect to rgb input of video size hd720:
  3715. @example
  3716. 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
  3717. @end example
  3718. @end itemize
  3719. @section drawbox
  3720. Draw a colored box on the input image.
  3721. It accepts the following parameters:
  3722. @table @option
  3723. @item x
  3724. @item y
  3725. The expressions which specify the top left corner coordinates of the box. It defaults to 0.
  3726. @item width, w
  3727. @item height, h
  3728. The expressions which specify the width and height of the box; if 0 they are interpreted as
  3729. the input width and height. It defaults to 0.
  3730. @item color, c
  3731. Specify the color of the box to write. For the general syntax of this option,
  3732. check the "Color" section in the ffmpeg-utils manual. If the special
  3733. value @code{invert} is used, the box edge color is the same as the
  3734. video with inverted luma.
  3735. @item thickness, t
  3736. The expression which sets the thickness of the box edge. Default value is @code{3}.
  3737. See below for the list of accepted constants.
  3738. @end table
  3739. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  3740. following constants:
  3741. @table @option
  3742. @item dar
  3743. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  3744. @item hsub
  3745. @item vsub
  3746. horizontal and vertical chroma subsample values. For example for the
  3747. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3748. @item in_h, ih
  3749. @item in_w, iw
  3750. The input width and height.
  3751. @item sar
  3752. The input sample aspect ratio.
  3753. @item x
  3754. @item y
  3755. The x and y offset coordinates where the box is drawn.
  3756. @item w
  3757. @item h
  3758. The width and height of the drawn box.
  3759. @item t
  3760. The thickness of the drawn box.
  3761. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  3762. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  3763. @end table
  3764. @subsection Examples
  3765. @itemize
  3766. @item
  3767. Draw a black box around the edge of the input image:
  3768. @example
  3769. drawbox
  3770. @end example
  3771. @item
  3772. Draw a box with color red and an opacity of 50%:
  3773. @example
  3774. drawbox=10:20:200:60:red@@0.5
  3775. @end example
  3776. The previous example can be specified as:
  3777. @example
  3778. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  3779. @end example
  3780. @item
  3781. Fill the box with pink color:
  3782. @example
  3783. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  3784. @end example
  3785. @item
  3786. Draw a 2-pixel red 2.40:1 mask:
  3787. @example
  3788. 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
  3789. @end example
  3790. @end itemize
  3791. @section drawgraph, adrawgraph
  3792. Draw a graph using input video or audio metadata.
  3793. It accepts the following parameters:
  3794. @table @option
  3795. @item m1
  3796. Set 1st frame metadata key from which metadata values will be used to draw a graph.
  3797. @item fg1
  3798. Set 1st foreground color expression.
  3799. @item m2
  3800. Set 2nd frame metadata key from which metadata values will be used to draw a graph.
  3801. @item fg2
  3802. Set 2nd foreground color expression.
  3803. @item m3
  3804. Set 3rd frame metadata key from which metadata values will be used to draw a graph.
  3805. @item fg3
  3806. Set 3rd foreground color expression.
  3807. @item m4
  3808. Set 4th frame metadata key from which metadata values will be used to draw a graph.
  3809. @item fg4
  3810. Set 4th foreground color expression.
  3811. @item min
  3812. Set minimal value of metadata value.
  3813. @item max
  3814. Set maximal value of metadata value.
  3815. @item bg
  3816. Set graph background color. Default is white.
  3817. @item mode
  3818. Set graph mode.
  3819. Available values for mode is:
  3820. @table @samp
  3821. @item bar
  3822. @item dot
  3823. @item line
  3824. @end table
  3825. Default is @code{line}.
  3826. @item slide
  3827. Set slide mode.
  3828. Available values for slide is:
  3829. @table @samp
  3830. @item frame
  3831. Draw new frame when right border is reached.
  3832. @item replace
  3833. Replace old columns with new ones.
  3834. @item scroll
  3835. Scroll from right to left.
  3836. @item rscroll
  3837. Scroll from left to right.
  3838. @end table
  3839. Default is @code{frame}.
  3840. @item size
  3841. Set size of graph video. For the syntax of this option, check the
  3842. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  3843. The default value is @code{900x256}.
  3844. The foreground color expressions can use the following variables:
  3845. @table @option
  3846. @item MIN
  3847. Minimal value of metadata value.
  3848. @item MAX
  3849. Maximal value of metadata value.
  3850. @item VAL
  3851. Current metadata key value.
  3852. @end table
  3853. The color is defined as 0xAABBGGRR.
  3854. @end table
  3855. Example using metadata from @ref{signalstats} filter:
  3856. @example
  3857. signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255
  3858. @end example
  3859. Example using metadata from @ref{ebur128} filter:
  3860. @example
  3861. ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5
  3862. @end example
  3863. @section drawgrid
  3864. Draw a grid on the input image.
  3865. It accepts the following parameters:
  3866. @table @option
  3867. @item x
  3868. @item y
  3869. The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
  3870. @item width, w
  3871. @item height, h
  3872. The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
  3873. input width and height, respectively, minus @code{thickness}, so image gets
  3874. framed. Default to 0.
  3875. @item color, c
  3876. Specify the color of the grid. For the general syntax of this option,
  3877. check the "Color" section in the ffmpeg-utils manual. If the special
  3878. value @code{invert} is used, the grid color is the same as the
  3879. video with inverted luma.
  3880. @item thickness, t
  3881. The expression which sets the thickness of the grid line. Default value is @code{1}.
  3882. See below for the list of accepted constants.
  3883. @end table
  3884. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  3885. following constants:
  3886. @table @option
  3887. @item dar
  3888. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  3889. @item hsub
  3890. @item vsub
  3891. horizontal and vertical chroma subsample values. For example for the
  3892. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3893. @item in_h, ih
  3894. @item in_w, iw
  3895. The input grid cell width and height.
  3896. @item sar
  3897. The input sample aspect ratio.
  3898. @item x
  3899. @item y
  3900. The x and y coordinates of some point of grid intersection (meant to configure offset).
  3901. @item w
  3902. @item h
  3903. The width and height of the drawn cell.
  3904. @item t
  3905. The thickness of the drawn cell.
  3906. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  3907. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  3908. @end table
  3909. @subsection Examples
  3910. @itemize
  3911. @item
  3912. Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
  3913. @example
  3914. drawgrid=width=100:height=100:thickness=2:color=red@@0.5
  3915. @end example
  3916. @item
  3917. Draw a white 3x3 grid with an opacity of 50%:
  3918. @example
  3919. drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
  3920. @end example
  3921. @end itemize
  3922. @anchor{drawtext}
  3923. @section drawtext
  3924. Draw a text string or text from a specified file on top of a video, using the
  3925. libfreetype library.
  3926. To enable compilation of this filter, you need to configure FFmpeg with
  3927. @code{--enable-libfreetype}.
  3928. To enable default font fallback and the @var{font} option you need to
  3929. configure FFmpeg with @code{--enable-libfontconfig}.
  3930. To enable the @var{text_shaping} option, you need to configure FFmpeg with
  3931. @code{--enable-libfribidi}.
  3932. @subsection Syntax
  3933. It accepts the following parameters:
  3934. @table @option
  3935. @item box
  3936. Used to draw a box around text using the background color.
  3937. The value must be either 1 (enable) or 0 (disable).
  3938. The default value of @var{box} is 0.
  3939. @item boxborderw
  3940. Set the width of the border to be drawn around the box using @var{boxcolor}.
  3941. The default value of @var{boxborderw} is 0.
  3942. @item boxcolor
  3943. The color to be used for drawing box around text. For the syntax of this
  3944. option, check the "Color" section in the ffmpeg-utils manual.
  3945. The default value of @var{boxcolor} is "white".
  3946. @item borderw
  3947. Set the width of the border to be drawn around the text using @var{bordercolor}.
  3948. The default value of @var{borderw} is 0.
  3949. @item bordercolor
  3950. Set the color to be used for drawing border around text. For the syntax of this
  3951. option, check the "Color" section in the ffmpeg-utils manual.
  3952. The default value of @var{bordercolor} is "black".
  3953. @item expansion
  3954. Select how the @var{text} is expanded. Can be either @code{none},
  3955. @code{strftime} (deprecated) or
  3956. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  3957. below for details.
  3958. @item fix_bounds
  3959. If true, check and fix text coords to avoid clipping.
  3960. @item fontcolor
  3961. The color to be used for drawing fonts. For the syntax of this option, check
  3962. the "Color" section in the ffmpeg-utils manual.
  3963. The default value of @var{fontcolor} is "black".
  3964. @item fontcolor_expr
  3965. String which is expanded the same way as @var{text} to obtain dynamic
  3966. @var{fontcolor} value. By default this option has empty value and is not
  3967. processed. When this option is set, it overrides @var{fontcolor} option.
  3968. @item font
  3969. The font family to be used for drawing text. By default Sans.
  3970. @item fontfile
  3971. The font file to be used for drawing text. The path must be included.
  3972. This parameter is mandatory if the fontconfig support is disabled.
  3973. @item draw
  3974. This option does not exist, please see the timeline system
  3975. @item alpha
  3976. Draw the text applying alpha blending. The value can
  3977. be either a number between 0.0 and 1.0
  3978. The expression accepts the same variables @var{x, y} do.
  3979. The default value is 1.
  3980. Please see fontcolor_expr
  3981. @item fontsize
  3982. The font size to be used for drawing text.
  3983. The default value of @var{fontsize} is 16.
  3984. @item text_shaping
  3985. If set to 1, attempt to shape the text (for example, reverse the order of
  3986. right-to-left text and join Arabic characters) before drawing it.
  3987. Otherwise, just draw the text exactly as given.
  3988. By default 1 (if supported).
  3989. @item ft_load_flags
  3990. The flags to be used for loading the fonts.
  3991. The flags map the corresponding flags supported by libfreetype, and are
  3992. a combination of the following values:
  3993. @table @var
  3994. @item default
  3995. @item no_scale
  3996. @item no_hinting
  3997. @item render
  3998. @item no_bitmap
  3999. @item vertical_layout
  4000. @item force_autohint
  4001. @item crop_bitmap
  4002. @item pedantic
  4003. @item ignore_global_advance_width
  4004. @item no_recurse
  4005. @item ignore_transform
  4006. @item monochrome
  4007. @item linear_design
  4008. @item no_autohint
  4009. @end table
  4010. Default value is "default".
  4011. For more information consult the documentation for the FT_LOAD_*
  4012. libfreetype flags.
  4013. @item shadowcolor
  4014. The color to be used for drawing a shadow behind the drawn text. For the
  4015. syntax of this option, check the "Color" section in the ffmpeg-utils manual.
  4016. The default value of @var{shadowcolor} is "black".
  4017. @item shadowx
  4018. @item shadowy
  4019. The x and y offsets for the text shadow position with respect to the
  4020. position of the text. They can be either positive or negative
  4021. values. The default value for both is "0".
  4022. @item start_number
  4023. The starting frame number for the n/frame_num variable. The default value
  4024. is "0".
  4025. @item tabsize
  4026. The size in number of spaces to use for rendering the tab.
  4027. Default value is 4.
  4028. @item timecode
  4029. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  4030. format. It can be used with or without text parameter. @var{timecode_rate}
  4031. option must be specified.
  4032. @item timecode_rate, rate, r
  4033. Set the timecode frame rate (timecode only).
  4034. @item text
  4035. The text string to be drawn. The text must be a sequence of UTF-8
  4036. encoded characters.
  4037. This parameter is mandatory if no file is specified with the parameter
  4038. @var{textfile}.
  4039. @item textfile
  4040. A text file containing text to be drawn. The text must be a sequence
  4041. of UTF-8 encoded characters.
  4042. This parameter is mandatory if no text string is specified with the
  4043. parameter @var{text}.
  4044. If both @var{text} and @var{textfile} are specified, an error is thrown.
  4045. @item reload
  4046. If set to 1, the @var{textfile} will be reloaded before each frame.
  4047. Be sure to update it atomically, or it may be read partially, or even fail.
  4048. @item x
  4049. @item y
  4050. The expressions which specify the offsets where text will be drawn
  4051. within the video frame. They are relative to the top/left border of the
  4052. output image.
  4053. The default value of @var{x} and @var{y} is "0".
  4054. See below for the list of accepted constants and functions.
  4055. @end table
  4056. The parameters for @var{x} and @var{y} are expressions containing the
  4057. following constants and functions:
  4058. @table @option
  4059. @item dar
  4060. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  4061. @item hsub
  4062. @item vsub
  4063. horizontal and vertical chroma subsample values. For example for the
  4064. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  4065. @item line_h, lh
  4066. the height of each text line
  4067. @item main_h, h, H
  4068. the input height
  4069. @item main_w, w, W
  4070. the input width
  4071. @item max_glyph_a, ascent
  4072. the maximum distance from the baseline to the highest/upper grid
  4073. coordinate used to place a glyph outline point, for all the rendered
  4074. glyphs.
  4075. It is a positive value, due to the grid's orientation with the Y axis
  4076. upwards.
  4077. @item max_glyph_d, descent
  4078. the maximum distance from the baseline to the lowest grid coordinate
  4079. used to place a glyph outline point, for all the rendered glyphs.
  4080. This is a negative value, due to the grid's orientation, with the Y axis
  4081. upwards.
  4082. @item max_glyph_h
  4083. maximum glyph height, that is the maximum height for all the glyphs
  4084. contained in the rendered text, it is equivalent to @var{ascent} -
  4085. @var{descent}.
  4086. @item max_glyph_w
  4087. maximum glyph width, that is the maximum width for all the glyphs
  4088. contained in the rendered text
  4089. @item n
  4090. the number of input frame, starting from 0
  4091. @item rand(min, max)
  4092. return a random number included between @var{min} and @var{max}
  4093. @item sar
  4094. The input sample aspect ratio.
  4095. @item t
  4096. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4097. @item text_h, th
  4098. the height of the rendered text
  4099. @item text_w, tw
  4100. the width of the rendered text
  4101. @item x
  4102. @item y
  4103. the x and y offset coordinates where the text is drawn.
  4104. These parameters allow the @var{x} and @var{y} expressions to refer
  4105. each other, so you can for example specify @code{y=x/dar}.
  4106. @end table
  4107. @anchor{drawtext_expansion}
  4108. @subsection Text expansion
  4109. If @option{expansion} is set to @code{strftime},
  4110. the filter recognizes strftime() sequences in the provided text and
  4111. expands them accordingly. Check the documentation of strftime(). This
  4112. feature is deprecated.
  4113. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  4114. If @option{expansion} is set to @code{normal} (which is the default),
  4115. the following expansion mechanism is used.
  4116. The backslash character @samp{\}, followed by any character, always expands to
  4117. the second character.
  4118. Sequence of the form @code{%@{...@}} are expanded. The text between the
  4119. braces is a function name, possibly followed by arguments separated by ':'.
  4120. If the arguments contain special characters or delimiters (':' or '@}'),
  4121. they should be escaped.
  4122. Note that they probably must also be escaped as the value for the
  4123. @option{text} option in the filter argument string and as the filter
  4124. argument in the filtergraph description, and possibly also for the shell,
  4125. that makes up to four levels of escaping; using a text file avoids these
  4126. problems.
  4127. The following functions are available:
  4128. @table @command
  4129. @item expr, e
  4130. The expression evaluation result.
  4131. It must take one argument specifying the expression to be evaluated,
  4132. which accepts the same constants and functions as the @var{x} and
  4133. @var{y} values. Note that not all constants should be used, for
  4134. example the text size is not known when evaluating the expression, so
  4135. the constants @var{text_w} and @var{text_h} will have an undefined
  4136. value.
  4137. @item expr_int_format, eif
  4138. Evaluate the expression's value and output as formatted integer.
  4139. The first argument is the expression to be evaluated, just as for the @var{expr} function.
  4140. The second argument specifies the output format. Allowed values are @samp{x},
  4141. @samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
  4142. @code{printf} function.
  4143. The third parameter is optional and sets the number of positions taken by the output.
  4144. It can be used to add padding with zeros from the left.
  4145. @item gmtime
  4146. The time at which the filter is running, expressed in UTC.
  4147. It can accept an argument: a strftime() format string.
  4148. @item localtime
  4149. The time at which the filter is running, expressed in the local time zone.
  4150. It can accept an argument: a strftime() format string.
  4151. @item metadata
  4152. Frame metadata. It must take one argument specifying metadata key.
  4153. @item n, frame_num
  4154. The frame number, starting from 0.
  4155. @item pict_type
  4156. A 1 character description of the current picture type.
  4157. @item pts
  4158. The timestamp of the current frame.
  4159. It can take up to three arguments.
  4160. The first argument is the format of the timestamp; it defaults to @code{flt}
  4161. for seconds as a decimal number with microsecond accuracy; @code{hms} stands
  4162. for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
  4163. @code{gmtime} stands for the timestamp of the frame formatted as UTC time;
  4164. @code{localtime} stands for the timestamp of the frame formatted as
  4165. local time zone time.
  4166. The second argument is an offset added to the timestamp.
  4167. If the format is set to @code{localtime} or @code{gmtime},
  4168. a third argument may be supplied: a strftime() format string.
  4169. By default, @var{YYYY-MM-DD HH:MM:SS} format will be used.
  4170. @end table
  4171. @subsection Examples
  4172. @itemize
  4173. @item
  4174. Draw "Test Text" with font FreeSerif, using the default values for the
  4175. optional parameters.
  4176. @example
  4177. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  4178. @end example
  4179. @item
  4180. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  4181. and y=50 (counting from the top-left corner of the screen), text is
  4182. yellow with a red box around it. Both the text and the box have an
  4183. opacity of 20%.
  4184. @example
  4185. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  4186. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  4187. @end example
  4188. Note that the double quotes are not necessary if spaces are not used
  4189. within the parameter list.
  4190. @item
  4191. Show the text at the center of the video frame:
  4192. @example
  4193. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  4194. @end example
  4195. @item
  4196. Show a text line sliding from right to left in the last row of the video
  4197. frame. The file @file{LONG_LINE} is assumed to contain a single line
  4198. with no newlines.
  4199. @example
  4200. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  4201. @end example
  4202. @item
  4203. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  4204. @example
  4205. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  4206. @end example
  4207. @item
  4208. Draw a single green letter "g", at the center of the input video.
  4209. The glyph baseline is placed at half screen height.
  4210. @example
  4211. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  4212. @end example
  4213. @item
  4214. Show text for 1 second every 3 seconds:
  4215. @example
  4216. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  4217. @end example
  4218. @item
  4219. Use fontconfig to set the font. Note that the colons need to be escaped.
  4220. @example
  4221. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  4222. @end example
  4223. @item
  4224. Print the date of a real-time encoding (see strftime(3)):
  4225. @example
  4226. drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
  4227. @end example
  4228. @item
  4229. Show text fading in and out (appearing/disappearing):
  4230. @example
  4231. #!/bin/sh
  4232. DS=1.0 # display start
  4233. DE=10.0 # display end
  4234. FID=1.5 # fade in duration
  4235. FOD=5 # fade out duration
  4236. 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 @}"
  4237. @end example
  4238. @end itemize
  4239. For more information about libfreetype, check:
  4240. @url{http://www.freetype.org/}.
  4241. For more information about fontconfig, check:
  4242. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  4243. For more information about libfribidi, check:
  4244. @url{http://fribidi.org/}.
  4245. @section edgedetect
  4246. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  4247. The filter accepts the following options:
  4248. @table @option
  4249. @item low
  4250. @item high
  4251. Set low and high threshold values used by the Canny thresholding
  4252. algorithm.
  4253. The high threshold selects the "strong" edge pixels, which are then
  4254. connected through 8-connectivity with the "weak" edge pixels selected
  4255. by the low threshold.
  4256. @var{low} and @var{high} threshold values must be chosen in the range
  4257. [0,1], and @var{low} should be lesser or equal to @var{high}.
  4258. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  4259. is @code{50/255}.
  4260. @item mode
  4261. Define the drawing mode.
  4262. @table @samp
  4263. @item wires
  4264. Draw white/gray wires on black background.
  4265. @item colormix
  4266. Mix the colors to create a paint/cartoon effect.
  4267. @end table
  4268. Default value is @var{wires}.
  4269. @end table
  4270. @subsection Examples
  4271. @itemize
  4272. @item
  4273. Standard edge detection with custom values for the hysteresis thresholding:
  4274. @example
  4275. edgedetect=low=0.1:high=0.4
  4276. @end example
  4277. @item
  4278. Painting effect without thresholding:
  4279. @example
  4280. edgedetect=mode=colormix:high=0
  4281. @end example
  4282. @end itemize
  4283. @section eq
  4284. Set brightness, contrast, saturation and approximate gamma adjustment.
  4285. The filter accepts the following options:
  4286. @table @option
  4287. @item contrast
  4288. Set the contrast expression. The value must be a float value in range
  4289. @code{-2.0} to @code{2.0}. The default value is "1".
  4290. @item brightness
  4291. Set the brightness expression. The value must be a float value in
  4292. range @code{-1.0} to @code{1.0}. The default value is "0".
  4293. @item saturation
  4294. Set the saturation expression. The value must be a float in
  4295. range @code{0.0} to @code{3.0}. The default value is "1".
  4296. @item gamma
  4297. Set the gamma expression. The value must be a float in range
  4298. @code{0.1} to @code{10.0}. The default value is "1".
  4299. @item gamma_r
  4300. Set the gamma expression for red. The value must be a float in
  4301. range @code{0.1} to @code{10.0}. The default value is "1".
  4302. @item gamma_g
  4303. Set the gamma expression for green. The value must be a float in range
  4304. @code{0.1} to @code{10.0}. The default value is "1".
  4305. @item gamma_b
  4306. Set the gamma expression for blue. The value must be a float in range
  4307. @code{0.1} to @code{10.0}. The default value is "1".
  4308. @item gamma_weight
  4309. Set the gamma weight expression. It can be used to reduce the effect
  4310. of a high gamma value on bright image areas, e.g. keep them from
  4311. getting overamplified and just plain white. The value must be a float
  4312. in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
  4313. gamma correction all the way down while @code{1.0} leaves it at its
  4314. full strength. Default is "1".
  4315. @item eval
  4316. Set when the expressions for brightness, contrast, saturation and
  4317. gamma expressions are evaluated.
  4318. It accepts the following values:
  4319. @table @samp
  4320. @item init
  4321. only evaluate expressions once during the filter initialization or
  4322. when a command is processed
  4323. @item frame
  4324. evaluate expressions for each incoming frame
  4325. @end table
  4326. Default value is @samp{init}.
  4327. @end table
  4328. The expressions accept the following parameters:
  4329. @table @option
  4330. @item n
  4331. frame count of the input frame starting from 0
  4332. @item pos
  4333. byte position of the corresponding packet in the input file, NAN if
  4334. unspecified
  4335. @item r
  4336. frame rate of the input video, NAN if the input frame rate is unknown
  4337. @item t
  4338. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4339. @end table
  4340. @subsection Commands
  4341. The filter supports the following commands:
  4342. @table @option
  4343. @item contrast
  4344. Set the contrast expression.
  4345. @item brightness
  4346. Set the brightness expression.
  4347. @item saturation
  4348. Set the saturation expression.
  4349. @item gamma
  4350. Set the gamma expression.
  4351. @item gamma_r
  4352. Set the gamma_r expression.
  4353. @item gamma_g
  4354. Set gamma_g expression.
  4355. @item gamma_b
  4356. Set gamma_b expression.
  4357. @item gamma_weight
  4358. Set gamma_weight expression.
  4359. The command accepts the same syntax of the corresponding option.
  4360. If the specified expression is not valid, it is kept at its current
  4361. value.
  4362. @end table
  4363. @section erosion
  4364. Apply erosion effect to the video.
  4365. This filter replaces the pixel by the local(3x3) minimum.
  4366. It accepts the following options:
  4367. @table @option
  4368. @item threshold0
  4369. @item threshold1
  4370. @item threshold2
  4371. @item threshold3
  4372. Limit the maximum change for each plane, default is 65535.
  4373. If 0, plane will remain unchanged.
  4374. @item coordinates
  4375. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  4376. pixels are used.
  4377. Flags to local 3x3 coordinates maps like this:
  4378. 1 2 3
  4379. 4 5
  4380. 6 7 8
  4381. @end table
  4382. @section extractplanes
  4383. Extract color channel components from input video stream into
  4384. separate grayscale video streams.
  4385. The filter accepts the following option:
  4386. @table @option
  4387. @item planes
  4388. Set plane(s) to extract.
  4389. Available values for planes are:
  4390. @table @samp
  4391. @item y
  4392. @item u
  4393. @item v
  4394. @item a
  4395. @item r
  4396. @item g
  4397. @item b
  4398. @end table
  4399. Choosing planes not available in the input will result in an error.
  4400. That means you cannot select @code{r}, @code{g}, @code{b} planes
  4401. with @code{y}, @code{u}, @code{v} planes at same time.
  4402. @end table
  4403. @subsection Examples
  4404. @itemize
  4405. @item
  4406. Extract luma, u and v color channel component from input video frame
  4407. into 3 grayscale outputs:
  4408. @example
  4409. 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
  4410. @end example
  4411. @end itemize
  4412. @section elbg
  4413. Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
  4414. For each input image, the filter will compute the optimal mapping from
  4415. the input to the output given the codebook length, that is the number
  4416. of distinct output colors.
  4417. This filter accepts the following options.
  4418. @table @option
  4419. @item codebook_length, l
  4420. Set codebook length. The value must be a positive integer, and
  4421. represents the number of distinct output colors. Default value is 256.
  4422. @item nb_steps, n
  4423. Set the maximum number of iterations to apply for computing the optimal
  4424. mapping. The higher the value the better the result and the higher the
  4425. computation time. Default value is 1.
  4426. @item seed, s
  4427. Set a random seed, must be an integer included between 0 and
  4428. UINT32_MAX. If not specified, or if explicitly set to -1, the filter
  4429. will try to use a good random seed on a best effort basis.
  4430. @item pal8
  4431. Set pal8 output pixel format. This option does not work with codebook
  4432. length greater than 256.
  4433. @end table
  4434. @section fade
  4435. Apply a fade-in/out effect to the input video.
  4436. It accepts the following parameters:
  4437. @table @option
  4438. @item type, t
  4439. The effect type can be either "in" for a fade-in, or "out" for a fade-out
  4440. effect.
  4441. Default is @code{in}.
  4442. @item start_frame, s
  4443. Specify the number of the frame to start applying the fade
  4444. effect at. Default is 0.
  4445. @item nb_frames, n
  4446. The number of frames that the fade effect lasts. At the end of the
  4447. fade-in effect, the output video will have the same intensity as the input video.
  4448. At the end of the fade-out transition, the output video will be filled with the
  4449. selected @option{color}.
  4450. Default is 25.
  4451. @item alpha
  4452. If set to 1, fade only alpha channel, if one exists on the input.
  4453. Default value is 0.
  4454. @item start_time, st
  4455. Specify the timestamp (in seconds) of the frame to start to apply the fade
  4456. effect. If both start_frame and start_time are specified, the fade will start at
  4457. whichever comes last. Default is 0.
  4458. @item duration, d
  4459. The number of seconds for which the fade effect has to last. At the end of the
  4460. fade-in effect the output video will have the same intensity as the input video,
  4461. at the end of the fade-out transition the output video will be filled with the
  4462. selected @option{color}.
  4463. If both duration and nb_frames are specified, duration is used. Default is 0
  4464. (nb_frames is used by default).
  4465. @item color, c
  4466. Specify the color of the fade. Default is "black".
  4467. @end table
  4468. @subsection Examples
  4469. @itemize
  4470. @item
  4471. Fade in the first 30 frames of video:
  4472. @example
  4473. fade=in:0:30
  4474. @end example
  4475. The command above is equivalent to:
  4476. @example
  4477. fade=t=in:s=0:n=30
  4478. @end example
  4479. @item
  4480. Fade out the last 45 frames of a 200-frame video:
  4481. @example
  4482. fade=out:155:45
  4483. fade=type=out:start_frame=155:nb_frames=45
  4484. @end example
  4485. @item
  4486. Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
  4487. @example
  4488. fade=in:0:25, fade=out:975:25
  4489. @end example
  4490. @item
  4491. Make the first 5 frames yellow, then fade in from frame 5-24:
  4492. @example
  4493. fade=in:5:20:color=yellow
  4494. @end example
  4495. @item
  4496. Fade in alpha over first 25 frames of video:
  4497. @example
  4498. fade=in:0:25:alpha=1
  4499. @end example
  4500. @item
  4501. Make the first 5.5 seconds black, then fade in for 0.5 seconds:
  4502. @example
  4503. fade=t=in:st=5.5:d=0.5
  4504. @end example
  4505. @end itemize
  4506. @section fftfilt
  4507. Apply arbitrary expressions to samples in frequency domain
  4508. @table @option
  4509. @item dc_Y
  4510. Adjust the dc value (gain) of the luma plane of the image. The filter
  4511. accepts an integer value in range @code{0} to @code{1000}. The default
  4512. value is set to @code{0}.
  4513. @item dc_U
  4514. Adjust the dc value (gain) of the 1st chroma plane of the image. The
  4515. filter accepts an integer value in range @code{0} to @code{1000}. The
  4516. default value is set to @code{0}.
  4517. @item dc_V
  4518. Adjust the dc value (gain) of the 2nd chroma plane of the image. The
  4519. filter accepts an integer value in range @code{0} to @code{1000}. The
  4520. default value is set to @code{0}.
  4521. @item weight_Y
  4522. Set the frequency domain weight expression for the luma plane.
  4523. @item weight_U
  4524. Set the frequency domain weight expression for the 1st chroma plane.
  4525. @item weight_V
  4526. Set the frequency domain weight expression for the 2nd chroma plane.
  4527. The filter accepts the following variables:
  4528. @item X
  4529. @item Y
  4530. The coordinates of the current sample.
  4531. @item W
  4532. @item H
  4533. The width and height of the image.
  4534. @end table
  4535. @subsection Examples
  4536. @itemize
  4537. @item
  4538. High-pass:
  4539. @example
  4540. fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
  4541. @end example
  4542. @item
  4543. Low-pass:
  4544. @example
  4545. fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
  4546. @end example
  4547. @item
  4548. Sharpen:
  4549. @example
  4550. fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
  4551. @end example
  4552. @end itemize
  4553. @section field
  4554. Extract a single field from an interlaced image using stride
  4555. arithmetic to avoid wasting CPU time. The output frames are marked as
  4556. non-interlaced.
  4557. The filter accepts the following options:
  4558. @table @option
  4559. @item type
  4560. Specify whether to extract the top (if the value is @code{0} or
  4561. @code{top}) or the bottom field (if the value is @code{1} or
  4562. @code{bottom}).
  4563. @end table
  4564. @section fieldmatch
  4565. Field matching filter for inverse telecine. It is meant to reconstruct the
  4566. progressive frames from a telecined stream. The filter does not drop duplicated
  4567. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  4568. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  4569. The separation of the field matching and the decimation is notably motivated by
  4570. the possibility of inserting a de-interlacing filter fallback between the two.
  4571. If the source has mixed telecined and real interlaced content,
  4572. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  4573. But these remaining combed frames will be marked as interlaced, and thus can be
  4574. de-interlaced by a later filter such as @ref{yadif} before decimation.
  4575. In addition to the various configuration options, @code{fieldmatch} can take an
  4576. optional second stream, activated through the @option{ppsrc} option. If
  4577. enabled, the frames reconstruction will be based on the fields and frames from
  4578. this second stream. This allows the first input to be pre-processed in order to
  4579. help the various algorithms of the filter, while keeping the output lossless
  4580. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  4581. or brightness/contrast adjustments can help.
  4582. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  4583. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  4584. which @code{fieldmatch} is based on. While the semantic and usage are very
  4585. close, some behaviour and options names can differ.
  4586. The @ref{decimate} filter currently only works for constant frame rate input.
  4587. If your input has mixed telecined (30fps) and progressive content with a lower
  4588. framerate like 24fps use the following filterchain to produce the necessary cfr
  4589. stream: @code{dejudder,fps=30000/1001,fieldmatch,decimate}.
  4590. The filter accepts the following options:
  4591. @table @option
  4592. @item order
  4593. Specify the assumed field order of the input stream. Available values are:
  4594. @table @samp
  4595. @item auto
  4596. Auto detect parity (use FFmpeg's internal parity value).
  4597. @item bff
  4598. Assume bottom field first.
  4599. @item tff
  4600. Assume top field first.
  4601. @end table
  4602. Note that it is sometimes recommended not to trust the parity announced by the
  4603. stream.
  4604. Default value is @var{auto}.
  4605. @item mode
  4606. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  4607. sense that it won't risk creating jerkiness due to duplicate frames when
  4608. possible, but if there are bad edits or blended fields it will end up
  4609. outputting combed frames when a good match might actually exist. On the other
  4610. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  4611. but will almost always find a good frame if there is one. The other values are
  4612. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  4613. jerkiness and creating duplicate frames versus finding good matches in sections
  4614. with bad edits, orphaned fields, blended fields, etc.
  4615. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  4616. Available values are:
  4617. @table @samp
  4618. @item pc
  4619. 2-way matching (p/c)
  4620. @item pc_n
  4621. 2-way matching, and trying 3rd match if still combed (p/c + n)
  4622. @item pc_u
  4623. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  4624. @item pc_n_ub
  4625. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  4626. still combed (p/c + n + u/b)
  4627. @item pcn
  4628. 3-way matching (p/c/n)
  4629. @item pcn_ub
  4630. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  4631. detected as combed (p/c/n + u/b)
  4632. @end table
  4633. The parenthesis at the end indicate the matches that would be used for that
  4634. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  4635. @var{top}).
  4636. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  4637. the slowest.
  4638. Default value is @var{pc_n}.
  4639. @item ppsrc
  4640. Mark the main input stream as a pre-processed input, and enable the secondary
  4641. input stream as the clean source to pick the fields from. See the filter
  4642. introduction for more details. It is similar to the @option{clip2} feature from
  4643. VFM/TFM.
  4644. Default value is @code{0} (disabled).
  4645. @item field
  4646. Set the field to match from. It is recommended to set this to the same value as
  4647. @option{order} unless you experience matching failures with that setting. In
  4648. certain circumstances changing the field that is used to match from can have a
  4649. large impact on matching performance. Available values are:
  4650. @table @samp
  4651. @item auto
  4652. Automatic (same value as @option{order}).
  4653. @item bottom
  4654. Match from the bottom field.
  4655. @item top
  4656. Match from the top field.
  4657. @end table
  4658. Default value is @var{auto}.
  4659. @item mchroma
  4660. Set whether or not chroma is included during the match comparisons. In most
  4661. cases it is recommended to leave this enabled. You should set this to @code{0}
  4662. only if your clip has bad chroma problems such as heavy rainbowing or other
  4663. artifacts. Setting this to @code{0} could also be used to speed things up at
  4664. the cost of some accuracy.
  4665. Default value is @code{1}.
  4666. @item y0
  4667. @item y1
  4668. These define an exclusion band which excludes the lines between @option{y0} and
  4669. @option{y1} from being included in the field matching decision. An exclusion
  4670. band can be used to ignore subtitles, a logo, or other things that may
  4671. interfere with the matching. @option{y0} sets the starting scan line and
  4672. @option{y1} sets the ending line; all lines in between @option{y0} and
  4673. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  4674. @option{y0} and @option{y1} to the same value will disable the feature.
  4675. @option{y0} and @option{y1} defaults to @code{0}.
  4676. @item scthresh
  4677. Set the scene change detection threshold as a percentage of maximum change on
  4678. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  4679. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  4680. @option{scthresh} is @code{[0.0, 100.0]}.
  4681. Default value is @code{12.0}.
  4682. @item combmatch
  4683. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  4684. account the combed scores of matches when deciding what match to use as the
  4685. final match. Available values are:
  4686. @table @samp
  4687. @item none
  4688. No final matching based on combed scores.
  4689. @item sc
  4690. Combed scores are only used when a scene change is detected.
  4691. @item full
  4692. Use combed scores all the time.
  4693. @end table
  4694. Default is @var{sc}.
  4695. @item combdbg
  4696. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  4697. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  4698. Available values are:
  4699. @table @samp
  4700. @item none
  4701. No forced calculation.
  4702. @item pcn
  4703. Force p/c/n calculations.
  4704. @item pcnub
  4705. Force p/c/n/u/b calculations.
  4706. @end table
  4707. Default value is @var{none}.
  4708. @item cthresh
  4709. This is the area combing threshold used for combed frame detection. This
  4710. essentially controls how "strong" or "visible" combing must be to be detected.
  4711. Larger values mean combing must be more visible and smaller values mean combing
  4712. can be less visible or strong and still be detected. Valid settings are from
  4713. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  4714. be detected as combed). This is basically a pixel difference value. A good
  4715. range is @code{[8, 12]}.
  4716. Default value is @code{9}.
  4717. @item chroma
  4718. Sets whether or not chroma is considered in the combed frame decision. Only
  4719. disable this if your source has chroma problems (rainbowing, etc.) that are
  4720. causing problems for the combed frame detection with chroma enabled. Actually,
  4721. using @option{chroma}=@var{0} is usually more reliable, except for the case
  4722. where there is chroma only combing in the source.
  4723. Default value is @code{0}.
  4724. @item blockx
  4725. @item blocky
  4726. Respectively set the x-axis and y-axis size of the window used during combed
  4727. frame detection. This has to do with the size of the area in which
  4728. @option{combpel} pixels are required to be detected as combed for a frame to be
  4729. declared combed. See the @option{combpel} parameter description for more info.
  4730. Possible values are any number that is a power of 2 starting at 4 and going up
  4731. to 512.
  4732. Default value is @code{16}.
  4733. @item combpel
  4734. The number of combed pixels inside any of the @option{blocky} by
  4735. @option{blockx} size blocks on the frame for the frame to be detected as
  4736. combed. While @option{cthresh} controls how "visible" the combing must be, this
  4737. setting controls "how much" combing there must be in any localized area (a
  4738. window defined by the @option{blockx} and @option{blocky} settings) on the
  4739. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  4740. which point no frames will ever be detected as combed). This setting is known
  4741. as @option{MI} in TFM/VFM vocabulary.
  4742. Default value is @code{80}.
  4743. @end table
  4744. @anchor{p/c/n/u/b meaning}
  4745. @subsection p/c/n/u/b meaning
  4746. @subsubsection p/c/n
  4747. We assume the following telecined stream:
  4748. @example
  4749. Top fields: 1 2 2 3 4
  4750. Bottom fields: 1 2 3 4 4
  4751. @end example
  4752. The numbers correspond to the progressive frame the fields relate to. Here, the
  4753. first two frames are progressive, the 3rd and 4th are combed, and so on.
  4754. When @code{fieldmatch} is configured to run a matching from bottom
  4755. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  4756. @example
  4757. Input stream:
  4758. T 1 2 2 3 4
  4759. B 1 2 3 4 4 <-- matching reference
  4760. Matches: c c n n c
  4761. Output stream:
  4762. T 1 2 3 4 4
  4763. B 1 2 3 4 4
  4764. @end example
  4765. As a result of the field matching, we can see that some frames get duplicated.
  4766. To perform a complete inverse telecine, you need to rely on a decimation filter
  4767. after this operation. See for instance the @ref{decimate} filter.
  4768. The same operation now matching from top fields (@option{field}=@var{top})
  4769. looks like this:
  4770. @example
  4771. Input stream:
  4772. T 1 2 2 3 4 <-- matching reference
  4773. B 1 2 3 4 4
  4774. Matches: c c p p c
  4775. Output stream:
  4776. T 1 2 2 3 4
  4777. B 1 2 2 3 4
  4778. @end example
  4779. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  4780. basically, they refer to the frame and field of the opposite parity:
  4781. @itemize
  4782. @item @var{p} matches the field of the opposite parity in the previous frame
  4783. @item @var{c} matches the field of the opposite parity in the current frame
  4784. @item @var{n} matches the field of the opposite parity in the next frame
  4785. @end itemize
  4786. @subsubsection u/b
  4787. The @var{u} and @var{b} matching are a bit special in the sense that they match
  4788. from the opposite parity flag. In the following examples, we assume that we are
  4789. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  4790. 'x' is placed above and below each matched fields.
  4791. With bottom matching (@option{field}=@var{bottom}):
  4792. @example
  4793. Match: c p n b u
  4794. x x x x x
  4795. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  4796. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  4797. x x x x x
  4798. Output frames:
  4799. 2 1 2 2 2
  4800. 2 2 2 1 3
  4801. @end example
  4802. With top matching (@option{field}=@var{top}):
  4803. @example
  4804. Match: c p n b u
  4805. x x x x x
  4806. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  4807. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  4808. x x x x x
  4809. Output frames:
  4810. 2 2 2 1 2
  4811. 2 1 3 2 2
  4812. @end example
  4813. @subsection Examples
  4814. Simple IVTC of a top field first telecined stream:
  4815. @example
  4816. fieldmatch=order=tff:combmatch=none, decimate
  4817. @end example
  4818. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  4819. @example
  4820. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  4821. @end example
  4822. @section fieldorder
  4823. Transform the field order of the input video.
  4824. It accepts the following parameters:
  4825. @table @option
  4826. @item order
  4827. The output field order. Valid values are @var{tff} for top field first or @var{bff}
  4828. for bottom field first.
  4829. @end table
  4830. The default value is @samp{tff}.
  4831. The transformation is done by shifting the picture content up or down
  4832. by one line, and filling the remaining line with appropriate picture content.
  4833. This method is consistent with most broadcast field order converters.
  4834. If the input video is not flagged as being interlaced, or it is already
  4835. flagged as being of the required output field order, then this filter does
  4836. not alter the incoming video.
  4837. It is very useful when converting to or from PAL DV material,
  4838. which is bottom field first.
  4839. For example:
  4840. @example
  4841. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  4842. @end example
  4843. @section fifo
  4844. Buffer input images and send them when they are requested.
  4845. It is mainly useful when auto-inserted by the libavfilter
  4846. framework.
  4847. It does not take parameters.
  4848. @section find_rect
  4849. Find a rectangular object
  4850. It accepts the following options:
  4851. @table @option
  4852. @item object
  4853. Filepath of the object image, needs to be in gray8.
  4854. @item threshold
  4855. Detection threshold, default is 0.5.
  4856. @item mipmaps
  4857. Number of mipmaps, default is 3.
  4858. @item xmin, ymin, xmax, ymax
  4859. Specifies the rectangle in which to search.
  4860. @end table
  4861. @subsection Examples
  4862. @itemize
  4863. @item
  4864. Generate a representative palette of a given video using @command{ffmpeg}:
  4865. @example
  4866. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  4867. @end example
  4868. @end itemize
  4869. @section cover_rect
  4870. Cover a rectangular object
  4871. It accepts the following options:
  4872. @table @option
  4873. @item cover
  4874. Filepath of the optional cover image, needs to be in yuv420.
  4875. @item mode
  4876. Set covering mode.
  4877. It accepts the following values:
  4878. @table @samp
  4879. @item cover
  4880. cover it by the supplied image
  4881. @item blur
  4882. cover it by interpolating the surrounding pixels
  4883. @end table
  4884. Default value is @var{blur}.
  4885. @end table
  4886. @subsection Examples
  4887. @itemize
  4888. @item
  4889. Generate a representative palette of a given video using @command{ffmpeg}:
  4890. @example
  4891. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  4892. @end example
  4893. @end itemize
  4894. @anchor{format}
  4895. @section format
  4896. Convert the input video to one of the specified pixel formats.
  4897. Libavfilter will try to pick one that is suitable as input to
  4898. the next filter.
  4899. It accepts the following parameters:
  4900. @table @option
  4901. @item pix_fmts
  4902. A '|'-separated list of pixel format names, such as
  4903. "pix_fmts=yuv420p|monow|rgb24".
  4904. @end table
  4905. @subsection Examples
  4906. @itemize
  4907. @item
  4908. Convert the input video to the @var{yuv420p} format
  4909. @example
  4910. format=pix_fmts=yuv420p
  4911. @end example
  4912. Convert the input video to any of the formats in the list
  4913. @example
  4914. format=pix_fmts=yuv420p|yuv444p|yuv410p
  4915. @end example
  4916. @end itemize
  4917. @anchor{fps}
  4918. @section fps
  4919. Convert the video to specified constant frame rate by duplicating or dropping
  4920. frames as necessary.
  4921. It accepts the following parameters:
  4922. @table @option
  4923. @item fps
  4924. The desired output frame rate. The default is @code{25}.
  4925. @item round
  4926. Rounding method.
  4927. Possible values are:
  4928. @table @option
  4929. @item zero
  4930. zero round towards 0
  4931. @item inf
  4932. round away from 0
  4933. @item down
  4934. round towards -infinity
  4935. @item up
  4936. round towards +infinity
  4937. @item near
  4938. round to nearest
  4939. @end table
  4940. The default is @code{near}.
  4941. @item start_time
  4942. Assume the first PTS should be the given value, in seconds. This allows for
  4943. padding/trimming at the start of stream. By default, no assumption is made
  4944. about the first frame's expected PTS, so no padding or trimming is done.
  4945. For example, this could be set to 0 to pad the beginning with duplicates of
  4946. the first frame if a video stream starts after the audio stream or to trim any
  4947. frames with a negative PTS.
  4948. @end table
  4949. Alternatively, the options can be specified as a flat string:
  4950. @var{fps}[:@var{round}].
  4951. See also the @ref{setpts} filter.
  4952. @subsection Examples
  4953. @itemize
  4954. @item
  4955. A typical usage in order to set the fps to 25:
  4956. @example
  4957. fps=fps=25
  4958. @end example
  4959. @item
  4960. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  4961. @example
  4962. fps=fps=film:round=near
  4963. @end example
  4964. @end itemize
  4965. @section framepack
  4966. Pack two different video streams into a stereoscopic video, setting proper
  4967. metadata on supported codecs. The two views should have the same size and
  4968. framerate and processing will stop when the shorter video ends. Please note
  4969. that you may conveniently adjust view properties with the @ref{scale} and
  4970. @ref{fps} filters.
  4971. It accepts the following parameters:
  4972. @table @option
  4973. @item format
  4974. The desired packing format. Supported values are:
  4975. @table @option
  4976. @item sbs
  4977. The views are next to each other (default).
  4978. @item tab
  4979. The views are on top of each other.
  4980. @item lines
  4981. The views are packed by line.
  4982. @item columns
  4983. The views are packed by column.
  4984. @item frameseq
  4985. The views are temporally interleaved.
  4986. @end table
  4987. @end table
  4988. Some examples:
  4989. @example
  4990. # Convert left and right views into a frame-sequential video
  4991. ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
  4992. # Convert views into a side-by-side video with the same output resolution as the input
  4993. 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
  4994. @end example
  4995. @section framerate
  4996. Change the frame rate by interpolating new video output frames from the source
  4997. frames.
  4998. This filter is not designed to function correctly with interlaced media. If
  4999. you wish to change the frame rate of interlaced media then you are required
  5000. to deinterlace before this filter and re-interlace after this filter.
  5001. A description of the accepted options follows.
  5002. @table @option
  5003. @item fps
  5004. Specify the output frames per second. This option can also be specified
  5005. as a value alone. The default is @code{50}.
  5006. @item interp_start
  5007. Specify the start of a range where the output frame will be created as a
  5008. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  5009. the default is @code{15}.
  5010. @item interp_end
  5011. Specify the end of a range where the output frame will be created as a
  5012. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  5013. the default is @code{240}.
  5014. @item scene
  5015. Specify the level at which a scene change is detected as a value between
  5016. 0 and 100 to indicate a new scene; a low value reflects a low
  5017. probability for the current frame to introduce a new scene, while a higher
  5018. value means the current frame is more likely to be one.
  5019. The default is @code{7}.
  5020. @item flags
  5021. Specify flags influencing the filter process.
  5022. Available value for @var{flags} is:
  5023. @table @option
  5024. @item scene_change_detect, scd
  5025. Enable scene change detection using the value of the option @var{scene}.
  5026. This flag is enabled by default.
  5027. @end table
  5028. @end table
  5029. @section framestep
  5030. Select one frame every N-th frame.
  5031. This filter accepts the following option:
  5032. @table @option
  5033. @item step
  5034. Select frame after every @code{step} frames.
  5035. Allowed values are positive integers higher than 0. Default value is @code{1}.
  5036. @end table
  5037. @anchor{frei0r}
  5038. @section frei0r
  5039. Apply a frei0r effect to the input video.
  5040. To enable the compilation of this filter, you need to install the frei0r
  5041. header and configure FFmpeg with @code{--enable-frei0r}.
  5042. It accepts the following parameters:
  5043. @table @option
  5044. @item filter_name
  5045. The name of the frei0r effect to load. If the environment variable
  5046. @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
  5047. directories specified by the colon-separated list in @env{FREIOR_PATH}.
  5048. Otherwise, the standard frei0r paths are searched, in this order:
  5049. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  5050. @file{/usr/lib/frei0r-1/}.
  5051. @item filter_params
  5052. A '|'-separated list of parameters to pass to the frei0r effect.
  5053. @end table
  5054. A frei0r effect parameter can be a boolean (its value is either
  5055. "y" or "n"), a double, a color (specified as
  5056. @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
  5057. numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
  5058. section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
  5059. @var{X} and @var{Y} are floating point numbers) and/or a string.
  5060. The number and types of parameters depend on the loaded effect. If an
  5061. effect parameter is not specified, the default value is set.
  5062. @subsection Examples
  5063. @itemize
  5064. @item
  5065. Apply the distort0r effect, setting the first two double parameters:
  5066. @example
  5067. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  5068. @end example
  5069. @item
  5070. Apply the colordistance effect, taking a color as the first parameter:
  5071. @example
  5072. frei0r=colordistance:0.2/0.3/0.4
  5073. frei0r=colordistance:violet
  5074. frei0r=colordistance:0x112233
  5075. @end example
  5076. @item
  5077. Apply the perspective effect, specifying the top left and top right image
  5078. positions:
  5079. @example
  5080. frei0r=perspective:0.2/0.2|0.8/0.2
  5081. @end example
  5082. @end itemize
  5083. For more information, see
  5084. @url{http://frei0r.dyne.org}
  5085. @section fspp
  5086. Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
  5087. It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
  5088. processing filter, one of them is performed once per block, not per pixel.
  5089. This allows for much higher speed.
  5090. The filter accepts the following options:
  5091. @table @option
  5092. @item quality
  5093. Set quality. This option defines the number of levels for averaging. It accepts
  5094. an integer in the range 4-5. Default value is @code{4}.
  5095. @item qp
  5096. Force a constant quantization parameter. It accepts an integer in range 0-63.
  5097. If not set, the filter will use the QP from the video stream (if available).
  5098. @item strength
  5099. Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
  5100. more details but also more artifacts, while higher values make the image smoother
  5101. but also blurrier. Default value is @code{0} − PSNR optimal.
  5102. @item use_bframe_qp
  5103. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  5104. option may cause flicker since the B-Frames have often larger QP. Default is
  5105. @code{0} (not enabled).
  5106. @end table
  5107. @section geq
  5108. The filter accepts the following options:
  5109. @table @option
  5110. @item lum_expr, lum
  5111. Set the luminance expression.
  5112. @item cb_expr, cb
  5113. Set the chrominance blue expression.
  5114. @item cr_expr, cr
  5115. Set the chrominance red expression.
  5116. @item alpha_expr, a
  5117. Set the alpha expression.
  5118. @item red_expr, r
  5119. Set the red expression.
  5120. @item green_expr, g
  5121. Set the green expression.
  5122. @item blue_expr, b
  5123. Set the blue expression.
  5124. @end table
  5125. The colorspace is selected according to the specified options. If one
  5126. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  5127. options is specified, the filter will automatically select a YCbCr
  5128. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  5129. @option{blue_expr} options is specified, it will select an RGB
  5130. colorspace.
  5131. If one of the chrominance expression is not defined, it falls back on the other
  5132. one. If no alpha expression is specified it will evaluate to opaque value.
  5133. If none of chrominance expressions are specified, they will evaluate
  5134. to the luminance expression.
  5135. The expressions can use the following variables and functions:
  5136. @table @option
  5137. @item N
  5138. The sequential number of the filtered frame, starting from @code{0}.
  5139. @item X
  5140. @item Y
  5141. The coordinates of the current sample.
  5142. @item W
  5143. @item H
  5144. The width and height of the image.
  5145. @item SW
  5146. @item SH
  5147. Width and height scale depending on the currently filtered plane. It is the
  5148. ratio between the corresponding luma plane number of pixels and the current
  5149. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  5150. @code{0.5,0.5} for chroma planes.
  5151. @item T
  5152. Time of the current frame, expressed in seconds.
  5153. @item p(x, y)
  5154. Return the value of the pixel at location (@var{x},@var{y}) of the current
  5155. plane.
  5156. @item lum(x, y)
  5157. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  5158. plane.
  5159. @item cb(x, y)
  5160. Return the value of the pixel at location (@var{x},@var{y}) of the
  5161. blue-difference chroma plane. Return 0 if there is no such plane.
  5162. @item cr(x, y)
  5163. Return the value of the pixel at location (@var{x},@var{y}) of the
  5164. red-difference chroma plane. Return 0 if there is no such plane.
  5165. @item r(x, y)
  5166. @item g(x, y)
  5167. @item b(x, y)
  5168. Return the value of the pixel at location (@var{x},@var{y}) of the
  5169. red/green/blue component. Return 0 if there is no such component.
  5170. @item alpha(x, y)
  5171. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  5172. plane. Return 0 if there is no such plane.
  5173. @end table
  5174. For functions, if @var{x} and @var{y} are outside the area, the value will be
  5175. automatically clipped to the closer edge.
  5176. @subsection Examples
  5177. @itemize
  5178. @item
  5179. Flip the image horizontally:
  5180. @example
  5181. geq=p(W-X\,Y)
  5182. @end example
  5183. @item
  5184. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  5185. wavelength of 100 pixels:
  5186. @example
  5187. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  5188. @end example
  5189. @item
  5190. Generate a fancy enigmatic moving light:
  5191. @example
  5192. 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
  5193. @end example
  5194. @item
  5195. Generate a quick emboss effect:
  5196. @example
  5197. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  5198. @end example
  5199. @item
  5200. Modify RGB components depending on pixel position:
  5201. @example
  5202. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  5203. @end example
  5204. @item
  5205. Create a radial gradient that is the same size as the input (also see
  5206. the @ref{vignette} filter):
  5207. @example
  5208. geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
  5209. @end example
  5210. @item
  5211. Create a linear gradient to use as a mask for another filter, then
  5212. compose with @ref{overlay}. In this example the video will gradually
  5213. become more blurry from the top to the bottom of the y-axis as defined
  5214. by the linear gradient:
  5215. @example
  5216. ffmpeg -i input.mp4 -filter_complex "geq=lum=255*(Y/H),format=gray[grad];[0:v]boxblur=4[blur];[blur][grad]alphamerge[alpha];[0:v][alpha]overlay" output.mp4
  5217. @end example
  5218. @end itemize
  5219. @section gradfun
  5220. Fix the banding artifacts that are sometimes introduced into nearly flat
  5221. regions by truncation to 8bit color depth.
  5222. Interpolate the gradients that should go where the bands are, and
  5223. dither them.
  5224. It is designed for playback only. Do not use it prior to
  5225. lossy compression, because compression tends to lose the dither and
  5226. bring back the bands.
  5227. It accepts the following parameters:
  5228. @table @option
  5229. @item strength
  5230. The maximum amount by which the filter will change any one pixel. This is also
  5231. the threshold for detecting nearly flat regions. Acceptable values range from
  5232. .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
  5233. valid range.
  5234. @item radius
  5235. The neighborhood to fit the gradient to. A larger radius makes for smoother
  5236. gradients, but also prevents the filter from modifying the pixels near detailed
  5237. regions. Acceptable values are 8-32; the default value is 16. Out-of-range
  5238. values will be clipped to the valid range.
  5239. @end table
  5240. Alternatively, the options can be specified as a flat string:
  5241. @var{strength}[:@var{radius}]
  5242. @subsection Examples
  5243. @itemize
  5244. @item
  5245. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  5246. @example
  5247. gradfun=3.5:8
  5248. @end example
  5249. @item
  5250. Specify radius, omitting the strength (which will fall-back to the default
  5251. value):
  5252. @example
  5253. gradfun=radius=8
  5254. @end example
  5255. @end itemize
  5256. @anchor{haldclut}
  5257. @section haldclut
  5258. Apply a Hald CLUT to a video stream.
  5259. First input is the video stream to process, and second one is the Hald CLUT.
  5260. The Hald CLUT input can be a simple picture or a complete video stream.
  5261. The filter accepts the following options:
  5262. @table @option
  5263. @item shortest
  5264. Force termination when the shortest input terminates. Default is @code{0}.
  5265. @item repeatlast
  5266. Continue applying the last CLUT after the end of the stream. A value of
  5267. @code{0} disable the filter after the last frame of the CLUT is reached.
  5268. Default is @code{1}.
  5269. @end table
  5270. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  5271. filters share the same internals).
  5272. More information about the Hald CLUT can be found on Eskil Steenberg's website
  5273. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  5274. @subsection Workflow examples
  5275. @subsubsection Hald CLUT video stream
  5276. Generate an identity Hald CLUT stream altered with various effects:
  5277. @example
  5278. 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
  5279. @end example
  5280. Note: make sure you use a lossless codec.
  5281. Then use it with @code{haldclut} to apply it on some random stream:
  5282. @example
  5283. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  5284. @end example
  5285. The Hald CLUT will be applied to the 10 first seconds (duration of
  5286. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  5287. to the remaining frames of the @code{mandelbrot} stream.
  5288. @subsubsection Hald CLUT with preview
  5289. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  5290. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  5291. biggest possible square starting at the top left of the picture. The remaining
  5292. padding pixels (bottom or right) will be ignored. This area can be used to add
  5293. a preview of the Hald CLUT.
  5294. Typically, the following generated Hald CLUT will be supported by the
  5295. @code{haldclut} filter:
  5296. @example
  5297. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  5298. pad=iw+320 [padded_clut];
  5299. smptebars=s=320x256, split [a][b];
  5300. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  5301. [main][b] overlay=W-320" -frames:v 1 clut.png
  5302. @end example
  5303. It contains the original and a preview of the effect of the CLUT: SMPTE color
  5304. bars are displayed on the right-top, and below the same color bars processed by
  5305. the color changes.
  5306. Then, the effect of this Hald CLUT can be visualized with:
  5307. @example
  5308. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  5309. @end example
  5310. @section hflip
  5311. Flip the input video horizontally.
  5312. For example, to horizontally flip the input video with @command{ffmpeg}:
  5313. @example
  5314. ffmpeg -i in.avi -vf "hflip" out.avi
  5315. @end example
  5316. @section histeq
  5317. This filter applies a global color histogram equalization on a
  5318. per-frame basis.
  5319. It can be used to correct video that has a compressed range of pixel
  5320. intensities. The filter redistributes the pixel intensities to
  5321. equalize their distribution across the intensity range. It may be
  5322. viewed as an "automatically adjusting contrast filter". This filter is
  5323. useful only for correcting degraded or poorly captured source
  5324. video.
  5325. The filter accepts the following options:
  5326. @table @option
  5327. @item strength
  5328. Determine the amount of equalization to be applied. As the strength
  5329. is reduced, the distribution of pixel intensities more-and-more
  5330. approaches that of the input frame. The value must be a float number
  5331. in the range [0,1] and defaults to 0.200.
  5332. @item intensity
  5333. Set the maximum intensity that can generated and scale the output
  5334. values appropriately. The strength should be set as desired and then
  5335. the intensity can be limited if needed to avoid washing-out. The value
  5336. must be a float number in the range [0,1] and defaults to 0.210.
  5337. @item antibanding
  5338. Set the antibanding level. If enabled the filter will randomly vary
  5339. the luminance of output pixels by a small amount to avoid banding of
  5340. the histogram. Possible values are @code{none}, @code{weak} or
  5341. @code{strong}. It defaults to @code{none}.
  5342. @end table
  5343. @section histogram
  5344. Compute and draw a color distribution histogram for the input video.
  5345. The computed histogram is a representation of the color component
  5346. distribution in an image.
  5347. The filter accepts the following options:
  5348. @table @option
  5349. @item mode
  5350. Set histogram mode.
  5351. It accepts the following values:
  5352. @table @samp
  5353. @item levels
  5354. Standard histogram that displays the color components distribution in an
  5355. image. Displays color graph for each color component. Shows distribution of
  5356. the Y, U, V, A or R, G, B components, depending on input format, in the
  5357. current frame. Below each graph a color component scale meter is shown.
  5358. @item color
  5359. Displays chroma values (U/V color placement) in a two dimensional
  5360. graph (which is called a vectorscope). The brighter a pixel in the
  5361. vectorscope, the more pixels of the input frame correspond to that pixel
  5362. (i.e., more pixels have this chroma value). The V component is displayed on
  5363. the horizontal (X) axis, with the leftmost side being V = 0 and the rightmost
  5364. side being V = 255. The U component is displayed on the vertical (Y) axis,
  5365. with the top representing U = 0 and the bottom representing U = 255.
  5366. The position of a white pixel in the graph corresponds to the chroma value of
  5367. a pixel of the input clip. The graph can therefore be used to read the hue
  5368. (color flavor) and the saturation (the dominance of the hue in the color). As
  5369. the hue of a color changes, it moves around the square. At the center of the
  5370. square the saturation is zero, which means that the corresponding pixel has no
  5371. color. If the amount of a specific color is increased (while leaving the other
  5372. colors unchanged) the saturation increases, and the indicator moves towards
  5373. the edge of the square.
  5374. @item color2
  5375. Chroma values in vectorscope, similar as @code{color} but actual chroma values
  5376. are displayed.
  5377. @item waveform
  5378. Per row/column color component graph. In row mode, the graph on the left side
  5379. represents color component value 0 and the right side represents value = 255.
  5380. In column mode, the top side represents color component value = 0 and bottom
  5381. side represents value = 255.
  5382. @end table
  5383. Default value is @code{levels}.
  5384. @item level_height
  5385. Set height of level in @code{levels}. Default value is @code{200}.
  5386. Allowed range is [50, 2048].
  5387. @item scale_height
  5388. Set height of color scale in @code{levels}. Default value is @code{12}.
  5389. Allowed range is [0, 40].
  5390. @item step
  5391. Set step for @code{waveform} mode. Smaller values are useful to find out how
  5392. many values of the same luminance are distributed across input rows/columns.
  5393. Default value is @code{10}. Allowed range is [1, 255].
  5394. @item waveform_mode
  5395. Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
  5396. Default is @code{row}.
  5397. @item waveform_mirror
  5398. Set mirroring mode for @code{waveform}. @code{0} means unmirrored, @code{1}
  5399. means mirrored. In mirrored mode, higher values will be represented on the left
  5400. side for @code{row} mode and at the top for @code{column} mode. Default is
  5401. @code{0} (unmirrored).
  5402. @item display_mode
  5403. Set display mode for @code{waveform} and @code{levels}.
  5404. It accepts the following values:
  5405. @table @samp
  5406. @item parade
  5407. Display separate graph for the color components side by side in
  5408. @code{row} waveform mode or one below the other in @code{column} waveform mode
  5409. for @code{waveform} histogram mode. For @code{levels} histogram mode,
  5410. per color component graphs are placed below each other.
  5411. Using this display mode in @code{waveform} histogram mode makes it easy to
  5412. spot color casts in the highlights and shadows of an image, by comparing the
  5413. contours of the top and the bottom graphs of each waveform. Since whites,
  5414. grays, and blacks are characterized by exactly equal amounts of red, green,
  5415. and blue, neutral areas of the picture should display three waveforms of
  5416. roughly equal width/height. If not, the correction is easy to perform by
  5417. making level adjustments the three waveforms.
  5418. @item overlay
  5419. Presents information identical to that in the @code{parade}, except
  5420. that the graphs representing color components are superimposed directly
  5421. over one another.
  5422. This display mode in @code{waveform} histogram mode makes it easier to spot
  5423. relative differences or similarities in overlapping areas of the color
  5424. components that are supposed to be identical, such as neutral whites, grays,
  5425. or blacks.
  5426. @end table
  5427. Default is @code{parade}.
  5428. @item levels_mode
  5429. Set mode for @code{levels}. Can be either @code{linear}, or @code{logarithmic}.
  5430. Default is @code{linear}.
  5431. @item components
  5432. Set what color components to display for mode @code{levels}.
  5433. Default is @code{7}.
  5434. @end table
  5435. @subsection Examples
  5436. @itemize
  5437. @item
  5438. Calculate and draw histogram:
  5439. @example
  5440. ffplay -i input -vf histogram
  5441. @end example
  5442. @end itemize
  5443. @anchor{hqdn3d}
  5444. @section hqdn3d
  5445. This is a high precision/quality 3d denoise filter. It aims to reduce
  5446. image noise, producing smooth images and making still images really
  5447. still. It should enhance compressibility.
  5448. It accepts the following optional parameters:
  5449. @table @option
  5450. @item luma_spatial
  5451. A non-negative floating point number which specifies spatial luma strength.
  5452. It defaults to 4.0.
  5453. @item chroma_spatial
  5454. A non-negative floating point number which specifies spatial chroma strength.
  5455. It defaults to 3.0*@var{luma_spatial}/4.0.
  5456. @item luma_tmp
  5457. A floating point number which specifies luma temporal strength. It defaults to
  5458. 6.0*@var{luma_spatial}/4.0.
  5459. @item chroma_tmp
  5460. A floating point number which specifies chroma temporal strength. It defaults to
  5461. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
  5462. @end table
  5463. @section hqx
  5464. Apply a high-quality magnification filter designed for pixel art. This filter
  5465. was originally created by Maxim Stepin.
  5466. It accepts the following option:
  5467. @table @option
  5468. @item n
  5469. Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
  5470. @code{hq3x} and @code{4} for @code{hq4x}.
  5471. Default is @code{3}.
  5472. @end table
  5473. @section hstack
  5474. Stack input videos horizontally.
  5475. All streams must be of same pixel format and of same height.
  5476. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  5477. to create same output.
  5478. The filter accept the following option:
  5479. @table @option
  5480. @item nb_inputs
  5481. Set number of input streams. Default is 2.
  5482. @end table
  5483. @section hue
  5484. Modify the hue and/or the saturation of the input.
  5485. It accepts the following parameters:
  5486. @table @option
  5487. @item h
  5488. Specify the hue angle as a number of degrees. It accepts an expression,
  5489. and defaults to "0".
  5490. @item s
  5491. Specify the saturation in the [-10,10] range. It accepts an expression and
  5492. defaults to "1".
  5493. @item H
  5494. Specify the hue angle as a number of radians. It accepts an
  5495. expression, and defaults to "0".
  5496. @item b
  5497. Specify the brightness in the [-10,10] range. It accepts an expression and
  5498. defaults to "0".
  5499. @end table
  5500. @option{h} and @option{H} are mutually exclusive, and can't be
  5501. specified at the same time.
  5502. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  5503. expressions containing the following constants:
  5504. @table @option
  5505. @item n
  5506. frame count of the input frame starting from 0
  5507. @item pts
  5508. presentation timestamp of the input frame expressed in time base units
  5509. @item r
  5510. frame rate of the input video, NAN if the input frame rate is unknown
  5511. @item t
  5512. timestamp expressed in seconds, NAN if the input timestamp is unknown
  5513. @item tb
  5514. time base of the input video
  5515. @end table
  5516. @subsection Examples
  5517. @itemize
  5518. @item
  5519. Set the hue to 90 degrees and the saturation to 1.0:
  5520. @example
  5521. hue=h=90:s=1
  5522. @end example
  5523. @item
  5524. Same command but expressing the hue in radians:
  5525. @example
  5526. hue=H=PI/2:s=1
  5527. @end example
  5528. @item
  5529. Rotate hue and make the saturation swing between 0
  5530. and 2 over a period of 1 second:
  5531. @example
  5532. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  5533. @end example
  5534. @item
  5535. Apply a 3 seconds saturation fade-in effect starting at 0:
  5536. @example
  5537. hue="s=min(t/3\,1)"
  5538. @end example
  5539. The general fade-in expression can be written as:
  5540. @example
  5541. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  5542. @end example
  5543. @item
  5544. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  5545. @example
  5546. hue="s=max(0\, min(1\, (8-t)/3))"
  5547. @end example
  5548. The general fade-out expression can be written as:
  5549. @example
  5550. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  5551. @end example
  5552. @end itemize
  5553. @subsection Commands
  5554. This filter supports the following commands:
  5555. @table @option
  5556. @item b
  5557. @item s
  5558. @item h
  5559. @item H
  5560. Modify the hue and/or the saturation and/or brightness of the input video.
  5561. The command accepts the same syntax of the corresponding option.
  5562. If the specified expression is not valid, it is kept at its current
  5563. value.
  5564. @end table
  5565. @section idet
  5566. Detect video interlacing type.
  5567. This filter tries to detect if the input frames as interlaced, progressive,
  5568. top or bottom field first. It will also try and detect fields that are
  5569. repeated between adjacent frames (a sign of telecine).
  5570. Single frame detection considers only immediately adjacent frames when classifying each frame.
  5571. Multiple frame detection incorporates the classification history of previous frames.
  5572. The filter will log these metadata values:
  5573. @table @option
  5574. @item single.current_frame
  5575. Detected type of current frame using single-frame detection. One of:
  5576. ``tff'' (top field first), ``bff'' (bottom field first),
  5577. ``progressive'', or ``undetermined''
  5578. @item single.tff
  5579. Cumulative number of frames detected as top field first using single-frame detection.
  5580. @item multiple.tff
  5581. Cumulative number of frames detected as top field first using multiple-frame detection.
  5582. @item single.bff
  5583. Cumulative number of frames detected as bottom field first using single-frame detection.
  5584. @item multiple.current_frame
  5585. Detected type of current frame using multiple-frame detection. One of:
  5586. ``tff'' (top field first), ``bff'' (bottom field first),
  5587. ``progressive'', or ``undetermined''
  5588. @item multiple.bff
  5589. Cumulative number of frames detected as bottom field first using multiple-frame detection.
  5590. @item single.progressive
  5591. Cumulative number of frames detected as progressive using single-frame detection.
  5592. @item multiple.progressive
  5593. Cumulative number of frames detected as progressive using multiple-frame detection.
  5594. @item single.undetermined
  5595. Cumulative number of frames that could not be classified using single-frame detection.
  5596. @item multiple.undetermined
  5597. Cumulative number of frames that could not be classified using multiple-frame detection.
  5598. @item repeated.current_frame
  5599. Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
  5600. @item repeated.neither
  5601. Cumulative number of frames with no repeated field.
  5602. @item repeated.top
  5603. Cumulative number of frames with the top field repeated from the previous frame's top field.
  5604. @item repeated.bottom
  5605. Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
  5606. @end table
  5607. The filter accepts the following options:
  5608. @table @option
  5609. @item intl_thres
  5610. Set interlacing threshold.
  5611. @item prog_thres
  5612. Set progressive threshold.
  5613. @item repeat_thres
  5614. Threshold for repeated field detection.
  5615. @item half_life
  5616. Number of frames after which a given frame's contribution to the
  5617. statistics is halved (i.e., it contributes only 0.5 to it's
  5618. classification). The default of 0 means that all frames seen are given
  5619. full weight of 1.0 forever.
  5620. @item analyze_interlaced_flag
  5621. When this is not 0 then idet will use the specified number of frames to determine
  5622. if the interlaced flag is accurate, it will not count undetermined frames.
  5623. If the flag is found to be accurate it will be used without any further
  5624. computations, if it is found to be inaccurate it will be cleared without any
  5625. further computations. This allows inserting the idet filter as a low computational
  5626. method to clean up the interlaced flag
  5627. @end table
  5628. @section il
  5629. Deinterleave or interleave fields.
  5630. This filter allows one to process interlaced images fields without
  5631. deinterlacing them. Deinterleaving splits the input frame into 2
  5632. fields (so called half pictures). Odd lines are moved to the top
  5633. half of the output image, even lines to the bottom half.
  5634. You can process (filter) them independently and then re-interleave them.
  5635. The filter accepts the following options:
  5636. @table @option
  5637. @item luma_mode, l
  5638. @item chroma_mode, c
  5639. @item alpha_mode, a
  5640. Available values for @var{luma_mode}, @var{chroma_mode} and
  5641. @var{alpha_mode} are:
  5642. @table @samp
  5643. @item none
  5644. Do nothing.
  5645. @item deinterleave, d
  5646. Deinterleave fields, placing one above the other.
  5647. @item interleave, i
  5648. Interleave fields. Reverse the effect of deinterleaving.
  5649. @end table
  5650. Default value is @code{none}.
  5651. @item luma_swap, ls
  5652. @item chroma_swap, cs
  5653. @item alpha_swap, as
  5654. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  5655. @end table
  5656. @section inflate
  5657. Apply inflate effect to the video.
  5658. This filter replaces the pixel by the local(3x3) average by taking into account
  5659. only values higher than the pixel.
  5660. It accepts the following options:
  5661. @table @option
  5662. @item threshold0
  5663. @item threshold1
  5664. @item threshold2
  5665. @item threshold3
  5666. Limit the maximum change for each plane, default is 65535.
  5667. If 0, plane will remain unchanged.
  5668. @end table
  5669. @section interlace
  5670. Simple interlacing filter from progressive contents. This interleaves upper (or
  5671. lower) lines from odd frames with lower (or upper) lines from even frames,
  5672. halving the frame rate and preserving image height.
  5673. @example
  5674. Original Original New Frame
  5675. Frame 'j' Frame 'j+1' (tff)
  5676. ========== =========== ==================
  5677. Line 0 --------------------> Frame 'j' Line 0
  5678. Line 1 Line 1 ----> Frame 'j+1' Line 1
  5679. Line 2 ---------------------> Frame 'j' Line 2
  5680. Line 3 Line 3 ----> Frame 'j+1' Line 3
  5681. ... ... ...
  5682. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  5683. @end example
  5684. It accepts the following optional parameters:
  5685. @table @option
  5686. @item scan
  5687. This determines whether the interlaced frame is taken from the even
  5688. (tff - default) or odd (bff) lines of the progressive frame.
  5689. @item lowpass
  5690. Enable (default) or disable the vertical lowpass filter to avoid twitter
  5691. interlacing and reduce moire patterns.
  5692. @end table
  5693. @section kerndeint
  5694. Deinterlace input video by applying Donald Graft's adaptive kernel
  5695. deinterling. Work on interlaced parts of a video to produce
  5696. progressive frames.
  5697. The description of the accepted parameters follows.
  5698. @table @option
  5699. @item thresh
  5700. Set the threshold which affects the filter's tolerance when
  5701. determining if a pixel line must be processed. It must be an integer
  5702. in the range [0,255] and defaults to 10. A value of 0 will result in
  5703. applying the process on every pixels.
  5704. @item map
  5705. Paint pixels exceeding the threshold value to white if set to 1.
  5706. Default is 0.
  5707. @item order
  5708. Set the fields order. Swap fields if set to 1, leave fields alone if
  5709. 0. Default is 0.
  5710. @item sharp
  5711. Enable additional sharpening if set to 1. Default is 0.
  5712. @item twoway
  5713. Enable twoway sharpening if set to 1. Default is 0.
  5714. @end table
  5715. @subsection Examples
  5716. @itemize
  5717. @item
  5718. Apply default values:
  5719. @example
  5720. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  5721. @end example
  5722. @item
  5723. Enable additional sharpening:
  5724. @example
  5725. kerndeint=sharp=1
  5726. @end example
  5727. @item
  5728. Paint processed pixels in white:
  5729. @example
  5730. kerndeint=map=1
  5731. @end example
  5732. @end itemize
  5733. @section lenscorrection
  5734. Correct radial lens distortion
  5735. This filter can be used to correct for radial distortion as can result from the use
  5736. of wide angle lenses, and thereby re-rectify the image. To find the right parameters
  5737. one can use tools available for example as part of opencv or simply trial-and-error.
  5738. To use opencv use the calibration sample (under samples/cpp) from the opencv sources
  5739. and extract the k1 and k2 coefficients from the resulting matrix.
  5740. Note that effectively the same filter is available in the open-source tools Krita and
  5741. Digikam from the KDE project.
  5742. In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
  5743. this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
  5744. brightness distribution, so you may want to use both filters together in certain
  5745. cases, though you will have to take care of ordering, i.e. whether vignetting should
  5746. be applied before or after lens correction.
  5747. @subsection Options
  5748. The filter accepts the following options:
  5749. @table @option
  5750. @item cx
  5751. Relative x-coordinate of the focal point of the image, and thereby the center of the
  5752. distortion. This value has a range [0,1] and is expressed as fractions of the image
  5753. width.
  5754. @item cy
  5755. Relative y-coordinate of the focal point of the image, and thereby the center of the
  5756. distortion. This value has a range [0,1] and is expressed as fractions of the image
  5757. height.
  5758. @item k1
  5759. Coefficient of the quadratic correction term. 0.5 means no correction.
  5760. @item k2
  5761. Coefficient of the double quadratic correction term. 0.5 means no correction.
  5762. @end table
  5763. The formula that generates the correction is:
  5764. @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)
  5765. where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
  5766. distances from the focal point in the source and target images, respectively.
  5767. @anchor{lut3d}
  5768. @section lut3d
  5769. Apply a 3D LUT to an input video.
  5770. The filter accepts the following options:
  5771. @table @option
  5772. @item file
  5773. Set the 3D LUT file name.
  5774. Currently supported formats:
  5775. @table @samp
  5776. @item 3dl
  5777. AfterEffects
  5778. @item cube
  5779. Iridas
  5780. @item dat
  5781. DaVinci
  5782. @item m3d
  5783. Pandora
  5784. @end table
  5785. @item interp
  5786. Select interpolation mode.
  5787. Available values are:
  5788. @table @samp
  5789. @item nearest
  5790. Use values from the nearest defined point.
  5791. @item trilinear
  5792. Interpolate values using the 8 points defining a cube.
  5793. @item tetrahedral
  5794. Interpolate values using a tetrahedron.
  5795. @end table
  5796. @end table
  5797. @section lut, lutrgb, lutyuv
  5798. Compute a look-up table for binding each pixel component input value
  5799. to an output value, and apply it to the input video.
  5800. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  5801. to an RGB input video.
  5802. These filters accept the following parameters:
  5803. @table @option
  5804. @item c0
  5805. set first pixel component expression
  5806. @item c1
  5807. set second pixel component expression
  5808. @item c2
  5809. set third pixel component expression
  5810. @item c3
  5811. set fourth pixel component expression, corresponds to the alpha component
  5812. @item r
  5813. set red component expression
  5814. @item g
  5815. set green component expression
  5816. @item b
  5817. set blue component expression
  5818. @item a
  5819. alpha component expression
  5820. @item y
  5821. set Y/luminance component expression
  5822. @item u
  5823. set U/Cb component expression
  5824. @item v
  5825. set V/Cr component expression
  5826. @end table
  5827. Each of them specifies the expression to use for computing the lookup table for
  5828. the corresponding pixel component values.
  5829. The exact component associated to each of the @var{c*} options depends on the
  5830. format in input.
  5831. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  5832. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  5833. The expressions can contain the following constants and functions:
  5834. @table @option
  5835. @item w
  5836. @item h
  5837. The input width and height.
  5838. @item val
  5839. The input value for the pixel component.
  5840. @item clipval
  5841. The input value, clipped to the @var{minval}-@var{maxval} range.
  5842. @item maxval
  5843. The maximum value for the pixel component.
  5844. @item minval
  5845. The minimum value for the pixel component.
  5846. @item negval
  5847. The negated value for the pixel component value, clipped to the
  5848. @var{minval}-@var{maxval} range; it corresponds to the expression
  5849. "maxval-clipval+minval".
  5850. @item clip(val)
  5851. The computed value in @var{val}, clipped to the
  5852. @var{minval}-@var{maxval} range.
  5853. @item gammaval(gamma)
  5854. The computed gamma correction value of the pixel component value,
  5855. clipped to the @var{minval}-@var{maxval} range. It corresponds to the
  5856. expression
  5857. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  5858. @end table
  5859. All expressions default to "val".
  5860. @subsection Examples
  5861. @itemize
  5862. @item
  5863. Negate input video:
  5864. @example
  5865. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  5866. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  5867. @end example
  5868. The above is the same as:
  5869. @example
  5870. lutrgb="r=negval:g=negval:b=negval"
  5871. lutyuv="y=negval:u=negval:v=negval"
  5872. @end example
  5873. @item
  5874. Negate luminance:
  5875. @example
  5876. lutyuv=y=negval
  5877. @end example
  5878. @item
  5879. Remove chroma components, turning the video into a graytone image:
  5880. @example
  5881. lutyuv="u=128:v=128"
  5882. @end example
  5883. @item
  5884. Apply a luma burning effect:
  5885. @example
  5886. lutyuv="y=2*val"
  5887. @end example
  5888. @item
  5889. Remove green and blue components:
  5890. @example
  5891. lutrgb="g=0:b=0"
  5892. @end example
  5893. @item
  5894. Set a constant alpha channel value on input:
  5895. @example
  5896. format=rgba,lutrgb=a="maxval-minval/2"
  5897. @end example
  5898. @item
  5899. Correct luminance gamma by a factor of 0.5:
  5900. @example
  5901. lutyuv=y=gammaval(0.5)
  5902. @end example
  5903. @item
  5904. Discard least significant bits of luma:
  5905. @example
  5906. lutyuv=y='bitand(val, 128+64+32)'
  5907. @end example
  5908. @end itemize
  5909. @section maskedmerge
  5910. Merge the first input stream with the second input stream using per pixel
  5911. weights in the third input stream.
  5912. A value of 0 in the third stream pixel component means that pixel component
  5913. from first stream is returned unchanged, while maximum value (eg. 255 for
  5914. 8-bit videos) means that pixel component from second stream is returned
  5915. unchanged. Intermediate values define the amount of merging between both
  5916. input stream's pixel components.
  5917. This filter accepts the following options:
  5918. @table @option
  5919. @item planes
  5920. Set which planes will be processed as bitmap, unprocessed planes will be
  5921. copied from first stream.
  5922. By default value 0xf, all planes will be processed.
  5923. @end table
  5924. @section mcdeint
  5925. Apply motion-compensation deinterlacing.
  5926. It needs one field per frame as input and must thus be used together
  5927. with yadif=1/3 or equivalent.
  5928. This filter accepts the following options:
  5929. @table @option
  5930. @item mode
  5931. Set the deinterlacing mode.
  5932. It accepts one of the following values:
  5933. @table @samp
  5934. @item fast
  5935. @item medium
  5936. @item slow
  5937. use iterative motion estimation
  5938. @item extra_slow
  5939. like @samp{slow}, but use multiple reference frames.
  5940. @end table
  5941. Default value is @samp{fast}.
  5942. @item parity
  5943. Set the picture field parity assumed for the input video. It must be
  5944. one of the following values:
  5945. @table @samp
  5946. @item 0, tff
  5947. assume top field first
  5948. @item 1, bff
  5949. assume bottom field first
  5950. @end table
  5951. Default value is @samp{bff}.
  5952. @item qp
  5953. Set per-block quantization parameter (QP) used by the internal
  5954. encoder.
  5955. Higher values should result in a smoother motion vector field but less
  5956. optimal individual vectors. Default value is 1.
  5957. @end table
  5958. @section mergeplanes
  5959. Merge color channel components from several video streams.
  5960. The filter accepts up to 4 input streams, and merge selected input
  5961. planes to the output video.
  5962. This filter accepts the following options:
  5963. @table @option
  5964. @item mapping
  5965. Set input to output plane mapping. Default is @code{0}.
  5966. The mappings is specified as a bitmap. It should be specified as a
  5967. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  5968. mapping for the first plane of the output stream. 'A' sets the number of
  5969. the input stream to use (from 0 to 3), and 'a' the plane number of the
  5970. corresponding input to use (from 0 to 3). The rest of the mappings is
  5971. similar, 'Bb' describes the mapping for the output stream second
  5972. plane, 'Cc' describes the mapping for the output stream third plane and
  5973. 'Dd' describes the mapping for the output stream fourth plane.
  5974. @item format
  5975. Set output pixel format. Default is @code{yuva444p}.
  5976. @end table
  5977. @subsection Examples
  5978. @itemize
  5979. @item
  5980. Merge three gray video streams of same width and height into single video stream:
  5981. @example
  5982. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  5983. @end example
  5984. @item
  5985. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  5986. @example
  5987. [a0][a1]mergeplanes=0x00010210:yuva444p
  5988. @end example
  5989. @item
  5990. Swap Y and A plane in yuva444p stream:
  5991. @example
  5992. format=yuva444p,mergeplanes=0x03010200:yuva444p
  5993. @end example
  5994. @item
  5995. Swap U and V plane in yuv420p stream:
  5996. @example
  5997. format=yuv420p,mergeplanes=0x000201:yuv420p
  5998. @end example
  5999. @item
  6000. Cast a rgb24 clip to yuv444p:
  6001. @example
  6002. format=rgb24,mergeplanes=0x000102:yuv444p
  6003. @end example
  6004. @end itemize
  6005. @section mpdecimate
  6006. Drop frames that do not differ greatly from the previous frame in
  6007. order to reduce frame rate.
  6008. The main use of this filter is for very-low-bitrate encoding
  6009. (e.g. streaming over dialup modem), but it could in theory be used for
  6010. fixing movies that were inverse-telecined incorrectly.
  6011. A description of the accepted options follows.
  6012. @table @option
  6013. @item max
  6014. Set the maximum number of consecutive frames which can be dropped (if
  6015. positive), or the minimum interval between dropped frames (if
  6016. negative). If the value is 0, the frame is dropped unregarding the
  6017. number of previous sequentially dropped frames.
  6018. Default value is 0.
  6019. @item hi
  6020. @item lo
  6021. @item frac
  6022. Set the dropping threshold values.
  6023. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  6024. represent actual pixel value differences, so a threshold of 64
  6025. corresponds to 1 unit of difference for each pixel, or the same spread
  6026. out differently over the block.
  6027. A frame is a candidate for dropping if no 8x8 blocks differ by more
  6028. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  6029. meaning the whole image) differ by more than a threshold of @option{lo}.
  6030. Default value for @option{hi} is 64*12, default value for @option{lo} is
  6031. 64*5, and default value for @option{frac} is 0.33.
  6032. @end table
  6033. @section negate
  6034. Negate input video.
  6035. It accepts an integer in input; if non-zero it negates the
  6036. alpha component (if available). The default value in input is 0.
  6037. @section noformat
  6038. Force libavfilter not to use any of the specified pixel formats for the
  6039. input to the next filter.
  6040. It accepts the following parameters:
  6041. @table @option
  6042. @item pix_fmts
  6043. A '|'-separated list of pixel format names, such as
  6044. apix_fmts=yuv420p|monow|rgb24".
  6045. @end table
  6046. @subsection Examples
  6047. @itemize
  6048. @item
  6049. Force libavfilter to use a format different from @var{yuv420p} for the
  6050. input to the vflip filter:
  6051. @example
  6052. noformat=pix_fmts=yuv420p,vflip
  6053. @end example
  6054. @item
  6055. Convert the input video to any of the formats not contained in the list:
  6056. @example
  6057. noformat=yuv420p|yuv444p|yuv410p
  6058. @end example
  6059. @end itemize
  6060. @section noise
  6061. Add noise on video input frame.
  6062. The filter accepts the following options:
  6063. @table @option
  6064. @item all_seed
  6065. @item c0_seed
  6066. @item c1_seed
  6067. @item c2_seed
  6068. @item c3_seed
  6069. Set noise seed for specific pixel component or all pixel components in case
  6070. of @var{all_seed}. Default value is @code{123457}.
  6071. @item all_strength, alls
  6072. @item c0_strength, c0s
  6073. @item c1_strength, c1s
  6074. @item c2_strength, c2s
  6075. @item c3_strength, c3s
  6076. Set noise strength for specific pixel component or all pixel components in case
  6077. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  6078. @item all_flags, allf
  6079. @item c0_flags, c0f
  6080. @item c1_flags, c1f
  6081. @item c2_flags, c2f
  6082. @item c3_flags, c3f
  6083. Set pixel component flags or set flags for all components if @var{all_flags}.
  6084. Available values for component flags are:
  6085. @table @samp
  6086. @item a
  6087. averaged temporal noise (smoother)
  6088. @item p
  6089. mix random noise with a (semi)regular pattern
  6090. @item t
  6091. temporal noise (noise pattern changes between frames)
  6092. @item u
  6093. uniform noise (gaussian otherwise)
  6094. @end table
  6095. @end table
  6096. @subsection Examples
  6097. Add temporal and uniform noise to input video:
  6098. @example
  6099. noise=alls=20:allf=t+u
  6100. @end example
  6101. @section null
  6102. Pass the video source unchanged to the output.
  6103. @section ocr
  6104. Optical Character Recognition
  6105. This filter uses Tesseract for optical character recognition.
  6106. It accepts the following options:
  6107. @table @option
  6108. @item datapath
  6109. Set datapath to tesseract data. Default is to use whatever was
  6110. set at installation.
  6111. @item language
  6112. Set language, default is "eng".
  6113. @item whitelist
  6114. Set character whitelist.
  6115. @item blacklist
  6116. Set character blacklist.
  6117. @end table
  6118. The filter exports recognized text as the frame metadata @code{lavfi.ocr.text}.
  6119. @section ocv
  6120. Apply a video transform using libopencv.
  6121. To enable this filter, install the libopencv library and headers and
  6122. configure FFmpeg with @code{--enable-libopencv}.
  6123. It accepts the following parameters:
  6124. @table @option
  6125. @item filter_name
  6126. The name of the libopencv filter to apply.
  6127. @item filter_params
  6128. The parameters to pass to the libopencv filter. If not specified, the default
  6129. values are assumed.
  6130. @end table
  6131. Refer to the official libopencv documentation for more precise
  6132. information:
  6133. @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
  6134. Several libopencv filters are supported; see the following subsections.
  6135. @anchor{dilate}
  6136. @subsection dilate
  6137. Dilate an image by using a specific structuring element.
  6138. It corresponds to the libopencv function @code{cvDilate}.
  6139. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  6140. @var{struct_el} represents a structuring element, and has the syntax:
  6141. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  6142. @var{cols} and @var{rows} represent the number of columns and rows of
  6143. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  6144. point, and @var{shape} the shape for the structuring element. @var{shape}
  6145. must be "rect", "cross", "ellipse", or "custom".
  6146. If the value for @var{shape} is "custom", it must be followed by a
  6147. string of the form "=@var{filename}". The file with name
  6148. @var{filename} is assumed to represent a binary image, with each
  6149. printable character corresponding to a bright pixel. When a custom
  6150. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  6151. or columns and rows of the read file are assumed instead.
  6152. The default value for @var{struct_el} is "3x3+0x0/rect".
  6153. @var{nb_iterations} specifies the number of times the transform is
  6154. applied to the image, and defaults to 1.
  6155. Some examples:
  6156. @example
  6157. # Use the default values
  6158. ocv=dilate
  6159. # Dilate using a structuring element with a 5x5 cross, iterating two times
  6160. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  6161. # Read the shape from the file diamond.shape, iterating two times.
  6162. # The file diamond.shape may contain a pattern of characters like this
  6163. # *
  6164. # ***
  6165. # *****
  6166. # ***
  6167. # *
  6168. # The specified columns and rows are ignored
  6169. # but the anchor point coordinates are not
  6170. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  6171. @end example
  6172. @subsection erode
  6173. Erode an image by using a specific structuring element.
  6174. It corresponds to the libopencv function @code{cvErode}.
  6175. It accepts the parameters: @var{struct_el}:@var{nb_iterations},
  6176. with the same syntax and semantics as the @ref{dilate} filter.
  6177. @subsection smooth
  6178. Smooth the input video.
  6179. The filter takes the following parameters:
  6180. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  6181. @var{type} is the type of smooth filter to apply, and must be one of
  6182. the following values: "blur", "blur_no_scale", "median", "gaussian",
  6183. or "bilateral". The default value is "gaussian".
  6184. The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
  6185. depend on the smooth type. @var{param1} and
  6186. @var{param2} accept integer positive values or 0. @var{param3} and
  6187. @var{param4} accept floating point values.
  6188. The default value for @var{param1} is 3. The default value for the
  6189. other parameters is 0.
  6190. These parameters correspond to the parameters assigned to the
  6191. libopencv function @code{cvSmooth}.
  6192. @anchor{overlay}
  6193. @section overlay
  6194. Overlay one video on top of another.
  6195. It takes two inputs and has one output. The first input is the "main"
  6196. video on which the second input is overlaid.
  6197. It accepts the following parameters:
  6198. A description of the accepted options follows.
  6199. @table @option
  6200. @item x
  6201. @item y
  6202. Set the expression for the x and y coordinates of the overlaid video
  6203. on the main video. Default value is "0" for both expressions. In case
  6204. the expression is invalid, it is set to a huge value (meaning that the
  6205. overlay will not be displayed within the output visible area).
  6206. @item eof_action
  6207. The action to take when EOF is encountered on the secondary input; it accepts
  6208. one of the following values:
  6209. @table @option
  6210. @item repeat
  6211. Repeat the last frame (the default).
  6212. @item endall
  6213. End both streams.
  6214. @item pass
  6215. Pass the main input through.
  6216. @end table
  6217. @item eval
  6218. Set when the expressions for @option{x}, and @option{y} are evaluated.
  6219. It accepts the following values:
  6220. @table @samp
  6221. @item init
  6222. only evaluate expressions once during the filter initialization or
  6223. when a command is processed
  6224. @item frame
  6225. evaluate expressions for each incoming frame
  6226. @end table
  6227. Default value is @samp{frame}.
  6228. @item shortest
  6229. If set to 1, force the output to terminate when the shortest input
  6230. terminates. Default value is 0.
  6231. @item format
  6232. Set the format for the output video.
  6233. It accepts the following values:
  6234. @table @samp
  6235. @item yuv420
  6236. force YUV420 output
  6237. @item yuv422
  6238. force YUV422 output
  6239. @item yuv444
  6240. force YUV444 output
  6241. @item rgb
  6242. force RGB output
  6243. @end table
  6244. Default value is @samp{yuv420}.
  6245. @item rgb @emph{(deprecated)}
  6246. If set to 1, force the filter to accept inputs in the RGB
  6247. color space. Default value is 0. This option is deprecated, use
  6248. @option{format} instead.
  6249. @item repeatlast
  6250. If set to 1, force the filter to draw the last overlay frame over the
  6251. main input until the end of the stream. A value of 0 disables this
  6252. behavior. Default value is 1.
  6253. @end table
  6254. The @option{x}, and @option{y} expressions can contain the following
  6255. parameters.
  6256. @table @option
  6257. @item main_w, W
  6258. @item main_h, H
  6259. The main input width and height.
  6260. @item overlay_w, w
  6261. @item overlay_h, h
  6262. The overlay input width and height.
  6263. @item x
  6264. @item y
  6265. The computed values for @var{x} and @var{y}. They are evaluated for
  6266. each new frame.
  6267. @item hsub
  6268. @item vsub
  6269. horizontal and vertical chroma subsample values of the output
  6270. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  6271. @var{vsub} is 1.
  6272. @item n
  6273. the number of input frame, starting from 0
  6274. @item pos
  6275. the position in the file of the input frame, NAN if unknown
  6276. @item t
  6277. The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
  6278. @end table
  6279. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  6280. when evaluation is done @emph{per frame}, and will evaluate to NAN
  6281. when @option{eval} is set to @samp{init}.
  6282. Be aware that frames are taken from each input video in timestamp
  6283. order, hence, if their initial timestamps differ, it is a good idea
  6284. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  6285. have them begin in the same zero timestamp, as the example for
  6286. the @var{movie} filter does.
  6287. You can chain together more overlays but you should test the
  6288. efficiency of such approach.
  6289. @subsection Commands
  6290. This filter supports the following commands:
  6291. @table @option
  6292. @item x
  6293. @item y
  6294. Modify the x and y of the overlay input.
  6295. The command accepts the same syntax of the corresponding option.
  6296. If the specified expression is not valid, it is kept at its current
  6297. value.
  6298. @end table
  6299. @subsection Examples
  6300. @itemize
  6301. @item
  6302. Draw the overlay at 10 pixels from the bottom right corner of the main
  6303. video:
  6304. @example
  6305. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  6306. @end example
  6307. Using named options the example above becomes:
  6308. @example
  6309. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  6310. @end example
  6311. @item
  6312. Insert a transparent PNG logo in the bottom left corner of the input,
  6313. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  6314. @example
  6315. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  6316. @end example
  6317. @item
  6318. Insert 2 different transparent PNG logos (second logo on bottom
  6319. right corner) using the @command{ffmpeg} tool:
  6320. @example
  6321. 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
  6322. @end example
  6323. @item
  6324. Add a transparent color layer on top of the main video; @code{WxH}
  6325. must specify the size of the main input to the overlay filter:
  6326. @example
  6327. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  6328. @end example
  6329. @item
  6330. Play an original video and a filtered version (here with the deshake
  6331. filter) side by side using the @command{ffplay} tool:
  6332. @example
  6333. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  6334. @end example
  6335. The above command is the same as:
  6336. @example
  6337. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  6338. @end example
  6339. @item
  6340. Make a sliding overlay appearing from the left to the right top part of the
  6341. screen starting since time 2:
  6342. @example
  6343. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  6344. @end example
  6345. @item
  6346. Compose output by putting two input videos side to side:
  6347. @example
  6348. ffmpeg -i left.avi -i right.avi -filter_complex "
  6349. nullsrc=size=200x100 [background];
  6350. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  6351. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  6352. [background][left] overlay=shortest=1 [background+left];
  6353. [background+left][right] overlay=shortest=1:x=100 [left+right]
  6354. "
  6355. @end example
  6356. @item
  6357. Mask 10-20 seconds of a video by applying the delogo filter to a section
  6358. @example
  6359. ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
  6360. -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]'
  6361. masked.avi
  6362. @end example
  6363. @item
  6364. Chain several overlays in cascade:
  6365. @example
  6366. nullsrc=s=200x200 [bg];
  6367. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  6368. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  6369. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  6370. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  6371. [in3] null, [mid2] overlay=100:100 [out0]
  6372. @end example
  6373. @end itemize
  6374. @section owdenoise
  6375. Apply Overcomplete Wavelet denoiser.
  6376. The filter accepts the following options:
  6377. @table @option
  6378. @item depth
  6379. Set depth.
  6380. Larger depth values will denoise lower frequency components more, but
  6381. slow down filtering.
  6382. Must be an int in the range 8-16, default is @code{8}.
  6383. @item luma_strength, ls
  6384. Set luma strength.
  6385. Must be a double value in the range 0-1000, default is @code{1.0}.
  6386. @item chroma_strength, cs
  6387. Set chroma strength.
  6388. Must be a double value in the range 0-1000, default is @code{1.0}.
  6389. @end table
  6390. @anchor{pad}
  6391. @section pad
  6392. Add paddings to the input image, and place the original input at the
  6393. provided @var{x}, @var{y} coordinates.
  6394. It accepts the following parameters:
  6395. @table @option
  6396. @item width, w
  6397. @item height, h
  6398. Specify an expression for the size of the output image with the
  6399. paddings added. If the value for @var{width} or @var{height} is 0, the
  6400. corresponding input size is used for the output.
  6401. The @var{width} expression can reference the value set by the
  6402. @var{height} expression, and vice versa.
  6403. The default value of @var{width} and @var{height} is 0.
  6404. @item x
  6405. @item y
  6406. Specify the offsets to place the input image at within the padded area,
  6407. with respect to the top/left border of the output image.
  6408. The @var{x} expression can reference the value set by the @var{y}
  6409. expression, and vice versa.
  6410. The default value of @var{x} and @var{y} is 0.
  6411. @item color
  6412. Specify the color of the padded area. For the syntax of this option,
  6413. check the "Color" section in the ffmpeg-utils manual.
  6414. The default value of @var{color} is "black".
  6415. @end table
  6416. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  6417. options are expressions containing the following constants:
  6418. @table @option
  6419. @item in_w
  6420. @item in_h
  6421. The input video width and height.
  6422. @item iw
  6423. @item ih
  6424. These are the same as @var{in_w} and @var{in_h}.
  6425. @item out_w
  6426. @item out_h
  6427. The output width and height (the size of the padded area), as
  6428. specified by the @var{width} and @var{height} expressions.
  6429. @item ow
  6430. @item oh
  6431. These are the same as @var{out_w} and @var{out_h}.
  6432. @item x
  6433. @item y
  6434. The x and y offsets as specified by the @var{x} and @var{y}
  6435. expressions, or NAN if not yet specified.
  6436. @item a
  6437. same as @var{iw} / @var{ih}
  6438. @item sar
  6439. input sample aspect ratio
  6440. @item dar
  6441. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  6442. @item hsub
  6443. @item vsub
  6444. The horizontal and vertical chroma subsample values. For example for the
  6445. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6446. @end table
  6447. @subsection Examples
  6448. @itemize
  6449. @item
  6450. Add paddings with the color "violet" to the input video. The output video
  6451. size is 640x480, and the top-left corner of the input video is placed at
  6452. column 0, row 40
  6453. @example
  6454. pad=640:480:0:40:violet
  6455. @end example
  6456. The example above is equivalent to the following command:
  6457. @example
  6458. pad=width=640:height=480:x=0:y=40:color=violet
  6459. @end example
  6460. @item
  6461. Pad the input to get an output with dimensions increased by 3/2,
  6462. and put the input video at the center of the padded area:
  6463. @example
  6464. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  6465. @end example
  6466. @item
  6467. Pad the input to get a squared output with size equal to the maximum
  6468. value between the input width and height, and put the input video at
  6469. the center of the padded area:
  6470. @example
  6471. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  6472. @end example
  6473. @item
  6474. Pad the input to get a final w/h ratio of 16:9:
  6475. @example
  6476. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  6477. @end example
  6478. @item
  6479. In case of anamorphic video, in order to set the output display aspect
  6480. correctly, it is necessary to use @var{sar} in the expression,
  6481. according to the relation:
  6482. @example
  6483. (ih * X / ih) * sar = output_dar
  6484. X = output_dar / sar
  6485. @end example
  6486. Thus the previous example needs to be modified to:
  6487. @example
  6488. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  6489. @end example
  6490. @item
  6491. Double the output size and put the input video in the bottom-right
  6492. corner of the output padded area:
  6493. @example
  6494. pad="2*iw:2*ih:ow-iw:oh-ih"
  6495. @end example
  6496. @end itemize
  6497. @anchor{palettegen}
  6498. @section palettegen
  6499. Generate one palette for a whole video stream.
  6500. It accepts the following options:
  6501. @table @option
  6502. @item max_colors
  6503. Set the maximum number of colors to quantize in the palette.
  6504. Note: the palette will still contain 256 colors; the unused palette entries
  6505. will be black.
  6506. @item reserve_transparent
  6507. Create a palette of 255 colors maximum and reserve the last one for
  6508. transparency. Reserving the transparency color is useful for GIF optimization.
  6509. If not set, the maximum of colors in the palette will be 256. You probably want
  6510. to disable this option for a standalone image.
  6511. Set by default.
  6512. @item stats_mode
  6513. Set statistics mode.
  6514. It accepts the following values:
  6515. @table @samp
  6516. @item full
  6517. Compute full frame histograms.
  6518. @item diff
  6519. Compute histograms only for the part that differs from previous frame. This
  6520. might be relevant to give more importance to the moving part of your input if
  6521. the background is static.
  6522. @end table
  6523. Default value is @var{full}.
  6524. @end table
  6525. The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
  6526. (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
  6527. color quantization of the palette. This information is also visible at
  6528. @var{info} logging level.
  6529. @subsection Examples
  6530. @itemize
  6531. @item
  6532. Generate a representative palette of a given video using @command{ffmpeg}:
  6533. @example
  6534. ffmpeg -i input.mkv -vf palettegen palette.png
  6535. @end example
  6536. @end itemize
  6537. @section paletteuse
  6538. Use a palette to downsample an input video stream.
  6539. The filter takes two inputs: one video stream and a palette. The palette must
  6540. be a 256 pixels image.
  6541. It accepts the following options:
  6542. @table @option
  6543. @item dither
  6544. Select dithering mode. Available algorithms are:
  6545. @table @samp
  6546. @item bayer
  6547. Ordered 8x8 bayer dithering (deterministic)
  6548. @item heckbert
  6549. Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
  6550. Note: this dithering is sometimes considered "wrong" and is included as a
  6551. reference.
  6552. @item floyd_steinberg
  6553. Floyd and Steingberg dithering (error diffusion)
  6554. @item sierra2
  6555. Frankie Sierra dithering v2 (error diffusion)
  6556. @item sierra2_4a
  6557. Frankie Sierra dithering v2 "Lite" (error diffusion)
  6558. @end table
  6559. Default is @var{sierra2_4a}.
  6560. @item bayer_scale
  6561. When @var{bayer} dithering is selected, this option defines the scale of the
  6562. pattern (how much the crosshatch pattern is visible). A low value means more
  6563. visible pattern for less banding, and higher value means less visible pattern
  6564. at the cost of more banding.
  6565. The option must be an integer value in the range [0,5]. Default is @var{2}.
  6566. @item diff_mode
  6567. If set, define the zone to process
  6568. @table @samp
  6569. @item rectangle
  6570. Only the changing rectangle will be reprocessed. This is similar to GIF
  6571. cropping/offsetting compression mechanism. This option can be useful for speed
  6572. if only a part of the image is changing, and has use cases such as limiting the
  6573. scope of the error diffusal @option{dither} to the rectangle that bounds the
  6574. moving scene (it leads to more deterministic output if the scene doesn't change
  6575. much, and as a result less moving noise and better GIF compression).
  6576. @end table
  6577. Default is @var{none}.
  6578. @end table
  6579. @subsection Examples
  6580. @itemize
  6581. @item
  6582. Use a palette (generated for example with @ref{palettegen}) to encode a GIF
  6583. using @command{ffmpeg}:
  6584. @example
  6585. ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
  6586. @end example
  6587. @end itemize
  6588. @section perspective
  6589. Correct perspective of video not recorded perpendicular to the screen.
  6590. A description of the accepted parameters follows.
  6591. @table @option
  6592. @item x0
  6593. @item y0
  6594. @item x1
  6595. @item y1
  6596. @item x2
  6597. @item y2
  6598. @item x3
  6599. @item y3
  6600. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  6601. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  6602. If the @code{sense} option is set to @code{source}, then the specified points will be sent
  6603. to the corners of the destination. If the @code{sense} option is set to @code{destination},
  6604. then the corners of the source will be sent to the specified coordinates.
  6605. The expressions can use the following variables:
  6606. @table @option
  6607. @item W
  6608. @item H
  6609. the width and height of video frame.
  6610. @end table
  6611. @item interpolation
  6612. Set interpolation for perspective correction.
  6613. It accepts the following values:
  6614. @table @samp
  6615. @item linear
  6616. @item cubic
  6617. @end table
  6618. Default value is @samp{linear}.
  6619. @item sense
  6620. Set interpretation of coordinate options.
  6621. It accepts the following values:
  6622. @table @samp
  6623. @item 0, source
  6624. Send point in the source specified by the given coordinates to
  6625. the corners of the destination.
  6626. @item 1, destination
  6627. Send the corners of the source to the point in the destination specified
  6628. by the given coordinates.
  6629. Default value is @samp{source}.
  6630. @end table
  6631. @end table
  6632. @section phase
  6633. Delay interlaced video by one field time so that the field order changes.
  6634. The intended use is to fix PAL movies that have been captured with the
  6635. opposite field order to the film-to-video transfer.
  6636. A description of the accepted parameters follows.
  6637. @table @option
  6638. @item mode
  6639. Set phase mode.
  6640. It accepts the following values:
  6641. @table @samp
  6642. @item t
  6643. Capture field order top-first, transfer bottom-first.
  6644. Filter will delay the bottom field.
  6645. @item b
  6646. Capture field order bottom-first, transfer top-first.
  6647. Filter will delay the top field.
  6648. @item p
  6649. Capture and transfer with the same field order. This mode only exists
  6650. for the documentation of the other options to refer to, but if you
  6651. actually select it, the filter will faithfully do nothing.
  6652. @item a
  6653. Capture field order determined automatically by field flags, transfer
  6654. opposite.
  6655. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  6656. basis using field flags. If no field information is available,
  6657. then this works just like @samp{u}.
  6658. @item u
  6659. Capture unknown or varying, transfer opposite.
  6660. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  6661. analyzing the images and selecting the alternative that produces best
  6662. match between the fields.
  6663. @item T
  6664. Capture top-first, transfer unknown or varying.
  6665. Filter selects among @samp{t} and @samp{p} using image analysis.
  6666. @item B
  6667. Capture bottom-first, transfer unknown or varying.
  6668. Filter selects among @samp{b} and @samp{p} using image analysis.
  6669. @item A
  6670. Capture determined by field flags, transfer unknown or varying.
  6671. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  6672. image analysis. If no field information is available, then this works just
  6673. like @samp{U}. This is the default mode.
  6674. @item U
  6675. Both capture and transfer unknown or varying.
  6676. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  6677. @end table
  6678. @end table
  6679. @section pixdesctest
  6680. Pixel format descriptor test filter, mainly useful for internal
  6681. testing. The output video should be equal to the input video.
  6682. For example:
  6683. @example
  6684. format=monow, pixdesctest
  6685. @end example
  6686. can be used to test the monowhite pixel format descriptor definition.
  6687. @section pp
  6688. Enable the specified chain of postprocessing subfilters using libpostproc. This
  6689. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  6690. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  6691. Each subfilter and some options have a short and a long name that can be used
  6692. interchangeably, i.e. dr/dering are the same.
  6693. The filters accept the following options:
  6694. @table @option
  6695. @item subfilters
  6696. Set postprocessing subfilters string.
  6697. @end table
  6698. All subfilters share common options to determine their scope:
  6699. @table @option
  6700. @item a/autoq
  6701. Honor the quality commands for this subfilter.
  6702. @item c/chrom
  6703. Do chrominance filtering, too (default).
  6704. @item y/nochrom
  6705. Do luminance filtering only (no chrominance).
  6706. @item n/noluma
  6707. Do chrominance filtering only (no luminance).
  6708. @end table
  6709. These options can be appended after the subfilter name, separated by a '|'.
  6710. Available subfilters are:
  6711. @table @option
  6712. @item hb/hdeblock[|difference[|flatness]]
  6713. Horizontal deblocking filter
  6714. @table @option
  6715. @item difference
  6716. Difference factor where higher values mean more deblocking (default: @code{32}).
  6717. @item flatness
  6718. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6719. @end table
  6720. @item vb/vdeblock[|difference[|flatness]]
  6721. Vertical deblocking filter
  6722. @table @option
  6723. @item difference
  6724. Difference factor where higher values mean more deblocking (default: @code{32}).
  6725. @item flatness
  6726. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6727. @end table
  6728. @item ha/hadeblock[|difference[|flatness]]
  6729. Accurate horizontal deblocking filter
  6730. @table @option
  6731. @item difference
  6732. Difference factor where higher values mean more deblocking (default: @code{32}).
  6733. @item flatness
  6734. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6735. @end table
  6736. @item va/vadeblock[|difference[|flatness]]
  6737. Accurate vertical deblocking filter
  6738. @table @option
  6739. @item difference
  6740. Difference factor where higher values mean more deblocking (default: @code{32}).
  6741. @item flatness
  6742. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6743. @end table
  6744. @end table
  6745. The horizontal and vertical deblocking filters share the difference and
  6746. flatness values so you cannot set different horizontal and vertical
  6747. thresholds.
  6748. @table @option
  6749. @item h1/x1hdeblock
  6750. Experimental horizontal deblocking filter
  6751. @item v1/x1vdeblock
  6752. Experimental vertical deblocking filter
  6753. @item dr/dering
  6754. Deringing filter
  6755. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  6756. @table @option
  6757. @item threshold1
  6758. larger -> stronger filtering
  6759. @item threshold2
  6760. larger -> stronger filtering
  6761. @item threshold3
  6762. larger -> stronger filtering
  6763. @end table
  6764. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  6765. @table @option
  6766. @item f/fullyrange
  6767. Stretch luminance to @code{0-255}.
  6768. @end table
  6769. @item lb/linblenddeint
  6770. Linear blend deinterlacing filter that deinterlaces the given block by
  6771. filtering all lines with a @code{(1 2 1)} filter.
  6772. @item li/linipoldeint
  6773. Linear interpolating deinterlacing filter that deinterlaces the given block by
  6774. linearly interpolating every second line.
  6775. @item ci/cubicipoldeint
  6776. Cubic interpolating deinterlacing filter deinterlaces the given block by
  6777. cubically interpolating every second line.
  6778. @item md/mediandeint
  6779. Median deinterlacing filter that deinterlaces the given block by applying a
  6780. median filter to every second line.
  6781. @item fd/ffmpegdeint
  6782. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  6783. second line with a @code{(-1 4 2 4 -1)} filter.
  6784. @item l5/lowpass5
  6785. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  6786. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  6787. @item fq/forceQuant[|quantizer]
  6788. Overrides the quantizer table from the input with the constant quantizer you
  6789. specify.
  6790. @table @option
  6791. @item quantizer
  6792. Quantizer to use
  6793. @end table
  6794. @item de/default
  6795. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  6796. @item fa/fast
  6797. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  6798. @item ac
  6799. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  6800. @end table
  6801. @subsection Examples
  6802. @itemize
  6803. @item
  6804. Apply horizontal and vertical deblocking, deringing and automatic
  6805. brightness/contrast:
  6806. @example
  6807. pp=hb/vb/dr/al
  6808. @end example
  6809. @item
  6810. Apply default filters without brightness/contrast correction:
  6811. @example
  6812. pp=de/-al
  6813. @end example
  6814. @item
  6815. Apply default filters and temporal denoiser:
  6816. @example
  6817. pp=default/tmpnoise|1|2|3
  6818. @end example
  6819. @item
  6820. Apply deblocking on luminance only, and switch vertical deblocking on or off
  6821. automatically depending on available CPU time:
  6822. @example
  6823. pp=hb|y/vb|a
  6824. @end example
  6825. @end itemize
  6826. @section pp7
  6827. Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
  6828. similar to spp = 6 with 7 point DCT, where only the center sample is
  6829. used after IDCT.
  6830. The filter accepts the following options:
  6831. @table @option
  6832. @item qp
  6833. Force a constant quantization parameter. It accepts an integer in range
  6834. 0 to 63. If not set, the filter will use the QP from the video stream
  6835. (if available).
  6836. @item mode
  6837. Set thresholding mode. Available modes are:
  6838. @table @samp
  6839. @item hard
  6840. Set hard thresholding.
  6841. @item soft
  6842. Set soft thresholding (better de-ringing effect, but likely blurrier).
  6843. @item medium
  6844. Set medium thresholding (good results, default).
  6845. @end table
  6846. @end table
  6847. @section psnr
  6848. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  6849. Ratio) between two input videos.
  6850. This filter takes in input two input videos, the first input is
  6851. considered the "main" source and is passed unchanged to the
  6852. output. The second input is used as a "reference" video for computing
  6853. the PSNR.
  6854. Both video inputs must have the same resolution and pixel format for
  6855. this filter to work correctly. Also it assumes that both inputs
  6856. have the same number of frames, which are compared one by one.
  6857. The obtained average PSNR is printed through the logging system.
  6858. The filter stores the accumulated MSE (mean squared error) of each
  6859. frame, and at the end of the processing it is averaged across all frames
  6860. equally, and the following formula is applied to obtain the PSNR:
  6861. @example
  6862. PSNR = 10*log10(MAX^2/MSE)
  6863. @end example
  6864. Where MAX is the average of the maximum values of each component of the
  6865. image.
  6866. The description of the accepted parameters follows.
  6867. @table @option
  6868. @item stats_file, f
  6869. If specified the filter will use the named file to save the PSNR of
  6870. each individual frame.
  6871. @end table
  6872. The file printed if @var{stats_file} is selected, contains a sequence of
  6873. key/value pairs of the form @var{key}:@var{value} for each compared
  6874. couple of frames.
  6875. A description of each shown parameter follows:
  6876. @table @option
  6877. @item n
  6878. sequential number of the input frame, starting from 1
  6879. @item mse_avg
  6880. Mean Square Error pixel-by-pixel average difference of the compared
  6881. frames, averaged over all the image components.
  6882. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  6883. Mean Square Error pixel-by-pixel average difference of the compared
  6884. frames for the component specified by the suffix.
  6885. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  6886. Peak Signal to Noise ratio of the compared frames for the component
  6887. specified by the suffix.
  6888. @end table
  6889. For example:
  6890. @example
  6891. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  6892. [main][ref] psnr="stats_file=stats.log" [out]
  6893. @end example
  6894. On this example the input file being processed is compared with the
  6895. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  6896. is stored in @file{stats.log}.
  6897. @anchor{pullup}
  6898. @section pullup
  6899. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  6900. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  6901. content.
  6902. The pullup filter is designed to take advantage of future context in making
  6903. its decisions. This filter is stateless in the sense that it does not lock
  6904. onto a pattern to follow, but it instead looks forward to the following
  6905. fields in order to identify matches and rebuild progressive frames.
  6906. To produce content with an even framerate, insert the fps filter after
  6907. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  6908. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  6909. The filter accepts the following options:
  6910. @table @option
  6911. @item jl
  6912. @item jr
  6913. @item jt
  6914. @item jb
  6915. These options set the amount of "junk" to ignore at the left, right, top, and
  6916. bottom of the image, respectively. Left and right are in units of 8 pixels,
  6917. while top and bottom are in units of 2 lines.
  6918. The default is 8 pixels on each side.
  6919. @item sb
  6920. Set the strict breaks. Setting this option to 1 will reduce the chances of
  6921. filter generating an occasional mismatched frame, but it may also cause an
  6922. excessive number of frames to be dropped during high motion sequences.
  6923. Conversely, setting it to -1 will make filter match fields more easily.
  6924. This may help processing of video where there is slight blurring between
  6925. the fields, but may also cause there to be interlaced frames in the output.
  6926. Default value is @code{0}.
  6927. @item mp
  6928. Set the metric plane to use. It accepts the following values:
  6929. @table @samp
  6930. @item l
  6931. Use luma plane.
  6932. @item u
  6933. Use chroma blue plane.
  6934. @item v
  6935. Use chroma red plane.
  6936. @end table
  6937. This option may be set to use chroma plane instead of the default luma plane
  6938. for doing filter's computations. This may improve accuracy on very clean
  6939. source material, but more likely will decrease accuracy, especially if there
  6940. is chroma noise (rainbow effect) or any grayscale video.
  6941. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  6942. load and make pullup usable in realtime on slow machines.
  6943. @end table
  6944. For best results (without duplicated frames in the output file) it is
  6945. necessary to change the output frame rate. For example, to inverse
  6946. telecine NTSC input:
  6947. @example
  6948. ffmpeg -i input -vf pullup -r 24000/1001 ...
  6949. @end example
  6950. @section qp
  6951. Change video quantization parameters (QP).
  6952. The filter accepts the following option:
  6953. @table @option
  6954. @item qp
  6955. Set expression for quantization parameter.
  6956. @end table
  6957. The expression is evaluated through the eval API and can contain, among others,
  6958. the following constants:
  6959. @table @var
  6960. @item known
  6961. 1 if index is not 129, 0 otherwise.
  6962. @item qp
  6963. Sequentional index starting from -129 to 128.
  6964. @end table
  6965. @subsection Examples
  6966. @itemize
  6967. @item
  6968. Some equation like:
  6969. @example
  6970. qp=2+2*sin(PI*qp)
  6971. @end example
  6972. @end itemize
  6973. @section random
  6974. Flush video frames from internal cache of frames into a random order.
  6975. No frame is discarded.
  6976. Inspired by @ref{frei0r} nervous filter.
  6977. @table @option
  6978. @item frames
  6979. Set size in number of frames of internal cache, in range from @code{2} to
  6980. @code{512}. Default is @code{30}.
  6981. @item seed
  6982. Set seed for random number generator, must be an integer included between
  6983. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  6984. less than @code{0}, the filter will try to use a good random seed on a
  6985. best effort basis.
  6986. @end table
  6987. @section removegrain
  6988. The removegrain filter is a spatial denoiser for progressive video.
  6989. @table @option
  6990. @item m0
  6991. Set mode for the first plane.
  6992. @item m1
  6993. Set mode for the second plane.
  6994. @item m2
  6995. Set mode for the third plane.
  6996. @item m3
  6997. Set mode for the fourth plane.
  6998. @end table
  6999. Range of mode is from 0 to 24. Description of each mode follows:
  7000. @table @var
  7001. @item 0
  7002. Leave input plane unchanged. Default.
  7003. @item 1
  7004. Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
  7005. @item 2
  7006. Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
  7007. @item 3
  7008. Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
  7009. @item 4
  7010. Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
  7011. This is equivalent to a median filter.
  7012. @item 5
  7013. Line-sensitive clipping giving the minimal change.
  7014. @item 6
  7015. Line-sensitive clipping, intermediate.
  7016. @item 7
  7017. Line-sensitive clipping, intermediate.
  7018. @item 8
  7019. Line-sensitive clipping, intermediate.
  7020. @item 9
  7021. Line-sensitive clipping on a line where the neighbours pixels are the closest.
  7022. @item 10
  7023. Replaces the target pixel with the closest neighbour.
  7024. @item 11
  7025. [1 2 1] horizontal and vertical kernel blur.
  7026. @item 12
  7027. Same as mode 11.
  7028. @item 13
  7029. Bob mode, interpolates top field from the line where the neighbours
  7030. pixels are the closest.
  7031. @item 14
  7032. Bob mode, interpolates bottom field from the line where the neighbours
  7033. pixels are the closest.
  7034. @item 15
  7035. Bob mode, interpolates top field. Same as 13 but with a more complicated
  7036. interpolation formula.
  7037. @item 16
  7038. Bob mode, interpolates bottom field. Same as 14 but with a more complicated
  7039. interpolation formula.
  7040. @item 17
  7041. Clips the pixel with the minimum and maximum of respectively the maximum and
  7042. minimum of each pair of opposite neighbour pixels.
  7043. @item 18
  7044. Line-sensitive clipping using opposite neighbours whose greatest distance from
  7045. the current pixel is minimal.
  7046. @item 19
  7047. Replaces the pixel with the average of its 8 neighbours.
  7048. @item 20
  7049. Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
  7050. @item 21
  7051. Clips pixels using the averages of opposite neighbour.
  7052. @item 22
  7053. Same as mode 21 but simpler and faster.
  7054. @item 23
  7055. Small edge and halo removal, but reputed useless.
  7056. @item 24
  7057. Similar as 23.
  7058. @end table
  7059. @section removelogo
  7060. Suppress a TV station logo, using an image file to determine which
  7061. pixels comprise the logo. It works by filling in the pixels that
  7062. comprise the logo with neighboring pixels.
  7063. The filter accepts the following options:
  7064. @table @option
  7065. @item filename, f
  7066. Set the filter bitmap file, which can be any image format supported by
  7067. libavformat. The width and height of the image file must match those of the
  7068. video stream being processed.
  7069. @end table
  7070. Pixels in the provided bitmap image with a value of zero are not
  7071. considered part of the logo, non-zero pixels are considered part of
  7072. the logo. If you use white (255) for the logo and black (0) for the
  7073. rest, you will be safe. For making the filter bitmap, it is
  7074. recommended to take a screen capture of a black frame with the logo
  7075. visible, and then using a threshold filter followed by the erode
  7076. filter once or twice.
  7077. If needed, little splotches can be fixed manually. Remember that if
  7078. logo pixels are not covered, the filter quality will be much
  7079. reduced. Marking too many pixels as part of the logo does not hurt as
  7080. much, but it will increase the amount of blurring needed to cover over
  7081. the image and will destroy more information than necessary, and extra
  7082. pixels will slow things down on a large logo.
  7083. @section repeatfields
  7084. This filter uses the repeat_field flag from the Video ES headers and hard repeats
  7085. fields based on its value.
  7086. @section reverse, areverse
  7087. Reverse a clip.
  7088. Warning: This filter requires memory to buffer the entire clip, so trimming
  7089. is suggested.
  7090. @subsection Examples
  7091. @itemize
  7092. @item
  7093. Take the first 5 seconds of a clip, and reverse it.
  7094. @example
  7095. trim=end=5,reverse
  7096. @end example
  7097. @end itemize
  7098. @section rotate
  7099. Rotate video by an arbitrary angle expressed in radians.
  7100. The filter accepts the following options:
  7101. A description of the optional parameters follows.
  7102. @table @option
  7103. @item angle, a
  7104. Set an expression for the angle by which to rotate the input video
  7105. clockwise, expressed as a number of radians. A negative value will
  7106. result in a counter-clockwise rotation. By default it is set to "0".
  7107. This expression is evaluated for each frame.
  7108. @item out_w, ow
  7109. Set the output width expression, default value is "iw".
  7110. This expression is evaluated just once during configuration.
  7111. @item out_h, oh
  7112. Set the output height expression, default value is "ih".
  7113. This expression is evaluated just once during configuration.
  7114. @item bilinear
  7115. Enable bilinear interpolation if set to 1, a value of 0 disables
  7116. it. Default value is 1.
  7117. @item fillcolor, c
  7118. Set the color used to fill the output area not covered by the rotated
  7119. image. For the general syntax of this option, check the "Color" section in the
  7120. ffmpeg-utils manual. If the special value "none" is selected then no
  7121. background is printed (useful for example if the background is never shown).
  7122. Default value is "black".
  7123. @end table
  7124. The expressions for the angle and the output size can contain the
  7125. following constants and functions:
  7126. @table @option
  7127. @item n
  7128. sequential number of the input frame, starting from 0. It is always NAN
  7129. before the first frame is filtered.
  7130. @item t
  7131. time in seconds of the input frame, it is set to 0 when the filter is
  7132. configured. It is always NAN before the first frame is filtered.
  7133. @item hsub
  7134. @item vsub
  7135. horizontal and vertical chroma subsample values. For example for the
  7136. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7137. @item in_w, iw
  7138. @item in_h, ih
  7139. the input video width and height
  7140. @item out_w, ow
  7141. @item out_h, oh
  7142. the output width and height, that is the size of the padded area as
  7143. specified by the @var{width} and @var{height} expressions
  7144. @item rotw(a)
  7145. @item roth(a)
  7146. the minimal width/height required for completely containing the input
  7147. video rotated by @var{a} radians.
  7148. These are only available when computing the @option{out_w} and
  7149. @option{out_h} expressions.
  7150. @end table
  7151. @subsection Examples
  7152. @itemize
  7153. @item
  7154. Rotate the input by PI/6 radians clockwise:
  7155. @example
  7156. rotate=PI/6
  7157. @end example
  7158. @item
  7159. Rotate the input by PI/6 radians counter-clockwise:
  7160. @example
  7161. rotate=-PI/6
  7162. @end example
  7163. @item
  7164. Rotate the input by 45 degrees clockwise:
  7165. @example
  7166. rotate=45*PI/180
  7167. @end example
  7168. @item
  7169. Apply a constant rotation with period T, starting from an angle of PI/3:
  7170. @example
  7171. rotate=PI/3+2*PI*t/T
  7172. @end example
  7173. @item
  7174. Make the input video rotation oscillating with a period of T
  7175. seconds and an amplitude of A radians:
  7176. @example
  7177. rotate=A*sin(2*PI/T*t)
  7178. @end example
  7179. @item
  7180. Rotate the video, output size is chosen so that the whole rotating
  7181. input video is always completely contained in the output:
  7182. @example
  7183. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  7184. @end example
  7185. @item
  7186. Rotate the video, reduce the output size so that no background is ever
  7187. shown:
  7188. @example
  7189. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  7190. @end example
  7191. @end itemize
  7192. @subsection Commands
  7193. The filter supports the following commands:
  7194. @table @option
  7195. @item a, angle
  7196. Set the angle expression.
  7197. The command accepts the same syntax of the corresponding option.
  7198. If the specified expression is not valid, it is kept at its current
  7199. value.
  7200. @end table
  7201. @section sab
  7202. Apply Shape Adaptive Blur.
  7203. The filter accepts the following options:
  7204. @table @option
  7205. @item luma_radius, lr
  7206. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  7207. value is 1.0. A greater value will result in a more blurred image, and
  7208. in slower processing.
  7209. @item luma_pre_filter_radius, lpfr
  7210. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  7211. value is 1.0.
  7212. @item luma_strength, ls
  7213. Set luma maximum difference between pixels to still be considered, must
  7214. be a value in the 0.1-100.0 range, default value is 1.0.
  7215. @item chroma_radius, cr
  7216. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  7217. greater value will result in a more blurred image, and in slower
  7218. processing.
  7219. @item chroma_pre_filter_radius, cpfr
  7220. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  7221. @item chroma_strength, cs
  7222. Set chroma maximum difference between pixels to still be considered,
  7223. must be a value in the 0.1-100.0 range.
  7224. @end table
  7225. Each chroma option value, if not explicitly specified, is set to the
  7226. corresponding luma option value.
  7227. @anchor{scale}
  7228. @section scale
  7229. Scale (resize) the input video, using the libswscale library.
  7230. The scale filter forces the output display aspect ratio to be the same
  7231. of the input, by changing the output sample aspect ratio.
  7232. If the input image format is different from the format requested by
  7233. the next filter, the scale filter will convert the input to the
  7234. requested format.
  7235. @subsection Options
  7236. The filter accepts the following options, or any of the options
  7237. supported by the libswscale scaler.
  7238. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  7239. the complete list of scaler options.
  7240. @table @option
  7241. @item width, w
  7242. @item height, h
  7243. Set the output video dimension expression. Default value is the input
  7244. dimension.
  7245. If the value is 0, the input width is used for the output.
  7246. If one of the values is -1, the scale filter will use a value that
  7247. maintains the aspect ratio of the input image, calculated from the
  7248. other specified dimension. If both of them are -1, the input size is
  7249. used
  7250. If one of the values is -n with n > 1, the scale filter will also use a value
  7251. that maintains the aspect ratio of the input image, calculated from the other
  7252. specified dimension. After that it will, however, make sure that the calculated
  7253. dimension is divisible by n and adjust the value if necessary.
  7254. See below for the list of accepted constants for use in the dimension
  7255. expression.
  7256. @item interl
  7257. Set the interlacing mode. It accepts the following values:
  7258. @table @samp
  7259. @item 1
  7260. Force interlaced aware scaling.
  7261. @item 0
  7262. Do not apply interlaced scaling.
  7263. @item -1
  7264. Select interlaced aware scaling depending on whether the source frames
  7265. are flagged as interlaced or not.
  7266. @end table
  7267. Default value is @samp{0}.
  7268. @item flags
  7269. Set libswscale scaling flags. See
  7270. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  7271. complete list of values. If not explicitly specified the filter applies
  7272. the default flags.
  7273. @item size, s
  7274. Set the video size. For the syntax of this option, check the
  7275. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7276. @item in_color_matrix
  7277. @item out_color_matrix
  7278. Set in/output YCbCr color space type.
  7279. This allows the autodetected value to be overridden as well as allows forcing
  7280. a specific value used for the output and encoder.
  7281. If not specified, the color space type depends on the pixel format.
  7282. Possible values:
  7283. @table @samp
  7284. @item auto
  7285. Choose automatically.
  7286. @item bt709
  7287. Format conforming to International Telecommunication Union (ITU)
  7288. Recommendation BT.709.
  7289. @item fcc
  7290. Set color space conforming to the United States Federal Communications
  7291. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  7292. @item bt601
  7293. Set color space conforming to:
  7294. @itemize
  7295. @item
  7296. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  7297. @item
  7298. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  7299. @item
  7300. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  7301. @end itemize
  7302. @item smpte240m
  7303. Set color space conforming to SMPTE ST 240:1999.
  7304. @end table
  7305. @item in_range
  7306. @item out_range
  7307. Set in/output YCbCr sample range.
  7308. This allows the autodetected value to be overridden as well as allows forcing
  7309. a specific value used for the output and encoder. If not specified, the
  7310. range depends on the pixel format. Possible values:
  7311. @table @samp
  7312. @item auto
  7313. Choose automatically.
  7314. @item jpeg/full/pc
  7315. Set full range (0-255 in case of 8-bit luma).
  7316. @item mpeg/tv
  7317. Set "MPEG" range (16-235 in case of 8-bit luma).
  7318. @end table
  7319. @item force_original_aspect_ratio
  7320. Enable decreasing or increasing output video width or height if necessary to
  7321. keep the original aspect ratio. Possible values:
  7322. @table @samp
  7323. @item disable
  7324. Scale the video as specified and disable this feature.
  7325. @item decrease
  7326. The output video dimensions will automatically be decreased if needed.
  7327. @item increase
  7328. The output video dimensions will automatically be increased if needed.
  7329. @end table
  7330. One useful instance of this option is that when you know a specific device's
  7331. maximum allowed resolution, you can use this to limit the output video to
  7332. that, while retaining the aspect ratio. For example, device A allows
  7333. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  7334. decrease) and specifying 1280x720 to the command line makes the output
  7335. 1280x533.
  7336. Please note that this is a different thing than specifying -1 for @option{w}
  7337. or @option{h}, you still need to specify the output resolution for this option
  7338. to work.
  7339. @end table
  7340. The values of the @option{w} and @option{h} options are expressions
  7341. containing the following constants:
  7342. @table @var
  7343. @item in_w
  7344. @item in_h
  7345. The input width and height
  7346. @item iw
  7347. @item ih
  7348. These are the same as @var{in_w} and @var{in_h}.
  7349. @item out_w
  7350. @item out_h
  7351. The output (scaled) width and height
  7352. @item ow
  7353. @item oh
  7354. These are the same as @var{out_w} and @var{out_h}
  7355. @item a
  7356. The same as @var{iw} / @var{ih}
  7357. @item sar
  7358. input sample aspect ratio
  7359. @item dar
  7360. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  7361. @item hsub
  7362. @item vsub
  7363. horizontal and vertical input chroma subsample values. For example for the
  7364. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7365. @item ohsub
  7366. @item ovsub
  7367. horizontal and vertical output chroma subsample values. For example for the
  7368. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7369. @end table
  7370. @subsection Examples
  7371. @itemize
  7372. @item
  7373. Scale the input video to a size of 200x100
  7374. @example
  7375. scale=w=200:h=100
  7376. @end example
  7377. This is equivalent to:
  7378. @example
  7379. scale=200:100
  7380. @end example
  7381. or:
  7382. @example
  7383. scale=200x100
  7384. @end example
  7385. @item
  7386. Specify a size abbreviation for the output size:
  7387. @example
  7388. scale=qcif
  7389. @end example
  7390. which can also be written as:
  7391. @example
  7392. scale=size=qcif
  7393. @end example
  7394. @item
  7395. Scale the input to 2x:
  7396. @example
  7397. scale=w=2*iw:h=2*ih
  7398. @end example
  7399. @item
  7400. The above is the same as:
  7401. @example
  7402. scale=2*in_w:2*in_h
  7403. @end example
  7404. @item
  7405. Scale the input to 2x with forced interlaced scaling:
  7406. @example
  7407. scale=2*iw:2*ih:interl=1
  7408. @end example
  7409. @item
  7410. Scale the input to half size:
  7411. @example
  7412. scale=w=iw/2:h=ih/2
  7413. @end example
  7414. @item
  7415. Increase the width, and set the height to the same size:
  7416. @example
  7417. scale=3/2*iw:ow
  7418. @end example
  7419. @item
  7420. Seek Greek harmony:
  7421. @example
  7422. scale=iw:1/PHI*iw
  7423. scale=ih*PHI:ih
  7424. @end example
  7425. @item
  7426. Increase the height, and set the width to 3/2 of the height:
  7427. @example
  7428. scale=w=3/2*oh:h=3/5*ih
  7429. @end example
  7430. @item
  7431. Increase the size, making the size a multiple of the chroma
  7432. subsample values:
  7433. @example
  7434. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  7435. @end example
  7436. @item
  7437. Increase the width to a maximum of 500 pixels,
  7438. keeping the same aspect ratio as the input:
  7439. @example
  7440. scale=w='min(500\, iw*3/2):h=-1'
  7441. @end example
  7442. @end itemize
  7443. @subsection Commands
  7444. This filter supports the following commands:
  7445. @table @option
  7446. @item width, w
  7447. @item height, h
  7448. Set the output video dimension expression.
  7449. The command accepts the same syntax of the corresponding option.
  7450. If the specified expression is not valid, it is kept at its current
  7451. value.
  7452. @end table
  7453. @section scale2ref
  7454. Scale (resize) the input video, based on a reference video.
  7455. See the scale filter for available options, scale2ref supports the same but
  7456. uses the reference video instead of the main input as basis.
  7457. @subsection Examples
  7458. @itemize
  7459. @item
  7460. Scale a subtitle stream to match the main video in size before overlaying
  7461. @example
  7462. 'scale2ref[b][a];[a][b]overlay'
  7463. @end example
  7464. @end itemize
  7465. @section separatefields
  7466. The @code{separatefields} takes a frame-based video input and splits
  7467. each frame into its components fields, producing a new half height clip
  7468. with twice the frame rate and twice the frame count.
  7469. This filter use field-dominance information in frame to decide which
  7470. of each pair of fields to place first in the output.
  7471. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  7472. @section setdar, setsar
  7473. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  7474. output video.
  7475. This is done by changing the specified Sample (aka Pixel) Aspect
  7476. Ratio, according to the following equation:
  7477. @example
  7478. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  7479. @end example
  7480. Keep in mind that the @code{setdar} filter does not modify the pixel
  7481. dimensions of the video frame. Also, the display aspect ratio set by
  7482. this filter may be changed by later filters in the filterchain,
  7483. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  7484. applied.
  7485. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  7486. the filter output video.
  7487. Note that as a consequence of the application of this filter, the
  7488. output display aspect ratio will change according to the equation
  7489. above.
  7490. Keep in mind that the sample aspect ratio set by the @code{setsar}
  7491. filter may be changed by later filters in the filterchain, e.g. if
  7492. another "setsar" or a "setdar" filter is applied.
  7493. It accepts the following parameters:
  7494. @table @option
  7495. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  7496. Set the aspect ratio used by the filter.
  7497. The parameter can be a floating point number string, an expression, or
  7498. a string of the form @var{num}:@var{den}, where @var{num} and
  7499. @var{den} are the numerator and denominator of the aspect ratio. If
  7500. the parameter is not specified, it is assumed the value "0".
  7501. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  7502. should be escaped.
  7503. @item max
  7504. Set the maximum integer value to use for expressing numerator and
  7505. denominator when reducing the expressed aspect ratio to a rational.
  7506. Default value is @code{100}.
  7507. @end table
  7508. The parameter @var{sar} is an expression containing
  7509. the following constants:
  7510. @table @option
  7511. @item E, PI, PHI
  7512. These are approximated values for the mathematical constants e
  7513. (Euler's number), pi (Greek pi), and phi (the golden ratio).
  7514. @item w, h
  7515. The input width and height.
  7516. @item a
  7517. These are the same as @var{w} / @var{h}.
  7518. @item sar
  7519. The input sample aspect ratio.
  7520. @item dar
  7521. The input display aspect ratio. It is the same as
  7522. (@var{w} / @var{h}) * @var{sar}.
  7523. @item hsub, vsub
  7524. Horizontal and vertical chroma subsample values. For example, for the
  7525. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7526. @end table
  7527. @subsection Examples
  7528. @itemize
  7529. @item
  7530. To change the display aspect ratio to 16:9, specify one of the following:
  7531. @example
  7532. setdar=dar=1.77777
  7533. setdar=dar=16/9
  7534. setdar=dar=1.77777
  7535. @end example
  7536. @item
  7537. To change the sample aspect ratio to 10:11, specify:
  7538. @example
  7539. setsar=sar=10/11
  7540. @end example
  7541. @item
  7542. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  7543. 1000 in the aspect ratio reduction, use the command:
  7544. @example
  7545. setdar=ratio=16/9:max=1000
  7546. @end example
  7547. @end itemize
  7548. @anchor{setfield}
  7549. @section setfield
  7550. Force field for the output video frame.
  7551. The @code{setfield} filter marks the interlace type field for the
  7552. output frames. It does not change the input frame, but only sets the
  7553. corresponding property, which affects how the frame is treated by
  7554. following filters (e.g. @code{fieldorder} or @code{yadif}).
  7555. The filter accepts the following options:
  7556. @table @option
  7557. @item mode
  7558. Available values are:
  7559. @table @samp
  7560. @item auto
  7561. Keep the same field property.
  7562. @item bff
  7563. Mark the frame as bottom-field-first.
  7564. @item tff
  7565. Mark the frame as top-field-first.
  7566. @item prog
  7567. Mark the frame as progressive.
  7568. @end table
  7569. @end table
  7570. @section showinfo
  7571. Show a line containing various information for each input video frame.
  7572. The input video is not modified.
  7573. The shown line contains a sequence of key/value pairs of the form
  7574. @var{key}:@var{value}.
  7575. The following values are shown in the output:
  7576. @table @option
  7577. @item n
  7578. The (sequential) number of the input frame, starting from 0.
  7579. @item pts
  7580. The Presentation TimeStamp of the input frame, expressed as a number of
  7581. time base units. The time base unit depends on the filter input pad.
  7582. @item pts_time
  7583. The Presentation TimeStamp of the input frame, expressed as a number of
  7584. seconds.
  7585. @item pos
  7586. The position of the frame in the input stream, or -1 if this information is
  7587. unavailable and/or meaningless (for example in case of synthetic video).
  7588. @item fmt
  7589. The pixel format name.
  7590. @item sar
  7591. The sample aspect ratio of the input frame, expressed in the form
  7592. @var{num}/@var{den}.
  7593. @item s
  7594. The size of the input frame. For the syntax of this option, check the
  7595. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7596. @item i
  7597. The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
  7598. for bottom field first).
  7599. @item iskey
  7600. This is 1 if the frame is a key frame, 0 otherwise.
  7601. @item type
  7602. The picture type of the input frame ("I" for an I-frame, "P" for a
  7603. P-frame, "B" for a B-frame, or "?" for an unknown type).
  7604. Also refer to the documentation of the @code{AVPictureType} enum and of
  7605. the @code{av_get_picture_type_char} function defined in
  7606. @file{libavutil/avutil.h}.
  7607. @item checksum
  7608. The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
  7609. @item plane_checksum
  7610. The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  7611. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
  7612. @end table
  7613. @section showpalette
  7614. Displays the 256 colors palette of each frame. This filter is only relevant for
  7615. @var{pal8} pixel format frames.
  7616. It accepts the following option:
  7617. @table @option
  7618. @item s
  7619. Set the size of the box used to represent one palette color entry. Default is
  7620. @code{30} (for a @code{30x30} pixel box).
  7621. @end table
  7622. @section shuffleplanes
  7623. Reorder and/or duplicate video planes.
  7624. It accepts the following parameters:
  7625. @table @option
  7626. @item map0
  7627. The index of the input plane to be used as the first output plane.
  7628. @item map1
  7629. The index of the input plane to be used as the second output plane.
  7630. @item map2
  7631. The index of the input plane to be used as the third output plane.
  7632. @item map3
  7633. The index of the input plane to be used as the fourth output plane.
  7634. @end table
  7635. The first plane has the index 0. The default is to keep the input unchanged.
  7636. Swap the second and third planes of the input:
  7637. @example
  7638. ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
  7639. @end example
  7640. @anchor{signalstats}
  7641. @section signalstats
  7642. Evaluate various visual metrics that assist in determining issues associated
  7643. with the digitization of analog video media.
  7644. By default the filter will log these metadata values:
  7645. @table @option
  7646. @item YMIN
  7647. Display the minimal Y value contained within the input frame. Expressed in
  7648. range of [0-255].
  7649. @item YLOW
  7650. Display the Y value at the 10% percentile within the input frame. Expressed in
  7651. range of [0-255].
  7652. @item YAVG
  7653. Display the average Y value within the input frame. Expressed in range of
  7654. [0-255].
  7655. @item YHIGH
  7656. Display the Y value at the 90% percentile within the input frame. Expressed in
  7657. range of [0-255].
  7658. @item YMAX
  7659. Display the maximum Y value contained within the input frame. Expressed in
  7660. range of [0-255].
  7661. @item UMIN
  7662. Display the minimal U value contained within the input frame. Expressed in
  7663. range of [0-255].
  7664. @item ULOW
  7665. Display the U value at the 10% percentile within the input frame. Expressed in
  7666. range of [0-255].
  7667. @item UAVG
  7668. Display the average U value within the input frame. Expressed in range of
  7669. [0-255].
  7670. @item UHIGH
  7671. Display the U value at the 90% percentile within the input frame. Expressed in
  7672. range of [0-255].
  7673. @item UMAX
  7674. Display the maximum U value contained within the input frame. Expressed in
  7675. range of [0-255].
  7676. @item VMIN
  7677. Display the minimal V value contained within the input frame. Expressed in
  7678. range of [0-255].
  7679. @item VLOW
  7680. Display the V value at the 10% percentile within the input frame. Expressed in
  7681. range of [0-255].
  7682. @item VAVG
  7683. Display the average V value within the input frame. Expressed in range of
  7684. [0-255].
  7685. @item VHIGH
  7686. Display the V value at the 90% percentile within the input frame. Expressed in
  7687. range of [0-255].
  7688. @item VMAX
  7689. Display the maximum V value contained within the input frame. Expressed in
  7690. range of [0-255].
  7691. @item SATMIN
  7692. Display the minimal saturation value contained within the input frame.
  7693. Expressed in range of [0-~181.02].
  7694. @item SATLOW
  7695. Display the saturation value at the 10% percentile within the input frame.
  7696. Expressed in range of [0-~181.02].
  7697. @item SATAVG
  7698. Display the average saturation value within the input frame. Expressed in range
  7699. of [0-~181.02].
  7700. @item SATHIGH
  7701. Display the saturation value at the 90% percentile within the input frame.
  7702. Expressed in range of [0-~181.02].
  7703. @item SATMAX
  7704. Display the maximum saturation value contained within the input frame.
  7705. Expressed in range of [0-~181.02].
  7706. @item HUEMED
  7707. Display the median value for hue within the input frame. Expressed in range of
  7708. [0-360].
  7709. @item HUEAVG
  7710. Display the average value for hue within the input frame. Expressed in range of
  7711. [0-360].
  7712. @item YDIF
  7713. Display the average of sample value difference between all values of the Y
  7714. plane in the current frame and corresponding values of the previous input frame.
  7715. Expressed in range of [0-255].
  7716. @item UDIF
  7717. Display the average of sample value difference between all values of the U
  7718. plane in the current frame and corresponding values of the previous input frame.
  7719. Expressed in range of [0-255].
  7720. @item VDIF
  7721. Display the average of sample value difference between all values of the V
  7722. plane in the current frame and corresponding values of the previous input frame.
  7723. Expressed in range of [0-255].
  7724. @end table
  7725. The filter accepts the following options:
  7726. @table @option
  7727. @item stat
  7728. @item out
  7729. @option{stat} specify an additional form of image analysis.
  7730. @option{out} output video with the specified type of pixel highlighted.
  7731. Both options accept the following values:
  7732. @table @samp
  7733. @item tout
  7734. Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
  7735. unlike the neighboring pixels of the same field. Examples of temporal outliers
  7736. include the results of video dropouts, head clogs, or tape tracking issues.
  7737. @item vrep
  7738. Identify @var{vertical line repetition}. Vertical line repetition includes
  7739. similar rows of pixels within a frame. In born-digital video vertical line
  7740. repetition is common, but this pattern is uncommon in video digitized from an
  7741. analog source. When it occurs in video that results from the digitization of an
  7742. analog source it can indicate concealment from a dropout compensator.
  7743. @item brng
  7744. Identify pixels that fall outside of legal broadcast range.
  7745. @end table
  7746. @item color, c
  7747. Set the highlight color for the @option{out} option. The default color is
  7748. yellow.
  7749. @end table
  7750. @subsection Examples
  7751. @itemize
  7752. @item
  7753. Output data of various video metrics:
  7754. @example
  7755. ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
  7756. @end example
  7757. @item
  7758. Output specific data about the minimum and maximum values of the Y plane per frame:
  7759. @example
  7760. ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
  7761. @end example
  7762. @item
  7763. Playback video while highlighting pixels that are outside of broadcast range in red.
  7764. @example
  7765. ffplay example.mov -vf signalstats="out=brng:color=red"
  7766. @end example
  7767. @item
  7768. Playback video with signalstats metadata drawn over the frame.
  7769. @example
  7770. ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
  7771. @end example
  7772. The contents of signalstat_drawtext.txt used in the command are:
  7773. @example
  7774. time %@{pts:hms@}
  7775. Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
  7776. U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
  7777. V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
  7778. saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
  7779. @end example
  7780. @end itemize
  7781. @anchor{smartblur}
  7782. @section smartblur
  7783. Blur the input video without impacting the outlines.
  7784. It accepts the following options:
  7785. @table @option
  7786. @item luma_radius, lr
  7787. Set the luma radius. The option value must be a float number in
  7788. the range [0.1,5.0] that specifies the variance of the gaussian filter
  7789. used to blur the image (slower if larger). Default value is 1.0.
  7790. @item luma_strength, ls
  7791. Set the luma strength. The option value must be a float number
  7792. in the range [-1.0,1.0] that configures the blurring. A value included
  7793. in [0.0,1.0] will blur the image whereas a value included in
  7794. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  7795. @item luma_threshold, lt
  7796. Set the luma threshold used as a coefficient to determine
  7797. whether a pixel should be blurred or not. The option value must be an
  7798. integer in the range [-30,30]. A value of 0 will filter all the image,
  7799. a value included in [0,30] will filter flat areas and a value included
  7800. in [-30,0] will filter edges. Default value is 0.
  7801. @item chroma_radius, cr
  7802. Set the chroma radius. The option value must be a float number in
  7803. the range [0.1,5.0] that specifies the variance of the gaussian filter
  7804. used to blur the image (slower if larger). Default value is 1.0.
  7805. @item chroma_strength, cs
  7806. Set the chroma strength. The option value must be a float number
  7807. in the range [-1.0,1.0] that configures the blurring. A value included
  7808. in [0.0,1.0] will blur the image whereas a value included in
  7809. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  7810. @item chroma_threshold, ct
  7811. Set the chroma threshold used as a coefficient to determine
  7812. whether a pixel should be blurred or not. The option value must be an
  7813. integer in the range [-30,30]. A value of 0 will filter all the image,
  7814. a value included in [0,30] will filter flat areas and a value included
  7815. in [-30,0] will filter edges. Default value is 0.
  7816. @end table
  7817. If a chroma option is not explicitly set, the corresponding luma value
  7818. is set.
  7819. @section ssim
  7820. Obtain the SSIM (Structural SImilarity Metric) between two input videos.
  7821. This filter takes in input two input videos, the first input is
  7822. considered the "main" source and is passed unchanged to the
  7823. output. The second input is used as a "reference" video for computing
  7824. the SSIM.
  7825. Both video inputs must have the same resolution and pixel format for
  7826. this filter to work correctly. Also it assumes that both inputs
  7827. have the same number of frames, which are compared one by one.
  7828. The filter stores the calculated SSIM of each frame.
  7829. The description of the accepted parameters follows.
  7830. @table @option
  7831. @item stats_file, f
  7832. If specified the filter will use the named file to save the SSIM of
  7833. each individual frame.
  7834. @end table
  7835. The file printed if @var{stats_file} is selected, contains a sequence of
  7836. key/value pairs of the form @var{key}:@var{value} for each compared
  7837. couple of frames.
  7838. A description of each shown parameter follows:
  7839. @table @option
  7840. @item n
  7841. sequential number of the input frame, starting from 1
  7842. @item Y, U, V, R, G, B
  7843. SSIM of the compared frames for the component specified by the suffix.
  7844. @item All
  7845. SSIM of the compared frames for the whole frame.
  7846. @item dB
  7847. Same as above but in dB representation.
  7848. @end table
  7849. For example:
  7850. @example
  7851. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  7852. [main][ref] ssim="stats_file=stats.log" [out]
  7853. @end example
  7854. On this example the input file being processed is compared with the
  7855. reference file @file{ref_movie.mpg}. The SSIM of each individual frame
  7856. is stored in @file{stats.log}.
  7857. Another example with both psnr and ssim at same time:
  7858. @example
  7859. ffmpeg -i main.mpg -i ref.mpg -lavfi "ssim;[0:v][1:v]psnr" -f null -
  7860. @end example
  7861. @section stereo3d
  7862. Convert between different stereoscopic image formats.
  7863. The filters accept the following options:
  7864. @table @option
  7865. @item in
  7866. Set stereoscopic image format of input.
  7867. Available values for input image formats are:
  7868. @table @samp
  7869. @item sbsl
  7870. side by side parallel (left eye left, right eye right)
  7871. @item sbsr
  7872. side by side crosseye (right eye left, left eye right)
  7873. @item sbs2l
  7874. side by side parallel with half width resolution
  7875. (left eye left, right eye right)
  7876. @item sbs2r
  7877. side by side crosseye with half width resolution
  7878. (right eye left, left eye right)
  7879. @item abl
  7880. above-below (left eye above, right eye below)
  7881. @item abr
  7882. above-below (right eye above, left eye below)
  7883. @item ab2l
  7884. above-below with half height resolution
  7885. (left eye above, right eye below)
  7886. @item ab2r
  7887. above-below with half height resolution
  7888. (right eye above, left eye below)
  7889. @item al
  7890. alternating frames (left eye first, right eye second)
  7891. @item ar
  7892. alternating frames (right eye first, left eye second)
  7893. @item irl
  7894. interleaved rows (left eye has top row, right eye starts on next row)
  7895. @item irr
  7896. interleaved rows (right eye has top row, left eye starts on next row)
  7897. Default value is @samp{sbsl}.
  7898. @end table
  7899. @item out
  7900. Set stereoscopic image format of output.
  7901. Available values for output image formats are all the input formats as well as:
  7902. @table @samp
  7903. @item arbg
  7904. anaglyph red/blue gray
  7905. (red filter on left eye, blue filter on right eye)
  7906. @item argg
  7907. anaglyph red/green gray
  7908. (red filter on left eye, green filter on right eye)
  7909. @item arcg
  7910. anaglyph red/cyan gray
  7911. (red filter on left eye, cyan filter on right eye)
  7912. @item arch
  7913. anaglyph red/cyan half colored
  7914. (red filter on left eye, cyan filter on right eye)
  7915. @item arcc
  7916. anaglyph red/cyan color
  7917. (red filter on left eye, cyan filter on right eye)
  7918. @item arcd
  7919. anaglyph red/cyan color optimized with the least squares projection of dubois
  7920. (red filter on left eye, cyan filter on right eye)
  7921. @item agmg
  7922. anaglyph green/magenta gray
  7923. (green filter on left eye, magenta filter on right eye)
  7924. @item agmh
  7925. anaglyph green/magenta half colored
  7926. (green filter on left eye, magenta filter on right eye)
  7927. @item agmc
  7928. anaglyph green/magenta colored
  7929. (green filter on left eye, magenta filter on right eye)
  7930. @item agmd
  7931. anaglyph green/magenta color optimized with the least squares projection of dubois
  7932. (green filter on left eye, magenta filter on right eye)
  7933. @item aybg
  7934. anaglyph yellow/blue gray
  7935. (yellow filter on left eye, blue filter on right eye)
  7936. @item aybh
  7937. anaglyph yellow/blue half colored
  7938. (yellow filter on left eye, blue filter on right eye)
  7939. @item aybc
  7940. anaglyph yellow/blue colored
  7941. (yellow filter on left eye, blue filter on right eye)
  7942. @item aybd
  7943. anaglyph yellow/blue color optimized with the least squares projection of dubois
  7944. (yellow filter on left eye, blue filter on right eye)
  7945. @item ml
  7946. mono output (left eye only)
  7947. @item mr
  7948. mono output (right eye only)
  7949. @item chl
  7950. checkerboard, left eye first
  7951. @item chr
  7952. checkerboard, right eye first
  7953. @item icl
  7954. interleaved columns, left eye first
  7955. @item icr
  7956. interleaved columns, right eye first
  7957. @end table
  7958. Default value is @samp{arcd}.
  7959. @end table
  7960. @subsection Examples
  7961. @itemize
  7962. @item
  7963. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  7964. @example
  7965. stereo3d=sbsl:aybd
  7966. @end example
  7967. @item
  7968. Convert input video from above below (left eye above, right eye below) to side by side crosseye.
  7969. @example
  7970. stereo3d=abl:sbsr
  7971. @end example
  7972. @end itemize
  7973. @anchor{spp}
  7974. @section spp
  7975. Apply a simple postprocessing filter that compresses and decompresses the image
  7976. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  7977. and average the results.
  7978. The filter accepts the following options:
  7979. @table @option
  7980. @item quality
  7981. Set quality. This option defines the number of levels for averaging. It accepts
  7982. an integer in the range 0-6. If set to @code{0}, the filter will have no
  7983. effect. A value of @code{6} means the higher quality. For each increment of
  7984. that value the speed drops by a factor of approximately 2. Default value is
  7985. @code{3}.
  7986. @item qp
  7987. Force a constant quantization parameter. If not set, the filter will use the QP
  7988. from the video stream (if available).
  7989. @item mode
  7990. Set thresholding mode. Available modes are:
  7991. @table @samp
  7992. @item hard
  7993. Set hard thresholding (default).
  7994. @item soft
  7995. Set soft thresholding (better de-ringing effect, but likely blurrier).
  7996. @end table
  7997. @item use_bframe_qp
  7998. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  7999. option may cause flicker since the B-Frames have often larger QP. Default is
  8000. @code{0} (not enabled).
  8001. @end table
  8002. @anchor{subtitles}
  8003. @section subtitles
  8004. Draw subtitles on top of input video using the libass library.
  8005. To enable compilation of this filter you need to configure FFmpeg with
  8006. @code{--enable-libass}. This filter also requires a build with libavcodec and
  8007. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  8008. Alpha) subtitles format.
  8009. The filter accepts the following options:
  8010. @table @option
  8011. @item filename, f
  8012. Set the filename of the subtitle file to read. It must be specified.
  8013. @item original_size
  8014. Specify the size of the original video, the video for which the ASS file
  8015. was composed. For the syntax of this option, check the
  8016. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8017. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
  8018. correctly scale the fonts if the aspect ratio has been changed.
  8019. @item fontsdir
  8020. Set a directory path containing fonts that can be used by the filter.
  8021. These fonts will be used in addition to whatever the font provider uses.
  8022. @item charenc
  8023. Set subtitles input character encoding. @code{subtitles} filter only. Only
  8024. useful if not UTF-8.
  8025. @item stream_index, si
  8026. Set subtitles stream index. @code{subtitles} filter only.
  8027. @item force_style
  8028. Override default style or script info parameters of the subtitles. It accepts a
  8029. string containing ASS style format @code{KEY=VALUE} couples separated by ",".
  8030. @end table
  8031. If the first key is not specified, it is assumed that the first value
  8032. specifies the @option{filename}.
  8033. For example, to render the file @file{sub.srt} on top of the input
  8034. video, use the command:
  8035. @example
  8036. subtitles=sub.srt
  8037. @end example
  8038. which is equivalent to:
  8039. @example
  8040. subtitles=filename=sub.srt
  8041. @end example
  8042. To render the default subtitles stream from file @file{video.mkv}, use:
  8043. @example
  8044. subtitles=video.mkv
  8045. @end example
  8046. To render the second subtitles stream from that file, use:
  8047. @example
  8048. subtitles=video.mkv:si=1
  8049. @end example
  8050. To make the subtitles stream from @file{sub.srt} appear in transparent green
  8051. @code{DejaVu Serif}, use:
  8052. @example
  8053. subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
  8054. @end example
  8055. @section super2xsai
  8056. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  8057. Interpolate) pixel art scaling algorithm.
  8058. Useful for enlarging pixel art images without reducing sharpness.
  8059. @section swapuv
  8060. Swap U & V plane.
  8061. @section telecine
  8062. Apply telecine process to the video.
  8063. This filter accepts the following options:
  8064. @table @option
  8065. @item first_field
  8066. @table @samp
  8067. @item top, t
  8068. top field first
  8069. @item bottom, b
  8070. bottom field first
  8071. The default value is @code{top}.
  8072. @end table
  8073. @item pattern
  8074. A string of numbers representing the pulldown pattern you wish to apply.
  8075. The default value is @code{23}.
  8076. @end table
  8077. @example
  8078. Some typical patterns:
  8079. NTSC output (30i):
  8080. 27.5p: 32222
  8081. 24p: 23 (classic)
  8082. 24p: 2332 (preferred)
  8083. 20p: 33
  8084. 18p: 334
  8085. 16p: 3444
  8086. PAL output (25i):
  8087. 27.5p: 12222
  8088. 24p: 222222222223 ("Euro pulldown")
  8089. 16.67p: 33
  8090. 16p: 33333334
  8091. @end example
  8092. @section thumbnail
  8093. Select the most representative frame in a given sequence of consecutive frames.
  8094. The filter accepts the following options:
  8095. @table @option
  8096. @item n
  8097. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  8098. will pick one of them, and then handle the next batch of @var{n} frames until
  8099. the end. Default is @code{100}.
  8100. @end table
  8101. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  8102. value will result in a higher memory usage, so a high value is not recommended.
  8103. @subsection Examples
  8104. @itemize
  8105. @item
  8106. Extract one picture each 50 frames:
  8107. @example
  8108. thumbnail=50
  8109. @end example
  8110. @item
  8111. Complete example of a thumbnail creation with @command{ffmpeg}:
  8112. @example
  8113. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  8114. @end example
  8115. @end itemize
  8116. @section tile
  8117. Tile several successive frames together.
  8118. The filter accepts the following options:
  8119. @table @option
  8120. @item layout
  8121. Set the grid size (i.e. the number of lines and columns). For the syntax of
  8122. this option, check the
  8123. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8124. @item nb_frames
  8125. Set the maximum number of frames to render in the given area. It must be less
  8126. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  8127. the area will be used.
  8128. @item margin
  8129. Set the outer border margin in pixels.
  8130. @item padding
  8131. Set the inner border thickness (i.e. the number of pixels between frames). For
  8132. more advanced padding options (such as having different values for the edges),
  8133. refer to the pad video filter.
  8134. @item color
  8135. Specify the color of the unused area. For the syntax of this option, check the
  8136. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  8137. is "black".
  8138. @end table
  8139. @subsection Examples
  8140. @itemize
  8141. @item
  8142. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  8143. @example
  8144. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  8145. @end example
  8146. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  8147. duplicating each output frame to accommodate the originally detected frame
  8148. rate.
  8149. @item
  8150. Display @code{5} pictures in an area of @code{3x2} frames,
  8151. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  8152. mixed flat and named options:
  8153. @example
  8154. tile=3x2:nb_frames=5:padding=7:margin=2
  8155. @end example
  8156. @end itemize
  8157. @section tinterlace
  8158. Perform various types of temporal field interlacing.
  8159. Frames are counted starting from 1, so the first input frame is
  8160. considered odd.
  8161. The filter accepts the following options:
  8162. @table @option
  8163. @item mode
  8164. Specify the mode of the interlacing. This option can also be specified
  8165. as a value alone. See below for a list of values for this option.
  8166. Available values are:
  8167. @table @samp
  8168. @item merge, 0
  8169. Move odd frames into the upper field, even into the lower field,
  8170. generating a double height frame at half frame rate.
  8171. @example
  8172. ------> time
  8173. Input:
  8174. Frame 1 Frame 2 Frame 3 Frame 4
  8175. 11111 22222 33333 44444
  8176. 11111 22222 33333 44444
  8177. 11111 22222 33333 44444
  8178. 11111 22222 33333 44444
  8179. Output:
  8180. 11111 33333
  8181. 22222 44444
  8182. 11111 33333
  8183. 22222 44444
  8184. 11111 33333
  8185. 22222 44444
  8186. 11111 33333
  8187. 22222 44444
  8188. @end example
  8189. @item drop_odd, 1
  8190. Only output even frames, odd frames are dropped, generating a frame with
  8191. unchanged height at half frame rate.
  8192. @example
  8193. ------> time
  8194. Input:
  8195. Frame 1 Frame 2 Frame 3 Frame 4
  8196. 11111 22222 33333 44444
  8197. 11111 22222 33333 44444
  8198. 11111 22222 33333 44444
  8199. 11111 22222 33333 44444
  8200. Output:
  8201. 22222 44444
  8202. 22222 44444
  8203. 22222 44444
  8204. 22222 44444
  8205. @end example
  8206. @item drop_even, 2
  8207. Only output odd frames, even frames are dropped, generating a frame with
  8208. unchanged height at half frame rate.
  8209. @example
  8210. ------> time
  8211. Input:
  8212. Frame 1 Frame 2 Frame 3 Frame 4
  8213. 11111 22222 33333 44444
  8214. 11111 22222 33333 44444
  8215. 11111 22222 33333 44444
  8216. 11111 22222 33333 44444
  8217. Output:
  8218. 11111 33333
  8219. 11111 33333
  8220. 11111 33333
  8221. 11111 33333
  8222. @end example
  8223. @item pad, 3
  8224. Expand each frame to full height, but pad alternate lines with black,
  8225. generating a frame with double height at the same input frame rate.
  8226. @example
  8227. ------> time
  8228. Input:
  8229. Frame 1 Frame 2 Frame 3 Frame 4
  8230. 11111 22222 33333 44444
  8231. 11111 22222 33333 44444
  8232. 11111 22222 33333 44444
  8233. 11111 22222 33333 44444
  8234. Output:
  8235. 11111 ..... 33333 .....
  8236. ..... 22222 ..... 44444
  8237. 11111 ..... 33333 .....
  8238. ..... 22222 ..... 44444
  8239. 11111 ..... 33333 .....
  8240. ..... 22222 ..... 44444
  8241. 11111 ..... 33333 .....
  8242. ..... 22222 ..... 44444
  8243. @end example
  8244. @item interleave_top, 4
  8245. Interleave the upper field from odd frames with the lower field from
  8246. even frames, generating a frame with unchanged height at half frame rate.
  8247. @example
  8248. ------> time
  8249. Input:
  8250. Frame 1 Frame 2 Frame 3 Frame 4
  8251. 11111<- 22222 33333<- 44444
  8252. 11111 22222<- 33333 44444<-
  8253. 11111<- 22222 33333<- 44444
  8254. 11111 22222<- 33333 44444<-
  8255. Output:
  8256. 11111 33333
  8257. 22222 44444
  8258. 11111 33333
  8259. 22222 44444
  8260. @end example
  8261. @item interleave_bottom, 5
  8262. Interleave the lower field from odd frames with the upper field from
  8263. even frames, generating a frame with unchanged height at half frame rate.
  8264. @example
  8265. ------> time
  8266. Input:
  8267. Frame 1 Frame 2 Frame 3 Frame 4
  8268. 11111 22222<- 33333 44444<-
  8269. 11111<- 22222 33333<- 44444
  8270. 11111 22222<- 33333 44444<-
  8271. 11111<- 22222 33333<- 44444
  8272. Output:
  8273. 22222 44444
  8274. 11111 33333
  8275. 22222 44444
  8276. 11111 33333
  8277. @end example
  8278. @item interlacex2, 6
  8279. Double frame rate with unchanged height. Frames are inserted each
  8280. containing the second temporal field from the previous input frame and
  8281. the first temporal field from the next input frame. This mode relies on
  8282. the top_field_first flag. Useful for interlaced video displays with no
  8283. field synchronisation.
  8284. @example
  8285. ------> time
  8286. Input:
  8287. Frame 1 Frame 2 Frame 3 Frame 4
  8288. 11111 22222 33333 44444
  8289. 11111 22222 33333 44444
  8290. 11111 22222 33333 44444
  8291. 11111 22222 33333 44444
  8292. Output:
  8293. 11111 22222 22222 33333 33333 44444 44444
  8294. 11111 11111 22222 22222 33333 33333 44444
  8295. 11111 22222 22222 33333 33333 44444 44444
  8296. 11111 11111 22222 22222 33333 33333 44444
  8297. @end example
  8298. @item mergex2, 7
  8299. Move odd frames into the upper field, even into the lower field,
  8300. generating a double height frame at same frame rate.
  8301. @example
  8302. ------> time
  8303. Input:
  8304. Frame 1 Frame 2 Frame 3 Frame 4
  8305. 11111 22222 33333 44444
  8306. 11111 22222 33333 44444
  8307. 11111 22222 33333 44444
  8308. 11111 22222 33333 44444
  8309. Output:
  8310. 11111 33333 33333 55555
  8311. 22222 22222 44444 44444
  8312. 11111 33333 33333 55555
  8313. 22222 22222 44444 44444
  8314. 11111 33333 33333 55555
  8315. 22222 22222 44444 44444
  8316. 11111 33333 33333 55555
  8317. 22222 22222 44444 44444
  8318. @end example
  8319. @end table
  8320. Numeric values are deprecated but are accepted for backward
  8321. compatibility reasons.
  8322. Default mode is @code{merge}.
  8323. @item flags
  8324. Specify flags influencing the filter process.
  8325. Available value for @var{flags} is:
  8326. @table @option
  8327. @item low_pass_filter, vlfp
  8328. Enable vertical low-pass filtering in the filter.
  8329. Vertical low-pass filtering is required when creating an interlaced
  8330. destination from a progressive source which contains high-frequency
  8331. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  8332. patterning.
  8333. Vertical low-pass filtering can only be enabled for @option{mode}
  8334. @var{interleave_top} and @var{interleave_bottom}.
  8335. @end table
  8336. @end table
  8337. @section transpose
  8338. Transpose rows with columns in the input video and optionally flip it.
  8339. It accepts the following parameters:
  8340. @table @option
  8341. @item dir
  8342. Specify the transposition direction.
  8343. Can assume the following values:
  8344. @table @samp
  8345. @item 0, 4, cclock_flip
  8346. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  8347. @example
  8348. L.R L.l
  8349. . . -> . .
  8350. l.r R.r
  8351. @end example
  8352. @item 1, 5, clock
  8353. Rotate by 90 degrees clockwise, that is:
  8354. @example
  8355. L.R l.L
  8356. . . -> . .
  8357. l.r r.R
  8358. @end example
  8359. @item 2, 6, cclock
  8360. Rotate by 90 degrees counterclockwise, that is:
  8361. @example
  8362. L.R R.r
  8363. . . -> . .
  8364. l.r L.l
  8365. @end example
  8366. @item 3, 7, clock_flip
  8367. Rotate by 90 degrees clockwise and vertically flip, that is:
  8368. @example
  8369. L.R r.R
  8370. . . -> . .
  8371. l.r l.L
  8372. @end example
  8373. @end table
  8374. For values between 4-7, the transposition is only done if the input
  8375. video geometry is portrait and not landscape. These values are
  8376. deprecated, the @code{passthrough} option should be used instead.
  8377. Numerical values are deprecated, and should be dropped in favor of
  8378. symbolic constants.
  8379. @item passthrough
  8380. Do not apply the transposition if the input geometry matches the one
  8381. specified by the specified value. It accepts the following values:
  8382. @table @samp
  8383. @item none
  8384. Always apply transposition.
  8385. @item portrait
  8386. Preserve portrait geometry (when @var{height} >= @var{width}).
  8387. @item landscape
  8388. Preserve landscape geometry (when @var{width} >= @var{height}).
  8389. @end table
  8390. Default value is @code{none}.
  8391. @end table
  8392. For example to rotate by 90 degrees clockwise and preserve portrait
  8393. layout:
  8394. @example
  8395. transpose=dir=1:passthrough=portrait
  8396. @end example
  8397. The command above can also be specified as:
  8398. @example
  8399. transpose=1:portrait
  8400. @end example
  8401. @section trim
  8402. Trim the input so that the output contains one continuous subpart of the input.
  8403. It accepts the following parameters:
  8404. @table @option
  8405. @item start
  8406. Specify the time of the start of the kept section, i.e. the frame with the
  8407. timestamp @var{start} will be the first frame in the output.
  8408. @item end
  8409. Specify the time of the first frame that will be dropped, i.e. the frame
  8410. immediately preceding the one with the timestamp @var{end} will be the last
  8411. frame in the output.
  8412. @item start_pts
  8413. This is the same as @var{start}, except this option sets the start timestamp
  8414. in timebase units instead of seconds.
  8415. @item end_pts
  8416. This is the same as @var{end}, except this option sets the end timestamp
  8417. in timebase units instead of seconds.
  8418. @item duration
  8419. The maximum duration of the output in seconds.
  8420. @item start_frame
  8421. The number of the first frame that should be passed to the output.
  8422. @item end_frame
  8423. The number of the first frame that should be dropped.
  8424. @end table
  8425. @option{start}, @option{end}, and @option{duration} are expressed as time
  8426. duration specifications; see
  8427. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  8428. for the accepted syntax.
  8429. Note that the first two sets of the start/end options and the @option{duration}
  8430. option look at the frame timestamp, while the _frame variants simply count the
  8431. frames that pass through the filter. Also note that this filter does not modify
  8432. the timestamps. If you wish for the output timestamps to start at zero, insert a
  8433. setpts filter after the trim filter.
  8434. If multiple start or end options are set, this filter tries to be greedy and
  8435. keep all the frames that match at least one of the specified constraints. To keep
  8436. only the part that matches all the constraints at once, chain multiple trim
  8437. filters.
  8438. The defaults are such that all the input is kept. So it is possible to set e.g.
  8439. just the end values to keep everything before the specified time.
  8440. Examples:
  8441. @itemize
  8442. @item
  8443. Drop everything except the second minute of input:
  8444. @example
  8445. ffmpeg -i INPUT -vf trim=60:120
  8446. @end example
  8447. @item
  8448. Keep only the first second:
  8449. @example
  8450. ffmpeg -i INPUT -vf trim=duration=1
  8451. @end example
  8452. @end itemize
  8453. @anchor{unsharp}
  8454. @section unsharp
  8455. Sharpen or blur the input video.
  8456. It accepts the following parameters:
  8457. @table @option
  8458. @item luma_msize_x, lx
  8459. Set the luma matrix horizontal size. It must be an odd integer between
  8460. 3 and 63. The default value is 5.
  8461. @item luma_msize_y, ly
  8462. Set the luma matrix vertical size. It must be an odd integer between 3
  8463. and 63. The default value is 5.
  8464. @item luma_amount, la
  8465. Set the luma effect strength. It must be a floating point number, reasonable
  8466. values lay between -1.5 and 1.5.
  8467. Negative values will blur the input video, while positive values will
  8468. sharpen it, a value of zero will disable the effect.
  8469. Default value is 1.0.
  8470. @item chroma_msize_x, cx
  8471. Set the chroma matrix horizontal size. It must be an odd integer
  8472. between 3 and 63. The default value is 5.
  8473. @item chroma_msize_y, cy
  8474. Set the chroma matrix vertical size. It must be an odd integer
  8475. between 3 and 63. The default value is 5.
  8476. @item chroma_amount, ca
  8477. Set the chroma effect strength. It must be a floating point number, reasonable
  8478. values lay between -1.5 and 1.5.
  8479. Negative values will blur the input video, while positive values will
  8480. sharpen it, a value of zero will disable the effect.
  8481. Default value is 0.0.
  8482. @item opencl
  8483. If set to 1, specify using OpenCL capabilities, only available if
  8484. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  8485. @end table
  8486. All parameters are optional and default to the equivalent of the
  8487. string '5:5:1.0:5:5:0.0'.
  8488. @subsection Examples
  8489. @itemize
  8490. @item
  8491. Apply strong luma sharpen effect:
  8492. @example
  8493. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  8494. @end example
  8495. @item
  8496. Apply a strong blur of both luma and chroma parameters:
  8497. @example
  8498. unsharp=7:7:-2:7:7:-2
  8499. @end example
  8500. @end itemize
  8501. @section uspp
  8502. Apply ultra slow/simple postprocessing filter that compresses and decompresses
  8503. the image at several (or - in the case of @option{quality} level @code{8} - all)
  8504. shifts and average the results.
  8505. The way this differs from the behavior of spp is that uspp actually encodes &
  8506. decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
  8507. DCT similar to MJPEG.
  8508. The filter accepts the following options:
  8509. @table @option
  8510. @item quality
  8511. Set quality. This option defines the number of levels for averaging. It accepts
  8512. an integer in the range 0-8. If set to @code{0}, the filter will have no
  8513. effect. A value of @code{8} means the higher quality. For each increment of
  8514. that value the speed drops by a factor of approximately 2. Default value is
  8515. @code{3}.
  8516. @item qp
  8517. Force a constant quantization parameter. If not set, the filter will use the QP
  8518. from the video stream (if available).
  8519. @end table
  8520. @section vectorscope
  8521. Display 2 color component values in the two dimensional graph (which is called
  8522. a vectorscope).
  8523. This filter accepts the following options:
  8524. @table @option
  8525. @item mode, m
  8526. Set vectorscope mode.
  8527. It accepts the following values:
  8528. @table @samp
  8529. @item gray
  8530. Gray values are displayed on graph, higher brightness means more pixels have
  8531. same component color value on location in graph. This is the default mode.
  8532. @item color
  8533. Gray values are displayed on graph. Surrounding pixels values which are not
  8534. present in video frame are drawn in gradient of 2 color components which are
  8535. set by option @code{x} and @code{y}.
  8536. @item color2
  8537. Actual color components values present in video frame are displayed on graph.
  8538. @item color3
  8539. Similar as color2 but higher frequency of same values @code{x} and @code{y}
  8540. on graph increases value of another color component, which is luminance by
  8541. default values of @code{x} and @code{y}.
  8542. @item color4
  8543. Actual colors present in video frame are displayed on graph. If two different
  8544. colors map to same position on graph then color with higher value of component
  8545. not present in graph is picked.
  8546. @end table
  8547. @item x
  8548. Set which color component will be represented on X-axis. Default is @code{1}.
  8549. @item y
  8550. Set which color component will be represented on Y-axis. Default is @code{2}.
  8551. @item intensity, i
  8552. Set intensity, used by modes: gray, color and color3 for increasing brightness
  8553. of color component which represents frequency of (X, Y) location in graph.
  8554. @item envelope, e
  8555. @table @samp
  8556. @item none
  8557. No envelope, this is default.
  8558. @item instant
  8559. Instant envelope, even darkest single pixel will be clearly highlighted.
  8560. @item peak
  8561. Hold maximum and minimum values presented in graph over time. This way you
  8562. can still spot out of range values without constantly looking at vectorscope.
  8563. @item peak+instant
  8564. Peak and instant envelope combined together.
  8565. @end table
  8566. @end table
  8567. @anchor{vidstabdetect}
  8568. @section vidstabdetect
  8569. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  8570. @ref{vidstabtransform} for pass 2.
  8571. This filter generates a file with relative translation and rotation
  8572. transform information about subsequent frames, which is then used by
  8573. the @ref{vidstabtransform} filter.
  8574. To enable compilation of this filter you need to configure FFmpeg with
  8575. @code{--enable-libvidstab}.
  8576. This filter accepts the following options:
  8577. @table @option
  8578. @item result
  8579. Set the path to the file used to write the transforms information.
  8580. Default value is @file{transforms.trf}.
  8581. @item shakiness
  8582. Set how shaky the video is and how quick the camera is. It accepts an
  8583. integer in the range 1-10, a value of 1 means little shakiness, a
  8584. value of 10 means strong shakiness. Default value is 5.
  8585. @item accuracy
  8586. Set the accuracy of the detection process. It must be a value in the
  8587. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  8588. accuracy. Default value is 15.
  8589. @item stepsize
  8590. Set stepsize of the search process. The region around minimum is
  8591. scanned with 1 pixel resolution. Default value is 6.
  8592. @item mincontrast
  8593. Set minimum contrast. Below this value a local measurement field is
  8594. discarded. Must be a floating point value in the range 0-1. Default
  8595. value is 0.3.
  8596. @item tripod
  8597. Set reference frame number for tripod mode.
  8598. If enabled, the motion of the frames is compared to a reference frame
  8599. in the filtered stream, identified by the specified number. The idea
  8600. is to compensate all movements in a more-or-less static scene and keep
  8601. the camera view absolutely still.
  8602. If set to 0, it is disabled. The frames are counted starting from 1.
  8603. @item show
  8604. Show fields and transforms in the resulting frames. It accepts an
  8605. integer in the range 0-2. Default value is 0, which disables any
  8606. visualization.
  8607. @end table
  8608. @subsection Examples
  8609. @itemize
  8610. @item
  8611. Use default values:
  8612. @example
  8613. vidstabdetect
  8614. @end example
  8615. @item
  8616. Analyze strongly shaky movie and put the results in file
  8617. @file{mytransforms.trf}:
  8618. @example
  8619. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  8620. @end example
  8621. @item
  8622. Visualize the result of internal transformations in the resulting
  8623. video:
  8624. @example
  8625. vidstabdetect=show=1
  8626. @end example
  8627. @item
  8628. Analyze a video with medium shakiness using @command{ffmpeg}:
  8629. @example
  8630. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  8631. @end example
  8632. @end itemize
  8633. @anchor{vidstabtransform}
  8634. @section vidstabtransform
  8635. Video stabilization/deshaking: pass 2 of 2,
  8636. see @ref{vidstabdetect} for pass 1.
  8637. Read a file with transform information for each frame and
  8638. apply/compensate them. Together with the @ref{vidstabdetect}
  8639. filter this can be used to deshake videos. See also
  8640. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  8641. the @ref{unsharp} filter, see below.
  8642. To enable compilation of this filter you need to configure FFmpeg with
  8643. @code{--enable-libvidstab}.
  8644. @subsection Options
  8645. @table @option
  8646. @item input
  8647. Set path to the file used to read the transforms. Default value is
  8648. @file{transforms.trf}.
  8649. @item smoothing
  8650. Set the number of frames (value*2 + 1) used for lowpass filtering the
  8651. camera movements. Default value is 10.
  8652. For example a number of 10 means that 21 frames are used (10 in the
  8653. past and 10 in the future) to smoothen the motion in the video. A
  8654. larger value leads to a smoother video, but limits the acceleration of
  8655. the camera (pan/tilt movements). 0 is a special case where a static
  8656. camera is simulated.
  8657. @item optalgo
  8658. Set the camera path optimization algorithm.
  8659. Accepted values are:
  8660. @table @samp
  8661. @item gauss
  8662. gaussian kernel low-pass filter on camera motion (default)
  8663. @item avg
  8664. averaging on transformations
  8665. @end table
  8666. @item maxshift
  8667. Set maximal number of pixels to translate frames. Default value is -1,
  8668. meaning no limit.
  8669. @item maxangle
  8670. Set maximal angle in radians (degree*PI/180) to rotate frames. Default
  8671. value is -1, meaning no limit.
  8672. @item crop
  8673. Specify how to deal with borders that may be visible due to movement
  8674. compensation.
  8675. Available values are:
  8676. @table @samp
  8677. @item keep
  8678. keep image information from previous frame (default)
  8679. @item black
  8680. fill the border black
  8681. @end table
  8682. @item invert
  8683. Invert transforms if set to 1. Default value is 0.
  8684. @item relative
  8685. Consider transforms as relative to previous frame if set to 1,
  8686. absolute if set to 0. Default value is 0.
  8687. @item zoom
  8688. Set percentage to zoom. A positive value will result in a zoom-in
  8689. effect, a negative value in a zoom-out effect. Default value is 0 (no
  8690. zoom).
  8691. @item optzoom
  8692. Set optimal zooming to avoid borders.
  8693. Accepted values are:
  8694. @table @samp
  8695. @item 0
  8696. disabled
  8697. @item 1
  8698. optimal static zoom value is determined (only very strong movements
  8699. will lead to visible borders) (default)
  8700. @item 2
  8701. optimal adaptive zoom value is determined (no borders will be
  8702. visible), see @option{zoomspeed}
  8703. @end table
  8704. Note that the value given at zoom is added to the one calculated here.
  8705. @item zoomspeed
  8706. Set percent to zoom maximally each frame (enabled when
  8707. @option{optzoom} is set to 2). Range is from 0 to 5, default value is
  8708. 0.25.
  8709. @item interpol
  8710. Specify type of interpolation.
  8711. Available values are:
  8712. @table @samp
  8713. @item no
  8714. no interpolation
  8715. @item linear
  8716. linear only horizontal
  8717. @item bilinear
  8718. linear in both directions (default)
  8719. @item bicubic
  8720. cubic in both directions (slow)
  8721. @end table
  8722. @item tripod
  8723. Enable virtual tripod mode if set to 1, which is equivalent to
  8724. @code{relative=0:smoothing=0}. Default value is 0.
  8725. Use also @code{tripod} option of @ref{vidstabdetect}.
  8726. @item debug
  8727. Increase log verbosity if set to 1. Also the detected global motions
  8728. are written to the temporary file @file{global_motions.trf}. Default
  8729. value is 0.
  8730. @end table
  8731. @subsection Examples
  8732. @itemize
  8733. @item
  8734. Use @command{ffmpeg} for a typical stabilization with default values:
  8735. @example
  8736. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  8737. @end example
  8738. Note the use of the @ref{unsharp} filter which is always recommended.
  8739. @item
  8740. Zoom in a bit more and load transform data from a given file:
  8741. @example
  8742. vidstabtransform=zoom=5:input="mytransforms.trf"
  8743. @end example
  8744. @item
  8745. Smoothen the video even more:
  8746. @example
  8747. vidstabtransform=smoothing=30
  8748. @end example
  8749. @end itemize
  8750. @section vflip
  8751. Flip the input video vertically.
  8752. For example, to vertically flip a video with @command{ffmpeg}:
  8753. @example
  8754. ffmpeg -i in.avi -vf "vflip" out.avi
  8755. @end example
  8756. @anchor{vignette}
  8757. @section vignette
  8758. Make or reverse a natural vignetting effect.
  8759. The filter accepts the following options:
  8760. @table @option
  8761. @item angle, a
  8762. Set lens angle expression as a number of radians.
  8763. The value is clipped in the @code{[0,PI/2]} range.
  8764. Default value: @code{"PI/5"}
  8765. @item x0
  8766. @item y0
  8767. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  8768. by default.
  8769. @item mode
  8770. Set forward/backward mode.
  8771. Available modes are:
  8772. @table @samp
  8773. @item forward
  8774. The larger the distance from the central point, the darker the image becomes.
  8775. @item backward
  8776. The larger the distance from the central point, the brighter the image becomes.
  8777. This can be used to reverse a vignette effect, though there is no automatic
  8778. detection to extract the lens @option{angle} and other settings (yet). It can
  8779. also be used to create a burning effect.
  8780. @end table
  8781. Default value is @samp{forward}.
  8782. @item eval
  8783. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  8784. It accepts the following values:
  8785. @table @samp
  8786. @item init
  8787. Evaluate expressions only once during the filter initialization.
  8788. @item frame
  8789. Evaluate expressions for each incoming frame. This is way slower than the
  8790. @samp{init} mode since it requires all the scalers to be re-computed, but it
  8791. allows advanced dynamic expressions.
  8792. @end table
  8793. Default value is @samp{init}.
  8794. @item dither
  8795. Set dithering to reduce the circular banding effects. Default is @code{1}
  8796. (enabled).
  8797. @item aspect
  8798. Set vignette aspect. This setting allows one to adjust the shape of the vignette.
  8799. Setting this value to the SAR of the input will make a rectangular vignetting
  8800. following the dimensions of the video.
  8801. Default is @code{1/1}.
  8802. @end table
  8803. @subsection Expressions
  8804. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  8805. following parameters.
  8806. @table @option
  8807. @item w
  8808. @item h
  8809. input width and height
  8810. @item n
  8811. the number of input frame, starting from 0
  8812. @item pts
  8813. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  8814. @var{TB} units, NAN if undefined
  8815. @item r
  8816. frame rate of the input video, NAN if the input frame rate is unknown
  8817. @item t
  8818. the PTS (Presentation TimeStamp) of the filtered video frame,
  8819. expressed in seconds, NAN if undefined
  8820. @item tb
  8821. time base of the input video
  8822. @end table
  8823. @subsection Examples
  8824. @itemize
  8825. @item
  8826. Apply simple strong vignetting effect:
  8827. @example
  8828. vignette=PI/4
  8829. @end example
  8830. @item
  8831. Make a flickering vignetting:
  8832. @example
  8833. vignette='PI/4+random(1)*PI/50':eval=frame
  8834. @end example
  8835. @end itemize
  8836. @section vstack
  8837. Stack input videos vertically.
  8838. All streams must be of same pixel format and of same width.
  8839. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  8840. to create same output.
  8841. The filter accept the following option:
  8842. @table @option
  8843. @item nb_inputs
  8844. Set number of input streams. Default is 2.
  8845. @end table
  8846. @section w3fdif
  8847. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  8848. Deinterlacing Filter").
  8849. Based on the process described by Martin Weston for BBC R&D, and
  8850. implemented based on the de-interlace algorithm written by Jim
  8851. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  8852. uses filter coefficients calculated by BBC R&D.
  8853. There are two sets of filter coefficients, so called "simple":
  8854. and "complex". Which set of filter coefficients is used can
  8855. be set by passing an optional parameter:
  8856. @table @option
  8857. @item filter
  8858. Set the interlacing filter coefficients. Accepts one of the following values:
  8859. @table @samp
  8860. @item simple
  8861. Simple filter coefficient set.
  8862. @item complex
  8863. More-complex filter coefficient set.
  8864. @end table
  8865. Default value is @samp{complex}.
  8866. @item deint
  8867. Specify which frames to deinterlace. Accept one of the following values:
  8868. @table @samp
  8869. @item all
  8870. Deinterlace all frames,
  8871. @item interlaced
  8872. Only deinterlace frames marked as interlaced.
  8873. @end table
  8874. Default value is @samp{all}.
  8875. @end table
  8876. @section waveform
  8877. Video waveform monitor.
  8878. The waveform monitor plots color component intensity. By default luminance
  8879. only. Each column of the waveform corresponds to a column of pixels in the
  8880. source video.
  8881. It accepts the following options:
  8882. @table @option
  8883. @item mode, m
  8884. Can be either @code{row}, or @code{column}. Default is @code{column}.
  8885. In row mode, the graph on the left side represents color component value 0 and
  8886. the right side represents value = 255. In column mode, the top side represents
  8887. color component value = 0 and bottom side represents value = 255.
  8888. @item intensity, i
  8889. Set intensity. Smaller values are useful to find out how many values of the same
  8890. luminance are distributed across input rows/columns.
  8891. Default value is @code{0.04}. Allowed range is [0, 1].
  8892. @item mirror, r
  8893. Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored.
  8894. In mirrored mode, higher values will be represented on the left
  8895. side for @code{row} mode and at the top for @code{column} mode. Default is
  8896. @code{1} (mirrored).
  8897. @item display, d
  8898. Set display mode.
  8899. It accepts the following values:
  8900. @table @samp
  8901. @item overlay
  8902. Presents information identical to that in the @code{parade}, except
  8903. that the graphs representing color components are superimposed directly
  8904. over one another.
  8905. This display mode makes it easier to spot relative differences or similarities
  8906. in overlapping areas of the color components that are supposed to be identical,
  8907. such as neutral whites, grays, or blacks.
  8908. @item parade
  8909. Display separate graph for the color components side by side in
  8910. @code{row} mode or one below the other in @code{column} mode.
  8911. Using this display mode makes it easy to spot color casts in the highlights
  8912. and shadows of an image, by comparing the contours of the top and the bottom
  8913. graphs of each waveform. Since whites, grays, and blacks are characterized
  8914. by exactly equal amounts of red, green, and blue, neutral areas of the picture
  8915. should display three waveforms of roughly equal width/height. If not, the
  8916. correction is easy to perform by making level adjustments the three waveforms.
  8917. @end table
  8918. Default is @code{parade}.
  8919. @item components, c
  8920. Set which color components to display. Default is 1, which means only luminance
  8921. or red color component if input is in RGB colorspace. If is set for example to
  8922. 7 it will display all 3 (if) available color components.
  8923. @item envelope, e
  8924. @table @samp
  8925. @item none
  8926. No envelope, this is default.
  8927. @item instant
  8928. Instant envelope, minimum and maximum values presented in graph will be easily
  8929. visible even with small @code{step} value.
  8930. @item peak
  8931. Hold minimum and maximum values presented in graph across time. This way you
  8932. can still spot out of range values without constantly looking at waveforms.
  8933. @item peak+instant
  8934. Peak and instant envelope combined together.
  8935. @end table
  8936. @item filter, f
  8937. @table @samp
  8938. @item lowpass
  8939. No filtering, this is default.
  8940. @item flat
  8941. Luma and chroma combined together.
  8942. @item aflat
  8943. Similar as above, but shows difference between blue and red chroma.
  8944. @item chroma
  8945. Displays only chroma.
  8946. @item achroma
  8947. Similar as above, but shows difference between blue and red chroma.
  8948. @item color
  8949. Displays actual color value on waveform.
  8950. @end table
  8951. @end table
  8952. @section xbr
  8953. Apply the xBR high-quality magnification filter which is designed for pixel
  8954. art. It follows a set of edge-detection rules, see
  8955. @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
  8956. It accepts the following option:
  8957. @table @option
  8958. @item n
  8959. Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
  8960. @code{3xBR} and @code{4} for @code{4xBR}.
  8961. Default is @code{3}.
  8962. @end table
  8963. @anchor{yadif}
  8964. @section yadif
  8965. Deinterlace the input video ("yadif" means "yet another deinterlacing
  8966. filter").
  8967. It accepts the following parameters:
  8968. @table @option
  8969. @item mode
  8970. The interlacing mode to adopt. It accepts one of the following values:
  8971. @table @option
  8972. @item 0, send_frame
  8973. Output one frame for each frame.
  8974. @item 1, send_field
  8975. Output one frame for each field.
  8976. @item 2, send_frame_nospatial
  8977. Like @code{send_frame}, but it skips the spatial interlacing check.
  8978. @item 3, send_field_nospatial
  8979. Like @code{send_field}, but it skips the spatial interlacing check.
  8980. @end table
  8981. The default value is @code{send_frame}.
  8982. @item parity
  8983. The picture field parity assumed for the input interlaced video. It accepts one
  8984. of the following values:
  8985. @table @option
  8986. @item 0, tff
  8987. Assume the top field is first.
  8988. @item 1, bff
  8989. Assume the bottom field is first.
  8990. @item -1, auto
  8991. Enable automatic detection of field parity.
  8992. @end table
  8993. The default value is @code{auto}.
  8994. If the interlacing is unknown or the decoder does not export this information,
  8995. top field first will be assumed.
  8996. @item deint
  8997. Specify which frames to deinterlace. Accept one of the following
  8998. values:
  8999. @table @option
  9000. @item 0, all
  9001. Deinterlace all frames.
  9002. @item 1, interlaced
  9003. Only deinterlace frames marked as interlaced.
  9004. @end table
  9005. The default value is @code{all}.
  9006. @end table
  9007. @section zoompan
  9008. Apply Zoom & Pan effect.
  9009. This filter accepts the following options:
  9010. @table @option
  9011. @item zoom, z
  9012. Set the zoom expression. Default is 1.
  9013. @item x
  9014. @item y
  9015. Set the x and y expression. Default is 0.
  9016. @item d
  9017. Set the duration expression in number of frames.
  9018. This sets for how many number of frames effect will last for
  9019. single input image.
  9020. @item s
  9021. Set the output image size, default is 'hd720'.
  9022. @end table
  9023. Each expression can contain the following constants:
  9024. @table @option
  9025. @item in_w, iw
  9026. Input width.
  9027. @item in_h, ih
  9028. Input height.
  9029. @item out_w, ow
  9030. Output width.
  9031. @item out_h, oh
  9032. Output height.
  9033. @item in
  9034. Input frame count.
  9035. @item on
  9036. Output frame count.
  9037. @item x
  9038. @item y
  9039. Last calculated 'x' and 'y' position from 'x' and 'y' expression
  9040. for current input frame.
  9041. @item px
  9042. @item py
  9043. 'x' and 'y' of last output frame of previous input frame or 0 when there was
  9044. not yet such frame (first input frame).
  9045. @item zoom
  9046. Last calculated zoom from 'z' expression for current input frame.
  9047. @item pzoom
  9048. Last calculated zoom of last output frame of previous input frame.
  9049. @item duration
  9050. Number of output frames for current input frame. Calculated from 'd' expression
  9051. for each input frame.
  9052. @item pduration
  9053. number of output frames created for previous input frame
  9054. @item a
  9055. Rational number: input width / input height
  9056. @item sar
  9057. sample aspect ratio
  9058. @item dar
  9059. display aspect ratio
  9060. @end table
  9061. @subsection Examples
  9062. @itemize
  9063. @item
  9064. Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
  9065. @example
  9066. 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
  9067. @end example
  9068. @item
  9069. Zoom-in up to 1.5 and pan always at center of picture:
  9070. @example
  9071. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
  9072. @end example
  9073. @end itemize
  9074. @c man end VIDEO FILTERS
  9075. @chapter Video Sources
  9076. @c man begin VIDEO SOURCES
  9077. Below is a description of the currently available video sources.
  9078. @section buffer
  9079. Buffer video frames, and make them available to the filter chain.
  9080. This source is mainly intended for a programmatic use, in particular
  9081. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  9082. It accepts the following parameters:
  9083. @table @option
  9084. @item video_size
  9085. Specify the size (width and height) of the buffered video frames. For the
  9086. syntax of this option, check the
  9087. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9088. @item width
  9089. The input video width.
  9090. @item height
  9091. The input video height.
  9092. @item pix_fmt
  9093. A string representing the pixel format of the buffered video frames.
  9094. It may be a number corresponding to a pixel format, or a pixel format
  9095. name.
  9096. @item time_base
  9097. Specify the timebase assumed by the timestamps of the buffered frames.
  9098. @item frame_rate
  9099. Specify the frame rate expected for the video stream.
  9100. @item pixel_aspect, sar
  9101. The sample (pixel) aspect ratio of the input video.
  9102. @item sws_param
  9103. Specify the optional parameters to be used for the scale filter which
  9104. is automatically inserted when an input change is detected in the
  9105. input size or format.
  9106. @end table
  9107. For example:
  9108. @example
  9109. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  9110. @end example
  9111. will instruct the source to accept video frames with size 320x240 and
  9112. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  9113. square pixels (1:1 sample aspect ratio).
  9114. Since the pixel format with name "yuv410p" corresponds to the number 6
  9115. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  9116. this example corresponds to:
  9117. @example
  9118. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  9119. @end example
  9120. Alternatively, the options can be specified as a flat string, but this
  9121. syntax is deprecated:
  9122. @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}]
  9123. @section cellauto
  9124. Create a pattern generated by an elementary cellular automaton.
  9125. The initial state of the cellular automaton can be defined through the
  9126. @option{filename}, and @option{pattern} options. If such options are
  9127. not specified an initial state is created randomly.
  9128. At each new frame a new row in the video is filled with the result of
  9129. the cellular automaton next generation. The behavior when the whole
  9130. frame is filled is defined by the @option{scroll} option.
  9131. This source accepts the following options:
  9132. @table @option
  9133. @item filename, f
  9134. Read the initial cellular automaton state, i.e. the starting row, from
  9135. the specified file.
  9136. In the file, each non-whitespace character is considered an alive
  9137. cell, a newline will terminate the row, and further characters in the
  9138. file will be ignored.
  9139. @item pattern, p
  9140. Read the initial cellular automaton state, i.e. the starting row, from
  9141. the specified string.
  9142. Each non-whitespace character in the string is considered an alive
  9143. cell, a newline will terminate the row, and further characters in the
  9144. string will be ignored.
  9145. @item rate, r
  9146. Set the video rate, that is the number of frames generated per second.
  9147. Default is 25.
  9148. @item random_fill_ratio, ratio
  9149. Set the random fill ratio for the initial cellular automaton row. It
  9150. is a floating point number value ranging from 0 to 1, defaults to
  9151. 1/PHI.
  9152. This option is ignored when a file or a pattern is specified.
  9153. @item random_seed, seed
  9154. Set the seed for filling randomly the initial row, must be an integer
  9155. included between 0 and UINT32_MAX. If not specified, or if explicitly
  9156. set to -1, the filter will try to use a good random seed on a best
  9157. effort basis.
  9158. @item rule
  9159. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  9160. Default value is 110.
  9161. @item size, s
  9162. Set the size of the output video. For the syntax of this option, check the
  9163. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9164. If @option{filename} or @option{pattern} is specified, the size is set
  9165. by default to the width of the specified initial state row, and the
  9166. height is set to @var{width} * PHI.
  9167. If @option{size} is set, it must contain the width of the specified
  9168. pattern string, and the specified pattern will be centered in the
  9169. larger row.
  9170. If a filename or a pattern string is not specified, the size value
  9171. defaults to "320x518" (used for a randomly generated initial state).
  9172. @item scroll
  9173. If set to 1, scroll the output upward when all the rows in the output
  9174. have been already filled. If set to 0, the new generated row will be
  9175. written over the top row just after the bottom row is filled.
  9176. Defaults to 1.
  9177. @item start_full, full
  9178. If set to 1, completely fill the output with generated rows before
  9179. outputting the first frame.
  9180. This is the default behavior, for disabling set the value to 0.
  9181. @item stitch
  9182. If set to 1, stitch the left and right row edges together.
  9183. This is the default behavior, for disabling set the value to 0.
  9184. @end table
  9185. @subsection Examples
  9186. @itemize
  9187. @item
  9188. Read the initial state from @file{pattern}, and specify an output of
  9189. size 200x400.
  9190. @example
  9191. cellauto=f=pattern:s=200x400
  9192. @end example
  9193. @item
  9194. Generate a random initial row with a width of 200 cells, with a fill
  9195. ratio of 2/3:
  9196. @example
  9197. cellauto=ratio=2/3:s=200x200
  9198. @end example
  9199. @item
  9200. Create a pattern generated by rule 18 starting by a single alive cell
  9201. centered on an initial row with width 100:
  9202. @example
  9203. cellauto=p=@@:s=100x400:full=0:rule=18
  9204. @end example
  9205. @item
  9206. Specify a more elaborated initial pattern:
  9207. @example
  9208. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  9209. @end example
  9210. @end itemize
  9211. @section mandelbrot
  9212. Generate a Mandelbrot set fractal, and progressively zoom towards the
  9213. point specified with @var{start_x} and @var{start_y}.
  9214. This source accepts the following options:
  9215. @table @option
  9216. @item end_pts
  9217. Set the terminal pts value. Default value is 400.
  9218. @item end_scale
  9219. Set the terminal scale value.
  9220. Must be a floating point value. Default value is 0.3.
  9221. @item inner
  9222. Set the inner coloring mode, that is the algorithm used to draw the
  9223. Mandelbrot fractal internal region.
  9224. It shall assume one of the following values:
  9225. @table @option
  9226. @item black
  9227. Set black mode.
  9228. @item convergence
  9229. Show time until convergence.
  9230. @item mincol
  9231. Set color based on point closest to the origin of the iterations.
  9232. @item period
  9233. Set period mode.
  9234. @end table
  9235. Default value is @var{mincol}.
  9236. @item bailout
  9237. Set the bailout value. Default value is 10.0.
  9238. @item maxiter
  9239. Set the maximum of iterations performed by the rendering
  9240. algorithm. Default value is 7189.
  9241. @item outer
  9242. Set outer coloring mode.
  9243. It shall assume one of following values:
  9244. @table @option
  9245. @item iteration_count
  9246. Set iteration cound mode.
  9247. @item normalized_iteration_count
  9248. set normalized iteration count mode.
  9249. @end table
  9250. Default value is @var{normalized_iteration_count}.
  9251. @item rate, r
  9252. Set frame rate, expressed as number of frames per second. Default
  9253. value is "25".
  9254. @item size, s
  9255. Set frame size. For the syntax of this option, check the "Video
  9256. size" section in the ffmpeg-utils manual. Default value is "640x480".
  9257. @item start_scale
  9258. Set the initial scale value. Default value is 3.0.
  9259. @item start_x
  9260. Set the initial x position. Must be a floating point value between
  9261. -100 and 100. Default value is -0.743643887037158704752191506114774.
  9262. @item start_y
  9263. Set the initial y position. Must be a floating point value between
  9264. -100 and 100. Default value is -0.131825904205311970493132056385139.
  9265. @end table
  9266. @section mptestsrc
  9267. Generate various test patterns, as generated by the MPlayer test filter.
  9268. The size of the generated video is fixed, and is 256x256.
  9269. This source is useful in particular for testing encoding features.
  9270. This source accepts the following options:
  9271. @table @option
  9272. @item rate, r
  9273. Specify the frame rate of the sourced video, as the number of frames
  9274. generated per second. It has to be a string in the format
  9275. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  9276. number or a valid video frame rate abbreviation. The default value is
  9277. "25".
  9278. @item duration, d
  9279. Set the duration of the sourced video. See
  9280. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  9281. for the accepted syntax.
  9282. If not specified, or the expressed duration is negative, the video is
  9283. supposed to be generated forever.
  9284. @item test, t
  9285. Set the number or the name of the test to perform. Supported tests are:
  9286. @table @option
  9287. @item dc_luma
  9288. @item dc_chroma
  9289. @item freq_luma
  9290. @item freq_chroma
  9291. @item amp_luma
  9292. @item amp_chroma
  9293. @item cbp
  9294. @item mv
  9295. @item ring1
  9296. @item ring2
  9297. @item all
  9298. @end table
  9299. Default value is "all", which will cycle through the list of all tests.
  9300. @end table
  9301. Some examples:
  9302. @example
  9303. mptestsrc=t=dc_luma
  9304. @end example
  9305. will generate a "dc_luma" test pattern.
  9306. @section frei0r_src
  9307. Provide a frei0r source.
  9308. To enable compilation of this filter you need to install the frei0r
  9309. header and configure FFmpeg with @code{--enable-frei0r}.
  9310. This source accepts the following parameters:
  9311. @table @option
  9312. @item size
  9313. The size of the video to generate. For the syntax of this option, check the
  9314. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9315. @item framerate
  9316. The framerate of the generated video. It may be a string of the form
  9317. @var{num}/@var{den} or a frame rate abbreviation.
  9318. @item filter_name
  9319. The name to the frei0r source to load. For more information regarding frei0r and
  9320. how to set the parameters, read the @ref{frei0r} section in the video filters
  9321. documentation.
  9322. @item filter_params
  9323. A '|'-separated list of parameters to pass to the frei0r source.
  9324. @end table
  9325. For example, to generate a frei0r partik0l source with size 200x200
  9326. and frame rate 10 which is overlaid on the overlay filter main input:
  9327. @example
  9328. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  9329. @end example
  9330. @section life
  9331. Generate a life pattern.
  9332. This source is based on a generalization of John Conway's life game.
  9333. The sourced input represents a life grid, each pixel represents a cell
  9334. which can be in one of two possible states, alive or dead. Every cell
  9335. interacts with its eight neighbours, which are the cells that are
  9336. horizontally, vertically, or diagonally adjacent.
  9337. At each interaction the grid evolves according to the adopted rule,
  9338. which specifies the number of neighbor alive cells which will make a
  9339. cell stay alive or born. The @option{rule} option allows one to specify
  9340. the rule to adopt.
  9341. This source accepts the following options:
  9342. @table @option
  9343. @item filename, f
  9344. Set the file from which to read the initial grid state. In the file,
  9345. each non-whitespace character is considered an alive cell, and newline
  9346. is used to delimit the end of each row.
  9347. If this option is not specified, the initial grid is generated
  9348. randomly.
  9349. @item rate, r
  9350. Set the video rate, that is the number of frames generated per second.
  9351. Default is 25.
  9352. @item random_fill_ratio, ratio
  9353. Set the random fill ratio for the initial random grid. It is a
  9354. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  9355. It is ignored when a file is specified.
  9356. @item random_seed, seed
  9357. Set the seed for filling the initial random grid, must be an integer
  9358. included between 0 and UINT32_MAX. If not specified, or if explicitly
  9359. set to -1, the filter will try to use a good random seed on a best
  9360. effort basis.
  9361. @item rule
  9362. Set the life rule.
  9363. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  9364. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  9365. @var{NS} specifies the number of alive neighbor cells which make a
  9366. live cell stay alive, and @var{NB} the number of alive neighbor cells
  9367. which make a dead cell to become alive (i.e. to "born").
  9368. "s" and "b" can be used in place of "S" and "B", respectively.
  9369. Alternatively a rule can be specified by an 18-bits integer. The 9
  9370. high order bits are used to encode the next cell state if it is alive
  9371. for each number of neighbor alive cells, the low order bits specify
  9372. the rule for "borning" new cells. Higher order bits encode for an
  9373. higher number of neighbor cells.
  9374. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  9375. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  9376. Default value is "S23/B3", which is the original Conway's game of life
  9377. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  9378. cells, and will born a new cell if there are three alive cells around
  9379. a dead cell.
  9380. @item size, s
  9381. Set the size of the output video. For the syntax of this option, check the
  9382. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9383. If @option{filename} is specified, the size is set by default to the
  9384. same size of the input file. If @option{size} is set, it must contain
  9385. the size specified in the input file, and the initial grid defined in
  9386. that file is centered in the larger resulting area.
  9387. If a filename is not specified, the size value defaults to "320x240"
  9388. (used for a randomly generated initial grid).
  9389. @item stitch
  9390. If set to 1, stitch the left and right grid edges together, and the
  9391. top and bottom edges also. Defaults to 1.
  9392. @item mold
  9393. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  9394. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  9395. value from 0 to 255.
  9396. @item life_color
  9397. Set the color of living (or new born) cells.
  9398. @item death_color
  9399. Set the color of dead cells. If @option{mold} is set, this is the first color
  9400. used to represent a dead cell.
  9401. @item mold_color
  9402. Set mold color, for definitely dead and moldy cells.
  9403. For the syntax of these 3 color options, check the "Color" section in the
  9404. ffmpeg-utils manual.
  9405. @end table
  9406. @subsection Examples
  9407. @itemize
  9408. @item
  9409. Read a grid from @file{pattern}, and center it on a grid of size
  9410. 300x300 pixels:
  9411. @example
  9412. life=f=pattern:s=300x300
  9413. @end example
  9414. @item
  9415. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  9416. @example
  9417. life=ratio=2/3:s=200x200
  9418. @end example
  9419. @item
  9420. Specify a custom rule for evolving a randomly generated grid:
  9421. @example
  9422. life=rule=S14/B34
  9423. @end example
  9424. @item
  9425. Full example with slow death effect (mold) using @command{ffplay}:
  9426. @example
  9427. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  9428. @end example
  9429. @end itemize
  9430. @anchor{allrgb}
  9431. @anchor{allyuv}
  9432. @anchor{color}
  9433. @anchor{haldclutsrc}
  9434. @anchor{nullsrc}
  9435. @anchor{rgbtestsrc}
  9436. @anchor{smptebars}
  9437. @anchor{smptehdbars}
  9438. @anchor{testsrc}
  9439. @section allrgb, allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  9440. The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
  9441. The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
  9442. The @code{color} source provides an uniformly colored input.
  9443. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  9444. @ref{haldclut} filter.
  9445. The @code{nullsrc} source returns unprocessed video frames. It is
  9446. mainly useful to be employed in analysis / debugging tools, or as the
  9447. source for filters which ignore the input data.
  9448. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  9449. detecting RGB vs BGR issues. You should see a red, green and blue
  9450. stripe from top to bottom.
  9451. The @code{smptebars} source generates a color bars pattern, based on
  9452. the SMPTE Engineering Guideline EG 1-1990.
  9453. The @code{smptehdbars} source generates a color bars pattern, based on
  9454. the SMPTE RP 219-2002.
  9455. The @code{testsrc} source generates a test video pattern, showing a
  9456. color pattern, a scrolling gradient and a timestamp. This is mainly
  9457. intended for testing purposes.
  9458. The sources accept the following parameters:
  9459. @table @option
  9460. @item color, c
  9461. Specify the color of the source, only available in the @code{color}
  9462. source. For the syntax of this option, check the "Color" section in the
  9463. ffmpeg-utils manual.
  9464. @item level
  9465. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  9466. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  9467. pixels to be used as identity matrix for 3D lookup tables. Each component is
  9468. coded on a @code{1/(N*N)} scale.
  9469. @item size, s
  9470. Specify the size of the sourced video. For the syntax of this option, check the
  9471. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9472. The default value is @code{320x240}.
  9473. This option is not available with the @code{haldclutsrc} filter.
  9474. @item rate, r
  9475. Specify the frame rate of the sourced video, as the number of frames
  9476. generated per second. It has to be a string in the format
  9477. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  9478. number or a valid video frame rate abbreviation. The default value is
  9479. "25".
  9480. @item sar
  9481. Set the sample aspect ratio of the sourced video.
  9482. @item duration, d
  9483. Set the duration of the sourced video. See
  9484. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  9485. for the accepted syntax.
  9486. If not specified, or the expressed duration is negative, the video is
  9487. supposed to be generated forever.
  9488. @item decimals, n
  9489. Set the number of decimals to show in the timestamp, only available in the
  9490. @code{testsrc} source.
  9491. The displayed timestamp value will correspond to the original
  9492. timestamp value multiplied by the power of 10 of the specified
  9493. value. Default value is 0.
  9494. @end table
  9495. For example the following:
  9496. @example
  9497. testsrc=duration=5.3:size=qcif:rate=10
  9498. @end example
  9499. will generate a video with a duration of 5.3 seconds, with size
  9500. 176x144 and a frame rate of 10 frames per second.
  9501. The following graph description will generate a red source
  9502. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  9503. frames per second.
  9504. @example
  9505. color=c=red@@0.2:s=qcif:r=10
  9506. @end example
  9507. If the input content is to be ignored, @code{nullsrc} can be used. The
  9508. following command generates noise in the luminance plane by employing
  9509. the @code{geq} filter:
  9510. @example
  9511. nullsrc=s=256x256, geq=random(1)*255:128:128
  9512. @end example
  9513. @subsection Commands
  9514. The @code{color} source supports the following commands:
  9515. @table @option
  9516. @item c, color
  9517. Set the color of the created image. Accepts the same syntax of the
  9518. corresponding @option{color} option.
  9519. @end table
  9520. @c man end VIDEO SOURCES
  9521. @chapter Video Sinks
  9522. @c man begin VIDEO SINKS
  9523. Below is a description of the currently available video sinks.
  9524. @section buffersink
  9525. Buffer video frames, and make them available to the end of the filter
  9526. graph.
  9527. This sink is mainly intended for programmatic use, in particular
  9528. through the interface defined in @file{libavfilter/buffersink.h}
  9529. or the options system.
  9530. It accepts a pointer to an AVBufferSinkContext structure, which
  9531. defines the incoming buffers' formats, to be passed as the opaque
  9532. parameter to @code{avfilter_init_filter} for initialization.
  9533. @section nullsink
  9534. Null video sink: do absolutely nothing with the input video. It is
  9535. mainly useful as a template and for use in analysis / debugging
  9536. tools.
  9537. @c man end VIDEO SINKS
  9538. @chapter Multimedia Filters
  9539. @c man begin MULTIMEDIA FILTERS
  9540. Below is a description of the currently available multimedia filters.
  9541. @section aphasemeter
  9542. Convert input audio to a video output, displaying the audio phase.
  9543. The filter accepts the following options:
  9544. @table @option
  9545. @item rate, r
  9546. Set the output frame rate. Default value is @code{25}.
  9547. @item size, s
  9548. Set the video size for the output. For the syntax of this option, check the
  9549. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9550. Default value is @code{800x400}.
  9551. @item rc
  9552. @item gc
  9553. @item bc
  9554. Specify the red, green, blue contrast. Default values are @code{2},
  9555. @code{7} and @code{1}.
  9556. Allowed range is @code{[0, 255]}.
  9557. @item mpc
  9558. Set color which will be used for drawing median phase. If color is
  9559. @code{none} which is default, no median phase value will be drawn.
  9560. @end table
  9561. The filter also exports the frame metadata @code{lavfi.aphasemeter.phase} which
  9562. represents mean phase of current audio frame. Value is in range @code{[-1, 1]}.
  9563. The @code{-1} means left and right channels are completely out of phase and
  9564. @code{1} means channels are in phase.
  9565. @section avectorscope
  9566. Convert input audio to a video output, representing the audio vector
  9567. scope.
  9568. The filter is used to measure the difference between channels of stereo
  9569. audio stream. A monoaural signal, consisting of identical left and right
  9570. signal, results in straight vertical line. Any stereo separation is visible
  9571. as a deviation from this line, creating a Lissajous figure.
  9572. If the straight (or deviation from it) but horizontal line appears this
  9573. indicates that the left and right channels are out of phase.
  9574. The filter accepts the following options:
  9575. @table @option
  9576. @item mode, m
  9577. Set the vectorscope mode.
  9578. Available values are:
  9579. @table @samp
  9580. @item lissajous
  9581. Lissajous rotated by 45 degrees.
  9582. @item lissajous_xy
  9583. Same as above but not rotated.
  9584. @item polar
  9585. Shape resembling half of circle.
  9586. @end table
  9587. Default value is @samp{lissajous}.
  9588. @item size, s
  9589. Set the video size for the output. For the syntax of this option, check the
  9590. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9591. Default value is @code{400x400}.
  9592. @item rate, r
  9593. Set the output frame rate. Default value is @code{25}.
  9594. @item rc
  9595. @item gc
  9596. @item bc
  9597. @item ac
  9598. Specify the red, green, blue and alpha contrast. Default values are @code{40},
  9599. @code{160}, @code{80} and @code{255}.
  9600. Allowed range is @code{[0, 255]}.
  9601. @item rf
  9602. @item gf
  9603. @item bf
  9604. @item af
  9605. Specify the red, green, blue and alpha fade. Default values are @code{15},
  9606. @code{10}, @code{5} and @code{5}.
  9607. Allowed range is @code{[0, 255]}.
  9608. @item zoom
  9609. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  9610. @end table
  9611. @subsection Examples
  9612. @itemize
  9613. @item
  9614. Complete example using @command{ffplay}:
  9615. @example
  9616. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  9617. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  9618. @end example
  9619. @end itemize
  9620. @section concat
  9621. Concatenate audio and video streams, joining them together one after the
  9622. other.
  9623. The filter works on segments of synchronized video and audio streams. All
  9624. segments must have the same number of streams of each type, and that will
  9625. also be the number of streams at output.
  9626. The filter accepts the following options:
  9627. @table @option
  9628. @item n
  9629. Set the number of segments. Default is 2.
  9630. @item v
  9631. Set the number of output video streams, that is also the number of video
  9632. streams in each segment. Default is 1.
  9633. @item a
  9634. Set the number of output audio streams, that is also the number of audio
  9635. streams in each segment. Default is 0.
  9636. @item unsafe
  9637. Activate unsafe mode: do not fail if segments have a different format.
  9638. @end table
  9639. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  9640. @var{a} audio outputs.
  9641. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  9642. segment, in the same order as the outputs, then the inputs for the second
  9643. segment, etc.
  9644. Related streams do not always have exactly the same duration, for various
  9645. reasons including codec frame size or sloppy authoring. For that reason,
  9646. related synchronized streams (e.g. a video and its audio track) should be
  9647. concatenated at once. The concat filter will use the duration of the longest
  9648. stream in each segment (except the last one), and if necessary pad shorter
  9649. audio streams with silence.
  9650. For this filter to work correctly, all segments must start at timestamp 0.
  9651. All corresponding streams must have the same parameters in all segments; the
  9652. filtering system will automatically select a common pixel format for video
  9653. streams, and a common sample format, sample rate and channel layout for
  9654. audio streams, but other settings, such as resolution, must be converted
  9655. explicitly by the user.
  9656. Different frame rates are acceptable but will result in variable frame rate
  9657. at output; be sure to configure the output file to handle it.
  9658. @subsection Examples
  9659. @itemize
  9660. @item
  9661. Concatenate an opening, an episode and an ending, all in bilingual version
  9662. (video in stream 0, audio in streams 1 and 2):
  9663. @example
  9664. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  9665. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  9666. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  9667. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  9668. @end example
  9669. @item
  9670. Concatenate two parts, handling audio and video separately, using the
  9671. (a)movie sources, and adjusting the resolution:
  9672. @example
  9673. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  9674. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  9675. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  9676. @end example
  9677. Note that a desync will happen at the stitch if the audio and video streams
  9678. do not have exactly the same duration in the first file.
  9679. @end itemize
  9680. @anchor{ebur128}
  9681. @section ebur128
  9682. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  9683. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  9684. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  9685. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  9686. The filter also has a video output (see the @var{video} option) with a real
  9687. time graph to observe the loudness evolution. The graphic contains the logged
  9688. message mentioned above, so it is not printed anymore when this option is set,
  9689. unless the verbose logging is set. The main graphing area contains the
  9690. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  9691. the momentary loudness (400 milliseconds).
  9692. More information about the Loudness Recommendation EBU R128 on
  9693. @url{http://tech.ebu.ch/loudness}.
  9694. The filter accepts the following options:
  9695. @table @option
  9696. @item video
  9697. Activate the video output. The audio stream is passed unchanged whether this
  9698. option is set or no. The video stream will be the first output stream if
  9699. activated. Default is @code{0}.
  9700. @item size
  9701. Set the video size. This option is for video only. For the syntax of this
  9702. option, check the
  9703. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9704. Default and minimum resolution is @code{640x480}.
  9705. @item meter
  9706. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  9707. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  9708. other integer value between this range is allowed.
  9709. @item metadata
  9710. Set metadata injection. If set to @code{1}, the audio input will be segmented
  9711. into 100ms output frames, each of them containing various loudness information
  9712. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  9713. Default is @code{0}.
  9714. @item framelog
  9715. Force the frame logging level.
  9716. Available values are:
  9717. @table @samp
  9718. @item info
  9719. information logging level
  9720. @item verbose
  9721. verbose logging level
  9722. @end table
  9723. By default, the logging level is set to @var{info}. If the @option{video} or
  9724. the @option{metadata} options are set, it switches to @var{verbose}.
  9725. @item peak
  9726. Set peak mode(s).
  9727. Available modes can be cumulated (the option is a @code{flag} type). Possible
  9728. values are:
  9729. @table @samp
  9730. @item none
  9731. Disable any peak mode (default).
  9732. @item sample
  9733. Enable sample-peak mode.
  9734. Simple peak mode looking for the higher sample value. It logs a message
  9735. for sample-peak (identified by @code{SPK}).
  9736. @item true
  9737. Enable true-peak mode.
  9738. If enabled, the peak lookup is done on an over-sampled version of the input
  9739. stream for better peak accuracy. It logs a message for true-peak.
  9740. (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
  9741. This mode requires a build with @code{libswresample}.
  9742. @end table
  9743. @item dualmono
  9744. Treat mono input files as "dual mono". If a mono file is intended for playback
  9745. on a stereo system, its EBU R128 measurement will be perceptually incorrect.
  9746. If set to @code{true}, this option will compensate for this effect.
  9747. Multi-channel input files are not effected by this option.
  9748. @item panlaw
  9749. Set a specific pan law to be used for the measurement of dual mono files.
  9750. This parameter is optional, and has a default value of -3.01dB.
  9751. @end table
  9752. @subsection Examples
  9753. @itemize
  9754. @item
  9755. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  9756. @example
  9757. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  9758. @end example
  9759. @item
  9760. Run an analysis with @command{ffmpeg}:
  9761. @example
  9762. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  9763. @end example
  9764. @end itemize
  9765. @section interleave, ainterleave
  9766. Temporally interleave frames from several inputs.
  9767. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  9768. These filters read frames from several inputs and send the oldest
  9769. queued frame to the output.
  9770. Input streams must have a well defined, monotonically increasing frame
  9771. timestamp values.
  9772. In order to submit one frame to output, these filters need to enqueue
  9773. at least one frame for each input, so they cannot work in case one
  9774. input is not yet terminated and will not receive incoming frames.
  9775. For example consider the case when one input is a @code{select} filter
  9776. which always drop input frames. The @code{interleave} filter will keep
  9777. reading from that input, but it will never be able to send new frames
  9778. to output until the input will send an end-of-stream signal.
  9779. Also, depending on inputs synchronization, the filters will drop
  9780. frames in case one input receives more frames than the other ones, and
  9781. the queue is already filled.
  9782. These filters accept the following options:
  9783. @table @option
  9784. @item nb_inputs, n
  9785. Set the number of different inputs, it is 2 by default.
  9786. @end table
  9787. @subsection Examples
  9788. @itemize
  9789. @item
  9790. Interleave frames belonging to different streams using @command{ffmpeg}:
  9791. @example
  9792. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  9793. @end example
  9794. @item
  9795. Add flickering blur effect:
  9796. @example
  9797. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  9798. @end example
  9799. @end itemize
  9800. @section perms, aperms
  9801. Set read/write permissions for the output frames.
  9802. These filters are mainly aimed at developers to test direct path in the
  9803. following filter in the filtergraph.
  9804. The filters accept the following options:
  9805. @table @option
  9806. @item mode
  9807. Select the permissions mode.
  9808. It accepts the following values:
  9809. @table @samp
  9810. @item none
  9811. Do nothing. This is the default.
  9812. @item ro
  9813. Set all the output frames read-only.
  9814. @item rw
  9815. Set all the output frames directly writable.
  9816. @item toggle
  9817. Make the frame read-only if writable, and writable if read-only.
  9818. @item random
  9819. Set each output frame read-only or writable randomly.
  9820. @end table
  9821. @item seed
  9822. Set the seed for the @var{random} mode, must be an integer included between
  9823. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  9824. @code{-1}, the filter will try to use a good random seed on a best effort
  9825. basis.
  9826. @end table
  9827. Note: in case of auto-inserted filter between the permission filter and the
  9828. following one, the permission might not be received as expected in that
  9829. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  9830. perms/aperms filter can avoid this problem.
  9831. @section select, aselect
  9832. Select frames to pass in output.
  9833. This filter accepts the following options:
  9834. @table @option
  9835. @item expr, e
  9836. Set expression, which is evaluated for each input frame.
  9837. If the expression is evaluated to zero, the frame is discarded.
  9838. If the evaluation result is negative or NaN, the frame is sent to the
  9839. first output; otherwise it is sent to the output with index
  9840. @code{ceil(val)-1}, assuming that the input index starts from 0.
  9841. For example a value of @code{1.2} corresponds to the output with index
  9842. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  9843. @item outputs, n
  9844. Set the number of outputs. The output to which to send the selected
  9845. frame is based on the result of the evaluation. Default value is 1.
  9846. @end table
  9847. The expression can contain the following constants:
  9848. @table @option
  9849. @item n
  9850. The (sequential) number of the filtered frame, starting from 0.
  9851. @item selected_n
  9852. The (sequential) number of the selected frame, starting from 0.
  9853. @item prev_selected_n
  9854. The sequential number of the last selected frame. It's NAN if undefined.
  9855. @item TB
  9856. The timebase of the input timestamps.
  9857. @item pts
  9858. The PTS (Presentation TimeStamp) of the filtered video frame,
  9859. expressed in @var{TB} units. It's NAN if undefined.
  9860. @item t
  9861. The PTS of the filtered video frame,
  9862. expressed in seconds. It's NAN if undefined.
  9863. @item prev_pts
  9864. The PTS of the previously filtered video frame. It's NAN if undefined.
  9865. @item prev_selected_pts
  9866. The PTS of the last previously filtered video frame. It's NAN if undefined.
  9867. @item prev_selected_t
  9868. The PTS of the last previously selected video frame. It's NAN if undefined.
  9869. @item start_pts
  9870. The PTS of the first video frame in the video. It's NAN if undefined.
  9871. @item start_t
  9872. The time of the first video frame in the video. It's NAN if undefined.
  9873. @item pict_type @emph{(video only)}
  9874. The type of the filtered frame. It can assume one of the following
  9875. values:
  9876. @table @option
  9877. @item I
  9878. @item P
  9879. @item B
  9880. @item S
  9881. @item SI
  9882. @item SP
  9883. @item BI
  9884. @end table
  9885. @item interlace_type @emph{(video only)}
  9886. The frame interlace type. It can assume one of the following values:
  9887. @table @option
  9888. @item PROGRESSIVE
  9889. The frame is progressive (not interlaced).
  9890. @item TOPFIRST
  9891. The frame is top-field-first.
  9892. @item BOTTOMFIRST
  9893. The frame is bottom-field-first.
  9894. @end table
  9895. @item consumed_sample_n @emph{(audio only)}
  9896. the number of selected samples before the current frame
  9897. @item samples_n @emph{(audio only)}
  9898. the number of samples in the current frame
  9899. @item sample_rate @emph{(audio only)}
  9900. the input sample rate
  9901. @item key
  9902. This is 1 if the filtered frame is a key-frame, 0 otherwise.
  9903. @item pos
  9904. the position in the file of the filtered frame, -1 if the information
  9905. is not available (e.g. for synthetic video)
  9906. @item scene @emph{(video only)}
  9907. value between 0 and 1 to indicate a new scene; a low value reflects a low
  9908. probability for the current frame to introduce a new scene, while a higher
  9909. value means the current frame is more likely to be one (see the example below)
  9910. @end table
  9911. The default value of the select expression is "1".
  9912. @subsection Examples
  9913. @itemize
  9914. @item
  9915. Select all frames in input:
  9916. @example
  9917. select
  9918. @end example
  9919. The example above is the same as:
  9920. @example
  9921. select=1
  9922. @end example
  9923. @item
  9924. Skip all frames:
  9925. @example
  9926. select=0
  9927. @end example
  9928. @item
  9929. Select only I-frames:
  9930. @example
  9931. select='eq(pict_type\,I)'
  9932. @end example
  9933. @item
  9934. Select one frame every 100:
  9935. @example
  9936. select='not(mod(n\,100))'
  9937. @end example
  9938. @item
  9939. Select only frames contained in the 10-20 time interval:
  9940. @example
  9941. select=between(t\,10\,20)
  9942. @end example
  9943. @item
  9944. Select only I frames contained in the 10-20 time interval:
  9945. @example
  9946. select=between(t\,10\,20)*eq(pict_type\,I)
  9947. @end example
  9948. @item
  9949. Select frames with a minimum distance of 10 seconds:
  9950. @example
  9951. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  9952. @end example
  9953. @item
  9954. Use aselect to select only audio frames with samples number > 100:
  9955. @example
  9956. aselect='gt(samples_n\,100)'
  9957. @end example
  9958. @item
  9959. Create a mosaic of the first scenes:
  9960. @example
  9961. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  9962. @end example
  9963. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  9964. choice.
  9965. @item
  9966. Send even and odd frames to separate outputs, and compose them:
  9967. @example
  9968. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  9969. @end example
  9970. @end itemize
  9971. @section selectivecolor
  9972. Adjust cyan, magenta, yellow and black (CMYK) to certain ranges of colors (such
  9973. as "reds", "yellows", "greens", "cyans", ...). The adjustment range is defined
  9974. by the "purity" of the color (that is, how saturated it already is).
  9975. This filter is similar to the Adobe Photoshop Selective Color tool.
  9976. The filter accepts the following options:
  9977. @table @option
  9978. @item correction_method
  9979. Select color correction method.
  9980. Available values are:
  9981. @table @samp
  9982. @item absolute
  9983. Specified adjustments are applied "as-is" (added/subtracted to original pixel
  9984. component value).
  9985. @item relative
  9986. Specified adjustments are relative to the original component value.
  9987. @end table
  9988. Default is @code{absolute}.
  9989. @item reds
  9990. Adjustments for red pixels (pixels where the red component is the maximum)
  9991. @item yellows
  9992. Adjustments for yellow pixels (pixels where the blue component is the minimum)
  9993. @item greens
  9994. Adjustments for green pixels (pixels where the green component is the maximum)
  9995. @item cyans
  9996. Adjustments for cyan pixels (pixels where the red component is the minimum)
  9997. @item blues
  9998. Adjustments for blue pixels (pixels where the blue component is the maximum)
  9999. @item magentas
  10000. Adjustments for magenta pixels (pixels where the green component is the minimum)
  10001. @item whites
  10002. Adjustments for white pixels (pixels where all components are greater than 128)
  10003. @item neutrals
  10004. Adjustments for all pixels except pure black and pure white
  10005. @item blacks
  10006. Adjustments for black pixels (pixels where all components are lesser than 128)
  10007. @item psfile
  10008. Specify a Photoshop selective color file (@code{.asv}) to import the settings from.
  10009. @end table
  10010. All the adjustment settings (@option{reds}, @option{yellows}, ...) accept up to
  10011. 4 space separated floating point adjustment values in the [-1,1] range,
  10012. respectively to adjust the amount of cyan, magenta, yellow and black for the
  10013. pixels of its range.
  10014. @subsection Examples
  10015. @itemize
  10016. @item
  10017. Increase cyan by 55% and reduce yellow by 33% in every green areas, and
  10018. increase magenta by 27% in blue areas:
  10019. @example
  10020. selectivecolor=greens=.5 0 -.33 0:blues=0 .27
  10021. @end example
  10022. @item
  10023. Use a Photoshop selective color preset:
  10024. @example
  10025. selectivecolor=psfile=MySelectiveColorPresets/Misty.asv
  10026. @end example
  10027. @end itemize
  10028. @section sendcmd, asendcmd
  10029. Send commands to filters in the filtergraph.
  10030. These filters read commands to be sent to other filters in the
  10031. filtergraph.
  10032. @code{sendcmd} must be inserted between two video filters,
  10033. @code{asendcmd} must be inserted between two audio filters, but apart
  10034. from that they act the same way.
  10035. The specification of commands can be provided in the filter arguments
  10036. with the @var{commands} option, or in a file specified by the
  10037. @var{filename} option.
  10038. These filters accept the following options:
  10039. @table @option
  10040. @item commands, c
  10041. Set the commands to be read and sent to the other filters.
  10042. @item filename, f
  10043. Set the filename of the commands to be read and sent to the other
  10044. filters.
  10045. @end table
  10046. @subsection Commands syntax
  10047. A commands description consists of a sequence of interval
  10048. specifications, comprising a list of commands to be executed when a
  10049. particular event related to that interval occurs. The occurring event
  10050. is typically the current frame time entering or leaving a given time
  10051. interval.
  10052. An interval is specified by the following syntax:
  10053. @example
  10054. @var{START}[-@var{END}] @var{COMMANDS};
  10055. @end example
  10056. The time interval is specified by the @var{START} and @var{END} times.
  10057. @var{END} is optional and defaults to the maximum time.
  10058. The current frame time is considered within the specified interval if
  10059. it is included in the interval [@var{START}, @var{END}), that is when
  10060. the time is greater or equal to @var{START} and is lesser than
  10061. @var{END}.
  10062. @var{COMMANDS} consists of a sequence of one or more command
  10063. specifications, separated by ",", relating to that interval. The
  10064. syntax of a command specification is given by:
  10065. @example
  10066. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  10067. @end example
  10068. @var{FLAGS} is optional and specifies the type of events relating to
  10069. the time interval which enable sending the specified command, and must
  10070. be a non-null sequence of identifier flags separated by "+" or "|" and
  10071. enclosed between "[" and "]".
  10072. The following flags are recognized:
  10073. @table @option
  10074. @item enter
  10075. The command is sent when the current frame timestamp enters the
  10076. specified interval. In other words, the command is sent when the
  10077. previous frame timestamp was not in the given interval, and the
  10078. current is.
  10079. @item leave
  10080. The command is sent when the current frame timestamp leaves the
  10081. specified interval. In other words, the command is sent when the
  10082. previous frame timestamp was in the given interval, and the
  10083. current is not.
  10084. @end table
  10085. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  10086. assumed.
  10087. @var{TARGET} specifies the target of the command, usually the name of
  10088. the filter class or a specific filter instance name.
  10089. @var{COMMAND} specifies the name of the command for the target filter.
  10090. @var{ARG} is optional and specifies the optional list of argument for
  10091. the given @var{COMMAND}.
  10092. Between one interval specification and another, whitespaces, or
  10093. sequences of characters starting with @code{#} until the end of line,
  10094. are ignored and can be used to annotate comments.
  10095. A simplified BNF description of the commands specification syntax
  10096. follows:
  10097. @example
  10098. @var{COMMAND_FLAG} ::= "enter" | "leave"
  10099. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  10100. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  10101. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  10102. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  10103. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  10104. @end example
  10105. @subsection Examples
  10106. @itemize
  10107. @item
  10108. Specify audio tempo change at second 4:
  10109. @example
  10110. asendcmd=c='4.0 atempo tempo 1.5',atempo
  10111. @end example
  10112. @item
  10113. Specify a list of drawtext and hue commands in a file.
  10114. @example
  10115. # show text in the interval 5-10
  10116. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  10117. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  10118. # desaturate the image in the interval 15-20
  10119. 15.0-20.0 [enter] hue s 0,
  10120. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  10121. [leave] hue s 1,
  10122. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  10123. # apply an exponential saturation fade-out effect, starting from time 25
  10124. 25 [enter] hue s exp(25-t)
  10125. @end example
  10126. A filtergraph allowing to read and process the above command list
  10127. stored in a file @file{test.cmd}, can be specified with:
  10128. @example
  10129. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  10130. @end example
  10131. @end itemize
  10132. @anchor{setpts}
  10133. @section setpts, asetpts
  10134. Change the PTS (presentation timestamp) of the input frames.
  10135. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  10136. This filter accepts the following options:
  10137. @table @option
  10138. @item expr
  10139. The expression which is evaluated for each frame to construct its timestamp.
  10140. @end table
  10141. The expression is evaluated through the eval API and can contain the following
  10142. constants:
  10143. @table @option
  10144. @item FRAME_RATE
  10145. frame rate, only defined for constant frame-rate video
  10146. @item PTS
  10147. The presentation timestamp in input
  10148. @item N
  10149. The count of the input frame for video or the number of consumed samples,
  10150. not including the current frame for audio, starting from 0.
  10151. @item NB_CONSUMED_SAMPLES
  10152. The number of consumed samples, not including the current frame (only
  10153. audio)
  10154. @item NB_SAMPLES, S
  10155. The number of samples in the current frame (only audio)
  10156. @item SAMPLE_RATE, SR
  10157. The audio sample rate.
  10158. @item STARTPTS
  10159. The PTS of the first frame.
  10160. @item STARTT
  10161. the time in seconds of the first frame
  10162. @item INTERLACED
  10163. State whether the current frame is interlaced.
  10164. @item T
  10165. the time in seconds of the current frame
  10166. @item POS
  10167. original position in the file of the frame, or undefined if undefined
  10168. for the current frame
  10169. @item PREV_INPTS
  10170. The previous input PTS.
  10171. @item PREV_INT
  10172. previous input time in seconds
  10173. @item PREV_OUTPTS
  10174. The previous output PTS.
  10175. @item PREV_OUTT
  10176. previous output time in seconds
  10177. @item RTCTIME
  10178. The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  10179. instead.
  10180. @item RTCSTART
  10181. The wallclock (RTC) time at the start of the movie in microseconds.
  10182. @item TB
  10183. The timebase of the input timestamps.
  10184. @end table
  10185. @subsection Examples
  10186. @itemize
  10187. @item
  10188. Start counting PTS from zero
  10189. @example
  10190. setpts=PTS-STARTPTS
  10191. @end example
  10192. @item
  10193. Apply fast motion effect:
  10194. @example
  10195. setpts=0.5*PTS
  10196. @end example
  10197. @item
  10198. Apply slow motion effect:
  10199. @example
  10200. setpts=2.0*PTS
  10201. @end example
  10202. @item
  10203. Set fixed rate of 25 frames per second:
  10204. @example
  10205. setpts=N/(25*TB)
  10206. @end example
  10207. @item
  10208. Set fixed rate 25 fps with some jitter:
  10209. @example
  10210. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  10211. @end example
  10212. @item
  10213. Apply an offset of 10 seconds to the input PTS:
  10214. @example
  10215. setpts=PTS+10/TB
  10216. @end example
  10217. @item
  10218. Generate timestamps from a "live source" and rebase onto the current timebase:
  10219. @example
  10220. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  10221. @end example
  10222. @item
  10223. Generate timestamps by counting samples:
  10224. @example
  10225. asetpts=N/SR/TB
  10226. @end example
  10227. @end itemize
  10228. @section settb, asettb
  10229. Set the timebase to use for the output frames timestamps.
  10230. It is mainly useful for testing timebase configuration.
  10231. It accepts the following parameters:
  10232. @table @option
  10233. @item expr, tb
  10234. The expression which is evaluated into the output timebase.
  10235. @end table
  10236. The value for @option{tb} is an arithmetic expression representing a
  10237. rational. The expression can contain the constants "AVTB" (the default
  10238. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  10239. audio only). Default value is "intb".
  10240. @subsection Examples
  10241. @itemize
  10242. @item
  10243. Set the timebase to 1/25:
  10244. @example
  10245. settb=expr=1/25
  10246. @end example
  10247. @item
  10248. Set the timebase to 1/10:
  10249. @example
  10250. settb=expr=0.1
  10251. @end example
  10252. @item
  10253. Set the timebase to 1001/1000:
  10254. @example
  10255. settb=1+0.001
  10256. @end example
  10257. @item
  10258. Set the timebase to 2*intb:
  10259. @example
  10260. settb=2*intb
  10261. @end example
  10262. @item
  10263. Set the default timebase value:
  10264. @example
  10265. settb=AVTB
  10266. @end example
  10267. @end itemize
  10268. @section showcqt
  10269. Convert input audio to a video output representing
  10270. frequency spectrum logarithmically (using constant Q transform with
  10271. Brown-Puckette algorithm), with musical tone scale, from E0 to D#10 (10 octaves).
  10272. The filter accepts the following options:
  10273. @table @option
  10274. @item volume
  10275. Specify transform volume (multiplier) expression. The expression can contain
  10276. variables:
  10277. @table @option
  10278. @item frequency, freq, f
  10279. the frequency where transform is evaluated
  10280. @item timeclamp, tc
  10281. value of timeclamp option
  10282. @end table
  10283. and functions:
  10284. @table @option
  10285. @item a_weighting(f)
  10286. A-weighting of equal loudness
  10287. @item b_weighting(f)
  10288. B-weighting of equal loudness
  10289. @item c_weighting(f)
  10290. C-weighting of equal loudness
  10291. @end table
  10292. Default value is @code{16}.
  10293. @item tlength
  10294. Specify transform length expression. The expression can contain variables:
  10295. @table @option
  10296. @item frequency, freq, f
  10297. the frequency where transform is evaluated
  10298. @item timeclamp, tc
  10299. value of timeclamp option
  10300. @end table
  10301. Default value is @code{384/f*tc/(384/f+tc)}.
  10302. @item timeclamp
  10303. Specify the transform timeclamp. At low frequency, there is trade-off between
  10304. accuracy in time domain and frequency domain. If timeclamp is lower,
  10305. event in time domain is represented more accurately (such as fast bass drum),
  10306. otherwise event in frequency domain is represented more accurately
  10307. (such as bass guitar). Acceptable value is [0.1, 1.0]. Default value is @code{0.17}.
  10308. @item coeffclamp
  10309. Specify the transform coeffclamp. If coeffclamp is lower, transform is
  10310. more accurate, otherwise transform is faster. Acceptable value is [0.1, 10.0].
  10311. Default value is @code{1.0}.
  10312. @item gamma
  10313. Specify gamma. Lower gamma makes the spectrum more contrast, higher gamma
  10314. makes the spectrum having more range. Acceptable value is [1.0, 7.0].
  10315. Default value is @code{3.0}.
  10316. @item gamma2
  10317. Specify gamma of bargraph. Acceptable value is [1.0, 7.0].
  10318. Default value is @code{1.0}.
  10319. @item fontfile
  10320. Specify font file for use with freetype. If not specified, use embedded font.
  10321. @item fontcolor
  10322. Specify font color expression. This is arithmetic expression that should return
  10323. integer value 0xRRGGBB. The expression can contain variables:
  10324. @table @option
  10325. @item frequency, freq, f
  10326. the frequency where transform is evaluated
  10327. @item timeclamp, tc
  10328. value of timeclamp option
  10329. @end table
  10330. and functions:
  10331. @table @option
  10332. @item midi(f)
  10333. midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
  10334. @item r(x), g(x), b(x)
  10335. red, green, and blue value of intensity x
  10336. @end table
  10337. Default value is @code{st(0, (midi(f)-59.5)/12);
  10338. st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
  10339. r(1-ld(1)) + b(ld(1))}
  10340. @item fullhd
  10341. If set to 1 (the default), the video size is 1920x1080 (full HD),
  10342. if set to 0, the video size is 960x540. Use this option to make CPU usage lower.
  10343. @item fps
  10344. Specify video fps. Default value is @code{25}.
  10345. @item count
  10346. Specify number of transform per frame, so there are fps*count transforms
  10347. per second. Note that audio data rate must be divisible by fps*count.
  10348. Default value is @code{6}.
  10349. @end table
  10350. @subsection Examples
  10351. @itemize
  10352. @item
  10353. Playing audio while showing the spectrum:
  10354. @example
  10355. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
  10356. @end example
  10357. @item
  10358. Same as above, but with frame rate 30 fps:
  10359. @example
  10360. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
  10361. @end example
  10362. @item
  10363. Playing at 960x540 and lower CPU usage:
  10364. @example
  10365. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fullhd=0:count=3 [out0]'
  10366. @end example
  10367. @item
  10368. A1 and its harmonics: A1, A2, (near)E3, A3:
  10369. @example
  10370. 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),
  10371. asplit[a][out1]; [a] showcqt [out0]'
  10372. @end example
  10373. @item
  10374. Same as above, but with more accuracy in frequency domain (and slower):
  10375. @example
  10376. 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),
  10377. asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
  10378. @end example
  10379. @item
  10380. B-weighting of equal loudness
  10381. @example
  10382. volume=16*b_weighting(f)
  10383. @end example
  10384. @item
  10385. Lower Q factor
  10386. @example
  10387. tlength=100/f*tc/(100/f+tc)
  10388. @end example
  10389. @item
  10390. Custom fontcolor, C-note is colored green, others are colored blue
  10391. @example
  10392. fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))'
  10393. @end example
  10394. @item
  10395. Custom gamma, now spectrum is linear to the amplitude.
  10396. @example
  10397. gamma=2:gamma2=2
  10398. @end example
  10399. @end itemize
  10400. @section showfreqs
  10401. Convert input audio to video output representing the audio power spectrum.
  10402. Audio amplitude is on Y-axis while frequency is on X-axis.
  10403. The filter accepts the following options:
  10404. @table @option
  10405. @item size, s
  10406. Specify size of video. For the syntax of this option, check the
  10407. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10408. Default is @code{1024x512}.
  10409. @item mode
  10410. Set display mode.
  10411. This set how each frequency bin will be represented.
  10412. It accepts the following values:
  10413. @table @samp
  10414. @item line
  10415. @item bar
  10416. @item dot
  10417. @end table
  10418. Default is @code{bar}.
  10419. @item ascale
  10420. Set amplitude scale.
  10421. It accepts the following values:
  10422. @table @samp
  10423. @item lin
  10424. Linear scale.
  10425. @item sqrt
  10426. Square root scale.
  10427. @item cbrt
  10428. Cubic root scale.
  10429. @item log
  10430. Logarithmic scale.
  10431. @end table
  10432. Default is @code{log}.
  10433. @item fscale
  10434. Set frequency scale.
  10435. It accepts the following values:
  10436. @table @samp
  10437. @item lin
  10438. Linear scale.
  10439. @item log
  10440. Logarithmic scale.
  10441. @item rlog
  10442. Reverse logarithmic scale.
  10443. @end table
  10444. Default is @code{lin}.
  10445. @item win_size
  10446. Set window size.
  10447. It accepts the following values:
  10448. @table @samp
  10449. @item w16
  10450. @item w32
  10451. @item w64
  10452. @item w128
  10453. @item w256
  10454. @item w512
  10455. @item w1024
  10456. @item w2048
  10457. @item w4096
  10458. @item w8192
  10459. @item w16384
  10460. @item w32768
  10461. @item w65536
  10462. @end table
  10463. Default is @code{w2048}
  10464. @item win_func
  10465. Set windowing function.
  10466. It accepts the following values:
  10467. @table @samp
  10468. @item rect
  10469. @item bartlett
  10470. @item hanning
  10471. @item hamming
  10472. @item blackman
  10473. @item welch
  10474. @item flattop
  10475. @item bharris
  10476. @item bnuttall
  10477. @item bhann
  10478. @item sine
  10479. @item nuttall
  10480. @item lanczos
  10481. @item gauss
  10482. @end table
  10483. Default is @code{hanning}.
  10484. @item overlap
  10485. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  10486. which means optimal overlap for selected window function will be picked.
  10487. @item averaging
  10488. Set time averaging. Setting this to 0 will display current maximal peaks.
  10489. Default is @code{1}, which means time averaging is disabled.
  10490. @item colors
  10491. Specify list of colors separated by space or by '|' which will be used to
  10492. draw channel frequencies. Unrecognized or missing colors will be replaced
  10493. by white color.
  10494. @end table
  10495. @section showspectrum
  10496. Convert input audio to a video output, representing the audio frequency
  10497. spectrum.
  10498. The filter accepts the following options:
  10499. @table @option
  10500. @item size, s
  10501. Specify the video size for the output. For the syntax of this option, check the
  10502. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10503. Default value is @code{640x512}.
  10504. @item slide
  10505. Specify how the spectrum should slide along the window.
  10506. It accepts the following values:
  10507. @table @samp
  10508. @item replace
  10509. the samples start again on the left when they reach the right
  10510. @item scroll
  10511. the samples scroll from right to left
  10512. @item fullframe
  10513. frames are only produced when the samples reach the right
  10514. @end table
  10515. Default value is @code{replace}.
  10516. @item mode
  10517. Specify display mode.
  10518. It accepts the following values:
  10519. @table @samp
  10520. @item combined
  10521. all channels are displayed in the same row
  10522. @item separate
  10523. all channels are displayed in separate rows
  10524. @end table
  10525. Default value is @samp{combined}.
  10526. @item color
  10527. Specify display color mode.
  10528. It accepts the following values:
  10529. @table @samp
  10530. @item channel
  10531. each channel is displayed in a separate color
  10532. @item intensity
  10533. each channel is is displayed using the same color scheme
  10534. @end table
  10535. Default value is @samp{channel}.
  10536. @item scale
  10537. Specify scale used for calculating intensity color values.
  10538. It accepts the following values:
  10539. @table @samp
  10540. @item lin
  10541. linear
  10542. @item sqrt
  10543. square root, default
  10544. @item cbrt
  10545. cubic root
  10546. @item log
  10547. logarithmic
  10548. @end table
  10549. Default value is @samp{sqrt}.
  10550. @item saturation
  10551. Set saturation modifier for displayed colors. Negative values provide
  10552. alternative color scheme. @code{0} is no saturation at all.
  10553. Saturation must be in [-10.0, 10.0] range.
  10554. Default value is @code{1}.
  10555. @item win_func
  10556. Set window function.
  10557. It accepts the following values:
  10558. @table @samp
  10559. @item none
  10560. No samples pre-processing (do not expect this to be faster)
  10561. @item hann
  10562. Hann window
  10563. @item hamming
  10564. Hamming window
  10565. @item blackman
  10566. Blackman window
  10567. @end table
  10568. Default value is @code{hann}.
  10569. @end table
  10570. The usage is very similar to the showwaves filter; see the examples in that
  10571. section.
  10572. @subsection Examples
  10573. @itemize
  10574. @item
  10575. Large window with logarithmic color scaling:
  10576. @example
  10577. showspectrum=s=1280x480:scale=log
  10578. @end example
  10579. @item
  10580. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  10581. @example
  10582. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  10583. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  10584. @end example
  10585. @end itemize
  10586. @section showvolume
  10587. Convert input audio volume to a video output.
  10588. The filter accepts the following options:
  10589. @table @option
  10590. @item rate, r
  10591. Set video rate.
  10592. @item b
  10593. Set border width, allowed range is [0, 5]. Default is 1.
  10594. @item w
  10595. Set channel width, allowed range is [40, 1080]. Default is 400.
  10596. @item h
  10597. Set channel height, allowed range is [1, 100]. Default is 20.
  10598. @item f
  10599. Set fade, allowed range is [1, 255]. Default is 20.
  10600. @item c
  10601. Set volume color expression.
  10602. The expression can use the following variables:
  10603. @table @option
  10604. @item VOLUME
  10605. Current max volume of channel in dB.
  10606. @item CHANNEL
  10607. Current channel number, starting from 0.
  10608. @end table
  10609. @item t
  10610. If set, displays channel names. Default is enabled.
  10611. @end table
  10612. @section showwaves
  10613. Convert input audio to a video output, representing the samples waves.
  10614. The filter accepts the following options:
  10615. @table @option
  10616. @item size, s
  10617. Specify the video size for the output. For the syntax of this option, check the
  10618. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10619. Default value is @code{600x240}.
  10620. @item mode
  10621. Set display mode.
  10622. Available values are:
  10623. @table @samp
  10624. @item point
  10625. Draw a point for each sample.
  10626. @item line
  10627. Draw a vertical line for each sample.
  10628. @item p2p
  10629. Draw a point for each sample and a line between them.
  10630. @item cline
  10631. Draw a centered vertical line for each sample.
  10632. @end table
  10633. Default value is @code{point}.
  10634. @item n
  10635. Set the number of samples which are printed on the same column. A
  10636. larger value will decrease the frame rate. Must be a positive
  10637. integer. This option can be set only if the value for @var{rate}
  10638. is not explicitly specified.
  10639. @item rate, r
  10640. Set the (approximate) output frame rate. This is done by setting the
  10641. option @var{n}. Default value is "25".
  10642. @item split_channels
  10643. Set if channels should be drawn separately or overlap. Default value is 0.
  10644. @end table
  10645. @subsection Examples
  10646. @itemize
  10647. @item
  10648. Output the input file audio and the corresponding video representation
  10649. at the same time:
  10650. @example
  10651. amovie=a.mp3,asplit[out0],showwaves[out1]
  10652. @end example
  10653. @item
  10654. Create a synthetic signal and show it with showwaves, forcing a
  10655. frame rate of 30 frames per second:
  10656. @example
  10657. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  10658. @end example
  10659. @end itemize
  10660. @section showwavespic
  10661. Convert input audio to a single video frame, representing the samples waves.
  10662. The filter accepts the following options:
  10663. @table @option
  10664. @item size, s
  10665. Specify the video size for the output. For the syntax of this option, check the
  10666. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10667. Default value is @code{600x240}.
  10668. @item split_channels
  10669. Set if channels should be drawn separately or overlap. Default value is 0.
  10670. @end table
  10671. @subsection Examples
  10672. @itemize
  10673. @item
  10674. Extract a channel split representation of the wave form of a whole audio track
  10675. in a 1024x800 picture using @command{ffmpeg}:
  10676. @example
  10677. ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
  10678. @end example
  10679. @end itemize
  10680. @section split, asplit
  10681. Split input into several identical outputs.
  10682. @code{asplit} works with audio input, @code{split} with video.
  10683. The filter accepts a single parameter which specifies the number of outputs. If
  10684. unspecified, it defaults to 2.
  10685. @subsection Examples
  10686. @itemize
  10687. @item
  10688. Create two separate outputs from the same input:
  10689. @example
  10690. [in] split [out0][out1]
  10691. @end example
  10692. @item
  10693. To create 3 or more outputs, you need to specify the number of
  10694. outputs, like in:
  10695. @example
  10696. [in] asplit=3 [out0][out1][out2]
  10697. @end example
  10698. @item
  10699. Create two separate outputs from the same input, one cropped and
  10700. one padded:
  10701. @example
  10702. [in] split [splitout1][splitout2];
  10703. [splitout1] crop=100:100:0:0 [cropout];
  10704. [splitout2] pad=200:200:100:100 [padout];
  10705. @end example
  10706. @item
  10707. Create 5 copies of the input audio with @command{ffmpeg}:
  10708. @example
  10709. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  10710. @end example
  10711. @end itemize
  10712. @section zmq, azmq
  10713. Receive commands sent through a libzmq client, and forward them to
  10714. filters in the filtergraph.
  10715. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  10716. must be inserted between two video filters, @code{azmq} between two
  10717. audio filters.
  10718. To enable these filters you need to install the libzmq library and
  10719. headers and configure FFmpeg with @code{--enable-libzmq}.
  10720. For more information about libzmq see:
  10721. @url{http://www.zeromq.org/}
  10722. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  10723. receives messages sent through a network interface defined by the
  10724. @option{bind_address} option.
  10725. The received message must be in the form:
  10726. @example
  10727. @var{TARGET} @var{COMMAND} [@var{ARG}]
  10728. @end example
  10729. @var{TARGET} specifies the target of the command, usually the name of
  10730. the filter class or a specific filter instance name.
  10731. @var{COMMAND} specifies the name of the command for the target filter.
  10732. @var{ARG} is optional and specifies the optional argument list for the
  10733. given @var{COMMAND}.
  10734. Upon reception, the message is processed and the corresponding command
  10735. is injected into the filtergraph. Depending on the result, the filter
  10736. will send a reply to the client, adopting the format:
  10737. @example
  10738. @var{ERROR_CODE} @var{ERROR_REASON}
  10739. @var{MESSAGE}
  10740. @end example
  10741. @var{MESSAGE} is optional.
  10742. @subsection Examples
  10743. Look at @file{tools/zmqsend} for an example of a zmq client which can
  10744. be used to send commands processed by these filters.
  10745. Consider the following filtergraph generated by @command{ffplay}
  10746. @example
  10747. ffplay -dumpgraph 1 -f lavfi "
  10748. color=s=100x100:c=red [l];
  10749. color=s=100x100:c=blue [r];
  10750. nullsrc=s=200x100, zmq [bg];
  10751. [bg][l] overlay [bg+l];
  10752. [bg+l][r] overlay=x=100 "
  10753. @end example
  10754. To change the color of the left side of the video, the following
  10755. command can be used:
  10756. @example
  10757. echo Parsed_color_0 c yellow | tools/zmqsend
  10758. @end example
  10759. To change the right side:
  10760. @example
  10761. echo Parsed_color_1 c pink | tools/zmqsend
  10762. @end example
  10763. @c man end MULTIMEDIA FILTERS
  10764. @chapter Multimedia Sources
  10765. @c man begin MULTIMEDIA SOURCES
  10766. Below is a description of the currently available multimedia sources.
  10767. @section amovie
  10768. This is the same as @ref{movie} source, except it selects an audio
  10769. stream by default.
  10770. @anchor{movie}
  10771. @section movie
  10772. Read audio and/or video stream(s) from a movie container.
  10773. It accepts the following parameters:
  10774. @table @option
  10775. @item filename
  10776. The name of the resource to read (not necessarily a file; it can also be a
  10777. device or a stream accessed through some protocol).
  10778. @item format_name, f
  10779. Specifies the format assumed for the movie to read, and can be either
  10780. the name of a container or an input device. If not specified, the
  10781. format is guessed from @var{movie_name} or by probing.
  10782. @item seek_point, sp
  10783. Specifies the seek point in seconds. The frames will be output
  10784. starting from this seek point. The parameter is evaluated with
  10785. @code{av_strtod}, so the numerical value may be suffixed by an IS
  10786. postfix. The default value is "0".
  10787. @item streams, s
  10788. Specifies the streams to read. Several streams can be specified,
  10789. separated by "+". The source will then have as many outputs, in the
  10790. same order. The syntax is explained in the ``Stream specifiers''
  10791. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  10792. respectively the default (best suited) video and audio stream. Default
  10793. is "dv", or "da" if the filter is called as "amovie".
  10794. @item stream_index, si
  10795. Specifies the index of the video stream to read. If the value is -1,
  10796. the most suitable video stream will be automatically selected. The default
  10797. value is "-1". Deprecated. If the filter is called "amovie", it will select
  10798. audio instead of video.
  10799. @item loop
  10800. Specifies how many times to read the stream in sequence.
  10801. If the value is less than 1, the stream will be read again and again.
  10802. Default value is "1".
  10803. Note that when the movie is looped the source timestamps are not
  10804. changed, so it will generate non monotonically increasing timestamps.
  10805. @end table
  10806. It allows overlaying a second video on top of the main input of
  10807. a filtergraph, as shown in this graph:
  10808. @example
  10809. input -----------> deltapts0 --> overlay --> output
  10810. ^
  10811. |
  10812. movie --> scale--> deltapts1 -------+
  10813. @end example
  10814. @subsection Examples
  10815. @itemize
  10816. @item
  10817. Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
  10818. on top of the input labelled "in":
  10819. @example
  10820. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  10821. [in] setpts=PTS-STARTPTS [main];
  10822. [main][over] overlay=16:16 [out]
  10823. @end example
  10824. @item
  10825. Read from a video4linux2 device, and overlay it on top of the input
  10826. labelled "in":
  10827. @example
  10828. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  10829. [in] setpts=PTS-STARTPTS [main];
  10830. [main][over] overlay=16:16 [out]
  10831. @end example
  10832. @item
  10833. Read the first video stream and the audio stream with id 0x81 from
  10834. dvd.vob; the video is connected to the pad named "video" and the audio is
  10835. connected to the pad named "audio":
  10836. @example
  10837. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  10838. @end example
  10839. @end itemize
  10840. @c man end MULTIMEDIA SOURCES