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.

13388 lines
366KB

  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 allpass
  508. Apply a two-pole all-pass filter with central frequency (in Hz)
  509. @var{frequency}, and filter-width @var{width}.
  510. An all-pass filter changes the audio's frequency to phase relationship
  511. without changing its frequency to amplitude relationship.
  512. The filter accepts the following options:
  513. @table @option
  514. @item frequency, f
  515. Set frequency in Hz.
  516. @item width_type
  517. Set method to specify band-width of filter.
  518. @table @option
  519. @item h
  520. Hz
  521. @item q
  522. Q-Factor
  523. @item o
  524. octave
  525. @item s
  526. slope
  527. @end table
  528. @item width, w
  529. Specify the band-width of a filter in width_type units.
  530. @end table
  531. @anchor{amerge}
  532. @section amerge
  533. Merge two or more audio streams into a single multi-channel stream.
  534. The filter accepts the following options:
  535. @table @option
  536. @item inputs
  537. Set the number of inputs. Default is 2.
  538. @end table
  539. If the channel layouts of the inputs are disjoint, and therefore compatible,
  540. the channel layout of the output will be set accordingly and the channels
  541. will be reordered as necessary. If the channel layouts of the inputs are not
  542. disjoint, the output will have all the channels of the first input then all
  543. the channels of the second input, in that order, and the channel layout of
  544. the output will be the default value corresponding to the total number of
  545. channels.
  546. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  547. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  548. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  549. first input, b1 is the first channel of the second input).
  550. On the other hand, if both input are in stereo, the output channels will be
  551. in the default order: a1, a2, b1, b2, and the channel layout will be
  552. arbitrarily set to 4.0, which may or may not be the expected value.
  553. All inputs must have the same sample rate, and format.
  554. If inputs do not have the same duration, the output will stop with the
  555. shortest.
  556. @subsection Examples
  557. @itemize
  558. @item
  559. Merge two mono files into a stereo stream:
  560. @example
  561. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  562. @end example
  563. @item
  564. Multiple merges assuming 1 video stream and 6 audio streams in @file{input.mkv}:
  565. @example
  566. 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
  567. @end example
  568. @end itemize
  569. @section amix
  570. Mixes multiple audio inputs into a single output.
  571. Note that this filter only supports float samples (the @var{amerge}
  572. and @var{pan} audio filters support many formats). If the @var{amix}
  573. input has integer samples then @ref{aresample} will be automatically
  574. inserted to perform the conversion to float samples.
  575. For example
  576. @example
  577. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  578. @end example
  579. will mix 3 input audio streams to a single output with the same duration as the
  580. first input and a dropout transition time of 3 seconds.
  581. It accepts the following parameters:
  582. @table @option
  583. @item inputs
  584. The number of inputs. If unspecified, it defaults to 2.
  585. @item duration
  586. How to determine the end-of-stream.
  587. @table @option
  588. @item longest
  589. The duration of the longest input. (default)
  590. @item shortest
  591. The duration of the shortest input.
  592. @item first
  593. The duration of the first input.
  594. @end table
  595. @item dropout_transition
  596. The transition time, in seconds, for volume renormalization when an input
  597. stream ends. The default value is 2 seconds.
  598. @end table
  599. @section anull
  600. Pass the audio source unchanged to the output.
  601. @section apad
  602. Pad the end of an audio stream with silence.
  603. This can be used together with @command{ffmpeg} @option{-shortest} to
  604. extend audio streams to the same length as the video stream.
  605. A description of the accepted options follows.
  606. @table @option
  607. @item packet_size
  608. Set silence packet size. Default value is 4096.
  609. @item pad_len
  610. Set the number of samples of silence to add to the end. After the
  611. value is reached, the stream is terminated. This option is mutually
  612. exclusive with @option{whole_len}.
  613. @item whole_len
  614. Set the minimum total number of samples in the output audio stream. If
  615. the value is longer than the input audio length, silence is added to
  616. the end, until the value is reached. This option is mutually exclusive
  617. with @option{pad_len}.
  618. @end table
  619. If neither the @option{pad_len} nor the @option{whole_len} option is
  620. set, the filter will add silence to the end of the input stream
  621. indefinitely.
  622. @subsection Examples
  623. @itemize
  624. @item
  625. Add 1024 samples of silence to the end of the input:
  626. @example
  627. apad=pad_len=1024
  628. @end example
  629. @item
  630. Make sure the audio output will contain at least 10000 samples, pad
  631. the input with silence if required:
  632. @example
  633. apad=whole_len=10000
  634. @end example
  635. @item
  636. Use @command{ffmpeg} to pad the audio input with silence, so that the
  637. video stream will always result the shortest and will be converted
  638. until the end in the output file when using the @option{shortest}
  639. option:
  640. @example
  641. ffmpeg -i VIDEO -i AUDIO -filter_complex "[1:0]apad" -shortest OUTPUT
  642. @end example
  643. @end itemize
  644. @section aphaser
  645. Add a phasing effect to the input audio.
  646. A phaser filter creates series of peaks and troughs in the frequency spectrum.
  647. The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
  648. A description of the accepted parameters follows.
  649. @table @option
  650. @item in_gain
  651. Set input gain. Default is 0.4.
  652. @item out_gain
  653. Set output gain. Default is 0.74
  654. @item delay
  655. Set delay in milliseconds. Default is 3.0.
  656. @item decay
  657. Set decay. Default is 0.4.
  658. @item speed
  659. Set modulation speed in Hz. Default is 0.5.
  660. @item type
  661. Set modulation type. Default is triangular.
  662. It accepts the following values:
  663. @table @samp
  664. @item triangular, t
  665. @item sinusoidal, s
  666. @end table
  667. @end table
  668. @anchor{aresample}
  669. @section aresample
  670. Resample the input audio to the specified parameters, using the
  671. libswresample library. If none are specified then the filter will
  672. automatically convert between its input and output.
  673. This filter is also able to stretch/squeeze the audio data to make it match
  674. the timestamps or to inject silence / cut out audio to make it match the
  675. timestamps, do a combination of both or do neither.
  676. The filter accepts the syntax
  677. [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
  678. expresses a sample rate and @var{resampler_options} is a list of
  679. @var{key}=@var{value} pairs, separated by ":". See the
  680. ffmpeg-resampler manual for the complete list of supported options.
  681. @subsection Examples
  682. @itemize
  683. @item
  684. Resample the input audio to 44100Hz:
  685. @example
  686. aresample=44100
  687. @end example
  688. @item
  689. Stretch/squeeze samples to the given timestamps, with a maximum of 1000
  690. samples per second compensation:
  691. @example
  692. aresample=async=1000
  693. @end example
  694. @end itemize
  695. @section asetnsamples
  696. Set the number of samples per each output audio frame.
  697. The last output packet may contain a different number of samples, as
  698. the filter will flush all the remaining samples when the input audio
  699. signal its end.
  700. The filter accepts the following options:
  701. @table @option
  702. @item nb_out_samples, n
  703. Set the number of frames per each output audio frame. The number is
  704. intended as the number of samples @emph{per each channel}.
  705. Default value is 1024.
  706. @item pad, p
  707. If set to 1, the filter will pad the last audio frame with zeroes, so
  708. that the last frame will contain the same number of samples as the
  709. previous ones. Default value is 1.
  710. @end table
  711. For example, to set the number of per-frame samples to 1234 and
  712. disable padding for the last frame, use:
  713. @example
  714. asetnsamples=n=1234:p=0
  715. @end example
  716. @section asetrate
  717. Set the sample rate without altering the PCM data.
  718. This will result in a change of speed and pitch.
  719. The filter accepts the following options:
  720. @table @option
  721. @item sample_rate, r
  722. Set the output sample rate. Default is 44100 Hz.
  723. @end table
  724. @section ashowinfo
  725. Show a line containing various information for each input audio frame.
  726. The input audio is not modified.
  727. The shown line contains a sequence of key/value pairs of the form
  728. @var{key}:@var{value}.
  729. The following values are shown in the output:
  730. @table @option
  731. @item n
  732. The (sequential) number of the input frame, starting from 0.
  733. @item pts
  734. The presentation timestamp of the input frame, in time base units; the time base
  735. depends on the filter input pad, and is usually 1/@var{sample_rate}.
  736. @item pts_time
  737. The presentation timestamp of the input frame in seconds.
  738. @item pos
  739. position of the frame in the input stream, -1 if this information in
  740. unavailable and/or meaningless (for example in case of synthetic audio)
  741. @item fmt
  742. The sample format.
  743. @item chlayout
  744. The channel layout.
  745. @item rate
  746. The sample rate for the audio frame.
  747. @item nb_samples
  748. The number of samples (per channel) in the frame.
  749. @item checksum
  750. The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
  751. audio, the data is treated as if all the planes were concatenated.
  752. @item plane_checksums
  753. A list of Adler-32 checksums for each data plane.
  754. @end table
  755. @anchor{astats}
  756. @section astats
  757. Display time domain statistical information about the audio channels.
  758. Statistics are calculated and displayed for each audio channel and,
  759. where applicable, an overall figure is also given.
  760. It accepts the following option:
  761. @table @option
  762. @item length
  763. Short window length in seconds, used for peak and trough RMS measurement.
  764. Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.1 - 10]}.
  765. @item metadata
  766. Set metadata injection. All the metadata keys are prefixed with @code{lavfi.astats.X},
  767. where @code{X} is channel number starting from 1 or string @code{Overall}. Default is
  768. disabled.
  769. Available keys for each channel are:
  770. DC_offset
  771. Min_level
  772. Max_level
  773. Min_difference
  774. Max_difference
  775. Mean_difference
  776. Peak_level
  777. RMS_peak
  778. RMS_trough
  779. Crest_factor
  780. Flat_factor
  781. Peak_count
  782. Bit_depth
  783. and for Overall:
  784. DC_offset
  785. Min_level
  786. Max_level
  787. Min_difference
  788. Max_difference
  789. Mean_difference
  790. Peak_level
  791. RMS_level
  792. RMS_peak
  793. RMS_trough
  794. Flat_factor
  795. Peak_count
  796. Bit_depth
  797. Number_of_samples
  798. For example full key look like this @code{lavfi.astats.1.DC_offset} or
  799. this @code{lavfi.astats.Overall.Peak_count}.
  800. For description what each key means read bellow.
  801. @item reset
  802. Set number of frame after which stats are going to be recalculated.
  803. Default is disabled.
  804. @end table
  805. A description of each shown parameter follows:
  806. @table @option
  807. @item DC offset
  808. Mean amplitude displacement from zero.
  809. @item Min level
  810. Minimal sample level.
  811. @item Max level
  812. Maximal sample level.
  813. @item Min difference
  814. Minimal difference between two consecutive samples.
  815. @item Max difference
  816. Maximal difference between two consecutive samples.
  817. @item Mean difference
  818. Mean difference between two consecutive samples.
  819. The average of each difference between two consecutive samples.
  820. @item Peak level dB
  821. @item RMS level dB
  822. Standard peak and RMS level measured in dBFS.
  823. @item RMS peak dB
  824. @item RMS trough dB
  825. Peak and trough values for RMS level measured over a short window.
  826. @item Crest factor
  827. Standard ratio of peak to RMS level (note: not in dB).
  828. @item Flat factor
  829. Flatness (i.e. consecutive samples with the same value) of the signal at its peak levels
  830. (i.e. either @var{Min level} or @var{Max level}).
  831. @item Peak count
  832. Number of occasions (not the number of samples) that the signal attained either
  833. @var{Min level} or @var{Max level}.
  834. @item Bit depth
  835. Overall bit depth of audio. Number of bits used for each sample.
  836. @end table
  837. @section astreamsync
  838. Forward two audio streams and control the order the buffers are forwarded.
  839. The filter accepts the following options:
  840. @table @option
  841. @item expr, e
  842. Set the expression deciding which stream should be
  843. forwarded next: if the result is negative, the first stream is forwarded; if
  844. the result is positive or zero, the second stream is forwarded. It can use
  845. the following variables:
  846. @table @var
  847. @item b1 b2
  848. number of buffers forwarded so far on each stream
  849. @item s1 s2
  850. number of samples forwarded so far on each stream
  851. @item t1 t2
  852. current timestamp of each stream
  853. @end table
  854. The default value is @code{t1-t2}, which means to always forward the stream
  855. that has a smaller timestamp.
  856. @end table
  857. @subsection Examples
  858. Stress-test @code{amerge} by randomly sending buffers on the wrong
  859. input, while avoiding too much of a desynchronization:
  860. @example
  861. amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
  862. [a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
  863. [a2] [b2] amerge
  864. @end example
  865. @section asyncts
  866. Synchronize audio data with timestamps by squeezing/stretching it and/or
  867. dropping samples/adding silence when needed.
  868. This filter is not built by default, please use @ref{aresample} to do squeezing/stretching.
  869. It accepts the following parameters:
  870. @table @option
  871. @item compensate
  872. Enable stretching/squeezing the data to make it match the timestamps. Disabled
  873. by default. When disabled, time gaps are covered with silence.
  874. @item min_delta
  875. The minimum difference between timestamps and audio data (in seconds) to trigger
  876. adding/dropping samples. The default value is 0.1. If you get an imperfect
  877. sync with this filter, try setting this parameter to 0.
  878. @item max_comp
  879. The maximum compensation in samples per second. Only relevant with compensate=1.
  880. The default value is 500.
  881. @item first_pts
  882. Assume that the first PTS should be this value. The time base is 1 / sample
  883. rate. This allows for padding/trimming at the start of the stream. By default,
  884. no assumption is made about the first frame's expected PTS, so no padding or
  885. trimming is done. For example, this could be set to 0 to pad the beginning with
  886. silence if an audio stream starts after the video stream or to trim any samples
  887. with a negative PTS due to encoder delay.
  888. @end table
  889. @section atempo
  890. Adjust audio tempo.
  891. The filter accepts exactly one parameter, the audio tempo. If not
  892. specified then the filter will assume nominal 1.0 tempo. Tempo must
  893. be in the [0.5, 2.0] range.
  894. @subsection Examples
  895. @itemize
  896. @item
  897. Slow down audio to 80% tempo:
  898. @example
  899. atempo=0.8
  900. @end example
  901. @item
  902. To speed up audio to 125% tempo:
  903. @example
  904. atempo=1.25
  905. @end example
  906. @end itemize
  907. @section atrim
  908. Trim the input so that the output contains one continuous subpart of the input.
  909. It accepts the following parameters:
  910. @table @option
  911. @item start
  912. Timestamp (in seconds) of the start of the section to keep. I.e. the audio
  913. sample with the timestamp @var{start} will be the first sample in the output.
  914. @item end
  915. Specify time of the first audio sample that will be dropped, i.e. the
  916. audio sample immediately preceding the one with the timestamp @var{end} will be
  917. the last sample in the output.
  918. @item start_pts
  919. Same as @var{start}, except this option sets the start timestamp in samples
  920. instead of seconds.
  921. @item end_pts
  922. Same as @var{end}, except this option sets the end timestamp in samples instead
  923. of seconds.
  924. @item duration
  925. The maximum duration of the output in seconds.
  926. @item start_sample
  927. The number of the first sample that should be output.
  928. @item end_sample
  929. The number of the first sample that should be dropped.
  930. @end table
  931. @option{start}, @option{end}, and @option{duration} are expressed as time
  932. duration specifications; see
  933. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  934. Note that the first two sets of the start/end options and the @option{duration}
  935. option look at the frame timestamp, while the _sample options simply count the
  936. samples that pass through the filter. So start/end_pts and start/end_sample will
  937. give different results when the timestamps are wrong, inexact or do not start at
  938. zero. Also note that this filter does not modify the timestamps. If you wish
  939. to have the output timestamps start at zero, insert the asetpts filter after the
  940. atrim filter.
  941. If multiple start or end options are set, this filter tries to be greedy and
  942. keep all samples that match at least one of the specified constraints. To keep
  943. only the part that matches all the constraints at once, chain multiple atrim
  944. filters.
  945. The defaults are such that all the input is kept. So it is possible to set e.g.
  946. just the end values to keep everything before the specified time.
  947. Examples:
  948. @itemize
  949. @item
  950. Drop everything except the second minute of input:
  951. @example
  952. ffmpeg -i INPUT -af atrim=60:120
  953. @end example
  954. @item
  955. Keep only the first 1000 samples:
  956. @example
  957. ffmpeg -i INPUT -af atrim=end_sample=1000
  958. @end example
  959. @end itemize
  960. @section bandpass
  961. Apply a two-pole Butterworth band-pass filter with central
  962. frequency @var{frequency}, and (3dB-point) band-width width.
  963. The @var{csg} option selects a constant skirt gain (peak gain = Q)
  964. instead of the default: constant 0dB peak gain.
  965. The filter roll off at 6dB per octave (20dB per decade).
  966. The filter accepts the following options:
  967. @table @option
  968. @item frequency, f
  969. Set the filter's central frequency. Default is @code{3000}.
  970. @item csg
  971. Constant skirt gain if set to 1. Defaults to 0.
  972. @item width_type
  973. Set method to specify band-width of filter.
  974. @table @option
  975. @item h
  976. Hz
  977. @item q
  978. Q-Factor
  979. @item o
  980. octave
  981. @item s
  982. slope
  983. @end table
  984. @item width, w
  985. Specify the band-width of a filter in width_type units.
  986. @end table
  987. @section bandreject
  988. Apply a two-pole Butterworth band-reject filter with central
  989. frequency @var{frequency}, and (3dB-point) band-width @var{width}.
  990. The filter roll off at 6dB per octave (20dB per decade).
  991. The filter accepts the following options:
  992. @table @option
  993. @item frequency, f
  994. Set the filter's central frequency. Default is @code{3000}.
  995. @item width_type
  996. Set method to specify band-width of filter.
  997. @table @option
  998. @item h
  999. Hz
  1000. @item q
  1001. Q-Factor
  1002. @item o
  1003. octave
  1004. @item s
  1005. slope
  1006. @end table
  1007. @item width, w
  1008. Specify the band-width of a filter in width_type units.
  1009. @end table
  1010. @section bass
  1011. Boost or cut the bass (lower) frequencies of the audio using a two-pole
  1012. shelving filter with a response similar to that of a standard
  1013. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  1014. The filter accepts the following options:
  1015. @table @option
  1016. @item gain, g
  1017. Give the gain at 0 Hz. Its useful range is about -20
  1018. (for a large cut) to +20 (for a large boost).
  1019. Beware of clipping when using a positive gain.
  1020. @item frequency, f
  1021. Set the filter's central frequency and so can be used
  1022. to extend or reduce the frequency range to be boosted or cut.
  1023. The default value is @code{100} Hz.
  1024. @item width_type
  1025. Set method to specify band-width of filter.
  1026. @table @option
  1027. @item h
  1028. Hz
  1029. @item q
  1030. Q-Factor
  1031. @item o
  1032. octave
  1033. @item s
  1034. slope
  1035. @end table
  1036. @item width, w
  1037. Determine how steep is the filter's shelf transition.
  1038. @end table
  1039. @section biquad
  1040. Apply a biquad IIR filter with the given coefficients.
  1041. Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
  1042. are the numerator and denominator coefficients respectively.
  1043. @section bs2b
  1044. Bauer stereo to binaural transformation, which improves headphone listening of
  1045. stereo audio records.
  1046. It accepts the following parameters:
  1047. @table @option
  1048. @item profile
  1049. Pre-defined crossfeed level.
  1050. @table @option
  1051. @item default
  1052. Default level (fcut=700, feed=50).
  1053. @item cmoy
  1054. Chu Moy circuit (fcut=700, feed=60).
  1055. @item jmeier
  1056. Jan Meier circuit (fcut=650, feed=95).
  1057. @end table
  1058. @item fcut
  1059. Cut frequency (in Hz).
  1060. @item feed
  1061. Feed level (in Hz).
  1062. @end table
  1063. @section channelmap
  1064. Remap input channels to new locations.
  1065. It accepts the following parameters:
  1066. @table @option
  1067. @item channel_layout
  1068. The channel layout of the output stream.
  1069. @item map
  1070. Map channels from input to output. The argument is a '|'-separated list of
  1071. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  1072. @var{in_channel} form. @var{in_channel} can be either the name of the input
  1073. channel (e.g. FL for front left) or its index in the input channel layout.
  1074. @var{out_channel} is the name of the output channel or its index in the output
  1075. channel layout. If @var{out_channel} is not given then it is implicitly an
  1076. index, starting with zero and increasing by one for each mapping.
  1077. @end table
  1078. If no mapping is present, the filter will implicitly map input channels to
  1079. output channels, preserving indices.
  1080. For example, assuming a 5.1+downmix input MOV file,
  1081. @example
  1082. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
  1083. @end example
  1084. will create an output WAV file tagged as stereo from the downmix channels of
  1085. the input.
  1086. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  1087. @example
  1088. ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:5.1' out.wav
  1089. @end example
  1090. @section channelsplit
  1091. Split each channel from an input audio stream into a separate output stream.
  1092. It accepts the following parameters:
  1093. @table @option
  1094. @item channel_layout
  1095. The channel layout of the input stream. The default is "stereo".
  1096. @end table
  1097. For example, assuming a stereo input MP3 file,
  1098. @example
  1099. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  1100. @end example
  1101. will create an output Matroska file with two audio streams, one containing only
  1102. the left channel and the other the right channel.
  1103. Split a 5.1 WAV file into per-channel files:
  1104. @example
  1105. ffmpeg -i in.wav -filter_complex
  1106. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  1107. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  1108. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  1109. side_right.wav
  1110. @end example
  1111. @section chorus
  1112. Add a chorus effect to the audio.
  1113. Can make a single vocal sound like a chorus, but can also be applied to instrumentation.
  1114. Chorus resembles an echo effect with a short delay, but whereas with echo the delay is
  1115. constant, with chorus, it is varied using using sinusoidal or triangular modulation.
  1116. The modulation depth defines the range the modulated delay is played before or after
  1117. the delay. Hence the delayed sound will sound slower or faster, that is the delayed
  1118. sound tuned around the original one, like in a chorus where some vocals are slightly
  1119. off key.
  1120. It accepts the following parameters:
  1121. @table @option
  1122. @item in_gain
  1123. Set input gain. Default is 0.4.
  1124. @item out_gain
  1125. Set output gain. Default is 0.4.
  1126. @item delays
  1127. Set delays. A typical delay is around 40ms to 60ms.
  1128. @item decays
  1129. Set decays.
  1130. @item speeds
  1131. Set speeds.
  1132. @item depths
  1133. Set depths.
  1134. @end table
  1135. @subsection Examples
  1136. @itemize
  1137. @item
  1138. A single delay:
  1139. @example
  1140. chorus=0.7:0.9:55:0.4:0.25:2
  1141. @end example
  1142. @item
  1143. Two delays:
  1144. @example
  1145. chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3
  1146. @end example
  1147. @item
  1148. Fuller sounding chorus with three delays:
  1149. @example
  1150. 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
  1151. @end example
  1152. @end itemize
  1153. @section compand
  1154. Compress or expand the audio's dynamic range.
  1155. It accepts the following parameters:
  1156. @table @option
  1157. @item attacks
  1158. @item decays
  1159. A list of times in seconds for each channel over which the instantaneous level
  1160. of the input signal is averaged to determine its volume. @var{attacks} refers to
  1161. increase of volume and @var{decays} refers to decrease of volume. For most
  1162. situations, the attack time (response to the audio getting louder) should be
  1163. shorter than the decay time, because the human ear is more sensitive to sudden
  1164. loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
  1165. a typical value for decay is 0.8 seconds.
  1166. If specified number of attacks & decays is lower than number of channels, the last
  1167. set attack/decay will be used for all remaining channels.
  1168. @item points
  1169. A list of points for the transfer function, specified in dB relative to the
  1170. maximum possible signal amplitude. Each key points list must be defined using
  1171. the following syntax: @code{x0/y0|x1/y1|x2/y2|....} or
  1172. @code{x0/y0 x1/y1 x2/y2 ....}
  1173. The input values must be in strictly increasing order but the transfer function
  1174. does not have to be monotonically rising. The point @code{0/0} is assumed but
  1175. may be overridden (by @code{0/out-dBn}). Typical values for the transfer
  1176. function are @code{-70/-70|-60/-20}.
  1177. @item soft-knee
  1178. Set the curve radius in dB for all joints. It defaults to 0.01.
  1179. @item gain
  1180. Set the additional gain in dB to be applied at all points on the transfer
  1181. function. This allows for easy adjustment of the overall gain.
  1182. It defaults to 0.
  1183. @item volume
  1184. Set an initial volume, in dB, to be assumed for each channel when filtering
  1185. starts. This permits the user to supply a nominal level initially, so that, for
  1186. example, a very large gain is not applied to initial signal levels before the
  1187. companding has begun to operate. A typical value for audio which is initially
  1188. quiet is -90 dB. It defaults to 0.
  1189. @item delay
  1190. Set a delay, in seconds. The input audio is analyzed immediately, but audio is
  1191. delayed before being fed to the volume adjuster. Specifying a delay
  1192. approximately equal to the attack/decay times allows the filter to effectively
  1193. operate in predictive rather than reactive mode. It defaults to 0.
  1194. @end table
  1195. @subsection Examples
  1196. @itemize
  1197. @item
  1198. Make music with both quiet and loud passages suitable for listening to in a
  1199. noisy environment:
  1200. @example
  1201. compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
  1202. @end example
  1203. Another example for audio with whisper and explosion parts:
  1204. @example
  1205. compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0
  1206. @end example
  1207. @item
  1208. A noise gate for when the noise is at a lower level than the signal:
  1209. @example
  1210. compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
  1211. @end example
  1212. @item
  1213. Here is another noise gate, this time for when the noise is at a higher level
  1214. than the signal (making it, in some ways, similar to squelch):
  1215. @example
  1216. compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
  1217. @end example
  1218. @end itemize
  1219. @section dcshift
  1220. Apply a DC shift to the audio.
  1221. This can be useful to remove a DC offset (caused perhaps by a hardware problem
  1222. in the recording chain) from the audio. The effect of a DC offset is reduced
  1223. headroom and hence volume. The @ref{astats} filter can be used to determine if
  1224. a signal has a DC offset.
  1225. @table @option
  1226. @item shift
  1227. Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift
  1228. the audio.
  1229. @item limitergain
  1230. Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
  1231. used to prevent clipping.
  1232. @end table
  1233. @section dynaudnorm
  1234. Dynamic Audio Normalizer.
  1235. This filter applies a certain amount of gain to the input audio in order
  1236. to bring its peak magnitude to a target level (e.g. 0 dBFS). However, in
  1237. contrast to more "simple" normalization algorithms, the Dynamic Audio
  1238. Normalizer *dynamically* re-adjusts the gain factor to the input audio.
  1239. This allows for applying extra gain to the "quiet" sections of the audio
  1240. while avoiding distortions or clipping the "loud" sections. In other words:
  1241. The Dynamic Audio Normalizer will "even out" the volume of quiet and loud
  1242. sections, in the sense that the volume of each section is brought to the
  1243. same target level. Note, however, that the Dynamic Audio Normalizer achieves
  1244. this goal *without* applying "dynamic range compressing". It will retain 100%
  1245. of the dynamic range *within* each section of the audio file.
  1246. @table @option
  1247. @item f
  1248. Set the frame length in milliseconds. In range from 10 to 8000 milliseconds.
  1249. Default is 500 milliseconds.
  1250. The Dynamic Audio Normalizer processes the input audio in small chunks,
  1251. referred to as frames. This is required, because a peak magnitude has no
  1252. meaning for just a single sample value. Instead, we need to determine the
  1253. peak magnitude for a contiguous sequence of sample values. While a "standard"
  1254. normalizer would simply use the peak magnitude of the complete file, the
  1255. Dynamic Audio Normalizer determines the peak magnitude individually for each
  1256. frame. The length of a frame is specified in milliseconds. By default, the
  1257. Dynamic Audio Normalizer uses a frame length of 500 milliseconds, which has
  1258. been found to give good results with most files.
  1259. Note that the exact frame length, in number of samples, will be determined
  1260. automatically, based on the sampling rate of the individual input audio file.
  1261. @item g
  1262. Set the Gaussian filter window size. In range from 3 to 301, must be odd
  1263. number. Default is 31.
  1264. Probably the most important parameter of the Dynamic Audio Normalizer is the
  1265. @code{window size} of the Gaussian smoothing filter. The filter's window size
  1266. is specified in frames, centered around the current frame. For the sake of
  1267. simplicity, this must be an odd number. Consequently, the default value of 31
  1268. takes into account the current frame, as well as the 15 preceding frames and
  1269. the 15 subsequent frames. Using a larger window results in a stronger
  1270. smoothing effect and thus in less gain variation, i.e. slower gain
  1271. adaptation. Conversely, using a smaller window results in a weaker smoothing
  1272. effect and thus in more gain variation, i.e. faster gain adaptation.
  1273. In other words, the more you increase this value, the more the Dynamic Audio
  1274. Normalizer will behave like a "traditional" normalization filter. On the
  1275. contrary, the more you decrease this value, the more the Dynamic Audio
  1276. Normalizer will behave like a dynamic range compressor.
  1277. @item p
  1278. Set the target peak value. This specifies the highest permissible magnitude
  1279. level for the normalized audio input. This filter will try to approach the
  1280. target peak magnitude as closely as possible, but at the same time it also
  1281. makes sure that the normalized signal will never exceed the peak magnitude.
  1282. A frame's maximum local gain factor is imposed directly by the target peak
  1283. magnitude. The default value is 0.95 and thus leaves a headroom of 5%*.
  1284. It is not recommended to go above this value.
  1285. @item m
  1286. Set the maximum gain factor. In range from 1.0 to 100.0. Default is 10.0.
  1287. The Dynamic Audio Normalizer determines the maximum possible (local) gain
  1288. factor for each input frame, i.e. the maximum gain factor that does not
  1289. result in clipping or distortion. The maximum gain factor is determined by
  1290. the frame's highest magnitude sample. However, the Dynamic Audio Normalizer
  1291. additionally bounds the frame's maximum gain factor by a predetermined
  1292. (global) maximum gain factor. This is done in order to avoid excessive gain
  1293. factors in "silent" or almost silent frames. By default, the maximum gain
  1294. factor is 10.0, For most inputs the default value should be sufficient and
  1295. it usually is not recommended to increase this value. Though, for input
  1296. with an extremely low overall volume level, it may be necessary to allow even
  1297. higher gain factors. Note, however, that the Dynamic Audio Normalizer does
  1298. not simply apply a "hard" threshold (i.e. cut off values above the threshold).
  1299. Instead, a "sigmoid" threshold function will be applied. This way, the
  1300. gain factors will smoothly approach the threshold value, but never exceed that
  1301. value.
  1302. @item r
  1303. Set the target RMS. In range from 0.0 to 1.0. Default is 0.0 - disabled.
  1304. By default, the Dynamic Audio Normalizer performs "peak" normalization.
  1305. This means that the maximum local gain factor for each frame is defined
  1306. (only) by the frame's highest magnitude sample. This way, the samples can
  1307. be amplified as much as possible without exceeding the maximum signal
  1308. level, i.e. without clipping. Optionally, however, the Dynamic Audio
  1309. Normalizer can also take into account the frame's root mean square,
  1310. abbreviated RMS. In electrical engineering, the RMS is commonly used to
  1311. determine the power of a time-varying signal. It is therefore considered
  1312. that the RMS is a better approximation of the "perceived loudness" than
  1313. just looking at the signal's peak magnitude. Consequently, by adjusting all
  1314. frames to a constant RMS value, a uniform "perceived loudness" can be
  1315. established. If a target RMS value has been specified, a frame's local gain
  1316. factor is defined as the factor that would result in exactly that RMS value.
  1317. Note, however, that the maximum local gain factor is still restricted by the
  1318. frame's highest magnitude sample, in order to prevent clipping.
  1319. @item n
  1320. Enable channels coupling. By default is enabled.
  1321. By default, the Dynamic Audio Normalizer will amplify all channels by the same
  1322. amount. This means the same gain factor will be applied to all channels, i.e.
  1323. the maximum possible gain factor is determined by the "loudest" channel.
  1324. However, in some recordings, it may happen that the volume of the different
  1325. channels is uneven, e.g. one channel may be "quieter" than the other one(s).
  1326. In this case, this option can be used to disable the channel coupling. This way,
  1327. the gain factor will be determined independently for each channel, depending
  1328. only on the individual channel's highest magnitude sample. This allows for
  1329. harmonizing the volume of the different channels.
  1330. @item c
  1331. Enable DC bias correction. By default is disabled.
  1332. An audio signal (in the time domain) is a sequence of sample values.
  1333. In the Dynamic Audio Normalizer these sample values are represented in the
  1334. -1.0 to 1.0 range, regardless of the original input format. Normally, the
  1335. audio signal, or "waveform", should be centered around the zero point.
  1336. That means if we calculate the mean value of all samples in a file, or in a
  1337. single frame, then the result should be 0.0 or at least very close to that
  1338. value. If, however, there is a significant deviation of the mean value from
  1339. 0.0, in either positive or negative direction, this is referred to as a
  1340. DC bias or DC offset. Since a DC bias is clearly undesirable, the Dynamic
  1341. Audio Normalizer provides optional DC bias correction.
  1342. With DC bias correction enabled, the Dynamic Audio Normalizer will determine
  1343. the mean value, or "DC correction" offset, of each input frame and subtract
  1344. that value from all of the frame's sample values which ensures those samples
  1345. are centered around 0.0 again. Also, in order to avoid "gaps" at the frame
  1346. boundaries, the DC correction offset values will be interpolated smoothly
  1347. between neighbouring frames.
  1348. @item b
  1349. Enable alternative boundary mode. By default is disabled.
  1350. The Dynamic Audio Normalizer takes into account a certain neighbourhood
  1351. around each frame. This includes the preceding frames as well as the
  1352. subsequent frames. However, for the "boundary" frames, located at the very
  1353. beginning and at the very end of the audio file, not all neighbouring
  1354. frames are available. In particular, for the first few frames in the audio
  1355. file, the preceding frames are not known. And, similarly, for the last few
  1356. frames in the audio file, the subsequent frames are not known. Thus, the
  1357. question arises which gain factors should be assumed for the missing frames
  1358. in the "boundary" region. The Dynamic Audio Normalizer implements two modes
  1359. to deal with this situation. The default boundary mode assumes a gain factor
  1360. of exactly 1.0 for the missing frames, resulting in a smooth "fade in" and
  1361. "fade out" at the beginning and at the end of the input, respectively.
  1362. @item s
  1363. Set the compress factor. In range from 0.0 to 30.0. Default is 0.0.
  1364. By default, the Dynamic Audio Normalizer does not apply "traditional"
  1365. compression. This means that signal peaks will not be pruned and thus the
  1366. full dynamic range will be retained within each local neighbourhood. However,
  1367. in some cases it may be desirable to combine the Dynamic Audio Normalizer's
  1368. normalization algorithm with a more "traditional" compression.
  1369. For this purpose, the Dynamic Audio Normalizer provides an optional compression
  1370. (thresholding) function. If (and only if) the compression feature is enabled,
  1371. all input frames will be processed by a soft knee thresholding function prior
  1372. to the actual normalization process. Put simply, the thresholding function is
  1373. going to prune all samples whose magnitude exceeds a certain threshold value.
  1374. However, the Dynamic Audio Normalizer does not simply apply a fixed threshold
  1375. value. Instead, the threshold value will be adjusted for each individual
  1376. frame.
  1377. In general, smaller parameters result in stronger compression, and vice versa.
  1378. Values below 3.0 are not recommended, because audible distortion may appear.
  1379. @end table
  1380. @section earwax
  1381. Make audio easier to listen to on headphones.
  1382. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  1383. so that when listened to on headphones the stereo image is moved from
  1384. inside your head (standard for headphones) to outside and in front of
  1385. the listener (standard for speakers).
  1386. Ported from SoX.
  1387. @section equalizer
  1388. Apply a two-pole peaking equalisation (EQ) filter. With this
  1389. filter, the signal-level at and around a selected frequency can
  1390. be increased or decreased, whilst (unlike bandpass and bandreject
  1391. filters) that at all other frequencies is unchanged.
  1392. In order to produce complex equalisation curves, this filter can
  1393. be given several times, each with a different central frequency.
  1394. The filter accepts the following options:
  1395. @table @option
  1396. @item frequency, f
  1397. Set the filter's central frequency in Hz.
  1398. @item width_type
  1399. Set method to specify band-width of filter.
  1400. @table @option
  1401. @item h
  1402. Hz
  1403. @item q
  1404. Q-Factor
  1405. @item o
  1406. octave
  1407. @item s
  1408. slope
  1409. @end table
  1410. @item width, w
  1411. Specify the band-width of a filter in width_type units.
  1412. @item gain, g
  1413. Set the required gain or attenuation in dB.
  1414. Beware of clipping when using a positive gain.
  1415. @end table
  1416. @subsection Examples
  1417. @itemize
  1418. @item
  1419. Attenuate 10 dB at 1000 Hz, with a bandwidth of 200 Hz:
  1420. @example
  1421. equalizer=f=1000:width_type=h:width=200:g=-10
  1422. @end example
  1423. @item
  1424. Apply 2 dB gain at 1000 Hz with Q 1 and attenuate 5 dB at 100 Hz with Q 2:
  1425. @example
  1426. equalizer=f=1000:width_type=q:width=1:g=2,equalizer=f=100:width_type=q:width=2:g=-5
  1427. @end example
  1428. @end itemize
  1429. @section flanger
  1430. Apply a flanging effect to the audio.
  1431. The filter accepts the following options:
  1432. @table @option
  1433. @item delay
  1434. Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
  1435. @item depth
  1436. Set added swep delay in milliseconds. Range from 0 to 10. Default value is 2.
  1437. @item regen
  1438. Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
  1439. Default value is 0.
  1440. @item width
  1441. Set percentage of delayed signal mixed with original. Range from 0 to 100.
  1442. Default value is 71.
  1443. @item speed
  1444. Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
  1445. @item shape
  1446. Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
  1447. Default value is @var{sinusoidal}.
  1448. @item phase
  1449. Set swept wave percentage-shift for multi channel. Range from 0 to 100.
  1450. Default value is 25.
  1451. @item interp
  1452. Set delay-line interpolation, @var{linear} or @var{quadratic}.
  1453. Default is @var{linear}.
  1454. @end table
  1455. @section highpass
  1456. Apply a high-pass filter with 3dB point frequency.
  1457. The filter can be either single-pole, or double-pole (the default).
  1458. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1459. The filter accepts the following options:
  1460. @table @option
  1461. @item frequency, f
  1462. Set frequency in Hz. Default is 3000.
  1463. @item poles, p
  1464. Set number of poles. Default is 2.
  1465. @item width_type
  1466. Set method to specify band-width of filter.
  1467. @table @option
  1468. @item h
  1469. Hz
  1470. @item q
  1471. Q-Factor
  1472. @item o
  1473. octave
  1474. @item s
  1475. slope
  1476. @end table
  1477. @item width, w
  1478. Specify the band-width of a filter in width_type units.
  1479. Applies only to double-pole filter.
  1480. The default is 0.707q and gives a Butterworth response.
  1481. @end table
  1482. @section join
  1483. Join multiple input streams into one multi-channel stream.
  1484. It accepts the following parameters:
  1485. @table @option
  1486. @item inputs
  1487. The number of input streams. It defaults to 2.
  1488. @item channel_layout
  1489. The desired output channel layout. It defaults to stereo.
  1490. @item map
  1491. Map channels from inputs to output. The argument is a '|'-separated list of
  1492. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  1493. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  1494. can be either the name of the input channel (e.g. FL for front left) or its
  1495. index in the specified input stream. @var{out_channel} is the name of the output
  1496. channel.
  1497. @end table
  1498. The filter will attempt to guess the mappings when they are not specified
  1499. explicitly. It does so by first trying to find an unused matching input channel
  1500. and if that fails it picks the first unused input channel.
  1501. Join 3 inputs (with properly set channel layouts):
  1502. @example
  1503. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  1504. @end example
  1505. Build a 5.1 output from 6 single-channel streams:
  1506. @example
  1507. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  1508. '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'
  1509. out
  1510. @end example
  1511. @section ladspa
  1512. Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
  1513. To enable compilation of this filter you need to configure FFmpeg with
  1514. @code{--enable-ladspa}.
  1515. @table @option
  1516. @item file, f
  1517. Specifies the name of LADSPA plugin library to load. If the environment
  1518. variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
  1519. each one of the directories specified by the colon separated list in
  1520. @env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
  1521. this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
  1522. @file{/usr/lib/ladspa/}.
  1523. @item plugin, p
  1524. Specifies the plugin within the library. Some libraries contain only
  1525. one plugin, but others contain many of them. If this is not set filter
  1526. will list all available plugins within the specified library.
  1527. @item controls, c
  1528. Set the '|' separated list of controls which are zero or more floating point
  1529. values that determine the behavior of the loaded plugin (for example delay,
  1530. threshold or gain).
  1531. Controls need to be defined using the following syntax:
  1532. c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
  1533. @var{valuei} is the value set on the @var{i}-th control.
  1534. If @option{controls} is set to @code{help}, all available controls and
  1535. their valid ranges are printed.
  1536. @item sample_rate, s
  1537. Specify the sample rate, default to 44100. Only used if plugin have
  1538. zero inputs.
  1539. @item nb_samples, n
  1540. Set the number of samples per channel per each output frame, default
  1541. is 1024. Only used if plugin have zero inputs.
  1542. @item duration, d
  1543. Set the minimum duration of the sourced audio. See
  1544. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  1545. for the accepted syntax.
  1546. Note that the resulting duration may be greater than the specified duration,
  1547. as the generated audio is always cut at the end of a complete frame.
  1548. If not specified, or the expressed duration is negative, the audio is
  1549. supposed to be generated forever.
  1550. Only used if plugin have zero inputs.
  1551. @end table
  1552. @subsection Examples
  1553. @itemize
  1554. @item
  1555. List all available plugins within amp (LADSPA example plugin) library:
  1556. @example
  1557. ladspa=file=amp
  1558. @end example
  1559. @item
  1560. List all available controls and their valid ranges for @code{vcf_notch}
  1561. plugin from @code{VCF} library:
  1562. @example
  1563. ladspa=f=vcf:p=vcf_notch:c=help
  1564. @end example
  1565. @item
  1566. Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
  1567. plugin library:
  1568. @example
  1569. ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
  1570. @end example
  1571. @item
  1572. Add reverberation to the audio using TAP-plugins
  1573. (Tom's Audio Processing plugins):
  1574. @example
  1575. ladspa=file=tap_reverb:tap_reverb
  1576. @end example
  1577. @item
  1578. Generate white noise, with 0.2 amplitude:
  1579. @example
  1580. ladspa=file=cmt:noise_source_white:c=c0=.2
  1581. @end example
  1582. @item
  1583. Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
  1584. @code{C* Audio Plugin Suite} (CAPS) library:
  1585. @example
  1586. ladspa=file=caps:Click:c=c1=20'
  1587. @end example
  1588. @item
  1589. Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
  1590. @example
  1591. ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
  1592. @end example
  1593. @end itemize
  1594. @subsection Commands
  1595. This filter supports the following commands:
  1596. @table @option
  1597. @item cN
  1598. Modify the @var{N}-th control value.
  1599. If the specified value is not valid, it is ignored and prior one is kept.
  1600. @end table
  1601. @section lowpass
  1602. Apply a low-pass filter with 3dB point frequency.
  1603. The filter can be either single-pole or double-pole (the default).
  1604. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1605. The filter accepts the following options:
  1606. @table @option
  1607. @item frequency, f
  1608. Set frequency in Hz. Default is 500.
  1609. @item poles, p
  1610. Set number of poles. Default is 2.
  1611. @item width_type
  1612. Set method to specify band-width of filter.
  1613. @table @option
  1614. @item h
  1615. Hz
  1616. @item q
  1617. Q-Factor
  1618. @item o
  1619. octave
  1620. @item s
  1621. slope
  1622. @end table
  1623. @item width, w
  1624. Specify the band-width of a filter in width_type units.
  1625. Applies only to double-pole filter.
  1626. The default is 0.707q and gives a Butterworth response.
  1627. @end table
  1628. @anchor{pan}
  1629. @section pan
  1630. Mix channels with specific gain levels. The filter accepts the output
  1631. channel layout followed by a set of channels definitions.
  1632. This filter is also designed to efficiently remap the channels of an audio
  1633. stream.
  1634. The filter accepts parameters of the form:
  1635. "@var{l}|@var{outdef}|@var{outdef}|..."
  1636. @table @option
  1637. @item l
  1638. output channel layout or number of channels
  1639. @item outdef
  1640. output channel specification, of the form:
  1641. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  1642. @item out_name
  1643. output channel to define, either a channel name (FL, FR, etc.) or a channel
  1644. number (c0, c1, etc.)
  1645. @item gain
  1646. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  1647. @item in_name
  1648. input channel to use, see out_name for details; it is not possible to mix
  1649. named and numbered input channels
  1650. @end table
  1651. If the `=' in a channel specification is replaced by `<', then the gains for
  1652. that specification will be renormalized so that the total is 1, thus
  1653. avoiding clipping noise.
  1654. @subsection Mixing examples
  1655. For example, if you want to down-mix from stereo to mono, but with a bigger
  1656. factor for the left channel:
  1657. @example
  1658. pan=1c|c0=0.9*c0+0.1*c1
  1659. @end example
  1660. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  1661. 7-channels surround:
  1662. @example
  1663. pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  1664. @end example
  1665. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  1666. that should be preferred (see "-ac" option) unless you have very specific
  1667. needs.
  1668. @subsection Remapping examples
  1669. The channel remapping will be effective if, and only if:
  1670. @itemize
  1671. @item gain coefficients are zeroes or ones,
  1672. @item only one input per channel output,
  1673. @end itemize
  1674. If all these conditions are satisfied, the filter will notify the user ("Pure
  1675. channel mapping detected"), and use an optimized and lossless method to do the
  1676. remapping.
  1677. For example, if you have a 5.1 source and want a stereo audio stream by
  1678. dropping the extra channels:
  1679. @example
  1680. pan="stereo| c0=FL | c1=FR"
  1681. @end example
  1682. Given the same source, you can also switch front left and front right channels
  1683. and keep the input channel layout:
  1684. @example
  1685. pan="5.1| c0=c1 | c1=c0 | c2=c2 | c3=c3 | c4=c4 | c5=c5"
  1686. @end example
  1687. If the input is a stereo audio stream, you can mute the front left channel (and
  1688. still keep the stereo channel layout) with:
  1689. @example
  1690. pan="stereo|c1=c1"
  1691. @end example
  1692. Still with a stereo audio stream input, you can copy the right channel in both
  1693. front left and right:
  1694. @example
  1695. pan="stereo| c0=FR | c1=FR"
  1696. @end example
  1697. @section replaygain
  1698. ReplayGain scanner filter. This filter takes an audio stream as an input and
  1699. outputs it unchanged.
  1700. At end of filtering it displays @code{track_gain} and @code{track_peak}.
  1701. @section resample
  1702. Convert the audio sample format, sample rate and channel layout. It is
  1703. not meant to be used directly.
  1704. @section sidechaincompress
  1705. This filter acts like normal compressor but has the ability to compress
  1706. detected signal using second input signal.
  1707. It needs two input streams and returns one output stream.
  1708. First input stream will be processed depending on second stream signal.
  1709. The filtered signal then can be filtered with other filters in later stages of
  1710. processing. See @ref{pan} and @ref{amerge} filter.
  1711. The filter accepts the following options:
  1712. @table @option
  1713. @item threshold
  1714. If a signal of second stream raises above this level it will affect the gain
  1715. reduction of first stream.
  1716. By default is 0.125. Range is between 0.00097563 and 1.
  1717. @item ratio
  1718. Set a ratio about which the signal is reduced. 1:2 means that if the level
  1719. raised 4dB above the threshold, it will be only 2dB above after the reduction.
  1720. Default is 2. Range is between 1 and 20.
  1721. @item attack
  1722. Amount of milliseconds the signal has to rise above the threshold before gain
  1723. reduction starts. Default is 20. Range is between 0.01 and 2000.
  1724. @item release
  1725. Amount of milliseconds the signal has to fall bellow the threshold before
  1726. reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
  1727. @item makeup
  1728. Set the amount by how much signal will be amplified after processing.
  1729. Default is 2. Range is from 1 and 64.
  1730. @item knee
  1731. Curve the sharp knee around the threshold to enter gain reduction more softly.
  1732. Default is 2.82843. Range is between 1 and 8.
  1733. @item link
  1734. Choose if the @code{average} level between all channels of side-chain stream
  1735. or the louder(@code{maximum}) channel of side-chain stream affects the
  1736. reduction. Default is @code{average}.
  1737. @item detection
  1738. Should the exact signal be taken in case of @code{peak} or an RMS one in case
  1739. of @code{rms}. Default is @code{rms} which is mainly smoother.
  1740. @end table
  1741. @subsection Examples
  1742. @itemize
  1743. @item
  1744. Full ffmpeg example taking 2 audio inputs, 1st input to be compressed
  1745. depending on the signal of 2nd input and later compressed signal to be
  1746. merged with 2nd input:
  1747. @example
  1748. ffmpeg -i main.flac -i sidechain.flac -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge"
  1749. @end example
  1750. @end itemize
  1751. @section silencedetect
  1752. Detect silence in an audio stream.
  1753. This filter logs a message when it detects that the input audio volume is less
  1754. or equal to a noise tolerance value for a duration greater or equal to the
  1755. minimum detected noise duration.
  1756. The printed times and duration are expressed in seconds.
  1757. The filter accepts the following options:
  1758. @table @option
  1759. @item duration, d
  1760. Set silence duration until notification (default is 2 seconds).
  1761. @item noise, n
  1762. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  1763. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  1764. @end table
  1765. @subsection Examples
  1766. @itemize
  1767. @item
  1768. Detect 5 seconds of silence with -50dB noise tolerance:
  1769. @example
  1770. silencedetect=n=-50dB:d=5
  1771. @end example
  1772. @item
  1773. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  1774. tolerance in @file{silence.mp3}:
  1775. @example
  1776. ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
  1777. @end example
  1778. @end itemize
  1779. @section silenceremove
  1780. Remove silence from the beginning, middle or end of the audio.
  1781. The filter accepts the following options:
  1782. @table @option
  1783. @item start_periods
  1784. This value is used to indicate if audio should be trimmed at beginning of
  1785. the audio. A value of zero indicates no silence should be trimmed from the
  1786. beginning. When specifying a non-zero value, it trims audio up until it
  1787. finds non-silence. Normally, when trimming silence from beginning of audio
  1788. the @var{start_periods} will be @code{1} but it can be increased to higher
  1789. values to trim all audio up to specific count of non-silence periods.
  1790. Default value is @code{0}.
  1791. @item start_duration
  1792. Specify the amount of time that non-silence must be detected before it stops
  1793. trimming audio. By increasing the duration, bursts of noises can be treated
  1794. as silence and trimmed off. Default value is @code{0}.
  1795. @item start_threshold
  1796. This indicates what sample value should be treated as silence. For digital
  1797. audio, a value of @code{0} may be fine but for audio recorded from analog,
  1798. you may wish to increase the value to account for background noise.
  1799. Can be specified in dB (in case "dB" is appended to the specified value)
  1800. or amplitude ratio. Default value is @code{0}.
  1801. @item stop_periods
  1802. Set the count for trimming silence from the end of audio.
  1803. To remove silence from the middle of a file, specify a @var{stop_periods}
  1804. that is negative. This value is then treated as a positive value and is
  1805. used to indicate the effect should restart processing as specified by
  1806. @var{start_periods}, making it suitable for removing periods of silence
  1807. in the middle of the audio.
  1808. Default value is @code{0}.
  1809. @item stop_duration
  1810. Specify a duration of silence that must exist before audio is not copied any
  1811. more. By specifying a higher duration, silence that is wanted can be left in
  1812. the audio.
  1813. Default value is @code{0}.
  1814. @item stop_threshold
  1815. This is the same as @option{start_threshold} but for trimming silence from
  1816. the end of audio.
  1817. Can be specified in dB (in case "dB" is appended to the specified value)
  1818. or amplitude ratio. Default value is @code{0}.
  1819. @item leave_silence
  1820. This indicate that @var{stop_duration} length of audio should be left intact
  1821. at the beginning of each period of silence.
  1822. For example, if you want to remove long pauses between words but do not want
  1823. to remove the pauses completely. Default value is @code{0}.
  1824. @end table
  1825. @subsection Examples
  1826. @itemize
  1827. @item
  1828. The following example shows how this filter can be used to start a recording
  1829. that does not contain the delay at the start which usually occurs between
  1830. pressing the record button and the start of the performance:
  1831. @example
  1832. silenceremove=1:5:0.02
  1833. @end example
  1834. @end itemize
  1835. @section treble
  1836. Boost or cut treble (upper) frequencies of the audio using a two-pole
  1837. shelving filter with a response similar to that of a standard
  1838. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  1839. The filter accepts the following options:
  1840. @table @option
  1841. @item gain, g
  1842. Give the gain at whichever is the lower of ~22 kHz and the
  1843. Nyquist frequency. Its useful range is about -20 (for a large cut)
  1844. to +20 (for a large boost). Beware of clipping when using a positive gain.
  1845. @item frequency, f
  1846. Set the filter's central frequency and so can be used
  1847. to extend or reduce the frequency range to be boosted or cut.
  1848. The default value is @code{3000} Hz.
  1849. @item width_type
  1850. Set method to specify band-width of filter.
  1851. @table @option
  1852. @item h
  1853. Hz
  1854. @item q
  1855. Q-Factor
  1856. @item o
  1857. octave
  1858. @item s
  1859. slope
  1860. @end table
  1861. @item width, w
  1862. Determine how steep is the filter's shelf transition.
  1863. @end table
  1864. @section volume
  1865. Adjust the input audio volume.
  1866. It accepts the following parameters:
  1867. @table @option
  1868. @item volume
  1869. Set audio volume expression.
  1870. Output values are clipped to the maximum value.
  1871. The output audio volume is given by the relation:
  1872. @example
  1873. @var{output_volume} = @var{volume} * @var{input_volume}
  1874. @end example
  1875. The default value for @var{volume} is "1.0".
  1876. @item precision
  1877. This parameter represents the mathematical precision.
  1878. It determines which input sample formats will be allowed, which affects the
  1879. precision of the volume scaling.
  1880. @table @option
  1881. @item fixed
  1882. 8-bit fixed-point; this limits input sample format to U8, S16, and S32.
  1883. @item float
  1884. 32-bit floating-point; this limits input sample format to FLT. (default)
  1885. @item double
  1886. 64-bit floating-point; this limits input sample format to DBL.
  1887. @end table
  1888. @item replaygain
  1889. Choose the behaviour on encountering ReplayGain side data in input frames.
  1890. @table @option
  1891. @item drop
  1892. Remove ReplayGain side data, ignoring its contents (the default).
  1893. @item ignore
  1894. Ignore ReplayGain side data, but leave it in the frame.
  1895. @item track
  1896. Prefer the track gain, if present.
  1897. @item album
  1898. Prefer the album gain, if present.
  1899. @end table
  1900. @item replaygain_preamp
  1901. Pre-amplification gain in dB to apply to the selected replaygain gain.
  1902. Default value for @var{replaygain_preamp} is 0.0.
  1903. @item eval
  1904. Set when the volume expression is evaluated.
  1905. It accepts the following values:
  1906. @table @samp
  1907. @item once
  1908. only evaluate expression once during the filter initialization, or
  1909. when the @samp{volume} command is sent
  1910. @item frame
  1911. evaluate expression for each incoming frame
  1912. @end table
  1913. Default value is @samp{once}.
  1914. @end table
  1915. The volume expression can contain the following parameters.
  1916. @table @option
  1917. @item n
  1918. frame number (starting at zero)
  1919. @item nb_channels
  1920. number of channels
  1921. @item nb_consumed_samples
  1922. number of samples consumed by the filter
  1923. @item nb_samples
  1924. number of samples in the current frame
  1925. @item pos
  1926. original frame position in the file
  1927. @item pts
  1928. frame PTS
  1929. @item sample_rate
  1930. sample rate
  1931. @item startpts
  1932. PTS at start of stream
  1933. @item startt
  1934. time at start of stream
  1935. @item t
  1936. frame time
  1937. @item tb
  1938. timestamp timebase
  1939. @item volume
  1940. last set volume value
  1941. @end table
  1942. Note that when @option{eval} is set to @samp{once} only the
  1943. @var{sample_rate} and @var{tb} variables are available, all other
  1944. variables will evaluate to NAN.
  1945. @subsection Commands
  1946. This filter supports the following commands:
  1947. @table @option
  1948. @item volume
  1949. Modify the volume expression.
  1950. The command accepts the same syntax of the corresponding option.
  1951. If the specified expression is not valid, it is kept at its current
  1952. value.
  1953. @item replaygain_noclip
  1954. Prevent clipping by limiting the gain applied.
  1955. Default value for @var{replaygain_noclip} is 1.
  1956. @end table
  1957. @subsection Examples
  1958. @itemize
  1959. @item
  1960. Halve the input audio volume:
  1961. @example
  1962. volume=volume=0.5
  1963. volume=volume=1/2
  1964. volume=volume=-6.0206dB
  1965. @end example
  1966. In all the above example the named key for @option{volume} can be
  1967. omitted, for example like in:
  1968. @example
  1969. volume=0.5
  1970. @end example
  1971. @item
  1972. Increase input audio power by 6 decibels using fixed-point precision:
  1973. @example
  1974. volume=volume=6dB:precision=fixed
  1975. @end example
  1976. @item
  1977. Fade volume after time 10 with an annihilation period of 5 seconds:
  1978. @example
  1979. volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
  1980. @end example
  1981. @end itemize
  1982. @section volumedetect
  1983. Detect the volume of the input video.
  1984. The filter has no parameters. The input is not modified. Statistics about
  1985. the volume will be printed in the log when the input stream end is reached.
  1986. In particular it will show the mean volume (root mean square), maximum
  1987. volume (on a per-sample basis), and the beginning of a histogram of the
  1988. registered volume values (from the maximum value to a cumulated 1/1000 of
  1989. the samples).
  1990. All volumes are in decibels relative to the maximum PCM value.
  1991. @subsection Examples
  1992. Here is an excerpt of the output:
  1993. @example
  1994. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  1995. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  1996. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  1997. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  1998. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  1999. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  2000. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  2001. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  2002. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  2003. @end example
  2004. It means that:
  2005. @itemize
  2006. @item
  2007. The mean square energy is approximately -27 dB, or 10^-2.7.
  2008. @item
  2009. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  2010. @item
  2011. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  2012. @end itemize
  2013. In other words, raising the volume by +4 dB does not cause any clipping,
  2014. raising it by +5 dB causes clipping for 6 samples, etc.
  2015. @c man end AUDIO FILTERS
  2016. @chapter Audio Sources
  2017. @c man begin AUDIO SOURCES
  2018. Below is a description of the currently available audio sources.
  2019. @section abuffer
  2020. Buffer audio frames, and make them available to the filter chain.
  2021. This source is mainly intended for a programmatic use, in particular
  2022. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  2023. It accepts the following parameters:
  2024. @table @option
  2025. @item time_base
  2026. The timebase which will be used for timestamps of submitted frames. It must be
  2027. either a floating-point number or in @var{numerator}/@var{denominator} form.
  2028. @item sample_rate
  2029. The sample rate of the incoming audio buffers.
  2030. @item sample_fmt
  2031. The sample format of the incoming audio buffers.
  2032. Either a sample format name or its corresponding integer representation from
  2033. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  2034. @item channel_layout
  2035. The channel layout of the incoming audio buffers.
  2036. Either a channel layout name from channel_layout_map in
  2037. @file{libavutil/channel_layout.c} or its corresponding integer representation
  2038. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  2039. @item channels
  2040. The number of channels of the incoming audio buffers.
  2041. If both @var{channels} and @var{channel_layout} are specified, then they
  2042. must be consistent.
  2043. @end table
  2044. @subsection Examples
  2045. @example
  2046. abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
  2047. @end example
  2048. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  2049. Since the sample format with name "s16p" corresponds to the number
  2050. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  2051. equivalent to:
  2052. @example
  2053. abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
  2054. @end example
  2055. @section aevalsrc
  2056. Generate an audio signal specified by an expression.
  2057. This source accepts in input one or more expressions (one for each
  2058. channel), which are evaluated and used to generate a corresponding
  2059. audio signal.
  2060. This source accepts the following options:
  2061. @table @option
  2062. @item exprs
  2063. Set the '|'-separated expressions list for each separate channel. In case the
  2064. @option{channel_layout} option is not specified, the selected channel layout
  2065. depends on the number of provided expressions. Otherwise the last
  2066. specified expression is applied to the remaining output channels.
  2067. @item channel_layout, c
  2068. Set the channel layout. The number of channels in the specified layout
  2069. must be equal to the number of specified expressions.
  2070. @item duration, d
  2071. Set the minimum duration of the sourced audio. See
  2072. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  2073. for the accepted syntax.
  2074. Note that the resulting duration may be greater than the specified
  2075. duration, as the generated audio is always cut at the end of a
  2076. complete frame.
  2077. If not specified, or the expressed duration is negative, the audio is
  2078. supposed to be generated forever.
  2079. @item nb_samples, n
  2080. Set the number of samples per channel per each output frame,
  2081. default to 1024.
  2082. @item sample_rate, s
  2083. Specify the sample rate, default to 44100.
  2084. @end table
  2085. Each expression in @var{exprs} can contain the following constants:
  2086. @table @option
  2087. @item n
  2088. number of the evaluated sample, starting from 0
  2089. @item t
  2090. time of the evaluated sample expressed in seconds, starting from 0
  2091. @item s
  2092. sample rate
  2093. @end table
  2094. @subsection Examples
  2095. @itemize
  2096. @item
  2097. Generate silence:
  2098. @example
  2099. aevalsrc=0
  2100. @end example
  2101. @item
  2102. Generate a sin signal with frequency of 440 Hz, set sample rate to
  2103. 8000 Hz:
  2104. @example
  2105. aevalsrc="sin(440*2*PI*t):s=8000"
  2106. @end example
  2107. @item
  2108. Generate a two channels signal, specify the channel layout (Front
  2109. Center + Back Center) explicitly:
  2110. @example
  2111. aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
  2112. @end example
  2113. @item
  2114. Generate white noise:
  2115. @example
  2116. aevalsrc="-2+random(0)"
  2117. @end example
  2118. @item
  2119. Generate an amplitude modulated signal:
  2120. @example
  2121. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  2122. @end example
  2123. @item
  2124. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  2125. @example
  2126. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
  2127. @end example
  2128. @end itemize
  2129. @section anullsrc
  2130. The null audio source, return unprocessed audio frames. It is mainly useful
  2131. as a template and to be employed in analysis / debugging tools, or as
  2132. the source for filters which ignore the input data (for example the sox
  2133. synth filter).
  2134. This source accepts the following options:
  2135. @table @option
  2136. @item channel_layout, cl
  2137. Specifies the channel layout, and can be either an integer or a string
  2138. representing a channel layout. The default value of @var{channel_layout}
  2139. is "stereo".
  2140. Check the channel_layout_map definition in
  2141. @file{libavutil/channel_layout.c} for the mapping between strings and
  2142. channel layout values.
  2143. @item sample_rate, r
  2144. Specifies the sample rate, and defaults to 44100.
  2145. @item nb_samples, n
  2146. Set the number of samples per requested frames.
  2147. @end table
  2148. @subsection Examples
  2149. @itemize
  2150. @item
  2151. Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  2152. @example
  2153. anullsrc=r=48000:cl=4
  2154. @end example
  2155. @item
  2156. Do the same operation with a more obvious syntax:
  2157. @example
  2158. anullsrc=r=48000:cl=mono
  2159. @end example
  2160. @end itemize
  2161. All the parameters need to be explicitly defined.
  2162. @section flite
  2163. Synthesize a voice utterance using the libflite library.
  2164. To enable compilation of this filter you need to configure FFmpeg with
  2165. @code{--enable-libflite}.
  2166. Note that the flite library is not thread-safe.
  2167. The filter accepts the following options:
  2168. @table @option
  2169. @item list_voices
  2170. If set to 1, list the names of the available voices and exit
  2171. immediately. Default value is 0.
  2172. @item nb_samples, n
  2173. Set the maximum number of samples per frame. Default value is 512.
  2174. @item textfile
  2175. Set the filename containing the text to speak.
  2176. @item text
  2177. Set the text to speak.
  2178. @item voice, v
  2179. Set the voice to use for the speech synthesis. Default value is
  2180. @code{kal}. See also the @var{list_voices} option.
  2181. @end table
  2182. @subsection Examples
  2183. @itemize
  2184. @item
  2185. Read from file @file{speech.txt}, and synthesize the text using the
  2186. standard flite voice:
  2187. @example
  2188. flite=textfile=speech.txt
  2189. @end example
  2190. @item
  2191. Read the specified text selecting the @code{slt} voice:
  2192. @example
  2193. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2194. @end example
  2195. @item
  2196. Input text to ffmpeg:
  2197. @example
  2198. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2199. @end example
  2200. @item
  2201. Make @file{ffplay} speak the specified text, using @code{flite} and
  2202. the @code{lavfi} device:
  2203. @example
  2204. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  2205. @end example
  2206. @end itemize
  2207. For more information about libflite, check:
  2208. @url{http://www.speech.cs.cmu.edu/flite/}
  2209. @section sine
  2210. Generate an audio signal made of a sine wave with amplitude 1/8.
  2211. The audio signal is bit-exact.
  2212. The filter accepts the following options:
  2213. @table @option
  2214. @item frequency, f
  2215. Set the carrier frequency. Default is 440 Hz.
  2216. @item beep_factor, b
  2217. Enable a periodic beep every second with frequency @var{beep_factor} times
  2218. the carrier frequency. Default is 0, meaning the beep is disabled.
  2219. @item sample_rate, r
  2220. Specify the sample rate, default is 44100.
  2221. @item duration, d
  2222. Specify the duration of the generated audio stream.
  2223. @item samples_per_frame
  2224. Set the number of samples per output frame, default is 1024.
  2225. @end table
  2226. @subsection Examples
  2227. @itemize
  2228. @item
  2229. Generate a simple 440 Hz sine wave:
  2230. @example
  2231. sine
  2232. @end example
  2233. @item
  2234. Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
  2235. @example
  2236. sine=220:4:d=5
  2237. sine=f=220:b=4:d=5
  2238. sine=frequency=220:beep_factor=4:duration=5
  2239. @end example
  2240. @end itemize
  2241. @c man end AUDIO SOURCES
  2242. @chapter Audio Sinks
  2243. @c man begin AUDIO SINKS
  2244. Below is a description of the currently available audio sinks.
  2245. @section abuffersink
  2246. Buffer audio frames, and make them available to the end of filter chain.
  2247. This sink is mainly intended for programmatic use, in particular
  2248. through the interface defined in @file{libavfilter/buffersink.h}
  2249. or the options system.
  2250. It accepts a pointer to an AVABufferSinkContext structure, which
  2251. defines the incoming buffers' formats, to be passed as the opaque
  2252. parameter to @code{avfilter_init_filter} for initialization.
  2253. @section anullsink
  2254. Null audio sink; do absolutely nothing with the input audio. It is
  2255. mainly useful as a template and for use in analysis / debugging
  2256. tools.
  2257. @c man end AUDIO SINKS
  2258. @chapter Video Filters
  2259. @c man begin VIDEO FILTERS
  2260. When you configure your FFmpeg build, you can disable any of the
  2261. existing filters using @code{--disable-filters}.
  2262. The configure output will show the video filters included in your
  2263. build.
  2264. Below is a description of the currently available video filters.
  2265. @section alphaextract
  2266. Extract the alpha component from the input as a grayscale video. This
  2267. is especially useful with the @var{alphamerge} filter.
  2268. @section alphamerge
  2269. Add or replace the alpha component of the primary input with the
  2270. grayscale value of a second input. This is intended for use with
  2271. @var{alphaextract} to allow the transmission or storage of frame
  2272. sequences that have alpha in a format that doesn't support an alpha
  2273. channel.
  2274. For example, to reconstruct full frames from a normal YUV-encoded video
  2275. and a separate video created with @var{alphaextract}, you might use:
  2276. @example
  2277. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  2278. @end example
  2279. Since this filter is designed for reconstruction, it operates on frame
  2280. sequences without considering timestamps, and terminates when either
  2281. input reaches end of stream. This will cause problems if your encoding
  2282. pipeline drops frames. If you're trying to apply an image as an
  2283. overlay to a video stream, consider the @var{overlay} filter instead.
  2284. @section ass
  2285. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  2286. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  2287. Substation Alpha) subtitles files.
  2288. This filter accepts the following option in addition to the common options from
  2289. the @ref{subtitles} filter:
  2290. @table @option
  2291. @item shaping
  2292. Set the shaping engine
  2293. Available values are:
  2294. @table @samp
  2295. @item auto
  2296. The default libass shaping engine, which is the best available.
  2297. @item simple
  2298. Fast, font-agnostic shaper that can do only substitutions
  2299. @item complex
  2300. Slower shaper using OpenType for substitutions and positioning
  2301. @end table
  2302. The default is @code{auto}.
  2303. @end table
  2304. @section atadenoise
  2305. Apply an Adaptive Temporal Averaging Denoiser to the video input.
  2306. The filter accepts the following options:
  2307. @table @option
  2308. @item 0a
  2309. Set threshold A for 1st plane. Default is 0.02.
  2310. Valid range is 0 to 0.3.
  2311. @item 0b
  2312. Set threshold B for 1st plane. Default is 0.04.
  2313. Valid range is 0 to 5.
  2314. @item 1a
  2315. Set threshold A for 2nd plane. Default is 0.02.
  2316. Valid range is 0 to 0.3.
  2317. @item 1b
  2318. Set threshold B for 2nd plane. Default is 0.04.
  2319. Valid range is 0 to 5.
  2320. @item 2a
  2321. Set threshold A for 3rd plane. Default is 0.02.
  2322. Valid range is 0 to 0.3.
  2323. @item 2b
  2324. Set threshold B for 3rd plane. Default is 0.04.
  2325. Valid range is 0 to 5.
  2326. Threshold A is designed to react on abrupt changes in the input signal and
  2327. threshold B is designed to react on continuous changes in the input signal.
  2328. @item s
  2329. Set number of frames filter will use for averaging. Default is 33. Must be odd
  2330. number in range [5, 129].
  2331. @end table
  2332. @section bbox
  2333. Compute the bounding box for the non-black pixels in the input frame
  2334. luminance plane.
  2335. This filter computes the bounding box containing all the pixels with a
  2336. luminance value greater than the minimum allowed value.
  2337. The parameters describing the bounding box are printed on the filter
  2338. log.
  2339. The filter accepts the following option:
  2340. @table @option
  2341. @item min_val
  2342. Set the minimal luminance value. Default is @code{16}.
  2343. @end table
  2344. @section blackdetect
  2345. Detect video intervals that are (almost) completely black. Can be
  2346. useful to detect chapter transitions, commercials, or invalid
  2347. recordings. Output lines contains the time for the start, end and
  2348. duration of the detected black interval expressed in seconds.
  2349. In order to display the output lines, you need to set the loglevel at
  2350. least to the AV_LOG_INFO value.
  2351. The filter accepts the following options:
  2352. @table @option
  2353. @item black_min_duration, d
  2354. Set the minimum detected black duration expressed in seconds. It must
  2355. be a non-negative floating point number.
  2356. Default value is 2.0.
  2357. @item picture_black_ratio_th, pic_th
  2358. Set the threshold for considering a picture "black".
  2359. Express the minimum value for the ratio:
  2360. @example
  2361. @var{nb_black_pixels} / @var{nb_pixels}
  2362. @end example
  2363. for which a picture is considered black.
  2364. Default value is 0.98.
  2365. @item pixel_black_th, pix_th
  2366. Set the threshold for considering a pixel "black".
  2367. The threshold expresses the maximum pixel luminance value for which a
  2368. pixel is considered "black". The provided value is scaled according to
  2369. the following equation:
  2370. @example
  2371. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  2372. @end example
  2373. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  2374. the input video format, the range is [0-255] for YUV full-range
  2375. formats and [16-235] for YUV non full-range formats.
  2376. Default value is 0.10.
  2377. @end table
  2378. The following example sets the maximum pixel threshold to the minimum
  2379. value, and detects only black intervals of 2 or more seconds:
  2380. @example
  2381. blackdetect=d=2:pix_th=0.00
  2382. @end example
  2383. @section blackframe
  2384. Detect frames that are (almost) completely black. Can be useful to
  2385. detect chapter transitions or commercials. Output lines consist of
  2386. the frame number of the detected frame, the percentage of blackness,
  2387. the position in the file if known or -1 and the timestamp in seconds.
  2388. In order to display the output lines, you need to set the loglevel at
  2389. least to the AV_LOG_INFO value.
  2390. It accepts the following parameters:
  2391. @table @option
  2392. @item amount
  2393. The percentage of the pixels that have to be below the threshold; it defaults to
  2394. @code{98}.
  2395. @item threshold, thresh
  2396. The threshold below which a pixel value is considered black; it defaults to
  2397. @code{32}.
  2398. @end table
  2399. @section blend, tblend
  2400. Blend two video frames into each other.
  2401. The @code{blend} filter takes two input streams and outputs one
  2402. stream, the first input is the "top" layer and second input is
  2403. "bottom" layer. Output terminates when shortest input terminates.
  2404. The @code{tblend} (time blend) filter takes two consecutive frames
  2405. from one single stream, and outputs the result obtained by blending
  2406. the new frame on top of the old frame.
  2407. A description of the accepted options follows.
  2408. @table @option
  2409. @item c0_mode
  2410. @item c1_mode
  2411. @item c2_mode
  2412. @item c3_mode
  2413. @item all_mode
  2414. Set blend mode for specific pixel component or all pixel components in case
  2415. of @var{all_mode}. Default value is @code{normal}.
  2416. Available values for component modes are:
  2417. @table @samp
  2418. @item addition
  2419. @item and
  2420. @item average
  2421. @item burn
  2422. @item darken
  2423. @item difference
  2424. @item difference128
  2425. @item divide
  2426. @item dodge
  2427. @item exclusion
  2428. @item glow
  2429. @item hardlight
  2430. @item hardmix
  2431. @item lighten
  2432. @item linearlight
  2433. @item multiply
  2434. @item negation
  2435. @item normal
  2436. @item or
  2437. @item overlay
  2438. @item phoenix
  2439. @item pinlight
  2440. @item reflect
  2441. @item screen
  2442. @item softlight
  2443. @item subtract
  2444. @item vividlight
  2445. @item xor
  2446. @end table
  2447. @item c0_opacity
  2448. @item c1_opacity
  2449. @item c2_opacity
  2450. @item c3_opacity
  2451. @item all_opacity
  2452. Set blend opacity for specific pixel component or all pixel components in case
  2453. of @var{all_opacity}. Only used in combination with pixel component blend modes.
  2454. @item c0_expr
  2455. @item c1_expr
  2456. @item c2_expr
  2457. @item c3_expr
  2458. @item all_expr
  2459. Set blend expression for specific pixel component or all pixel components in case
  2460. of @var{all_expr}. Note that related mode options will be ignored if those are set.
  2461. The expressions can use the following variables:
  2462. @table @option
  2463. @item N
  2464. The sequential number of the filtered frame, starting from @code{0}.
  2465. @item X
  2466. @item Y
  2467. the coordinates of the current sample
  2468. @item W
  2469. @item H
  2470. the width and height of currently filtered plane
  2471. @item SW
  2472. @item SH
  2473. Width and height scale depending on the currently filtered plane. It is the
  2474. ratio between the corresponding luma plane number of pixels and the current
  2475. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  2476. @code{0.5,0.5} for chroma planes.
  2477. @item T
  2478. Time of the current frame, expressed in seconds.
  2479. @item TOP, A
  2480. Value of pixel component at current location for first video frame (top layer).
  2481. @item BOTTOM, B
  2482. Value of pixel component at current location for second video frame (bottom layer).
  2483. @end table
  2484. @item shortest
  2485. Force termination when the shortest input terminates. Default is
  2486. @code{0}. This option is only defined for the @code{blend} filter.
  2487. @item repeatlast
  2488. Continue applying the last bottom frame after the end of the stream. A value of
  2489. @code{0} disable the filter after the last frame of the bottom layer is reached.
  2490. Default is @code{1}. This option is only defined for the @code{blend} filter.
  2491. @end table
  2492. @subsection Examples
  2493. @itemize
  2494. @item
  2495. Apply transition from bottom layer to top layer in first 10 seconds:
  2496. @example
  2497. blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
  2498. @end example
  2499. @item
  2500. Apply 1x1 checkerboard effect:
  2501. @example
  2502. blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
  2503. @end example
  2504. @item
  2505. Apply uncover left effect:
  2506. @example
  2507. blend=all_expr='if(gte(N*SW+X,W),A,B)'
  2508. @end example
  2509. @item
  2510. Apply uncover down effect:
  2511. @example
  2512. blend=all_expr='if(gte(Y-N*SH,0),A,B)'
  2513. @end example
  2514. @item
  2515. Apply uncover up-left effect:
  2516. @example
  2517. blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
  2518. @end example
  2519. @item
  2520. Display differences between the current and the previous frame:
  2521. @example
  2522. tblend=all_mode=difference128
  2523. @end example
  2524. @end itemize
  2525. @section boxblur
  2526. Apply a boxblur algorithm to the input video.
  2527. It accepts the following parameters:
  2528. @table @option
  2529. @item luma_radius, lr
  2530. @item luma_power, lp
  2531. @item chroma_radius, cr
  2532. @item chroma_power, cp
  2533. @item alpha_radius, ar
  2534. @item alpha_power, ap
  2535. @end table
  2536. A description of the accepted options follows.
  2537. @table @option
  2538. @item luma_radius, lr
  2539. @item chroma_radius, cr
  2540. @item alpha_radius, ar
  2541. Set an expression for the box radius in pixels used for blurring the
  2542. corresponding input plane.
  2543. The radius value must be a non-negative number, and must not be
  2544. greater than the value of the expression @code{min(w,h)/2} for the
  2545. luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
  2546. planes.
  2547. Default value for @option{luma_radius} is "2". If not specified,
  2548. @option{chroma_radius} and @option{alpha_radius} default to the
  2549. corresponding value set for @option{luma_radius}.
  2550. The expressions can contain the following constants:
  2551. @table @option
  2552. @item w
  2553. @item h
  2554. The input width and height in pixels.
  2555. @item cw
  2556. @item ch
  2557. The input chroma image width and height in pixels.
  2558. @item hsub
  2559. @item vsub
  2560. The horizontal and vertical chroma subsample values. For example, for the
  2561. pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
  2562. @end table
  2563. @item luma_power, lp
  2564. @item chroma_power, cp
  2565. @item alpha_power, ap
  2566. Specify how many times the boxblur filter is applied to the
  2567. corresponding plane.
  2568. Default value for @option{luma_power} is 2. If not specified,
  2569. @option{chroma_power} and @option{alpha_power} default to the
  2570. corresponding value set for @option{luma_power}.
  2571. A value of 0 will disable the effect.
  2572. @end table
  2573. @subsection Examples
  2574. @itemize
  2575. @item
  2576. Apply a boxblur filter with the luma, chroma, and alpha radii
  2577. set to 2:
  2578. @example
  2579. boxblur=luma_radius=2:luma_power=1
  2580. boxblur=2:1
  2581. @end example
  2582. @item
  2583. Set the luma radius to 2, and alpha and chroma radius to 0:
  2584. @example
  2585. boxblur=2:1:cr=0:ar=0
  2586. @end example
  2587. @item
  2588. Set the luma and chroma radii to a fraction of the video dimension:
  2589. @example
  2590. boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
  2591. @end example
  2592. @end itemize
  2593. @section codecview
  2594. Visualize information exported by some codecs.
  2595. Some codecs can export information through frames using side-data or other
  2596. means. For example, some MPEG based codecs export motion vectors through the
  2597. @var{export_mvs} flag in the codec @option{flags2} option.
  2598. The filter accepts the following option:
  2599. @table @option
  2600. @item mv
  2601. Set motion vectors to visualize.
  2602. Available flags for @var{mv} are:
  2603. @table @samp
  2604. @item pf
  2605. forward predicted MVs of P-frames
  2606. @item bf
  2607. forward predicted MVs of B-frames
  2608. @item bb
  2609. backward predicted MVs of B-frames
  2610. @end table
  2611. @end table
  2612. @subsection Examples
  2613. @itemize
  2614. @item
  2615. Visualizes multi-directionals MVs from P and B-Frames using @command{ffplay}:
  2616. @example
  2617. ffplay -flags2 +export_mvs input.mpg -vf codecview=mv=pf+bf+bb
  2618. @end example
  2619. @end itemize
  2620. @section colorbalance
  2621. Modify intensity of primary colors (red, green and blue) of input frames.
  2622. The filter allows an input frame to be adjusted in the shadows, midtones or highlights
  2623. regions for the red-cyan, green-magenta or blue-yellow balance.
  2624. A positive adjustment value shifts the balance towards the primary color, a negative
  2625. value towards the complementary color.
  2626. The filter accepts the following options:
  2627. @table @option
  2628. @item rs
  2629. @item gs
  2630. @item bs
  2631. Adjust red, green and blue shadows (darkest pixels).
  2632. @item rm
  2633. @item gm
  2634. @item bm
  2635. Adjust red, green and blue midtones (medium pixels).
  2636. @item rh
  2637. @item gh
  2638. @item bh
  2639. Adjust red, green and blue highlights (brightest pixels).
  2640. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  2641. @end table
  2642. @subsection Examples
  2643. @itemize
  2644. @item
  2645. Add red color cast to shadows:
  2646. @example
  2647. colorbalance=rs=.3
  2648. @end example
  2649. @end itemize
  2650. @section colorkey
  2651. RGB colorspace color keying.
  2652. The filter accepts the following options:
  2653. @table @option
  2654. @item color
  2655. The color which will be replaced with transparency.
  2656. @item similarity
  2657. Similarity percentage with the key color.
  2658. 0.01 matches only the exact key color, while 1.0 matches everything.
  2659. @item blend
  2660. Blend percentage.
  2661. 0.0 makes pixels either fully transparent, or not transparent at all.
  2662. Higher values result in semi-transparent pixels, with a higher transparency
  2663. the more similar the pixels color is to the key color.
  2664. @end table
  2665. @subsection Examples
  2666. @itemize
  2667. @item
  2668. Make every green pixel in the input image transparent:
  2669. @example
  2670. ffmpeg -i input.png -vf colorkey=green out.png
  2671. @end example
  2672. @item
  2673. Overlay a greenscreen-video on top of a static background image.
  2674. @example
  2675. 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
  2676. @end example
  2677. @end itemize
  2678. @section colorlevels
  2679. Adjust video input frames using levels.
  2680. The filter accepts the following options:
  2681. @table @option
  2682. @item rimin
  2683. @item gimin
  2684. @item bimin
  2685. @item aimin
  2686. Adjust red, green, blue and alpha input black point.
  2687. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  2688. @item rimax
  2689. @item gimax
  2690. @item bimax
  2691. @item aimax
  2692. Adjust red, green, blue and alpha input white point.
  2693. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
  2694. Input levels are used to lighten highlights (bright tones), darken shadows
  2695. (dark tones), change the balance of bright and dark tones.
  2696. @item romin
  2697. @item gomin
  2698. @item bomin
  2699. @item aomin
  2700. Adjust red, green, blue and alpha output black point.
  2701. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
  2702. @item romax
  2703. @item gomax
  2704. @item bomax
  2705. @item aomax
  2706. Adjust red, green, blue and alpha output white point.
  2707. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
  2708. Output levels allows manual selection of a constrained output level range.
  2709. @end table
  2710. @subsection Examples
  2711. @itemize
  2712. @item
  2713. Make video output darker:
  2714. @example
  2715. colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
  2716. @end example
  2717. @item
  2718. Increase contrast:
  2719. @example
  2720. colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
  2721. @end example
  2722. @item
  2723. Make video output lighter:
  2724. @example
  2725. colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
  2726. @end example
  2727. @item
  2728. Increase brightness:
  2729. @example
  2730. colorlevels=romin=0.5:gomin=0.5:bomin=0.5
  2731. @end example
  2732. @end itemize
  2733. @section colorchannelmixer
  2734. Adjust video input frames by re-mixing color channels.
  2735. This filter modifies a color channel by adding the values associated to
  2736. the other channels of the same pixels. For example if the value to
  2737. modify is red, the output value will be:
  2738. @example
  2739. @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
  2740. @end example
  2741. The filter accepts the following options:
  2742. @table @option
  2743. @item rr
  2744. @item rg
  2745. @item rb
  2746. @item ra
  2747. Adjust contribution of input red, green, blue and alpha channels for output red channel.
  2748. Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
  2749. @item gr
  2750. @item gg
  2751. @item gb
  2752. @item ga
  2753. Adjust contribution of input red, green, blue and alpha channels for output green channel.
  2754. Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
  2755. @item br
  2756. @item bg
  2757. @item bb
  2758. @item ba
  2759. Adjust contribution of input red, green, blue and alpha channels for output blue channel.
  2760. Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
  2761. @item ar
  2762. @item ag
  2763. @item ab
  2764. @item aa
  2765. Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
  2766. Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
  2767. Allowed ranges for options are @code{[-2.0, 2.0]}.
  2768. @end table
  2769. @subsection Examples
  2770. @itemize
  2771. @item
  2772. Convert source to grayscale:
  2773. @example
  2774. colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
  2775. @end example
  2776. @item
  2777. Simulate sepia tones:
  2778. @example
  2779. colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
  2780. @end example
  2781. @end itemize
  2782. @section colormatrix
  2783. Convert color matrix.
  2784. The filter accepts the following options:
  2785. @table @option
  2786. @item src
  2787. @item dst
  2788. Specify the source and destination color matrix. Both values must be
  2789. specified.
  2790. The accepted values are:
  2791. @table @samp
  2792. @item bt709
  2793. BT.709
  2794. @item bt601
  2795. BT.601
  2796. @item smpte240m
  2797. SMPTE-240M
  2798. @item fcc
  2799. FCC
  2800. @end table
  2801. @end table
  2802. For example to convert from BT.601 to SMPTE-240M, use the command:
  2803. @example
  2804. colormatrix=bt601:smpte240m
  2805. @end example
  2806. @section copy
  2807. Copy the input source unchanged to the output. This is mainly useful for
  2808. testing purposes.
  2809. @section crop
  2810. Crop the input video to given dimensions.
  2811. It accepts the following parameters:
  2812. @table @option
  2813. @item w, out_w
  2814. The width of the output video. It defaults to @code{iw}.
  2815. This expression is evaluated only once during the filter
  2816. configuration, or when the @samp{w} or @samp{out_w} command is sent.
  2817. @item h, out_h
  2818. The height of the output video. It defaults to @code{ih}.
  2819. This expression is evaluated only once during the filter
  2820. configuration, or when the @samp{h} or @samp{out_h} command is sent.
  2821. @item x
  2822. The horizontal position, in the input video, of the left edge of the output
  2823. video. It defaults to @code{(in_w-out_w)/2}.
  2824. This expression is evaluated per-frame.
  2825. @item y
  2826. The vertical position, in the input video, of the top edge of the output video.
  2827. It defaults to @code{(in_h-out_h)/2}.
  2828. This expression is evaluated per-frame.
  2829. @item keep_aspect
  2830. If set to 1 will force the output display aspect ratio
  2831. to be the same of the input, by changing the output sample aspect
  2832. ratio. It defaults to 0.
  2833. @end table
  2834. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  2835. expressions containing the following constants:
  2836. @table @option
  2837. @item x
  2838. @item y
  2839. The computed values for @var{x} and @var{y}. They are evaluated for
  2840. each new frame.
  2841. @item in_w
  2842. @item in_h
  2843. The input width and height.
  2844. @item iw
  2845. @item ih
  2846. These are the same as @var{in_w} and @var{in_h}.
  2847. @item out_w
  2848. @item out_h
  2849. The output (cropped) width and height.
  2850. @item ow
  2851. @item oh
  2852. These are the same as @var{out_w} and @var{out_h}.
  2853. @item a
  2854. same as @var{iw} / @var{ih}
  2855. @item sar
  2856. input sample aspect ratio
  2857. @item dar
  2858. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2859. @item hsub
  2860. @item vsub
  2861. horizontal and vertical chroma subsample values. For example for the
  2862. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2863. @item n
  2864. The number of the input frame, starting from 0.
  2865. @item pos
  2866. the position in the file of the input frame, NAN if unknown
  2867. @item t
  2868. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  2869. @end table
  2870. The expression for @var{out_w} may depend on the value of @var{out_h},
  2871. and the expression for @var{out_h} may depend on @var{out_w}, but they
  2872. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  2873. evaluated after @var{out_w} and @var{out_h}.
  2874. The @var{x} and @var{y} parameters specify the expressions for the
  2875. position of the top-left corner of the output (non-cropped) area. They
  2876. are evaluated for each frame. If the evaluated value is not valid, it
  2877. is approximated to the nearest valid value.
  2878. The expression for @var{x} may depend on @var{y}, and the expression
  2879. for @var{y} may depend on @var{x}.
  2880. @subsection Examples
  2881. @itemize
  2882. @item
  2883. Crop area with size 100x100 at position (12,34).
  2884. @example
  2885. crop=100:100:12:34
  2886. @end example
  2887. Using named options, the example above becomes:
  2888. @example
  2889. crop=w=100:h=100:x=12:y=34
  2890. @end example
  2891. @item
  2892. Crop the central input area with size 100x100:
  2893. @example
  2894. crop=100:100
  2895. @end example
  2896. @item
  2897. Crop the central input area with size 2/3 of the input video:
  2898. @example
  2899. crop=2/3*in_w:2/3*in_h
  2900. @end example
  2901. @item
  2902. Crop the input video central square:
  2903. @example
  2904. crop=out_w=in_h
  2905. crop=in_h
  2906. @end example
  2907. @item
  2908. Delimit the rectangle with the top-left corner placed at position
  2909. 100:100 and the right-bottom corner corresponding to the right-bottom
  2910. corner of the input image.
  2911. @example
  2912. crop=in_w-100:in_h-100:100:100
  2913. @end example
  2914. @item
  2915. Crop 10 pixels from the left and right borders, and 20 pixels from
  2916. the top and bottom borders
  2917. @example
  2918. crop=in_w-2*10:in_h-2*20
  2919. @end example
  2920. @item
  2921. Keep only the bottom right quarter of the input image:
  2922. @example
  2923. crop=in_w/2:in_h/2:in_w/2:in_h/2
  2924. @end example
  2925. @item
  2926. Crop height for getting Greek harmony:
  2927. @example
  2928. crop=in_w:1/PHI*in_w
  2929. @end example
  2930. @item
  2931. Apply trembling effect:
  2932. @example
  2933. 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)
  2934. @end example
  2935. @item
  2936. Apply erratic camera effect depending on timestamp:
  2937. @example
  2938. 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)"
  2939. @end example
  2940. @item
  2941. Set x depending on the value of y:
  2942. @example
  2943. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  2944. @end example
  2945. @end itemize
  2946. @subsection Commands
  2947. This filter supports the following commands:
  2948. @table @option
  2949. @item w, out_w
  2950. @item h, out_h
  2951. @item x
  2952. @item y
  2953. Set width/height of the output video and the horizontal/vertical position
  2954. in the input video.
  2955. The command accepts the same syntax of the corresponding option.
  2956. If the specified expression is not valid, it is kept at its current
  2957. value.
  2958. @end table
  2959. @section cropdetect
  2960. Auto-detect the crop size.
  2961. It calculates the necessary cropping parameters and prints the
  2962. recommended parameters via the logging system. The detected dimensions
  2963. correspond to the non-black area of the input video.
  2964. It accepts the following parameters:
  2965. @table @option
  2966. @item limit
  2967. Set higher black value threshold, which can be optionally specified
  2968. from nothing (0) to everything (255 for 8bit based formats). An intensity
  2969. value greater to the set value is considered non-black. It defaults to 24.
  2970. You can also specify a value between 0.0 and 1.0 which will be scaled depending
  2971. on the bitdepth of the pixel format.
  2972. @item round
  2973. The value which the width/height should be divisible by. It defaults to
  2974. 16. The offset is automatically adjusted to center the video. Use 2 to
  2975. get only even dimensions (needed for 4:2:2 video). 16 is best when
  2976. encoding to most video codecs.
  2977. @item reset_count, reset
  2978. Set the counter that determines after how many frames cropdetect will
  2979. reset the previously detected largest video area and start over to
  2980. detect the current optimal crop area. Default value is 0.
  2981. This can be useful when channel logos distort the video area. 0
  2982. indicates 'never reset', and returns the largest area encountered during
  2983. playback.
  2984. @end table
  2985. @anchor{curves}
  2986. @section curves
  2987. Apply color adjustments using curves.
  2988. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  2989. component (red, green and blue) has its values defined by @var{N} key points
  2990. tied from each other using a smooth curve. The x-axis represents the pixel
  2991. values from the input frame, and the y-axis the new pixel values to be set for
  2992. the output frame.
  2993. By default, a component curve is defined by the two points @var{(0;0)} and
  2994. @var{(1;1)}. This creates a straight line where each original pixel value is
  2995. "adjusted" to its own value, which means no change to the image.
  2996. The filter allows you to redefine these two points and add some more. A new
  2997. curve (using a natural cubic spline interpolation) will be define to pass
  2998. smoothly through all these new coordinates. The new defined points needs to be
  2999. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  3000. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  3001. the vector spaces, the values will be clipped accordingly.
  3002. If there is no key point defined in @code{x=0}, the filter will automatically
  3003. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  3004. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  3005. The filter accepts the following options:
  3006. @table @option
  3007. @item preset
  3008. Select one of the available color presets. This option can be used in addition
  3009. to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
  3010. options takes priority on the preset values.
  3011. Available presets are:
  3012. @table @samp
  3013. @item none
  3014. @item color_negative
  3015. @item cross_process
  3016. @item darker
  3017. @item increase_contrast
  3018. @item lighter
  3019. @item linear_contrast
  3020. @item medium_contrast
  3021. @item negative
  3022. @item strong_contrast
  3023. @item vintage
  3024. @end table
  3025. Default is @code{none}.
  3026. @item master, m
  3027. Set the master key points. These points will define a second pass mapping. It
  3028. is sometimes called a "luminance" or "value" mapping. It can be used with
  3029. @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
  3030. post-processing LUT.
  3031. @item red, r
  3032. Set the key points for the red component.
  3033. @item green, g
  3034. Set the key points for the green component.
  3035. @item blue, b
  3036. Set the key points for the blue component.
  3037. @item all
  3038. Set the key points for all components (not including master).
  3039. Can be used in addition to the other key points component
  3040. options. In this case, the unset component(s) will fallback on this
  3041. @option{all} setting.
  3042. @item psfile
  3043. Specify a Photoshop curves file (@code{.asv}) to import the settings from.
  3044. @end table
  3045. To avoid some filtergraph syntax conflicts, each key points list need to be
  3046. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  3047. @subsection Examples
  3048. @itemize
  3049. @item
  3050. Increase slightly the middle level of blue:
  3051. @example
  3052. curves=blue='0.5/0.58'
  3053. @end example
  3054. @item
  3055. Vintage effect:
  3056. @example
  3057. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  3058. @end example
  3059. Here we obtain the following coordinates for each components:
  3060. @table @var
  3061. @item red
  3062. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  3063. @item green
  3064. @code{(0;0) (0.50;0.48) (1;1)}
  3065. @item blue
  3066. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  3067. @end table
  3068. @item
  3069. The previous example can also be achieved with the associated built-in preset:
  3070. @example
  3071. curves=preset=vintage
  3072. @end example
  3073. @item
  3074. Or simply:
  3075. @example
  3076. curves=vintage
  3077. @end example
  3078. @item
  3079. Use a Photoshop preset and redefine the points of the green component:
  3080. @example
  3081. curves=psfile='MyCurvesPresets/purple.asv':green='0.45/0.53'
  3082. @end example
  3083. @end itemize
  3084. @section dctdnoiz
  3085. Denoise frames using 2D DCT (frequency domain filtering).
  3086. This filter is not designed for real time.
  3087. The filter accepts the following options:
  3088. @table @option
  3089. @item sigma, s
  3090. Set the noise sigma constant.
  3091. This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
  3092. coefficient (absolute value) below this threshold with be dropped.
  3093. If you need a more advanced filtering, see @option{expr}.
  3094. Default is @code{0}.
  3095. @item overlap
  3096. Set number overlapping pixels for each block. Since the filter can be slow, you
  3097. may want to reduce this value, at the cost of a less effective filter and the
  3098. risk of various artefacts.
  3099. If the overlapping value doesn't permit processing the whole input width or
  3100. height, a warning will be displayed and according borders won't be denoised.
  3101. Default value is @var{blocksize}-1, which is the best possible setting.
  3102. @item expr, e
  3103. Set the coefficient factor expression.
  3104. For each coefficient of a DCT block, this expression will be evaluated as a
  3105. multiplier value for the coefficient.
  3106. If this is option is set, the @option{sigma} option will be ignored.
  3107. The absolute value of the coefficient can be accessed through the @var{c}
  3108. variable.
  3109. @item n
  3110. Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
  3111. @var{blocksize}, which is the width and height of the processed blocks.
  3112. The default value is @var{3} (8x8) and can be raised to @var{4} for a
  3113. @var{blocksize} of 16x16. Note that changing this setting has huge consequences
  3114. on the speed processing. Also, a larger block size does not necessarily means a
  3115. better de-noising.
  3116. @end table
  3117. @subsection Examples
  3118. Apply a denoise with a @option{sigma} of @code{4.5}:
  3119. @example
  3120. dctdnoiz=4.5
  3121. @end example
  3122. The same operation can be achieved using the expression system:
  3123. @example
  3124. dctdnoiz=e='gte(c, 4.5*3)'
  3125. @end example
  3126. Violent denoise using a block size of @code{16x16}:
  3127. @example
  3128. dctdnoiz=15:n=4
  3129. @end example
  3130. @section deband
  3131. Remove banding artifacts from input video.
  3132. It works by replacing banded pixels with average value of referenced pixels.
  3133. The filter accepts the following options:
  3134. @table @option
  3135. @item 1thr
  3136. @item 2thr
  3137. @item 3thr
  3138. @item 4thr
  3139. Set banding detection threshold for each plane. Default is 0.02.
  3140. Valid range is 0.00003 to 0.5.
  3141. If difference between current pixel and reference pixel is less than threshold,
  3142. it will be considered as banded.
  3143. @item range, r
  3144. Banding detection range in pixels. Default is 16. If positive, random number
  3145. in range 0 to set value will be used. If negative, exact absolute value
  3146. will be used.
  3147. The range defines square of four pixels around current pixel.
  3148. @item direction, d
  3149. Set direction in radians from which four pixel will be compared. If positive,
  3150. random direction from 0 to set direction will be picked. If negative, exact of
  3151. absolute value will be picked. For example direction 0, -PI or -2*PI radians
  3152. will pick only pixels on same row and -PI/2 will pick only pixels on same
  3153. column.
  3154. @item blur
  3155. If enabled, current pixel is compared with average value of all four
  3156. surrounding pixels. The default is enabled. If disabled current pixel is
  3157. compared with all four surrounding pixels. The pixel is considered banded
  3158. if only all four differences with surrounding pixels are less than threshold.
  3159. @end table
  3160. @anchor{decimate}
  3161. @section decimate
  3162. Drop duplicated frames at regular intervals.
  3163. The filter accepts the following options:
  3164. @table @option
  3165. @item cycle
  3166. Set the number of frames from which one will be dropped. Setting this to
  3167. @var{N} means one frame in every batch of @var{N} frames will be dropped.
  3168. Default is @code{5}.
  3169. @item dupthresh
  3170. Set the threshold for duplicate detection. If the difference metric for a frame
  3171. is less than or equal to this value, then it is declared as duplicate. Default
  3172. is @code{1.1}
  3173. @item scthresh
  3174. Set scene change threshold. Default is @code{15}.
  3175. @item blockx
  3176. @item blocky
  3177. Set the size of the x and y-axis blocks used during metric calculations.
  3178. Larger blocks give better noise suppression, but also give worse detection of
  3179. small movements. Must be a power of two. Default is @code{32}.
  3180. @item ppsrc
  3181. Mark main input as a pre-processed input and activate clean source input
  3182. stream. This allows the input to be pre-processed with various filters to help
  3183. the metrics calculation while keeping the frame selection lossless. When set to
  3184. @code{1}, the first stream is for the pre-processed input, and the second
  3185. stream is the clean source from where the kept frames are chosen. Default is
  3186. @code{0}.
  3187. @item chroma
  3188. Set whether or not chroma is considered in the metric calculations. Default is
  3189. @code{1}.
  3190. @end table
  3191. @section deflate
  3192. Apply deflate effect to the video.
  3193. This filter replaces the pixel by the local(3x3) average by taking into account
  3194. only values lower than the pixel.
  3195. It accepts the following options:
  3196. @table @option
  3197. @item threshold0
  3198. @item threshold1
  3199. @item threshold2
  3200. @item threshold3
  3201. Allows to limit the maximum change for each plane, default is 65535.
  3202. If 0, plane will remain unchanged.
  3203. @end table
  3204. @section dejudder
  3205. Remove judder produced by partially interlaced telecined content.
  3206. Judder can be introduced, for instance, by @ref{pullup} filter. If the original
  3207. source was partially telecined content then the output of @code{pullup,dejudder}
  3208. will have a variable frame rate. May change the recorded frame rate of the
  3209. container. Aside from that change, this filter will not affect constant frame
  3210. rate video.
  3211. The option available in this filter is:
  3212. @table @option
  3213. @item cycle
  3214. Specify the length of the window over which the judder repeats.
  3215. Accepts any integer greater than 1. Useful values are:
  3216. @table @samp
  3217. @item 4
  3218. If the original was telecined from 24 to 30 fps (Film to NTSC).
  3219. @item 5
  3220. If the original was telecined from 25 to 30 fps (PAL to NTSC).
  3221. @item 20
  3222. If a mixture of the two.
  3223. @end table
  3224. The default is @samp{4}.
  3225. @end table
  3226. @section delogo
  3227. Suppress a TV station logo by a simple interpolation of the surrounding
  3228. pixels. Just set a rectangle covering the logo and watch it disappear
  3229. (and sometimes something even uglier appear - your mileage may vary).
  3230. It accepts the following parameters:
  3231. @table @option
  3232. @item x
  3233. @item y
  3234. Specify the top left corner coordinates of the logo. They must be
  3235. specified.
  3236. @item w
  3237. @item h
  3238. Specify the width and height of the logo to clear. They must be
  3239. specified.
  3240. @item band, t
  3241. Specify the thickness of the fuzzy edge of the rectangle (added to
  3242. @var{w} and @var{h}). The default value is 4.
  3243. @item show
  3244. When set to 1, a green rectangle is drawn on the screen to simplify
  3245. finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
  3246. The default value is 0.
  3247. The rectangle is drawn on the outermost pixels which will be (partly)
  3248. replaced with interpolated values. The values of the next pixels
  3249. immediately outside this rectangle in each direction will be used to
  3250. compute the interpolated pixel values inside the rectangle.
  3251. @end table
  3252. @subsection Examples
  3253. @itemize
  3254. @item
  3255. Set a rectangle covering the area with top left corner coordinates 0,0
  3256. and size 100x77, and a band of size 10:
  3257. @example
  3258. delogo=x=0:y=0:w=100:h=77:band=10
  3259. @end example
  3260. @end itemize
  3261. @section deshake
  3262. Attempt to fix small changes in horizontal and/or vertical shift. This
  3263. filter helps remove camera shake from hand-holding a camera, bumping a
  3264. tripod, moving on a vehicle, etc.
  3265. The filter accepts the following options:
  3266. @table @option
  3267. @item x
  3268. @item y
  3269. @item w
  3270. @item h
  3271. Specify a rectangular area where to limit the search for motion
  3272. vectors.
  3273. If desired the search for motion vectors can be limited to a
  3274. rectangular area of the frame defined by its top left corner, width
  3275. and height. These parameters have the same meaning as the drawbox
  3276. filter which can be used to visualise the position of the bounding
  3277. box.
  3278. This is useful when simultaneous movement of subjects within the frame
  3279. might be confused for camera motion by the motion vector search.
  3280. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  3281. then the full frame is used. This allows later options to be set
  3282. without specifying the bounding box for the motion vector search.
  3283. Default - search the whole frame.
  3284. @item rx
  3285. @item ry
  3286. Specify the maximum extent of movement in x and y directions in the
  3287. range 0-64 pixels. Default 16.
  3288. @item edge
  3289. Specify how to generate pixels to fill blanks at the edge of the
  3290. frame. Available values are:
  3291. @table @samp
  3292. @item blank, 0
  3293. Fill zeroes at blank locations
  3294. @item original, 1
  3295. Original image at blank locations
  3296. @item clamp, 2
  3297. Extruded edge value at blank locations
  3298. @item mirror, 3
  3299. Mirrored edge at blank locations
  3300. @end table
  3301. Default value is @samp{mirror}.
  3302. @item blocksize
  3303. Specify the blocksize to use for motion search. Range 4-128 pixels,
  3304. default 8.
  3305. @item contrast
  3306. Specify the contrast threshold for blocks. Only blocks with more than
  3307. the specified contrast (difference between darkest and lightest
  3308. pixels) will be considered. Range 1-255, default 125.
  3309. @item search
  3310. Specify the search strategy. Available values are:
  3311. @table @samp
  3312. @item exhaustive, 0
  3313. Set exhaustive search
  3314. @item less, 1
  3315. Set less exhaustive search.
  3316. @end table
  3317. Default value is @samp{exhaustive}.
  3318. @item filename
  3319. If set then a detailed log of the motion search is written to the
  3320. specified file.
  3321. @item opencl
  3322. If set to 1, specify using OpenCL capabilities, only available if
  3323. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  3324. @end table
  3325. @section detelecine
  3326. Apply an exact inverse of the telecine operation. It requires a predefined
  3327. pattern specified using the pattern option which must be the same as that passed
  3328. to the telecine filter.
  3329. This filter accepts the following options:
  3330. @table @option
  3331. @item first_field
  3332. @table @samp
  3333. @item top, t
  3334. top field first
  3335. @item bottom, b
  3336. bottom field first
  3337. The default value is @code{top}.
  3338. @end table
  3339. @item pattern
  3340. A string of numbers representing the pulldown pattern you wish to apply.
  3341. The default value is @code{23}.
  3342. @item start_frame
  3343. A number representing position of the first frame with respect to the telecine
  3344. pattern. This is to be used if the stream is cut. The default value is @code{0}.
  3345. @end table
  3346. @section dilation
  3347. Apply dilation effect to the video.
  3348. This filter replaces the pixel by the local(3x3) maximum.
  3349. It accepts the following options:
  3350. @table @option
  3351. @item threshold0
  3352. @item threshold1
  3353. @item threshold2
  3354. @item threshold3
  3355. Allows to limit the maximum change for each plane, default is 65535.
  3356. If 0, plane will remain unchanged.
  3357. @item coordinates
  3358. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  3359. pixels are used.
  3360. Flags to local 3x3 coordinates maps like this:
  3361. 1 2 3
  3362. 4 5
  3363. 6 7 8
  3364. @end table
  3365. @section drawbox
  3366. Draw a colored box on the input image.
  3367. It accepts the following parameters:
  3368. @table @option
  3369. @item x
  3370. @item y
  3371. The expressions which specify the top left corner coordinates of the box. It defaults to 0.
  3372. @item width, w
  3373. @item height, h
  3374. The expressions which specify the width and height of the box; if 0 they are interpreted as
  3375. the input width and height. It defaults to 0.
  3376. @item color, c
  3377. Specify the color of the box to write. For the general syntax of this option,
  3378. check the "Color" section in the ffmpeg-utils manual. If the special
  3379. value @code{invert} is used, the box edge color is the same as the
  3380. video with inverted luma.
  3381. @item thickness, t
  3382. The expression which sets the thickness of the box edge. Default value is @code{3}.
  3383. See below for the list of accepted constants.
  3384. @end table
  3385. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  3386. following constants:
  3387. @table @option
  3388. @item dar
  3389. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  3390. @item hsub
  3391. @item vsub
  3392. horizontal and vertical chroma subsample values. For example for the
  3393. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3394. @item in_h, ih
  3395. @item in_w, iw
  3396. The input width and height.
  3397. @item sar
  3398. The input sample aspect ratio.
  3399. @item x
  3400. @item y
  3401. The x and y offset coordinates where the box is drawn.
  3402. @item w
  3403. @item h
  3404. The width and height of the drawn box.
  3405. @item t
  3406. The thickness of the drawn box.
  3407. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  3408. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  3409. @end table
  3410. @subsection Examples
  3411. @itemize
  3412. @item
  3413. Draw a black box around the edge of the input image:
  3414. @example
  3415. drawbox
  3416. @end example
  3417. @item
  3418. Draw a box with color red and an opacity of 50%:
  3419. @example
  3420. drawbox=10:20:200:60:red@@0.5
  3421. @end example
  3422. The previous example can be specified as:
  3423. @example
  3424. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  3425. @end example
  3426. @item
  3427. Fill the box with pink color:
  3428. @example
  3429. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  3430. @end example
  3431. @item
  3432. Draw a 2-pixel red 2.40:1 mask:
  3433. @example
  3434. 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
  3435. @end example
  3436. @end itemize
  3437. @section drawgraph, adrawgraph
  3438. Draw a graph using input video or audio metadata.
  3439. It accepts the following parameters:
  3440. @table @option
  3441. @item m1
  3442. Set 1st frame metadata key from which metadata values will be used to draw a graph.
  3443. @item fg1
  3444. Set 1st foreground color expression.
  3445. @item m2
  3446. Set 2nd frame metadata key from which metadata values will be used to draw a graph.
  3447. @item fg2
  3448. Set 2nd foreground color expression.
  3449. @item m3
  3450. Set 3rd frame metadata key from which metadata values will be used to draw a graph.
  3451. @item fg3
  3452. Set 3rd foreground color expression.
  3453. @item m4
  3454. Set 4th frame metadata key from which metadata values will be used to draw a graph.
  3455. @item fg4
  3456. Set 4th foreground color expression.
  3457. @item min
  3458. Set minimal value of metadata value.
  3459. @item max
  3460. Set maximal value of metadata value.
  3461. @item bg
  3462. Set graph background color. Default is white.
  3463. @item mode
  3464. Set graph mode.
  3465. Available values for mode is:
  3466. @table @samp
  3467. @item bar
  3468. @item dot
  3469. @item line
  3470. @end table
  3471. Default is @code{line}.
  3472. @item slide
  3473. Set slide mode.
  3474. Available values for slide is:
  3475. @table @samp
  3476. @item frame
  3477. Draw new frame when right border is reached.
  3478. @item replace
  3479. Replace old columns with new ones.
  3480. @item scroll
  3481. Scroll from right to left.
  3482. @end table
  3483. Default is @code{frame}.
  3484. @item size
  3485. Set size of graph video. For the syntax of this option, check the
  3486. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  3487. The default value is @code{900x256}.
  3488. The foreground color expressions can use the following variables:
  3489. @table @option
  3490. @item MIN
  3491. Minimal value of metadata value.
  3492. @item MAX
  3493. Maximal value of metadata value.
  3494. @item VAL
  3495. Current metadata key value.
  3496. @end table
  3497. The color is defined as 0xAABBGGRR.
  3498. @end table
  3499. Example using metadata from @ref{signalstats} filter:
  3500. @example
  3501. signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255
  3502. @end example
  3503. Example using metadata from @ref{ebur128} filter:
  3504. @example
  3505. ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5
  3506. @end example
  3507. @section drawgrid
  3508. Draw a grid on the input image.
  3509. It accepts the following parameters:
  3510. @table @option
  3511. @item x
  3512. @item y
  3513. The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
  3514. @item width, w
  3515. @item height, h
  3516. The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
  3517. input width and height, respectively, minus @code{thickness}, so image gets
  3518. framed. Default to 0.
  3519. @item color, c
  3520. Specify the color of the grid. For the general syntax of this option,
  3521. check the "Color" section in the ffmpeg-utils manual. If the special
  3522. value @code{invert} is used, the grid color is the same as the
  3523. video with inverted luma.
  3524. @item thickness, t
  3525. The expression which sets the thickness of the grid line. Default value is @code{1}.
  3526. See below for the list of accepted constants.
  3527. @end table
  3528. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  3529. following constants:
  3530. @table @option
  3531. @item dar
  3532. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  3533. @item hsub
  3534. @item vsub
  3535. horizontal and vertical chroma subsample values. For example for the
  3536. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3537. @item in_h, ih
  3538. @item in_w, iw
  3539. The input grid cell width and height.
  3540. @item sar
  3541. The input sample aspect ratio.
  3542. @item x
  3543. @item y
  3544. The x and y coordinates of some point of grid intersection (meant to configure offset).
  3545. @item w
  3546. @item h
  3547. The width and height of the drawn cell.
  3548. @item t
  3549. The thickness of the drawn cell.
  3550. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  3551. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  3552. @end table
  3553. @subsection Examples
  3554. @itemize
  3555. @item
  3556. Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
  3557. @example
  3558. drawgrid=width=100:height=100:thickness=2:color=red@@0.5
  3559. @end example
  3560. @item
  3561. Draw a white 3x3 grid with an opacity of 50%:
  3562. @example
  3563. drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
  3564. @end example
  3565. @end itemize
  3566. @anchor{drawtext}
  3567. @section drawtext
  3568. Draw a text string or text from a specified file on top of a video, using the
  3569. libfreetype library.
  3570. To enable compilation of this filter, you need to configure FFmpeg with
  3571. @code{--enable-libfreetype}.
  3572. To enable default font fallback and the @var{font} option you need to
  3573. configure FFmpeg with @code{--enable-libfontconfig}.
  3574. To enable the @var{text_shaping} option, you need to configure FFmpeg with
  3575. @code{--enable-libfribidi}.
  3576. @subsection Syntax
  3577. It accepts the following parameters:
  3578. @table @option
  3579. @item box
  3580. Used to draw a box around text using the background color.
  3581. The value must be either 1 (enable) or 0 (disable).
  3582. The default value of @var{box} is 0.
  3583. @item boxborderw
  3584. Set the width of the border to be drawn around the box using @var{boxcolor}.
  3585. The default value of @var{boxborderw} is 0.
  3586. @item boxcolor
  3587. The color to be used for drawing box around text. For the syntax of this
  3588. option, check the "Color" section in the ffmpeg-utils manual.
  3589. The default value of @var{boxcolor} is "white".
  3590. @item borderw
  3591. Set the width of the border to be drawn around the text using @var{bordercolor}.
  3592. The default value of @var{borderw} is 0.
  3593. @item bordercolor
  3594. Set the color to be used for drawing border around text. For the syntax of this
  3595. option, check the "Color" section in the ffmpeg-utils manual.
  3596. The default value of @var{bordercolor} is "black".
  3597. @item expansion
  3598. Select how the @var{text} is expanded. Can be either @code{none},
  3599. @code{strftime} (deprecated) or
  3600. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  3601. below for details.
  3602. @item fix_bounds
  3603. If true, check and fix text coords to avoid clipping.
  3604. @item fontcolor
  3605. The color to be used for drawing fonts. For the syntax of this option, check
  3606. the "Color" section in the ffmpeg-utils manual.
  3607. The default value of @var{fontcolor} is "black".
  3608. @item fontcolor_expr
  3609. String which is expanded the same way as @var{text} to obtain dynamic
  3610. @var{fontcolor} value. By default this option has empty value and is not
  3611. processed. When this option is set, it overrides @var{fontcolor} option.
  3612. @item font
  3613. The font family to be used for drawing text. By default Sans.
  3614. @item fontfile
  3615. The font file to be used for drawing text. The path must be included.
  3616. This parameter is mandatory if the fontconfig support is disabled.
  3617. @item draw
  3618. This option does not exist, please see the timeline system
  3619. @item alpha
  3620. Draw the text applying alpha blending. The value can
  3621. be either a number between 0.0 and 1.0
  3622. The expression accepts the same variables @var{x, y} do.
  3623. The default value is 1.
  3624. Please see fontcolor_expr
  3625. @item fontsize
  3626. The font size to be used for drawing text.
  3627. The default value of @var{fontsize} is 16.
  3628. @item text_shaping
  3629. If set to 1, attempt to shape the text (for example, reverse the order of
  3630. right-to-left text and join Arabic characters) before drawing it.
  3631. Otherwise, just draw the text exactly as given.
  3632. By default 1 (if supported).
  3633. @item ft_load_flags
  3634. The flags to be used for loading the fonts.
  3635. The flags map the corresponding flags supported by libfreetype, and are
  3636. a combination of the following values:
  3637. @table @var
  3638. @item default
  3639. @item no_scale
  3640. @item no_hinting
  3641. @item render
  3642. @item no_bitmap
  3643. @item vertical_layout
  3644. @item force_autohint
  3645. @item crop_bitmap
  3646. @item pedantic
  3647. @item ignore_global_advance_width
  3648. @item no_recurse
  3649. @item ignore_transform
  3650. @item monochrome
  3651. @item linear_design
  3652. @item no_autohint
  3653. @end table
  3654. Default value is "default".
  3655. For more information consult the documentation for the FT_LOAD_*
  3656. libfreetype flags.
  3657. @item shadowcolor
  3658. The color to be used for drawing a shadow behind the drawn text. For the
  3659. syntax of this option, check the "Color" section in the ffmpeg-utils manual.
  3660. The default value of @var{shadowcolor} is "black".
  3661. @item shadowx
  3662. @item shadowy
  3663. The x and y offsets for the text shadow position with respect to the
  3664. position of the text. They can be either positive or negative
  3665. values. The default value for both is "0".
  3666. @item start_number
  3667. The starting frame number for the n/frame_num variable. The default value
  3668. is "0".
  3669. @item tabsize
  3670. The size in number of spaces to use for rendering the tab.
  3671. Default value is 4.
  3672. @item timecode
  3673. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  3674. format. It can be used with or without text parameter. @var{timecode_rate}
  3675. option must be specified.
  3676. @item timecode_rate, rate, r
  3677. Set the timecode frame rate (timecode only).
  3678. @item text
  3679. The text string to be drawn. The text must be a sequence of UTF-8
  3680. encoded characters.
  3681. This parameter is mandatory if no file is specified with the parameter
  3682. @var{textfile}.
  3683. @item textfile
  3684. A text file containing text to be drawn. The text must be a sequence
  3685. of UTF-8 encoded characters.
  3686. This parameter is mandatory if no text string is specified with the
  3687. parameter @var{text}.
  3688. If both @var{text} and @var{textfile} are specified, an error is thrown.
  3689. @item reload
  3690. If set to 1, the @var{textfile} will be reloaded before each frame.
  3691. Be sure to update it atomically, or it may be read partially, or even fail.
  3692. @item x
  3693. @item y
  3694. The expressions which specify the offsets where text will be drawn
  3695. within the video frame. They are relative to the top/left border of the
  3696. output image.
  3697. The default value of @var{x} and @var{y} is "0".
  3698. See below for the list of accepted constants and functions.
  3699. @end table
  3700. The parameters for @var{x} and @var{y} are expressions containing the
  3701. following constants and functions:
  3702. @table @option
  3703. @item dar
  3704. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  3705. @item hsub
  3706. @item vsub
  3707. horizontal and vertical chroma subsample values. For example for the
  3708. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3709. @item line_h, lh
  3710. the height of each text line
  3711. @item main_h, h, H
  3712. the input height
  3713. @item main_w, w, W
  3714. the input width
  3715. @item max_glyph_a, ascent
  3716. the maximum distance from the baseline to the highest/upper grid
  3717. coordinate used to place a glyph outline point, for all the rendered
  3718. glyphs.
  3719. It is a positive value, due to the grid's orientation with the Y axis
  3720. upwards.
  3721. @item max_glyph_d, descent
  3722. the maximum distance from the baseline to the lowest grid coordinate
  3723. used to place a glyph outline point, for all the rendered glyphs.
  3724. This is a negative value, due to the grid's orientation, with the Y axis
  3725. upwards.
  3726. @item max_glyph_h
  3727. maximum glyph height, that is the maximum height for all the glyphs
  3728. contained in the rendered text, it is equivalent to @var{ascent} -
  3729. @var{descent}.
  3730. @item max_glyph_w
  3731. maximum glyph width, that is the maximum width for all the glyphs
  3732. contained in the rendered text
  3733. @item n
  3734. the number of input frame, starting from 0
  3735. @item rand(min, max)
  3736. return a random number included between @var{min} and @var{max}
  3737. @item sar
  3738. The input sample aspect ratio.
  3739. @item t
  3740. timestamp expressed in seconds, NAN if the input timestamp is unknown
  3741. @item text_h, th
  3742. the height of the rendered text
  3743. @item text_w, tw
  3744. the width of the rendered text
  3745. @item x
  3746. @item y
  3747. the x and y offset coordinates where the text is drawn.
  3748. These parameters allow the @var{x} and @var{y} expressions to refer
  3749. each other, so you can for example specify @code{y=x/dar}.
  3750. @end table
  3751. @anchor{drawtext_expansion}
  3752. @subsection Text expansion
  3753. If @option{expansion} is set to @code{strftime},
  3754. the filter recognizes strftime() sequences in the provided text and
  3755. expands them accordingly. Check the documentation of strftime(). This
  3756. feature is deprecated.
  3757. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  3758. If @option{expansion} is set to @code{normal} (which is the default),
  3759. the following expansion mechanism is used.
  3760. The backslash character @samp{\}, followed by any character, always expands to
  3761. the second character.
  3762. Sequence of the form @code{%@{...@}} are expanded. The text between the
  3763. braces is a function name, possibly followed by arguments separated by ':'.
  3764. If the arguments contain special characters or delimiters (':' or '@}'),
  3765. they should be escaped.
  3766. Note that they probably must also be escaped as the value for the
  3767. @option{text} option in the filter argument string and as the filter
  3768. argument in the filtergraph description, and possibly also for the shell,
  3769. that makes up to four levels of escaping; using a text file avoids these
  3770. problems.
  3771. The following functions are available:
  3772. @table @command
  3773. @item expr, e
  3774. The expression evaluation result.
  3775. It must take one argument specifying the expression to be evaluated,
  3776. which accepts the same constants and functions as the @var{x} and
  3777. @var{y} values. Note that not all constants should be used, for
  3778. example the text size is not known when evaluating the expression, so
  3779. the constants @var{text_w} and @var{text_h} will have an undefined
  3780. value.
  3781. @item expr_int_format, eif
  3782. Evaluate the expression's value and output as formatted integer.
  3783. The first argument is the expression to be evaluated, just as for the @var{expr} function.
  3784. The second argument specifies the output format. Allowed values are @samp{x},
  3785. @samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
  3786. @code{printf} function.
  3787. The third parameter is optional and sets the number of positions taken by the output.
  3788. It can be used to add padding with zeros from the left.
  3789. @item gmtime
  3790. The time at which the filter is running, expressed in UTC.
  3791. It can accept an argument: a strftime() format string.
  3792. @item localtime
  3793. The time at which the filter is running, expressed in the local time zone.
  3794. It can accept an argument: a strftime() format string.
  3795. @item metadata
  3796. Frame metadata. It must take one argument specifying metadata key.
  3797. @item n, frame_num
  3798. The frame number, starting from 0.
  3799. @item pict_type
  3800. A 1 character description of the current picture type.
  3801. @item pts
  3802. The timestamp of the current frame.
  3803. It can take up to two arguments.
  3804. The first argument is the format of the timestamp; it defaults to @code{flt}
  3805. for seconds as a decimal number with microsecond accuracy; @code{hms} stands
  3806. for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
  3807. The second argument is an offset added to the timestamp.
  3808. @end table
  3809. @subsection Examples
  3810. @itemize
  3811. @item
  3812. Draw "Test Text" with font FreeSerif, using the default values for the
  3813. optional parameters.
  3814. @example
  3815. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  3816. @end example
  3817. @item
  3818. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  3819. and y=50 (counting from the top-left corner of the screen), text is
  3820. yellow with a red box around it. Both the text and the box have an
  3821. opacity of 20%.
  3822. @example
  3823. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  3824. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  3825. @end example
  3826. Note that the double quotes are not necessary if spaces are not used
  3827. within the parameter list.
  3828. @item
  3829. Show the text at the center of the video frame:
  3830. @example
  3831. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  3832. @end example
  3833. @item
  3834. Show a text line sliding from right to left in the last row of the video
  3835. frame. The file @file{LONG_LINE} is assumed to contain a single line
  3836. with no newlines.
  3837. @example
  3838. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  3839. @end example
  3840. @item
  3841. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  3842. @example
  3843. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  3844. @end example
  3845. @item
  3846. Draw a single green letter "g", at the center of the input video.
  3847. The glyph baseline is placed at half screen height.
  3848. @example
  3849. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  3850. @end example
  3851. @item
  3852. Show text for 1 second every 3 seconds:
  3853. @example
  3854. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  3855. @end example
  3856. @item
  3857. Use fontconfig to set the font. Note that the colons need to be escaped.
  3858. @example
  3859. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  3860. @end example
  3861. @item
  3862. Print the date of a real-time encoding (see strftime(3)):
  3863. @example
  3864. drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
  3865. @end example
  3866. @item
  3867. Show text fading in and out (appearing/disappearing):
  3868. @example
  3869. #!/bin/sh
  3870. DS=1.0 # display start
  3871. DE=10.0 # display end
  3872. FID=1.5 # fade in duration
  3873. FOD=5 # fade out duration
  3874. 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 @}"
  3875. @end example
  3876. @end itemize
  3877. For more information about libfreetype, check:
  3878. @url{http://www.freetype.org/}.
  3879. For more information about fontconfig, check:
  3880. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  3881. For more information about libfribidi, check:
  3882. @url{http://fribidi.org/}.
  3883. @section edgedetect
  3884. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  3885. The filter accepts the following options:
  3886. @table @option
  3887. @item low
  3888. @item high
  3889. Set low and high threshold values used by the Canny thresholding
  3890. algorithm.
  3891. The high threshold selects the "strong" edge pixels, which are then
  3892. connected through 8-connectivity with the "weak" edge pixels selected
  3893. by the low threshold.
  3894. @var{low} and @var{high} threshold values must be chosen in the range
  3895. [0,1], and @var{low} should be lesser or equal to @var{high}.
  3896. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  3897. is @code{50/255}.
  3898. @item mode
  3899. Define the drawing mode.
  3900. @table @samp
  3901. @item wires
  3902. Draw white/gray wires on black background.
  3903. @item colormix
  3904. Mix the colors to create a paint/cartoon effect.
  3905. @end table
  3906. Default value is @var{wires}.
  3907. @end table
  3908. @subsection Examples
  3909. @itemize
  3910. @item
  3911. Standard edge detection with custom values for the hysteresis thresholding:
  3912. @example
  3913. edgedetect=low=0.1:high=0.4
  3914. @end example
  3915. @item
  3916. Painting effect without thresholding:
  3917. @example
  3918. edgedetect=mode=colormix:high=0
  3919. @end example
  3920. @end itemize
  3921. @section eq
  3922. Set brightness, contrast, saturation and approximate gamma adjustment.
  3923. The filter accepts the following options:
  3924. @table @option
  3925. @item contrast
  3926. Set the contrast expression. The value must be a float value in range
  3927. @code{-2.0} to @code{2.0}. The default value is "0".
  3928. @item brightness
  3929. Set the brightness expression. The value must be a float value in
  3930. range @code{-1.0} to @code{1.0}. The default value is "0".
  3931. @item saturation
  3932. Set the saturation expression. The value must be a float in
  3933. range @code{0.0} to @code{3.0}. The default value is "1".
  3934. @item gamma
  3935. Set the gamma expression. The value must be a float in range
  3936. @code{0.1} to @code{10.0}. The default value is "1".
  3937. @item gamma_r
  3938. Set the gamma expression for red. The value must be a float in
  3939. range @code{0.1} to @code{10.0}. The default value is "1".
  3940. @item gamma_g
  3941. Set the gamma expression for green. The value must be a float in range
  3942. @code{0.1} to @code{10.0}. The default value is "1".
  3943. @item gamma_b
  3944. Set the gamma expression for blue. The value must be a float in range
  3945. @code{0.1} to @code{10.0}. The default value is "1".
  3946. @item gamma_weight
  3947. Set the gamma weight expression. It can be used to reduce the effect
  3948. of a high gamma value on bright image areas, e.g. keep them from
  3949. getting overamplified and just plain white. The value must be a float
  3950. in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
  3951. gamma correction all the way down while @code{1.0} leaves it at its
  3952. full strength. Default is "1".
  3953. @item eval
  3954. Set when the expressions for brightness, contrast, saturation and
  3955. gamma expressions are evaluated.
  3956. It accepts the following values:
  3957. @table @samp
  3958. @item init
  3959. only evaluate expressions once during the filter initialization or
  3960. when a command is processed
  3961. @item frame
  3962. evaluate expressions for each incoming frame
  3963. @end table
  3964. Default value is @samp{init}.
  3965. @end table
  3966. The expressions accept the following parameters:
  3967. @table @option
  3968. @item n
  3969. frame count of the input frame starting from 0
  3970. @item pos
  3971. byte position of the corresponding packet in the input file, NAN if
  3972. unspecified
  3973. @item r
  3974. frame rate of the input video, NAN if the input frame rate is unknown
  3975. @item t
  3976. timestamp expressed in seconds, NAN if the input timestamp is unknown
  3977. @end table
  3978. @subsection Commands
  3979. The filter supports the following commands:
  3980. @table @option
  3981. @item contrast
  3982. Set the contrast expression.
  3983. @item brightness
  3984. Set the brightness expression.
  3985. @item saturation
  3986. Set the saturation expression.
  3987. @item gamma
  3988. Set the gamma expression.
  3989. @item gamma_r
  3990. Set the gamma_r expression.
  3991. @item gamma_g
  3992. Set gamma_g expression.
  3993. @item gamma_b
  3994. Set gamma_b expression.
  3995. @item gamma_weight
  3996. Set gamma_weight expression.
  3997. The command accepts the same syntax of the corresponding option.
  3998. If the specified expression is not valid, it is kept at its current
  3999. value.
  4000. @end table
  4001. @section erosion
  4002. Apply erosion effect to the video.
  4003. This filter replaces the pixel by the local(3x3) minimum.
  4004. It accepts the following options:
  4005. @table @option
  4006. @item threshold0
  4007. @item threshold1
  4008. @item threshold2
  4009. @item threshold3
  4010. Allows to limit the maximum change for each plane, default is 65535.
  4011. If 0, plane will remain unchanged.
  4012. @item coordinates
  4013. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  4014. pixels are used.
  4015. Flags to local 3x3 coordinates maps like this:
  4016. 1 2 3
  4017. 4 5
  4018. 6 7 8
  4019. @end table
  4020. @section extractplanes
  4021. Extract color channel components from input video stream into
  4022. separate grayscale video streams.
  4023. The filter accepts the following option:
  4024. @table @option
  4025. @item planes
  4026. Set plane(s) to extract.
  4027. Available values for planes are:
  4028. @table @samp
  4029. @item y
  4030. @item u
  4031. @item v
  4032. @item a
  4033. @item r
  4034. @item g
  4035. @item b
  4036. @end table
  4037. Choosing planes not available in the input will result in an error.
  4038. That means you cannot select @code{r}, @code{g}, @code{b} planes
  4039. with @code{y}, @code{u}, @code{v} planes at same time.
  4040. @end table
  4041. @subsection Examples
  4042. @itemize
  4043. @item
  4044. Extract luma, u and v color channel component from input video frame
  4045. into 3 grayscale outputs:
  4046. @example
  4047. 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
  4048. @end example
  4049. @end itemize
  4050. @section elbg
  4051. Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
  4052. For each input image, the filter will compute the optimal mapping from
  4053. the input to the output given the codebook length, that is the number
  4054. of distinct output colors.
  4055. This filter accepts the following options.
  4056. @table @option
  4057. @item codebook_length, l
  4058. Set codebook length. The value must be a positive integer, and
  4059. represents the number of distinct output colors. Default value is 256.
  4060. @item nb_steps, n
  4061. Set the maximum number of iterations to apply for computing the optimal
  4062. mapping. The higher the value the better the result and the higher the
  4063. computation time. Default value is 1.
  4064. @item seed, s
  4065. Set a random seed, must be an integer included between 0 and
  4066. UINT32_MAX. If not specified, or if explicitly set to -1, the filter
  4067. will try to use a good random seed on a best effort basis.
  4068. @end table
  4069. @section fade
  4070. Apply a fade-in/out effect to the input video.
  4071. It accepts the following parameters:
  4072. @table @option
  4073. @item type, t
  4074. The effect type can be either "in" for a fade-in, or "out" for a fade-out
  4075. effect.
  4076. Default is @code{in}.
  4077. @item start_frame, s
  4078. Specify the number of the frame to start applying the fade
  4079. effect at. Default is 0.
  4080. @item nb_frames, n
  4081. The number of frames that the fade effect lasts. At the end of the
  4082. fade-in effect, the output video will have the same intensity as the input video.
  4083. At the end of the fade-out transition, the output video will be filled with the
  4084. selected @option{color}.
  4085. Default is 25.
  4086. @item alpha
  4087. If set to 1, fade only alpha channel, if one exists on the input.
  4088. Default value is 0.
  4089. @item start_time, st
  4090. Specify the timestamp (in seconds) of the frame to start to apply the fade
  4091. effect. If both start_frame and start_time are specified, the fade will start at
  4092. whichever comes last. Default is 0.
  4093. @item duration, d
  4094. The number of seconds for which the fade effect has to last. At the end of the
  4095. fade-in effect the output video will have the same intensity as the input video,
  4096. at the end of the fade-out transition the output video will be filled with the
  4097. selected @option{color}.
  4098. If both duration and nb_frames are specified, duration is used. Default is 0
  4099. (nb_frames is used by default).
  4100. @item color, c
  4101. Specify the color of the fade. Default is "black".
  4102. @end table
  4103. @subsection Examples
  4104. @itemize
  4105. @item
  4106. Fade in the first 30 frames of video:
  4107. @example
  4108. fade=in:0:30
  4109. @end example
  4110. The command above is equivalent to:
  4111. @example
  4112. fade=t=in:s=0:n=30
  4113. @end example
  4114. @item
  4115. Fade out the last 45 frames of a 200-frame video:
  4116. @example
  4117. fade=out:155:45
  4118. fade=type=out:start_frame=155:nb_frames=45
  4119. @end example
  4120. @item
  4121. Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
  4122. @example
  4123. fade=in:0:25, fade=out:975:25
  4124. @end example
  4125. @item
  4126. Make the first 5 frames yellow, then fade in from frame 5-24:
  4127. @example
  4128. fade=in:5:20:color=yellow
  4129. @end example
  4130. @item
  4131. Fade in alpha over first 25 frames of video:
  4132. @example
  4133. fade=in:0:25:alpha=1
  4134. @end example
  4135. @item
  4136. Make the first 5.5 seconds black, then fade in for 0.5 seconds:
  4137. @example
  4138. fade=t=in:st=5.5:d=0.5
  4139. @end example
  4140. @end itemize
  4141. @section fftfilt
  4142. Apply arbitrary expressions to samples in frequency domain
  4143. @table @option
  4144. @item dc_Y
  4145. Adjust the dc value (gain) of the luma plane of the image. The filter
  4146. accepts an integer value in range @code{0} to @code{1000}. The default
  4147. value is set to @code{0}.
  4148. @item dc_U
  4149. Adjust the dc value (gain) of the 1st chroma plane of the image. The
  4150. filter accepts an integer value in range @code{0} to @code{1000}. The
  4151. default value is set to @code{0}.
  4152. @item dc_V
  4153. Adjust the dc value (gain) of the 2nd chroma plane of the image. The
  4154. filter accepts an integer value in range @code{0} to @code{1000}. The
  4155. default value is set to @code{0}.
  4156. @item weight_Y
  4157. Set the frequency domain weight expression for the luma plane.
  4158. @item weight_U
  4159. Set the frequency domain weight expression for the 1st chroma plane.
  4160. @item weight_V
  4161. Set the frequency domain weight expression for the 2nd chroma plane.
  4162. The filter accepts the following variables:
  4163. @item X
  4164. @item Y
  4165. The coordinates of the current sample.
  4166. @item W
  4167. @item H
  4168. The width and height of the image.
  4169. @end table
  4170. @subsection Examples
  4171. @itemize
  4172. @item
  4173. High-pass:
  4174. @example
  4175. fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
  4176. @end example
  4177. @item
  4178. Low-pass:
  4179. @example
  4180. fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
  4181. @end example
  4182. @item
  4183. Sharpen:
  4184. @example
  4185. fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
  4186. @end example
  4187. @end itemize
  4188. @section field
  4189. Extract a single field from an interlaced image using stride
  4190. arithmetic to avoid wasting CPU time. The output frames are marked as
  4191. non-interlaced.
  4192. The filter accepts the following options:
  4193. @table @option
  4194. @item type
  4195. Specify whether to extract the top (if the value is @code{0} or
  4196. @code{top}) or the bottom field (if the value is @code{1} or
  4197. @code{bottom}).
  4198. @end table
  4199. @section fieldmatch
  4200. Field matching filter for inverse telecine. It is meant to reconstruct the
  4201. progressive frames from a telecined stream. The filter does not drop duplicated
  4202. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  4203. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  4204. The separation of the field matching and the decimation is notably motivated by
  4205. the possibility of inserting a de-interlacing filter fallback between the two.
  4206. If the source has mixed telecined and real interlaced content,
  4207. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  4208. But these remaining combed frames will be marked as interlaced, and thus can be
  4209. de-interlaced by a later filter such as @ref{yadif} before decimation.
  4210. In addition to the various configuration options, @code{fieldmatch} can take an
  4211. optional second stream, activated through the @option{ppsrc} option. If
  4212. enabled, the frames reconstruction will be based on the fields and frames from
  4213. this second stream. This allows the first input to be pre-processed in order to
  4214. help the various algorithms of the filter, while keeping the output lossless
  4215. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  4216. or brightness/contrast adjustments can help.
  4217. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  4218. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  4219. which @code{fieldmatch} is based on. While the semantic and usage are very
  4220. close, some behaviour and options names can differ.
  4221. The @ref{decimate} filter currently only works for constant frame rate input.
  4222. Do not use @code{fieldmatch} and @ref{decimate} if your input has mixed
  4223. telecined and progressive content with changing framerate.
  4224. The filter accepts the following options:
  4225. @table @option
  4226. @item order
  4227. Specify the assumed field order of the input stream. Available values are:
  4228. @table @samp
  4229. @item auto
  4230. Auto detect parity (use FFmpeg's internal parity value).
  4231. @item bff
  4232. Assume bottom field first.
  4233. @item tff
  4234. Assume top field first.
  4235. @end table
  4236. Note that it is sometimes recommended not to trust the parity announced by the
  4237. stream.
  4238. Default value is @var{auto}.
  4239. @item mode
  4240. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  4241. sense that it won't risk creating jerkiness due to duplicate frames when
  4242. possible, but if there are bad edits or blended fields it will end up
  4243. outputting combed frames when a good match might actually exist. On the other
  4244. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  4245. but will almost always find a good frame if there is one. The other values are
  4246. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  4247. jerkiness and creating duplicate frames versus finding good matches in sections
  4248. with bad edits, orphaned fields, blended fields, etc.
  4249. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  4250. Available values are:
  4251. @table @samp
  4252. @item pc
  4253. 2-way matching (p/c)
  4254. @item pc_n
  4255. 2-way matching, and trying 3rd match if still combed (p/c + n)
  4256. @item pc_u
  4257. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  4258. @item pc_n_ub
  4259. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  4260. still combed (p/c + n + u/b)
  4261. @item pcn
  4262. 3-way matching (p/c/n)
  4263. @item pcn_ub
  4264. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  4265. detected as combed (p/c/n + u/b)
  4266. @end table
  4267. The parenthesis at the end indicate the matches that would be used for that
  4268. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  4269. @var{top}).
  4270. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  4271. the slowest.
  4272. Default value is @var{pc_n}.
  4273. @item ppsrc
  4274. Mark the main input stream as a pre-processed input, and enable the secondary
  4275. input stream as the clean source to pick the fields from. See the filter
  4276. introduction for more details. It is similar to the @option{clip2} feature from
  4277. VFM/TFM.
  4278. Default value is @code{0} (disabled).
  4279. @item field
  4280. Set the field to match from. It is recommended to set this to the same value as
  4281. @option{order} unless you experience matching failures with that setting. In
  4282. certain circumstances changing the field that is used to match from can have a
  4283. large impact on matching performance. Available values are:
  4284. @table @samp
  4285. @item auto
  4286. Automatic (same value as @option{order}).
  4287. @item bottom
  4288. Match from the bottom field.
  4289. @item top
  4290. Match from the top field.
  4291. @end table
  4292. Default value is @var{auto}.
  4293. @item mchroma
  4294. Set whether or not chroma is included during the match comparisons. In most
  4295. cases it is recommended to leave this enabled. You should set this to @code{0}
  4296. only if your clip has bad chroma problems such as heavy rainbowing or other
  4297. artifacts. Setting this to @code{0} could also be used to speed things up at
  4298. the cost of some accuracy.
  4299. Default value is @code{1}.
  4300. @item y0
  4301. @item y1
  4302. These define an exclusion band which excludes the lines between @option{y0} and
  4303. @option{y1} from being included in the field matching decision. An exclusion
  4304. band can be used to ignore subtitles, a logo, or other things that may
  4305. interfere with the matching. @option{y0} sets the starting scan line and
  4306. @option{y1} sets the ending line; all lines in between @option{y0} and
  4307. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  4308. @option{y0} and @option{y1} to the same value will disable the feature.
  4309. @option{y0} and @option{y1} defaults to @code{0}.
  4310. @item scthresh
  4311. Set the scene change detection threshold as a percentage of maximum change on
  4312. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  4313. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  4314. @option{scthresh} is @code{[0.0, 100.0]}.
  4315. Default value is @code{12.0}.
  4316. @item combmatch
  4317. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  4318. account the combed scores of matches when deciding what match to use as the
  4319. final match. Available values are:
  4320. @table @samp
  4321. @item none
  4322. No final matching based on combed scores.
  4323. @item sc
  4324. Combed scores are only used when a scene change is detected.
  4325. @item full
  4326. Use combed scores all the time.
  4327. @end table
  4328. Default is @var{sc}.
  4329. @item combdbg
  4330. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  4331. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  4332. Available values are:
  4333. @table @samp
  4334. @item none
  4335. No forced calculation.
  4336. @item pcn
  4337. Force p/c/n calculations.
  4338. @item pcnub
  4339. Force p/c/n/u/b calculations.
  4340. @end table
  4341. Default value is @var{none}.
  4342. @item cthresh
  4343. This is the area combing threshold used for combed frame detection. This
  4344. essentially controls how "strong" or "visible" combing must be to be detected.
  4345. Larger values mean combing must be more visible and smaller values mean combing
  4346. can be less visible or strong and still be detected. Valid settings are from
  4347. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  4348. be detected as combed). This is basically a pixel difference value. A good
  4349. range is @code{[8, 12]}.
  4350. Default value is @code{9}.
  4351. @item chroma
  4352. Sets whether or not chroma is considered in the combed frame decision. Only
  4353. disable this if your source has chroma problems (rainbowing, etc.) that are
  4354. causing problems for the combed frame detection with chroma enabled. Actually,
  4355. using @option{chroma}=@var{0} is usually more reliable, except for the case
  4356. where there is chroma only combing in the source.
  4357. Default value is @code{0}.
  4358. @item blockx
  4359. @item blocky
  4360. Respectively set the x-axis and y-axis size of the window used during combed
  4361. frame detection. This has to do with the size of the area in which
  4362. @option{combpel} pixels are required to be detected as combed for a frame to be
  4363. declared combed. See the @option{combpel} parameter description for more info.
  4364. Possible values are any number that is a power of 2 starting at 4 and going up
  4365. to 512.
  4366. Default value is @code{16}.
  4367. @item combpel
  4368. The number of combed pixels inside any of the @option{blocky} by
  4369. @option{blockx} size blocks on the frame for the frame to be detected as
  4370. combed. While @option{cthresh} controls how "visible" the combing must be, this
  4371. setting controls "how much" combing there must be in any localized area (a
  4372. window defined by the @option{blockx} and @option{blocky} settings) on the
  4373. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  4374. which point no frames will ever be detected as combed). This setting is known
  4375. as @option{MI} in TFM/VFM vocabulary.
  4376. Default value is @code{80}.
  4377. @end table
  4378. @anchor{p/c/n/u/b meaning}
  4379. @subsection p/c/n/u/b meaning
  4380. @subsubsection p/c/n
  4381. We assume the following telecined stream:
  4382. @example
  4383. Top fields: 1 2 2 3 4
  4384. Bottom fields: 1 2 3 4 4
  4385. @end example
  4386. The numbers correspond to the progressive frame the fields relate to. Here, the
  4387. first two frames are progressive, the 3rd and 4th are combed, and so on.
  4388. When @code{fieldmatch} is configured to run a matching from bottom
  4389. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  4390. @example
  4391. Input stream:
  4392. T 1 2 2 3 4
  4393. B 1 2 3 4 4 <-- matching reference
  4394. Matches: c c n n c
  4395. Output stream:
  4396. T 1 2 3 4 4
  4397. B 1 2 3 4 4
  4398. @end example
  4399. As a result of the field matching, we can see that some frames get duplicated.
  4400. To perform a complete inverse telecine, you need to rely on a decimation filter
  4401. after this operation. See for instance the @ref{decimate} filter.
  4402. The same operation now matching from top fields (@option{field}=@var{top})
  4403. looks like this:
  4404. @example
  4405. Input stream:
  4406. T 1 2 2 3 4 <-- matching reference
  4407. B 1 2 3 4 4
  4408. Matches: c c p p c
  4409. Output stream:
  4410. T 1 2 2 3 4
  4411. B 1 2 2 3 4
  4412. @end example
  4413. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  4414. basically, they refer to the frame and field of the opposite parity:
  4415. @itemize
  4416. @item @var{p} matches the field of the opposite parity in the previous frame
  4417. @item @var{c} matches the field of the opposite parity in the current frame
  4418. @item @var{n} matches the field of the opposite parity in the next frame
  4419. @end itemize
  4420. @subsubsection u/b
  4421. The @var{u} and @var{b} matching are a bit special in the sense that they match
  4422. from the opposite parity flag. In the following examples, we assume that we are
  4423. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  4424. 'x' is placed above and below each matched fields.
  4425. With bottom matching (@option{field}=@var{bottom}):
  4426. @example
  4427. Match: c p n b u
  4428. x x x x x
  4429. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  4430. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  4431. x x x x x
  4432. Output frames:
  4433. 2 1 2 2 2
  4434. 2 2 2 1 3
  4435. @end example
  4436. With top matching (@option{field}=@var{top}):
  4437. @example
  4438. Match: c p n b u
  4439. x x x x x
  4440. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  4441. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  4442. x x x x x
  4443. Output frames:
  4444. 2 2 2 1 2
  4445. 2 1 3 2 2
  4446. @end example
  4447. @subsection Examples
  4448. Simple IVTC of a top field first telecined stream:
  4449. @example
  4450. fieldmatch=order=tff:combmatch=none, decimate
  4451. @end example
  4452. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  4453. @example
  4454. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  4455. @end example
  4456. @section fieldorder
  4457. Transform the field order of the input video.
  4458. It accepts the following parameters:
  4459. @table @option
  4460. @item order
  4461. The output field order. Valid values are @var{tff} for top field first or @var{bff}
  4462. for bottom field first.
  4463. @end table
  4464. The default value is @samp{tff}.
  4465. The transformation is done by shifting the picture content up or down
  4466. by one line, and filling the remaining line with appropriate picture content.
  4467. This method is consistent with most broadcast field order converters.
  4468. If the input video is not flagged as being interlaced, or it is already
  4469. flagged as being of the required output field order, then this filter does
  4470. not alter the incoming video.
  4471. It is very useful when converting to or from PAL DV material,
  4472. which is bottom field first.
  4473. For example:
  4474. @example
  4475. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  4476. @end example
  4477. @section fifo
  4478. Buffer input images and send them when they are requested.
  4479. It is mainly useful when auto-inserted by the libavfilter
  4480. framework.
  4481. It does not take parameters.
  4482. @section find_rect
  4483. Find a rectangular object
  4484. It accepts the following options:
  4485. @table @option
  4486. @item object
  4487. Filepath of the object image, needs to be in gray8.
  4488. @item threshold
  4489. Detection threshold, default is 0.5.
  4490. @item mipmaps
  4491. Number of mipmaps, default is 3.
  4492. @item xmin, ymin, xmax, ymax
  4493. Specifies the rectangle in which to search.
  4494. @end table
  4495. @subsection Examples
  4496. @itemize
  4497. @item
  4498. Generate a representative palette of a given video using @command{ffmpeg}:
  4499. @example
  4500. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  4501. @end example
  4502. @end itemize
  4503. @section cover_rect
  4504. Cover a rectangular object
  4505. It accepts the following options:
  4506. @table @option
  4507. @item cover
  4508. Filepath of the optional cover image, needs to be in yuv420.
  4509. @item mode
  4510. Set covering mode.
  4511. It accepts the following values:
  4512. @table @samp
  4513. @item cover
  4514. cover it by the supplied image
  4515. @item blur
  4516. cover it by interpolating the surrounding pixels
  4517. @end table
  4518. Default value is @var{blur}.
  4519. @end table
  4520. @subsection Examples
  4521. @itemize
  4522. @item
  4523. Generate a representative palette of a given video using @command{ffmpeg}:
  4524. @example
  4525. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  4526. @end example
  4527. @end itemize
  4528. @anchor{format}
  4529. @section format
  4530. Convert the input video to one of the specified pixel formats.
  4531. Libavfilter will try to pick one that is suitable as input to
  4532. the next filter.
  4533. It accepts the following parameters:
  4534. @table @option
  4535. @item pix_fmts
  4536. A '|'-separated list of pixel format names, such as
  4537. "pix_fmts=yuv420p|monow|rgb24".
  4538. @end table
  4539. @subsection Examples
  4540. @itemize
  4541. @item
  4542. Convert the input video to the @var{yuv420p} format
  4543. @example
  4544. format=pix_fmts=yuv420p
  4545. @end example
  4546. Convert the input video to any of the formats in the list
  4547. @example
  4548. format=pix_fmts=yuv420p|yuv444p|yuv410p
  4549. @end example
  4550. @end itemize
  4551. @anchor{fps}
  4552. @section fps
  4553. Convert the video to specified constant frame rate by duplicating or dropping
  4554. frames as necessary.
  4555. It accepts the following parameters:
  4556. @table @option
  4557. @item fps
  4558. The desired output frame rate. The default is @code{25}.
  4559. @item round
  4560. Rounding method.
  4561. Possible values are:
  4562. @table @option
  4563. @item zero
  4564. zero round towards 0
  4565. @item inf
  4566. round away from 0
  4567. @item down
  4568. round towards -infinity
  4569. @item up
  4570. round towards +infinity
  4571. @item near
  4572. round to nearest
  4573. @end table
  4574. The default is @code{near}.
  4575. @item start_time
  4576. Assume the first PTS should be the given value, in seconds. This allows for
  4577. padding/trimming at the start of stream. By default, no assumption is made
  4578. about the first frame's expected PTS, so no padding or trimming is done.
  4579. For example, this could be set to 0 to pad the beginning with duplicates of
  4580. the first frame if a video stream starts after the audio stream or to trim any
  4581. frames with a negative PTS.
  4582. @end table
  4583. Alternatively, the options can be specified as a flat string:
  4584. @var{fps}[:@var{round}].
  4585. See also the @ref{setpts} filter.
  4586. @subsection Examples
  4587. @itemize
  4588. @item
  4589. A typical usage in order to set the fps to 25:
  4590. @example
  4591. fps=fps=25
  4592. @end example
  4593. @item
  4594. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  4595. @example
  4596. fps=fps=film:round=near
  4597. @end example
  4598. @end itemize
  4599. @section framepack
  4600. Pack two different video streams into a stereoscopic video, setting proper
  4601. metadata on supported codecs. The two views should have the same size and
  4602. framerate and processing will stop when the shorter video ends. Please note
  4603. that you may conveniently adjust view properties with the @ref{scale} and
  4604. @ref{fps} filters.
  4605. It accepts the following parameters:
  4606. @table @option
  4607. @item format
  4608. The desired packing format. Supported values are:
  4609. @table @option
  4610. @item sbs
  4611. The views are next to each other (default).
  4612. @item tab
  4613. The views are on top of each other.
  4614. @item lines
  4615. The views are packed by line.
  4616. @item columns
  4617. The views are packed by column.
  4618. @item frameseq
  4619. The views are temporally interleaved.
  4620. @end table
  4621. @end table
  4622. Some examples:
  4623. @example
  4624. # Convert left and right views into a frame-sequential video
  4625. ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
  4626. # Convert views into a side-by-side video with the same output resolution as the input
  4627. 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
  4628. @end example
  4629. @section framestep
  4630. Select one frame every N-th frame.
  4631. This filter accepts the following option:
  4632. @table @option
  4633. @item step
  4634. Select frame after every @code{step} frames.
  4635. Allowed values are positive integers higher than 0. Default value is @code{1}.
  4636. @end table
  4637. @anchor{frei0r}
  4638. @section frei0r
  4639. Apply a frei0r effect to the input video.
  4640. To enable the compilation of this filter, you need to install the frei0r
  4641. header and configure FFmpeg with @code{--enable-frei0r}.
  4642. It accepts the following parameters:
  4643. @table @option
  4644. @item filter_name
  4645. The name of the frei0r effect to load. If the environment variable
  4646. @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
  4647. directories specified by the colon-separated list in @env{FREIOR_PATH}.
  4648. Otherwise, the standard frei0r paths are searched, in this order:
  4649. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  4650. @file{/usr/lib/frei0r-1/}.
  4651. @item filter_params
  4652. A '|'-separated list of parameters to pass to the frei0r effect.
  4653. @end table
  4654. A frei0r effect parameter can be a boolean (its value is either
  4655. "y" or "n"), a double, a color (specified as
  4656. @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
  4657. numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
  4658. section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
  4659. @var{X} and @var{Y} are floating point numbers) and/or a string.
  4660. The number and types of parameters depend on the loaded effect. If an
  4661. effect parameter is not specified, the default value is set.
  4662. @subsection Examples
  4663. @itemize
  4664. @item
  4665. Apply the distort0r effect, setting the first two double parameters:
  4666. @example
  4667. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  4668. @end example
  4669. @item
  4670. Apply the colordistance effect, taking a color as the first parameter:
  4671. @example
  4672. frei0r=colordistance:0.2/0.3/0.4
  4673. frei0r=colordistance:violet
  4674. frei0r=colordistance:0x112233
  4675. @end example
  4676. @item
  4677. Apply the perspective effect, specifying the top left and top right image
  4678. positions:
  4679. @example
  4680. frei0r=perspective:0.2/0.2|0.8/0.2
  4681. @end example
  4682. @end itemize
  4683. For more information, see
  4684. @url{http://frei0r.dyne.org}
  4685. @section fspp
  4686. Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
  4687. It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
  4688. processing filter, one of them is performed once per block, not per pixel.
  4689. This allows for much higher speed.
  4690. The filter accepts the following options:
  4691. @table @option
  4692. @item quality
  4693. Set quality. This option defines the number of levels for averaging. It accepts
  4694. an integer in the range 4-5. Default value is @code{4}.
  4695. @item qp
  4696. Force a constant quantization parameter. It accepts an integer in range 0-63.
  4697. If not set, the filter will use the QP from the video stream (if available).
  4698. @item strength
  4699. Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
  4700. more details but also more artifacts, while higher values make the image smoother
  4701. but also blurrier. Default value is @code{0} − PSNR optimal.
  4702. @item use_bframe_qp
  4703. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  4704. option may cause flicker since the B-Frames have often larger QP. Default is
  4705. @code{0} (not enabled).
  4706. @end table
  4707. @section geq
  4708. The filter accepts the following options:
  4709. @table @option
  4710. @item lum_expr, lum
  4711. Set the luminance expression.
  4712. @item cb_expr, cb
  4713. Set the chrominance blue expression.
  4714. @item cr_expr, cr
  4715. Set the chrominance red expression.
  4716. @item alpha_expr, a
  4717. Set the alpha expression.
  4718. @item red_expr, r
  4719. Set the red expression.
  4720. @item green_expr, g
  4721. Set the green expression.
  4722. @item blue_expr, b
  4723. Set the blue expression.
  4724. @end table
  4725. The colorspace is selected according to the specified options. If one
  4726. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  4727. options is specified, the filter will automatically select a YCbCr
  4728. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  4729. @option{blue_expr} options is specified, it will select an RGB
  4730. colorspace.
  4731. If one of the chrominance expression is not defined, it falls back on the other
  4732. one. If no alpha expression is specified it will evaluate to opaque value.
  4733. If none of chrominance expressions are specified, they will evaluate
  4734. to the luminance expression.
  4735. The expressions can use the following variables and functions:
  4736. @table @option
  4737. @item N
  4738. The sequential number of the filtered frame, starting from @code{0}.
  4739. @item X
  4740. @item Y
  4741. The coordinates of the current sample.
  4742. @item W
  4743. @item H
  4744. The width and height of the image.
  4745. @item SW
  4746. @item SH
  4747. Width and height scale depending on the currently filtered plane. It is the
  4748. ratio between the corresponding luma plane number of pixels and the current
  4749. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  4750. @code{0.5,0.5} for chroma planes.
  4751. @item T
  4752. Time of the current frame, expressed in seconds.
  4753. @item p(x, y)
  4754. Return the value of the pixel at location (@var{x},@var{y}) of the current
  4755. plane.
  4756. @item lum(x, y)
  4757. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  4758. plane.
  4759. @item cb(x, y)
  4760. Return the value of the pixel at location (@var{x},@var{y}) of the
  4761. blue-difference chroma plane. Return 0 if there is no such plane.
  4762. @item cr(x, y)
  4763. Return the value of the pixel at location (@var{x},@var{y}) of the
  4764. red-difference chroma plane. Return 0 if there is no such plane.
  4765. @item r(x, y)
  4766. @item g(x, y)
  4767. @item b(x, y)
  4768. Return the value of the pixel at location (@var{x},@var{y}) of the
  4769. red/green/blue component. Return 0 if there is no such component.
  4770. @item alpha(x, y)
  4771. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  4772. plane. Return 0 if there is no such plane.
  4773. @end table
  4774. For functions, if @var{x} and @var{y} are outside the area, the value will be
  4775. automatically clipped to the closer edge.
  4776. @subsection Examples
  4777. @itemize
  4778. @item
  4779. Flip the image horizontally:
  4780. @example
  4781. geq=p(W-X\,Y)
  4782. @end example
  4783. @item
  4784. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  4785. wavelength of 100 pixels:
  4786. @example
  4787. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  4788. @end example
  4789. @item
  4790. Generate a fancy enigmatic moving light:
  4791. @example
  4792. 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
  4793. @end example
  4794. @item
  4795. Generate a quick emboss effect:
  4796. @example
  4797. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  4798. @end example
  4799. @item
  4800. Modify RGB components depending on pixel position:
  4801. @example
  4802. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  4803. @end example
  4804. @item
  4805. Create a radial gradient that is the same size as the input (also see
  4806. the @ref{vignette} filter):
  4807. @example
  4808. geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
  4809. @end example
  4810. @item
  4811. Create a linear gradient to use as a mask for another filter, then
  4812. compose with @ref{overlay}. In this example the video will gradually
  4813. become more blurry from the top to the bottom of the y-axis as defined
  4814. by the linear gradient:
  4815. @example
  4816. 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
  4817. @end example
  4818. @end itemize
  4819. @section gradfun
  4820. Fix the banding artifacts that are sometimes introduced into nearly flat
  4821. regions by truncation to 8bit color depth.
  4822. Interpolate the gradients that should go where the bands are, and
  4823. dither them.
  4824. It is designed for playback only. Do not use it prior to
  4825. lossy compression, because compression tends to lose the dither and
  4826. bring back the bands.
  4827. It accepts the following parameters:
  4828. @table @option
  4829. @item strength
  4830. The maximum amount by which the filter will change any one pixel. This is also
  4831. the threshold for detecting nearly flat regions. Acceptable values range from
  4832. .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
  4833. valid range.
  4834. @item radius
  4835. The neighborhood to fit the gradient to. A larger radius makes for smoother
  4836. gradients, but also prevents the filter from modifying the pixels near detailed
  4837. regions. Acceptable values are 8-32; the default value is 16. Out-of-range
  4838. values will be clipped to the valid range.
  4839. @end table
  4840. Alternatively, the options can be specified as a flat string:
  4841. @var{strength}[:@var{radius}]
  4842. @subsection Examples
  4843. @itemize
  4844. @item
  4845. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  4846. @example
  4847. gradfun=3.5:8
  4848. @end example
  4849. @item
  4850. Specify radius, omitting the strength (which will fall-back to the default
  4851. value):
  4852. @example
  4853. gradfun=radius=8
  4854. @end example
  4855. @end itemize
  4856. @anchor{haldclut}
  4857. @section haldclut
  4858. Apply a Hald CLUT to a video stream.
  4859. First input is the video stream to process, and second one is the Hald CLUT.
  4860. The Hald CLUT input can be a simple picture or a complete video stream.
  4861. The filter accepts the following options:
  4862. @table @option
  4863. @item shortest
  4864. Force termination when the shortest input terminates. Default is @code{0}.
  4865. @item repeatlast
  4866. Continue applying the last CLUT after the end of the stream. A value of
  4867. @code{0} disable the filter after the last frame of the CLUT is reached.
  4868. Default is @code{1}.
  4869. @end table
  4870. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  4871. filters share the same internals).
  4872. More information about the Hald CLUT can be found on Eskil Steenberg's website
  4873. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  4874. @subsection Workflow examples
  4875. @subsubsection Hald CLUT video stream
  4876. Generate an identity Hald CLUT stream altered with various effects:
  4877. @example
  4878. 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
  4879. @end example
  4880. Note: make sure you use a lossless codec.
  4881. Then use it with @code{haldclut} to apply it on some random stream:
  4882. @example
  4883. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  4884. @end example
  4885. The Hald CLUT will be applied to the 10 first seconds (duration of
  4886. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  4887. to the remaining frames of the @code{mandelbrot} stream.
  4888. @subsubsection Hald CLUT with preview
  4889. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  4890. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  4891. biggest possible square starting at the top left of the picture. The remaining
  4892. padding pixels (bottom or right) will be ignored. This area can be used to add
  4893. a preview of the Hald CLUT.
  4894. Typically, the following generated Hald CLUT will be supported by the
  4895. @code{haldclut} filter:
  4896. @example
  4897. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  4898. pad=iw+320 [padded_clut];
  4899. smptebars=s=320x256, split [a][b];
  4900. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  4901. [main][b] overlay=W-320" -frames:v 1 clut.png
  4902. @end example
  4903. It contains the original and a preview of the effect of the CLUT: SMPTE color
  4904. bars are displayed on the right-top, and below the same color bars processed by
  4905. the color changes.
  4906. Then, the effect of this Hald CLUT can be visualized with:
  4907. @example
  4908. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  4909. @end example
  4910. @section hflip
  4911. Flip the input video horizontally.
  4912. For example, to horizontally flip the input video with @command{ffmpeg}:
  4913. @example
  4914. ffmpeg -i in.avi -vf "hflip" out.avi
  4915. @end example
  4916. @section histeq
  4917. This filter applies a global color histogram equalization on a
  4918. per-frame basis.
  4919. It can be used to correct video that has a compressed range of pixel
  4920. intensities. The filter redistributes the pixel intensities to
  4921. equalize their distribution across the intensity range. It may be
  4922. viewed as an "automatically adjusting contrast filter". This filter is
  4923. useful only for correcting degraded or poorly captured source
  4924. video.
  4925. The filter accepts the following options:
  4926. @table @option
  4927. @item strength
  4928. Determine the amount of equalization to be applied. As the strength
  4929. is reduced, the distribution of pixel intensities more-and-more
  4930. approaches that of the input frame. The value must be a float number
  4931. in the range [0,1] and defaults to 0.200.
  4932. @item intensity
  4933. Set the maximum intensity that can generated and scale the output
  4934. values appropriately. The strength should be set as desired and then
  4935. the intensity can be limited if needed to avoid washing-out. The value
  4936. must be a float number in the range [0,1] and defaults to 0.210.
  4937. @item antibanding
  4938. Set the antibanding level. If enabled the filter will randomly vary
  4939. the luminance of output pixels by a small amount to avoid banding of
  4940. the histogram. Possible values are @code{none}, @code{weak} or
  4941. @code{strong}. It defaults to @code{none}.
  4942. @end table
  4943. @section histogram
  4944. Compute and draw a color distribution histogram for the input video.
  4945. The computed histogram is a representation of the color component
  4946. distribution in an image.
  4947. The filter accepts the following options:
  4948. @table @option
  4949. @item mode
  4950. Set histogram mode.
  4951. It accepts the following values:
  4952. @table @samp
  4953. @item levels
  4954. Standard histogram that displays the color components distribution in an
  4955. image. Displays color graph for each color component. Shows distribution of
  4956. the Y, U, V, A or R, G, B components, depending on input format, in the
  4957. current frame. Below each graph a color component scale meter is shown.
  4958. @item color
  4959. Displays chroma values (U/V color placement) in a two dimensional
  4960. graph (which is called a vectorscope). The brighter a pixel in the
  4961. vectorscope, the more pixels of the input frame correspond to that pixel
  4962. (i.e., more pixels have this chroma value). The V component is displayed on
  4963. the horizontal (X) axis, with the leftmost side being V = 0 and the rightmost
  4964. side being V = 255. The U component is displayed on the vertical (Y) axis,
  4965. with the top representing U = 0 and the bottom representing U = 255.
  4966. The position of a white pixel in the graph corresponds to the chroma value of
  4967. a pixel of the input clip. The graph can therefore be used to read the hue
  4968. (color flavor) and the saturation (the dominance of the hue in the color). As
  4969. the hue of a color changes, it moves around the square. At the center of the
  4970. square the saturation is zero, which means that the corresponding pixel has no
  4971. color. If the amount of a specific color is increased (while leaving the other
  4972. colors unchanged) the saturation increases, and the indicator moves towards
  4973. the edge of the square.
  4974. @item color2
  4975. Chroma values in vectorscope, similar as @code{color} but actual chroma values
  4976. are displayed.
  4977. @item waveform
  4978. Per row/column color component graph. In row mode, the graph on the left side
  4979. represents color component value 0 and the right side represents value = 255.
  4980. In column mode, the top side represents color component value = 0 and bottom
  4981. side represents value = 255.
  4982. @end table
  4983. Default value is @code{levels}.
  4984. @item level_height
  4985. Set height of level in @code{levels}. Default value is @code{200}.
  4986. Allowed range is [50, 2048].
  4987. @item scale_height
  4988. Set height of color scale in @code{levels}. Default value is @code{12}.
  4989. Allowed range is [0, 40].
  4990. @item step
  4991. Set step for @code{waveform} mode. Smaller values are useful to find out how
  4992. many values of the same luminance are distributed across input rows/columns.
  4993. Default value is @code{10}. Allowed range is [1, 255].
  4994. @item waveform_mode
  4995. Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
  4996. Default is @code{row}.
  4997. @item waveform_mirror
  4998. Set mirroring mode for @code{waveform}. @code{0} means unmirrored, @code{1}
  4999. means mirrored. In mirrored mode, higher values will be represented on the left
  5000. side for @code{row} mode and at the top for @code{column} mode. Default is
  5001. @code{0} (unmirrored).
  5002. @item display_mode
  5003. Set display mode for @code{waveform} and @code{levels}.
  5004. It accepts the following values:
  5005. @table @samp
  5006. @item parade
  5007. Display separate graph for the color components side by side in
  5008. @code{row} waveform mode or one below the other in @code{column} waveform mode
  5009. for @code{waveform} histogram mode. For @code{levels} histogram mode,
  5010. per color component graphs are placed below each other.
  5011. Using this display mode in @code{waveform} histogram mode makes it easy to
  5012. spot color casts in the highlights and shadows of an image, by comparing the
  5013. contours of the top and the bottom graphs of each waveform. Since whites,
  5014. grays, and blacks are characterized by exactly equal amounts of red, green,
  5015. and blue, neutral areas of the picture should display three waveforms of
  5016. roughly equal width/height. If not, the correction is easy to perform by
  5017. making level adjustments the three waveforms.
  5018. @item overlay
  5019. Presents information identical to that in the @code{parade}, except
  5020. that the graphs representing color components are superimposed directly
  5021. over one another.
  5022. This display mode in @code{waveform} histogram mode makes it easier to spot
  5023. relative differences or similarities in overlapping areas of the color
  5024. components that are supposed to be identical, such as neutral whites, grays,
  5025. or blacks.
  5026. @end table
  5027. Default is @code{parade}.
  5028. @item levels_mode
  5029. Set mode for @code{levels}. Can be either @code{linear}, or @code{logarithmic}.
  5030. Default is @code{linear}.
  5031. @item components
  5032. Set what color components to display for mode @code{levels}.
  5033. Default is @code{7}.
  5034. @end table
  5035. @subsection Examples
  5036. @itemize
  5037. @item
  5038. Calculate and draw histogram:
  5039. @example
  5040. ffplay -i input -vf histogram
  5041. @end example
  5042. @end itemize
  5043. @anchor{hqdn3d}
  5044. @section hqdn3d
  5045. This is a high precision/quality 3d denoise filter. It aims to reduce
  5046. image noise, producing smooth images and making still images really
  5047. still. It should enhance compressibility.
  5048. It accepts the following optional parameters:
  5049. @table @option
  5050. @item luma_spatial
  5051. A non-negative floating point number which specifies spatial luma strength.
  5052. It defaults to 4.0.
  5053. @item chroma_spatial
  5054. A non-negative floating point number which specifies spatial chroma strength.
  5055. It defaults to 3.0*@var{luma_spatial}/4.0.
  5056. @item luma_tmp
  5057. A floating point number which specifies luma temporal strength. It defaults to
  5058. 6.0*@var{luma_spatial}/4.0.
  5059. @item chroma_tmp
  5060. A floating point number which specifies chroma temporal strength. It defaults to
  5061. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
  5062. @end table
  5063. @section hqx
  5064. Apply a high-quality magnification filter designed for pixel art. This filter
  5065. was originally created by Maxim Stepin.
  5066. It accepts the following option:
  5067. @table @option
  5068. @item n
  5069. Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
  5070. @code{hq3x} and @code{4} for @code{hq4x}.
  5071. Default is @code{3}.
  5072. @end table
  5073. @section hue
  5074. Modify the hue and/or the saturation of the input.
  5075. It accepts the following parameters:
  5076. @table @option
  5077. @item h
  5078. Specify the hue angle as a number of degrees. It accepts an expression,
  5079. and defaults to "0".
  5080. @item s
  5081. Specify the saturation in the [-10,10] range. It accepts an expression and
  5082. defaults to "1".
  5083. @item H
  5084. Specify the hue angle as a number of radians. It accepts an
  5085. expression, and defaults to "0".
  5086. @item b
  5087. Specify the brightness in the [-10,10] range. It accepts an expression and
  5088. defaults to "0".
  5089. @end table
  5090. @option{h} and @option{H} are mutually exclusive, and can't be
  5091. specified at the same time.
  5092. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  5093. expressions containing the following constants:
  5094. @table @option
  5095. @item n
  5096. frame count of the input frame starting from 0
  5097. @item pts
  5098. presentation timestamp of the input frame expressed in time base units
  5099. @item r
  5100. frame rate of the input video, NAN if the input frame rate is unknown
  5101. @item t
  5102. timestamp expressed in seconds, NAN if the input timestamp is unknown
  5103. @item tb
  5104. time base of the input video
  5105. @end table
  5106. @subsection Examples
  5107. @itemize
  5108. @item
  5109. Set the hue to 90 degrees and the saturation to 1.0:
  5110. @example
  5111. hue=h=90:s=1
  5112. @end example
  5113. @item
  5114. Same command but expressing the hue in radians:
  5115. @example
  5116. hue=H=PI/2:s=1
  5117. @end example
  5118. @item
  5119. Rotate hue and make the saturation swing between 0
  5120. and 2 over a period of 1 second:
  5121. @example
  5122. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  5123. @end example
  5124. @item
  5125. Apply a 3 seconds saturation fade-in effect starting at 0:
  5126. @example
  5127. hue="s=min(t/3\,1)"
  5128. @end example
  5129. The general fade-in expression can be written as:
  5130. @example
  5131. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  5132. @end example
  5133. @item
  5134. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  5135. @example
  5136. hue="s=max(0\, min(1\, (8-t)/3))"
  5137. @end example
  5138. The general fade-out expression can be written as:
  5139. @example
  5140. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  5141. @end example
  5142. @end itemize
  5143. @subsection Commands
  5144. This filter supports the following commands:
  5145. @table @option
  5146. @item b
  5147. @item s
  5148. @item h
  5149. @item H
  5150. Modify the hue and/or the saturation and/or brightness of the input video.
  5151. The command accepts the same syntax of the corresponding option.
  5152. If the specified expression is not valid, it is kept at its current
  5153. value.
  5154. @end table
  5155. @section idet
  5156. Detect video interlacing type.
  5157. This filter tries to detect if the input frames as interlaced, progressive,
  5158. top or bottom field first. It will also try and detect fields that are
  5159. repeated between adjacent frames (a sign of telecine).
  5160. Single frame detection considers only immediately adjacent frames when classifying each frame.
  5161. Multiple frame detection incorporates the classification history of previous frames.
  5162. The filter will log these metadata values:
  5163. @table @option
  5164. @item single.current_frame
  5165. Detected type of current frame using single-frame detection. One of:
  5166. ``tff'' (top field first), ``bff'' (bottom field first),
  5167. ``progressive'', or ``undetermined''
  5168. @item single.tff
  5169. Cumulative number of frames detected as top field first using single-frame detection.
  5170. @item multiple.tff
  5171. Cumulative number of frames detected as top field first using multiple-frame detection.
  5172. @item single.bff
  5173. Cumulative number of frames detected as bottom field first using single-frame detection.
  5174. @item multiple.current_frame
  5175. Detected type of current frame using multiple-frame detection. One of:
  5176. ``tff'' (top field first), ``bff'' (bottom field first),
  5177. ``progressive'', or ``undetermined''
  5178. @item multiple.bff
  5179. Cumulative number of frames detected as bottom field first using multiple-frame detection.
  5180. @item single.progressive
  5181. Cumulative number of frames detected as progressive using single-frame detection.
  5182. @item multiple.progressive
  5183. Cumulative number of frames detected as progressive using multiple-frame detection.
  5184. @item single.undetermined
  5185. Cumulative number of frames that could not be classified using single-frame detection.
  5186. @item multiple.undetermined
  5187. Cumulative number of frames that could not be classified using multiple-frame detection.
  5188. @item repeated.current_frame
  5189. Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
  5190. @item repeated.neither
  5191. Cumulative number of frames with no repeated field.
  5192. @item repeated.top
  5193. Cumulative number of frames with the top field repeated from the previous frame's top field.
  5194. @item repeated.bottom
  5195. Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
  5196. @end table
  5197. The filter accepts the following options:
  5198. @table @option
  5199. @item intl_thres
  5200. Set interlacing threshold.
  5201. @item prog_thres
  5202. Set progressive threshold.
  5203. @item repeat_thres
  5204. Threshold for repeated field detection.
  5205. @item half_life
  5206. Number of frames after which a given frame's contribution to the
  5207. statistics is halved (i.e., it contributes only 0.5 to it's
  5208. classification). The default of 0 means that all frames seen are given
  5209. full weight of 1.0 forever.
  5210. @item analyze_interlaced_flag
  5211. When this is not 0 then idet will use the specified number of frames to determine
  5212. if the interlaced flag is accurate, it will not count undetermined frames.
  5213. If the flag is found to be accurate it will be used without any further
  5214. computations, if it is found to be inaccurate it will be cleared without any
  5215. further computations. This allows inserting the idet filter as a low computational
  5216. method to clean up the interlaced flag
  5217. @end table
  5218. @section il
  5219. Deinterleave or interleave fields.
  5220. This filter allows one to process interlaced images fields without
  5221. deinterlacing them. Deinterleaving splits the input frame into 2
  5222. fields (so called half pictures). Odd lines are moved to the top
  5223. half of the output image, even lines to the bottom half.
  5224. You can process (filter) them independently and then re-interleave them.
  5225. The filter accepts the following options:
  5226. @table @option
  5227. @item luma_mode, l
  5228. @item chroma_mode, c
  5229. @item alpha_mode, a
  5230. Available values for @var{luma_mode}, @var{chroma_mode} and
  5231. @var{alpha_mode} are:
  5232. @table @samp
  5233. @item none
  5234. Do nothing.
  5235. @item deinterleave, d
  5236. Deinterleave fields, placing one above the other.
  5237. @item interleave, i
  5238. Interleave fields. Reverse the effect of deinterleaving.
  5239. @end table
  5240. Default value is @code{none}.
  5241. @item luma_swap, ls
  5242. @item chroma_swap, cs
  5243. @item alpha_swap, as
  5244. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  5245. @end table
  5246. @section inflate
  5247. Apply inflate effect to the video.
  5248. This filter replaces the pixel by the local(3x3) average by taking into account
  5249. only values higher than the pixel.
  5250. It accepts the following options:
  5251. @table @option
  5252. @item threshold0
  5253. @item threshold1
  5254. @item threshold2
  5255. @item threshold3
  5256. Allows to limit the maximum change for each plane, default is 65535.
  5257. If 0, plane will remain unchanged.
  5258. @end table
  5259. @section interlace
  5260. Simple interlacing filter from progressive contents. This interleaves upper (or
  5261. lower) lines from odd frames with lower (or upper) lines from even frames,
  5262. halving the frame rate and preserving image height.
  5263. @example
  5264. Original Original New Frame
  5265. Frame 'j' Frame 'j+1' (tff)
  5266. ========== =========== ==================
  5267. Line 0 --------------------> Frame 'j' Line 0
  5268. Line 1 Line 1 ----> Frame 'j+1' Line 1
  5269. Line 2 ---------------------> Frame 'j' Line 2
  5270. Line 3 Line 3 ----> Frame 'j+1' Line 3
  5271. ... ... ...
  5272. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  5273. @end example
  5274. It accepts the following optional parameters:
  5275. @table @option
  5276. @item scan
  5277. This determines whether the interlaced frame is taken from the even
  5278. (tff - default) or odd (bff) lines of the progressive frame.
  5279. @item lowpass
  5280. Enable (default) or disable the vertical lowpass filter to avoid twitter
  5281. interlacing and reduce moire patterns.
  5282. @end table
  5283. @section kerndeint
  5284. Deinterlace input video by applying Donald Graft's adaptive kernel
  5285. deinterling. Work on interlaced parts of a video to produce
  5286. progressive frames.
  5287. The description of the accepted parameters follows.
  5288. @table @option
  5289. @item thresh
  5290. Set the threshold which affects the filter's tolerance when
  5291. determining if a pixel line must be processed. It must be an integer
  5292. in the range [0,255] and defaults to 10. A value of 0 will result in
  5293. applying the process on every pixels.
  5294. @item map
  5295. Paint pixels exceeding the threshold value to white if set to 1.
  5296. Default is 0.
  5297. @item order
  5298. Set the fields order. Swap fields if set to 1, leave fields alone if
  5299. 0. Default is 0.
  5300. @item sharp
  5301. Enable additional sharpening if set to 1. Default is 0.
  5302. @item twoway
  5303. Enable twoway sharpening if set to 1. Default is 0.
  5304. @end table
  5305. @subsection Examples
  5306. @itemize
  5307. @item
  5308. Apply default values:
  5309. @example
  5310. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  5311. @end example
  5312. @item
  5313. Enable additional sharpening:
  5314. @example
  5315. kerndeint=sharp=1
  5316. @end example
  5317. @item
  5318. Paint processed pixels in white:
  5319. @example
  5320. kerndeint=map=1
  5321. @end example
  5322. @end itemize
  5323. @section lenscorrection
  5324. Correct radial lens distortion
  5325. This filter can be used to correct for radial distortion as can result from the use
  5326. of wide angle lenses, and thereby re-rectify the image. To find the right parameters
  5327. one can use tools available for example as part of opencv or simply trial-and-error.
  5328. To use opencv use the calibration sample (under samples/cpp) from the opencv sources
  5329. and extract the k1 and k2 coefficients from the resulting matrix.
  5330. Note that effectively the same filter is available in the open-source tools Krita and
  5331. Digikam from the KDE project.
  5332. In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
  5333. this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
  5334. brightness distribution, so you may want to use both filters together in certain
  5335. cases, though you will have to take care of ordering, i.e. whether vignetting should
  5336. be applied before or after lens correction.
  5337. @subsection Options
  5338. The filter accepts the following options:
  5339. @table @option
  5340. @item cx
  5341. Relative x-coordinate of the focal point of the image, and thereby the center of the
  5342. distortion. This value has a range [0,1] and is expressed as fractions of the image
  5343. width.
  5344. @item cy
  5345. Relative y-coordinate of the focal point of the image, and thereby the center of the
  5346. distortion. This value has a range [0,1] and is expressed as fractions of the image
  5347. height.
  5348. @item k1
  5349. Coefficient of the quadratic correction term. 0.5 means no correction.
  5350. @item k2
  5351. Coefficient of the double quadratic correction term. 0.5 means no correction.
  5352. @end table
  5353. The formula that generates the correction is:
  5354. @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)
  5355. where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
  5356. distances from the focal point in the source and target images, respectively.
  5357. @anchor{lut3d}
  5358. @section lut3d
  5359. Apply a 3D LUT to an input video.
  5360. The filter accepts the following options:
  5361. @table @option
  5362. @item file
  5363. Set the 3D LUT file name.
  5364. Currently supported formats:
  5365. @table @samp
  5366. @item 3dl
  5367. AfterEffects
  5368. @item cube
  5369. Iridas
  5370. @item dat
  5371. DaVinci
  5372. @item m3d
  5373. Pandora
  5374. @end table
  5375. @item interp
  5376. Select interpolation mode.
  5377. Available values are:
  5378. @table @samp
  5379. @item nearest
  5380. Use values from the nearest defined point.
  5381. @item trilinear
  5382. Interpolate values using the 8 points defining a cube.
  5383. @item tetrahedral
  5384. Interpolate values using a tetrahedron.
  5385. @end table
  5386. @end table
  5387. @section lut, lutrgb, lutyuv
  5388. Compute a look-up table for binding each pixel component input value
  5389. to an output value, and apply it to the input video.
  5390. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  5391. to an RGB input video.
  5392. These filters accept the following parameters:
  5393. @table @option
  5394. @item c0
  5395. set first pixel component expression
  5396. @item c1
  5397. set second pixel component expression
  5398. @item c2
  5399. set third pixel component expression
  5400. @item c3
  5401. set fourth pixel component expression, corresponds to the alpha component
  5402. @item r
  5403. set red component expression
  5404. @item g
  5405. set green component expression
  5406. @item b
  5407. set blue component expression
  5408. @item a
  5409. alpha component expression
  5410. @item y
  5411. set Y/luminance component expression
  5412. @item u
  5413. set U/Cb component expression
  5414. @item v
  5415. set V/Cr component expression
  5416. @end table
  5417. Each of them specifies the expression to use for computing the lookup table for
  5418. the corresponding pixel component values.
  5419. The exact component associated to each of the @var{c*} options depends on the
  5420. format in input.
  5421. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  5422. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  5423. The expressions can contain the following constants and functions:
  5424. @table @option
  5425. @item w
  5426. @item h
  5427. The input width and height.
  5428. @item val
  5429. The input value for the pixel component.
  5430. @item clipval
  5431. The input value, clipped to the @var{minval}-@var{maxval} range.
  5432. @item maxval
  5433. The maximum value for the pixel component.
  5434. @item minval
  5435. The minimum value for the pixel component.
  5436. @item negval
  5437. The negated value for the pixel component value, clipped to the
  5438. @var{minval}-@var{maxval} range; it corresponds to the expression
  5439. "maxval-clipval+minval".
  5440. @item clip(val)
  5441. The computed value in @var{val}, clipped to the
  5442. @var{minval}-@var{maxval} range.
  5443. @item gammaval(gamma)
  5444. The computed gamma correction value of the pixel component value,
  5445. clipped to the @var{minval}-@var{maxval} range. It corresponds to the
  5446. expression
  5447. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  5448. @end table
  5449. All expressions default to "val".
  5450. @subsection Examples
  5451. @itemize
  5452. @item
  5453. Negate input video:
  5454. @example
  5455. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  5456. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  5457. @end example
  5458. The above is the same as:
  5459. @example
  5460. lutrgb="r=negval:g=negval:b=negval"
  5461. lutyuv="y=negval:u=negval:v=negval"
  5462. @end example
  5463. @item
  5464. Negate luminance:
  5465. @example
  5466. lutyuv=y=negval
  5467. @end example
  5468. @item
  5469. Remove chroma components, turning the video into a graytone image:
  5470. @example
  5471. lutyuv="u=128:v=128"
  5472. @end example
  5473. @item
  5474. Apply a luma burning effect:
  5475. @example
  5476. lutyuv="y=2*val"
  5477. @end example
  5478. @item
  5479. Remove green and blue components:
  5480. @example
  5481. lutrgb="g=0:b=0"
  5482. @end example
  5483. @item
  5484. Set a constant alpha channel value on input:
  5485. @example
  5486. format=rgba,lutrgb=a="maxval-minval/2"
  5487. @end example
  5488. @item
  5489. Correct luminance gamma by a factor of 0.5:
  5490. @example
  5491. lutyuv=y=gammaval(0.5)
  5492. @end example
  5493. @item
  5494. Discard least significant bits of luma:
  5495. @example
  5496. lutyuv=y='bitand(val, 128+64+32)'
  5497. @end example
  5498. @end itemize
  5499. @section mergeplanes
  5500. Merge color channel components from several video streams.
  5501. The filter accepts up to 4 input streams, and merge selected input
  5502. planes to the output video.
  5503. This filter accepts the following options:
  5504. @table @option
  5505. @item mapping
  5506. Set input to output plane mapping. Default is @code{0}.
  5507. The mappings is specified as a bitmap. It should be specified as a
  5508. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  5509. mapping for the first plane of the output stream. 'A' sets the number of
  5510. the input stream to use (from 0 to 3), and 'a' the plane number of the
  5511. corresponding input to use (from 0 to 3). The rest of the mappings is
  5512. similar, 'Bb' describes the mapping for the output stream second
  5513. plane, 'Cc' describes the mapping for the output stream third plane and
  5514. 'Dd' describes the mapping for the output stream fourth plane.
  5515. @item format
  5516. Set output pixel format. Default is @code{yuva444p}.
  5517. @end table
  5518. @subsection Examples
  5519. @itemize
  5520. @item
  5521. Merge three gray video streams of same width and height into single video stream:
  5522. @example
  5523. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  5524. @end example
  5525. @item
  5526. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  5527. @example
  5528. [a0][a1]mergeplanes=0x00010210:yuva444p
  5529. @end example
  5530. @item
  5531. Swap Y and A plane in yuva444p stream:
  5532. @example
  5533. format=yuva444p,mergeplanes=0x03010200:yuva444p
  5534. @end example
  5535. @item
  5536. Swap U and V plane in yuv420p stream:
  5537. @example
  5538. format=yuv420p,mergeplanes=0x000201:yuv420p
  5539. @end example
  5540. @item
  5541. Cast a rgb24 clip to yuv444p:
  5542. @example
  5543. format=rgb24,mergeplanes=0x000102:yuv444p
  5544. @end example
  5545. @end itemize
  5546. @section mcdeint
  5547. Apply motion-compensation deinterlacing.
  5548. It needs one field per frame as input and must thus be used together
  5549. with yadif=1/3 or equivalent.
  5550. This filter accepts the following options:
  5551. @table @option
  5552. @item mode
  5553. Set the deinterlacing mode.
  5554. It accepts one of the following values:
  5555. @table @samp
  5556. @item fast
  5557. @item medium
  5558. @item slow
  5559. use iterative motion estimation
  5560. @item extra_slow
  5561. like @samp{slow}, but use multiple reference frames.
  5562. @end table
  5563. Default value is @samp{fast}.
  5564. @item parity
  5565. Set the picture field parity assumed for the input video. It must be
  5566. one of the following values:
  5567. @table @samp
  5568. @item 0, tff
  5569. assume top field first
  5570. @item 1, bff
  5571. assume bottom field first
  5572. @end table
  5573. Default value is @samp{bff}.
  5574. @item qp
  5575. Set per-block quantization parameter (QP) used by the internal
  5576. encoder.
  5577. Higher values should result in a smoother motion vector field but less
  5578. optimal individual vectors. Default value is 1.
  5579. @end table
  5580. @section mpdecimate
  5581. Drop frames that do not differ greatly from the previous frame in
  5582. order to reduce frame rate.
  5583. The main use of this filter is for very-low-bitrate encoding
  5584. (e.g. streaming over dialup modem), but it could in theory be used for
  5585. fixing movies that were inverse-telecined incorrectly.
  5586. A description of the accepted options follows.
  5587. @table @option
  5588. @item max
  5589. Set the maximum number of consecutive frames which can be dropped (if
  5590. positive), or the minimum interval between dropped frames (if
  5591. negative). If the value is 0, the frame is dropped unregarding the
  5592. number of previous sequentially dropped frames.
  5593. Default value is 0.
  5594. @item hi
  5595. @item lo
  5596. @item frac
  5597. Set the dropping threshold values.
  5598. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  5599. represent actual pixel value differences, so a threshold of 64
  5600. corresponds to 1 unit of difference for each pixel, or the same spread
  5601. out differently over the block.
  5602. A frame is a candidate for dropping if no 8x8 blocks differ by more
  5603. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  5604. meaning the whole image) differ by more than a threshold of @option{lo}.
  5605. Default value for @option{hi} is 64*12, default value for @option{lo} is
  5606. 64*5, and default value for @option{frac} is 0.33.
  5607. @end table
  5608. @section negate
  5609. Negate input video.
  5610. It accepts an integer in input; if non-zero it negates the
  5611. alpha component (if available). The default value in input is 0.
  5612. @section noformat
  5613. Force libavfilter not to use any of the specified pixel formats for the
  5614. input to the next filter.
  5615. It accepts the following parameters:
  5616. @table @option
  5617. @item pix_fmts
  5618. A '|'-separated list of pixel format names, such as
  5619. apix_fmts=yuv420p|monow|rgb24".
  5620. @end table
  5621. @subsection Examples
  5622. @itemize
  5623. @item
  5624. Force libavfilter to use a format different from @var{yuv420p} for the
  5625. input to the vflip filter:
  5626. @example
  5627. noformat=pix_fmts=yuv420p,vflip
  5628. @end example
  5629. @item
  5630. Convert the input video to any of the formats not contained in the list:
  5631. @example
  5632. noformat=yuv420p|yuv444p|yuv410p
  5633. @end example
  5634. @end itemize
  5635. @section noise
  5636. Add noise on video input frame.
  5637. The filter accepts the following options:
  5638. @table @option
  5639. @item all_seed
  5640. @item c0_seed
  5641. @item c1_seed
  5642. @item c2_seed
  5643. @item c3_seed
  5644. Set noise seed for specific pixel component or all pixel components in case
  5645. of @var{all_seed}. Default value is @code{123457}.
  5646. @item all_strength, alls
  5647. @item c0_strength, c0s
  5648. @item c1_strength, c1s
  5649. @item c2_strength, c2s
  5650. @item c3_strength, c3s
  5651. Set noise strength for specific pixel component or all pixel components in case
  5652. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  5653. @item all_flags, allf
  5654. @item c0_flags, c0f
  5655. @item c1_flags, c1f
  5656. @item c2_flags, c2f
  5657. @item c3_flags, c3f
  5658. Set pixel component flags or set flags for all components if @var{all_flags}.
  5659. Available values for component flags are:
  5660. @table @samp
  5661. @item a
  5662. averaged temporal noise (smoother)
  5663. @item p
  5664. mix random noise with a (semi)regular pattern
  5665. @item t
  5666. temporal noise (noise pattern changes between frames)
  5667. @item u
  5668. uniform noise (gaussian otherwise)
  5669. @end table
  5670. @end table
  5671. @subsection Examples
  5672. Add temporal and uniform noise to input video:
  5673. @example
  5674. noise=alls=20:allf=t+u
  5675. @end example
  5676. @section null
  5677. Pass the video source unchanged to the output.
  5678. @section ocv
  5679. Apply a video transform using libopencv.
  5680. To enable this filter, install the libopencv library and headers and
  5681. configure FFmpeg with @code{--enable-libopencv}.
  5682. It accepts the following parameters:
  5683. @table @option
  5684. @item filter_name
  5685. The name of the libopencv filter to apply.
  5686. @item filter_params
  5687. The parameters to pass to the libopencv filter. If not specified, the default
  5688. values are assumed.
  5689. @end table
  5690. Refer to the official libopencv documentation for more precise
  5691. information:
  5692. @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
  5693. Several libopencv filters are supported; see the following subsections.
  5694. @anchor{dilate}
  5695. @subsection dilate
  5696. Dilate an image by using a specific structuring element.
  5697. It corresponds to the libopencv function @code{cvDilate}.
  5698. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  5699. @var{struct_el} represents a structuring element, and has the syntax:
  5700. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  5701. @var{cols} and @var{rows} represent the number of columns and rows of
  5702. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  5703. point, and @var{shape} the shape for the structuring element. @var{shape}
  5704. must be "rect", "cross", "ellipse", or "custom".
  5705. If the value for @var{shape} is "custom", it must be followed by a
  5706. string of the form "=@var{filename}". The file with name
  5707. @var{filename} is assumed to represent a binary image, with each
  5708. printable character corresponding to a bright pixel. When a custom
  5709. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  5710. or columns and rows of the read file are assumed instead.
  5711. The default value for @var{struct_el} is "3x3+0x0/rect".
  5712. @var{nb_iterations} specifies the number of times the transform is
  5713. applied to the image, and defaults to 1.
  5714. Some examples:
  5715. @example
  5716. # Use the default values
  5717. ocv=dilate
  5718. # Dilate using a structuring element with a 5x5 cross, iterating two times
  5719. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  5720. # Read the shape from the file diamond.shape, iterating two times.
  5721. # The file diamond.shape may contain a pattern of characters like this
  5722. # *
  5723. # ***
  5724. # *****
  5725. # ***
  5726. # *
  5727. # The specified columns and rows are ignored
  5728. # but the anchor point coordinates are not
  5729. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  5730. @end example
  5731. @subsection erode
  5732. Erode an image by using a specific structuring element.
  5733. It corresponds to the libopencv function @code{cvErode}.
  5734. It accepts the parameters: @var{struct_el}:@var{nb_iterations},
  5735. with the same syntax and semantics as the @ref{dilate} filter.
  5736. @subsection smooth
  5737. Smooth the input video.
  5738. The filter takes the following parameters:
  5739. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  5740. @var{type} is the type of smooth filter to apply, and must be one of
  5741. the following values: "blur", "blur_no_scale", "median", "gaussian",
  5742. or "bilateral". The default value is "gaussian".
  5743. The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
  5744. depend on the smooth type. @var{param1} and
  5745. @var{param2} accept integer positive values or 0. @var{param3} and
  5746. @var{param4} accept floating point values.
  5747. The default value for @var{param1} is 3. The default value for the
  5748. other parameters is 0.
  5749. These parameters correspond to the parameters assigned to the
  5750. libopencv function @code{cvSmooth}.
  5751. @anchor{overlay}
  5752. @section overlay
  5753. Overlay one video on top of another.
  5754. It takes two inputs and has one output. The first input is the "main"
  5755. video on which the second input is overlaid.
  5756. It accepts the following parameters:
  5757. A description of the accepted options follows.
  5758. @table @option
  5759. @item x
  5760. @item y
  5761. Set the expression for the x and y coordinates of the overlaid video
  5762. on the main video. Default value is "0" for both expressions. In case
  5763. the expression is invalid, it is set to a huge value (meaning that the
  5764. overlay will not be displayed within the output visible area).
  5765. @item eof_action
  5766. The action to take when EOF is encountered on the secondary input; it accepts
  5767. one of the following values:
  5768. @table @option
  5769. @item repeat
  5770. Repeat the last frame (the default).
  5771. @item endall
  5772. End both streams.
  5773. @item pass
  5774. Pass the main input through.
  5775. @end table
  5776. @item eval
  5777. Set when the expressions for @option{x}, and @option{y} are evaluated.
  5778. It accepts the following values:
  5779. @table @samp
  5780. @item init
  5781. only evaluate expressions once during the filter initialization or
  5782. when a command is processed
  5783. @item frame
  5784. evaluate expressions for each incoming frame
  5785. @end table
  5786. Default value is @samp{frame}.
  5787. @item shortest
  5788. If set to 1, force the output to terminate when the shortest input
  5789. terminates. Default value is 0.
  5790. @item format
  5791. Set the format for the output video.
  5792. It accepts the following values:
  5793. @table @samp
  5794. @item yuv420
  5795. force YUV420 output
  5796. @item yuv422
  5797. force YUV422 output
  5798. @item yuv444
  5799. force YUV444 output
  5800. @item rgb
  5801. force RGB output
  5802. @end table
  5803. Default value is @samp{yuv420}.
  5804. @item rgb @emph{(deprecated)}
  5805. If set to 1, force the filter to accept inputs in the RGB
  5806. color space. Default value is 0. This option is deprecated, use
  5807. @option{format} instead.
  5808. @item repeatlast
  5809. If set to 1, force the filter to draw the last overlay frame over the
  5810. main input until the end of the stream. A value of 0 disables this
  5811. behavior. Default value is 1.
  5812. @end table
  5813. The @option{x}, and @option{y} expressions can contain the following
  5814. parameters.
  5815. @table @option
  5816. @item main_w, W
  5817. @item main_h, H
  5818. The main input width and height.
  5819. @item overlay_w, w
  5820. @item overlay_h, h
  5821. The overlay input width and height.
  5822. @item x
  5823. @item y
  5824. The computed values for @var{x} and @var{y}. They are evaluated for
  5825. each new frame.
  5826. @item hsub
  5827. @item vsub
  5828. horizontal and vertical chroma subsample values of the output
  5829. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  5830. @var{vsub} is 1.
  5831. @item n
  5832. the number of input frame, starting from 0
  5833. @item pos
  5834. the position in the file of the input frame, NAN if unknown
  5835. @item t
  5836. The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
  5837. @end table
  5838. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  5839. when evaluation is done @emph{per frame}, and will evaluate to NAN
  5840. when @option{eval} is set to @samp{init}.
  5841. Be aware that frames are taken from each input video in timestamp
  5842. order, hence, if their initial timestamps differ, it is a good idea
  5843. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  5844. have them begin in the same zero timestamp, as the example for
  5845. the @var{movie} filter does.
  5846. You can chain together more overlays but you should test the
  5847. efficiency of such approach.
  5848. @subsection Commands
  5849. This filter supports the following commands:
  5850. @table @option
  5851. @item x
  5852. @item y
  5853. Modify the x and y of the overlay input.
  5854. The command accepts the same syntax of the corresponding option.
  5855. If the specified expression is not valid, it is kept at its current
  5856. value.
  5857. @end table
  5858. @subsection Examples
  5859. @itemize
  5860. @item
  5861. Draw the overlay at 10 pixels from the bottom right corner of the main
  5862. video:
  5863. @example
  5864. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  5865. @end example
  5866. Using named options the example above becomes:
  5867. @example
  5868. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  5869. @end example
  5870. @item
  5871. Insert a transparent PNG logo in the bottom left corner of the input,
  5872. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  5873. @example
  5874. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  5875. @end example
  5876. @item
  5877. Insert 2 different transparent PNG logos (second logo on bottom
  5878. right corner) using the @command{ffmpeg} tool:
  5879. @example
  5880. 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
  5881. @end example
  5882. @item
  5883. Add a transparent color layer on top of the main video; @code{WxH}
  5884. must specify the size of the main input to the overlay filter:
  5885. @example
  5886. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  5887. @end example
  5888. @item
  5889. Play an original video and a filtered version (here with the deshake
  5890. filter) side by side using the @command{ffplay} tool:
  5891. @example
  5892. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  5893. @end example
  5894. The above command is the same as:
  5895. @example
  5896. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  5897. @end example
  5898. @item
  5899. Make a sliding overlay appearing from the left to the right top part of the
  5900. screen starting since time 2:
  5901. @example
  5902. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  5903. @end example
  5904. @item
  5905. Compose output by putting two input videos side to side:
  5906. @example
  5907. ffmpeg -i left.avi -i right.avi -filter_complex "
  5908. nullsrc=size=200x100 [background];
  5909. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  5910. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  5911. [background][left] overlay=shortest=1 [background+left];
  5912. [background+left][right] overlay=shortest=1:x=100 [left+right]
  5913. "
  5914. @end example
  5915. @item
  5916. Mask 10-20 seconds of a video by applying the delogo filter to a section
  5917. @example
  5918. ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
  5919. -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]'
  5920. masked.avi
  5921. @end example
  5922. @item
  5923. Chain several overlays in cascade:
  5924. @example
  5925. nullsrc=s=200x200 [bg];
  5926. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  5927. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  5928. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  5929. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  5930. [in3] null, [mid2] overlay=100:100 [out0]
  5931. @end example
  5932. @end itemize
  5933. @section owdenoise
  5934. Apply Overcomplete Wavelet denoiser.
  5935. The filter accepts the following options:
  5936. @table @option
  5937. @item depth
  5938. Set depth.
  5939. Larger depth values will denoise lower frequency components more, but
  5940. slow down filtering.
  5941. Must be an int in the range 8-16, default is @code{8}.
  5942. @item luma_strength, ls
  5943. Set luma strength.
  5944. Must be a double value in the range 0-1000, default is @code{1.0}.
  5945. @item chroma_strength, cs
  5946. Set chroma strength.
  5947. Must be a double value in the range 0-1000, default is @code{1.0}.
  5948. @end table
  5949. @section pad
  5950. Add paddings to the input image, and place the original input at the
  5951. provided @var{x}, @var{y} coordinates.
  5952. It accepts the following parameters:
  5953. @table @option
  5954. @item width, w
  5955. @item height, h
  5956. Specify an expression for the size of the output image with the
  5957. paddings added. If the value for @var{width} or @var{height} is 0, the
  5958. corresponding input size is used for the output.
  5959. The @var{width} expression can reference the value set by the
  5960. @var{height} expression, and vice versa.
  5961. The default value of @var{width} and @var{height} is 0.
  5962. @item x
  5963. @item y
  5964. Specify the offsets to place the input image at within the padded area,
  5965. with respect to the top/left border of the output image.
  5966. The @var{x} expression can reference the value set by the @var{y}
  5967. expression, and vice versa.
  5968. The default value of @var{x} and @var{y} is 0.
  5969. @item color
  5970. Specify the color of the padded area. For the syntax of this option,
  5971. check the "Color" section in the ffmpeg-utils manual.
  5972. The default value of @var{color} is "black".
  5973. @end table
  5974. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  5975. options are expressions containing the following constants:
  5976. @table @option
  5977. @item in_w
  5978. @item in_h
  5979. The input video width and height.
  5980. @item iw
  5981. @item ih
  5982. These are the same as @var{in_w} and @var{in_h}.
  5983. @item out_w
  5984. @item out_h
  5985. The output width and height (the size of the padded area), as
  5986. specified by the @var{width} and @var{height} expressions.
  5987. @item ow
  5988. @item oh
  5989. These are the same as @var{out_w} and @var{out_h}.
  5990. @item x
  5991. @item y
  5992. The x and y offsets as specified by the @var{x} and @var{y}
  5993. expressions, or NAN if not yet specified.
  5994. @item a
  5995. same as @var{iw} / @var{ih}
  5996. @item sar
  5997. input sample aspect ratio
  5998. @item dar
  5999. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  6000. @item hsub
  6001. @item vsub
  6002. The horizontal and vertical chroma subsample values. For example for the
  6003. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6004. @end table
  6005. @subsection Examples
  6006. @itemize
  6007. @item
  6008. Add paddings with the color "violet" to the input video. The output video
  6009. size is 640x480, and the top-left corner of the input video is placed at
  6010. column 0, row 40
  6011. @example
  6012. pad=640:480:0:40:violet
  6013. @end example
  6014. The example above is equivalent to the following command:
  6015. @example
  6016. pad=width=640:height=480:x=0:y=40:color=violet
  6017. @end example
  6018. @item
  6019. Pad the input to get an output with dimensions increased by 3/2,
  6020. and put the input video at the center of the padded area:
  6021. @example
  6022. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  6023. @end example
  6024. @item
  6025. Pad the input to get a squared output with size equal to the maximum
  6026. value between the input width and height, and put the input video at
  6027. the center of the padded area:
  6028. @example
  6029. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  6030. @end example
  6031. @item
  6032. Pad the input to get a final w/h ratio of 16:9:
  6033. @example
  6034. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  6035. @end example
  6036. @item
  6037. In case of anamorphic video, in order to set the output display aspect
  6038. correctly, it is necessary to use @var{sar} in the expression,
  6039. according to the relation:
  6040. @example
  6041. (ih * X / ih) * sar = output_dar
  6042. X = output_dar / sar
  6043. @end example
  6044. Thus the previous example needs to be modified to:
  6045. @example
  6046. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  6047. @end example
  6048. @item
  6049. Double the output size and put the input video in the bottom-right
  6050. corner of the output padded area:
  6051. @example
  6052. pad="2*iw:2*ih:ow-iw:oh-ih"
  6053. @end example
  6054. @end itemize
  6055. @anchor{palettegen}
  6056. @section palettegen
  6057. Generate one palette for a whole video stream.
  6058. It accepts the following options:
  6059. @table @option
  6060. @item max_colors
  6061. Set the maximum number of colors to quantize in the palette.
  6062. Note: the palette will still contain 256 colors; the unused palette entries
  6063. will be black.
  6064. @item reserve_transparent
  6065. Create a palette of 255 colors maximum and reserve the last one for
  6066. transparency. Reserving the transparency color is useful for GIF optimization.
  6067. If not set, the maximum of colors in the palette will be 256. You probably want
  6068. to disable this option for a standalone image.
  6069. Set by default.
  6070. @item stats_mode
  6071. Set statistics mode.
  6072. It accepts the following values:
  6073. @table @samp
  6074. @item full
  6075. Compute full frame histograms.
  6076. @item diff
  6077. Compute histograms only for the part that differs from previous frame. This
  6078. might be relevant to give more importance to the moving part of your input if
  6079. the background is static.
  6080. @end table
  6081. Default value is @var{full}.
  6082. @end table
  6083. The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
  6084. (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
  6085. color quantization of the palette. This information is also visible at
  6086. @var{info} logging level.
  6087. @subsection Examples
  6088. @itemize
  6089. @item
  6090. Generate a representative palette of a given video using @command{ffmpeg}:
  6091. @example
  6092. ffmpeg -i input.mkv -vf palettegen palette.png
  6093. @end example
  6094. @end itemize
  6095. @section paletteuse
  6096. Use a palette to downsample an input video stream.
  6097. The filter takes two inputs: one video stream and a palette. The palette must
  6098. be a 256 pixels image.
  6099. It accepts the following options:
  6100. @table @option
  6101. @item dither
  6102. Select dithering mode. Available algorithms are:
  6103. @table @samp
  6104. @item bayer
  6105. Ordered 8x8 bayer dithering (deterministic)
  6106. @item heckbert
  6107. Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
  6108. Note: this dithering is sometimes considered "wrong" and is included as a
  6109. reference.
  6110. @item floyd_steinberg
  6111. Floyd and Steingberg dithering (error diffusion)
  6112. @item sierra2
  6113. Frankie Sierra dithering v2 (error diffusion)
  6114. @item sierra2_4a
  6115. Frankie Sierra dithering v2 "Lite" (error diffusion)
  6116. @end table
  6117. Default is @var{sierra2_4a}.
  6118. @item bayer_scale
  6119. When @var{bayer} dithering is selected, this option defines the scale of the
  6120. pattern (how much the crosshatch pattern is visible). A low value means more
  6121. visible pattern for less banding, and higher value means less visible pattern
  6122. at the cost of more banding.
  6123. The option must be an integer value in the range [0,5]. Default is @var{2}.
  6124. @item diff_mode
  6125. If set, define the zone to process
  6126. @table @samp
  6127. @item rectangle
  6128. Only the changing rectangle will be reprocessed. This is similar to GIF
  6129. cropping/offsetting compression mechanism. This option can be useful for speed
  6130. if only a part of the image is changing, and has use cases such as limiting the
  6131. scope of the error diffusal @option{dither} to the rectangle that bounds the
  6132. moving scene (it leads to more deterministic output if the scene doesn't change
  6133. much, and as a result less moving noise and better GIF compression).
  6134. @end table
  6135. Default is @var{none}.
  6136. @end table
  6137. @subsection Examples
  6138. @itemize
  6139. @item
  6140. Use a palette (generated for example with @ref{palettegen}) to encode a GIF
  6141. using @command{ffmpeg}:
  6142. @example
  6143. ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
  6144. @end example
  6145. @end itemize
  6146. @section perspective
  6147. Correct perspective of video not recorded perpendicular to the screen.
  6148. A description of the accepted parameters follows.
  6149. @table @option
  6150. @item x0
  6151. @item y0
  6152. @item x1
  6153. @item y1
  6154. @item x2
  6155. @item y2
  6156. @item x3
  6157. @item y3
  6158. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  6159. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  6160. If the @code{sense} option is set to @code{source}, then the specified points will be sent
  6161. to the corners of the destination. If the @code{sense} option is set to @code{destination},
  6162. then the corners of the source will be sent to the specified coordinates.
  6163. The expressions can use the following variables:
  6164. @table @option
  6165. @item W
  6166. @item H
  6167. the width and height of video frame.
  6168. @end table
  6169. @item interpolation
  6170. Set interpolation for perspective correction.
  6171. It accepts the following values:
  6172. @table @samp
  6173. @item linear
  6174. @item cubic
  6175. @end table
  6176. Default value is @samp{linear}.
  6177. @item sense
  6178. Set interpretation of coordinate options.
  6179. It accepts the following values:
  6180. @table @samp
  6181. @item 0, source
  6182. Send point in the source specified by the given coordinates to
  6183. the corners of the destination.
  6184. @item 1, destination
  6185. Send the corners of the source to the point in the destination specified
  6186. by the given coordinates.
  6187. Default value is @samp{source}.
  6188. @end table
  6189. @end table
  6190. @section phase
  6191. Delay interlaced video by one field time so that the field order changes.
  6192. The intended use is to fix PAL movies that have been captured with the
  6193. opposite field order to the film-to-video transfer.
  6194. A description of the accepted parameters follows.
  6195. @table @option
  6196. @item mode
  6197. Set phase mode.
  6198. It accepts the following values:
  6199. @table @samp
  6200. @item t
  6201. Capture field order top-first, transfer bottom-first.
  6202. Filter will delay the bottom field.
  6203. @item b
  6204. Capture field order bottom-first, transfer top-first.
  6205. Filter will delay the top field.
  6206. @item p
  6207. Capture and transfer with the same field order. This mode only exists
  6208. for the documentation of the other options to refer to, but if you
  6209. actually select it, the filter will faithfully do nothing.
  6210. @item a
  6211. Capture field order determined automatically by field flags, transfer
  6212. opposite.
  6213. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  6214. basis using field flags. If no field information is available,
  6215. then this works just like @samp{u}.
  6216. @item u
  6217. Capture unknown or varying, transfer opposite.
  6218. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  6219. analyzing the images and selecting the alternative that produces best
  6220. match between the fields.
  6221. @item T
  6222. Capture top-first, transfer unknown or varying.
  6223. Filter selects among @samp{t} and @samp{p} using image analysis.
  6224. @item B
  6225. Capture bottom-first, transfer unknown or varying.
  6226. Filter selects among @samp{b} and @samp{p} using image analysis.
  6227. @item A
  6228. Capture determined by field flags, transfer unknown or varying.
  6229. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  6230. image analysis. If no field information is available, then this works just
  6231. like @samp{U}. This is the default mode.
  6232. @item U
  6233. Both capture and transfer unknown or varying.
  6234. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  6235. @end table
  6236. @end table
  6237. @section pixdesctest
  6238. Pixel format descriptor test filter, mainly useful for internal
  6239. testing. The output video should be equal to the input video.
  6240. For example:
  6241. @example
  6242. format=monow, pixdesctest
  6243. @end example
  6244. can be used to test the monowhite pixel format descriptor definition.
  6245. @section pp
  6246. Enable the specified chain of postprocessing subfilters using libpostproc. This
  6247. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  6248. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  6249. Each subfilter and some options have a short and a long name that can be used
  6250. interchangeably, i.e. dr/dering are the same.
  6251. The filters accept the following options:
  6252. @table @option
  6253. @item subfilters
  6254. Set postprocessing subfilters string.
  6255. @end table
  6256. All subfilters share common options to determine their scope:
  6257. @table @option
  6258. @item a/autoq
  6259. Honor the quality commands for this subfilter.
  6260. @item c/chrom
  6261. Do chrominance filtering, too (default).
  6262. @item y/nochrom
  6263. Do luminance filtering only (no chrominance).
  6264. @item n/noluma
  6265. Do chrominance filtering only (no luminance).
  6266. @end table
  6267. These options can be appended after the subfilter name, separated by a '|'.
  6268. Available subfilters are:
  6269. @table @option
  6270. @item hb/hdeblock[|difference[|flatness]]
  6271. Horizontal deblocking filter
  6272. @table @option
  6273. @item difference
  6274. Difference factor where higher values mean more deblocking (default: @code{32}).
  6275. @item flatness
  6276. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6277. @end table
  6278. @item vb/vdeblock[|difference[|flatness]]
  6279. Vertical deblocking filter
  6280. @table @option
  6281. @item difference
  6282. Difference factor where higher values mean more deblocking (default: @code{32}).
  6283. @item flatness
  6284. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6285. @end table
  6286. @item ha/hadeblock[|difference[|flatness]]
  6287. Accurate horizontal deblocking filter
  6288. @table @option
  6289. @item difference
  6290. Difference factor where higher values mean more deblocking (default: @code{32}).
  6291. @item flatness
  6292. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6293. @end table
  6294. @item va/vadeblock[|difference[|flatness]]
  6295. Accurate vertical deblocking filter
  6296. @table @option
  6297. @item difference
  6298. Difference factor where higher values mean more deblocking (default: @code{32}).
  6299. @item flatness
  6300. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6301. @end table
  6302. @end table
  6303. The horizontal and vertical deblocking filters share the difference and
  6304. flatness values so you cannot set different horizontal and vertical
  6305. thresholds.
  6306. @table @option
  6307. @item h1/x1hdeblock
  6308. Experimental horizontal deblocking filter
  6309. @item v1/x1vdeblock
  6310. Experimental vertical deblocking filter
  6311. @item dr/dering
  6312. Deringing filter
  6313. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  6314. @table @option
  6315. @item threshold1
  6316. larger -> stronger filtering
  6317. @item threshold2
  6318. larger -> stronger filtering
  6319. @item threshold3
  6320. larger -> stronger filtering
  6321. @end table
  6322. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  6323. @table @option
  6324. @item f/fullyrange
  6325. Stretch luminance to @code{0-255}.
  6326. @end table
  6327. @item lb/linblenddeint
  6328. Linear blend deinterlacing filter that deinterlaces the given block by
  6329. filtering all lines with a @code{(1 2 1)} filter.
  6330. @item li/linipoldeint
  6331. Linear interpolating deinterlacing filter that deinterlaces the given block by
  6332. linearly interpolating every second line.
  6333. @item ci/cubicipoldeint
  6334. Cubic interpolating deinterlacing filter deinterlaces the given block by
  6335. cubically interpolating every second line.
  6336. @item md/mediandeint
  6337. Median deinterlacing filter that deinterlaces the given block by applying a
  6338. median filter to every second line.
  6339. @item fd/ffmpegdeint
  6340. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  6341. second line with a @code{(-1 4 2 4 -1)} filter.
  6342. @item l5/lowpass5
  6343. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  6344. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  6345. @item fq/forceQuant[|quantizer]
  6346. Overrides the quantizer table from the input with the constant quantizer you
  6347. specify.
  6348. @table @option
  6349. @item quantizer
  6350. Quantizer to use
  6351. @end table
  6352. @item de/default
  6353. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  6354. @item fa/fast
  6355. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  6356. @item ac
  6357. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  6358. @end table
  6359. @subsection Examples
  6360. @itemize
  6361. @item
  6362. Apply horizontal and vertical deblocking, deringing and automatic
  6363. brightness/contrast:
  6364. @example
  6365. pp=hb/vb/dr/al
  6366. @end example
  6367. @item
  6368. Apply default filters without brightness/contrast correction:
  6369. @example
  6370. pp=de/-al
  6371. @end example
  6372. @item
  6373. Apply default filters and temporal denoiser:
  6374. @example
  6375. pp=default/tmpnoise|1|2|3
  6376. @end example
  6377. @item
  6378. Apply deblocking on luminance only, and switch vertical deblocking on or off
  6379. automatically depending on available CPU time:
  6380. @example
  6381. pp=hb|y/vb|a
  6382. @end example
  6383. @end itemize
  6384. @section pp7
  6385. Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
  6386. similar to spp = 6 with 7 point DCT, where only the center sample is
  6387. used after IDCT.
  6388. The filter accepts the following options:
  6389. @table @option
  6390. @item qp
  6391. Force a constant quantization parameter. It accepts an integer in range
  6392. 0 to 63. If not set, the filter will use the QP from the video stream
  6393. (if available).
  6394. @item mode
  6395. Set thresholding mode. Available modes are:
  6396. @table @samp
  6397. @item hard
  6398. Set hard thresholding.
  6399. @item soft
  6400. Set soft thresholding (better de-ringing effect, but likely blurrier).
  6401. @item medium
  6402. Set medium thresholding (good results, default).
  6403. @end table
  6404. @end table
  6405. @section psnr
  6406. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  6407. Ratio) between two input videos.
  6408. This filter takes in input two input videos, the first input is
  6409. considered the "main" source and is passed unchanged to the
  6410. output. The second input is used as a "reference" video for computing
  6411. the PSNR.
  6412. Both video inputs must have the same resolution and pixel format for
  6413. this filter to work correctly. Also it assumes that both inputs
  6414. have the same number of frames, which are compared one by one.
  6415. The obtained average PSNR is printed through the logging system.
  6416. The filter stores the accumulated MSE (mean squared error) of each
  6417. frame, and at the end of the processing it is averaged across all frames
  6418. equally, and the following formula is applied to obtain the PSNR:
  6419. @example
  6420. PSNR = 10*log10(MAX^2/MSE)
  6421. @end example
  6422. Where MAX is the average of the maximum values of each component of the
  6423. image.
  6424. The description of the accepted parameters follows.
  6425. @table @option
  6426. @item stats_file, f
  6427. If specified the filter will use the named file to save the PSNR of
  6428. each individual frame.
  6429. @end table
  6430. The file printed if @var{stats_file} is selected, contains a sequence of
  6431. key/value pairs of the form @var{key}:@var{value} for each compared
  6432. couple of frames.
  6433. A description of each shown parameter follows:
  6434. @table @option
  6435. @item n
  6436. sequential number of the input frame, starting from 1
  6437. @item mse_avg
  6438. Mean Square Error pixel-by-pixel average difference of the compared
  6439. frames, averaged over all the image components.
  6440. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  6441. Mean Square Error pixel-by-pixel average difference of the compared
  6442. frames for the component specified by the suffix.
  6443. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  6444. Peak Signal to Noise ratio of the compared frames for the component
  6445. specified by the suffix.
  6446. @end table
  6447. For example:
  6448. @example
  6449. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  6450. [main][ref] psnr="stats_file=stats.log" [out]
  6451. @end example
  6452. On this example the input file being processed is compared with the
  6453. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  6454. is stored in @file{stats.log}.
  6455. @anchor{pullup}
  6456. @section pullup
  6457. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  6458. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  6459. content.
  6460. The pullup filter is designed to take advantage of future context in making
  6461. its decisions. This filter is stateless in the sense that it does not lock
  6462. onto a pattern to follow, but it instead looks forward to the following
  6463. fields in order to identify matches and rebuild progressive frames.
  6464. To produce content with an even framerate, insert the fps filter after
  6465. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  6466. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  6467. The filter accepts the following options:
  6468. @table @option
  6469. @item jl
  6470. @item jr
  6471. @item jt
  6472. @item jb
  6473. These options set the amount of "junk" to ignore at the left, right, top, and
  6474. bottom of the image, respectively. Left and right are in units of 8 pixels,
  6475. while top and bottom are in units of 2 lines.
  6476. The default is 8 pixels on each side.
  6477. @item sb
  6478. Set the strict breaks. Setting this option to 1 will reduce the chances of
  6479. filter generating an occasional mismatched frame, but it may also cause an
  6480. excessive number of frames to be dropped during high motion sequences.
  6481. Conversely, setting it to -1 will make filter match fields more easily.
  6482. This may help processing of video where there is slight blurring between
  6483. the fields, but may also cause there to be interlaced frames in the output.
  6484. Default value is @code{0}.
  6485. @item mp
  6486. Set the metric plane to use. It accepts the following values:
  6487. @table @samp
  6488. @item l
  6489. Use luma plane.
  6490. @item u
  6491. Use chroma blue plane.
  6492. @item v
  6493. Use chroma red plane.
  6494. @end table
  6495. This option may be set to use chroma plane instead of the default luma plane
  6496. for doing filter's computations. This may improve accuracy on very clean
  6497. source material, but more likely will decrease accuracy, especially if there
  6498. is chroma noise (rainbow effect) or any grayscale video.
  6499. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  6500. load and make pullup usable in realtime on slow machines.
  6501. @end table
  6502. For best results (without duplicated frames in the output file) it is
  6503. necessary to change the output frame rate. For example, to inverse
  6504. telecine NTSC input:
  6505. @example
  6506. ffmpeg -i input -vf pullup -r 24000/1001 ...
  6507. @end example
  6508. @section qp
  6509. Change video quantization parameters (QP).
  6510. The filter accepts the following option:
  6511. @table @option
  6512. @item qp
  6513. Set expression for quantization parameter.
  6514. @end table
  6515. The expression is evaluated through the eval API and can contain, among others,
  6516. the following constants:
  6517. @table @var
  6518. @item known
  6519. 1 if index is not 129, 0 otherwise.
  6520. @item qp
  6521. Sequentional index starting from -129 to 128.
  6522. @end table
  6523. @subsection Examples
  6524. @itemize
  6525. @item
  6526. Some equation like:
  6527. @example
  6528. qp=2+2*sin(PI*qp)
  6529. @end example
  6530. @end itemize
  6531. @section random
  6532. Flush video frames from internal cache of frames into a random order.
  6533. No frame is discarded.
  6534. Inspired by @ref{frei0r} nervous filter.
  6535. @table @option
  6536. @item frames
  6537. Set size in number of frames of internal cache, in range from @code{2} to
  6538. @code{512}. Default is @code{30}.
  6539. @item seed
  6540. Set seed for random number generator, must be an integer included between
  6541. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  6542. less than @code{0}, the filter will try to use a good random seed on a
  6543. best effort basis.
  6544. @end table
  6545. @section removegrain
  6546. The removegrain filter is a spatial denoiser for progressive video.
  6547. @table @option
  6548. @item m0
  6549. Set mode for the first plane.
  6550. @item m1
  6551. Set mode for the second plane.
  6552. @item m2
  6553. Set mode for the third plane.
  6554. @item m3
  6555. Set mode for the fourth plane.
  6556. @end table
  6557. Range of mode is from 0 to 24. Description of each mode follows:
  6558. @table @var
  6559. @item 0
  6560. Leave input plane unchanged. Default.
  6561. @item 1
  6562. Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
  6563. @item 2
  6564. Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
  6565. @item 3
  6566. Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
  6567. @item 4
  6568. Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
  6569. This is equivalent to a median filter.
  6570. @item 5
  6571. Line-sensitive clipping giving the minimal change.
  6572. @item 6
  6573. Line-sensitive clipping, intermediate.
  6574. @item 7
  6575. Line-sensitive clipping, intermediate.
  6576. @item 8
  6577. Line-sensitive clipping, intermediate.
  6578. @item 9
  6579. Line-sensitive clipping on a line where the neighbours pixels are the closest.
  6580. @item 10
  6581. Replaces the target pixel with the closest neighbour.
  6582. @item 11
  6583. [1 2 1] horizontal and vertical kernel blur.
  6584. @item 12
  6585. Same as mode 11.
  6586. @item 13
  6587. Bob mode, interpolates top field from the line where the neighbours
  6588. pixels are the closest.
  6589. @item 14
  6590. Bob mode, interpolates bottom field from the line where the neighbours
  6591. pixels are the closest.
  6592. @item 15
  6593. Bob mode, interpolates top field. Same as 13 but with a more complicated
  6594. interpolation formula.
  6595. @item 16
  6596. Bob mode, interpolates bottom field. Same as 14 but with a more complicated
  6597. interpolation formula.
  6598. @item 17
  6599. Clips the pixel with the minimum and maximum of respectively the maximum and
  6600. minimum of each pair of opposite neighbour pixels.
  6601. @item 18
  6602. Line-sensitive clipping using opposite neighbours whose greatest distance from
  6603. the current pixel is minimal.
  6604. @item 19
  6605. Replaces the pixel with the average of its 8 neighbours.
  6606. @item 20
  6607. Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
  6608. @item 21
  6609. Clips pixels using the averages of opposite neighbour.
  6610. @item 22
  6611. Same as mode 21 but simpler and faster.
  6612. @item 23
  6613. Small edge and halo removal, but reputed useless.
  6614. @item 24
  6615. Similar as 23.
  6616. @end table
  6617. @section removelogo
  6618. Suppress a TV station logo, using an image file to determine which
  6619. pixels comprise the logo. It works by filling in the pixels that
  6620. comprise the logo with neighboring pixels.
  6621. The filter accepts the following options:
  6622. @table @option
  6623. @item filename, f
  6624. Set the filter bitmap file, which can be any image format supported by
  6625. libavformat. The width and height of the image file must match those of the
  6626. video stream being processed.
  6627. @end table
  6628. Pixels in the provided bitmap image with a value of zero are not
  6629. considered part of the logo, non-zero pixels are considered part of
  6630. the logo. If you use white (255) for the logo and black (0) for the
  6631. rest, you will be safe. For making the filter bitmap, it is
  6632. recommended to take a screen capture of a black frame with the logo
  6633. visible, and then using a threshold filter followed by the erode
  6634. filter once or twice.
  6635. If needed, little splotches can be fixed manually. Remember that if
  6636. logo pixels are not covered, the filter quality will be much
  6637. reduced. Marking too many pixels as part of the logo does not hurt as
  6638. much, but it will increase the amount of blurring needed to cover over
  6639. the image and will destroy more information than necessary, and extra
  6640. pixels will slow things down on a large logo.
  6641. @section repeatfields
  6642. This filter uses the repeat_field flag from the Video ES headers and hard repeats
  6643. fields based on its value.
  6644. @section reverse, areverse
  6645. Reverse a clip.
  6646. Warning: This filter requires memory to buffer the entire clip, so trimming
  6647. is suggested.
  6648. @subsection Examples
  6649. @itemize
  6650. @item
  6651. Take the first 5 seconds of a clip, and reverse it.
  6652. @example
  6653. trim=end=5,reverse
  6654. @end example
  6655. @end itemize
  6656. @section rotate
  6657. Rotate video by an arbitrary angle expressed in radians.
  6658. The filter accepts the following options:
  6659. A description of the optional parameters follows.
  6660. @table @option
  6661. @item angle, a
  6662. Set an expression for the angle by which to rotate the input video
  6663. clockwise, expressed as a number of radians. A negative value will
  6664. result in a counter-clockwise rotation. By default it is set to "0".
  6665. This expression is evaluated for each frame.
  6666. @item out_w, ow
  6667. Set the output width expression, default value is "iw".
  6668. This expression is evaluated just once during configuration.
  6669. @item out_h, oh
  6670. Set the output height expression, default value is "ih".
  6671. This expression is evaluated just once during configuration.
  6672. @item bilinear
  6673. Enable bilinear interpolation if set to 1, a value of 0 disables
  6674. it. Default value is 1.
  6675. @item fillcolor, c
  6676. Set the color used to fill the output area not covered by the rotated
  6677. image. For the general syntax of this option, check the "Color" section in the
  6678. ffmpeg-utils manual. If the special value "none" is selected then no
  6679. background is printed (useful for example if the background is never shown).
  6680. Default value is "black".
  6681. @end table
  6682. The expressions for the angle and the output size can contain the
  6683. following constants and functions:
  6684. @table @option
  6685. @item n
  6686. sequential number of the input frame, starting from 0. It is always NAN
  6687. before the first frame is filtered.
  6688. @item t
  6689. time in seconds of the input frame, it is set to 0 when the filter is
  6690. configured. It is always NAN before the first frame is filtered.
  6691. @item hsub
  6692. @item vsub
  6693. horizontal and vertical chroma subsample values. For example for the
  6694. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6695. @item in_w, iw
  6696. @item in_h, ih
  6697. the input video width and height
  6698. @item out_w, ow
  6699. @item out_h, oh
  6700. the output width and height, that is the size of the padded area as
  6701. specified by the @var{width} and @var{height} expressions
  6702. @item rotw(a)
  6703. @item roth(a)
  6704. the minimal width/height required for completely containing the input
  6705. video rotated by @var{a} radians.
  6706. These are only available when computing the @option{out_w} and
  6707. @option{out_h} expressions.
  6708. @end table
  6709. @subsection Examples
  6710. @itemize
  6711. @item
  6712. Rotate the input by PI/6 radians clockwise:
  6713. @example
  6714. rotate=PI/6
  6715. @end example
  6716. @item
  6717. Rotate the input by PI/6 radians counter-clockwise:
  6718. @example
  6719. rotate=-PI/6
  6720. @end example
  6721. @item
  6722. Rotate the input by 45 degrees clockwise:
  6723. @example
  6724. rotate=45*PI/180
  6725. @end example
  6726. @item
  6727. Apply a constant rotation with period T, starting from an angle of PI/3:
  6728. @example
  6729. rotate=PI/3+2*PI*t/T
  6730. @end example
  6731. @item
  6732. Make the input video rotation oscillating with a period of T
  6733. seconds and an amplitude of A radians:
  6734. @example
  6735. rotate=A*sin(2*PI/T*t)
  6736. @end example
  6737. @item
  6738. Rotate the video, output size is chosen so that the whole rotating
  6739. input video is always completely contained in the output:
  6740. @example
  6741. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  6742. @end example
  6743. @item
  6744. Rotate the video, reduce the output size so that no background is ever
  6745. shown:
  6746. @example
  6747. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  6748. @end example
  6749. @end itemize
  6750. @subsection Commands
  6751. The filter supports the following commands:
  6752. @table @option
  6753. @item a, angle
  6754. Set the angle expression.
  6755. The command accepts the same syntax of the corresponding option.
  6756. If the specified expression is not valid, it is kept at its current
  6757. value.
  6758. @end table
  6759. @section sab
  6760. Apply Shape Adaptive Blur.
  6761. The filter accepts the following options:
  6762. @table @option
  6763. @item luma_radius, lr
  6764. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  6765. value is 1.0. A greater value will result in a more blurred image, and
  6766. in slower processing.
  6767. @item luma_pre_filter_radius, lpfr
  6768. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  6769. value is 1.0.
  6770. @item luma_strength, ls
  6771. Set luma maximum difference between pixels to still be considered, must
  6772. be a value in the 0.1-100.0 range, default value is 1.0.
  6773. @item chroma_radius, cr
  6774. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  6775. greater value will result in a more blurred image, and in slower
  6776. processing.
  6777. @item chroma_pre_filter_radius, cpfr
  6778. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  6779. @item chroma_strength, cs
  6780. Set chroma maximum difference between pixels to still be considered,
  6781. must be a value in the 0.1-100.0 range.
  6782. @end table
  6783. Each chroma option value, if not explicitly specified, is set to the
  6784. corresponding luma option value.
  6785. @anchor{scale}
  6786. @section scale
  6787. Scale (resize) the input video, using the libswscale library.
  6788. The scale filter forces the output display aspect ratio to be the same
  6789. of the input, by changing the output sample aspect ratio.
  6790. If the input image format is different from the format requested by
  6791. the next filter, the scale filter will convert the input to the
  6792. requested format.
  6793. @subsection Options
  6794. The filter accepts the following options, or any of the options
  6795. supported by the libswscale scaler.
  6796. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  6797. the complete list of scaler options.
  6798. @table @option
  6799. @item width, w
  6800. @item height, h
  6801. Set the output video dimension expression. Default value is the input
  6802. dimension.
  6803. If the value is 0, the input width is used for the output.
  6804. If one of the values is -1, the scale filter will use a value that
  6805. maintains the aspect ratio of the input image, calculated from the
  6806. other specified dimension. If both of them are -1, the input size is
  6807. used
  6808. If one of the values is -n with n > 1, the scale filter will also use a value
  6809. that maintains the aspect ratio of the input image, calculated from the other
  6810. specified dimension. After that it will, however, make sure that the calculated
  6811. dimension is divisible by n and adjust the value if necessary.
  6812. See below for the list of accepted constants for use in the dimension
  6813. expression.
  6814. @item interl
  6815. Set the interlacing mode. It accepts the following values:
  6816. @table @samp
  6817. @item 1
  6818. Force interlaced aware scaling.
  6819. @item 0
  6820. Do not apply interlaced scaling.
  6821. @item -1
  6822. Select interlaced aware scaling depending on whether the source frames
  6823. are flagged as interlaced or not.
  6824. @end table
  6825. Default value is @samp{0}.
  6826. @item flags
  6827. Set libswscale scaling flags. See
  6828. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  6829. complete list of values. If not explicitly specified the filter applies
  6830. the default flags.
  6831. @item size, s
  6832. Set the video size. For the syntax of this option, check the
  6833. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  6834. @item in_color_matrix
  6835. @item out_color_matrix
  6836. Set in/output YCbCr color space type.
  6837. This allows the autodetected value to be overridden as well as allows forcing
  6838. a specific value used for the output and encoder.
  6839. If not specified, the color space type depends on the pixel format.
  6840. Possible values:
  6841. @table @samp
  6842. @item auto
  6843. Choose automatically.
  6844. @item bt709
  6845. Format conforming to International Telecommunication Union (ITU)
  6846. Recommendation BT.709.
  6847. @item fcc
  6848. Set color space conforming to the United States Federal Communications
  6849. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  6850. @item bt601
  6851. Set color space conforming to:
  6852. @itemize
  6853. @item
  6854. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  6855. @item
  6856. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  6857. @item
  6858. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  6859. @end itemize
  6860. @item smpte240m
  6861. Set color space conforming to SMPTE ST 240:1999.
  6862. @end table
  6863. @item in_range
  6864. @item out_range
  6865. Set in/output YCbCr sample range.
  6866. This allows the autodetected value to be overridden as well as allows forcing
  6867. a specific value used for the output and encoder. If not specified, the
  6868. range depends on the pixel format. Possible values:
  6869. @table @samp
  6870. @item auto
  6871. Choose automatically.
  6872. @item jpeg/full/pc
  6873. Set full range (0-255 in case of 8-bit luma).
  6874. @item mpeg/tv
  6875. Set "MPEG" range (16-235 in case of 8-bit luma).
  6876. @end table
  6877. @item force_original_aspect_ratio
  6878. Enable decreasing or increasing output video width or height if necessary to
  6879. keep the original aspect ratio. Possible values:
  6880. @table @samp
  6881. @item disable
  6882. Scale the video as specified and disable this feature.
  6883. @item decrease
  6884. The output video dimensions will automatically be decreased if needed.
  6885. @item increase
  6886. The output video dimensions will automatically be increased if needed.
  6887. @end table
  6888. One useful instance of this option is that when you know a specific device's
  6889. maximum allowed resolution, you can use this to limit the output video to
  6890. that, while retaining the aspect ratio. For example, device A allows
  6891. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  6892. decrease) and specifying 1280x720 to the command line makes the output
  6893. 1280x533.
  6894. Please note that this is a different thing than specifying -1 for @option{w}
  6895. or @option{h}, you still need to specify the output resolution for this option
  6896. to work.
  6897. @end table
  6898. The values of the @option{w} and @option{h} options are expressions
  6899. containing the following constants:
  6900. @table @var
  6901. @item in_w
  6902. @item in_h
  6903. The input width and height
  6904. @item iw
  6905. @item ih
  6906. These are the same as @var{in_w} and @var{in_h}.
  6907. @item out_w
  6908. @item out_h
  6909. The output (scaled) width and height
  6910. @item ow
  6911. @item oh
  6912. These are the same as @var{out_w} and @var{out_h}
  6913. @item a
  6914. The same as @var{iw} / @var{ih}
  6915. @item sar
  6916. input sample aspect ratio
  6917. @item dar
  6918. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  6919. @item hsub
  6920. @item vsub
  6921. horizontal and vertical input chroma subsample values. For example for the
  6922. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6923. @item ohsub
  6924. @item ovsub
  6925. horizontal and vertical output chroma subsample values. For example for the
  6926. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6927. @end table
  6928. @subsection Examples
  6929. @itemize
  6930. @item
  6931. Scale the input video to a size of 200x100
  6932. @example
  6933. scale=w=200:h=100
  6934. @end example
  6935. This is equivalent to:
  6936. @example
  6937. scale=200:100
  6938. @end example
  6939. or:
  6940. @example
  6941. scale=200x100
  6942. @end example
  6943. @item
  6944. Specify a size abbreviation for the output size:
  6945. @example
  6946. scale=qcif
  6947. @end example
  6948. which can also be written as:
  6949. @example
  6950. scale=size=qcif
  6951. @end example
  6952. @item
  6953. Scale the input to 2x:
  6954. @example
  6955. scale=w=2*iw:h=2*ih
  6956. @end example
  6957. @item
  6958. The above is the same as:
  6959. @example
  6960. scale=2*in_w:2*in_h
  6961. @end example
  6962. @item
  6963. Scale the input to 2x with forced interlaced scaling:
  6964. @example
  6965. scale=2*iw:2*ih:interl=1
  6966. @end example
  6967. @item
  6968. Scale the input to half size:
  6969. @example
  6970. scale=w=iw/2:h=ih/2
  6971. @end example
  6972. @item
  6973. Increase the width, and set the height to the same size:
  6974. @example
  6975. scale=3/2*iw:ow
  6976. @end example
  6977. @item
  6978. Seek Greek harmony:
  6979. @example
  6980. scale=iw:1/PHI*iw
  6981. scale=ih*PHI:ih
  6982. @end example
  6983. @item
  6984. Increase the height, and set the width to 3/2 of the height:
  6985. @example
  6986. scale=w=3/2*oh:h=3/5*ih
  6987. @end example
  6988. @item
  6989. Increase the size, making the size a multiple of the chroma
  6990. subsample values:
  6991. @example
  6992. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  6993. @end example
  6994. @item
  6995. Increase the width to a maximum of 500 pixels,
  6996. keeping the same aspect ratio as the input:
  6997. @example
  6998. scale=w='min(500\, iw*3/2):h=-1'
  6999. @end example
  7000. @end itemize
  7001. @subsection Commands
  7002. This filter supports the following commands:
  7003. @table @option
  7004. @item width, w
  7005. @item height, h
  7006. Set the output video dimension expression.
  7007. The command accepts the same syntax of the corresponding option.
  7008. If the specified expression is not valid, it is kept at its current
  7009. value.
  7010. @end table
  7011. @section scale2ref
  7012. Scale (resize) the input video, based on a reference video.
  7013. See the scale filter for available options, scale2ref supports the same but
  7014. uses the reference video instead of the main input as basis.
  7015. @subsection Examples
  7016. @itemize
  7017. @item
  7018. Scale a subtitle stream to match the main video in size before overlaying
  7019. @example
  7020. 'scale2ref[b][a];[a][b]overlay'
  7021. @end example
  7022. @end itemize
  7023. @section separatefields
  7024. The @code{separatefields} takes a frame-based video input and splits
  7025. each frame into its components fields, producing a new half height clip
  7026. with twice the frame rate and twice the frame count.
  7027. This filter use field-dominance information in frame to decide which
  7028. of each pair of fields to place first in the output.
  7029. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  7030. @section setdar, setsar
  7031. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  7032. output video.
  7033. This is done by changing the specified Sample (aka Pixel) Aspect
  7034. Ratio, according to the following equation:
  7035. @example
  7036. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  7037. @end example
  7038. Keep in mind that the @code{setdar} filter does not modify the pixel
  7039. dimensions of the video frame. Also, the display aspect ratio set by
  7040. this filter may be changed by later filters in the filterchain,
  7041. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  7042. applied.
  7043. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  7044. the filter output video.
  7045. Note that as a consequence of the application of this filter, the
  7046. output display aspect ratio will change according to the equation
  7047. above.
  7048. Keep in mind that the sample aspect ratio set by the @code{setsar}
  7049. filter may be changed by later filters in the filterchain, e.g. if
  7050. another "setsar" or a "setdar" filter is applied.
  7051. It accepts the following parameters:
  7052. @table @option
  7053. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  7054. Set the aspect ratio used by the filter.
  7055. The parameter can be a floating point number string, an expression, or
  7056. a string of the form @var{num}:@var{den}, where @var{num} and
  7057. @var{den} are the numerator and denominator of the aspect ratio. If
  7058. the parameter is not specified, it is assumed the value "0".
  7059. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  7060. should be escaped.
  7061. @item max
  7062. Set the maximum integer value to use for expressing numerator and
  7063. denominator when reducing the expressed aspect ratio to a rational.
  7064. Default value is @code{100}.
  7065. @end table
  7066. The parameter @var{sar} is an expression containing
  7067. the following constants:
  7068. @table @option
  7069. @item E, PI, PHI
  7070. These are approximated values for the mathematical constants e
  7071. (Euler's number), pi (Greek pi), and phi (the golden ratio).
  7072. @item w, h
  7073. The input width and height.
  7074. @item a
  7075. These are the same as @var{w} / @var{h}.
  7076. @item sar
  7077. The input sample aspect ratio.
  7078. @item dar
  7079. The input display aspect ratio. It is the same as
  7080. (@var{w} / @var{h}) * @var{sar}.
  7081. @item hsub, vsub
  7082. Horizontal and vertical chroma subsample values. For example, for the
  7083. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7084. @end table
  7085. @subsection Examples
  7086. @itemize
  7087. @item
  7088. To change the display aspect ratio to 16:9, specify one of the following:
  7089. @example
  7090. setdar=dar=1.77777
  7091. setdar=dar=16/9
  7092. setdar=dar=1.77777
  7093. @end example
  7094. @item
  7095. To change the sample aspect ratio to 10:11, specify:
  7096. @example
  7097. setsar=sar=10/11
  7098. @end example
  7099. @item
  7100. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  7101. 1000 in the aspect ratio reduction, use the command:
  7102. @example
  7103. setdar=ratio=16/9:max=1000
  7104. @end example
  7105. @end itemize
  7106. @anchor{setfield}
  7107. @section setfield
  7108. Force field for the output video frame.
  7109. The @code{setfield} filter marks the interlace type field for the
  7110. output frames. It does not change the input frame, but only sets the
  7111. corresponding property, which affects how the frame is treated by
  7112. following filters (e.g. @code{fieldorder} or @code{yadif}).
  7113. The filter accepts the following options:
  7114. @table @option
  7115. @item mode
  7116. Available values are:
  7117. @table @samp
  7118. @item auto
  7119. Keep the same field property.
  7120. @item bff
  7121. Mark the frame as bottom-field-first.
  7122. @item tff
  7123. Mark the frame as top-field-first.
  7124. @item prog
  7125. Mark the frame as progressive.
  7126. @end table
  7127. @end table
  7128. @section showinfo
  7129. Show a line containing various information for each input video frame.
  7130. The input video is not modified.
  7131. The shown line contains a sequence of key/value pairs of the form
  7132. @var{key}:@var{value}.
  7133. The following values are shown in the output:
  7134. @table @option
  7135. @item n
  7136. The (sequential) number of the input frame, starting from 0.
  7137. @item pts
  7138. The Presentation TimeStamp of the input frame, expressed as a number of
  7139. time base units. The time base unit depends on the filter input pad.
  7140. @item pts_time
  7141. The Presentation TimeStamp of the input frame, expressed as a number of
  7142. seconds.
  7143. @item pos
  7144. The position of the frame in the input stream, or -1 if this information is
  7145. unavailable and/or meaningless (for example in case of synthetic video).
  7146. @item fmt
  7147. The pixel format name.
  7148. @item sar
  7149. The sample aspect ratio of the input frame, expressed in the form
  7150. @var{num}/@var{den}.
  7151. @item s
  7152. The size of the input frame. For the syntax of this option, check the
  7153. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7154. @item i
  7155. The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
  7156. for bottom field first).
  7157. @item iskey
  7158. This is 1 if the frame is a key frame, 0 otherwise.
  7159. @item type
  7160. The picture type of the input frame ("I" for an I-frame, "P" for a
  7161. P-frame, "B" for a B-frame, or "?" for an unknown type).
  7162. Also refer to the documentation of the @code{AVPictureType} enum and of
  7163. the @code{av_get_picture_type_char} function defined in
  7164. @file{libavutil/avutil.h}.
  7165. @item checksum
  7166. The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
  7167. @item plane_checksum
  7168. The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  7169. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
  7170. @end table
  7171. @section showpalette
  7172. Displays the 256 colors palette of each frame. This filter is only relevant for
  7173. @var{pal8} pixel format frames.
  7174. It accepts the following option:
  7175. @table @option
  7176. @item s
  7177. Set the size of the box used to represent one palette color entry. Default is
  7178. @code{30} (for a @code{30x30} pixel box).
  7179. @end table
  7180. @section shuffleplanes
  7181. Reorder and/or duplicate video planes.
  7182. It accepts the following parameters:
  7183. @table @option
  7184. @item map0
  7185. The index of the input plane to be used as the first output plane.
  7186. @item map1
  7187. The index of the input plane to be used as the second output plane.
  7188. @item map2
  7189. The index of the input plane to be used as the third output plane.
  7190. @item map3
  7191. The index of the input plane to be used as the fourth output plane.
  7192. @end table
  7193. The first plane has the index 0. The default is to keep the input unchanged.
  7194. Swap the second and third planes of the input:
  7195. @example
  7196. ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
  7197. @end example
  7198. @anchor{signalstats}
  7199. @section signalstats
  7200. Evaluate various visual metrics that assist in determining issues associated
  7201. with the digitization of analog video media.
  7202. By default the filter will log these metadata values:
  7203. @table @option
  7204. @item YMIN
  7205. Display the minimal Y value contained within the input frame. Expressed in
  7206. range of [0-255].
  7207. @item YLOW
  7208. Display the Y value at the 10% percentile within the input frame. Expressed in
  7209. range of [0-255].
  7210. @item YAVG
  7211. Display the average Y value within the input frame. Expressed in range of
  7212. [0-255].
  7213. @item YHIGH
  7214. Display the Y value at the 90% percentile within the input frame. Expressed in
  7215. range of [0-255].
  7216. @item YMAX
  7217. Display the maximum Y value contained within the input frame. Expressed in
  7218. range of [0-255].
  7219. @item UMIN
  7220. Display the minimal U value contained within the input frame. Expressed in
  7221. range of [0-255].
  7222. @item ULOW
  7223. Display the U value at the 10% percentile within the input frame. Expressed in
  7224. range of [0-255].
  7225. @item UAVG
  7226. Display the average U value within the input frame. Expressed in range of
  7227. [0-255].
  7228. @item UHIGH
  7229. Display the U value at the 90% percentile within the input frame. Expressed in
  7230. range of [0-255].
  7231. @item UMAX
  7232. Display the maximum U value contained within the input frame. Expressed in
  7233. range of [0-255].
  7234. @item VMIN
  7235. Display the minimal V value contained within the input frame. Expressed in
  7236. range of [0-255].
  7237. @item VLOW
  7238. Display the V value at the 10% percentile within the input frame. Expressed in
  7239. range of [0-255].
  7240. @item VAVG
  7241. Display the average V value within the input frame. Expressed in range of
  7242. [0-255].
  7243. @item VHIGH
  7244. Display the V value at the 90% percentile within the input frame. Expressed in
  7245. range of [0-255].
  7246. @item VMAX
  7247. Display the maximum V value contained within the input frame. Expressed in
  7248. range of [0-255].
  7249. @item SATMIN
  7250. Display the minimal saturation value contained within the input frame.
  7251. Expressed in range of [0-~181.02].
  7252. @item SATLOW
  7253. Display the saturation value at the 10% percentile within the input frame.
  7254. Expressed in range of [0-~181.02].
  7255. @item SATAVG
  7256. Display the average saturation value within the input frame. Expressed in range
  7257. of [0-~181.02].
  7258. @item SATHIGH
  7259. Display the saturation value at the 90% percentile within the input frame.
  7260. Expressed in range of [0-~181.02].
  7261. @item SATMAX
  7262. Display the maximum saturation value contained within the input frame.
  7263. Expressed in range of [0-~181.02].
  7264. @item HUEMED
  7265. Display the median value for hue within the input frame. Expressed in range of
  7266. [0-360].
  7267. @item HUEAVG
  7268. Display the average value for hue within the input frame. Expressed in range of
  7269. [0-360].
  7270. @item YDIF
  7271. Display the average of sample value difference between all values of the Y
  7272. plane in the current frame and corresponding values of the previous input frame.
  7273. Expressed in range of [0-255].
  7274. @item UDIF
  7275. Display the average of sample value difference between all values of the U
  7276. plane in the current frame and corresponding values of the previous input frame.
  7277. Expressed in range of [0-255].
  7278. @item VDIF
  7279. Display the average of sample value difference between all values of the V
  7280. plane in the current frame and corresponding values of the previous input frame.
  7281. Expressed in range of [0-255].
  7282. @end table
  7283. The filter accepts the following options:
  7284. @table @option
  7285. @item stat
  7286. @item out
  7287. @option{stat} specify an additional form of image analysis.
  7288. @option{out} output video with the specified type of pixel highlighted.
  7289. Both options accept the following values:
  7290. @table @samp
  7291. @item tout
  7292. Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
  7293. unlike the neighboring pixels of the same field. Examples of temporal outliers
  7294. include the results of video dropouts, head clogs, or tape tracking issues.
  7295. @item vrep
  7296. Identify @var{vertical line repetition}. Vertical line repetition includes
  7297. similar rows of pixels within a frame. In born-digital video vertical line
  7298. repetition is common, but this pattern is uncommon in video digitized from an
  7299. analog source. When it occurs in video that results from the digitization of an
  7300. analog source it can indicate concealment from a dropout compensator.
  7301. @item brng
  7302. Identify pixels that fall outside of legal broadcast range.
  7303. @end table
  7304. @item color, c
  7305. Set the highlight color for the @option{out} option. The default color is
  7306. yellow.
  7307. @end table
  7308. @subsection Examples
  7309. @itemize
  7310. @item
  7311. Output data of various video metrics:
  7312. @example
  7313. ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
  7314. @end example
  7315. @item
  7316. Output specific data about the minimum and maximum values of the Y plane per frame:
  7317. @example
  7318. ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
  7319. @end example
  7320. @item
  7321. Playback video while highlighting pixels that are outside of broadcast range in red.
  7322. @example
  7323. ffplay example.mov -vf signalstats="out=brng:color=red"
  7324. @end example
  7325. @item
  7326. Playback video with signalstats metadata drawn over the frame.
  7327. @example
  7328. ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
  7329. @end example
  7330. The contents of signalstat_drawtext.txt used in the command are:
  7331. @example
  7332. time %@{pts:hms@}
  7333. Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
  7334. U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
  7335. V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
  7336. saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
  7337. @end example
  7338. @end itemize
  7339. @anchor{smartblur}
  7340. @section smartblur
  7341. Blur the input video without impacting the outlines.
  7342. It accepts the following options:
  7343. @table @option
  7344. @item luma_radius, lr
  7345. Set the luma radius. The option value must be a float number in
  7346. the range [0.1,5.0] that specifies the variance of the gaussian filter
  7347. used to blur the image (slower if larger). Default value is 1.0.
  7348. @item luma_strength, ls
  7349. Set the luma strength. The option value must be a float number
  7350. in the range [-1.0,1.0] that configures the blurring. A value included
  7351. in [0.0,1.0] will blur the image whereas a value included in
  7352. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  7353. @item luma_threshold, lt
  7354. Set the luma threshold used as a coefficient to determine
  7355. whether a pixel should be blurred or not. The option value must be an
  7356. integer in the range [-30,30]. A value of 0 will filter all the image,
  7357. a value included in [0,30] will filter flat areas and a value included
  7358. in [-30,0] will filter edges. Default value is 0.
  7359. @item chroma_radius, cr
  7360. Set the chroma radius. The option value must be a float number in
  7361. the range [0.1,5.0] that specifies the variance of the gaussian filter
  7362. used to blur the image (slower if larger). Default value is 1.0.
  7363. @item chroma_strength, cs
  7364. Set the chroma strength. The option value must be a float number
  7365. in the range [-1.0,1.0] that configures the blurring. A value included
  7366. in [0.0,1.0] will blur the image whereas a value included in
  7367. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  7368. @item chroma_threshold, ct
  7369. Set the chroma threshold used as a coefficient to determine
  7370. whether a pixel should be blurred or not. The option value must be an
  7371. integer in the range [-30,30]. A value of 0 will filter all the image,
  7372. a value included in [0,30] will filter flat areas and a value included
  7373. in [-30,0] will filter edges. Default value is 0.
  7374. @end table
  7375. If a chroma option is not explicitly set, the corresponding luma value
  7376. is set.
  7377. @section ssim
  7378. Obtain the SSIM (Structural SImilarity Metric) between two input videos.
  7379. This filter takes in input two input videos, the first input is
  7380. considered the "main" source and is passed unchanged to the
  7381. output. The second input is used as a "reference" video for computing
  7382. the SSIM.
  7383. Both video inputs must have the same resolution and pixel format for
  7384. this filter to work correctly. Also it assumes that both inputs
  7385. have the same number of frames, which are compared one by one.
  7386. The filter stores the calculated SSIM of each frame.
  7387. The description of the accepted parameters follows.
  7388. @table @option
  7389. @item stats_file, f
  7390. If specified the filter will use the named file to save the SSIM of
  7391. each individual frame.
  7392. @end table
  7393. The file printed if @var{stats_file} is selected, contains a sequence of
  7394. key/value pairs of the form @var{key}:@var{value} for each compared
  7395. couple of frames.
  7396. A description of each shown parameter follows:
  7397. @table @option
  7398. @item n
  7399. sequential number of the input frame, starting from 1
  7400. @item Y, U, V, R, G, B
  7401. SSIM of the compared frames for the component specified by the suffix.
  7402. @item All
  7403. SSIM of the compared frames for the whole frame.
  7404. @item dB
  7405. Same as above but in dB representation.
  7406. @end table
  7407. For example:
  7408. @example
  7409. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  7410. [main][ref] ssim="stats_file=stats.log" [out]
  7411. @end example
  7412. On this example the input file being processed is compared with the
  7413. reference file @file{ref_movie.mpg}. The SSIM of each individual frame
  7414. is stored in @file{stats.log}.
  7415. Another example with both psnr and ssim at same time:
  7416. @example
  7417. ffmpeg -i main.mpg -i ref.mpg -lavfi "ssim;[0:v][1:v]psnr" -f null -
  7418. @end example
  7419. @section stereo3d
  7420. Convert between different stereoscopic image formats.
  7421. The filters accept the following options:
  7422. @table @option
  7423. @item in
  7424. Set stereoscopic image format of input.
  7425. Available values for input image formats are:
  7426. @table @samp
  7427. @item sbsl
  7428. side by side parallel (left eye left, right eye right)
  7429. @item sbsr
  7430. side by side crosseye (right eye left, left eye right)
  7431. @item sbs2l
  7432. side by side parallel with half width resolution
  7433. (left eye left, right eye right)
  7434. @item sbs2r
  7435. side by side crosseye with half width resolution
  7436. (right eye left, left eye right)
  7437. @item abl
  7438. above-below (left eye above, right eye below)
  7439. @item abr
  7440. above-below (right eye above, left eye below)
  7441. @item ab2l
  7442. above-below with half height resolution
  7443. (left eye above, right eye below)
  7444. @item ab2r
  7445. above-below with half height resolution
  7446. (right eye above, left eye below)
  7447. @item al
  7448. alternating frames (left eye first, right eye second)
  7449. @item ar
  7450. alternating frames (right eye first, left eye second)
  7451. Default value is @samp{sbsl}.
  7452. @end table
  7453. @item out
  7454. Set stereoscopic image format of output.
  7455. Available values for output image formats are all the input formats as well as:
  7456. @table @samp
  7457. @item arbg
  7458. anaglyph red/blue gray
  7459. (red filter on left eye, blue filter on right eye)
  7460. @item argg
  7461. anaglyph red/green gray
  7462. (red filter on left eye, green filter on right eye)
  7463. @item arcg
  7464. anaglyph red/cyan gray
  7465. (red filter on left eye, cyan filter on right eye)
  7466. @item arch
  7467. anaglyph red/cyan half colored
  7468. (red filter on left eye, cyan filter on right eye)
  7469. @item arcc
  7470. anaglyph red/cyan color
  7471. (red filter on left eye, cyan filter on right eye)
  7472. @item arcd
  7473. anaglyph red/cyan color optimized with the least squares projection of dubois
  7474. (red filter on left eye, cyan filter on right eye)
  7475. @item agmg
  7476. anaglyph green/magenta gray
  7477. (green filter on left eye, magenta filter on right eye)
  7478. @item agmh
  7479. anaglyph green/magenta half colored
  7480. (green filter on left eye, magenta filter on right eye)
  7481. @item agmc
  7482. anaglyph green/magenta colored
  7483. (green filter on left eye, magenta filter on right eye)
  7484. @item agmd
  7485. anaglyph green/magenta color optimized with the least squares projection of dubois
  7486. (green filter on left eye, magenta filter on right eye)
  7487. @item aybg
  7488. anaglyph yellow/blue gray
  7489. (yellow filter on left eye, blue filter on right eye)
  7490. @item aybh
  7491. anaglyph yellow/blue half colored
  7492. (yellow filter on left eye, blue filter on right eye)
  7493. @item aybc
  7494. anaglyph yellow/blue colored
  7495. (yellow filter on left eye, blue filter on right eye)
  7496. @item aybd
  7497. anaglyph yellow/blue color optimized with the least squares projection of dubois
  7498. (yellow filter on left eye, blue filter on right eye)
  7499. @item irl
  7500. interleaved rows (left eye has top row, right eye starts on next row)
  7501. @item irr
  7502. interleaved rows (right eye has top row, left eye starts on next row)
  7503. @item ml
  7504. mono output (left eye only)
  7505. @item mr
  7506. mono output (right eye only)
  7507. @end table
  7508. Default value is @samp{arcd}.
  7509. @end table
  7510. @subsection Examples
  7511. @itemize
  7512. @item
  7513. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  7514. @example
  7515. stereo3d=sbsl:aybd
  7516. @end example
  7517. @item
  7518. Convert input video from above bellow (left eye above, right eye below) to side by side crosseye.
  7519. @example
  7520. stereo3d=abl:sbsr
  7521. @end example
  7522. @end itemize
  7523. @anchor{spp}
  7524. @section spp
  7525. Apply a simple postprocessing filter that compresses and decompresses the image
  7526. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  7527. and average the results.
  7528. The filter accepts the following options:
  7529. @table @option
  7530. @item quality
  7531. Set quality. This option defines the number of levels for averaging. It accepts
  7532. an integer in the range 0-6. If set to @code{0}, the filter will have no
  7533. effect. A value of @code{6} means the higher quality. For each increment of
  7534. that value the speed drops by a factor of approximately 2. Default value is
  7535. @code{3}.
  7536. @item qp
  7537. Force a constant quantization parameter. If not set, the filter will use the QP
  7538. from the video stream (if available).
  7539. @item mode
  7540. Set thresholding mode. Available modes are:
  7541. @table @samp
  7542. @item hard
  7543. Set hard thresholding (default).
  7544. @item soft
  7545. Set soft thresholding (better de-ringing effect, but likely blurrier).
  7546. @end table
  7547. @item use_bframe_qp
  7548. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  7549. option may cause flicker since the B-Frames have often larger QP. Default is
  7550. @code{0} (not enabled).
  7551. @end table
  7552. @anchor{subtitles}
  7553. @section subtitles
  7554. Draw subtitles on top of input video using the libass library.
  7555. To enable compilation of this filter you need to configure FFmpeg with
  7556. @code{--enable-libass}. This filter also requires a build with libavcodec and
  7557. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  7558. Alpha) subtitles format.
  7559. The filter accepts the following options:
  7560. @table @option
  7561. @item filename, f
  7562. Set the filename of the subtitle file to read. It must be specified.
  7563. @item original_size
  7564. Specify the size of the original video, the video for which the ASS file
  7565. was composed. For the syntax of this option, check the
  7566. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7567. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
  7568. correctly scale the fonts if the aspect ratio has been changed.
  7569. @item charenc
  7570. Set subtitles input character encoding. @code{subtitles} filter only. Only
  7571. useful if not UTF-8.
  7572. @item stream_index, si
  7573. Set subtitles stream index. @code{subtitles} filter only.
  7574. @item force_style
  7575. Override default style or script info parameters of the subtitles. It accepts a
  7576. string containing ASS style format @code{KEY=VALUE} couples separated by ",".
  7577. @end table
  7578. If the first key is not specified, it is assumed that the first value
  7579. specifies the @option{filename}.
  7580. For example, to render the file @file{sub.srt} on top of the input
  7581. video, use the command:
  7582. @example
  7583. subtitles=sub.srt
  7584. @end example
  7585. which is equivalent to:
  7586. @example
  7587. subtitles=filename=sub.srt
  7588. @end example
  7589. To render the default subtitles stream from file @file{video.mkv}, use:
  7590. @example
  7591. subtitles=video.mkv
  7592. @end example
  7593. To render the second subtitles stream from that file, use:
  7594. @example
  7595. subtitles=video.mkv:si=1
  7596. @end example
  7597. To make the subtitles stream from @file{sub.srt} appear in transparent green
  7598. @code{DejaVu Serif}, use:
  7599. @example
  7600. subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
  7601. @end example
  7602. @section super2xsai
  7603. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  7604. Interpolate) pixel art scaling algorithm.
  7605. Useful for enlarging pixel art images without reducing sharpness.
  7606. @section swapuv
  7607. Swap U & V plane.
  7608. @section telecine
  7609. Apply telecine process to the video.
  7610. This filter accepts the following options:
  7611. @table @option
  7612. @item first_field
  7613. @table @samp
  7614. @item top, t
  7615. top field first
  7616. @item bottom, b
  7617. bottom field first
  7618. The default value is @code{top}.
  7619. @end table
  7620. @item pattern
  7621. A string of numbers representing the pulldown pattern you wish to apply.
  7622. The default value is @code{23}.
  7623. @end table
  7624. @example
  7625. Some typical patterns:
  7626. NTSC output (30i):
  7627. 27.5p: 32222
  7628. 24p: 23 (classic)
  7629. 24p: 2332 (preferred)
  7630. 20p: 33
  7631. 18p: 334
  7632. 16p: 3444
  7633. PAL output (25i):
  7634. 27.5p: 12222
  7635. 24p: 222222222223 ("Euro pulldown")
  7636. 16.67p: 33
  7637. 16p: 33333334
  7638. @end example
  7639. @section thumbnail
  7640. Select the most representative frame in a given sequence of consecutive frames.
  7641. The filter accepts the following options:
  7642. @table @option
  7643. @item n
  7644. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  7645. will pick one of them, and then handle the next batch of @var{n} frames until
  7646. the end. Default is @code{100}.
  7647. @end table
  7648. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  7649. value will result in a higher memory usage, so a high value is not recommended.
  7650. @subsection Examples
  7651. @itemize
  7652. @item
  7653. Extract one picture each 50 frames:
  7654. @example
  7655. thumbnail=50
  7656. @end example
  7657. @item
  7658. Complete example of a thumbnail creation with @command{ffmpeg}:
  7659. @example
  7660. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  7661. @end example
  7662. @end itemize
  7663. @section tile
  7664. Tile several successive frames together.
  7665. The filter accepts the following options:
  7666. @table @option
  7667. @item layout
  7668. Set the grid size (i.e. the number of lines and columns). For the syntax of
  7669. this option, check the
  7670. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7671. @item nb_frames
  7672. Set the maximum number of frames to render in the given area. It must be less
  7673. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  7674. the area will be used.
  7675. @item margin
  7676. Set the outer border margin in pixels.
  7677. @item padding
  7678. Set the inner border thickness (i.e. the number of pixels between frames). For
  7679. more advanced padding options (such as having different values for the edges),
  7680. refer to the pad video filter.
  7681. @item color
  7682. Specify the color of the unused area. For the syntax of this option, check the
  7683. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  7684. is "black".
  7685. @end table
  7686. @subsection Examples
  7687. @itemize
  7688. @item
  7689. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  7690. @example
  7691. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  7692. @end example
  7693. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  7694. duplicating each output frame to accommodate the originally detected frame
  7695. rate.
  7696. @item
  7697. Display @code{5} pictures in an area of @code{3x2} frames,
  7698. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  7699. mixed flat and named options:
  7700. @example
  7701. tile=3x2:nb_frames=5:padding=7:margin=2
  7702. @end example
  7703. @end itemize
  7704. @section tinterlace
  7705. Perform various types of temporal field interlacing.
  7706. Frames are counted starting from 1, so the first input frame is
  7707. considered odd.
  7708. The filter accepts the following options:
  7709. @table @option
  7710. @item mode
  7711. Specify the mode of the interlacing. This option can also be specified
  7712. as a value alone. See below for a list of values for this option.
  7713. Available values are:
  7714. @table @samp
  7715. @item merge, 0
  7716. Move odd frames into the upper field, even into the lower field,
  7717. generating a double height frame at half frame rate.
  7718. @example
  7719. ------> time
  7720. Input:
  7721. Frame 1 Frame 2 Frame 3 Frame 4
  7722. 11111 22222 33333 44444
  7723. 11111 22222 33333 44444
  7724. 11111 22222 33333 44444
  7725. 11111 22222 33333 44444
  7726. Output:
  7727. 11111 33333
  7728. 22222 44444
  7729. 11111 33333
  7730. 22222 44444
  7731. 11111 33333
  7732. 22222 44444
  7733. 11111 33333
  7734. 22222 44444
  7735. @end example
  7736. @item drop_odd, 1
  7737. Only output even frames, odd frames are dropped, generating a frame with
  7738. unchanged height at half frame rate.
  7739. @example
  7740. ------> time
  7741. Input:
  7742. Frame 1 Frame 2 Frame 3 Frame 4
  7743. 11111 22222 33333 44444
  7744. 11111 22222 33333 44444
  7745. 11111 22222 33333 44444
  7746. 11111 22222 33333 44444
  7747. Output:
  7748. 22222 44444
  7749. 22222 44444
  7750. 22222 44444
  7751. 22222 44444
  7752. @end example
  7753. @item drop_even, 2
  7754. Only output odd frames, even frames are dropped, generating a frame with
  7755. unchanged height at half frame rate.
  7756. @example
  7757. ------> time
  7758. Input:
  7759. Frame 1 Frame 2 Frame 3 Frame 4
  7760. 11111 22222 33333 44444
  7761. 11111 22222 33333 44444
  7762. 11111 22222 33333 44444
  7763. 11111 22222 33333 44444
  7764. Output:
  7765. 11111 33333
  7766. 11111 33333
  7767. 11111 33333
  7768. 11111 33333
  7769. @end example
  7770. @item pad, 3
  7771. Expand each frame to full height, but pad alternate lines with black,
  7772. generating a frame with double height at the same input frame rate.
  7773. @example
  7774. ------> time
  7775. Input:
  7776. Frame 1 Frame 2 Frame 3 Frame 4
  7777. 11111 22222 33333 44444
  7778. 11111 22222 33333 44444
  7779. 11111 22222 33333 44444
  7780. 11111 22222 33333 44444
  7781. Output:
  7782. 11111 ..... 33333 .....
  7783. ..... 22222 ..... 44444
  7784. 11111 ..... 33333 .....
  7785. ..... 22222 ..... 44444
  7786. 11111 ..... 33333 .....
  7787. ..... 22222 ..... 44444
  7788. 11111 ..... 33333 .....
  7789. ..... 22222 ..... 44444
  7790. @end example
  7791. @item interleave_top, 4
  7792. Interleave the upper field from odd frames with the lower field from
  7793. even frames, generating a frame with unchanged height at half frame rate.
  7794. @example
  7795. ------> time
  7796. Input:
  7797. Frame 1 Frame 2 Frame 3 Frame 4
  7798. 11111<- 22222 33333<- 44444
  7799. 11111 22222<- 33333 44444<-
  7800. 11111<- 22222 33333<- 44444
  7801. 11111 22222<- 33333 44444<-
  7802. Output:
  7803. 11111 33333
  7804. 22222 44444
  7805. 11111 33333
  7806. 22222 44444
  7807. @end example
  7808. @item interleave_bottom, 5
  7809. Interleave the lower field from odd frames with the upper field from
  7810. even frames, generating a frame with unchanged height at half frame rate.
  7811. @example
  7812. ------> time
  7813. Input:
  7814. Frame 1 Frame 2 Frame 3 Frame 4
  7815. 11111 22222<- 33333 44444<-
  7816. 11111<- 22222 33333<- 44444
  7817. 11111 22222<- 33333 44444<-
  7818. 11111<- 22222 33333<- 44444
  7819. Output:
  7820. 22222 44444
  7821. 11111 33333
  7822. 22222 44444
  7823. 11111 33333
  7824. @end example
  7825. @item interlacex2, 6
  7826. Double frame rate with unchanged height. Frames are inserted each
  7827. containing the second temporal field from the previous input frame and
  7828. the first temporal field from the next input frame. This mode relies on
  7829. the top_field_first flag. Useful for interlaced video displays with no
  7830. field synchronisation.
  7831. @example
  7832. ------> time
  7833. Input:
  7834. Frame 1 Frame 2 Frame 3 Frame 4
  7835. 11111 22222 33333 44444
  7836. 11111 22222 33333 44444
  7837. 11111 22222 33333 44444
  7838. 11111 22222 33333 44444
  7839. Output:
  7840. 11111 22222 22222 33333 33333 44444 44444
  7841. 11111 11111 22222 22222 33333 33333 44444
  7842. 11111 22222 22222 33333 33333 44444 44444
  7843. 11111 11111 22222 22222 33333 33333 44444
  7844. @end example
  7845. @end table
  7846. Numeric values are deprecated but are accepted for backward
  7847. compatibility reasons.
  7848. Default mode is @code{merge}.
  7849. @item flags
  7850. Specify flags influencing the filter process.
  7851. Available value for @var{flags} is:
  7852. @table @option
  7853. @item low_pass_filter, vlfp
  7854. Enable vertical low-pass filtering in the filter.
  7855. Vertical low-pass filtering is required when creating an interlaced
  7856. destination from a progressive source which contains high-frequency
  7857. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  7858. patterning.
  7859. Vertical low-pass filtering can only be enabled for @option{mode}
  7860. @var{interleave_top} and @var{interleave_bottom}.
  7861. @end table
  7862. @end table
  7863. @section transpose
  7864. Transpose rows with columns in the input video and optionally flip it.
  7865. It accepts the following parameters:
  7866. @table @option
  7867. @item dir
  7868. Specify the transposition direction.
  7869. Can assume the following values:
  7870. @table @samp
  7871. @item 0, 4, cclock_flip
  7872. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  7873. @example
  7874. L.R L.l
  7875. . . -> . .
  7876. l.r R.r
  7877. @end example
  7878. @item 1, 5, clock
  7879. Rotate by 90 degrees clockwise, that is:
  7880. @example
  7881. L.R l.L
  7882. . . -> . .
  7883. l.r r.R
  7884. @end example
  7885. @item 2, 6, cclock
  7886. Rotate by 90 degrees counterclockwise, that is:
  7887. @example
  7888. L.R R.r
  7889. . . -> . .
  7890. l.r L.l
  7891. @end example
  7892. @item 3, 7, clock_flip
  7893. Rotate by 90 degrees clockwise and vertically flip, that is:
  7894. @example
  7895. L.R r.R
  7896. . . -> . .
  7897. l.r l.L
  7898. @end example
  7899. @end table
  7900. For values between 4-7, the transposition is only done if the input
  7901. video geometry is portrait and not landscape. These values are
  7902. deprecated, the @code{passthrough} option should be used instead.
  7903. Numerical values are deprecated, and should be dropped in favor of
  7904. symbolic constants.
  7905. @item passthrough
  7906. Do not apply the transposition if the input geometry matches the one
  7907. specified by the specified value. It accepts the following values:
  7908. @table @samp
  7909. @item none
  7910. Always apply transposition.
  7911. @item portrait
  7912. Preserve portrait geometry (when @var{height} >= @var{width}).
  7913. @item landscape
  7914. Preserve landscape geometry (when @var{width} >= @var{height}).
  7915. @end table
  7916. Default value is @code{none}.
  7917. @end table
  7918. For example to rotate by 90 degrees clockwise and preserve portrait
  7919. layout:
  7920. @example
  7921. transpose=dir=1:passthrough=portrait
  7922. @end example
  7923. The command above can also be specified as:
  7924. @example
  7925. transpose=1:portrait
  7926. @end example
  7927. @section trim
  7928. Trim the input so that the output contains one continuous subpart of the input.
  7929. It accepts the following parameters:
  7930. @table @option
  7931. @item start
  7932. Specify the time of the start of the kept section, i.e. the frame with the
  7933. timestamp @var{start} will be the first frame in the output.
  7934. @item end
  7935. Specify the time of the first frame that will be dropped, i.e. the frame
  7936. immediately preceding the one with the timestamp @var{end} will be the last
  7937. frame in the output.
  7938. @item start_pts
  7939. This is the same as @var{start}, except this option sets the start timestamp
  7940. in timebase units instead of seconds.
  7941. @item end_pts
  7942. This is the same as @var{end}, except this option sets the end timestamp
  7943. in timebase units instead of seconds.
  7944. @item duration
  7945. The maximum duration of the output in seconds.
  7946. @item start_frame
  7947. The number of the first frame that should be passed to the output.
  7948. @item end_frame
  7949. The number of the first frame that should be dropped.
  7950. @end table
  7951. @option{start}, @option{end}, and @option{duration} are expressed as time
  7952. duration specifications; see
  7953. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  7954. for the accepted syntax.
  7955. Note that the first two sets of the start/end options and the @option{duration}
  7956. option look at the frame timestamp, while the _frame variants simply count the
  7957. frames that pass through the filter. Also note that this filter does not modify
  7958. the timestamps. If you wish for the output timestamps to start at zero, insert a
  7959. setpts filter after the trim filter.
  7960. If multiple start or end options are set, this filter tries to be greedy and
  7961. keep all the frames that match at least one of the specified constraints. To keep
  7962. only the part that matches all the constraints at once, chain multiple trim
  7963. filters.
  7964. The defaults are such that all the input is kept. So it is possible to set e.g.
  7965. just the end values to keep everything before the specified time.
  7966. Examples:
  7967. @itemize
  7968. @item
  7969. Drop everything except the second minute of input:
  7970. @example
  7971. ffmpeg -i INPUT -vf trim=60:120
  7972. @end example
  7973. @item
  7974. Keep only the first second:
  7975. @example
  7976. ffmpeg -i INPUT -vf trim=duration=1
  7977. @end example
  7978. @end itemize
  7979. @anchor{unsharp}
  7980. @section unsharp
  7981. Sharpen or blur the input video.
  7982. It accepts the following parameters:
  7983. @table @option
  7984. @item luma_msize_x, lx
  7985. Set the luma matrix horizontal size. It must be an odd integer between
  7986. 3 and 63. The default value is 5.
  7987. @item luma_msize_y, ly
  7988. Set the luma matrix vertical size. It must be an odd integer between 3
  7989. and 63. The default value is 5.
  7990. @item luma_amount, la
  7991. Set the luma effect strength. It must be a floating point number, reasonable
  7992. values lay between -1.5 and 1.5.
  7993. Negative values will blur the input video, while positive values will
  7994. sharpen it, a value of zero will disable the effect.
  7995. Default value is 1.0.
  7996. @item chroma_msize_x, cx
  7997. Set the chroma matrix horizontal size. It must be an odd integer
  7998. between 3 and 63. The default value is 5.
  7999. @item chroma_msize_y, cy
  8000. Set the chroma matrix vertical size. It must be an odd integer
  8001. between 3 and 63. The default value is 5.
  8002. @item chroma_amount, ca
  8003. Set the chroma effect strength. It must be a floating point number, reasonable
  8004. values lay between -1.5 and 1.5.
  8005. Negative values will blur the input video, while positive values will
  8006. sharpen it, a value of zero will disable the effect.
  8007. Default value is 0.0.
  8008. @item opencl
  8009. If set to 1, specify using OpenCL capabilities, only available if
  8010. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  8011. @end table
  8012. All parameters are optional and default to the equivalent of the
  8013. string '5:5:1.0:5:5:0.0'.
  8014. @subsection Examples
  8015. @itemize
  8016. @item
  8017. Apply strong luma sharpen effect:
  8018. @example
  8019. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  8020. @end example
  8021. @item
  8022. Apply a strong blur of both luma and chroma parameters:
  8023. @example
  8024. unsharp=7:7:-2:7:7:-2
  8025. @end example
  8026. @end itemize
  8027. @section uspp
  8028. Apply ultra slow/simple postprocessing filter that compresses and decompresses
  8029. the image at several (or - in the case of @option{quality} level @code{8} - all)
  8030. shifts and average the results.
  8031. The way this differs from the behavior of spp is that uspp actually encodes &
  8032. decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
  8033. DCT similar to MJPEG.
  8034. The filter accepts the following options:
  8035. @table @option
  8036. @item quality
  8037. Set quality. This option defines the number of levels for averaging. It accepts
  8038. an integer in the range 0-8. If set to @code{0}, the filter will have no
  8039. effect. A value of @code{8} means the higher quality. For each increment of
  8040. that value the speed drops by a factor of approximately 2. Default value is
  8041. @code{3}.
  8042. @item qp
  8043. Force a constant quantization parameter. If not set, the filter will use the QP
  8044. from the video stream (if available).
  8045. @end table
  8046. @section vectorscope
  8047. Display 2 color component values in the two dimensional graph (which is called
  8048. a vectorscope).
  8049. This filter accepts the following options:
  8050. @table @option
  8051. @item mode
  8052. Set vectorscope mode.
  8053. It accepts the following values:
  8054. @table @samp
  8055. @item gray
  8056. Gray values are displayed on graph, higher brightness means more pixels have
  8057. same component color value on location in graph. This is the default mode.
  8058. @item color
  8059. Gray values are displayed on graph. Surrounding pixels values which are not
  8060. present in video frame are drawn in gradient of 2 color components which are
  8061. set by option @code{x} and @code{y}.
  8062. @item color2
  8063. Actual color components values present in video frame are displayed on graph.
  8064. @item color3
  8065. Similar as color2 but higher frequency of same values @code{x} and @code{y}
  8066. on graph increases value of another color component, which is luminance by
  8067. default values of @code{x} and @code{y}.
  8068. @end table
  8069. @item x
  8070. Set which color component will be represented on X-axis. Default is @code{1}.
  8071. @item y
  8072. Set which color component will be represented on Y-axis. Default is @code{2}.
  8073. @end table
  8074. @anchor{vidstabdetect}
  8075. @section vidstabdetect
  8076. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  8077. @ref{vidstabtransform} for pass 2.
  8078. This filter generates a file with relative translation and rotation
  8079. transform information about subsequent frames, which is then used by
  8080. the @ref{vidstabtransform} filter.
  8081. To enable compilation of this filter you need to configure FFmpeg with
  8082. @code{--enable-libvidstab}.
  8083. This filter accepts the following options:
  8084. @table @option
  8085. @item result
  8086. Set the path to the file used to write the transforms information.
  8087. Default value is @file{transforms.trf}.
  8088. @item shakiness
  8089. Set how shaky the video is and how quick the camera is. It accepts an
  8090. integer in the range 1-10, a value of 1 means little shakiness, a
  8091. value of 10 means strong shakiness. Default value is 5.
  8092. @item accuracy
  8093. Set the accuracy of the detection process. It must be a value in the
  8094. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  8095. accuracy. Default value is 15.
  8096. @item stepsize
  8097. Set stepsize of the search process. The region around minimum is
  8098. scanned with 1 pixel resolution. Default value is 6.
  8099. @item mincontrast
  8100. Set minimum contrast. Below this value a local measurement field is
  8101. discarded. Must be a floating point value in the range 0-1. Default
  8102. value is 0.3.
  8103. @item tripod
  8104. Set reference frame number for tripod mode.
  8105. If enabled, the motion of the frames is compared to a reference frame
  8106. in the filtered stream, identified by the specified number. The idea
  8107. is to compensate all movements in a more-or-less static scene and keep
  8108. the camera view absolutely still.
  8109. If set to 0, it is disabled. The frames are counted starting from 1.
  8110. @item show
  8111. Show fields and transforms in the resulting frames. It accepts an
  8112. integer in the range 0-2. Default value is 0, which disables any
  8113. visualization.
  8114. @end table
  8115. @subsection Examples
  8116. @itemize
  8117. @item
  8118. Use default values:
  8119. @example
  8120. vidstabdetect
  8121. @end example
  8122. @item
  8123. Analyze strongly shaky movie and put the results in file
  8124. @file{mytransforms.trf}:
  8125. @example
  8126. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  8127. @end example
  8128. @item
  8129. Visualize the result of internal transformations in the resulting
  8130. video:
  8131. @example
  8132. vidstabdetect=show=1
  8133. @end example
  8134. @item
  8135. Analyze a video with medium shakiness using @command{ffmpeg}:
  8136. @example
  8137. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  8138. @end example
  8139. @end itemize
  8140. @anchor{vidstabtransform}
  8141. @section vidstabtransform
  8142. Video stabilization/deshaking: pass 2 of 2,
  8143. see @ref{vidstabdetect} for pass 1.
  8144. Read a file with transform information for each frame and
  8145. apply/compensate them. Together with the @ref{vidstabdetect}
  8146. filter this can be used to deshake videos. See also
  8147. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  8148. the @ref{unsharp} filter, see below.
  8149. To enable compilation of this filter you need to configure FFmpeg with
  8150. @code{--enable-libvidstab}.
  8151. @subsection Options
  8152. @table @option
  8153. @item input
  8154. Set path to the file used to read the transforms. Default value is
  8155. @file{transforms.trf}.
  8156. @item smoothing
  8157. Set the number of frames (value*2 + 1) used for lowpass filtering the
  8158. camera movements. Default value is 10.
  8159. For example a number of 10 means that 21 frames are used (10 in the
  8160. past and 10 in the future) to smoothen the motion in the video. A
  8161. larger value leads to a smoother video, but limits the acceleration of
  8162. the camera (pan/tilt movements). 0 is a special case where a static
  8163. camera is simulated.
  8164. @item optalgo
  8165. Set the camera path optimization algorithm.
  8166. Accepted values are:
  8167. @table @samp
  8168. @item gauss
  8169. gaussian kernel low-pass filter on camera motion (default)
  8170. @item avg
  8171. averaging on transformations
  8172. @end table
  8173. @item maxshift
  8174. Set maximal number of pixels to translate frames. Default value is -1,
  8175. meaning no limit.
  8176. @item maxangle
  8177. Set maximal angle in radians (degree*PI/180) to rotate frames. Default
  8178. value is -1, meaning no limit.
  8179. @item crop
  8180. Specify how to deal with borders that may be visible due to movement
  8181. compensation.
  8182. Available values are:
  8183. @table @samp
  8184. @item keep
  8185. keep image information from previous frame (default)
  8186. @item black
  8187. fill the border black
  8188. @end table
  8189. @item invert
  8190. Invert transforms if set to 1. Default value is 0.
  8191. @item relative
  8192. Consider transforms as relative to previous frame if set to 1,
  8193. absolute if set to 0. Default value is 0.
  8194. @item zoom
  8195. Set percentage to zoom. A positive value will result in a zoom-in
  8196. effect, a negative value in a zoom-out effect. Default value is 0 (no
  8197. zoom).
  8198. @item optzoom
  8199. Set optimal zooming to avoid borders.
  8200. Accepted values are:
  8201. @table @samp
  8202. @item 0
  8203. disabled
  8204. @item 1
  8205. optimal static zoom value is determined (only very strong movements
  8206. will lead to visible borders) (default)
  8207. @item 2
  8208. optimal adaptive zoom value is determined (no borders will be
  8209. visible), see @option{zoomspeed}
  8210. @end table
  8211. Note that the value given at zoom is added to the one calculated here.
  8212. @item zoomspeed
  8213. Set percent to zoom maximally each frame (enabled when
  8214. @option{optzoom} is set to 2). Range is from 0 to 5, default value is
  8215. 0.25.
  8216. @item interpol
  8217. Specify type of interpolation.
  8218. Available values are:
  8219. @table @samp
  8220. @item no
  8221. no interpolation
  8222. @item linear
  8223. linear only horizontal
  8224. @item bilinear
  8225. linear in both directions (default)
  8226. @item bicubic
  8227. cubic in both directions (slow)
  8228. @end table
  8229. @item tripod
  8230. Enable virtual tripod mode if set to 1, which is equivalent to
  8231. @code{relative=0:smoothing=0}. Default value is 0.
  8232. Use also @code{tripod} option of @ref{vidstabdetect}.
  8233. @item debug
  8234. Increase log verbosity if set to 1. Also the detected global motions
  8235. are written to the temporary file @file{global_motions.trf}. Default
  8236. value is 0.
  8237. @end table
  8238. @subsection Examples
  8239. @itemize
  8240. @item
  8241. Use @command{ffmpeg} for a typical stabilization with default values:
  8242. @example
  8243. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  8244. @end example
  8245. Note the use of the @ref{unsharp} filter which is always recommended.
  8246. @item
  8247. Zoom in a bit more and load transform data from a given file:
  8248. @example
  8249. vidstabtransform=zoom=5:input="mytransforms.trf"
  8250. @end example
  8251. @item
  8252. Smoothen the video even more:
  8253. @example
  8254. vidstabtransform=smoothing=30
  8255. @end example
  8256. @end itemize
  8257. @section vflip
  8258. Flip the input video vertically.
  8259. For example, to vertically flip a video with @command{ffmpeg}:
  8260. @example
  8261. ffmpeg -i in.avi -vf "vflip" out.avi
  8262. @end example
  8263. @anchor{vignette}
  8264. @section vignette
  8265. Make or reverse a natural vignetting effect.
  8266. The filter accepts the following options:
  8267. @table @option
  8268. @item angle, a
  8269. Set lens angle expression as a number of radians.
  8270. The value is clipped in the @code{[0,PI/2]} range.
  8271. Default value: @code{"PI/5"}
  8272. @item x0
  8273. @item y0
  8274. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  8275. by default.
  8276. @item mode
  8277. Set forward/backward mode.
  8278. Available modes are:
  8279. @table @samp
  8280. @item forward
  8281. The larger the distance from the central point, the darker the image becomes.
  8282. @item backward
  8283. The larger the distance from the central point, the brighter the image becomes.
  8284. This can be used to reverse a vignette effect, though there is no automatic
  8285. detection to extract the lens @option{angle} and other settings (yet). It can
  8286. also be used to create a burning effect.
  8287. @end table
  8288. Default value is @samp{forward}.
  8289. @item eval
  8290. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  8291. It accepts the following values:
  8292. @table @samp
  8293. @item init
  8294. Evaluate expressions only once during the filter initialization.
  8295. @item frame
  8296. Evaluate expressions for each incoming frame. This is way slower than the
  8297. @samp{init} mode since it requires all the scalers to be re-computed, but it
  8298. allows advanced dynamic expressions.
  8299. @end table
  8300. Default value is @samp{init}.
  8301. @item dither
  8302. Set dithering to reduce the circular banding effects. Default is @code{1}
  8303. (enabled).
  8304. @item aspect
  8305. Set vignette aspect. This setting allows one to adjust the shape of the vignette.
  8306. Setting this value to the SAR of the input will make a rectangular vignetting
  8307. following the dimensions of the video.
  8308. Default is @code{1/1}.
  8309. @end table
  8310. @subsection Expressions
  8311. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  8312. following parameters.
  8313. @table @option
  8314. @item w
  8315. @item h
  8316. input width and height
  8317. @item n
  8318. the number of input frame, starting from 0
  8319. @item pts
  8320. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  8321. @var{TB} units, NAN if undefined
  8322. @item r
  8323. frame rate of the input video, NAN if the input frame rate is unknown
  8324. @item t
  8325. the PTS (Presentation TimeStamp) of the filtered video frame,
  8326. expressed in seconds, NAN if undefined
  8327. @item tb
  8328. time base of the input video
  8329. @end table
  8330. @subsection Examples
  8331. @itemize
  8332. @item
  8333. Apply simple strong vignetting effect:
  8334. @example
  8335. vignette=PI/4
  8336. @end example
  8337. @item
  8338. Make a flickering vignetting:
  8339. @example
  8340. vignette='PI/4+random(1)*PI/50':eval=frame
  8341. @end example
  8342. @end itemize
  8343. @section w3fdif
  8344. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  8345. Deinterlacing Filter").
  8346. Based on the process described by Martin Weston for BBC R&D, and
  8347. implemented based on the de-interlace algorithm written by Jim
  8348. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  8349. uses filter coefficients calculated by BBC R&D.
  8350. There are two sets of filter coefficients, so called "simple":
  8351. and "complex". Which set of filter coefficients is used can
  8352. be set by passing an optional parameter:
  8353. @table @option
  8354. @item filter
  8355. Set the interlacing filter coefficients. Accepts one of the following values:
  8356. @table @samp
  8357. @item simple
  8358. Simple filter coefficient set.
  8359. @item complex
  8360. More-complex filter coefficient set.
  8361. @end table
  8362. Default value is @samp{complex}.
  8363. @item deint
  8364. Specify which frames to deinterlace. Accept one of the following values:
  8365. @table @samp
  8366. @item all
  8367. Deinterlace all frames,
  8368. @item interlaced
  8369. Only deinterlace frames marked as interlaced.
  8370. @end table
  8371. Default value is @samp{all}.
  8372. @end table
  8373. @section waveform
  8374. Video waveform monitor.
  8375. The waveform monitor plots color component intensity. By default luminance
  8376. only. Each column of the waveform corresponds to a column of pixels in the
  8377. source video.
  8378. It accepts the following options:
  8379. @table @option
  8380. @item mode, m
  8381. Can be either @code{row}, or @code{column}. Default is @code{column}.
  8382. In row mode, the graph on the left side represents color component value 0 and
  8383. the right side represents value = 255. In column mode, the top side represents
  8384. color component value = 0 and bottom side represents value = 255.
  8385. @item intensity, i
  8386. Set intensity. Smaller values are useful to find out how many values of the same
  8387. luminance are distributed across input rows/columns.
  8388. Default value is @code{10}. Allowed range is [1, 255].
  8389. @item mirror, r
  8390. Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored.
  8391. In mirrored mode, higher values will be represented on the left
  8392. side for @code{row} mode and at the top for @code{column} mode. Default is
  8393. @code{1} (mirrored).
  8394. @item display, d
  8395. Set display mode.
  8396. It accepts the following values:
  8397. @table @samp
  8398. @item overlay
  8399. Presents information identical to that in the @code{parade}, except
  8400. that the graphs representing color components are superimposed directly
  8401. over one another.
  8402. This display mode makes it easier to spot relative differences or similarities
  8403. in overlapping areas of the color components that are supposed to be identical,
  8404. such as neutral whites, grays, or blacks.
  8405. @item parade
  8406. Display separate graph for the color components side by side in
  8407. @code{row} mode or one below the other in @code{column} mode.
  8408. Using this display mode makes it easy to spot color casts in the highlights
  8409. and shadows of an image, by comparing the contours of the top and the bottom
  8410. graphs of each waveform. Since whites, grays, and blacks are characterized
  8411. by exactly equal amounts of red, green, and blue, neutral areas of the picture
  8412. should display three waveforms of roughly equal width/height. If not, the
  8413. correction is easy to perform by making level adjustments the three waveforms.
  8414. @end table
  8415. Default is @code{parade}.
  8416. @item components, c
  8417. Set which color components to display. Default is 1, which means only luminance
  8418. or red color component if input is in RGB colorspace. If is set for example to
  8419. 7 it will display all 3 (if) available color components.
  8420. @item envelope, e
  8421. @table @samp
  8422. @item none
  8423. No envelope, this is default.
  8424. @item instant
  8425. Instant envelope, minimum and maximum values presented in graph will be easily
  8426. visible even with small @code{step} value.
  8427. @item peak
  8428. Hold minimum and maximum values presented in graph across time. This way you
  8429. can still spot out of range values without constantly looking at waveforms.
  8430. @item peak+instant
  8431. Peak and instant envelope combined together.
  8432. @end table
  8433. @end table
  8434. @section xbr
  8435. Apply the xBR high-quality magnification filter which is designed for pixel
  8436. art. It follows a set of edge-detection rules, see
  8437. @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
  8438. It accepts the following option:
  8439. @table @option
  8440. @item n
  8441. Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
  8442. @code{3xBR} and @code{4} for @code{4xBR}.
  8443. Default is @code{3}.
  8444. @end table
  8445. @anchor{yadif}
  8446. @section yadif
  8447. Deinterlace the input video ("yadif" means "yet another deinterlacing
  8448. filter").
  8449. It accepts the following parameters:
  8450. @table @option
  8451. @item mode
  8452. The interlacing mode to adopt. It accepts one of the following values:
  8453. @table @option
  8454. @item 0, send_frame
  8455. Output one frame for each frame.
  8456. @item 1, send_field
  8457. Output one frame for each field.
  8458. @item 2, send_frame_nospatial
  8459. Like @code{send_frame}, but it skips the spatial interlacing check.
  8460. @item 3, send_field_nospatial
  8461. Like @code{send_field}, but it skips the spatial interlacing check.
  8462. @end table
  8463. The default value is @code{send_frame}.
  8464. @item parity
  8465. The picture field parity assumed for the input interlaced video. It accepts one
  8466. of the following values:
  8467. @table @option
  8468. @item 0, tff
  8469. Assume the top field is first.
  8470. @item 1, bff
  8471. Assume the bottom field is first.
  8472. @item -1, auto
  8473. Enable automatic detection of field parity.
  8474. @end table
  8475. The default value is @code{auto}.
  8476. If the interlacing is unknown or the decoder does not export this information,
  8477. top field first will be assumed.
  8478. @item deint
  8479. Specify which frames to deinterlace. Accept one of the following
  8480. values:
  8481. @table @option
  8482. @item 0, all
  8483. Deinterlace all frames.
  8484. @item 1, interlaced
  8485. Only deinterlace frames marked as interlaced.
  8486. @end table
  8487. The default value is @code{all}.
  8488. @end table
  8489. @section zoompan
  8490. Apply Zoom & Pan effect.
  8491. This filter accepts the following options:
  8492. @table @option
  8493. @item zoom, z
  8494. Set the zoom expression. Default is 1.
  8495. @item x
  8496. @item y
  8497. Set the x and y expression. Default is 0.
  8498. @item d
  8499. Set the duration expression in number of frames.
  8500. This sets for how many number of frames effect will last for
  8501. single input image.
  8502. @item s
  8503. Set the output image size, default is 'hd720'.
  8504. @end table
  8505. Each expression can contain the following constants:
  8506. @table @option
  8507. @item in_w, iw
  8508. Input width.
  8509. @item in_h, ih
  8510. Input height.
  8511. @item out_w, ow
  8512. Output width.
  8513. @item out_h, oh
  8514. Output height.
  8515. @item in
  8516. Input frame count.
  8517. @item on
  8518. Output frame count.
  8519. @item x
  8520. @item y
  8521. Last calculated 'x' and 'y' position from 'x' and 'y' expression
  8522. for current input frame.
  8523. @item px
  8524. @item py
  8525. 'x' and 'y' of last output frame of previous input frame or 0 when there was
  8526. not yet such frame (first input frame).
  8527. @item zoom
  8528. Last calculated zoom from 'z' expression for current input frame.
  8529. @item pzoom
  8530. Last calculated zoom of last output frame of previous input frame.
  8531. @item duration
  8532. Number of output frames for current input frame. Calculated from 'd' expression
  8533. for each input frame.
  8534. @item pduration
  8535. number of output frames created for previous input frame
  8536. @item a
  8537. Rational number: input width / input height
  8538. @item sar
  8539. sample aspect ratio
  8540. @item dar
  8541. display aspect ratio
  8542. @end table
  8543. @subsection Examples
  8544. @itemize
  8545. @item
  8546. Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
  8547. @example
  8548. 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
  8549. @end example
  8550. @item
  8551. Zoom-in up to 1.5 and pan always at center of picture:
  8552. @example
  8553. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
  8554. @end example
  8555. @end itemize
  8556. @c man end VIDEO FILTERS
  8557. @chapter Video Sources
  8558. @c man begin VIDEO SOURCES
  8559. Below is a description of the currently available video sources.
  8560. @section buffer
  8561. Buffer video frames, and make them available to the filter chain.
  8562. This source is mainly intended for a programmatic use, in particular
  8563. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  8564. It accepts the following parameters:
  8565. @table @option
  8566. @item video_size
  8567. Specify the size (width and height) of the buffered video frames. For the
  8568. syntax of this option, check the
  8569. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8570. @item width
  8571. The input video width.
  8572. @item height
  8573. The input video height.
  8574. @item pix_fmt
  8575. A string representing the pixel format of the buffered video frames.
  8576. It may be a number corresponding to a pixel format, or a pixel format
  8577. name.
  8578. @item time_base
  8579. Specify the timebase assumed by the timestamps of the buffered frames.
  8580. @item frame_rate
  8581. Specify the frame rate expected for the video stream.
  8582. @item pixel_aspect, sar
  8583. The sample (pixel) aspect ratio of the input video.
  8584. @item sws_param
  8585. Specify the optional parameters to be used for the scale filter which
  8586. is automatically inserted when an input change is detected in the
  8587. input size or format.
  8588. @end table
  8589. For example:
  8590. @example
  8591. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  8592. @end example
  8593. will instruct the source to accept video frames with size 320x240 and
  8594. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  8595. square pixels (1:1 sample aspect ratio).
  8596. Since the pixel format with name "yuv410p" corresponds to the number 6
  8597. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  8598. this example corresponds to:
  8599. @example
  8600. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  8601. @end example
  8602. Alternatively, the options can be specified as a flat string, but this
  8603. syntax is deprecated:
  8604. @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}]
  8605. @section cellauto
  8606. Create a pattern generated by an elementary cellular automaton.
  8607. The initial state of the cellular automaton can be defined through the
  8608. @option{filename}, and @option{pattern} options. If such options are
  8609. not specified an initial state is created randomly.
  8610. At each new frame a new row in the video is filled with the result of
  8611. the cellular automaton next generation. The behavior when the whole
  8612. frame is filled is defined by the @option{scroll} option.
  8613. This source accepts the following options:
  8614. @table @option
  8615. @item filename, f
  8616. Read the initial cellular automaton state, i.e. the starting row, from
  8617. the specified file.
  8618. In the file, each non-whitespace character is considered an alive
  8619. cell, a newline will terminate the row, and further characters in the
  8620. file will be ignored.
  8621. @item pattern, p
  8622. Read the initial cellular automaton state, i.e. the starting row, from
  8623. the specified string.
  8624. Each non-whitespace character in the string is considered an alive
  8625. cell, a newline will terminate the row, and further characters in the
  8626. string will be ignored.
  8627. @item rate, r
  8628. Set the video rate, that is the number of frames generated per second.
  8629. Default is 25.
  8630. @item random_fill_ratio, ratio
  8631. Set the random fill ratio for the initial cellular automaton row. It
  8632. is a floating point number value ranging from 0 to 1, defaults to
  8633. 1/PHI.
  8634. This option is ignored when a file or a pattern is specified.
  8635. @item random_seed, seed
  8636. Set the seed for filling randomly the initial row, must be an integer
  8637. included between 0 and UINT32_MAX. If not specified, or if explicitly
  8638. set to -1, the filter will try to use a good random seed on a best
  8639. effort basis.
  8640. @item rule
  8641. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  8642. Default value is 110.
  8643. @item size, s
  8644. Set the size of the output video. For the syntax of this option, check the
  8645. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8646. If @option{filename} or @option{pattern} is specified, the size is set
  8647. by default to the width of the specified initial state row, and the
  8648. height is set to @var{width} * PHI.
  8649. If @option{size} is set, it must contain the width of the specified
  8650. pattern string, and the specified pattern will be centered in the
  8651. larger row.
  8652. If a filename or a pattern string is not specified, the size value
  8653. defaults to "320x518" (used for a randomly generated initial state).
  8654. @item scroll
  8655. If set to 1, scroll the output upward when all the rows in the output
  8656. have been already filled. If set to 0, the new generated row will be
  8657. written over the top row just after the bottom row is filled.
  8658. Defaults to 1.
  8659. @item start_full, full
  8660. If set to 1, completely fill the output with generated rows before
  8661. outputting the first frame.
  8662. This is the default behavior, for disabling set the value to 0.
  8663. @item stitch
  8664. If set to 1, stitch the left and right row edges together.
  8665. This is the default behavior, for disabling set the value to 0.
  8666. @end table
  8667. @subsection Examples
  8668. @itemize
  8669. @item
  8670. Read the initial state from @file{pattern}, and specify an output of
  8671. size 200x400.
  8672. @example
  8673. cellauto=f=pattern:s=200x400
  8674. @end example
  8675. @item
  8676. Generate a random initial row with a width of 200 cells, with a fill
  8677. ratio of 2/3:
  8678. @example
  8679. cellauto=ratio=2/3:s=200x200
  8680. @end example
  8681. @item
  8682. Create a pattern generated by rule 18 starting by a single alive cell
  8683. centered on an initial row with width 100:
  8684. @example
  8685. cellauto=p=@@:s=100x400:full=0:rule=18
  8686. @end example
  8687. @item
  8688. Specify a more elaborated initial pattern:
  8689. @example
  8690. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  8691. @end example
  8692. @end itemize
  8693. @section mandelbrot
  8694. Generate a Mandelbrot set fractal, and progressively zoom towards the
  8695. point specified with @var{start_x} and @var{start_y}.
  8696. This source accepts the following options:
  8697. @table @option
  8698. @item end_pts
  8699. Set the terminal pts value. Default value is 400.
  8700. @item end_scale
  8701. Set the terminal scale value.
  8702. Must be a floating point value. Default value is 0.3.
  8703. @item inner
  8704. Set the inner coloring mode, that is the algorithm used to draw the
  8705. Mandelbrot fractal internal region.
  8706. It shall assume one of the following values:
  8707. @table @option
  8708. @item black
  8709. Set black mode.
  8710. @item convergence
  8711. Show time until convergence.
  8712. @item mincol
  8713. Set color based on point closest to the origin of the iterations.
  8714. @item period
  8715. Set period mode.
  8716. @end table
  8717. Default value is @var{mincol}.
  8718. @item bailout
  8719. Set the bailout value. Default value is 10.0.
  8720. @item maxiter
  8721. Set the maximum of iterations performed by the rendering
  8722. algorithm. Default value is 7189.
  8723. @item outer
  8724. Set outer coloring mode.
  8725. It shall assume one of following values:
  8726. @table @option
  8727. @item iteration_count
  8728. Set iteration cound mode.
  8729. @item normalized_iteration_count
  8730. set normalized iteration count mode.
  8731. @end table
  8732. Default value is @var{normalized_iteration_count}.
  8733. @item rate, r
  8734. Set frame rate, expressed as number of frames per second. Default
  8735. value is "25".
  8736. @item size, s
  8737. Set frame size. For the syntax of this option, check the "Video
  8738. size" section in the ffmpeg-utils manual. Default value is "640x480".
  8739. @item start_scale
  8740. Set the initial scale value. Default value is 3.0.
  8741. @item start_x
  8742. Set the initial x position. Must be a floating point value between
  8743. -100 and 100. Default value is -0.743643887037158704752191506114774.
  8744. @item start_y
  8745. Set the initial y position. Must be a floating point value between
  8746. -100 and 100. Default value is -0.131825904205311970493132056385139.
  8747. @end table
  8748. @section mptestsrc
  8749. Generate various test patterns, as generated by the MPlayer test filter.
  8750. The size of the generated video is fixed, and is 256x256.
  8751. This source is useful in particular for testing encoding features.
  8752. This source accepts the following options:
  8753. @table @option
  8754. @item rate, r
  8755. Specify the frame rate of the sourced video, as the number of frames
  8756. generated per second. It has to be a string in the format
  8757. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  8758. number or a valid video frame rate abbreviation. The default value is
  8759. "25".
  8760. @item duration, d
  8761. Set the duration of the sourced video. See
  8762. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  8763. for the accepted syntax.
  8764. If not specified, or the expressed duration is negative, the video is
  8765. supposed to be generated forever.
  8766. @item test, t
  8767. Set the number or the name of the test to perform. Supported tests are:
  8768. @table @option
  8769. @item dc_luma
  8770. @item dc_chroma
  8771. @item freq_luma
  8772. @item freq_chroma
  8773. @item amp_luma
  8774. @item amp_chroma
  8775. @item cbp
  8776. @item mv
  8777. @item ring1
  8778. @item ring2
  8779. @item all
  8780. @end table
  8781. Default value is "all", which will cycle through the list of all tests.
  8782. @end table
  8783. Some examples:
  8784. @example
  8785. mptestsrc=t=dc_luma
  8786. @end example
  8787. will generate a "dc_luma" test pattern.
  8788. @section frei0r_src
  8789. Provide a frei0r source.
  8790. To enable compilation of this filter you need to install the frei0r
  8791. header and configure FFmpeg with @code{--enable-frei0r}.
  8792. This source accepts the following parameters:
  8793. @table @option
  8794. @item size
  8795. The size of the video to generate. For the syntax of this option, check the
  8796. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8797. @item framerate
  8798. The framerate of the generated video. It may be a string of the form
  8799. @var{num}/@var{den} or a frame rate abbreviation.
  8800. @item filter_name
  8801. The name to the frei0r source to load. For more information regarding frei0r and
  8802. how to set the parameters, read the @ref{frei0r} section in the video filters
  8803. documentation.
  8804. @item filter_params
  8805. A '|'-separated list of parameters to pass to the frei0r source.
  8806. @end table
  8807. For example, to generate a frei0r partik0l source with size 200x200
  8808. and frame rate 10 which is overlaid on the overlay filter main input:
  8809. @example
  8810. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  8811. @end example
  8812. @section life
  8813. Generate a life pattern.
  8814. This source is based on a generalization of John Conway's life game.
  8815. The sourced input represents a life grid, each pixel represents a cell
  8816. which can be in one of two possible states, alive or dead. Every cell
  8817. interacts with its eight neighbours, which are the cells that are
  8818. horizontally, vertically, or diagonally adjacent.
  8819. At each interaction the grid evolves according to the adopted rule,
  8820. which specifies the number of neighbor alive cells which will make a
  8821. cell stay alive or born. The @option{rule} option allows one to specify
  8822. the rule to adopt.
  8823. This source accepts the following options:
  8824. @table @option
  8825. @item filename, f
  8826. Set the file from which to read the initial grid state. In the file,
  8827. each non-whitespace character is considered an alive cell, and newline
  8828. is used to delimit the end of each row.
  8829. If this option is not specified, the initial grid is generated
  8830. randomly.
  8831. @item rate, r
  8832. Set the video rate, that is the number of frames generated per second.
  8833. Default is 25.
  8834. @item random_fill_ratio, ratio
  8835. Set the random fill ratio for the initial random grid. It is a
  8836. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  8837. It is ignored when a file is specified.
  8838. @item random_seed, seed
  8839. Set the seed for filling the initial random grid, must be an integer
  8840. included between 0 and UINT32_MAX. If not specified, or if explicitly
  8841. set to -1, the filter will try to use a good random seed on a best
  8842. effort basis.
  8843. @item rule
  8844. Set the life rule.
  8845. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  8846. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  8847. @var{NS} specifies the number of alive neighbor cells which make a
  8848. live cell stay alive, and @var{NB} the number of alive neighbor cells
  8849. which make a dead cell to become alive (i.e. to "born").
  8850. "s" and "b" can be used in place of "S" and "B", respectively.
  8851. Alternatively a rule can be specified by an 18-bits integer. The 9
  8852. high order bits are used to encode the next cell state if it is alive
  8853. for each number of neighbor alive cells, the low order bits specify
  8854. the rule for "borning" new cells. Higher order bits encode for an
  8855. higher number of neighbor cells.
  8856. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  8857. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  8858. Default value is "S23/B3", which is the original Conway's game of life
  8859. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  8860. cells, and will born a new cell if there are three alive cells around
  8861. a dead cell.
  8862. @item size, s
  8863. Set the size of the output video. For the syntax of this option, check the
  8864. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8865. If @option{filename} is specified, the size is set by default to the
  8866. same size of the input file. If @option{size} is set, it must contain
  8867. the size specified in the input file, and the initial grid defined in
  8868. that file is centered in the larger resulting area.
  8869. If a filename is not specified, the size value defaults to "320x240"
  8870. (used for a randomly generated initial grid).
  8871. @item stitch
  8872. If set to 1, stitch the left and right grid edges together, and the
  8873. top and bottom edges also. Defaults to 1.
  8874. @item mold
  8875. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  8876. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  8877. value from 0 to 255.
  8878. @item life_color
  8879. Set the color of living (or new born) cells.
  8880. @item death_color
  8881. Set the color of dead cells. If @option{mold} is set, this is the first color
  8882. used to represent a dead cell.
  8883. @item mold_color
  8884. Set mold color, for definitely dead and moldy cells.
  8885. For the syntax of these 3 color options, check the "Color" section in the
  8886. ffmpeg-utils manual.
  8887. @end table
  8888. @subsection Examples
  8889. @itemize
  8890. @item
  8891. Read a grid from @file{pattern}, and center it on a grid of size
  8892. 300x300 pixels:
  8893. @example
  8894. life=f=pattern:s=300x300
  8895. @end example
  8896. @item
  8897. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  8898. @example
  8899. life=ratio=2/3:s=200x200
  8900. @end example
  8901. @item
  8902. Specify a custom rule for evolving a randomly generated grid:
  8903. @example
  8904. life=rule=S14/B34
  8905. @end example
  8906. @item
  8907. Full example with slow death effect (mold) using @command{ffplay}:
  8908. @example
  8909. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  8910. @end example
  8911. @end itemize
  8912. @anchor{allyuv}
  8913. @anchor{color}
  8914. @anchor{haldclutsrc}
  8915. @anchor{nullsrc}
  8916. @anchor{rgbtestsrc}
  8917. @anchor{smptebars}
  8918. @anchor{smptehdbars}
  8919. @anchor{testsrc}
  8920. @section allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  8921. The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
  8922. The @code{color} source provides an uniformly colored input.
  8923. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  8924. @ref{haldclut} filter.
  8925. The @code{nullsrc} source returns unprocessed video frames. It is
  8926. mainly useful to be employed in analysis / debugging tools, or as the
  8927. source for filters which ignore the input data.
  8928. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  8929. detecting RGB vs BGR issues. You should see a red, green and blue
  8930. stripe from top to bottom.
  8931. The @code{smptebars} source generates a color bars pattern, based on
  8932. the SMPTE Engineering Guideline EG 1-1990.
  8933. The @code{smptehdbars} source generates a color bars pattern, based on
  8934. the SMPTE RP 219-2002.
  8935. The @code{testsrc} source generates a test video pattern, showing a
  8936. color pattern, a scrolling gradient and a timestamp. This is mainly
  8937. intended for testing purposes.
  8938. The sources accept the following parameters:
  8939. @table @option
  8940. @item color, c
  8941. Specify the color of the source, only available in the @code{color}
  8942. source. For the syntax of this option, check the "Color" section in the
  8943. ffmpeg-utils manual.
  8944. @item level
  8945. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  8946. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  8947. pixels to be used as identity matrix for 3D lookup tables. Each component is
  8948. coded on a @code{1/(N*N)} scale.
  8949. @item size, s
  8950. Specify the size of the sourced video. For the syntax of this option, check the
  8951. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8952. The default value is @code{320x240}.
  8953. This option is not available with the @code{haldclutsrc} filter.
  8954. @item rate, r
  8955. Specify the frame rate of the sourced video, as the number of frames
  8956. generated per second. It has to be a string in the format
  8957. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  8958. number or a valid video frame rate abbreviation. The default value is
  8959. "25".
  8960. @item sar
  8961. Set the sample aspect ratio of the sourced video.
  8962. @item duration, d
  8963. Set the duration of the sourced video. See
  8964. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  8965. for the accepted syntax.
  8966. If not specified, or the expressed duration is negative, the video is
  8967. supposed to be generated forever.
  8968. @item decimals, n
  8969. Set the number of decimals to show in the timestamp, only available in the
  8970. @code{testsrc} source.
  8971. The displayed timestamp value will correspond to the original
  8972. timestamp value multiplied by the power of 10 of the specified
  8973. value. Default value is 0.
  8974. @end table
  8975. For example the following:
  8976. @example
  8977. testsrc=duration=5.3:size=qcif:rate=10
  8978. @end example
  8979. will generate a video with a duration of 5.3 seconds, with size
  8980. 176x144 and a frame rate of 10 frames per second.
  8981. The following graph description will generate a red source
  8982. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  8983. frames per second.
  8984. @example
  8985. color=c=red@@0.2:s=qcif:r=10
  8986. @end example
  8987. If the input content is to be ignored, @code{nullsrc} can be used. The
  8988. following command generates noise in the luminance plane by employing
  8989. the @code{geq} filter:
  8990. @example
  8991. nullsrc=s=256x256, geq=random(1)*255:128:128
  8992. @end example
  8993. @subsection Commands
  8994. The @code{color} source supports the following commands:
  8995. @table @option
  8996. @item c, color
  8997. Set the color of the created image. Accepts the same syntax of the
  8998. corresponding @option{color} option.
  8999. @end table
  9000. @c man end VIDEO SOURCES
  9001. @chapter Video Sinks
  9002. @c man begin VIDEO SINKS
  9003. Below is a description of the currently available video sinks.
  9004. @section buffersink
  9005. Buffer video frames, and make them available to the end of the filter
  9006. graph.
  9007. This sink is mainly intended for programmatic use, in particular
  9008. through the interface defined in @file{libavfilter/buffersink.h}
  9009. or the options system.
  9010. It accepts a pointer to an AVBufferSinkContext structure, which
  9011. defines the incoming buffers' formats, to be passed as the opaque
  9012. parameter to @code{avfilter_init_filter} for initialization.
  9013. @section nullsink
  9014. Null video sink: do absolutely nothing with the input video. It is
  9015. mainly useful as a template and for use in analysis / debugging
  9016. tools.
  9017. @c man end VIDEO SINKS
  9018. @chapter Multimedia Filters
  9019. @c man begin MULTIMEDIA FILTERS
  9020. Below is a description of the currently available multimedia filters.
  9021. @section aphasemeter
  9022. Convert input audio to a video output, displaying the audio phase.
  9023. The filter accepts the following options:
  9024. @table @option
  9025. @item rate, r
  9026. Set the output frame rate. Default value is @code{25}.
  9027. @item size, s
  9028. Set the video size for the output. For the syntax of this option, check the
  9029. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9030. Default value is @code{800x400}.
  9031. @item rc
  9032. @item gc
  9033. @item bc
  9034. Specify the red, green, blue contrast. Default values are @code{2},
  9035. @code{7} and @code{1}.
  9036. Allowed range is @code{[0, 255]}.
  9037. @item mpc
  9038. Set color which will be used for drawing median phase. If color is
  9039. @code{none} which is default, no median phase value will be drawn.
  9040. @end table
  9041. The filter also exports the frame metadata @code{lavfi.aphasemeter.phase} which
  9042. represents mean phase of current audio frame. Value is in range @code{[-1, 1]}.
  9043. The @code{-1} means left and right channels are completely out of phase and
  9044. @code{1} means channels are in phase.
  9045. @section avectorscope
  9046. Convert input audio to a video output, representing the audio vector
  9047. scope.
  9048. The filter is used to measure the difference between channels of stereo
  9049. audio stream. A monoaural signal, consisting of identical left and right
  9050. signal, results in straight vertical line. Any stereo separation is visible
  9051. as a deviation from this line, creating a Lissajous figure.
  9052. If the straight (or deviation from it) but horizontal line appears this
  9053. indicates that the left and right channels are out of phase.
  9054. The filter accepts the following options:
  9055. @table @option
  9056. @item mode, m
  9057. Set the vectorscope mode.
  9058. Available values are:
  9059. @table @samp
  9060. @item lissajous
  9061. Lissajous rotated by 45 degrees.
  9062. @item lissajous_xy
  9063. Same as above but not rotated.
  9064. @item polar
  9065. Shape resembling half of circle.
  9066. @end table
  9067. Default value is @samp{lissajous}.
  9068. @item size, s
  9069. Set the video size for the output. For the syntax of this option, check the
  9070. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9071. Default value is @code{400x400}.
  9072. @item rate, r
  9073. Set the output frame rate. Default value is @code{25}.
  9074. @item rc
  9075. @item gc
  9076. @item bc
  9077. @item ac
  9078. Specify the red, green, blue and alpha contrast. Default values are @code{40},
  9079. @code{160}, @code{80} and @code{255}.
  9080. Allowed range is @code{[0, 255]}.
  9081. @item rf
  9082. @item gf
  9083. @item bf
  9084. @item af
  9085. Specify the red, green, blue and alpha fade. Default values are @code{15},
  9086. @code{10}, @code{5} and @code{5}.
  9087. Allowed range is @code{[0, 255]}.
  9088. @item zoom
  9089. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  9090. @end table
  9091. @subsection Examples
  9092. @itemize
  9093. @item
  9094. Complete example using @command{ffplay}:
  9095. @example
  9096. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  9097. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  9098. @end example
  9099. @end itemize
  9100. @section concat
  9101. Concatenate audio and video streams, joining them together one after the
  9102. other.
  9103. The filter works on segments of synchronized video and audio streams. All
  9104. segments must have the same number of streams of each type, and that will
  9105. also be the number of streams at output.
  9106. The filter accepts the following options:
  9107. @table @option
  9108. @item n
  9109. Set the number of segments. Default is 2.
  9110. @item v
  9111. Set the number of output video streams, that is also the number of video
  9112. streams in each segment. Default is 1.
  9113. @item a
  9114. Set the number of output audio streams, that is also the number of audio
  9115. streams in each segment. Default is 0.
  9116. @item unsafe
  9117. Activate unsafe mode: do not fail if segments have a different format.
  9118. @end table
  9119. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  9120. @var{a} audio outputs.
  9121. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  9122. segment, in the same order as the outputs, then the inputs for the second
  9123. segment, etc.
  9124. Related streams do not always have exactly the same duration, for various
  9125. reasons including codec frame size or sloppy authoring. For that reason,
  9126. related synchronized streams (e.g. a video and its audio track) should be
  9127. concatenated at once. The concat filter will use the duration of the longest
  9128. stream in each segment (except the last one), and if necessary pad shorter
  9129. audio streams with silence.
  9130. For this filter to work correctly, all segments must start at timestamp 0.
  9131. All corresponding streams must have the same parameters in all segments; the
  9132. filtering system will automatically select a common pixel format for video
  9133. streams, and a common sample format, sample rate and channel layout for
  9134. audio streams, but other settings, such as resolution, must be converted
  9135. explicitly by the user.
  9136. Different frame rates are acceptable but will result in variable frame rate
  9137. at output; be sure to configure the output file to handle it.
  9138. @subsection Examples
  9139. @itemize
  9140. @item
  9141. Concatenate an opening, an episode and an ending, all in bilingual version
  9142. (video in stream 0, audio in streams 1 and 2):
  9143. @example
  9144. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  9145. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  9146. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  9147. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  9148. @end example
  9149. @item
  9150. Concatenate two parts, handling audio and video separately, using the
  9151. (a)movie sources, and adjusting the resolution:
  9152. @example
  9153. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  9154. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  9155. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  9156. @end example
  9157. Note that a desync will happen at the stitch if the audio and video streams
  9158. do not have exactly the same duration in the first file.
  9159. @end itemize
  9160. @anchor{ebur128}
  9161. @section ebur128
  9162. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  9163. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  9164. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  9165. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  9166. The filter also has a video output (see the @var{video} option) with a real
  9167. time graph to observe the loudness evolution. The graphic contains the logged
  9168. message mentioned above, so it is not printed anymore when this option is set,
  9169. unless the verbose logging is set. The main graphing area contains the
  9170. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  9171. the momentary loudness (400 milliseconds).
  9172. More information about the Loudness Recommendation EBU R128 on
  9173. @url{http://tech.ebu.ch/loudness}.
  9174. The filter accepts the following options:
  9175. @table @option
  9176. @item video
  9177. Activate the video output. The audio stream is passed unchanged whether this
  9178. option is set or no. The video stream will be the first output stream if
  9179. activated. Default is @code{0}.
  9180. @item size
  9181. Set the video size. This option is for video only. For the syntax of this
  9182. option, check the
  9183. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9184. Default and minimum resolution is @code{640x480}.
  9185. @item meter
  9186. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  9187. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  9188. other integer value between this range is allowed.
  9189. @item metadata
  9190. Set metadata injection. If set to @code{1}, the audio input will be segmented
  9191. into 100ms output frames, each of them containing various loudness information
  9192. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  9193. Default is @code{0}.
  9194. @item framelog
  9195. Force the frame logging level.
  9196. Available values are:
  9197. @table @samp
  9198. @item info
  9199. information logging level
  9200. @item verbose
  9201. verbose logging level
  9202. @end table
  9203. By default, the logging level is set to @var{info}. If the @option{video} or
  9204. the @option{metadata} options are set, it switches to @var{verbose}.
  9205. @item peak
  9206. Set peak mode(s).
  9207. Available modes can be cumulated (the option is a @code{flag} type). Possible
  9208. values are:
  9209. @table @samp
  9210. @item none
  9211. Disable any peak mode (default).
  9212. @item sample
  9213. Enable sample-peak mode.
  9214. Simple peak mode looking for the higher sample value. It logs a message
  9215. for sample-peak (identified by @code{SPK}).
  9216. @item true
  9217. Enable true-peak mode.
  9218. If enabled, the peak lookup is done on an over-sampled version of the input
  9219. stream for better peak accuracy. It logs a message for true-peak.
  9220. (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
  9221. This mode requires a build with @code{libswresample}.
  9222. @end table
  9223. @end table
  9224. @subsection Examples
  9225. @itemize
  9226. @item
  9227. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  9228. @example
  9229. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  9230. @end example
  9231. @item
  9232. Run an analysis with @command{ffmpeg}:
  9233. @example
  9234. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  9235. @end example
  9236. @end itemize
  9237. @section interleave, ainterleave
  9238. Temporally interleave frames from several inputs.
  9239. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  9240. These filters read frames from several inputs and send the oldest
  9241. queued frame to the output.
  9242. Input streams must have a well defined, monotonically increasing frame
  9243. timestamp values.
  9244. In order to submit one frame to output, these filters need to enqueue
  9245. at least one frame for each input, so they cannot work in case one
  9246. input is not yet terminated and will not receive incoming frames.
  9247. For example consider the case when one input is a @code{select} filter
  9248. which always drop input frames. The @code{interleave} filter will keep
  9249. reading from that input, but it will never be able to send new frames
  9250. to output until the input will send an end-of-stream signal.
  9251. Also, depending on inputs synchronization, the filters will drop
  9252. frames in case one input receives more frames than the other ones, and
  9253. the queue is already filled.
  9254. These filters accept the following options:
  9255. @table @option
  9256. @item nb_inputs, n
  9257. Set the number of different inputs, it is 2 by default.
  9258. @end table
  9259. @subsection Examples
  9260. @itemize
  9261. @item
  9262. Interleave frames belonging to different streams using @command{ffmpeg}:
  9263. @example
  9264. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  9265. @end example
  9266. @item
  9267. Add flickering blur effect:
  9268. @example
  9269. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  9270. @end example
  9271. @end itemize
  9272. @section perms, aperms
  9273. Set read/write permissions for the output frames.
  9274. These filters are mainly aimed at developers to test direct path in the
  9275. following filter in the filtergraph.
  9276. The filters accept the following options:
  9277. @table @option
  9278. @item mode
  9279. Select the permissions mode.
  9280. It accepts the following values:
  9281. @table @samp
  9282. @item none
  9283. Do nothing. This is the default.
  9284. @item ro
  9285. Set all the output frames read-only.
  9286. @item rw
  9287. Set all the output frames directly writable.
  9288. @item toggle
  9289. Make the frame read-only if writable, and writable if read-only.
  9290. @item random
  9291. Set each output frame read-only or writable randomly.
  9292. @end table
  9293. @item seed
  9294. Set the seed for the @var{random} mode, must be an integer included between
  9295. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  9296. @code{-1}, the filter will try to use a good random seed on a best effort
  9297. basis.
  9298. @end table
  9299. Note: in case of auto-inserted filter between the permission filter and the
  9300. following one, the permission might not be received as expected in that
  9301. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  9302. perms/aperms filter can avoid this problem.
  9303. @section select, aselect
  9304. Select frames to pass in output.
  9305. This filter accepts the following options:
  9306. @table @option
  9307. @item expr, e
  9308. Set expression, which is evaluated for each input frame.
  9309. If the expression is evaluated to zero, the frame is discarded.
  9310. If the evaluation result is negative or NaN, the frame is sent to the
  9311. first output; otherwise it is sent to the output with index
  9312. @code{ceil(val)-1}, assuming that the input index starts from 0.
  9313. For example a value of @code{1.2} corresponds to the output with index
  9314. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  9315. @item outputs, n
  9316. Set the number of outputs. The output to which to send the selected
  9317. frame is based on the result of the evaluation. Default value is 1.
  9318. @end table
  9319. The expression can contain the following constants:
  9320. @table @option
  9321. @item n
  9322. The (sequential) number of the filtered frame, starting from 0.
  9323. @item selected_n
  9324. The (sequential) number of the selected frame, starting from 0.
  9325. @item prev_selected_n
  9326. The sequential number of the last selected frame. It's NAN if undefined.
  9327. @item TB
  9328. The timebase of the input timestamps.
  9329. @item pts
  9330. The PTS (Presentation TimeStamp) of the filtered video frame,
  9331. expressed in @var{TB} units. It's NAN if undefined.
  9332. @item t
  9333. The PTS of the filtered video frame,
  9334. expressed in seconds. It's NAN if undefined.
  9335. @item prev_pts
  9336. The PTS of the previously filtered video frame. It's NAN if undefined.
  9337. @item prev_selected_pts
  9338. The PTS of the last previously filtered video frame. It's NAN if undefined.
  9339. @item prev_selected_t
  9340. The PTS of the last previously selected video frame. It's NAN if undefined.
  9341. @item start_pts
  9342. The PTS of the first video frame in the video. It's NAN if undefined.
  9343. @item start_t
  9344. The time of the first video frame in the video. It's NAN if undefined.
  9345. @item pict_type @emph{(video only)}
  9346. The type of the filtered frame. It can assume one of the following
  9347. values:
  9348. @table @option
  9349. @item I
  9350. @item P
  9351. @item B
  9352. @item S
  9353. @item SI
  9354. @item SP
  9355. @item BI
  9356. @end table
  9357. @item interlace_type @emph{(video only)}
  9358. The frame interlace type. It can assume one of the following values:
  9359. @table @option
  9360. @item PROGRESSIVE
  9361. The frame is progressive (not interlaced).
  9362. @item TOPFIRST
  9363. The frame is top-field-first.
  9364. @item BOTTOMFIRST
  9365. The frame is bottom-field-first.
  9366. @end table
  9367. @item consumed_sample_n @emph{(audio only)}
  9368. the number of selected samples before the current frame
  9369. @item samples_n @emph{(audio only)}
  9370. the number of samples in the current frame
  9371. @item sample_rate @emph{(audio only)}
  9372. the input sample rate
  9373. @item key
  9374. This is 1 if the filtered frame is a key-frame, 0 otherwise.
  9375. @item pos
  9376. the position in the file of the filtered frame, -1 if the information
  9377. is not available (e.g. for synthetic video)
  9378. @item scene @emph{(video only)}
  9379. value between 0 and 1 to indicate a new scene; a low value reflects a low
  9380. probability for the current frame to introduce a new scene, while a higher
  9381. value means the current frame is more likely to be one (see the example below)
  9382. @end table
  9383. The default value of the select expression is "1".
  9384. @subsection Examples
  9385. @itemize
  9386. @item
  9387. Select all frames in input:
  9388. @example
  9389. select
  9390. @end example
  9391. The example above is the same as:
  9392. @example
  9393. select=1
  9394. @end example
  9395. @item
  9396. Skip all frames:
  9397. @example
  9398. select=0
  9399. @end example
  9400. @item
  9401. Select only I-frames:
  9402. @example
  9403. select='eq(pict_type\,I)'
  9404. @end example
  9405. @item
  9406. Select one frame every 100:
  9407. @example
  9408. select='not(mod(n\,100))'
  9409. @end example
  9410. @item
  9411. Select only frames contained in the 10-20 time interval:
  9412. @example
  9413. select=between(t\,10\,20)
  9414. @end example
  9415. @item
  9416. Select only I frames contained in the 10-20 time interval:
  9417. @example
  9418. select=between(t\,10\,20)*eq(pict_type\,I)
  9419. @end example
  9420. @item
  9421. Select frames with a minimum distance of 10 seconds:
  9422. @example
  9423. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  9424. @end example
  9425. @item
  9426. Use aselect to select only audio frames with samples number > 100:
  9427. @example
  9428. aselect='gt(samples_n\,100)'
  9429. @end example
  9430. @item
  9431. Create a mosaic of the first scenes:
  9432. @example
  9433. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  9434. @end example
  9435. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  9436. choice.
  9437. @item
  9438. Send even and odd frames to separate outputs, and compose them:
  9439. @example
  9440. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  9441. @end example
  9442. @end itemize
  9443. @section sendcmd, asendcmd
  9444. Send commands to filters in the filtergraph.
  9445. These filters read commands to be sent to other filters in the
  9446. filtergraph.
  9447. @code{sendcmd} must be inserted between two video filters,
  9448. @code{asendcmd} must be inserted between two audio filters, but apart
  9449. from that they act the same way.
  9450. The specification of commands can be provided in the filter arguments
  9451. with the @var{commands} option, or in a file specified by the
  9452. @var{filename} option.
  9453. These filters accept the following options:
  9454. @table @option
  9455. @item commands, c
  9456. Set the commands to be read and sent to the other filters.
  9457. @item filename, f
  9458. Set the filename of the commands to be read and sent to the other
  9459. filters.
  9460. @end table
  9461. @subsection Commands syntax
  9462. A commands description consists of a sequence of interval
  9463. specifications, comprising a list of commands to be executed when a
  9464. particular event related to that interval occurs. The occurring event
  9465. is typically the current frame time entering or leaving a given time
  9466. interval.
  9467. An interval is specified by the following syntax:
  9468. @example
  9469. @var{START}[-@var{END}] @var{COMMANDS};
  9470. @end example
  9471. The time interval is specified by the @var{START} and @var{END} times.
  9472. @var{END} is optional and defaults to the maximum time.
  9473. The current frame time is considered within the specified interval if
  9474. it is included in the interval [@var{START}, @var{END}), that is when
  9475. the time is greater or equal to @var{START} and is lesser than
  9476. @var{END}.
  9477. @var{COMMANDS} consists of a sequence of one or more command
  9478. specifications, separated by ",", relating to that interval. The
  9479. syntax of a command specification is given by:
  9480. @example
  9481. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  9482. @end example
  9483. @var{FLAGS} is optional and specifies the type of events relating to
  9484. the time interval which enable sending the specified command, and must
  9485. be a non-null sequence of identifier flags separated by "+" or "|" and
  9486. enclosed between "[" and "]".
  9487. The following flags are recognized:
  9488. @table @option
  9489. @item enter
  9490. The command is sent when the current frame timestamp enters the
  9491. specified interval. In other words, the command is sent when the
  9492. previous frame timestamp was not in the given interval, and the
  9493. current is.
  9494. @item leave
  9495. The command is sent when the current frame timestamp leaves the
  9496. specified interval. In other words, the command is sent when the
  9497. previous frame timestamp was in the given interval, and the
  9498. current is not.
  9499. @end table
  9500. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  9501. assumed.
  9502. @var{TARGET} specifies the target of the command, usually the name of
  9503. the filter class or a specific filter instance name.
  9504. @var{COMMAND} specifies the name of the command for the target filter.
  9505. @var{ARG} is optional and specifies the optional list of argument for
  9506. the given @var{COMMAND}.
  9507. Between one interval specification and another, whitespaces, or
  9508. sequences of characters starting with @code{#} until the end of line,
  9509. are ignored and can be used to annotate comments.
  9510. A simplified BNF description of the commands specification syntax
  9511. follows:
  9512. @example
  9513. @var{COMMAND_FLAG} ::= "enter" | "leave"
  9514. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  9515. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  9516. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  9517. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  9518. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  9519. @end example
  9520. @subsection Examples
  9521. @itemize
  9522. @item
  9523. Specify audio tempo change at second 4:
  9524. @example
  9525. asendcmd=c='4.0 atempo tempo 1.5',atempo
  9526. @end example
  9527. @item
  9528. Specify a list of drawtext and hue commands in a file.
  9529. @example
  9530. # show text in the interval 5-10
  9531. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  9532. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  9533. # desaturate the image in the interval 15-20
  9534. 15.0-20.0 [enter] hue s 0,
  9535. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  9536. [leave] hue s 1,
  9537. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  9538. # apply an exponential saturation fade-out effect, starting from time 25
  9539. 25 [enter] hue s exp(25-t)
  9540. @end example
  9541. A filtergraph allowing to read and process the above command list
  9542. stored in a file @file{test.cmd}, can be specified with:
  9543. @example
  9544. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  9545. @end example
  9546. @end itemize
  9547. @anchor{setpts}
  9548. @section setpts, asetpts
  9549. Change the PTS (presentation timestamp) of the input frames.
  9550. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  9551. This filter accepts the following options:
  9552. @table @option
  9553. @item expr
  9554. The expression which is evaluated for each frame to construct its timestamp.
  9555. @end table
  9556. The expression is evaluated through the eval API and can contain the following
  9557. constants:
  9558. @table @option
  9559. @item FRAME_RATE
  9560. frame rate, only defined for constant frame-rate video
  9561. @item PTS
  9562. The presentation timestamp in input
  9563. @item N
  9564. The count of the input frame for video or the number of consumed samples,
  9565. not including the current frame for audio, starting from 0.
  9566. @item NB_CONSUMED_SAMPLES
  9567. The number of consumed samples, not including the current frame (only
  9568. audio)
  9569. @item NB_SAMPLES, S
  9570. The number of samples in the current frame (only audio)
  9571. @item SAMPLE_RATE, SR
  9572. The audio sample rate.
  9573. @item STARTPTS
  9574. The PTS of the first frame.
  9575. @item STARTT
  9576. the time in seconds of the first frame
  9577. @item INTERLACED
  9578. State whether the current frame is interlaced.
  9579. @item T
  9580. the time in seconds of the current frame
  9581. @item POS
  9582. original position in the file of the frame, or undefined if undefined
  9583. for the current frame
  9584. @item PREV_INPTS
  9585. The previous input PTS.
  9586. @item PREV_INT
  9587. previous input time in seconds
  9588. @item PREV_OUTPTS
  9589. The previous output PTS.
  9590. @item PREV_OUTT
  9591. previous output time in seconds
  9592. @item RTCTIME
  9593. The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  9594. instead.
  9595. @item RTCSTART
  9596. The wallclock (RTC) time at the start of the movie in microseconds.
  9597. @item TB
  9598. The timebase of the input timestamps.
  9599. @end table
  9600. @subsection Examples
  9601. @itemize
  9602. @item
  9603. Start counting PTS from zero
  9604. @example
  9605. setpts=PTS-STARTPTS
  9606. @end example
  9607. @item
  9608. Apply fast motion effect:
  9609. @example
  9610. setpts=0.5*PTS
  9611. @end example
  9612. @item
  9613. Apply slow motion effect:
  9614. @example
  9615. setpts=2.0*PTS
  9616. @end example
  9617. @item
  9618. Set fixed rate of 25 frames per second:
  9619. @example
  9620. setpts=N/(25*TB)
  9621. @end example
  9622. @item
  9623. Set fixed rate 25 fps with some jitter:
  9624. @example
  9625. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  9626. @end example
  9627. @item
  9628. Apply an offset of 10 seconds to the input PTS:
  9629. @example
  9630. setpts=PTS+10/TB
  9631. @end example
  9632. @item
  9633. Generate timestamps from a "live source" and rebase onto the current timebase:
  9634. @example
  9635. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  9636. @end example
  9637. @item
  9638. Generate timestamps by counting samples:
  9639. @example
  9640. asetpts=N/SR/TB
  9641. @end example
  9642. @end itemize
  9643. @section settb, asettb
  9644. Set the timebase to use for the output frames timestamps.
  9645. It is mainly useful for testing timebase configuration.
  9646. It accepts the following parameters:
  9647. @table @option
  9648. @item expr, tb
  9649. The expression which is evaluated into the output timebase.
  9650. @end table
  9651. The value for @option{tb} is an arithmetic expression representing a
  9652. rational. The expression can contain the constants "AVTB" (the default
  9653. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  9654. audio only). Default value is "intb".
  9655. @subsection Examples
  9656. @itemize
  9657. @item
  9658. Set the timebase to 1/25:
  9659. @example
  9660. settb=expr=1/25
  9661. @end example
  9662. @item
  9663. Set the timebase to 1/10:
  9664. @example
  9665. settb=expr=0.1
  9666. @end example
  9667. @item
  9668. Set the timebase to 1001/1000:
  9669. @example
  9670. settb=1+0.001
  9671. @end example
  9672. @item
  9673. Set the timebase to 2*intb:
  9674. @example
  9675. settb=2*intb
  9676. @end example
  9677. @item
  9678. Set the default timebase value:
  9679. @example
  9680. settb=AVTB
  9681. @end example
  9682. @end itemize
  9683. @section showcqt
  9684. Convert input audio to a video output representing
  9685. frequency spectrum logarithmically (using constant Q transform with
  9686. Brown-Puckette algorithm), with musical tone scale, from E0 to D#10 (10 octaves).
  9687. The filter accepts the following options:
  9688. @table @option
  9689. @item volume
  9690. Specify transform volume (multiplier) expression. The expression can contain
  9691. variables:
  9692. @table @option
  9693. @item frequency, freq, f
  9694. the frequency where transform is evaluated
  9695. @item timeclamp, tc
  9696. value of timeclamp option
  9697. @end table
  9698. and functions:
  9699. @table @option
  9700. @item a_weighting(f)
  9701. A-weighting of equal loudness
  9702. @item b_weighting(f)
  9703. B-weighting of equal loudness
  9704. @item c_weighting(f)
  9705. C-weighting of equal loudness
  9706. @end table
  9707. Default value is @code{16}.
  9708. @item tlength
  9709. Specify transform length expression. The expression can contain variables:
  9710. @table @option
  9711. @item frequency, freq, f
  9712. the frequency where transform is evaluated
  9713. @item timeclamp, tc
  9714. value of timeclamp option
  9715. @end table
  9716. Default value is @code{384/f*tc/(384/f+tc)}.
  9717. @item timeclamp
  9718. Specify the transform timeclamp. At low frequency, there is trade-off between
  9719. accuracy in time domain and frequency domain. If timeclamp is lower,
  9720. event in time domain is represented more accurately (such as fast bass drum),
  9721. otherwise event in frequency domain is represented more accurately
  9722. (such as bass guitar). Acceptable value is [0.1, 1.0]. Default value is @code{0.17}.
  9723. @item coeffclamp
  9724. Specify the transform coeffclamp. If coeffclamp is lower, transform is
  9725. more accurate, otherwise transform is faster. Acceptable value is [0.1, 10.0].
  9726. Default value is @code{1.0}.
  9727. @item gamma
  9728. Specify gamma. Lower gamma makes the spectrum more contrast, higher gamma
  9729. makes the spectrum having more range. Acceptable value is [1.0, 7.0].
  9730. Default value is @code{3.0}.
  9731. @item gamma2
  9732. Specify gamma of bargraph. Acceptable value is [1.0, 7.0].
  9733. Default value is @code{1.0}.
  9734. @item fontfile
  9735. Specify font file for use with freetype. If not specified, use embedded font.
  9736. @item fontcolor
  9737. Specify font color expression. This is arithmetic expression that should return
  9738. integer value 0xRRGGBB. The expression can contain variables:
  9739. @table @option
  9740. @item frequency, freq, f
  9741. the frequency where transform is evaluated
  9742. @item timeclamp, tc
  9743. value of timeclamp option
  9744. @end table
  9745. and functions:
  9746. @table @option
  9747. @item midi(f)
  9748. midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
  9749. @item r(x), g(x), b(x)
  9750. red, green, and blue value of intensity x
  9751. @end table
  9752. Default value is @code{st(0, (midi(f)-59.5)/12);
  9753. st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
  9754. r(1-ld(1)) + b(ld(1))}
  9755. @item fullhd
  9756. If set to 1 (the default), the video size is 1920x1080 (full HD),
  9757. if set to 0, the video size is 960x540. Use this option to make CPU usage lower.
  9758. @item fps
  9759. Specify video fps. Default value is @code{25}.
  9760. @item count
  9761. Specify number of transform per frame, so there are fps*count transforms
  9762. per second. Note that audio data rate must be divisible by fps*count.
  9763. Default value is @code{6}.
  9764. @end table
  9765. @subsection Examples
  9766. @itemize
  9767. @item
  9768. Playing audio while showing the spectrum:
  9769. @example
  9770. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
  9771. @end example
  9772. @item
  9773. Same as above, but with frame rate 30 fps:
  9774. @example
  9775. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
  9776. @end example
  9777. @item
  9778. Playing at 960x540 and lower CPU usage:
  9779. @example
  9780. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fullhd=0:count=3 [out0]'
  9781. @end example
  9782. @item
  9783. A1 and its harmonics: A1, A2, (near)E3, A3:
  9784. @example
  9785. 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),
  9786. asplit[a][out1]; [a] showcqt [out0]'
  9787. @end example
  9788. @item
  9789. Same as above, but with more accuracy in frequency domain (and slower):
  9790. @example
  9791. 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),
  9792. asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
  9793. @end example
  9794. @item
  9795. B-weighting of equal loudness
  9796. @example
  9797. volume=16*b_weighting(f)
  9798. @end example
  9799. @item
  9800. Lower Q factor
  9801. @example
  9802. tlength=100/f*tc/(100/f+tc)
  9803. @end example
  9804. @item
  9805. Custom fontcolor, C-note is colored green, others are colored blue
  9806. @example
  9807. fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))'
  9808. @end example
  9809. @item
  9810. Custom gamma, now spectrum is linear to the amplitude.
  9811. @example
  9812. gamma=2:gamma2=2
  9813. @end example
  9814. @end itemize
  9815. @section showfreqs
  9816. Convert input audio to video output representing the audio power spectrum.
  9817. Audio amplitude is on Y-axis while frequency is on X-axis.
  9818. The filter accepts the following options:
  9819. @table @option
  9820. @item size, s
  9821. Specify size of video. For the syntax of this option, check the
  9822. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9823. Default is @code{1024x512}.
  9824. @item mode
  9825. Set display mode.
  9826. This set how each frequency bin will be represented.
  9827. It accepts the following values:
  9828. @table @samp
  9829. @item line
  9830. @item bar
  9831. @item dot
  9832. @end table
  9833. Default is @code{bar}.
  9834. @item ascale
  9835. Set amplitude scale.
  9836. It accepts the following values:
  9837. @table @samp
  9838. @item lin
  9839. Linear scale.
  9840. @item sqrt
  9841. Square root scale.
  9842. @item cbrt
  9843. Cubic root scale.
  9844. @item log
  9845. Logarithmic scale.
  9846. @end table
  9847. Default is @code{log}.
  9848. @item fscale
  9849. Set frequency scale.
  9850. It accepts the following values:
  9851. @table @samp
  9852. @item lin
  9853. Linear scale.
  9854. @item log
  9855. Logarithmic scale.
  9856. @item rlog
  9857. Reverse logarithmic scale.
  9858. @end table
  9859. Default is @code{lin}.
  9860. @item win_size
  9861. Set window size.
  9862. It accepts the following values:
  9863. @table @samp
  9864. @item w16
  9865. @item w32
  9866. @item w64
  9867. @item w128
  9868. @item w256
  9869. @item w512
  9870. @item w1024
  9871. @item w2048
  9872. @item w4096
  9873. @item w8192
  9874. @item w16384
  9875. @item w32768
  9876. @item w65536
  9877. @end table
  9878. Default is @code{w2048}
  9879. @item win_func
  9880. Set windowing function.
  9881. It accepts the following values:
  9882. @table @samp
  9883. @item rect
  9884. @item bartlett
  9885. @item hanning
  9886. @item hamming
  9887. @item blackman
  9888. @item welch
  9889. @item flattop
  9890. @item bharris
  9891. @item bnuttall
  9892. @item bhann
  9893. @item sine
  9894. @item nuttall
  9895. @end table
  9896. Default is @code{hanning}.
  9897. @item overlap
  9898. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  9899. which means optimal overlap for selected window function will be picked.
  9900. @item averaging
  9901. Set time averaging. Setting this to 0 will display current maximal peaks.
  9902. Default is @code{1}, which means time averaging is disabled.
  9903. @item color
  9904. Specify list of colors separated by space or by '|' which will be used to
  9905. draw channel frequencies. Unrecognized or missing colors will be replaced
  9906. by white color.
  9907. @end table
  9908. @section showspectrum
  9909. Convert input audio to a video output, representing the audio frequency
  9910. spectrum.
  9911. The filter accepts the following options:
  9912. @table @option
  9913. @item size, s
  9914. Specify the video size for the output. For the syntax of this option, check the
  9915. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9916. Default value is @code{640x512}.
  9917. @item slide
  9918. Specify how the spectrum should slide along the window.
  9919. It accepts the following values:
  9920. @table @samp
  9921. @item replace
  9922. the samples start again on the left when they reach the right
  9923. @item scroll
  9924. the samples scroll from right to left
  9925. @item fullframe
  9926. frames are only produced when the samples reach the right
  9927. @end table
  9928. Default value is @code{replace}.
  9929. @item mode
  9930. Specify display mode.
  9931. It accepts the following values:
  9932. @table @samp
  9933. @item combined
  9934. all channels are displayed in the same row
  9935. @item separate
  9936. all channels are displayed in separate rows
  9937. @end table
  9938. Default value is @samp{combined}.
  9939. @item color
  9940. Specify display color mode.
  9941. It accepts the following values:
  9942. @table @samp
  9943. @item channel
  9944. each channel is displayed in a separate color
  9945. @item intensity
  9946. each channel is is displayed using the same color scheme
  9947. @end table
  9948. Default value is @samp{channel}.
  9949. @item scale
  9950. Specify scale used for calculating intensity color values.
  9951. It accepts the following values:
  9952. @table @samp
  9953. @item lin
  9954. linear
  9955. @item sqrt
  9956. square root, default
  9957. @item cbrt
  9958. cubic root
  9959. @item log
  9960. logarithmic
  9961. @end table
  9962. Default value is @samp{sqrt}.
  9963. @item saturation
  9964. Set saturation modifier for displayed colors. Negative values provide
  9965. alternative color scheme. @code{0} is no saturation at all.
  9966. Saturation must be in [-10.0, 10.0] range.
  9967. Default value is @code{1}.
  9968. @item win_func
  9969. Set window function.
  9970. It accepts the following values:
  9971. @table @samp
  9972. @item none
  9973. No samples pre-processing (do not expect this to be faster)
  9974. @item hann
  9975. Hann window
  9976. @item hamming
  9977. Hamming window
  9978. @item blackman
  9979. Blackman window
  9980. @end table
  9981. Default value is @code{hann}.
  9982. @end table
  9983. The usage is very similar to the showwaves filter; see the examples in that
  9984. section.
  9985. @subsection Examples
  9986. @itemize
  9987. @item
  9988. Large window with logarithmic color scaling:
  9989. @example
  9990. showspectrum=s=1280x480:scale=log
  9991. @end example
  9992. @item
  9993. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  9994. @example
  9995. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  9996. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  9997. @end example
  9998. @end itemize
  9999. @section showvolume
  10000. Convert input audio volume to a video output.
  10001. The filter accepts the following options:
  10002. @table @option
  10003. @item rate, r
  10004. Set video rate.
  10005. @item b
  10006. Set border width, allowed range is [0, 5]. Default is 1.
  10007. @item w
  10008. Set channel width, allowed range is [40, 1080]. Default is 400.
  10009. @item h
  10010. Set channel height, allowed range is [1, 100]. Default is 20.
  10011. @item f
  10012. Set fade, allowed range is [1, 255]. Default is 20.
  10013. @item c
  10014. Set volume color expression.
  10015. The expression can use the following variables:
  10016. @table @option
  10017. @item VOLUME
  10018. Current max volume of channel in dB.
  10019. @item CHANNEL
  10020. Current channel number, starting from 0.
  10021. @end table
  10022. @item t
  10023. If set, displays channel names. Default is enabled.
  10024. @end table
  10025. @section showwaves
  10026. Convert input audio to a video output, representing the samples waves.
  10027. The filter accepts the following options:
  10028. @table @option
  10029. @item size, s
  10030. Specify the video size for the output. For the syntax of this option, check the
  10031. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10032. Default value is @code{600x240}.
  10033. @item mode
  10034. Set display mode.
  10035. Available values are:
  10036. @table @samp
  10037. @item point
  10038. Draw a point for each sample.
  10039. @item line
  10040. Draw a vertical line for each sample.
  10041. @item p2p
  10042. Draw a point for each sample and a line between them.
  10043. @item cline
  10044. Draw a centered vertical line for each sample.
  10045. @end table
  10046. Default value is @code{point}.
  10047. @item n
  10048. Set the number of samples which are printed on the same column. A
  10049. larger value will decrease the frame rate. Must be a positive
  10050. integer. This option can be set only if the value for @var{rate}
  10051. is not explicitly specified.
  10052. @item rate, r
  10053. Set the (approximate) output frame rate. This is done by setting the
  10054. option @var{n}. Default value is "25".
  10055. @item split_channels
  10056. Set if channels should be drawn separately or overlap. Default value is 0.
  10057. @end table
  10058. @subsection Examples
  10059. @itemize
  10060. @item
  10061. Output the input file audio and the corresponding video representation
  10062. at the same time:
  10063. @example
  10064. amovie=a.mp3,asplit[out0],showwaves[out1]
  10065. @end example
  10066. @item
  10067. Create a synthetic signal and show it with showwaves, forcing a
  10068. frame rate of 30 frames per second:
  10069. @example
  10070. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  10071. @end example
  10072. @end itemize
  10073. @section showwavespic
  10074. Convert input audio to a single video frame, representing the samples waves.
  10075. The filter accepts the following options:
  10076. @table @option
  10077. @item size, s
  10078. Specify the video size for the output. For the syntax of this option, check the
  10079. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10080. Default value is @code{600x240}.
  10081. @item split_channels
  10082. Set if channels should be drawn separately or overlap. Default value is 0.
  10083. @end table
  10084. @subsection Examples
  10085. @itemize
  10086. @item
  10087. Extract a channel split representation of the wave form of a whole audio track
  10088. in a 1024x800 picture using @command{ffmpeg}:
  10089. @example
  10090. ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
  10091. @end example
  10092. @end itemize
  10093. @section split, asplit
  10094. Split input into several identical outputs.
  10095. @code{asplit} works with audio input, @code{split} with video.
  10096. The filter accepts a single parameter which specifies the number of outputs. If
  10097. unspecified, it defaults to 2.
  10098. @subsection Examples
  10099. @itemize
  10100. @item
  10101. Create two separate outputs from the same input:
  10102. @example
  10103. [in] split [out0][out1]
  10104. @end example
  10105. @item
  10106. To create 3 or more outputs, you need to specify the number of
  10107. outputs, like in:
  10108. @example
  10109. [in] asplit=3 [out0][out1][out2]
  10110. @end example
  10111. @item
  10112. Create two separate outputs from the same input, one cropped and
  10113. one padded:
  10114. @example
  10115. [in] split [splitout1][splitout2];
  10116. [splitout1] crop=100:100:0:0 [cropout];
  10117. [splitout2] pad=200:200:100:100 [padout];
  10118. @end example
  10119. @item
  10120. Create 5 copies of the input audio with @command{ffmpeg}:
  10121. @example
  10122. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  10123. @end example
  10124. @end itemize
  10125. @section zmq, azmq
  10126. Receive commands sent through a libzmq client, and forward them to
  10127. filters in the filtergraph.
  10128. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  10129. must be inserted between two video filters, @code{azmq} between two
  10130. audio filters.
  10131. To enable these filters you need to install the libzmq library and
  10132. headers and configure FFmpeg with @code{--enable-libzmq}.
  10133. For more information about libzmq see:
  10134. @url{http://www.zeromq.org/}
  10135. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  10136. receives messages sent through a network interface defined by the
  10137. @option{bind_address} option.
  10138. The received message must be in the form:
  10139. @example
  10140. @var{TARGET} @var{COMMAND} [@var{ARG}]
  10141. @end example
  10142. @var{TARGET} specifies the target of the command, usually the name of
  10143. the filter class or a specific filter instance name.
  10144. @var{COMMAND} specifies the name of the command for the target filter.
  10145. @var{ARG} is optional and specifies the optional argument list for the
  10146. given @var{COMMAND}.
  10147. Upon reception, the message is processed and the corresponding command
  10148. is injected into the filtergraph. Depending on the result, the filter
  10149. will send a reply to the client, adopting the format:
  10150. @example
  10151. @var{ERROR_CODE} @var{ERROR_REASON}
  10152. @var{MESSAGE}
  10153. @end example
  10154. @var{MESSAGE} is optional.
  10155. @subsection Examples
  10156. Look at @file{tools/zmqsend} for an example of a zmq client which can
  10157. be used to send commands processed by these filters.
  10158. Consider the following filtergraph generated by @command{ffplay}
  10159. @example
  10160. ffplay -dumpgraph 1 -f lavfi "
  10161. color=s=100x100:c=red [l];
  10162. color=s=100x100:c=blue [r];
  10163. nullsrc=s=200x100, zmq [bg];
  10164. [bg][l] overlay [bg+l];
  10165. [bg+l][r] overlay=x=100 "
  10166. @end example
  10167. To change the color of the left side of the video, the following
  10168. command can be used:
  10169. @example
  10170. echo Parsed_color_0 c yellow | tools/zmqsend
  10171. @end example
  10172. To change the right side:
  10173. @example
  10174. echo Parsed_color_1 c pink | tools/zmqsend
  10175. @end example
  10176. @c man end MULTIMEDIA FILTERS
  10177. @chapter Multimedia Sources
  10178. @c man begin MULTIMEDIA SOURCES
  10179. Below is a description of the currently available multimedia sources.
  10180. @section amovie
  10181. This is the same as @ref{movie} source, except it selects an audio
  10182. stream by default.
  10183. @anchor{movie}
  10184. @section movie
  10185. Read audio and/or video stream(s) from a movie container.
  10186. It accepts the following parameters:
  10187. @table @option
  10188. @item filename
  10189. The name of the resource to read (not necessarily a file; it can also be a
  10190. device or a stream accessed through some protocol).
  10191. @item format_name, f
  10192. Specifies the format assumed for the movie to read, and can be either
  10193. the name of a container or an input device. If not specified, the
  10194. format is guessed from @var{movie_name} or by probing.
  10195. @item seek_point, sp
  10196. Specifies the seek point in seconds. The frames will be output
  10197. starting from this seek point. The parameter is evaluated with
  10198. @code{av_strtod}, so the numerical value may be suffixed by an IS
  10199. postfix. The default value is "0".
  10200. @item streams, s
  10201. Specifies the streams to read. Several streams can be specified,
  10202. separated by "+". The source will then have as many outputs, in the
  10203. same order. The syntax is explained in the ``Stream specifiers''
  10204. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  10205. respectively the default (best suited) video and audio stream. Default
  10206. is "dv", or "da" if the filter is called as "amovie".
  10207. @item stream_index, si
  10208. Specifies the index of the video stream to read. If the value is -1,
  10209. the most suitable video stream will be automatically selected. The default
  10210. value is "-1". Deprecated. If the filter is called "amovie", it will select
  10211. audio instead of video.
  10212. @item loop
  10213. Specifies how many times to read the stream in sequence.
  10214. If the value is less than 1, the stream will be read again and again.
  10215. Default value is "1".
  10216. Note that when the movie is looped the source timestamps are not
  10217. changed, so it will generate non monotonically increasing timestamps.
  10218. @end table
  10219. It allows overlaying a second video on top of the main input of
  10220. a filtergraph, as shown in this graph:
  10221. @example
  10222. input -----------> deltapts0 --> overlay --> output
  10223. ^
  10224. |
  10225. movie --> scale--> deltapts1 -------+
  10226. @end example
  10227. @subsection Examples
  10228. @itemize
  10229. @item
  10230. Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
  10231. on top of the input labelled "in":
  10232. @example
  10233. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  10234. [in] setpts=PTS-STARTPTS [main];
  10235. [main][over] overlay=16:16 [out]
  10236. @end example
  10237. @item
  10238. Read from a video4linux2 device, and overlay it on top of the input
  10239. labelled "in":
  10240. @example
  10241. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  10242. [in] setpts=PTS-STARTPTS [main];
  10243. [main][over] overlay=16:16 [out]
  10244. @end example
  10245. @item
  10246. Read the first video stream and the audio stream with id 0x81 from
  10247. dvd.vob; the video is connected to the pad named "video" and the audio is
  10248. connected to the pad named "audio":
  10249. @example
  10250. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  10251. @end example
  10252. @end itemize
  10253. @c man end MULTIMEDIA SOURCES