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.

13684 lines
374KB

  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 alimiter
  508. The limiter prevents input signal from raising over a desired threshold.
  509. This limiter uses lookahead technology to prevent your signal from distorting.
  510. It means that there is a small delay after signal is processed. Keep in mind
  511. that the delay it produces is the attack time you set.
  512. The filter accepts the following options:
  513. @table @option
  514. @item limit
  515. Don't let signals above this level pass the limiter. The removed amplitude is
  516. added automatically. Default is 1.
  517. @item attack
  518. The limiter will reach its attenuation level in this amount of time in
  519. milliseconds. Default is 5 milliseconds.
  520. @item release
  521. Come back from limiting to attenuation 1.0 in this amount of milliseconds.
  522. Default is 50 milliseconds.
  523. @item asc
  524. When gain reduction is always needed ASC takes care of releasing to an
  525. average reduction level rather than reaching a reduction of 0 in the release
  526. time.
  527. @item asc_level
  528. Select how much the release time is affected by ASC, 0 means nearly no changes
  529. in release time while 1 produces higher release times.
  530. @end table
  531. Depending on picked setting it is recommended to upsample input 2x or 4x times
  532. with @ref{aresample} before applying this filter.
  533. @section allpass
  534. Apply a two-pole all-pass filter with central frequency (in Hz)
  535. @var{frequency}, and filter-width @var{width}.
  536. An all-pass filter changes the audio's frequency to phase relationship
  537. without changing its frequency to amplitude relationship.
  538. The filter accepts the following options:
  539. @table @option
  540. @item frequency, f
  541. Set frequency in Hz.
  542. @item width_type
  543. Set method to specify band-width of filter.
  544. @table @option
  545. @item h
  546. Hz
  547. @item q
  548. Q-Factor
  549. @item o
  550. octave
  551. @item s
  552. slope
  553. @end table
  554. @item width, w
  555. Specify the band-width of a filter in width_type units.
  556. @end table
  557. @anchor{amerge}
  558. @section amerge
  559. Merge two or more audio streams into a single multi-channel stream.
  560. The filter accepts the following options:
  561. @table @option
  562. @item inputs
  563. Set the number of inputs. Default is 2.
  564. @end table
  565. If the channel layouts of the inputs are disjoint, and therefore compatible,
  566. the channel layout of the output will be set accordingly and the channels
  567. will be reordered as necessary. If the channel layouts of the inputs are not
  568. disjoint, the output will have all the channels of the first input then all
  569. the channels of the second input, in that order, and the channel layout of
  570. the output will be the default value corresponding to the total number of
  571. channels.
  572. For example, if the first input is in 2.1 (FL+FR+LF) and the second input
  573. is FC+BL+BR, then the output will be in 5.1, with the channels in the
  574. following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the
  575. first input, b1 is the first channel of the second input).
  576. On the other hand, if both input are in stereo, the output channels will be
  577. in the default order: a1, a2, b1, b2, and the channel layout will be
  578. arbitrarily set to 4.0, which may or may not be the expected value.
  579. All inputs must have the same sample rate, and format.
  580. If inputs do not have the same duration, the output will stop with the
  581. shortest.
  582. @subsection Examples
  583. @itemize
  584. @item
  585. Merge two mono files into a stereo stream:
  586. @example
  587. amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
  588. @end example
  589. @item
  590. Multiple merges assuming 1 video stream and 6 audio streams in @file{input.mkv}:
  591. @example
  592. 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
  593. @end example
  594. @end itemize
  595. @section amix
  596. Mixes multiple audio inputs into a single output.
  597. Note that this filter only supports float samples (the @var{amerge}
  598. and @var{pan} audio filters support many formats). If the @var{amix}
  599. input has integer samples then @ref{aresample} will be automatically
  600. inserted to perform the conversion to float samples.
  601. For example
  602. @example
  603. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT
  604. @end example
  605. will mix 3 input audio streams to a single output with the same duration as the
  606. first input and a dropout transition time of 3 seconds.
  607. It accepts the following parameters:
  608. @table @option
  609. @item inputs
  610. The number of inputs. If unspecified, it defaults to 2.
  611. @item duration
  612. How to determine the end-of-stream.
  613. @table @option
  614. @item longest
  615. The duration of the longest input. (default)
  616. @item shortest
  617. The duration of the shortest input.
  618. @item first
  619. The duration of the first input.
  620. @end table
  621. @item dropout_transition
  622. The transition time, in seconds, for volume renormalization when an input
  623. stream ends. The default value is 2 seconds.
  624. @end table
  625. @section anull
  626. Pass the audio source unchanged to the output.
  627. @section apad
  628. Pad the end of an audio stream with silence.
  629. This can be used together with @command{ffmpeg} @option{-shortest} to
  630. extend audio streams to the same length as the video stream.
  631. A description of the accepted options follows.
  632. @table @option
  633. @item packet_size
  634. Set silence packet size. Default value is 4096.
  635. @item pad_len
  636. Set the number of samples of silence to add to the end. After the
  637. value is reached, the stream is terminated. This option is mutually
  638. exclusive with @option{whole_len}.
  639. @item whole_len
  640. Set the minimum total number of samples in the output audio stream. If
  641. the value is longer than the input audio length, silence is added to
  642. the end, until the value is reached. This option is mutually exclusive
  643. with @option{pad_len}.
  644. @end table
  645. If neither the @option{pad_len} nor the @option{whole_len} option is
  646. set, the filter will add silence to the end of the input stream
  647. indefinitely.
  648. @subsection Examples
  649. @itemize
  650. @item
  651. Add 1024 samples of silence to the end of the input:
  652. @example
  653. apad=pad_len=1024
  654. @end example
  655. @item
  656. Make sure the audio output will contain at least 10000 samples, pad
  657. the input with silence if required:
  658. @example
  659. apad=whole_len=10000
  660. @end example
  661. @item
  662. Use @command{ffmpeg} to pad the audio input with silence, so that the
  663. video stream will always result the shortest and will be converted
  664. until the end in the output file when using the @option{shortest}
  665. option:
  666. @example
  667. ffmpeg -i VIDEO -i AUDIO -filter_complex "[1:0]apad" -shortest OUTPUT
  668. @end example
  669. @end itemize
  670. @section aphaser
  671. Add a phasing effect to the input audio.
  672. A phaser filter creates series of peaks and troughs in the frequency spectrum.
  673. The position of the peaks and troughs are modulated so that they vary over time, creating a sweeping effect.
  674. A description of the accepted parameters follows.
  675. @table @option
  676. @item in_gain
  677. Set input gain. Default is 0.4.
  678. @item out_gain
  679. Set output gain. Default is 0.74
  680. @item delay
  681. Set delay in milliseconds. Default is 3.0.
  682. @item decay
  683. Set decay. Default is 0.4.
  684. @item speed
  685. Set modulation speed in Hz. Default is 0.5.
  686. @item type
  687. Set modulation type. Default is triangular.
  688. It accepts the following values:
  689. @table @samp
  690. @item triangular, t
  691. @item sinusoidal, s
  692. @end table
  693. @end table
  694. @anchor{aresample}
  695. @section aresample
  696. Resample the input audio to the specified parameters, using the
  697. libswresample library. If none are specified then the filter will
  698. automatically convert between its input and output.
  699. This filter is also able to stretch/squeeze the audio data to make it match
  700. the timestamps or to inject silence / cut out audio to make it match the
  701. timestamps, do a combination of both or do neither.
  702. The filter accepts the syntax
  703. [@var{sample_rate}:]@var{resampler_options}, where @var{sample_rate}
  704. expresses a sample rate and @var{resampler_options} is a list of
  705. @var{key}=@var{value} pairs, separated by ":". See the
  706. ffmpeg-resampler manual for the complete list of supported options.
  707. @subsection Examples
  708. @itemize
  709. @item
  710. Resample the input audio to 44100Hz:
  711. @example
  712. aresample=44100
  713. @end example
  714. @item
  715. Stretch/squeeze samples to the given timestamps, with a maximum of 1000
  716. samples per second compensation:
  717. @example
  718. aresample=async=1000
  719. @end example
  720. @end itemize
  721. @section asetnsamples
  722. Set the number of samples per each output audio frame.
  723. The last output packet may contain a different number of samples, as
  724. the filter will flush all the remaining samples when the input audio
  725. signal its end.
  726. The filter accepts the following options:
  727. @table @option
  728. @item nb_out_samples, n
  729. Set the number of frames per each output audio frame. The number is
  730. intended as the number of samples @emph{per each channel}.
  731. Default value is 1024.
  732. @item pad, p
  733. If set to 1, the filter will pad the last audio frame with zeroes, so
  734. that the last frame will contain the same number of samples as the
  735. previous ones. Default value is 1.
  736. @end table
  737. For example, to set the number of per-frame samples to 1234 and
  738. disable padding for the last frame, use:
  739. @example
  740. asetnsamples=n=1234:p=0
  741. @end example
  742. @section asetrate
  743. Set the sample rate without altering the PCM data.
  744. This will result in a change of speed and pitch.
  745. The filter accepts the following options:
  746. @table @option
  747. @item sample_rate, r
  748. Set the output sample rate. Default is 44100 Hz.
  749. @end table
  750. @section ashowinfo
  751. Show a line containing various information for each input audio frame.
  752. The input audio is not modified.
  753. The shown line contains a sequence of key/value pairs of the form
  754. @var{key}:@var{value}.
  755. The following values are shown in the output:
  756. @table @option
  757. @item n
  758. The (sequential) number of the input frame, starting from 0.
  759. @item pts
  760. The presentation timestamp of the input frame, in time base units; the time base
  761. depends on the filter input pad, and is usually 1/@var{sample_rate}.
  762. @item pts_time
  763. The presentation timestamp of the input frame in seconds.
  764. @item pos
  765. position of the frame in the input stream, -1 if this information in
  766. unavailable and/or meaningless (for example in case of synthetic audio)
  767. @item fmt
  768. The sample format.
  769. @item chlayout
  770. The channel layout.
  771. @item rate
  772. The sample rate for the audio frame.
  773. @item nb_samples
  774. The number of samples (per channel) in the frame.
  775. @item checksum
  776. The Adler-32 checksum (printed in hexadecimal) of the audio data. For planar
  777. audio, the data is treated as if all the planes were concatenated.
  778. @item plane_checksums
  779. A list of Adler-32 checksums for each data plane.
  780. @end table
  781. @anchor{astats}
  782. @section astats
  783. Display time domain statistical information about the audio channels.
  784. Statistics are calculated and displayed for each audio channel and,
  785. where applicable, an overall figure is also given.
  786. It accepts the following option:
  787. @table @option
  788. @item length
  789. Short window length in seconds, used for peak and trough RMS measurement.
  790. Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.1 - 10]}.
  791. @item metadata
  792. Set metadata injection. All the metadata keys are prefixed with @code{lavfi.astats.X},
  793. where @code{X} is channel number starting from 1 or string @code{Overall}. Default is
  794. disabled.
  795. Available keys for each channel are:
  796. DC_offset
  797. Min_level
  798. Max_level
  799. Min_difference
  800. Max_difference
  801. Mean_difference
  802. Peak_level
  803. RMS_peak
  804. RMS_trough
  805. Crest_factor
  806. Flat_factor
  807. Peak_count
  808. Bit_depth
  809. and for Overall:
  810. DC_offset
  811. Min_level
  812. Max_level
  813. Min_difference
  814. Max_difference
  815. Mean_difference
  816. Peak_level
  817. RMS_level
  818. RMS_peak
  819. RMS_trough
  820. Flat_factor
  821. Peak_count
  822. Bit_depth
  823. Number_of_samples
  824. For example full key look like this @code{lavfi.astats.1.DC_offset} or
  825. this @code{lavfi.astats.Overall.Peak_count}.
  826. For description what each key means read bellow.
  827. @item reset
  828. Set number of frame after which stats are going to be recalculated.
  829. Default is disabled.
  830. @end table
  831. A description of each shown parameter follows:
  832. @table @option
  833. @item DC offset
  834. Mean amplitude displacement from zero.
  835. @item Min level
  836. Minimal sample level.
  837. @item Max level
  838. Maximal sample level.
  839. @item Min difference
  840. Minimal difference between two consecutive samples.
  841. @item Max difference
  842. Maximal difference between two consecutive samples.
  843. @item Mean difference
  844. Mean difference between two consecutive samples.
  845. The average of each difference between two consecutive samples.
  846. @item Peak level dB
  847. @item RMS level dB
  848. Standard peak and RMS level measured in dBFS.
  849. @item RMS peak dB
  850. @item RMS trough dB
  851. Peak and trough values for RMS level measured over a short window.
  852. @item Crest factor
  853. Standard ratio of peak to RMS level (note: not in dB).
  854. @item Flat factor
  855. Flatness (i.e. consecutive samples with the same value) of the signal at its peak levels
  856. (i.e. either @var{Min level} or @var{Max level}).
  857. @item Peak count
  858. Number of occasions (not the number of samples) that the signal attained either
  859. @var{Min level} or @var{Max level}.
  860. @item Bit depth
  861. Overall bit depth of audio. Number of bits used for each sample.
  862. @end table
  863. @section astreamsync
  864. Forward two audio streams and control the order the buffers are forwarded.
  865. The filter accepts the following options:
  866. @table @option
  867. @item expr, e
  868. Set the expression deciding which stream should be
  869. forwarded next: if the result is negative, the first stream is forwarded; if
  870. the result is positive or zero, the second stream is forwarded. It can use
  871. the following variables:
  872. @table @var
  873. @item b1 b2
  874. number of buffers forwarded so far on each stream
  875. @item s1 s2
  876. number of samples forwarded so far on each stream
  877. @item t1 t2
  878. current timestamp of each stream
  879. @end table
  880. The default value is @code{t1-t2}, which means to always forward the stream
  881. that has a smaller timestamp.
  882. @end table
  883. @subsection Examples
  884. Stress-test @code{amerge} by randomly sending buffers on the wrong
  885. input, while avoiding too much of a desynchronization:
  886. @example
  887. amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
  888. [a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
  889. [a2] [b2] amerge
  890. @end example
  891. @section asyncts
  892. Synchronize audio data with timestamps by squeezing/stretching it and/or
  893. dropping samples/adding silence when needed.
  894. This filter is not built by default, please use @ref{aresample} to do squeezing/stretching.
  895. It accepts the following parameters:
  896. @table @option
  897. @item compensate
  898. Enable stretching/squeezing the data to make it match the timestamps. Disabled
  899. by default. When disabled, time gaps are covered with silence.
  900. @item min_delta
  901. The minimum difference between timestamps and audio data (in seconds) to trigger
  902. adding/dropping samples. The default value is 0.1. If you get an imperfect
  903. sync with this filter, try setting this parameter to 0.
  904. @item max_comp
  905. The maximum compensation in samples per second. Only relevant with compensate=1.
  906. The default value is 500.
  907. @item first_pts
  908. Assume that the first PTS should be this value. The time base is 1 / sample
  909. rate. This allows for padding/trimming at the start of the stream. By default,
  910. no assumption is made about the first frame's expected PTS, so no padding or
  911. trimming is done. For example, this could be set to 0 to pad the beginning with
  912. silence if an audio stream starts after the video stream or to trim any samples
  913. with a negative PTS due to encoder delay.
  914. @end table
  915. @section atempo
  916. Adjust audio tempo.
  917. The filter accepts exactly one parameter, the audio tempo. If not
  918. specified then the filter will assume nominal 1.0 tempo. Tempo must
  919. be in the [0.5, 2.0] range.
  920. @subsection Examples
  921. @itemize
  922. @item
  923. Slow down audio to 80% tempo:
  924. @example
  925. atempo=0.8
  926. @end example
  927. @item
  928. To speed up audio to 125% tempo:
  929. @example
  930. atempo=1.25
  931. @end example
  932. @end itemize
  933. @section atrim
  934. Trim the input so that the output contains one continuous subpart of the input.
  935. It accepts the following parameters:
  936. @table @option
  937. @item start
  938. Timestamp (in seconds) of the start of the section to keep. I.e. the audio
  939. sample with the timestamp @var{start} will be the first sample in the output.
  940. @item end
  941. Specify time of the first audio sample that will be dropped, i.e. the
  942. audio sample immediately preceding the one with the timestamp @var{end} will be
  943. the last sample in the output.
  944. @item start_pts
  945. Same as @var{start}, except this option sets the start timestamp in samples
  946. instead of seconds.
  947. @item end_pts
  948. Same as @var{end}, except this option sets the end timestamp in samples instead
  949. of seconds.
  950. @item duration
  951. The maximum duration of the output in seconds.
  952. @item start_sample
  953. The number of the first sample that should be output.
  954. @item end_sample
  955. The number of the first sample that should be dropped.
  956. @end table
  957. @option{start}, @option{end}, and @option{duration} are expressed as time
  958. duration specifications; see
  959. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  960. Note that the first two sets of the start/end options and the @option{duration}
  961. option look at the frame timestamp, while the _sample options simply count the
  962. samples that pass through the filter. So start/end_pts and start/end_sample will
  963. give different results when the timestamps are wrong, inexact or do not start at
  964. zero. Also note that this filter does not modify the timestamps. If you wish
  965. to have the output timestamps start at zero, insert the asetpts filter after the
  966. atrim filter.
  967. If multiple start or end options are set, this filter tries to be greedy and
  968. keep all samples that match at least one of the specified constraints. To keep
  969. only the part that matches all the constraints at once, chain multiple atrim
  970. filters.
  971. The defaults are such that all the input is kept. So it is possible to set e.g.
  972. just the end values to keep everything before the specified time.
  973. Examples:
  974. @itemize
  975. @item
  976. Drop everything except the second minute of input:
  977. @example
  978. ffmpeg -i INPUT -af atrim=60:120
  979. @end example
  980. @item
  981. Keep only the first 1000 samples:
  982. @example
  983. ffmpeg -i INPUT -af atrim=end_sample=1000
  984. @end example
  985. @end itemize
  986. @section bandpass
  987. Apply a two-pole Butterworth band-pass filter with central
  988. frequency @var{frequency}, and (3dB-point) band-width width.
  989. The @var{csg} option selects a constant skirt gain (peak gain = Q)
  990. instead of the default: constant 0dB peak gain.
  991. The filter roll off at 6dB per octave (20dB per decade).
  992. The filter accepts the following options:
  993. @table @option
  994. @item frequency, f
  995. Set the filter's central frequency. Default is @code{3000}.
  996. @item csg
  997. Constant skirt gain if set to 1. Defaults to 0.
  998. @item width_type
  999. Set method to specify band-width of filter.
  1000. @table @option
  1001. @item h
  1002. Hz
  1003. @item q
  1004. Q-Factor
  1005. @item o
  1006. octave
  1007. @item s
  1008. slope
  1009. @end table
  1010. @item width, w
  1011. Specify the band-width of a filter in width_type units.
  1012. @end table
  1013. @section bandreject
  1014. Apply a two-pole Butterworth band-reject filter with central
  1015. frequency @var{frequency}, and (3dB-point) band-width @var{width}.
  1016. The filter roll off at 6dB per octave (20dB per decade).
  1017. The filter accepts the following options:
  1018. @table @option
  1019. @item frequency, f
  1020. Set the filter's central frequency. Default is @code{3000}.
  1021. @item width_type
  1022. Set method to specify band-width of filter.
  1023. @table @option
  1024. @item h
  1025. Hz
  1026. @item q
  1027. Q-Factor
  1028. @item o
  1029. octave
  1030. @item s
  1031. slope
  1032. @end table
  1033. @item width, w
  1034. Specify the band-width of a filter in width_type units.
  1035. @end table
  1036. @section bass
  1037. Boost or cut the bass (lower) frequencies of the audio using a two-pole
  1038. shelving filter with a response similar to that of a standard
  1039. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  1040. The filter accepts the following options:
  1041. @table @option
  1042. @item gain, g
  1043. Give the gain at 0 Hz. Its useful range is about -20
  1044. (for a large cut) to +20 (for a large boost).
  1045. Beware of clipping when using a positive gain.
  1046. @item frequency, f
  1047. Set the filter's central frequency and so can be used
  1048. to extend or reduce the frequency range to be boosted or cut.
  1049. The default value is @code{100} Hz.
  1050. @item width_type
  1051. Set method to specify band-width of filter.
  1052. @table @option
  1053. @item h
  1054. Hz
  1055. @item q
  1056. Q-Factor
  1057. @item o
  1058. octave
  1059. @item s
  1060. slope
  1061. @end table
  1062. @item width, w
  1063. Determine how steep is the filter's shelf transition.
  1064. @end table
  1065. @section biquad
  1066. Apply a biquad IIR filter with the given coefficients.
  1067. Where @var{b0}, @var{b1}, @var{b2} and @var{a0}, @var{a1}, @var{a2}
  1068. are the numerator and denominator coefficients respectively.
  1069. @section bs2b
  1070. Bauer stereo to binaural transformation, which improves headphone listening of
  1071. stereo audio records.
  1072. It accepts the following parameters:
  1073. @table @option
  1074. @item profile
  1075. Pre-defined crossfeed level.
  1076. @table @option
  1077. @item default
  1078. Default level (fcut=700, feed=50).
  1079. @item cmoy
  1080. Chu Moy circuit (fcut=700, feed=60).
  1081. @item jmeier
  1082. Jan Meier circuit (fcut=650, feed=95).
  1083. @end table
  1084. @item fcut
  1085. Cut frequency (in Hz).
  1086. @item feed
  1087. Feed level (in Hz).
  1088. @end table
  1089. @section channelmap
  1090. Remap input channels to new locations.
  1091. It accepts the following parameters:
  1092. @table @option
  1093. @item channel_layout
  1094. The channel layout of the output stream.
  1095. @item map
  1096. Map channels from input to output. The argument is a '|'-separated list of
  1097. mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
  1098. @var{in_channel} form. @var{in_channel} can be either the name of the input
  1099. channel (e.g. FL for front left) or its index in the input channel layout.
  1100. @var{out_channel} is the name of the output channel or its index in the output
  1101. channel layout. If @var{out_channel} is not given then it is implicitly an
  1102. index, starting with zero and increasing by one for each mapping.
  1103. @end table
  1104. If no mapping is present, the filter will implicitly map input channels to
  1105. output channels, preserving indices.
  1106. For example, assuming a 5.1+downmix input MOV file,
  1107. @example
  1108. ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
  1109. @end example
  1110. will create an output WAV file tagged as stereo from the downmix channels of
  1111. the input.
  1112. To fix a 5.1 WAV improperly encoded in AAC's native channel order
  1113. @example
  1114. ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:5.1' out.wav
  1115. @end example
  1116. @section channelsplit
  1117. Split each channel from an input audio stream into a separate output stream.
  1118. It accepts the following parameters:
  1119. @table @option
  1120. @item channel_layout
  1121. The channel layout of the input stream. The default is "stereo".
  1122. @end table
  1123. For example, assuming a stereo input MP3 file,
  1124. @example
  1125. ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
  1126. @end example
  1127. will create an output Matroska file with two audio streams, one containing only
  1128. the left channel and the other the right channel.
  1129. Split a 5.1 WAV file into per-channel files:
  1130. @example
  1131. ffmpeg -i in.wav -filter_complex
  1132. 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]'
  1133. -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]'
  1134. front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]'
  1135. side_right.wav
  1136. @end example
  1137. @section chorus
  1138. Add a chorus effect to the audio.
  1139. Can make a single vocal sound like a chorus, but can also be applied to instrumentation.
  1140. Chorus resembles an echo effect with a short delay, but whereas with echo the delay is
  1141. constant, with chorus, it is varied using using sinusoidal or triangular modulation.
  1142. The modulation depth defines the range the modulated delay is played before or after
  1143. the delay. Hence the delayed sound will sound slower or faster, that is the delayed
  1144. sound tuned around the original one, like in a chorus where some vocals are slightly
  1145. off key.
  1146. It accepts the following parameters:
  1147. @table @option
  1148. @item in_gain
  1149. Set input gain. Default is 0.4.
  1150. @item out_gain
  1151. Set output gain. Default is 0.4.
  1152. @item delays
  1153. Set delays. A typical delay is around 40ms to 60ms.
  1154. @item decays
  1155. Set decays.
  1156. @item speeds
  1157. Set speeds.
  1158. @item depths
  1159. Set depths.
  1160. @end table
  1161. @subsection Examples
  1162. @itemize
  1163. @item
  1164. A single delay:
  1165. @example
  1166. chorus=0.7:0.9:55:0.4:0.25:2
  1167. @end example
  1168. @item
  1169. Two delays:
  1170. @example
  1171. chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3
  1172. @end example
  1173. @item
  1174. Fuller sounding chorus with three delays:
  1175. @example
  1176. 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
  1177. @end example
  1178. @end itemize
  1179. @section compand
  1180. Compress or expand the audio's dynamic range.
  1181. It accepts the following parameters:
  1182. @table @option
  1183. @item attacks
  1184. @item decays
  1185. A list of times in seconds for each channel over which the instantaneous level
  1186. of the input signal is averaged to determine its volume. @var{attacks} refers to
  1187. increase of volume and @var{decays} refers to decrease of volume. For most
  1188. situations, the attack time (response to the audio getting louder) should be
  1189. shorter than the decay time, because the human ear is more sensitive to sudden
  1190. loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
  1191. a typical value for decay is 0.8 seconds.
  1192. If specified number of attacks & decays is lower than number of channels, the last
  1193. set attack/decay will be used for all remaining channels.
  1194. @item points
  1195. A list of points for the transfer function, specified in dB relative to the
  1196. maximum possible signal amplitude. Each key points list must be defined using
  1197. the following syntax: @code{x0/y0|x1/y1|x2/y2|....} or
  1198. @code{x0/y0 x1/y1 x2/y2 ....}
  1199. The input values must be in strictly increasing order but the transfer function
  1200. does not have to be monotonically rising. The point @code{0/0} is assumed but
  1201. may be overridden (by @code{0/out-dBn}). Typical values for the transfer
  1202. function are @code{-70/-70|-60/-20}.
  1203. @item soft-knee
  1204. Set the curve radius in dB for all joints. It defaults to 0.01.
  1205. @item gain
  1206. Set the additional gain in dB to be applied at all points on the transfer
  1207. function. This allows for easy adjustment of the overall gain.
  1208. It defaults to 0.
  1209. @item volume
  1210. Set an initial volume, in dB, to be assumed for each channel when filtering
  1211. starts. This permits the user to supply a nominal level initially, so that, for
  1212. example, a very large gain is not applied to initial signal levels before the
  1213. companding has begun to operate. A typical value for audio which is initially
  1214. quiet is -90 dB. It defaults to 0.
  1215. @item delay
  1216. Set a delay, in seconds. The input audio is analyzed immediately, but audio is
  1217. delayed before being fed to the volume adjuster. Specifying a delay
  1218. approximately equal to the attack/decay times allows the filter to effectively
  1219. operate in predictive rather than reactive mode. It defaults to 0.
  1220. @end table
  1221. @subsection Examples
  1222. @itemize
  1223. @item
  1224. Make music with both quiet and loud passages suitable for listening to in a
  1225. noisy environment:
  1226. @example
  1227. compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
  1228. @end example
  1229. Another example for audio with whisper and explosion parts:
  1230. @example
  1231. compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0
  1232. @end example
  1233. @item
  1234. A noise gate for when the noise is at a lower level than the signal:
  1235. @example
  1236. compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
  1237. @end example
  1238. @item
  1239. Here is another noise gate, this time for when the noise is at a higher level
  1240. than the signal (making it, in some ways, similar to squelch):
  1241. @example
  1242. compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
  1243. @end example
  1244. @end itemize
  1245. @section dcshift
  1246. Apply a DC shift to the audio.
  1247. This can be useful to remove a DC offset (caused perhaps by a hardware problem
  1248. in the recording chain) from the audio. The effect of a DC offset is reduced
  1249. headroom and hence volume. The @ref{astats} filter can be used to determine if
  1250. a signal has a DC offset.
  1251. @table @option
  1252. @item shift
  1253. Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift
  1254. the audio.
  1255. @item limitergain
  1256. Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is
  1257. used to prevent clipping.
  1258. @end table
  1259. @section dynaudnorm
  1260. Dynamic Audio Normalizer.
  1261. This filter applies a certain amount of gain to the input audio in order
  1262. to bring its peak magnitude to a target level (e.g. 0 dBFS). However, in
  1263. contrast to more "simple" normalization algorithms, the Dynamic Audio
  1264. Normalizer *dynamically* re-adjusts the gain factor to the input audio.
  1265. This allows for applying extra gain to the "quiet" sections of the audio
  1266. while avoiding distortions or clipping the "loud" sections. In other words:
  1267. The Dynamic Audio Normalizer will "even out" the volume of quiet and loud
  1268. sections, in the sense that the volume of each section is brought to the
  1269. same target level. Note, however, that the Dynamic Audio Normalizer achieves
  1270. this goal *without* applying "dynamic range compressing". It will retain 100%
  1271. of the dynamic range *within* each section of the audio file.
  1272. @table @option
  1273. @item f
  1274. Set the frame length in milliseconds. In range from 10 to 8000 milliseconds.
  1275. Default is 500 milliseconds.
  1276. The Dynamic Audio Normalizer processes the input audio in small chunks,
  1277. referred to as frames. This is required, because a peak magnitude has no
  1278. meaning for just a single sample value. Instead, we need to determine the
  1279. peak magnitude for a contiguous sequence of sample values. While a "standard"
  1280. normalizer would simply use the peak magnitude of the complete file, the
  1281. Dynamic Audio Normalizer determines the peak magnitude individually for each
  1282. frame. The length of a frame is specified in milliseconds. By default, the
  1283. Dynamic Audio Normalizer uses a frame length of 500 milliseconds, which has
  1284. been found to give good results with most files.
  1285. Note that the exact frame length, in number of samples, will be determined
  1286. automatically, based on the sampling rate of the individual input audio file.
  1287. @item g
  1288. Set the Gaussian filter window size. In range from 3 to 301, must be odd
  1289. number. Default is 31.
  1290. Probably the most important parameter of the Dynamic Audio Normalizer is the
  1291. @code{window size} of the Gaussian smoothing filter. The filter's window size
  1292. is specified in frames, centered around the current frame. For the sake of
  1293. simplicity, this must be an odd number. Consequently, the default value of 31
  1294. takes into account the current frame, as well as the 15 preceding frames and
  1295. the 15 subsequent frames. Using a larger window results in a stronger
  1296. smoothing effect and thus in less gain variation, i.e. slower gain
  1297. adaptation. Conversely, using a smaller window results in a weaker smoothing
  1298. effect and thus in more gain variation, i.e. faster gain adaptation.
  1299. In other words, the more you increase this value, the more the Dynamic Audio
  1300. Normalizer will behave like a "traditional" normalization filter. On the
  1301. contrary, the more you decrease this value, the more the Dynamic Audio
  1302. Normalizer will behave like a dynamic range compressor.
  1303. @item p
  1304. Set the target peak value. This specifies the highest permissible magnitude
  1305. level for the normalized audio input. This filter will try to approach the
  1306. target peak magnitude as closely as possible, but at the same time it also
  1307. makes sure that the normalized signal will never exceed the peak magnitude.
  1308. A frame's maximum local gain factor is imposed directly by the target peak
  1309. magnitude. The default value is 0.95 and thus leaves a headroom of 5%*.
  1310. It is not recommended to go above this value.
  1311. @item m
  1312. Set the maximum gain factor. In range from 1.0 to 100.0. Default is 10.0.
  1313. The Dynamic Audio Normalizer determines the maximum possible (local) gain
  1314. factor for each input frame, i.e. the maximum gain factor that does not
  1315. result in clipping or distortion. The maximum gain factor is determined by
  1316. the frame's highest magnitude sample. However, the Dynamic Audio Normalizer
  1317. additionally bounds the frame's maximum gain factor by a predetermined
  1318. (global) maximum gain factor. This is done in order to avoid excessive gain
  1319. factors in "silent" or almost silent frames. By default, the maximum gain
  1320. factor is 10.0, For most inputs the default value should be sufficient and
  1321. it usually is not recommended to increase this value. Though, for input
  1322. with an extremely low overall volume level, it may be necessary to allow even
  1323. higher gain factors. Note, however, that the Dynamic Audio Normalizer does
  1324. not simply apply a "hard" threshold (i.e. cut off values above the threshold).
  1325. Instead, a "sigmoid" threshold function will be applied. This way, the
  1326. gain factors will smoothly approach the threshold value, but never exceed that
  1327. value.
  1328. @item r
  1329. Set the target RMS. In range from 0.0 to 1.0. Default is 0.0 - disabled.
  1330. By default, the Dynamic Audio Normalizer performs "peak" normalization.
  1331. This means that the maximum local gain factor for each frame is defined
  1332. (only) by the frame's highest magnitude sample. This way, the samples can
  1333. be amplified as much as possible without exceeding the maximum signal
  1334. level, i.e. without clipping. Optionally, however, the Dynamic Audio
  1335. Normalizer can also take into account the frame's root mean square,
  1336. abbreviated RMS. In electrical engineering, the RMS is commonly used to
  1337. determine the power of a time-varying signal. It is therefore considered
  1338. that the RMS is a better approximation of the "perceived loudness" than
  1339. just looking at the signal's peak magnitude. Consequently, by adjusting all
  1340. frames to a constant RMS value, a uniform "perceived loudness" can be
  1341. established. If a target RMS value has been specified, a frame's local gain
  1342. factor is defined as the factor that would result in exactly that RMS value.
  1343. Note, however, that the maximum local gain factor is still restricted by the
  1344. frame's highest magnitude sample, in order to prevent clipping.
  1345. @item n
  1346. Enable channels coupling. By default is enabled.
  1347. By default, the Dynamic Audio Normalizer will amplify all channels by the same
  1348. amount. This means the same gain factor will be applied to all channels, i.e.
  1349. the maximum possible gain factor is determined by the "loudest" channel.
  1350. However, in some recordings, it may happen that the volume of the different
  1351. channels is uneven, e.g. one channel may be "quieter" than the other one(s).
  1352. In this case, this option can be used to disable the channel coupling. This way,
  1353. the gain factor will be determined independently for each channel, depending
  1354. only on the individual channel's highest magnitude sample. This allows for
  1355. harmonizing the volume of the different channels.
  1356. @item c
  1357. Enable DC bias correction. By default is disabled.
  1358. An audio signal (in the time domain) is a sequence of sample values.
  1359. In the Dynamic Audio Normalizer these sample values are represented in the
  1360. -1.0 to 1.0 range, regardless of the original input format. Normally, the
  1361. audio signal, or "waveform", should be centered around the zero point.
  1362. That means if we calculate the mean value of all samples in a file, or in a
  1363. single frame, then the result should be 0.0 or at least very close to that
  1364. value. If, however, there is a significant deviation of the mean value from
  1365. 0.0, in either positive or negative direction, this is referred to as a
  1366. DC bias or DC offset. Since a DC bias is clearly undesirable, the Dynamic
  1367. Audio Normalizer provides optional DC bias correction.
  1368. With DC bias correction enabled, the Dynamic Audio Normalizer will determine
  1369. the mean value, or "DC correction" offset, of each input frame and subtract
  1370. that value from all of the frame's sample values which ensures those samples
  1371. are centered around 0.0 again. Also, in order to avoid "gaps" at the frame
  1372. boundaries, the DC correction offset values will be interpolated smoothly
  1373. between neighbouring frames.
  1374. @item b
  1375. Enable alternative boundary mode. By default is disabled.
  1376. The Dynamic Audio Normalizer takes into account a certain neighbourhood
  1377. around each frame. This includes the preceding frames as well as the
  1378. subsequent frames. However, for the "boundary" frames, located at the very
  1379. beginning and at the very end of the audio file, not all neighbouring
  1380. frames are available. In particular, for the first few frames in the audio
  1381. file, the preceding frames are not known. And, similarly, for the last few
  1382. frames in the audio file, the subsequent frames are not known. Thus, the
  1383. question arises which gain factors should be assumed for the missing frames
  1384. in the "boundary" region. The Dynamic Audio Normalizer implements two modes
  1385. to deal with this situation. The default boundary mode assumes a gain factor
  1386. of exactly 1.0 for the missing frames, resulting in a smooth "fade in" and
  1387. "fade out" at the beginning and at the end of the input, respectively.
  1388. @item s
  1389. Set the compress factor. In range from 0.0 to 30.0. Default is 0.0.
  1390. By default, the Dynamic Audio Normalizer does not apply "traditional"
  1391. compression. This means that signal peaks will not be pruned and thus the
  1392. full dynamic range will be retained within each local neighbourhood. However,
  1393. in some cases it may be desirable to combine the Dynamic Audio Normalizer's
  1394. normalization algorithm with a more "traditional" compression.
  1395. For this purpose, the Dynamic Audio Normalizer provides an optional compression
  1396. (thresholding) function. If (and only if) the compression feature is enabled,
  1397. all input frames will be processed by a soft knee thresholding function prior
  1398. to the actual normalization process. Put simply, the thresholding function is
  1399. going to prune all samples whose magnitude exceeds a certain threshold value.
  1400. However, the Dynamic Audio Normalizer does not simply apply a fixed threshold
  1401. value. Instead, the threshold value will be adjusted for each individual
  1402. frame.
  1403. In general, smaller parameters result in stronger compression, and vice versa.
  1404. Values below 3.0 are not recommended, because audible distortion may appear.
  1405. @end table
  1406. @section earwax
  1407. Make audio easier to listen to on headphones.
  1408. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio
  1409. so that when listened to on headphones the stereo image is moved from
  1410. inside your head (standard for headphones) to outside and in front of
  1411. the listener (standard for speakers).
  1412. Ported from SoX.
  1413. @section equalizer
  1414. Apply a two-pole peaking equalisation (EQ) filter. With this
  1415. filter, the signal-level at and around a selected frequency can
  1416. be increased or decreased, whilst (unlike bandpass and bandreject
  1417. filters) that at all other frequencies is unchanged.
  1418. In order to produce complex equalisation curves, this filter can
  1419. be given several times, each with a different central frequency.
  1420. The filter accepts the following options:
  1421. @table @option
  1422. @item frequency, f
  1423. Set the filter's central frequency in Hz.
  1424. @item width_type
  1425. Set method to specify band-width of filter.
  1426. @table @option
  1427. @item h
  1428. Hz
  1429. @item q
  1430. Q-Factor
  1431. @item o
  1432. octave
  1433. @item s
  1434. slope
  1435. @end table
  1436. @item width, w
  1437. Specify the band-width of a filter in width_type units.
  1438. @item gain, g
  1439. Set the required gain or attenuation in dB.
  1440. Beware of clipping when using a positive gain.
  1441. @end table
  1442. @subsection Examples
  1443. @itemize
  1444. @item
  1445. Attenuate 10 dB at 1000 Hz, with a bandwidth of 200 Hz:
  1446. @example
  1447. equalizer=f=1000:width_type=h:width=200:g=-10
  1448. @end example
  1449. @item
  1450. Apply 2 dB gain at 1000 Hz with Q 1 and attenuate 5 dB at 100 Hz with Q 2:
  1451. @example
  1452. equalizer=f=1000:width_type=q:width=1:g=2,equalizer=f=100:width_type=q:width=2:g=-5
  1453. @end example
  1454. @end itemize
  1455. @section extrastereo
  1456. Linearly increases the difference between left and right channels which
  1457. adds some sort of "live" effect to playback.
  1458. The filter accepts the following option:
  1459. @table @option
  1460. @item m
  1461. Sets the difference coefficient (default: 2.5). 0.0 means mono sound
  1462. (average of both channels), with 1.0 sound will be unchanged, with
  1463. -1.0 left and right channels will be swapped.
  1464. @item c
  1465. Enable clipping. By default is enabled.
  1466. @end table
  1467. @section flanger
  1468. Apply a flanging effect to the audio.
  1469. The filter accepts the following options:
  1470. @table @option
  1471. @item delay
  1472. Set base delay in milliseconds. Range from 0 to 30. Default value is 0.
  1473. @item depth
  1474. Set added swep delay in milliseconds. Range from 0 to 10. Default value is 2.
  1475. @item regen
  1476. Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
  1477. Default value is 0.
  1478. @item width
  1479. Set percentage of delayed signal mixed with original. Range from 0 to 100.
  1480. Default value is 71.
  1481. @item speed
  1482. Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
  1483. @item shape
  1484. Set swept wave shape, can be @var{triangular} or @var{sinusoidal}.
  1485. Default value is @var{sinusoidal}.
  1486. @item phase
  1487. Set swept wave percentage-shift for multi channel. Range from 0 to 100.
  1488. Default value is 25.
  1489. @item interp
  1490. Set delay-line interpolation, @var{linear} or @var{quadratic}.
  1491. Default is @var{linear}.
  1492. @end table
  1493. @section highpass
  1494. Apply a high-pass filter with 3dB point frequency.
  1495. The filter can be either single-pole, or double-pole (the default).
  1496. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1497. The filter accepts the following options:
  1498. @table @option
  1499. @item frequency, f
  1500. Set frequency in Hz. Default is 3000.
  1501. @item poles, p
  1502. Set number of poles. Default is 2.
  1503. @item width_type
  1504. Set method to specify band-width of filter.
  1505. @table @option
  1506. @item h
  1507. Hz
  1508. @item q
  1509. Q-Factor
  1510. @item o
  1511. octave
  1512. @item s
  1513. slope
  1514. @end table
  1515. @item width, w
  1516. Specify the band-width of a filter in width_type units.
  1517. Applies only to double-pole filter.
  1518. The default is 0.707q and gives a Butterworth response.
  1519. @end table
  1520. @section join
  1521. Join multiple input streams into one multi-channel stream.
  1522. It accepts the following parameters:
  1523. @table @option
  1524. @item inputs
  1525. The number of input streams. It defaults to 2.
  1526. @item channel_layout
  1527. The desired output channel layout. It defaults to stereo.
  1528. @item map
  1529. Map channels from inputs to output. The argument is a '|'-separated list of
  1530. mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
  1531. form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
  1532. can be either the name of the input channel (e.g. FL for front left) or its
  1533. index in the specified input stream. @var{out_channel} is the name of the output
  1534. channel.
  1535. @end table
  1536. The filter will attempt to guess the mappings when they are not specified
  1537. explicitly. It does so by first trying to find an unused matching input channel
  1538. and if that fails it picks the first unused input channel.
  1539. Join 3 inputs (with properly set channel layouts):
  1540. @example
  1541. ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
  1542. @end example
  1543. Build a 5.1 output from 6 single-channel streams:
  1544. @example
  1545. ffmpeg -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
  1546. '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'
  1547. out
  1548. @end example
  1549. @section ladspa
  1550. Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin.
  1551. To enable compilation of this filter you need to configure FFmpeg with
  1552. @code{--enable-ladspa}.
  1553. @table @option
  1554. @item file, f
  1555. Specifies the name of LADSPA plugin library to load. If the environment
  1556. variable @env{LADSPA_PATH} is defined, the LADSPA plugin is searched in
  1557. each one of the directories specified by the colon separated list in
  1558. @env{LADSPA_PATH}, otherwise in the standard LADSPA paths, which are in
  1559. this order: @file{HOME/.ladspa/lib/}, @file{/usr/local/lib/ladspa/},
  1560. @file{/usr/lib/ladspa/}.
  1561. @item plugin, p
  1562. Specifies the plugin within the library. Some libraries contain only
  1563. one plugin, but others contain many of them. If this is not set filter
  1564. will list all available plugins within the specified library.
  1565. @item controls, c
  1566. Set the '|' separated list of controls which are zero or more floating point
  1567. values that determine the behavior of the loaded plugin (for example delay,
  1568. threshold or gain).
  1569. Controls need to be defined using the following syntax:
  1570. c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where
  1571. @var{valuei} is the value set on the @var{i}-th control.
  1572. Alternatively they can be also defined using the following syntax:
  1573. @var{value0}|@var{value1}|@var{value2}|..., where
  1574. @var{valuei} is the value set on the @var{i}-th control.
  1575. If @option{controls} is set to @code{help}, all available controls and
  1576. their valid ranges are printed.
  1577. @item sample_rate, s
  1578. Specify the sample rate, default to 44100. Only used if plugin have
  1579. zero inputs.
  1580. @item nb_samples, n
  1581. Set the number of samples per channel per each output frame, default
  1582. is 1024. Only used if plugin have zero inputs.
  1583. @item duration, d
  1584. Set the minimum duration of the sourced audio. See
  1585. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  1586. for the accepted syntax.
  1587. Note that the resulting duration may be greater than the specified duration,
  1588. as the generated audio is always cut at the end of a complete frame.
  1589. If not specified, or the expressed duration is negative, the audio is
  1590. supposed to be generated forever.
  1591. Only used if plugin have zero inputs.
  1592. @end table
  1593. @subsection Examples
  1594. @itemize
  1595. @item
  1596. List all available plugins within amp (LADSPA example plugin) library:
  1597. @example
  1598. ladspa=file=amp
  1599. @end example
  1600. @item
  1601. List all available controls and their valid ranges for @code{vcf_notch}
  1602. plugin from @code{VCF} library:
  1603. @example
  1604. ladspa=f=vcf:p=vcf_notch:c=help
  1605. @end example
  1606. @item
  1607. Simulate low quality audio equipment using @code{Computer Music Toolkit} (CMT)
  1608. plugin library:
  1609. @example
  1610. ladspa=file=cmt:plugin=lofi:controls=c0=22|c1=12|c2=12
  1611. @end example
  1612. @item
  1613. Add reverberation to the audio using TAP-plugins
  1614. (Tom's Audio Processing plugins):
  1615. @example
  1616. ladspa=file=tap_reverb:tap_reverb
  1617. @end example
  1618. @item
  1619. Generate white noise, with 0.2 amplitude:
  1620. @example
  1621. ladspa=file=cmt:noise_source_white:c=c0=.2
  1622. @end example
  1623. @item
  1624. Generate 20 bpm clicks using plugin @code{C* Click - Metronome} from the
  1625. @code{C* Audio Plugin Suite} (CAPS) library:
  1626. @example
  1627. ladspa=file=caps:Click:c=c1=20'
  1628. @end example
  1629. @item
  1630. Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect:
  1631. @example
  1632. ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2
  1633. @end example
  1634. @item
  1635. Increase volume by 20dB using fast lookahead limiter from Steve Harris
  1636. @code{SWH Plugins} collection:
  1637. @example
  1638. ladspa=fast_lookahead_limiter_1913:fastLookaheadLimiter:20|0|2
  1639. @end example
  1640. @item
  1641. Attenuate low frequencies using Multiband EQ from Steve Harris
  1642. @code{SWH Plugins} collection:
  1643. @example
  1644. ladspa=mbeq_1197:mbeq:-24|-24|-24|0|0|0|0|0|0|0|0|0|0|0|0
  1645. @end example
  1646. @end itemize
  1647. @subsection Commands
  1648. This filter supports the following commands:
  1649. @table @option
  1650. @item cN
  1651. Modify the @var{N}-th control value.
  1652. If the specified value is not valid, it is ignored and prior one is kept.
  1653. @end table
  1654. @section lowpass
  1655. Apply a low-pass filter with 3dB point frequency.
  1656. The filter can be either single-pole or double-pole (the default).
  1657. The filter roll off at 6dB per pole per octave (20dB per pole per decade).
  1658. The filter accepts the following options:
  1659. @table @option
  1660. @item frequency, f
  1661. Set frequency in Hz. Default is 500.
  1662. @item poles, p
  1663. Set number of poles. Default is 2.
  1664. @item width_type
  1665. Set method to specify band-width of filter.
  1666. @table @option
  1667. @item h
  1668. Hz
  1669. @item q
  1670. Q-Factor
  1671. @item o
  1672. octave
  1673. @item s
  1674. slope
  1675. @end table
  1676. @item width, w
  1677. Specify the band-width of a filter in width_type units.
  1678. Applies only to double-pole filter.
  1679. The default is 0.707q and gives a Butterworth response.
  1680. @end table
  1681. @anchor{pan}
  1682. @section pan
  1683. Mix channels with specific gain levels. The filter accepts the output
  1684. channel layout followed by a set of channels definitions.
  1685. This filter is also designed to efficiently remap the channels of an audio
  1686. stream.
  1687. The filter accepts parameters of the form:
  1688. "@var{l}|@var{outdef}|@var{outdef}|..."
  1689. @table @option
  1690. @item l
  1691. output channel layout or number of channels
  1692. @item outdef
  1693. output channel specification, of the form:
  1694. "@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
  1695. @item out_name
  1696. output channel to define, either a channel name (FL, FR, etc.) or a channel
  1697. number (c0, c1, etc.)
  1698. @item gain
  1699. multiplicative coefficient for the channel, 1 leaving the volume unchanged
  1700. @item in_name
  1701. input channel to use, see out_name for details; it is not possible to mix
  1702. named and numbered input channels
  1703. @end table
  1704. If the `=' in a channel specification is replaced by `<', then the gains for
  1705. that specification will be renormalized so that the total is 1, thus
  1706. avoiding clipping noise.
  1707. @subsection Mixing examples
  1708. For example, if you want to down-mix from stereo to mono, but with a bigger
  1709. factor for the left channel:
  1710. @example
  1711. pan=1c|c0=0.9*c0+0.1*c1
  1712. @end example
  1713. A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
  1714. 7-channels surround:
  1715. @example
  1716. pan=stereo| FL < FL + 0.5*FC + 0.6*BL + 0.6*SL | FR < FR + 0.5*FC + 0.6*BR + 0.6*SR
  1717. @end example
  1718. Note that @command{ffmpeg} integrates a default down-mix (and up-mix) system
  1719. that should be preferred (see "-ac" option) unless you have very specific
  1720. needs.
  1721. @subsection Remapping examples
  1722. The channel remapping will be effective if, and only if:
  1723. @itemize
  1724. @item gain coefficients are zeroes or ones,
  1725. @item only one input per channel output,
  1726. @end itemize
  1727. If all these conditions are satisfied, the filter will notify the user ("Pure
  1728. channel mapping detected"), and use an optimized and lossless method to do the
  1729. remapping.
  1730. For example, if you have a 5.1 source and want a stereo audio stream by
  1731. dropping the extra channels:
  1732. @example
  1733. pan="stereo| c0=FL | c1=FR"
  1734. @end example
  1735. Given the same source, you can also switch front left and front right channels
  1736. and keep the input channel layout:
  1737. @example
  1738. pan="5.1| c0=c1 | c1=c0 | c2=c2 | c3=c3 | c4=c4 | c5=c5"
  1739. @end example
  1740. If the input is a stereo audio stream, you can mute the front left channel (and
  1741. still keep the stereo channel layout) with:
  1742. @example
  1743. pan="stereo|c1=c1"
  1744. @end example
  1745. Still with a stereo audio stream input, you can copy the right channel in both
  1746. front left and right:
  1747. @example
  1748. pan="stereo| c0=FR | c1=FR"
  1749. @end example
  1750. @section replaygain
  1751. ReplayGain scanner filter. This filter takes an audio stream as an input and
  1752. outputs it unchanged.
  1753. At end of filtering it displays @code{track_gain} and @code{track_peak}.
  1754. @section resample
  1755. Convert the audio sample format, sample rate and channel layout. It is
  1756. not meant to be used directly.
  1757. @section sidechaincompress
  1758. This filter acts like normal compressor but has the ability to compress
  1759. detected signal using second input signal.
  1760. It needs two input streams and returns one output stream.
  1761. First input stream will be processed depending on second stream signal.
  1762. The filtered signal then can be filtered with other filters in later stages of
  1763. processing. See @ref{pan} and @ref{amerge} filter.
  1764. The filter accepts the following options:
  1765. @table @option
  1766. @item threshold
  1767. If a signal of second stream raises above this level it will affect the gain
  1768. reduction of first stream.
  1769. By default is 0.125. Range is between 0.00097563 and 1.
  1770. @item ratio
  1771. Set a ratio about which the signal is reduced. 1:2 means that if the level
  1772. raised 4dB above the threshold, it will be only 2dB above after the reduction.
  1773. Default is 2. Range is between 1 and 20.
  1774. @item attack
  1775. Amount of milliseconds the signal has to rise above the threshold before gain
  1776. reduction starts. Default is 20. Range is between 0.01 and 2000.
  1777. @item release
  1778. Amount of milliseconds the signal has to fall bellow the threshold before
  1779. reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
  1780. @item makeup
  1781. Set the amount by how much signal will be amplified after processing.
  1782. Default is 2. Range is from 1 and 64.
  1783. @item knee
  1784. Curve the sharp knee around the threshold to enter gain reduction more softly.
  1785. Default is 2.82843. Range is between 1 and 8.
  1786. @item link
  1787. Choose if the @code{average} level between all channels of side-chain stream
  1788. or the louder(@code{maximum}) channel of side-chain stream affects the
  1789. reduction. Default is @code{average}.
  1790. @item detection
  1791. Should the exact signal be taken in case of @code{peak} or an RMS one in case
  1792. of @code{rms}. Default is @code{rms} which is mainly smoother.
  1793. @end table
  1794. @subsection Examples
  1795. @itemize
  1796. @item
  1797. Full ffmpeg example taking 2 audio inputs, 1st input to be compressed
  1798. depending on the signal of 2nd input and later compressed signal to be
  1799. merged with 2nd input:
  1800. @example
  1801. ffmpeg -i main.flac -i sidechain.flac -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge"
  1802. @end example
  1803. @end itemize
  1804. @section silencedetect
  1805. Detect silence in an audio stream.
  1806. This filter logs a message when it detects that the input audio volume is less
  1807. or equal to a noise tolerance value for a duration greater or equal to the
  1808. minimum detected noise duration.
  1809. The printed times and duration are expressed in seconds.
  1810. The filter accepts the following options:
  1811. @table @option
  1812. @item duration, d
  1813. Set silence duration until notification (default is 2 seconds).
  1814. @item noise, n
  1815. Set noise tolerance. Can be specified in dB (in case "dB" is appended to the
  1816. specified value) or amplitude ratio. Default is -60dB, or 0.001.
  1817. @end table
  1818. @subsection Examples
  1819. @itemize
  1820. @item
  1821. Detect 5 seconds of silence with -50dB noise tolerance:
  1822. @example
  1823. silencedetect=n=-50dB:d=5
  1824. @end example
  1825. @item
  1826. Complete example with @command{ffmpeg} to detect silence with 0.0001 noise
  1827. tolerance in @file{silence.mp3}:
  1828. @example
  1829. ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -
  1830. @end example
  1831. @end itemize
  1832. @section silenceremove
  1833. Remove silence from the beginning, middle or end of the audio.
  1834. The filter accepts the following options:
  1835. @table @option
  1836. @item start_periods
  1837. This value is used to indicate if audio should be trimmed at beginning of
  1838. the audio. A value of zero indicates no silence should be trimmed from the
  1839. beginning. When specifying a non-zero value, it trims audio up until it
  1840. finds non-silence. Normally, when trimming silence from beginning of audio
  1841. the @var{start_periods} will be @code{1} but it can be increased to higher
  1842. values to trim all audio up to specific count of non-silence periods.
  1843. Default value is @code{0}.
  1844. @item start_duration
  1845. Specify the amount of time that non-silence must be detected before it stops
  1846. trimming audio. By increasing the duration, bursts of noises can be treated
  1847. as silence and trimmed off. Default value is @code{0}.
  1848. @item start_threshold
  1849. This indicates what sample value should be treated as silence. For digital
  1850. audio, a value of @code{0} may be fine but for audio recorded from analog,
  1851. you may wish to increase the value to account for background noise.
  1852. Can be specified in dB (in case "dB" is appended to the specified value)
  1853. or amplitude ratio. Default value is @code{0}.
  1854. @item stop_periods
  1855. Set the count for trimming silence from the end of audio.
  1856. To remove silence from the middle of a file, specify a @var{stop_periods}
  1857. that is negative. This value is then treated as a positive value and is
  1858. used to indicate the effect should restart processing as specified by
  1859. @var{start_periods}, making it suitable for removing periods of silence
  1860. in the middle of the audio.
  1861. Default value is @code{0}.
  1862. @item stop_duration
  1863. Specify a duration of silence that must exist before audio is not copied any
  1864. more. By specifying a higher duration, silence that is wanted can be left in
  1865. the audio.
  1866. Default value is @code{0}.
  1867. @item stop_threshold
  1868. This is the same as @option{start_threshold} but for trimming silence from
  1869. the end of audio.
  1870. Can be specified in dB (in case "dB" is appended to the specified value)
  1871. or amplitude ratio. Default value is @code{0}.
  1872. @item leave_silence
  1873. This indicate that @var{stop_duration} length of audio should be left intact
  1874. at the beginning of each period of silence.
  1875. For example, if you want to remove long pauses between words but do not want
  1876. to remove the pauses completely. Default value is @code{0}.
  1877. @end table
  1878. @subsection Examples
  1879. @itemize
  1880. @item
  1881. The following example shows how this filter can be used to start a recording
  1882. that does not contain the delay at the start which usually occurs between
  1883. pressing the record button and the start of the performance:
  1884. @example
  1885. silenceremove=1:5:0.02
  1886. @end example
  1887. @end itemize
  1888. @section stereowiden
  1889. This filter enhance the stereo effect by suppressing signal common to both
  1890. channels and by delaying the signal of left into right and vice versa,
  1891. thereby widening the stereo effect.
  1892. The filter accepts the following options:
  1893. @table @option
  1894. @item delay
  1895. Time in milliseconds of the delay of left signal into right and vice versa.
  1896. Default is 20 milliseconds.
  1897. @item feedback
  1898. Amount of gain in delayed signal into right and vice versa. Gives a delay
  1899. effect of left signal in right output and vice versa which gives widening
  1900. effect. Default is 0.3.
  1901. @item crossfeed
  1902. Cross feed of left into right with inverted phase. This helps in suppressing
  1903. the mono. If the value is 1 it will cancel all the signal common to both
  1904. channels. Default is 0.3.
  1905. @item drymix
  1906. Set level of input signal of original channel. Default is 0.8.
  1907. @end table
  1908. @section treble
  1909. Boost or cut treble (upper) frequencies of the audio using a two-pole
  1910. shelving filter with a response similar to that of a standard
  1911. hi-fi's tone-controls. This is also known as shelving equalisation (EQ).
  1912. The filter accepts the following options:
  1913. @table @option
  1914. @item gain, g
  1915. Give the gain at whichever is the lower of ~22 kHz and the
  1916. Nyquist frequency. Its useful range is about -20 (for a large cut)
  1917. to +20 (for a large boost). Beware of clipping when using a positive gain.
  1918. @item frequency, f
  1919. Set the filter's central frequency and so can be used
  1920. to extend or reduce the frequency range to be boosted or cut.
  1921. The default value is @code{3000} Hz.
  1922. @item width_type
  1923. Set method to specify band-width of filter.
  1924. @table @option
  1925. @item h
  1926. Hz
  1927. @item q
  1928. Q-Factor
  1929. @item o
  1930. octave
  1931. @item s
  1932. slope
  1933. @end table
  1934. @item width, w
  1935. Determine how steep is the filter's shelf transition.
  1936. @end table
  1937. @section volume
  1938. Adjust the input audio volume.
  1939. It accepts the following parameters:
  1940. @table @option
  1941. @item volume
  1942. Set audio volume expression.
  1943. Output values are clipped to the maximum value.
  1944. The output audio volume is given by the relation:
  1945. @example
  1946. @var{output_volume} = @var{volume} * @var{input_volume}
  1947. @end example
  1948. The default value for @var{volume} is "1.0".
  1949. @item precision
  1950. This parameter represents the mathematical precision.
  1951. It determines which input sample formats will be allowed, which affects the
  1952. precision of the volume scaling.
  1953. @table @option
  1954. @item fixed
  1955. 8-bit fixed-point; this limits input sample format to U8, S16, and S32.
  1956. @item float
  1957. 32-bit floating-point; this limits input sample format to FLT. (default)
  1958. @item double
  1959. 64-bit floating-point; this limits input sample format to DBL.
  1960. @end table
  1961. @item replaygain
  1962. Choose the behaviour on encountering ReplayGain side data in input frames.
  1963. @table @option
  1964. @item drop
  1965. Remove ReplayGain side data, ignoring its contents (the default).
  1966. @item ignore
  1967. Ignore ReplayGain side data, but leave it in the frame.
  1968. @item track
  1969. Prefer the track gain, if present.
  1970. @item album
  1971. Prefer the album gain, if present.
  1972. @end table
  1973. @item replaygain_preamp
  1974. Pre-amplification gain in dB to apply to the selected replaygain gain.
  1975. Default value for @var{replaygain_preamp} is 0.0.
  1976. @item eval
  1977. Set when the volume expression is evaluated.
  1978. It accepts the following values:
  1979. @table @samp
  1980. @item once
  1981. only evaluate expression once during the filter initialization, or
  1982. when the @samp{volume} command is sent
  1983. @item frame
  1984. evaluate expression for each incoming frame
  1985. @end table
  1986. Default value is @samp{once}.
  1987. @end table
  1988. The volume expression can contain the following parameters.
  1989. @table @option
  1990. @item n
  1991. frame number (starting at zero)
  1992. @item nb_channels
  1993. number of channels
  1994. @item nb_consumed_samples
  1995. number of samples consumed by the filter
  1996. @item nb_samples
  1997. number of samples in the current frame
  1998. @item pos
  1999. original frame position in the file
  2000. @item pts
  2001. frame PTS
  2002. @item sample_rate
  2003. sample rate
  2004. @item startpts
  2005. PTS at start of stream
  2006. @item startt
  2007. time at start of stream
  2008. @item t
  2009. frame time
  2010. @item tb
  2011. timestamp timebase
  2012. @item volume
  2013. last set volume value
  2014. @end table
  2015. Note that when @option{eval} is set to @samp{once} only the
  2016. @var{sample_rate} and @var{tb} variables are available, all other
  2017. variables will evaluate to NAN.
  2018. @subsection Commands
  2019. This filter supports the following commands:
  2020. @table @option
  2021. @item volume
  2022. Modify the volume expression.
  2023. The command accepts the same syntax of the corresponding option.
  2024. If the specified expression is not valid, it is kept at its current
  2025. value.
  2026. @item replaygain_noclip
  2027. Prevent clipping by limiting the gain applied.
  2028. Default value for @var{replaygain_noclip} is 1.
  2029. @end table
  2030. @subsection Examples
  2031. @itemize
  2032. @item
  2033. Halve the input audio volume:
  2034. @example
  2035. volume=volume=0.5
  2036. volume=volume=1/2
  2037. volume=volume=-6.0206dB
  2038. @end example
  2039. In all the above example the named key for @option{volume} can be
  2040. omitted, for example like in:
  2041. @example
  2042. volume=0.5
  2043. @end example
  2044. @item
  2045. Increase input audio power by 6 decibels using fixed-point precision:
  2046. @example
  2047. volume=volume=6dB:precision=fixed
  2048. @end example
  2049. @item
  2050. Fade volume after time 10 with an annihilation period of 5 seconds:
  2051. @example
  2052. volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame
  2053. @end example
  2054. @end itemize
  2055. @section volumedetect
  2056. Detect the volume of the input video.
  2057. The filter has no parameters. The input is not modified. Statistics about
  2058. the volume will be printed in the log when the input stream end is reached.
  2059. In particular it will show the mean volume (root mean square), maximum
  2060. volume (on a per-sample basis), and the beginning of a histogram of the
  2061. registered volume values (from the maximum value to a cumulated 1/1000 of
  2062. the samples).
  2063. All volumes are in decibels relative to the maximum PCM value.
  2064. @subsection Examples
  2065. Here is an excerpt of the output:
  2066. @example
  2067. [Parsed_volumedetect_0 @ 0xa23120] mean_volume: -27 dB
  2068. [Parsed_volumedetect_0 @ 0xa23120] max_volume: -4 dB
  2069. [Parsed_volumedetect_0 @ 0xa23120] histogram_4db: 6
  2070. [Parsed_volumedetect_0 @ 0xa23120] histogram_5db: 62
  2071. [Parsed_volumedetect_0 @ 0xa23120] histogram_6db: 286
  2072. [Parsed_volumedetect_0 @ 0xa23120] histogram_7db: 1042
  2073. [Parsed_volumedetect_0 @ 0xa23120] histogram_8db: 2551
  2074. [Parsed_volumedetect_0 @ 0xa23120] histogram_9db: 4609
  2075. [Parsed_volumedetect_0 @ 0xa23120] histogram_10db: 8409
  2076. @end example
  2077. It means that:
  2078. @itemize
  2079. @item
  2080. The mean square energy is approximately -27 dB, or 10^-2.7.
  2081. @item
  2082. The largest sample is at -4 dB, or more precisely between -4 dB and -5 dB.
  2083. @item
  2084. There are 6 samples at -4 dB, 62 at -5 dB, 286 at -6 dB, etc.
  2085. @end itemize
  2086. In other words, raising the volume by +4 dB does not cause any clipping,
  2087. raising it by +5 dB causes clipping for 6 samples, etc.
  2088. @c man end AUDIO FILTERS
  2089. @chapter Audio Sources
  2090. @c man begin AUDIO SOURCES
  2091. Below is a description of the currently available audio sources.
  2092. @section abuffer
  2093. Buffer audio frames, and make them available to the filter chain.
  2094. This source is mainly intended for a programmatic use, in particular
  2095. through the interface defined in @file{libavfilter/asrc_abuffer.h}.
  2096. It accepts the following parameters:
  2097. @table @option
  2098. @item time_base
  2099. The timebase which will be used for timestamps of submitted frames. It must be
  2100. either a floating-point number or in @var{numerator}/@var{denominator} form.
  2101. @item sample_rate
  2102. The sample rate of the incoming audio buffers.
  2103. @item sample_fmt
  2104. The sample format of the incoming audio buffers.
  2105. Either a sample format name or its corresponding integer representation from
  2106. the enum AVSampleFormat in @file{libavutil/samplefmt.h}
  2107. @item channel_layout
  2108. The channel layout of the incoming audio buffers.
  2109. Either a channel layout name from channel_layout_map in
  2110. @file{libavutil/channel_layout.c} or its corresponding integer representation
  2111. from the AV_CH_LAYOUT_* macros in @file{libavutil/channel_layout.h}
  2112. @item channels
  2113. The number of channels of the incoming audio buffers.
  2114. If both @var{channels} and @var{channel_layout} are specified, then they
  2115. must be consistent.
  2116. @end table
  2117. @subsection Examples
  2118. @example
  2119. abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo
  2120. @end example
  2121. will instruct the source to accept planar 16bit signed stereo at 44100Hz.
  2122. Since the sample format with name "s16p" corresponds to the number
  2123. 6 and the "stereo" channel layout corresponds to the value 0x3, this is
  2124. equivalent to:
  2125. @example
  2126. abuffer=sample_rate=44100:sample_fmt=6:channel_layout=0x3
  2127. @end example
  2128. @section aevalsrc
  2129. Generate an audio signal specified by an expression.
  2130. This source accepts in input one or more expressions (one for each
  2131. channel), which are evaluated and used to generate a corresponding
  2132. audio signal.
  2133. This source accepts the following options:
  2134. @table @option
  2135. @item exprs
  2136. Set the '|'-separated expressions list for each separate channel. In case the
  2137. @option{channel_layout} option is not specified, the selected channel layout
  2138. depends on the number of provided expressions. Otherwise the last
  2139. specified expression is applied to the remaining output channels.
  2140. @item channel_layout, c
  2141. Set the channel layout. The number of channels in the specified layout
  2142. must be equal to the number of specified expressions.
  2143. @item duration, d
  2144. Set the minimum duration of the sourced audio. See
  2145. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  2146. for the accepted syntax.
  2147. Note that the resulting duration may be greater than the specified
  2148. duration, as the generated audio is always cut at the end of a
  2149. complete frame.
  2150. If not specified, or the expressed duration is negative, the audio is
  2151. supposed to be generated forever.
  2152. @item nb_samples, n
  2153. Set the number of samples per channel per each output frame,
  2154. default to 1024.
  2155. @item sample_rate, s
  2156. Specify the sample rate, default to 44100.
  2157. @end table
  2158. Each expression in @var{exprs} can contain the following constants:
  2159. @table @option
  2160. @item n
  2161. number of the evaluated sample, starting from 0
  2162. @item t
  2163. time of the evaluated sample expressed in seconds, starting from 0
  2164. @item s
  2165. sample rate
  2166. @end table
  2167. @subsection Examples
  2168. @itemize
  2169. @item
  2170. Generate silence:
  2171. @example
  2172. aevalsrc=0
  2173. @end example
  2174. @item
  2175. Generate a sin signal with frequency of 440 Hz, set sample rate to
  2176. 8000 Hz:
  2177. @example
  2178. aevalsrc="sin(440*2*PI*t):s=8000"
  2179. @end example
  2180. @item
  2181. Generate a two channels signal, specify the channel layout (Front
  2182. Center + Back Center) explicitly:
  2183. @example
  2184. aevalsrc="sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC"
  2185. @end example
  2186. @item
  2187. Generate white noise:
  2188. @example
  2189. aevalsrc="-2+random(0)"
  2190. @end example
  2191. @item
  2192. Generate an amplitude modulated signal:
  2193. @example
  2194. aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)"
  2195. @end example
  2196. @item
  2197. Generate 2.5 Hz binaural beats on a 360 Hz carrier:
  2198. @example
  2199. aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t)"
  2200. @end example
  2201. @end itemize
  2202. @section anullsrc
  2203. The null audio source, return unprocessed audio frames. It is mainly useful
  2204. as a template and to be employed in analysis / debugging tools, or as
  2205. the source for filters which ignore the input data (for example the sox
  2206. synth filter).
  2207. This source accepts the following options:
  2208. @table @option
  2209. @item channel_layout, cl
  2210. Specifies the channel layout, and can be either an integer or a string
  2211. representing a channel layout. The default value of @var{channel_layout}
  2212. is "stereo".
  2213. Check the channel_layout_map definition in
  2214. @file{libavutil/channel_layout.c} for the mapping between strings and
  2215. channel layout values.
  2216. @item sample_rate, r
  2217. Specifies the sample rate, and defaults to 44100.
  2218. @item nb_samples, n
  2219. Set the number of samples per requested frames.
  2220. @end table
  2221. @subsection Examples
  2222. @itemize
  2223. @item
  2224. Set the sample rate to 48000 Hz and the channel layout to AV_CH_LAYOUT_MONO.
  2225. @example
  2226. anullsrc=r=48000:cl=4
  2227. @end example
  2228. @item
  2229. Do the same operation with a more obvious syntax:
  2230. @example
  2231. anullsrc=r=48000:cl=mono
  2232. @end example
  2233. @end itemize
  2234. All the parameters need to be explicitly defined.
  2235. @section flite
  2236. Synthesize a voice utterance using the libflite library.
  2237. To enable compilation of this filter you need to configure FFmpeg with
  2238. @code{--enable-libflite}.
  2239. Note that the flite library is not thread-safe.
  2240. The filter accepts the following options:
  2241. @table @option
  2242. @item list_voices
  2243. If set to 1, list the names of the available voices and exit
  2244. immediately. Default value is 0.
  2245. @item nb_samples, n
  2246. Set the maximum number of samples per frame. Default value is 512.
  2247. @item textfile
  2248. Set the filename containing the text to speak.
  2249. @item text
  2250. Set the text to speak.
  2251. @item voice, v
  2252. Set the voice to use for the speech synthesis. Default value is
  2253. @code{kal}. See also the @var{list_voices} option.
  2254. @end table
  2255. @subsection Examples
  2256. @itemize
  2257. @item
  2258. Read from file @file{speech.txt}, and synthesize the text using the
  2259. standard flite voice:
  2260. @example
  2261. flite=textfile=speech.txt
  2262. @end example
  2263. @item
  2264. Read the specified text selecting the @code{slt} voice:
  2265. @example
  2266. flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2267. @end example
  2268. @item
  2269. Input text to ffmpeg:
  2270. @example
  2271. ffmpeg -f lavfi -i flite=text='So fare thee well, poor devil of a Sub-Sub, whose commentator I am':voice=slt
  2272. @end example
  2273. @item
  2274. Make @file{ffplay} speak the specified text, using @code{flite} and
  2275. the @code{lavfi} device:
  2276. @example
  2277. ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.'
  2278. @end example
  2279. @end itemize
  2280. For more information about libflite, check:
  2281. @url{http://www.speech.cs.cmu.edu/flite/}
  2282. @section sine
  2283. Generate an audio signal made of a sine wave with amplitude 1/8.
  2284. The audio signal is bit-exact.
  2285. The filter accepts the following options:
  2286. @table @option
  2287. @item frequency, f
  2288. Set the carrier frequency. Default is 440 Hz.
  2289. @item beep_factor, b
  2290. Enable a periodic beep every second with frequency @var{beep_factor} times
  2291. the carrier frequency. Default is 0, meaning the beep is disabled.
  2292. @item sample_rate, r
  2293. Specify the sample rate, default is 44100.
  2294. @item duration, d
  2295. Specify the duration of the generated audio stream.
  2296. @item samples_per_frame
  2297. Set the number of samples per output frame.
  2298. The expression can contain the following constants:
  2299. @table @option
  2300. @item n
  2301. The (sequential) number of the output audio frame, starting from 0.
  2302. @item pts
  2303. The PTS (Presentation TimeStamp) of the output audio frame,
  2304. expressed in @var{TB} units.
  2305. @item t
  2306. The PTS of the output audio frame, expressed in seconds.
  2307. @item TB
  2308. The timebase of the output audio frames.
  2309. @end table
  2310. Default is @code{1024}.
  2311. @end table
  2312. @subsection Examples
  2313. @itemize
  2314. @item
  2315. Generate a simple 440 Hz sine wave:
  2316. @example
  2317. sine
  2318. @end example
  2319. @item
  2320. Generate a 220 Hz sine wave with a 880 Hz beep each second, for 5 seconds:
  2321. @example
  2322. sine=220:4:d=5
  2323. sine=f=220:b=4:d=5
  2324. sine=frequency=220:beep_factor=4:duration=5
  2325. @end example
  2326. @item
  2327. Generate a 1 kHz sine wave following @code{1602,1601,1602,1601,1602} NTSC
  2328. pattern:
  2329. @example
  2330. sine=1000:samples_per_frame='st(0,mod(n,5)); 1602-not(not(eq(ld(0),1)+eq(ld(0),3)))'
  2331. @end example
  2332. @end itemize
  2333. @c man end AUDIO SOURCES
  2334. @chapter Audio Sinks
  2335. @c man begin AUDIO SINKS
  2336. Below is a description of the currently available audio sinks.
  2337. @section abuffersink
  2338. Buffer audio frames, and make them available to the end of filter chain.
  2339. This sink is mainly intended for programmatic use, in particular
  2340. through the interface defined in @file{libavfilter/buffersink.h}
  2341. or the options system.
  2342. It accepts a pointer to an AVABufferSinkContext structure, which
  2343. defines the incoming buffers' formats, to be passed as the opaque
  2344. parameter to @code{avfilter_init_filter} for initialization.
  2345. @section anullsink
  2346. Null audio sink; do absolutely nothing with the input audio. It is
  2347. mainly useful as a template and for use in analysis / debugging
  2348. tools.
  2349. @c man end AUDIO SINKS
  2350. @chapter Video Filters
  2351. @c man begin VIDEO FILTERS
  2352. When you configure your FFmpeg build, you can disable any of the
  2353. existing filters using @code{--disable-filters}.
  2354. The configure output will show the video filters included in your
  2355. build.
  2356. Below is a description of the currently available video filters.
  2357. @section alphaextract
  2358. Extract the alpha component from the input as a grayscale video. This
  2359. is especially useful with the @var{alphamerge} filter.
  2360. @section alphamerge
  2361. Add or replace the alpha component of the primary input with the
  2362. grayscale value of a second input. This is intended for use with
  2363. @var{alphaextract} to allow the transmission or storage of frame
  2364. sequences that have alpha in a format that doesn't support an alpha
  2365. channel.
  2366. For example, to reconstruct full frames from a normal YUV-encoded video
  2367. and a separate video created with @var{alphaextract}, you might use:
  2368. @example
  2369. movie=in_alpha.mkv [alpha]; [in][alpha] alphamerge [out]
  2370. @end example
  2371. Since this filter is designed for reconstruction, it operates on frame
  2372. sequences without considering timestamps, and terminates when either
  2373. input reaches end of stream. This will cause problems if your encoding
  2374. pipeline drops frames. If you're trying to apply an image as an
  2375. overlay to a video stream, consider the @var{overlay} filter instead.
  2376. @section ass
  2377. Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
  2378. and libavformat to work. On the other hand, it is limited to ASS (Advanced
  2379. Substation Alpha) subtitles files.
  2380. This filter accepts the following option in addition to the common options from
  2381. the @ref{subtitles} filter:
  2382. @table @option
  2383. @item shaping
  2384. Set the shaping engine
  2385. Available values are:
  2386. @table @samp
  2387. @item auto
  2388. The default libass shaping engine, which is the best available.
  2389. @item simple
  2390. Fast, font-agnostic shaper that can do only substitutions
  2391. @item complex
  2392. Slower shaper using OpenType for substitutions and positioning
  2393. @end table
  2394. The default is @code{auto}.
  2395. @end table
  2396. @section atadenoise
  2397. Apply an Adaptive Temporal Averaging Denoiser to the video input.
  2398. The filter accepts the following options:
  2399. @table @option
  2400. @item 0a
  2401. Set threshold A for 1st plane. Default is 0.02.
  2402. Valid range is 0 to 0.3.
  2403. @item 0b
  2404. Set threshold B for 1st plane. Default is 0.04.
  2405. Valid range is 0 to 5.
  2406. @item 1a
  2407. Set threshold A for 2nd plane. Default is 0.02.
  2408. Valid range is 0 to 0.3.
  2409. @item 1b
  2410. Set threshold B for 2nd plane. Default is 0.04.
  2411. Valid range is 0 to 5.
  2412. @item 2a
  2413. Set threshold A for 3rd plane. Default is 0.02.
  2414. Valid range is 0 to 0.3.
  2415. @item 2b
  2416. Set threshold B for 3rd plane. Default is 0.04.
  2417. Valid range is 0 to 5.
  2418. Threshold A is designed to react on abrupt changes in the input signal and
  2419. threshold B is designed to react on continuous changes in the input signal.
  2420. @item s
  2421. Set number of frames filter will use for averaging. Default is 33. Must be odd
  2422. number in range [5, 129].
  2423. @end table
  2424. @section bbox
  2425. Compute the bounding box for the non-black pixels in the input frame
  2426. luminance plane.
  2427. This filter computes the bounding box containing all the pixels with a
  2428. luminance value greater than the minimum allowed value.
  2429. The parameters describing the bounding box are printed on the filter
  2430. log.
  2431. The filter accepts the following option:
  2432. @table @option
  2433. @item min_val
  2434. Set the minimal luminance value. Default is @code{16}.
  2435. @end table
  2436. @section blackdetect
  2437. Detect video intervals that are (almost) completely black. Can be
  2438. useful to detect chapter transitions, commercials, or invalid
  2439. recordings. Output lines contains the time for the start, end and
  2440. duration of the detected black interval expressed in seconds.
  2441. In order to display the output lines, you need to set the loglevel at
  2442. least to the AV_LOG_INFO value.
  2443. The filter accepts the following options:
  2444. @table @option
  2445. @item black_min_duration, d
  2446. Set the minimum detected black duration expressed in seconds. It must
  2447. be a non-negative floating point number.
  2448. Default value is 2.0.
  2449. @item picture_black_ratio_th, pic_th
  2450. Set the threshold for considering a picture "black".
  2451. Express the minimum value for the ratio:
  2452. @example
  2453. @var{nb_black_pixels} / @var{nb_pixels}
  2454. @end example
  2455. for which a picture is considered black.
  2456. Default value is 0.98.
  2457. @item pixel_black_th, pix_th
  2458. Set the threshold for considering a pixel "black".
  2459. The threshold expresses the maximum pixel luminance value for which a
  2460. pixel is considered "black". The provided value is scaled according to
  2461. the following equation:
  2462. @example
  2463. @var{absolute_threshold} = @var{luminance_minimum_value} + @var{pixel_black_th} * @var{luminance_range_size}
  2464. @end example
  2465. @var{luminance_range_size} and @var{luminance_minimum_value} depend on
  2466. the input video format, the range is [0-255] for YUV full-range
  2467. formats and [16-235] for YUV non full-range formats.
  2468. Default value is 0.10.
  2469. @end table
  2470. The following example sets the maximum pixel threshold to the minimum
  2471. value, and detects only black intervals of 2 or more seconds:
  2472. @example
  2473. blackdetect=d=2:pix_th=0.00
  2474. @end example
  2475. @section blackframe
  2476. Detect frames that are (almost) completely black. Can be useful to
  2477. detect chapter transitions or commercials. Output lines consist of
  2478. the frame number of the detected frame, the percentage of blackness,
  2479. the position in the file if known or -1 and the timestamp in seconds.
  2480. In order to display the output lines, you need to set the loglevel at
  2481. least to the AV_LOG_INFO value.
  2482. It accepts the following parameters:
  2483. @table @option
  2484. @item amount
  2485. The percentage of the pixels that have to be below the threshold; it defaults to
  2486. @code{98}.
  2487. @item threshold, thresh
  2488. The threshold below which a pixel value is considered black; it defaults to
  2489. @code{32}.
  2490. @end table
  2491. @section blend, tblend
  2492. Blend two video frames into each other.
  2493. The @code{blend} filter takes two input streams and outputs one
  2494. stream, the first input is the "top" layer and second input is
  2495. "bottom" layer. Output terminates when shortest input terminates.
  2496. The @code{tblend} (time blend) filter takes two consecutive frames
  2497. from one single stream, and outputs the result obtained by blending
  2498. the new frame on top of the old frame.
  2499. A description of the accepted options follows.
  2500. @table @option
  2501. @item c0_mode
  2502. @item c1_mode
  2503. @item c2_mode
  2504. @item c3_mode
  2505. @item all_mode
  2506. Set blend mode for specific pixel component or all pixel components in case
  2507. of @var{all_mode}. Default value is @code{normal}.
  2508. Available values for component modes are:
  2509. @table @samp
  2510. @item addition
  2511. @item and
  2512. @item average
  2513. @item burn
  2514. @item darken
  2515. @item difference
  2516. @item difference128
  2517. @item divide
  2518. @item dodge
  2519. @item exclusion
  2520. @item glow
  2521. @item hardlight
  2522. @item hardmix
  2523. @item lighten
  2524. @item linearlight
  2525. @item multiply
  2526. @item negation
  2527. @item normal
  2528. @item or
  2529. @item overlay
  2530. @item phoenix
  2531. @item pinlight
  2532. @item reflect
  2533. @item screen
  2534. @item softlight
  2535. @item subtract
  2536. @item vividlight
  2537. @item xor
  2538. @end table
  2539. @item c0_opacity
  2540. @item c1_opacity
  2541. @item c2_opacity
  2542. @item c3_opacity
  2543. @item all_opacity
  2544. Set blend opacity for specific pixel component or all pixel components in case
  2545. of @var{all_opacity}. Only used in combination with pixel component blend modes.
  2546. @item c0_expr
  2547. @item c1_expr
  2548. @item c2_expr
  2549. @item c3_expr
  2550. @item all_expr
  2551. Set blend expression for specific pixel component or all pixel components in case
  2552. of @var{all_expr}. Note that related mode options will be ignored if those are set.
  2553. The expressions can use the following variables:
  2554. @table @option
  2555. @item N
  2556. The sequential number of the filtered frame, starting from @code{0}.
  2557. @item X
  2558. @item Y
  2559. the coordinates of the current sample
  2560. @item W
  2561. @item H
  2562. the width and height of currently filtered plane
  2563. @item SW
  2564. @item SH
  2565. Width and height scale depending on the currently filtered plane. It is the
  2566. ratio between the corresponding luma plane number of pixels and the current
  2567. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  2568. @code{0.5,0.5} for chroma planes.
  2569. @item T
  2570. Time of the current frame, expressed in seconds.
  2571. @item TOP, A
  2572. Value of pixel component at current location for first video frame (top layer).
  2573. @item BOTTOM, B
  2574. Value of pixel component at current location for second video frame (bottom layer).
  2575. @end table
  2576. @item shortest
  2577. Force termination when the shortest input terminates. Default is
  2578. @code{0}. This option is only defined for the @code{blend} filter.
  2579. @item repeatlast
  2580. Continue applying the last bottom frame after the end of the stream. A value of
  2581. @code{0} disable the filter after the last frame of the bottom layer is reached.
  2582. Default is @code{1}. This option is only defined for the @code{blend} filter.
  2583. @end table
  2584. @subsection Examples
  2585. @itemize
  2586. @item
  2587. Apply transition from bottom layer to top layer in first 10 seconds:
  2588. @example
  2589. blend=all_expr='A*(if(gte(T,10),1,T/10))+B*(1-(if(gte(T,10),1,T/10)))'
  2590. @end example
  2591. @item
  2592. Apply 1x1 checkerboard effect:
  2593. @example
  2594. blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
  2595. @end example
  2596. @item
  2597. Apply uncover left effect:
  2598. @example
  2599. blend=all_expr='if(gte(N*SW+X,W),A,B)'
  2600. @end example
  2601. @item
  2602. Apply uncover down effect:
  2603. @example
  2604. blend=all_expr='if(gte(Y-N*SH,0),A,B)'
  2605. @end example
  2606. @item
  2607. Apply uncover up-left effect:
  2608. @example
  2609. blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)'
  2610. @end example
  2611. @item
  2612. Display differences between the current and the previous frame:
  2613. @example
  2614. tblend=all_mode=difference128
  2615. @end example
  2616. @end itemize
  2617. @section boxblur
  2618. Apply a boxblur algorithm to the input video.
  2619. It accepts the following parameters:
  2620. @table @option
  2621. @item luma_radius, lr
  2622. @item luma_power, lp
  2623. @item chroma_radius, cr
  2624. @item chroma_power, cp
  2625. @item alpha_radius, ar
  2626. @item alpha_power, ap
  2627. @end table
  2628. A description of the accepted options follows.
  2629. @table @option
  2630. @item luma_radius, lr
  2631. @item chroma_radius, cr
  2632. @item alpha_radius, ar
  2633. Set an expression for the box radius in pixels used for blurring the
  2634. corresponding input plane.
  2635. The radius value must be a non-negative number, and must not be
  2636. greater than the value of the expression @code{min(w,h)/2} for the
  2637. luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
  2638. planes.
  2639. Default value for @option{luma_radius} is "2". If not specified,
  2640. @option{chroma_radius} and @option{alpha_radius} default to the
  2641. corresponding value set for @option{luma_radius}.
  2642. The expressions can contain the following constants:
  2643. @table @option
  2644. @item w
  2645. @item h
  2646. The input width and height in pixels.
  2647. @item cw
  2648. @item ch
  2649. The input chroma image width and height in pixels.
  2650. @item hsub
  2651. @item vsub
  2652. The horizontal and vertical chroma subsample values. For example, for the
  2653. pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
  2654. @end table
  2655. @item luma_power, lp
  2656. @item chroma_power, cp
  2657. @item alpha_power, ap
  2658. Specify how many times the boxblur filter is applied to the
  2659. corresponding plane.
  2660. Default value for @option{luma_power} is 2. If not specified,
  2661. @option{chroma_power} and @option{alpha_power} default to the
  2662. corresponding value set for @option{luma_power}.
  2663. A value of 0 will disable the effect.
  2664. @end table
  2665. @subsection Examples
  2666. @itemize
  2667. @item
  2668. Apply a boxblur filter with the luma, chroma, and alpha radii
  2669. set to 2:
  2670. @example
  2671. boxblur=luma_radius=2:luma_power=1
  2672. boxblur=2:1
  2673. @end example
  2674. @item
  2675. Set the luma radius to 2, and alpha and chroma radius to 0:
  2676. @example
  2677. boxblur=2:1:cr=0:ar=0
  2678. @end example
  2679. @item
  2680. Set the luma and chroma radii to a fraction of the video dimension:
  2681. @example
  2682. boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chroma_power=1
  2683. @end example
  2684. @end itemize
  2685. @section codecview
  2686. Visualize information exported by some codecs.
  2687. Some codecs can export information through frames using side-data or other
  2688. means. For example, some MPEG based codecs export motion vectors through the
  2689. @var{export_mvs} flag in the codec @option{flags2} option.
  2690. The filter accepts the following option:
  2691. @table @option
  2692. @item mv
  2693. Set motion vectors to visualize.
  2694. Available flags for @var{mv} are:
  2695. @table @samp
  2696. @item pf
  2697. forward predicted MVs of P-frames
  2698. @item bf
  2699. forward predicted MVs of B-frames
  2700. @item bb
  2701. backward predicted MVs of B-frames
  2702. @end table
  2703. @end table
  2704. @subsection Examples
  2705. @itemize
  2706. @item
  2707. Visualizes multi-directionals MVs from P and B-Frames using @command{ffplay}:
  2708. @example
  2709. ffplay -flags2 +export_mvs input.mpg -vf codecview=mv=pf+bf+bb
  2710. @end example
  2711. @end itemize
  2712. @section colorbalance
  2713. Modify intensity of primary colors (red, green and blue) of input frames.
  2714. The filter allows an input frame to be adjusted in the shadows, midtones or highlights
  2715. regions for the red-cyan, green-magenta or blue-yellow balance.
  2716. A positive adjustment value shifts the balance towards the primary color, a negative
  2717. value towards the complementary color.
  2718. The filter accepts the following options:
  2719. @table @option
  2720. @item rs
  2721. @item gs
  2722. @item bs
  2723. Adjust red, green and blue shadows (darkest pixels).
  2724. @item rm
  2725. @item gm
  2726. @item bm
  2727. Adjust red, green and blue midtones (medium pixels).
  2728. @item rh
  2729. @item gh
  2730. @item bh
  2731. Adjust red, green and blue highlights (brightest pixels).
  2732. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  2733. @end table
  2734. @subsection Examples
  2735. @itemize
  2736. @item
  2737. Add red color cast to shadows:
  2738. @example
  2739. colorbalance=rs=.3
  2740. @end example
  2741. @end itemize
  2742. @section colorkey
  2743. RGB colorspace color keying.
  2744. The filter accepts the following options:
  2745. @table @option
  2746. @item color
  2747. The color which will be replaced with transparency.
  2748. @item similarity
  2749. Similarity percentage with the key color.
  2750. 0.01 matches only the exact key color, while 1.0 matches everything.
  2751. @item blend
  2752. Blend percentage.
  2753. 0.0 makes pixels either fully transparent, or not transparent at all.
  2754. Higher values result in semi-transparent pixels, with a higher transparency
  2755. the more similar the pixels color is to the key color.
  2756. @end table
  2757. @subsection Examples
  2758. @itemize
  2759. @item
  2760. Make every green pixel in the input image transparent:
  2761. @example
  2762. ffmpeg -i input.png -vf colorkey=green out.png
  2763. @end example
  2764. @item
  2765. Overlay a greenscreen-video on top of a static background image.
  2766. @example
  2767. 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
  2768. @end example
  2769. @end itemize
  2770. @section colorlevels
  2771. Adjust video input frames using levels.
  2772. The filter accepts the following options:
  2773. @table @option
  2774. @item rimin
  2775. @item gimin
  2776. @item bimin
  2777. @item aimin
  2778. Adjust red, green, blue and alpha input black point.
  2779. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
  2780. @item rimax
  2781. @item gimax
  2782. @item bimax
  2783. @item aimax
  2784. Adjust red, green, blue and alpha input white point.
  2785. Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
  2786. Input levels are used to lighten highlights (bright tones), darken shadows
  2787. (dark tones), change the balance of bright and dark tones.
  2788. @item romin
  2789. @item gomin
  2790. @item bomin
  2791. @item aomin
  2792. Adjust red, green, blue and alpha output black point.
  2793. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
  2794. @item romax
  2795. @item gomax
  2796. @item bomax
  2797. @item aomax
  2798. Adjust red, green, blue and alpha output white point.
  2799. Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
  2800. Output levels allows manual selection of a constrained output level range.
  2801. @end table
  2802. @subsection Examples
  2803. @itemize
  2804. @item
  2805. Make video output darker:
  2806. @example
  2807. colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
  2808. @end example
  2809. @item
  2810. Increase contrast:
  2811. @example
  2812. colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
  2813. @end example
  2814. @item
  2815. Make video output lighter:
  2816. @example
  2817. colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
  2818. @end example
  2819. @item
  2820. Increase brightness:
  2821. @example
  2822. colorlevels=romin=0.5:gomin=0.5:bomin=0.5
  2823. @end example
  2824. @end itemize
  2825. @section colorchannelmixer
  2826. Adjust video input frames by re-mixing color channels.
  2827. This filter modifies a color channel by adding the values associated to
  2828. the other channels of the same pixels. For example if the value to
  2829. modify is red, the output value will be:
  2830. @example
  2831. @var{red}=@var{red}*@var{rr} + @var{blue}*@var{rb} + @var{green}*@var{rg} + @var{alpha}*@var{ra}
  2832. @end example
  2833. The filter accepts the following options:
  2834. @table @option
  2835. @item rr
  2836. @item rg
  2837. @item rb
  2838. @item ra
  2839. Adjust contribution of input red, green, blue and alpha channels for output red channel.
  2840. Default is @code{1} for @var{rr}, and @code{0} for @var{rg}, @var{rb} and @var{ra}.
  2841. @item gr
  2842. @item gg
  2843. @item gb
  2844. @item ga
  2845. Adjust contribution of input red, green, blue and alpha channels for output green channel.
  2846. Default is @code{1} for @var{gg}, and @code{0} for @var{gr}, @var{gb} and @var{ga}.
  2847. @item br
  2848. @item bg
  2849. @item bb
  2850. @item ba
  2851. Adjust contribution of input red, green, blue and alpha channels for output blue channel.
  2852. Default is @code{1} for @var{bb}, and @code{0} for @var{br}, @var{bg} and @var{ba}.
  2853. @item ar
  2854. @item ag
  2855. @item ab
  2856. @item aa
  2857. Adjust contribution of input red, green, blue and alpha channels for output alpha channel.
  2858. Default is @code{1} for @var{aa}, and @code{0} for @var{ar}, @var{ag} and @var{ab}.
  2859. Allowed ranges for options are @code{[-2.0, 2.0]}.
  2860. @end table
  2861. @subsection Examples
  2862. @itemize
  2863. @item
  2864. Convert source to grayscale:
  2865. @example
  2866. colorchannelmixer=.3:.4:.3:0:.3:.4:.3:0:.3:.4:.3
  2867. @end example
  2868. @item
  2869. Simulate sepia tones:
  2870. @example
  2871. colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
  2872. @end example
  2873. @end itemize
  2874. @section colormatrix
  2875. Convert color matrix.
  2876. The filter accepts the following options:
  2877. @table @option
  2878. @item src
  2879. @item dst
  2880. Specify the source and destination color matrix. Both values must be
  2881. specified.
  2882. The accepted values are:
  2883. @table @samp
  2884. @item bt709
  2885. BT.709
  2886. @item bt601
  2887. BT.601
  2888. @item smpte240m
  2889. SMPTE-240M
  2890. @item fcc
  2891. FCC
  2892. @end table
  2893. @end table
  2894. For example to convert from BT.601 to SMPTE-240M, use the command:
  2895. @example
  2896. colormatrix=bt601:smpte240m
  2897. @end example
  2898. @section copy
  2899. Copy the input source unchanged to the output. This is mainly useful for
  2900. testing purposes.
  2901. @section crop
  2902. Crop the input video to given dimensions.
  2903. It accepts the following parameters:
  2904. @table @option
  2905. @item w, out_w
  2906. The width of the output video. It defaults to @code{iw}.
  2907. This expression is evaluated only once during the filter
  2908. configuration, or when the @samp{w} or @samp{out_w} command is sent.
  2909. @item h, out_h
  2910. The height of the output video. It defaults to @code{ih}.
  2911. This expression is evaluated only once during the filter
  2912. configuration, or when the @samp{h} or @samp{out_h} command is sent.
  2913. @item x
  2914. The horizontal position, in the input video, of the left edge of the output
  2915. video. It defaults to @code{(in_w-out_w)/2}.
  2916. This expression is evaluated per-frame.
  2917. @item y
  2918. The vertical position, in the input video, of the top edge of the output video.
  2919. It defaults to @code{(in_h-out_h)/2}.
  2920. This expression is evaluated per-frame.
  2921. @item keep_aspect
  2922. If set to 1 will force the output display aspect ratio
  2923. to be the same of the input, by changing the output sample aspect
  2924. ratio. It defaults to 0.
  2925. @end table
  2926. The @var{out_w}, @var{out_h}, @var{x}, @var{y} parameters are
  2927. expressions containing the following constants:
  2928. @table @option
  2929. @item x
  2930. @item y
  2931. The computed values for @var{x} and @var{y}. They are evaluated for
  2932. each new frame.
  2933. @item in_w
  2934. @item in_h
  2935. The input width and height.
  2936. @item iw
  2937. @item ih
  2938. These are the same as @var{in_w} and @var{in_h}.
  2939. @item out_w
  2940. @item out_h
  2941. The output (cropped) width and height.
  2942. @item ow
  2943. @item oh
  2944. These are the same as @var{out_w} and @var{out_h}.
  2945. @item a
  2946. same as @var{iw} / @var{ih}
  2947. @item sar
  2948. input sample aspect ratio
  2949. @item dar
  2950. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  2951. @item hsub
  2952. @item vsub
  2953. horizontal and vertical chroma subsample values. For example for the
  2954. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  2955. @item n
  2956. The number of the input frame, starting from 0.
  2957. @item pos
  2958. the position in the file of the input frame, NAN if unknown
  2959. @item t
  2960. The timestamp expressed in seconds. It's NAN if the input timestamp is unknown.
  2961. @end table
  2962. The expression for @var{out_w} may depend on the value of @var{out_h},
  2963. and the expression for @var{out_h} may depend on @var{out_w}, but they
  2964. cannot depend on @var{x} and @var{y}, as @var{x} and @var{y} are
  2965. evaluated after @var{out_w} and @var{out_h}.
  2966. The @var{x} and @var{y} parameters specify the expressions for the
  2967. position of the top-left corner of the output (non-cropped) area. They
  2968. are evaluated for each frame. If the evaluated value is not valid, it
  2969. is approximated to the nearest valid value.
  2970. The expression for @var{x} may depend on @var{y}, and the expression
  2971. for @var{y} may depend on @var{x}.
  2972. @subsection Examples
  2973. @itemize
  2974. @item
  2975. Crop area with size 100x100 at position (12,34).
  2976. @example
  2977. crop=100:100:12:34
  2978. @end example
  2979. Using named options, the example above becomes:
  2980. @example
  2981. crop=w=100:h=100:x=12:y=34
  2982. @end example
  2983. @item
  2984. Crop the central input area with size 100x100:
  2985. @example
  2986. crop=100:100
  2987. @end example
  2988. @item
  2989. Crop the central input area with size 2/3 of the input video:
  2990. @example
  2991. crop=2/3*in_w:2/3*in_h
  2992. @end example
  2993. @item
  2994. Crop the input video central square:
  2995. @example
  2996. crop=out_w=in_h
  2997. crop=in_h
  2998. @end example
  2999. @item
  3000. Delimit the rectangle with the top-left corner placed at position
  3001. 100:100 and the right-bottom corner corresponding to the right-bottom
  3002. corner of the input image.
  3003. @example
  3004. crop=in_w-100:in_h-100:100:100
  3005. @end example
  3006. @item
  3007. Crop 10 pixels from the left and right borders, and 20 pixels from
  3008. the top and bottom borders
  3009. @example
  3010. crop=in_w-2*10:in_h-2*20
  3011. @end example
  3012. @item
  3013. Keep only the bottom right quarter of the input image:
  3014. @example
  3015. crop=in_w/2:in_h/2:in_w/2:in_h/2
  3016. @end example
  3017. @item
  3018. Crop height for getting Greek harmony:
  3019. @example
  3020. crop=in_w:1/PHI*in_w
  3021. @end example
  3022. @item
  3023. Apply trembling effect:
  3024. @example
  3025. 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)
  3026. @end example
  3027. @item
  3028. Apply erratic camera effect depending on timestamp:
  3029. @example
  3030. 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)"
  3031. @end example
  3032. @item
  3033. Set x depending on the value of y:
  3034. @example
  3035. crop=in_w/2:in_h/2:y:10+10*sin(n/10)
  3036. @end example
  3037. @end itemize
  3038. @subsection Commands
  3039. This filter supports the following commands:
  3040. @table @option
  3041. @item w, out_w
  3042. @item h, out_h
  3043. @item x
  3044. @item y
  3045. Set width/height of the output video and the horizontal/vertical position
  3046. in the input video.
  3047. The command accepts the same syntax of the corresponding option.
  3048. If the specified expression is not valid, it is kept at its current
  3049. value.
  3050. @end table
  3051. @section cropdetect
  3052. Auto-detect the crop size.
  3053. It calculates the necessary cropping parameters and prints the
  3054. recommended parameters via the logging system. The detected dimensions
  3055. correspond to the non-black area of the input video.
  3056. It accepts the following parameters:
  3057. @table @option
  3058. @item limit
  3059. Set higher black value threshold, which can be optionally specified
  3060. from nothing (0) to everything (255 for 8bit based formats). An intensity
  3061. value greater to the set value is considered non-black. It defaults to 24.
  3062. You can also specify a value between 0.0 and 1.0 which will be scaled depending
  3063. on the bitdepth of the pixel format.
  3064. @item round
  3065. The value which the width/height should be divisible by. It defaults to
  3066. 16. The offset is automatically adjusted to center the video. Use 2 to
  3067. get only even dimensions (needed for 4:2:2 video). 16 is best when
  3068. encoding to most video codecs.
  3069. @item reset_count, reset
  3070. Set the counter that determines after how many frames cropdetect will
  3071. reset the previously detected largest video area and start over to
  3072. detect the current optimal crop area. Default value is 0.
  3073. This can be useful when channel logos distort the video area. 0
  3074. indicates 'never reset', and returns the largest area encountered during
  3075. playback.
  3076. @end table
  3077. @anchor{curves}
  3078. @section curves
  3079. Apply color adjustments using curves.
  3080. This filter is similar to the Adobe Photoshop and GIMP curves tools. Each
  3081. component (red, green and blue) has its values defined by @var{N} key points
  3082. tied from each other using a smooth curve. The x-axis represents the pixel
  3083. values from the input frame, and the y-axis the new pixel values to be set for
  3084. the output frame.
  3085. By default, a component curve is defined by the two points @var{(0;0)} and
  3086. @var{(1;1)}. This creates a straight line where each original pixel value is
  3087. "adjusted" to its own value, which means no change to the image.
  3088. The filter allows you to redefine these two points and add some more. A new
  3089. curve (using a natural cubic spline interpolation) will be define to pass
  3090. smoothly through all these new coordinates. The new defined points needs to be
  3091. strictly increasing over the x-axis, and their @var{x} and @var{y} values must
  3092. be in the @var{[0;1]} interval. If the computed curves happened to go outside
  3093. the vector spaces, the values will be clipped accordingly.
  3094. If there is no key point defined in @code{x=0}, the filter will automatically
  3095. insert a @var{(0;0)} point. In the same way, if there is no key point defined
  3096. in @code{x=1}, the filter will automatically insert a @var{(1;1)} point.
  3097. The filter accepts the following options:
  3098. @table @option
  3099. @item preset
  3100. Select one of the available color presets. This option can be used in addition
  3101. to the @option{r}, @option{g}, @option{b} parameters; in this case, the later
  3102. options takes priority on the preset values.
  3103. Available presets are:
  3104. @table @samp
  3105. @item none
  3106. @item color_negative
  3107. @item cross_process
  3108. @item darker
  3109. @item increase_contrast
  3110. @item lighter
  3111. @item linear_contrast
  3112. @item medium_contrast
  3113. @item negative
  3114. @item strong_contrast
  3115. @item vintage
  3116. @end table
  3117. Default is @code{none}.
  3118. @item master, m
  3119. Set the master key points. These points will define a second pass mapping. It
  3120. is sometimes called a "luminance" or "value" mapping. It can be used with
  3121. @option{r}, @option{g}, @option{b} or @option{all} since it acts like a
  3122. post-processing LUT.
  3123. @item red, r
  3124. Set the key points for the red component.
  3125. @item green, g
  3126. Set the key points for the green component.
  3127. @item blue, b
  3128. Set the key points for the blue component.
  3129. @item all
  3130. Set the key points for all components (not including master).
  3131. Can be used in addition to the other key points component
  3132. options. In this case, the unset component(s) will fallback on this
  3133. @option{all} setting.
  3134. @item psfile
  3135. Specify a Photoshop curves file (@code{.acv}) to import the settings from.
  3136. @end table
  3137. To avoid some filtergraph syntax conflicts, each key points list need to be
  3138. defined using the following syntax: @code{x0/y0 x1/y1 x2/y2 ...}.
  3139. @subsection Examples
  3140. @itemize
  3141. @item
  3142. Increase slightly the middle level of blue:
  3143. @example
  3144. curves=blue='0.5/0.58'
  3145. @end example
  3146. @item
  3147. Vintage effect:
  3148. @example
  3149. curves=r='0/0.11 .42/.51 1/0.95':g='0.50/0.48':b='0/0.22 .49/.44 1/0.8'
  3150. @end example
  3151. Here we obtain the following coordinates for each components:
  3152. @table @var
  3153. @item red
  3154. @code{(0;0.11) (0.42;0.51) (1;0.95)}
  3155. @item green
  3156. @code{(0;0) (0.50;0.48) (1;1)}
  3157. @item blue
  3158. @code{(0;0.22) (0.49;0.44) (1;0.80)}
  3159. @end table
  3160. @item
  3161. The previous example can also be achieved with the associated built-in preset:
  3162. @example
  3163. curves=preset=vintage
  3164. @end example
  3165. @item
  3166. Or simply:
  3167. @example
  3168. curves=vintage
  3169. @end example
  3170. @item
  3171. Use a Photoshop preset and redefine the points of the green component:
  3172. @example
  3173. curves=psfile='MyCurvesPresets/purple.acv':green='0.45/0.53'
  3174. @end example
  3175. @end itemize
  3176. @section dctdnoiz
  3177. Denoise frames using 2D DCT (frequency domain filtering).
  3178. This filter is not designed for real time.
  3179. The filter accepts the following options:
  3180. @table @option
  3181. @item sigma, s
  3182. Set the noise sigma constant.
  3183. This @var{sigma} defines a hard threshold of @code{3 * sigma}; every DCT
  3184. coefficient (absolute value) below this threshold with be dropped.
  3185. If you need a more advanced filtering, see @option{expr}.
  3186. Default is @code{0}.
  3187. @item overlap
  3188. Set number overlapping pixels for each block. Since the filter can be slow, you
  3189. may want to reduce this value, at the cost of a less effective filter and the
  3190. risk of various artefacts.
  3191. If the overlapping value doesn't permit processing the whole input width or
  3192. height, a warning will be displayed and according borders won't be denoised.
  3193. Default value is @var{blocksize}-1, which is the best possible setting.
  3194. @item expr, e
  3195. Set the coefficient factor expression.
  3196. For each coefficient of a DCT block, this expression will be evaluated as a
  3197. multiplier value for the coefficient.
  3198. If this is option is set, the @option{sigma} option will be ignored.
  3199. The absolute value of the coefficient can be accessed through the @var{c}
  3200. variable.
  3201. @item n
  3202. Set the @var{blocksize} using the number of bits. @code{1<<@var{n}} defines the
  3203. @var{blocksize}, which is the width and height of the processed blocks.
  3204. The default value is @var{3} (8x8) and can be raised to @var{4} for a
  3205. @var{blocksize} of 16x16. Note that changing this setting has huge consequences
  3206. on the speed processing. Also, a larger block size does not necessarily means a
  3207. better de-noising.
  3208. @end table
  3209. @subsection Examples
  3210. Apply a denoise with a @option{sigma} of @code{4.5}:
  3211. @example
  3212. dctdnoiz=4.5
  3213. @end example
  3214. The same operation can be achieved using the expression system:
  3215. @example
  3216. dctdnoiz=e='gte(c, 4.5*3)'
  3217. @end example
  3218. Violent denoise using a block size of @code{16x16}:
  3219. @example
  3220. dctdnoiz=15:n=4
  3221. @end example
  3222. @section deband
  3223. Remove banding artifacts from input video.
  3224. It works by replacing banded pixels with average value of referenced pixels.
  3225. The filter accepts the following options:
  3226. @table @option
  3227. @item 1thr
  3228. @item 2thr
  3229. @item 3thr
  3230. @item 4thr
  3231. Set banding detection threshold for each plane. Default is 0.02.
  3232. Valid range is 0.00003 to 0.5.
  3233. If difference between current pixel and reference pixel is less than threshold,
  3234. it will be considered as banded.
  3235. @item range, r
  3236. Banding detection range in pixels. Default is 16. If positive, random number
  3237. in range 0 to set value will be used. If negative, exact absolute value
  3238. will be used.
  3239. The range defines square of four pixels around current pixel.
  3240. @item direction, d
  3241. Set direction in radians from which four pixel will be compared. If positive,
  3242. random direction from 0 to set direction will be picked. If negative, exact of
  3243. absolute value will be picked. For example direction 0, -PI or -2*PI radians
  3244. will pick only pixels on same row and -PI/2 will pick only pixels on same
  3245. column.
  3246. @item blur
  3247. If enabled, current pixel is compared with average value of all four
  3248. surrounding pixels. The default is enabled. If disabled current pixel is
  3249. compared with all four surrounding pixels. The pixel is considered banded
  3250. if only all four differences with surrounding pixels are less than threshold.
  3251. @end table
  3252. @anchor{decimate}
  3253. @section decimate
  3254. Drop duplicated frames at regular intervals.
  3255. The filter accepts the following options:
  3256. @table @option
  3257. @item cycle
  3258. Set the number of frames from which one will be dropped. Setting this to
  3259. @var{N} means one frame in every batch of @var{N} frames will be dropped.
  3260. Default is @code{5}.
  3261. @item dupthresh
  3262. Set the threshold for duplicate detection. If the difference metric for a frame
  3263. is less than or equal to this value, then it is declared as duplicate. Default
  3264. is @code{1.1}
  3265. @item scthresh
  3266. Set scene change threshold. Default is @code{15}.
  3267. @item blockx
  3268. @item blocky
  3269. Set the size of the x and y-axis blocks used during metric calculations.
  3270. Larger blocks give better noise suppression, but also give worse detection of
  3271. small movements. Must be a power of two. Default is @code{32}.
  3272. @item ppsrc
  3273. Mark main input as a pre-processed input and activate clean source input
  3274. stream. This allows the input to be pre-processed with various filters to help
  3275. the metrics calculation while keeping the frame selection lossless. When set to
  3276. @code{1}, the first stream is for the pre-processed input, and the second
  3277. stream is the clean source from where the kept frames are chosen. Default is
  3278. @code{0}.
  3279. @item chroma
  3280. Set whether or not chroma is considered in the metric calculations. Default is
  3281. @code{1}.
  3282. @end table
  3283. @section deflate
  3284. Apply deflate effect to the video.
  3285. This filter replaces the pixel by the local(3x3) average by taking into account
  3286. only values lower than the pixel.
  3287. It accepts the following options:
  3288. @table @option
  3289. @item threshold0
  3290. @item threshold1
  3291. @item threshold2
  3292. @item threshold3
  3293. Allows to limit the maximum change for each plane, default is 65535.
  3294. If 0, plane will remain unchanged.
  3295. @end table
  3296. @section dejudder
  3297. Remove judder produced by partially interlaced telecined content.
  3298. Judder can be introduced, for instance, by @ref{pullup} filter. If the original
  3299. source was partially telecined content then the output of @code{pullup,dejudder}
  3300. will have a variable frame rate. May change the recorded frame rate of the
  3301. container. Aside from that change, this filter will not affect constant frame
  3302. rate video.
  3303. The option available in this filter is:
  3304. @table @option
  3305. @item cycle
  3306. Specify the length of the window over which the judder repeats.
  3307. Accepts any integer greater than 1. Useful values are:
  3308. @table @samp
  3309. @item 4
  3310. If the original was telecined from 24 to 30 fps (Film to NTSC).
  3311. @item 5
  3312. If the original was telecined from 25 to 30 fps (PAL to NTSC).
  3313. @item 20
  3314. If a mixture of the two.
  3315. @end table
  3316. The default is @samp{4}.
  3317. @end table
  3318. @section delogo
  3319. Suppress a TV station logo by a simple interpolation of the surrounding
  3320. pixels. Just set a rectangle covering the logo and watch it disappear
  3321. (and sometimes something even uglier appear - your mileage may vary).
  3322. It accepts the following parameters:
  3323. @table @option
  3324. @item x
  3325. @item y
  3326. Specify the top left corner coordinates of the logo. They must be
  3327. specified.
  3328. @item w
  3329. @item h
  3330. Specify the width and height of the logo to clear. They must be
  3331. specified.
  3332. @item band, t
  3333. Specify the thickness of the fuzzy edge of the rectangle (added to
  3334. @var{w} and @var{h}). The default value is 4.
  3335. @item show
  3336. When set to 1, a green rectangle is drawn on the screen to simplify
  3337. finding the right @var{x}, @var{y}, @var{w}, and @var{h} parameters.
  3338. The default value is 0.
  3339. The rectangle is drawn on the outermost pixels which will be (partly)
  3340. replaced with interpolated values. The values of the next pixels
  3341. immediately outside this rectangle in each direction will be used to
  3342. compute the interpolated pixel values inside the rectangle.
  3343. @end table
  3344. @subsection Examples
  3345. @itemize
  3346. @item
  3347. Set a rectangle covering the area with top left corner coordinates 0,0
  3348. and size 100x77, and a band of size 10:
  3349. @example
  3350. delogo=x=0:y=0:w=100:h=77:band=10
  3351. @end example
  3352. @end itemize
  3353. @section deshake
  3354. Attempt to fix small changes in horizontal and/or vertical shift. This
  3355. filter helps remove camera shake from hand-holding a camera, bumping a
  3356. tripod, moving on a vehicle, etc.
  3357. The filter accepts the following options:
  3358. @table @option
  3359. @item x
  3360. @item y
  3361. @item w
  3362. @item h
  3363. Specify a rectangular area where to limit the search for motion
  3364. vectors.
  3365. If desired the search for motion vectors can be limited to a
  3366. rectangular area of the frame defined by its top left corner, width
  3367. and height. These parameters have the same meaning as the drawbox
  3368. filter which can be used to visualise the position of the bounding
  3369. box.
  3370. This is useful when simultaneous movement of subjects within the frame
  3371. might be confused for camera motion by the motion vector search.
  3372. If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1
  3373. then the full frame is used. This allows later options to be set
  3374. without specifying the bounding box for the motion vector search.
  3375. Default - search the whole frame.
  3376. @item rx
  3377. @item ry
  3378. Specify the maximum extent of movement in x and y directions in the
  3379. range 0-64 pixels. Default 16.
  3380. @item edge
  3381. Specify how to generate pixels to fill blanks at the edge of the
  3382. frame. Available values are:
  3383. @table @samp
  3384. @item blank, 0
  3385. Fill zeroes at blank locations
  3386. @item original, 1
  3387. Original image at blank locations
  3388. @item clamp, 2
  3389. Extruded edge value at blank locations
  3390. @item mirror, 3
  3391. Mirrored edge at blank locations
  3392. @end table
  3393. Default value is @samp{mirror}.
  3394. @item blocksize
  3395. Specify the blocksize to use for motion search. Range 4-128 pixels,
  3396. default 8.
  3397. @item contrast
  3398. Specify the contrast threshold for blocks. Only blocks with more than
  3399. the specified contrast (difference between darkest and lightest
  3400. pixels) will be considered. Range 1-255, default 125.
  3401. @item search
  3402. Specify the search strategy. Available values are:
  3403. @table @samp
  3404. @item exhaustive, 0
  3405. Set exhaustive search
  3406. @item less, 1
  3407. Set less exhaustive search.
  3408. @end table
  3409. Default value is @samp{exhaustive}.
  3410. @item filename
  3411. If set then a detailed log of the motion search is written to the
  3412. specified file.
  3413. @item opencl
  3414. If set to 1, specify using OpenCL capabilities, only available if
  3415. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  3416. @end table
  3417. @section detelecine
  3418. Apply an exact inverse of the telecine operation. It requires a predefined
  3419. pattern specified using the pattern option which must be the same as that passed
  3420. to the telecine filter.
  3421. This filter accepts the following options:
  3422. @table @option
  3423. @item first_field
  3424. @table @samp
  3425. @item top, t
  3426. top field first
  3427. @item bottom, b
  3428. bottom field first
  3429. The default value is @code{top}.
  3430. @end table
  3431. @item pattern
  3432. A string of numbers representing the pulldown pattern you wish to apply.
  3433. The default value is @code{23}.
  3434. @item start_frame
  3435. A number representing position of the first frame with respect to the telecine
  3436. pattern. This is to be used if the stream is cut. The default value is @code{0}.
  3437. @end table
  3438. @section dilation
  3439. Apply dilation effect to the video.
  3440. This filter replaces the pixel by the local(3x3) maximum.
  3441. It accepts the following options:
  3442. @table @option
  3443. @item threshold0
  3444. @item threshold1
  3445. @item threshold2
  3446. @item threshold3
  3447. Allows to limit the maximum change for each plane, default is 65535.
  3448. If 0, plane will remain unchanged.
  3449. @item coordinates
  3450. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  3451. pixels are used.
  3452. Flags to local 3x3 coordinates maps like this:
  3453. 1 2 3
  3454. 4 5
  3455. 6 7 8
  3456. @end table
  3457. @section drawbox
  3458. Draw a colored box on the input image.
  3459. It accepts the following parameters:
  3460. @table @option
  3461. @item x
  3462. @item y
  3463. The expressions which specify the top left corner coordinates of the box. It defaults to 0.
  3464. @item width, w
  3465. @item height, h
  3466. The expressions which specify the width and height of the box; if 0 they are interpreted as
  3467. the input width and height. It defaults to 0.
  3468. @item color, c
  3469. Specify the color of the box to write. For the general syntax of this option,
  3470. check the "Color" section in the ffmpeg-utils manual. If the special
  3471. value @code{invert} is used, the box edge color is the same as the
  3472. video with inverted luma.
  3473. @item thickness, t
  3474. The expression which sets the thickness of the box edge. Default value is @code{3}.
  3475. See below for the list of accepted constants.
  3476. @end table
  3477. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  3478. following constants:
  3479. @table @option
  3480. @item dar
  3481. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  3482. @item hsub
  3483. @item vsub
  3484. horizontal and vertical chroma subsample values. For example for the
  3485. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3486. @item in_h, ih
  3487. @item in_w, iw
  3488. The input width and height.
  3489. @item sar
  3490. The input sample aspect ratio.
  3491. @item x
  3492. @item y
  3493. The x and y offset coordinates where the box is drawn.
  3494. @item w
  3495. @item h
  3496. The width and height of the drawn box.
  3497. @item t
  3498. The thickness of the drawn box.
  3499. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  3500. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  3501. @end table
  3502. @subsection Examples
  3503. @itemize
  3504. @item
  3505. Draw a black box around the edge of the input image:
  3506. @example
  3507. drawbox
  3508. @end example
  3509. @item
  3510. Draw a box with color red and an opacity of 50%:
  3511. @example
  3512. drawbox=10:20:200:60:red@@0.5
  3513. @end example
  3514. The previous example can be specified as:
  3515. @example
  3516. drawbox=x=10:y=20:w=200:h=60:color=red@@0.5
  3517. @end example
  3518. @item
  3519. Fill the box with pink color:
  3520. @example
  3521. drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=max
  3522. @end example
  3523. @item
  3524. Draw a 2-pixel red 2.40:1 mask:
  3525. @example
  3526. 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
  3527. @end example
  3528. @end itemize
  3529. @section drawgraph, adrawgraph
  3530. Draw a graph using input video or audio metadata.
  3531. It accepts the following parameters:
  3532. @table @option
  3533. @item m1
  3534. Set 1st frame metadata key from which metadata values will be used to draw a graph.
  3535. @item fg1
  3536. Set 1st foreground color expression.
  3537. @item m2
  3538. Set 2nd frame metadata key from which metadata values will be used to draw a graph.
  3539. @item fg2
  3540. Set 2nd foreground color expression.
  3541. @item m3
  3542. Set 3rd frame metadata key from which metadata values will be used to draw a graph.
  3543. @item fg3
  3544. Set 3rd foreground color expression.
  3545. @item m4
  3546. Set 4th frame metadata key from which metadata values will be used to draw a graph.
  3547. @item fg4
  3548. Set 4th foreground color expression.
  3549. @item min
  3550. Set minimal value of metadata value.
  3551. @item max
  3552. Set maximal value of metadata value.
  3553. @item bg
  3554. Set graph background color. Default is white.
  3555. @item mode
  3556. Set graph mode.
  3557. Available values for mode is:
  3558. @table @samp
  3559. @item bar
  3560. @item dot
  3561. @item line
  3562. @end table
  3563. Default is @code{line}.
  3564. @item slide
  3565. Set slide mode.
  3566. Available values for slide is:
  3567. @table @samp
  3568. @item frame
  3569. Draw new frame when right border is reached.
  3570. @item replace
  3571. Replace old columns with new ones.
  3572. @item scroll
  3573. Scroll from right to left.
  3574. @item rscroll
  3575. Scroll from left to right.
  3576. @end table
  3577. Default is @code{frame}.
  3578. @item size
  3579. Set size of graph video. For the syntax of this option, check the
  3580. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  3581. The default value is @code{900x256}.
  3582. The foreground color expressions can use the following variables:
  3583. @table @option
  3584. @item MIN
  3585. Minimal value of metadata value.
  3586. @item MAX
  3587. Maximal value of metadata value.
  3588. @item VAL
  3589. Current metadata key value.
  3590. @end table
  3591. The color is defined as 0xAABBGGRR.
  3592. @end table
  3593. Example using metadata from @ref{signalstats} filter:
  3594. @example
  3595. signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255
  3596. @end example
  3597. Example using metadata from @ref{ebur128} filter:
  3598. @example
  3599. ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5
  3600. @end example
  3601. @section drawgrid
  3602. Draw a grid on the input image.
  3603. It accepts the following parameters:
  3604. @table @option
  3605. @item x
  3606. @item y
  3607. The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0.
  3608. @item width, w
  3609. @item height, h
  3610. The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the
  3611. input width and height, respectively, minus @code{thickness}, so image gets
  3612. framed. Default to 0.
  3613. @item color, c
  3614. Specify the color of the grid. For the general syntax of this option,
  3615. check the "Color" section in the ffmpeg-utils manual. If the special
  3616. value @code{invert} is used, the grid color is the same as the
  3617. video with inverted luma.
  3618. @item thickness, t
  3619. The expression which sets the thickness of the grid line. Default value is @code{1}.
  3620. See below for the list of accepted constants.
  3621. @end table
  3622. The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the
  3623. following constants:
  3624. @table @option
  3625. @item dar
  3626. The input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}.
  3627. @item hsub
  3628. @item vsub
  3629. horizontal and vertical chroma subsample values. For example for the
  3630. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3631. @item in_h, ih
  3632. @item in_w, iw
  3633. The input grid cell width and height.
  3634. @item sar
  3635. The input sample aspect ratio.
  3636. @item x
  3637. @item y
  3638. The x and y coordinates of some point of grid intersection (meant to configure offset).
  3639. @item w
  3640. @item h
  3641. The width and height of the drawn cell.
  3642. @item t
  3643. The thickness of the drawn cell.
  3644. These constants allow the @var{x}, @var{y}, @var{w}, @var{h} and @var{t} expressions to refer to
  3645. each other, so you may for example specify @code{y=x/dar} or @code{h=w/dar}.
  3646. @end table
  3647. @subsection Examples
  3648. @itemize
  3649. @item
  3650. Draw a grid with cell 100x100 pixels, thickness 2 pixels, with color red and an opacity of 50%:
  3651. @example
  3652. drawgrid=width=100:height=100:thickness=2:color=red@@0.5
  3653. @end example
  3654. @item
  3655. Draw a white 3x3 grid with an opacity of 50%:
  3656. @example
  3657. drawgrid=w=iw/3:h=ih/3:t=2:c=white@@0.5
  3658. @end example
  3659. @end itemize
  3660. @anchor{drawtext}
  3661. @section drawtext
  3662. Draw a text string or text from a specified file on top of a video, using the
  3663. libfreetype library.
  3664. To enable compilation of this filter, you need to configure FFmpeg with
  3665. @code{--enable-libfreetype}.
  3666. To enable default font fallback and the @var{font} option you need to
  3667. configure FFmpeg with @code{--enable-libfontconfig}.
  3668. To enable the @var{text_shaping} option, you need to configure FFmpeg with
  3669. @code{--enable-libfribidi}.
  3670. @subsection Syntax
  3671. It accepts the following parameters:
  3672. @table @option
  3673. @item box
  3674. Used to draw a box around text using the background color.
  3675. The value must be either 1 (enable) or 0 (disable).
  3676. The default value of @var{box} is 0.
  3677. @item boxborderw
  3678. Set the width of the border to be drawn around the box using @var{boxcolor}.
  3679. The default value of @var{boxborderw} is 0.
  3680. @item boxcolor
  3681. The color to be used for drawing box around text. For the syntax of this
  3682. option, check the "Color" section in the ffmpeg-utils manual.
  3683. The default value of @var{boxcolor} is "white".
  3684. @item borderw
  3685. Set the width of the border to be drawn around the text using @var{bordercolor}.
  3686. The default value of @var{borderw} is 0.
  3687. @item bordercolor
  3688. Set the color to be used for drawing border around text. For the syntax of this
  3689. option, check the "Color" section in the ffmpeg-utils manual.
  3690. The default value of @var{bordercolor} is "black".
  3691. @item expansion
  3692. Select how the @var{text} is expanded. Can be either @code{none},
  3693. @code{strftime} (deprecated) or
  3694. @code{normal} (default). See the @ref{drawtext_expansion, Text expansion} section
  3695. below for details.
  3696. @item fix_bounds
  3697. If true, check and fix text coords to avoid clipping.
  3698. @item fontcolor
  3699. The color to be used for drawing fonts. For the syntax of this option, check
  3700. the "Color" section in the ffmpeg-utils manual.
  3701. The default value of @var{fontcolor} is "black".
  3702. @item fontcolor_expr
  3703. String which is expanded the same way as @var{text} to obtain dynamic
  3704. @var{fontcolor} value. By default this option has empty value and is not
  3705. processed. When this option is set, it overrides @var{fontcolor} option.
  3706. @item font
  3707. The font family to be used for drawing text. By default Sans.
  3708. @item fontfile
  3709. The font file to be used for drawing text. The path must be included.
  3710. This parameter is mandatory if the fontconfig support is disabled.
  3711. @item draw
  3712. This option does not exist, please see the timeline system
  3713. @item alpha
  3714. Draw the text applying alpha blending. The value can
  3715. be either a number between 0.0 and 1.0
  3716. The expression accepts the same variables @var{x, y} do.
  3717. The default value is 1.
  3718. Please see fontcolor_expr
  3719. @item fontsize
  3720. The font size to be used for drawing text.
  3721. The default value of @var{fontsize} is 16.
  3722. @item text_shaping
  3723. If set to 1, attempt to shape the text (for example, reverse the order of
  3724. right-to-left text and join Arabic characters) before drawing it.
  3725. Otherwise, just draw the text exactly as given.
  3726. By default 1 (if supported).
  3727. @item ft_load_flags
  3728. The flags to be used for loading the fonts.
  3729. The flags map the corresponding flags supported by libfreetype, and are
  3730. a combination of the following values:
  3731. @table @var
  3732. @item default
  3733. @item no_scale
  3734. @item no_hinting
  3735. @item render
  3736. @item no_bitmap
  3737. @item vertical_layout
  3738. @item force_autohint
  3739. @item crop_bitmap
  3740. @item pedantic
  3741. @item ignore_global_advance_width
  3742. @item no_recurse
  3743. @item ignore_transform
  3744. @item monochrome
  3745. @item linear_design
  3746. @item no_autohint
  3747. @end table
  3748. Default value is "default".
  3749. For more information consult the documentation for the FT_LOAD_*
  3750. libfreetype flags.
  3751. @item shadowcolor
  3752. The color to be used for drawing a shadow behind the drawn text. For the
  3753. syntax of this option, check the "Color" section in the ffmpeg-utils manual.
  3754. The default value of @var{shadowcolor} is "black".
  3755. @item shadowx
  3756. @item shadowy
  3757. The x and y offsets for the text shadow position with respect to the
  3758. position of the text. They can be either positive or negative
  3759. values. The default value for both is "0".
  3760. @item start_number
  3761. The starting frame number for the n/frame_num variable. The default value
  3762. is "0".
  3763. @item tabsize
  3764. The size in number of spaces to use for rendering the tab.
  3765. Default value is 4.
  3766. @item timecode
  3767. Set the initial timecode representation in "hh:mm:ss[:;.]ff"
  3768. format. It can be used with or without text parameter. @var{timecode_rate}
  3769. option must be specified.
  3770. @item timecode_rate, rate, r
  3771. Set the timecode frame rate (timecode only).
  3772. @item text
  3773. The text string to be drawn. The text must be a sequence of UTF-8
  3774. encoded characters.
  3775. This parameter is mandatory if no file is specified with the parameter
  3776. @var{textfile}.
  3777. @item textfile
  3778. A text file containing text to be drawn. The text must be a sequence
  3779. of UTF-8 encoded characters.
  3780. This parameter is mandatory if no text string is specified with the
  3781. parameter @var{text}.
  3782. If both @var{text} and @var{textfile} are specified, an error is thrown.
  3783. @item reload
  3784. If set to 1, the @var{textfile} will be reloaded before each frame.
  3785. Be sure to update it atomically, or it may be read partially, or even fail.
  3786. @item x
  3787. @item y
  3788. The expressions which specify the offsets where text will be drawn
  3789. within the video frame. They are relative to the top/left border of the
  3790. output image.
  3791. The default value of @var{x} and @var{y} is "0".
  3792. See below for the list of accepted constants and functions.
  3793. @end table
  3794. The parameters for @var{x} and @var{y} are expressions containing the
  3795. following constants and functions:
  3796. @table @option
  3797. @item dar
  3798. input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
  3799. @item hsub
  3800. @item vsub
  3801. horizontal and vertical chroma subsample values. For example for the
  3802. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  3803. @item line_h, lh
  3804. the height of each text line
  3805. @item main_h, h, H
  3806. the input height
  3807. @item main_w, w, W
  3808. the input width
  3809. @item max_glyph_a, ascent
  3810. the maximum distance from the baseline to the highest/upper grid
  3811. coordinate used to place a glyph outline point, for all the rendered
  3812. glyphs.
  3813. It is a positive value, due to the grid's orientation with the Y axis
  3814. upwards.
  3815. @item max_glyph_d, descent
  3816. the maximum distance from the baseline to the lowest grid coordinate
  3817. used to place a glyph outline point, for all the rendered glyphs.
  3818. This is a negative value, due to the grid's orientation, with the Y axis
  3819. upwards.
  3820. @item max_glyph_h
  3821. maximum glyph height, that is the maximum height for all the glyphs
  3822. contained in the rendered text, it is equivalent to @var{ascent} -
  3823. @var{descent}.
  3824. @item max_glyph_w
  3825. maximum glyph width, that is the maximum width for all the glyphs
  3826. contained in the rendered text
  3827. @item n
  3828. the number of input frame, starting from 0
  3829. @item rand(min, max)
  3830. return a random number included between @var{min} and @var{max}
  3831. @item sar
  3832. The input sample aspect ratio.
  3833. @item t
  3834. timestamp expressed in seconds, NAN if the input timestamp is unknown
  3835. @item text_h, th
  3836. the height of the rendered text
  3837. @item text_w, tw
  3838. the width of the rendered text
  3839. @item x
  3840. @item y
  3841. the x and y offset coordinates where the text is drawn.
  3842. These parameters allow the @var{x} and @var{y} expressions to refer
  3843. each other, so you can for example specify @code{y=x/dar}.
  3844. @end table
  3845. @anchor{drawtext_expansion}
  3846. @subsection Text expansion
  3847. If @option{expansion} is set to @code{strftime},
  3848. the filter recognizes strftime() sequences in the provided text and
  3849. expands them accordingly. Check the documentation of strftime(). This
  3850. feature is deprecated.
  3851. If @option{expansion} is set to @code{none}, the text is printed verbatim.
  3852. If @option{expansion} is set to @code{normal} (which is the default),
  3853. the following expansion mechanism is used.
  3854. The backslash character @samp{\}, followed by any character, always expands to
  3855. the second character.
  3856. Sequence of the form @code{%@{...@}} are expanded. The text between the
  3857. braces is a function name, possibly followed by arguments separated by ':'.
  3858. If the arguments contain special characters or delimiters (':' or '@}'),
  3859. they should be escaped.
  3860. Note that they probably must also be escaped as the value for the
  3861. @option{text} option in the filter argument string and as the filter
  3862. argument in the filtergraph description, and possibly also for the shell,
  3863. that makes up to four levels of escaping; using a text file avoids these
  3864. problems.
  3865. The following functions are available:
  3866. @table @command
  3867. @item expr, e
  3868. The expression evaluation result.
  3869. It must take one argument specifying the expression to be evaluated,
  3870. which accepts the same constants and functions as the @var{x} and
  3871. @var{y} values. Note that not all constants should be used, for
  3872. example the text size is not known when evaluating the expression, so
  3873. the constants @var{text_w} and @var{text_h} will have an undefined
  3874. value.
  3875. @item expr_int_format, eif
  3876. Evaluate the expression's value and output as formatted integer.
  3877. The first argument is the expression to be evaluated, just as for the @var{expr} function.
  3878. The second argument specifies the output format. Allowed values are @samp{x},
  3879. @samp{X}, @samp{d} and @samp{u}. They are treated exactly as in the
  3880. @code{printf} function.
  3881. The third parameter is optional and sets the number of positions taken by the output.
  3882. It can be used to add padding with zeros from the left.
  3883. @item gmtime
  3884. The time at which the filter is running, expressed in UTC.
  3885. It can accept an argument: a strftime() format string.
  3886. @item localtime
  3887. The time at which the filter is running, expressed in the local time zone.
  3888. It can accept an argument: a strftime() format string.
  3889. @item metadata
  3890. Frame metadata. It must take one argument specifying metadata key.
  3891. @item n, frame_num
  3892. The frame number, starting from 0.
  3893. @item pict_type
  3894. A 1 character description of the current picture type.
  3895. @item pts
  3896. The timestamp of the current frame.
  3897. It can take up to two arguments.
  3898. The first argument is the format of the timestamp; it defaults to @code{flt}
  3899. for seconds as a decimal number with microsecond accuracy; @code{hms} stands
  3900. for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy.
  3901. The second argument is an offset added to the timestamp.
  3902. @end table
  3903. @subsection Examples
  3904. @itemize
  3905. @item
  3906. Draw "Test Text" with font FreeSerif, using the default values for the
  3907. optional parameters.
  3908. @example
  3909. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'"
  3910. @end example
  3911. @item
  3912. Draw 'Test Text' with font FreeSerif of size 24 at position x=100
  3913. and y=50 (counting from the top-left corner of the screen), text is
  3914. yellow with a red box around it. Both the text and the box have an
  3915. opacity of 20%.
  3916. @example
  3917. drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text':\
  3918. x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: box=1: boxcolor=red@@0.2"
  3919. @end example
  3920. Note that the double quotes are not necessary if spaces are not used
  3921. within the parameter list.
  3922. @item
  3923. Show the text at the center of the video frame:
  3924. @example
  3925. drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
  3926. @end example
  3927. @item
  3928. Show a text line sliding from right to left in the last row of the video
  3929. frame. The file @file{LONG_LINE} is assumed to contain a single line
  3930. with no newlines.
  3931. @example
  3932. drawtext="fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t"
  3933. @end example
  3934. @item
  3935. Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
  3936. @example
  3937. drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
  3938. @end example
  3939. @item
  3940. Draw a single green letter "g", at the center of the input video.
  3941. The glyph baseline is placed at half screen height.
  3942. @example
  3943. drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent"
  3944. @end example
  3945. @item
  3946. Show text for 1 second every 3 seconds:
  3947. @example
  3948. drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
  3949. @end example
  3950. @item
  3951. Use fontconfig to set the font. Note that the colons need to be escaped.
  3952. @example
  3953. drawtext='fontfile=Linux Libertine O-40\:style=Semibold:text=FFmpeg'
  3954. @end example
  3955. @item
  3956. Print the date of a real-time encoding (see strftime(3)):
  3957. @example
  3958. drawtext='fontfile=FreeSans.ttf:text=%@{localtime\:%a %b %d %Y@}'
  3959. @end example
  3960. @item
  3961. Show text fading in and out (appearing/disappearing):
  3962. @example
  3963. #!/bin/sh
  3964. DS=1.0 # display start
  3965. DE=10.0 # display end
  3966. FID=1.5 # fade in duration
  3967. FOD=5 # fade out duration
  3968. 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 @}"
  3969. @end example
  3970. @end itemize
  3971. For more information about libfreetype, check:
  3972. @url{http://www.freetype.org/}.
  3973. For more information about fontconfig, check:
  3974. @url{http://freedesktop.org/software/fontconfig/fontconfig-user.html}.
  3975. For more information about libfribidi, check:
  3976. @url{http://fribidi.org/}.
  3977. @section edgedetect
  3978. Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
  3979. The filter accepts the following options:
  3980. @table @option
  3981. @item low
  3982. @item high
  3983. Set low and high threshold values used by the Canny thresholding
  3984. algorithm.
  3985. The high threshold selects the "strong" edge pixels, which are then
  3986. connected through 8-connectivity with the "weak" edge pixels selected
  3987. by the low threshold.
  3988. @var{low} and @var{high} threshold values must be chosen in the range
  3989. [0,1], and @var{low} should be lesser or equal to @var{high}.
  3990. Default value for @var{low} is @code{20/255}, and default value for @var{high}
  3991. is @code{50/255}.
  3992. @item mode
  3993. Define the drawing mode.
  3994. @table @samp
  3995. @item wires
  3996. Draw white/gray wires on black background.
  3997. @item colormix
  3998. Mix the colors to create a paint/cartoon effect.
  3999. @end table
  4000. Default value is @var{wires}.
  4001. @end table
  4002. @subsection Examples
  4003. @itemize
  4004. @item
  4005. Standard edge detection with custom values for the hysteresis thresholding:
  4006. @example
  4007. edgedetect=low=0.1:high=0.4
  4008. @end example
  4009. @item
  4010. Painting effect without thresholding:
  4011. @example
  4012. edgedetect=mode=colormix:high=0
  4013. @end example
  4014. @end itemize
  4015. @section eq
  4016. Set brightness, contrast, saturation and approximate gamma adjustment.
  4017. The filter accepts the following options:
  4018. @table @option
  4019. @item contrast
  4020. Set the contrast expression. The value must be a float value in range
  4021. @code{-2.0} to @code{2.0}. The default value is "0".
  4022. @item brightness
  4023. Set the brightness expression. The value must be a float value in
  4024. range @code{-1.0} to @code{1.0}. The default value is "0".
  4025. @item saturation
  4026. Set the saturation expression. The value must be a float in
  4027. range @code{0.0} to @code{3.0}. The default value is "1".
  4028. @item gamma
  4029. Set the gamma expression. The value must be a float in range
  4030. @code{0.1} to @code{10.0}. The default value is "1".
  4031. @item gamma_r
  4032. Set the gamma expression for red. The value must be a float in
  4033. range @code{0.1} to @code{10.0}. The default value is "1".
  4034. @item gamma_g
  4035. Set the gamma expression for green. The value must be a float in range
  4036. @code{0.1} to @code{10.0}. The default value is "1".
  4037. @item gamma_b
  4038. Set the gamma expression for blue. The value must be a float in range
  4039. @code{0.1} to @code{10.0}. The default value is "1".
  4040. @item gamma_weight
  4041. Set the gamma weight expression. It can be used to reduce the effect
  4042. of a high gamma value on bright image areas, e.g. keep them from
  4043. getting overamplified and just plain white. The value must be a float
  4044. in range @code{0.0} to @code{1.0}. A value of @code{0.0} turns the
  4045. gamma correction all the way down while @code{1.0} leaves it at its
  4046. full strength. Default is "1".
  4047. @item eval
  4048. Set when the expressions for brightness, contrast, saturation and
  4049. gamma expressions are evaluated.
  4050. It accepts the following values:
  4051. @table @samp
  4052. @item init
  4053. only evaluate expressions once during the filter initialization or
  4054. when a command is processed
  4055. @item frame
  4056. evaluate expressions for each incoming frame
  4057. @end table
  4058. Default value is @samp{init}.
  4059. @end table
  4060. The expressions accept the following parameters:
  4061. @table @option
  4062. @item n
  4063. frame count of the input frame starting from 0
  4064. @item pos
  4065. byte position of the corresponding packet in the input file, NAN if
  4066. unspecified
  4067. @item r
  4068. frame rate of the input video, NAN if the input frame rate is unknown
  4069. @item t
  4070. timestamp expressed in seconds, NAN if the input timestamp is unknown
  4071. @end table
  4072. @subsection Commands
  4073. The filter supports the following commands:
  4074. @table @option
  4075. @item contrast
  4076. Set the contrast expression.
  4077. @item brightness
  4078. Set the brightness expression.
  4079. @item saturation
  4080. Set the saturation expression.
  4081. @item gamma
  4082. Set the gamma expression.
  4083. @item gamma_r
  4084. Set the gamma_r expression.
  4085. @item gamma_g
  4086. Set gamma_g expression.
  4087. @item gamma_b
  4088. Set gamma_b expression.
  4089. @item gamma_weight
  4090. Set gamma_weight expression.
  4091. The command accepts the same syntax of the corresponding option.
  4092. If the specified expression is not valid, it is kept at its current
  4093. value.
  4094. @end table
  4095. @section erosion
  4096. Apply erosion effect to the video.
  4097. This filter replaces the pixel by the local(3x3) minimum.
  4098. It accepts the following options:
  4099. @table @option
  4100. @item threshold0
  4101. @item threshold1
  4102. @item threshold2
  4103. @item threshold3
  4104. Allows to limit the maximum change for each plane, default is 65535.
  4105. If 0, plane will remain unchanged.
  4106. @item coordinates
  4107. Flag which specifies the pixel to refer to. Default is 255 i.e. all eight
  4108. pixels are used.
  4109. Flags to local 3x3 coordinates maps like this:
  4110. 1 2 3
  4111. 4 5
  4112. 6 7 8
  4113. @end table
  4114. @section extractplanes
  4115. Extract color channel components from input video stream into
  4116. separate grayscale video streams.
  4117. The filter accepts the following option:
  4118. @table @option
  4119. @item planes
  4120. Set plane(s) to extract.
  4121. Available values for planes are:
  4122. @table @samp
  4123. @item y
  4124. @item u
  4125. @item v
  4126. @item a
  4127. @item r
  4128. @item g
  4129. @item b
  4130. @end table
  4131. Choosing planes not available in the input will result in an error.
  4132. That means you cannot select @code{r}, @code{g}, @code{b} planes
  4133. with @code{y}, @code{u}, @code{v} planes at same time.
  4134. @end table
  4135. @subsection Examples
  4136. @itemize
  4137. @item
  4138. Extract luma, u and v color channel component from input video frame
  4139. into 3 grayscale outputs:
  4140. @example
  4141. 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
  4142. @end example
  4143. @end itemize
  4144. @section elbg
  4145. Apply a posterize effect using the ELBG (Enhanced LBG) algorithm.
  4146. For each input image, the filter will compute the optimal mapping from
  4147. the input to the output given the codebook length, that is the number
  4148. of distinct output colors.
  4149. This filter accepts the following options.
  4150. @table @option
  4151. @item codebook_length, l
  4152. Set codebook length. The value must be a positive integer, and
  4153. represents the number of distinct output colors. Default value is 256.
  4154. @item nb_steps, n
  4155. Set the maximum number of iterations to apply for computing the optimal
  4156. mapping. The higher the value the better the result and the higher the
  4157. computation time. Default value is 1.
  4158. @item seed, s
  4159. Set a random seed, must be an integer included between 0 and
  4160. UINT32_MAX. If not specified, or if explicitly set to -1, the filter
  4161. will try to use a good random seed on a best effort basis.
  4162. @item pal8
  4163. Set pal8 output pixel format. This option does not work with codebook
  4164. length greater than 256.
  4165. @end table
  4166. @section fade
  4167. Apply a fade-in/out effect to the input video.
  4168. It accepts the following parameters:
  4169. @table @option
  4170. @item type, t
  4171. The effect type can be either "in" for a fade-in, or "out" for a fade-out
  4172. effect.
  4173. Default is @code{in}.
  4174. @item start_frame, s
  4175. Specify the number of the frame to start applying the fade
  4176. effect at. Default is 0.
  4177. @item nb_frames, n
  4178. The number of frames that the fade effect lasts. At the end of the
  4179. fade-in effect, the output video will have the same intensity as the input video.
  4180. At the end of the fade-out transition, the output video will be filled with the
  4181. selected @option{color}.
  4182. Default is 25.
  4183. @item alpha
  4184. If set to 1, fade only alpha channel, if one exists on the input.
  4185. Default value is 0.
  4186. @item start_time, st
  4187. Specify the timestamp (in seconds) of the frame to start to apply the fade
  4188. effect. If both start_frame and start_time are specified, the fade will start at
  4189. whichever comes last. Default is 0.
  4190. @item duration, d
  4191. The number of seconds for which the fade effect has to last. At the end of the
  4192. fade-in effect the output video will have the same intensity as the input video,
  4193. at the end of the fade-out transition the output video will be filled with the
  4194. selected @option{color}.
  4195. If both duration and nb_frames are specified, duration is used. Default is 0
  4196. (nb_frames is used by default).
  4197. @item color, c
  4198. Specify the color of the fade. Default is "black".
  4199. @end table
  4200. @subsection Examples
  4201. @itemize
  4202. @item
  4203. Fade in the first 30 frames of video:
  4204. @example
  4205. fade=in:0:30
  4206. @end example
  4207. The command above is equivalent to:
  4208. @example
  4209. fade=t=in:s=0:n=30
  4210. @end example
  4211. @item
  4212. Fade out the last 45 frames of a 200-frame video:
  4213. @example
  4214. fade=out:155:45
  4215. fade=type=out:start_frame=155:nb_frames=45
  4216. @end example
  4217. @item
  4218. Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video:
  4219. @example
  4220. fade=in:0:25, fade=out:975:25
  4221. @end example
  4222. @item
  4223. Make the first 5 frames yellow, then fade in from frame 5-24:
  4224. @example
  4225. fade=in:5:20:color=yellow
  4226. @end example
  4227. @item
  4228. Fade in alpha over first 25 frames of video:
  4229. @example
  4230. fade=in:0:25:alpha=1
  4231. @end example
  4232. @item
  4233. Make the first 5.5 seconds black, then fade in for 0.5 seconds:
  4234. @example
  4235. fade=t=in:st=5.5:d=0.5
  4236. @end example
  4237. @end itemize
  4238. @section fftfilt
  4239. Apply arbitrary expressions to samples in frequency domain
  4240. @table @option
  4241. @item dc_Y
  4242. Adjust the dc value (gain) of the luma plane of the image. The filter
  4243. accepts an integer value in range @code{0} to @code{1000}. The default
  4244. value is set to @code{0}.
  4245. @item dc_U
  4246. Adjust the dc value (gain) of the 1st chroma plane of the image. The
  4247. filter accepts an integer value in range @code{0} to @code{1000}. The
  4248. default value is set to @code{0}.
  4249. @item dc_V
  4250. Adjust the dc value (gain) of the 2nd chroma plane of the image. The
  4251. filter accepts an integer value in range @code{0} to @code{1000}. The
  4252. default value is set to @code{0}.
  4253. @item weight_Y
  4254. Set the frequency domain weight expression for the luma plane.
  4255. @item weight_U
  4256. Set the frequency domain weight expression for the 1st chroma plane.
  4257. @item weight_V
  4258. Set the frequency domain weight expression for the 2nd chroma plane.
  4259. The filter accepts the following variables:
  4260. @item X
  4261. @item Y
  4262. The coordinates of the current sample.
  4263. @item W
  4264. @item H
  4265. The width and height of the image.
  4266. @end table
  4267. @subsection Examples
  4268. @itemize
  4269. @item
  4270. High-pass:
  4271. @example
  4272. fftfilt=dc_Y=128:weight_Y='squish(1-(Y+X)/100)'
  4273. @end example
  4274. @item
  4275. Low-pass:
  4276. @example
  4277. fftfilt=dc_Y=0:weight_Y='squish((Y+X)/100-1)'
  4278. @end example
  4279. @item
  4280. Sharpen:
  4281. @example
  4282. fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)'
  4283. @end example
  4284. @end itemize
  4285. @section field
  4286. Extract a single field from an interlaced image using stride
  4287. arithmetic to avoid wasting CPU time. The output frames are marked as
  4288. non-interlaced.
  4289. The filter accepts the following options:
  4290. @table @option
  4291. @item type
  4292. Specify whether to extract the top (if the value is @code{0} or
  4293. @code{top}) or the bottom field (if the value is @code{1} or
  4294. @code{bottom}).
  4295. @end table
  4296. @section fieldmatch
  4297. Field matching filter for inverse telecine. It is meant to reconstruct the
  4298. progressive frames from a telecined stream. The filter does not drop duplicated
  4299. frames, so to achieve a complete inverse telecine @code{fieldmatch} needs to be
  4300. followed by a decimation filter such as @ref{decimate} in the filtergraph.
  4301. The separation of the field matching and the decimation is notably motivated by
  4302. the possibility of inserting a de-interlacing filter fallback between the two.
  4303. If the source has mixed telecined and real interlaced content,
  4304. @code{fieldmatch} will not be able to match fields for the interlaced parts.
  4305. But these remaining combed frames will be marked as interlaced, and thus can be
  4306. de-interlaced by a later filter such as @ref{yadif} before decimation.
  4307. In addition to the various configuration options, @code{fieldmatch} can take an
  4308. optional second stream, activated through the @option{ppsrc} option. If
  4309. enabled, the frames reconstruction will be based on the fields and frames from
  4310. this second stream. This allows the first input to be pre-processed in order to
  4311. help the various algorithms of the filter, while keeping the output lossless
  4312. (assuming the fields are matched properly). Typically, a field-aware denoiser,
  4313. or brightness/contrast adjustments can help.
  4314. Note that this filter uses the same algorithms as TIVTC/TFM (AviSynth project)
  4315. and VIVTC/VFM (VapourSynth project). The later is a light clone of TFM from
  4316. which @code{fieldmatch} is based on. While the semantic and usage are very
  4317. close, some behaviour and options names can differ.
  4318. The @ref{decimate} filter currently only works for constant frame rate input.
  4319. If your input has mixed telecined (30fps) and progressive content with a lower
  4320. framerate like 24fps use the following filterchain to produce the necessary cfr
  4321. stream: @code{dejudder,fps=30000/1001,fieldmatch,decimate}.
  4322. The filter accepts the following options:
  4323. @table @option
  4324. @item order
  4325. Specify the assumed field order of the input stream. Available values are:
  4326. @table @samp
  4327. @item auto
  4328. Auto detect parity (use FFmpeg's internal parity value).
  4329. @item bff
  4330. Assume bottom field first.
  4331. @item tff
  4332. Assume top field first.
  4333. @end table
  4334. Note that it is sometimes recommended not to trust the parity announced by the
  4335. stream.
  4336. Default value is @var{auto}.
  4337. @item mode
  4338. Set the matching mode or strategy to use. @option{pc} mode is the safest in the
  4339. sense that it won't risk creating jerkiness due to duplicate frames when
  4340. possible, but if there are bad edits or blended fields it will end up
  4341. outputting combed frames when a good match might actually exist. On the other
  4342. hand, @option{pcn_ub} mode is the most risky in terms of creating jerkiness,
  4343. but will almost always find a good frame if there is one. The other values are
  4344. all somewhere in between @option{pc} and @option{pcn_ub} in terms of risking
  4345. jerkiness and creating duplicate frames versus finding good matches in sections
  4346. with bad edits, orphaned fields, blended fields, etc.
  4347. More details about p/c/n/u/b are available in @ref{p/c/n/u/b meaning} section.
  4348. Available values are:
  4349. @table @samp
  4350. @item pc
  4351. 2-way matching (p/c)
  4352. @item pc_n
  4353. 2-way matching, and trying 3rd match if still combed (p/c + n)
  4354. @item pc_u
  4355. 2-way matching, and trying 3rd match (same order) if still combed (p/c + u)
  4356. @item pc_n_ub
  4357. 2-way matching, trying 3rd match if still combed, and trying 4th/5th matches if
  4358. still combed (p/c + n + u/b)
  4359. @item pcn
  4360. 3-way matching (p/c/n)
  4361. @item pcn_ub
  4362. 3-way matching, and trying 4th/5th matches if all 3 of the original matches are
  4363. detected as combed (p/c/n + u/b)
  4364. @end table
  4365. The parenthesis at the end indicate the matches that would be used for that
  4366. mode assuming @option{order}=@var{tff} (and @option{field} on @var{auto} or
  4367. @var{top}).
  4368. In terms of speed @option{pc} mode is by far the fastest and @option{pcn_ub} is
  4369. the slowest.
  4370. Default value is @var{pc_n}.
  4371. @item ppsrc
  4372. Mark the main input stream as a pre-processed input, and enable the secondary
  4373. input stream as the clean source to pick the fields from. See the filter
  4374. introduction for more details. It is similar to the @option{clip2} feature from
  4375. VFM/TFM.
  4376. Default value is @code{0} (disabled).
  4377. @item field
  4378. Set the field to match from. It is recommended to set this to the same value as
  4379. @option{order} unless you experience matching failures with that setting. In
  4380. certain circumstances changing the field that is used to match from can have a
  4381. large impact on matching performance. Available values are:
  4382. @table @samp
  4383. @item auto
  4384. Automatic (same value as @option{order}).
  4385. @item bottom
  4386. Match from the bottom field.
  4387. @item top
  4388. Match from the top field.
  4389. @end table
  4390. Default value is @var{auto}.
  4391. @item mchroma
  4392. Set whether or not chroma is included during the match comparisons. In most
  4393. cases it is recommended to leave this enabled. You should set this to @code{0}
  4394. only if your clip has bad chroma problems such as heavy rainbowing or other
  4395. artifacts. Setting this to @code{0} could also be used to speed things up at
  4396. the cost of some accuracy.
  4397. Default value is @code{1}.
  4398. @item y0
  4399. @item y1
  4400. These define an exclusion band which excludes the lines between @option{y0} and
  4401. @option{y1} from being included in the field matching decision. An exclusion
  4402. band can be used to ignore subtitles, a logo, or other things that may
  4403. interfere with the matching. @option{y0} sets the starting scan line and
  4404. @option{y1} sets the ending line; all lines in between @option{y0} and
  4405. @option{y1} (including @option{y0} and @option{y1}) will be ignored. Setting
  4406. @option{y0} and @option{y1} to the same value will disable the feature.
  4407. @option{y0} and @option{y1} defaults to @code{0}.
  4408. @item scthresh
  4409. Set the scene change detection threshold as a percentage of maximum change on
  4410. the luma plane. Good values are in the @code{[8.0, 14.0]} range. Scene change
  4411. detection is only relevant in case @option{combmatch}=@var{sc}. The range for
  4412. @option{scthresh} is @code{[0.0, 100.0]}.
  4413. Default value is @code{12.0}.
  4414. @item combmatch
  4415. When @option{combatch} is not @var{none}, @code{fieldmatch} will take into
  4416. account the combed scores of matches when deciding what match to use as the
  4417. final match. Available values are:
  4418. @table @samp
  4419. @item none
  4420. No final matching based on combed scores.
  4421. @item sc
  4422. Combed scores are only used when a scene change is detected.
  4423. @item full
  4424. Use combed scores all the time.
  4425. @end table
  4426. Default is @var{sc}.
  4427. @item combdbg
  4428. Force @code{fieldmatch} to calculate the combed metrics for certain matches and
  4429. print them. This setting is known as @option{micout} in TFM/VFM vocabulary.
  4430. Available values are:
  4431. @table @samp
  4432. @item none
  4433. No forced calculation.
  4434. @item pcn
  4435. Force p/c/n calculations.
  4436. @item pcnub
  4437. Force p/c/n/u/b calculations.
  4438. @end table
  4439. Default value is @var{none}.
  4440. @item cthresh
  4441. This is the area combing threshold used for combed frame detection. This
  4442. essentially controls how "strong" or "visible" combing must be to be detected.
  4443. Larger values mean combing must be more visible and smaller values mean combing
  4444. can be less visible or strong and still be detected. Valid settings are from
  4445. @code{-1} (every pixel will be detected as combed) to @code{255} (no pixel will
  4446. be detected as combed). This is basically a pixel difference value. A good
  4447. range is @code{[8, 12]}.
  4448. Default value is @code{9}.
  4449. @item chroma
  4450. Sets whether or not chroma is considered in the combed frame decision. Only
  4451. disable this if your source has chroma problems (rainbowing, etc.) that are
  4452. causing problems for the combed frame detection with chroma enabled. Actually,
  4453. using @option{chroma}=@var{0} is usually more reliable, except for the case
  4454. where there is chroma only combing in the source.
  4455. Default value is @code{0}.
  4456. @item blockx
  4457. @item blocky
  4458. Respectively set the x-axis and y-axis size of the window used during combed
  4459. frame detection. This has to do with the size of the area in which
  4460. @option{combpel} pixels are required to be detected as combed for a frame to be
  4461. declared combed. See the @option{combpel} parameter description for more info.
  4462. Possible values are any number that is a power of 2 starting at 4 and going up
  4463. to 512.
  4464. Default value is @code{16}.
  4465. @item combpel
  4466. The number of combed pixels inside any of the @option{blocky} by
  4467. @option{blockx} size blocks on the frame for the frame to be detected as
  4468. combed. While @option{cthresh} controls how "visible" the combing must be, this
  4469. setting controls "how much" combing there must be in any localized area (a
  4470. window defined by the @option{blockx} and @option{blocky} settings) on the
  4471. frame. Minimum value is @code{0} and maximum is @code{blocky x blockx} (at
  4472. which point no frames will ever be detected as combed). This setting is known
  4473. as @option{MI} in TFM/VFM vocabulary.
  4474. Default value is @code{80}.
  4475. @end table
  4476. @anchor{p/c/n/u/b meaning}
  4477. @subsection p/c/n/u/b meaning
  4478. @subsubsection p/c/n
  4479. We assume the following telecined stream:
  4480. @example
  4481. Top fields: 1 2 2 3 4
  4482. Bottom fields: 1 2 3 4 4
  4483. @end example
  4484. The numbers correspond to the progressive frame the fields relate to. Here, the
  4485. first two frames are progressive, the 3rd and 4th are combed, and so on.
  4486. When @code{fieldmatch} is configured to run a matching from bottom
  4487. (@option{field}=@var{bottom}) this is how this input stream get transformed:
  4488. @example
  4489. Input stream:
  4490. T 1 2 2 3 4
  4491. B 1 2 3 4 4 <-- matching reference
  4492. Matches: c c n n c
  4493. Output stream:
  4494. T 1 2 3 4 4
  4495. B 1 2 3 4 4
  4496. @end example
  4497. As a result of the field matching, we can see that some frames get duplicated.
  4498. To perform a complete inverse telecine, you need to rely on a decimation filter
  4499. after this operation. See for instance the @ref{decimate} filter.
  4500. The same operation now matching from top fields (@option{field}=@var{top})
  4501. looks like this:
  4502. @example
  4503. Input stream:
  4504. T 1 2 2 3 4 <-- matching reference
  4505. B 1 2 3 4 4
  4506. Matches: c c p p c
  4507. Output stream:
  4508. T 1 2 2 3 4
  4509. B 1 2 2 3 4
  4510. @end example
  4511. In these examples, we can see what @var{p}, @var{c} and @var{n} mean;
  4512. basically, they refer to the frame and field of the opposite parity:
  4513. @itemize
  4514. @item @var{p} matches the field of the opposite parity in the previous frame
  4515. @item @var{c} matches the field of the opposite parity in the current frame
  4516. @item @var{n} matches the field of the opposite parity in the next frame
  4517. @end itemize
  4518. @subsubsection u/b
  4519. The @var{u} and @var{b} matching are a bit special in the sense that they match
  4520. from the opposite parity flag. In the following examples, we assume that we are
  4521. currently matching the 2nd frame (Top:2, bottom:2). According to the match, a
  4522. 'x' is placed above and below each matched fields.
  4523. With bottom matching (@option{field}=@var{bottom}):
  4524. @example
  4525. Match: c p n b u
  4526. x x x x x
  4527. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  4528. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  4529. x x x x x
  4530. Output frames:
  4531. 2 1 2 2 2
  4532. 2 2 2 1 3
  4533. @end example
  4534. With top matching (@option{field}=@var{top}):
  4535. @example
  4536. Match: c p n b u
  4537. x x x x x
  4538. Top 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2
  4539. Bottom 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
  4540. x x x x x
  4541. Output frames:
  4542. 2 2 2 1 2
  4543. 2 1 3 2 2
  4544. @end example
  4545. @subsection Examples
  4546. Simple IVTC of a top field first telecined stream:
  4547. @example
  4548. fieldmatch=order=tff:combmatch=none, decimate
  4549. @end example
  4550. Advanced IVTC, with fallback on @ref{yadif} for still combed frames:
  4551. @example
  4552. fieldmatch=order=tff:combmatch=full, yadif=deint=interlaced, decimate
  4553. @end example
  4554. @section fieldorder
  4555. Transform the field order of the input video.
  4556. It accepts the following parameters:
  4557. @table @option
  4558. @item order
  4559. The output field order. Valid values are @var{tff} for top field first or @var{bff}
  4560. for bottom field first.
  4561. @end table
  4562. The default value is @samp{tff}.
  4563. The transformation is done by shifting the picture content up or down
  4564. by one line, and filling the remaining line with appropriate picture content.
  4565. This method is consistent with most broadcast field order converters.
  4566. If the input video is not flagged as being interlaced, or it is already
  4567. flagged as being of the required output field order, then this filter does
  4568. not alter the incoming video.
  4569. It is very useful when converting to or from PAL DV material,
  4570. which is bottom field first.
  4571. For example:
  4572. @example
  4573. ffmpeg -i in.vob -vf "fieldorder=bff" out.dv
  4574. @end example
  4575. @section fifo
  4576. Buffer input images and send them when they are requested.
  4577. It is mainly useful when auto-inserted by the libavfilter
  4578. framework.
  4579. It does not take parameters.
  4580. @section find_rect
  4581. Find a rectangular object
  4582. It accepts the following options:
  4583. @table @option
  4584. @item object
  4585. Filepath of the object image, needs to be in gray8.
  4586. @item threshold
  4587. Detection threshold, default is 0.5.
  4588. @item mipmaps
  4589. Number of mipmaps, default is 3.
  4590. @item xmin, ymin, xmax, ymax
  4591. Specifies the rectangle in which to search.
  4592. @end table
  4593. @subsection Examples
  4594. @itemize
  4595. @item
  4596. Generate a representative palette of a given video using @command{ffmpeg}:
  4597. @example
  4598. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  4599. @end example
  4600. @end itemize
  4601. @section cover_rect
  4602. Cover a rectangular object
  4603. It accepts the following options:
  4604. @table @option
  4605. @item cover
  4606. Filepath of the optional cover image, needs to be in yuv420.
  4607. @item mode
  4608. Set covering mode.
  4609. It accepts the following values:
  4610. @table @samp
  4611. @item cover
  4612. cover it by the supplied image
  4613. @item blur
  4614. cover it by interpolating the surrounding pixels
  4615. @end table
  4616. Default value is @var{blur}.
  4617. @end table
  4618. @subsection Examples
  4619. @itemize
  4620. @item
  4621. Generate a representative palette of a given video using @command{ffmpeg}:
  4622. @example
  4623. ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover new.mkv
  4624. @end example
  4625. @end itemize
  4626. @anchor{format}
  4627. @section format
  4628. Convert the input video to one of the specified pixel formats.
  4629. Libavfilter will try to pick one that is suitable as input to
  4630. the next filter.
  4631. It accepts the following parameters:
  4632. @table @option
  4633. @item pix_fmts
  4634. A '|'-separated list of pixel format names, such as
  4635. "pix_fmts=yuv420p|monow|rgb24".
  4636. @end table
  4637. @subsection Examples
  4638. @itemize
  4639. @item
  4640. Convert the input video to the @var{yuv420p} format
  4641. @example
  4642. format=pix_fmts=yuv420p
  4643. @end example
  4644. Convert the input video to any of the formats in the list
  4645. @example
  4646. format=pix_fmts=yuv420p|yuv444p|yuv410p
  4647. @end example
  4648. @end itemize
  4649. @anchor{fps}
  4650. @section fps
  4651. Convert the video to specified constant frame rate by duplicating or dropping
  4652. frames as necessary.
  4653. It accepts the following parameters:
  4654. @table @option
  4655. @item fps
  4656. The desired output frame rate. The default is @code{25}.
  4657. @item round
  4658. Rounding method.
  4659. Possible values are:
  4660. @table @option
  4661. @item zero
  4662. zero round towards 0
  4663. @item inf
  4664. round away from 0
  4665. @item down
  4666. round towards -infinity
  4667. @item up
  4668. round towards +infinity
  4669. @item near
  4670. round to nearest
  4671. @end table
  4672. The default is @code{near}.
  4673. @item start_time
  4674. Assume the first PTS should be the given value, in seconds. This allows for
  4675. padding/trimming at the start of stream. By default, no assumption is made
  4676. about the first frame's expected PTS, so no padding or trimming is done.
  4677. For example, this could be set to 0 to pad the beginning with duplicates of
  4678. the first frame if a video stream starts after the audio stream or to trim any
  4679. frames with a negative PTS.
  4680. @end table
  4681. Alternatively, the options can be specified as a flat string:
  4682. @var{fps}[:@var{round}].
  4683. See also the @ref{setpts} filter.
  4684. @subsection Examples
  4685. @itemize
  4686. @item
  4687. A typical usage in order to set the fps to 25:
  4688. @example
  4689. fps=fps=25
  4690. @end example
  4691. @item
  4692. Sets the fps to 24, using abbreviation and rounding method to round to nearest:
  4693. @example
  4694. fps=fps=film:round=near
  4695. @end example
  4696. @end itemize
  4697. @section framepack
  4698. Pack two different video streams into a stereoscopic video, setting proper
  4699. metadata on supported codecs. The two views should have the same size and
  4700. framerate and processing will stop when the shorter video ends. Please note
  4701. that you may conveniently adjust view properties with the @ref{scale} and
  4702. @ref{fps} filters.
  4703. It accepts the following parameters:
  4704. @table @option
  4705. @item format
  4706. The desired packing format. Supported values are:
  4707. @table @option
  4708. @item sbs
  4709. The views are next to each other (default).
  4710. @item tab
  4711. The views are on top of each other.
  4712. @item lines
  4713. The views are packed by line.
  4714. @item columns
  4715. The views are packed by column.
  4716. @item frameseq
  4717. The views are temporally interleaved.
  4718. @end table
  4719. @end table
  4720. Some examples:
  4721. @example
  4722. # Convert left and right views into a frame-sequential video
  4723. ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT
  4724. # Convert views into a side-by-side video with the same output resolution as the input
  4725. 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
  4726. @end example
  4727. @section framerate
  4728. Change the frame rate by interpolating new video output frames from the source
  4729. frames.
  4730. This filter is not designed to function correctly with interlaced media. If
  4731. you wish to change the frame rate of interlaced media then you are required
  4732. to deinterlace before this filter and re-interlace after this filter.
  4733. A description of the accepted options follows.
  4734. @table @option
  4735. @item fps
  4736. Specify the output frames per second. This option can also be specified
  4737. as a value alone. The default is @code{50}.
  4738. @item interp_start
  4739. Specify the start of a range where the output frame will be created as a
  4740. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  4741. the default is @code{15}.
  4742. @item interp_end
  4743. Specify the end of a range where the output frame will be created as a
  4744. linear interpolation of two frames. The range is [@code{0}-@code{255}],
  4745. the default is @code{240}.
  4746. @item scene
  4747. Specify the level at which a scene change is detected as a value between
  4748. 0 and 100 to indicate a new scene; a low value reflects a low
  4749. probability for the current frame to introduce a new scene, while a higher
  4750. value means the current frame is more likely to be one.
  4751. The default is @code{7}.
  4752. @item flags
  4753. Specify flags influencing the filter process.
  4754. Available value for @var{flags} is:
  4755. @table @option
  4756. @item scene_change_detect, scd
  4757. Enable scene change detection using the value of the option @var{scene}.
  4758. This flag is enabled by default.
  4759. @end table
  4760. @end table
  4761. @section framestep
  4762. Select one frame every N-th frame.
  4763. This filter accepts the following option:
  4764. @table @option
  4765. @item step
  4766. Select frame after every @code{step} frames.
  4767. Allowed values are positive integers higher than 0. Default value is @code{1}.
  4768. @end table
  4769. @anchor{frei0r}
  4770. @section frei0r
  4771. Apply a frei0r effect to the input video.
  4772. To enable the compilation of this filter, you need to install the frei0r
  4773. header and configure FFmpeg with @code{--enable-frei0r}.
  4774. It accepts the following parameters:
  4775. @table @option
  4776. @item filter_name
  4777. The name of the frei0r effect to load. If the environment variable
  4778. @env{FREI0R_PATH} is defined, the frei0r effect is searched for in each of the
  4779. directories specified by the colon-separated list in @env{FREIOR_PATH}.
  4780. Otherwise, the standard frei0r paths are searched, in this order:
  4781. @file{HOME/.frei0r-1/lib/}, @file{/usr/local/lib/frei0r-1/},
  4782. @file{/usr/lib/frei0r-1/}.
  4783. @item filter_params
  4784. A '|'-separated list of parameters to pass to the frei0r effect.
  4785. @end table
  4786. A frei0r effect parameter can be a boolean (its value is either
  4787. "y" or "n"), a double, a color (specified as
  4788. @var{R}/@var{G}/@var{B}, where @var{R}, @var{G}, and @var{B} are floating point
  4789. numbers between 0.0 and 1.0, inclusive) or by a color description specified in the "Color"
  4790. section in the ffmpeg-utils manual), a position (specified as @var{X}/@var{Y}, where
  4791. @var{X} and @var{Y} are floating point numbers) and/or a string.
  4792. The number and types of parameters depend on the loaded effect. If an
  4793. effect parameter is not specified, the default value is set.
  4794. @subsection Examples
  4795. @itemize
  4796. @item
  4797. Apply the distort0r effect, setting the first two double parameters:
  4798. @example
  4799. frei0r=filter_name=distort0r:filter_params=0.5|0.01
  4800. @end example
  4801. @item
  4802. Apply the colordistance effect, taking a color as the first parameter:
  4803. @example
  4804. frei0r=colordistance:0.2/0.3/0.4
  4805. frei0r=colordistance:violet
  4806. frei0r=colordistance:0x112233
  4807. @end example
  4808. @item
  4809. Apply the perspective effect, specifying the top left and top right image
  4810. positions:
  4811. @example
  4812. frei0r=perspective:0.2/0.2|0.8/0.2
  4813. @end example
  4814. @end itemize
  4815. For more information, see
  4816. @url{http://frei0r.dyne.org}
  4817. @section fspp
  4818. Apply fast and simple postprocessing. It is a faster version of @ref{spp}.
  4819. It splits (I)DCT into horizontal/vertical passes. Unlike the simple post-
  4820. processing filter, one of them is performed once per block, not per pixel.
  4821. This allows for much higher speed.
  4822. The filter accepts the following options:
  4823. @table @option
  4824. @item quality
  4825. Set quality. This option defines the number of levels for averaging. It accepts
  4826. an integer in the range 4-5. Default value is @code{4}.
  4827. @item qp
  4828. Force a constant quantization parameter. It accepts an integer in range 0-63.
  4829. If not set, the filter will use the QP from the video stream (if available).
  4830. @item strength
  4831. Set filter strength. It accepts an integer in range -15 to 32. Lower values mean
  4832. more details but also more artifacts, while higher values make the image smoother
  4833. but also blurrier. Default value is @code{0} − PSNR optimal.
  4834. @item use_bframe_qp
  4835. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  4836. option may cause flicker since the B-Frames have often larger QP. Default is
  4837. @code{0} (not enabled).
  4838. @end table
  4839. @section geq
  4840. The filter accepts the following options:
  4841. @table @option
  4842. @item lum_expr, lum
  4843. Set the luminance expression.
  4844. @item cb_expr, cb
  4845. Set the chrominance blue expression.
  4846. @item cr_expr, cr
  4847. Set the chrominance red expression.
  4848. @item alpha_expr, a
  4849. Set the alpha expression.
  4850. @item red_expr, r
  4851. Set the red expression.
  4852. @item green_expr, g
  4853. Set the green expression.
  4854. @item blue_expr, b
  4855. Set the blue expression.
  4856. @end table
  4857. The colorspace is selected according to the specified options. If one
  4858. of the @option{lum_expr}, @option{cb_expr}, or @option{cr_expr}
  4859. options is specified, the filter will automatically select a YCbCr
  4860. colorspace. If one of the @option{red_expr}, @option{green_expr}, or
  4861. @option{blue_expr} options is specified, it will select an RGB
  4862. colorspace.
  4863. If one of the chrominance expression is not defined, it falls back on the other
  4864. one. If no alpha expression is specified it will evaluate to opaque value.
  4865. If none of chrominance expressions are specified, they will evaluate
  4866. to the luminance expression.
  4867. The expressions can use the following variables and functions:
  4868. @table @option
  4869. @item N
  4870. The sequential number of the filtered frame, starting from @code{0}.
  4871. @item X
  4872. @item Y
  4873. The coordinates of the current sample.
  4874. @item W
  4875. @item H
  4876. The width and height of the image.
  4877. @item SW
  4878. @item SH
  4879. Width and height scale depending on the currently filtered plane. It is the
  4880. ratio between the corresponding luma plane number of pixels and the current
  4881. plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
  4882. @code{0.5,0.5} for chroma planes.
  4883. @item T
  4884. Time of the current frame, expressed in seconds.
  4885. @item p(x, y)
  4886. Return the value of the pixel at location (@var{x},@var{y}) of the current
  4887. plane.
  4888. @item lum(x, y)
  4889. Return the value of the pixel at location (@var{x},@var{y}) of the luminance
  4890. plane.
  4891. @item cb(x, y)
  4892. Return the value of the pixel at location (@var{x},@var{y}) of the
  4893. blue-difference chroma plane. Return 0 if there is no such plane.
  4894. @item cr(x, y)
  4895. Return the value of the pixel at location (@var{x},@var{y}) of the
  4896. red-difference chroma plane. Return 0 if there is no such plane.
  4897. @item r(x, y)
  4898. @item g(x, y)
  4899. @item b(x, y)
  4900. Return the value of the pixel at location (@var{x},@var{y}) of the
  4901. red/green/blue component. Return 0 if there is no such component.
  4902. @item alpha(x, y)
  4903. Return the value of the pixel at location (@var{x},@var{y}) of the alpha
  4904. plane. Return 0 if there is no such plane.
  4905. @end table
  4906. For functions, if @var{x} and @var{y} are outside the area, the value will be
  4907. automatically clipped to the closer edge.
  4908. @subsection Examples
  4909. @itemize
  4910. @item
  4911. Flip the image horizontally:
  4912. @example
  4913. geq=p(W-X\,Y)
  4914. @end example
  4915. @item
  4916. Generate a bidimensional sine wave, with angle @code{PI/3} and a
  4917. wavelength of 100 pixels:
  4918. @example
  4919. geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
  4920. @end example
  4921. @item
  4922. Generate a fancy enigmatic moving light:
  4923. @example
  4924. 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
  4925. @end example
  4926. @item
  4927. Generate a quick emboss effect:
  4928. @example
  4929. format=gray,geq=lum_expr='(p(X,Y)+(256-p(X-4,Y-4)))/2'
  4930. @end example
  4931. @item
  4932. Modify RGB components depending on pixel position:
  4933. @example
  4934. geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'
  4935. @end example
  4936. @item
  4937. Create a radial gradient that is the same size as the input (also see
  4938. the @ref{vignette} filter):
  4939. @example
  4940. geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray
  4941. @end example
  4942. @item
  4943. Create a linear gradient to use as a mask for another filter, then
  4944. compose with @ref{overlay}. In this example the video will gradually
  4945. become more blurry from the top to the bottom of the y-axis as defined
  4946. by the linear gradient:
  4947. @example
  4948. 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
  4949. @end example
  4950. @end itemize
  4951. @section gradfun
  4952. Fix the banding artifacts that are sometimes introduced into nearly flat
  4953. regions by truncation to 8bit color depth.
  4954. Interpolate the gradients that should go where the bands are, and
  4955. dither them.
  4956. It is designed for playback only. Do not use it prior to
  4957. lossy compression, because compression tends to lose the dither and
  4958. bring back the bands.
  4959. It accepts the following parameters:
  4960. @table @option
  4961. @item strength
  4962. The maximum amount by which the filter will change any one pixel. This is also
  4963. the threshold for detecting nearly flat regions. Acceptable values range from
  4964. .51 to 64; the default value is 1.2. Out-of-range values will be clipped to the
  4965. valid range.
  4966. @item radius
  4967. The neighborhood to fit the gradient to. A larger radius makes for smoother
  4968. gradients, but also prevents the filter from modifying the pixels near detailed
  4969. regions. Acceptable values are 8-32; the default value is 16. Out-of-range
  4970. values will be clipped to the valid range.
  4971. @end table
  4972. Alternatively, the options can be specified as a flat string:
  4973. @var{strength}[:@var{radius}]
  4974. @subsection Examples
  4975. @itemize
  4976. @item
  4977. Apply the filter with a @code{3.5} strength and radius of @code{8}:
  4978. @example
  4979. gradfun=3.5:8
  4980. @end example
  4981. @item
  4982. Specify radius, omitting the strength (which will fall-back to the default
  4983. value):
  4984. @example
  4985. gradfun=radius=8
  4986. @end example
  4987. @end itemize
  4988. @anchor{haldclut}
  4989. @section haldclut
  4990. Apply a Hald CLUT to a video stream.
  4991. First input is the video stream to process, and second one is the Hald CLUT.
  4992. The Hald CLUT input can be a simple picture or a complete video stream.
  4993. The filter accepts the following options:
  4994. @table @option
  4995. @item shortest
  4996. Force termination when the shortest input terminates. Default is @code{0}.
  4997. @item repeatlast
  4998. Continue applying the last CLUT after the end of the stream. A value of
  4999. @code{0} disable the filter after the last frame of the CLUT is reached.
  5000. Default is @code{1}.
  5001. @end table
  5002. @code{haldclut} also has the same interpolation options as @ref{lut3d} (both
  5003. filters share the same internals).
  5004. More information about the Hald CLUT can be found on Eskil Steenberg's website
  5005. (Hald CLUT author) at @url{http://www.quelsolaar.com/technology/clut.html}.
  5006. @subsection Workflow examples
  5007. @subsubsection Hald CLUT video stream
  5008. Generate an identity Hald CLUT stream altered with various effects:
  5009. @example
  5010. 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
  5011. @end example
  5012. Note: make sure you use a lossless codec.
  5013. Then use it with @code{haldclut} to apply it on some random stream:
  5014. @example
  5015. ffmpeg -f lavfi -i mandelbrot -i clut.nut -filter_complex '[0][1] haldclut' -t 20 mandelclut.mkv
  5016. @end example
  5017. The Hald CLUT will be applied to the 10 first seconds (duration of
  5018. @file{clut.nut}), then the latest picture of that CLUT stream will be applied
  5019. to the remaining frames of the @code{mandelbrot} stream.
  5020. @subsubsection Hald CLUT with preview
  5021. A Hald CLUT is supposed to be a squared image of @code{Level*Level*Level} by
  5022. @code{Level*Level*Level} pixels. For a given Hald CLUT, FFmpeg will select the
  5023. biggest possible square starting at the top left of the picture. The remaining
  5024. padding pixels (bottom or right) will be ignored. This area can be used to add
  5025. a preview of the Hald CLUT.
  5026. Typically, the following generated Hald CLUT will be supported by the
  5027. @code{haldclut} filter:
  5028. @example
  5029. ffmpeg -f lavfi -i @ref{haldclutsrc}=8 -vf "
  5030. pad=iw+320 [padded_clut];
  5031. smptebars=s=320x256, split [a][b];
  5032. [padded_clut][a] overlay=W-320:h, curves=color_negative [main];
  5033. [main][b] overlay=W-320" -frames:v 1 clut.png
  5034. @end example
  5035. It contains the original and a preview of the effect of the CLUT: SMPTE color
  5036. bars are displayed on the right-top, and below the same color bars processed by
  5037. the color changes.
  5038. Then, the effect of this Hald CLUT can be visualized with:
  5039. @example
  5040. ffplay input.mkv -vf "movie=clut.png, [in] haldclut"
  5041. @end example
  5042. @section hflip
  5043. Flip the input video horizontally.
  5044. For example, to horizontally flip the input video with @command{ffmpeg}:
  5045. @example
  5046. ffmpeg -i in.avi -vf "hflip" out.avi
  5047. @end example
  5048. @section histeq
  5049. This filter applies a global color histogram equalization on a
  5050. per-frame basis.
  5051. It can be used to correct video that has a compressed range of pixel
  5052. intensities. The filter redistributes the pixel intensities to
  5053. equalize their distribution across the intensity range. It may be
  5054. viewed as an "automatically adjusting contrast filter". This filter is
  5055. useful only for correcting degraded or poorly captured source
  5056. video.
  5057. The filter accepts the following options:
  5058. @table @option
  5059. @item strength
  5060. Determine the amount of equalization to be applied. As the strength
  5061. is reduced, the distribution of pixel intensities more-and-more
  5062. approaches that of the input frame. The value must be a float number
  5063. in the range [0,1] and defaults to 0.200.
  5064. @item intensity
  5065. Set the maximum intensity that can generated and scale the output
  5066. values appropriately. The strength should be set as desired and then
  5067. the intensity can be limited if needed to avoid washing-out. The value
  5068. must be a float number in the range [0,1] and defaults to 0.210.
  5069. @item antibanding
  5070. Set the antibanding level. If enabled the filter will randomly vary
  5071. the luminance of output pixels by a small amount to avoid banding of
  5072. the histogram. Possible values are @code{none}, @code{weak} or
  5073. @code{strong}. It defaults to @code{none}.
  5074. @end table
  5075. @section histogram
  5076. Compute and draw a color distribution histogram for the input video.
  5077. The computed histogram is a representation of the color component
  5078. distribution in an image.
  5079. The filter accepts the following options:
  5080. @table @option
  5081. @item mode
  5082. Set histogram mode.
  5083. It accepts the following values:
  5084. @table @samp
  5085. @item levels
  5086. Standard histogram that displays the color components distribution in an
  5087. image. Displays color graph for each color component. Shows distribution of
  5088. the Y, U, V, A or R, G, B components, depending on input format, in the
  5089. current frame. Below each graph a color component scale meter is shown.
  5090. @item color
  5091. Displays chroma values (U/V color placement) in a two dimensional
  5092. graph (which is called a vectorscope). The brighter a pixel in the
  5093. vectorscope, the more pixels of the input frame correspond to that pixel
  5094. (i.e., more pixels have this chroma value). The V component is displayed on
  5095. the horizontal (X) axis, with the leftmost side being V = 0 and the rightmost
  5096. side being V = 255. The U component is displayed on the vertical (Y) axis,
  5097. with the top representing U = 0 and the bottom representing U = 255.
  5098. The position of a white pixel in the graph corresponds to the chroma value of
  5099. a pixel of the input clip. The graph can therefore be used to read the hue
  5100. (color flavor) and the saturation (the dominance of the hue in the color). As
  5101. the hue of a color changes, it moves around the square. At the center of the
  5102. square the saturation is zero, which means that the corresponding pixel has no
  5103. color. If the amount of a specific color is increased (while leaving the other
  5104. colors unchanged) the saturation increases, and the indicator moves towards
  5105. the edge of the square.
  5106. @item color2
  5107. Chroma values in vectorscope, similar as @code{color} but actual chroma values
  5108. are displayed.
  5109. @item waveform
  5110. Per row/column color component graph. In row mode, the graph on the left side
  5111. represents color component value 0 and the right side represents value = 255.
  5112. In column mode, the top side represents color component value = 0 and bottom
  5113. side represents value = 255.
  5114. @end table
  5115. Default value is @code{levels}.
  5116. @item level_height
  5117. Set height of level in @code{levels}. Default value is @code{200}.
  5118. Allowed range is [50, 2048].
  5119. @item scale_height
  5120. Set height of color scale in @code{levels}. Default value is @code{12}.
  5121. Allowed range is [0, 40].
  5122. @item step
  5123. Set step for @code{waveform} mode. Smaller values are useful to find out how
  5124. many values of the same luminance are distributed across input rows/columns.
  5125. Default value is @code{10}. Allowed range is [1, 255].
  5126. @item waveform_mode
  5127. Set mode for @code{waveform}. Can be either @code{row}, or @code{column}.
  5128. Default is @code{row}.
  5129. @item waveform_mirror
  5130. Set mirroring mode for @code{waveform}. @code{0} means unmirrored, @code{1}
  5131. means mirrored. In mirrored mode, higher values will be represented on the left
  5132. side for @code{row} mode and at the top for @code{column} mode. Default is
  5133. @code{0} (unmirrored).
  5134. @item display_mode
  5135. Set display mode for @code{waveform} and @code{levels}.
  5136. It accepts the following values:
  5137. @table @samp
  5138. @item parade
  5139. Display separate graph for the color components side by side in
  5140. @code{row} waveform mode or one below the other in @code{column} waveform mode
  5141. for @code{waveform} histogram mode. For @code{levels} histogram mode,
  5142. per color component graphs are placed below each other.
  5143. Using this display mode in @code{waveform} histogram mode makes it easy to
  5144. spot color casts in the highlights and shadows of an image, by comparing the
  5145. contours of the top and the bottom graphs of each waveform. Since whites,
  5146. grays, and blacks are characterized by exactly equal amounts of red, green,
  5147. and blue, neutral areas of the picture should display three waveforms of
  5148. roughly equal width/height. If not, the correction is easy to perform by
  5149. making level adjustments the three waveforms.
  5150. @item overlay
  5151. Presents information identical to that in the @code{parade}, except
  5152. that the graphs representing color components are superimposed directly
  5153. over one another.
  5154. This display mode in @code{waveform} histogram mode makes it easier to spot
  5155. relative differences or similarities in overlapping areas of the color
  5156. components that are supposed to be identical, such as neutral whites, grays,
  5157. or blacks.
  5158. @end table
  5159. Default is @code{parade}.
  5160. @item levels_mode
  5161. Set mode for @code{levels}. Can be either @code{linear}, or @code{logarithmic}.
  5162. Default is @code{linear}.
  5163. @item components
  5164. Set what color components to display for mode @code{levels}.
  5165. Default is @code{7}.
  5166. @end table
  5167. @subsection Examples
  5168. @itemize
  5169. @item
  5170. Calculate and draw histogram:
  5171. @example
  5172. ffplay -i input -vf histogram
  5173. @end example
  5174. @end itemize
  5175. @anchor{hqdn3d}
  5176. @section hqdn3d
  5177. This is a high precision/quality 3d denoise filter. It aims to reduce
  5178. image noise, producing smooth images and making still images really
  5179. still. It should enhance compressibility.
  5180. It accepts the following optional parameters:
  5181. @table @option
  5182. @item luma_spatial
  5183. A non-negative floating point number which specifies spatial luma strength.
  5184. It defaults to 4.0.
  5185. @item chroma_spatial
  5186. A non-negative floating point number which specifies spatial chroma strength.
  5187. It defaults to 3.0*@var{luma_spatial}/4.0.
  5188. @item luma_tmp
  5189. A floating point number which specifies luma temporal strength. It defaults to
  5190. 6.0*@var{luma_spatial}/4.0.
  5191. @item chroma_tmp
  5192. A floating point number which specifies chroma temporal strength. It defaults to
  5193. @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
  5194. @end table
  5195. @section hqx
  5196. Apply a high-quality magnification filter designed for pixel art. This filter
  5197. was originally created by Maxim Stepin.
  5198. It accepts the following option:
  5199. @table @option
  5200. @item n
  5201. Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for
  5202. @code{hq3x} and @code{4} for @code{hq4x}.
  5203. Default is @code{3}.
  5204. @end table
  5205. @section hstack
  5206. Stack input videos horizontally.
  5207. All streams must be of same pixel format and of same height.
  5208. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  5209. to create same output.
  5210. The filter accept the following option:
  5211. @table @option
  5212. @item nb_inputs
  5213. Set number of input streams. Default is 2.
  5214. @end table
  5215. @section hue
  5216. Modify the hue and/or the saturation of the input.
  5217. It accepts the following parameters:
  5218. @table @option
  5219. @item h
  5220. Specify the hue angle as a number of degrees. It accepts an expression,
  5221. and defaults to "0".
  5222. @item s
  5223. Specify the saturation in the [-10,10] range. It accepts an expression and
  5224. defaults to "1".
  5225. @item H
  5226. Specify the hue angle as a number of radians. It accepts an
  5227. expression, and defaults to "0".
  5228. @item b
  5229. Specify the brightness in the [-10,10] range. It accepts an expression and
  5230. defaults to "0".
  5231. @end table
  5232. @option{h} and @option{H} are mutually exclusive, and can't be
  5233. specified at the same time.
  5234. The @option{b}, @option{h}, @option{H} and @option{s} option values are
  5235. expressions containing the following constants:
  5236. @table @option
  5237. @item n
  5238. frame count of the input frame starting from 0
  5239. @item pts
  5240. presentation timestamp of the input frame expressed in time base units
  5241. @item r
  5242. frame rate of the input video, NAN if the input frame rate is unknown
  5243. @item t
  5244. timestamp expressed in seconds, NAN if the input timestamp is unknown
  5245. @item tb
  5246. time base of the input video
  5247. @end table
  5248. @subsection Examples
  5249. @itemize
  5250. @item
  5251. Set the hue to 90 degrees and the saturation to 1.0:
  5252. @example
  5253. hue=h=90:s=1
  5254. @end example
  5255. @item
  5256. Same command but expressing the hue in radians:
  5257. @example
  5258. hue=H=PI/2:s=1
  5259. @end example
  5260. @item
  5261. Rotate hue and make the saturation swing between 0
  5262. and 2 over a period of 1 second:
  5263. @example
  5264. hue="H=2*PI*t: s=sin(2*PI*t)+1"
  5265. @end example
  5266. @item
  5267. Apply a 3 seconds saturation fade-in effect starting at 0:
  5268. @example
  5269. hue="s=min(t/3\,1)"
  5270. @end example
  5271. The general fade-in expression can be written as:
  5272. @example
  5273. hue="s=min(0\, max((t-START)/DURATION\, 1))"
  5274. @end example
  5275. @item
  5276. Apply a 3 seconds saturation fade-out effect starting at 5 seconds:
  5277. @example
  5278. hue="s=max(0\, min(1\, (8-t)/3))"
  5279. @end example
  5280. The general fade-out expression can be written as:
  5281. @example
  5282. hue="s=max(0\, min(1\, (START+DURATION-t)/DURATION))"
  5283. @end example
  5284. @end itemize
  5285. @subsection Commands
  5286. This filter supports the following commands:
  5287. @table @option
  5288. @item b
  5289. @item s
  5290. @item h
  5291. @item H
  5292. Modify the hue and/or the saturation and/or brightness of the input video.
  5293. The command accepts the same syntax of the corresponding option.
  5294. If the specified expression is not valid, it is kept at its current
  5295. value.
  5296. @end table
  5297. @section idet
  5298. Detect video interlacing type.
  5299. This filter tries to detect if the input frames as interlaced, progressive,
  5300. top or bottom field first. It will also try and detect fields that are
  5301. repeated between adjacent frames (a sign of telecine).
  5302. Single frame detection considers only immediately adjacent frames when classifying each frame.
  5303. Multiple frame detection incorporates the classification history of previous frames.
  5304. The filter will log these metadata values:
  5305. @table @option
  5306. @item single.current_frame
  5307. Detected type of current frame using single-frame detection. One of:
  5308. ``tff'' (top field first), ``bff'' (bottom field first),
  5309. ``progressive'', or ``undetermined''
  5310. @item single.tff
  5311. Cumulative number of frames detected as top field first using single-frame detection.
  5312. @item multiple.tff
  5313. Cumulative number of frames detected as top field first using multiple-frame detection.
  5314. @item single.bff
  5315. Cumulative number of frames detected as bottom field first using single-frame detection.
  5316. @item multiple.current_frame
  5317. Detected type of current frame using multiple-frame detection. One of:
  5318. ``tff'' (top field first), ``bff'' (bottom field first),
  5319. ``progressive'', or ``undetermined''
  5320. @item multiple.bff
  5321. Cumulative number of frames detected as bottom field first using multiple-frame detection.
  5322. @item single.progressive
  5323. Cumulative number of frames detected as progressive using single-frame detection.
  5324. @item multiple.progressive
  5325. Cumulative number of frames detected as progressive using multiple-frame detection.
  5326. @item single.undetermined
  5327. Cumulative number of frames that could not be classified using single-frame detection.
  5328. @item multiple.undetermined
  5329. Cumulative number of frames that could not be classified using multiple-frame detection.
  5330. @item repeated.current_frame
  5331. Which field in the current frame is repeated from the last. One of ``neither'', ``top'', or ``bottom''.
  5332. @item repeated.neither
  5333. Cumulative number of frames with no repeated field.
  5334. @item repeated.top
  5335. Cumulative number of frames with the top field repeated from the previous frame's top field.
  5336. @item repeated.bottom
  5337. Cumulative number of frames with the bottom field repeated from the previous frame's bottom field.
  5338. @end table
  5339. The filter accepts the following options:
  5340. @table @option
  5341. @item intl_thres
  5342. Set interlacing threshold.
  5343. @item prog_thres
  5344. Set progressive threshold.
  5345. @item repeat_thres
  5346. Threshold for repeated field detection.
  5347. @item half_life
  5348. Number of frames after which a given frame's contribution to the
  5349. statistics is halved (i.e., it contributes only 0.5 to it's
  5350. classification). The default of 0 means that all frames seen are given
  5351. full weight of 1.0 forever.
  5352. @item analyze_interlaced_flag
  5353. When this is not 0 then idet will use the specified number of frames to determine
  5354. if the interlaced flag is accurate, it will not count undetermined frames.
  5355. If the flag is found to be accurate it will be used without any further
  5356. computations, if it is found to be inaccurate it will be cleared without any
  5357. further computations. This allows inserting the idet filter as a low computational
  5358. method to clean up the interlaced flag
  5359. @end table
  5360. @section il
  5361. Deinterleave or interleave fields.
  5362. This filter allows one to process interlaced images fields without
  5363. deinterlacing them. Deinterleaving splits the input frame into 2
  5364. fields (so called half pictures). Odd lines are moved to the top
  5365. half of the output image, even lines to the bottom half.
  5366. You can process (filter) them independently and then re-interleave them.
  5367. The filter accepts the following options:
  5368. @table @option
  5369. @item luma_mode, l
  5370. @item chroma_mode, c
  5371. @item alpha_mode, a
  5372. Available values for @var{luma_mode}, @var{chroma_mode} and
  5373. @var{alpha_mode} are:
  5374. @table @samp
  5375. @item none
  5376. Do nothing.
  5377. @item deinterleave, d
  5378. Deinterleave fields, placing one above the other.
  5379. @item interleave, i
  5380. Interleave fields. Reverse the effect of deinterleaving.
  5381. @end table
  5382. Default value is @code{none}.
  5383. @item luma_swap, ls
  5384. @item chroma_swap, cs
  5385. @item alpha_swap, as
  5386. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}.
  5387. @end table
  5388. @section inflate
  5389. Apply inflate effect to the video.
  5390. This filter replaces the pixel by the local(3x3) average by taking into account
  5391. only values higher than the pixel.
  5392. It accepts the following options:
  5393. @table @option
  5394. @item threshold0
  5395. @item threshold1
  5396. @item threshold2
  5397. @item threshold3
  5398. Allows to limit the maximum change for each plane, default is 65535.
  5399. If 0, plane will remain unchanged.
  5400. @end table
  5401. @section interlace
  5402. Simple interlacing filter from progressive contents. This interleaves upper (or
  5403. lower) lines from odd frames with lower (or upper) lines from even frames,
  5404. halving the frame rate and preserving image height.
  5405. @example
  5406. Original Original New Frame
  5407. Frame 'j' Frame 'j+1' (tff)
  5408. ========== =========== ==================
  5409. Line 0 --------------------> Frame 'j' Line 0
  5410. Line 1 Line 1 ----> Frame 'j+1' Line 1
  5411. Line 2 ---------------------> Frame 'j' Line 2
  5412. Line 3 Line 3 ----> Frame 'j+1' Line 3
  5413. ... ... ...
  5414. New Frame + 1 will be generated by Frame 'j+2' and Frame 'j+3' and so on
  5415. @end example
  5416. It accepts the following optional parameters:
  5417. @table @option
  5418. @item scan
  5419. This determines whether the interlaced frame is taken from the even
  5420. (tff - default) or odd (bff) lines of the progressive frame.
  5421. @item lowpass
  5422. Enable (default) or disable the vertical lowpass filter to avoid twitter
  5423. interlacing and reduce moire patterns.
  5424. @end table
  5425. @section kerndeint
  5426. Deinterlace input video by applying Donald Graft's adaptive kernel
  5427. deinterling. Work on interlaced parts of a video to produce
  5428. progressive frames.
  5429. The description of the accepted parameters follows.
  5430. @table @option
  5431. @item thresh
  5432. Set the threshold which affects the filter's tolerance when
  5433. determining if a pixel line must be processed. It must be an integer
  5434. in the range [0,255] and defaults to 10. A value of 0 will result in
  5435. applying the process on every pixels.
  5436. @item map
  5437. Paint pixels exceeding the threshold value to white if set to 1.
  5438. Default is 0.
  5439. @item order
  5440. Set the fields order. Swap fields if set to 1, leave fields alone if
  5441. 0. Default is 0.
  5442. @item sharp
  5443. Enable additional sharpening if set to 1. Default is 0.
  5444. @item twoway
  5445. Enable twoway sharpening if set to 1. Default is 0.
  5446. @end table
  5447. @subsection Examples
  5448. @itemize
  5449. @item
  5450. Apply default values:
  5451. @example
  5452. kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0
  5453. @end example
  5454. @item
  5455. Enable additional sharpening:
  5456. @example
  5457. kerndeint=sharp=1
  5458. @end example
  5459. @item
  5460. Paint processed pixels in white:
  5461. @example
  5462. kerndeint=map=1
  5463. @end example
  5464. @end itemize
  5465. @section lenscorrection
  5466. Correct radial lens distortion
  5467. This filter can be used to correct for radial distortion as can result from the use
  5468. of wide angle lenses, and thereby re-rectify the image. To find the right parameters
  5469. one can use tools available for example as part of opencv or simply trial-and-error.
  5470. To use opencv use the calibration sample (under samples/cpp) from the opencv sources
  5471. and extract the k1 and k2 coefficients from the resulting matrix.
  5472. Note that effectively the same filter is available in the open-source tools Krita and
  5473. Digikam from the KDE project.
  5474. In contrast to the @ref{vignette} filter, which can also be used to compensate lens errors,
  5475. this filter corrects the distortion of the image, whereas @ref{vignette} corrects the
  5476. brightness distribution, so you may want to use both filters together in certain
  5477. cases, though you will have to take care of ordering, i.e. whether vignetting should
  5478. be applied before or after lens correction.
  5479. @subsection Options
  5480. The filter accepts the following options:
  5481. @table @option
  5482. @item cx
  5483. Relative x-coordinate of the focal point of the image, and thereby the center of the
  5484. distortion. This value has a range [0,1] and is expressed as fractions of the image
  5485. width.
  5486. @item cy
  5487. Relative y-coordinate of the focal point of the image, and thereby the center of the
  5488. distortion. This value has a range [0,1] and is expressed as fractions of the image
  5489. height.
  5490. @item k1
  5491. Coefficient of the quadratic correction term. 0.5 means no correction.
  5492. @item k2
  5493. Coefficient of the double quadratic correction term. 0.5 means no correction.
  5494. @end table
  5495. The formula that generates the correction is:
  5496. @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)
  5497. where @var{r_0} is halve of the image diagonal and @var{r_src} and @var{r_tgt} are the
  5498. distances from the focal point in the source and target images, respectively.
  5499. @anchor{lut3d}
  5500. @section lut3d
  5501. Apply a 3D LUT to an input video.
  5502. The filter accepts the following options:
  5503. @table @option
  5504. @item file
  5505. Set the 3D LUT file name.
  5506. Currently supported formats:
  5507. @table @samp
  5508. @item 3dl
  5509. AfterEffects
  5510. @item cube
  5511. Iridas
  5512. @item dat
  5513. DaVinci
  5514. @item m3d
  5515. Pandora
  5516. @end table
  5517. @item interp
  5518. Select interpolation mode.
  5519. Available values are:
  5520. @table @samp
  5521. @item nearest
  5522. Use values from the nearest defined point.
  5523. @item trilinear
  5524. Interpolate values using the 8 points defining a cube.
  5525. @item tetrahedral
  5526. Interpolate values using a tetrahedron.
  5527. @end table
  5528. @end table
  5529. @section lut, lutrgb, lutyuv
  5530. Compute a look-up table for binding each pixel component input value
  5531. to an output value, and apply it to the input video.
  5532. @var{lutyuv} applies a lookup table to a YUV input video, @var{lutrgb}
  5533. to an RGB input video.
  5534. These filters accept the following parameters:
  5535. @table @option
  5536. @item c0
  5537. set first pixel component expression
  5538. @item c1
  5539. set second pixel component expression
  5540. @item c2
  5541. set third pixel component expression
  5542. @item c3
  5543. set fourth pixel component expression, corresponds to the alpha component
  5544. @item r
  5545. set red component expression
  5546. @item g
  5547. set green component expression
  5548. @item b
  5549. set blue component expression
  5550. @item a
  5551. alpha component expression
  5552. @item y
  5553. set Y/luminance component expression
  5554. @item u
  5555. set U/Cb component expression
  5556. @item v
  5557. set V/Cr component expression
  5558. @end table
  5559. Each of them specifies the expression to use for computing the lookup table for
  5560. the corresponding pixel component values.
  5561. The exact component associated to each of the @var{c*} options depends on the
  5562. format in input.
  5563. The @var{lut} filter requires either YUV or RGB pixel formats in input,
  5564. @var{lutrgb} requires RGB pixel formats in input, and @var{lutyuv} requires YUV.
  5565. The expressions can contain the following constants and functions:
  5566. @table @option
  5567. @item w
  5568. @item h
  5569. The input width and height.
  5570. @item val
  5571. The input value for the pixel component.
  5572. @item clipval
  5573. The input value, clipped to the @var{minval}-@var{maxval} range.
  5574. @item maxval
  5575. The maximum value for the pixel component.
  5576. @item minval
  5577. The minimum value for the pixel component.
  5578. @item negval
  5579. The negated value for the pixel component value, clipped to the
  5580. @var{minval}-@var{maxval} range; it corresponds to the expression
  5581. "maxval-clipval+minval".
  5582. @item clip(val)
  5583. The computed value in @var{val}, clipped to the
  5584. @var{minval}-@var{maxval} range.
  5585. @item gammaval(gamma)
  5586. The computed gamma correction value of the pixel component value,
  5587. clipped to the @var{minval}-@var{maxval} range. It corresponds to the
  5588. expression
  5589. "pow((clipval-minval)/(maxval-minval)\,@var{gamma})*(maxval-minval)+minval"
  5590. @end table
  5591. All expressions default to "val".
  5592. @subsection Examples
  5593. @itemize
  5594. @item
  5595. Negate input video:
  5596. @example
  5597. lutrgb="r=maxval+minval-val:g=maxval+minval-val:b=maxval+minval-val"
  5598. lutyuv="y=maxval+minval-val:u=maxval+minval-val:v=maxval+minval-val"
  5599. @end example
  5600. The above is the same as:
  5601. @example
  5602. lutrgb="r=negval:g=negval:b=negval"
  5603. lutyuv="y=negval:u=negval:v=negval"
  5604. @end example
  5605. @item
  5606. Negate luminance:
  5607. @example
  5608. lutyuv=y=negval
  5609. @end example
  5610. @item
  5611. Remove chroma components, turning the video into a graytone image:
  5612. @example
  5613. lutyuv="u=128:v=128"
  5614. @end example
  5615. @item
  5616. Apply a luma burning effect:
  5617. @example
  5618. lutyuv="y=2*val"
  5619. @end example
  5620. @item
  5621. Remove green and blue components:
  5622. @example
  5623. lutrgb="g=0:b=0"
  5624. @end example
  5625. @item
  5626. Set a constant alpha channel value on input:
  5627. @example
  5628. format=rgba,lutrgb=a="maxval-minval/2"
  5629. @end example
  5630. @item
  5631. Correct luminance gamma by a factor of 0.5:
  5632. @example
  5633. lutyuv=y=gammaval(0.5)
  5634. @end example
  5635. @item
  5636. Discard least significant bits of luma:
  5637. @example
  5638. lutyuv=y='bitand(val, 128+64+32)'
  5639. @end example
  5640. @end itemize
  5641. @section mergeplanes
  5642. Merge color channel components from several video streams.
  5643. The filter accepts up to 4 input streams, and merge selected input
  5644. planes to the output video.
  5645. This filter accepts the following options:
  5646. @table @option
  5647. @item mapping
  5648. Set input to output plane mapping. Default is @code{0}.
  5649. The mappings is specified as a bitmap. It should be specified as a
  5650. hexadecimal number in the form 0xAa[Bb[Cc[Dd]]]. 'Aa' describes the
  5651. mapping for the first plane of the output stream. 'A' sets the number of
  5652. the input stream to use (from 0 to 3), and 'a' the plane number of the
  5653. corresponding input to use (from 0 to 3). The rest of the mappings is
  5654. similar, 'Bb' describes the mapping for the output stream second
  5655. plane, 'Cc' describes the mapping for the output stream third plane and
  5656. 'Dd' describes the mapping for the output stream fourth plane.
  5657. @item format
  5658. Set output pixel format. Default is @code{yuva444p}.
  5659. @end table
  5660. @subsection Examples
  5661. @itemize
  5662. @item
  5663. Merge three gray video streams of same width and height into single video stream:
  5664. @example
  5665. [a0][a1][a2]mergeplanes=0x001020:yuv444p
  5666. @end example
  5667. @item
  5668. Merge 1st yuv444p stream and 2nd gray video stream into yuva444p video stream:
  5669. @example
  5670. [a0][a1]mergeplanes=0x00010210:yuva444p
  5671. @end example
  5672. @item
  5673. Swap Y and A plane in yuva444p stream:
  5674. @example
  5675. format=yuva444p,mergeplanes=0x03010200:yuva444p
  5676. @end example
  5677. @item
  5678. Swap U and V plane in yuv420p stream:
  5679. @example
  5680. format=yuv420p,mergeplanes=0x000201:yuv420p
  5681. @end example
  5682. @item
  5683. Cast a rgb24 clip to yuv444p:
  5684. @example
  5685. format=rgb24,mergeplanes=0x000102:yuv444p
  5686. @end example
  5687. @end itemize
  5688. @section mcdeint
  5689. Apply motion-compensation deinterlacing.
  5690. It needs one field per frame as input and must thus be used together
  5691. with yadif=1/3 or equivalent.
  5692. This filter accepts the following options:
  5693. @table @option
  5694. @item mode
  5695. Set the deinterlacing mode.
  5696. It accepts one of the following values:
  5697. @table @samp
  5698. @item fast
  5699. @item medium
  5700. @item slow
  5701. use iterative motion estimation
  5702. @item extra_slow
  5703. like @samp{slow}, but use multiple reference frames.
  5704. @end table
  5705. Default value is @samp{fast}.
  5706. @item parity
  5707. Set the picture field parity assumed for the input video. It must be
  5708. one of the following values:
  5709. @table @samp
  5710. @item 0, tff
  5711. assume top field first
  5712. @item 1, bff
  5713. assume bottom field first
  5714. @end table
  5715. Default value is @samp{bff}.
  5716. @item qp
  5717. Set per-block quantization parameter (QP) used by the internal
  5718. encoder.
  5719. Higher values should result in a smoother motion vector field but less
  5720. optimal individual vectors. Default value is 1.
  5721. @end table
  5722. @section mpdecimate
  5723. Drop frames that do not differ greatly from the previous frame in
  5724. order to reduce frame rate.
  5725. The main use of this filter is for very-low-bitrate encoding
  5726. (e.g. streaming over dialup modem), but it could in theory be used for
  5727. fixing movies that were inverse-telecined incorrectly.
  5728. A description of the accepted options follows.
  5729. @table @option
  5730. @item max
  5731. Set the maximum number of consecutive frames which can be dropped (if
  5732. positive), or the minimum interval between dropped frames (if
  5733. negative). If the value is 0, the frame is dropped unregarding the
  5734. number of previous sequentially dropped frames.
  5735. Default value is 0.
  5736. @item hi
  5737. @item lo
  5738. @item frac
  5739. Set the dropping threshold values.
  5740. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and
  5741. represent actual pixel value differences, so a threshold of 64
  5742. corresponds to 1 unit of difference for each pixel, or the same spread
  5743. out differently over the block.
  5744. A frame is a candidate for dropping if no 8x8 blocks differ by more
  5745. than a threshold of @option{hi}, and if no more than @option{frac} blocks (1
  5746. meaning the whole image) differ by more than a threshold of @option{lo}.
  5747. Default value for @option{hi} is 64*12, default value for @option{lo} is
  5748. 64*5, and default value for @option{frac} is 0.33.
  5749. @end table
  5750. @section negate
  5751. Negate input video.
  5752. It accepts an integer in input; if non-zero it negates the
  5753. alpha component (if available). The default value in input is 0.
  5754. @section noformat
  5755. Force libavfilter not to use any of the specified pixel formats for the
  5756. input to the next filter.
  5757. It accepts the following parameters:
  5758. @table @option
  5759. @item pix_fmts
  5760. A '|'-separated list of pixel format names, such as
  5761. apix_fmts=yuv420p|monow|rgb24".
  5762. @end table
  5763. @subsection Examples
  5764. @itemize
  5765. @item
  5766. Force libavfilter to use a format different from @var{yuv420p} for the
  5767. input to the vflip filter:
  5768. @example
  5769. noformat=pix_fmts=yuv420p,vflip
  5770. @end example
  5771. @item
  5772. Convert the input video to any of the formats not contained in the list:
  5773. @example
  5774. noformat=yuv420p|yuv444p|yuv410p
  5775. @end example
  5776. @end itemize
  5777. @section noise
  5778. Add noise on video input frame.
  5779. The filter accepts the following options:
  5780. @table @option
  5781. @item all_seed
  5782. @item c0_seed
  5783. @item c1_seed
  5784. @item c2_seed
  5785. @item c3_seed
  5786. Set noise seed for specific pixel component or all pixel components in case
  5787. of @var{all_seed}. Default value is @code{123457}.
  5788. @item all_strength, alls
  5789. @item c0_strength, c0s
  5790. @item c1_strength, c1s
  5791. @item c2_strength, c2s
  5792. @item c3_strength, c3s
  5793. Set noise strength for specific pixel component or all pixel components in case
  5794. @var{all_strength}. Default value is @code{0}. Allowed range is [0, 100].
  5795. @item all_flags, allf
  5796. @item c0_flags, c0f
  5797. @item c1_flags, c1f
  5798. @item c2_flags, c2f
  5799. @item c3_flags, c3f
  5800. Set pixel component flags or set flags for all components if @var{all_flags}.
  5801. Available values for component flags are:
  5802. @table @samp
  5803. @item a
  5804. averaged temporal noise (smoother)
  5805. @item p
  5806. mix random noise with a (semi)regular pattern
  5807. @item t
  5808. temporal noise (noise pattern changes between frames)
  5809. @item u
  5810. uniform noise (gaussian otherwise)
  5811. @end table
  5812. @end table
  5813. @subsection Examples
  5814. Add temporal and uniform noise to input video:
  5815. @example
  5816. noise=alls=20:allf=t+u
  5817. @end example
  5818. @section null
  5819. Pass the video source unchanged to the output.
  5820. @section ocr
  5821. Optical Character Recognition
  5822. This filter uses Tesseract for optical character recognition.
  5823. It accepts the following options:
  5824. @table @option
  5825. @item datapath
  5826. Set datapath to tesseract data. Default is to use whatever was
  5827. set at installation.
  5828. @item language
  5829. Set language, default is "eng".
  5830. @item whitelist
  5831. Set character whitelist.
  5832. @item blacklist
  5833. Set character blacklist.
  5834. @end table
  5835. The filter exports recognized text as the frame metadata @code{lavfi.ocr.text}.
  5836. @section ocv
  5837. Apply a video transform using libopencv.
  5838. To enable this filter, install the libopencv library and headers and
  5839. configure FFmpeg with @code{--enable-libopencv}.
  5840. It accepts the following parameters:
  5841. @table @option
  5842. @item filter_name
  5843. The name of the libopencv filter to apply.
  5844. @item filter_params
  5845. The parameters to pass to the libopencv filter. If not specified, the default
  5846. values are assumed.
  5847. @end table
  5848. Refer to the official libopencv documentation for more precise
  5849. information:
  5850. @url{http://docs.opencv.org/master/modules/imgproc/doc/filtering.html}
  5851. Several libopencv filters are supported; see the following subsections.
  5852. @anchor{dilate}
  5853. @subsection dilate
  5854. Dilate an image by using a specific structuring element.
  5855. It corresponds to the libopencv function @code{cvDilate}.
  5856. It accepts the parameters: @var{struct_el}|@var{nb_iterations}.
  5857. @var{struct_el} represents a structuring element, and has the syntax:
  5858. @var{cols}x@var{rows}+@var{anchor_x}x@var{anchor_y}/@var{shape}
  5859. @var{cols} and @var{rows} represent the number of columns and rows of
  5860. the structuring element, @var{anchor_x} and @var{anchor_y} the anchor
  5861. point, and @var{shape} the shape for the structuring element. @var{shape}
  5862. must be "rect", "cross", "ellipse", or "custom".
  5863. If the value for @var{shape} is "custom", it must be followed by a
  5864. string of the form "=@var{filename}". The file with name
  5865. @var{filename} is assumed to represent a binary image, with each
  5866. printable character corresponding to a bright pixel. When a custom
  5867. @var{shape} is used, @var{cols} and @var{rows} are ignored, the number
  5868. or columns and rows of the read file are assumed instead.
  5869. The default value for @var{struct_el} is "3x3+0x0/rect".
  5870. @var{nb_iterations} specifies the number of times the transform is
  5871. applied to the image, and defaults to 1.
  5872. Some examples:
  5873. @example
  5874. # Use the default values
  5875. ocv=dilate
  5876. # Dilate using a structuring element with a 5x5 cross, iterating two times
  5877. ocv=filter_name=dilate:filter_params=5x5+2x2/cross|2
  5878. # Read the shape from the file diamond.shape, iterating two times.
  5879. # The file diamond.shape may contain a pattern of characters like this
  5880. # *
  5881. # ***
  5882. # *****
  5883. # ***
  5884. # *
  5885. # The specified columns and rows are ignored
  5886. # but the anchor point coordinates are not
  5887. ocv=dilate:0x0+2x2/custom=diamond.shape|2
  5888. @end example
  5889. @subsection erode
  5890. Erode an image by using a specific structuring element.
  5891. It corresponds to the libopencv function @code{cvErode}.
  5892. It accepts the parameters: @var{struct_el}:@var{nb_iterations},
  5893. with the same syntax and semantics as the @ref{dilate} filter.
  5894. @subsection smooth
  5895. Smooth the input video.
  5896. The filter takes the following parameters:
  5897. @var{type}|@var{param1}|@var{param2}|@var{param3}|@var{param4}.
  5898. @var{type} is the type of smooth filter to apply, and must be one of
  5899. the following values: "blur", "blur_no_scale", "median", "gaussian",
  5900. or "bilateral". The default value is "gaussian".
  5901. The meaning of @var{param1}, @var{param2}, @var{param3}, and @var{param4}
  5902. depend on the smooth type. @var{param1} and
  5903. @var{param2} accept integer positive values or 0. @var{param3} and
  5904. @var{param4} accept floating point values.
  5905. The default value for @var{param1} is 3. The default value for the
  5906. other parameters is 0.
  5907. These parameters correspond to the parameters assigned to the
  5908. libopencv function @code{cvSmooth}.
  5909. @anchor{overlay}
  5910. @section overlay
  5911. Overlay one video on top of another.
  5912. It takes two inputs and has one output. The first input is the "main"
  5913. video on which the second input is overlaid.
  5914. It accepts the following parameters:
  5915. A description of the accepted options follows.
  5916. @table @option
  5917. @item x
  5918. @item y
  5919. Set the expression for the x and y coordinates of the overlaid video
  5920. on the main video. Default value is "0" for both expressions. In case
  5921. the expression is invalid, it is set to a huge value (meaning that the
  5922. overlay will not be displayed within the output visible area).
  5923. @item eof_action
  5924. The action to take when EOF is encountered on the secondary input; it accepts
  5925. one of the following values:
  5926. @table @option
  5927. @item repeat
  5928. Repeat the last frame (the default).
  5929. @item endall
  5930. End both streams.
  5931. @item pass
  5932. Pass the main input through.
  5933. @end table
  5934. @item eval
  5935. Set when the expressions for @option{x}, and @option{y} are evaluated.
  5936. It accepts the following values:
  5937. @table @samp
  5938. @item init
  5939. only evaluate expressions once during the filter initialization or
  5940. when a command is processed
  5941. @item frame
  5942. evaluate expressions for each incoming frame
  5943. @end table
  5944. Default value is @samp{frame}.
  5945. @item shortest
  5946. If set to 1, force the output to terminate when the shortest input
  5947. terminates. Default value is 0.
  5948. @item format
  5949. Set the format for the output video.
  5950. It accepts the following values:
  5951. @table @samp
  5952. @item yuv420
  5953. force YUV420 output
  5954. @item yuv422
  5955. force YUV422 output
  5956. @item yuv444
  5957. force YUV444 output
  5958. @item rgb
  5959. force RGB output
  5960. @end table
  5961. Default value is @samp{yuv420}.
  5962. @item rgb @emph{(deprecated)}
  5963. If set to 1, force the filter to accept inputs in the RGB
  5964. color space. Default value is 0. This option is deprecated, use
  5965. @option{format} instead.
  5966. @item repeatlast
  5967. If set to 1, force the filter to draw the last overlay frame over the
  5968. main input until the end of the stream. A value of 0 disables this
  5969. behavior. Default value is 1.
  5970. @end table
  5971. The @option{x}, and @option{y} expressions can contain the following
  5972. parameters.
  5973. @table @option
  5974. @item main_w, W
  5975. @item main_h, H
  5976. The main input width and height.
  5977. @item overlay_w, w
  5978. @item overlay_h, h
  5979. The overlay input width and height.
  5980. @item x
  5981. @item y
  5982. The computed values for @var{x} and @var{y}. They are evaluated for
  5983. each new frame.
  5984. @item hsub
  5985. @item vsub
  5986. horizontal and vertical chroma subsample values of the output
  5987. format. For example for the pixel format "yuv422p" @var{hsub} is 2 and
  5988. @var{vsub} is 1.
  5989. @item n
  5990. the number of input frame, starting from 0
  5991. @item pos
  5992. the position in the file of the input frame, NAN if unknown
  5993. @item t
  5994. The timestamp, expressed in seconds. It's NAN if the input timestamp is unknown.
  5995. @end table
  5996. Note that the @var{n}, @var{pos}, @var{t} variables are available only
  5997. when evaluation is done @emph{per frame}, and will evaluate to NAN
  5998. when @option{eval} is set to @samp{init}.
  5999. Be aware that frames are taken from each input video in timestamp
  6000. order, hence, if their initial timestamps differ, it is a good idea
  6001. to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to
  6002. have them begin in the same zero timestamp, as the example for
  6003. the @var{movie} filter does.
  6004. You can chain together more overlays but you should test the
  6005. efficiency of such approach.
  6006. @subsection Commands
  6007. This filter supports the following commands:
  6008. @table @option
  6009. @item x
  6010. @item y
  6011. Modify the x and y of the overlay input.
  6012. The command accepts the same syntax of the corresponding option.
  6013. If the specified expression is not valid, it is kept at its current
  6014. value.
  6015. @end table
  6016. @subsection Examples
  6017. @itemize
  6018. @item
  6019. Draw the overlay at 10 pixels from the bottom right corner of the main
  6020. video:
  6021. @example
  6022. overlay=main_w-overlay_w-10:main_h-overlay_h-10
  6023. @end example
  6024. Using named options the example above becomes:
  6025. @example
  6026. overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10
  6027. @end example
  6028. @item
  6029. Insert a transparent PNG logo in the bottom left corner of the input,
  6030. using the @command{ffmpeg} tool with the @code{-filter_complex} option:
  6031. @example
  6032. ffmpeg -i input -i logo -filter_complex 'overlay=10:main_h-overlay_h-10' output
  6033. @end example
  6034. @item
  6035. Insert 2 different transparent PNG logos (second logo on bottom
  6036. right corner) using the @command{ffmpeg} tool:
  6037. @example
  6038. 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
  6039. @end example
  6040. @item
  6041. Add a transparent color layer on top of the main video; @code{WxH}
  6042. must specify the size of the main input to the overlay filter:
  6043. @example
  6044. color=color=red@@.3:size=WxH [over]; [in][over] overlay [out]
  6045. @end example
  6046. @item
  6047. Play an original video and a filtered version (here with the deshake
  6048. filter) side by side using the @command{ffplay} tool:
  6049. @example
  6050. ffplay input.avi -vf 'split[a][b]; [a]pad=iw*2:ih[src]; [b]deshake[filt]; [src][filt]overlay=w'
  6051. @end example
  6052. The above command is the same as:
  6053. @example
  6054. ffplay input.avi -vf 'split[b], pad=iw*2[src], [b]deshake, [src]overlay=w'
  6055. @end example
  6056. @item
  6057. Make a sliding overlay appearing from the left to the right top part of the
  6058. screen starting since time 2:
  6059. @example
  6060. overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0
  6061. @end example
  6062. @item
  6063. Compose output by putting two input videos side to side:
  6064. @example
  6065. ffmpeg -i left.avi -i right.avi -filter_complex "
  6066. nullsrc=size=200x100 [background];
  6067. [0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
  6068. [1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
  6069. [background][left] overlay=shortest=1 [background+left];
  6070. [background+left][right] overlay=shortest=1:x=100 [left+right]
  6071. "
  6072. @end example
  6073. @item
  6074. Mask 10-20 seconds of a video by applying the delogo filter to a section
  6075. @example
  6076. ffmpeg -i test.avi -codec:v:0 wmv2 -ar 11025 -b:v 9000k
  6077. -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]'
  6078. masked.avi
  6079. @end example
  6080. @item
  6081. Chain several overlays in cascade:
  6082. @example
  6083. nullsrc=s=200x200 [bg];
  6084. testsrc=s=100x100, split=4 [in0][in1][in2][in3];
  6085. [in0] lutrgb=r=0, [bg] overlay=0:0 [mid0];
  6086. [in1] lutrgb=g=0, [mid0] overlay=100:0 [mid1];
  6087. [in2] lutrgb=b=0, [mid1] overlay=0:100 [mid2];
  6088. [in3] null, [mid2] overlay=100:100 [out0]
  6089. @end example
  6090. @end itemize
  6091. @section owdenoise
  6092. Apply Overcomplete Wavelet denoiser.
  6093. The filter accepts the following options:
  6094. @table @option
  6095. @item depth
  6096. Set depth.
  6097. Larger depth values will denoise lower frequency components more, but
  6098. slow down filtering.
  6099. Must be an int in the range 8-16, default is @code{8}.
  6100. @item luma_strength, ls
  6101. Set luma strength.
  6102. Must be a double value in the range 0-1000, default is @code{1.0}.
  6103. @item chroma_strength, cs
  6104. Set chroma strength.
  6105. Must be a double value in the range 0-1000, default is @code{1.0}.
  6106. @end table
  6107. @anchor{pad}
  6108. @section pad
  6109. Add paddings to the input image, and place the original input at the
  6110. provided @var{x}, @var{y} coordinates.
  6111. It accepts the following parameters:
  6112. @table @option
  6113. @item width, w
  6114. @item height, h
  6115. Specify an expression for the size of the output image with the
  6116. paddings added. If the value for @var{width} or @var{height} is 0, the
  6117. corresponding input size is used for the output.
  6118. The @var{width} expression can reference the value set by the
  6119. @var{height} expression, and vice versa.
  6120. The default value of @var{width} and @var{height} is 0.
  6121. @item x
  6122. @item y
  6123. Specify the offsets to place the input image at within the padded area,
  6124. with respect to the top/left border of the output image.
  6125. The @var{x} expression can reference the value set by the @var{y}
  6126. expression, and vice versa.
  6127. The default value of @var{x} and @var{y} is 0.
  6128. @item color
  6129. Specify the color of the padded area. For the syntax of this option,
  6130. check the "Color" section in the ffmpeg-utils manual.
  6131. The default value of @var{color} is "black".
  6132. @end table
  6133. The value for the @var{width}, @var{height}, @var{x}, and @var{y}
  6134. options are expressions containing the following constants:
  6135. @table @option
  6136. @item in_w
  6137. @item in_h
  6138. The input video width and height.
  6139. @item iw
  6140. @item ih
  6141. These are the same as @var{in_w} and @var{in_h}.
  6142. @item out_w
  6143. @item out_h
  6144. The output width and height (the size of the padded area), as
  6145. specified by the @var{width} and @var{height} expressions.
  6146. @item ow
  6147. @item oh
  6148. These are the same as @var{out_w} and @var{out_h}.
  6149. @item x
  6150. @item y
  6151. The x and y offsets as specified by the @var{x} and @var{y}
  6152. expressions, or NAN if not yet specified.
  6153. @item a
  6154. same as @var{iw} / @var{ih}
  6155. @item sar
  6156. input sample aspect ratio
  6157. @item dar
  6158. input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
  6159. @item hsub
  6160. @item vsub
  6161. The horizontal and vertical chroma subsample values. For example for the
  6162. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6163. @end table
  6164. @subsection Examples
  6165. @itemize
  6166. @item
  6167. Add paddings with the color "violet" to the input video. The output video
  6168. size is 640x480, and the top-left corner of the input video is placed at
  6169. column 0, row 40
  6170. @example
  6171. pad=640:480:0:40:violet
  6172. @end example
  6173. The example above is equivalent to the following command:
  6174. @example
  6175. pad=width=640:height=480:x=0:y=40:color=violet
  6176. @end example
  6177. @item
  6178. Pad the input to get an output with dimensions increased by 3/2,
  6179. and put the input video at the center of the padded area:
  6180. @example
  6181. pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2"
  6182. @end example
  6183. @item
  6184. Pad the input to get a squared output with size equal to the maximum
  6185. value between the input width and height, and put the input video at
  6186. the center of the padded area:
  6187. @example
  6188. pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2"
  6189. @end example
  6190. @item
  6191. Pad the input to get a final w/h ratio of 16:9:
  6192. @example
  6193. pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2"
  6194. @end example
  6195. @item
  6196. In case of anamorphic video, in order to set the output display aspect
  6197. correctly, it is necessary to use @var{sar} in the expression,
  6198. according to the relation:
  6199. @example
  6200. (ih * X / ih) * sar = output_dar
  6201. X = output_dar / sar
  6202. @end example
  6203. Thus the previous example needs to be modified to:
  6204. @example
  6205. pad="ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2"
  6206. @end example
  6207. @item
  6208. Double the output size and put the input video in the bottom-right
  6209. corner of the output padded area:
  6210. @example
  6211. pad="2*iw:2*ih:ow-iw:oh-ih"
  6212. @end example
  6213. @end itemize
  6214. @anchor{palettegen}
  6215. @section palettegen
  6216. Generate one palette for a whole video stream.
  6217. It accepts the following options:
  6218. @table @option
  6219. @item max_colors
  6220. Set the maximum number of colors to quantize in the palette.
  6221. Note: the palette will still contain 256 colors; the unused palette entries
  6222. will be black.
  6223. @item reserve_transparent
  6224. Create a palette of 255 colors maximum and reserve the last one for
  6225. transparency. Reserving the transparency color is useful for GIF optimization.
  6226. If not set, the maximum of colors in the palette will be 256. You probably want
  6227. to disable this option for a standalone image.
  6228. Set by default.
  6229. @item stats_mode
  6230. Set statistics mode.
  6231. It accepts the following values:
  6232. @table @samp
  6233. @item full
  6234. Compute full frame histograms.
  6235. @item diff
  6236. Compute histograms only for the part that differs from previous frame. This
  6237. might be relevant to give more importance to the moving part of your input if
  6238. the background is static.
  6239. @end table
  6240. Default value is @var{full}.
  6241. @end table
  6242. The filter also exports the frame metadata @code{lavfi.color_quant_ratio}
  6243. (@code{nb_color_in / nb_color_out}) which you can use to evaluate the degree of
  6244. color quantization of the palette. This information is also visible at
  6245. @var{info} logging level.
  6246. @subsection Examples
  6247. @itemize
  6248. @item
  6249. Generate a representative palette of a given video using @command{ffmpeg}:
  6250. @example
  6251. ffmpeg -i input.mkv -vf palettegen palette.png
  6252. @end example
  6253. @end itemize
  6254. @section paletteuse
  6255. Use a palette to downsample an input video stream.
  6256. The filter takes two inputs: one video stream and a palette. The palette must
  6257. be a 256 pixels image.
  6258. It accepts the following options:
  6259. @table @option
  6260. @item dither
  6261. Select dithering mode. Available algorithms are:
  6262. @table @samp
  6263. @item bayer
  6264. Ordered 8x8 bayer dithering (deterministic)
  6265. @item heckbert
  6266. Dithering as defined by Paul Heckbert in 1982 (simple error diffusion).
  6267. Note: this dithering is sometimes considered "wrong" and is included as a
  6268. reference.
  6269. @item floyd_steinberg
  6270. Floyd and Steingberg dithering (error diffusion)
  6271. @item sierra2
  6272. Frankie Sierra dithering v2 (error diffusion)
  6273. @item sierra2_4a
  6274. Frankie Sierra dithering v2 "Lite" (error diffusion)
  6275. @end table
  6276. Default is @var{sierra2_4a}.
  6277. @item bayer_scale
  6278. When @var{bayer} dithering is selected, this option defines the scale of the
  6279. pattern (how much the crosshatch pattern is visible). A low value means more
  6280. visible pattern for less banding, and higher value means less visible pattern
  6281. at the cost of more banding.
  6282. The option must be an integer value in the range [0,5]. Default is @var{2}.
  6283. @item diff_mode
  6284. If set, define the zone to process
  6285. @table @samp
  6286. @item rectangle
  6287. Only the changing rectangle will be reprocessed. This is similar to GIF
  6288. cropping/offsetting compression mechanism. This option can be useful for speed
  6289. if only a part of the image is changing, and has use cases such as limiting the
  6290. scope of the error diffusal @option{dither} to the rectangle that bounds the
  6291. moving scene (it leads to more deterministic output if the scene doesn't change
  6292. much, and as a result less moving noise and better GIF compression).
  6293. @end table
  6294. Default is @var{none}.
  6295. @end table
  6296. @subsection Examples
  6297. @itemize
  6298. @item
  6299. Use a palette (generated for example with @ref{palettegen}) to encode a GIF
  6300. using @command{ffmpeg}:
  6301. @example
  6302. ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
  6303. @end example
  6304. @end itemize
  6305. @section perspective
  6306. Correct perspective of video not recorded perpendicular to the screen.
  6307. A description of the accepted parameters follows.
  6308. @table @option
  6309. @item x0
  6310. @item y0
  6311. @item x1
  6312. @item y1
  6313. @item x2
  6314. @item y2
  6315. @item x3
  6316. @item y3
  6317. Set coordinates expression for top left, top right, bottom left and bottom right corners.
  6318. Default values are @code{0:0:W:0:0:H:W:H} with which perspective will remain unchanged.
  6319. If the @code{sense} option is set to @code{source}, then the specified points will be sent
  6320. to the corners of the destination. If the @code{sense} option is set to @code{destination},
  6321. then the corners of the source will be sent to the specified coordinates.
  6322. The expressions can use the following variables:
  6323. @table @option
  6324. @item W
  6325. @item H
  6326. the width and height of video frame.
  6327. @end table
  6328. @item interpolation
  6329. Set interpolation for perspective correction.
  6330. It accepts the following values:
  6331. @table @samp
  6332. @item linear
  6333. @item cubic
  6334. @end table
  6335. Default value is @samp{linear}.
  6336. @item sense
  6337. Set interpretation of coordinate options.
  6338. It accepts the following values:
  6339. @table @samp
  6340. @item 0, source
  6341. Send point in the source specified by the given coordinates to
  6342. the corners of the destination.
  6343. @item 1, destination
  6344. Send the corners of the source to the point in the destination specified
  6345. by the given coordinates.
  6346. Default value is @samp{source}.
  6347. @end table
  6348. @end table
  6349. @section phase
  6350. Delay interlaced video by one field time so that the field order changes.
  6351. The intended use is to fix PAL movies that have been captured with the
  6352. opposite field order to the film-to-video transfer.
  6353. A description of the accepted parameters follows.
  6354. @table @option
  6355. @item mode
  6356. Set phase mode.
  6357. It accepts the following values:
  6358. @table @samp
  6359. @item t
  6360. Capture field order top-first, transfer bottom-first.
  6361. Filter will delay the bottom field.
  6362. @item b
  6363. Capture field order bottom-first, transfer top-first.
  6364. Filter will delay the top field.
  6365. @item p
  6366. Capture and transfer with the same field order. This mode only exists
  6367. for the documentation of the other options to refer to, but if you
  6368. actually select it, the filter will faithfully do nothing.
  6369. @item a
  6370. Capture field order determined automatically by field flags, transfer
  6371. opposite.
  6372. Filter selects among @samp{t} and @samp{b} modes on a frame by frame
  6373. basis using field flags. If no field information is available,
  6374. then this works just like @samp{u}.
  6375. @item u
  6376. Capture unknown or varying, transfer opposite.
  6377. Filter selects among @samp{t} and @samp{b} on a frame by frame basis by
  6378. analyzing the images and selecting the alternative that produces best
  6379. match between the fields.
  6380. @item T
  6381. Capture top-first, transfer unknown or varying.
  6382. Filter selects among @samp{t} and @samp{p} using image analysis.
  6383. @item B
  6384. Capture bottom-first, transfer unknown or varying.
  6385. Filter selects among @samp{b} and @samp{p} using image analysis.
  6386. @item A
  6387. Capture determined by field flags, transfer unknown or varying.
  6388. Filter selects among @samp{t}, @samp{b} and @samp{p} using field flags and
  6389. image analysis. If no field information is available, then this works just
  6390. like @samp{U}. This is the default mode.
  6391. @item U
  6392. Both capture and transfer unknown or varying.
  6393. Filter selects among @samp{t}, @samp{b} and @samp{p} using image analysis only.
  6394. @end table
  6395. @end table
  6396. @section pixdesctest
  6397. Pixel format descriptor test filter, mainly useful for internal
  6398. testing. The output video should be equal to the input video.
  6399. For example:
  6400. @example
  6401. format=monow, pixdesctest
  6402. @end example
  6403. can be used to test the monowhite pixel format descriptor definition.
  6404. @section pp
  6405. Enable the specified chain of postprocessing subfilters using libpostproc. This
  6406. library should be automatically selected with a GPL build (@code{--enable-gpl}).
  6407. Subfilters must be separated by '/' and can be disabled by prepending a '-'.
  6408. Each subfilter and some options have a short and a long name that can be used
  6409. interchangeably, i.e. dr/dering are the same.
  6410. The filters accept the following options:
  6411. @table @option
  6412. @item subfilters
  6413. Set postprocessing subfilters string.
  6414. @end table
  6415. All subfilters share common options to determine their scope:
  6416. @table @option
  6417. @item a/autoq
  6418. Honor the quality commands for this subfilter.
  6419. @item c/chrom
  6420. Do chrominance filtering, too (default).
  6421. @item y/nochrom
  6422. Do luminance filtering only (no chrominance).
  6423. @item n/noluma
  6424. Do chrominance filtering only (no luminance).
  6425. @end table
  6426. These options can be appended after the subfilter name, separated by a '|'.
  6427. Available subfilters are:
  6428. @table @option
  6429. @item hb/hdeblock[|difference[|flatness]]
  6430. Horizontal deblocking filter
  6431. @table @option
  6432. @item difference
  6433. Difference factor where higher values mean more deblocking (default: @code{32}).
  6434. @item flatness
  6435. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6436. @end table
  6437. @item vb/vdeblock[|difference[|flatness]]
  6438. Vertical deblocking filter
  6439. @table @option
  6440. @item difference
  6441. Difference factor where higher values mean more deblocking (default: @code{32}).
  6442. @item flatness
  6443. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6444. @end table
  6445. @item ha/hadeblock[|difference[|flatness]]
  6446. Accurate horizontal deblocking filter
  6447. @table @option
  6448. @item difference
  6449. Difference factor where higher values mean more deblocking (default: @code{32}).
  6450. @item flatness
  6451. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6452. @end table
  6453. @item va/vadeblock[|difference[|flatness]]
  6454. Accurate vertical deblocking filter
  6455. @table @option
  6456. @item difference
  6457. Difference factor where higher values mean more deblocking (default: @code{32}).
  6458. @item flatness
  6459. Flatness threshold where lower values mean more deblocking (default: @code{39}).
  6460. @end table
  6461. @end table
  6462. The horizontal and vertical deblocking filters share the difference and
  6463. flatness values so you cannot set different horizontal and vertical
  6464. thresholds.
  6465. @table @option
  6466. @item h1/x1hdeblock
  6467. Experimental horizontal deblocking filter
  6468. @item v1/x1vdeblock
  6469. Experimental vertical deblocking filter
  6470. @item dr/dering
  6471. Deringing filter
  6472. @item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
  6473. @table @option
  6474. @item threshold1
  6475. larger -> stronger filtering
  6476. @item threshold2
  6477. larger -> stronger filtering
  6478. @item threshold3
  6479. larger -> stronger filtering
  6480. @end table
  6481. @item al/autolevels[:f/fullyrange], automatic brightness / contrast correction
  6482. @table @option
  6483. @item f/fullyrange
  6484. Stretch luminance to @code{0-255}.
  6485. @end table
  6486. @item lb/linblenddeint
  6487. Linear blend deinterlacing filter that deinterlaces the given block by
  6488. filtering all lines with a @code{(1 2 1)} filter.
  6489. @item li/linipoldeint
  6490. Linear interpolating deinterlacing filter that deinterlaces the given block by
  6491. linearly interpolating every second line.
  6492. @item ci/cubicipoldeint
  6493. Cubic interpolating deinterlacing filter deinterlaces the given block by
  6494. cubically interpolating every second line.
  6495. @item md/mediandeint
  6496. Median deinterlacing filter that deinterlaces the given block by applying a
  6497. median filter to every second line.
  6498. @item fd/ffmpegdeint
  6499. FFmpeg deinterlacing filter that deinterlaces the given block by filtering every
  6500. second line with a @code{(-1 4 2 4 -1)} filter.
  6501. @item l5/lowpass5
  6502. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
  6503. block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
  6504. @item fq/forceQuant[|quantizer]
  6505. Overrides the quantizer table from the input with the constant quantizer you
  6506. specify.
  6507. @table @option
  6508. @item quantizer
  6509. Quantizer to use
  6510. @end table
  6511. @item de/default
  6512. Default pp filter combination (@code{hb|a,vb|a,dr|a})
  6513. @item fa/fast
  6514. Fast pp filter combination (@code{h1|a,v1|a,dr|a})
  6515. @item ac
  6516. High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
  6517. @end table
  6518. @subsection Examples
  6519. @itemize
  6520. @item
  6521. Apply horizontal and vertical deblocking, deringing and automatic
  6522. brightness/contrast:
  6523. @example
  6524. pp=hb/vb/dr/al
  6525. @end example
  6526. @item
  6527. Apply default filters without brightness/contrast correction:
  6528. @example
  6529. pp=de/-al
  6530. @end example
  6531. @item
  6532. Apply default filters and temporal denoiser:
  6533. @example
  6534. pp=default/tmpnoise|1|2|3
  6535. @end example
  6536. @item
  6537. Apply deblocking on luminance only, and switch vertical deblocking on or off
  6538. automatically depending on available CPU time:
  6539. @example
  6540. pp=hb|y/vb|a
  6541. @end example
  6542. @end itemize
  6543. @section pp7
  6544. Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
  6545. similar to spp = 6 with 7 point DCT, where only the center sample is
  6546. used after IDCT.
  6547. The filter accepts the following options:
  6548. @table @option
  6549. @item qp
  6550. Force a constant quantization parameter. It accepts an integer in range
  6551. 0 to 63. If not set, the filter will use the QP from the video stream
  6552. (if available).
  6553. @item mode
  6554. Set thresholding mode. Available modes are:
  6555. @table @samp
  6556. @item hard
  6557. Set hard thresholding.
  6558. @item soft
  6559. Set soft thresholding (better de-ringing effect, but likely blurrier).
  6560. @item medium
  6561. Set medium thresholding (good results, default).
  6562. @end table
  6563. @end table
  6564. @section psnr
  6565. Obtain the average, maximum and minimum PSNR (Peak Signal to Noise
  6566. Ratio) between two input videos.
  6567. This filter takes in input two input videos, the first input is
  6568. considered the "main" source and is passed unchanged to the
  6569. output. The second input is used as a "reference" video for computing
  6570. the PSNR.
  6571. Both video inputs must have the same resolution and pixel format for
  6572. this filter to work correctly. Also it assumes that both inputs
  6573. have the same number of frames, which are compared one by one.
  6574. The obtained average PSNR is printed through the logging system.
  6575. The filter stores the accumulated MSE (mean squared error) of each
  6576. frame, and at the end of the processing it is averaged across all frames
  6577. equally, and the following formula is applied to obtain the PSNR:
  6578. @example
  6579. PSNR = 10*log10(MAX^2/MSE)
  6580. @end example
  6581. Where MAX is the average of the maximum values of each component of the
  6582. image.
  6583. The description of the accepted parameters follows.
  6584. @table @option
  6585. @item stats_file, f
  6586. If specified the filter will use the named file to save the PSNR of
  6587. each individual frame.
  6588. @end table
  6589. The file printed if @var{stats_file} is selected, contains a sequence of
  6590. key/value pairs of the form @var{key}:@var{value} for each compared
  6591. couple of frames.
  6592. A description of each shown parameter follows:
  6593. @table @option
  6594. @item n
  6595. sequential number of the input frame, starting from 1
  6596. @item mse_avg
  6597. Mean Square Error pixel-by-pixel average difference of the compared
  6598. frames, averaged over all the image components.
  6599. @item mse_y, mse_u, mse_v, mse_r, mse_g, mse_g, mse_a
  6600. Mean Square Error pixel-by-pixel average difference of the compared
  6601. frames for the component specified by the suffix.
  6602. @item psnr_y, psnr_u, psnr_v, psnr_r, psnr_g, psnr_b, psnr_a
  6603. Peak Signal to Noise ratio of the compared frames for the component
  6604. specified by the suffix.
  6605. @end table
  6606. For example:
  6607. @example
  6608. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  6609. [main][ref] psnr="stats_file=stats.log" [out]
  6610. @end example
  6611. On this example the input file being processed is compared with the
  6612. reference file @file{ref_movie.mpg}. The PSNR of each individual frame
  6613. is stored in @file{stats.log}.
  6614. @anchor{pullup}
  6615. @section pullup
  6616. Pulldown reversal (inverse telecine) filter, capable of handling mixed
  6617. hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
  6618. content.
  6619. The pullup filter is designed to take advantage of future context in making
  6620. its decisions. This filter is stateless in the sense that it does not lock
  6621. onto a pattern to follow, but it instead looks forward to the following
  6622. fields in order to identify matches and rebuild progressive frames.
  6623. To produce content with an even framerate, insert the fps filter after
  6624. pullup, use @code{fps=24000/1001} if the input frame rate is 29.97fps,
  6625. @code{fps=24} for 30fps and the (rare) telecined 25fps input.
  6626. The filter accepts the following options:
  6627. @table @option
  6628. @item jl
  6629. @item jr
  6630. @item jt
  6631. @item jb
  6632. These options set the amount of "junk" to ignore at the left, right, top, and
  6633. bottom of the image, respectively. Left and right are in units of 8 pixels,
  6634. while top and bottom are in units of 2 lines.
  6635. The default is 8 pixels on each side.
  6636. @item sb
  6637. Set the strict breaks. Setting this option to 1 will reduce the chances of
  6638. filter generating an occasional mismatched frame, but it may also cause an
  6639. excessive number of frames to be dropped during high motion sequences.
  6640. Conversely, setting it to -1 will make filter match fields more easily.
  6641. This may help processing of video where there is slight blurring between
  6642. the fields, but may also cause there to be interlaced frames in the output.
  6643. Default value is @code{0}.
  6644. @item mp
  6645. Set the metric plane to use. It accepts the following values:
  6646. @table @samp
  6647. @item l
  6648. Use luma plane.
  6649. @item u
  6650. Use chroma blue plane.
  6651. @item v
  6652. Use chroma red plane.
  6653. @end table
  6654. This option may be set to use chroma plane instead of the default luma plane
  6655. for doing filter's computations. This may improve accuracy on very clean
  6656. source material, but more likely will decrease accuracy, especially if there
  6657. is chroma noise (rainbow effect) or any grayscale video.
  6658. The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
  6659. load and make pullup usable in realtime on slow machines.
  6660. @end table
  6661. For best results (without duplicated frames in the output file) it is
  6662. necessary to change the output frame rate. For example, to inverse
  6663. telecine NTSC input:
  6664. @example
  6665. ffmpeg -i input -vf pullup -r 24000/1001 ...
  6666. @end example
  6667. @section qp
  6668. Change video quantization parameters (QP).
  6669. The filter accepts the following option:
  6670. @table @option
  6671. @item qp
  6672. Set expression for quantization parameter.
  6673. @end table
  6674. The expression is evaluated through the eval API and can contain, among others,
  6675. the following constants:
  6676. @table @var
  6677. @item known
  6678. 1 if index is not 129, 0 otherwise.
  6679. @item qp
  6680. Sequentional index starting from -129 to 128.
  6681. @end table
  6682. @subsection Examples
  6683. @itemize
  6684. @item
  6685. Some equation like:
  6686. @example
  6687. qp=2+2*sin(PI*qp)
  6688. @end example
  6689. @end itemize
  6690. @section random
  6691. Flush video frames from internal cache of frames into a random order.
  6692. No frame is discarded.
  6693. Inspired by @ref{frei0r} nervous filter.
  6694. @table @option
  6695. @item frames
  6696. Set size in number of frames of internal cache, in range from @code{2} to
  6697. @code{512}. Default is @code{30}.
  6698. @item seed
  6699. Set seed for random number generator, must be an integer included between
  6700. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  6701. less than @code{0}, the filter will try to use a good random seed on a
  6702. best effort basis.
  6703. @end table
  6704. @section removegrain
  6705. The removegrain filter is a spatial denoiser for progressive video.
  6706. @table @option
  6707. @item m0
  6708. Set mode for the first plane.
  6709. @item m1
  6710. Set mode for the second plane.
  6711. @item m2
  6712. Set mode for the third plane.
  6713. @item m3
  6714. Set mode for the fourth plane.
  6715. @end table
  6716. Range of mode is from 0 to 24. Description of each mode follows:
  6717. @table @var
  6718. @item 0
  6719. Leave input plane unchanged. Default.
  6720. @item 1
  6721. Clips the pixel with the minimum and maximum of the 8 neighbour pixels.
  6722. @item 2
  6723. Clips the pixel with the second minimum and maximum of the 8 neighbour pixels.
  6724. @item 3
  6725. Clips the pixel with the third minimum and maximum of the 8 neighbour pixels.
  6726. @item 4
  6727. Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels.
  6728. This is equivalent to a median filter.
  6729. @item 5
  6730. Line-sensitive clipping giving the minimal change.
  6731. @item 6
  6732. Line-sensitive clipping, intermediate.
  6733. @item 7
  6734. Line-sensitive clipping, intermediate.
  6735. @item 8
  6736. Line-sensitive clipping, intermediate.
  6737. @item 9
  6738. Line-sensitive clipping on a line where the neighbours pixels are the closest.
  6739. @item 10
  6740. Replaces the target pixel with the closest neighbour.
  6741. @item 11
  6742. [1 2 1] horizontal and vertical kernel blur.
  6743. @item 12
  6744. Same as mode 11.
  6745. @item 13
  6746. Bob mode, interpolates top field from the line where the neighbours
  6747. pixels are the closest.
  6748. @item 14
  6749. Bob mode, interpolates bottom field from the line where the neighbours
  6750. pixels are the closest.
  6751. @item 15
  6752. Bob mode, interpolates top field. Same as 13 but with a more complicated
  6753. interpolation formula.
  6754. @item 16
  6755. Bob mode, interpolates bottom field. Same as 14 but with a more complicated
  6756. interpolation formula.
  6757. @item 17
  6758. Clips the pixel with the minimum and maximum of respectively the maximum and
  6759. minimum of each pair of opposite neighbour pixels.
  6760. @item 18
  6761. Line-sensitive clipping using opposite neighbours whose greatest distance from
  6762. the current pixel is minimal.
  6763. @item 19
  6764. Replaces the pixel with the average of its 8 neighbours.
  6765. @item 20
  6766. Averages the 9 pixels ([1 1 1] horizontal and vertical blur).
  6767. @item 21
  6768. Clips pixels using the averages of opposite neighbour.
  6769. @item 22
  6770. Same as mode 21 but simpler and faster.
  6771. @item 23
  6772. Small edge and halo removal, but reputed useless.
  6773. @item 24
  6774. Similar as 23.
  6775. @end table
  6776. @section removelogo
  6777. Suppress a TV station logo, using an image file to determine which
  6778. pixels comprise the logo. It works by filling in the pixels that
  6779. comprise the logo with neighboring pixels.
  6780. The filter accepts the following options:
  6781. @table @option
  6782. @item filename, f
  6783. Set the filter bitmap file, which can be any image format supported by
  6784. libavformat. The width and height of the image file must match those of the
  6785. video stream being processed.
  6786. @end table
  6787. Pixels in the provided bitmap image with a value of zero are not
  6788. considered part of the logo, non-zero pixels are considered part of
  6789. the logo. If you use white (255) for the logo and black (0) for the
  6790. rest, you will be safe. For making the filter bitmap, it is
  6791. recommended to take a screen capture of a black frame with the logo
  6792. visible, and then using a threshold filter followed by the erode
  6793. filter once or twice.
  6794. If needed, little splotches can be fixed manually. Remember that if
  6795. logo pixels are not covered, the filter quality will be much
  6796. reduced. Marking too many pixels as part of the logo does not hurt as
  6797. much, but it will increase the amount of blurring needed to cover over
  6798. the image and will destroy more information than necessary, and extra
  6799. pixels will slow things down on a large logo.
  6800. @section repeatfields
  6801. This filter uses the repeat_field flag from the Video ES headers and hard repeats
  6802. fields based on its value.
  6803. @section reverse, areverse
  6804. Reverse a clip.
  6805. Warning: This filter requires memory to buffer the entire clip, so trimming
  6806. is suggested.
  6807. @subsection Examples
  6808. @itemize
  6809. @item
  6810. Take the first 5 seconds of a clip, and reverse it.
  6811. @example
  6812. trim=end=5,reverse
  6813. @end example
  6814. @end itemize
  6815. @section rotate
  6816. Rotate video by an arbitrary angle expressed in radians.
  6817. The filter accepts the following options:
  6818. A description of the optional parameters follows.
  6819. @table @option
  6820. @item angle, a
  6821. Set an expression for the angle by which to rotate the input video
  6822. clockwise, expressed as a number of radians. A negative value will
  6823. result in a counter-clockwise rotation. By default it is set to "0".
  6824. This expression is evaluated for each frame.
  6825. @item out_w, ow
  6826. Set the output width expression, default value is "iw".
  6827. This expression is evaluated just once during configuration.
  6828. @item out_h, oh
  6829. Set the output height expression, default value is "ih".
  6830. This expression is evaluated just once during configuration.
  6831. @item bilinear
  6832. Enable bilinear interpolation if set to 1, a value of 0 disables
  6833. it. Default value is 1.
  6834. @item fillcolor, c
  6835. Set the color used to fill the output area not covered by the rotated
  6836. image. For the general syntax of this option, check the "Color" section in the
  6837. ffmpeg-utils manual. If the special value "none" is selected then no
  6838. background is printed (useful for example if the background is never shown).
  6839. Default value is "black".
  6840. @end table
  6841. The expressions for the angle and the output size can contain the
  6842. following constants and functions:
  6843. @table @option
  6844. @item n
  6845. sequential number of the input frame, starting from 0. It is always NAN
  6846. before the first frame is filtered.
  6847. @item t
  6848. time in seconds of the input frame, it is set to 0 when the filter is
  6849. configured. It is always NAN before the first frame is filtered.
  6850. @item hsub
  6851. @item vsub
  6852. horizontal and vertical chroma subsample values. For example for the
  6853. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  6854. @item in_w, iw
  6855. @item in_h, ih
  6856. the input video width and height
  6857. @item out_w, ow
  6858. @item out_h, oh
  6859. the output width and height, that is the size of the padded area as
  6860. specified by the @var{width} and @var{height} expressions
  6861. @item rotw(a)
  6862. @item roth(a)
  6863. the minimal width/height required for completely containing the input
  6864. video rotated by @var{a} radians.
  6865. These are only available when computing the @option{out_w} and
  6866. @option{out_h} expressions.
  6867. @end table
  6868. @subsection Examples
  6869. @itemize
  6870. @item
  6871. Rotate the input by PI/6 radians clockwise:
  6872. @example
  6873. rotate=PI/6
  6874. @end example
  6875. @item
  6876. Rotate the input by PI/6 radians counter-clockwise:
  6877. @example
  6878. rotate=-PI/6
  6879. @end example
  6880. @item
  6881. Rotate the input by 45 degrees clockwise:
  6882. @example
  6883. rotate=45*PI/180
  6884. @end example
  6885. @item
  6886. Apply a constant rotation with period T, starting from an angle of PI/3:
  6887. @example
  6888. rotate=PI/3+2*PI*t/T
  6889. @end example
  6890. @item
  6891. Make the input video rotation oscillating with a period of T
  6892. seconds and an amplitude of A radians:
  6893. @example
  6894. rotate=A*sin(2*PI/T*t)
  6895. @end example
  6896. @item
  6897. Rotate the video, output size is chosen so that the whole rotating
  6898. input video is always completely contained in the output:
  6899. @example
  6900. rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
  6901. @end example
  6902. @item
  6903. Rotate the video, reduce the output size so that no background is ever
  6904. shown:
  6905. @example
  6906. rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
  6907. @end example
  6908. @end itemize
  6909. @subsection Commands
  6910. The filter supports the following commands:
  6911. @table @option
  6912. @item a, angle
  6913. Set the angle expression.
  6914. The command accepts the same syntax of the corresponding option.
  6915. If the specified expression is not valid, it is kept at its current
  6916. value.
  6917. @end table
  6918. @section sab
  6919. Apply Shape Adaptive Blur.
  6920. The filter accepts the following options:
  6921. @table @option
  6922. @item luma_radius, lr
  6923. Set luma blur filter strength, must be a value in range 0.1-4.0, default
  6924. value is 1.0. A greater value will result in a more blurred image, and
  6925. in slower processing.
  6926. @item luma_pre_filter_radius, lpfr
  6927. Set luma pre-filter radius, must be a value in the 0.1-2.0 range, default
  6928. value is 1.0.
  6929. @item luma_strength, ls
  6930. Set luma maximum difference between pixels to still be considered, must
  6931. be a value in the 0.1-100.0 range, default value is 1.0.
  6932. @item chroma_radius, cr
  6933. Set chroma blur filter strength, must be a value in range 0.1-4.0. A
  6934. greater value will result in a more blurred image, and in slower
  6935. processing.
  6936. @item chroma_pre_filter_radius, cpfr
  6937. Set chroma pre-filter radius, must be a value in the 0.1-2.0 range.
  6938. @item chroma_strength, cs
  6939. Set chroma maximum difference between pixels to still be considered,
  6940. must be a value in the 0.1-100.0 range.
  6941. @end table
  6942. Each chroma option value, if not explicitly specified, is set to the
  6943. corresponding luma option value.
  6944. @anchor{scale}
  6945. @section scale
  6946. Scale (resize) the input video, using the libswscale library.
  6947. The scale filter forces the output display aspect ratio to be the same
  6948. of the input, by changing the output sample aspect ratio.
  6949. If the input image format is different from the format requested by
  6950. the next filter, the scale filter will convert the input to the
  6951. requested format.
  6952. @subsection Options
  6953. The filter accepts the following options, or any of the options
  6954. supported by the libswscale scaler.
  6955. See @ref{scaler_options,,the ffmpeg-scaler manual,ffmpeg-scaler} for
  6956. the complete list of scaler options.
  6957. @table @option
  6958. @item width, w
  6959. @item height, h
  6960. Set the output video dimension expression. Default value is the input
  6961. dimension.
  6962. If the value is 0, the input width is used for the output.
  6963. If one of the values is -1, the scale filter will use a value that
  6964. maintains the aspect ratio of the input image, calculated from the
  6965. other specified dimension. If both of them are -1, the input size is
  6966. used
  6967. If one of the values is -n with n > 1, the scale filter will also use a value
  6968. that maintains the aspect ratio of the input image, calculated from the other
  6969. specified dimension. After that it will, however, make sure that the calculated
  6970. dimension is divisible by n and adjust the value if necessary.
  6971. See below for the list of accepted constants for use in the dimension
  6972. expression.
  6973. @item interl
  6974. Set the interlacing mode. It accepts the following values:
  6975. @table @samp
  6976. @item 1
  6977. Force interlaced aware scaling.
  6978. @item 0
  6979. Do not apply interlaced scaling.
  6980. @item -1
  6981. Select interlaced aware scaling depending on whether the source frames
  6982. are flagged as interlaced or not.
  6983. @end table
  6984. Default value is @samp{0}.
  6985. @item flags
  6986. Set libswscale scaling flags. See
  6987. @ref{sws_flags,,the ffmpeg-scaler manual,ffmpeg-scaler} for the
  6988. complete list of values. If not explicitly specified the filter applies
  6989. the default flags.
  6990. @item size, s
  6991. Set the video size. For the syntax of this option, check the
  6992. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  6993. @item in_color_matrix
  6994. @item out_color_matrix
  6995. Set in/output YCbCr color space type.
  6996. This allows the autodetected value to be overridden as well as allows forcing
  6997. a specific value used for the output and encoder.
  6998. If not specified, the color space type depends on the pixel format.
  6999. Possible values:
  7000. @table @samp
  7001. @item auto
  7002. Choose automatically.
  7003. @item bt709
  7004. Format conforming to International Telecommunication Union (ITU)
  7005. Recommendation BT.709.
  7006. @item fcc
  7007. Set color space conforming to the United States Federal Communications
  7008. Commission (FCC) Code of Federal Regulations (CFR) Title 47 (2003) 73.682 (a).
  7009. @item bt601
  7010. Set color space conforming to:
  7011. @itemize
  7012. @item
  7013. ITU Radiocommunication Sector (ITU-R) Recommendation BT.601
  7014. @item
  7015. ITU-R Rec. BT.470-6 (1998) Systems B, B1, and G
  7016. @item
  7017. Society of Motion Picture and Television Engineers (SMPTE) ST 170:2004
  7018. @end itemize
  7019. @item smpte240m
  7020. Set color space conforming to SMPTE ST 240:1999.
  7021. @end table
  7022. @item in_range
  7023. @item out_range
  7024. Set in/output YCbCr sample range.
  7025. This allows the autodetected value to be overridden as well as allows forcing
  7026. a specific value used for the output and encoder. If not specified, the
  7027. range depends on the pixel format. Possible values:
  7028. @table @samp
  7029. @item auto
  7030. Choose automatically.
  7031. @item jpeg/full/pc
  7032. Set full range (0-255 in case of 8-bit luma).
  7033. @item mpeg/tv
  7034. Set "MPEG" range (16-235 in case of 8-bit luma).
  7035. @end table
  7036. @item force_original_aspect_ratio
  7037. Enable decreasing or increasing output video width or height if necessary to
  7038. keep the original aspect ratio. Possible values:
  7039. @table @samp
  7040. @item disable
  7041. Scale the video as specified and disable this feature.
  7042. @item decrease
  7043. The output video dimensions will automatically be decreased if needed.
  7044. @item increase
  7045. The output video dimensions will automatically be increased if needed.
  7046. @end table
  7047. One useful instance of this option is that when you know a specific device's
  7048. maximum allowed resolution, you can use this to limit the output video to
  7049. that, while retaining the aspect ratio. For example, device A allows
  7050. 1280x720 playback, and your video is 1920x800. Using this option (set it to
  7051. decrease) and specifying 1280x720 to the command line makes the output
  7052. 1280x533.
  7053. Please note that this is a different thing than specifying -1 for @option{w}
  7054. or @option{h}, you still need to specify the output resolution for this option
  7055. to work.
  7056. @end table
  7057. The values of the @option{w} and @option{h} options are expressions
  7058. containing the following constants:
  7059. @table @var
  7060. @item in_w
  7061. @item in_h
  7062. The input width and height
  7063. @item iw
  7064. @item ih
  7065. These are the same as @var{in_w} and @var{in_h}.
  7066. @item out_w
  7067. @item out_h
  7068. The output (scaled) width and height
  7069. @item ow
  7070. @item oh
  7071. These are the same as @var{out_w} and @var{out_h}
  7072. @item a
  7073. The same as @var{iw} / @var{ih}
  7074. @item sar
  7075. input sample aspect ratio
  7076. @item dar
  7077. The input display aspect ratio. Calculated from @code{(iw / ih) * sar}.
  7078. @item hsub
  7079. @item vsub
  7080. horizontal and vertical input chroma subsample values. For example for the
  7081. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7082. @item ohsub
  7083. @item ovsub
  7084. horizontal and vertical output chroma subsample values. For example for the
  7085. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7086. @end table
  7087. @subsection Examples
  7088. @itemize
  7089. @item
  7090. Scale the input video to a size of 200x100
  7091. @example
  7092. scale=w=200:h=100
  7093. @end example
  7094. This is equivalent to:
  7095. @example
  7096. scale=200:100
  7097. @end example
  7098. or:
  7099. @example
  7100. scale=200x100
  7101. @end example
  7102. @item
  7103. Specify a size abbreviation for the output size:
  7104. @example
  7105. scale=qcif
  7106. @end example
  7107. which can also be written as:
  7108. @example
  7109. scale=size=qcif
  7110. @end example
  7111. @item
  7112. Scale the input to 2x:
  7113. @example
  7114. scale=w=2*iw:h=2*ih
  7115. @end example
  7116. @item
  7117. The above is the same as:
  7118. @example
  7119. scale=2*in_w:2*in_h
  7120. @end example
  7121. @item
  7122. Scale the input to 2x with forced interlaced scaling:
  7123. @example
  7124. scale=2*iw:2*ih:interl=1
  7125. @end example
  7126. @item
  7127. Scale the input to half size:
  7128. @example
  7129. scale=w=iw/2:h=ih/2
  7130. @end example
  7131. @item
  7132. Increase the width, and set the height to the same size:
  7133. @example
  7134. scale=3/2*iw:ow
  7135. @end example
  7136. @item
  7137. Seek Greek harmony:
  7138. @example
  7139. scale=iw:1/PHI*iw
  7140. scale=ih*PHI:ih
  7141. @end example
  7142. @item
  7143. Increase the height, and set the width to 3/2 of the height:
  7144. @example
  7145. scale=w=3/2*oh:h=3/5*ih
  7146. @end example
  7147. @item
  7148. Increase the size, making the size a multiple of the chroma
  7149. subsample values:
  7150. @example
  7151. scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub"
  7152. @end example
  7153. @item
  7154. Increase the width to a maximum of 500 pixels,
  7155. keeping the same aspect ratio as the input:
  7156. @example
  7157. scale=w='min(500\, iw*3/2):h=-1'
  7158. @end example
  7159. @end itemize
  7160. @subsection Commands
  7161. This filter supports the following commands:
  7162. @table @option
  7163. @item width, w
  7164. @item height, h
  7165. Set the output video dimension expression.
  7166. The command accepts the same syntax of the corresponding option.
  7167. If the specified expression is not valid, it is kept at its current
  7168. value.
  7169. @end table
  7170. @section scale2ref
  7171. Scale (resize) the input video, based on a reference video.
  7172. See the scale filter for available options, scale2ref supports the same but
  7173. uses the reference video instead of the main input as basis.
  7174. @subsection Examples
  7175. @itemize
  7176. @item
  7177. Scale a subtitle stream to match the main video in size before overlaying
  7178. @example
  7179. 'scale2ref[b][a];[a][b]overlay'
  7180. @end example
  7181. @end itemize
  7182. @section separatefields
  7183. The @code{separatefields} takes a frame-based video input and splits
  7184. each frame into its components fields, producing a new half height clip
  7185. with twice the frame rate and twice the frame count.
  7186. This filter use field-dominance information in frame to decide which
  7187. of each pair of fields to place first in the output.
  7188. If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
  7189. @section setdar, setsar
  7190. The @code{setdar} filter sets the Display Aspect Ratio for the filter
  7191. output video.
  7192. This is done by changing the specified Sample (aka Pixel) Aspect
  7193. Ratio, according to the following equation:
  7194. @example
  7195. @var{DAR} = @var{HORIZONTAL_RESOLUTION} / @var{VERTICAL_RESOLUTION} * @var{SAR}
  7196. @end example
  7197. Keep in mind that the @code{setdar} filter does not modify the pixel
  7198. dimensions of the video frame. Also, the display aspect ratio set by
  7199. this filter may be changed by later filters in the filterchain,
  7200. e.g. in case of scaling or if another "setdar" or a "setsar" filter is
  7201. applied.
  7202. The @code{setsar} filter sets the Sample (aka Pixel) Aspect Ratio for
  7203. the filter output video.
  7204. Note that as a consequence of the application of this filter, the
  7205. output display aspect ratio will change according to the equation
  7206. above.
  7207. Keep in mind that the sample aspect ratio set by the @code{setsar}
  7208. filter may be changed by later filters in the filterchain, e.g. if
  7209. another "setsar" or a "setdar" filter is applied.
  7210. It accepts the following parameters:
  7211. @table @option
  7212. @item r, ratio, dar (@code{setdar} only), sar (@code{setsar} only)
  7213. Set the aspect ratio used by the filter.
  7214. The parameter can be a floating point number string, an expression, or
  7215. a string of the form @var{num}:@var{den}, where @var{num} and
  7216. @var{den} are the numerator and denominator of the aspect ratio. If
  7217. the parameter is not specified, it is assumed the value "0".
  7218. In case the form "@var{num}:@var{den}" is used, the @code{:} character
  7219. should be escaped.
  7220. @item max
  7221. Set the maximum integer value to use for expressing numerator and
  7222. denominator when reducing the expressed aspect ratio to a rational.
  7223. Default value is @code{100}.
  7224. @end table
  7225. The parameter @var{sar} is an expression containing
  7226. the following constants:
  7227. @table @option
  7228. @item E, PI, PHI
  7229. These are approximated values for the mathematical constants e
  7230. (Euler's number), pi (Greek pi), and phi (the golden ratio).
  7231. @item w, h
  7232. The input width and height.
  7233. @item a
  7234. These are the same as @var{w} / @var{h}.
  7235. @item sar
  7236. The input sample aspect ratio.
  7237. @item dar
  7238. The input display aspect ratio. It is the same as
  7239. (@var{w} / @var{h}) * @var{sar}.
  7240. @item hsub, vsub
  7241. Horizontal and vertical chroma subsample values. For example, for the
  7242. pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
  7243. @end table
  7244. @subsection Examples
  7245. @itemize
  7246. @item
  7247. To change the display aspect ratio to 16:9, specify one of the following:
  7248. @example
  7249. setdar=dar=1.77777
  7250. setdar=dar=16/9
  7251. setdar=dar=1.77777
  7252. @end example
  7253. @item
  7254. To change the sample aspect ratio to 10:11, specify:
  7255. @example
  7256. setsar=sar=10/11
  7257. @end example
  7258. @item
  7259. To set a display aspect ratio of 16:9, and specify a maximum integer value of
  7260. 1000 in the aspect ratio reduction, use the command:
  7261. @example
  7262. setdar=ratio=16/9:max=1000
  7263. @end example
  7264. @end itemize
  7265. @anchor{setfield}
  7266. @section setfield
  7267. Force field for the output video frame.
  7268. The @code{setfield} filter marks the interlace type field for the
  7269. output frames. It does not change the input frame, but only sets the
  7270. corresponding property, which affects how the frame is treated by
  7271. following filters (e.g. @code{fieldorder} or @code{yadif}).
  7272. The filter accepts the following options:
  7273. @table @option
  7274. @item mode
  7275. Available values are:
  7276. @table @samp
  7277. @item auto
  7278. Keep the same field property.
  7279. @item bff
  7280. Mark the frame as bottom-field-first.
  7281. @item tff
  7282. Mark the frame as top-field-first.
  7283. @item prog
  7284. Mark the frame as progressive.
  7285. @end table
  7286. @end table
  7287. @section showinfo
  7288. Show a line containing various information for each input video frame.
  7289. The input video is not modified.
  7290. The shown line contains a sequence of key/value pairs of the form
  7291. @var{key}:@var{value}.
  7292. The following values are shown in the output:
  7293. @table @option
  7294. @item n
  7295. The (sequential) number of the input frame, starting from 0.
  7296. @item pts
  7297. The Presentation TimeStamp of the input frame, expressed as a number of
  7298. time base units. The time base unit depends on the filter input pad.
  7299. @item pts_time
  7300. The Presentation TimeStamp of the input frame, expressed as a number of
  7301. seconds.
  7302. @item pos
  7303. The position of the frame in the input stream, or -1 if this information is
  7304. unavailable and/or meaningless (for example in case of synthetic video).
  7305. @item fmt
  7306. The pixel format name.
  7307. @item sar
  7308. The sample aspect ratio of the input frame, expressed in the form
  7309. @var{num}/@var{den}.
  7310. @item s
  7311. The size of the input frame. For the syntax of this option, check the
  7312. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7313. @item i
  7314. The type of interlaced mode ("P" for "progressive", "T" for top field first, "B"
  7315. for bottom field first).
  7316. @item iskey
  7317. This is 1 if the frame is a key frame, 0 otherwise.
  7318. @item type
  7319. The picture type of the input frame ("I" for an I-frame, "P" for a
  7320. P-frame, "B" for a B-frame, or "?" for an unknown type).
  7321. Also refer to the documentation of the @code{AVPictureType} enum and of
  7322. the @code{av_get_picture_type_char} function defined in
  7323. @file{libavutil/avutil.h}.
  7324. @item checksum
  7325. The Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame.
  7326. @item plane_checksum
  7327. The Adler-32 checksum (printed in hexadecimal) of each plane of the input frame,
  7328. expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]".
  7329. @end table
  7330. @section showpalette
  7331. Displays the 256 colors palette of each frame. This filter is only relevant for
  7332. @var{pal8} pixel format frames.
  7333. It accepts the following option:
  7334. @table @option
  7335. @item s
  7336. Set the size of the box used to represent one palette color entry. Default is
  7337. @code{30} (for a @code{30x30} pixel box).
  7338. @end table
  7339. @section shuffleplanes
  7340. Reorder and/or duplicate video planes.
  7341. It accepts the following parameters:
  7342. @table @option
  7343. @item map0
  7344. The index of the input plane to be used as the first output plane.
  7345. @item map1
  7346. The index of the input plane to be used as the second output plane.
  7347. @item map2
  7348. The index of the input plane to be used as the third output plane.
  7349. @item map3
  7350. The index of the input plane to be used as the fourth output plane.
  7351. @end table
  7352. The first plane has the index 0. The default is to keep the input unchanged.
  7353. Swap the second and third planes of the input:
  7354. @example
  7355. ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
  7356. @end example
  7357. @anchor{signalstats}
  7358. @section signalstats
  7359. Evaluate various visual metrics that assist in determining issues associated
  7360. with the digitization of analog video media.
  7361. By default the filter will log these metadata values:
  7362. @table @option
  7363. @item YMIN
  7364. Display the minimal Y value contained within the input frame. Expressed in
  7365. range of [0-255].
  7366. @item YLOW
  7367. Display the Y value at the 10% percentile within the input frame. Expressed in
  7368. range of [0-255].
  7369. @item YAVG
  7370. Display the average Y value within the input frame. Expressed in range of
  7371. [0-255].
  7372. @item YHIGH
  7373. Display the Y value at the 90% percentile within the input frame. Expressed in
  7374. range of [0-255].
  7375. @item YMAX
  7376. Display the maximum Y value contained within the input frame. Expressed in
  7377. range of [0-255].
  7378. @item UMIN
  7379. Display the minimal U value contained within the input frame. Expressed in
  7380. range of [0-255].
  7381. @item ULOW
  7382. Display the U value at the 10% percentile within the input frame. Expressed in
  7383. range of [0-255].
  7384. @item UAVG
  7385. Display the average U value within the input frame. Expressed in range of
  7386. [0-255].
  7387. @item UHIGH
  7388. Display the U value at the 90% percentile within the input frame. Expressed in
  7389. range of [0-255].
  7390. @item UMAX
  7391. Display the maximum U value contained within the input frame. Expressed in
  7392. range of [0-255].
  7393. @item VMIN
  7394. Display the minimal V value contained within the input frame. Expressed in
  7395. range of [0-255].
  7396. @item VLOW
  7397. Display the V value at the 10% percentile within the input frame. Expressed in
  7398. range of [0-255].
  7399. @item VAVG
  7400. Display the average V value within the input frame. Expressed in range of
  7401. [0-255].
  7402. @item VHIGH
  7403. Display the V value at the 90% percentile within the input frame. Expressed in
  7404. range of [0-255].
  7405. @item VMAX
  7406. Display the maximum V value contained within the input frame. Expressed in
  7407. range of [0-255].
  7408. @item SATMIN
  7409. Display the minimal saturation value contained within the input frame.
  7410. Expressed in range of [0-~181.02].
  7411. @item SATLOW
  7412. Display the saturation value at the 10% percentile within the input frame.
  7413. Expressed in range of [0-~181.02].
  7414. @item SATAVG
  7415. Display the average saturation value within the input frame. Expressed in range
  7416. of [0-~181.02].
  7417. @item SATHIGH
  7418. Display the saturation value at the 90% percentile within the input frame.
  7419. Expressed in range of [0-~181.02].
  7420. @item SATMAX
  7421. Display the maximum saturation value contained within the input frame.
  7422. Expressed in range of [0-~181.02].
  7423. @item HUEMED
  7424. Display the median value for hue within the input frame. Expressed in range of
  7425. [0-360].
  7426. @item HUEAVG
  7427. Display the average value for hue within the input frame. Expressed in range of
  7428. [0-360].
  7429. @item YDIF
  7430. Display the average of sample value difference between all values of the Y
  7431. plane in the current frame and corresponding values of the previous input frame.
  7432. Expressed in range of [0-255].
  7433. @item UDIF
  7434. Display the average of sample value difference between all values of the U
  7435. plane in the current frame and corresponding values of the previous input frame.
  7436. Expressed in range of [0-255].
  7437. @item VDIF
  7438. Display the average of sample value difference between all values of the V
  7439. plane in the current frame and corresponding values of the previous input frame.
  7440. Expressed in range of [0-255].
  7441. @end table
  7442. The filter accepts the following options:
  7443. @table @option
  7444. @item stat
  7445. @item out
  7446. @option{stat} specify an additional form of image analysis.
  7447. @option{out} output video with the specified type of pixel highlighted.
  7448. Both options accept the following values:
  7449. @table @samp
  7450. @item tout
  7451. Identify @var{temporal outliers} pixels. A @var{temporal outlier} is a pixel
  7452. unlike the neighboring pixels of the same field. Examples of temporal outliers
  7453. include the results of video dropouts, head clogs, or tape tracking issues.
  7454. @item vrep
  7455. Identify @var{vertical line repetition}. Vertical line repetition includes
  7456. similar rows of pixels within a frame. In born-digital video vertical line
  7457. repetition is common, but this pattern is uncommon in video digitized from an
  7458. analog source. When it occurs in video that results from the digitization of an
  7459. analog source it can indicate concealment from a dropout compensator.
  7460. @item brng
  7461. Identify pixels that fall outside of legal broadcast range.
  7462. @end table
  7463. @item color, c
  7464. Set the highlight color for the @option{out} option. The default color is
  7465. yellow.
  7466. @end table
  7467. @subsection Examples
  7468. @itemize
  7469. @item
  7470. Output data of various video metrics:
  7471. @example
  7472. ffprobe -f lavfi movie=example.mov,signalstats="stat=tout+vrep+brng" -show_frames
  7473. @end example
  7474. @item
  7475. Output specific data about the minimum and maximum values of the Y plane per frame:
  7476. @example
  7477. ffprobe -f lavfi movie=example.mov,signalstats -show_entries frame_tags=lavfi.signalstats.YMAX,lavfi.signalstats.YMIN
  7478. @end example
  7479. @item
  7480. Playback video while highlighting pixels that are outside of broadcast range in red.
  7481. @example
  7482. ffplay example.mov -vf signalstats="out=brng:color=red"
  7483. @end example
  7484. @item
  7485. Playback video with signalstats metadata drawn over the frame.
  7486. @example
  7487. ffplay example.mov -vf signalstats=stat=brng+vrep+tout,drawtext=fontfile=FreeSerif.ttf:textfile=signalstat_drawtext.txt
  7488. @end example
  7489. The contents of signalstat_drawtext.txt used in the command are:
  7490. @example
  7491. time %@{pts:hms@}
  7492. Y (%@{metadata:lavfi.signalstats.YMIN@}-%@{metadata:lavfi.signalstats.YMAX@})
  7493. U (%@{metadata:lavfi.signalstats.UMIN@}-%@{metadata:lavfi.signalstats.UMAX@})
  7494. V (%@{metadata:lavfi.signalstats.VMIN@}-%@{metadata:lavfi.signalstats.VMAX@})
  7495. saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
  7496. @end example
  7497. @end itemize
  7498. @anchor{smartblur}
  7499. @section smartblur
  7500. Blur the input video without impacting the outlines.
  7501. It accepts the following options:
  7502. @table @option
  7503. @item luma_radius, lr
  7504. Set the luma radius. The option value must be a float number in
  7505. the range [0.1,5.0] that specifies the variance of the gaussian filter
  7506. used to blur the image (slower if larger). Default value is 1.0.
  7507. @item luma_strength, ls
  7508. Set the luma strength. The option value must be a float number
  7509. in the range [-1.0,1.0] that configures the blurring. A value included
  7510. in [0.0,1.0] will blur the image whereas a value included in
  7511. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  7512. @item luma_threshold, lt
  7513. Set the luma threshold used as a coefficient to determine
  7514. whether a pixel should be blurred or not. The option value must be an
  7515. integer in the range [-30,30]. A value of 0 will filter all the image,
  7516. a value included in [0,30] will filter flat areas and a value included
  7517. in [-30,0] will filter edges. Default value is 0.
  7518. @item chroma_radius, cr
  7519. Set the chroma radius. The option value must be a float number in
  7520. the range [0.1,5.0] that specifies the variance of the gaussian filter
  7521. used to blur the image (slower if larger). Default value is 1.0.
  7522. @item chroma_strength, cs
  7523. Set the chroma strength. The option value must be a float number
  7524. in the range [-1.0,1.0] that configures the blurring. A value included
  7525. in [0.0,1.0] will blur the image whereas a value included in
  7526. [-1.0,0.0] will sharpen the image. Default value is 1.0.
  7527. @item chroma_threshold, ct
  7528. Set the chroma threshold used as a coefficient to determine
  7529. whether a pixel should be blurred or not. The option value must be an
  7530. integer in the range [-30,30]. A value of 0 will filter all the image,
  7531. a value included in [0,30] will filter flat areas and a value included
  7532. in [-30,0] will filter edges. Default value is 0.
  7533. @end table
  7534. If a chroma option is not explicitly set, the corresponding luma value
  7535. is set.
  7536. @section ssim
  7537. Obtain the SSIM (Structural SImilarity Metric) between two input videos.
  7538. This filter takes in input two input videos, the first input is
  7539. considered the "main" source and is passed unchanged to the
  7540. output. The second input is used as a "reference" video for computing
  7541. the SSIM.
  7542. Both video inputs must have the same resolution and pixel format for
  7543. this filter to work correctly. Also it assumes that both inputs
  7544. have the same number of frames, which are compared one by one.
  7545. The filter stores the calculated SSIM of each frame.
  7546. The description of the accepted parameters follows.
  7547. @table @option
  7548. @item stats_file, f
  7549. If specified the filter will use the named file to save the SSIM of
  7550. each individual frame.
  7551. @end table
  7552. The file printed if @var{stats_file} is selected, contains a sequence of
  7553. key/value pairs of the form @var{key}:@var{value} for each compared
  7554. couple of frames.
  7555. A description of each shown parameter follows:
  7556. @table @option
  7557. @item n
  7558. sequential number of the input frame, starting from 1
  7559. @item Y, U, V, R, G, B
  7560. SSIM of the compared frames for the component specified by the suffix.
  7561. @item All
  7562. SSIM of the compared frames for the whole frame.
  7563. @item dB
  7564. Same as above but in dB representation.
  7565. @end table
  7566. For example:
  7567. @example
  7568. movie=ref_movie.mpg, setpts=PTS-STARTPTS [main];
  7569. [main][ref] ssim="stats_file=stats.log" [out]
  7570. @end example
  7571. On this example the input file being processed is compared with the
  7572. reference file @file{ref_movie.mpg}. The SSIM of each individual frame
  7573. is stored in @file{stats.log}.
  7574. Another example with both psnr and ssim at same time:
  7575. @example
  7576. ffmpeg -i main.mpg -i ref.mpg -lavfi "ssim;[0:v][1:v]psnr" -f null -
  7577. @end example
  7578. @section stereo3d
  7579. Convert between different stereoscopic image formats.
  7580. The filters accept the following options:
  7581. @table @option
  7582. @item in
  7583. Set stereoscopic image format of input.
  7584. Available values for input image formats are:
  7585. @table @samp
  7586. @item sbsl
  7587. side by side parallel (left eye left, right eye right)
  7588. @item sbsr
  7589. side by side crosseye (right eye left, left eye right)
  7590. @item sbs2l
  7591. side by side parallel with half width resolution
  7592. (left eye left, right eye right)
  7593. @item sbs2r
  7594. side by side crosseye with half width resolution
  7595. (right eye left, left eye right)
  7596. @item abl
  7597. above-below (left eye above, right eye below)
  7598. @item abr
  7599. above-below (right eye above, left eye below)
  7600. @item ab2l
  7601. above-below with half height resolution
  7602. (left eye above, right eye below)
  7603. @item ab2r
  7604. above-below with half height resolution
  7605. (right eye above, left eye below)
  7606. @item al
  7607. alternating frames (left eye first, right eye second)
  7608. @item ar
  7609. alternating frames (right eye first, left eye second)
  7610. @item irl
  7611. interleaved rows (left eye has top row, right eye starts on next row)
  7612. @item irr
  7613. interleaved rows (right eye has top row, left eye starts on next row)
  7614. Default value is @samp{sbsl}.
  7615. @end table
  7616. @item out
  7617. Set stereoscopic image format of output.
  7618. Available values for output image formats are all the input formats as well as:
  7619. @table @samp
  7620. @item arbg
  7621. anaglyph red/blue gray
  7622. (red filter on left eye, blue filter on right eye)
  7623. @item argg
  7624. anaglyph red/green gray
  7625. (red filter on left eye, green filter on right eye)
  7626. @item arcg
  7627. anaglyph red/cyan gray
  7628. (red filter on left eye, cyan filter on right eye)
  7629. @item arch
  7630. anaglyph red/cyan half colored
  7631. (red filter on left eye, cyan filter on right eye)
  7632. @item arcc
  7633. anaglyph red/cyan color
  7634. (red filter on left eye, cyan filter on right eye)
  7635. @item arcd
  7636. anaglyph red/cyan color optimized with the least squares projection of dubois
  7637. (red filter on left eye, cyan filter on right eye)
  7638. @item agmg
  7639. anaglyph green/magenta gray
  7640. (green filter on left eye, magenta filter on right eye)
  7641. @item agmh
  7642. anaglyph green/magenta half colored
  7643. (green filter on left eye, magenta filter on right eye)
  7644. @item agmc
  7645. anaglyph green/magenta colored
  7646. (green filter on left eye, magenta filter on right eye)
  7647. @item agmd
  7648. anaglyph green/magenta color optimized with the least squares projection of dubois
  7649. (green filter on left eye, magenta filter on right eye)
  7650. @item aybg
  7651. anaglyph yellow/blue gray
  7652. (yellow filter on left eye, blue filter on right eye)
  7653. @item aybh
  7654. anaglyph yellow/blue half colored
  7655. (yellow filter on left eye, blue filter on right eye)
  7656. @item aybc
  7657. anaglyph yellow/blue colored
  7658. (yellow filter on left eye, blue filter on right eye)
  7659. @item aybd
  7660. anaglyph yellow/blue color optimized with the least squares projection of dubois
  7661. (yellow filter on left eye, blue filter on right eye)
  7662. @item ml
  7663. mono output (left eye only)
  7664. @item mr
  7665. mono output (right eye only)
  7666. @item chl
  7667. checkerboard, left eye first
  7668. @item chr
  7669. checkerboard, right eye first
  7670. @item icl
  7671. interleaved columns, left eye first
  7672. @item icr
  7673. interleaved columns, right eye first
  7674. @end table
  7675. Default value is @samp{arcd}.
  7676. @end table
  7677. @subsection Examples
  7678. @itemize
  7679. @item
  7680. Convert input video from side by side parallel to anaglyph yellow/blue dubois:
  7681. @example
  7682. stereo3d=sbsl:aybd
  7683. @end example
  7684. @item
  7685. Convert input video from above bellow (left eye above, right eye below) to side by side crosseye.
  7686. @example
  7687. stereo3d=abl:sbsr
  7688. @end example
  7689. @end itemize
  7690. @anchor{spp}
  7691. @section spp
  7692. Apply a simple postprocessing filter that compresses and decompresses the image
  7693. at several (or - in the case of @option{quality} level @code{6} - all) shifts
  7694. and average the results.
  7695. The filter accepts the following options:
  7696. @table @option
  7697. @item quality
  7698. Set quality. This option defines the number of levels for averaging. It accepts
  7699. an integer in the range 0-6. If set to @code{0}, the filter will have no
  7700. effect. A value of @code{6} means the higher quality. For each increment of
  7701. that value the speed drops by a factor of approximately 2. Default value is
  7702. @code{3}.
  7703. @item qp
  7704. Force a constant quantization parameter. If not set, the filter will use the QP
  7705. from the video stream (if available).
  7706. @item mode
  7707. Set thresholding mode. Available modes are:
  7708. @table @samp
  7709. @item hard
  7710. Set hard thresholding (default).
  7711. @item soft
  7712. Set soft thresholding (better de-ringing effect, but likely blurrier).
  7713. @end table
  7714. @item use_bframe_qp
  7715. Enable the use of the QP from the B-Frames if set to @code{1}. Using this
  7716. option may cause flicker since the B-Frames have often larger QP. Default is
  7717. @code{0} (not enabled).
  7718. @end table
  7719. @anchor{subtitles}
  7720. @section subtitles
  7721. Draw subtitles on top of input video using the libass library.
  7722. To enable compilation of this filter you need to configure FFmpeg with
  7723. @code{--enable-libass}. This filter also requires a build with libavcodec and
  7724. libavformat to convert the passed subtitles file to ASS (Advanced Substation
  7725. Alpha) subtitles format.
  7726. The filter accepts the following options:
  7727. @table @option
  7728. @item filename, f
  7729. Set the filename of the subtitle file to read. It must be specified.
  7730. @item original_size
  7731. Specify the size of the original video, the video for which the ASS file
  7732. was composed. For the syntax of this option, check the
  7733. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7734. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to
  7735. correctly scale the fonts if the aspect ratio has been changed.
  7736. @item fontsdir
  7737. Set a directory path containing fonts that can be used by the filter.
  7738. These fonts will be used in addition to whatever the font provider uses.
  7739. @item charenc
  7740. Set subtitles input character encoding. @code{subtitles} filter only. Only
  7741. useful if not UTF-8.
  7742. @item stream_index, si
  7743. Set subtitles stream index. @code{subtitles} filter only.
  7744. @item force_style
  7745. Override default style or script info parameters of the subtitles. It accepts a
  7746. string containing ASS style format @code{KEY=VALUE} couples separated by ",".
  7747. @end table
  7748. If the first key is not specified, it is assumed that the first value
  7749. specifies the @option{filename}.
  7750. For example, to render the file @file{sub.srt} on top of the input
  7751. video, use the command:
  7752. @example
  7753. subtitles=sub.srt
  7754. @end example
  7755. which is equivalent to:
  7756. @example
  7757. subtitles=filename=sub.srt
  7758. @end example
  7759. To render the default subtitles stream from file @file{video.mkv}, use:
  7760. @example
  7761. subtitles=video.mkv
  7762. @end example
  7763. To render the second subtitles stream from that file, use:
  7764. @example
  7765. subtitles=video.mkv:si=1
  7766. @end example
  7767. To make the subtitles stream from @file{sub.srt} appear in transparent green
  7768. @code{DejaVu Serif}, use:
  7769. @example
  7770. subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
  7771. @end example
  7772. @section super2xsai
  7773. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  7774. Interpolate) pixel art scaling algorithm.
  7775. Useful for enlarging pixel art images without reducing sharpness.
  7776. @section swapuv
  7777. Swap U & V plane.
  7778. @section telecine
  7779. Apply telecine process to the video.
  7780. This filter accepts the following options:
  7781. @table @option
  7782. @item first_field
  7783. @table @samp
  7784. @item top, t
  7785. top field first
  7786. @item bottom, b
  7787. bottom field first
  7788. The default value is @code{top}.
  7789. @end table
  7790. @item pattern
  7791. A string of numbers representing the pulldown pattern you wish to apply.
  7792. The default value is @code{23}.
  7793. @end table
  7794. @example
  7795. Some typical patterns:
  7796. NTSC output (30i):
  7797. 27.5p: 32222
  7798. 24p: 23 (classic)
  7799. 24p: 2332 (preferred)
  7800. 20p: 33
  7801. 18p: 334
  7802. 16p: 3444
  7803. PAL output (25i):
  7804. 27.5p: 12222
  7805. 24p: 222222222223 ("Euro pulldown")
  7806. 16.67p: 33
  7807. 16p: 33333334
  7808. @end example
  7809. @section thumbnail
  7810. Select the most representative frame in a given sequence of consecutive frames.
  7811. The filter accepts the following options:
  7812. @table @option
  7813. @item n
  7814. Set the frames batch size to analyze; in a set of @var{n} frames, the filter
  7815. will pick one of them, and then handle the next batch of @var{n} frames until
  7816. the end. Default is @code{100}.
  7817. @end table
  7818. Since the filter keeps track of the whole frames sequence, a bigger @var{n}
  7819. value will result in a higher memory usage, so a high value is not recommended.
  7820. @subsection Examples
  7821. @itemize
  7822. @item
  7823. Extract one picture each 50 frames:
  7824. @example
  7825. thumbnail=50
  7826. @end example
  7827. @item
  7828. Complete example of a thumbnail creation with @command{ffmpeg}:
  7829. @example
  7830. ffmpeg -i in.avi -vf thumbnail,scale=300:200 -frames:v 1 out.png
  7831. @end example
  7832. @end itemize
  7833. @section tile
  7834. Tile several successive frames together.
  7835. The filter accepts the following options:
  7836. @table @option
  7837. @item layout
  7838. Set the grid size (i.e. the number of lines and columns). For the syntax of
  7839. this option, check the
  7840. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  7841. @item nb_frames
  7842. Set the maximum number of frames to render in the given area. It must be less
  7843. than or equal to @var{w}x@var{h}. The default value is @code{0}, meaning all
  7844. the area will be used.
  7845. @item margin
  7846. Set the outer border margin in pixels.
  7847. @item padding
  7848. Set the inner border thickness (i.e. the number of pixels between frames). For
  7849. more advanced padding options (such as having different values for the edges),
  7850. refer to the pad video filter.
  7851. @item color
  7852. Specify the color of the unused area. For the syntax of this option, check the
  7853. "Color" section in the ffmpeg-utils manual. The default value of @var{color}
  7854. is "black".
  7855. @end table
  7856. @subsection Examples
  7857. @itemize
  7858. @item
  7859. Produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie:
  7860. @example
  7861. ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png
  7862. @end example
  7863. The @option{-vsync 0} is necessary to prevent @command{ffmpeg} from
  7864. duplicating each output frame to accommodate the originally detected frame
  7865. rate.
  7866. @item
  7867. Display @code{5} pictures in an area of @code{3x2} frames,
  7868. with @code{7} pixels between them, and @code{2} pixels of initial margin, using
  7869. mixed flat and named options:
  7870. @example
  7871. tile=3x2:nb_frames=5:padding=7:margin=2
  7872. @end example
  7873. @end itemize
  7874. @section tinterlace
  7875. Perform various types of temporal field interlacing.
  7876. Frames are counted starting from 1, so the first input frame is
  7877. considered odd.
  7878. The filter accepts the following options:
  7879. @table @option
  7880. @item mode
  7881. Specify the mode of the interlacing. This option can also be specified
  7882. as a value alone. See below for a list of values for this option.
  7883. Available values are:
  7884. @table @samp
  7885. @item merge, 0
  7886. Move odd frames into the upper field, even into the lower field,
  7887. generating a double height frame at half frame rate.
  7888. @example
  7889. ------> time
  7890. Input:
  7891. Frame 1 Frame 2 Frame 3 Frame 4
  7892. 11111 22222 33333 44444
  7893. 11111 22222 33333 44444
  7894. 11111 22222 33333 44444
  7895. 11111 22222 33333 44444
  7896. Output:
  7897. 11111 33333
  7898. 22222 44444
  7899. 11111 33333
  7900. 22222 44444
  7901. 11111 33333
  7902. 22222 44444
  7903. 11111 33333
  7904. 22222 44444
  7905. @end example
  7906. @item drop_odd, 1
  7907. Only output even frames, odd frames are dropped, generating a frame with
  7908. unchanged height at half frame rate.
  7909. @example
  7910. ------> time
  7911. Input:
  7912. Frame 1 Frame 2 Frame 3 Frame 4
  7913. 11111 22222 33333 44444
  7914. 11111 22222 33333 44444
  7915. 11111 22222 33333 44444
  7916. 11111 22222 33333 44444
  7917. Output:
  7918. 22222 44444
  7919. 22222 44444
  7920. 22222 44444
  7921. 22222 44444
  7922. @end example
  7923. @item drop_even, 2
  7924. Only output odd frames, even frames are dropped, generating a frame with
  7925. unchanged height at half frame rate.
  7926. @example
  7927. ------> time
  7928. Input:
  7929. Frame 1 Frame 2 Frame 3 Frame 4
  7930. 11111 22222 33333 44444
  7931. 11111 22222 33333 44444
  7932. 11111 22222 33333 44444
  7933. 11111 22222 33333 44444
  7934. Output:
  7935. 11111 33333
  7936. 11111 33333
  7937. 11111 33333
  7938. 11111 33333
  7939. @end example
  7940. @item pad, 3
  7941. Expand each frame to full height, but pad alternate lines with black,
  7942. generating a frame with double height at the same input frame rate.
  7943. @example
  7944. ------> time
  7945. Input:
  7946. Frame 1 Frame 2 Frame 3 Frame 4
  7947. 11111 22222 33333 44444
  7948. 11111 22222 33333 44444
  7949. 11111 22222 33333 44444
  7950. 11111 22222 33333 44444
  7951. Output:
  7952. 11111 ..... 33333 .....
  7953. ..... 22222 ..... 44444
  7954. 11111 ..... 33333 .....
  7955. ..... 22222 ..... 44444
  7956. 11111 ..... 33333 .....
  7957. ..... 22222 ..... 44444
  7958. 11111 ..... 33333 .....
  7959. ..... 22222 ..... 44444
  7960. @end example
  7961. @item interleave_top, 4
  7962. Interleave the upper field from odd frames with the lower field from
  7963. even frames, generating a frame with unchanged height at half frame rate.
  7964. @example
  7965. ------> time
  7966. Input:
  7967. Frame 1 Frame 2 Frame 3 Frame 4
  7968. 11111<- 22222 33333<- 44444
  7969. 11111 22222<- 33333 44444<-
  7970. 11111<- 22222 33333<- 44444
  7971. 11111 22222<- 33333 44444<-
  7972. Output:
  7973. 11111 33333
  7974. 22222 44444
  7975. 11111 33333
  7976. 22222 44444
  7977. @end example
  7978. @item interleave_bottom, 5
  7979. Interleave the lower field from odd frames with the upper field from
  7980. even frames, generating a frame with unchanged height at half frame rate.
  7981. @example
  7982. ------> time
  7983. Input:
  7984. Frame 1 Frame 2 Frame 3 Frame 4
  7985. 11111 22222<- 33333 44444<-
  7986. 11111<- 22222 33333<- 44444
  7987. 11111 22222<- 33333 44444<-
  7988. 11111<- 22222 33333<- 44444
  7989. Output:
  7990. 22222 44444
  7991. 11111 33333
  7992. 22222 44444
  7993. 11111 33333
  7994. @end example
  7995. @item interlacex2, 6
  7996. Double frame rate with unchanged height. Frames are inserted each
  7997. containing the second temporal field from the previous input frame and
  7998. the first temporal field from the next input frame. This mode relies on
  7999. the top_field_first flag. Useful for interlaced video displays with no
  8000. field synchronisation.
  8001. @example
  8002. ------> time
  8003. Input:
  8004. Frame 1 Frame 2 Frame 3 Frame 4
  8005. 11111 22222 33333 44444
  8006. 11111 22222 33333 44444
  8007. 11111 22222 33333 44444
  8008. 11111 22222 33333 44444
  8009. Output:
  8010. 11111 22222 22222 33333 33333 44444 44444
  8011. 11111 11111 22222 22222 33333 33333 44444
  8012. 11111 22222 22222 33333 33333 44444 44444
  8013. 11111 11111 22222 22222 33333 33333 44444
  8014. @end example
  8015. @end table
  8016. Numeric values are deprecated but are accepted for backward
  8017. compatibility reasons.
  8018. Default mode is @code{merge}.
  8019. @item flags
  8020. Specify flags influencing the filter process.
  8021. Available value for @var{flags} is:
  8022. @table @option
  8023. @item low_pass_filter, vlfp
  8024. Enable vertical low-pass filtering in the filter.
  8025. Vertical low-pass filtering is required when creating an interlaced
  8026. destination from a progressive source which contains high-frequency
  8027. vertical detail. Filtering will reduce interlace 'twitter' and Moire
  8028. patterning.
  8029. Vertical low-pass filtering can only be enabled for @option{mode}
  8030. @var{interleave_top} and @var{interleave_bottom}.
  8031. @end table
  8032. @end table
  8033. @section transpose
  8034. Transpose rows with columns in the input video and optionally flip it.
  8035. It accepts the following parameters:
  8036. @table @option
  8037. @item dir
  8038. Specify the transposition direction.
  8039. Can assume the following values:
  8040. @table @samp
  8041. @item 0, 4, cclock_flip
  8042. Rotate by 90 degrees counterclockwise and vertically flip (default), that is:
  8043. @example
  8044. L.R L.l
  8045. . . -> . .
  8046. l.r R.r
  8047. @end example
  8048. @item 1, 5, clock
  8049. Rotate by 90 degrees clockwise, that is:
  8050. @example
  8051. L.R l.L
  8052. . . -> . .
  8053. l.r r.R
  8054. @end example
  8055. @item 2, 6, cclock
  8056. Rotate by 90 degrees counterclockwise, that is:
  8057. @example
  8058. L.R R.r
  8059. . . -> . .
  8060. l.r L.l
  8061. @end example
  8062. @item 3, 7, clock_flip
  8063. Rotate by 90 degrees clockwise and vertically flip, that is:
  8064. @example
  8065. L.R r.R
  8066. . . -> . .
  8067. l.r l.L
  8068. @end example
  8069. @end table
  8070. For values between 4-7, the transposition is only done if the input
  8071. video geometry is portrait and not landscape. These values are
  8072. deprecated, the @code{passthrough} option should be used instead.
  8073. Numerical values are deprecated, and should be dropped in favor of
  8074. symbolic constants.
  8075. @item passthrough
  8076. Do not apply the transposition if the input geometry matches the one
  8077. specified by the specified value. It accepts the following values:
  8078. @table @samp
  8079. @item none
  8080. Always apply transposition.
  8081. @item portrait
  8082. Preserve portrait geometry (when @var{height} >= @var{width}).
  8083. @item landscape
  8084. Preserve landscape geometry (when @var{width} >= @var{height}).
  8085. @end table
  8086. Default value is @code{none}.
  8087. @end table
  8088. For example to rotate by 90 degrees clockwise and preserve portrait
  8089. layout:
  8090. @example
  8091. transpose=dir=1:passthrough=portrait
  8092. @end example
  8093. The command above can also be specified as:
  8094. @example
  8095. transpose=1:portrait
  8096. @end example
  8097. @section trim
  8098. Trim the input so that the output contains one continuous subpart of the input.
  8099. It accepts the following parameters:
  8100. @table @option
  8101. @item start
  8102. Specify the time of the start of the kept section, i.e. the frame with the
  8103. timestamp @var{start} will be the first frame in the output.
  8104. @item end
  8105. Specify the time of the first frame that will be dropped, i.e. the frame
  8106. immediately preceding the one with the timestamp @var{end} will be the last
  8107. frame in the output.
  8108. @item start_pts
  8109. This is the same as @var{start}, except this option sets the start timestamp
  8110. in timebase units instead of seconds.
  8111. @item end_pts
  8112. This is the same as @var{end}, except this option sets the end timestamp
  8113. in timebase units instead of seconds.
  8114. @item duration
  8115. The maximum duration of the output in seconds.
  8116. @item start_frame
  8117. The number of the first frame that should be passed to the output.
  8118. @item end_frame
  8119. The number of the first frame that should be dropped.
  8120. @end table
  8121. @option{start}, @option{end}, and @option{duration} are expressed as time
  8122. duration specifications; see
  8123. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  8124. for the accepted syntax.
  8125. Note that the first two sets of the start/end options and the @option{duration}
  8126. option look at the frame timestamp, while the _frame variants simply count the
  8127. frames that pass through the filter. Also note that this filter does not modify
  8128. the timestamps. If you wish for the output timestamps to start at zero, insert a
  8129. setpts filter after the trim filter.
  8130. If multiple start or end options are set, this filter tries to be greedy and
  8131. keep all the frames that match at least one of the specified constraints. To keep
  8132. only the part that matches all the constraints at once, chain multiple trim
  8133. filters.
  8134. The defaults are such that all the input is kept. So it is possible to set e.g.
  8135. just the end values to keep everything before the specified time.
  8136. Examples:
  8137. @itemize
  8138. @item
  8139. Drop everything except the second minute of input:
  8140. @example
  8141. ffmpeg -i INPUT -vf trim=60:120
  8142. @end example
  8143. @item
  8144. Keep only the first second:
  8145. @example
  8146. ffmpeg -i INPUT -vf trim=duration=1
  8147. @end example
  8148. @end itemize
  8149. @anchor{unsharp}
  8150. @section unsharp
  8151. Sharpen or blur the input video.
  8152. It accepts the following parameters:
  8153. @table @option
  8154. @item luma_msize_x, lx
  8155. Set the luma matrix horizontal size. It must be an odd integer between
  8156. 3 and 63. The default value is 5.
  8157. @item luma_msize_y, ly
  8158. Set the luma matrix vertical size. It must be an odd integer between 3
  8159. and 63. The default value is 5.
  8160. @item luma_amount, la
  8161. Set the luma effect strength. It must be a floating point number, reasonable
  8162. values lay between -1.5 and 1.5.
  8163. Negative values will blur the input video, while positive values will
  8164. sharpen it, a value of zero will disable the effect.
  8165. Default value is 1.0.
  8166. @item chroma_msize_x, cx
  8167. Set the chroma matrix horizontal size. It must be an odd integer
  8168. between 3 and 63. The default value is 5.
  8169. @item chroma_msize_y, cy
  8170. Set the chroma matrix vertical size. It must be an odd integer
  8171. between 3 and 63. The default value is 5.
  8172. @item chroma_amount, ca
  8173. Set the chroma effect strength. It must be a floating point number, reasonable
  8174. values lay between -1.5 and 1.5.
  8175. Negative values will blur the input video, while positive values will
  8176. sharpen it, a value of zero will disable the effect.
  8177. Default value is 0.0.
  8178. @item opencl
  8179. If set to 1, specify using OpenCL capabilities, only available if
  8180. FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
  8181. @end table
  8182. All parameters are optional and default to the equivalent of the
  8183. string '5:5:1.0:5:5:0.0'.
  8184. @subsection Examples
  8185. @itemize
  8186. @item
  8187. Apply strong luma sharpen effect:
  8188. @example
  8189. unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5
  8190. @end example
  8191. @item
  8192. Apply a strong blur of both luma and chroma parameters:
  8193. @example
  8194. unsharp=7:7:-2:7:7:-2
  8195. @end example
  8196. @end itemize
  8197. @section uspp
  8198. Apply ultra slow/simple postprocessing filter that compresses and decompresses
  8199. the image at several (or - in the case of @option{quality} level @code{8} - all)
  8200. shifts and average the results.
  8201. The way this differs from the behavior of spp is that uspp actually encodes &
  8202. decodes each case with libavcodec Snow, whereas spp uses a simplified intra only 8x8
  8203. DCT similar to MJPEG.
  8204. The filter accepts the following options:
  8205. @table @option
  8206. @item quality
  8207. Set quality. This option defines the number of levels for averaging. It accepts
  8208. an integer in the range 0-8. If set to @code{0}, the filter will have no
  8209. effect. A value of @code{8} means the higher quality. For each increment of
  8210. that value the speed drops by a factor of approximately 2. Default value is
  8211. @code{3}.
  8212. @item qp
  8213. Force a constant quantization parameter. If not set, the filter will use the QP
  8214. from the video stream (if available).
  8215. @end table
  8216. @section vectorscope
  8217. Display 2 color component values in the two dimensional graph (which is called
  8218. a vectorscope).
  8219. This filter accepts the following options:
  8220. @table @option
  8221. @item mode, m
  8222. Set vectorscope mode.
  8223. It accepts the following values:
  8224. @table @samp
  8225. @item gray
  8226. Gray values are displayed on graph, higher brightness means more pixels have
  8227. same component color value on location in graph. This is the default mode.
  8228. @item color
  8229. Gray values are displayed on graph. Surrounding pixels values which are not
  8230. present in video frame are drawn in gradient of 2 color components which are
  8231. set by option @code{x} and @code{y}.
  8232. @item color2
  8233. Actual color components values present in video frame are displayed on graph.
  8234. @item color3
  8235. Similar as color2 but higher frequency of same values @code{x} and @code{y}
  8236. on graph increases value of another color component, which is luminance by
  8237. default values of @code{x} and @code{y}.
  8238. @item color4
  8239. Actual colors present in video frame are displayed on graph. If two different
  8240. colors map to same position on graph then color with higher value of component
  8241. not present in graph is picked.
  8242. @end table
  8243. @item x
  8244. Set which color component will be represented on X-axis. Default is @code{1}.
  8245. @item y
  8246. Set which color component will be represented on Y-axis. Default is @code{2}.
  8247. @item intensity, i
  8248. Set intensity, used by modes: gray, color and color3 for increasing brightness
  8249. of color component which represents frequency of (X, Y) location in graph.
  8250. @item envelope, e
  8251. @table @samp
  8252. @item none
  8253. No envelope, this is default.
  8254. @item instant
  8255. Instant envelope, even darkest single pixel will be clearly highlighted.
  8256. @item peak
  8257. Hold maximum and minimum values presented in graph over time. This way you
  8258. can still spot out of range values without constantly looking at vectorscope.
  8259. @item peak+instant
  8260. Peak and instant envelope combined together.
  8261. @end table
  8262. @end table
  8263. @anchor{vidstabdetect}
  8264. @section vidstabdetect
  8265. Analyze video stabilization/deshaking. Perform pass 1 of 2, see
  8266. @ref{vidstabtransform} for pass 2.
  8267. This filter generates a file with relative translation and rotation
  8268. transform information about subsequent frames, which is then used by
  8269. the @ref{vidstabtransform} filter.
  8270. To enable compilation of this filter you need to configure FFmpeg with
  8271. @code{--enable-libvidstab}.
  8272. This filter accepts the following options:
  8273. @table @option
  8274. @item result
  8275. Set the path to the file used to write the transforms information.
  8276. Default value is @file{transforms.trf}.
  8277. @item shakiness
  8278. Set how shaky the video is and how quick the camera is. It accepts an
  8279. integer in the range 1-10, a value of 1 means little shakiness, a
  8280. value of 10 means strong shakiness. Default value is 5.
  8281. @item accuracy
  8282. Set the accuracy of the detection process. It must be a value in the
  8283. range 1-15. A value of 1 means low accuracy, a value of 15 means high
  8284. accuracy. Default value is 15.
  8285. @item stepsize
  8286. Set stepsize of the search process. The region around minimum is
  8287. scanned with 1 pixel resolution. Default value is 6.
  8288. @item mincontrast
  8289. Set minimum contrast. Below this value a local measurement field is
  8290. discarded. Must be a floating point value in the range 0-1. Default
  8291. value is 0.3.
  8292. @item tripod
  8293. Set reference frame number for tripod mode.
  8294. If enabled, the motion of the frames is compared to a reference frame
  8295. in the filtered stream, identified by the specified number. The idea
  8296. is to compensate all movements in a more-or-less static scene and keep
  8297. the camera view absolutely still.
  8298. If set to 0, it is disabled. The frames are counted starting from 1.
  8299. @item show
  8300. Show fields and transforms in the resulting frames. It accepts an
  8301. integer in the range 0-2. Default value is 0, which disables any
  8302. visualization.
  8303. @end table
  8304. @subsection Examples
  8305. @itemize
  8306. @item
  8307. Use default values:
  8308. @example
  8309. vidstabdetect
  8310. @end example
  8311. @item
  8312. Analyze strongly shaky movie and put the results in file
  8313. @file{mytransforms.trf}:
  8314. @example
  8315. vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf"
  8316. @end example
  8317. @item
  8318. Visualize the result of internal transformations in the resulting
  8319. video:
  8320. @example
  8321. vidstabdetect=show=1
  8322. @end example
  8323. @item
  8324. Analyze a video with medium shakiness using @command{ffmpeg}:
  8325. @example
  8326. ffmpeg -i input -vf vidstabdetect=shakiness=5:show=1 dummy.avi
  8327. @end example
  8328. @end itemize
  8329. @anchor{vidstabtransform}
  8330. @section vidstabtransform
  8331. Video stabilization/deshaking: pass 2 of 2,
  8332. see @ref{vidstabdetect} for pass 1.
  8333. Read a file with transform information for each frame and
  8334. apply/compensate them. Together with the @ref{vidstabdetect}
  8335. filter this can be used to deshake videos. See also
  8336. @url{http://public.hronopik.de/vid.stab}. It is important to also use
  8337. the @ref{unsharp} filter, see below.
  8338. To enable compilation of this filter you need to configure FFmpeg with
  8339. @code{--enable-libvidstab}.
  8340. @subsection Options
  8341. @table @option
  8342. @item input
  8343. Set path to the file used to read the transforms. Default value is
  8344. @file{transforms.trf}.
  8345. @item smoothing
  8346. Set the number of frames (value*2 + 1) used for lowpass filtering the
  8347. camera movements. Default value is 10.
  8348. For example a number of 10 means that 21 frames are used (10 in the
  8349. past and 10 in the future) to smoothen the motion in the video. A
  8350. larger value leads to a smoother video, but limits the acceleration of
  8351. the camera (pan/tilt movements). 0 is a special case where a static
  8352. camera is simulated.
  8353. @item optalgo
  8354. Set the camera path optimization algorithm.
  8355. Accepted values are:
  8356. @table @samp
  8357. @item gauss
  8358. gaussian kernel low-pass filter on camera motion (default)
  8359. @item avg
  8360. averaging on transformations
  8361. @end table
  8362. @item maxshift
  8363. Set maximal number of pixels to translate frames. Default value is -1,
  8364. meaning no limit.
  8365. @item maxangle
  8366. Set maximal angle in radians (degree*PI/180) to rotate frames. Default
  8367. value is -1, meaning no limit.
  8368. @item crop
  8369. Specify how to deal with borders that may be visible due to movement
  8370. compensation.
  8371. Available values are:
  8372. @table @samp
  8373. @item keep
  8374. keep image information from previous frame (default)
  8375. @item black
  8376. fill the border black
  8377. @end table
  8378. @item invert
  8379. Invert transforms if set to 1. Default value is 0.
  8380. @item relative
  8381. Consider transforms as relative to previous frame if set to 1,
  8382. absolute if set to 0. Default value is 0.
  8383. @item zoom
  8384. Set percentage to zoom. A positive value will result in a zoom-in
  8385. effect, a negative value in a zoom-out effect. Default value is 0 (no
  8386. zoom).
  8387. @item optzoom
  8388. Set optimal zooming to avoid borders.
  8389. Accepted values are:
  8390. @table @samp
  8391. @item 0
  8392. disabled
  8393. @item 1
  8394. optimal static zoom value is determined (only very strong movements
  8395. will lead to visible borders) (default)
  8396. @item 2
  8397. optimal adaptive zoom value is determined (no borders will be
  8398. visible), see @option{zoomspeed}
  8399. @end table
  8400. Note that the value given at zoom is added to the one calculated here.
  8401. @item zoomspeed
  8402. Set percent to zoom maximally each frame (enabled when
  8403. @option{optzoom} is set to 2). Range is from 0 to 5, default value is
  8404. 0.25.
  8405. @item interpol
  8406. Specify type of interpolation.
  8407. Available values are:
  8408. @table @samp
  8409. @item no
  8410. no interpolation
  8411. @item linear
  8412. linear only horizontal
  8413. @item bilinear
  8414. linear in both directions (default)
  8415. @item bicubic
  8416. cubic in both directions (slow)
  8417. @end table
  8418. @item tripod
  8419. Enable virtual tripod mode if set to 1, which is equivalent to
  8420. @code{relative=0:smoothing=0}. Default value is 0.
  8421. Use also @code{tripod} option of @ref{vidstabdetect}.
  8422. @item debug
  8423. Increase log verbosity if set to 1. Also the detected global motions
  8424. are written to the temporary file @file{global_motions.trf}. Default
  8425. value is 0.
  8426. @end table
  8427. @subsection Examples
  8428. @itemize
  8429. @item
  8430. Use @command{ffmpeg} for a typical stabilization with default values:
  8431. @example
  8432. ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
  8433. @end example
  8434. Note the use of the @ref{unsharp} filter which is always recommended.
  8435. @item
  8436. Zoom in a bit more and load transform data from a given file:
  8437. @example
  8438. vidstabtransform=zoom=5:input="mytransforms.trf"
  8439. @end example
  8440. @item
  8441. Smoothen the video even more:
  8442. @example
  8443. vidstabtransform=smoothing=30
  8444. @end example
  8445. @end itemize
  8446. @section vflip
  8447. Flip the input video vertically.
  8448. For example, to vertically flip a video with @command{ffmpeg}:
  8449. @example
  8450. ffmpeg -i in.avi -vf "vflip" out.avi
  8451. @end example
  8452. @anchor{vignette}
  8453. @section vignette
  8454. Make or reverse a natural vignetting effect.
  8455. The filter accepts the following options:
  8456. @table @option
  8457. @item angle, a
  8458. Set lens angle expression as a number of radians.
  8459. The value is clipped in the @code{[0,PI/2]} range.
  8460. Default value: @code{"PI/5"}
  8461. @item x0
  8462. @item y0
  8463. Set center coordinates expressions. Respectively @code{"w/2"} and @code{"h/2"}
  8464. by default.
  8465. @item mode
  8466. Set forward/backward mode.
  8467. Available modes are:
  8468. @table @samp
  8469. @item forward
  8470. The larger the distance from the central point, the darker the image becomes.
  8471. @item backward
  8472. The larger the distance from the central point, the brighter the image becomes.
  8473. This can be used to reverse a vignette effect, though there is no automatic
  8474. detection to extract the lens @option{angle} and other settings (yet). It can
  8475. also be used to create a burning effect.
  8476. @end table
  8477. Default value is @samp{forward}.
  8478. @item eval
  8479. Set evaluation mode for the expressions (@option{angle}, @option{x0}, @option{y0}).
  8480. It accepts the following values:
  8481. @table @samp
  8482. @item init
  8483. Evaluate expressions only once during the filter initialization.
  8484. @item frame
  8485. Evaluate expressions for each incoming frame. This is way slower than the
  8486. @samp{init} mode since it requires all the scalers to be re-computed, but it
  8487. allows advanced dynamic expressions.
  8488. @end table
  8489. Default value is @samp{init}.
  8490. @item dither
  8491. Set dithering to reduce the circular banding effects. Default is @code{1}
  8492. (enabled).
  8493. @item aspect
  8494. Set vignette aspect. This setting allows one to adjust the shape of the vignette.
  8495. Setting this value to the SAR of the input will make a rectangular vignetting
  8496. following the dimensions of the video.
  8497. Default is @code{1/1}.
  8498. @end table
  8499. @subsection Expressions
  8500. The @option{alpha}, @option{x0} and @option{y0} expressions can contain the
  8501. following parameters.
  8502. @table @option
  8503. @item w
  8504. @item h
  8505. input width and height
  8506. @item n
  8507. the number of input frame, starting from 0
  8508. @item pts
  8509. the PTS (Presentation TimeStamp) time of the filtered video frame, expressed in
  8510. @var{TB} units, NAN if undefined
  8511. @item r
  8512. frame rate of the input video, NAN if the input frame rate is unknown
  8513. @item t
  8514. the PTS (Presentation TimeStamp) of the filtered video frame,
  8515. expressed in seconds, NAN if undefined
  8516. @item tb
  8517. time base of the input video
  8518. @end table
  8519. @subsection Examples
  8520. @itemize
  8521. @item
  8522. Apply simple strong vignetting effect:
  8523. @example
  8524. vignette=PI/4
  8525. @end example
  8526. @item
  8527. Make a flickering vignetting:
  8528. @example
  8529. vignette='PI/4+random(1)*PI/50':eval=frame
  8530. @end example
  8531. @end itemize
  8532. @section vstack
  8533. Stack input videos vertically.
  8534. All streams must be of same pixel format and of same width.
  8535. Note that this filter is faster than using @ref{overlay} and @ref{pad} filter
  8536. to create same output.
  8537. The filter accept the following option:
  8538. @table @option
  8539. @item nb_inputs
  8540. Set number of input streams. Default is 2.
  8541. @end table
  8542. @section w3fdif
  8543. Deinterlace the input video ("w3fdif" stands for "Weston 3 Field
  8544. Deinterlacing Filter").
  8545. Based on the process described by Martin Weston for BBC R&D, and
  8546. implemented based on the de-interlace algorithm written by Jim
  8547. Easterbrook for BBC R&D, the Weston 3 field deinterlacing filter
  8548. uses filter coefficients calculated by BBC R&D.
  8549. There are two sets of filter coefficients, so called "simple":
  8550. and "complex". Which set of filter coefficients is used can
  8551. be set by passing an optional parameter:
  8552. @table @option
  8553. @item filter
  8554. Set the interlacing filter coefficients. Accepts one of the following values:
  8555. @table @samp
  8556. @item simple
  8557. Simple filter coefficient set.
  8558. @item complex
  8559. More-complex filter coefficient set.
  8560. @end table
  8561. Default value is @samp{complex}.
  8562. @item deint
  8563. Specify which frames to deinterlace. Accept one of the following values:
  8564. @table @samp
  8565. @item all
  8566. Deinterlace all frames,
  8567. @item interlaced
  8568. Only deinterlace frames marked as interlaced.
  8569. @end table
  8570. Default value is @samp{all}.
  8571. @end table
  8572. @section waveform
  8573. Video waveform monitor.
  8574. The waveform monitor plots color component intensity. By default luminance
  8575. only. Each column of the waveform corresponds to a column of pixels in the
  8576. source video.
  8577. It accepts the following options:
  8578. @table @option
  8579. @item mode, m
  8580. Can be either @code{row}, or @code{column}. Default is @code{column}.
  8581. In row mode, the graph on the left side represents color component value 0 and
  8582. the right side represents value = 255. In column mode, the top side represents
  8583. color component value = 0 and bottom side represents value = 255.
  8584. @item intensity, i
  8585. Set intensity. Smaller values are useful to find out how many values of the same
  8586. luminance are distributed across input rows/columns.
  8587. Default value is @code{0.04}. Allowed range is [0, 1].
  8588. @item mirror, r
  8589. Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored.
  8590. In mirrored mode, higher values will be represented on the left
  8591. side for @code{row} mode and at the top for @code{column} mode. Default is
  8592. @code{1} (mirrored).
  8593. @item display, d
  8594. Set display mode.
  8595. It accepts the following values:
  8596. @table @samp
  8597. @item overlay
  8598. Presents information identical to that in the @code{parade}, except
  8599. that the graphs representing color components are superimposed directly
  8600. over one another.
  8601. This display mode makes it easier to spot relative differences or similarities
  8602. in overlapping areas of the color components that are supposed to be identical,
  8603. such as neutral whites, grays, or blacks.
  8604. @item parade
  8605. Display separate graph for the color components side by side in
  8606. @code{row} mode or one below the other in @code{column} mode.
  8607. Using this display mode makes it easy to spot color casts in the highlights
  8608. and shadows of an image, by comparing the contours of the top and the bottom
  8609. graphs of each waveform. Since whites, grays, and blacks are characterized
  8610. by exactly equal amounts of red, green, and blue, neutral areas of the picture
  8611. should display three waveforms of roughly equal width/height. If not, the
  8612. correction is easy to perform by making level adjustments the three waveforms.
  8613. @end table
  8614. Default is @code{parade}.
  8615. @item components, c
  8616. Set which color components to display. Default is 1, which means only luminance
  8617. or red color component if input is in RGB colorspace. If is set for example to
  8618. 7 it will display all 3 (if) available color components.
  8619. @item envelope, e
  8620. @table @samp
  8621. @item none
  8622. No envelope, this is default.
  8623. @item instant
  8624. Instant envelope, minimum and maximum values presented in graph will be easily
  8625. visible even with small @code{step} value.
  8626. @item peak
  8627. Hold minimum and maximum values presented in graph across time. This way you
  8628. can still spot out of range values without constantly looking at waveforms.
  8629. @item peak+instant
  8630. Peak and instant envelope combined together.
  8631. @end table
  8632. @item filter, f
  8633. @table @samp
  8634. @item lowpass
  8635. No filtering, this is default.
  8636. @item flat
  8637. Luma and chroma combined together.
  8638. @item aflat
  8639. Similar as above, but shows difference between blue and red chroma.
  8640. @item chroma
  8641. Displays only chroma.
  8642. @item achroma
  8643. Similar as above, but shows difference between blue and red chroma.
  8644. @item color
  8645. Displays actual color value on waveform.
  8646. @end table
  8647. @end table
  8648. @section xbr
  8649. Apply the xBR high-quality magnification filter which is designed for pixel
  8650. art. It follows a set of edge-detection rules, see
  8651. @url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
  8652. It accepts the following option:
  8653. @table @option
  8654. @item n
  8655. Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for
  8656. @code{3xBR} and @code{4} for @code{4xBR}.
  8657. Default is @code{3}.
  8658. @end table
  8659. @anchor{yadif}
  8660. @section yadif
  8661. Deinterlace the input video ("yadif" means "yet another deinterlacing
  8662. filter").
  8663. It accepts the following parameters:
  8664. @table @option
  8665. @item mode
  8666. The interlacing mode to adopt. It accepts one of the following values:
  8667. @table @option
  8668. @item 0, send_frame
  8669. Output one frame for each frame.
  8670. @item 1, send_field
  8671. Output one frame for each field.
  8672. @item 2, send_frame_nospatial
  8673. Like @code{send_frame}, but it skips the spatial interlacing check.
  8674. @item 3, send_field_nospatial
  8675. Like @code{send_field}, but it skips the spatial interlacing check.
  8676. @end table
  8677. The default value is @code{send_frame}.
  8678. @item parity
  8679. The picture field parity assumed for the input interlaced video. It accepts one
  8680. of the following values:
  8681. @table @option
  8682. @item 0, tff
  8683. Assume the top field is first.
  8684. @item 1, bff
  8685. Assume the bottom field is first.
  8686. @item -1, auto
  8687. Enable automatic detection of field parity.
  8688. @end table
  8689. The default value is @code{auto}.
  8690. If the interlacing is unknown or the decoder does not export this information,
  8691. top field first will be assumed.
  8692. @item deint
  8693. Specify which frames to deinterlace. Accept one of the following
  8694. values:
  8695. @table @option
  8696. @item 0, all
  8697. Deinterlace all frames.
  8698. @item 1, interlaced
  8699. Only deinterlace frames marked as interlaced.
  8700. @end table
  8701. The default value is @code{all}.
  8702. @end table
  8703. @section zoompan
  8704. Apply Zoom & Pan effect.
  8705. This filter accepts the following options:
  8706. @table @option
  8707. @item zoom, z
  8708. Set the zoom expression. Default is 1.
  8709. @item x
  8710. @item y
  8711. Set the x and y expression. Default is 0.
  8712. @item d
  8713. Set the duration expression in number of frames.
  8714. This sets for how many number of frames effect will last for
  8715. single input image.
  8716. @item s
  8717. Set the output image size, default is 'hd720'.
  8718. @end table
  8719. Each expression can contain the following constants:
  8720. @table @option
  8721. @item in_w, iw
  8722. Input width.
  8723. @item in_h, ih
  8724. Input height.
  8725. @item out_w, ow
  8726. Output width.
  8727. @item out_h, oh
  8728. Output height.
  8729. @item in
  8730. Input frame count.
  8731. @item on
  8732. Output frame count.
  8733. @item x
  8734. @item y
  8735. Last calculated 'x' and 'y' position from 'x' and 'y' expression
  8736. for current input frame.
  8737. @item px
  8738. @item py
  8739. 'x' and 'y' of last output frame of previous input frame or 0 when there was
  8740. not yet such frame (first input frame).
  8741. @item zoom
  8742. Last calculated zoom from 'z' expression for current input frame.
  8743. @item pzoom
  8744. Last calculated zoom of last output frame of previous input frame.
  8745. @item duration
  8746. Number of output frames for current input frame. Calculated from 'd' expression
  8747. for each input frame.
  8748. @item pduration
  8749. number of output frames created for previous input frame
  8750. @item a
  8751. Rational number: input width / input height
  8752. @item sar
  8753. sample aspect ratio
  8754. @item dar
  8755. display aspect ratio
  8756. @end table
  8757. @subsection Examples
  8758. @itemize
  8759. @item
  8760. Zoom-in up to 1.5 and pan at same time to some spot near center of picture:
  8761. @example
  8762. 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
  8763. @end example
  8764. @item
  8765. Zoom-in up to 1.5 and pan always at center of picture:
  8766. @example
  8767. zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
  8768. @end example
  8769. @end itemize
  8770. @c man end VIDEO FILTERS
  8771. @chapter Video Sources
  8772. @c man begin VIDEO SOURCES
  8773. Below is a description of the currently available video sources.
  8774. @section buffer
  8775. Buffer video frames, and make them available to the filter chain.
  8776. This source is mainly intended for a programmatic use, in particular
  8777. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
  8778. It accepts the following parameters:
  8779. @table @option
  8780. @item video_size
  8781. Specify the size (width and height) of the buffered video frames. For the
  8782. syntax of this option, check the
  8783. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8784. @item width
  8785. The input video width.
  8786. @item height
  8787. The input video height.
  8788. @item pix_fmt
  8789. A string representing the pixel format of the buffered video frames.
  8790. It may be a number corresponding to a pixel format, or a pixel format
  8791. name.
  8792. @item time_base
  8793. Specify the timebase assumed by the timestamps of the buffered frames.
  8794. @item frame_rate
  8795. Specify the frame rate expected for the video stream.
  8796. @item pixel_aspect, sar
  8797. The sample (pixel) aspect ratio of the input video.
  8798. @item sws_param
  8799. Specify the optional parameters to be used for the scale filter which
  8800. is automatically inserted when an input change is detected in the
  8801. input size or format.
  8802. @end table
  8803. For example:
  8804. @example
  8805. buffer=width=320:height=240:pix_fmt=yuv410p:time_base=1/24:sar=1
  8806. @end example
  8807. will instruct the source to accept video frames with size 320x240 and
  8808. with format "yuv410p", assuming 1/24 as the timestamps timebase and
  8809. square pixels (1:1 sample aspect ratio).
  8810. Since the pixel format with name "yuv410p" corresponds to the number 6
  8811. (check the enum AVPixelFormat definition in @file{libavutil/pixfmt.h}),
  8812. this example corresponds to:
  8813. @example
  8814. buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1
  8815. @end example
  8816. Alternatively, the options can be specified as a flat string, but this
  8817. syntax is deprecated:
  8818. @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}]
  8819. @section cellauto
  8820. Create a pattern generated by an elementary cellular automaton.
  8821. The initial state of the cellular automaton can be defined through the
  8822. @option{filename}, and @option{pattern} options. If such options are
  8823. not specified an initial state is created randomly.
  8824. At each new frame a new row in the video is filled with the result of
  8825. the cellular automaton next generation. The behavior when the whole
  8826. frame is filled is defined by the @option{scroll} option.
  8827. This source accepts the following options:
  8828. @table @option
  8829. @item filename, f
  8830. Read the initial cellular automaton state, i.e. the starting row, from
  8831. the specified file.
  8832. In the file, each non-whitespace character is considered an alive
  8833. cell, a newline will terminate the row, and further characters in the
  8834. file will be ignored.
  8835. @item pattern, p
  8836. Read the initial cellular automaton state, i.e. the starting row, from
  8837. the specified string.
  8838. Each non-whitespace character in the string is considered an alive
  8839. cell, a newline will terminate the row, and further characters in the
  8840. string will be ignored.
  8841. @item rate, r
  8842. Set the video rate, that is the number of frames generated per second.
  8843. Default is 25.
  8844. @item random_fill_ratio, ratio
  8845. Set the random fill ratio for the initial cellular automaton row. It
  8846. is a floating point number value ranging from 0 to 1, defaults to
  8847. 1/PHI.
  8848. This option is ignored when a file or a pattern is specified.
  8849. @item random_seed, seed
  8850. Set the seed for filling randomly the initial row, must be an integer
  8851. included between 0 and UINT32_MAX. If not specified, or if explicitly
  8852. set to -1, the filter will try to use a good random seed on a best
  8853. effort basis.
  8854. @item rule
  8855. Set the cellular automaton rule, it is a number ranging from 0 to 255.
  8856. Default value is 110.
  8857. @item size, s
  8858. Set the size of the output video. For the syntax of this option, check the
  8859. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  8860. If @option{filename} or @option{pattern} is specified, the size is set
  8861. by default to the width of the specified initial state row, and the
  8862. height is set to @var{width} * PHI.
  8863. If @option{size} is set, it must contain the width of the specified
  8864. pattern string, and the specified pattern will be centered in the
  8865. larger row.
  8866. If a filename or a pattern string is not specified, the size value
  8867. defaults to "320x518" (used for a randomly generated initial state).
  8868. @item scroll
  8869. If set to 1, scroll the output upward when all the rows in the output
  8870. have been already filled. If set to 0, the new generated row will be
  8871. written over the top row just after the bottom row is filled.
  8872. Defaults to 1.
  8873. @item start_full, full
  8874. If set to 1, completely fill the output with generated rows before
  8875. outputting the first frame.
  8876. This is the default behavior, for disabling set the value to 0.
  8877. @item stitch
  8878. If set to 1, stitch the left and right row edges together.
  8879. This is the default behavior, for disabling set the value to 0.
  8880. @end table
  8881. @subsection Examples
  8882. @itemize
  8883. @item
  8884. Read the initial state from @file{pattern}, and specify an output of
  8885. size 200x400.
  8886. @example
  8887. cellauto=f=pattern:s=200x400
  8888. @end example
  8889. @item
  8890. Generate a random initial row with a width of 200 cells, with a fill
  8891. ratio of 2/3:
  8892. @example
  8893. cellauto=ratio=2/3:s=200x200
  8894. @end example
  8895. @item
  8896. Create a pattern generated by rule 18 starting by a single alive cell
  8897. centered on an initial row with width 100:
  8898. @example
  8899. cellauto=p=@@:s=100x400:full=0:rule=18
  8900. @end example
  8901. @item
  8902. Specify a more elaborated initial pattern:
  8903. @example
  8904. cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18
  8905. @end example
  8906. @end itemize
  8907. @section mandelbrot
  8908. Generate a Mandelbrot set fractal, and progressively zoom towards the
  8909. point specified with @var{start_x} and @var{start_y}.
  8910. This source accepts the following options:
  8911. @table @option
  8912. @item end_pts
  8913. Set the terminal pts value. Default value is 400.
  8914. @item end_scale
  8915. Set the terminal scale value.
  8916. Must be a floating point value. Default value is 0.3.
  8917. @item inner
  8918. Set the inner coloring mode, that is the algorithm used to draw the
  8919. Mandelbrot fractal internal region.
  8920. It shall assume one of the following values:
  8921. @table @option
  8922. @item black
  8923. Set black mode.
  8924. @item convergence
  8925. Show time until convergence.
  8926. @item mincol
  8927. Set color based on point closest to the origin of the iterations.
  8928. @item period
  8929. Set period mode.
  8930. @end table
  8931. Default value is @var{mincol}.
  8932. @item bailout
  8933. Set the bailout value. Default value is 10.0.
  8934. @item maxiter
  8935. Set the maximum of iterations performed by the rendering
  8936. algorithm. Default value is 7189.
  8937. @item outer
  8938. Set outer coloring mode.
  8939. It shall assume one of following values:
  8940. @table @option
  8941. @item iteration_count
  8942. Set iteration cound mode.
  8943. @item normalized_iteration_count
  8944. set normalized iteration count mode.
  8945. @end table
  8946. Default value is @var{normalized_iteration_count}.
  8947. @item rate, r
  8948. Set frame rate, expressed as number of frames per second. Default
  8949. value is "25".
  8950. @item size, s
  8951. Set frame size. For the syntax of this option, check the "Video
  8952. size" section in the ffmpeg-utils manual. Default value is "640x480".
  8953. @item start_scale
  8954. Set the initial scale value. Default value is 3.0.
  8955. @item start_x
  8956. Set the initial x position. Must be a floating point value between
  8957. -100 and 100. Default value is -0.743643887037158704752191506114774.
  8958. @item start_y
  8959. Set the initial y position. Must be a floating point value between
  8960. -100 and 100. Default value is -0.131825904205311970493132056385139.
  8961. @end table
  8962. @section mptestsrc
  8963. Generate various test patterns, as generated by the MPlayer test filter.
  8964. The size of the generated video is fixed, and is 256x256.
  8965. This source is useful in particular for testing encoding features.
  8966. This source accepts the following options:
  8967. @table @option
  8968. @item rate, r
  8969. Specify the frame rate of the sourced video, as the number of frames
  8970. generated per second. It has to be a string in the format
  8971. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  8972. number or a valid video frame rate abbreviation. The default value is
  8973. "25".
  8974. @item duration, d
  8975. Set the duration of the sourced video. See
  8976. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  8977. for the accepted syntax.
  8978. If not specified, or the expressed duration is negative, the video is
  8979. supposed to be generated forever.
  8980. @item test, t
  8981. Set the number or the name of the test to perform. Supported tests are:
  8982. @table @option
  8983. @item dc_luma
  8984. @item dc_chroma
  8985. @item freq_luma
  8986. @item freq_chroma
  8987. @item amp_luma
  8988. @item amp_chroma
  8989. @item cbp
  8990. @item mv
  8991. @item ring1
  8992. @item ring2
  8993. @item all
  8994. @end table
  8995. Default value is "all", which will cycle through the list of all tests.
  8996. @end table
  8997. Some examples:
  8998. @example
  8999. mptestsrc=t=dc_luma
  9000. @end example
  9001. will generate a "dc_luma" test pattern.
  9002. @section frei0r_src
  9003. Provide a frei0r source.
  9004. To enable compilation of this filter you need to install the frei0r
  9005. header and configure FFmpeg with @code{--enable-frei0r}.
  9006. This source accepts the following parameters:
  9007. @table @option
  9008. @item size
  9009. The size of the video to generate. For the syntax of this option, check the
  9010. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9011. @item framerate
  9012. The framerate of the generated video. It may be a string of the form
  9013. @var{num}/@var{den} or a frame rate abbreviation.
  9014. @item filter_name
  9015. The name to the frei0r source to load. For more information regarding frei0r and
  9016. how to set the parameters, read the @ref{frei0r} section in the video filters
  9017. documentation.
  9018. @item filter_params
  9019. A '|'-separated list of parameters to pass to the frei0r source.
  9020. @end table
  9021. For example, to generate a frei0r partik0l source with size 200x200
  9022. and frame rate 10 which is overlaid on the overlay filter main input:
  9023. @example
  9024. frei0r_src=size=200x200:framerate=10:filter_name=partik0l:filter_params=1234 [overlay]; [in][overlay] overlay
  9025. @end example
  9026. @section life
  9027. Generate a life pattern.
  9028. This source is based on a generalization of John Conway's life game.
  9029. The sourced input represents a life grid, each pixel represents a cell
  9030. which can be in one of two possible states, alive or dead. Every cell
  9031. interacts with its eight neighbours, which are the cells that are
  9032. horizontally, vertically, or diagonally adjacent.
  9033. At each interaction the grid evolves according to the adopted rule,
  9034. which specifies the number of neighbor alive cells which will make a
  9035. cell stay alive or born. The @option{rule} option allows one to specify
  9036. the rule to adopt.
  9037. This source accepts the following options:
  9038. @table @option
  9039. @item filename, f
  9040. Set the file from which to read the initial grid state. In the file,
  9041. each non-whitespace character is considered an alive cell, and newline
  9042. is used to delimit the end of each row.
  9043. If this option is not specified, the initial grid is generated
  9044. randomly.
  9045. @item rate, r
  9046. Set the video rate, that is the number of frames generated per second.
  9047. Default is 25.
  9048. @item random_fill_ratio, ratio
  9049. Set the random fill ratio for the initial random grid. It is a
  9050. floating point number value ranging from 0 to 1, defaults to 1/PHI.
  9051. It is ignored when a file is specified.
  9052. @item random_seed, seed
  9053. Set the seed for filling the initial random grid, must be an integer
  9054. included between 0 and UINT32_MAX. If not specified, or if explicitly
  9055. set to -1, the filter will try to use a good random seed on a best
  9056. effort basis.
  9057. @item rule
  9058. Set the life rule.
  9059. A rule can be specified with a code of the kind "S@var{NS}/B@var{NB}",
  9060. where @var{NS} and @var{NB} are sequences of numbers in the range 0-8,
  9061. @var{NS} specifies the number of alive neighbor cells which make a
  9062. live cell stay alive, and @var{NB} the number of alive neighbor cells
  9063. which make a dead cell to become alive (i.e. to "born").
  9064. "s" and "b" can be used in place of "S" and "B", respectively.
  9065. Alternatively a rule can be specified by an 18-bits integer. The 9
  9066. high order bits are used to encode the next cell state if it is alive
  9067. for each number of neighbor alive cells, the low order bits specify
  9068. the rule for "borning" new cells. Higher order bits encode for an
  9069. higher number of neighbor cells.
  9070. For example the number 6153 = @code{(12<<9)+9} specifies a stay alive
  9071. rule of 12 and a born rule of 9, which corresponds to "S23/B03".
  9072. Default value is "S23/B3", which is the original Conway's game of life
  9073. rule, and will keep a cell alive if it has 2 or 3 neighbor alive
  9074. cells, and will born a new cell if there are three alive cells around
  9075. a dead cell.
  9076. @item size, s
  9077. Set the size of the output video. For the syntax of this option, check the
  9078. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9079. If @option{filename} is specified, the size is set by default to the
  9080. same size of the input file. If @option{size} is set, it must contain
  9081. the size specified in the input file, and the initial grid defined in
  9082. that file is centered in the larger resulting area.
  9083. If a filename is not specified, the size value defaults to "320x240"
  9084. (used for a randomly generated initial grid).
  9085. @item stitch
  9086. If set to 1, stitch the left and right grid edges together, and the
  9087. top and bottom edges also. Defaults to 1.
  9088. @item mold
  9089. Set cell mold speed. If set, a dead cell will go from @option{death_color} to
  9090. @option{mold_color} with a step of @option{mold}. @option{mold} can have a
  9091. value from 0 to 255.
  9092. @item life_color
  9093. Set the color of living (or new born) cells.
  9094. @item death_color
  9095. Set the color of dead cells. If @option{mold} is set, this is the first color
  9096. used to represent a dead cell.
  9097. @item mold_color
  9098. Set mold color, for definitely dead and moldy cells.
  9099. For the syntax of these 3 color options, check the "Color" section in the
  9100. ffmpeg-utils manual.
  9101. @end table
  9102. @subsection Examples
  9103. @itemize
  9104. @item
  9105. Read a grid from @file{pattern}, and center it on a grid of size
  9106. 300x300 pixels:
  9107. @example
  9108. life=f=pattern:s=300x300
  9109. @end example
  9110. @item
  9111. Generate a random grid of size 200x200, with a fill ratio of 2/3:
  9112. @example
  9113. life=ratio=2/3:s=200x200
  9114. @end example
  9115. @item
  9116. Specify a custom rule for evolving a randomly generated grid:
  9117. @example
  9118. life=rule=S14/B34
  9119. @end example
  9120. @item
  9121. Full example with slow death effect (mold) using @command{ffplay}:
  9122. @example
  9123. ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_color=#00ff00,scale=1200:800:flags=16
  9124. @end example
  9125. @end itemize
  9126. @anchor{allrgb}
  9127. @anchor{allyuv}
  9128. @anchor{color}
  9129. @anchor{haldclutsrc}
  9130. @anchor{nullsrc}
  9131. @anchor{rgbtestsrc}
  9132. @anchor{smptebars}
  9133. @anchor{smptehdbars}
  9134. @anchor{testsrc}
  9135. @section allrgb, allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
  9136. The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
  9137. The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
  9138. The @code{color} source provides an uniformly colored input.
  9139. The @code{haldclutsrc} source provides an identity Hald CLUT. See also
  9140. @ref{haldclut} filter.
  9141. The @code{nullsrc} source returns unprocessed video frames. It is
  9142. mainly useful to be employed in analysis / debugging tools, or as the
  9143. source for filters which ignore the input data.
  9144. The @code{rgbtestsrc} source generates an RGB test pattern useful for
  9145. detecting RGB vs BGR issues. You should see a red, green and blue
  9146. stripe from top to bottom.
  9147. The @code{smptebars} source generates a color bars pattern, based on
  9148. the SMPTE Engineering Guideline EG 1-1990.
  9149. The @code{smptehdbars} source generates a color bars pattern, based on
  9150. the SMPTE RP 219-2002.
  9151. The @code{testsrc} source generates a test video pattern, showing a
  9152. color pattern, a scrolling gradient and a timestamp. This is mainly
  9153. intended for testing purposes.
  9154. The sources accept the following parameters:
  9155. @table @option
  9156. @item color, c
  9157. Specify the color of the source, only available in the @code{color}
  9158. source. For the syntax of this option, check the "Color" section in the
  9159. ffmpeg-utils manual.
  9160. @item level
  9161. Specify the level of the Hald CLUT, only available in the @code{haldclutsrc}
  9162. source. A level of @code{N} generates a picture of @code{N*N*N} by @code{N*N*N}
  9163. pixels to be used as identity matrix for 3D lookup tables. Each component is
  9164. coded on a @code{1/(N*N)} scale.
  9165. @item size, s
  9166. Specify the size of the sourced video. For the syntax of this option, check the
  9167. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9168. The default value is @code{320x240}.
  9169. This option is not available with the @code{haldclutsrc} filter.
  9170. @item rate, r
  9171. Specify the frame rate of the sourced video, as the number of frames
  9172. generated per second. It has to be a string in the format
  9173. @var{frame_rate_num}/@var{frame_rate_den}, an integer number, a floating point
  9174. number or a valid video frame rate abbreviation. The default value is
  9175. "25".
  9176. @item sar
  9177. Set the sample aspect ratio of the sourced video.
  9178. @item duration, d
  9179. Set the duration of the sourced video. See
  9180. @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}
  9181. for the accepted syntax.
  9182. If not specified, or the expressed duration is negative, the video is
  9183. supposed to be generated forever.
  9184. @item decimals, n
  9185. Set the number of decimals to show in the timestamp, only available in the
  9186. @code{testsrc} source.
  9187. The displayed timestamp value will correspond to the original
  9188. timestamp value multiplied by the power of 10 of the specified
  9189. value. Default value is 0.
  9190. @end table
  9191. For example the following:
  9192. @example
  9193. testsrc=duration=5.3:size=qcif:rate=10
  9194. @end example
  9195. will generate a video with a duration of 5.3 seconds, with size
  9196. 176x144 and a frame rate of 10 frames per second.
  9197. The following graph description will generate a red source
  9198. with an opacity of 0.2, with size "qcif" and a frame rate of 10
  9199. frames per second.
  9200. @example
  9201. color=c=red@@0.2:s=qcif:r=10
  9202. @end example
  9203. If the input content is to be ignored, @code{nullsrc} can be used. The
  9204. following command generates noise in the luminance plane by employing
  9205. the @code{geq} filter:
  9206. @example
  9207. nullsrc=s=256x256, geq=random(1)*255:128:128
  9208. @end example
  9209. @subsection Commands
  9210. The @code{color} source supports the following commands:
  9211. @table @option
  9212. @item c, color
  9213. Set the color of the created image. Accepts the same syntax of the
  9214. corresponding @option{color} option.
  9215. @end table
  9216. @c man end VIDEO SOURCES
  9217. @chapter Video Sinks
  9218. @c man begin VIDEO SINKS
  9219. Below is a description of the currently available video sinks.
  9220. @section buffersink
  9221. Buffer video frames, and make them available to the end of the filter
  9222. graph.
  9223. This sink is mainly intended for programmatic use, in particular
  9224. through the interface defined in @file{libavfilter/buffersink.h}
  9225. or the options system.
  9226. It accepts a pointer to an AVBufferSinkContext structure, which
  9227. defines the incoming buffers' formats, to be passed as the opaque
  9228. parameter to @code{avfilter_init_filter} for initialization.
  9229. @section nullsink
  9230. Null video sink: do absolutely nothing with the input video. It is
  9231. mainly useful as a template and for use in analysis / debugging
  9232. tools.
  9233. @c man end VIDEO SINKS
  9234. @chapter Multimedia Filters
  9235. @c man begin MULTIMEDIA FILTERS
  9236. Below is a description of the currently available multimedia filters.
  9237. @section aphasemeter
  9238. Convert input audio to a video output, displaying the audio phase.
  9239. The filter accepts the following options:
  9240. @table @option
  9241. @item rate, r
  9242. Set the output frame rate. Default value is @code{25}.
  9243. @item size, s
  9244. Set the video size for the output. For the syntax of this option, check the
  9245. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9246. Default value is @code{800x400}.
  9247. @item rc
  9248. @item gc
  9249. @item bc
  9250. Specify the red, green, blue contrast. Default values are @code{2},
  9251. @code{7} and @code{1}.
  9252. Allowed range is @code{[0, 255]}.
  9253. @item mpc
  9254. Set color which will be used for drawing median phase. If color is
  9255. @code{none} which is default, no median phase value will be drawn.
  9256. @end table
  9257. The filter also exports the frame metadata @code{lavfi.aphasemeter.phase} which
  9258. represents mean phase of current audio frame. Value is in range @code{[-1, 1]}.
  9259. The @code{-1} means left and right channels are completely out of phase and
  9260. @code{1} means channels are in phase.
  9261. @section avectorscope
  9262. Convert input audio to a video output, representing the audio vector
  9263. scope.
  9264. The filter is used to measure the difference between channels of stereo
  9265. audio stream. A monoaural signal, consisting of identical left and right
  9266. signal, results in straight vertical line. Any stereo separation is visible
  9267. as a deviation from this line, creating a Lissajous figure.
  9268. If the straight (or deviation from it) but horizontal line appears this
  9269. indicates that the left and right channels are out of phase.
  9270. The filter accepts the following options:
  9271. @table @option
  9272. @item mode, m
  9273. Set the vectorscope mode.
  9274. Available values are:
  9275. @table @samp
  9276. @item lissajous
  9277. Lissajous rotated by 45 degrees.
  9278. @item lissajous_xy
  9279. Same as above but not rotated.
  9280. @item polar
  9281. Shape resembling half of circle.
  9282. @end table
  9283. Default value is @samp{lissajous}.
  9284. @item size, s
  9285. Set the video size for the output. For the syntax of this option, check the
  9286. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9287. Default value is @code{400x400}.
  9288. @item rate, r
  9289. Set the output frame rate. Default value is @code{25}.
  9290. @item rc
  9291. @item gc
  9292. @item bc
  9293. @item ac
  9294. Specify the red, green, blue and alpha contrast. Default values are @code{40},
  9295. @code{160}, @code{80} and @code{255}.
  9296. Allowed range is @code{[0, 255]}.
  9297. @item rf
  9298. @item gf
  9299. @item bf
  9300. @item af
  9301. Specify the red, green, blue and alpha fade. Default values are @code{15},
  9302. @code{10}, @code{5} and @code{5}.
  9303. Allowed range is @code{[0, 255]}.
  9304. @item zoom
  9305. Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}.
  9306. @end table
  9307. @subsection Examples
  9308. @itemize
  9309. @item
  9310. Complete example using @command{ffplay}:
  9311. @example
  9312. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  9313. [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out0]'
  9314. @end example
  9315. @end itemize
  9316. @section concat
  9317. Concatenate audio and video streams, joining them together one after the
  9318. other.
  9319. The filter works on segments of synchronized video and audio streams. All
  9320. segments must have the same number of streams of each type, and that will
  9321. also be the number of streams at output.
  9322. The filter accepts the following options:
  9323. @table @option
  9324. @item n
  9325. Set the number of segments. Default is 2.
  9326. @item v
  9327. Set the number of output video streams, that is also the number of video
  9328. streams in each segment. Default is 1.
  9329. @item a
  9330. Set the number of output audio streams, that is also the number of audio
  9331. streams in each segment. Default is 0.
  9332. @item unsafe
  9333. Activate unsafe mode: do not fail if segments have a different format.
  9334. @end table
  9335. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then
  9336. @var{a} audio outputs.
  9337. There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first
  9338. segment, in the same order as the outputs, then the inputs for the second
  9339. segment, etc.
  9340. Related streams do not always have exactly the same duration, for various
  9341. reasons including codec frame size or sloppy authoring. For that reason,
  9342. related synchronized streams (e.g. a video and its audio track) should be
  9343. concatenated at once. The concat filter will use the duration of the longest
  9344. stream in each segment (except the last one), and if necessary pad shorter
  9345. audio streams with silence.
  9346. For this filter to work correctly, all segments must start at timestamp 0.
  9347. All corresponding streams must have the same parameters in all segments; the
  9348. filtering system will automatically select a common pixel format for video
  9349. streams, and a common sample format, sample rate and channel layout for
  9350. audio streams, but other settings, such as resolution, must be converted
  9351. explicitly by the user.
  9352. Different frame rates are acceptable but will result in variable frame rate
  9353. at output; be sure to configure the output file to handle it.
  9354. @subsection Examples
  9355. @itemize
  9356. @item
  9357. Concatenate an opening, an episode and an ending, all in bilingual version
  9358. (video in stream 0, audio in streams 1 and 2):
  9359. @example
  9360. ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv -filter_complex \
  9361. '[0:0] [0:1] [0:2] [1:0] [1:1] [1:2] [2:0] [2:1] [2:2]
  9362. concat=n=3:v=1:a=2 [v] [a1] [a2]' \
  9363. -map '[v]' -map '[a1]' -map '[a2]' output.mkv
  9364. @end example
  9365. @item
  9366. Concatenate two parts, handling audio and video separately, using the
  9367. (a)movie sources, and adjusting the resolution:
  9368. @example
  9369. movie=part1.mp4, scale=512:288 [v1] ; amovie=part1.mp4 [a1] ;
  9370. movie=part2.mp4, scale=512:288 [v2] ; amovie=part2.mp4 [a2] ;
  9371. [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]
  9372. @end example
  9373. Note that a desync will happen at the stitch if the audio and video streams
  9374. do not have exactly the same duration in the first file.
  9375. @end itemize
  9376. @anchor{ebur128}
  9377. @section ebur128
  9378. EBU R128 scanner filter. This filter takes an audio stream as input and outputs
  9379. it unchanged. By default, it logs a message at a frequency of 10Hz with the
  9380. Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}),
  9381. Integrated loudness (@code{I}) and Loudness Range (@code{LRA}).
  9382. The filter also has a video output (see the @var{video} option) with a real
  9383. time graph to observe the loudness evolution. The graphic contains the logged
  9384. message mentioned above, so it is not printed anymore when this option is set,
  9385. unless the verbose logging is set. The main graphing area contains the
  9386. short-term loudness (3 seconds of analysis), and the gauge on the right is for
  9387. the momentary loudness (400 milliseconds).
  9388. More information about the Loudness Recommendation EBU R128 on
  9389. @url{http://tech.ebu.ch/loudness}.
  9390. The filter accepts the following options:
  9391. @table @option
  9392. @item video
  9393. Activate the video output. The audio stream is passed unchanged whether this
  9394. option is set or no. The video stream will be the first output stream if
  9395. activated. Default is @code{0}.
  9396. @item size
  9397. Set the video size. This option is for video only. For the syntax of this
  9398. option, check the
  9399. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  9400. Default and minimum resolution is @code{640x480}.
  9401. @item meter
  9402. Set the EBU scale meter. Default is @code{9}. Common values are @code{9} and
  9403. @code{18}, respectively for EBU scale meter +9 and EBU scale meter +18. Any
  9404. other integer value between this range is allowed.
  9405. @item metadata
  9406. Set metadata injection. If set to @code{1}, the audio input will be segmented
  9407. into 100ms output frames, each of them containing various loudness information
  9408. in metadata. All the metadata keys are prefixed with @code{lavfi.r128.}.
  9409. Default is @code{0}.
  9410. @item framelog
  9411. Force the frame logging level.
  9412. Available values are:
  9413. @table @samp
  9414. @item info
  9415. information logging level
  9416. @item verbose
  9417. verbose logging level
  9418. @end table
  9419. By default, the logging level is set to @var{info}. If the @option{video} or
  9420. the @option{metadata} options are set, it switches to @var{verbose}.
  9421. @item peak
  9422. Set peak mode(s).
  9423. Available modes can be cumulated (the option is a @code{flag} type). Possible
  9424. values are:
  9425. @table @samp
  9426. @item none
  9427. Disable any peak mode (default).
  9428. @item sample
  9429. Enable sample-peak mode.
  9430. Simple peak mode looking for the higher sample value. It logs a message
  9431. for sample-peak (identified by @code{SPK}).
  9432. @item true
  9433. Enable true-peak mode.
  9434. If enabled, the peak lookup is done on an over-sampled version of the input
  9435. stream for better peak accuracy. It logs a message for true-peak.
  9436. (identified by @code{TPK}) and true-peak per frame (identified by @code{FTPK}).
  9437. This mode requires a build with @code{libswresample}.
  9438. @end table
  9439. @end table
  9440. @subsection Examples
  9441. @itemize
  9442. @item
  9443. Real-time graph using @command{ffplay}, with a EBU scale meter +18:
  9444. @example
  9445. ffplay -f lavfi -i "amovie=input.mp3,ebur128=video=1:meter=18 [out0][out1]"
  9446. @end example
  9447. @item
  9448. Run an analysis with @command{ffmpeg}:
  9449. @example
  9450. ffmpeg -nostats -i input.mp3 -filter_complex ebur128 -f null -
  9451. @end example
  9452. @end itemize
  9453. @section interleave, ainterleave
  9454. Temporally interleave frames from several inputs.
  9455. @code{interleave} works with video inputs, @code{ainterleave} with audio.
  9456. These filters read frames from several inputs and send the oldest
  9457. queued frame to the output.
  9458. Input streams must have a well defined, monotonically increasing frame
  9459. timestamp values.
  9460. In order to submit one frame to output, these filters need to enqueue
  9461. at least one frame for each input, so they cannot work in case one
  9462. input is not yet terminated and will not receive incoming frames.
  9463. For example consider the case when one input is a @code{select} filter
  9464. which always drop input frames. The @code{interleave} filter will keep
  9465. reading from that input, but it will never be able to send new frames
  9466. to output until the input will send an end-of-stream signal.
  9467. Also, depending on inputs synchronization, the filters will drop
  9468. frames in case one input receives more frames than the other ones, and
  9469. the queue is already filled.
  9470. These filters accept the following options:
  9471. @table @option
  9472. @item nb_inputs, n
  9473. Set the number of different inputs, it is 2 by default.
  9474. @end table
  9475. @subsection Examples
  9476. @itemize
  9477. @item
  9478. Interleave frames belonging to different streams using @command{ffmpeg}:
  9479. @example
  9480. ffmpeg -i bambi.avi -i pr0n.mkv -filter_complex "[0:v][1:v] interleave" out.avi
  9481. @end example
  9482. @item
  9483. Add flickering blur effect:
  9484. @example
  9485. select='if(gt(random(0), 0.2), 1, 2)':n=2 [tmp], boxblur=2:2, [tmp] interleave
  9486. @end example
  9487. @end itemize
  9488. @section perms, aperms
  9489. Set read/write permissions for the output frames.
  9490. These filters are mainly aimed at developers to test direct path in the
  9491. following filter in the filtergraph.
  9492. The filters accept the following options:
  9493. @table @option
  9494. @item mode
  9495. Select the permissions mode.
  9496. It accepts the following values:
  9497. @table @samp
  9498. @item none
  9499. Do nothing. This is the default.
  9500. @item ro
  9501. Set all the output frames read-only.
  9502. @item rw
  9503. Set all the output frames directly writable.
  9504. @item toggle
  9505. Make the frame read-only if writable, and writable if read-only.
  9506. @item random
  9507. Set each output frame read-only or writable randomly.
  9508. @end table
  9509. @item seed
  9510. Set the seed for the @var{random} mode, must be an integer included between
  9511. @code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to
  9512. @code{-1}, the filter will try to use a good random seed on a best effort
  9513. basis.
  9514. @end table
  9515. Note: in case of auto-inserted filter between the permission filter and the
  9516. following one, the permission might not be received as expected in that
  9517. following filter. Inserting a @ref{format} or @ref{aformat} filter before the
  9518. perms/aperms filter can avoid this problem.
  9519. @section select, aselect
  9520. Select frames to pass in output.
  9521. This filter accepts the following options:
  9522. @table @option
  9523. @item expr, e
  9524. Set expression, which is evaluated for each input frame.
  9525. If the expression is evaluated to zero, the frame is discarded.
  9526. If the evaluation result is negative or NaN, the frame is sent to the
  9527. first output; otherwise it is sent to the output with index
  9528. @code{ceil(val)-1}, assuming that the input index starts from 0.
  9529. For example a value of @code{1.2} corresponds to the output with index
  9530. @code{ceil(1.2)-1 = 2-1 = 1}, that is the second output.
  9531. @item outputs, n
  9532. Set the number of outputs. The output to which to send the selected
  9533. frame is based on the result of the evaluation. Default value is 1.
  9534. @end table
  9535. The expression can contain the following constants:
  9536. @table @option
  9537. @item n
  9538. The (sequential) number of the filtered frame, starting from 0.
  9539. @item selected_n
  9540. The (sequential) number of the selected frame, starting from 0.
  9541. @item prev_selected_n
  9542. The sequential number of the last selected frame. It's NAN if undefined.
  9543. @item TB
  9544. The timebase of the input timestamps.
  9545. @item pts
  9546. The PTS (Presentation TimeStamp) of the filtered video frame,
  9547. expressed in @var{TB} units. It's NAN if undefined.
  9548. @item t
  9549. The PTS of the filtered video frame,
  9550. expressed in seconds. It's NAN if undefined.
  9551. @item prev_pts
  9552. The PTS of the previously filtered video frame. It's NAN if undefined.
  9553. @item prev_selected_pts
  9554. The PTS of the last previously filtered video frame. It's NAN if undefined.
  9555. @item prev_selected_t
  9556. The PTS of the last previously selected video frame. It's NAN if undefined.
  9557. @item start_pts
  9558. The PTS of the first video frame in the video. It's NAN if undefined.
  9559. @item start_t
  9560. The time of the first video frame in the video. It's NAN if undefined.
  9561. @item pict_type @emph{(video only)}
  9562. The type of the filtered frame. It can assume one of the following
  9563. values:
  9564. @table @option
  9565. @item I
  9566. @item P
  9567. @item B
  9568. @item S
  9569. @item SI
  9570. @item SP
  9571. @item BI
  9572. @end table
  9573. @item interlace_type @emph{(video only)}
  9574. The frame interlace type. It can assume one of the following values:
  9575. @table @option
  9576. @item PROGRESSIVE
  9577. The frame is progressive (not interlaced).
  9578. @item TOPFIRST
  9579. The frame is top-field-first.
  9580. @item BOTTOMFIRST
  9581. The frame is bottom-field-first.
  9582. @end table
  9583. @item consumed_sample_n @emph{(audio only)}
  9584. the number of selected samples before the current frame
  9585. @item samples_n @emph{(audio only)}
  9586. the number of samples in the current frame
  9587. @item sample_rate @emph{(audio only)}
  9588. the input sample rate
  9589. @item key
  9590. This is 1 if the filtered frame is a key-frame, 0 otherwise.
  9591. @item pos
  9592. the position in the file of the filtered frame, -1 if the information
  9593. is not available (e.g. for synthetic video)
  9594. @item scene @emph{(video only)}
  9595. value between 0 and 1 to indicate a new scene; a low value reflects a low
  9596. probability for the current frame to introduce a new scene, while a higher
  9597. value means the current frame is more likely to be one (see the example below)
  9598. @end table
  9599. The default value of the select expression is "1".
  9600. @subsection Examples
  9601. @itemize
  9602. @item
  9603. Select all frames in input:
  9604. @example
  9605. select
  9606. @end example
  9607. The example above is the same as:
  9608. @example
  9609. select=1
  9610. @end example
  9611. @item
  9612. Skip all frames:
  9613. @example
  9614. select=0
  9615. @end example
  9616. @item
  9617. Select only I-frames:
  9618. @example
  9619. select='eq(pict_type\,I)'
  9620. @end example
  9621. @item
  9622. Select one frame every 100:
  9623. @example
  9624. select='not(mod(n\,100))'
  9625. @end example
  9626. @item
  9627. Select only frames contained in the 10-20 time interval:
  9628. @example
  9629. select=between(t\,10\,20)
  9630. @end example
  9631. @item
  9632. Select only I frames contained in the 10-20 time interval:
  9633. @example
  9634. select=between(t\,10\,20)*eq(pict_type\,I)
  9635. @end example
  9636. @item
  9637. Select frames with a minimum distance of 10 seconds:
  9638. @example
  9639. select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)'
  9640. @end example
  9641. @item
  9642. Use aselect to select only audio frames with samples number > 100:
  9643. @example
  9644. aselect='gt(samples_n\,100)'
  9645. @end example
  9646. @item
  9647. Create a mosaic of the first scenes:
  9648. @example
  9649. ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
  9650. @end example
  9651. Comparing @var{scene} against a value between 0.3 and 0.5 is generally a sane
  9652. choice.
  9653. @item
  9654. Send even and odd frames to separate outputs, and compose them:
  9655. @example
  9656. select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h
  9657. @end example
  9658. @end itemize
  9659. @section sendcmd, asendcmd
  9660. Send commands to filters in the filtergraph.
  9661. These filters read commands to be sent to other filters in the
  9662. filtergraph.
  9663. @code{sendcmd} must be inserted between two video filters,
  9664. @code{asendcmd} must be inserted between two audio filters, but apart
  9665. from that they act the same way.
  9666. The specification of commands can be provided in the filter arguments
  9667. with the @var{commands} option, or in a file specified by the
  9668. @var{filename} option.
  9669. These filters accept the following options:
  9670. @table @option
  9671. @item commands, c
  9672. Set the commands to be read and sent to the other filters.
  9673. @item filename, f
  9674. Set the filename of the commands to be read and sent to the other
  9675. filters.
  9676. @end table
  9677. @subsection Commands syntax
  9678. A commands description consists of a sequence of interval
  9679. specifications, comprising a list of commands to be executed when a
  9680. particular event related to that interval occurs. The occurring event
  9681. is typically the current frame time entering or leaving a given time
  9682. interval.
  9683. An interval is specified by the following syntax:
  9684. @example
  9685. @var{START}[-@var{END}] @var{COMMANDS};
  9686. @end example
  9687. The time interval is specified by the @var{START} and @var{END} times.
  9688. @var{END} is optional and defaults to the maximum time.
  9689. The current frame time is considered within the specified interval if
  9690. it is included in the interval [@var{START}, @var{END}), that is when
  9691. the time is greater or equal to @var{START} and is lesser than
  9692. @var{END}.
  9693. @var{COMMANDS} consists of a sequence of one or more command
  9694. specifications, separated by ",", relating to that interval. The
  9695. syntax of a command specification is given by:
  9696. @example
  9697. [@var{FLAGS}] @var{TARGET} @var{COMMAND} @var{ARG}
  9698. @end example
  9699. @var{FLAGS} is optional and specifies the type of events relating to
  9700. the time interval which enable sending the specified command, and must
  9701. be a non-null sequence of identifier flags separated by "+" or "|" and
  9702. enclosed between "[" and "]".
  9703. The following flags are recognized:
  9704. @table @option
  9705. @item enter
  9706. The command is sent when the current frame timestamp enters the
  9707. specified interval. In other words, the command is sent when the
  9708. previous frame timestamp was not in the given interval, and the
  9709. current is.
  9710. @item leave
  9711. The command is sent when the current frame timestamp leaves the
  9712. specified interval. In other words, the command is sent when the
  9713. previous frame timestamp was in the given interval, and the
  9714. current is not.
  9715. @end table
  9716. If @var{FLAGS} is not specified, a default value of @code{[enter]} is
  9717. assumed.
  9718. @var{TARGET} specifies the target of the command, usually the name of
  9719. the filter class or a specific filter instance name.
  9720. @var{COMMAND} specifies the name of the command for the target filter.
  9721. @var{ARG} is optional and specifies the optional list of argument for
  9722. the given @var{COMMAND}.
  9723. Between one interval specification and another, whitespaces, or
  9724. sequences of characters starting with @code{#} until the end of line,
  9725. are ignored and can be used to annotate comments.
  9726. A simplified BNF description of the commands specification syntax
  9727. follows:
  9728. @example
  9729. @var{COMMAND_FLAG} ::= "enter" | "leave"
  9730. @var{COMMAND_FLAGS} ::= @var{COMMAND_FLAG} [(+|"|")@var{COMMAND_FLAG}]
  9731. @var{COMMAND} ::= ["[" @var{COMMAND_FLAGS} "]"] @var{TARGET} @var{COMMAND} [@var{ARG}]
  9732. @var{COMMANDS} ::= @var{COMMAND} [,@var{COMMANDS}]
  9733. @var{INTERVAL} ::= @var{START}[-@var{END}] @var{COMMANDS}
  9734. @var{INTERVALS} ::= @var{INTERVAL}[;@var{INTERVALS}]
  9735. @end example
  9736. @subsection Examples
  9737. @itemize
  9738. @item
  9739. Specify audio tempo change at second 4:
  9740. @example
  9741. asendcmd=c='4.0 atempo tempo 1.5',atempo
  9742. @end example
  9743. @item
  9744. Specify a list of drawtext and hue commands in a file.
  9745. @example
  9746. # show text in the interval 5-10
  9747. 5.0-10.0 [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=hello world',
  9748. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=';
  9749. # desaturate the image in the interval 15-20
  9750. 15.0-20.0 [enter] hue s 0,
  9751. [enter] drawtext reinit 'fontfile=FreeSerif.ttf:text=nocolor',
  9752. [leave] hue s 1,
  9753. [leave] drawtext reinit 'fontfile=FreeSerif.ttf:text=color';
  9754. # apply an exponential saturation fade-out effect, starting from time 25
  9755. 25 [enter] hue s exp(25-t)
  9756. @end example
  9757. A filtergraph allowing to read and process the above command list
  9758. stored in a file @file{test.cmd}, can be specified with:
  9759. @example
  9760. sendcmd=f=test.cmd,drawtext=fontfile=FreeSerif.ttf:text='',hue
  9761. @end example
  9762. @end itemize
  9763. @anchor{setpts}
  9764. @section setpts, asetpts
  9765. Change the PTS (presentation timestamp) of the input frames.
  9766. @code{setpts} works on video frames, @code{asetpts} on audio frames.
  9767. This filter accepts the following options:
  9768. @table @option
  9769. @item expr
  9770. The expression which is evaluated for each frame to construct its timestamp.
  9771. @end table
  9772. The expression is evaluated through the eval API and can contain the following
  9773. constants:
  9774. @table @option
  9775. @item FRAME_RATE
  9776. frame rate, only defined for constant frame-rate video
  9777. @item PTS
  9778. The presentation timestamp in input
  9779. @item N
  9780. The count of the input frame for video or the number of consumed samples,
  9781. not including the current frame for audio, starting from 0.
  9782. @item NB_CONSUMED_SAMPLES
  9783. The number of consumed samples, not including the current frame (only
  9784. audio)
  9785. @item NB_SAMPLES, S
  9786. The number of samples in the current frame (only audio)
  9787. @item SAMPLE_RATE, SR
  9788. The audio sample rate.
  9789. @item STARTPTS
  9790. The PTS of the first frame.
  9791. @item STARTT
  9792. the time in seconds of the first frame
  9793. @item INTERLACED
  9794. State whether the current frame is interlaced.
  9795. @item T
  9796. the time in seconds of the current frame
  9797. @item POS
  9798. original position in the file of the frame, or undefined if undefined
  9799. for the current frame
  9800. @item PREV_INPTS
  9801. The previous input PTS.
  9802. @item PREV_INT
  9803. previous input time in seconds
  9804. @item PREV_OUTPTS
  9805. The previous output PTS.
  9806. @item PREV_OUTT
  9807. previous output time in seconds
  9808. @item RTCTIME
  9809. The wallclock (RTC) time in microseconds. This is deprecated, use time(0)
  9810. instead.
  9811. @item RTCSTART
  9812. The wallclock (RTC) time at the start of the movie in microseconds.
  9813. @item TB
  9814. The timebase of the input timestamps.
  9815. @end table
  9816. @subsection Examples
  9817. @itemize
  9818. @item
  9819. Start counting PTS from zero
  9820. @example
  9821. setpts=PTS-STARTPTS
  9822. @end example
  9823. @item
  9824. Apply fast motion effect:
  9825. @example
  9826. setpts=0.5*PTS
  9827. @end example
  9828. @item
  9829. Apply slow motion effect:
  9830. @example
  9831. setpts=2.0*PTS
  9832. @end example
  9833. @item
  9834. Set fixed rate of 25 frames per second:
  9835. @example
  9836. setpts=N/(25*TB)
  9837. @end example
  9838. @item
  9839. Set fixed rate 25 fps with some jitter:
  9840. @example
  9841. setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
  9842. @end example
  9843. @item
  9844. Apply an offset of 10 seconds to the input PTS:
  9845. @example
  9846. setpts=PTS+10/TB
  9847. @end example
  9848. @item
  9849. Generate timestamps from a "live source" and rebase onto the current timebase:
  9850. @example
  9851. setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
  9852. @end example
  9853. @item
  9854. Generate timestamps by counting samples:
  9855. @example
  9856. asetpts=N/SR/TB
  9857. @end example
  9858. @end itemize
  9859. @section settb, asettb
  9860. Set the timebase to use for the output frames timestamps.
  9861. It is mainly useful for testing timebase configuration.
  9862. It accepts the following parameters:
  9863. @table @option
  9864. @item expr, tb
  9865. The expression which is evaluated into the output timebase.
  9866. @end table
  9867. The value for @option{tb} is an arithmetic expression representing a
  9868. rational. The expression can contain the constants "AVTB" (the default
  9869. timebase), "intb" (the input timebase) and "sr" (the sample rate,
  9870. audio only). Default value is "intb".
  9871. @subsection Examples
  9872. @itemize
  9873. @item
  9874. Set the timebase to 1/25:
  9875. @example
  9876. settb=expr=1/25
  9877. @end example
  9878. @item
  9879. Set the timebase to 1/10:
  9880. @example
  9881. settb=expr=0.1
  9882. @end example
  9883. @item
  9884. Set the timebase to 1001/1000:
  9885. @example
  9886. settb=1+0.001
  9887. @end example
  9888. @item
  9889. Set the timebase to 2*intb:
  9890. @example
  9891. settb=2*intb
  9892. @end example
  9893. @item
  9894. Set the default timebase value:
  9895. @example
  9896. settb=AVTB
  9897. @end example
  9898. @end itemize
  9899. @section showcqt
  9900. Convert input audio to a video output representing
  9901. frequency spectrum logarithmically (using constant Q transform with
  9902. Brown-Puckette algorithm), with musical tone scale, from E0 to D#10 (10 octaves).
  9903. The filter accepts the following options:
  9904. @table @option
  9905. @item volume
  9906. Specify transform volume (multiplier) expression. The expression can contain
  9907. variables:
  9908. @table @option
  9909. @item frequency, freq, f
  9910. the frequency where transform is evaluated
  9911. @item timeclamp, tc
  9912. value of timeclamp option
  9913. @end table
  9914. and functions:
  9915. @table @option
  9916. @item a_weighting(f)
  9917. A-weighting of equal loudness
  9918. @item b_weighting(f)
  9919. B-weighting of equal loudness
  9920. @item c_weighting(f)
  9921. C-weighting of equal loudness
  9922. @end table
  9923. Default value is @code{16}.
  9924. @item tlength
  9925. Specify transform length expression. The expression can contain variables:
  9926. @table @option
  9927. @item frequency, freq, f
  9928. the frequency where transform is evaluated
  9929. @item timeclamp, tc
  9930. value of timeclamp option
  9931. @end table
  9932. Default value is @code{384/f*tc/(384/f+tc)}.
  9933. @item timeclamp
  9934. Specify the transform timeclamp. At low frequency, there is trade-off between
  9935. accuracy in time domain and frequency domain. If timeclamp is lower,
  9936. event in time domain is represented more accurately (such as fast bass drum),
  9937. otherwise event in frequency domain is represented more accurately
  9938. (such as bass guitar). Acceptable value is [0.1, 1.0]. Default value is @code{0.17}.
  9939. @item coeffclamp
  9940. Specify the transform coeffclamp. If coeffclamp is lower, transform is
  9941. more accurate, otherwise transform is faster. Acceptable value is [0.1, 10.0].
  9942. Default value is @code{1.0}.
  9943. @item gamma
  9944. Specify gamma. Lower gamma makes the spectrum more contrast, higher gamma
  9945. makes the spectrum having more range. Acceptable value is [1.0, 7.0].
  9946. Default value is @code{3.0}.
  9947. @item gamma2
  9948. Specify gamma of bargraph. Acceptable value is [1.0, 7.0].
  9949. Default value is @code{1.0}.
  9950. @item fontfile
  9951. Specify font file for use with freetype. If not specified, use embedded font.
  9952. @item fontcolor
  9953. Specify font color expression. This is arithmetic expression that should return
  9954. integer value 0xRRGGBB. The expression can contain variables:
  9955. @table @option
  9956. @item frequency, freq, f
  9957. the frequency where transform is evaluated
  9958. @item timeclamp, tc
  9959. value of timeclamp option
  9960. @end table
  9961. and functions:
  9962. @table @option
  9963. @item midi(f)
  9964. midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
  9965. @item r(x), g(x), b(x)
  9966. red, green, and blue value of intensity x
  9967. @end table
  9968. Default value is @code{st(0, (midi(f)-59.5)/12);
  9969. st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
  9970. r(1-ld(1)) + b(ld(1))}
  9971. @item fullhd
  9972. If set to 1 (the default), the video size is 1920x1080 (full HD),
  9973. if set to 0, the video size is 960x540. Use this option to make CPU usage lower.
  9974. @item fps
  9975. Specify video fps. Default value is @code{25}.
  9976. @item count
  9977. Specify number of transform per frame, so there are fps*count transforms
  9978. per second. Note that audio data rate must be divisible by fps*count.
  9979. Default value is @code{6}.
  9980. @end table
  9981. @subsection Examples
  9982. @itemize
  9983. @item
  9984. Playing audio while showing the spectrum:
  9985. @example
  9986. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt [out0]'
  9987. @end example
  9988. @item
  9989. Same as above, but with frame rate 30 fps:
  9990. @example
  9991. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out0]'
  9992. @end example
  9993. @item
  9994. Playing at 960x540 and lower CPU usage:
  9995. @example
  9996. ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fullhd=0:count=3 [out0]'
  9997. @end example
  9998. @item
  9999. A1 and its harmonics: A1, A2, (near)E3, A3:
  10000. @example
  10001. 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),
  10002. asplit[a][out1]; [a] showcqt [out0]'
  10003. @end example
  10004. @item
  10005. Same as above, but with more accuracy in frequency domain (and slower):
  10006. @example
  10007. 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),
  10008. asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]'
  10009. @end example
  10010. @item
  10011. B-weighting of equal loudness
  10012. @example
  10013. volume=16*b_weighting(f)
  10014. @end example
  10015. @item
  10016. Lower Q factor
  10017. @example
  10018. tlength=100/f*tc/(100/f+tc)
  10019. @end example
  10020. @item
  10021. Custom fontcolor, C-note is colored green, others are colored blue
  10022. @example
  10023. fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))'
  10024. @end example
  10025. @item
  10026. Custom gamma, now spectrum is linear to the amplitude.
  10027. @example
  10028. gamma=2:gamma2=2
  10029. @end example
  10030. @end itemize
  10031. @section showfreqs
  10032. Convert input audio to video output representing the audio power spectrum.
  10033. Audio amplitude is on Y-axis while frequency is on X-axis.
  10034. The filter accepts the following options:
  10035. @table @option
  10036. @item size, s
  10037. Specify size of video. For the syntax of this option, check the
  10038. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10039. Default is @code{1024x512}.
  10040. @item mode
  10041. Set display mode.
  10042. This set how each frequency bin will be represented.
  10043. It accepts the following values:
  10044. @table @samp
  10045. @item line
  10046. @item bar
  10047. @item dot
  10048. @end table
  10049. Default is @code{bar}.
  10050. @item ascale
  10051. Set amplitude scale.
  10052. It accepts the following values:
  10053. @table @samp
  10054. @item lin
  10055. Linear scale.
  10056. @item sqrt
  10057. Square root scale.
  10058. @item cbrt
  10059. Cubic root scale.
  10060. @item log
  10061. Logarithmic scale.
  10062. @end table
  10063. Default is @code{log}.
  10064. @item fscale
  10065. Set frequency scale.
  10066. It accepts the following values:
  10067. @table @samp
  10068. @item lin
  10069. Linear scale.
  10070. @item log
  10071. Logarithmic scale.
  10072. @item rlog
  10073. Reverse logarithmic scale.
  10074. @end table
  10075. Default is @code{lin}.
  10076. @item win_size
  10077. Set window size.
  10078. It accepts the following values:
  10079. @table @samp
  10080. @item w16
  10081. @item w32
  10082. @item w64
  10083. @item w128
  10084. @item w256
  10085. @item w512
  10086. @item w1024
  10087. @item w2048
  10088. @item w4096
  10089. @item w8192
  10090. @item w16384
  10091. @item w32768
  10092. @item w65536
  10093. @end table
  10094. Default is @code{w2048}
  10095. @item win_func
  10096. Set windowing function.
  10097. It accepts the following values:
  10098. @table @samp
  10099. @item rect
  10100. @item bartlett
  10101. @item hanning
  10102. @item hamming
  10103. @item blackman
  10104. @item welch
  10105. @item flattop
  10106. @item bharris
  10107. @item bnuttall
  10108. @item bhann
  10109. @item sine
  10110. @item nuttall
  10111. @item lanczos
  10112. @item gauss
  10113. @end table
  10114. Default is @code{hanning}.
  10115. @item overlap
  10116. Set window overlap. In range @code{[0, 1]}. Default is @code{1},
  10117. which means optimal overlap for selected window function will be picked.
  10118. @item averaging
  10119. Set time averaging. Setting this to 0 will display current maximal peaks.
  10120. Default is @code{1}, which means time averaging is disabled.
  10121. @item color
  10122. Specify list of colors separated by space or by '|' which will be used to
  10123. draw channel frequencies. Unrecognized or missing colors will be replaced
  10124. by white color.
  10125. @end table
  10126. @section showspectrum
  10127. Convert input audio to a video output, representing the audio frequency
  10128. spectrum.
  10129. The filter accepts the following options:
  10130. @table @option
  10131. @item size, s
  10132. Specify the video size for the output. For the syntax of this option, check the
  10133. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10134. Default value is @code{640x512}.
  10135. @item slide
  10136. Specify how the spectrum should slide along the window.
  10137. It accepts the following values:
  10138. @table @samp
  10139. @item replace
  10140. the samples start again on the left when they reach the right
  10141. @item scroll
  10142. the samples scroll from right to left
  10143. @item fullframe
  10144. frames are only produced when the samples reach the right
  10145. @end table
  10146. Default value is @code{replace}.
  10147. @item mode
  10148. Specify display mode.
  10149. It accepts the following values:
  10150. @table @samp
  10151. @item combined
  10152. all channels are displayed in the same row
  10153. @item separate
  10154. all channels are displayed in separate rows
  10155. @end table
  10156. Default value is @samp{combined}.
  10157. @item color
  10158. Specify display color mode.
  10159. It accepts the following values:
  10160. @table @samp
  10161. @item channel
  10162. each channel is displayed in a separate color
  10163. @item intensity
  10164. each channel is is displayed using the same color scheme
  10165. @end table
  10166. Default value is @samp{channel}.
  10167. @item scale
  10168. Specify scale used for calculating intensity color values.
  10169. It accepts the following values:
  10170. @table @samp
  10171. @item lin
  10172. linear
  10173. @item sqrt
  10174. square root, default
  10175. @item cbrt
  10176. cubic root
  10177. @item log
  10178. logarithmic
  10179. @end table
  10180. Default value is @samp{sqrt}.
  10181. @item saturation
  10182. Set saturation modifier for displayed colors. Negative values provide
  10183. alternative color scheme. @code{0} is no saturation at all.
  10184. Saturation must be in [-10.0, 10.0] range.
  10185. Default value is @code{1}.
  10186. @item win_func
  10187. Set window function.
  10188. It accepts the following values:
  10189. @table @samp
  10190. @item none
  10191. No samples pre-processing (do not expect this to be faster)
  10192. @item hann
  10193. Hann window
  10194. @item hamming
  10195. Hamming window
  10196. @item blackman
  10197. Blackman window
  10198. @end table
  10199. Default value is @code{hann}.
  10200. @end table
  10201. The usage is very similar to the showwaves filter; see the examples in that
  10202. section.
  10203. @subsection Examples
  10204. @itemize
  10205. @item
  10206. Large window with logarithmic color scaling:
  10207. @example
  10208. showspectrum=s=1280x480:scale=log
  10209. @end example
  10210. @item
  10211. Complete example for a colored and sliding spectrum per channel using @command{ffplay}:
  10212. @example
  10213. ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1];
  10214. [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out0]'
  10215. @end example
  10216. @end itemize
  10217. @section showvolume
  10218. Convert input audio volume to a video output.
  10219. The filter accepts the following options:
  10220. @table @option
  10221. @item rate, r
  10222. Set video rate.
  10223. @item b
  10224. Set border width, allowed range is [0, 5]. Default is 1.
  10225. @item w
  10226. Set channel width, allowed range is [40, 1080]. Default is 400.
  10227. @item h
  10228. Set channel height, allowed range is [1, 100]. Default is 20.
  10229. @item f
  10230. Set fade, allowed range is [1, 255]. Default is 20.
  10231. @item c
  10232. Set volume color expression.
  10233. The expression can use the following variables:
  10234. @table @option
  10235. @item VOLUME
  10236. Current max volume of channel in dB.
  10237. @item CHANNEL
  10238. Current channel number, starting from 0.
  10239. @end table
  10240. @item t
  10241. If set, displays channel names. Default is enabled.
  10242. @end table
  10243. @section showwaves
  10244. Convert input audio to a video output, representing the samples waves.
  10245. The filter accepts the following options:
  10246. @table @option
  10247. @item size, s
  10248. Specify the video size for the output. For the syntax of this option, check the
  10249. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10250. Default value is @code{600x240}.
  10251. @item mode
  10252. Set display mode.
  10253. Available values are:
  10254. @table @samp
  10255. @item point
  10256. Draw a point for each sample.
  10257. @item line
  10258. Draw a vertical line for each sample.
  10259. @item p2p
  10260. Draw a point for each sample and a line between them.
  10261. @item cline
  10262. Draw a centered vertical line for each sample.
  10263. @end table
  10264. Default value is @code{point}.
  10265. @item n
  10266. Set the number of samples which are printed on the same column. A
  10267. larger value will decrease the frame rate. Must be a positive
  10268. integer. This option can be set only if the value for @var{rate}
  10269. is not explicitly specified.
  10270. @item rate, r
  10271. Set the (approximate) output frame rate. This is done by setting the
  10272. option @var{n}. Default value is "25".
  10273. @item split_channels
  10274. Set if channels should be drawn separately or overlap. Default value is 0.
  10275. @end table
  10276. @subsection Examples
  10277. @itemize
  10278. @item
  10279. Output the input file audio and the corresponding video representation
  10280. at the same time:
  10281. @example
  10282. amovie=a.mp3,asplit[out0],showwaves[out1]
  10283. @end example
  10284. @item
  10285. Create a synthetic signal and show it with showwaves, forcing a
  10286. frame rate of 30 frames per second:
  10287. @example
  10288. aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t):cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]
  10289. @end example
  10290. @end itemize
  10291. @section showwavespic
  10292. Convert input audio to a single video frame, representing the samples waves.
  10293. The filter accepts the following options:
  10294. @table @option
  10295. @item size, s
  10296. Specify the video size for the output. For the syntax of this option, check the
  10297. @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
  10298. Default value is @code{600x240}.
  10299. @item split_channels
  10300. Set if channels should be drawn separately or overlap. Default value is 0.
  10301. @end table
  10302. @subsection Examples
  10303. @itemize
  10304. @item
  10305. Extract a channel split representation of the wave form of a whole audio track
  10306. in a 1024x800 picture using @command{ffmpeg}:
  10307. @example
  10308. ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png
  10309. @end example
  10310. @end itemize
  10311. @section split, asplit
  10312. Split input into several identical outputs.
  10313. @code{asplit} works with audio input, @code{split} with video.
  10314. The filter accepts a single parameter which specifies the number of outputs. If
  10315. unspecified, it defaults to 2.
  10316. @subsection Examples
  10317. @itemize
  10318. @item
  10319. Create two separate outputs from the same input:
  10320. @example
  10321. [in] split [out0][out1]
  10322. @end example
  10323. @item
  10324. To create 3 or more outputs, you need to specify the number of
  10325. outputs, like in:
  10326. @example
  10327. [in] asplit=3 [out0][out1][out2]
  10328. @end example
  10329. @item
  10330. Create two separate outputs from the same input, one cropped and
  10331. one padded:
  10332. @example
  10333. [in] split [splitout1][splitout2];
  10334. [splitout1] crop=100:100:0:0 [cropout];
  10335. [splitout2] pad=200:200:100:100 [padout];
  10336. @end example
  10337. @item
  10338. Create 5 copies of the input audio with @command{ffmpeg}:
  10339. @example
  10340. ffmpeg -i INPUT -filter_complex asplit=5 OUTPUT
  10341. @end example
  10342. @end itemize
  10343. @section zmq, azmq
  10344. Receive commands sent through a libzmq client, and forward them to
  10345. filters in the filtergraph.
  10346. @code{zmq} and @code{azmq} work as a pass-through filters. @code{zmq}
  10347. must be inserted between two video filters, @code{azmq} between two
  10348. audio filters.
  10349. To enable these filters you need to install the libzmq library and
  10350. headers and configure FFmpeg with @code{--enable-libzmq}.
  10351. For more information about libzmq see:
  10352. @url{http://www.zeromq.org/}
  10353. The @code{zmq} and @code{azmq} filters work as a libzmq server, which
  10354. receives messages sent through a network interface defined by the
  10355. @option{bind_address} option.
  10356. The received message must be in the form:
  10357. @example
  10358. @var{TARGET} @var{COMMAND} [@var{ARG}]
  10359. @end example
  10360. @var{TARGET} specifies the target of the command, usually the name of
  10361. the filter class or a specific filter instance name.
  10362. @var{COMMAND} specifies the name of the command for the target filter.
  10363. @var{ARG} is optional and specifies the optional argument list for the
  10364. given @var{COMMAND}.
  10365. Upon reception, the message is processed and the corresponding command
  10366. is injected into the filtergraph. Depending on the result, the filter
  10367. will send a reply to the client, adopting the format:
  10368. @example
  10369. @var{ERROR_CODE} @var{ERROR_REASON}
  10370. @var{MESSAGE}
  10371. @end example
  10372. @var{MESSAGE} is optional.
  10373. @subsection Examples
  10374. Look at @file{tools/zmqsend} for an example of a zmq client which can
  10375. be used to send commands processed by these filters.
  10376. Consider the following filtergraph generated by @command{ffplay}
  10377. @example
  10378. ffplay -dumpgraph 1 -f lavfi "
  10379. color=s=100x100:c=red [l];
  10380. color=s=100x100:c=blue [r];
  10381. nullsrc=s=200x100, zmq [bg];
  10382. [bg][l] overlay [bg+l];
  10383. [bg+l][r] overlay=x=100 "
  10384. @end example
  10385. To change the color of the left side of the video, the following
  10386. command can be used:
  10387. @example
  10388. echo Parsed_color_0 c yellow | tools/zmqsend
  10389. @end example
  10390. To change the right side:
  10391. @example
  10392. echo Parsed_color_1 c pink | tools/zmqsend
  10393. @end example
  10394. @c man end MULTIMEDIA FILTERS
  10395. @chapter Multimedia Sources
  10396. @c man begin MULTIMEDIA SOURCES
  10397. Below is a description of the currently available multimedia sources.
  10398. @section amovie
  10399. This is the same as @ref{movie} source, except it selects an audio
  10400. stream by default.
  10401. @anchor{movie}
  10402. @section movie
  10403. Read audio and/or video stream(s) from a movie container.
  10404. It accepts the following parameters:
  10405. @table @option
  10406. @item filename
  10407. The name of the resource to read (not necessarily a file; it can also be a
  10408. device or a stream accessed through some protocol).
  10409. @item format_name, f
  10410. Specifies the format assumed for the movie to read, and can be either
  10411. the name of a container or an input device. If not specified, the
  10412. format is guessed from @var{movie_name} or by probing.
  10413. @item seek_point, sp
  10414. Specifies the seek point in seconds. The frames will be output
  10415. starting from this seek point. The parameter is evaluated with
  10416. @code{av_strtod}, so the numerical value may be suffixed by an IS
  10417. postfix. The default value is "0".
  10418. @item streams, s
  10419. Specifies the streams to read. Several streams can be specified,
  10420. separated by "+". The source will then have as many outputs, in the
  10421. same order. The syntax is explained in the ``Stream specifiers''
  10422. section in the ffmpeg manual. Two special names, "dv" and "da" specify
  10423. respectively the default (best suited) video and audio stream. Default
  10424. is "dv", or "da" if the filter is called as "amovie".
  10425. @item stream_index, si
  10426. Specifies the index of the video stream to read. If the value is -1,
  10427. the most suitable video stream will be automatically selected. The default
  10428. value is "-1". Deprecated. If the filter is called "amovie", it will select
  10429. audio instead of video.
  10430. @item loop
  10431. Specifies how many times to read the stream in sequence.
  10432. If the value is less than 1, the stream will be read again and again.
  10433. Default value is "1".
  10434. Note that when the movie is looped the source timestamps are not
  10435. changed, so it will generate non monotonically increasing timestamps.
  10436. @end table
  10437. It allows overlaying a second video on top of the main input of
  10438. a filtergraph, as shown in this graph:
  10439. @example
  10440. input -----------> deltapts0 --> overlay --> output
  10441. ^
  10442. |
  10443. movie --> scale--> deltapts1 -------+
  10444. @end example
  10445. @subsection Examples
  10446. @itemize
  10447. @item
  10448. Skip 3.2 seconds from the start of the AVI file in.avi, and overlay it
  10449. on top of the input labelled "in":
  10450. @example
  10451. movie=in.avi:seek_point=3.2, scale=180:-1, setpts=PTS-STARTPTS [over];
  10452. [in] setpts=PTS-STARTPTS [main];
  10453. [main][over] overlay=16:16 [out]
  10454. @end example
  10455. @item
  10456. Read from a video4linux2 device, and overlay it on top of the input
  10457. labelled "in":
  10458. @example
  10459. movie=/dev/video0:f=video4linux2, scale=180:-1, setpts=PTS-STARTPTS [over];
  10460. [in] setpts=PTS-STARTPTS [main];
  10461. [main][over] overlay=16:16 [out]
  10462. @end example
  10463. @item
  10464. Read the first video stream and the audio stream with id 0x81 from
  10465. dvd.vob; the video is connected to the pad named "video" and the audio is
  10466. connected to the pad named "audio":
  10467. @example
  10468. movie=dvd.vob:s=v:0+#0x81 [video] [audio]
  10469. @end example
  10470. @end itemize
  10471. @c man end MULTIMEDIA SOURCES