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.

13492 lines
369KB

  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 framerate
  4630. Change the frame rate by interpolating new video output frames from the source
  4631. frames.
  4632. This filter is not designed to function correctly with interlaced media. If
  4633. you wish to change the frame rate of interlaced media then you are required
  4634. to deinterlace before this filter and re-interlace after this filter.
  4635. A description of the accepted options follows.
  4636. @table @option
  4637. @item fps
  4638. Specify the output frames per second. This option can also be specified
  4639. as a value alone. The default is @code{50}.
  4640. @item interp_start
  4641. Specify the start of a range where the output frame will be created as a
  4642. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  4643. the default is @code{15}.
  4644. @item interp_end
  4645. Specify the end of a range where the output frame will be created as a
  4646. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  4647. the default is @code{240}.
  4648. @item scene
  4649. Specify the level at which a scene change is detected as a value between
  4650. 0 and 100 to indicate a new scene; a low value reflects a low
  4651. probability for the current frame to introduce a new scene, while a higher
  4652. value means the current frame is more likely to be one.
  4653. The default is @code{7}.
  4654. @item flags
  4655. Specify flags influencing the filter process.
  4656. Available value for @var{flags} is:
  4657. @table @option
  4658. @item scene_change_detect, scd
  4659. Enable scene change detection using the value of the option @var{scene}.
  4660. This flag is enabled by default.
  4661. @end table
  4662. @end table
  4663. @section framestep
  4664. Select one frame every N-th frame.
  4665. This filter accepts the following option:
  4666. @table @option
  4667. @item step
  4668. Select frame after every @code{step} frames.
  4669. Allowed values are positive integers higher than 0. Default value is @code{1}.
  4670. @end table
  4671. @anchor{frei0r}
  4672. @section frei0r
  4673. Apply a frei0r effect to the input video.
  4674. To enable the compilation of this filter, you need to install the frei0r
  4675. header and configure FFmpeg with @code{--enable-frei0r}.
  4676. It accepts the following parameters:
  4677. @table @option
  4678. @item filter_name
  4679. The name of the frei0r effect to load. If the environment variable
  4680. @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
  4681. directories specified by the colon-separated list in @env{FREIOR_PATH}.
  4682. Otherwise, the standard frei0r paths are searched, in this order:
  4683. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  4684. @file{/usr/lib/frei0r-1/}.
  4685. @item filter_params
  4686. A '|'-separated list of parameters to pass to the frei0r effect.
  4687. @end table
  4688. A frei0r effect parameter can be a boolean (its value is either
  4689. "y" or "n"), a double, a color (specified as
  4690. @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
  4691. numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
  4692. section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
  4693. @var{X} and @var{Y} are floating point numbers) and/or a string.
  4694. The number and types of parameters depend on the loaded effect. If an
  4695. effect parameter is not specified, the default value is set.
  4696. @subsection Examples
  4697. @itemize
  4698. @item
  4699. Apply the distort0r effect, setting the first two double parameters:
  4700. @example
  4701. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  4702. @end example
  4703. @item
  4704. Apply the colordistance effect, taking a color as the first parameter:
  4705. @example
  4706. frei0r=colordistance:0.2/0.3/0.4
  4707. frei0r=colordistance:violet
  4708. frei0r=colordistance:0x112233
  4709. @end example
  4710. @item
  4711. Apply the perspective effect, specifying the top left and top right image
  4712. positions:
  4713. @example
  4714. frei0r=perspective:0.2/0.2|0.8/0.2
  4715. @end example
  4716. @end itemize
  4717. For more information, see
  4718. @url{http://frei0r.dyne.org}
  4719. @section fspp
  4720. Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
  4721. It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
  4722. processing filter, one of them is performed once per block, not per pixel.
  4723. This allows for much higher speed.
  4724. The filter accepts the following options:
  4725. @table @option
  4726. @item quality
  4727. Set quality. This option defines the number of levels for averaging. It accepts
  4728. an integer in the range 4-5. Default value is @code{4}.
  4729. @item qp
  4730. Force a constant quantization parameter. It accepts an integer in range 0-63.
  4731. If not set, the filter will use the QP from the video stream (if available).
  4732. @item strength
  4733. Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
  4734. more details but also more artifacts, while higher values make the image smoother
  4735. but also blurrier. Default value is @code{0} − PSNR optimal.
  4736. @item use_bframe_qp
  4737. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  4738. option may cause flicker since the B-Frames have often larger QP. Default is
  4739. @code{0} (not enabled).
  4740. @end table
  4741. @section geq
  4742. The filter accepts the following options:
  4743. @table @option
  4744. @item lum_expr, lum
  4745. Set the luminance expression.
  4746. @item cb_expr, cb
  4747. Set the chrominance blue expression.
  4748. @item cr_expr, cr
  4749. Set the chrominance red expression.
  4750. @item alpha_expr, a
  4751. Set the alpha expression.
  4752. @item red_expr, r
  4753. Set the red expression.
  4754. @item green_expr, g
  4755. Set the green expression.
  4756. @item blue_expr, b
  4757. Set the blue expression.
  4758. @end table
  4759. The colorspace is selected according to the specified options. If one
  4760. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  4761. options is specified, the filter will automatically select a YCbCr
  4762. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  4763. @option{blue_expr} options is specified, it will select an RGB
  4764. colorspace.
  4765. If one of the chrominance expression is not defined, it falls back on the other
  4766. one. If no alpha expression is specified it will evaluate to opaque value.
  4767. If none of chrominance expressions are specified, they will evaluate
  4768. to the luminance expression.
  4769. The expressions can use the following variables and functions:
  4770. @table @option
  4771. @item N
  4772. The sequential number of the filtered frame, starting from @code{0}.
  4773. @item X
  4774. @item Y
  4775. The coordinates of the current sample.
  4776. @item W
  4777. @item H
  4778. The width and height of the image.
  4779. @item SW
  4780. @item SH
  4781. Width and height scale depending on the currently filtered plane. It is the
  4782. ratio between the corresponding luma plane number of pixels and the current
  4783. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  4784. @code{0.5,0.5} for chroma planes.
  4785. @item T
  4786. Time of the current frame, expressed in seconds.
  4787. @item p(x, y)
  4788. Return the value of the pixel at location (@var{x},@var{y}) of the current
  4789. plane.
  4790. @item lum(x, y)
  4791. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  4792. plane.
  4793. @item cb(x, y)
  4794. Return the value of the pixel at location (@var{x},@var{y}) of the
  4795. blue-difference chroma plane. Return 0 if there is no such plane.
  4796. @item cr(x, y)
  4797. Return the value of the pixel at location (@var{x},@var{y}) of the
  4798. red-difference chroma plane. Return 0 if there is no such plane.
  4799. @item r(x, y)
  4800. @item g(x, y)
  4801. @item b(x, y)
  4802. Return the value of the pixel at location (@var{x},@var{y}) of the
  4803. red/green/blue component. Return 0 if there is no such component.
  4804. @item alpha(x, y)
  4805. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  4806. plane. Return 0 if there is no such plane.
  4807. @end table
  4808. For functions, if @var{x} and @var{y} are outside the area, the value will be
  4809. automatically clipped to the closer edge.
  4810. @subsection Examples
  4811. @itemize
  4812. @item
  4813. Flip the image horizontally:
  4814. @example
  4815. geq=p(W-X\,Y)
  4816. @end example
  4817. @item
  4818. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  4819. wavelength of 100 pixels:
  4820. @example
  4821. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  4822. @end example
  4823. @item
  4824. Generate a fancy enigmatic moving light:
  4825. @example
  4826. 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
  4827. @end example
  4828. @item
  4829. Generate a quick emboss effect:
  4830. @example
  4831. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  4832. @end example
  4833. @item
  4834. Modify RGB components depending on pixel position:
  4835. @example
  4836. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  4837. @end example
  4838. @item
  4839. Create a radial gradient that is the same size as the input (also see
  4840. the @ref{vignette} filter):
  4841. @example
  4842. geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
  4843. @end example
  4844. @item
  4845. Create a linear gradient to use as a mask for another filter, then
  4846. compose with @ref{overlay}. In this example the video will gradually
  4847. become more blurry from the top to the bottom of the y-axis as defined
  4848. by the linear gradient:
  4849. @example
  4850. 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
  4851. @end example
  4852. @end itemize
  4853. @section gradfun
  4854. Fix the banding artifacts that are sometimes introduced into nearly flat
  4855. regions by truncation to 8bit color depth.
  4856. Interpolate the gradients that should go where the bands are, and
  4857. dither them.
  4858. It is designed for playback only. Do not use it prior to
  4859. lossy compression, because compression tends to lose the dither and
  4860. bring back the bands.
  4861. It accepts the following parameters:
  4862. @table @option
  4863. @item strength
  4864. The maximum amount by which the filter will change any one pixel. This is also
  4865. the threshold for detecting nearly flat regions. Acceptable values range from
  4866. .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
  4867. valid range.
  4868. @item radius
  4869. The neighborhood to fit the gradient to. A larger radius makes for smoother
  4870. gradients, but also prevents the filter from modifying the pixels near detailed
  4871. regions. Acceptable values are 8-32; the default value is 16. Out-of-range
  4872. values will be clipped to the valid range.
  4873. @end table
  4874. Alternatively, the options can be specified as a flat string:
  4875. @var{strength}[:@var{radius}]
  4876. @subsection Examples
  4877. @itemize
  4878. @item
  4879. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  4880. @example
  4881. gradfun=3.5:8
  4882. @end example
  4883. @item
  4884. Specify radius, omitting the strength (which will fall-back to the default
  4885. value):
  4886. @example
  4887. gradfun=radius=8
  4888. @end example
  4889. @end itemize
  4890. @anchor{haldclut}
  4891. @section haldclut
  4892. Apply a Hald CLUT to a video stream.
  4893. First input is the video stream to process, and second one is the Hald CLUT.
  4894. The Hald CLUT input can be a simple picture or a complete video stream.
  4895. The filter accepts the following options:
  4896. @table @option
  4897. @item shortest
  4898. Force termination when the shortest input terminates. Default is @code{0}.
  4899. @item repeatlast
  4900. Continue applying the last CLUT after the end of the stream. A value of
  4901. @code{0} disable the filter after the last frame of the CLUT is reached.
  4902. Default is @code{1}.
  4903. @end table
  4904. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  4905. filters share the same internals).
  4906. More information about the Hald CLUT can be found on Eskil Steenberg's website
  4907. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  4908. @subsection Workflow examples
  4909. @subsubsection Hald CLUT video stream
  4910. Generate an identity Hald CLUT stream altered with various effects:
  4911. @example
  4912. 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
  4913. @end example
  4914. Note: make sure you use a lossless codec.
  4915. Then use it with @code{haldclut} to apply it on some random stream:
  4916. @example
  4917. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  4918. @end example
  4919. The Hald CLUT will be applied to the 10 first seconds (duration of
  4920. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  4921. to the remaining frames of the @code{mandelbrot} stream.
  4922. @subsubsection Hald CLUT with preview
  4923. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  4924. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  4925. biggest possible square starting at the top left of the picture. The remaining
  4926. padding pixels (bottom or right) will be ignored. This area can be used to add
  4927. a preview of the Hald CLUT.
  4928. Typically, the following generated Hald CLUT will be supported by the
  4929. @code{haldclut} filter:
  4930. @example
  4931. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  4932. pad=iw+320 [padded_clut];
  4933. smptebars=s=320x256, split [a][b];
  4934. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  4935. [main][b] overlay=W-320" -frames:v 1 clut.png
  4936. @end example
  4937. It contains the original and a preview of the effect of the CLUT: SMPTE color
  4938. bars are displayed on the right-top, and below the same color bars processed by
  4939. the color changes.
  4940. Then, the effect of this Hald CLUT can be visualized with:
  4941. @example
  4942. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  4943. @end example
  4944. @section hflip
  4945. Flip the input video horizontally.
  4946. For example, to horizontally flip the input video with @command{ffmpeg}:
  4947. @example
  4948. ffmpeg -i in.avi -vf "hflip" out.avi
  4949. @end example
  4950. @section histeq
  4951. This filter applies a global color histogram equalization on a
  4952. per-frame basis.
  4953. It can be used to correct video that has a compressed range of pixel
  4954. intensities. The filter redistributes the pixel intensities to
  4955. equalize their distribution across the intensity range. It may be
  4956. viewed as an "automatically adjusting contrast filter". This filter is
  4957. useful only for correcting degraded or poorly captured source
  4958. video.
  4959. The filter accepts the following options:
  4960. @table @option
  4961. @item strength
  4962. Determine the amount of equalization to be applied. As the strength
  4963. is reduced, the distribution of pixel intensities more-and-more
  4964. approaches that of the input frame. The value must be a float number
  4965. in the range [0,1] and defaults to 0.200.
  4966. @item intensity
  4967. Set the maximum intensity that can generated and scale the output
  4968. values appropriately. The strength should be set as desired and then
  4969. the intensity can be limited if needed to avoid washing-out. The value
  4970. must be a float number in the range [0,1] and defaults to 0.210.
  4971. @item antibanding
  4972. Set the antibanding level. If enabled the filter will randomly vary
  4973. the luminance of output pixels by a small amount to avoid banding of
  4974. the histogram. Possible values are @code{none}, @code{weak} or
  4975. @code{strong}. It defaults to @code{none}.
  4976. @end table
  4977. @section histogram
  4978. Compute and draw a color distribution histogram for the input video.
  4979. The computed histogram is a representation of the color component
  4980. distribution in an image.
  4981. The filter accepts the following options:
  4982. @table @option
  4983. @item mode
  4984. Set histogram mode.
  4985. It accepts the following values:
  4986. @table @samp
  4987. @item levels
  4988. Standard histogram that displays the color components distribution in an
  4989. image. Displays color graph for each color component. Shows distribution of
  4990. the Y, U, V, A or R, G, B components, depending on input format, in the
  4991. current frame. Below each graph a color component scale meter is shown.
  4992. @item color
  4993. Displays chroma values (U/V color placement) in a two dimensional
  4994. graph (which is called a vectorscope). The brighter a pixel in the
  4995. vectorscope, the more pixels of the input frame correspond to that pixel
  4996. (i.e., more pixels have this chroma value). The V component is displayed on
  4997. the horizontal (X) axis, with the leftmost side being V = 0 and the rightmost
  4998. side being V = 255. The U component is displayed on the vertical (Y) axis,
  4999. with the top representing U = 0 and the bottom representing U = 255.
  5000. The position of a white pixel in the graph corresponds to the chroma value of
  5001. a pixel of the input clip. The graph can therefore be used to read the hue
  5002. (color flavor) and the saturation (the dominance of the hue in the color). As
  5003. the hue of a color changes, it moves around the square. At the center of the
  5004. square the saturation is zero, which means that the corresponding pixel has no
  5005. color. If the amount of a specific color is increased (while leaving the other
  5006. colors unchanged) the saturation increases, and the indicator moves towards
  5007. the edge of the square.
  5008. @item color2
  5009. Chroma values in vectorscope, similar as @code{color} but actual chroma values
  5010. are displayed.
  5011. @item waveform
  5012. Per row/column color component graph. In row mode, the graph on the left side
  5013. represents color component value 0 and the right side represents value = 255.
  5014. In column mode, the top side represents color component value = 0 and bottom
  5015. side represents value = 255.
  5016. @end table
  5017. Default value is @code{levels}.
  5018. @item level_height
  5019. Set height of level in @code{levels}. Default value is @code{200}.
  5020. Allowed range is [50, 2048].
  5021. @item scale_height
  5022. Set height of color scale in @code{levels}. Default value is @code{12}.
  5023. Allowed range is [0, 40].
  5024. @item step
  5025. Set step for @code{waveform} mode. Smaller values are useful to find out how
  5026. many values of the same luminance are distributed across input rows/columns.
  5027. Default value is @code{10}. Allowed range is [1, 255].
  5028. @item waveform_mode
  5029. Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
  5030. Default is @code{row}.
  5031. @item waveform_mirror
  5032. Set mirroring mode for @code{waveform}. @code{0} means unmirrored, @code{1}
  5033. means mirrored. In mirrored mode, higher values will be represented on the left
  5034. side for @code{row} mode and at the top for @code{column} mode. Default is
  5035. @code{0} (unmirrored).
  5036. @item display_mode
  5037. Set display mode for @code{waveform} and @code{levels}.
  5038. It accepts the following values:
  5039. @table @samp
  5040. @item parade
  5041. Display separate graph for the color components side by side in
  5042. @code{row} waveform mode or one below the other in @code{column} waveform mode
  5043. for @code{waveform} histogram mode. For @code{levels} histogram mode,
  5044. per color component graphs are placed below each other.
  5045. Using this display mode in @code{waveform} histogram mode makes it easy to
  5046. spot color casts in the highlights and shadows of an image, by comparing the
  5047. contours of the top and the bottom graphs of each waveform. Since whites,
  5048. grays, and blacks are characterized by exactly equal amounts of red, green,
  5049. and blue, neutral areas of the picture should display three waveforms of
  5050. roughly equal width/height. If not, the correction is easy to perform by
  5051. making level adjustments the three waveforms.
  5052. @item overlay
  5053. Presents information identical to that in the @code{parade}, except
  5054. that the graphs representing color components are superimposed directly
  5055. over one another.
  5056. This display mode in @code{waveform} histogram mode makes it easier to spot
  5057. relative differences or similarities in overlapping areas of the color
  5058. components that are supposed to be identical, such as neutral whites, grays,
  5059. or blacks.
  5060. @end table
  5061. Default is @code{parade}.
  5062. @item levels_mode
  5063. Set mode for @code{levels}. Can be either @code{linear}, or @code{logarithmic}.
  5064. Default is @code{linear}.
  5065. @item components
  5066. Set what color components to display for mode @code{levels}.
  5067. Default is @code{7}.
  5068. @end table
  5069. @subsection Examples
  5070. @itemize
  5071. @item
  5072. Calculate and draw histogram:
  5073. @example
  5074. ffplay -i input -vf histogram
  5075. @end example
  5076. @end itemize
  5077. @anchor{hqdn3d}
  5078. @section hqdn3d
  5079. This is a high precision/quality 3d denoise filter. It aims to reduce
  5080. image noise, producing smooth images and making still images really
  5081. still. It should enhance compressibility.
  5082. It accepts the following optional parameters:
  5083. @table @option
  5084. @item luma_spatial
  5085. A non-negative floating point number which specifies spatial luma strength.
  5086. It defaults to 4.0.
  5087. @item chroma_spatial
  5088. A non-negative floating point number which specifies spatial chroma strength.
  5089. It defaults to 3.0*@var{luma_spatial}/4.0.
  5090. @item luma_tmp
  5091. A floating point number which specifies luma temporal strength. It defaults to
  5092. 6.0*@var{luma_spatial}/4.0.
  5093. @item chroma_tmp
  5094. A floating point number which specifies chroma temporal strength. It defaults to
  5095. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
  5096. @end table
  5097. @section hqx
  5098. Apply a high-quality magnification filter designed for pixel art. This filter
  5099. was originally created by Maxim Stepin.
  5100. It accepts the following option:
  5101. @table @option
  5102. @item n
  5103. Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
  5104. @code{hq3x} and @code{4} for @code{hq4x}.
  5105. Default is @code{3}.
  5106. @end table
  5107. @section hstack
  5108. Stack input videos horizontally.
  5109. All streams must be of same pixel format and of same height.
  5110. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  5111. to create same output.
  5112. The filter accept the following option:
  5113. @table @option
  5114. @item nb_inputs
  5115. Set number of input streams. Default is 2.
  5116. @end table
  5117. @section hue
  5118. Modify the hue and/or the saturation of the input.
  5119. It accepts the following parameters:
  5120. @table @option
  5121. @item h
  5122. Specify the hue angle as a number of degrees. It accepts an expression,
  5123. and defaults to "0".
  5124. @item s
  5125. Specify the saturation in the [-10,10] range. It accepts an expression and
  5126. defaults to "1".
  5127. @item H
  5128. Specify the hue angle as a number of radians. It accepts an
  5129. expression, and defaults to "0".
  5130. @item b
  5131. Specify the brightness in the [-10,10] range. It accepts an expression and
  5132. defaults to "0".
  5133. @end table
  5134. @option{h} and @option{H} are mutually exclusive, and can't be
  5135. specified at the same time.
  5136. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  5137. expressions containing the following constants:
  5138. @table @option
  5139. @item n
  5140. frame count of the input frame starting from 0
  5141. @item pts
  5142. presentation timestamp of the input frame expressed in time base units
  5143. @item r
  5144. frame rate of the input video, NAN if the input frame rate is unknown
  5145. @item t
  5146. timestamp expressed in seconds, NAN if the input timestamp is unknown
  5147. @item tb
  5148. time base of the input video
  5149. @end table
  5150. @subsection Examples
  5151. @itemize
  5152. @item
  5153. Set the hue to 90 degrees and the saturation to 1.0:
  5154. @example
  5155. hue=h=90:s=1
  5156. @end example
  5157. @item
  5158. Same command but expressing the hue in radians:
  5159. @example
  5160. hue=H=PI/2:s=1
  5161. @end example
  5162. @item
  5163. Rotate hue and make the saturation swing between 0
  5164. and 2 over a period of 1 second:
  5165. @example
  5166. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  5167. @end example
  5168. @item
  5169. Apply a 3 seconds saturation fade-in effect starting at 0:
  5170. @example
  5171. hue="s=min(t/3\,1)"
  5172. @end example
  5173. The general fade-in expression can be written as:
  5174. @example
  5175. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  5176. @end example
  5177. @item
  5178. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  5179. @example
  5180. hue="s=max(0\, min(1\, (8-t)/3))"
  5181. @end example
  5182. The general fade-out expression can be written as:
  5183. @example
  5184. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  5185. @end example
  5186. @end itemize
  5187. @subsection Commands
  5188. This filter supports the following commands:
  5189. @table @option
  5190. @item b
  5191. @item s
  5192. @item h
  5193. @item H
  5194. Modify the hue and/or the saturation and/or brightness of the input video.
  5195. The command accepts the same syntax of the corresponding option.
  5196. If the specified expression is not valid, it is kept at its current
  5197. value.
  5198. @end table
  5199. @section idet
  5200. Detect video interlacing type.
  5201. This filter tries to detect if the input frames as interlaced, progressive,
  5202. top or bottom field first. It will also try and detect fields that are
  5203. repeated between adjacent frames (a sign of telecine).
  5204. Single frame detection considers only immediately adjacent frames when classifying each frame.
  5205. Multiple frame detection incorporates the classification history of previous frames.
  5206. The filter will log these metadata values:
  5207. @table @option
  5208. @item single.current_frame
  5209. Detected type of current frame using single-frame detection. One of:
  5210. ``tff'' (top field first), ``bff'' (bottom field first),
  5211. ``progressive'', or ``undetermined''
  5212. @item single.tff
  5213. Cumulative number of frames detected as top field first using single-frame detection.
  5214. @item multiple.tff
  5215. Cumulative number of frames detected as top field first using multiple-frame detection.
  5216. @item single.bff
  5217. Cumulative number of frames detected as bottom field first using single-frame detection.
  5218. @item multiple.current_frame
  5219. Detected type of current frame using multiple-frame detection. One of:
  5220. ``tff'' (top field first), ``bff'' (bottom field first),
  5221. ``progressive'', or ``undetermined''
  5222. @item multiple.bff
  5223. Cumulative number of frames detected as bottom field first using multiple-frame detection.
  5224. @item single.progressive
  5225. Cumulative number of frames detected as progressive using single-frame detection.
  5226. @item multiple.progressive
  5227. Cumulative number of frames detected as progressive using multiple-frame detection.
  5228. @item single.undetermined
  5229. Cumulative number of frames that could not be classified using single-frame detection.
  5230. @item multiple.undetermined
  5231. Cumulative number of frames that could not be classified using multiple-frame detection.
  5232. @item repeated.current_frame
  5233. Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
  5234. @item repeated.neither
  5235. Cumulative number of frames with no repeated field.
  5236. @item repeated.top
  5237. Cumulative number of frames with the top field repeated from the previous frame's top field.
  5238. @item repeated.bottom
  5239. Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
  5240. @end table
  5241. The filter accepts the following options:
  5242. @table @option
  5243. @item intl_thres
  5244. Set interlacing threshold.
  5245. @item prog_thres
  5246. Set progressive threshold.
  5247. @item repeat_thres
  5248. Threshold for repeated field detection.
  5249. @item half_life
  5250. Number of frames after which a given frame's contribution to the
  5251. statistics is halved (i.e., it contributes only 0.5 to it's
  5252. classification). The default of 0 means that all frames seen are given
  5253. full weight of 1.0 forever.
  5254. @item analyze_interlaced_flag
  5255. When this is not 0 then idet will use the specified number of frames to determine
  5256. if the interlaced flag is accurate, it will not count undetermined frames.
  5257. If the flag is found to be accurate it will be used without any further
  5258. computations, if it is found to be inaccurate it will be cleared without any
  5259. further computations. This allows inserting the idet filter as a low computational
  5260. method to clean up the interlaced flag
  5261. @end table
  5262. @section il
  5263. Deinterleave or interleave fields.
  5264. This filter allows one to process interlaced images fields without
  5265. deinterlacing them. Deinterleaving splits the input frame into 2
  5266. fields (so called half pictures). Odd lines are moved to the top
  5267. half of the output image, even lines to the bottom half.
  5268. You can process (filter) them independently and then re-interleave them.
  5269. The filter accepts the following options:
  5270. @table @option
  5271. @item luma_mode, l
  5272. @item chroma_mode, c
  5273. @item alpha_mode, a
  5274. Available values for @var{luma_mode}, @var{chroma_mode} and
  5275. @var{alpha_mode} are:
  5276. @table @samp
  5277. @item none
  5278. Do nothing.
  5279. @item deinterleave, d
  5280. Deinterleave fields, placing one above the other.
  5281. @item interleave, i
  5282. Interleave fields. Reverse the effect of deinterleaving.
  5283. @end table
  5284. Default value is @code{none}.
  5285. @item luma_swap, ls
  5286. @item chroma_swap, cs
  5287. @item alpha_swap, as
  5288. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  5289. @end table
  5290. @section inflate
  5291. Apply inflate effect to the video.
  5292. This filter replaces the pixel by the local(3x3) average by taking into account
  5293. only values higher than the pixel.
  5294. It accepts the following options:
  5295. @table @option
  5296. @item threshold0
  5297. @item threshold1
  5298. @item threshold2
  5299. @item threshold3
  5300. Allows to limit the maximum change for each plane, default is 65535.
  5301. If 0, plane will remain unchanged.
  5302. @end table
  5303. @section interlace
  5304. Simple interlacing filter from progressive contents. This interleaves upper (or
  5305. lower) lines from odd frames with lower (or upper) lines from even frames,
  5306. halving the frame rate and preserving image height.
  5307. @example
  5308. Original Original New Frame
  5309. Frame 'j' Frame 'j+1' (tff)
  5310. ========== =========== ==================
  5311. Line 0 --------------------> Frame 'j' Line 0
  5312. Line 1 Line 1 ----> Frame 'j+1' Line 1
  5313. Line 2 ---------------------> Frame 'j' Line 2
  5314. Line 3 Line 3 ----> Frame 'j+1' Line 3
  5315. ... ... ...
  5316. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  5317. @end example
  5318. It accepts the following optional parameters:
  5319. @table @option
  5320. @item scan
  5321. This determines whether the interlaced frame is taken from the even
  5322. (tff - default) or odd (bff) lines of the progressive frame.
  5323. @item lowpass
  5324. Enable (default) or disable the vertical lowpass filter to avoid twitter
  5325. interlacing and reduce moire patterns.
  5326. @end table
  5327. @section kerndeint
  5328. Deinterlace input video by applying Donald Graft's adaptive kernel
  5329. deinterling. Work on interlaced parts of a video to produce
  5330. progressive frames.
  5331. The description of the accepted parameters follows.
  5332. @table @option
  5333. @item thresh
  5334. Set the threshold which affects the filter's tolerance when
  5335. determining if a pixel line must be processed. It must be an integer
  5336. in the range [0,255] and defaults to 10. A value of 0 will result in
  5337. applying the process on every pixels.
  5338. @item map
  5339. Paint pixels exceeding the threshold value to white if set to 1.
  5340. Default is 0.
  5341. @item order
  5342. Set the fields order. Swap fields if set to 1, leave fields alone if
  5343. 0. Default is 0.
  5344. @item sharp
  5345. Enable additional sharpening if set to 1. Default is 0.
  5346. @item twoway
  5347. Enable twoway sharpening if set to 1. Default is 0.
  5348. @end table
  5349. @subsection Examples
  5350. @itemize
  5351. @item
  5352. Apply default values:
  5353. @example
  5354. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  5355. @end example
  5356. @item
  5357. Enable additional sharpening:
  5358. @example
  5359. kerndeint=sharp=1
  5360. @end example
  5361. @item
  5362. Paint processed pixels in white:
  5363. @example
  5364. kerndeint=map=1
  5365. @end example
  5366. @end itemize
  5367. @section lenscorrection
  5368. Correct radial lens distortion
  5369. This filter can be used to correct for radial distortion as can result from the use
  5370. of wide angle lenses, and thereby re-rectify the image. To find the right parameters
  5371. one can use tools available for example as part of opencv or simply trial-and-error.
  5372. To use opencv use the calibration sample (under samples/cpp) from the opencv sources
  5373. and extract the k1 and k2 coefficients from the resulting matrix.
  5374. Note that effectively the same filter is available in the open-source tools Krita and
  5375. Digikam from the KDE project.
  5376. In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
  5377. this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
  5378. brightness distribution, so you may want to use both filters together in certain
  5379. cases, though you will have to take care of ordering, i.e. whether vignetting should
  5380. be applied before or after lens correction.
  5381. @subsection Options
  5382. The filter accepts the following options:
  5383. @table @option
  5384. @item cx
  5385. Relative x-coordinate of the focal point of the image, and thereby the center of the
  5386. distortion. This value has a range [0,1] and is expressed as fractions of the image
  5387. width.
  5388. @item cy
  5389. Relative y-coordinate of the focal point of the image, and thereby the center of the
  5390. distortion. This value has a range [0,1] and is expressed as fractions of the image
  5391. height.
  5392. @item k1
  5393. Coefficient of the quadratic correction term. 0.5 means no correction.
  5394. @item k2
  5395. Coefficient of the double quadratic correction term. 0.5 means no correction.
  5396. @end table
  5397. The formula that generates the correction is:
  5398. @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)
  5399. where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
  5400. distances from the focal point in the source and target images, respectively.
  5401. @anchor{lut3d}
  5402. @section lut3d
  5403. Apply a 3D LUT to an input video.
  5404. The filter accepts the following options:
  5405. @table @option
  5406. @item file
  5407. Set the 3D LUT file name.
  5408. Currently supported formats:
  5409. @table @samp
  5410. @item 3dl
  5411. AfterEffects
  5412. @item cube
  5413. Iridas
  5414. @item dat
  5415. DaVinci
  5416. @item m3d
  5417. Pandora
  5418. @end table
  5419. @item interp
  5420. Select interpolation mode.
  5421. Available values are:
  5422. @table @samp
  5423. @item nearest
  5424. Use values from the nearest defined point.
  5425. @item trilinear
  5426. Interpolate values using the 8 points defining a cube.
  5427. @item tetrahedral
  5428. Interpolate values using a tetrahedron.
  5429. @end table
  5430. @end table
  5431. @section lut, lutrgb, lutyuv
  5432. Compute a look-up table for binding each pixel component input value
  5433. to an output value, and apply it to the input video.
  5434. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  5435. to an RGB input video.
  5436. These filters accept the following parameters:
  5437. @table @option
  5438. @item c0
  5439. set first pixel component expression
  5440. @item c1
  5441. set second pixel component expression
  5442. @item c2
  5443. set third pixel component expression
  5444. @item c3
  5445. set fourth pixel component expression, corresponds to the alpha component
  5446. @item r
  5447. set red component expression
  5448. @item g
  5449. set green component expression
  5450. @item b
  5451. set blue component expression
  5452. @item a
  5453. alpha component expression
  5454. @item y
  5455. set Y/luminance component expression
  5456. @item u
  5457. set U/Cb component expression
  5458. @item v
  5459. set V/Cr component expression
  5460. @end table
  5461. Each of them specifies the expression to use for computing the lookup table for
  5462. the corresponding pixel component values.
  5463. The exact component associated to each of the @var{c*} options depends on the
  5464. format in input.
  5465. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  5466. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  5467. The expressions can contain the following constants and functions:
  5468. @table @option
  5469. @item w
  5470. @item h
  5471. The input width and height.
  5472. @item val
  5473. The input value for the pixel component.
  5474. @item clipval
  5475. The input value, clipped to the @var{minval}-@var{maxval} range.
  5476. @item maxval
  5477. The maximum value for the pixel component.
  5478. @item minval
  5479. The minimum value for the pixel component.
  5480. @item negval
  5481. The negated value for the pixel component value, clipped to the
  5482. @var{minval}-@var{maxval} range; it corresponds to the expression
  5483. "maxval-clipval+minval".
  5484. @item clip(val)
  5485. The computed value in @var{val}, clipped to the
  5486. @var{minval}-@var{maxval} range.
  5487. @item gammaval(gamma)
  5488. The computed gamma correction value of the pixel component value,
  5489. clipped to the @var{minval}-@var{maxval} range. It corresponds to the
  5490. expression
  5491. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  5492. @end table
  5493. All expressions default to "val".
  5494. @subsection Examples
  5495. @itemize
  5496. @item
  5497. Negate input video:
  5498. @example
  5499. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  5500. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  5501. @end example
  5502. The above is the same as:
  5503. @example
  5504. lutrgb="r=negval:g=negval:b=negval"
  5505. lutyuv="y=negval:u=negval:v=negval"
  5506. @end example
  5507. @item
  5508. Negate luminance:
  5509. @example
  5510. lutyuv=y=negval
  5511. @end example
  5512. @item
  5513. Remove chroma components, turning the video into a graytone image:
  5514. @example
  5515. lutyuv="u=128:v=128"
  5516. @end example
  5517. @item
  5518. Apply a luma burning effect:
  5519. @example
  5520. lutyuv="y=2*val"
  5521. @end example
  5522. @item
  5523. Remove green and blue components:
  5524. @example
  5525. lutrgb="g=0:b=0"
  5526. @end example
  5527. @item
  5528. Set a constant alpha channel value on input:
  5529. @example
  5530. format=rgba,lutrgb=a="maxval-minval/2"
  5531. @end example
  5532. @item
  5533. Correct luminance gamma by a factor of 0.5:
  5534. @example
  5535. lutyuv=y=gammaval(0.5)
  5536. @end example
  5537. @item
  5538. Discard least significant bits of luma:
  5539. @example
  5540. lutyuv=y='bitand(val, 128+64+32)'
  5541. @end example
  5542. @end itemize
  5543. @section mergeplanes
  5544. Merge color channel components from several video streams.
  5545. The filter accepts up to 4 input streams, and merge selected input
  5546. planes to the output video.
  5547. This filter accepts the following options:
  5548. @table @option
  5549. @item mapping
  5550. Set input to output plane mapping. Default is @code{0}.
  5551. The mappings is specified as a bitmap. It should be specified as a
  5552. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  5553. mapping for the first plane of the output stream. 'A' sets the number of
  5554. the input stream to use (from 0 to 3), and 'a' the plane number of the
  5555. corresponding input to use (from 0 to 3). The rest of the mappings is
  5556. similar, 'Bb' describes the mapping for the output stream second
  5557. plane, 'Cc' describes the mapping for the output stream third plane and
  5558. 'Dd' describes the mapping for the output stream fourth plane.
  5559. @item format
  5560. Set output pixel format. Default is @code{yuva444p}.
  5561. @end table
  5562. @subsection Examples
  5563. @itemize
  5564. @item
  5565. Merge three gray video streams of same width and height into single video stream:
  5566. @example
  5567. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  5568. @end example
  5569. @item
  5570. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  5571. @example
  5572. [a0][a1]mergeplanes=0x00010210:yuva444p
  5573. @end example
  5574. @item
  5575. Swap Y and A plane in yuva444p stream:
  5576. @example
  5577. format=yuva444p,mergeplanes=0x03010200:yuva444p
  5578. @end example
  5579. @item
  5580. Swap U and V plane in yuv420p stream:
  5581. @example
  5582. format=yuv420p,mergeplanes=0x000201:yuv420p
  5583. @end example
  5584. @item
  5585. Cast a rgb24 clip to yuv444p:
  5586. @example
  5587. format=rgb24,mergeplanes=0x000102:yuv444p
  5588. @end example
  5589. @end itemize
  5590. @section mcdeint
  5591. Apply motion-compensation deinterlacing.
  5592. It needs one field per frame as input and must thus be used together
  5593. with yadif=1/3 or equivalent.
  5594. This filter accepts the following options:
  5595. @table @option
  5596. @item mode
  5597. Set the deinterlacing mode.
  5598. It accepts one of the following values:
  5599. @table @samp
  5600. @item fast
  5601. @item medium
  5602. @item slow
  5603. use iterative motion estimation
  5604. @item extra_slow
  5605. like @samp{slow}, but use multiple reference frames.
  5606. @end table
  5607. Default value is @samp{fast}.
  5608. @item parity
  5609. Set the picture field parity assumed for the input video. It must be
  5610. one of the following values:
  5611. @table @samp
  5612. @item 0, tff
  5613. assume top field first
  5614. @item 1, bff
  5615. assume bottom field first
  5616. @end table
  5617. Default value is @samp{bff}.
  5618. @item qp
  5619. Set per-block quantization parameter (QP) used by the internal
  5620. encoder.
  5621. Higher values should result in a smoother motion vector field but less
  5622. optimal individual vectors. Default value is 1.
  5623. @end table
  5624. @section mpdecimate
  5625. Drop frames that do not differ greatly from the previous frame in
  5626. order to reduce frame rate.
  5627. The main use of this filter is for very-low-bitrate encoding
  5628. (e.g. streaming over dialup modem), but it could in theory be used for
  5629. fixing movies that were inverse-telecined incorrectly.
  5630. A description of the accepted options follows.
  5631. @table @option
  5632. @item max
  5633. Set the maximum number of consecutive frames which can be dropped (if
  5634. positive), or the minimum interval between dropped frames (if
  5635. negative). If the value is 0, the frame is dropped unregarding the
  5636. number of previous sequentially dropped frames.
  5637. Default value is 0.
  5638. @item hi
  5639. @item lo
  5640. @item frac
  5641. Set the dropping threshold values.
  5642. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  5643. represent actual pixel value differences, so a threshold of 64
  5644. corresponds to 1 unit of difference for each pixel, or the same spread
  5645. out differently over the block.
  5646. A frame is a candidate for dropping if no 8x8 blocks differ by more
  5647. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  5648. meaning the whole image) differ by more than a threshold of @option{lo}.
  5649. Default value for @option{hi} is 64*12, default value for @option{lo} is
  5650. 64*5, and default value for @option{frac} is 0.33.
  5651. @end table
  5652. @section negate
  5653. Negate input video.
  5654. It accepts an integer in input; if non-zero it negates the
  5655. alpha component (if available). The default value in input is 0.
  5656. @section noformat
  5657. Force libavfilter not to use any of the specified pixel formats for the
  5658. input to the next filter.
  5659. It accepts the following parameters:
  5660. @table @option
  5661. @item pix_fmts
  5662. A '|'-separated list of pixel format names, such as
  5663. apix_fmts=yuv420p|monow|rgb24".
  5664. @end table
  5665. @subsection Examples
  5666. @itemize
  5667. @item
  5668. Force libavfilter to use a format different from @var{yuv420p} for the
  5669. input to the vflip filter:
  5670. @example
  5671. noformat=pix_fmts=yuv420p,vflip
  5672. @end example
  5673. @item
  5674. Convert the input video to any of the formats not contained in the list:
  5675. @example
  5676. noformat=yuv420p|yuv444p|yuv410p
  5677. @end example
  5678. @end itemize
  5679. @section noise
  5680. Add noise on video input frame.
  5681. The filter accepts the following options:
  5682. @table @option
  5683. @item all_seed
  5684. @item c0_seed
  5685. @item c1_seed
  5686. @item c2_seed
  5687. @item c3_seed
  5688. Set noise seed for specific pixel component or all pixel components in case
  5689. of @var{all_seed}. Default value is @code{123457}.
  5690. @item all_strength, alls
  5691. @item c0_strength, c0s
  5692. @item c1_strength, c1s
  5693. @item c2_strength, c2s
  5694. @item c3_strength, c3s
  5695. Set noise strength for specific pixel component or all pixel components in case
  5696. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  5697. @item all_flags, allf
  5698. @item c0_flags, c0f
  5699. @item c1_flags, c1f
  5700. @item c2_flags, c2f
  5701. @item c3_flags, c3f
  5702. Set pixel component flags or set flags for all components if @var{all_flags}.
  5703. Available values for component flags are:
  5704. @table @samp
  5705. @item a
  5706. averaged temporal noise (smoother)
  5707. @item p
  5708. mix random noise with a (semi)regular pattern
  5709. @item t
  5710. temporal noise (noise pattern changes between frames)
  5711. @item u
  5712. uniform noise (gaussian otherwise)
  5713. @end table
  5714. @end table
  5715. @subsection Examples
  5716. Add temporal and uniform noise to input video:
  5717. @example
  5718. noise=alls=20:allf=t+u
  5719. @end example
  5720. @section null
  5721. Pass the video source unchanged to the output.
  5722. @section ocv
  5723. Apply a video transform using libopencv.
  5724. To enable this filter, install the libopencv library and headers and
  5725. configure FFmpeg with @code{--enable-libopencv}.
  5726. It accepts the following parameters:
  5727. @table @option
  5728. @item filter_name
  5729. The name of the libopencv filter to apply.
  5730. @item filter_params
  5731. The parameters to pass to the libopencv filter. If not specified, the default
  5732. values are assumed.
  5733. @end table
  5734. Refer to the official libopencv documentation for more precise
  5735. information:
  5736. @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
  5737. Several libopencv filters are supported; see the following subsections.
  5738. @anchor{dilate}
  5739. @subsection dilate
  5740. Dilate an image by using a specific structuring element.
  5741. It corresponds to the libopencv function @code{cvDilate}.
  5742. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  5743. @var{struct_el} represents a structuring element, and has the syntax:
  5744. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  5745. @var{cols} and @var{rows} represent the number of columns and rows of
  5746. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  5747. point, and @var{shape} the shape for the structuring element. @var{shape}
  5748. must be "rect", "cross", "ellipse", or "custom".
  5749. If the value for @var{shape} is "custom", it must be followed by a
  5750. string of the form "=@var{filename}". The file with name
  5751. @var{filename} is assumed to represent a binary image, with each
  5752. printable character corresponding to a bright pixel. When a custom
  5753. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  5754. or columns and rows of the read file are assumed instead.
  5755. The default value for @var{struct_el} is "3x3+0x0/rect".
  5756. @var{nb_iterations} specifies the number of times the transform is
  5757. applied to the image, and defaults to 1.
  5758. Some examples:
  5759. @example
  5760. # Use the default values
  5761. ocv=dilate
  5762. # Dilate using a structuring element with a 5x5 cross, iterating two times
  5763. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  5764. # Read the shape from the file diamond.shape, iterating two times.
  5765. # The file diamond.shape may contain a pattern of characters like this
  5766. # *
  5767. # ***
  5768. # *****
  5769. # ***
  5770. # *
  5771. # The specified columns and rows are ignored
  5772. # but the anchor point coordinates are not
  5773. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  5774. @end example
  5775. @subsection erode
  5776. Erode an image by using a specific structuring element.
  5777. It corresponds to the libopencv function @code{cvErode}.
  5778. It accepts the parameters: @var{struct_el}:@var{nb_iterations},
  5779. with the same syntax and semantics as the @ref{dilate} filter.
  5780. @subsection smooth
  5781. Smooth the input video.
  5782. The filter takes the following parameters:
  5783. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  5784. @var{type} is the type of smooth filter to apply, and must be one of
  5785. the following values: "blur", "blur_no_scale", "median", "gaussian",
  5786. or "bilateral". The default value is "gaussian".
  5787. The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
  5788. depend on the smooth type. @var{param1} and
  5789. @var{param2} accept integer positive values or 0. @var{param3} and
  5790. @var{param4} accept floating point values.
  5791. The default value for @var{param1} is 3. The default value for the
  5792. other parameters is 0.
  5793. These parameters correspond to the parameters assigned to the
  5794. libopencv function @code{cvSmooth}.
  5795. @anchor{overlay}
  5796. @section overlay
  5797. Overlay one video on top of another.
  5798. It takes two inputs and has one output. The first input is the "main"
  5799. video on which the second input is overlaid.
  5800. It accepts the following parameters:
  5801. A description of the accepted options follows.
  5802. @table @option
  5803. @item x
  5804. @item y
  5805. Set the expression for the x and y coordinates of the overlaid video
  5806. on the main video. Default value is "0" for both expressions. In case
  5807. the expression is invalid, it is set to a huge value (meaning that the
  5808. overlay will not be displayed within the output visible area).
  5809. @item eof_action
  5810. The action to take when EOF is encountered on the secondary input; it accepts
  5811. one of the following values:
  5812. @table @option
  5813. @item repeat
  5814. Repeat the last frame (the default).
  5815. @item endall
  5816. End both streams.
  5817. @item pass
  5818. Pass the main input through.
  5819. @end table
  5820. @item eval
  5821. Set when the expressions for @option{x}, and @option{y} are evaluated.
  5822. It accepts the following values:
  5823. @table @samp
  5824. @item init
  5825. only evaluate expressions once during the filter initialization or
  5826. when a command is processed
  5827. @item frame
  5828. evaluate expressions for each incoming frame
  5829. @end table
  5830. Default value is @samp{frame}.
  5831. @item shortest
  5832. If set to 1, force the output to terminate when the shortest input
  5833. terminates. Default value is 0.
  5834. @item format
  5835. Set the format for the output video.
  5836. It accepts the following values:
  5837. @table @samp
  5838. @item yuv420
  5839. force YUV420 output
  5840. @item yuv422
  5841. force YUV422 output
  5842. @item yuv444
  5843. force YUV444 output
  5844. @item rgb
  5845. force RGB output
  5846. @end table
  5847. Default value is @samp{yuv420}.
  5848. @item rgb @emph{(deprecated)}
  5849. If set to 1, force the filter to accept inputs in the RGB
  5850. color space. Default value is 0. This option is deprecated, use
  5851. @option{format} instead.
  5852. @item repeatlast
  5853. If set to 1, force the filter to draw the last overlay frame over the
  5854. main input until the end of the stream. A value of 0 disables this
  5855. behavior. Default value is 1.
  5856. @end table
  5857. The @option{x}, and @option{y} expressions can contain the following
  5858. parameters.
  5859. @table @option
  5860. @item main_w, W
  5861. @item main_h, H
  5862. The main input width and height.
  5863. @item overlay_w, w
  5864. @item overlay_h, h
  5865. The overlay input width and height.
  5866. @item x
  5867. @item y
  5868. The computed values for @var{x} and @var{y}. They are evaluated for
  5869. each new frame.
  5870. @item hsub
  5871. @item vsub
  5872. horizontal and vertical chroma subsample values of the output
  5873. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  5874. @var{vsub} is 1.
  5875. @item n
  5876. the number of input frame, starting from 0
  5877. @item pos
  5878. the position in the file of the input frame, NAN if unknown
  5879. @item t
  5880. The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
  5881. @end table
  5882. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  5883. when evaluation is done @emph{per frame}, and will evaluate to NAN
  5884. when @option{eval} is set to @samp{init}.
  5885. Be aware that frames are taken from each input video in timestamp
  5886. order, hence, if their initial timestamps differ, it is a good idea
  5887. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  5888. have them begin in the same zero timestamp, as the example for
  5889. the @var{movie} filter does.
  5890. You can chain together more overlays but you should test the
  5891. efficiency of such approach.
  5892. @subsection Commands
  5893. This filter supports the following commands:
  5894. @table @option
  5895. @item x
  5896. @item y
  5897. Modify the x and y of the overlay input.
  5898. The command accepts the same syntax of the corresponding option.
  5899. If the specified expression is not valid, it is kept at its current
  5900. value.
  5901. @end table
  5902. @subsection Examples
  5903. @itemize
  5904. @item
  5905. Draw the overlay at 10 pixels from the bottom right corner of the main
  5906. video:
  5907. @example
  5908. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  5909. @end example
  5910. Using named options the example above becomes:
  5911. @example
  5912. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  5913. @end example
  5914. @item
  5915. Insert a transparent PNG logo in the bottom left corner of the input,
  5916. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  5917. @example
  5918. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  5919. @end example
  5920. @item
  5921. Insert 2 different transparent PNG logos (second logo on bottom
  5922. right corner) using the @command{ffmpeg} tool:
  5923. @example
  5924. 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
  5925. @end example
  5926. @item
  5927. Add a transparent color layer on top of the main video; @code{WxH}
  5928. must specify the size of the main input to the overlay filter:
  5929. @example
  5930. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  5931. @end example
  5932. @item
  5933. Play an original video and a filtered version (here with the deshake
  5934. filter) side by side using the @command{ffplay} tool:
  5935. @example
  5936. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  5937. @end example
  5938. The above command is the same as:
  5939. @example
  5940. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  5941. @end example
  5942. @item
  5943. Make a sliding overlay appearing from the left to the right top part of the
  5944. screen starting since time 2:
  5945. @example
  5946. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  5947. @end example
  5948. @item
  5949. Compose output by putting two input videos side to side:
  5950. @example
  5951. ffmpeg -i left.avi -i right.avi -filter_complex "
  5952. nullsrc=size=200x100 [background];
  5953. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  5954. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  5955. [background][left] overlay=shortest=1 [background+left];
  5956. [background+left][right] overlay=shortest=1:x=100 [left+right]
  5957. "
  5958. @end example
  5959. @item
  5960. Mask 10-20 seconds of a video by applying the delogo filter to a section
  5961. @example
  5962. ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
  5963. -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]'
  5964. masked.avi
  5965. @end example
  5966. @item
  5967. Chain several overlays in cascade:
  5968. @example
  5969. nullsrc=s=200x200 [bg];
  5970. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  5971. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  5972. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  5973. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  5974. [in3] null, [mid2] overlay=100:100 [out0]
  5975. @end example
  5976. @end itemize
  5977. @section owdenoise
  5978. Apply Overcomplete Wavelet denoiser.
  5979. The filter accepts the following options:
  5980. @table @option
  5981. @item depth
  5982. Set depth.
  5983. Larger depth values will denoise lower frequency components more, but
  5984. slow down filtering.
  5985. Must be an int in the range 8-16, default is @code{8}.
  5986. @item luma_strength, ls
  5987. Set luma strength.
  5988. Must be a double value in the range 0-1000, default is @code{1.0}.
  5989. @item chroma_strength, cs
  5990. Set chroma strength.
  5991. Must be a double value in the range 0-1000, default is @code{1.0}.
  5992. @end table
  5993. @anchor{pad}
  5994. @section pad
  5995. Add paddings to the input image, and place the original input at the
  5996. provided @var{x}, @var{y} coordinates.
  5997. It accepts the following parameters:
  5998. @table @option
  5999. @item width, w
  6000. @item height, h
  6001. Specify an expression for the size of the output image with the
  6002. paddings added. If the value for @var{width} or @var{height} is 0, the
  6003. corresponding input size is used for the output.
  6004. The @var{width} expression can reference the value set by the
  6005. @var{height} expression, and vice versa.
  6006. The default value of @var{width} and @var{height} is 0.
  6007. @item x
  6008. @item y
  6009. Specify the offsets to place the input image at within the padded area,
  6010. with respect to the top/left border of the output image.
  6011. The @var{x} expression can reference the value set by the @var{y}
  6012. expression, and vice versa.
  6013. The default value of @var{x} and @var{y} is 0.
  6014. @item color
  6015. Specify the color of the padded area. For the syntax of this option,
  6016. check the "Color" section in the ffmpeg-utils manual.
  6017. The default value of @var{color} is "black".
  6018. @end table
  6019. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  6020. options are expressions containing the following constants:
  6021. @table @option
  6022. @item in_w
  6023. @item in_h
  6024. The input video width and height.
  6025. @item iw
  6026. @item ih
  6027. These are the same as @var{in_w} and @var{in_h}.
  6028. @item out_w
  6029. @item out_h
  6030. The output width and height (the size of the padded area), as
  6031. specified by the @var{width} and @var{height} expressions.
  6032. @item ow
  6033. @item oh
  6034. These are the same as @var{out_w} and @var{out_h}.
  6035. @item x
  6036. @item y
  6037. The x and y offsets as specified by the @var{x} and @var{y}
  6038. expressions, or NAN if not yet specified.
  6039. @item a
  6040. same as @var{iw} / @var{ih}
  6041. @item sar
  6042. input sample aspect ratio
  6043. @item dar
  6044. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  6045. @item hsub
  6046. @item vsub
  6047. The horizontal and vertical chroma subsample values. For example for the
  6048. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6049. @end table
  6050. @subsection Examples
  6051. @itemize
  6052. @item
  6053. Add paddings with the color "violet" to the input video. The output video
  6054. size is 640x480, and the top-left corner of the input video is placed at
  6055. column 0, row 40
  6056. @example
  6057. pad=640:480:0:40:violet
  6058. @end example
  6059. The example above is equivalent to the following command:
  6060. @example
  6061. pad=width=640:height=480:x=0:y=40:color=violet
  6062. @end example
  6063. @item
  6064. Pad the input to get an output with dimensions increased by 3/2,
  6065. and put the input video at the center of the padded area:
  6066. @example
  6067. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  6068. @end example
  6069. @item
  6070. Pad the input to get a squared output with size equal to the maximum
  6071. value between the input width and height, and put the input video at
  6072. the center of the padded area:
  6073. @example
  6074. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  6075. @end example
  6076. @item
  6077. Pad the input to get a final w/h ratio of 16:9:
  6078. @example
  6079. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  6080. @end example
  6081. @item
  6082. In case of anamorphic video, in order to set the output display aspect
  6083. correctly, it is necessary to use @var{sar} in the expression,
  6084. according to the relation:
  6085. @example
  6086. (ih * X / ih) * sar = output_dar
  6087. X = output_dar / sar
  6088. @end example
  6089. Thus the previous example needs to be modified to:
  6090. @example
  6091. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  6092. @end example
  6093. @item
  6094. Double the output size and put the input video in the bottom-right
  6095. corner of the output padded area:
  6096. @example
  6097. pad="2*iw:2*ih:ow-iw:oh-ih"
  6098. @end example
  6099. @end itemize
  6100. @anchor{palettegen}
  6101. @section palettegen
  6102. Generate one palette for a whole video stream.
  6103. It accepts the following options:
  6104. @table @option
  6105. @item max_colors
  6106. Set the maximum number of colors to quantize in the palette.
  6107. Note: the palette will still contain 256 colors; the unused palette entries
  6108. will be black.
  6109. @item reserve_transparent
  6110. Create a palette of 255 colors maximum and reserve the last one for
  6111. transparency. Reserving the transparency color is useful for GIF optimization.
  6112. If not set, the maximum of colors in the palette will be 256. You probably want
  6113. to disable this option for a standalone image.
  6114. Set by default.
  6115. @item stats_mode
  6116. Set statistics mode.
  6117. It accepts the following values:
  6118. @table @samp
  6119. @item full
  6120. Compute full frame histograms.
  6121. @item diff
  6122. Compute histograms only for the part that differs from previous frame. This
  6123. might be relevant to give more importance to the moving part of your input if
  6124. the background is static.
  6125. @end table
  6126. Default value is @var{full}.
  6127. @end table
  6128. The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
  6129. (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
  6130. color quantization of the palette. This information is also visible at
  6131. @var{info} logging level.
  6132. @subsection Examples
  6133. @itemize
  6134. @item
  6135. Generate a representative palette of a given video using @command{ffmpeg}:
  6136. @example
  6137. ffmpeg -i input.mkv -vf palettegen palette.png
  6138. @end example
  6139. @end itemize
  6140. @section paletteuse
  6141. Use a palette to downsample an input video stream.
  6142. The filter takes two inputs: one video stream and a palette. The palette must
  6143. be a 256 pixels image.
  6144. It accepts the following options:
  6145. @table @option
  6146. @item dither
  6147. Select dithering mode. Available algorithms are:
  6148. @table @samp
  6149. @item bayer
  6150. Ordered 8x8 bayer dithering (deterministic)
  6151. @item heckbert
  6152. Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
  6153. Note: this dithering is sometimes considered "wrong" and is included as a
  6154. reference.
  6155. @item floyd_steinberg
  6156. Floyd and Steingberg dithering (error diffusion)
  6157. @item sierra2
  6158. Frankie Sierra dithering v2 (error diffusion)
  6159. @item sierra2_4a
  6160. Frankie Sierra dithering v2 "Lite" (error diffusion)
  6161. @end table
  6162. Default is @var{sierra2_4a}.
  6163. @item bayer_scale
  6164. When @var{bayer} dithering is selected, this option defines the scale of the
  6165. pattern (how much the crosshatch pattern is visible). A low value means more
  6166. visible pattern for less banding, and higher value means less visible pattern
  6167. at the cost of more banding.
  6168. The option must be an integer value in the range [0,5]. Default is @var{2}.
  6169. @item diff_mode
  6170. If set, define the zone to process
  6171. @table @samp
  6172. @item rectangle
  6173. Only the changing rectangle will be reprocessed. This is similar to GIF
  6174. cropping/offsetting compression mechanism. This option can be useful for speed
  6175. if only a part of the image is changing, and has use cases such as limiting the
  6176. scope of the error diffusal @option{dither} to the rectangle that bounds the
  6177. moving scene (it leads to more deterministic output if the scene doesn't change
  6178. much, and as a result less moving noise and better GIF compression).
  6179. @end table
  6180. Default is @var{none}.
  6181. @end table
  6182. @subsection Examples
  6183. @itemize
  6184. @item
  6185. Use a palette (generated for example with @ref{palettegen}) to encode a GIF
  6186. using @command{ffmpeg}:
  6187. @example
  6188. ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
  6189. @end example
  6190. @end itemize
  6191. @section perspective
  6192. Correct perspective of video not recorded perpendicular to the screen.
  6193. A description of the accepted parameters follows.
  6194. @table @option
  6195. @item x0
  6196. @item y0
  6197. @item x1
  6198. @item y1
  6199. @item x2
  6200. @item y2
  6201. @item x3
  6202. @item y3
  6203. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  6204. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  6205. If the @code{sense} option is set to @code{source}, then the specified points will be sent
  6206. to the corners of the destination. If the @code{sense} option is set to @code{destination},
  6207. then the corners of the source will be sent to the specified coordinates.
  6208. The expressions can use the following variables:
  6209. @table @option
  6210. @item W
  6211. @item H
  6212. the width and height of video frame.
  6213. @end table
  6214. @item interpolation
  6215. Set interpolation for perspective correction.
  6216. It accepts the following values:
  6217. @table @samp
  6218. @item linear
  6219. @item cubic
  6220. @end table
  6221. Default value is @samp{linear}.
  6222. @item sense
  6223. Set interpretation of coordinate options.
  6224. It accepts the following values:
  6225. @table @samp
  6226. @item 0, source
  6227. Send point in the source specified by the given coordinates to
  6228. the corners of the destination.
  6229. @item 1, destination
  6230. Send the corners of the source to the point in the destination specified
  6231. by the given coordinates.
  6232. Default value is @samp{source}.
  6233. @end table
  6234. @end table
  6235. @section phase
  6236. Delay interlaced video by one field time so that the field order changes.
  6237. The intended use is to fix PAL movies that have been captured with the
  6238. opposite field order to the film-to-video transfer.
  6239. A description of the accepted parameters follows.
  6240. @table @option
  6241. @item mode
  6242. Set phase mode.
  6243. It accepts the following values:
  6244. @table @samp
  6245. @item t
  6246. Capture field order top-first, transfer bottom-first.
  6247. Filter will delay the bottom field.
  6248. @item b
  6249. Capture field order bottom-first, transfer top-first.
  6250. Filter will delay the top field.
  6251. @item p
  6252. Capture and transfer with the same field order. This mode only exists
  6253. for the documentation of the other options to refer to, but if you
  6254. actually select it, the filter will faithfully do nothing.
  6255. @item a
  6256. Capture field order determined automatically by field flags, transfer
  6257. opposite.
  6258. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  6259. basis using field flags. If no field information is available,
  6260. then this works just like @samp{u}.
  6261. @item u
  6262. Capture unknown or varying, transfer opposite.
  6263. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  6264. analyzing the images and selecting the alternative that produces best
  6265. match between the fields.
  6266. @item T
  6267. Capture top-first, transfer unknown or varying.
  6268. Filter selects among @samp{t} and @samp{p} using image analysis.
  6269. @item B
  6270. Capture bottom-first, transfer unknown or varying.
  6271. Filter selects among @samp{b} and @samp{p} using image analysis.
  6272. @item A
  6273. Capture determined by field flags, transfer unknown or varying.
  6274. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  6275. image analysis. If no field information is available, then this works just
  6276. like @samp{U}. This is the default mode.
  6277. @item U
  6278. Both capture and transfer unknown or varying.
  6279. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  6280. @end table
  6281. @end table
  6282. @section pixdesctest
  6283. Pixel format descriptor test filter, mainly useful for internal
  6284. testing. The output video should be equal to the input video.
  6285. For example:
  6286. @example
  6287. format=monow, pixdesctest
  6288. @end example
  6289. can be used to test the monowhite pixel format descriptor definition.
  6290. @section pp
  6291. Enable the specified chain of postprocessing subfilters using libpostproc. This
  6292. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  6293. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  6294. Each subfilter and some options have a short and a long name that can be used
  6295. interchangeably, i.e. dr/dering are the same.
  6296. The filters accept the following options:
  6297. @table @option
  6298. @item subfilters
  6299. Set postprocessing subfilters string.
  6300. @end table
  6301. All subfilters share common options to determine their scope:
  6302. @table @option
  6303. @item a/autoq
  6304. Honor the quality commands for this subfilter.
  6305. @item c/chrom
  6306. Do chrominance filtering, too (default).
  6307. @item y/nochrom
  6308. Do luminance filtering only (no chrominance).
  6309. @item n/noluma
  6310. Do chrominance filtering only (no luminance).
  6311. @end table
  6312. These options can be appended after the subfilter name, separated by a '|'.
  6313. Available subfilters are:
  6314. @table @option
  6315. @item hb/hdeblock[|difference[|flatness]]
  6316. Horizontal deblocking filter
  6317. @table @option
  6318. @item difference
  6319. Difference factor where higher values mean more deblocking (default: @code{32}).
  6320. @item flatness
  6321. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6322. @end table
  6323. @item vb/vdeblock[|difference[|flatness]]
  6324. Vertical deblocking filter
  6325. @table @option
  6326. @item difference
  6327. Difference factor where higher values mean more deblocking (default: @code{32}).
  6328. @item flatness
  6329. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6330. @end table
  6331. @item ha/hadeblock[|difference[|flatness]]
  6332. Accurate horizontal deblocking filter
  6333. @table @option
  6334. @item difference
  6335. Difference factor where higher values mean more deblocking (default: @code{32}).
  6336. @item flatness
  6337. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6338. @end table
  6339. @item va/vadeblock[|difference[|flatness]]
  6340. Accurate vertical deblocking filter
  6341. @table @option
  6342. @item difference
  6343. Difference factor where higher values mean more deblocking (default: @code{32}).
  6344. @item flatness
  6345. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6346. @end table
  6347. @end table
  6348. The horizontal and vertical deblocking filters share the difference and
  6349. flatness values so you cannot set different horizontal and vertical
  6350. thresholds.
  6351. @table @option
  6352. @item h1/x1hdeblock
  6353. Experimental horizontal deblocking filter
  6354. @item v1/x1vdeblock
  6355. Experimental vertical deblocking filter
  6356. @item dr/dering
  6357. Deringing filter
  6358. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  6359. @table @option
  6360. @item threshold1
  6361. larger -> stronger filtering
  6362. @item threshold2
  6363. larger -> stronger filtering
  6364. @item threshold3
  6365. larger -> stronger filtering
  6366. @end table
  6367. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  6368. @table @option
  6369. @item f/fullyrange
  6370. Stretch luminance to @code{0-255}.
  6371. @end table
  6372. @item lb/linblenddeint
  6373. Linear blend deinterlacing filter that deinterlaces the given block by
  6374. filtering all lines with a @code{(1 2 1)} filter.
  6375. @item li/linipoldeint
  6376. Linear interpolating deinterlacing filter that deinterlaces the given block by
  6377. linearly interpolating every second line.
  6378. @item ci/cubicipoldeint
  6379. Cubic interpolating deinterlacing filter deinterlaces the given block by
  6380. cubically interpolating every second line.
  6381. @item md/mediandeint
  6382. Median deinterlacing filter that deinterlaces the given block by applying a
  6383. median filter to every second line.
  6384. @item fd/ffmpegdeint
  6385. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  6386. second line with a @code{(-1 4 2 4 -1)} filter.
  6387. @item l5/lowpass5
  6388. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  6389. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  6390. @item fq/forceQuant[|quantizer]
  6391. Overrides the quantizer table from the input with the constant quantizer you
  6392. specify.
  6393. @table @option
  6394. @item quantizer
  6395. Quantizer to use
  6396. @end table
  6397. @item de/default
  6398. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  6399. @item fa/fast
  6400. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  6401. @item ac
  6402. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  6403. @end table
  6404. @subsection Examples
  6405. @itemize
  6406. @item
  6407. Apply horizontal and vertical deblocking, deringing and automatic
  6408. brightness/contrast:
  6409. @example
  6410. pp=hb/vb/dr/al
  6411. @end example
  6412. @item
  6413. Apply default filters without brightness/contrast correction:
  6414. @example
  6415. pp=de/-al
  6416. @end example
  6417. @item
  6418. Apply default filters and temporal denoiser:
  6419. @example
  6420. pp=default/tmpnoise|1|2|3
  6421. @end example
  6422. @item
  6423. Apply deblocking on luminance only, and switch vertical deblocking on or off
  6424. automatically depending on available CPU time:
  6425. @example
  6426. pp=hb|y/vb|a
  6427. @end example
  6428. @end itemize
  6429. @section pp7
  6430. Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
  6431. similar to spp = 6 with 7 point DCT, where only the center sample is
  6432. used after IDCT.
  6433. The filter accepts the following options:
  6434. @table @option
  6435. @item qp
  6436. Force a constant quantization parameter. It accepts an integer in range
  6437. 0 to 63. If not set, the filter will use the QP from the video stream
  6438. (if available).
  6439. @item mode
  6440. Set thresholding mode. Available modes are:
  6441. @table @samp
  6442. @item hard
  6443. Set hard thresholding.
  6444. @item soft
  6445. Set soft thresholding (better de-ringing effect, but likely blurrier).
  6446. @item medium
  6447. Set medium thresholding (good results, default).
  6448. @end table
  6449. @end table
  6450. @section psnr
  6451. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  6452. Ratio) between two input videos.
  6453. This filter takes in input two input videos, the first input is
  6454. considered the "main" source and is passed unchanged to the
  6455. output. The second input is used as a "reference" video for computing
  6456. the PSNR.
  6457. Both video inputs must have the same resolution and pixel format for
  6458. this filter to work correctly. Also it assumes that both inputs
  6459. have the same number of frames, which are compared one by one.
  6460. The obtained average PSNR is printed through the logging system.
  6461. The filter stores the accumulated MSE (mean squared error) of each
  6462. frame, and at the end of the processing it is averaged across all frames
  6463. equally, and the following formula is applied to obtain the PSNR:
  6464. @example
  6465. PSNR = 10*log10(MAX^2/MSE)
  6466. @end example
  6467. Where MAX is the average of the maximum values of each component of the
  6468. image.
  6469. The description of the accepted parameters follows.
  6470. @table @option
  6471. @item stats_file, f
  6472. If specified the filter will use the named file to save the PSNR of
  6473. each individual frame.
  6474. @end table
  6475. The file printed if @var{stats_file} is selected, contains a sequence of
  6476. key/value pairs of the form @var{key}:@var{value} for each compared
  6477. couple of frames.
  6478. A description of each shown parameter follows:
  6479. @table @option
  6480. @item n
  6481. sequential number of the input frame, starting from 1
  6482. @item mse_avg
  6483. Mean Square Error pixel-by-pixel average difference of the compared
  6484. frames, averaged over all the image components.
  6485. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  6486. Mean Square Error pixel-by-pixel average difference of the compared
  6487. frames for the component specified by the suffix.
  6488. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  6489. Peak Signal to Noise ratio of the compared frames for the component
  6490. specified by the suffix.
  6491. @end table
  6492. For example:
  6493. @example
  6494. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  6495. [main][ref] psnr="stats_file=stats.log" [out]
  6496. @end example
  6497. On this example the input file being processed is compared with the
  6498. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  6499. is stored in @file{stats.log}.
  6500. @anchor{pullup}
  6501. @section pullup
  6502. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  6503. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  6504. content.
  6505. The pullup filter is designed to take advantage of future context in making
  6506. its decisions. This filter is stateless in the sense that it does not lock
  6507. onto a pattern to follow, but it instead looks forward to the following
  6508. fields in order to identify matches and rebuild progressive frames.
  6509. To produce content with an even framerate, insert the fps filter after
  6510. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  6511. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  6512. The filter accepts the following options:
  6513. @table @option
  6514. @item jl
  6515. @item jr
  6516. @item jt
  6517. @item jb
  6518. These options set the amount of "junk" to ignore at the left, right, top, and
  6519. bottom of the image, respectively. Left and right are in units of 8 pixels,
  6520. while top and bottom are in units of 2 lines.
  6521. The default is 8 pixels on each side.
  6522. @item sb
  6523. Set the strict breaks. Setting this option to 1 will reduce the chances of
  6524. filter generating an occasional mismatched frame, but it may also cause an
  6525. excessive number of frames to be dropped during high motion sequences.
  6526. Conversely, setting it to -1 will make filter match fields more easily.
  6527. This may help processing of video where there is slight blurring between
  6528. the fields, but may also cause there to be interlaced frames in the output.
  6529. Default value is @code{0}.
  6530. @item mp
  6531. Set the metric plane to use. It accepts the following values:
  6532. @table @samp
  6533. @item l
  6534. Use luma plane.
  6535. @item u
  6536. Use chroma blue plane.
  6537. @item v
  6538. Use chroma red plane.
  6539. @end table
  6540. This option may be set to use chroma plane instead of the default luma plane
  6541. for doing filter's computations. This may improve accuracy on very clean
  6542. source material, but more likely will decrease accuracy, especially if there
  6543. is chroma noise (rainbow effect) or any grayscale video.
  6544. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  6545. load and make pullup usable in realtime on slow machines.
  6546. @end table
  6547. For best results (without duplicated frames in the output file) it is
  6548. necessary to change the output frame rate. For example, to inverse
  6549. telecine NTSC input:
  6550. @example
  6551. ffmpeg -i input -vf pullup -r 24000/1001 ...
  6552. @end example
  6553. @section qp
  6554. Change video quantization parameters (QP).
  6555. The filter accepts the following option:
  6556. @table @option
  6557. @item qp
  6558. Set expression for quantization parameter.
  6559. @end table
  6560. The expression is evaluated through the eval API and can contain, among others,
  6561. the following constants:
  6562. @table @var
  6563. @item known
  6564. 1 if index is not 129, 0 otherwise.
  6565. @item qp
  6566. Sequentional index starting from -129 to 128.
  6567. @end table
  6568. @subsection Examples
  6569. @itemize
  6570. @item
  6571. Some equation like:
  6572. @example
  6573. qp=2+2*sin(PI*qp)
  6574. @end example
  6575. @end itemize
  6576. @section random
  6577. Flush video frames from internal cache of frames into a random order.
  6578. No frame is discarded.
  6579. Inspired by @ref{frei0r} nervous filter.
  6580. @table @option
  6581. @item frames
  6582. Set size in number of frames of internal cache, in range from @code{2} to
  6583. @code{512}. Default is @code{30}.
  6584. @item seed
  6585. Set seed for random number generator, must be an integer included between
  6586. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  6587. less than @code{0}, the filter will try to use a good random seed on a
  6588. best effort basis.
  6589. @end table
  6590. @section removegrain
  6591. The removegrain filter is a spatial denoiser for progressive video.
  6592. @table @option
  6593. @item m0
  6594. Set mode for the first plane.
  6595. @item m1
  6596. Set mode for the second plane.
  6597. @item m2
  6598. Set mode for the third plane.
  6599. @item m3
  6600. Set mode for the fourth plane.
  6601. @end table
  6602. Range of mode is from 0 to 24. Description of each mode follows:
  6603. @table @var
  6604. @item 0
  6605. Leave input plane unchanged. Default.
  6606. @item 1
  6607. Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
  6608. @item 2
  6609. Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
  6610. @item 3
  6611. Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
  6612. @item 4
  6613. Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
  6614. This is equivalent to a median filter.
  6615. @item 5
  6616. Line-sensitive clipping giving the minimal change.
  6617. @item 6
  6618. Line-sensitive clipping, intermediate.
  6619. @item 7
  6620. Line-sensitive clipping, intermediate.
  6621. @item 8
  6622. Line-sensitive clipping, intermediate.
  6623. @item 9
  6624. Line-sensitive clipping on a line where the neighbours pixels are the closest.
  6625. @item 10
  6626. Replaces the target pixel with the closest neighbour.
  6627. @item 11
  6628. [1 2 1] horizontal and vertical kernel blur.
  6629. @item 12
  6630. Same as mode 11.
  6631. @item 13
  6632. Bob mode, interpolates top field from the line where the neighbours
  6633. pixels are the closest.
  6634. @item 14
  6635. Bob mode, interpolates bottom field from the line where the neighbours
  6636. pixels are the closest.
  6637. @item 15
  6638. Bob mode, interpolates top field. Same as 13 but with a more complicated
  6639. interpolation formula.
  6640. @item 16
  6641. Bob mode, interpolates bottom field. Same as 14 but with a more complicated
  6642. interpolation formula.
  6643. @item 17
  6644. Clips the pixel with the minimum and maximum of respectively the maximum and
  6645. minimum of each pair of opposite neighbour pixels.
  6646. @item 18
  6647. Line-sensitive clipping using opposite neighbours whose greatest distance from
  6648. the current pixel is minimal.
  6649. @item 19
  6650. Replaces the pixel with the average of its 8 neighbours.
  6651. @item 20
  6652. Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
  6653. @item 21
  6654. Clips pixels using the averages of opposite neighbour.
  6655. @item 22
  6656. Same as mode 21 but simpler and faster.
  6657. @item 23
  6658. Small edge and halo removal, but reputed useless.
  6659. @item 24
  6660. Similar as 23.
  6661. @end table
  6662. @section removelogo
  6663. Suppress a TV station logo, using an image file to determine which
  6664. pixels comprise the logo. It works by filling in the pixels that
  6665. comprise the logo with neighboring pixels.
  6666. The filter accepts the following options:
  6667. @table @option
  6668. @item filename, f
  6669. Set the filter bitmap file, which can be any image format supported by
  6670. libavformat. The width and height of the image file must match those of the
  6671. video stream being processed.
  6672. @end table
  6673. Pixels in the provided bitmap image with a value of zero are not
  6674. considered part of the logo, non-zero pixels are considered part of
  6675. the logo. If you use white (255) for the logo and black (0) for the
  6676. rest, you will be safe. For making the filter bitmap, it is
  6677. recommended to take a screen capture of a black frame with the logo
  6678. visible, and then using a threshold filter followed by the erode
  6679. filter once or twice.
  6680. If needed, little splotches can be fixed manually. Remember that if
  6681. logo pixels are not covered, the filter quality will be much
  6682. reduced. Marking too many pixels as part of the logo does not hurt as
  6683. much, but it will increase the amount of blurring needed to cover over
  6684. the image and will destroy more information than necessary, and extra
  6685. pixels will slow things down on a large logo.
  6686. @section repeatfields
  6687. This filter uses the repeat_field flag from the Video ES headers and hard repeats
  6688. fields based on its value.
  6689. @section reverse, areverse
  6690. Reverse a clip.
  6691. Warning: This filter requires memory to buffer the entire clip, so trimming
  6692. is suggested.
  6693. @subsection Examples
  6694. @itemize
  6695. @item
  6696. Take the first 5 seconds of a clip, and reverse it.
  6697. @example
  6698. trim=end=5,reverse
  6699. @end example
  6700. @end itemize
  6701. @section rotate
  6702. Rotate video by an arbitrary angle expressed in radians.
  6703. The filter accepts the following options:
  6704. A description of the optional parameters follows.
  6705. @table @option
  6706. @item angle, a
  6707. Set an expression for the angle by which to rotate the input video
  6708. clockwise, expressed as a number of radians. A negative value will
  6709. result in a counter-clockwise rotation. By default it is set to "0".
  6710. This expression is evaluated for each frame.
  6711. @item out_w, ow
  6712. Set the output width expression, default value is "iw".
  6713. This expression is evaluated just once during configuration.
  6714. @item out_h, oh
  6715. Set the output height expression, default value is "ih".
  6716. This expression is evaluated just once during configuration.
  6717. @item bilinear
  6718. Enable bilinear interpolation if set to 1, a value of 0 disables
  6719. it. Default value is 1.
  6720. @item fillcolor, c
  6721. Set the color used to fill the output area not covered by the rotated
  6722. image. For the general syntax of this option, check the "Color" section in the
  6723. ffmpeg-utils manual. If the special value "none" is selected then no
  6724. background is printed (useful for example if the background is never shown).
  6725. Default value is "black".
  6726. @end table
  6727. The expressions for the angle and the output size can contain the
  6728. following constants and functions:
  6729. @table @option
  6730. @item n
  6731. sequential number of the input frame, starting from 0. It is always NAN
  6732. before the first frame is filtered.
  6733. @item t
  6734. time in seconds of the input frame, it is set to 0 when the filter is
  6735. configured. It is always NAN before the first frame is filtered.
  6736. @item hsub
  6737. @item vsub
  6738. horizontal and vertical chroma subsample values. For example for the
  6739. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6740. @item in_w, iw
  6741. @item in_h, ih
  6742. the input video width and height
  6743. @item out_w, ow
  6744. @item out_h, oh
  6745. the output width and height, that is the size of the padded area as
  6746. specified by the @var{width} and @var{height} expressions
  6747. @item rotw(a)
  6748. @item roth(a)
  6749. the minimal width/height required for completely containing the input
  6750. video rotated by @var{a} radians.
  6751. These are only available when computing the @option{out_w} and
  6752. @option{out_h} expressions.
  6753. @end table
  6754. @subsection Examples
  6755. @itemize
  6756. @item
  6757. Rotate the input by PI/6 radians clockwise:
  6758. @example
  6759. rotate=PI/6
  6760. @end example
  6761. @item
  6762. Rotate the input by PI/6 radians counter-clockwise:
  6763. @example
  6764. rotate=-PI/6
  6765. @end example
  6766. @item
  6767. Rotate the input by 45 degrees clockwise:
  6768. @example
  6769. rotate=45*PI/180
  6770. @end example
  6771. @item
  6772. Apply a constant rotation with period T, starting from an angle of PI/3:
  6773. @example
  6774. rotate=PI/3+2*PI*t/T
  6775. @end example
  6776. @item
  6777. Make the input video rotation oscillating with a period of T
  6778. seconds and an amplitude of A radians:
  6779. @example
  6780. rotate=A*sin(2*PI/T*t)
  6781. @end example
  6782. @item
  6783. Rotate the video, output size is chosen so that the whole rotating
  6784. input video is always completely contained in the output:
  6785. @example
  6786. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  6787. @end example
  6788. @item
  6789. Rotate the video, reduce the output size so that no background is ever
  6790. shown:
  6791. @example
  6792. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  6793. @end example
  6794. @end itemize
  6795. @subsection Commands
  6796. The filter supports the following commands:
  6797. @table @option
  6798. @item a, angle
  6799. Set the angle expression.
  6800. The command accepts the same syntax of the corresponding option.
  6801. If the specified expression is not valid, it is kept at its current
  6802. value.
  6803. @end table
  6804. @section sab
  6805. Apply Shape Adaptive Blur.
  6806. The filter accepts the following options:
  6807. @table @option
  6808. @item luma_radius, lr
  6809. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  6810. value is 1.0. A greater value will result in a more blurred image, and
  6811. in slower processing.
  6812. @item luma_pre_filter_radius, lpfr
  6813. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  6814. value is 1.0.
  6815. @item luma_strength, ls
  6816. Set luma maximum difference between pixels to still be considered, must
  6817. be a value in the 0.1-100.0 range, default value is 1.0.
  6818. @item chroma_radius, cr
  6819. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  6820. greater value will result in a more blurred image, and in slower
  6821. processing.
  6822. @item chroma_pre_filter_radius, cpfr
  6823. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  6824. @item chroma_strength, cs
  6825. Set chroma maximum difference between pixels to still be considered,
  6826. must be a value in the 0.1-100.0 range.
  6827. @end table
  6828. Each chroma option value, if not explicitly specified, is set to the
  6829. corresponding luma option value.
  6830. @anchor{scale}
  6831. @section scale
  6832. Scale (resize) the input video, using the libswscale library.
  6833. The scale filter forces the output display aspect ratio to be the same
  6834. of the input, by changing the output sample aspect ratio.
  6835. If the input image format is different from the format requested by
  6836. the next filter, the scale filter will convert the input to the
  6837. requested format.
  6838. @subsection Options
  6839. The filter accepts the following options, or any of the options
  6840. supported by the libswscale scaler.
  6841. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  6842. the complete list of scaler options.
  6843. @table @option
  6844. @item width, w
  6845. @item height, h
  6846. Set the output video dimension expression. Default value is the input
  6847. dimension.
  6848. If the value is 0, the input width is used for the output.
  6849. If one of the values is -1, the scale filter will use a value that
  6850. maintains the aspect ratio of the input image, calculated from the
  6851. other specified dimension. If both of them are -1, the input size is
  6852. used
  6853. If one of the values is -n with n > 1, the scale filter will also use a value
  6854. that maintains the aspect ratio of the input image, calculated from the other
  6855. specified dimension. After that it will, however, make sure that the calculated
  6856. dimension is divisible by n and adjust the value if necessary.
  6857. See below for the list of accepted constants for use in the dimension
  6858. expression.
  6859. @item interl
  6860. Set the interlacing mode. It accepts the following values:
  6861. @table @samp
  6862. @item 1
  6863. Force interlaced aware scaling.
  6864. @item 0
  6865. Do not apply interlaced scaling.
  6866. @item -1
  6867. Select interlaced aware scaling depending on whether the source frames
  6868. are flagged as interlaced or not.
  6869. @end table
  6870. Default value is @samp{0}.
  6871. @item flags
  6872. Set libswscale scaling flags. See
  6873. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  6874. complete list of values. If not explicitly specified the filter applies
  6875. the default flags.
  6876. @item size, s
  6877. Set the video size. For the syntax of this option, check the
  6878. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  6879. @item in_color_matrix
  6880. @item out_color_matrix
  6881. Set in/output YCbCr color space type.
  6882. This allows the autodetected value to be overridden as well as allows forcing
  6883. a specific value used for the output and encoder.
  6884. If not specified, the color space type depends on the pixel format.
  6885. Possible values:
  6886. @table @samp
  6887. @item auto
  6888. Choose automatically.
  6889. @item bt709
  6890. Format conforming to International Telecommunication Union (ITU)
  6891. Recommendation BT.709.
  6892. @item fcc
  6893. Set color space conforming to the United States Federal Communications
  6894. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  6895. @item bt601
  6896. Set color space conforming to:
  6897. @itemize
  6898. @item
  6899. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  6900. @item
  6901. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  6902. @item
  6903. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  6904. @end itemize
  6905. @item smpte240m
  6906. Set color space conforming to SMPTE ST 240:1999.
  6907. @end table
  6908. @item in_range
  6909. @item out_range
  6910. Set in/output YCbCr sample range.
  6911. This allows the autodetected value to be overridden as well as allows forcing
  6912. a specific value used for the output and encoder. If not specified, the
  6913. range depends on the pixel format. Possible values:
  6914. @table @samp
  6915. @item auto
  6916. Choose automatically.
  6917. @item jpeg/full/pc
  6918. Set full range (0-255 in case of 8-bit luma).
  6919. @item mpeg/tv
  6920. Set "MPEG" range (16-235 in case of 8-bit luma).
  6921. @end table
  6922. @item force_original_aspect_ratio
  6923. Enable decreasing or increasing output video width or height if necessary to
  6924. keep the original aspect ratio. Possible values:
  6925. @table @samp
  6926. @item disable
  6927. Scale the video as specified and disable this feature.
  6928. @item decrease
  6929. The output video dimensions will automatically be decreased if needed.
  6930. @item increase
  6931. The output video dimensions will automatically be increased if needed.
  6932. @end table
  6933. One useful instance of this option is that when you know a specific device's
  6934. maximum allowed resolution, you can use this to limit the output video to
  6935. that, while retaining the aspect ratio. For example, device A allows
  6936. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  6937. decrease) and specifying 1280x720 to the command line makes the output
  6938. 1280x533.
  6939. Please note that this is a different thing than specifying -1 for @option{w}
  6940. or @option{h}, you still need to specify the output resolution for this option
  6941. to work.
  6942. @end table
  6943. The values of the @option{w} and @option{h} options are expressions
  6944. containing the following constants:
  6945. @table @var
  6946. @item in_w
  6947. @item in_h
  6948. The input width and height
  6949. @item iw
  6950. @item ih
  6951. These are the same as @var{in_w} and @var{in_h}.
  6952. @item out_w
  6953. @item out_h
  6954. The output (scaled) width and height
  6955. @item ow
  6956. @item oh
  6957. These are the same as @var{out_w} and @var{out_h}
  6958. @item a
  6959. The same as @var{iw} / @var{ih}
  6960. @item sar
  6961. input sample aspect ratio
  6962. @item dar
  6963. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  6964. @item hsub
  6965. @item vsub
  6966. horizontal and vertical input chroma subsample values. For example for the
  6967. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6968. @item ohsub
  6969. @item ovsub
  6970. horizontal and vertical output chroma subsample values. For example for the
  6971. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6972. @end table
  6973. @subsection Examples
  6974. @itemize
  6975. @item
  6976. Scale the input video to a size of 200x100
  6977. @example
  6978. scale=w=200:h=100
  6979. @end example
  6980. This is equivalent to:
  6981. @example
  6982. scale=200:100
  6983. @end example
  6984. or:
  6985. @example
  6986. scale=200x100
  6987. @end example
  6988. @item
  6989. Specify a size abbreviation for the output size:
  6990. @example
  6991. scale=qcif
  6992. @end example
  6993. which can also be written as:
  6994. @example
  6995. scale=size=qcif
  6996. @end example
  6997. @item
  6998. Scale the input to 2x:
  6999. @example
  7000. scale=w=2*iw:h=2*ih
  7001. @end example
  7002. @item
  7003. The above is the same as:
  7004. @example
  7005. scale=2*in_w:2*in_h
  7006. @end example
  7007. @item
  7008. Scale the input to 2x with forced interlaced scaling:
  7009. @example
  7010. scale=2*iw:2*ih:interl=1
  7011. @end example
  7012. @item
  7013. Scale the input to half size:
  7014. @example
  7015. scale=w=iw/2:h=ih/2
  7016. @end example
  7017. @item
  7018. Increase the width, and set the height to the same size:
  7019. @example
  7020. scale=3/2*iw:ow
  7021. @end example
  7022. @item
  7023. Seek Greek harmony:
  7024. @example
  7025. scale=iw:1/PHI*iw
  7026. scale=ih*PHI:ih
  7027. @end example
  7028. @item
  7029. Increase the height, and set the width to 3/2 of the height:
  7030. @example
  7031. scale=w=3/2*oh:h=3/5*ih
  7032. @end example
  7033. @item
  7034. Increase the size, making the size a multiple of the chroma
  7035. subsample values:
  7036. @example
  7037. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  7038. @end example
  7039. @item
  7040. Increase the width to a maximum of 500 pixels,
  7041. keeping the same aspect ratio as the input:
  7042. @example
  7043. scale=w='min(500\, iw*3/2):h=-1'
  7044. @end example
  7045. @end itemize
  7046. @subsection Commands
  7047. This filter supports the following commands:
  7048. @table @option
  7049. @item width, w
  7050. @item height, h
  7051. Set the output video dimension expression.
  7052. The command accepts the same syntax of the corresponding option.
  7053. If the specified expression is not valid, it is kept at its current
  7054. value.
  7055. @end table
  7056. @section scale2ref
  7057. Scale (resize) the input video, based on a reference video.
  7058. See the scale filter for available options, scale2ref supports the same but
  7059. uses the reference video instead of the main input as basis.
  7060. @subsection Examples
  7061. @itemize
  7062. @item
  7063. Scale a subtitle stream to match the main video in size before overlaying
  7064. @example
  7065. 'scale2ref[b][a];[a][b]overlay'
  7066. @end example
  7067. @end itemize
  7068. @section separatefields
  7069. The @code{separatefields} takes a frame-based video input and splits
  7070. each frame into its components fields, producing a new half height clip
  7071. with twice the frame rate and twice the frame count.
  7072. This filter use field-dominance information in frame to decide which
  7073. of each pair of fields to place first in the output.
  7074. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  7075. @section setdar, setsar
  7076. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  7077. output video.
  7078. This is done by changing the specified Sample (aka Pixel) Aspect
  7079. Ratio, according to the following equation:
  7080. @example
  7081. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  7082. @end example
  7083. Keep in mind that the @code{setdar} filter does not modify the pixel
  7084. dimensions of the video frame. Also, the display aspect ratio set by
  7085. this filter may be changed by later filters in the filterchain,
  7086. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  7087. applied.
  7088. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  7089. the filter output video.
  7090. Note that as a consequence of the application of this filter, the
  7091. output display aspect ratio will change according to the equation
  7092. above.
  7093. Keep in mind that the sample aspect ratio set by the @code{setsar}
  7094. filter may be changed by later filters in the filterchain, e.g. if
  7095. another "setsar" or a "setdar" filter is applied.
  7096. It accepts the following parameters:
  7097. @table @option
  7098. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  7099. Set the aspect ratio used by the filter.
  7100. The parameter can be a floating point number string, an expression, or
  7101. a string of the form @var{num}:@var{den}, where @var{num} and
  7102. @var{den} are the numerator and denominator of the aspect ratio. If
  7103. the parameter is not specified, it is assumed the value "0".
  7104. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  7105. should be escaped.
  7106. @item max
  7107. Set the maximum integer value to use for expressing numerator and
  7108. denominator when reducing the expressed aspect ratio to a rational.
  7109. Default value is @code{100}.
  7110. @end table
  7111. The parameter @var{sar} is an expression containing
  7112. the following constants:
  7113. @table @option
  7114. @item E, PI, PHI
  7115. These are approximated values for the mathematical constants e
  7116. (Euler's number), pi (Greek pi), and phi (the golden ratio).
  7117. @item w, h
  7118. The input width and height.
  7119. @item a
  7120. These are the same as @var{w} / @var{h}.
  7121. @item sar
  7122. The input sample aspect ratio.
  7123. @item dar
  7124. The input display aspect ratio. It is the same as
  7125. (@var{w} / @var{h}) * @var{sar}.
  7126. @item hsub, vsub
  7127. Horizontal and vertical chroma subsample values. For example, for the
  7128. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7129. @end table
  7130. @subsection Examples
  7131. @itemize
  7132. @item
  7133. To change the display aspect ratio to 16:9, specify one of the following:
  7134. @example
  7135. setdar=dar=1.77777
  7136. setdar=dar=16/9
  7137. setdar=dar=1.77777
  7138. @end example
  7139. @item
  7140. To change the sample aspect ratio to 10:11, specify:
  7141. @example
  7142. setsar=sar=10/11
  7143. @end example
  7144. @item
  7145. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  7146. 1000 in the aspect ratio reduction, use the command:
  7147. @example
  7148. setdar=ratio=16/9:max=1000
  7149. @end example
  7150. @end itemize
  7151. @anchor{setfield}
  7152. @section setfield
  7153. Force field for the output video frame.
  7154. The @code{setfield} filter marks the interlace type field for the
  7155. output frames. It does not change the input frame, but only sets the
  7156. corresponding property, which affects how the frame is treated by
  7157. following filters (e.g. @code{fieldorder} or @code{yadif}).
  7158. The filter accepts the following options:
  7159. @table @option
  7160. @item mode
  7161. Available values are:
  7162. @table @samp
  7163. @item auto
  7164. Keep the same field property.
  7165. @item bff
  7166. Mark the frame as bottom-field-first.
  7167. @item tff
  7168. Mark the frame as top-field-first.
  7169. @item prog
  7170. Mark the frame as progressive.
  7171. @end table
  7172. @end table
  7173. @section showinfo
  7174. Show a line containing various information for each input video frame.
  7175. The input video is not modified.
  7176. The shown line contains a sequence of key/value pairs of the form
  7177. @var{key}:@var{value}.
  7178. The following values are shown in the output:
  7179. @table @option
  7180. @item n
  7181. The (sequential) number of the input frame, starting from 0.
  7182. @item pts
  7183. The Presentation TimeStamp of the input frame, expressed as a number of
  7184. time base units. The time base unit depends on the filter input pad.
  7185. @item pts_time
  7186. The Presentation TimeStamp of the input frame, expressed as a number of
  7187. seconds.
  7188. @item pos
  7189. The position of the frame in the input stream, or -1 if this information is
  7190. unavailable and/or meaningless (for example in case of synthetic video).
  7191. @item fmt
  7192. The pixel format name.
  7193. @item sar
  7194. The sample aspect ratio of the input frame, expressed in the form
  7195. @var{num}/@var{den}.
  7196. @item s
  7197. The size of the input frame. For the syntax of this option, check the
  7198. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7199. @item i
  7200. The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
  7201. for bottom field first).
  7202. @item iskey
  7203. This is 1 if the frame is a key frame, 0 otherwise.
  7204. @item type
  7205. The picture type of the input frame ("I" for an I-frame, "P" for a
  7206. P-frame, "B" for a B-frame, or "?" for an unknown type).
  7207. Also refer to the documentation of the @code{AVPictureType} enum and of
  7208. the @code{av_get_picture_type_char} function defined in
  7209. @file{libavutil/avutil.h}.
  7210. @item checksum
  7211. The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
  7212. @item plane_checksum
  7213. The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  7214. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
  7215. @end table
  7216. @section showpalette
  7217. Displays the 256 colors palette of each frame. This filter is only relevant for
  7218. @var{pal8} pixel format frames.
  7219. It accepts the following option:
  7220. @table @option
  7221. @item s
  7222. Set the size of the box used to represent one palette color entry. Default is
  7223. @code{30} (for a @code{30x30} pixel box).
  7224. @end table
  7225. @section shuffleplanes
  7226. Reorder and/or duplicate video planes.
  7227. It accepts the following parameters:
  7228. @table @option
  7229. @item map0
  7230. The index of the input plane to be used as the first output plane.
  7231. @item map1
  7232. The index of the input plane to be used as the second output plane.
  7233. @item map2
  7234. The index of the input plane to be used as the third output plane.
  7235. @item map3
  7236. The index of the input plane to be used as the fourth output plane.
  7237. @end table
  7238. The first plane has the index 0. The default is to keep the input unchanged.
  7239. Swap the second and third planes of the input:
  7240. @example
  7241. ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
  7242. @end example
  7243. @anchor{signalstats}
  7244. @section signalstats
  7245. Evaluate various visual metrics that assist in determining issues associated
  7246. with the digitization of analog video media.
  7247. By default the filter will log these metadata values:
  7248. @table @option
  7249. @item YMIN
  7250. Display the minimal Y value contained within the input frame. Expressed in
  7251. range of [0-255].
  7252. @item YLOW
  7253. Display the Y value at the 10% percentile within the input frame. Expressed in
  7254. range of [0-255].
  7255. @item YAVG
  7256. Display the average Y value within the input frame. Expressed in range of
  7257. [0-255].
  7258. @item YHIGH
  7259. Display the Y value at the 90% percentile within the input frame. Expressed in
  7260. range of [0-255].
  7261. @item YMAX
  7262. Display the maximum Y value contained within the input frame. Expressed in
  7263. range of [0-255].
  7264. @item UMIN
  7265. Display the minimal U value contained within the input frame. Expressed in
  7266. range of [0-255].
  7267. @item ULOW
  7268. Display the U value at the 10% percentile within the input frame. Expressed in
  7269. range of [0-255].
  7270. @item UAVG
  7271. Display the average U value within the input frame. Expressed in range of
  7272. [0-255].
  7273. @item UHIGH
  7274. Display the U value at the 90% percentile within the input frame. Expressed in
  7275. range of [0-255].
  7276. @item UMAX
  7277. Display the maximum U value contained within the input frame. Expressed in
  7278. range of [0-255].
  7279. @item VMIN
  7280. Display the minimal V value contained within the input frame. Expressed in
  7281. range of [0-255].
  7282. @item VLOW
  7283. Display the V value at the 10% percentile within the input frame. Expressed in
  7284. range of [0-255].
  7285. @item VAVG
  7286. Display the average V value within the input frame. Expressed in range of
  7287. [0-255].
  7288. @item VHIGH
  7289. Display the V value at the 90% percentile within the input frame. Expressed in
  7290. range of [0-255].
  7291. @item VMAX
  7292. Display the maximum V value contained within the input frame. Expressed in
  7293. range of [0-255].
  7294. @item SATMIN
  7295. Display the minimal saturation value contained within the input frame.
  7296. Expressed in range of [0-~181.02].
  7297. @item SATLOW
  7298. Display the saturation value at the 10% percentile within the input frame.
  7299. Expressed in range of [0-~181.02].
  7300. @item SATAVG
  7301. Display the average saturation value within the input frame. Expressed in range
  7302. of [0-~181.02].
  7303. @item SATHIGH
  7304. Display the saturation value at the 90% percentile within the input frame.
  7305. Expressed in range of [0-~181.02].
  7306. @item SATMAX
  7307. Display the maximum saturation value contained within the input frame.
  7308. Expressed in range of [0-~181.02].
  7309. @item HUEMED
  7310. Display the median value for hue within the input frame. Expressed in range of
  7311. [0-360].
  7312. @item HUEAVG
  7313. Display the average value for hue within the input frame. Expressed in range of
  7314. [0-360].
  7315. @item YDIF
  7316. Display the average of sample value difference between all values of the Y
  7317. plane in the current frame and corresponding values of the previous input frame.
  7318. Expressed in range of [0-255].
  7319. @item UDIF
  7320. Display the average of sample value difference between all values of the U
  7321. plane in the current frame and corresponding values of the previous input frame.
  7322. Expressed in range of [0-255].
  7323. @item VDIF
  7324. Display the average of sample value difference between all values of the V
  7325. plane in the current frame and corresponding values of the previous input frame.
  7326. Expressed in range of [0-255].
  7327. @end table
  7328. The filter accepts the following options:
  7329. @table @option
  7330. @item stat
  7331. @item out
  7332. @option{stat} specify an additional form of image analysis.
  7333. @option{out} output video with the specified type of pixel highlighted.
  7334. Both options accept the following values:
  7335. @table @samp
  7336. @item tout
  7337. Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
  7338. unlike the neighboring pixels of the same field. Examples of temporal outliers
  7339. include the results of video dropouts, head clogs, or tape tracking issues.
  7340. @item vrep
  7341. Identify @var{vertical line repetition}. Vertical line repetition includes
  7342. similar rows of pixels within a frame. In born-digital video vertical line
  7343. repetition is common, but this pattern is uncommon in video digitized from an
  7344. analog source. When it occurs in video that results from the digitization of an
  7345. analog source it can indicate concealment from a dropout compensator.
  7346. @item brng
  7347. Identify pixels that fall outside of legal broadcast range.
  7348. @end table
  7349. @item color, c
  7350. Set the highlight color for the @option{out} option. The default color is
  7351. yellow.
  7352. @end table
  7353. @subsection Examples
  7354. @itemize
  7355. @item
  7356. Output data of various video metrics:
  7357. @example
  7358. ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
  7359. @end example
  7360. @item
  7361. Output specific data about the minimum and maximum values of the Y plane per frame:
  7362. @example
  7363. ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
  7364. @end example
  7365. @item
  7366. Playback video while highlighting pixels that are outside of broadcast range in red.
  7367. @example
  7368. ffplay example.mov -vf signalstats="out=brng:color=red"
  7369. @end example
  7370. @item
  7371. Playback video with signalstats metadata drawn over the frame.
  7372. @example
  7373. ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
  7374. @end example
  7375. The contents of signalstat_drawtext.txt used in the command are:
  7376. @example
  7377. time %@{pts:hms@}
  7378. Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
  7379. U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
  7380. V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
  7381. saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
  7382. @end example
  7383. @end itemize
  7384. @anchor{smartblur}
  7385. @section smartblur
  7386. Blur the input video without impacting the outlines.
  7387. It accepts the following options:
  7388. @table @option
  7389. @item luma_radius, lr
  7390. Set the luma radius. The option value must be a float number in
  7391. the range [0.1,5.0] that specifies the variance of the gaussian filter
  7392. used to blur the image (slower if larger). Default value is 1.0.
  7393. @item luma_strength, ls
  7394. Set the luma strength. The option value must be a float number
  7395. in the range [-1.0,1.0] that configures the blurring. A value included
  7396. in [0.0,1.0] will blur the image whereas a value included in
  7397. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  7398. @item luma_threshold, lt
  7399. Set the luma threshold used as a coefficient to determine
  7400. whether a pixel should be blurred or not. The option value must be an
  7401. integer in the range [-30,30]. A value of 0 will filter all the image,
  7402. a value included in [0,30] will filter flat areas and a value included
  7403. in [-30,0] will filter edges. Default value is 0.
  7404. @item chroma_radius, cr
  7405. Set the chroma radius. The option value must be a float number in
  7406. the range [0.1,5.0] that specifies the variance of the gaussian filter
  7407. used to blur the image (slower if larger). Default value is 1.0.
  7408. @item chroma_strength, cs
  7409. Set the chroma strength. The option value must be a float number
  7410. in the range [-1.0,1.0] that configures the blurring. A value included
  7411. in [0.0,1.0] will blur the image whereas a value included in
  7412. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  7413. @item chroma_threshold, ct
  7414. Set the chroma threshold used as a coefficient to determine
  7415. whether a pixel should be blurred or not. The option value must be an
  7416. integer in the range [-30,30]. A value of 0 will filter all the image,
  7417. a value included in [0,30] will filter flat areas and a value included
  7418. in [-30,0] will filter edges. Default value is 0.
  7419. @end table
  7420. If a chroma option is not explicitly set, the corresponding luma value
  7421. is set.
  7422. @section ssim
  7423. Obtain the SSIM (Structural SImilarity Metric) between two input videos.
  7424. This filter takes in input two input videos, the first input is
  7425. considered the "main" source and is passed unchanged to the
  7426. output. The second input is used as a "reference" video for computing
  7427. the SSIM.
  7428. Both video inputs must have the same resolution and pixel format for
  7429. this filter to work correctly. Also it assumes that both inputs
  7430. have the same number of frames, which are compared one by one.
  7431. The filter stores the calculated SSIM of each frame.
  7432. The description of the accepted parameters follows.
  7433. @table @option
  7434. @item stats_file, f
  7435. If specified the filter will use the named file to save the SSIM of
  7436. each individual frame.
  7437. @end table
  7438. The file printed if @var{stats_file} is selected, contains a sequence of
  7439. key/value pairs of the form @var{key}:@var{value} for each compared
  7440. couple of frames.
  7441. A description of each shown parameter follows:
  7442. @table @option
  7443. @item n
  7444. sequential number of the input frame, starting from 1
  7445. @item Y, U, V, R, G, B
  7446. SSIM of the compared frames for the component specified by the suffix.
  7447. @item All
  7448. SSIM of the compared frames for the whole frame.
  7449. @item dB
  7450. Same as above but in dB representation.
  7451. @end table
  7452. For example:
  7453. @example
  7454. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  7455. [main][ref] ssim="stats_file=stats.log" [out]
  7456. @end example
  7457. On this example the input file being processed is compared with the
  7458. reference file @file{ref_movie.mpg}. The SSIM of each individual frame
  7459. is stored in @file{stats.log}.
  7460. Another example with both psnr and ssim at same time:
  7461. @example
  7462. ffmpeg -i main.mpg -i ref.mpg -lavfi "ssim;[0:v][1:v]psnr" -f null -
  7463. @end example
  7464. @section stereo3d
  7465. Convert between different stereoscopic image formats.
  7466. The filters accept the following options:
  7467. @table @option
  7468. @item in
  7469. Set stereoscopic image format of input.
  7470. Available values for input image formats are:
  7471. @table @samp
  7472. @item sbsl
  7473. side by side parallel (left eye left, right eye right)
  7474. @item sbsr
  7475. side by side crosseye (right eye left, left eye right)
  7476. @item sbs2l
  7477. side by side parallel with half width resolution
  7478. (left eye left, right eye right)
  7479. @item sbs2r
  7480. side by side crosseye with half width resolution
  7481. (right eye left, left eye right)
  7482. @item abl
  7483. above-below (left eye above, right eye below)
  7484. @item abr
  7485. above-below (right eye above, left eye below)
  7486. @item ab2l
  7487. above-below with half height resolution
  7488. (left eye above, right eye below)
  7489. @item ab2r
  7490. above-below with half height resolution
  7491. (right eye above, left eye below)
  7492. @item al
  7493. alternating frames (left eye first, right eye second)
  7494. @item ar
  7495. alternating frames (right eye first, left eye second)
  7496. Default value is @samp{sbsl}.
  7497. @end table
  7498. @item out
  7499. Set stereoscopic image format of output.
  7500. Available values for output image formats are all the input formats as well as:
  7501. @table @samp
  7502. @item arbg
  7503. anaglyph red/blue gray
  7504. (red filter on left eye, blue filter on right eye)
  7505. @item argg
  7506. anaglyph red/green gray
  7507. (red filter on left eye, green filter on right eye)
  7508. @item arcg
  7509. anaglyph red/cyan gray
  7510. (red filter on left eye, cyan filter on right eye)
  7511. @item arch
  7512. anaglyph red/cyan half colored
  7513. (red filter on left eye, cyan filter on right eye)
  7514. @item arcc
  7515. anaglyph red/cyan color
  7516. (red filter on left eye, cyan filter on right eye)
  7517. @item arcd
  7518. anaglyph red/cyan color optimized with the least squares projection of dubois
  7519. (red filter on left eye, cyan filter on right eye)
  7520. @item agmg
  7521. anaglyph green/magenta gray
  7522. (green filter on left eye, magenta filter on right eye)
  7523. @item agmh
  7524. anaglyph green/magenta half colored
  7525. (green filter on left eye, magenta filter on right eye)
  7526. @item agmc
  7527. anaglyph green/magenta colored
  7528. (green filter on left eye, magenta filter on right eye)
  7529. @item agmd
  7530. anaglyph green/magenta color optimized with the least squares projection of dubois
  7531. (green filter on left eye, magenta filter on right eye)
  7532. @item aybg
  7533. anaglyph yellow/blue gray
  7534. (yellow filter on left eye, blue filter on right eye)
  7535. @item aybh
  7536. anaglyph yellow/blue half colored
  7537. (yellow filter on left eye, blue filter on right eye)
  7538. @item aybc
  7539. anaglyph yellow/blue colored
  7540. (yellow filter on left eye, blue filter on right eye)
  7541. @item aybd
  7542. anaglyph yellow/blue color optimized with the least squares projection of dubois
  7543. (yellow filter on left eye, blue filter on right eye)
  7544. @item irl
  7545. interleaved rows (left eye has top row, right eye starts on next row)
  7546. @item irr
  7547. interleaved rows (right eye has top row, left eye starts on next row)
  7548. @item ml
  7549. mono output (left eye only)
  7550. @item mr
  7551. mono output (right eye only)
  7552. @end table
  7553. Default value is @samp{arcd}.
  7554. @end table
  7555. @subsection Examples
  7556. @itemize
  7557. @item
  7558. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  7559. @example
  7560. stereo3d=sbsl:aybd
  7561. @end example
  7562. @item
  7563. Convert input video from above bellow (left eye above, right eye below) to side by side crosseye.
  7564. @example
  7565. stereo3d=abl:sbsr
  7566. @end example
  7567. @end itemize
  7568. @anchor{spp}
  7569. @section spp
  7570. Apply a simple postprocessing filter that compresses and decompresses the image
  7571. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  7572. and average the results.
  7573. The filter accepts the following options:
  7574. @table @option
  7575. @item quality
  7576. Set quality. This option defines the number of levels for averaging. It accepts
  7577. an integer in the range 0-6. If set to @code{0}, the filter will have no
  7578. effect. A value of @code{6} means the higher quality. For each increment of
  7579. that value the speed drops by a factor of approximately 2. Default value is
  7580. @code{3}.
  7581. @item qp
  7582. Force a constant quantization parameter. If not set, the filter will use the QP
  7583. from the video stream (if available).
  7584. @item mode
  7585. Set thresholding mode. Available modes are:
  7586. @table @samp
  7587. @item hard
  7588. Set hard thresholding (default).
  7589. @item soft
  7590. Set soft thresholding (better de-ringing effect, but likely blurrier).
  7591. @end table
  7592. @item use_bframe_qp
  7593. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  7594. option may cause flicker since the B-Frames have often larger QP. Default is
  7595. @code{0} (not enabled).
  7596. @end table
  7597. @anchor{subtitles}
  7598. @section subtitles
  7599. Draw subtitles on top of input video using the libass library.
  7600. To enable compilation of this filter you need to configure FFmpeg with
  7601. @code{--enable-libass}. This filter also requires a build with libavcodec and
  7602. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  7603. Alpha) subtitles format.
  7604. The filter accepts the following options:
  7605. @table @option
  7606. @item filename, f
  7607. Set the filename of the subtitle file to read. It must be specified.
  7608. @item original_size
  7609. Specify the size of the original video, the video for which the ASS file
  7610. was composed. For the syntax of this option, check the
  7611. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7612. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
  7613. correctly scale the fonts if the aspect ratio has been changed.
  7614. @item charenc
  7615. Set subtitles input character encoding. @code{subtitles} filter only. Only
  7616. useful if not UTF-8.
  7617. @item stream_index, si
  7618. Set subtitles stream index. @code{subtitles} filter only.
  7619. @item force_style
  7620. Override default style or script info parameters of the subtitles. It accepts a
  7621. string containing ASS style format @code{KEY=VALUE} couples separated by ",".
  7622. @end table
  7623. If the first key is not specified, it is assumed that the first value
  7624. specifies the @option{filename}.
  7625. For example, to render the file @file{sub.srt} on top of the input
  7626. video, use the command:
  7627. @example
  7628. subtitles=sub.srt
  7629. @end example
  7630. which is equivalent to:
  7631. @example
  7632. subtitles=filename=sub.srt
  7633. @end example
  7634. To render the default subtitles stream from file @file{video.mkv}, use:
  7635. @example
  7636. subtitles=video.mkv
  7637. @end example
  7638. To render the second subtitles stream from that file, use:
  7639. @example
  7640. subtitles=video.mkv:si=1
  7641. @end example
  7642. To make the subtitles stream from @file{sub.srt} appear in transparent green
  7643. @code{DejaVu Serif}, use:
  7644. @example
  7645. subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
  7646. @end example
  7647. @section super2xsai
  7648. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  7649. Interpolate) pixel art scaling algorithm.
  7650. Useful for enlarging pixel art images without reducing sharpness.
  7651. @section swapuv
  7652. Swap U & V plane.
  7653. @section telecine
  7654. Apply telecine process to the video.
  7655. This filter accepts the following options:
  7656. @table @option
  7657. @item first_field
  7658. @table @samp
  7659. @item top, t
  7660. top field first
  7661. @item bottom, b
  7662. bottom field first
  7663. The default value is @code{top}.
  7664. @end table
  7665. @item pattern
  7666. A string of numbers representing the pulldown pattern you wish to apply.
  7667. The default value is @code{23}.
  7668. @end table
  7669. @example
  7670. Some typical patterns:
  7671. NTSC output (30i):
  7672. 27.5p: 32222
  7673. 24p: 23 (classic)
  7674. 24p: 2332 (preferred)
  7675. 20p: 33
  7676. 18p: 334
  7677. 16p: 3444
  7678. PAL output (25i):
  7679. 27.5p: 12222
  7680. 24p: 222222222223 ("Euro pulldown")
  7681. 16.67p: 33
  7682. 16p: 33333334
  7683. @end example
  7684. @section thumbnail
  7685. Select the most representative frame in a given sequence of consecutive frames.
  7686. The filter accepts the following options:
  7687. @table @option
  7688. @item n
  7689. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  7690. will pick one of them, and then handle the next batch of @var{n} frames until
  7691. the end. Default is @code{100}.
  7692. @end table
  7693. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  7694. value will result in a higher memory usage, so a high value is not recommended.
  7695. @subsection Examples
  7696. @itemize
  7697. @item
  7698. Extract one picture each 50 frames:
  7699. @example
  7700. thumbnail=50
  7701. @end example
  7702. @item
  7703. Complete example of a thumbnail creation with @command{ffmpeg}:
  7704. @example
  7705. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  7706. @end example
  7707. @end itemize
  7708. @section tile
  7709. Tile several successive frames together.
  7710. The filter accepts the following options:
  7711. @table @option
  7712. @item layout
  7713. Set the grid size (i.e. the number of lines and columns). For the syntax of
  7714. this option, check the
  7715. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7716. @item nb_frames
  7717. Set the maximum number of frames to render in the given area. It must be less
  7718. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  7719. the area will be used.
  7720. @item margin
  7721. Set the outer border margin in pixels.
  7722. @item padding
  7723. Set the inner border thickness (i.e. the number of pixels between frames). For
  7724. more advanced padding options (such as having different values for the edges),
  7725. refer to the pad video filter.
  7726. @item color
  7727. Specify the color of the unused area. For the syntax of this option, check the
  7728. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  7729. is "black".
  7730. @end table
  7731. @subsection Examples
  7732. @itemize
  7733. @item
  7734. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  7735. @example
  7736. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  7737. @end example
  7738. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  7739. duplicating each output frame to accommodate the originally detected frame
  7740. rate.
  7741. @item
  7742. Display @code{5} pictures in an area of @code{3x2} frames,
  7743. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  7744. mixed flat and named options:
  7745. @example
  7746. tile=3x2:nb_frames=5:padding=7:margin=2
  7747. @end example
  7748. @end itemize
  7749. @section tinterlace
  7750. Perform various types of temporal field interlacing.
  7751. Frames are counted starting from 1, so the first input frame is
  7752. considered odd.
  7753. The filter accepts the following options:
  7754. @table @option
  7755. @item mode
  7756. Specify the mode of the interlacing. This option can also be specified
  7757. as a value alone. See below for a list of values for this option.
  7758. Available values are:
  7759. @table @samp
  7760. @item merge, 0
  7761. Move odd frames into the upper field, even into the lower field,
  7762. generating a double height frame at half frame rate.
  7763. @example
  7764. ------> time
  7765. Input:
  7766. Frame 1 Frame 2 Frame 3 Frame 4
  7767. 11111 22222 33333 44444
  7768. 11111 22222 33333 44444
  7769. 11111 22222 33333 44444
  7770. 11111 22222 33333 44444
  7771. Output:
  7772. 11111 33333
  7773. 22222 44444
  7774. 11111 33333
  7775. 22222 44444
  7776. 11111 33333
  7777. 22222 44444
  7778. 11111 33333
  7779. 22222 44444
  7780. @end example
  7781. @item drop_odd, 1
  7782. Only output even frames, odd frames are dropped, generating a frame with
  7783. unchanged height at half frame rate.
  7784. @example
  7785. ------> time
  7786. Input:
  7787. Frame 1 Frame 2 Frame 3 Frame 4
  7788. 11111 22222 33333 44444
  7789. 11111 22222 33333 44444
  7790. 11111 22222 33333 44444
  7791. 11111 22222 33333 44444
  7792. Output:
  7793. 22222 44444
  7794. 22222 44444
  7795. 22222 44444
  7796. 22222 44444
  7797. @end example
  7798. @item drop_even, 2
  7799. Only output odd frames, even frames are dropped, generating a frame with
  7800. unchanged height at half frame rate.
  7801. @example
  7802. ------> time
  7803. Input:
  7804. Frame 1 Frame 2 Frame 3 Frame 4
  7805. 11111 22222 33333 44444
  7806. 11111 22222 33333 44444
  7807. 11111 22222 33333 44444
  7808. 11111 22222 33333 44444
  7809. Output:
  7810. 11111 33333
  7811. 11111 33333
  7812. 11111 33333
  7813. 11111 33333
  7814. @end example
  7815. @item pad, 3
  7816. Expand each frame to full height, but pad alternate lines with black,
  7817. generating a frame with double height at the same input frame rate.
  7818. @example
  7819. ------> time
  7820. Input:
  7821. Frame 1 Frame 2 Frame 3 Frame 4
  7822. 11111 22222 33333 44444
  7823. 11111 22222 33333 44444
  7824. 11111 22222 33333 44444
  7825. 11111 22222 33333 44444
  7826. Output:
  7827. 11111 ..... 33333 .....
  7828. ..... 22222 ..... 44444
  7829. 11111 ..... 33333 .....
  7830. ..... 22222 ..... 44444
  7831. 11111 ..... 33333 .....
  7832. ..... 22222 ..... 44444
  7833. 11111 ..... 33333 .....
  7834. ..... 22222 ..... 44444
  7835. @end example
  7836. @item interleave_top, 4
  7837. Interleave the upper field from odd frames with the lower field from
  7838. even frames, generating a frame with unchanged height at half frame rate.
  7839. @example
  7840. ------> time
  7841. Input:
  7842. Frame 1 Frame 2 Frame 3 Frame 4
  7843. 11111<- 22222 33333<- 44444
  7844. 11111 22222<- 33333 44444<-
  7845. 11111<- 22222 33333<- 44444
  7846. 11111 22222<- 33333 44444<-
  7847. Output:
  7848. 11111 33333
  7849. 22222 44444
  7850. 11111 33333
  7851. 22222 44444
  7852. @end example
  7853. @item interleave_bottom, 5
  7854. Interleave the lower field from odd frames with the upper field from
  7855. even frames, generating a frame with unchanged height at half frame rate.
  7856. @example
  7857. ------> time
  7858. Input:
  7859. Frame 1 Frame 2 Frame 3 Frame 4
  7860. 11111 22222<- 33333 44444<-
  7861. 11111<- 22222 33333<- 44444
  7862. 11111 22222<- 33333 44444<-
  7863. 11111<- 22222 33333<- 44444
  7864. Output:
  7865. 22222 44444
  7866. 11111 33333
  7867. 22222 44444
  7868. 11111 33333
  7869. @end example
  7870. @item interlacex2, 6
  7871. Double frame rate with unchanged height. Frames are inserted each
  7872. containing the second temporal field from the previous input frame and
  7873. the first temporal field from the next input frame. This mode relies on
  7874. the top_field_first flag. Useful for interlaced video displays with no
  7875. field synchronisation.
  7876. @example
  7877. ------> time
  7878. Input:
  7879. Frame 1 Frame 2 Frame 3 Frame 4
  7880. 11111 22222 33333 44444
  7881. 11111 22222 33333 44444
  7882. 11111 22222 33333 44444
  7883. 11111 22222 33333 44444
  7884. Output:
  7885. 11111 22222 22222 33333 33333 44444 44444
  7886. 11111 11111 22222 22222 33333 33333 44444
  7887. 11111 22222 22222 33333 33333 44444 44444
  7888. 11111 11111 22222 22222 33333 33333 44444
  7889. @end example
  7890. @end table
  7891. Numeric values are deprecated but are accepted for backward
  7892. compatibility reasons.
  7893. Default mode is @code{merge}.
  7894. @item flags
  7895. Specify flags influencing the filter process.
  7896. Available value for @var{flags} is:
  7897. @table @option
  7898. @item low_pass_filter, vlfp
  7899. Enable vertical low-pass filtering in the filter.
  7900. Vertical low-pass filtering is required when creating an interlaced
  7901. destination from a progressive source which contains high-frequency
  7902. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  7903. patterning.
  7904. Vertical low-pass filtering can only be enabled for @option{mode}
  7905. @var{interleave_top} and @var{interleave_bottom}.
  7906. @end table
  7907. @end table
  7908. @section transpose
  7909. Transpose rows with columns in the input video and optionally flip it.
  7910. It accepts the following parameters:
  7911. @table @option
  7912. @item dir
  7913. Specify the transposition direction.
  7914. Can assume the following values:
  7915. @table @samp
  7916. @item 0, 4, cclock_flip
  7917. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  7918. @example
  7919. L.R L.l
  7920. . . -> . .
  7921. l.r R.r
  7922. @end example
  7923. @item 1, 5, clock
  7924. Rotate by 90 degrees clockwise, that is:
  7925. @example
  7926. L.R l.L
  7927. . . -> . .
  7928. l.r r.R
  7929. @end example
  7930. @item 2, 6, cclock
  7931. Rotate by 90 degrees counterclockwise, that is:
  7932. @example
  7933. L.R R.r
  7934. . . -> . .
  7935. l.r L.l
  7936. @end example
  7937. @item 3, 7, clock_flip
  7938. Rotate by 90 degrees clockwise and vertically flip, that is:
  7939. @example
  7940. L.R r.R
  7941. . . -> . .
  7942. l.r l.L
  7943. @end example
  7944. @end table
  7945. For values between 4-7, the transposition is only done if the input
  7946. video geometry is portrait and not landscape. These values are
  7947. deprecated, the @code{passthrough} option should be used instead.
  7948. Numerical values are deprecated, and should be dropped in favor of
  7949. symbolic constants.
  7950. @item passthrough
  7951. Do not apply the transposition if the input geometry matches the one
  7952. specified by the specified value. It accepts the following values:
  7953. @table @samp
  7954. @item none
  7955. Always apply transposition.
  7956. @item portrait
  7957. Preserve portrait geometry (when @var{height} >= @var{width}).
  7958. @item landscape
  7959. Preserve landscape geometry (when @var{width} >= @var{height}).
  7960. @end table
  7961. Default value is @code{none}.
  7962. @end table
  7963. For example to rotate by 90 degrees clockwise and preserve portrait
  7964. layout:
  7965. @example
  7966. transpose=dir=1:passthrough=portrait
  7967. @end example
  7968. The command above can also be specified as:
  7969. @example
  7970. transpose=1:portrait
  7971. @end example
  7972. @section trim
  7973. Trim the input so that the output contains one continuous subpart of the input.
  7974. It accepts the following parameters:
  7975. @table @option
  7976. @item start
  7977. Specify the time of the start of the kept section, i.e. the frame with the
  7978. timestamp @var{start} will be the first frame in the output.
  7979. @item end
  7980. Specify the time of the first frame that will be dropped, i.e. the frame
  7981. immediately preceding the one with the timestamp @var{end} will be the last
  7982. frame in the output.
  7983. @item start_pts
  7984. This is the same as @var{start}, except this option sets the start timestamp
  7985. in timebase units instead of seconds.
  7986. @item end_pts
  7987. This is the same as @var{end}, except this option sets the end timestamp
  7988. in timebase units instead of seconds.
  7989. @item duration
  7990. The maximum duration of the output in seconds.
  7991. @item start_frame
  7992. The number of the first frame that should be passed to the output.
  7993. @item end_frame
  7994. The number of the first frame that should be dropped.
  7995. @end table
  7996. @option{start}, @option{end}, and @option{duration} are expressed as time
  7997. duration specifications; see
  7998. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  7999. for the accepted syntax.
  8000. Note that the first two sets of the start/end options and the @option{duration}
  8001. option look at the frame timestamp, while the _frame variants simply count the
  8002. frames that pass through the filter. Also note that this filter does not modify
  8003. the timestamps. If you wish for the output timestamps to start at zero, insert a
  8004. setpts filter after the trim filter.
  8005. If multiple start or end options are set, this filter tries to be greedy and
  8006. keep all the frames that match at least one of the specified constraints. To keep
  8007. only the part that matches all the constraints at once, chain multiple trim
  8008. filters.
  8009. The defaults are such that all the input is kept. So it is possible to set e.g.
  8010. just the end values to keep everything before the specified time.
  8011. Examples:
  8012. @itemize
  8013. @item
  8014. Drop everything except the second minute of input:
  8015. @example
  8016. ffmpeg -i INPUT -vf trim=60:120
  8017. @end example
  8018. @item
  8019. Keep only the first second:
  8020. @example
  8021. ffmpeg -i INPUT -vf trim=duration=1
  8022. @end example
  8023. @end itemize
  8024. @anchor{unsharp}
  8025. @section unsharp
  8026. Sharpen or blur the input video.
  8027. It accepts the following parameters:
  8028. @table @option
  8029. @item luma_msize_x, lx
  8030. Set the luma matrix horizontal size. It must be an odd integer between
  8031. 3 and 63. The default value is 5.
  8032. @item luma_msize_y, ly
  8033. Set the luma matrix vertical size. It must be an odd integer between 3
  8034. and 63. The default value is 5.
  8035. @item luma_amount, la
  8036. Set the luma effect strength. It must be a floating point number, reasonable
  8037. values lay between -1.5 and 1.5.
  8038. Negative values will blur the input video, while positive values will
  8039. sharpen it, a value of zero will disable the effect.
  8040. Default value is 1.0.
  8041. @item chroma_msize_x, cx
  8042. Set the chroma matrix horizontal size. It must be an odd integer
  8043. between 3 and 63. The default value is 5.
  8044. @item chroma_msize_y, cy
  8045. Set the chroma matrix vertical size. It must be an odd integer
  8046. between 3 and 63. The default value is 5.
  8047. @item chroma_amount, ca
  8048. Set the chroma effect strength. It must be a floating point number, reasonable
  8049. values lay between -1.5 and 1.5.
  8050. Negative values will blur the input video, while positive values will
  8051. sharpen it, a value of zero will disable the effect.
  8052. Default value is 0.0.
  8053. @item opencl
  8054. If set to 1, specify using OpenCL capabilities, only available if
  8055. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  8056. @end table
  8057. All parameters are optional and default to the equivalent of the
  8058. string '5:5:1.0:5:5:0.0'.
  8059. @subsection Examples
  8060. @itemize
  8061. @item
  8062. Apply strong luma sharpen effect:
  8063. @example
  8064. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  8065. @end example
  8066. @item
  8067. Apply a strong blur of both luma and chroma parameters:
  8068. @example
  8069. unsharp=7:7:-2:7:7:-2
  8070. @end example
  8071. @end itemize
  8072. @section uspp
  8073. Apply ultra slow/simple postprocessing filter that compresses and decompresses
  8074. the image at several (or - in the case of @option{quality} level @code{8} - all)
  8075. shifts and average the results.
  8076. The way this differs from the behavior of spp is that uspp actually encodes &
  8077. decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
  8078. DCT similar to MJPEG.
  8079. The filter accepts the following options:
  8080. @table @option
  8081. @item quality
  8082. Set quality. This option defines the number of levels for averaging. It accepts
  8083. an integer in the range 0-8. If set to @code{0}, the filter will have no
  8084. effect. A value of @code{8} means the higher quality. For each increment of
  8085. that value the speed drops by a factor of approximately 2. Default value is
  8086. @code{3}.
  8087. @item qp
  8088. Force a constant quantization parameter. If not set, the filter will use the QP
  8089. from the video stream (if available).
  8090. @end table
  8091. @section vectorscope
  8092. Display 2 color component values in the two dimensional graph (which is called
  8093. a vectorscope).
  8094. This filter accepts the following options:
  8095. @table @option
  8096. @item mode, m
  8097. Set vectorscope mode.
  8098. It accepts the following values:
  8099. @table @samp
  8100. @item gray
  8101. Gray values are displayed on graph, higher brightness means more pixels have
  8102. same component color value on location in graph. This is the default mode.
  8103. @item color
  8104. Gray values are displayed on graph. Surrounding pixels values which are not
  8105. present in video frame are drawn in gradient of 2 color components which are
  8106. set by option @code{x} and @code{y}.
  8107. @item color2
  8108. Actual color components values present in video frame are displayed on graph.
  8109. @item color3
  8110. Similar as color2 but higher frequency of same values @code{x} and @code{y}
  8111. on graph increases value of another color component, which is luminance by
  8112. default values of @code{x} and @code{y}.
  8113. @item color4
  8114. Actual colors present in video frame are displayed on graph. If two different
  8115. colors map to same position on graph then color with higher value of component
  8116. not present in graph is picked.
  8117. @end table
  8118. @item x
  8119. Set which color component will be represented on X-axis. Default is @code{1}.
  8120. @item y
  8121. Set which color component will be represented on Y-axis. Default is @code{2}.
  8122. @item intensity, i
  8123. Set intensity, used by modes: gray, color and color3 for increasing brightness
  8124. of color component which represents frequency of (X, Y) location in graph.
  8125. @item envelope, e
  8126. @table @samp
  8127. @item none
  8128. No envelope, this is default.
  8129. @item instant
  8130. Instant envelope, even darkest single pixel will be clearly highlighted.
  8131. @item peak
  8132. Hold maximum and minimum values presented in graph over time. This way you
  8133. can still spot out of range values without constantly looking at vectorscope.
  8134. @item peak+instant
  8135. Peak and instant envelope combined together.
  8136. @end table
  8137. @end table
  8138. @anchor{vidstabdetect}
  8139. @section vidstabdetect
  8140. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  8141. @ref{vidstabtransform} for pass 2.
  8142. This filter generates a file with relative translation and rotation
  8143. transform information about subsequent frames, which is then used by
  8144. the @ref{vidstabtransform} filter.
  8145. To enable compilation of this filter you need to configure FFmpeg with
  8146. @code{--enable-libvidstab}.
  8147. This filter accepts the following options:
  8148. @table @option
  8149. @item result
  8150. Set the path to the file used to write the transforms information.
  8151. Default value is @file{transforms.trf}.
  8152. @item shakiness
  8153. Set how shaky the video is and how quick the camera is. It accepts an
  8154. integer in the range 1-10, a value of 1 means little shakiness, a
  8155. value of 10 means strong shakiness. Default value is 5.
  8156. @item accuracy
  8157. Set the accuracy of the detection process. It must be a value in the
  8158. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  8159. accuracy. Default value is 15.
  8160. @item stepsize
  8161. Set stepsize of the search process. The region around minimum is
  8162. scanned with 1 pixel resolution. Default value is 6.
  8163. @item mincontrast
  8164. Set minimum contrast. Below this value a local measurement field is
  8165. discarded. Must be a floating point value in the range 0-1. Default
  8166. value is 0.3.
  8167. @item tripod
  8168. Set reference frame number for tripod mode.
  8169. If enabled, the motion of the frames is compared to a reference frame
  8170. in the filtered stream, identified by the specified number. The idea
  8171. is to compensate all movements in a more-or-less static scene and keep
  8172. the camera view absolutely still.
  8173. If set to 0, it is disabled. The frames are counted starting from 1.
  8174. @item show
  8175. Show fields and transforms in the resulting frames. It accepts an
  8176. integer in the range 0-2. Default value is 0, which disables any
  8177. visualization.
  8178. @end table
  8179. @subsection Examples
  8180. @itemize
  8181. @item
  8182. Use default values:
  8183. @example
  8184. vidstabdetect
  8185. @end example
  8186. @item
  8187. Analyze strongly shaky movie and put the results in file
  8188. @file{mytransforms.trf}:
  8189. @example
  8190. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  8191. @end example
  8192. @item
  8193. Visualize the result of internal transformations in the resulting
  8194. video:
  8195. @example
  8196. vidstabdetect=show=1
  8197. @end example
  8198. @item
  8199. Analyze a video with medium shakiness using @command{ffmpeg}:
  8200. @example
  8201. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  8202. @end example
  8203. @end itemize
  8204. @anchor{vidstabtransform}
  8205. @section vidstabtransform
  8206. Video stabilization/deshaking: pass 2 of 2,
  8207. see @ref{vidstabdetect} for pass 1.
  8208. Read a file with transform information for each frame and
  8209. apply/compensate them. Together with the @ref{vidstabdetect}
  8210. filter this can be used to deshake videos. See also
  8211. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  8212. the @ref{unsharp} filter, see below.
  8213. To enable compilation of this filter you need to configure FFmpeg with
  8214. @code{--enable-libvidstab}.
  8215. @subsection Options
  8216. @table @option
  8217. @item input
  8218. Set path to the file used to read the transforms. Default value is
  8219. @file{transforms.trf}.
  8220. @item smoothing
  8221. Set the number of frames (value*2 + 1) used for lowpass filtering the
  8222. camera movements. Default value is 10.
  8223. For example a number of 10 means that 21 frames are used (10 in the
  8224. past and 10 in the future) to smoothen the motion in the video. A
  8225. larger value leads to a smoother video, but limits the acceleration of
  8226. the camera (pan/tilt movements). 0 is a special case where a static
  8227. camera is simulated.
  8228. @item optalgo
  8229. Set the camera path optimization algorithm.
  8230. Accepted values are:
  8231. @table @samp
  8232. @item gauss
  8233. gaussian kernel low-pass filter on camera motion (default)
  8234. @item avg
  8235. averaging on transformations
  8236. @end table
  8237. @item maxshift
  8238. Set maximal number of pixels to translate frames. Default value is -1,
  8239. meaning no limit.
  8240. @item maxangle
  8241. Set maximal angle in radians (degree*PI/180) to rotate frames. Default
  8242. value is -1, meaning no limit.
  8243. @item crop
  8244. Specify how to deal with borders that may be visible due to movement
  8245. compensation.
  8246. Available values are:
  8247. @table @samp
  8248. @item keep
  8249. keep image information from previous frame (default)
  8250. @item black
  8251. fill the border black
  8252. @end table
  8253. @item invert
  8254. Invert transforms if set to 1. Default value is 0.
  8255. @item relative
  8256. Consider transforms as relative to previous frame if set to 1,
  8257. absolute if set to 0. Default value is 0.
  8258. @item zoom
  8259. Set percentage to zoom. A positive value will result in a zoom-in
  8260. effect, a negative value in a zoom-out effect. Default value is 0 (no
  8261. zoom).
  8262. @item optzoom
  8263. Set optimal zooming to avoid borders.
  8264. Accepted values are:
  8265. @table @samp
  8266. @item 0
  8267. disabled
  8268. @item 1
  8269. optimal static zoom value is determined (only very strong movements
  8270. will lead to visible borders) (default)
  8271. @item 2
  8272. optimal adaptive zoom value is determined (no borders will be
  8273. visible), see @option{zoomspeed}
  8274. @end table
  8275. Note that the value given at zoom is added to the one calculated here.
  8276. @item zoomspeed
  8277. Set percent to zoom maximally each frame (enabled when
  8278. @option{optzoom} is set to 2). Range is from 0 to 5, default value is
  8279. 0.25.
  8280. @item interpol
  8281. Specify type of interpolation.
  8282. Available values are:
  8283. @table @samp
  8284. @item no
  8285. no interpolation
  8286. @item linear
  8287. linear only horizontal
  8288. @item bilinear
  8289. linear in both directions (default)
  8290. @item bicubic
  8291. cubic in both directions (slow)
  8292. @end table
  8293. @item tripod
  8294. Enable virtual tripod mode if set to 1, which is equivalent to
  8295. @code{relative=0:smoothing=0}. Default value is 0.
  8296. Use also @code{tripod} option of @ref{vidstabdetect}.
  8297. @item debug
  8298. Increase log verbosity if set to 1. Also the detected global motions
  8299. are written to the temporary file @file{global_motions.trf}. Default
  8300. value is 0.
  8301. @end table
  8302. @subsection Examples
  8303. @itemize
  8304. @item
  8305. Use @command{ffmpeg} for a typical stabilization with default values:
  8306. @example
  8307. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  8308. @end example
  8309. Note the use of the @ref{unsharp} filter which is always recommended.
  8310. @item
  8311. Zoom in a bit more and load transform data from a given file:
  8312. @example
  8313. vidstabtransform=zoom=5:input="mytransforms.trf"
  8314. @end example
  8315. @item
  8316. Smoothen the video even more:
  8317. @example
  8318. vidstabtransform=smoothing=30
  8319. @end example
  8320. @end itemize
  8321. @section vflip
  8322. Flip the input video vertically.
  8323. For example, to vertically flip a video with @command{ffmpeg}:
  8324. @example
  8325. ffmpeg -i in.avi -vf "vflip" out.avi
  8326. @end example
  8327. @anchor{vignette}
  8328. @section vignette
  8329. Make or reverse a natural vignetting effect.
  8330. The filter accepts the following options:
  8331. @table @option
  8332. @item angle, a
  8333. Set lens angle expression as a number of radians.
  8334. The value is clipped in the @code{[0,PI/2]} range.
  8335. Default value: @code{"PI/5"}
  8336. @item x0
  8337. @item y0
  8338. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  8339. by default.
  8340. @item mode
  8341. Set forward/backward mode.
  8342. Available modes are:
  8343. @table @samp
  8344. @item forward
  8345. The larger the distance from the central point, the darker the image becomes.
  8346. @item backward
  8347. The larger the distance from the central point, the brighter the image becomes.
  8348. This can be used to reverse a vignette effect, though there is no automatic
  8349. detection to extract the lens @option{angle} and other settings (yet). It can
  8350. also be used to create a burning effect.
  8351. @end table
  8352. Default value is @samp{forward}.
  8353. @item eval
  8354. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  8355. It accepts the following values:
  8356. @table @samp
  8357. @item init
  8358. Evaluate expressions only once during the filter initialization.
  8359. @item frame
  8360. Evaluate expressions for each incoming frame. This is way slower than the
  8361. @samp{init} mode since it requires all the scalers to be re-computed, but it
  8362. allows advanced dynamic expressions.
  8363. @end table
  8364. Default value is @samp{init}.
  8365. @item dither
  8366. Set dithering to reduce the circular banding effects. Default is @code{1}
  8367. (enabled).
  8368. @item aspect
  8369. Set vignette aspect. This setting allows one to adjust the shape of the vignette.
  8370. Setting this value to the SAR of the input will make a rectangular vignetting
  8371. following the dimensions of the video.
  8372. Default is @code{1/1}.
  8373. @end table
  8374. @subsection Expressions
  8375. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  8376. following parameters.
  8377. @table @option
  8378. @item w
  8379. @item h
  8380. input width and height
  8381. @item n
  8382. the number of input frame, starting from 0
  8383. @item pts
  8384. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  8385. @var{TB} units, NAN if undefined
  8386. @item r
  8387. frame rate of the input video, NAN if the input frame rate is unknown
  8388. @item t
  8389. the PTS (Presentation TimeStamp) of the filtered video frame,
  8390. expressed in seconds, NAN if undefined
  8391. @item tb
  8392. time base of the input video
  8393. @end table
  8394. @subsection Examples
  8395. @itemize
  8396. @item
  8397. Apply simple strong vignetting effect:
  8398. @example
  8399. vignette=PI/4
  8400. @end example
  8401. @item
  8402. Make a flickering vignetting:
  8403. @example
  8404. vignette='PI/4+random(1)*PI/50':eval=frame
  8405. @end example
  8406. @end itemize
  8407. @section vstack
  8408. Stack input videos vertically.
  8409. All streams must be of same pixel format and of same width.
  8410. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  8411. to create same output.
  8412. The filter accept the following option:
  8413. @table @option
  8414. @item nb_inputs
  8415. Set number of input streams. Default is 2.
  8416. @end table
  8417. @section w3fdif
  8418. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  8419. Deinterlacing Filter").
  8420. Based on the process described by Martin Weston for BBC R&D, and
  8421. implemented based on the de-interlace algorithm written by Jim
  8422. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  8423. uses filter coefficients calculated by BBC R&D.
  8424. There are two sets of filter coefficients, so called "simple":
  8425. and "complex". Which set of filter coefficients is used can
  8426. be set by passing an optional parameter:
  8427. @table @option
  8428. @item filter
  8429. Set the interlacing filter coefficients. Accepts one of the following values:
  8430. @table @samp
  8431. @item simple
  8432. Simple filter coefficient set.
  8433. @item complex
  8434. More-complex filter coefficient set.
  8435. @end table
  8436. Default value is @samp{complex}.
  8437. @item deint
  8438. Specify which frames to deinterlace. Accept one of the following values:
  8439. @table @samp
  8440. @item all
  8441. Deinterlace all frames,
  8442. @item interlaced
  8443. Only deinterlace frames marked as interlaced.
  8444. @end table
  8445. Default value is @samp{all}.
  8446. @end table
  8447. @section waveform
  8448. Video waveform monitor.
  8449. The waveform monitor plots color component intensity. By default luminance
  8450. only. Each column of the waveform corresponds to a column of pixels in the
  8451. source video.
  8452. It accepts the following options:
  8453. @table @option
  8454. @item mode, m
  8455. Can be either @code{row}, or @code{column}. Default is @code{column}.
  8456. In row mode, the graph on the left side represents color component value 0 and
  8457. the right side represents value = 255. In column mode, the top side represents
  8458. color component value = 0 and bottom side represents value = 255.
  8459. @item intensity, i
  8460. Set intensity. Smaller values are useful to find out how many values of the same
  8461. luminance are distributed across input rows/columns.
  8462. Default value is @code{10}. Allowed range is [1, 255].
  8463. @item mirror, r
  8464. Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored.
  8465. In mirrored mode, higher values will be represented on the left
  8466. side for @code{row} mode and at the top for @code{column} mode. Default is
  8467. @code{1} (mirrored).
  8468. @item display, d
  8469. Set display mode.
  8470. It accepts the following values:
  8471. @table @samp
  8472. @item overlay
  8473. Presents information identical to that in the @code{parade}, except
  8474. that the graphs representing color components are superimposed directly
  8475. over one another.
  8476. This display mode makes it easier to spot relative differences or similarities
  8477. in overlapping areas of the color components that are supposed to be identical,
  8478. such as neutral whites, grays, or blacks.
  8479. @item parade
  8480. Display separate graph for the color components side by side in
  8481. @code{row} mode or one below the other in @code{column} mode.
  8482. Using this display mode makes it easy to spot color casts in the highlights
  8483. and shadows of an image, by comparing the contours of the top and the bottom
  8484. graphs of each waveform. Since whites, grays, and blacks are characterized
  8485. by exactly equal amounts of red, green, and blue, neutral areas of the picture
  8486. should display three waveforms of roughly equal width/height. If not, the
  8487. correction is easy to perform by making level adjustments the three waveforms.
  8488. @end table
  8489. Default is @code{parade}.
  8490. @item components, c
  8491. Set which color components to display. Default is 1, which means only luminance
  8492. or red color component if input is in RGB colorspace. If is set for example to
  8493. 7 it will display all 3 (if) available color components.
  8494. @item envelope, e
  8495. @table @samp
  8496. @item none
  8497. No envelope, this is default.
  8498. @item instant
  8499. Instant envelope, minimum and maximum values presented in graph will be easily
  8500. visible even with small @code{step} value.
  8501. @item peak
  8502. Hold minimum and maximum values presented in graph across time. This way you
  8503. can still spot out of range values without constantly looking at waveforms.
  8504. @item peak+instant
  8505. Peak and instant envelope combined together.
  8506. @end table
  8507. @end table
  8508. @section xbr
  8509. Apply the xBR high-quality magnification filter which is designed for pixel
  8510. art. It follows a set of edge-detection rules, see
  8511. @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
  8512. It accepts the following option:
  8513. @table @option
  8514. @item n
  8515. Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
  8516. @code{3xBR} and @code{4} for @code{4xBR}.
  8517. Default is @code{3}.
  8518. @end table
  8519. @anchor{yadif}
  8520. @section yadif
  8521. Deinterlace the input video ("yadif" means "yet another deinterlacing
  8522. filter").
  8523. It accepts the following parameters:
  8524. @table @option
  8525. @item mode
  8526. The interlacing mode to adopt. It accepts one of the following values:
  8527. @table @option
  8528. @item 0, send_frame
  8529. Output one frame for each frame.
  8530. @item 1, send_field
  8531. Output one frame for each field.
  8532. @item 2, send_frame_nospatial
  8533. Like @code{send_frame}, but it skips the spatial interlacing check.
  8534. @item 3, send_field_nospatial
  8535. Like @code{send_field}, but it skips the spatial interlacing check.
  8536. @end table
  8537. The default value is @code{send_frame}.
  8538. @item parity
  8539. The picture field parity assumed for the input interlaced video. It accepts one
  8540. of the following values:
  8541. @table @option
  8542. @item 0, tff
  8543. Assume the top field is first.
  8544. @item 1, bff
  8545. Assume the bottom field is first.
  8546. @item -1, auto
  8547. Enable automatic detection of field parity.
  8548. @end table
  8549. The default value is @code{auto}.
  8550. If the interlacing is unknown or the decoder does not export this information,
  8551. top field first will be assumed.
  8552. @item deint
  8553. Specify which frames to deinterlace. Accept one of the following
  8554. values:
  8555. @table @option
  8556. @item 0, all
  8557. Deinterlace all frames.
  8558. @item 1, interlaced
  8559. Only deinterlace frames marked as interlaced.
  8560. @end table
  8561. The default value is @code{all}.
  8562. @end table
  8563. @section zoompan
  8564. Apply Zoom & Pan effect.
  8565. This filter accepts the following options:
  8566. @table @option
  8567. @item zoom, z
  8568. Set the zoom expression. Default is 1.
  8569. @item x
  8570. @item y
  8571. Set the x and y expression. Default is 0.
  8572. @item d
  8573. Set the duration expression in number of frames.
  8574. This sets for how many number of frames effect will last for
  8575. single input image.
  8576. @item s
  8577. Set the output image size, default is 'hd720'.
  8578. @end table
  8579. Each expression can contain the following constants:
  8580. @table @option
  8581. @item in_w, iw
  8582. Input width.
  8583. @item in_h, ih
  8584. Input height.
  8585. @item out_w, ow
  8586. Output width.
  8587. @item out_h, oh
  8588. Output height.
  8589. @item in
  8590. Input frame count.
  8591. @item on
  8592. Output frame count.
  8593. @item x
  8594. @item y
  8595. Last calculated 'x' and 'y' position from 'x' and 'y' expression
  8596. for current input frame.
  8597. @item px
  8598. @item py
  8599. 'x' and 'y' of last output frame of previous input frame or 0 when there was
  8600. not yet such frame (first input frame).
  8601. @item zoom
  8602. Last calculated zoom from 'z' expression for current input frame.
  8603. @item pzoom
  8604. Last calculated zoom of last output frame of previous input frame.
  8605. @item duration
  8606. Number of output frames for current input frame. Calculated from 'd' expression
  8607. for each input frame.
  8608. @item pduration
  8609. number of output frames created for previous input frame
  8610. @item a
  8611. Rational number: input width / input height
  8612. @item sar
  8613. sample aspect ratio
  8614. @item dar
  8615. display aspect ratio
  8616. @end table
  8617. @subsection Examples
  8618. @itemize
  8619. @item
  8620. Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
  8621. @example
  8622. 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
  8623. @end example
  8624. @item
  8625. Zoom-in up to 1.5 and pan always at center of picture:
  8626. @example
  8627. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
  8628. @end example
  8629. @end itemize
  8630. @c man end VIDEO FILTERS
  8631. @chapter Video Sources
  8632. @c man begin VIDEO SOURCES
  8633. Below is a description of the currently available video sources.
  8634. @section buffer
  8635. Buffer video frames, and make them available to the filter chain.
  8636. This source is mainly intended for a programmatic use, in particular
  8637. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  8638. It accepts the following parameters:
  8639. @table @option
  8640. @item video_size
  8641. Specify the size (width and height) of the buffered video frames. For the
  8642. syntax of this option, check the
  8643. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8644. @item width
  8645. The input video width.
  8646. @item height
  8647. The input video height.
  8648. @item pix_fmt
  8649. A string representing the pixel format of the buffered video frames.
  8650. It may be a number corresponding to a pixel format, or a pixel format
  8651. name.
  8652. @item time_base
  8653. Specify the timebase assumed by the timestamps of the buffered frames.
  8654. @item frame_rate
  8655. Specify the frame rate expected for the video stream.
  8656. @item pixel_aspect, sar
  8657. The sample (pixel) aspect ratio of the input video.
  8658. @item sws_param
  8659. Specify the optional parameters to be used for the scale filter which
  8660. is automatically inserted when an input change is detected in the
  8661. input size or format.
  8662. @end table
  8663. For example:
  8664. @example
  8665. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  8666. @end example
  8667. will instruct the source to accept video frames with size 320x240 and
  8668. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  8669. square pixels (1:1 sample aspect ratio).
  8670. Since the pixel format with name "yuv410p" corresponds to the number 6
  8671. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  8672. this example corresponds to:
  8673. @example
  8674. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  8675. @end example
  8676. Alternatively, the options can be specified as a flat string, but this
  8677. syntax is deprecated:
  8678. @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}]
  8679. @section cellauto
  8680. Create a pattern generated by an elementary cellular automaton.
  8681. The initial state of the cellular automaton can be defined through the
  8682. @option{filename}, and @option{pattern} options. If such options are
  8683. not specified an initial state is created randomly.
  8684. At each new frame a new row in the video is filled with the result of
  8685. the cellular automaton next generation. The behavior when the whole
  8686. frame is filled is defined by the @option{scroll} option.
  8687. This source accepts the following options:
  8688. @table @option
  8689. @item filename, f
  8690. Read the initial cellular automaton state, i.e. the starting row, from
  8691. the specified file.
  8692. In the file, each non-whitespace character is considered an alive
  8693. cell, a newline will terminate the row, and further characters in the
  8694. file will be ignored.
  8695. @item pattern, p
  8696. Read the initial cellular automaton state, i.e. the starting row, from
  8697. the specified string.
  8698. Each non-whitespace character in the string is considered an alive
  8699. cell, a newline will terminate the row, and further characters in the
  8700. string will be ignored.
  8701. @item rate, r
  8702. Set the video rate, that is the number of frames generated per second.
  8703. Default is 25.
  8704. @item random_fill_ratio, ratio
  8705. Set the random fill ratio for the initial cellular automaton row. It
  8706. is a floating point number value ranging from 0 to 1, defaults to
  8707. 1/PHI.
  8708. This option is ignored when a file or a pattern is specified.
  8709. @item random_seed, seed
  8710. Set the seed for filling randomly the initial row, must be an integer
  8711. included between 0 and UINT32_MAX. If not specified, or if explicitly
  8712. set to -1, the filter will try to use a good random seed on a best
  8713. effort basis.
  8714. @item rule
  8715. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  8716. Default value is 110.
  8717. @item size, s
  8718. Set the size of the output video. For the syntax of this option, check the
  8719. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8720. If @option{filename} or @option{pattern} is specified, the size is set
  8721. by default to the width of the specified initial state row, and the
  8722. height is set to @var{width} * PHI.
  8723. If @option{size} is set, it must contain the width of the specified
  8724. pattern string, and the specified pattern will be centered in the
  8725. larger row.
  8726. If a filename or a pattern string is not specified, the size value
  8727. defaults to "320x518" (used for a randomly generated initial state).
  8728. @item scroll
  8729. If set to 1, scroll the output upward when all the rows in the output
  8730. have been already filled. If set to 0, the new generated row will be
  8731. written over the top row just after the bottom row is filled.
  8732. Defaults to 1.
  8733. @item start_full, full
  8734. If set to 1, completely fill the output with generated rows before
  8735. outputting the first frame.
  8736. This is the default behavior, for disabling set the value to 0.
  8737. @item stitch
  8738. If set to 1, stitch the left and right row edges together.
  8739. This is the default behavior, for disabling set the value to 0.
  8740. @end table
  8741. @subsection Examples
  8742. @itemize
  8743. @item
  8744. Read the initial state from @file{pattern}, and specify an output of
  8745. size 200x400.
  8746. @example
  8747. cellauto=f=pattern:s=200x400
  8748. @end example
  8749. @item
  8750. Generate a random initial row with a width of 200 cells, with a fill
  8751. ratio of 2/3:
  8752. @example
  8753. cellauto=ratio=2/3:s=200x200
  8754. @end example
  8755. @item
  8756. Create a pattern generated by rule 18 starting by a single alive cell
  8757. centered on an initial row with width 100:
  8758. @example
  8759. cellauto=p=@@:s=100x400:full=0:rule=18
  8760. @end example
  8761. @item
  8762. Specify a more elaborated initial pattern:
  8763. @example
  8764. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  8765. @end example
  8766. @end itemize
  8767. @section mandelbrot
  8768. Generate a Mandelbrot set fractal, and progressively zoom towards the
  8769. point specified with @var{start_x} and @var{start_y}.
  8770. This source accepts the following options:
  8771. @table @option
  8772. @item end_pts
  8773. Set the terminal pts value. Default value is 400.
  8774. @item end_scale
  8775. Set the terminal scale value.
  8776. Must be a floating point value. Default value is 0.3.
  8777. @item inner
  8778. Set the inner coloring mode, that is the algorithm used to draw the
  8779. Mandelbrot fractal internal region.
  8780. It shall assume one of the following values:
  8781. @table @option
  8782. @item black
  8783. Set black mode.
  8784. @item convergence
  8785. Show time until convergence.
  8786. @item mincol
  8787. Set color based on point closest to the origin of the iterations.
  8788. @item period
  8789. Set period mode.
  8790. @end table
  8791. Default value is @var{mincol}.
  8792. @item bailout
  8793. Set the bailout value. Default value is 10.0.
  8794. @item maxiter
  8795. Set the maximum of iterations performed by the rendering
  8796. algorithm. Default value is 7189.
  8797. @item outer
  8798. Set outer coloring mode.
  8799. It shall assume one of following values:
  8800. @table @option
  8801. @item iteration_count
  8802. Set iteration cound mode.
  8803. @item normalized_iteration_count
  8804. set normalized iteration count mode.
  8805. @end table
  8806. Default value is @var{normalized_iteration_count}.
  8807. @item rate, r
  8808. Set frame rate, expressed as number of frames per second. Default
  8809. value is "25".
  8810. @item size, s
  8811. Set frame size. For the syntax of this option, check the "Video
  8812. size" section in the ffmpeg-utils manual. Default value is "640x480".
  8813. @item start_scale
  8814. Set the initial scale value. Default value is 3.0.
  8815. @item start_x
  8816. Set the initial x position. Must be a floating point value between
  8817. -100 and 100. Default value is -0.743643887037158704752191506114774.
  8818. @item start_y
  8819. Set the initial y position. Must be a floating point value between
  8820. -100 and 100. Default value is -0.131825904205311970493132056385139.
  8821. @end table
  8822. @section mptestsrc
  8823. Generate various test patterns, as generated by the MPlayer test filter.
  8824. The size of the generated video is fixed, and is 256x256.
  8825. This source is useful in particular for testing encoding features.
  8826. This source accepts the following options:
  8827. @table @option
  8828. @item rate, r
  8829. Specify the frame rate of the sourced video, as the number of frames
  8830. generated per second. It has to be a string in the format
  8831. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  8832. number or a valid video frame rate abbreviation. The default value is
  8833. "25".
  8834. @item duration, d
  8835. Set the duration of the sourced video. See
  8836. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  8837. for the accepted syntax.
  8838. If not specified, or the expressed duration is negative, the video is
  8839. supposed to be generated forever.
  8840. @item test, t
  8841. Set the number or the name of the test to perform. Supported tests are:
  8842. @table @option
  8843. @item dc_luma
  8844. @item dc_chroma
  8845. @item freq_luma
  8846. @item freq_chroma
  8847. @item amp_luma
  8848. @item amp_chroma
  8849. @item cbp
  8850. @item mv
  8851. @item ring1
  8852. @item ring2
  8853. @item all
  8854. @end table
  8855. Default value is "all", which will cycle through the list of all tests.
  8856. @end table
  8857. Some examples:
  8858. @example
  8859. mptestsrc=t=dc_luma
  8860. @end example
  8861. will generate a "dc_luma" test pattern.
  8862. @section frei0r_src
  8863. Provide a frei0r source.
  8864. To enable compilation of this filter you need to install the frei0r
  8865. header and configure FFmpeg with @code{--enable-frei0r}.
  8866. This source accepts the following parameters:
  8867. @table @option
  8868. @item size
  8869. The size of the video to generate. For the syntax of this option, check the
  8870. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8871. @item framerate
  8872. The framerate of the generated video. It may be a string of the form
  8873. @var{num}/@var{den} or a frame rate abbreviation.
  8874. @item filter_name
  8875. The name to the frei0r source to load. For more information regarding frei0r and
  8876. how to set the parameters, read the @ref{frei0r} section in the video filters
  8877. documentation.
  8878. @item filter_params
  8879. A '|'-separated list of parameters to pass to the frei0r source.
  8880. @end table
  8881. For example, to generate a frei0r partik0l source with size 200x200
  8882. and frame rate 10 which is overlaid on the overlay filter main input:
  8883. @example
  8884. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  8885. @end example
  8886. @section life
  8887. Generate a life pattern.
  8888. This source is based on a generalization of John Conway's life game.
  8889. The sourced input represents a life grid, each pixel represents a cell
  8890. which can be in one of two possible states, alive or dead. Every cell
  8891. interacts with its eight neighbours, which are the cells that are
  8892. horizontally, vertically, or diagonally adjacent.
  8893. At each interaction the grid evolves according to the adopted rule,
  8894. which specifies the number of neighbor alive cells which will make a
  8895. cell stay alive or born. The @option{rule} option allows one to specify
  8896. the rule to adopt.
  8897. This source accepts the following options:
  8898. @table @option
  8899. @item filename, f
  8900. Set the file from which to read the initial grid state. In the file,
  8901. each non-whitespace character is considered an alive cell, and newline
  8902. is used to delimit the end of each row.
  8903. If this option is not specified, the initial grid is generated
  8904. randomly.
  8905. @item rate, r
  8906. Set the video rate, that is the number of frames generated per second.
  8907. Default is 25.
  8908. @item random_fill_ratio, ratio
  8909. Set the random fill ratio for the initial random grid. It is a
  8910. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  8911. It is ignored when a file is specified.
  8912. @item random_seed, seed
  8913. Set the seed for filling the initial random grid, must be an integer
  8914. included between 0 and UINT32_MAX. If not specified, or if explicitly
  8915. set to -1, the filter will try to use a good random seed on a best
  8916. effort basis.
  8917. @item rule
  8918. Set the life rule.
  8919. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  8920. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  8921. @var{NS} specifies the number of alive neighbor cells which make a
  8922. live cell stay alive, and @var{NB} the number of alive neighbor cells
  8923. which make a dead cell to become alive (i.e. to "born").
  8924. "s" and "b" can be used in place of "S" and "B", respectively.
  8925. Alternatively a rule can be specified by an 18-bits integer. The 9
  8926. high order bits are used to encode the next cell state if it is alive
  8927. for each number of neighbor alive cells, the low order bits specify
  8928. the rule for "borning" new cells. Higher order bits encode for an
  8929. higher number of neighbor cells.
  8930. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  8931. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  8932. Default value is "S23/B3", which is the original Conway's game of life
  8933. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  8934. cells, and will born a new cell if there are three alive cells around
  8935. a dead cell.
  8936. @item size, s
  8937. Set the size of the output video. For the syntax of this option, check the
  8938. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8939. If @option{filename} is specified, the size is set by default to the
  8940. same size of the input file. If @option{size} is set, it must contain
  8941. the size specified in the input file, and the initial grid defined in
  8942. that file is centered in the larger resulting area.
  8943. If a filename is not specified, the size value defaults to "320x240"
  8944. (used for a randomly generated initial grid).
  8945. @item stitch
  8946. If set to 1, stitch the left and right grid edges together, and the
  8947. top and bottom edges also. Defaults to 1.
  8948. @item mold
  8949. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  8950. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  8951. value from 0 to 255.
  8952. @item life_color
  8953. Set the color of living (or new born) cells.
  8954. @item death_color
  8955. Set the color of dead cells. If @option{mold} is set, this is the first color
  8956. used to represent a dead cell.
  8957. @item mold_color
  8958. Set mold color, for definitely dead and moldy cells.
  8959. For the syntax of these 3 color options, check the "Color" section in the
  8960. ffmpeg-utils manual.
  8961. @end table
  8962. @subsection Examples
  8963. @itemize
  8964. @item
  8965. Read a grid from @file{pattern}, and center it on a grid of size
  8966. 300x300 pixels:
  8967. @example
  8968. life=f=pattern:s=300x300
  8969. @end example
  8970. @item
  8971. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  8972. @example
  8973. life=ratio=2/3:s=200x200
  8974. @end example
  8975. @item
  8976. Specify a custom rule for evolving a randomly generated grid:
  8977. @example
  8978. life=rule=S14/B34
  8979. @end example
  8980. @item
  8981. Full example with slow death effect (mold) using @command{ffplay}:
  8982. @example
  8983. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  8984. @end example
  8985. @end itemize
  8986. @anchor{allrgb}
  8987. @anchor{allyuv}
  8988. @anchor{color}
  8989. @anchor{haldclutsrc}
  8990. @anchor{nullsrc}
  8991. @anchor{rgbtestsrc}
  8992. @anchor{smptebars}
  8993. @anchor{smptehdbars}
  8994. @anchor{testsrc}
  8995. @section allrgb, allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  8996. The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
  8997. The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
  8998. The @code{color} source provides an uniformly colored input.
  8999. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  9000. @ref{haldclut} filter.
  9001. The @code{nullsrc} source returns unprocessed video frames. It is
  9002. mainly useful to be employed in analysis / debugging tools, or as the
  9003. source for filters which ignore the input data.
  9004. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  9005. detecting RGB vs BGR issues. You should see a red, green and blue
  9006. stripe from top to bottom.
  9007. The @code{smptebars} source generates a color bars pattern, based on
  9008. the SMPTE Engineering Guideline EG 1-1990.
  9009. The @code{smptehdbars} source generates a color bars pattern, based on
  9010. the SMPTE RP 219-2002.
  9011. The @code{testsrc} source generates a test video pattern, showing a
  9012. color pattern, a scrolling gradient and a timestamp. This is mainly
  9013. intended for testing purposes.
  9014. The sources accept the following parameters:
  9015. @table @option
  9016. @item color, c
  9017. Specify the color of the source, only available in the @code{color}
  9018. source. For the syntax of this option, check the "Color" section in the
  9019. ffmpeg-utils manual.
  9020. @item level
  9021. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  9022. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  9023. pixels to be used as identity matrix for 3D lookup tables. Each component is
  9024. coded on a @code{1/(N*N)} scale.
  9025. @item size, s
  9026. Specify the size of the sourced video. For the syntax of this option, check the
  9027. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9028. The default value is @code{320x240}.
  9029. This option is not available with the @code{haldclutsrc} filter.
  9030. @item rate, r
  9031. Specify the frame rate of the sourced video, as the number of frames
  9032. generated per second. It has to be a string in the format
  9033. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  9034. number or a valid video frame rate abbreviation. The default value is
  9035. "25".
  9036. @item sar
  9037. Set the sample aspect ratio of the sourced video.
  9038. @item duration, d
  9039. Set the duration of the sourced video. See
  9040. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  9041. for the accepted syntax.
  9042. If not specified, or the expressed duration is negative, the video is
  9043. supposed to be generated forever.
  9044. @item decimals, n
  9045. Set the number of decimals to show in the timestamp, only available in the
  9046. @code{testsrc} source.
  9047. The displayed timestamp value will correspond to the original
  9048. timestamp value multiplied by the power of 10 of the specified
  9049. value. Default value is 0.
  9050. @end table
  9051. For example the following:
  9052. @example
  9053. testsrc=duration=5.3:size=qcif:rate=10
  9054. @end example
  9055. will generate a video with a duration of 5.3 seconds, with size
  9056. 176x144 and a frame rate of 10 frames per second.
  9057. The following graph description will generate a red source
  9058. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  9059. frames per second.
  9060. @example
  9061. color=c=red@@0.2:s=qcif:r=10
  9062. @end example
  9063. If the input content is to be ignored, @code{nullsrc} can be used. The
  9064. following command generates noise in the luminance plane by employing
  9065. the @code{geq} filter:
  9066. @example
  9067. nullsrc=s=256x256, geq=random(1)*255:128:128
  9068. @end example
  9069. @subsection Commands
  9070. The @code{color} source supports the following commands:
  9071. @table @option
  9072. @item c, color
  9073. Set the color of the created image. Accepts the same syntax of the
  9074. corresponding @option{color} option.
  9075. @end table
  9076. @c man end VIDEO SOURCES
  9077. @chapter Video Sinks
  9078. @c man begin VIDEO SINKS
  9079. Below is a description of the currently available video sinks.
  9080. @section buffersink
  9081. Buffer video frames, and make them available to the end of the filter
  9082. graph.
  9083. This sink is mainly intended for programmatic use, in particular
  9084. through the interface defined in @file{libavfilter/buffersink.h}
  9085. or the options system.
  9086. It accepts a pointer to an AVBufferSinkContext structure, which
  9087. defines the incoming buffers' formats, to be passed as the opaque
  9088. parameter to @code{avfilter_init_filter} for initialization.
  9089. @section nullsink
  9090. Null video sink: do absolutely nothing with the input video. It is
  9091. mainly useful as a template and for use in analysis / debugging
  9092. tools.
  9093. @c man end VIDEO SINKS
  9094. @chapter Multimedia Filters
  9095. @c man begin MULTIMEDIA FILTERS
  9096. Below is a description of the currently available multimedia filters.
  9097. @section aphasemeter
  9098. Convert input audio to a video output, displaying the audio phase.
  9099. The filter accepts the following options:
  9100. @table @option
  9101. @item rate, r
  9102. Set the output frame rate. Default value is @code{25}.
  9103. @item size, s
  9104. Set the video size for the output. For the syntax of this option, check the
  9105. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9106. Default value is @code{800x400}.
  9107. @item rc
  9108. @item gc
  9109. @item bc
  9110. Specify the red, green, blue contrast. Default values are @code{2},
  9111. @code{7} and @code{1}.
  9112. Allowed range is @code{[0, 255]}.
  9113. @item mpc
  9114. Set color which will be used for drawing median phase. If color is
  9115. @code{none} which is default, no median phase value will be drawn.
  9116. @end table
  9117. The filter also exports the frame metadata @code{lavfi.aphasemeter.phase} which
  9118. represents mean phase of current audio frame. Value is in range @code{[-1, 1]}.
  9119. The @code{-1} means left and right channels are completely out of phase and
  9120. @code{1} means channels are in phase.
  9121. @section avectorscope
  9122. Convert input audio to a video output, representing the audio vector
  9123. scope.
  9124. The filter is used to measure the difference between channels of stereo
  9125. audio stream. A monoaural signal, consisting of identical left and right
  9126. signal, results in straight vertical line. Any stereo separation is visible
  9127. as a deviation from this line, creating a Lissajous figure.
  9128. If the straight (or deviation from it) but horizontal line appears this
  9129. indicates that the left and right channels are out of phase.
  9130. The filter accepts the following options:
  9131. @table @option
  9132. @item mode, m
  9133. Set the vectorscope mode.
  9134. Available values are:
  9135. @table @samp
  9136. @item lissajous
  9137. Lissajous rotated by 45 degrees.
  9138. @item lissajous_xy
  9139. Same as above but not rotated.
  9140. @item polar
  9141. Shape resembling half of circle.
  9142. @end table
  9143. Default value is @samp{lissajous}.
  9144. @item size, s
  9145. Set the video size for the output. For the syntax of this option, check the
  9146. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9147. Default value is @code{400x400}.
  9148. @item rate, r
  9149. Set the output frame rate. Default value is @code{25}.
  9150. @item rc
  9151. @item gc
  9152. @item bc
  9153. @item ac
  9154. Specify the red, green, blue and alpha contrast. Default values are @code{40},
  9155. @code{160}, @code{80} and @code{255}.
  9156. Allowed range is @code{[0, 255]}.
  9157. @item rf
  9158. @item gf
  9159. @item bf
  9160. @item af
  9161. Specify the red, green, blue and alpha fade. Default values are @code{15},
  9162. @code{10}, @code{5} and @code{5}.
  9163. Allowed range is @code{[0, 255]}.
  9164. @item zoom
  9165. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  9166. @end table
  9167. @subsection Examples
  9168. @itemize
  9169. @item
  9170. Complete example using @command{ffplay}:
  9171. @example
  9172. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  9173. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  9174. @end example
  9175. @end itemize
  9176. @section concat
  9177. Concatenate audio and video streams, joining them together one after the
  9178. other.
  9179. The filter works on segments of synchronized video and audio streams. All
  9180. segments must have the same number of streams of each type, and that will
  9181. also be the number of streams at output.
  9182. The filter accepts the following options:
  9183. @table @option
  9184. @item n
  9185. Set the number of segments. Default is 2.
  9186. @item v
  9187. Set the number of output video streams, that is also the number of video
  9188. streams in each segment. Default is 1.
  9189. @item a
  9190. Set the number of output audio streams, that is also the number of audio
  9191. streams in each segment. Default is 0.
  9192. @item unsafe
  9193. Activate unsafe mode: do not fail if segments have a different format.
  9194. @end table
  9195. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  9196. @var{a} audio outputs.
  9197. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  9198. segment, in the same order as the outputs, then the inputs for the second
  9199. segment, etc.
  9200. Related streams do not always have exactly the same duration, for various
  9201. reasons including codec frame size or sloppy authoring. For that reason,
  9202. related synchronized streams (e.g. a video and its audio track) should be
  9203. concatenated at once. The concat filter will use the duration of the longest
  9204. stream in each segment (except the last one), and if necessary pad shorter
  9205. audio streams with silence.
  9206. For this filter to work correctly, all segments must start at timestamp 0.
  9207. All corresponding streams must have the same parameters in all segments; the
  9208. filtering system will automatically select a common pixel format for video
  9209. streams, and a common sample format, sample rate and channel layout for
  9210. audio streams, but other settings, such as resolution, must be converted
  9211. explicitly by the user.
  9212. Different frame rates are acceptable but will result in variable frame rate
  9213. at output; be sure to configure the output file to handle it.
  9214. @subsection Examples
  9215. @itemize
  9216. @item
  9217. Concatenate an opening, an episode and an ending, all in bilingual version
  9218. (video in stream 0, audio in streams 1 and 2):
  9219. @example
  9220. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  9221. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  9222. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  9223. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  9224. @end example
  9225. @item
  9226. Concatenate two parts, handling audio and video separately, using the
  9227. (a)movie sources, and adjusting the resolution:
  9228. @example
  9229. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  9230. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  9231. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  9232. @end example
  9233. Note that a desync will happen at the stitch if the audio and video streams
  9234. do not have exactly the same duration in the first file.
  9235. @end itemize
  9236. @anchor{ebur128}
  9237. @section ebur128
  9238. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  9239. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  9240. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  9241. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  9242. The filter also has a video output (see the @var{video} option) with a real
  9243. time graph to observe the loudness evolution. The graphic contains the logged
  9244. message mentioned above, so it is not printed anymore when this option is set,
  9245. unless the verbose logging is set. The main graphing area contains the
  9246. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  9247. the momentary loudness (400 milliseconds).
  9248. More information about the Loudness Recommendation EBU R128 on
  9249. @url{http://tech.ebu.ch/loudness}.
  9250. The filter accepts the following options:
  9251. @table @option
  9252. @item video
  9253. Activate the video output. The audio stream is passed unchanged whether this
  9254. option is set or no. The video stream will be the first output stream if
  9255. activated. Default is @code{0}.
  9256. @item size
  9257. Set the video size. This option is for video only. For the syntax of this
  9258. option, check the
  9259. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9260. Default and minimum resolution is @code{640x480}.
  9261. @item meter
  9262. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  9263. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  9264. other integer value between this range is allowed.
  9265. @item metadata
  9266. Set metadata injection. If set to @code{1}, the audio input will be segmented
  9267. into 100ms output frames, each of them containing various loudness information
  9268. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  9269. Default is @code{0}.
  9270. @item framelog
  9271. Force the frame logging level.
  9272. Available values are:
  9273. @table @samp
  9274. @item info
  9275. information logging level
  9276. @item verbose
  9277. verbose logging level
  9278. @end table
  9279. By default, the logging level is set to @var{info}. If the @option{video} or
  9280. the @option{metadata} options are set, it switches to @var{verbose}.
  9281. @item peak
  9282. Set peak mode(s).
  9283. Available modes can be cumulated (the option is a @code{flag} type). Possible
  9284. values are:
  9285. @table @samp
  9286. @item none
  9287. Disable any peak mode (default).
  9288. @item sample
  9289. Enable sample-peak mode.
  9290. Simple peak mode looking for the higher sample value. It logs a message
  9291. for sample-peak (identified by @code{SPK}).
  9292. @item true
  9293. Enable true-peak mode.
  9294. If enabled, the peak lookup is done on an over-sampled version of the input
  9295. stream for better peak accuracy. It logs a message for true-peak.
  9296. (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
  9297. This mode requires a build with @code{libswresample}.
  9298. @end table
  9299. @end table
  9300. @subsection Examples
  9301. @itemize
  9302. @item
  9303. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  9304. @example
  9305. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  9306. @end example
  9307. @item
  9308. Run an analysis with @command{ffmpeg}:
  9309. @example
  9310. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  9311. @end example
  9312. @end itemize
  9313. @section interleave, ainterleave
  9314. Temporally interleave frames from several inputs.
  9315. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  9316. These filters read frames from several inputs and send the oldest
  9317. queued frame to the output.
  9318. Input streams must have a well defined, monotonically increasing frame
  9319. timestamp values.
  9320. In order to submit one frame to output, these filters need to enqueue
  9321. at least one frame for each input, so they cannot work in case one
  9322. input is not yet terminated and will not receive incoming frames.
  9323. For example consider the case when one input is a @code{select} filter
  9324. which always drop input frames. The @code{interleave} filter will keep
  9325. reading from that input, but it will never be able to send new frames
  9326. to output until the input will send an end-of-stream signal.
  9327. Also, depending on inputs synchronization, the filters will drop
  9328. frames in case one input receives more frames than the other ones, and
  9329. the queue is already filled.
  9330. These filters accept the following options:
  9331. @table @option
  9332. @item nb_inputs, n
  9333. Set the number of different inputs, it is 2 by default.
  9334. @end table
  9335. @subsection Examples
  9336. @itemize
  9337. @item
  9338. Interleave frames belonging to different streams using @command{ffmpeg}:
  9339. @example
  9340. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  9341. @end example
  9342. @item
  9343. Add flickering blur effect:
  9344. @example
  9345. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  9346. @end example
  9347. @end itemize
  9348. @section perms, aperms
  9349. Set read/write permissions for the output frames.
  9350. These filters are mainly aimed at developers to test direct path in the
  9351. following filter in the filtergraph.
  9352. The filters accept the following options:
  9353. @table @option
  9354. @item mode
  9355. Select the permissions mode.
  9356. It accepts the following values:
  9357. @table @samp
  9358. @item none
  9359. Do nothing. This is the default.
  9360. @item ro
  9361. Set all the output frames read-only.
  9362. @item rw
  9363. Set all the output frames directly writable.
  9364. @item toggle
  9365. Make the frame read-only if writable, and writable if read-only.
  9366. @item random
  9367. Set each output frame read-only or writable randomly.
  9368. @end table
  9369. @item seed
  9370. Set the seed for the @var{random} mode, must be an integer included between
  9371. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  9372. @code{-1}, the filter will try to use a good random seed on a best effort
  9373. basis.
  9374. @end table
  9375. Note: in case of auto-inserted filter between the permission filter and the
  9376. following one, the permission might not be received as expected in that
  9377. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  9378. perms/aperms filter can avoid this problem.
  9379. @section select, aselect
  9380. Select frames to pass in output.
  9381. This filter accepts the following options:
  9382. @table @option
  9383. @item expr, e
  9384. Set expression, which is evaluated for each input frame.
  9385. If the expression is evaluated to zero, the frame is discarded.
  9386. If the evaluation result is negative or NaN, the frame is sent to the
  9387. first output; otherwise it is sent to the output with index
  9388. @code{ceil(val)-1}, assuming that the input index starts from 0.
  9389. For example a value of @code{1.2} corresponds to the output with index
  9390. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  9391. @item outputs, n
  9392. Set the number of outputs. The output to which to send the selected
  9393. frame is based on the result of the evaluation. Default value is 1.
  9394. @end table
  9395. The expression can contain the following constants:
  9396. @table @option
  9397. @item n
  9398. The (sequential) number of the filtered frame, starting from 0.
  9399. @item selected_n
  9400. The (sequential) number of the selected frame, starting from 0.
  9401. @item prev_selected_n
  9402. The sequential number of the last selected frame. It's NAN if undefined.
  9403. @item TB
  9404. The timebase of the input timestamps.
  9405. @item pts
  9406. The PTS (Presentation TimeStamp) of the filtered video frame,
  9407. expressed in @var{TB} units. It's NAN if undefined.
  9408. @item t
  9409. The PTS of the filtered video frame,
  9410. expressed in seconds. It's NAN if undefined.
  9411. @item prev_pts
  9412. The PTS of the previously filtered video frame. It's NAN if undefined.
  9413. @item prev_selected_pts
  9414. The PTS of the last previously filtered video frame. It's NAN if undefined.
  9415. @item prev_selected_t
  9416. The PTS of the last previously selected video frame. It's NAN if undefined.
  9417. @item start_pts
  9418. The PTS of the first video frame in the video. It's NAN if undefined.
  9419. @item start_t
  9420. The time of the first video frame in the video. It's NAN if undefined.
  9421. @item pict_type @emph{(video only)}
  9422. The type of the filtered frame. It can assume one of the following
  9423. values:
  9424. @table @option
  9425. @item I
  9426. @item P
  9427. @item B
  9428. @item S
  9429. @item SI
  9430. @item SP
  9431. @item BI
  9432. @end table
  9433. @item interlace_type @emph{(video only)}
  9434. The frame interlace type. It can assume one of the following values:
  9435. @table @option
  9436. @item PROGRESSIVE
  9437. The frame is progressive (not interlaced).
  9438. @item TOPFIRST
  9439. The frame is top-field-first.
  9440. @item BOTTOMFIRST
  9441. The frame is bottom-field-first.
  9442. @end table
  9443. @item consumed_sample_n @emph{(audio only)}
  9444. the number of selected samples before the current frame
  9445. @item samples_n @emph{(audio only)}
  9446. the number of samples in the current frame
  9447. @item sample_rate @emph{(audio only)}
  9448. the input sample rate
  9449. @item key
  9450. This is 1 if the filtered frame is a key-frame, 0 otherwise.
  9451. @item pos
  9452. the position in the file of the filtered frame, -1 if the information
  9453. is not available (e.g. for synthetic video)
  9454. @item scene @emph{(video only)}
  9455. value between 0 and 1 to indicate a new scene; a low value reflects a low
  9456. probability for the current frame to introduce a new scene, while a higher
  9457. value means the current frame is more likely to be one (see the example below)
  9458. @end table
  9459. The default value of the select expression is "1".
  9460. @subsection Examples
  9461. @itemize
  9462. @item
  9463. Select all frames in input:
  9464. @example
  9465. select
  9466. @end example
  9467. The example above is the same as:
  9468. @example
  9469. select=1
  9470. @end example
  9471. @item
  9472. Skip all frames:
  9473. @example
  9474. select=0
  9475. @end example
  9476. @item
  9477. Select only I-frames:
  9478. @example
  9479. select='eq(pict_type\,I)'
  9480. @end example
  9481. @item
  9482. Select one frame every 100:
  9483. @example
  9484. select='not(mod(n\,100))'
  9485. @end example
  9486. @item
  9487. Select only frames contained in the 10-20 time interval:
  9488. @example
  9489. select=between(t\,10\,20)
  9490. @end example
  9491. @item
  9492. Select only I frames contained in the 10-20 time interval:
  9493. @example
  9494. select=between(t\,10\,20)*eq(pict_type\,I)
  9495. @end example
  9496. @item
  9497. Select frames with a minimum distance of 10 seconds:
  9498. @example
  9499. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  9500. @end example
  9501. @item
  9502. Use aselect to select only audio frames with samples number > 100:
  9503. @example
  9504. aselect='gt(samples_n\,100)'
  9505. @end example
  9506. @item
  9507. Create a mosaic of the first scenes:
  9508. @example
  9509. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  9510. @end example
  9511. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  9512. choice.
  9513. @item
  9514. Send even and odd frames to separate outputs, and compose them:
  9515. @example
  9516. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  9517. @end example
  9518. @end itemize
  9519. @section sendcmd, asendcmd
  9520. Send commands to filters in the filtergraph.
  9521. These filters read commands to be sent to other filters in the
  9522. filtergraph.
  9523. @code{sendcmd} must be inserted between two video filters,
  9524. @code{asendcmd} must be inserted between two audio filters, but apart
  9525. from that they act the same way.
  9526. The specification of commands can be provided in the filter arguments
  9527. with the @var{commands} option, or in a file specified by the
  9528. @var{filename} option.
  9529. These filters accept the following options:
  9530. @table @option
  9531. @item commands, c
  9532. Set the commands to be read and sent to the other filters.
  9533. @item filename, f
  9534. Set the filename of the commands to be read and sent to the other
  9535. filters.
  9536. @end table
  9537. @subsection Commands syntax
  9538. A commands description consists of a sequence of interval
  9539. specifications, comprising a list of commands to be executed when a
  9540. particular event related to that interval occurs. The occurring event
  9541. is typically the current frame time entering or leaving a given time
  9542. interval.
  9543. An interval is specified by the following syntax:
  9544. @example
  9545. @var{START}[-@var{END}] @var{COMMANDS};
  9546. @end example
  9547. The time interval is specified by the @var{START} and @var{END} times.
  9548. @var{END} is optional and defaults to the maximum time.
  9549. The current frame time is considered within the specified interval if
  9550. it is included in the interval [@var{START}, @var{END}), that is when
  9551. the time is greater or equal to @var{START} and is lesser than
  9552. @var{END}.
  9553. @var{COMMANDS} consists of a sequence of one or more command
  9554. specifications, separated by ",", relating to that interval. The
  9555. syntax of a command specification is given by:
  9556. @example
  9557. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  9558. @end example
  9559. @var{FLAGS} is optional and specifies the type of events relating to
  9560. the time interval which enable sending the specified command, and must
  9561. be a non-null sequence of identifier flags separated by "+" or "|" and
  9562. enclosed between "[" and "]".
  9563. The following flags are recognized:
  9564. @table @option
  9565. @item enter
  9566. The command is sent when the current frame timestamp enters the
  9567. specified interval. In other words, the command is sent when the
  9568. previous frame timestamp was not in the given interval, and the
  9569. current is.
  9570. @item leave
  9571. The command is sent when the current frame timestamp leaves the
  9572. specified interval. In other words, the command is sent when the
  9573. previous frame timestamp was in the given interval, and the
  9574. current is not.
  9575. @end table
  9576. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  9577. assumed.
  9578. @var{TARGET} specifies the target of the command, usually the name of
  9579. the filter class or a specific filter instance name.
  9580. @var{COMMAND} specifies the name of the command for the target filter.
  9581. @var{ARG} is optional and specifies the optional list of argument for
  9582. the given @var{COMMAND}.
  9583. Between one interval specification and another, whitespaces, or
  9584. sequences of characters starting with @code{#} until the end of line,
  9585. are ignored and can be used to annotate comments.
  9586. A simplified BNF description of the commands specification syntax
  9587. follows:
  9588. @example
  9589. @var{COMMAND_FLAG} ::= "enter" | "leave"
  9590. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  9591. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  9592. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  9593. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  9594. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  9595. @end example
  9596. @subsection Examples
  9597. @itemize
  9598. @item
  9599. Specify audio tempo change at second 4:
  9600. @example
  9601. asendcmd=c='4.0 atempo tempo 1.5',atempo
  9602. @end example
  9603. @item
  9604. Specify a list of drawtext and hue commands in a file.
  9605. @example
  9606. # show text in the interval 5-10
  9607. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  9608. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  9609. # desaturate the image in the interval 15-20
  9610. 15.0-20.0 [enter] hue s 0,
  9611. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  9612. [leave] hue s 1,
  9613. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  9614. # apply an exponential saturation fade-out effect, starting from time 25
  9615. 25 [enter] hue s exp(25-t)
  9616. @end example
  9617. A filtergraph allowing to read and process the above command list
  9618. stored in a file @file{test.cmd}, can be specified with:
  9619. @example
  9620. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  9621. @end example
  9622. @end itemize
  9623. @anchor{setpts}
  9624. @section setpts, asetpts
  9625. Change the PTS (presentation timestamp) of the input frames.
  9626. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  9627. This filter accepts the following options:
  9628. @table @option
  9629. @item expr
  9630. The expression which is evaluated for each frame to construct its timestamp.
  9631. @end table
  9632. The expression is evaluated through the eval API and can contain the following
  9633. constants:
  9634. @table @option
  9635. @item FRAME_RATE
  9636. frame rate, only defined for constant frame-rate video
  9637. @item PTS
  9638. The presentation timestamp in input
  9639. @item N
  9640. The count of the input frame for video or the number of consumed samples,
  9641. not including the current frame for audio, starting from 0.
  9642. @item NB_CONSUMED_SAMPLES
  9643. The number of consumed samples, not including the current frame (only
  9644. audio)
  9645. @item NB_SAMPLES, S
  9646. The number of samples in the current frame (only audio)
  9647. @item SAMPLE_RATE, SR
  9648. The audio sample rate.
  9649. @item STARTPTS
  9650. The PTS of the first frame.
  9651. @item STARTT
  9652. the time in seconds of the first frame
  9653. @item INTERLACED
  9654. State whether the current frame is interlaced.
  9655. @item T
  9656. the time in seconds of the current frame
  9657. @item POS
  9658. original position in the file of the frame, or undefined if undefined
  9659. for the current frame
  9660. @item PREV_INPTS
  9661. The previous input PTS.
  9662. @item PREV_INT
  9663. previous input time in seconds
  9664. @item PREV_OUTPTS
  9665. The previous output PTS.
  9666. @item PREV_OUTT
  9667. previous output time in seconds
  9668. @item RTCTIME
  9669. The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  9670. instead.
  9671. @item RTCSTART
  9672. The wallclock (RTC) time at the start of the movie in microseconds.
  9673. @item TB
  9674. The timebase of the input timestamps.
  9675. @end table
  9676. @subsection Examples
  9677. @itemize
  9678. @item
  9679. Start counting PTS from zero
  9680. @example
  9681. setpts=PTS-STARTPTS
  9682. @end example
  9683. @item
  9684. Apply fast motion effect:
  9685. @example
  9686. setpts=0.5*PTS
  9687. @end example
  9688. @item
  9689. Apply slow motion effect:
  9690. @example
  9691. setpts=2.0*PTS
  9692. @end example
  9693. @item
  9694. Set fixed rate of 25 frames per second:
  9695. @example
  9696. setpts=N/(25*TB)
  9697. @end example
  9698. @item
  9699. Set fixed rate 25 fps with some jitter:
  9700. @example
  9701. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  9702. @end example
  9703. @item
  9704. Apply an offset of 10 seconds to the input PTS:
  9705. @example
  9706. setpts=PTS+10/TB
  9707. @end example
  9708. @item
  9709. Generate timestamps from a "live source" and rebase onto the current timebase:
  9710. @example
  9711. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  9712. @end example
  9713. @item
  9714. Generate timestamps by counting samples:
  9715. @example
  9716. asetpts=N/SR/TB
  9717. @end example
  9718. @end itemize
  9719. @section settb, asettb
  9720. Set the timebase to use for the output frames timestamps.
  9721. It is mainly useful for testing timebase configuration.
  9722. It accepts the following parameters:
  9723. @table @option
  9724. @item expr, tb
  9725. The expression which is evaluated into the output timebase.
  9726. @end table
  9727. The value for @option{tb} is an arithmetic expression representing a
  9728. rational. The expression can contain the constants "AVTB" (the default
  9729. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  9730. audio only). Default value is "intb".
  9731. @subsection Examples
  9732. @itemize
  9733. @item
  9734. Set the timebase to 1/25:
  9735. @example
  9736. settb=expr=1/25
  9737. @end example
  9738. @item
  9739. Set the timebase to 1/10:
  9740. @example
  9741. settb=expr=0.1
  9742. @end example
  9743. @item
  9744. Set the timebase to 1001/1000:
  9745. @example
  9746. settb=1+0.001
  9747. @end example
  9748. @item
  9749. Set the timebase to 2*intb:
  9750. @example
  9751. settb=2*intb
  9752. @end example
  9753. @item
  9754. Set the default timebase value:
  9755. @example
  9756. settb=AVTB
  9757. @end example
  9758. @end itemize
  9759. @section showcqt
  9760. Convert input audio to a video output representing
  9761. frequency spectrum logarithmically (using constant Q transform with
  9762. Brown-Puckette algorithm), with musical tone scale, from E0 to D#10 (10 octaves).
  9763. The filter accepts the following options:
  9764. @table @option
  9765. @item volume
  9766. Specify transform volume (multiplier) expression. The expression can contain
  9767. variables:
  9768. @table @option
  9769. @item frequency, freq, f
  9770. the frequency where transform is evaluated
  9771. @item timeclamp, tc
  9772. value of timeclamp option
  9773. @end table
  9774. and functions:
  9775. @table @option
  9776. @item a_weighting(f)
  9777. A-weighting of equal loudness
  9778. @item b_weighting(f)
  9779. B-weighting of equal loudness
  9780. @item c_weighting(f)
  9781. C-weighting of equal loudness
  9782. @end table
  9783. Default value is @code{16}.
  9784. @item tlength
  9785. Specify transform length expression. The expression can contain variables:
  9786. @table @option
  9787. @item frequency, freq, f
  9788. the frequency where transform is evaluated
  9789. @item timeclamp, tc
  9790. value of timeclamp option
  9791. @end table
  9792. Default value is @code{384/f*tc/(384/f+tc)}.
  9793. @item timeclamp
  9794. Specify the transform timeclamp. At low frequency, there is trade-off between
  9795. accuracy in time domain and frequency domain. If timeclamp is lower,
  9796. event in time domain is represented more accurately (such as fast bass drum),
  9797. otherwise event in frequency domain is represented more accurately
  9798. (such as bass guitar). Acceptable value is [0.1, 1.0]. Default value is @code{0.17}.
  9799. @item coeffclamp
  9800. Specify the transform coeffclamp. If coeffclamp is lower, transform is
  9801. more accurate, otherwise transform is faster. Acceptable value is [0.1, 10.0].
  9802. Default value is @code{1.0}.
  9803. @item gamma
  9804. Specify gamma. Lower gamma makes the spectrum more contrast, higher gamma
  9805. makes the spectrum having more range. Acceptable value is [1.0, 7.0].
  9806. Default value is @code{3.0}.
  9807. @item gamma2
  9808. Specify gamma of bargraph. Acceptable value is [1.0, 7.0].
  9809. Default value is @code{1.0}.
  9810. @item fontfile
  9811. Specify font file for use with freetype. If not specified, use embedded font.
  9812. @item fontcolor
  9813. Specify font color expression. This is arithmetic expression that should return
  9814. integer value 0xRRGGBB. The expression can contain variables:
  9815. @table @option
  9816. @item frequency, freq, f
  9817. the frequency where transform is evaluated
  9818. @item timeclamp, tc
  9819. value of timeclamp option
  9820. @end table
  9821. and functions:
  9822. @table @option
  9823. @item midi(f)
  9824. midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
  9825. @item r(x), g(x), b(x)
  9826. red, green, and blue value of intensity x
  9827. @end table
  9828. Default value is @code{st(0, (midi(f)-59.5)/12);
  9829. st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
  9830. r(1-ld(1)) + b(ld(1))}
  9831. @item fullhd
  9832. If set to 1 (the default), the video size is 1920x1080 (full HD),
  9833. if set to 0, the video size is 960x540. Use this option to make CPU usage lower.
  9834. @item fps
  9835. Specify video fps. Default value is @code{25}.
  9836. @item count
  9837. Specify number of transform per frame, so there are fps*count transforms
  9838. per second. Note that audio data rate must be divisible by fps*count.
  9839. Default value is @code{6}.
  9840. @end table
  9841. @subsection Examples
  9842. @itemize
  9843. @item
  9844. Playing audio while showing the spectrum:
  9845. @example
  9846. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
  9847. @end example
  9848. @item
  9849. Same as above, but with frame rate 30 fps:
  9850. @example
  9851. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
  9852. @end example
  9853. @item
  9854. Playing at 960x540 and lower CPU usage:
  9855. @example
  9856. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fullhd=0:count=3 [out0]'
  9857. @end example
  9858. @item
  9859. A1 and its harmonics: A1, A2, (near)E3, A3:
  9860. @example
  9861. 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),
  9862. asplit[a][out1]; [a] showcqt [out0]'
  9863. @end example
  9864. @item
  9865. Same as above, but with more accuracy in frequency domain (and slower):
  9866. @example
  9867. 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),
  9868. asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
  9869. @end example
  9870. @item
  9871. B-weighting of equal loudness
  9872. @example
  9873. volume=16*b_weighting(f)
  9874. @end example
  9875. @item
  9876. Lower Q factor
  9877. @example
  9878. tlength=100/f*tc/(100/f+tc)
  9879. @end example
  9880. @item
  9881. Custom fontcolor, C-note is colored green, others are colored blue
  9882. @example
  9883. fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))'
  9884. @end example
  9885. @item
  9886. Custom gamma, now spectrum is linear to the amplitude.
  9887. @example
  9888. gamma=2:gamma2=2
  9889. @end example
  9890. @end itemize
  9891. @section showfreqs
  9892. Convert input audio to video output representing the audio power spectrum.
  9893. Audio amplitude is on Y-axis while frequency is on X-axis.
  9894. The filter accepts the following options:
  9895. @table @option
  9896. @item size, s
  9897. Specify size of video. For the syntax of this option, check the
  9898. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9899. Default is @code{1024x512}.
  9900. @item mode
  9901. Set display mode.
  9902. This set how each frequency bin will be represented.
  9903. It accepts the following values:
  9904. @table @samp
  9905. @item line
  9906. @item bar
  9907. @item dot
  9908. @end table
  9909. Default is @code{bar}.
  9910. @item ascale
  9911. Set amplitude scale.
  9912. It accepts the following values:
  9913. @table @samp
  9914. @item lin
  9915. Linear scale.
  9916. @item sqrt
  9917. Square root scale.
  9918. @item cbrt
  9919. Cubic root scale.
  9920. @item log
  9921. Logarithmic scale.
  9922. @end table
  9923. Default is @code{log}.
  9924. @item fscale
  9925. Set frequency scale.
  9926. It accepts the following values:
  9927. @table @samp
  9928. @item lin
  9929. Linear scale.
  9930. @item log
  9931. Logarithmic scale.
  9932. @item rlog
  9933. Reverse logarithmic scale.
  9934. @end table
  9935. Default is @code{lin}.
  9936. @item win_size
  9937. Set window size.
  9938. It accepts the following values:
  9939. @table @samp
  9940. @item w16
  9941. @item w32
  9942. @item w64
  9943. @item w128
  9944. @item w256
  9945. @item w512
  9946. @item w1024
  9947. @item w2048
  9948. @item w4096
  9949. @item w8192
  9950. @item w16384
  9951. @item w32768
  9952. @item w65536
  9953. @end table
  9954. Default is @code{w2048}
  9955. @item win_func
  9956. Set windowing function.
  9957. It accepts the following values:
  9958. @table @samp
  9959. @item rect
  9960. @item bartlett
  9961. @item hanning
  9962. @item hamming
  9963. @item blackman
  9964. @item welch
  9965. @item flattop
  9966. @item bharris
  9967. @item bnuttall
  9968. @item bhann
  9969. @item sine
  9970. @item nuttall
  9971. @end table
  9972. Default is @code{hanning}.
  9973. @item overlap
  9974. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  9975. which means optimal overlap for selected window function will be picked.
  9976. @item averaging
  9977. Set time averaging. Setting this to 0 will display current maximal peaks.
  9978. Default is @code{1}, which means time averaging is disabled.
  9979. @item color
  9980. Specify list of colors separated by space or by '|' which will be used to
  9981. draw channel frequencies. Unrecognized or missing colors will be replaced
  9982. by white color.
  9983. @end table
  9984. @section showspectrum
  9985. Convert input audio to a video output, representing the audio frequency
  9986. spectrum.
  9987. The filter accepts the following options:
  9988. @table @option
  9989. @item size, s
  9990. Specify the video size for the output. For the syntax of this option, check the
  9991. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9992. Default value is @code{640x512}.
  9993. @item slide
  9994. Specify how the spectrum should slide along the window.
  9995. It accepts the following values:
  9996. @table @samp
  9997. @item replace
  9998. the samples start again on the left when they reach the right
  9999. @item scroll
  10000. the samples scroll from right to left
  10001. @item fullframe
  10002. frames are only produced when the samples reach the right
  10003. @end table
  10004. Default value is @code{replace}.
  10005. @item mode
  10006. Specify display mode.
  10007. It accepts the following values:
  10008. @table @samp
  10009. @item combined
  10010. all channels are displayed in the same row
  10011. @item separate
  10012. all channels are displayed in separate rows
  10013. @end table
  10014. Default value is @samp{combined}.
  10015. @item color
  10016. Specify display color mode.
  10017. It accepts the following values:
  10018. @table @samp
  10019. @item channel
  10020. each channel is displayed in a separate color
  10021. @item intensity
  10022. each channel is is displayed using the same color scheme
  10023. @end table
  10024. Default value is @samp{channel}.
  10025. @item scale
  10026. Specify scale used for calculating intensity color values.
  10027. It accepts the following values:
  10028. @table @samp
  10029. @item lin
  10030. linear
  10031. @item sqrt
  10032. square root, default
  10033. @item cbrt
  10034. cubic root
  10035. @item log
  10036. logarithmic
  10037. @end table
  10038. Default value is @samp{sqrt}.
  10039. @item saturation
  10040. Set saturation modifier for displayed colors. Negative values provide
  10041. alternative color scheme. @code{0} is no saturation at all.
  10042. Saturation must be in [-10.0, 10.0] range.
  10043. Default value is @code{1}.
  10044. @item win_func
  10045. Set window function.
  10046. It accepts the following values:
  10047. @table @samp
  10048. @item none
  10049. No samples pre-processing (do not expect this to be faster)
  10050. @item hann
  10051. Hann window
  10052. @item hamming
  10053. Hamming window
  10054. @item blackman
  10055. Blackman window
  10056. @end table
  10057. Default value is @code{hann}.
  10058. @end table
  10059. The usage is very similar to the showwaves filter; see the examples in that
  10060. section.
  10061. @subsection Examples
  10062. @itemize
  10063. @item
  10064. Large window with logarithmic color scaling:
  10065. @example
  10066. showspectrum=s=1280x480:scale=log
  10067. @end example
  10068. @item
  10069. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  10070. @example
  10071. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  10072. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  10073. @end example
  10074. @end itemize
  10075. @section showvolume
  10076. Convert input audio volume to a video output.
  10077. The filter accepts the following options:
  10078. @table @option
  10079. @item rate, r
  10080. Set video rate.
  10081. @item b
  10082. Set border width, allowed range is [0, 5]. Default is 1.
  10083. @item w
  10084. Set channel width, allowed range is [40, 1080]. Default is 400.
  10085. @item h
  10086. Set channel height, allowed range is [1, 100]. Default is 20.
  10087. @item f
  10088. Set fade, allowed range is [1, 255]. Default is 20.
  10089. @item c
  10090. Set volume color expression.
  10091. The expression can use the following variables:
  10092. @table @option
  10093. @item VOLUME
  10094. Current max volume of channel in dB.
  10095. @item CHANNEL
  10096. Current channel number, starting from 0.
  10097. @end table
  10098. @item t
  10099. If set, displays channel names. Default is enabled.
  10100. @end table
  10101. @section showwaves
  10102. Convert input audio to a video output, representing the samples waves.
  10103. The filter accepts the following options:
  10104. @table @option
  10105. @item size, s
  10106. Specify the video size for the output. For the syntax of this option, check the
  10107. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10108. Default value is @code{600x240}.
  10109. @item mode
  10110. Set display mode.
  10111. Available values are:
  10112. @table @samp
  10113. @item point
  10114. Draw a point for each sample.
  10115. @item line
  10116. Draw a vertical line for each sample.
  10117. @item p2p
  10118. Draw a point for each sample and a line between them.
  10119. @item cline
  10120. Draw a centered vertical line for each sample.
  10121. @end table
  10122. Default value is @code{point}.
  10123. @item n
  10124. Set the number of samples which are printed on the same column. A
  10125. larger value will decrease the frame rate. Must be a positive
  10126. integer. This option can be set only if the value for @var{rate}
  10127. is not explicitly specified.
  10128. @item rate, r
  10129. Set the (approximate) output frame rate. This is done by setting the
  10130. option @var{n}. Default value is "25".
  10131. @item split_channels
  10132. Set if channels should be drawn separately or overlap. Default value is 0.
  10133. @end table
  10134. @subsection Examples
  10135. @itemize
  10136. @item
  10137. Output the input file audio and the corresponding video representation
  10138. at the same time:
  10139. @example
  10140. amovie=a.mp3,asplit[out0],showwaves[out1]
  10141. @end example
  10142. @item
  10143. Create a synthetic signal and show it with showwaves, forcing a
  10144. frame rate of 30 frames per second:
  10145. @example
  10146. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  10147. @end example
  10148. @end itemize
  10149. @section showwavespic
  10150. Convert input audio to a single video frame, representing the samples waves.
  10151. The filter accepts the following options:
  10152. @table @option
  10153. @item size, s
  10154. Specify the video size for the output. For the syntax of this option, check the
  10155. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10156. Default value is @code{600x240}.
  10157. @item split_channels
  10158. Set if channels should be drawn separately or overlap. Default value is 0.
  10159. @end table
  10160. @subsection Examples
  10161. @itemize
  10162. @item
  10163. Extract a channel split representation of the wave form of a whole audio track
  10164. in a 1024x800 picture using @command{ffmpeg}:
  10165. @example
  10166. ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
  10167. @end example
  10168. @end itemize
  10169. @section split, asplit
  10170. Split input into several identical outputs.
  10171. @code{asplit} works with audio input, @code{split} with video.
  10172. The filter accepts a single parameter which specifies the number of outputs. If
  10173. unspecified, it defaults to 2.
  10174. @subsection Examples
  10175. @itemize
  10176. @item
  10177. Create two separate outputs from the same input:
  10178. @example
  10179. [in] split [out0][out1]
  10180. @end example
  10181. @item
  10182. To create 3 or more outputs, you need to specify the number of
  10183. outputs, like in:
  10184. @example
  10185. [in] asplit=3 [out0][out1][out2]
  10186. @end example
  10187. @item
  10188. Create two separate outputs from the same input, one cropped and
  10189. one padded:
  10190. @example
  10191. [in] split [splitout1][splitout2];
  10192. [splitout1] crop=100:100:0:0 [cropout];
  10193. [splitout2] pad=200:200:100:100 [padout];
  10194. @end example
  10195. @item
  10196. Create 5 copies of the input audio with @command{ffmpeg}:
  10197. @example
  10198. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  10199. @end example
  10200. @end itemize
  10201. @section zmq, azmq
  10202. Receive commands sent through a libzmq client, and forward them to
  10203. filters in the filtergraph.
  10204. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  10205. must be inserted between two video filters, @code{azmq} between two
  10206. audio filters.
  10207. To enable these filters you need to install the libzmq library and
  10208. headers and configure FFmpeg with @code{--enable-libzmq}.
  10209. For more information about libzmq see:
  10210. @url{http://www.zeromq.org/}
  10211. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  10212. receives messages sent through a network interface defined by the
  10213. @option{bind_address} option.
  10214. The received message must be in the form:
  10215. @example
  10216. @var{TARGET} @var{COMMAND} [@var{ARG}]
  10217. @end example
  10218. @var{TARGET} specifies the target of the command, usually the name of
  10219. the filter class or a specific filter instance name.
  10220. @var{COMMAND} specifies the name of the command for the target filter.
  10221. @var{ARG} is optional and specifies the optional argument list for the
  10222. given @var{COMMAND}.
  10223. Upon reception, the message is processed and the corresponding command
  10224. is injected into the filtergraph. Depending on the result, the filter
  10225. will send a reply to the client, adopting the format:
  10226. @example
  10227. @var{ERROR_CODE} @var{ERROR_REASON}
  10228. @var{MESSAGE}
  10229. @end example
  10230. @var{MESSAGE} is optional.
  10231. @subsection Examples
  10232. Look at @file{tools/zmqsend} for an example of a zmq client which can
  10233. be used to send commands processed by these filters.
  10234. Consider the following filtergraph generated by @command{ffplay}
  10235. @example
  10236. ffplay -dumpgraph 1 -f lavfi "
  10237. color=s=100x100:c=red [l];
  10238. color=s=100x100:c=blue [r];
  10239. nullsrc=s=200x100, zmq [bg];
  10240. [bg][l] overlay [bg+l];
  10241. [bg+l][r] overlay=x=100 "
  10242. @end example
  10243. To change the color of the left side of the video, the following
  10244. command can be used:
  10245. @example
  10246. echo Parsed_color_0 c yellow | tools/zmqsend
  10247. @end example
  10248. To change the right side:
  10249. @example
  10250. echo Parsed_color_1 c pink | tools/zmqsend
  10251. @end example
  10252. @c man end MULTIMEDIA FILTERS
  10253. @chapter Multimedia Sources
  10254. @c man begin MULTIMEDIA SOURCES
  10255. Below is a description of the currently available multimedia sources.
  10256. @section amovie
  10257. This is the same as @ref{movie} source, except it selects an audio
  10258. stream by default.
  10259. @anchor{movie}
  10260. @section movie
  10261. Read audio and/or video stream(s) from a movie container.
  10262. It accepts the following parameters:
  10263. @table @option
  10264. @item filename
  10265. The name of the resource to read (not necessarily a file; it can also be a
  10266. device or a stream accessed through some protocol).
  10267. @item format_name, f
  10268. Specifies the format assumed for the movie to read, and can be either
  10269. the name of a container or an input device. If not specified, the
  10270. format is guessed from @var{movie_name} or by probing.
  10271. @item seek_point, sp
  10272. Specifies the seek point in seconds. The frames will be output
  10273. starting from this seek point. The parameter is evaluated with
  10274. @code{av_strtod}, so the numerical value may be suffixed by an IS
  10275. postfix. The default value is "0".
  10276. @item streams, s
  10277. Specifies the streams to read. Several streams can be specified,
  10278. separated by "+". The source will then have as many outputs, in the
  10279. same order. The syntax is explained in the ``Stream specifiers''
  10280. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  10281. respectively the default (best suited) video and audio stream. Default
  10282. is "dv", or "da" if the filter is called as "amovie".
  10283. @item stream_index, si
  10284. Specifies the index of the video stream to read. If the value is -1,
  10285. the most suitable video stream will be automatically selected. The default
  10286. value is "-1". Deprecated. If the filter is called "amovie", it will select
  10287. audio instead of video.
  10288. @item loop
  10289. Specifies how many times to read the stream in sequence.
  10290. If the value is less than 1, the stream will be read again and again.
  10291. Default value is "1".
  10292. Note that when the movie is looped the source timestamps are not
  10293. changed, so it will generate non monotonically increasing timestamps.
  10294. @end table
  10295. It allows overlaying a second video on top of the main input of
  10296. a filtergraph, as shown in this graph:
  10297. @example
  10298. input -----------> deltapts0 --> overlay --> output
  10299. ^
  10300. |
  10301. movie --> scale--> deltapts1 -------+
  10302. @end example
  10303. @subsection Examples
  10304. @itemize
  10305. @item
  10306. Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
  10307. on top of the input labelled "in":
  10308. @example
  10309. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  10310. [in] setpts=PTS-STARTPTS [main];
  10311. [main][over] overlay=16:16 [out]
  10312. @end example
  10313. @item
  10314. Read from a video4linux2 device, and overlay it on top of the input
  10315. labelled "in":
  10316. @example
  10317. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  10318. [in] setpts=PTS-STARTPTS [main];
  10319. [main][over] overlay=16:16 [out]
  10320. @end example
  10321. @item
  10322. Read the first video stream and the audio stream with id 0x81 from
  10323. dvd.vob; the video is connected to the pad named "video" and the audio is
  10324. connected to the pad named "audio":
  10325. @example
  10326. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  10327. @end example
  10328. @end itemize
  10329. @c man end MULTIMEDIA SOURCES