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.

13525 lines
370KB

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